Project import
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..14c3026 --- /dev/null +++ b/Makefile
@@ -0,0 +1,114 @@ +# +# Copyright (c) 2010-2011 Nest, Inc. +# All rights reserved. +# +# This document is the property of Nest. It is considered +# confidential and proprietary information. +# +# This document may not be reproduced or transmitted in any form, +# in whole or in part, without the express written permission of +# Nest. +# +# Description: +# This file is the makefile for the network traffic dump utility +# (tcpdump). +# + +BuildConfigSpecialized := No +BuildProductSpecialized := No + +include pre.mak + +PackageName := tcpdump + +PackageExtension := tar.gz +PackageSeparator := - + +PackagePatchArgs := -p1 + +PackageArchive := $(PackageName).$(PackageExtension) +PackageSourceDir := $(PackageName)$(PackageSeparator)$(PackageVersion) + +PackageBuildMakefile = $(call GenerateBuildPaths,Makefile) + +CleanPaths += $(PackageLicenseFile) + +LibPcapDir := sw/tps/libpcap +LibPcapIncDir = $(call GenerateResultPaths,$(LibPcapDir),usr/include) +LibPcapLibDir = $(call GenerateResultPaths,$(LibPcapDir),usr/lib) + +OpenSSLDir := sw/tps/openssl +OpenSSLSearchPath = $(call GenerateResultPaths,$(OpenSSLDir),usr) + +all: $(PackageDefaultGoal) + +# Generate the package license contents. + +$(PackageSourceDir)/LICENSE: source + +$(PackageLicenseFile): $(PackageSourceDir)/LICENSE + $(copy-result) + +# Extract the source from the archive and apply patches, if any. + +$(PackageSourceDir): $(PackageArchive) $(PackagePatchPaths) + $(expand-and-patch-package) + +# Prepare the sources. + +.PHONY: source +source: | $(PackageSourceDir) + +# Patch the sources, if necessary. + +.PHONY: patch +patch: source + +# Generate the package build makefile. + +$(PackageBuildMakefile): | $(PackageSourceDir) $(BuildDirectory) + $(Verbose)cd $(BuildDirectory) && \ + $(CURDIR)/$(PackageSourceDir)/configure \ + CC="$(CC)" AR=$(AR) RANLIB=$(RANLIB) STRIP=$(STRIP) \ + INSTALL="$(INSTALL) $(INSTALLFLAGS)" \ + CPPFLAGS=-I$(LibPcapIncDir) \ + LDFLAGS=-L$(LibPcapLibDir) \ + ac_cv_linux_vers=2 \ + td_cv_buggygetaddrinfo=no \ + --build=$(HostTuple) \ + --host=$(TargetTuple) \ + --enable-ipv6 \ + --with-crypto=$(OpenSSLSearchPath) \ + --prefix=/usr \ + --sysconfdir=/etc \ + --localstatedir=/var + +# Configure the source for building. + +.PHONY: configure +configure: source $(PackageBuildMakefile) + +# Build the source. +# +# We have to unset MAKEFLAGS since they confuse the package build otherwise. + +.PHONY: build +build: configure + $(Verbose)unset MAKEFLAGS && \ + $(MAKE) $(JOBSFLAG) -C $(BuildDirectory) all + +# Stage the build to a temporary installation area. +# +# We have to unset MAKEFLAGS since they confuse the package build otherwise. + +.PHONY: stage +stage: build | $(ResultDirectory) + $(Verbose)unset MAKEFLAGS && \ + $(MAKE) $(JOBSFLAG) -C $(BuildDirectory) DESTDIR=$(ResultDirectory) install + +clean: + $(Verbose)$(RM) $(RMFLAGS) -r $(PackageSourceDir) + $(Verbose)$(RM) $(RMFLAGS) -r $(BuildDirectory) + $(Verbose)$(RM) $(RMFLAGS) -r $(ResultDirectory) + +include post.mak
diff --git a/tcpdump-4.3.0/CHANGES b/tcpdump-4.3.0/CHANGES new file mode 100644 index 0000000..0031431 --- /dev/null +++ b/tcpdump-4.3.0/CHANGES
@@ -0,0 +1,1012 @@ +Friday April 3, 2011. mcr@sandelman.ca. + Summary for 4.3.0 tcpdump release + fixes for forces: SPARSE data (per RFC 5810) + some more test cases added + updates to documentation on -l, -U and -w flags. + Fix printing of BGP optional headers. + Tried to include DLT_PFSYNC support, failed due to headers required. + added TIPC support. + Fix LLDP Network Policy bit definitions. + fixes for IGMPv3's Max Response Time: it is in units of 0.1 second. + SIGUSR1 can be used rather than SIGINFO for stats + permit -n flag to affect print-ip for protocol numbers + ND_OPT_ADVINTERVAL is in milliseconds, not seconds + Teach PPPoE parser about RFC 4638 + + +Friday December 9, 2011. guy@alum.mit.edu. + Summary for 4.2.1 tcpdump release + Only build the Babel printer if IPv6 is enabled. + Support Babel on port 6696 as well as 6697. + Include ppi.h in release tarball. + Include all the test files in the release tarball, and don't + "include" test files that no longer exist. + Don't assume we have <rpc/rpc.h> - check for it. + Support "-T carp" as a way of dissecting IP protocol 112 as CARP + rather than VRRP. + Support Hilscher NetAnalyzer link-layer header format. + Constify some pointers and fix compiler warnings. + Get rid of never-true test. + Fix an unintended fall-through in a case statement in the ARP + printer. + Fix several cases where sizeof(sizeof(XXX)) was used when just + sizeof(XXX) was intended. + Make stricter sanity checks in the ES-IS printer. + Get rid of some GCCisms that caused builds to fai with compilers + that don't support them. + Fix typo in man page. + Added length checks to Babel printer. + +Sunday July 24, 2011. mcr@sandelman.ca. + Summary for 4.2.+ + merged 802.15.4 decoder from Dmitry Eremin-Solenikov <dbaryshkov + at gmail dot com> + updates to forces for new port numbers + Use "-H", not "-h", for the 802.11s option. (-h always help) + Better ICMPv6 checksum handling. + add support for the RPKI/Router Protocol, per -ietf-sidr-rpki-rtr-12 + get rid of uuencoded pcap test files, git can do binary. + sFlow changes for 64-bit counters. + fixes for PPI packet header handling and printing. + Add DCB Exchange protocol (DCBX) version 1.01. + Babel dissector, from Juliusz Chroboczek and Grégoire Henry. + improvements to radiotap for rate values > 127. + Many improvements to ForCES decode, including fix SCTP TML port + updated RPL type code to RPL-17 draft + Improve printout of DHCPv6 options. + added support and test case for QinQ (802.1q VLAN) packets + Handle DLT_IEEE802_15_4_NOFCS like DLT_IEEE802_15_4. + Build fixes for Sparc and other machines with alignment restrictions. + Merged changes from Debian package. + PGM: Add ACK decoding and add PGMCC DATA and FEEDBACK options. + Build fixes for OSX (Snow Leopard and others) + Add support for IEEE 802.15.4 packets + +Tue. July 20, 2010. guy@alum.mit.edu. + Summary for 4.1.2 tcpdump release + If -U is specified, flush the file after creating it, so it's + not zero-length + Fix TCP flags output description, and some typoes, in the man + page + Add a -h flag, and only attempt to recognize 802.11s mesh + headers if it's set + When printing the link-layer type list, send *all* output to + stderr + Include the CFLAGS setting when configure was run in the + compiler flags + +Thu. April 1, 2010. guy@alum.mit.edu. + Summary for 4.1.1 tcpdump release + Fix build on systems with PF, such as FreeBSD and OpenBSD. + Don't blow up if a zero-length link-layer address is passed to + linkaddr_string(). + +Thu. March 11, 2010. ken@netfunctional.ca/guy@alum.mit.edu. + Summary for 4.1.0 tcpdump release + Fix printing of MAC addresses for VLAN frames with a length + field + Add some additional bounds checks and use the EXTRACT_ macros + more + Add a -b flag to print the AS number in BGP packets in ASDOT + notation rather than ASPLAIN notation + Add ICMPv6 RFC 5006 support + Decode the access flags in NFS access requests + Handle the new DLT_ for memory-mapped USB captures on Linux + Make the default snapshot (-s) the maximum + Print name of device (when -L is used) + Support for OpenSolaris (and SXCE build 125 and later) + Print new TCP flags + Add support for RPL DIO + Add support for TCP User Timeout (UTO) + Add support for non-standard Ethertypes used by 3com PPPoE gear + Add support for 802.11n and 802.11s + Add support for Transparent Ethernet Bridge ethertype in GRE + Add 4 byte AS support for BGP printer + Add support for the MDT SAFI 66 BG printer + Add basic IPv6 support to print-olsr + Add USB printer + Add printer for ForCES + Handle frames with an FCS + Handle 802.11n Control Wrapper, Block Acq Req and Block Ack frames + Fix TCP sequence number printing + Report 802.2 packets as 802.2 instead of 802.3 + Don't include -L/usr/lib in LDFLAGS + On x86_64 Linux, look in lib64 directory too + Lots of code clean ups + Autoconf clean ups + Update testcases to make output changes + Fix compiling with/out smi (--with{,out}-smi) + Fix compiling without IPv6 support (--disable-ipv6) + +Mon. October 27, 2008. ken@netfunctional.ca. Summary for 4.0.0 tcpdump release + Add support for Bluetooth Sniffing + Add support for Realtek Remote Control Protocol (openrrcp.org.ru) + Add support for 802.11 AVS + Add support for SMB over TCP + Add support for 4 byte BGP AS printing + Add support for compiling on case-insensitive file systems + Add support for ikev2 printing + Update support for decoding AFS + Update DHCPv6 printer + Use newer libpcap API's (allows -B option on all platforms) + Add -I to turn on monitor mode + Bugfixes in lldp, lspping, dccp, ESP, NFS printers + Cleanup unused files and various cruft + +Mon. September 10, 2007. ken@xelerance.com. Summary for 3.9.8 tcpdump release + Rework ARP printer + Rework OSPFv3 printer + Add support for Frame-Relay ARP + Decode DHCP Option 121 (RFC 3442 Classless Static Route) + Decode DHCP Option 249 (MS Classless Static Route) the same as Option 121 + TLV: Add support for Juniper .pcap extensions + Print EGP header in new-world-order style + Converted print-isakmp.c to NETDISSECT + Moved AF specific stuff into af.h + Test subsystem now table driven, and saves outputs and diffs to one place + Require <net/pfvar.h> for pf definitions - allows reading of pflog formatted + libpcap files on an OS other than where the file was generated + + +Wed. July 23, 2007. mcr@xelerance.com. Summary for 3.9.7 libpcap release + + NFS: Print unsigned values as such. + RX: parse safely. + BGP: fixes for IPv6-less builds. + 801.1ag: use standard codepoint. + use /dev/bpf on systems with such a device. + 802.11: print QoS data, avoid dissect of no-data frame, ignore padding. + smb: make sure that we haven't gone past the end of the captured data. + smb: squelch an uninitialized complaint from coverity. + NFS: from NetBSD; don't interpret the reply as a possible NFS reply + if it got MSG_DENIED. + BGP: don't print TLV values that didn't fit, from www.digit-labs.org. + revised INSTALL.txt about libpcap dependancy. + +Wed. April 25, 2007. ken@xelerance.com. Summary for 3.9.6 tcpdump release + Update man page to reflect changes to libpcap + Changes to both TCP and IP Printer Output + Fix a potential buffer overflow in the 802.11 printer + Print basic info about a few more Cisco LAN protocols. + mDNS cleanup + ICMP MPLS rework of the extension code + bugfix: use the correct codepoint for the OSPF simple text auth token + entry, and use safeputs to print the password. + Add support in pflog for additional values + Add support for OIF RSVP Extensions UNI 1.0 Rev. 2 and additional RSVP objects + Add support for the Message-id NACK c-type. + Add support for 802.3ah loopback ctrl msg + Add support for Multiple-STP as per 802.1s + Add support for rapid-SPT as per 802.1w + Add support for CFM Link-trace msg, Link-trace-Reply msg, + Sender-ID tlv, private tlv, port, interface status + Add support for unidirectional link detection as per + http://www.ietf.org/internet-drafts/draft-foschiano-udld-02.txt + Add support for the olsr protocol as per RFC 3626 plus the LQ + extensions from olsr.org + Add support for variable-length checksum in DCCP, as per section 9 of + RFC 4340. + Add support for per-VLAN spanning tree and per-VLAN rapid spanning tree + Add support for Multiple-STP as per 802.1s + Add support for the cisco propriatry 'dynamic trunking protocol' + Add support for the cisco proprietary VTP protocol + Update dhcp6 options table as per IETF standardization activities + + +Tue. September 19, 2006. ken@xelerance.com. Summary for 3.9.5 tcpdump release + + Fix compiling on AIX (, at end of ENUM) + Updated list of DNS RR typecodes + Use local Ethernet defs on WIN32 + Add support for Frame-Relay ARP + Fixes for compiling under MSVC++ + Add support for parsing Juniper .pcap files + Add support for FRF.16 Multilink Frame-Relay (DLT_MFR) + Rework the OSPFv3 printer + Fix printing for 4.4BSD/NetBSD NFS Filehandles + Add support for Cisco style NLPID encapsulation + Add cisco prop. eigrp related, extended communities + Add support for BGP signaled VPLS + Cleanup the bootp printer + Add support for PPP over Frame-Relay + Add some bounds checking to the IP options code, and clean up + the options output a bit. + Add additional modp groups to ISAKMP printer + Add support for Address-Withdraw and Label-Withdraw Msgs + Add support for the BFD Discriminator TLV + Fixes for 64bit compiling + Add support for PIMv2 checksum verification + Add support for further dissection of the IPCP Compression Option + Add support for Cisco's proposed VQP protocol + Add basic support for keyed authentication TCP option + Lots of minor cosmetic changes to output printers + + +Mon. September 19, 2005. ken@xelerance.com. Summary for 3.9.4 tcpdump release + Decoder support for more Juniper link-layer types + Fix a potential buffer overflow (although it can't occur in + practice). + Fix the handling of unknown management frame types in the 802.11 + printer. + Add FRF.16 support, fix various Frame Relay bugs. + Add support for RSVP integrity objects, update fast-reroute + object printer to latest spec. + Clean up documentation of vlan filter expression, document mpls + filter expression. + Document new pppoed and pppoes filter expressions. + Update diffserver-TE codepoints as per RFC 4124. + Spelling fixes in ICMPv6. + Don't require any fields other than flags to be present in IS-IS + restart signaling TLVs, and only print the system ID in + those TLVs as system IDs, not as node IDs. + Support for DCCP. + +Tue. July 5, 2005. ken@xelerance.com. Summary for 3.9.3 tcpdump release + + Option to chroot() when dropping privs + Fixes for compiling on nearly every platform, + including improved 64bit support + Many new testcases + Support for sending packets + Many compliation fixes on most platforms + Fixes for recent version of GCC to eliminate warnings + Improved Unicode support + + Decoders & DLT Changes, Updates and New: + AES ESP support + Juniper ATM, FRF.15, FRF.16, PPPoE, + ML-FR, ML-PIC, ML-PPP, PL-PPP, LS-PIC + GGSN,ES,MONITOR,SERVICES + L2VPN + Axent Raptor/Symantec Firewall + TCP-MD5 (RFC 2385) + ESP-in-UDP (RFC 3948) + ATM OAM + LMP, LMP Service Discovery + IP over FC + IP over IEEE 1394 + BACnet MS/TP + SS7 + LDP over TCP + LACP, MARKER as per 802.3ad + PGM (RFC 3208) + LSP-PING + G.7041/Y.1303 Generic Framing Procedure + EIGRP-IP, EIGRP-IPX + ICMP6 + Radio - via radiotap + DHCPv6 + HDLC over PPP + +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 + + Fixed infinite loop when parsing malformed isakmp packets. + (reported by iDefense; already fixed in CVS) + Fixed infinite loop when parsing malformed BGP packets. + Fixed buffer overflow with certain malformed NFS packets. + Pretty-print unprintable network names in 802.11 printer. + Handle truncated nbp (appletalk) packets. + Updated DHCPv6 printer to match draft-ietf-dhc-dhcpv6-22.txt + Print IP protocol name even if we don't have a printer for it. + Print IP protocol name or number for fragments. + Print the whole MPLS label stack, not just the top label. + Print request header and file handle for NFS v3 FSINFO and PATHCONF + requests. + Fix NFS packet truncation checks. + Handle "old" DR-Priority and Bidir-Capable PIM HELLO options. + Handle unknown RADIUS attributes properly. + Fix an ASN.1 parsing error that would cause e.g. the OID + 2.100.3 to be misrepresented as 4.20.3 . + +Monday, January 21, 2002. mcr@sandelman.ottawa.on.ca. Summary for 3.7 release +see http://www.tcpdump.org/cvs-log/2002-01-21.10:16:48.html for commit log. + keyword "ipx" added. + Better OSI/802.2 support on Linux. + IEEE 802.11 support, from clenahan@fortresstech.com, achirica@ttd.net. + LLC SAP support for FDDI/token ring/RFC-1483 style ATM + BXXP protocol was replaced by the BEEP protocol; + improvements to SNAP demux. + Changes to "any" interface documentation. + Documentation on pcap_stats() counters. + Fix a memory leak found by Miklos Szeredi - pcap_ether_aton(). + Added MPLS encapsulation decoding per RFC3032. + DNS dissector handles TKEY, TSIG and IXFR. + adaptive SLIP interface patch from Igor Khristophorov <igor@atdot.org> + SMB printing has much improved bounds checks + OUI 0x0000f8 decoded as encapsulated ethernet for Cisco-custom bridging + Zephyr support, from Nickolai Zeldovich <kolya@MIT.EDU>. + Solaris - devices with digits in them. Stefan Hudson <hudson@mbay.net> + IPX socket 0x85be is for Cisco EIGRP over IPX. + Improvements to fragmented ESP handling. + SCTP support from Armando L. Caro Jr. <acaro@mail.eecis.udel.edu> + Linux ARPHDR_ATM support fixed. + Added a "netbeui" keyword, which selects NetBEUI packets. + IPv6 ND improvements, MobileIP dissector, 2292bis-02 for RA option. + Handle ARPHDR_HDLC from Marcus Felipe Pereira <marcus@task.com.br>. + Handle IPX socket 0x553 -> NetBIOS-over-IPX socket, "nwlink-dgm" + Better Linux libc5 compat. + BIND9 lwres dissector added. + MIPS and SPARC get strict alignment macros (affects print-bgp.c) + Apple LocalTalk LINKTYPE_ reserved. + New time stamp formats documented. + DHCP6 updated to draft-22.txt spec. + ICMP types/codes now accept symbolic names. + Add SIGINFO handler from LBL + encrypted CIPE tunnels in IRIX, from Franz Schaefer <schaefer@mond.at>. + now we are -Wstrict-prototype clean. + NetBSD DLT_PPP_ETHER; adapted from Martin Husemann <martin@netbsd.org>. + PPPoE dissector cleaned up. + Support for LocalTalk hardware, from Uns Lider <unslider@miranda.org>. + In dissector, now the caller prints the IP addresses rather than proto. + cjclark@alum.mit.edu: print the IP proto for non-initial fragments. + LLC frames with a DSAP and LSAP of 0xe0 are IPX frames. + Linux cooked frames with a type value of LINUX_SLL_P_802_3 are IPX. + captures on the "any" device won't be done in promiscuous mode + Token Ring support on DLPI - Onno van der Linden <onno@simplex.nl> + ARCNet support, from NetBSD. + HSRP dissector, from Julian Cowley <julian@lava.net>. + Handle (GRE-encapsulated) PPTP + added -C option to rotate save file every optarg * 1,000,000 bytes. + support for "vrrp" name - NetBSD, by Klaus Klein <kleink@netbsd.org>. + PPTP support, from Motonori Shindo <mshindo@mshindo.net>. + IS-IS over PPP support, from Hannes Gredler <hannes@juniper.net>. + CNFP support for IPv6,format. Harry Raaymakers <harryr@connect.com.au>. + ESP printing updated to RFC2406. + HP-UX can now handle large number of PPAs. + MSDP printer added. + L2TP dissector improvements from Motonori Shindo. + +Tuesday January 9, 2001. mcr@sandelman.ottawa.on.ca. Summary for 3.6 release + Cleaned up documentation. + Promisc mode fixes for Linux + IPsec changes/cleanups. + Alignment fixes for picky architectures + + Removed dependency on native headers for packet dissectors. + Removed Linux specific headers that were shipped + + libpcap changes provide for exchanging capture files between + systems. Save files now have well known PACKET_ values instead of + depending upon system dependant mappings of DLT_* types. + + Support for computing/checking IP and UDP/TCP checksums. + + Updated autoconf stock files. + + IPv6 improvements: dhcp (draft-15), mobile-ip6, ppp, ospf6, + + Added dissector support for: ISOCLNS, Token Ring, IGMPv3, bxxp, + timed, vrrp, radius, chdlc, cnfp, cdp, IEEE802.1d, raw-AppleTalk + + Added filtering support for: VLANs, ESIS, ISIS + + Improvements to: print-telnet, IPTalk, bootp/dhcp, ECN, PPP, + L2TP, PPPoE + + HP-UX 11.0 -- find the right dlpi device. + Solaris 8 - IPv6 works + Linux - Added support for an "any" device to capture on all interfaces + + Security fixes: buffer overrun audit done. Strcpy replaced with + strlcpy, sprintf replaced with snprintf. + Look for lex problems, and warn about them. + + +v3.5 Fri Jan 28 18:00:00 PST 2000 + +Bill Fenner <fenner@research.att.com> +- switch to config.h for autoconf +- unify RCSID strings +- Updated PIMv1, PIMv2, DVMRP, IGMP parsers, add Cisco Auto-RP parser +- Really fix the RIP printer +- Fix MAC address -> name translation. +- some -Wall -Wformat fixes +- update makemib to parse much of SMIv2 +- Print TCP sequence # with -vv even if you normally wouldn't +- Print as much of IP/TCP/UDP headers as possible even if truncated. + +itojun@iijlab.net +- -X will make a ascii dump. from netbsd. +- telnet command sequence decoder (ff xx xx). from netbsd. +- print-bgp.c: improve options printing. ugly code exists for + unaligned option parsing (need some fix). +- const poisoning in SMB decoder. +- -Wall -Werror clean checks. +- bring in KAME IPv6/IPsec decoding code. + +Assar Westerlund <assar@sics.se> +- SNMPv2 and SNMPv3 printer +- If compiled with libsmi, tcpdump can load MIBs on the fly to decode + SNMP packets. +- Incorporate NFS parsing code from NetBSD. Adds support for nfsv3. +- portability fixes +- permit building in different directories. + +Ken Hornstein <kenh@cmf.nrl.navy.mil> +- bring in code at + /afs/transarc.com/public/afs-contrib/tools/tcpdump for parsing + AFS3 packets + +Andrew Tridgell <tridge@linuxcare.com> +- SMB printing code + +Love <lha@stacken.kth.se> +- print-rx.c: add code for printing MakeDir and StoreStatus. Also + change date format to the right one. + +Michael C. Richardson <mcr@sandelman.ottawa.on.ca> +- Created tcpdump.org repository + +v3.4 Sat Jul 25 12:40:55 PDT 1998 + +- Hardwire Linux slip support since it's too hard to detect. + +- Redo configuration of "network" libraries (-lsocket and -lnsl) to + deal with IRIX. Thanks to John Hawkinson (jhawk@mit.edu) + +- Added -a which tries to translate network and broadcast addresses to + names. Suggested by Rob van Nieuwkerk (robn@verdi.et.tudelft.nl) + +- Added a configure option to disable gcc. + +- Added a "raw" packet printer. + +- Not having an interface address is no longer fatal. Requested by John + Hawkinson. + +- Rework signal setup to accommodate Linux. + +- OSPF truncation check fix. Also display the type of OSPF packets + using MD5 authentication. Thanks to Brian Wellington + (bwelling@tis.com) + +- Fix truncation check bugs in the Kerberos printer. Reported by Ezra + Peisach (epeisach@mit.edu) + +- Don't catch SIGHUP when invoked with nohup(1). Thanks to Dave Plonka + (plonka@mfa.com) + +- Specify full install target as a way of detecting if install + directory does not exist. Thanks to Dave Plonka. + +- Bit-swap FDDI addresses for BSD/OS too. Thanks to Paul Vixie + (paul@vix.com) + +- Fix off-by-one bug when testing size of ethernet packets. Thanks to + Marty Leisner (leisner@sdsp.mc.xerox.com) + +- Add a local autoconf macro to check for routines in libraries; the + autoconf version is broken (it only puts the library name in the + cache variable name). Thanks to John Hawkinson. + +- Add a local autoconf macro to check for types; the autoconf version + is broken (it uses grep instead of actually compiling a code fragment). + +- Modified to support the new BSD/OS 2.1 PPP and SLIP link layer header + formats. + +- Extend OSF ip header workaround to versions 1 and 2. + +- Fix some signed problems in the nfs printer. As reported by David + Sacerdote (davids@silence.secnet.com) + +- Detect group wheel and use it as the default since BSD/OS' install + can't hack numeric groups. Reported by David Sacerdote. + +- AIX needs special loader options. Thanks to Jonathan I. Kamens + (jik@cam.ov.com) + +- Fixed the nfs printer to print port numbers in decimal. Thanks to + Kent Vander Velden (graphix@iastate.edu) + +- Find installed libpcap in /usr/local/lib when not using gcc. + +- Disallow network masks with non-network bits set. + +- Attempt to detect "egcs" versions of gcc. + +- Add missing closing double quotes when displaying bootp strings. + Reported by Viet-Trung Luu (vluu@picard.math.uwaterloo.ca) + +v3.3 Sat Nov 30 20:56:27 PST 1996 + +- Added Linux support. + +- GRE encapsulated packet printer thanks to John Hawkinson + (jhawk@mit.edu) + +- Rewrite gmt2local() to avoid problematic os dependencies. + +- Suppress nfs truncation message on errors. + +- Add missing m4 quoting in AC_LBL_UNALIGNED_ACCESS autoconf macro. + Reported by Joachim Ott (ott@ardala.han.de) + +- Enable "ip_hl vs. ip_vhl" workaround for OSF4 too. + +- Print arp hardware type in host order. Thanks to Onno van der Linden + (onno@simplex.nl) + +- Avoid solaris compiler warnings. Thanks to Bruce Barnett + (barnett@grymoire.crd.ge.com) + +- Fix rip printer to not print one more route than is actually in the + packet. Thanks to Jean-Luc Richier (Jean-Luc.Richier@imag.fr) and + Bill Fenner (fenner@parc.xerox.com) + +- Use autoconf endian detection since BYTE_ORDER isn't defined on all systems. + +- Fix dvmrp printer truncation checks and add a dvmrp probe printer. + Thanks to Danny J. Mitzel (mitzel@ipsilon.com) + +- Rewrite ospf printer to improve truncation checks. + +- Don't parse tcp options past the EOL. As noted by David Sacerdote + (davids@secnet.com). Also, check tcp options to make sure they ar + actually in the tcp header (in addition to the normal truncation + checks). Fix the SACK code to print the N blocks (instead of the + first block N times). + +- Don't say really small UDP packets are truncated just because they + aren't big enough to be a RPC. As noted by David Sacerdote. + +v3.2.1 Sun Jul 14 03:02:26 PDT 1996 + +- Added rfc1716 icmp codes as suggested by Martin Fredriksson + (martin@msp.se) + +- Print mtu for icmp unreach need frag packets. Thanks to John + Hawkinson (jhawk@mit.edu) + +- Decode icmp router discovery messages. Thanks to Jeffrey Honig + (jch@bsdi.com) + +- Added a printer entry for DLT_IEEE802 as suggested by Tak Kushida + (kushida@trl.ibm.co.jp) + +- Check igmp checksum if possible. Thanks to John Hawkinson. + +- Made changes for SINIX. Thanks to Andrej Borsenkow + (borsenkow.msk@sni.de) + +- Use autoconf's idea of the top level directory in install targets. + Thanks to John Hawkinson. + +- Avoid infinite loop in tcp options printing code. Thanks to Jeffrey + Mogul (mogul@pa.dec.com) + +- Avoid using -lsocket in IRIX 5.2 and earlier since it breaks snoop. + Thanks to John Hawkinson. + +- Added some more packet truncation checks. + +- On systems that have it, use sigset() instead of signal() since + signal() has different semantics on these systems. + +- Fixed some more alignment problems on the alpha. + +- Add code to massage unprintable characters in the domain and ipx + printers. Thanks to John Hawkinson. + +- Added explicit netmask support. Thanks to Steve Nuchia + (steve@research.oknet.com) + +- Add "sca" keyword (for DEC cluster services) as suggested by Terry + Kennedy (terry@spcvxa.spc.edu) + +- Add "atalk" keyword as suggested by John Hawkinson. + +- Added an igrp printer. Thanks to Francis Dupont + (francis.dupont@inria.fr) + +- Print IPX net numbers in hex a la Novell Netware. Thanks to Terry + Kennedy (terry@spcvxa.spc.edu) + +- Fixed snmp extended tag field parsing bug. Thanks to Pascal Hennequin + (pascal.hennequin@hugo.int-evry.fr) + +- Added some ETHERTYPEs missing on some systems. + +- Added truncated packet macros and various checks. + +- Fixed endian problems with the DECnet printer. + +- Use $CC when checking gcc version. Thanks to Carl Lindberg + (carl_lindberg@blacksmith.com) + +- Fixes for AIX (although this system is not yet supported). Thanks to + John Hawkinson. + +- Fix bugs in the autoconf misaligned accesses code fragment. + +- Include sys/param.h to get BYTE_ORDER in a few places. Thanks to + Pavlin Ivanov Radoslavov (pavlin@cs.titech.ac.jp) + +v3.2 Sun Jun 23 02:28:10 PDT 1996 + +- Print new icmp unreachable codes as suggested by Martin Fredriksson + (martin@msp.se). Also print code value when unknown for icmp redirect + and time exceeded. + +- Fix an alignment endian bug in getname(). Thanks to John Hawkinson. + +- Define "new" domain record types if not found in arpa/nameserv.h. + Resulted from a suggestion from John Hawkinson (jhawk@mit.edu). Also + fixed an endian bug when printing mx record and added some new record + types. + +- Added RIP V2 support. Thanks to Jeffrey Honig (jch@bsdi.com) + +- Added T/TCP options printing. As suggested by Richard Stevens + (rstevens@noao.edu) + +- Use autoconf to detect architectures that can't handle misaligned + accesses. + +v3.1 Thu Jun 13 20:59:32 PDT 1996 + +- Changed u_int32/int32 to u_int32_t/int32_t to be consistent with bsd + and bind (as suggested by Charles Hannum). + +- Port to GNU autoconf. + +- Add support for printing DVMRP and PIM traffic thanks to + Havard Eidnes (Havard.Eidnes@runit.sintef.no). + +- Fix AppleTalk, IPX and DECnet byte order problems due to wrong endian + define being referenced. Reported by Terry Kennedy. + +- Minor fixes to the man page thanks to Mark Andrews. + +- Endian fixes to RTP and vat packet dumpers, thanks to Bruce Mah + (bmah@cs.berkeley.edu). + +- Added support for new dns types, thanks to Rainer Orth. + +- Fixed tftp_print() to print the block number for ACKs. + +- Document -dd and -ddd. Resulted from a bug report from Charlie Slater + (cslater@imatek.com). + +- Check return status from malloc/calloc/etc. + +- Check return status from pcap_loop() so we can print an error and + exit with a bad status if there were problems. + +- Bail if ip option length is <= 0. Resulted from a bug report from + Darren Reed (darrenr@vitruvius.arbld.unimelb.edu.au). + +- Print out a little more information for sun rpc packets. + +- Add suport for Kerberos 4 thanks to John Hawkinson (jhawk@mit.edu). + +- Fixed the Fix EXTRACT_SHORT() and EXTRACT_LONG() macros (which were + wrong on little endian machines). + +- Fixed alignment bug in ipx_decode(). Thanks to Matt Crawford + (crawdad@fnal.gov). + +- Fix ntp_print() to not print garbage when the stratum is + "unspecified." Thanks to Deus Ex Machina (root@belle.bork.com). + +- Rewrote tcp options printer code to check for truncation. Added + selective acknowledgment case. + +- Fixed an endian bug in the ospf printer. Thanks to Jeffrey C Honig + (jch@bsdi.com) + +- Fix rip printer to handle 4.4 BSD sockaddr struct which only uses one + octet for the sa_family member. Thanks to Yoshitaka Tokugawa + (toku@dit.co.jp) + +- Don't checksum ip header if we don't have all of it. Thanks to John + Hawkinson (jhawk@mit.edu). + +- Print out hostnames if possible in egp printer. Thanks to Jeffrey + Honig (jhc@bsdi.com) + + +v3.1a1 Wed May 3 19:21:11 PDT 1995 + +- Include time.h when SVR4 is defined to avoid problems under Solaris + 2.3. + +- Fix etheraddr_string() in the ETHER_SERVICE to return the saved + strings, not the local buffer. Thanks to Stefan Petri + (petri@ibr.cs.tu-bs.de). + +- Detect when pcap raises the snaplen (e.g. with snit). Print a warning + that the selected value was not used. Thanks to Pascal Hennequin + (Pascal.Hennequin@hugo.int-evry.fr). + +- Add a truncated packet test to print-nfs.c. Thanks to Pascal Hennequin. + +- BYTEORDER -> BYTE_ORDER Thanks to Terry Kennedy (terry@spcvxa.spc.edu). + +v3.0.3 Sun Oct 1 18:35:00 GMT 1995 + +- Although there never was a 3.0.3 release, the linux boys cleverly + "released" one in late 1995. + +v3.0.2 Thu Apr 20 21:28:16 PDT 1995 + +- Change configuration to not use gcc v2 flags with gcc v1. + +- Redo gmt2local() so that it works under BSDI (which seems to return + an empty timezone struct from gettimeofday()). Based on report from + Terry Kennedy (terry@spcvxa.spc.edu). + +- Change configure to recognize IP[0-9]* as "mips" SGI hardware. Based + on report from Mark Andrews (mandrews@alias.com). + +- Don't pass cc flags to gcc. Resulted from a bug report from Rainer + Orth (ro@techfak.uni-bielefeld.de). + +- Fixed printout of connection id for uncompressed tcp slip packets. + Resulted from a bug report from Richard Stevens (rstevens@noao.edu). + +- Hack around deficiency in Ultrix's make. + +- Add ETHERTYPE_TRAIL define which is missing from irix5. + +v3.0.1 Wed Aug 31 22:42:26 PDT 1994 + +- Fix problems with gcc2 vs. malloc() and read() prototypes under SunOS 4. + +v3.0 Mon Jun 20 19:23:27 PDT 1994 + +- Added support for printing tcp option timestamps thanks to + Mark Andrews (mandrews@alias.com). + +- Reorganize protocol dumpers to take const pointers to packets so they + never change the contents (i.e., they used to do endian conversions + in place). Previously, whenever more than one pass was taken over + the packet, the packet contents would be dumped incorrectly (i.e., + the output form -x would be wrong on little endian machines because + the protocol dumpers would modify the data). Thanks to Charles Hannum + (mycroft@gnu.ai.mit.edu) for reporting this problem. + +- Added support for decnet protocol dumping thanks to Jeff Mogul + (mogul@pa.dec.com). + +- Fix bug that caused length of packet to be incorrectly printed + (off by ether header size) for unknown ethernet types thanks + to Greg Miller (gmiller@kayak.mitre.org). + +- Added support for IPX protocol dumping thanks to Brad Parker + (brad@fcr.com). + +- Added check to verify IP header checksum under -v thanks to + Brad Parker (brad@fcr.com). + +- Move packet capture code to new libpcap library (which is + packaged separately). + +- Prototype everything and assume an ansi compiler. + +- print-arp.c: Print hardware ethernet addresses if they're not + what we expect. + +- print-bootp.c: Decode the cmu vendor field. Add RFC1497 tags. + Many helpful suggestions from Gordon Ross (gwr@jericho.mc.com). + +- print-fddi.c: Improvements. Thanks to Jeffrey Mogul + (mogul@pa.dec.com). + +- print-icmp.c: Byte swap netmask before printing. Thanks to + Richard Stevens (rstevens@noao.edu). Print icmp type when unknown. + +- print-ip.c: Print the inner ip datagram of ip-in-ip encapsulated packets. + By default, only the inner packet is dumped, appended with the token + "(encap)". Under -v, both the inner and output packets are dumped + (on the same line). Note that the filter applies to the original packet, + not the encapsulated packet. So if you run tcpdump on a net with an + IP Multicast tunnel, you cannot filter out the datagrams using the + conventional syntax. (You can filter away all the ip-in-ip traffic + with "not ip proto 4".) + +- print-nfs.c: Keep pending rpc's in circular table. Add generic + nfs header and remove os dependences. Thanks to Jeffrey Mogul. + +- print-ospf.c: Improvements. Thanks to Jeffrey Mogul. + +- tcpdump.c: Add -T flag allows interpretation of "vat", "wb", "rpc" + (sunrpc) and rtp packets. Added "inbound" and "outbound" keywords + Add && and || operators + +v2.2.1 Tue Jun 6 17:57:22 PDT 1992 + +- Fix bug with -c flag. + +v2.2 Fri May 22 17:19:41 PDT 1992 + +- savefile.c: Remove hack that shouldn't have been exported. Add + truncate checks. + +- Added the 'icmp' keyword. For example, 'icmp[0] != 8 and icmp[0] != 0' + matches non-echo/reply ICMP packets. + +- Many improvements to filter code optimizer. + +- Added 'multicast' keyword and extended the 'broadcast' keyword can now be + so that protocol qualifications are allowed. For example, "ip broadcast" + and "ether multicast" are valid filters. + +- Added support for monitoring the loopback interface (i.e. 'tcpdump -i lo'). + Jeffrey Honig (jch@MITCHELL.CIT.CORNELL.EDU) contributed the kernel + patches to netinet/if_loop.c. + +- Added support for the Ungermann-Bass Ethernet on IBM/PC-RTs running AOS. + Contact Jeffrey Honig (jch@MITCHELL.CIT.CORNELL.EDU) for the diffs. + +- Added EGP and OSPF printers, thanks to Jeffrey Honig. + +v2.1 Tue Jan 28 11:00:14 PST 1992 + +- Internal release (never publically exported). + +v2.0.1 Sun Jan 26 21:10:10 PDT + +- Various byte ordering fixes. + +- Add truncation checks. + +- inet.c: Support BSD style SIOCGIFCONF. + +- nametoaddr.c: Handle multi addresses for single host. + +- optimize.c: Rewritten. + +- pcap-bpf.c: don't choke when we get ptraced. only set promiscuous + for broadcast nets. + +- print-atal.c: Fix an alignment bug (thanks to + stanonik@nprdc.navy.mil) Add missing printf() argument. + +- print-bootp.c: First attempt at decoding the vendor buffer. + +- print-domain.c: Fix truncation checks. + +- print-icmp.c: Calculate length of packets from the ip header. + +- print-ip.c: Print frag id in decimal (so it's easier to match up + with non-frags). Add support for ospf, egp and igmp. + +- print-nfs.c: Lots of changes. + +- print-ntp.c: Make some verbose output depend on -v. + +- print-snmp.c: New version from John LoVerso. + +- print-tcp.c: Print rfc1072 tcp options. + +- tcpdump.c: Print "0x" prefix for %x formats. Always print 6 digits + (microseconds) worth of precision. Fix uid bugs. + +- A packet dumper has been added (thanks to Jeff Mogul of DECWRL). + With this option, you can create an architecture independent binary + trace file in real time, without the overhead of the packet printer. + At a later time, the packets can be filtered (again) and printed. + +- BSD is supported. You must have BPF in your kernel. + Since the filtering is now done in the kernel, fewer packets are + dropped. In fact, with BPF and the packet dumper option, a measly + Sun 3/50 can keep up with a busy network. + +- Compressed SLIP packets can now be dumped, provided you use our + SLIP software and BPF. These packets are dumped as any other IP + packet; the compressed headers are dumped with the '-e' option. + +- Machines with little-endian byte ordering are supported (thanks to + Jeff Mogul). + +- Ultrix 4.0 is supported (also thanks to Jeff Mogul). + +- IBM RT and Stanford Enetfilter support has been added by + Rayan Zachariassen <rayan@canet.ca>. Tcpdump has been tested under + both the vanilla Enetfilter interface, and the extended interface + (#ifdef'd by IBMRTPC) present in the MERIT version of the Enetfilter. + +- TFTP packets are now printed (requests only). + +- BOOTP packets are now printed. + +- SNMP packets are now printed. (thanks to John LoVerso of Xylogics). + +- Sparc architectures, including the Sparcstation-1, are now + supported thanks to Steve McCanne and Craig Leres. + +- SunOS 4 is now supported thanks to Micky Liu of Columbia + University (micky@cunixc.cc.columbia.edu). + +- IP options are now printed. + +- RIP packets are now printed. + +- There's a -v flag that prints out more information than the + default (e.g., it will enable printing of IP ttl, tos and id) + and -q flag that prints out less (e.g., it will disable + interpretation of AppleTalk-in-UDP). + +- The grammar has undergone substantial changes (if you have an + earlier version of tcpdump, you should re-read the manual + entry). + + The most useful change is the addition of an expression + syntax that lets you filter on arbitrary fields or values in the + packet. E.g., "ip[0] > 0x45" would print only packets with IP + options, "tcp[13] & 3 != 0" would print only TCP SYN and FIN + packets. + + The most painful change is that concatenation no longer means + "and" -- e.g., you have to say "host foo and port bar" instead + of "host foo port bar". The up side to this down is that + repeated qualifiers can be omitted, making most filter + expressions shorter. E.g., you can now say "ip host foo and + (bar or baz)" to look at ip traffic between hosts foo and bar or + between hosts foo and baz. [The old way of saying this was "ip + host foo and (ip host bar or ip host baz)".] + +v2.0 Sun Jan 13 12:20:40 PST 1991 + +- Initial public release.
diff --git a/tcpdump-4.3.0/CREDITS b/tcpdump-4.3.0/CREDITS new file mode 100644 index 0000000..3a0fba8 --- /dev/null +++ b/tcpdump-4.3.0/CREDITS
@@ -0,0 +1,206 @@ +This file lists people who have contributed to tcpdump: + +The current maintainers: + Bill Fenner <fenner at research dot att dot com> + David Young <dyoung at pobox dot com> + Fulvio Risso <risso at polito dot it> + Guy Harris <guy at alum dot mit dot edu> + Hannes Gredler <hannes at juniper dot net> + Michael Richardson <mcr at sandelman dot ottawa dot on dot ca> + +Additional people who have contributed patches: + + A Costa <agcosta at gis dot net> + Aaron Campbell <aaron at arbor dot net> + Alfredo Andres <aandres at s21sec dot com> + Albert Chin <china at thewrittenword dot com> + Ananth Suryanarayana <anantha at juniper dot net> + Andrea Bittau <a dot bittau at cs dot ucl dot ac dot uk> + Andrew Brown <atatat at atatdot dot net> + Andrew Church <andrew at users dot sourceforge dot net> + Andrew Hintz <adhintz at users dot sourceforge dot net> + Andrew Nording <andrew at nording dot ru> + Andrew Tridgell <tridge at linuxcare dot com> + Andy Heffernan <ahh at juniper dot net> + Anton Bernal <anton at juniper dot net> + Arkadiusz Miskiewicz <misiek at pld dot org dot pl> + Armando L. Caro Jr. <acaro at mail dot eecis dot udel dot edu> + Arnaldo Carvalho de Melo <acme at ghostprotocols dot net> + Ben Byer <bushing at sourceforge dot net> + Atsushi Onoe <onoe at netbsd dot org> + Ben Smithurst <ben at scientia dot demon dot co dot uk> + Bert Vermeulen <bert at biot dot com> + Bjoern A. Zeeb <bzeeb at Zabbadoz dot NeT> + Brent L. Bates <blbates at vigyan dot com> + Brian Ginsbach <ginsbach at cray dot com> + Bruce M. Simpson <bms at spc dot org> + Carles Kishimoto Bisbe <ckishimo at ac dot upc dot es> + Charlie Lenahan <clenahan at fortresstech dot com> + Charles M. Hannum <mycroft at netbsd dot org> + Chris Cogdon <chris at cogdon dot org> + Chris G. Demetriou <cgd at netbsd dot org> + Chris Jepeway <jepeway at blasted-heath dot com> + Chris Larson <clarson at kergoth dot com> + Christian Sievers <c_s at users dot sourceforge dot net> + Christophe Rhodes <csr21 at cantab dot net> + Cliff Frey <cliff at meraki dot com> + Craig Rodrigues <rodrigc at mediaone dot net> + Crist J. Clark <cjclark at alum dot mit dot edu> + Daniel Hagerty <hag at ai dot mit dot edu> + Darren Reed <darrenr at reed dot wattle dot id dot au> + David Binderman <d dot binderman at virgin dot net> + David Horn <dhorn2000 at gmail dot com> + David Smith <dsmith at redhat dot com> + David Young <dyoung at ojctech dot com> + Dmitry Eremin-Solenikov <dbaryshkov at gmail dot com> + Don Ebright <Don dot Ebright at compuware dot com> + Eddie Kohler <xexd at sourceforge dot net> + Elmar Kirchner <elmar at juniper dot net> + Fang Wang <fangwang at sourceforge dot net> + Florent Drouin <Florent dot Drouin at alcatel-lucent dot fr> + Florian Forster <octo at verplant dot org> + Francis Dupont <Francis dot Dupont at enst-bretagne dot fr> + Francisco Matias Cuenca-Acuna <mcuenca at george dot rutgers dot edu> + Francois-Xavier Le Bail <fx dot lebail at yahoo dot com> + Frank Volf <volf at oasis dot IAEhv dot nl> + Fulvio Risso <risso at polito dot it> + George Bakos <gbakos at ists dot dartmouth dot edu> + Gerald Combs <gerald at ethereal dot com> + Gerrit Renker <gerrit at erg dot abdn dot ac dot uk> + Gert Doering <gert at greenie dot muc dot de> + Greg Minshall <minshall at acm dot org> + Greg Stark <gsstark at mit dot edu> + Grégoire Henry <henry@pps.jussieu.fr> + Gilbert Ramirez Jr. <gram at xiexie dot org> + Gisle Vanem <gvanem at broadpark dot no> + Hannes Viertel <hviertel at juniper dot net> + Hank Leininger <tcpdump-workers at progressive-comp dot com> + Harry Raaymakers <harryr at connect dot com dot au> + Heinz-Ado Arnolds <Ado dot Arnolds at dhm-systems dot de> + Hendrik Scholz <hendrik at scholz dot net> + Ian McDonald <imcdnzl at gmail dot com> + Ilpo Järvinen <ilpo dot jarvinen at helsinki dot fi> + Jacek Tobiasz <Jacek dot Tobiasz at atm dot com dot pl> + Jakob Schlyter <jakob at openbsd dot org> + Jamal Hadi Salim <hadi at cyberus dot ca> + Jan Oravec <wsx at wsx6 dot net> + Jason R. Thorpe <thorpej at netbsd dot org> + Jefferson Ogata <jogata at nodc dot noaa dot gov> + Jeffrey Hutzelman <jhutz at cmu dot edu> + Jesper Peterson <jesper at endace dot com> + Jim Hutchins <jim at ca dot sandia dot gov> + Jonathan Heusser <jonny at drugphish dot ch> + Tatuya Jinmei <jinmei at kame dot net> + João Medeiros <ignotus21 at sourceforge dot net> + Joerg Mayer <jmayer@loplof.de> + Jørgen Thomsen <jth at jth dot net> + Julian Cowley <julian at lava dot net> + Juliusz Chroboczek <jch@pps.jussieu.fr> + Kaarthik Sivakumar <kaarthik at torrentnet dot com> + Kaladhar Musunuru <kaladharm at sourceforge dot net> + Karl Norby <karl-norby at sourceforge dot net> + Kazushi Sugyo <sugyo at pb dot jp dot nec dot com> + Kelly Carmichael <kcarmich at ipapp dot com> + Ken Hornstein <kenh at cmf dot nrl dot navy dot mil> + Kevin Steves <stevesk at pobox dot com> + Kenichi Maehashi <webmaster at kenichimaehashi dot com> + Klaus Klein <kleink at reziprozitaet dot de> + Kris Kennaway <kris at freebsd dot org> + Krzysztof Halasa <khc at pm dot waw dot pl> + Larry Lile <lile at stdio dot com> + Lennert Buytenhek <buytenh at gnu dot org> + Loris Degioanni <loris at netgroup-serv dot polito dot it> + Love Hörnquist-Åstrand <lha at stacken dot kth dot se> + Lucas C. Villa Real <lucasvr at us dot ibm dot com> + Luis MartinGarcia <luis dot mgarc at gmail dot com> + Maciej W. Rozycki <macro at ds2 dot pg dot gda dot pl> + Manu Pathak <mapathak at cisco dot com> + Marc Binderberger <mbind at sourceforge dot net> + Marc A. Lehmann <pcg at goof dot com> + Mark Ellzey Thomas <mark at ackers dot net> + Marko Kiiskila <carnil at cs dot tut dot fi> + Markus Schöpflin <schoepflin at sourceforge dot net> + Marshall Rose <mrose at dbc dot mtview dot ca dot us> + Martin Husemann <martin at netbsd dot org> + Max Laier <max at love2party dot net> + Michael A. Meffie III <meffie at sourceforge dot net> + Michael Madore <mmadore at turbolinux dot com> + Michael Riepe <too-tired at sourceforge dot net> + Michael Shalayeff <mickey at openbsd dot org> + Michael Shields <shields at msrl dot com> + Michael T. Stolarchuk <mts at off dot to> + Michal Sekletar <msekleta at redhat dot com> + Michele "mydecay" Marchetto <smarchetto1 at tin dot it> + Mike Frysinger <vapier at gmail dot com> + Minto Jeyananth <minto at juniper dot net> + Monroe Williams <monroe at pobox dot com> + Motonori Shindo <mshindo at mshindo dot net> + Nathan J. Williams <nathanw at MIT dot EDU> + Nathaniel Couper-Noles <Nathaniel at isi1 dot tccisi dot com> + Neil T. Spring <bluehal at users dot sourceforge dot net> + Niels Provos <provos at openbsd dot org> + Nickolai Zeldovich <kolya at MIT dot EDU> + Nicolas Ferrero <toorop at babylo dot net> + Noritoshi Demizu <demizu at users dot sourceforge dot net> + Olaf Kirch <okir at caldera dot de> + Onno van der Linden <onno at simplex dot nl> + Paolo Abeni <paolo dot abeni at email dot it> + Pascal Hennequin <pascal dot hennequin at int-evry dot fr> + Pasvorn Boonmark <boonmark at juniper dot net> + Paul Ferrell <pflarr at sourceforge dot net> + Paul Mundt <lethal at linux-sh dot org> + Paul S. Traina <pst at freebsd dot org> + Pavlin Radoslavov <pavlin at icir dot org> + Pawel Worach <pawel dot worach at gmail dot com> + Pekka Savola <pekkas at netcore dot fi> + Peter Fales <peter at fales-lorenz dot net> + Peter Jeremy <peter dot jeremy at alcatel dot com dot au> + <pfhunt at users dot sourceforge dot net> + Peter Volkov <pva at gentoo dot org> + Phil Wood <cpw at lanl dot gov> + Rafal Maszkowski <rzm at icm dot edu dot pl> + Randy Sofia <rsofia at users dot sourceforge dot net> + Raphael Raimbault <raphael dot raimbault at netasq dot com> + Rick Cheng <rcheng at juniper dot net> + Rick Jones <rick dot jones2 at hp dot com> + Rick Watson <watsonrick at users dot sourceforge dot net> + Rob Braun <bbraun at synack dot net> + Robert Edmonds <stu-42 at sourceforge dot net> + Roderick Schertler <roderick at argon dot org> + Romain Francoise <rfrancoise at debian dot org> + Sagun Shakya <sagun dot shakya at sun dot com> + Sami Farin <safari at iki dot fi> + Scott Mcmillan <scott.a.mcmillan at intel dot com> + Scott Rose <syberpunk at users dot sourceforge dot net> + Sebastian Krahmer <krahmer at cs dot uni-potsdam dot de> + Sebastien Raveau <sebastien dot raveau at epita dot fr> + Sebastien Vincent <svincent at idems dot fr> + Sepherosa Ziehau <sepherosa at gmail dot com> + Seth Webster <swebster at sst dot ll dot mit dot edu> + Shinsuke Suzuki <suz at kame dot net> + Simon Ruderich <simon at ruderich dot org> + Steinar Haug <sthaug at nethelp dot no> + Swaminathan Chandrasekaran <chander at juniper dot net> + Takashi Yamamoto <yamt at mwd dot biglobe dot ne dot jp> + Terry Kennedy <terry at tmk dot com> + Timo Koskiahde + Tony Li <tli at procket dot com> + Toshihiro Kanda <candy at fct dot kgc dot co dot jp> + Uns Lider <unslider at miranda dot org> + Victor Oppleman <oppleman at users dot sourceforge dot net> + Weesan Lee <weesan at juniper dot net> + Wesley Griffin <wgriffin at users dot sourceforge dot net> + Wesley Shields <wxs at FreeBSD dot org> + Wilbert de Graaf <wilbertdg at hetnet dot nl> + Will Drewry <will at alum dot bu dot edu> + William J. Hulley <bill dot hulley at gmail dot com> + Yen Yen Lim + Yoshifumi Nishida + +The original LBL crew: + Steve McCanne + Craig Leres + Van Jacobson + +Past maintainers: + Jun-ichiro itojun Hagino <itojun at iijlab dot net>
diff --git a/tcpdump-4.3.0/INSTALL.txt b/tcpdump-4.3.0/INSTALL.txt new file mode 100644 index 0000000..a03e2c0 --- /dev/null +++ b/tcpdump-4.3.0/INSTALL.txt
@@ -0,0 +1,255 @@ +@(#) $Header: /tcpdump/master/tcpdump/INSTALL.txt,v 1.2 2008-02-06 10:47:53 guy Exp $ (LBL) + +If you have not built libpcap, and your system does not have libpcap +installed, install libpcap first. Your system might provide a version +of libpcap that can be installed; if so, to compile tcpdump you might +need to install a "developer" version of libpcap as well as the +"run-time" version. You can also install tcpdump.org's version of +libpcap; see the README file in this directory for the ftp location. + +You will need an ANSI C compiler to build tcpdump. The configure script +will abort if your compiler is not ANSI compliant. If this happens, use +the GNU C compiler, available via anonymous ftp: + + ftp://ftp.gnu.org/pub/gnu/gcc/ + +After libpcap has been built (either install it with "make install" or +make sure both the libpcap and tcpdump source trees are in the same +directory), run ./configure (a shell script). "configure" will +determine your system attributes and generate an appropriate Makefile +from Makefile.in. Now build tcpdump by running "make". + +If everything builds ok, su and type "make install". This will install +tcpdump and the manual entry. Any user will be able to use tcpdump to +read saved captures. Whether a user will be able to capture traffic +depends on the OS and the configuration of the system; see the tcpdump +man page for details. DO NOT give untrusted users the ability to +capture traffic. If a user can capture traffic, he or she could use +utilities such as tcpdump to capture any traffic on your net, including +passwords. + +Note that most systems ship tcpdump, but usually an older version. +Remember to remove or rename the installed binary when upgrading. + +If your system is not one which we have tested tcpdump on, you may have +to modify the configure script and Makefile.in. Please send us patches +for any modifications you need to make. + +Please see "PLATFORMS" for notes about tested platforms. + + +FILES +----- +CHANGES - description of differences between releases +CREDITS - people that have helped tcpdump along +FILES - list of files exported as part of the distribution +INSTALL.txt - 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 +bgp.h - BGP declarations +bootp.h - BOOTP definitions +bpf_dump.c - BPF program printing routines, in case libpcap doesn't + have them +chdlc.h - Cisco HDLC definitions +cpack.c - functions to extract packed data +cpack.h - declarations of functions to extract packed data +config.guess - autoconf support +config.h.in - autoconf input +config.sub - autoconf support +configure - configure script (run this first) +configure.in - configure script source +dccp.h - DCCP definitions +decnet.h - DECnet definitions +decode_prefix.h - Declarations of "decode_prefix{4,6}()" +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 +ieee802_11.h - IEEE 802.11 definitions +ieee802_11_radio.h - radiotap header definitions +igrp.h - Interior Gateway Routing Protocol definitions +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.c - IP protocol type value-to-name table +ipproto.h - IP protocol type value definitions +ipsec_doi.h - ISAKMP packet definitions - RFC2407 +ipx.h - IPX definitions +isakmp.h - ISAKMP packet definitions - RFC2408 +l2vpn.c - L2VPN encapsulation value-to-name table +l2vpn.h - L2VPN encapsulation definitions +l2tp.h - Layer Two Tunneling Protocol definitions +lane.h - ATM LANE definitions +lbl/os-*.h - OS-dependent defines and prototypes +llc.h - LLC definitions +machdep.c - machine dependent routines +machdep.h - machine dependent definitions +makemib - mib to header script +mib.h - mib definitions +missing/* - replacements for missing library functions +mkdep - construct Makefile dependency list +mpls.h - MPLS definitions +nameser.h - DNS definitions +netbios.h - NETBIOS definitions +netdissect.h - definitions and declarations for tcpdump-as-library + (under development) +nfs.h - Network File System V2 definitions +nfsfh.h - Network File System file handle definitions +nlpid.c - OSI NLPID value-to-name table +nlpid.h - OSI NLPID definitions +ntp.h - Network Time Protocol definitions +oakley.h - ISAKMP packet definitions - RFC2409 +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_dump_ftell.c - pcap_dump_ftell() implementation, in case libpcap + doesn't have it +pcap-missing.h - declarations of functions possibly missing from libpcap +pmap_prot.h - definitions for ONC RPC portmapper protocol +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 +print-atalk.c - AppleTalk printer routines +print-atm.c - ATM printer routines +print-beep.c - BEEP printer routines +print-bgp.c - Border Gateway Protocol printer routines +print-bootp.c - BOOTP and IPv4 DHCP printer routines +print-bt.c - Bluetooth printer routines +print-cdp.c - Cisco Discovery Protocol printer routines +print-chdlc.c - Cisco HDLC printer routines +print-cip.c - Classical-IP over ATM routines +print-cnfp.c - Cisco NetFlow printer routines +print-dccp.c - DCCP printer routines +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-eap.c - EAP 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 +print-icmp.c - Internet Control Message Protocol printer routines +print-icmp6.c - IPv6 Internet Control Message Protocol printer routines +print-igmp.c - Internet Group Management Protocol printer routines +print-igrp.c - Interior Gateway Routing Protocol printer routines +print-ip.c - IP printer routines +print-ip6.c - IPv6 printer routines +print-ip6opts.c - IPv6 header option printer routines +print-ipcomp.c - IP Payload Compression Protocol printer routines +print-ipx.c - IPX printer routines +print-isakmp.c - Internet Security Association and Key Management Protocol +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-llc.c - IEEE 802.2 LLC printer routines +print-lspping.c - LSPPING 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 +print-nfs.c - Network File System printer routines +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-pgm.c - Pragmatic General Multicast 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 +print-pptp.c - Point-to-Point Tunnelling Protocol printer routines +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-rrcp.c - Realtek Remote Control Protocol 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 +print-sip.c - SIP printer routines +print-sl.c - Compressed Serial Line Internet Protocol printer routines +print-sll.c - Linux "cooked" capture printer routines +print-slow.c - IEEE "slow protocol" (802.3ad) 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-symantec.c - Symantec Enterprise Firewall printer routines +print-tcp.c - TCP printer routines +print-telnet.c - Telnet option printer routines +print-tftp.c - Trivial File Transfer Protocol printer routines +print-timed.c - BSD time daemon protocol printer routines +print-token.c - Token Ring printer routines +print-udp.c - UDP printer routines +print-usb.c - USB printer routines +print-vjc.c - PPP Van Jacobson compression (RFC1144) printer routines +print-vrrp.c - Virtual Router Redundancy Protocol +print-wb.c - White Board printer routines +print-zephyr.c - Zephyr printer routines +route6d.h - packet definition for IPv6 Routing Information Protocol +rpc_auth.h - definitions for ONC RPC authentication +rpc_msg.h - definitions for ONC RPC messages +rx.h - AFS RX definitions +sctpConstants.h - Stream Control Transmission Protocol constant definitions +sctpHeader.h - Stream Control Transmission Protocol packet definitions +send-ack.awk - unidirectional tcp send/ack awk script +setsignal.c - OS-independent signal routines +setsignal.h - OS-independent signal prototypes +slcompress.h - SLIP/PPP Van Jacobson compression (RFC1144) definitions +slip.h - SLIP definitions +sll.h - Linux "cooked" capture definitions +smb.h - SMB/CIFS definitions +smbutil.c - SMB/CIFS utility routines +stime.awk - TCP send awk script +strcasecmp.c - missing routine +tcp.h - TCP definitions +tcpdump.1 - manual entry +tcpdump.c - main program +telnet.h - Telnet definitions +tftp.h - TFTP definitions +timed.h - BSD time daemon protocol definitions +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/tcpdump-4.3.0/LICENSE b/tcpdump-4.3.0/LICENSE new file mode 100644 index 0000000..dea5f7d --- /dev/null +++ b/tcpdump-4.3.0/LICENSE
@@ -0,0 +1,19 @@ +License: BSD + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + +THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/tcpdump-4.3.0/Makefile-devel-adds b/tcpdump-4.3.0/Makefile-devel-adds new file mode 100644 index 0000000..512a119 --- /dev/null +++ b/tcpdump-4.3.0/Makefile-devel-adds
@@ -0,0 +1,22 @@ +# +# Auto-regenerate configure script or Makefile when things change. +# From autoconf.info . Works best with GNU Make. +# +${srcdir}/configure: configure.in + cd ${srcdir} && autoconf + +# autoheader might not change config.h.in, so touch a stamp file. +${srcdir}/config.h.in: ${srcdir}/stamp-h.in +${srcdir}/stamp-h.in: configure.in acconfig.h + cd ${srcdir} && autoheader + echo timestamp > ${srcdir}/stamp-h.in + +config.h: stamp-h +stamp-h: ${srcdir}/config.h.in config.status + ./config.status + +Makefile: Makefile.in config.status + ./config.status + +config.status: ${srcdir}/configure + ./config.status --recheck
diff --git a/tcpdump-4.3.0/Makefile.in b/tcpdump-4.3.0/Makefile.in new file mode 100644 index 0000000..3b589dc --- /dev/null +++ b/tcpdump-4.3.0/Makefile.in
@@ -0,0 +1,451 @@ +# Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 +# The Regents of the University of California. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that: (1) source code distributions +# retain the above copyright notice and this paragraph in its entirety, (2) +# distributions including binary code include the above copyright notice and +# this paragraph in its entirety in the documentation or other materials +# provided with the distribution, and (3) all advertising materials mentioning +# features or use of this software display the following acknowledgement: +# ``This product includes software developed by the University of California, +# Lawrence Berkeley Laboratory and its contributors.'' Neither the name of +# the University nor the names of its contributors may be used to endorse +# or promote products derived from this software without specific prior +# written permission. +# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +# +# @(#) $Header: /tcpdump/master/tcpdump/Makefile.in,v 1.325 2008-11-21 23:17:26 guy Exp $ (LBL) + +# +# Various configurable paths (remember to edit Makefile.in, not Makefile) +# + +# Top level hierarchy +prefix = @prefix@ +exec_prefix = @exec_prefix@ +datarootdir = @datarootdir@ +# Pathname of directory to install the binary +sbindir = @sbindir@ +# Pathname of directory to install the man page +mandir = @mandir@ + +# VPATH +srcdir = @srcdir@ +VPATH = @srcdir@ + +# +# You shouldn't need to edit anything below here. +# + +CC = @CC@ +PROG = tcpdump +CCOPT = @V_CCOPT@ +INCLS = -I. @V_INCLS@ +DEFS = @DEFS@ @CPPFLAGS@ @V_DEFS@ + +# Standard CFLAGS +CFLAGS = @CFLAGS@ +FULL_CFLAGS = $(CCOPT) $(DEFS) $(INCLS) $(CFLAGS) + +# Standard LDFLAGS +LDFLAGS = @LDFLAGS@ + +# Standard LIBS +LIBS = @LIBS@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +RANLIB = @RANLIB@ + +# Explicitly define compilation rule since SunOS 4's make doesn't like gcc. +# Also, gcc does not remove the .o before forking 'as', which can be a +# problem if you don't own the file but can write to the directory. +.c.o: + @rm -f $@ + $(CC) $(FULL_CFLAGS) -c $(srcdir)/$*.c + +CSRC = addrtoname.c af.c checksum.c cpack.c gmpls.c oui.c gmt2local.c ipproto.c \ + nlpid.c l2vpn.c machdep.c parsenfsfh.c in_cksum.c \ + print-802_11.c print-802_15_4.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-bt.c print-carp.c print-cdp.c print-cfm.c \ + print-chdlc.c print-cip.c print-cnfp.c print-dccp.c print-decnet.c \ + print-domain.c print-dtp.c print-dvmrp.c print-enc.c print-egp.c \ + print-eap.c print-eigrp.c\ + print-esp.c print-ether.c print-fddi.c print-forces.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-ipnet.c \ + print-ipx.c print-isoclns.c print-juniper.c print-krb.c \ + print-l2tp.c print-lane.c print-ldp.c print-lldp.c print-llc.c \ + print-lmp.c print-lspping.c print-lwapp.c \ + print-lwres.c print-mobile.c print-mpcp.c print-mpls.c print-msdp.c \ + print-nfs.c print-ntp.c print-null.c print-olsr.c print-ospf.c \ + print-pgm.c print-pim.c \ + print-ppi.c print-ppp.c print-pppoe.c print-pptp.c \ + print-radius.c print-raw.c print-rip.c print-rpki-rtr.c print-rrcp.c print-rsvp.c \ + print-rx.c print-sctp.c print-sflow.c print-sip.c print-sl.c print-sll.c \ + print-slow.c print-snmp.c print-stp.c print-sunatm.c print-sunrpc.c \ + print-symantec.c print-syslog.c print-tcp.c print-telnet.c print-tftp.c \ + print-timed.c print-tipc.c print-token.c print-udld.c print-udp.c \ + print-usb.c print-vjc.c print-vqp.c print-vrrp.c print-vtp.c \ + print-wb.c print-zephyr.c signature.c setsignal.c tcpdump.c util.c + +LIBNETDISSECT_SRC=print-isakmp.c +LIBNETDISSECT_OBJ=$(LIBNETDISSECT_SRC:.c=.o) +LIBNETDISSECT=libnetdissect.a + +LOCALSRC = @LOCALSRC@ +GENSRC = version.c +LIBOBJS = @LIBOBJS@ + +SRC = $(CSRC) $(GENSRC) $(LOCALSRC) $(LIBNETDISSECT_SRC) + +# We would like to say "OBJ = $(SRC:.c=.o)" but Ultrix's make cannot +# hack the extra indirection +OBJ = $(CSRC:.c=.o) $(GENSRC:.c=.o) $(LOCALSRC:.c=.o) $(LIBOBJS) $(LIBNETDISSECT_OBJ) +HDR = \ + acconfig.h \ + addrtoname.h \ + af.h \ + ah.h \ + aodv.h \ + appletalk.h \ + arcnet.h \ + atm.h \ + atmuni31.h \ + bootp.h \ + bgp.h \ + chdlc.h \ + cpack.h \ + dccp.h \ + decnet.h \ + decode_prefix.h \ + enc.h \ + esp.h \ + ether.h \ + ethertype.h \ + extract.h \ + fddi.h \ + forces.h \ + gmpls.h \ + gmt2local.h \ + icmp6.h \ + ieee802_11.h \ + ieee802_11_radio.h \ + igrp.h \ + interface.h \ + interface.h \ + ip.h \ + ip6.h \ + ipfc.h \ + ipnet.h \ + ipproto.h \ + ipsec_doi.h \ + ipx.h \ + isakmp.h \ + l2tp.h \ + l2vpn.h \ + lane.h \ + llc.h \ + machdep.h \ + mib.h \ + mpls.h \ + nameser.h \ + netbios.h \ + netdissect.h \ + nfs.h \ + nfsfh.h \ + nlpid.h \ + ntp.h \ + oakley.h \ + ospf.h \ + ospf6.h \ + oui.h \ + pcap-missing.h \ + pmap_prot.h \ + ppi.h \ + ppp.h \ + route6d.h \ + rpc_auth.h \ + rpc_msg.h \ + rx.h \ + sctpConstants.h \ + sctpHeader.h \ + setsignal.h \ + signature.h \ + slcompress.h \ + slip.h \ + sll.h \ + smb.h \ + tcp.h \ + tcpdump-stdinc.h \ + telnet.h \ + tftp.h \ + timed.h \ + token.h \ + udp.h + +TAGHDR = \ + /usr/include/arpa/tftp.h \ + /usr/include/net/if_arp.h \ + /usr/include/net/slip.h \ + /usr/include/netinet/if_ether.h \ + /usr/include/netinet/in.h \ + /usr/include/netinet/ip_icmp.h \ + /usr/include/netinet/tcp.h \ + /usr/include/netinet/udp.h \ + /usr/include/protocols/routed.h + +TAGFILES = $(SRC) $(HDR) $(TAGHDR) + +CLEANFILES = $(PROG) $(OBJ) $(GENSRC) + +EXTRA_DIST = \ + CHANGES \ + CREDITS \ + INSTALL.txt \ + LICENSE \ + Makefile.in \ + Makefile-devel-adds \ + README \ + Readme.Win32 \ + VERSION \ + aclocal.m4 \ + atime.awk \ + bpf_dump.c \ + config.guess \ + config.h.in \ + config.sub \ + configure \ + configure.in \ + install-sh \ + lbl/os-osf4.h \ + lbl/os-solaris2.h \ + lbl/os-sunos4.h \ + lbl/os-ultrix4.h \ + makemib \ + missing/addrinfo.h \ + missing/dlnames.c \ + missing/datalinks.c \ + missing/getnameinfo.c \ + missing/inet_aton.c \ + missing/inet_ntop.c \ + missing/inet_pton.c \ + missing/snprintf.c \ + missing/sockstorage.h \ + missing/strdup.c \ + missing/strlcat.c \ + missing/strlcpy.c \ + missing/strsep.c \ + mkdep \ + packetdat.awk \ + pcap_dump_ftell.c \ + print-babel.c \ + print-dhcp6.c \ + print-frag6.c \ + print-icmp6.c \ + print-ip6.c \ + print-ip6opts.c \ + print-mobility.c \ + print-netbios.c \ + print-ospf6.c \ + print-pflog.c \ + print-ripng.c \ + print-rt6.c \ + print-smb.c \ + send-ack.awk \ + smbutil.c \ + stime.awk \ + strcasecmp.c \ + tcpdump.1.in \ + tests/02-sunrise-sunset-esp.pcap \ + tests/08-sunrise-sunset-aes.pcap \ + tests/08-sunrise-sunset-esp2.pcap \ + tests/QinQpacket.out \ + tests/QinQpacket.pcap \ + tests/QinQpacketv.out \ + tests/TESTLIST \ + tests/TESTonce \ + tests/TESTrun.sh \ + tests/babel.pcap \ + tests/babel1.out \ + tests/babel1v.out \ + tests/bgp-infinite-loop.pcap \ + tests/bgp_vpn_attrset.out \ + tests/bgp_vpn_attrset.pcap \ + tests/chdlc-slarp-short.pcap \ + tests/chdlc-slarp.pcap \ + tests/dio.out \ + tests/dio.pcap \ + tests/e1000g.out \ + tests/e1000g.pcap \ + tests/eapon1.gdbinit \ + tests/eapon1.out \ + tests/eapon1.pcap \ + tests/empty.uu \ + tests/esp-secrets.txt \ + tests/esp0.out \ + tests/esp1.gdbinit \ + tests/esp1.out \ + tests/esp2.gdbinit \ + tests/esp2.out \ + tests/esp3.gdbinit \ + tests/esp4.gdbinit \ + tests/esp5.gdbinit \ + tests/esp5.out \ + tests/espudp1.out \ + tests/espudp1.pcap \ + tests/forces1.out \ + tests/forces1.pcap \ + tests/forces1vvv.out \ + tests/forces1vvvv.out \ + tests/forces2v.out \ + tests/forces2vv.out \ + tests/forces3vvv.out \ + tests/icmpv6.out \ + tests/icmpv6.pcap \ + tests/ikev2four.out \ + tests/ikev2four.pcap \ + tests/ikev2fourv.out \ + tests/ikev2fourv4.out \ + tests/ikev2pI2-secrets.txt \ + tests/ikev2pI2.out \ + tests/ikev2pI2.pcap \ + tests/isakmp-delete-segfault.pcap \ + tests/isakmp-identification-segfault.pcap \ + tests/isakmp-pointer-loop.pcap \ + tests/isakmp1.out \ + tests/isakmp2.out \ + tests/isakmp3.out \ + tests/isakmp4.out \ + tests/isakmp4500.pcap \ + tests/isis-infinite-loop.pcap \ + tests/ldp-infinite-loop.pcap \ + tests/lmp.out \ + tests/lmp.pcap \ + tests/lmp.sh \ + tests/lspping-fec-ldp.pcap \ + tests/lspping-fec-rsvp.pcap \ + tests/mpls-ldp-hello.out \ + tests/mpls-ldp-hello.pcap \ + tests/mpls-traceroute.pcap \ + tests/ospf-gmpls.out \ + tests/ospf-gmpls.pcap \ + tests/pppoe.out \ + tests/pppoe.pcap \ + tests/print-A.out \ + tests/print-AA.out \ + tests/print-capX.out \ + tests/print-capXX.out \ + tests/print-flags.pcap \ + tests/print-flags.sh \ + tests/print-x.out \ + tests/print-xx.out \ + tests/rsvp-infinite-loop.pcap \ + tests/sflow_multiple_counter_30_pdus.out \ + tests/sflow_multiple_counter_30_pdus.pcap \ + vfprintf.c \ + win32/Include/errno.h \ + win32/Include/getopt.h \ + win32/Include/w32_fzs.h \ + win32/Src/getopt.c \ + win32/prj/GNUmakefile \ + win32/prj/WinDump.dsp \ + win32/prj/WinDump.dsw + +all: $(PROG) + +$(PROG): $(OBJ) @V_PCAPDEP@ + @rm -f $@ + $(CC) $(FULL_CFLAGS) $(LDFLAGS) -o $@ $(OBJ) $(LIBS) + +$(LIBNETDISSECT): $(LIBNETDISSECT_OBJ) + @rm -f $@ + $(AR) cr $@ $(LIBNETDISSECT_OBJ) + $(RANLIB) $@ + +datalinks.o: $(srcdir)/missing/datalinks.c + $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/datalinks.c +dlnames.o: $(srcdir)/missing/dlnames.c + $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/dlnames.c +getnameinfo.o: $(srcdir)/missing/getnameinfo.c + $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/getnameinfo.c +getaddrinfo.o: $(srcdir)/missing/getaddrinfo.c + $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/getaddrinfo.c +inet_pton.o: $(srcdir)/missing/inet_pton.c + $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/inet_pton.c +inet_ntop.o: $(srcdir)/missing/inet_ntop.c + $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/inet_ntop.c +inet_aton.o: $(srcdir)/missing/inet_aton.c + $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/inet_aton.c +snprintf.o: $(srcdir)/missing/snprintf.c + $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c +strlcat.o: $(srcdir)/missing/strlcat.c + $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strlcat.c +strlcpy.o: $(srcdir)/missing/strlcpy.c + $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strlcpy.c +strsep.o: $(srcdir)/missing/strsep.c + $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strsep.c + +version.o: version.c + $(CC) $(FULL_CFLAGS) -c version.c + +version.c: $(srcdir)/VERSION + @rm -f $@ + if grep GIT ${srcdir}/VERSION >/dev/null; then \ + read ver <${srcdir}/VERSION; \ + echo $$ver | tr -d '\012'; \ + date +_%Y_%m_%d; \ + else \ + cat ${srcdir}/VERSION; \ + fi | sed -e 's/.*/const char version[] = "&";/' > $@ + +install: all + [ -d $(DESTDIR)$(sbindir) ] || \ + (mkdir -p $(DESTDIR)$(sbindir); chmod 755 $(DESTDIR)$(sbindir)) + $(INSTALL_PROGRAM) $(PROG) $(DESTDIR)$(sbindir)/$(PROG) + $(INSTALL_PROGRAM) $(PROG) $(DESTDIR)$(sbindir)/$(PROG).`cat ${srcdir}/VERSION` + [ -d $(DESTDIR)$(mandir)/man1 ] || \ + (mkdir -p $(DESTDIR)$(mandir)/man1; chmod 755 $(DESTDIR)$(mandir)/man1) + $(INSTALL_DATA) $(PROG).1 $(DESTDIR)$(mandir)/man1/$(PROG).1 + +uninstall: + rm -f $(DESTDIR)$(sbindir)/$(PROG) + rm -f $(DESTDIR)$(mandir)/man1/$(PROG).1 + +lint: $(GENSRC) + lint -hbxn $(SRC) | \ + grep -v 'struct/union .* never defined' | \ + grep -v 'possible pointer alignment problem' + +clean: + rm -f $(CLEANFILES) $(PROG)-`cat VERSION`.tar.gz + +distclean: + rm -f $(CLEANFILES) Makefile config.cache config.log config.status \ + config.h gnuc.h os-proto.h stamp-h stamp-h.in $(PROG).1 + rm -rf autom4te.cache + +check: tcpdump + (cd tests && ./TESTrun.sh) + +tags: $(TAGFILES) + ctags -wtd $(TAGFILES) + +TAGS: $(TAGFILES) + etags $(TAGFILES) + +releasetar: + @cwd=`pwd` ; dir=`basename $$cwd` ; name=$(PROG)-`cat VERSION` ; \ + mkdir $$name; \ + tar cf - $(CSRC) $(HDR) $(LIBNETDISSECT_SRC) $(EXTRA_DIST) | (cd $$name; tar xf -); \ + tar -c -z -f $$name.tar.gz $$name; \ + rm -rf $$name + +depend: $(GENSRC) + ${srcdir}/mkdep -c $(CC) $(DEFS) $(INCLS) $(SRC)
diff --git a/tcpdump-4.3.0/README b/tcpdump-4.3.0/README new file mode 100644 index 0000000..ed657c1 --- /dev/null +++ b/tcpdump-4.3.0/README
@@ -0,0 +1,233 @@ +@(#) $Header: /tcpdump/master/tcpdump/README,v 1.68 2008-12-15 00:05:27 guy Exp $ (LBL) + +TCPDUMP 4.x.y +Now maintained by "The Tcpdump Group" +See www.tcpdump.org + +Please send inquiries/comments/reports to: + tcpdump-workers@lists.tcpdump.org + +Anonymous Git is available via: + git clone git://bpf.tcpdump.org/tcpdump + +Version 4.x.y of TCPDUMP can be retrieved with the CVS tag "tcpdump_4_xrely": + cvs -d :pserver:cvs.tcpdump.org:/tcpdump/master checkout -r tcpdump_4_xrely tcpdump + +Please submit patches against the master copy to the tcpdump project on +sourceforge.net. + +formerly from Lawrence Berkeley National Laboratory + Network Research Group <tcpdump@ee.lbl.gov> + ftp://ftp.ee.lbl.gov/tcpdump.tar.Z (3.4) + +This directory contains source code for tcpdump, a tool for network +monitoring and data acquisition. This software was originally +developed by the Network Research Group at the Lawrence Berkeley +National Laboratory. The original distribution is available via +anonymous ftp to ftp.ee.lbl.gov, in tcpdump.tar.Z. More recent +development is performed at tcpdump.org, http://www.tcpdump.org/ + +Tcpdump uses libpcap, a system-independent interface for user-level +packet capture. Before building tcpdump, you must first retrieve and +build libpcap, also originally from LBL and now being maintained by +tcpdump.org; see http://www.tcpdump.org/ . + +Once libpcap is built (either install it or make sure it's in +../libpcap), you can build tcpdump using the procedure in the INSTALL +file. + +The program is loosely based on SMI's "etherfind" although none of the +etherfind code remains. It was originally written by Van Jacobson as +part of an ongoing research project to investigate and improve tcp and +internet gateway performance. The parts of the program originally +taken from Sun's etherfind were later re-written by Steven McCanne of +LBL. To insure that there would be no vestige of proprietary code in +tcpdump, Steve wrote these pieces from the specification given by the +manual entry, with no access to the source of tcpdump or etherfind. + +Over the past few years, tcpdump has been steadily improved by the +excellent contributions from the Internet community (just browse +through the CHANGES file). We are grateful for all the input. + +Richard Stevens gives an excellent treatment of the Internet protocols +in his book ``TCP/IP Illustrated, Volume 1''. If you want to learn more +about tcpdump and how to interpret its output, pick up this book. + +Some tools for viewing and analyzing tcpdump trace files are available +from the Internet Traffic Archive: + + http://www.acm.org/sigcomm/ITA/ + +Another tool that tcpdump users might find useful is tcpslice: + + ftp://ftp.ee.lbl.gov/tcpslice.tar.Z + +It is a program that can be used to extract portions of tcpdump binary +trace files. See the above distribution for further details and +documentation. + +Problems, bugs, questions, desirable enhancements, etc. should be sent +to the address "tcpdump-workers@lists.tcpdump.org". Bugs, support +requests, and feature requests may also be submitted on the SourceForge +site for tcpdump at + + http://sourceforge.net/projects/tcpdump/ + +Source code contributions, etc. should be sent to the email address +submitted as patches on the SourceForge site for tcpdump. + +Current versions can be found at www.tcpdump.org, or the SourceForge +site for tcpdump. + + - The TCPdump team + +original text by: Steve McCanne, Craig Leres, Van Jacobson + +------------------------------------- +This directory also contains some short awk programs intended as +examples of ways to reduce tcpdump data when you're tracking +particular network problems: + +send-ack.awk + Simplifies the tcpdump trace for an ftp (or other unidirectional + tcp transfer). Since we assume that one host only sends and + the other only acks, all address information is left off and + we just note if the packet is a "send" or an "ack". + + There is one output line per line of the original trace. + Field 1 is the packet time in decimal seconds, relative + to the start of the conversation. Field 2 is delta-time + from last packet. Field 3 is packet type/direction. + "Send" means data going from sender to receiver, "ack" + means an ack going from the receiver to the sender. A + preceding "*" indicates that the data is a retransmission. + A preceding "-" indicates a hole in the sequence space + (i.e., missing packet(s)), a "#" means an odd-size (not max + seg size) packet. Field 4 has the packet flags + (same format as raw trace). Field 5 is the sequence + number (start seq. num for sender, next expected seq number + for acks). The number in parens following an ack is + the delta-time from the first send of the packet to the + ack. A number in parens following a send is the + delta-time from the first send of the packet to the + current send (on duplicate packets only). Duplicate + sends or acks have a number in square brackets showing + the number of duplicates so far. + + Here is a short sample from near the start of an ftp: + 3.00 0.20 send . 512 + 3.20 0.20 ack . 1024 (0.20) + 3.20 0.00 send P 1024 + 3.40 0.20 ack . 1536 (0.20) + 3.80 0.40 * send . 0 (3.80) [2] + 3.82 0.02 * ack . 1536 (0.62) [2] + Three seconds into the conversation, bytes 512 through 1023 + were sent. 200ms later they were acked. Shortly thereafter + bytes 1024-1535 were sent and again acked after 200ms. + Then, for no apparent reason, 0-511 is retransmitted, 3.8 + seconds after its initial send (the round trip time for this + ftp was 1sec, +-500ms). Since the receiver is expecting + 1536, 1536 is re-acked when 0 arrives. + +packetdat.awk + Computes chunk summary data for an ftp (or similar + unidirectional tcp transfer). [A "chunk" refers to + a chunk of the sequence space -- essentially the packet + sequence number divided by the max segment size.] + + A summary line is printed showing the number of chunks, + the number of packets it took to send that many chunks + (if there are no lost or duplicated packets, the number + of packets should equal the number of chunks) and the + number of acks. + + Following the summary line is one line of information + per chunk. The line contains eight fields: + 1 - the chunk number + 2 - the start sequence number for this chunk + 3 - time of first send + 4 - time of last send + 5 - time of first ack + 6 - time of last ack + 7 - number of times chunk was sent + 8 - number of times chunk was acked + (all times are in decimal seconds, relative to the start + of the conversation.) + + As an example, here is the first part of the output for + an ftp trace: + + # 134 chunks. 536 packets sent. 508 acks. + 1 1 0.00 5.80 0.20 0.20 4 1 + 2 513 0.28 6.20 0.40 0.40 4 1 + 3 1025 1.16 6.32 1.20 1.20 4 1 + 4 1561 1.86 15.00 2.00 2.00 6 1 + 5 2049 2.16 15.44 2.20 2.20 5 1 + 6 2585 2.64 16.44 2.80 2.80 5 1 + 7 3073 3.00 16.66 3.20 3.20 4 1 + 8 3609 3.20 17.24 3.40 5.82 4 11 + 9 4097 6.02 6.58 6.20 6.80 2 5 + + This says that 134 chunks were transferred (about 70K + since the average packet size was 512 bytes). It took + 536 packets to transfer the data (i.e., on the average + each chunk was transmitted four times). Looking at, + say, chunk 4, we see it represents the 512 bytes of + sequence space from 1561 to 2048. It was first sent + 1.86 seconds into the conversation. It was last + sent 15 seconds into the conversation and was sent + a total of 6 times (i.e., it was retransmitted every + 2 seconds on the average). It was acked once, 140ms + after it first arrived. + +stime.awk +atime.awk + Output one line per send or ack, respectively, in the form + <time> <seq. number> + where <time> is the time in seconds since the start of the + transfer and <seq. number> is the sequence number being sent + or acked. I typically plot this data looking for suspicious + patterns. + + +The problem I was looking at was the bulk-data-transfer +throughput of medium delay network paths (1-6 sec. round trip +time) under typical DARPA Internet conditions. The trace of the +ftp transfer of a large file was used as the raw data source. +The method was: + + - On a local host (but not the Sun running tcpdump), connect to + the remote ftp. + + - On the monitor Sun, start the trace going. E.g., + tcpdump host local-host and remote-host and port ftp-data >tracefile + + - On local, do either a get or put of a large file (~500KB), + preferably to the null device (to minimize effects like + closing the receive window while waiting for a disk write). + + - When transfer is finished, stop tcpdump. Use awk to make up + two files of summary data (maxsize is the maximum packet size, + tracedata is the file of tcpdump tracedata): + awk -f send-ack.awk packetsize=avgsize tracedata >sa + awk -f packetdat.awk packetsize=avgsize tracedata >pd + + - While the summary data files are printing, take a look at + how the transfer behaved: + awk -f stime.awk tracedata | xgraph + (90% of what you learn seems to happen in this step). + + - Do all of the above steps several times, both directions, + at different times of day, with different protocol + implementations on the other end. + + - Using one of the Unix data analysis packages (in my case, + S and Gary Perlman's Unix|Stat), spend a few months staring + at the data. + + - Change something in the local protocol implementation and + redo the steps above. + + - Once a week, tell your funding agent that you're discovering + wonderful things and you'll write up that research report + "real soon now".
diff --git a/tcpdump-4.3.0/Readme.Win32 b/tcpdump-4.3.0/Readme.Win32 new file mode 100644 index 0000000..fdf8b12 --- /dev/null +++ b/tcpdump-4.3.0/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/tcpdump-4.3.0/VERSION b/tcpdump-4.3.0/VERSION new file mode 100644 index 0000000..8089590 --- /dev/null +++ b/tcpdump-4.3.0/VERSION
@@ -0,0 +1 @@ +4.3.0
diff --git a/tcpdump-4.3.0/acconfig.h b/tcpdump-4.3.0/acconfig.h new file mode 100644 index 0000000..9eb54f8 --- /dev/null +++ b/tcpdump-4.3.0/acconfig.h
@@ -0,0 +1,75 @@ +/* "generated automatically" means DO NOT MAKE CHANGES TO config.h.in -- + * make them to acconfig.h and rerun autoheader */ +@TOP@ + +/* Define if you enable IPv6 support */ +#undef INET6 + +/* Define if you enable support for the libsmi. */ +#undef LIBSMI + +/* define if you have the addrinfo function. */ +#undef HAVE_ADDRINFO + +/* define if you need to include missing/addrinfoh.h. */ +#undef NEED_ADDRINFO_H + +/* define ifyou have the h_errno variable. */ +#undef HAVE_H_ERRNO + +/* 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 libpcap has pcap_dump_ftell() */ +#undef HAVE_PCAP_DUMP_FTELL + +/* define if you have getrpcbynumber() */ +#undef HAVE_GETRPCBYNUMBER + +/* Workaround for missing 64-bit formats */ +#undef PRId64 +#undef PRIo64 +#undef PRIx64 +#undef PRIu64 + +/* Whether or not to include the possibly-buggy SMB printer */ +#undef TCPDUMP_DO_SMB + +/* 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 + +/* define if should drop privileges by default */ +#undef WITH_USER + +/* define if should chroot when dropping privileges */ +#undef WITH_CHROOT
diff --git a/tcpdump-4.3.0/aclocal.m4 b/tcpdump-4.3.0/aclocal.m4 new file mode 100644 index 0000000..7573fae --- /dev/null +++ b/tcpdump-4.3.0/aclocal.m4
@@ -0,0 +1,1216 @@ +dnl @(#) $Header: /tcpdump/master/tcpdump/aclocal.m4,v 1.116 2008-09-25 21:45:50 guy Exp $ (LBL) +dnl +dnl Copyright (c) 1995, 1996, 1997, 1998 +dnl The Regents of the University of California. All rights reserved. +dnl +dnl Redistribution and use in source and binary forms, with or without +dnl modification, are permitted provided that: (1) source code distributions +dnl retain the above copyright notice and this paragraph in its entirety, (2) +dnl distributions including binary code include the above copyright notice and +dnl this paragraph in its entirety in the documentation or other materials +dnl provided with the distribution, and (3) all advertising materials mentioning +dnl features or use of this software display the following acknowledgement: +dnl ``This product includes software developed by the University of California, +dnl Lawrence Berkeley Laboratory and its contributors.'' Neither the name of +dnl the University nor the names of its contributors may be used to endorse +dnl or promote products derived from this software without specific prior +dnl written permission. +dnl THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED +dnl WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF +dnl MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +dnl +dnl LBL autoconf macros +dnl + +dnl +dnl Do whatever AC_LBL_C_INIT work is necessary before using AC_PROG_CC. +dnl +dnl It appears that newer versions of autoconf (2.64 and later) will, +dnl if you use AC_TRY_COMPILE in a macro, stick AC_PROG_CC at the +dnl beginning of the macro, even if the macro itself calls AC_PROG_CC. +dnl See the "Prerequisite Macros" and "Expanded Before Required" sections +dnl in the Autoconf documentation. +dnl +dnl This causes a steaming heap of fail in our case, as we were, in +dnl AC_LBL_C_INIT, doing the tests we now do in AC_LBL_C_INIT_BEFORE_CC, +dnl calling AC_PROG_CC, and then doing the tests we now do in +dnl AC_LBL_C_INIT. Now, we run AC_LBL_C_INIT_BEFORE_CC, AC_PROG_CC, +dnl and AC_LBL_C_INIT at the top level. +dnl +AC_DEFUN(AC_LBL_C_INIT_BEFORE_CC, + [AC_PREREQ(2.50) + AC_BEFORE([$0], [AC_LBL_C_INIT]) + AC_BEFORE([$0], [AC_PROG_CC]) + AC_BEFORE([$0], [AC_LBL_FIXINCLUDES]) + AC_BEFORE([$0], [AC_LBL_DEVEL]) + AC_ARG_WITH(gcc, [ --without-gcc don't use gcc]) + $1="-O" + $2="" + if test "${srcdir}" != "." ; then + $2="-I$srcdir" + fi + if test "${CFLAGS+set}" = set; then + LBL_CFLAGS="$CFLAGS" + fi + if test -z "$CC" ; then + case "$host_os" in + + bsdi*) + AC_CHECK_PROG(SHLICC2, shlicc2, yes, no) + if test $SHLICC2 = yes ; then + CC=shlicc2 + export CC + fi + ;; + esac + fi + if test -z "$CC" -a "$with_gcc" = no ; then + CC=cc + export CC + fi +]) + +dnl +dnl Determine which compiler we're using (cc or gcc) +dnl If using gcc, determine the version number +dnl If using cc, require that it support ansi prototypes +dnl If using gcc, use -O2 (otherwise use -O) +dnl If using cc, explicitly specify /usr/local/include +dnl +dnl usage: +dnl +dnl AC_LBL_C_INIT(copt, incls) +dnl +dnl results: +dnl +dnl $1 (copt set) +dnl $2 (incls set) +dnl CC +dnl LDFLAGS +dnl ac_cv_lbl_gcc_vers +dnl LBL_CFLAGS +dnl +AC_DEFUN(AC_LBL_C_INIT, + [AC_PREREQ(2.50) + AC_BEFORE([$0], [AC_LBL_FIXINCLUDES]) + AC_BEFORE([$0], [AC_LBL_DEVEL]) + AC_BEFORE([$0], [AC_LBL_SHLIBS_INIT]) + if test "$GCC" = yes ; then + if test "$SHLICC2" = yes ; then + ac_cv_lbl_gcc_vers=2 + $1="-O2" + else + AC_MSG_CHECKING(gcc version) + AC_CACHE_VAL(ac_cv_lbl_gcc_vers, + ac_cv_lbl_gcc_vers=`$CC -v 2>&1 | \ + sed -e '/^gcc version /!d' \ + -e 's/^gcc version //' \ + -e 's/ .*//' -e 's/^[[[^0-9]]]*//' \ + -e 's/\..*//'`) + AC_MSG_RESULT($ac_cv_lbl_gcc_vers) + if test $ac_cv_lbl_gcc_vers -gt 1 ; then + $1="-O2" + fi + fi + else + AC_MSG_CHECKING(that $CC handles ansi prototypes) + AC_CACHE_VAL(ac_cv_lbl_cc_ansi_prototypes, + AC_TRY_COMPILE( + [#include <sys/types.h>], + [int frob(int, char *)], + ac_cv_lbl_cc_ansi_prototypes=yes, + ac_cv_lbl_cc_ansi_prototypes=no)) + AC_MSG_RESULT($ac_cv_lbl_cc_ansi_prototypes) + if test $ac_cv_lbl_cc_ansi_prototypes = no ; then + case "$host_os" in + + hpux*) + AC_MSG_CHECKING(for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE)) + savedcflags="$CFLAGS" + CFLAGS="-Aa -D_HPUX_SOURCE $CFLAGS" + AC_CACHE_VAL(ac_cv_lbl_cc_hpux_cc_aa, + AC_TRY_COMPILE( + [#include <sys/types.h>], + [int frob(int, char *)], + ac_cv_lbl_cc_hpux_cc_aa=yes, + ac_cv_lbl_cc_hpux_cc_aa=no)) + AC_MSG_RESULT($ac_cv_lbl_cc_hpux_cc_aa) + if test $ac_cv_lbl_cc_hpux_cc_aa = no ; then + AC_MSG_ERROR(see the INSTALL doc for more info) + fi + CFLAGS="$savedcflags" + $1="-Aa $$1" + AC_DEFINE(_HPUX_SOURCE,1,[needed on HP-UX]) + ;; + + osf*) + AC_MSG_CHECKING(for ansi mode in DEC compiler ($CC -std1)) + savedcflags="$CFLAGS" + CFLAGS="-std1" + AC_CACHE_VAL(ac_cv_lbl_cc_osf1_cc_std1, + AC_TRY_COMPILE( + [#include <sys/types.h>], + [int frob(int, char *)], + ac_cv_lbl_cc_osf1_cc_std1=yes, + ac_cv_lbl_cc_osf1_cc_std1=no)) + AC_MSG_RESULT($ac_cv_lbl_cc_osf1_cc_std1) + if test $ac_cv_lbl_cc_osf1_cc_std1 = no ; then + AC_MSG_ERROR(see the INSTALL doc for more info) + fi + CFLAGS="$savedcflags" + $1="-std1 $$1" + ;; + + *) + AC_MSG_ERROR(see the INSTALL doc for more info) + ;; + esac + fi + $2="$$2 -I/usr/local/include" + LDFLAGS="$LDFLAGS -L/usr/local/lib" + + case "$host_os" in + + irix*) + $1="$$1 -xansi -signed -O" + ;; + + osf*) + # + # Presumed to be DEC OSF/1, Digital UNIX, or + # Tru64 UNIX. + # + $1="$$1 -O" + ;; + + ultrix*) + AC_MSG_CHECKING(that Ultrix $CC hacks const in prototypes) + AC_CACHE_VAL(ac_cv_lbl_cc_const_proto, + AC_TRY_COMPILE( + [#include <sys/types.h>], + [struct a { int b; }; + void c(const struct a *)], + ac_cv_lbl_cc_const_proto=yes, + ac_cv_lbl_cc_const_proto=no)) + AC_MSG_RESULT($ac_cv_lbl_cc_const_proto) + if test $ac_cv_lbl_cc_const_proto = no ; then + AC_DEFINE(const,[], + [to handle Ultrix compilers that don't support const in prototypes]) + fi + ;; + esac + fi +]) + +# +# Try compiling a sample of the type of code that appears in +# gencode.c with "inline", "__inline__", and "__inline". +# +# 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. +# +# Make sure we use the V_CCOPT flags, because some of those might +# disable inlining. +# +AC_DEFUN(AC_LBL_C_INLINE, + [AC_MSG_CHECKING(for inline) + save_CFLAGS="$CFLAGS" + CFLAGS="$V_CCOPT" + AC_CACHE_VAL(ac_cv_lbl_inline, [ + ac_cv_lbl_inline="" + ac_lbl_cc_inline=no + for ac_lbl_inline in inline __inline__ __inline + do + AC_TRY_COMPILE( + [#define inline $ac_lbl_inline + static inline struct iltest *foo(void); + struct iltest { + int iltest1; + int iltest2; + }; + + static inline struct iltest * + foo() + { + static struct iltest xxx; + + return &xxx; + }],,ac_lbl_cc_inline=yes,) + if test "$ac_lbl_cc_inline" = yes ; then + break; + fi + done + if test "$ac_lbl_cc_inline" = yes ; then + ac_cv_lbl_inline=$ac_lbl_inline + fi]) + CFLAGS="$save_CFLAGS" + if test ! -z "$ac_cv_lbl_inline" ; then + AC_MSG_RESULT($ac_cv_lbl_inline) + else + AC_MSG_RESULT(no) + fi + AC_DEFINE_UNQUOTED(inline, $ac_cv_lbl_inline, [Define as token for inline if inlining supported])]) + +dnl +dnl Use pfopen.c if available and pfopen() not in standard libraries +dnl Require libpcap +dnl Look for libpcap in .. +dnl Use the installed libpcap if there is no local version +dnl +dnl usage: +dnl +dnl AC_LBL_LIBPCAP(pcapdep, incls) +dnl +dnl results: +dnl +dnl $1 (pcapdep set) +dnl $2 (incls appended) +dnl LIBS +dnl LBL_LIBS +dnl +AC_DEFUN(AC_LBL_LIBPCAP, + [AC_REQUIRE([AC_LBL_LIBRARY_NET]) + dnl + dnl save a copy before locating libpcap.a + dnl + LBL_LIBS="$LIBS" + pfopen=/usr/examples/packetfilter/pfopen.c + if test -f $pfopen ; then + AC_CHECK_FUNCS(pfopen) + if test $ac_cv_func_pfopen = "no" ; then + AC_MSG_RESULT(Using $pfopen) + LIBS="$LIBS $pfopen" + fi + fi + AC_MSG_CHECKING(for local pcap library) + libpcap=FAIL + lastdir=FAIL + places=`ls $srcdir/.. | sed -e 's,/$,,' -e "s,^,$srcdir/../," | \ + egrep '/libpcap-[[0-9]]+\.[[0-9]]+(\.[[0-9]]*)?([[ab]][[0-9]]*|-PRE-GIT)?$'` + for dir in $places $srcdir/../libpcap $srcdir/libpcap ; do + basedir=`echo $dir | sed -e 's/[[ab]][[0-9]]*$//' | \ + sed -e 's/-PRE-GIT$//' ` + if test $lastdir = $basedir ; then + dnl skip alphas when an actual release is present + continue; + fi + lastdir=$dir + if test -r $dir/libpcap.a ; then + libpcap=$dir/libpcap.a + d=$dir + dnl continue and select the last one that exists + fi + done + if test $libpcap = FAIL ; then + AC_MSG_RESULT(not found) + + # + # Look for pcap-config. + # + AC_PATH_TOOL(PCAP_CONFIG, pcap-config) + if test -n "$PCAP_CONFIG" ; then + # + # Found - use it to get the include flags for + # libpcap and the flags to link with libpcap. + # + # Please read section 11.6 "Shell Substitutions" + # in the autoconf manual before doing anything + # to this that involves quoting. Especially note + # the statement "There is just no portable way to use + # double-quoted strings inside double-quoted back-quoted + # expressions (pfew!)." + # + cflags=`"$PCAP_CONFIG" --cflags` + $2="$cflags $$2" + libpcap=`"$PCAP_CONFIG" --libs` + else + # + # Not found; look for pcap. + # + AC_CHECK_LIB(pcap, main, libpcap="-lpcap") + if test $libpcap = FAIL ; then + AC_MSG_ERROR(see the INSTALL doc for more info) + fi + dnl + dnl Some versions of Red Hat Linux put "pcap.h" in + dnl "/usr/include/pcap"; had the LBL folks done so, + dnl that would have been a good idea, but for + dnl the Red Hat folks to do so just breaks source + dnl compatibility with other systems. + dnl + dnl We work around this by assuming that, as we didn't + dnl find a local libpcap, libpcap is in /usr/lib or + dnl /usr/local/lib and that the corresponding header + dnl file is under one of those directories; if we don't + dnl find it in either of those directories, we check to + dnl see if it's in a "pcap" subdirectory of them and, + dnl if so, add that subdirectory to the "-I" list. + dnl + dnl (We now also put pcap.h in /usr/include/pcap, but we + dnl leave behind a /usr/include/pcap.h that includes it, + dnl so you can still just include <pcap.h>.) + dnl + AC_MSG_CHECKING(for extraneous pcap header directories) + if test \( ! -r /usr/local/include/pcap.h \) -a \ + \( ! -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 + AC_MSG_RESULT(not found) + else + $2="-I$d $$2" + AC_MSG_RESULT(found -- -I$d added) + fi + fi + else + $1=$libpcap + places=`ls $srcdir/.. | sed -e 's,/$,,' -e "s,^,$srcdir/../," | \ + egrep '/libpcap-[[0-9]]*.[[0-9]]*(.[[0-9]]*)?([[ab]][[0-9]]*)?$'` + if test -r $d/pcap.h; then + $2="-I$d $$2" + elif test -r $places/pcap.h; then + $2="-I$places $$2" + else + AC_MSG_ERROR(cannot find pcap.h, see INSTALL) + fi + AC_MSG_RESULT($libpcap) + AC_PATH_PROG(PCAP_CONFIG, pcap-config,, $d) + if test -n "$PCAP_CONFIG"; then + # + # The libpcap directory has a pcap-config script. + # Use it to get any additioal libraries needed + # to link with the libpcap archive library in + # that directory. + # + # Please read section 11.6 "Shell Substitutions" + # in the autoconf manual before doing anything + # to this that involves quoting. Especially note + # the statement "There is just no portable way to use + # double-quoted strings inside double-quoted back-quoted + # expressions (pfew!)." + # + additional_libs=`"$PCAP_CONFIG" --additional-libs --static` + libpcap="$libpcap $additional_libs" + fi + fi + LIBS="$libpcap $LIBS" + if ! test -n "$PCAP_CONFIG" ; then + # + # We don't have pcap-config; find out any additional link flags + # we need. (If we have pcap-config, we assume it tells us what + # we need.) + # + case "$host_os" in + + aix*) + # + # If libpcap is DLPI-based, we have to use /lib/pse.exp if + # present, as we use the STREAMS routines. + # + # (XXX - true only if we're linking with a static libpcap?) + # + pseexe="/lib/pse.exp" + AC_MSG_CHECKING(for $pseexe) + if test -f $pseexe ; then + AC_MSG_RESULT(yes) + LIBS="$LIBS -I:$pseexe" + fi + + # + # If libpcap is BPF-based, we need "-lodm" and "-lcfg", as + # we use them to load the BPF module. + # + # (XXX - true only if we're linking with a static libpcap?) + # + LIBS="$LIBS -lodm -lcfg" + ;; + esac + fi + + dnl + dnl Check for "pcap_loop()", to make sure we found a working + dnl libpcap and have all the right other libraries with which + dnl to link. (Otherwise, the checks below will fail, not + dnl because the routines are missing from the library, but + dnl because we aren't linking properly with libpcap, and + dnl that will cause confusing errors at build time.) + dnl + AC_CHECK_FUNC(pcap_loop,, + [ + AC_MSG_ERROR( +[Report this to tcpdump-workers@lists.tcpdump.org, and include the +config.log file in your report. If you have downloaded libpcap from +tcpdump.org, and built it yourself, please also include the config.log +file from the libpcap source directory, the Makefile from the libpcap +source directory, and the output of the make process for libpcap, as +this could be a problem with the libpcap that was built, and we will +not be able to determine why this is happening, and thus will not be +able to fix it, without that information, as we have not been able to +reproduce this problem ourselves.]) + ]) + + dnl + dnl Check for "pcap_list_datalinks()", "pcap_set_datalink()", + dnl and "pcap_datalink_name_to_val()", and use substitute versions + dnl if they're not present. + dnl + AC_CHECK_FUNC(pcap_list_datalinks, + AC_DEFINE(HAVE_PCAP_LIST_DATALINKS), + [ + AC_LIBOBJ(datalinks) + ]) + AC_CHECK_FUNC(pcap_set_datalink, + AC_DEFINE(HAVE_PCAP_SET_DATALINK)) + AC_CHECK_FUNC(pcap_datalink_name_to_val, + [ + AC_DEFINE(HAVE_PCAP_DATALINK_NAME_TO_VAL) + AC_CHECK_FUNC(pcap_datalink_val_to_description, + AC_DEFINE(HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION), + [ + AC_LIBOBJ(dlnames) + ]) + ], + [ + AC_LIBOBJ(dlnames) + ]) + + dnl + dnl Check for "pcap_breakloop()"; you can't substitute for it if + dnl it's absent (it has hooks into the live capture routines), + dnl so just define the HAVE_ value if it's there. + dnl + AC_CHECK_FUNCS(pcap_breakloop) + + dnl + dnl Check for "pcap_dump_ftell()" and use a substitute version + dnl if it's not present. + AC_CHECK_FUNC(pcap_dump_ftell, + AC_DEFINE(HAVE_PCAP_DUMP_FTELL), + [ + AC_LIBOBJ(pcap_dump_ftell) + ]) +]) + +dnl +dnl Define RETSIGTYPE and RETSIGVAL +dnl +dnl usage: +dnl +dnl AC_LBL_TYPE_SIGNAL +dnl +dnl results: +dnl +dnl RETSIGTYPE (defined) +dnl RETSIGVAL (defined) +dnl +AC_DEFUN(AC_LBL_TYPE_SIGNAL, + [AC_BEFORE([$0], [AC_LBL_LIBPCAP]) + AC_TYPE_SIGNAL + if test "$ac_cv_type_signal" = void ; then + AC_DEFINE(RETSIGVAL,[],[return value of signal handlers]) + else + AC_DEFINE(RETSIGVAL,(0),[return value of signal handlers]) + fi + case "$host_os" in + + irix*) + AC_DEFINE(_BSD_SIGNALS,1,[get BSD semantics on Irix]) + ;; + + *) + dnl prefer sigaction() to sigset() + AC_CHECK_FUNCS(sigaction) + if test $ac_cv_func_sigaction = no ; then + AC_CHECK_FUNCS(sigset) + fi + ;; + esac]) + +dnl +dnl If using gcc, make sure we have ANSI ioctl definitions +dnl +dnl usage: +dnl +dnl AC_LBL_FIXINCLUDES +dnl +AC_DEFUN(AC_LBL_FIXINCLUDES, + [if test "$GCC" = yes ; then + AC_MSG_CHECKING(for ANSI ioctl definitions) + AC_CACHE_VAL(ac_cv_lbl_gcc_fixincludes, + AC_TRY_COMPILE( + [/* + * This generates a "duplicate case value" when fixincludes + * has not be run. + */ +# include <sys/types.h> +# include <sys/time.h> +# include <sys/ioctl.h> +# ifdef HAVE_SYS_IOCCOM_H +# include <sys/ioccom.h> +# endif], + [switch (0) { + case _IO('A', 1):; + case _IO('B', 1):; + }], + ac_cv_lbl_gcc_fixincludes=yes, + ac_cv_lbl_gcc_fixincludes=no)) + AC_MSG_RESULT($ac_cv_lbl_gcc_fixincludes) + if test $ac_cv_lbl_gcc_fixincludes = no ; then + # Don't cache failure + unset ac_cv_lbl_gcc_fixincludes + AC_MSG_ERROR(see the INSTALL for more info) + fi + fi]) + +dnl +dnl Checks to see if union wait is used with WEXITSTATUS() +dnl +dnl usage: +dnl +dnl AC_LBL_UNION_WAIT +dnl +dnl results: +dnl +dnl DECLWAITSTATUS (defined) +dnl +AC_DEFUN(AC_LBL_UNION_WAIT, + [AC_MSG_CHECKING(if union wait is used) + AC_CACHE_VAL(ac_cv_lbl_union_wait, + AC_TRY_COMPILE([ +# include <sys/types.h> +# include <sys/wait.h>], + [int status; + u_int i = WEXITSTATUS(status); + u_int j = waitpid(0, &status, 0);], + ac_cv_lbl_union_wait=no, + ac_cv_lbl_union_wait=yes)) + AC_MSG_RESULT($ac_cv_lbl_union_wait) + if test $ac_cv_lbl_union_wait = yes ; then + AC_DEFINE(DECLWAITSTATUS,union wait,[type for wait]) + else + AC_DEFINE(DECLWAITSTATUS,int,[type for wait]) + fi]) + +dnl +dnl Checks to see if the sockaddr struct has the 4.4 BSD sa_len member +dnl +dnl usage: +dnl +dnl AC_LBL_SOCKADDR_SA_LEN +dnl +dnl results: +dnl +dnl HAVE_SOCKADDR_SA_LEN (defined) +dnl +AC_DEFUN(AC_LBL_SOCKADDR_SA_LEN, + [AC_MSG_CHECKING(if sockaddr struct has the sa_len member) + AC_CACHE_VAL(ac_cv_lbl_sockaddr_has_sa_len, + AC_TRY_COMPILE([ +# include <sys/types.h> +# include <sys/socket.h>], + [u_int i = sizeof(((struct sockaddr *)0)->sa_len)], + ac_cv_lbl_sockaddr_has_sa_len=yes, + ac_cv_lbl_sockaddr_has_sa_len=no)) + AC_MSG_RESULT($ac_cv_lbl_sockaddr_has_sa_len) + if test $ac_cv_lbl_sockaddr_has_sa_len = yes ; then + AC_DEFINE(HAVE_SOCKADDR_SA_LEN,1,[if struct sockaddr has the sa_len member]) + fi]) + +dnl +dnl Checks to see if -R is used +dnl +dnl usage: +dnl +dnl AC_LBL_HAVE_RUN_PATH +dnl +dnl results: +dnl +dnl ac_cv_lbl_have_run_path (yes or no) +dnl +AC_DEFUN(AC_LBL_HAVE_RUN_PATH, + [AC_MSG_CHECKING(for ${CC-cc} -R) + AC_CACHE_VAL(ac_cv_lbl_have_run_path, + [echo 'main(){}' > conftest.c + ${CC-cc} -o conftest conftest.c -R/a1/b2/c3 >conftest.out 2>&1 + if test ! -s conftest.out ; then + ac_cv_lbl_have_run_path=yes + else + ac_cv_lbl_have_run_path=no + fi + rm -f -r conftest*]) + AC_MSG_RESULT($ac_cv_lbl_have_run_path) + ]) + +dnl +dnl Check whether a given format can be used to print 64-bit integers +dnl +AC_DEFUN(AC_LBL_CHECK_64BIT_FORMAT, + [ + AC_MSG_CHECKING([whether %$1x can be used to format 64-bit integers]) + AC_RUN_IFELSE( + [ + AC_LANG_SOURCE( + [[ +# ifdef HAVE_INTTYPES_H + #include <inttypes.h> +# endif +# ifdef HAVE_SYS_BITYPES_H + #include <sys/bitypes.h> +# endif + #include <stdio.h> + #include <sys/types.h> + + main() + { + u_int64_t t = 1; + char strbuf[16+1]; + sprintf(strbuf, "%016$1x", t << 32); + if (strcmp(strbuf, "0000000100000000") == 0) + exit(0); + else + exit(1); + } + ]]) + ], + [ + AC_DEFINE(PRId64, "$1d") + AC_DEFINE(PRIo64, "$1o") + AC_DEFINE(PRIx64, "$1x") + AC_DEFINE(PRIu64, "$1u") + AC_MSG_RESULT(yes) + ], + [ + AC_MSG_RESULT(no) + $2 + ]) + ]) + +dnl +dnl Checks to see if unaligned memory accesses fail +dnl +dnl usage: +dnl +dnl AC_LBL_UNALIGNED_ACCESS +dnl +dnl results: +dnl +dnl LBL_ALIGN (DEFINED) +dnl +AC_DEFUN(AC_LBL_UNALIGNED_ACCESS, + [AC_MSG_CHECKING(if unaligned accesses fail) + AC_CACHE_VAL(ac_cv_lbl_unaligned_fail, + [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) + # + # 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*|bfin*|hp*|mips*|sh*|sparc*|ia64|nv1) + ac_cv_lbl_unaligned_fail=yes + ;; + + *) + cat >conftest.c <<EOF +# include <sys/types.h> +# include <sys/wait.h> +# include <stdio.h> + unsigned char a[[5]] = { 1, 2, 3, 4, 5 }; + main() { + unsigned int i; + pid_t pid; + int status; + /* avoid "core dumped" message */ + pid = fork(); + if (pid < 0) + exit(2); + if (pid > 0) { + /* parent */ + pid = waitpid(pid, &status, 0); + if (pid < 0) + exit(3); + exit(!WIFEXITED(status)); + } + /* child */ + i = *(unsigned int *)&a[[1]]; + printf("%d\n", i); + exit(0); + } +EOF + ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \ + conftest.c $LIBS >/dev/null 2>&1 + if test ! -x conftest ; then + dnl failed to compile for some reason + ac_cv_lbl_unaligned_fail=yes + else + ./conftest >conftest.out + if test ! -s conftest.out ; then + ac_cv_lbl_unaligned_fail=yes + else + ac_cv_lbl_unaligned_fail=no + fi + fi + rm -f -r conftest* core core.conftest + ;; + esac]) + AC_MSG_RESULT($ac_cv_lbl_unaligned_fail) + if test $ac_cv_lbl_unaligned_fail = yes ; then + AC_DEFINE(LBL_ALIGN,1,[if unaligned access fails]) + fi]) + +dnl +dnl If using gcc and the file .devel exists: +dnl Compile with -g (if supported) and -Wall +dnl If using gcc 2 or later, do extra prototype checking and some other +dnl checks +dnl If an os prototype include exists, symlink os-proto.h to it +dnl +dnl usage: +dnl +dnl AC_LBL_DEVEL(copt) +dnl +dnl results: +dnl +dnl $1 (copt appended) +dnl HAVE_OS_PROTO_H (defined) +dnl os-proto.h (symlinked) +dnl +AC_DEFUN(AC_LBL_DEVEL, + [rm -f os-proto.h + if test "${LBL_CFLAGS+set}" = set; then + $1="$$1 ${LBL_CFLAGS}" + fi + if test -f .devel ; then + if test "$GCC" = yes ; then + if test "${LBL_CFLAGS+set}" != set; then + if test "$ac_cv_prog_cc_g" = yes ; then + $1="-g $$1" + fi + $1="$$1 -Wall" + if test $ac_cv_lbl_gcc_vers -gt 1 ; then + $1="$$1 -Wmissing-prototypes -Wstrict-prototypes -Wwrite-strings -Wpointer-arith -W" + fi + fi + else + case "$host_os" in + + irix6*) + V_CCOPT="$V_CCOPT -n32" + ;; + + *) + ;; + esac + fi + os=`echo $host_os | sed -e 's/\([[0-9]][[0-9]]*\)[[^0-9]].*$/\1/'` + name="lbl/os-$os.h" + if test -f $name ; then + ln -s $name os-proto.h + AC_DEFINE(HAVE_OS_PROTO_H, 1, + [if there's an os_proto.h for this platform, to use additional prototypes]) + else + AC_MSG_WARN(can't find $name) + fi + fi]) + +dnl +dnl Improved version of AC_CHECK_LIB +dnl +dnl Thanks to John Hawkinson (jhawk@mit.edu) +dnl +dnl usage: +dnl +dnl AC_LBL_CHECK_LIB(LIBRARY, FUNCTION [, ACTION-IF-FOUND [, +dnl ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]]) +dnl +dnl results: +dnl +dnl LIBS +dnl +dnl XXX - "AC_LBL_LIBRARY_NET" was redone to use "AC_SEARCH_LIBS" +dnl rather than "AC_LBL_CHECK_LIB", so this isn't used any more. +dnl We keep it around for reference purposes in case it's ever +dnl useful in the future. +dnl + +define(AC_LBL_CHECK_LIB, +[AC_MSG_CHECKING([for $2 in -l$1]) +dnl Use a cache variable name containing the library, function +dnl name, and extra libraries to link with, because the test really is +dnl for library $1 defining function $2, when linked with potinal +dnl library $5, not just for library $1. Separate tests with the same +dnl $1 and different $2's or $5's may have different results. +ac_lib_var=`echo $1['_']$2['_']$5 | sed 'y%./+- %__p__%'` +AC_CACHE_VAL(ac_cv_lbl_lib_$ac_lib_var, +[ac_save_LIBS="$LIBS" +LIBS="-l$1 $5 $LIBS" +AC_TRY_LINK(dnl +ifelse([$2], [main], , dnl Avoid conflicting decl of main. +[/* Override any gcc2 internal prototype to avoid an error. */ +]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus +extern "C" +#endif +])dnl +[/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $2(); +]), + [$2()], + eval "ac_cv_lbl_lib_$ac_lib_var=yes", + eval "ac_cv_lbl_lib_$ac_lib_var=no") +LIBS="$ac_save_LIBS" +])dnl +if eval "test \"`echo '$ac_cv_lbl_lib_'$ac_lib_var`\" = yes"; then + AC_MSG_RESULT(yes) + ifelse([$3], , +[changequote(, )dnl + ac_tr_lib=HAVE_LIB`echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` +changequote([, ])dnl + AC_DEFINE_UNQUOTED($ac_tr_lib) + LIBS="-l$1 $LIBS" +], [$3]) +else + AC_MSG_RESULT(no) +ifelse([$4], , , [$4 +])dnl +fi +]) + +dnl +dnl AC_LBL_LIBRARY_NET +dnl +dnl This test is for network applications that need socket() and +dnl gethostbyname() -ish functions. Under Solaris, those applications +dnl need to link with "-lsocket -lnsl". Under IRIX, they need to link +dnl with "-lnsl" but should *not* link with "-lsocket" because +dnl libsocket.a breaks a number of things (for instance: +dnl gethostbyname() under IRIX 5.2, and snoop sockets under most +dnl versions of IRIX). +dnl +dnl Unfortunately, many application developers are not aware of this, +dnl and mistakenly write tests that cause -lsocket to be used under +dnl IRIX. It is also easy to write tests that cause -lnsl to be used +dnl under operating systems where neither are necessary (or useful), +dnl such as SunOS 4.1.4, which uses -lnsl for TLI. +dnl +dnl This test exists so that every application developer does not test +dnl this in a different, and subtly broken fashion. + +dnl It has been argued that this test should be broken up into two +dnl seperate tests, one for the resolver libraries, and one for the +dnl libraries necessary for using Sockets API. Unfortunately, the two +dnl are carefully intertwined and allowing the autoconf user to use +dnl them independantly potentially results in unfortunate ordering +dnl dependancies -- as such, such component macros would have to +dnl carefully use indirection and be aware if the other components were +dnl executed. Since other autoconf macros do not go to this trouble, +dnl and almost no applications use sockets without the resolver, this +dnl complexity has not been implemented. +dnl +dnl The check for libresolv is in case you are attempting to link +dnl statically and happen to have a libresolv.a lying around (and no +dnl libnsl.a). +dnl +AC_DEFUN(AC_LBL_LIBRARY_NET, [ + # 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: + AC_SEARCH_LIBS(gethostbyname, nsl socket resolv) + # 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 + AC_CHECK_LIB(socket, gethostbyname, + LIBS="-lsocket -lnsl $LIBS", , -lnsl) + fi + AC_SEARCH_LIBS(socket, socket, , + AC_CHECK_LIB(socket, socket, LIBS="-lsocket -lnsl $LIBS", , -lnsl)) + # DLPI needs putmsg under HPUX so test for -lstr while we're at it + AC_SEARCH_LIBS(putmsg, str) + ]) + +dnl Copyright (c) 1999 WIDE Project. All rights reserved. +dnl +dnl Redistribution and use in source and binary forms, with or without +dnl modification, are permitted provided that the following conditions +dnl are met: +dnl 1. Redistributions of source code must retain the above copyright +dnl notice, this list of conditions and the following disclaimer. +dnl 2. Redistributions in binary form must reproduce the above copyright +dnl notice, this list of conditions and the following disclaimer in the +dnl documentation and/or other materials provided with the distribution. +dnl 3. Neither the name of the project nor the names of its contributors +dnl may be used to endorse or promote products derived from this software +dnl without specific prior written permission. +dnl +dnl THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND +dnl ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +dnl IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +dnl ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE +dnl FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +dnl DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +dnl OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +dnl HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +dnl LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +dnl OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +dnl SUCH DAMAGE. + +dnl +dnl Checks to see if AF_INET6 is defined +AC_DEFUN(AC_CHECK_AF_INET6, [ + AC_MSG_CHECKING(for AF_INET6) + AC_CACHE_VAL($1, + AC_TRY_COMPILE([ +# include <sys/types.h> +# include <sys/socket.h>], + [int a = AF_INET6], + $1=yes, + $1=no)) + AC_MSG_RESULT($$1) + if test $$1 = yes ; then + AC_DEFINE(HAVE_AF_INET6) + fi +]) + +dnl +dnl Checks to see if the sockaddr struct has the 4.4 BSD sa_len member +dnl borrowed from LBL libpcap +AC_DEFUN(AC_CHECK_SA_LEN, [ + AC_MSG_CHECKING(if sockaddr struct has sa_len member) + AC_CACHE_VAL($1, + AC_TRY_COMPILE([ +# include <sys/types.h> +# include <sys/socket.h>], + [u_int i = sizeof(((struct sockaddr *)0)->sa_len)], + $1=yes, + $1=no)) + AC_MSG_RESULT($$1) + if test $$1 = yes ; then + AC_DEFINE(HAVE_SOCKADDR_SA_LEN) + fi +]) + +dnl +dnl Checks for addrinfo structure +AC_DEFUN(AC_STRUCT_ADDRINFO, [ + AC_MSG_CHECKING(for addrinfo) + AC_CACHE_VAL($1, + AC_TRY_COMPILE([ +# include <netdb.h>], + [struct addrinfo a], + $1=yes, + $1=no)) + AC_MSG_RESULT($$1) + if test $$1 = yes; then + AC_DEFINE(HAVE_ADDRINFO) + else + AC_DEFINE(NEED_ADDRINFO_H) + fi +]) + +dnl +dnl Checks for NI_MAXSERV +AC_DEFUN(AC_NI_MAXSERV, [ + AC_MSG_CHECKING(for NI_MAXSERV) + AC_CACHE_VAL($1, + AC_EGREP_CPP(yes, [#include <netdb.h> +#ifdef NI_MAXSERV +yes +#endif], + $1=yes, + $1=no)) + AC_MSG_RESULT($$1) + if test $$1 != yes; then + AC_DEFINE(NEED_ADDRINFO_H) + fi +]) + +dnl +dnl Checks for NI_NAMEREQD +AC_DEFUN(AC_NI_NAMEREQD, [ + AC_MSG_CHECKING(for NI_NAMEREQD) + AC_CACHE_VAL($1, + AC_EGREP_CPP(yes, [#include <netdb.h> +#ifdef NI_NOFQDN +yes +#endif], + $1=yes, + $1=no)) + AC_MSG_RESULT($$1) + if test $$1 != yes; then + AC_DEFINE(NEED_ADDRINFO_H) + fi +]) + +dnl +dnl Checks for sockaddr_storage structure +AC_DEFUN(AC_STRUCT_SA_STORAGE, [ + AC_MSG_CHECKING(for sockaddr_storage) + AC_CACHE_VAL($1, + AC_TRY_COMPILE([ +# include <sys/types.h> +# include <sys/socket.h>], + [struct sockaddr_storage s], + $1=yes, + $1=no)) + AC_MSG_RESULT($$1) + if test $$1 = yes; then + AC_DEFINE(HAVE_SOCKADDR_STORAGE) + fi +]) + +dnl +dnl check for h_errno +AC_DEFUN(AC_VAR_H_ERRNO, [ + AC_MSG_CHECKING(for h_errno) + AC_CACHE_VAL(ac_cv_var_h_errno, + AC_TRY_COMPILE([ +# include <sys/types.h> +# include <netdb.h>], + [int foo = h_errno;], + ac_cv_var_h_errno=yes, + ac_cv_var_h_errno=no)) + AC_MSG_RESULT($ac_cv_var_h_errno) + if test "$ac_cv_var_h_errno" = "yes"; then + AC_DEFINE(HAVE_H_ERRNO) + fi +]) + +dnl +dnl Test for __attribute__ +dnl + +AC_DEFUN(AC_C___ATTRIBUTE__, [ +AC_MSG_CHECKING(for __attribute__) +AC_CACHE_VAL(ac_cv___attribute__, [ +AC_COMPILE_IFELSE([ + AC_LANG_SOURCE([[ +#include <stdlib.h> + +static void foo(void) __attribute__ ((noreturn)); + +static void +foo(void) +{ + exit(1); +} + +int +main(int argc, char **argv) +{ + foo(); +} + ]])], +ac_cv___attribute__=yes, +ac_cv___attribute__=no)]) +if test "$ac_cv___attribute__" = "yes"; then + AC_DEFINE(HAVE___ATTRIBUTE__, 1, [define if your compiler has __attribute__]) + V_DEFS="$V_DEFS -D_U_=\"__attribute__((unused))\"" +else + V_DEFS="$V_DEFS -D_U_=\"\"" +fi +AC_MSG_RESULT($ac_cv___attribute__) +]) + + +dnl +dnl Test whether __attribute__((format)) can be applied to function +dnl pointers +dnl + +AC_DEFUN(AC_C___ATTRIBUTE___FORMAT_FUNCTION_POINTER, [ +AC_MSG_CHECKING([whether __attribute__((format)) can be applied to function pointers]) +AC_CACHE_VAL(ac_cv___attribute___format_function_pointer, [ +AC_COMPILE_IFELSE([ + AC_LANG_SOURCE([[ +#include <stdlib.h> + +extern int (*foo)(const char *fmt, ...) + __attribute__ ((format (printf, 1, 2))); + +int +main(int argc, char **argv) +{ + (*foo)("%s", "test"); +} + ]])], +ac_cv___attribute___format_function_pointer=yes, +ac_cv___attribute___format_function_pointer=no)]) +if test "$ac_cv___attribute___format_function_pointer" = "yes"; then + AC_DEFINE(__ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS, 1, + [define if your compiler allows __attribute__((format)) to be applied to function pointers]) +fi +AC_MSG_RESULT($ac_cv___attribute___format_function_pointer) +]) + +AC_DEFUN(AC_LBL_SSLEAY, + [ + # + # Find the last component of $libdir; it's not necessarily + # "lib" - it might be "lib64" on, for example, x86-64 + # Linux systems. + # + # We assume the directory in which we're looking for + # libcrypto has a subdirectory with that as its name. + # + tmplib=`echo "$libdir" | sed 's,.*/,,'` + + # + # XXX - is there a better way to check if a given library is + # in a given directory than checking each of the possible + # shared library suffixes? + # + # 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 "$1/$tmplib" -a \( -f "$1/$tmplib/libcrypto.a" -o \ + -f "$1/$tmplib/libcrypto.so" -o \ + -f "$1/$tmplib/libcrypto.sl" -o \ + -f "$1/$tmplib/libcrypto.dylib" \); then + ac_cv_ssleay_path="$1" + fi + + # + # Make sure we have the headers as well. + # + if test -d "$1/include/openssl" -a -f "$1/include/openssl/des.h"; then + incdir="-I$1/include" + fi +])
diff --git a/tcpdump-4.3.0/addrtoname.c b/tcpdump-4.3.0/addrtoname.c new file mode 100644 index 0000000..d77f27b --- /dev/null +++ b/tcpdump-4.3.0/addrtoname.c
@@ -0,0 +1,1211 @@ +/* + * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * Internet, ethernet, port, and protocol string to address + * and address to string conversion routines + */ +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.119 2007-08-08 14:06:34 hannes Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#ifdef USE_ETHER_NTOHOST +#ifdef HAVE_NETINET_IF_ETHER_H +struct mbuf; /* Squelch compiler warnings on some platforms for */ +struct rtentry; /* declarations in <net/if.h> */ +#include <net/if.h> /* for "struct ifnet" in "struct arpcom" on Solaris */ +#include <netinet/if_ether.h> +#endif /* HAVE_NETINET_IF_ETHER_H */ +#ifdef NETINET_ETHER_H_DECLARES_ETHER_NTOHOST +#include <netinet/ether.h> +#endif /* NETINET_ETHER_H_DECLARES_ETHER_NTOHOST */ + +#if !defined(HAVE_DECL_ETHER_NTOHOST) || !HAVE_DECL_ETHER_NTOHOST +#ifndef HAVE_STRUCT_ETHER_ADDR +struct ether_addr { + unsigned char ether_addr_octet[6]; +}; +#endif +extern int ether_ntohost(char *, const struct ether_addr *); +#endif + +#endif /* USE_ETHER_NTOHOST */ + +#include <pcap.h> +#include <pcap-namedb.h> +#include <signal.h> +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + +#include "interface.h" +#include "addrtoname.h" +#include "llc.h" +#include "setsignal.h" +#include "extract.h" +#include "oui.h" + +#ifndef ETHER_ADDR_LEN +#define ETHER_ADDR_LEN 6 +#endif + +/* + * hash tables for whatever-to-name translations + * + * XXX there has to be error checks against strdup(3) failure + */ + +#define HASHNAMESIZE 4096 + +struct hnamemem { + u_int32_t addr; + const char *name; + struct hnamemem *nxt; +}; + +static struct hnamemem hnametable[HASHNAMESIZE]; +static struct hnamemem tporttable[HASHNAMESIZE]; +static struct hnamemem uporttable[HASHNAMESIZE]; +static struct hnamemem eprototable[HASHNAMESIZE]; +static struct hnamemem dnaddrtable[HASHNAMESIZE]; +static struct hnamemem ipxsaptable[HASHNAMESIZE]; + +#if defined(INET6) && defined(WIN32) +/* + * fake gethostbyaddr for Win2k/XP + * gethostbyaddr() returns incorrect value when AF_INET6 is passed + * to 3rd argument. + * + * h_name in struct hostent is only valid. + */ +static struct hostent * +win32_gethostbyaddr(const char *addr, int len, int type) +{ + static struct hostent host; + static char hostbuf[NI_MAXHOST]; + char hname[NI_MAXHOST]; + struct sockaddr_in6 addr6; + + host.h_name = hostbuf; + switch (type) { + case AF_INET: + return gethostbyaddr(addr, len, type); + break; + case AF_INET6: + memset(&addr6, 0, sizeof(addr6)); + addr6.sin6_family = AF_INET6; + memcpy(&addr6.sin6_addr, addr, len); + if (getnameinfo((struct sockaddr *)&addr6, sizeof(addr6), + hname, sizeof(hname), NULL, 0, 0)) { + return NULL; + } else { + strcpy(host.h_name, hname); + return &host; + } + break; + default: + return NULL; + } +} +#define gethostbyaddr win32_gethostbyaddr +#endif /* INET6 & WIN32 */ + +#ifdef INET6 +struct h6namemem { + struct in6_addr addr; + char *name; + struct h6namemem *nxt; +}; + +static struct h6namemem h6nametable[HASHNAMESIZE]; +#endif /* INET6 */ + +struct enamemem { + u_short e_addr0; + u_short e_addr1; + u_short e_addr2; + const char *e_name; + u_char *e_nsap; /* used only for nsaptable[] */ +#define e_bs e_nsap /* for bytestringtable */ + struct enamemem *e_nxt; +}; + +static struct enamemem enametable[HASHNAMESIZE]; +static struct enamemem nsaptable[HASHNAMESIZE]; +static struct enamemem bytestringtable[HASHNAMESIZE]; + +struct protoidmem { + u_int32_t p_oui; + u_short p_proto; + const char *p_name; + struct protoidmem *p_nxt; +}; + +static struct protoidmem protoidtable[HASHNAMESIZE]; + +/* + * A faster replacement for inet_ntoa(). + */ +const char * +intoa(u_int32_t addr) +{ + register char *cp; + register u_int byte; + register int n; + static char buf[sizeof(".xxx.xxx.xxx.xxx")]; + + NTOHL(addr); + cp = buf + sizeof(buf); + *--cp = '\0'; + + n = 4; + do { + byte = addr & 0xff; + *--cp = byte % 10 + '0'; + byte /= 10; + if (byte > 0) { + *--cp = byte % 10 + '0'; + byte /= 10; + if (byte > 0) + *--cp = byte + '0'; + } + *--cp = '.'; + addr >>= 8; + } while (--n > 0); + + return cp + 1; +} + +static u_int32_t f_netmask; +static u_int32_t f_localnet; + +/* + * Return a name for the IP address pointed to by ap. This address + * is assumed to be in network byte order. + * + * NOTE: ap is *NOT* necessarily part of the packet data (not even if + * this is being called with the "ipaddr_string()" macro), so you + * *CANNOT* use the TCHECK{2}/TTEST{2} macros on it. Furthermore, + * even in cases where it *is* part of the packet data, the caller + * would still have to check for a null return value, even if it's + * just printing the return value with "%s" - not all versions of + * printf print "(null)" with "%s" and a null pointer, some of them + * don't check for a null pointer and crash in that case. + * + * The callers of this routine should, before handing this routine + * a pointer to packet data, be sure that the data is present in + * the packet buffer. They should probably do those checks anyway, + * as other data at that layer might not be IP addresses, and it + * also needs to check whether they're present in the packet buffer. + */ +const char * +getname(const u_char *ap) +{ + register struct hostent *hp; + u_int32_t addr; + static struct hnamemem *p; /* static for longjmp() */ + + memcpy(&addr, ap, sizeof(addr)); + p = &hnametable[addr & (HASHNAMESIZE-1)]; + for (; p->nxt; p = p->nxt) { + if (p->addr == addr) + return (p->name); + } + p->addr = addr; + p->nxt = newhnamemem(); + + /* + * Print names unless: + * (1) -n was given. + * (2) Address is foreign and -f was given. (If -f was not + * given, f_netmask and f_localnet are 0 and the test + * evaluates to true) + */ + if (!nflag && + (addr & f_netmask) == f_localnet) { + hp = gethostbyaddr((char *)&addr, 4, AF_INET); + if (hp) { + char *dotp; + + p->name = strdup(hp->h_name); + if (Nflag) { + /* Remove domain qualifications */ + dotp = strchr(p->name, '.'); + if (dotp) + *dotp = '\0'; + } + return (p->name); + } + } + p->name = strdup(intoa(addr)); + return (p->name); +} + +#ifdef INET6 +/* + * Return a name for the IP6 address pointed to by ap. This address + * is assumed to be in network byte order. + */ +const char * +getname6(const u_char *ap) +{ + register struct hostent *hp; + struct in6_addr addr; + static struct h6namemem *p; /* static for longjmp() */ + register const char *cp; + char ntop_buf[INET6_ADDRSTRLEN]; + + memcpy(&addr, ap, sizeof(addr)); + p = &h6nametable[*(u_int16_t *)&addr.s6_addr[14] & (HASHNAMESIZE-1)]; + for (; p->nxt; p = p->nxt) { + if (memcmp(&p->addr, &addr, sizeof(addr)) == 0) + return (p->name); + } + p->addr = addr; + p->nxt = newh6namemem(); + + /* + * Do not print names if -n was given. + */ + if (!nflag) { + hp = gethostbyaddr((char *)&addr, sizeof(addr), AF_INET6); + if (hp) { + char *dotp; + + p->name = strdup(hp->h_name); + if (Nflag) { + /* Remove domain qualifications */ + dotp = strchr(p->name, '.'); + if (dotp) + *dotp = '\0'; + } + return (p->name); + } + } + cp = inet_ntop(AF_INET6, &addr, ntop_buf, sizeof(ntop_buf)); + p->name = strdup(cp); + return (p->name); +} +#endif /* INET6 */ + +static const char hex[] = "0123456789abcdef"; + + +/* Find the hash node that corresponds the ether address 'ep' */ + +static inline struct enamemem * +lookup_emem(const u_char *ep) +{ + register u_int i, j, k; + struct enamemem *tp; + + k = (ep[0] << 8) | ep[1]; + j = (ep[2] << 8) | ep[3]; + i = (ep[4] << 8) | ep[5]; + + tp = &enametable[(i ^ j) & (HASHNAMESIZE-1)]; + while (tp->e_nxt) + if (tp->e_addr0 == i && + tp->e_addr1 == j && + tp->e_addr2 == k) + return tp; + else + tp = tp->e_nxt; + tp->e_addr0 = i; + tp->e_addr1 = j; + tp->e_addr2 = k; + tp->e_nxt = (struct enamemem *)calloc(1, sizeof(*tp)); + if (tp->e_nxt == NULL) + error("lookup_emem: calloc"); + + return tp; +} + +/* + * Find the hash node that corresponds to the bytestring 'bs' + * with length 'nlen' + */ + +static inline struct enamemem * +lookup_bytestring(register const u_char *bs, const unsigned int nlen) +{ + struct enamemem *tp; + register u_int i, j, k; + + if (nlen >= 6) { + k = (bs[0] << 8) | bs[1]; + j = (bs[2] << 8) | bs[3]; + i = (bs[4] << 8) | bs[5]; + } else if (nlen >= 4) { + k = (bs[0] << 8) | bs[1]; + j = (bs[2] << 8) | bs[3]; + i = 0; + } else + i = j = k = 0; + + tp = &bytestringtable[(i ^ j) & (HASHNAMESIZE-1)]; + while (tp->e_nxt) + if (tp->e_addr0 == i && + tp->e_addr1 == j && + tp->e_addr2 == k && + memcmp((const char *)bs, (const char *)(tp->e_bs), nlen) == 0) + return tp; + else + tp = tp->e_nxt; + + tp->e_addr0 = i; + tp->e_addr1 = j; + tp->e_addr2 = k; + + tp->e_bs = (u_char *) calloc(1, nlen + 1); + memcpy(tp->e_bs, bs, nlen); + tp->e_nxt = (struct enamemem *)calloc(1, sizeof(*tp)); + if (tp->e_nxt == NULL) + error("lookup_bytestring: calloc"); + + return tp; +} + +/* Find the hash node that corresponds the NSAP 'nsap' */ + +static inline struct enamemem * +lookup_nsap(register const u_char *nsap) +{ + register u_int i, j, k; + unsigned int nlen = *nsap; + struct enamemem *tp; + const u_char *ensap = nsap + nlen - 6; + + if (nlen > 6) { + k = (ensap[0] << 8) | ensap[1]; + j = (ensap[2] << 8) | ensap[3]; + i = (ensap[4] << 8) | ensap[5]; + } + else + i = j = k = 0; + + tp = &nsaptable[(i ^ j) & (HASHNAMESIZE-1)]; + while (tp->e_nxt) + if (tp->e_addr0 == i && + tp->e_addr1 == j && + tp->e_addr2 == k && + tp->e_nsap[0] == nlen && + memcmp((const char *)&(nsap[1]), + (char *)&(tp->e_nsap[1]), nlen) == 0) + return tp; + else + tp = tp->e_nxt; + tp->e_addr0 = i; + tp->e_addr1 = j; + tp->e_addr2 = k; + tp->e_nsap = (u_char *)malloc(nlen + 1); + if (tp->e_nsap == NULL) + error("lookup_nsap: malloc"); + memcpy((char *)tp->e_nsap, (const char *)nsap, nlen + 1); + tp->e_nxt = (struct enamemem *)calloc(1, sizeof(*tp)); + if (tp->e_nxt == NULL) + error("lookup_nsap: calloc"); + + return tp; +} + +/* Find the hash node that corresponds the protoid 'pi'. */ + +static inline struct protoidmem * +lookup_protoid(const u_char *pi) +{ + register u_int i, j; + struct protoidmem *tp; + + /* 5 octets won't be aligned */ + i = (((pi[0] << 8) + pi[1]) << 8) + pi[2]; + j = (pi[3] << 8) + pi[4]; + /* XXX should be endian-insensitive, but do big-endian testing XXX */ + + tp = &protoidtable[(i ^ j) & (HASHNAMESIZE-1)]; + while (tp->p_nxt) + if (tp->p_oui == i && tp->p_proto == j) + return tp; + else + tp = tp->p_nxt; + tp->p_oui = i; + tp->p_proto = j; + tp->p_nxt = (struct protoidmem *)calloc(1, sizeof(*tp)); + if (tp->p_nxt == NULL) + error("lookup_protoid: calloc"); + + return tp; +} + +const char * +etheraddr_string(register const u_char *ep) +{ + register int i; + register char *cp; + register struct enamemem *tp; + int oui; + char buf[BUFSIZE]; + + tp = lookup_emem(ep); + if (tp->e_name) + return (tp->e_name); +#ifdef USE_ETHER_NTOHOST + if (!nflag) { + char buf2[BUFSIZE]; + + /* + * We don't cast it to "const struct ether_addr *" + * because some systems fail to declare the second + * argument as a "const" pointer, even though they + * don't modify what it points to. + */ + if (ether_ntohost(buf2, (struct ether_addr *)ep) == 0) { + tp->e_name = strdup(buf2); + return (tp->e_name); + } + } +#endif + cp = buf; + oui = EXTRACT_24BITS(ep); + *cp++ = hex[*ep >> 4 ]; + *cp++ = hex[*ep++ & 0xf]; + for (i = 5; --i >= 0;) { + *cp++ = ':'; + *cp++ = hex[*ep >> 4 ]; + *cp++ = hex[*ep++ & 0xf]; + } + + if (!nflag) { + snprintf(cp, BUFSIZE - (2 + 5*3), " (oui %s)", + tok2str(oui_values, "Unknown", oui)); + } else + *cp = '\0'; + tp->e_name = strdup(buf); + return (tp->e_name); +} + +const char * +le64addr_string(const u_char *ep) +{ + const unsigned int len = 8; + register u_int i; + register char *cp; + register struct enamemem *tp; + char buf[BUFSIZE]; + + tp = lookup_bytestring(ep, len); + if (tp->e_name) + return (tp->e_name); + + cp = buf; + for (i = len; i > 0 ; --i) { + *cp++ = hex[*(ep + i - 1) >> 4]; + *cp++ = hex[*(ep + i - 1) & 0xf]; + *cp++ = ':'; + } + cp --; + + *cp = '\0'; + + tp->e_name = strdup(buf); + + return (tp->e_name); +} + +const char * +linkaddr_string(const u_char *ep, const unsigned int type, const unsigned int len) +{ + register u_int i; + register char *cp; + register struct enamemem *tp; + + if (len == 0) + return ("<empty>"); + + if (type == LINKADDR_ETHER && len == ETHER_ADDR_LEN) + return (etheraddr_string(ep)); + + if (type == LINKADDR_FRELAY) + return (q922_string(ep)); + + tp = lookup_bytestring(ep, len); + if (tp->e_name) + return (tp->e_name); + + tp->e_name = cp = (char *)malloc(len*3); + if (tp->e_name == NULL) + error("linkaddr_string: malloc"); + *cp++ = hex[*ep >> 4]; + *cp++ = hex[*ep++ & 0xf]; + for (i = len-1; i > 0 ; --i) { + *cp++ = ':'; + *cp++ = hex[*ep >> 4]; + *cp++ = hex[*ep++ & 0xf]; + } + *cp = '\0'; + return (tp->e_name); +} + +const char * +etherproto_string(u_short port) +{ + register char *cp; + register struct hnamemem *tp; + register u_int32_t i = port; + char buf[sizeof("0000")]; + + for (tp = &eprototable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt) + if (tp->addr == i) + return (tp->name); + + tp->addr = i; + tp->nxt = newhnamemem(); + + cp = buf; + NTOHS(port); + *cp++ = hex[port >> 12 & 0xf]; + *cp++ = hex[port >> 8 & 0xf]; + *cp++ = hex[port >> 4 & 0xf]; + *cp++ = hex[port & 0xf]; + *cp++ = '\0'; + tp->name = strdup(buf); + return (tp->name); +} + +const char * +protoid_string(register const u_char *pi) +{ + register u_int i, j; + register char *cp; + register struct protoidmem *tp; + char buf[sizeof("00:00:00:00:00")]; + + tp = lookup_protoid(pi); + if (tp->p_name) + return tp->p_name; + + cp = buf; + if ((j = *pi >> 4) != 0) + *cp++ = hex[j]; + *cp++ = hex[*pi++ & 0xf]; + for (i = 4; (int)--i >= 0;) { + *cp++ = ':'; + if ((j = *pi >> 4) != 0) + *cp++ = hex[j]; + *cp++ = hex[*pi++ & 0xf]; + } + *cp = '\0'; + tp->p_name = strdup(buf); + return (tp->p_name); +} + +#define ISONSAP_MAX_LENGTH 20 +const char * +isonsap_string(const u_char *nsap, register u_int nsap_length) +{ + register u_int nsap_idx; + register char *cp; + register struct enamemem *tp; + + if (nsap_length < 1 || nsap_length > ISONSAP_MAX_LENGTH) + return ("isonsap_string: illegal length"); + + tp = lookup_nsap(nsap); + if (tp->e_name) + return tp->e_name; + + tp->e_name = cp = (char *)malloc(sizeof("xx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xx")); + if (cp == NULL) + error("isonsap_string: malloc"); + + for (nsap_idx = 0; nsap_idx < nsap_length; nsap_idx++) { + *cp++ = hex[*nsap >> 4]; + *cp++ = hex[*nsap++ & 0xf]; + if (((nsap_idx & 1) == 0) && + (nsap_idx + 1 < nsap_length)) { + *cp++ = '.'; + } + } + *cp = '\0'; + return (tp->e_name); +} + +const char * +tcpport_string(u_short port) +{ + register struct hnamemem *tp; + register u_int32_t i = port; + char buf[sizeof("00000")]; + + for (tp = &tporttable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt) + if (tp->addr == i) + return (tp->name); + + tp->addr = i; + tp->nxt = newhnamemem(); + + (void)snprintf(buf, sizeof(buf), "%u", i); + tp->name = strdup(buf); + return (tp->name); +} + +const char * +udpport_string(register u_short port) +{ + register struct hnamemem *tp; + register u_int32_t i = port; + char buf[sizeof("00000")]; + + for (tp = &uporttable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt) + if (tp->addr == i) + return (tp->name); + + tp->addr = i; + tp->nxt = newhnamemem(); + + (void)snprintf(buf, sizeof(buf), "%u", i); + tp->name = strdup(buf); + return (tp->name); +} + +const char * +ipxsap_string(u_short port) +{ + register char *cp; + register struct hnamemem *tp; + register u_int32_t i = port; + char buf[sizeof("0000")]; + + for (tp = &ipxsaptable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt) + if (tp->addr == i) + return (tp->name); + + tp->addr = i; + tp->nxt = newhnamemem(); + + cp = buf; + NTOHS(port); + *cp++ = hex[port >> 12 & 0xf]; + *cp++ = hex[port >> 8 & 0xf]; + *cp++ = hex[port >> 4 & 0xf]; + *cp++ = hex[port & 0xf]; + *cp++ = '\0'; + tp->name = strdup(buf); + return (tp->name); +} + +static void +init_servarray(void) +{ + struct servent *sv; + register struct hnamemem *table; + register int i; + char buf[sizeof("0000000000")]; + + while ((sv = getservent()) != NULL) { + int port = ntohs(sv->s_port); + i = port & (HASHNAMESIZE-1); + if (strcmp(sv->s_proto, "tcp") == 0) + table = &tporttable[i]; + else if (strcmp(sv->s_proto, "udp") == 0) + table = &uporttable[i]; + else + continue; + + while (table->name) + table = table->nxt; + if (nflag) { + (void)snprintf(buf, sizeof(buf), "%d", port); + table->name = strdup(buf); + } else + table->name = strdup(sv->s_name); + table->addr = port; + table->nxt = newhnamemem(); + } + endservent(); +} + +/* in libpcap.a (nametoaddr.c) */ +#if defined(WIN32) && !defined(USE_STATIC_LIBPCAP) +__declspec(dllimport) +#else +extern +#endif +const struct eproto { + const char *s; + u_short p; +} eproto_db[]; + +static void +init_eprotoarray(void) +{ + register int i; + register struct hnamemem *table; + + for (i = 0; eproto_db[i].s; i++) { + int j = htons(eproto_db[i].p) & (HASHNAMESIZE-1); + table = &eprototable[j]; + while (table->name) + table = table->nxt; + table->name = eproto_db[i].s; + table->addr = htons(eproto_db[i].p); + table->nxt = newhnamemem(); + } +} + +static const struct protoidlist { + const u_char protoid[5]; + const char *name; +} protoidlist[] = { + {{ 0x00, 0x00, 0x0c, 0x01, 0x07 }, "CiscoMLS" }, + {{ 0x00, 0x00, 0x0c, 0x20, 0x00 }, "CiscoCDP" }, + {{ 0x00, 0x00, 0x0c, 0x20, 0x01 }, "CiscoCGMP" }, + {{ 0x00, 0x00, 0x0c, 0x20, 0x03 }, "CiscoVTP" }, + {{ 0x00, 0xe0, 0x2b, 0x00, 0xbb }, "ExtremeEDP" }, + {{ 0x00, 0x00, 0x00, 0x00, 0x00 }, NULL } +}; + +/* + * SNAP proto IDs with org code 0:0:0 are actually encapsulated Ethernet + * types. + */ +static void +init_protoidarray(void) +{ + register int i; + register struct protoidmem *tp; + const struct protoidlist *pl; + u_char protoid[5]; + + protoid[0] = 0; + protoid[1] = 0; + protoid[2] = 0; + for (i = 0; eproto_db[i].s; i++) { + u_short etype = htons(eproto_db[i].p); + + memcpy((char *)&protoid[3], (char *)&etype, 2); + tp = lookup_protoid(protoid); + tp->p_name = strdup(eproto_db[i].s); + } + /* Hardwire some SNAP proto ID names */ + for (pl = protoidlist; pl->name != NULL; ++pl) { + tp = lookup_protoid(pl->protoid); + /* Don't override existing name */ + if (tp->p_name != NULL) + continue; + + tp->p_name = pl->name; + } +} + +static const struct etherlist { + const u_char addr[6]; + const char *name; +} etherlist[] = { + {{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, "Broadcast" }, + {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, NULL } +}; + +/* + * Initialize the ethers hash table. We take two different approaches + * depending on whether or not the system provides the ethers name + * service. If it does, we just wire in a few names at startup, + * and etheraddr_string() fills in the table on demand. If it doesn't, + * then we suck in the entire /etc/ethers file at startup. The idea + * is that parsing the local file will be fast, but spinning through + * all the ethers entries via NIS & next_etherent might be very slow. + * + * XXX pcap_next_etherent doesn't belong in the pcap interface, but + * since the pcap module already does name-to-address translation, + * it's already does most of the work for the ethernet address-to-name + * translation, so we just pcap_next_etherent as a convenience. + */ +static void +init_etherarray(void) +{ + register const struct etherlist *el; + register struct enamemem *tp; +#ifdef USE_ETHER_NTOHOST + char name[256]; +#else + register struct pcap_etherent *ep; + register FILE *fp; + + /* Suck in entire ethers file */ + fp = fopen(PCAP_ETHERS_FILE, "r"); + if (fp != NULL) { + while ((ep = pcap_next_etherent(fp)) != NULL) { + tp = lookup_emem(ep->addr); + tp->e_name = strdup(ep->name); + } + (void)fclose(fp); + } +#endif + + /* Hardwire some ethernet names */ + for (el = etherlist; el->name != NULL; ++el) { + tp = lookup_emem(el->addr); + /* Don't override existing name */ + if (tp->e_name != NULL) + continue; + +#ifdef USE_ETHER_NTOHOST + /* + * Use YP/NIS version of name if available. + * + * We don't cast it to "const struct ether_addr *" + * because some systems don't modify the Ethernet + * address but fail to declare the second argument + * as a "const" pointer. + */ + if (ether_ntohost(name, (struct ether_addr *)el->addr) == 0) { + tp->e_name = strdup(name); + continue; + } +#endif + tp->e_name = el->name; + } +} + +static const struct tok ipxsap_db[] = { + { 0x0000, "Unknown" }, + { 0x0001, "User" }, + { 0x0002, "User Group" }, + { 0x0003, "PrintQueue" }, + { 0x0004, "FileServer" }, + { 0x0005, "JobServer" }, + { 0x0006, "Gateway" }, + { 0x0007, "PrintServer" }, + { 0x0008, "ArchiveQueue" }, + { 0x0009, "ArchiveServer" }, + { 0x000a, "JobQueue" }, + { 0x000b, "Administration" }, + { 0x000F, "Novell TI-RPC" }, + { 0x0017, "Diagnostics" }, + { 0x0020, "NetBIOS" }, + { 0x0021, "NAS SNA Gateway" }, + { 0x0023, "NACS AsyncGateway" }, + { 0x0024, "RemoteBridge/RoutingService" }, + { 0x0026, "BridgeServer" }, + { 0x0027, "TCP/IP Gateway" }, + { 0x0028, "Point-to-point X.25 BridgeServer" }, + { 0x0029, "3270 Gateway" }, + { 0x002a, "CHI Corp" }, + { 0x002c, "PC Chalkboard" }, + { 0x002d, "TimeSynchServer" }, + { 0x002e, "ARCserve5.0/PalindromeBackup" }, + { 0x0045, "DI3270 Gateway" }, + { 0x0047, "AdvertisingPrintServer" }, + { 0x004a, "NetBlazerModems" }, + { 0x004b, "BtrieveVAP" }, + { 0x004c, "NetwareSQL" }, + { 0x004d, "XtreeNetwork" }, + { 0x0050, "BtrieveVAP4.11" }, + { 0x0052, "QuickLink" }, + { 0x0053, "PrintQueueUser" }, + { 0x0058, "Multipoint X.25 Router" }, + { 0x0060, "STLB/NLM" }, + { 0x0064, "ARCserve" }, + { 0x0066, "ARCserve3.0" }, + { 0x0072, "WAN CopyUtility" }, + { 0x007a, "TES-NetwareVMS" }, + { 0x0092, "WATCOM Debugger/EmeraldTapeBackupServer" }, + { 0x0095, "DDA OBGYN" }, + { 0x0098, "NetwareAccessServer" }, + { 0x009a, "Netware for VMS II/NamedPipeServer" }, + { 0x009b, "NetwareAccessServer" }, + { 0x009e, "PortableNetwareServer/SunLinkNVT" }, + { 0x00a1, "PowerchuteAPC UPS" }, + { 0x00aa, "LAWserve" }, + { 0x00ac, "CompaqIDA StatusMonitor" }, + { 0x0100, "PIPE STAIL" }, + { 0x0102, "LAN ProtectBindery" }, + { 0x0103, "OracleDataBaseServer" }, + { 0x0107, "Netware386/RSPX RemoteConsole" }, + { 0x010f, "NovellSNA Gateway" }, + { 0x0111, "TestServer" }, + { 0x0112, "HP PrintServer" }, + { 0x0114, "CSA MUX" }, + { 0x0115, "CSA LCA" }, + { 0x0116, "CSA CM" }, + { 0x0117, "CSA SMA" }, + { 0x0118, "CSA DBA" }, + { 0x0119, "CSA NMA" }, + { 0x011a, "CSA SSA" }, + { 0x011b, "CSA STATUS" }, + { 0x011e, "CSA APPC" }, + { 0x0126, "SNA TEST SSA Profile" }, + { 0x012a, "CSA TRACE" }, + { 0x012b, "NetwareSAA" }, + { 0x012e, "IKARUS VirusScan" }, + { 0x0130, "CommunicationsExecutive" }, + { 0x0133, "NNS DomainServer/NetwareNamingServicesDomain" }, + { 0x0135, "NetwareNamingServicesProfile" }, + { 0x0137, "Netware386 PrintQueue/NNS PrintQueue" }, + { 0x0141, "LAN SpoolServer" }, + { 0x0152, "IRMALAN Gateway" }, + { 0x0154, "NamedPipeServer" }, + { 0x0166, "NetWareManagement" }, + { 0x0168, "Intel PICKIT CommServer/Intel CAS TalkServer" }, + { 0x0173, "Compaq" }, + { 0x0174, "Compaq SNMP Agent" }, + { 0x0175, "Compaq" }, + { 0x0180, "XTreeServer/XTreeTools" }, + { 0x018A, "NASI ServicesBroadcastServer" }, + { 0x01b0, "GARP Gateway" }, + { 0x01b1, "Binfview" }, + { 0x01bf, "IntelLanDeskManager" }, + { 0x01ca, "AXTEC" }, + { 0x01cb, "ShivaNetModem/E" }, + { 0x01cc, "ShivaLanRover/E" }, + { 0x01cd, "ShivaLanRover/T" }, + { 0x01ce, "ShivaUniversal" }, + { 0x01d8, "CastelleFAXPressServer" }, + { 0x01da, "CastelleLANPressPrintServer" }, + { 0x01dc, "CastelleFAX/Xerox7033 FaxServer/ExcelLanFax" }, + { 0x01f0, "LEGATO" }, + { 0x01f5, "LEGATO" }, + { 0x0233, "NMS Agent/NetwareManagementAgent" }, + { 0x0237, "NMS IPX Discovery/LANternReadWriteChannel" }, + { 0x0238, "NMS IP Discovery/LANternTrapAlarmChannel" }, + { 0x023a, "LANtern" }, + { 0x023c, "MAVERICK" }, + { 0x023f, "NovellSMDR" }, + { 0x024e, "NetwareConnect" }, + { 0x024f, "NASI ServerBroadcast Cisco" }, + { 0x026a, "NMS ServiceConsole" }, + { 0x026b, "TimeSynchronizationServer Netware 4.x" }, + { 0x0278, "DirectoryServer Netware 4.x" }, + { 0x027b, "NetwareManagementAgent" }, + { 0x0280, "Novell File and Printer Sharing Service for PC" }, + { 0x0304, "NovellSAA Gateway" }, + { 0x0308, "COM/VERMED" }, + { 0x030a, "GalacticommWorldgroupServer" }, + { 0x030c, "IntelNetport2/HP JetDirect/HP Quicksilver" }, + { 0x0320, "AttachmateGateway" }, + { 0x0327, "MicrosoftDiagnostiocs" }, + { 0x0328, "WATCOM SQL Server" }, + { 0x0335, "MultiTechSystems MultisynchCommServer" }, + { 0x0343, "Xylogics RemoteAccessServer/LANModem" }, + { 0x0355, "ArcadaBackupExec" }, + { 0x0358, "MSLCD1" }, + { 0x0361, "NETINELO" }, + { 0x037e, "Powerchute UPS Monitoring" }, + { 0x037f, "ViruSafeNotify" }, + { 0x0386, "HP Bridge" }, + { 0x0387, "HP Hub" }, + { 0x0394, "NetWare SAA Gateway" }, + { 0x039b, "LotusNotes" }, + { 0x03b7, "CertusAntiVirus" }, + { 0x03c4, "ARCserve4.0" }, + { 0x03c7, "LANspool3.5" }, + { 0x03d7, "LexmarkPrinterServer" }, + { 0x03d8, "LexmarkXLE PrinterServer" }, + { 0x03dd, "BanyanENS NetwareClient" }, + { 0x03de, "GuptaSequelBaseServer/NetWareSQL" }, + { 0x03e1, "UnivelUnixware" }, + { 0x03e4, "UnivelUnixware" }, + { 0x03fc, "IntelNetport" }, + { 0x03fd, "PrintServerQueue" }, + { 0x040A, "ipnServer" }, + { 0x040D, "LVERRMAN" }, + { 0x040E, "LVLIC" }, + { 0x0414, "NET Silicon (DPI)/Kyocera" }, + { 0x0429, "SiteLockVirus" }, + { 0x0432, "UFHELPR???" }, + { 0x0433, "Synoptics281xAdvancedSNMPAgent" }, + { 0x0444, "MicrosoftNT SNA Server" }, + { 0x0448, "Oracle" }, + { 0x044c, "ARCserve5.01" }, + { 0x0457, "CanonGP55" }, + { 0x045a, "QMS Printers" }, + { 0x045b, "DellSCSI Array" }, + { 0x0491, "NetBlazerModems" }, + { 0x04ac, "OnTimeScheduler" }, + { 0x04b0, "CD-Net" }, + { 0x0513, "EmulexNQA" }, + { 0x0520, "SiteLockChecks" }, + { 0x0529, "SiteLockChecks" }, + { 0x052d, "CitrixOS2 AppServer" }, + { 0x0535, "Tektronix" }, + { 0x0536, "Milan" }, + { 0x055d, "Attachmate SNA gateway" }, + { 0x056b, "IBM8235 ModemServer" }, + { 0x056c, "ShivaLanRover/E PLUS" }, + { 0x056d, "ShivaLanRover/T PLUS" }, + { 0x0580, "McAfeeNetShield" }, + { 0x05B8, "NLM to workstation communication (Revelation Software)" }, + { 0x05BA, "CompatibleSystemsRouters" }, + { 0x05BE, "CheyenneHierarchicalStorageManager" }, + { 0x0606, "JCWatermarkImaging" }, + { 0x060c, "AXISNetworkPrinter" }, + { 0x0610, "AdaptecSCSIManagement" }, + { 0x0621, "IBM AntiVirus" }, + { 0x0640, "Windows95 RemoteRegistryService" }, + { 0x064e, "MicrosoftIIS" }, + { 0x067b, "Microsoft Win95/98 File and Print Sharing for NetWare" }, + { 0x067c, "Microsoft Win95/98 File and Print Sharing for NetWare" }, + { 0x076C, "Xerox" }, + { 0x079b, "ShivaLanRover/E 115" }, + { 0x079c, "ShivaLanRover/T 115" }, + { 0x07B4, "CubixWorldDesk" }, + { 0x07c2, "Quarterdeck IWare Connect V2.x NLM" }, + { 0x07c1, "Quarterdeck IWare Connect V3.x NLM" }, + { 0x0810, "ELAN License Server Demo" }, + { 0x0824, "ShivaLanRoverAccessSwitch/E" }, + { 0x086a, "ISSC Collector" }, + { 0x087f, "ISSC DAS AgentAIX" }, + { 0x0880, "Intel Netport PRO" }, + { 0x0881, "Intel Netport PRO" }, + { 0x0b29, "SiteLock" }, + { 0x0c29, "SiteLockApplications" }, + { 0x0c2c, "LicensingServer" }, + { 0x2101, "PerformanceTechnologyInstantInternet" }, + { 0x2380, "LAI SiteLock" }, + { 0x238c, "MeetingMaker" }, + { 0x4808, "SiteLockServer/SiteLockMetering" }, + { 0x5555, "SiteLockUser" }, + { 0x6312, "Tapeware" }, + { 0x6f00, "RabbitGateway" }, + { 0x7703, "MODEM" }, + { 0x8002, "NetPortPrinters" }, + { 0x8008, "WordPerfectNetworkVersion" }, + { 0x85BE, "Cisco EIGRP" }, + { 0x8888, "WordPerfectNetworkVersion/QuickNetworkManagement" }, + { 0x9000, "McAfeeNetShield" }, + { 0x9604, "CSA-NT_MON" }, + { 0xb6a8, "OceanIsleReachoutRemoteControl" }, + { 0xf11f, "SiteLockMetering" }, + { 0xf1ff, "SiteLock" }, + { 0xf503, "Microsoft SQL Server" }, + { 0xF905, "IBM TimeAndPlace" }, + { 0xfbfb, "TopCallIII FaxServer" }, + { 0xffff, "AnyService/Wildcard" }, + { 0, (char *)0 } +}; + +static void +init_ipxsaparray(void) +{ + register int i; + register struct hnamemem *table; + + for (i = 0; ipxsap_db[i].s != NULL; i++) { + int j = htons(ipxsap_db[i].v) & (HASHNAMESIZE-1); + table = &ipxsaptable[j]; + while (table->name) + table = table->nxt; + table->name = ipxsap_db[i].s; + table->addr = htons(ipxsap_db[i].v); + table->nxt = newhnamemem(); + } +} + +/* + * Initialize the address to name translation machinery. We map all + * non-local IP addresses to numeric addresses if fflag is true (i.e., + * to prevent blocking on the nameserver). localnet is the IP address + * of the local network. mask is its subnet mask. + */ +void +init_addrtoname(u_int32_t localnet, u_int32_t mask) +{ + if (fflag) { + f_localnet = localnet; + f_netmask = mask; + } + if (nflag) + /* + * Simplest way to suppress names. + */ + return; + + init_etherarray(); + init_servarray(); + init_eprotoarray(); + init_protoidarray(); + init_ipxsaparray(); +} + +const char * +dnaddr_string(u_short dnaddr) +{ + register struct hnamemem *tp; + + for (tp = &dnaddrtable[dnaddr & (HASHNAMESIZE-1)]; tp->nxt != 0; + tp = tp->nxt) + if (tp->addr == dnaddr) + return (tp->name); + + tp->addr = dnaddr; + tp->nxt = newhnamemem(); + if (nflag) + tp->name = dnnum_string(dnaddr); + else + tp->name = dnname_string(dnaddr); + + return(tp->name); +} + +/* Return a zero'ed hnamemem struct and cuts down on calloc() overhead */ +struct hnamemem * +newhnamemem(void) +{ + register struct hnamemem *p; + static struct hnamemem *ptr = NULL; + static u_int num = 0; + + if (num <= 0) { + num = 64; + ptr = (struct hnamemem *)calloc(num, sizeof (*ptr)); + if (ptr == NULL) + error("newhnamemem: calloc"); + } + --num; + p = ptr++; + return (p); +} + +#ifdef INET6 +/* Return a zero'ed h6namemem struct and cuts down on calloc() overhead */ +struct h6namemem * +newh6namemem(void) +{ + register struct h6namemem *p; + static struct h6namemem *ptr = NULL; + static u_int num = 0; + + if (num <= 0) { + num = 64; + ptr = (struct h6namemem *)calloc(num, sizeof (*ptr)); + if (ptr == NULL) + error("newh6namemem: calloc"); + } + --num; + p = ptr++; + return (p); +} +#endif /* INET6 */
diff --git a/tcpdump-4.3.0/addrtoname.h b/tcpdump-4.3.0/addrtoname.h new file mode 100644 index 0000000..cd5c41f --- /dev/null +++ b/tcpdump-4.3.0/addrtoname.h
@@ -0,0 +1,56 @@ +/* + * Copyright (c) 1990, 1992, 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * 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/addrtoname.h,v 1.20 2007-08-08 14:06:34 hannes Exp $ (LBL) + */ + +/* Name to address translation routines. */ + +enum { + LINKADDR_ETHER, + LINKADDR_FRELAY, + LINKADDR_IEEE1394, + LINKADDR_ATM +}; + +#define BUFSIZE 128 + +extern const char *linkaddr_string(const u_char *, const unsigned int, const unsigned int); +extern const char *etheraddr_string(const u_char *); +extern const char *le64addr_string(const u_char *); +extern const char *etherproto_string(u_short); +extern const char *tcpport_string(u_short); +extern const char *udpport_string(u_short); +extern const char *getname(const u_char *); +#ifdef INET6 +extern const char *getname6(const u_char *); +#endif +extern const char *intoa(u_int32_t); + +extern void init_addrtoname(u_int32_t, u_int32_t); +extern struct hnamemem *newhnamemem(void); +#ifdef INET6 +extern struct h6namemem *newh6namemem(void); +#endif + +#define ipaddr_string(p) getname((const u_char *)(p)) +#ifdef INET6 +#define ip6addr_string(p) getname6((const u_char *)(p)) +#endif
diff --git a/tcpdump-4.3.0/af.c b/tcpdump-4.3.0/af.c new file mode 100644 index 0000000..2c8a928 --- /dev/null +++ b/tcpdump-4.3.0/af.c
@@ -0,0 +1,63 @@ +/* + * Copyright (c) 1998-2006 The TCPDUMP project + * + * 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/af.c,v 1.3 2006-03-23 14:58:44 hannes Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> +#include "interface.h" +#include "af.h" + +const struct tok af_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"}, + { AFNUM_VPLS, "VPLS"}, + { 0, NULL}, +}; + +const struct tok bsd_af_values[] = { + { BSD_AFNUM_INET, "IPv4" }, + { BSD_AFNUM_NS, "NS" }, + { BSD_AFNUM_ISO, "ISO" }, + { BSD_AFNUM_APPLETALK, "Appletalk" }, + { BSD_AFNUM_IPX, "IPX" }, + { BSD_AFNUM_INET6_BSD, "IPv6" }, + { BSD_AFNUM_INET6_FREEBSD, "IPv6" }, + { BSD_AFNUM_INET6_DARWIN, "IPv6" }, + { 0, NULL} +};
diff --git a/tcpdump-4.3.0/af.h b/tcpdump-4.3.0/af.h new file mode 100644 index 0000000..679cc8e --- /dev/null +++ b/tcpdump-4.3.0/af.h
@@ -0,0 +1,57 @@ +/* @(#) $Header: /tcpdump/master/tcpdump/af.h,v 1.3 2006-03-23 14:58:44 hannes Exp $ (LBL) */ + +/* + * Copyright (c) 1998-2006 The TCPDUMP project + * + * 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 const struct tok af_values[]; +extern const struct tok bsd_af_values[]; + +/* RFC1700 address family numbers */ +#define AFNUM_INET 1 +#define AFNUM_INET6 2 +#define AFNUM_NSAP 3 +#define AFNUM_HDLC 4 +#define AFNUM_BBN1822 5 +#define AFNUM_802 6 +#define AFNUM_E163 7 +#define AFNUM_E164 8 +#define AFNUM_F69 9 +#define AFNUM_X121 10 +#define AFNUM_IPX 11 +#define AFNUM_ATALK 12 +#define AFNUM_DECNET 13 +#define AFNUM_BANYAN 14 +#define AFNUM_E164NSAP 15 +#define AFNUM_VPLS 25 +/* draft-kompella-ppvpn-l2vpn */ +#define AFNUM_L2VPN 196 /* still to be approved by IANA */ + +/* + * BSD AF_ values. + * + * Unfortunately, the BSDs don't all use the same value for AF_INET6, + * so, because we want to be able to read captures from all of the BSDs, + * we check for all of them. + */ +#define BSD_AFNUM_INET 2 +#define BSD_AFNUM_NS 6 /* XEROX NS protocols */ +#define BSD_AFNUM_ISO 7 +#define BSD_AFNUM_APPLETALK 16 +#define BSD_AFNUM_IPX 23 +#define BSD_AFNUM_INET6_BSD 24 /* OpenBSD (and probably NetBSD), BSD/OS */ +#define BSD_AFNUM_INET6_FREEBSD 28 +#define BSD_AFNUM_INET6_DARWIN 30
diff --git a/tcpdump-4.3.0/ah.h b/tcpdump-4.3.0/ah.h new file mode 100644 index 0000000..c22806a --- /dev/null +++ b/tcpdump-4.3.0/ah.h
@@ -0,0 +1,57 @@ +/* $NetBSD: ah.h,v 1.12 2000/07/23 05:23:04 itojun Exp $ */ +/* $KAME: ah.h,v 1.12 2000/07/20 17:41:01 itojun Exp $ */ + +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * RFC1826/2402 authentication header. + */ + +#ifndef _NETINET6_AH_H_ +#define _NETINET6_AH_H_ + +struct ah { + u_int8_t ah_nxt; /* Next Header */ + u_int8_t ah_len; /* Length of data, in 32bit */ + u_int16_t ah_reserve; /* Reserved for future use */ + u_int32_t ah_spi; /* Security parameter index */ + /* variable size, 32bit bound*/ /* Authentication data */ +}; + +struct newah { + u_int8_t ah_nxt; /* Next Header */ + u_int8_t ah_len; /* Length of data + 1, in 32bit */ + u_int16_t ah_reserve; /* Reserved for future use */ + u_int32_t ah_spi; /* Security parameter index */ + u_int32_t ah_seq; /* Sequence number field */ + /* variable size, 32bit bound*/ /* Authentication data */ +}; + +#endif /*_NETINET6_AH_H_*/
diff --git a/tcpdump-4.3.0/aodv.h b/tcpdump-4.3.0/aodv.h new file mode 100644 index 0000000..456ec8b --- /dev/null +++ b/tcpdump-4.3.0/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/tcpdump-4.3.0/appletalk.h b/tcpdump-4.3.0/appletalk.h new file mode 100644 index 0000000..ff972f6 --- /dev/null +++ b/tcpdump-4.3.0/appletalk.h
@@ -0,0 +1,168 @@ +/* + * Copyright (c) 1988, 1989, 1990, 1993, 1994, 1995, 1996 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * AppleTalk protocol formats (courtesy Bill Croft of Stanford/SUMEX). + * + * @(#) $Header: /tcpdump/master/tcpdump/appletalk.h,v 1.16 2004-05-01 09:41:50 hannes Exp $ (LBL) + */ + +struct LAP { + u_int8_t dst; + u_int8_t src; + u_int8_t type; +}; +#define lapShortDDP 1 /* short DDP type */ +#define lapDDP 2 /* DDP type */ +#define lapKLAP 'K' /* Kinetics KLAP type */ + +/* Datagram Delivery Protocol */ + +struct atDDP { + u_int16_t length; + u_int16_t checksum; + u_int16_t dstNet; + u_int16_t srcNet; + u_int8_t dstNode; + u_int8_t srcNode; + u_int8_t dstSkt; + u_int8_t srcSkt; + u_int8_t type; +}; + +struct atShortDDP { + u_int16_t length; + u_int8_t dstSkt; + u_int8_t srcSkt; + u_int8_t type; +}; + +#define ddpMaxWKS 0x7F +#define ddpMaxData 586 +#define ddpLengthMask 0x3FF +#define ddpHopShift 10 +#define ddpSize 13 /* size of DDP header (avoid struct padding) */ +#define ddpSSize 5 +#define ddpWKS 128 /* boundary of DDP well known sockets */ +#define ddpRTMP 1 /* RTMP type */ +#define ddpRTMPrequest 5 /* RTMP request type */ +#define ddpNBP 2 /* NBP type */ +#define ddpATP 3 /* ATP type */ +#define ddpECHO 4 /* ECHO type */ +#define ddpIP 22 /* IP type */ +#define ddpARP 23 /* ARP type */ +#define ddpEIGRP 88 /* EIGRP over Appletalk */ +#define ddpKLAP 0x4b /* Kinetics KLAP type */ + + +/* AppleTalk Transaction Protocol */ + +struct atATP { + u_int8_t control; + u_int8_t bitmap; + u_int16_t transID; + int32_t userData; +}; + +#define atpReqCode 0x40 +#define atpRspCode 0x80 +#define atpRelCode 0xC0 +#define atpXO 0x20 +#define atpEOM 0x10 +#define atpSTS 0x08 +#define atpFlagMask 0x3F +#define atpControlMask 0xF8 +#define atpMaxNum 8 +#define atpMaxData 578 + + +/* AppleTalk Echo Protocol */ + +struct atEcho { + u_int8_t echoFunction; + u_int8_t *echoData; +}; + +#define echoSkt 4 /* the echoer socket */ +#define echoSize 1 /* size of echo header */ +#define echoRequest 1 /* echo request */ +#define echoReply 2 /* echo request */ + + +/* Name Binding Protocol */ + +struct atNBP { + u_int8_t control; + u_int8_t id; +}; + +struct atNBPtuple { + u_int16_t net; + u_int8_t node; + u_int8_t skt; + u_int8_t enumerator; +}; + +#define nbpBrRq 0x10 +#define nbpLkUp 0x20 +#define nbpLkUpReply 0x30 + +#define nbpNIS 2 +#define nbpTupleMax 15 + +#define nbpHeaderSize 2 +#define nbpTupleSize 5 + +#define nbpSkt 2 /* NIS */ + + +/* Routing Table Maint. Protocol */ + +#define rtmpSkt 1 /* number of RTMP socket */ +#define rtmpSize 4 /* minimum size */ +#define rtmpTupleSize 3 + + +/* Zone Information Protocol */ + +struct zipHeader { + u_int8_t command; + u_int8_t netcount; +}; + +#define zipHeaderSize 2 +#define zipQuery 1 +#define zipReply 2 +#define zipTakedown 3 +#define zipBringup 4 +#define ddpZIP 6 +#define zipSkt 6 +#define GetMyZone 7 +#define GetZoneList 8 + +/* + * UDP port range used for ddp-in-udp encapsulation is 16512-16639 + * for client sockets (128-255) and 200-327 for server sockets + * (0-127). We also try to recognize the pre-April 88 server + * socket range of 768-895. + */ +#define atalk_port(p) \ + (((unsigned)((p) - 16512) < 128) || \ + ((unsigned)((p) - 200) < 128) || \ + ((unsigned)((p) - 768) < 128))
diff --git a/tcpdump-4.3.0/arcnet.h b/tcpdump-4.3.0/arcnet.h new file mode 100644 index 0000000..3b60956 --- /dev/null +++ b/tcpdump-4.3.0/arcnet.h
@@ -0,0 +1,101 @@ +/* + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#) $Id: arcnet.h,v 1.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 on the BSDs, + * as given to interface code. + */ +struct arc_header { + u_int8_t arc_shost; + u_int8_t arc_dhost; + u_int8_t arc_type; + /* + * only present for newstyle encoding with LL fragmentation. + * Don't use sizeof(anything), use ARC_HDR{,NEW}LEN instead. + */ + u_int8_t arc_flag; + u_int16_t arc_seqid; + + /* + * only present in exception packets (arc_flag == 0xff) + */ + u_int8_t arc_type2; /* same as arc_type */ + u_int8_t arc_flag2; /* real flag value */ + u_int16_t arc_seqid2; /* real seqid value */ +}; + +#define ARC_HDRLEN 3 +#define ARC_HDRNEWLEN 6 +#define ARC_HDRNEWLEN_EXC 10 + +/* RFC 1051 */ +#define ARCTYPE_IP_OLD 240 /* IP protocol */ +#define ARCTYPE_ARP_OLD 241 /* address resolution protocol */ + +/* RFC 1201 */ +#define ARCTYPE_IP 212 /* IP protocol */ +#define ARCTYPE_ARP 213 /* address resolution protocol */ +#define ARCTYPE_REVARP 214 /* reverse addr resolution protocol */ + +#define ARCTYPE_ATALK 221 /* Appletalk */ +#define ARCTYPE_BANIAN 247 /* Banyan Vines */ +#define ARCTYPE_IPX 250 /* Novell IPX */ + +#define ARCTYPE_INET6 0xc4 /* IPng */ +#define ARCTYPE_DIAGNOSE 0x80 /* as per ANSI/ATA 878.1 */ + +/* + * 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/tcpdump-4.3.0/atime.awk b/tcpdump-4.3.0/atime.awk new file mode 100644 index 0000000..b42dec2 --- /dev/null +++ b/tcpdump-4.3.0/atime.awk
@@ -0,0 +1,18 @@ +$6 ~ /^ack/ && $5 !~ /[SFR]/ { + # given a tcpdump ftp trace, output one line for each ack + # in the form + # <ack time> <seq no> + # where <ack time> is the time packet was acked (in seconds with + # zero at time of first packet) and <seq no> is the tcp sequence + # number of the ack divided by 1024 (i.e., Kbytes acked). + # + # convert time to seconds + n = split ($1,t,":") + tim = t[1]*3600 + t[2]*60 + t[3] + if (! tzero) { + tzero = tim + OFS = "\t" + } + # get packet sequence number + printf "%7.2f\t%g\n", tim-tzero, $7/1024 + }
diff --git a/tcpdump-4.3.0/atm.h b/tcpdump-4.3.0/atm.h new file mode 100644 index 0000000..65ac5c1 --- /dev/null +++ b/tcpdump-4.3.0/atm.h
@@ -0,0 +1,33 @@ +/* + * 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.3 2006-02-08 01:43:00 hannes Exp $ + */ + +/* + * Traffic types for ATM. + */ +#define ATM_UNKNOWN 0 /* Unknown */ +#define ATM_LANE 1 /* LANE */ +#define ATM_LLC 2 /* LLC encapsulation */ + +/* + * some OAM cell captures (most notably Juniper's) + * do not deliver a heading HEC byte + */ +#define ATM_OAM_NOHEC 0 +#define ATM_OAM_HEC 1 +#define ATM_HDR_LEN_NOHEC 4
diff --git a/tcpdump-4.3.0/atmuni31.h b/tcpdump-4.3.0/atmuni31.h new file mode 100644 index 0000000..ab7a03d --- /dev/null +++ b/tcpdump-4.3.0/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.3 2007-10-22 19:37:51 guy Exp $ (LBL) + */ + +/* Based on UNI3.1 standard by ATM Forum */ + +/* ATM traffic types based on VPI=0 and (the following VCI */ +#define VCI_PPC 0x05 /* Point-to-point signal msg */ +#define VCI_BCC 0x02 /* Broadcast signal msg */ +#define VCI_OAMF4SC 0x03 /* Segment OAM F4 flow cell */ +#define VCI_OAMF4EC 0x04 /* End-to-end OAM F4 flow cell */ +#define VCI_METAC 0x01 /* Meta signal msg */ +#define VCI_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/tcpdump-4.3.0/bgp.h b/tcpdump-4.3.0/bgp.h new file mode 100755 index 0000000..5081596 --- /dev/null +++ b/tcpdump-4.3.0/bgp.h
@@ -0,0 +1,17 @@ +/* @(#) $Header: /tcpdump/master/tcpdump/bgp.h,v 1.3 2004-06-16 08:45:15 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 char *bgp_vpn_rd_print (const u_char *);
diff --git a/tcpdump-4.3.0/bootp.h b/tcpdump-4.3.0/bootp.h new file mode 100644 index 0000000..b1b81dc --- /dev/null +++ b/tcpdump-4.3.0/bootp.h
@@ -0,0 +1,231 @@ +/* @(#) $Header: /tcpdump/master/tcpdump/bootp.h,v 1.19 2008-04-22 09:46:03 hannes Exp $ (LBL) */ +/* + * Bootstrap Protocol (BOOTP). RFC951 and RFC1048. + * + * This file specifies the "implementation-independent" BOOTP protocol + * information which is common to both client and server. + * + * Copyright 1988 by Carnegie Mellon. + * + * Permission to use, copy, modify, and distribute this program for any + * purpose and without fee is hereby granted, provided that this copyright + * and permission notice appear on all copies and supporting documentation, + * the name of Carnegie Mellon not be used in advertising or publicity + * pertaining to distribution of the program without specific prior + * permission, and notice be given in supporting documentation that copying + * and distribution is by permission of Carnegie Mellon and Stanford + * University. Carnegie Mellon makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + */ + + +struct bootp { + u_int8_t bp_op; /* packet opcode type */ + u_int8_t bp_htype; /* hardware addr type */ + u_int8_t bp_hlen; /* hardware addr length */ + u_int8_t bp_hops; /* gateway hops */ + u_int32_t bp_xid; /* transaction ID */ + u_int16_t bp_secs; /* seconds since boot began */ + 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 */ + struct in_addr bp_giaddr; /* gateway IP address */ + u_int8_t bp_chaddr[16]; /* client hardware address */ + u_int8_t bp_sname[64]; /* server host name */ + u_int8_t bp_file[128]; /* boot file name */ + u_int8_t bp_vend[64]; /* vendor-specific area */ +} UNALIGNED; + +/* + * UDP port numbers, server and client. + */ +#define IPPORT_BOOTPS 67 +#define IPPORT_BOOTPC 68 + +#define BOOTPREPLY 2 +#define BOOTPREQUEST 1 + +/* + * Vendor magic cookie (v_magic) for CMU + */ +#define VM_CMU "CMU" + +/* + * Vendor magic cookie (v_magic) for RFC1048 + */ +#define VM_RFC1048 { 99, 130, 83, 99 } + + + +/* + * RFC1048 tag values used to specify what information is being supplied in + * the vendor field of the packet. + */ + +#define TAG_PAD ((u_int8_t) 0) +#define TAG_SUBNET_MASK ((u_int8_t) 1) +#define TAG_TIME_OFFSET ((u_int8_t) 2) +#define TAG_GATEWAY ((u_int8_t) 3) +#define TAG_TIME_SERVER ((u_int8_t) 4) +#define TAG_NAME_SERVER ((u_int8_t) 5) +#define TAG_DOMAIN_SERVER ((u_int8_t) 6) +#define TAG_LOG_SERVER ((u_int8_t) 7) +#define TAG_COOKIE_SERVER ((u_int8_t) 8) +#define TAG_LPR_SERVER ((u_int8_t) 9) +#define TAG_IMPRESS_SERVER ((u_int8_t) 10) +#define TAG_RLP_SERVER ((u_int8_t) 11) +#define TAG_HOSTNAME ((u_int8_t) 12) +#define TAG_BOOTSIZE ((u_int8_t) 13) +#define TAG_END ((u_int8_t) 255) +/* RFC1497 tags */ +#define TAG_DUMPPATH ((u_int8_t) 14) +#define TAG_DOMAINNAME ((u_int8_t) 15) +#define TAG_SWAP_SERVER ((u_int8_t) 16) +#define TAG_ROOTPATH ((u_int8_t) 17) +#define TAG_EXTPATH ((u_int8_t) 18) +/* RFC2132 */ +#define TAG_IP_FORWARD ((u_int8_t) 19) +#define TAG_NL_SRCRT ((u_int8_t) 20) +#define TAG_PFILTERS ((u_int8_t) 21) +#define TAG_REASS_SIZE ((u_int8_t) 22) +#define TAG_DEF_TTL ((u_int8_t) 23) +#define TAG_MTU_TIMEOUT ((u_int8_t) 24) +#define TAG_MTU_TABLE ((u_int8_t) 25) +#define TAG_INT_MTU ((u_int8_t) 26) +#define TAG_LOCAL_SUBNETS ((u_int8_t) 27) +#define TAG_BROAD_ADDR ((u_int8_t) 28) +#define TAG_DO_MASK_DISC ((u_int8_t) 29) +#define TAG_SUPPLY_MASK ((u_int8_t) 30) +#define TAG_DO_RDISC ((u_int8_t) 31) +#define TAG_RTR_SOL_ADDR ((u_int8_t) 32) +#define TAG_STATIC_ROUTE ((u_int8_t) 33) +#define TAG_USE_TRAILERS ((u_int8_t) 34) +#define TAG_ARP_TIMEOUT ((u_int8_t) 35) +#define TAG_ETH_ENCAP ((u_int8_t) 36) +#define TAG_TCP_TTL ((u_int8_t) 37) +#define TAG_TCP_KEEPALIVE ((u_int8_t) 38) +#define TAG_KEEPALIVE_GO ((u_int8_t) 39) +#define TAG_NIS_DOMAIN ((u_int8_t) 40) +#define TAG_NIS_SERVERS ((u_int8_t) 41) +#define TAG_NTP_SERVERS ((u_int8_t) 42) +#define TAG_VENDOR_OPTS ((u_int8_t) 43) +#define TAG_NETBIOS_NS ((u_int8_t) 44) +#define TAG_NETBIOS_DDS ((u_int8_t) 45) +#define TAG_NETBIOS_NODE ((u_int8_t) 46) +#define TAG_NETBIOS_SCOPE ((u_int8_t) 47) +#define TAG_XWIN_FS ((u_int8_t) 48) +#define TAG_XWIN_DM ((u_int8_t) 49) +#define TAG_NIS_P_DOMAIN ((u_int8_t) 64) +#define TAG_NIS_P_SERVERS ((u_int8_t) 65) +#define TAG_MOBILE_HOME ((u_int8_t) 68) +#define TAG_SMPT_SERVER ((u_int8_t) 69) +#define TAG_POP3_SERVER ((u_int8_t) 70) +#define TAG_NNTP_SERVER ((u_int8_t) 71) +#define TAG_WWW_SERVER ((u_int8_t) 72) +#define TAG_FINGER_SERVER ((u_int8_t) 73) +#define TAG_IRC_SERVER ((u_int8_t) 74) +#define TAG_STREETTALK_SRVR ((u_int8_t) 75) +#define TAG_STREETTALK_STDA ((u_int8_t) 76) +/* DHCP options */ +#define TAG_REQUESTED_IP ((u_int8_t) 50) +#define TAG_IP_LEASE ((u_int8_t) 51) +#define TAG_OPT_OVERLOAD ((u_int8_t) 52) +#define TAG_TFTP_SERVER ((u_int8_t) 66) +#define TAG_BOOTFILENAME ((u_int8_t) 67) +#define TAG_DHCP_MESSAGE ((u_int8_t) 53) +#define TAG_SERVER_ID ((u_int8_t) 54) +#define TAG_PARM_REQUEST ((u_int8_t) 55) +#define TAG_MESSAGE ((u_int8_t) 56) +#define TAG_MAX_MSG_SIZE ((u_int8_t) 57) +#define TAG_RENEWAL_TIME ((u_int8_t) 58) +#define TAG_REBIND_TIME ((u_int8_t) 59) +#define TAG_VENDOR_CLASS ((u_int8_t) 60) +#define TAG_CLIENT_ID ((u_int8_t) 61) +/* RFC 2241 */ +#define TAG_NDS_SERVERS ((u_int8_t) 85) +#define TAG_NDS_TREE_NAME ((u_int8_t) 86) +#define TAG_NDS_CONTEXT ((u_int8_t) 87) +/* RFC 2242 */ +#define TAG_NDS_IPDOMAIN ((u_int8_t) 62) +#define TAG_NDS_IPINFO ((u_int8_t) 63) +/* RFC 2485 */ +#define TAG_OPEN_GROUP_UAP ((u_int8_t) 98) +/* RFC 2563 */ +#define TAG_DISABLE_AUTOCONF ((u_int8_t) 116) +/* RFC 2610 */ +#define TAG_SLP_DA ((u_int8_t) 78) +#define TAG_SLP_SCOPE ((u_int8_t) 79) +/* RFC 2937 */ +#define TAG_NS_SEARCH ((u_int8_t) 117) +/* RFC 3011 */ +#define TAG_IP4_SUBNET_SELECT ((u_int8_t) 118) +/* RFC 3442 */ +#define TAG_CLASSLESS_STATIC_RT ((u_int8_t) 121) +#define TAG_CLASSLESS_STA_RT_MS ((u_int8_t) 249) +/* ftp://ftp.isi.edu/.../assignments/bootp-dhcp-extensions */ +#define TAG_USER_CLASS ((u_int8_t) 77) +#define TAG_SLP_NAMING_AUTH ((u_int8_t) 80) +#define TAG_CLIENT_FQDN ((u_int8_t) 81) +#define TAG_AGENT_CIRCUIT ((u_int8_t) 82) +#define TAG_AGENT_REMOTE ((u_int8_t) 83) +#define TAG_AGENT_MASK ((u_int8_t) 84) +#define TAG_TZ_STRING ((u_int8_t) 88) +#define TAG_FQDN_OPTION ((u_int8_t) 89) +#define TAG_AUTH ((u_int8_t) 90) +#define TAG_VINES_SERVERS ((u_int8_t) 91) +#define TAG_SERVER_RANK ((u_int8_t) 92) +#define TAG_CLIENT_ARCH ((u_int8_t) 93) +#define TAG_CLIENT_NDI ((u_int8_t) 94) +#define TAG_CLIENT_GUID ((u_int8_t) 97) +#define TAG_LDAP_URL ((u_int8_t) 95) +#define TAG_6OVER4 ((u_int8_t) 96) +#define TAG_PRINTER_NAME ((u_int8_t) 100) +#define TAG_MDHCP_SERVER ((u_int8_t) 101) +#define TAG_IPX_COMPAT ((u_int8_t) 110) +#define TAG_NETINFO_PARENT ((u_int8_t) 112) +#define TAG_NETINFO_PARENT_TAG ((u_int8_t) 113) +#define TAG_URL ((u_int8_t) 114) +#define TAG_FAILOVER ((u_int8_t) 115) +#define TAG_EXTENDED_REQUEST ((u_int8_t) 126) +#define TAG_EXTENDED_OPTION ((u_int8_t) 127) + + +/* DHCP Message types (values for TAG_DHCP_MESSAGE option) */ +#define DHCPDISCOVER 1 +#define DHCPOFFER 2 +#define DHCPREQUEST 3 +#define DHCPDECLINE 4 +#define DHCPACK 5 +#define DHCPNAK 6 +#define DHCPRELEASE 7 +#define DHCPINFORM 8 + + +/* + * "vendor" data permitted for CMU bootp clients. + */ + +struct cmu_vend { + u_int8_t v_magic[4]; /* magic number */ + u_int32_t v_flags; /* flags/opcodes, etc. */ + struct in_addr v_smask; /* Subnet mask */ + struct in_addr v_dgate; /* Default gateway */ + struct in_addr v_dns1, v_dns2; /* Domain name servers */ + struct in_addr v_ins1, v_ins2; /* IEN-116 name servers */ + struct in_addr v_ts1, v_ts2; /* Time servers */ + u_int8_t v_unused[24]; /* currently unused */ +} UNALIGNED; + + +/* v_flags values */ +#define VF_SMASK 1 /* Subnet mask field contains valid data */ + +/* RFC 4702 DHCP Client FQDN Option */ + +#define CLIENT_FQDN_FLAGS_S 0x01 +#define CLIENT_FQDN_FLAGS_O 0x02 +#define CLIENT_FQDN_FLAGS_E 0x04 +#define CLIENT_FQDN_FLAGS_N 0x08
diff --git a/tcpdump-4.3.0/bpf_dump.c b/tcpdump-4.3.0/bpf_dump.c new file mode 100644 index 0000000..b50d7e7 --- /dev/null +++ b/tcpdump-4.3.0/bpf_dump.c
@@ -0,0 +1,66 @@ +/* + * 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. + */ +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/bpf_dump.c,v 1.17 2008-02-14 20:53:49 guy Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <pcap.h> +#include <stdio.h> + +#include "interface.h" + +void +bpf_dump(const struct bpf_program *p, int option) +{ + struct bpf_insn *insn; + int i; + int n = p->bf_len; + + insn = p->bf_insns; + if (option > 2) { + printf("%d\n", n); + for (i = 0; i < n; ++insn, ++i) { + printf("%u %u %u %u\n", insn->code, + insn->jt, insn->jf, insn->k); + } + return ; + } + if (option > 1) { + for (i = 0; i < n; ++insn, ++i) + printf("{ 0x%x, %d, %d, 0x%08x },\n", + insn->code, insn->jt, insn->jf, insn->k); + return; + } + for (i = 0; i < n; ++insn, ++i) { +#ifdef BDEBUG + extern int bids[]; + printf(bids[i] > 0 ? "[%02d]" : " -- ", bids[i] - 1); +#endif + puts(bpf_image(insn, i)); + } +}
diff --git a/tcpdump-4.3.0/chdlc.h b/tcpdump-4.3.0/chdlc.h new file mode 100644 index 0000000..d117263 --- /dev/null +++ b/tcpdump-4.3.0/chdlc.h
@@ -0,0 +1,27 @@ +/* @(#) $Header: /tcpdump/master/tcpdump/chdlc.h,v 1.1 2000-09-18 05:11:43 guy Exp $ (LBL) */ +/* + * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#define CHDLC_HDRLEN 4 +#define CHDLC_UNICAST 0x0f +#define CHDLC_BCAST 0x8f +#define CHDLC_TYPE_SLARP 0x8035 +#define CHDLC_TYPE_CDP 0x2000
diff --git a/tcpdump-4.3.0/checksum.c b/tcpdump-4.3.0/checksum.c new file mode 100644 index 0000000..da4718f --- /dev/null +++ b/tcpdump-4.3.0/checksum.c
@@ -0,0 +1,196 @@ +/* + * Copyright (c) 1998-2006 The TCPDUMP project + * + * 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. + * + * miscellaneous checksumming routines + * + * Original code by Hannes Gredler (hannes@juniper.net) + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/checksum.c,v 1.4 2006-09-25 09:23:32 hannes Exp $"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <assert.h> + +#include "interface.h" + +/* + * CRC-10 table generated using the following Python snippet: + +import sys + +crc_table = [] +for i in range(256): + accum = i << 2 + for j in range(8): + accum <<= 1 + if accum & 0x400: + accum ^= 0x633 + crc_table.append(accum) + +for i in range(len(crc_table)/8): + for j in range(8): + sys.stdout.write("0x%04x, " % crc_table[i*8+j]) + sys.stdout.write("\n") + + */ +static const u_int16_t crc10_table[256] = +{ + 0x0000, 0x0233, 0x0255, 0x0066, 0x0299, 0x00aa, 0x00cc, 0x02ff, + 0x0301, 0x0132, 0x0154, 0x0367, 0x0198, 0x03ab, 0x03cd, 0x01fe, + 0x0031, 0x0202, 0x0264, 0x0057, 0x02a8, 0x009b, 0x00fd, 0x02ce, + 0x0330, 0x0103, 0x0165, 0x0356, 0x01a9, 0x039a, 0x03fc, 0x01cf, + 0x0062, 0x0251, 0x0237, 0x0004, 0x02fb, 0x00c8, 0x00ae, 0x029d, + 0x0363, 0x0150, 0x0136, 0x0305, 0x01fa, 0x03c9, 0x03af, 0x019c, + 0x0053, 0x0260, 0x0206, 0x0035, 0x02ca, 0x00f9, 0x009f, 0x02ac, + 0x0352, 0x0161, 0x0107, 0x0334, 0x01cb, 0x03f8, 0x039e, 0x01ad, + 0x00c4, 0x02f7, 0x0291, 0x00a2, 0x025d, 0x006e, 0x0008, 0x023b, + 0x03c5, 0x01f6, 0x0190, 0x03a3, 0x015c, 0x036f, 0x0309, 0x013a, + 0x00f5, 0x02c6, 0x02a0, 0x0093, 0x026c, 0x005f, 0x0039, 0x020a, + 0x03f4, 0x01c7, 0x01a1, 0x0392, 0x016d, 0x035e, 0x0338, 0x010b, + 0x00a6, 0x0295, 0x02f3, 0x00c0, 0x023f, 0x000c, 0x006a, 0x0259, + 0x03a7, 0x0194, 0x01f2, 0x03c1, 0x013e, 0x030d, 0x036b, 0x0158, + 0x0097, 0x02a4, 0x02c2, 0x00f1, 0x020e, 0x003d, 0x005b, 0x0268, + 0x0396, 0x01a5, 0x01c3, 0x03f0, 0x010f, 0x033c, 0x035a, 0x0169, + 0x0188, 0x03bb, 0x03dd, 0x01ee, 0x0311, 0x0122, 0x0144, 0x0377, + 0x0289, 0x00ba, 0x00dc, 0x02ef, 0x0010, 0x0223, 0x0245, 0x0076, + 0x01b9, 0x038a, 0x03ec, 0x01df, 0x0320, 0x0113, 0x0175, 0x0346, + 0x02b8, 0x008b, 0x00ed, 0x02de, 0x0021, 0x0212, 0x0274, 0x0047, + 0x01ea, 0x03d9, 0x03bf, 0x018c, 0x0373, 0x0140, 0x0126, 0x0315, + 0x02eb, 0x00d8, 0x00be, 0x028d, 0x0072, 0x0241, 0x0227, 0x0014, + 0x01db, 0x03e8, 0x038e, 0x01bd, 0x0342, 0x0171, 0x0117, 0x0324, + 0x02da, 0x00e9, 0x008f, 0x02bc, 0x0043, 0x0270, 0x0216, 0x0025, + 0x014c, 0x037f, 0x0319, 0x012a, 0x03d5, 0x01e6, 0x0180, 0x03b3, + 0x024d, 0x007e, 0x0018, 0x022b, 0x00d4, 0x02e7, 0x0281, 0x00b2, + 0x017d, 0x034e, 0x0328, 0x011b, 0x03e4, 0x01d7, 0x01b1, 0x0382, + 0x027c, 0x004f, 0x0029, 0x021a, 0x00e5, 0x02d6, 0x02b0, 0x0083, + 0x012e, 0x031d, 0x037b, 0x0148, 0x03b7, 0x0184, 0x01e2, 0x03d1, + 0x022f, 0x001c, 0x007a, 0x0249, 0x00b6, 0x0285, 0x02e3, 0x00d0, + 0x011f, 0x032c, 0x034a, 0x0179, 0x0386, 0x01b5, 0x01d3, 0x03e0, + 0x021e, 0x002d, 0x004b, 0x0278, 0x0087, 0x02b4, 0x02d2, 0x00e1 +}; + +static void +init_crc10_table(void) +{ +#define CRC10_POLYNOMIAL 0x633 + register int i, j; + register u_int16_t accum; + u_int16_t verify_crc10_table[256]; + + for ( i = 0; i < 256; i++ ) + { + accum = ((unsigned short) i << 2); + for ( j = 0; j < 8; j++ ) + { + if ((accum <<= 1) & 0x400) accum ^= CRC10_POLYNOMIAL; + } + verify_crc10_table[i] = accum; + } + assert(memcmp(verify_crc10_table, + crc10_table, + sizeof(verify_crc10_table)) == 0); +#undef CRC10_POLYNOMIAL +} + +u_int16_t +verify_crc10_cksum(u_int16_t accum, const u_char *p, int length) +{ + register int i; + + for ( i = 0; i < length; i++ ) + { + accum = ((accum << 8) & 0x3ff) + ^ crc10_table[( accum >> 2) & 0xff] + ^ *p++; + } + return accum; +} + +/* precompute checksum tables */ +void +init_checksum(void) { + + init_crc10_table(); + +} + +/* + * Creates the OSI Fletcher checksum. See 8473-1, Appendix C, section C.3. + * The checksum field of the passed PDU does not need to be reset to zero. + */ +u_int16_t +create_osi_cksum (const u_int8_t *pptr, int checksum_offset, int length) +{ + + int x; + int y; + u_int32_t mul; + u_int32_t c0; + u_int32_t c1; + u_int16_t checksum; + int index; + + checksum = 0; + + c0 = 0; + c1 = 0; + + for (index = 0; index < length; index++) { + /* + * Ignore the contents of the checksum field. + */ + if (index == checksum_offset || + index == checksum_offset+1) { + c1 += c0; + pptr++; + } else { + c0 = c0 + *(pptr++); + c1 += c0; + } + } + + c0 = c0 % 255; + c1 = c1 % 255; + + mul = (length - checksum_offset)*(c0); + + x = mul - c0 - c1; + y = c1 - mul - 1; + + if ( y >= 0 ) y++; + if ( x < 0 ) x--; + + x %= 255; + y %= 255; + + + if (x == 0) x = 255; + if (y == 0) y = 255; + + y &= 0x00FF; + checksum = ((x << 8) | y); + + return checksum; +}
diff --git a/tcpdump-4.3.0/config.guess b/tcpdump-4.3.0/config.guess new file mode 100755 index 0000000..c2246a4 --- /dev/null +++ b/tcpdump-4.3.0/config.guess
@@ -0,0 +1,1502 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 +# Free Software Foundation, Inc. + +timestamp='2009-12-30' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA +# 02110-1301, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + + +# Originally written by Per Bothner. Please send patches (context +# diff format) to <config-patches@gnu.org> and include a ChangeLog +# entry. +# +# This script attempts to guess a canonical system name similar to +# config.sub. If it succeeds, it prints the system name on stdout, and +# exits with 0. Otherwise, it exits with 1. +# +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to <config-patches@gnu.org>." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, +2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free +Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + +trap '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. + +# 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 "$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 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 ; + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac ; set_cc_for_build= ;' + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 1994-08-24) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + *:NetBSD:*:*) + # NetBSD (nbsd) targets should (where applicable) match one or + # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # + # 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 ;; + sh5el) machine=sh5le-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_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 -q __ELF__ + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # The OS release + # 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 ;; + *:OpenBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + exit ;; + *:ekkoBSD:*:*) + echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + exit ;; + *:SolidBSD:*:*) + echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} + exit ;; + macppc:MirBSD:*:*) + echo powerpc-unknown-mirbsd${UNAME_RELEASE} + exit ;; + *:MirBSD:*:*) + echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + exit ;; + alpha:OSF1:*:*) + case $UNAME_RELEASE in + *4.0) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + ;; + *5.*) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + ;; + esac + # According to Compaq, /usr/sbin/psrinfo has been available on + # OSF/1 and Tru64 systems produced since 1995. I hope that + # covers most systems running today. This code pipes the CPU + # 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 Pn.n version is a patched version. + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + exit ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-unknown-sysv4 + exit ;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit ;; + *:[Mm]orph[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-morphos + exit ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit ;; + *:z/VM:*:*) + echo s390-ibm-zvmoe + exit ;; + *:OS400:*:*) + echo powerpc-ibm-os400 + exit ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit ;; + arm:riscos:*:*|arm:RISCOS:*:*) + echo arm-unknown-riscos + exit ;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit ;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit ;; + DRS?6000:unix:4.0:6*) + echo sparc-icl-nx6 + exit ;; + DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) echo sparc-icl-nx7; exit ;; + esac ;; + s390x:SunOS:*:*) + echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) + echo i386-pc-auroraux${UNAME_RELEASE} + exit ;; + i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) + eval $set_cc_for_build + SUN_ARCH="i386" + # If there is a compiler, see if it is configured for 64-bit objects. + # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. + # This test works for both compilers. + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + SUN_ARCH="x86_64" + fi + fi + echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint${UNAME_RELEASE} + exit ;; + m68k:machten:*:*) + echo m68k-apple-machten${UNAME_RELEASE} + exit ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus +#include <stdio.h> /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && + dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`$dummy $dummyarg` && + { echo "$SYSTEM_NAME"; exit; } + echo mips-mips-riscos${UNAME_RELEASE} + exit ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit ;; + Motorola:*:4.3:PL8-*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else + echo i586-dg-dgux${UNAME_RELEASE} + fi + exit ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + echo i386-ibm-aix + exit ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + exit ;; + *: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> + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + then + echo "$SYSTEM_NAME" + else + echo rs6000-ibm-aix3.2.5 + fi + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit ;; + *:AIX:*:[456]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` + if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; + '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + esac ;; + esac + fi + if [ "${HP_ARCH}" = "" ]; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include <stdlib.h> + #include <unistd.h> + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS= $CC_FOR_BUILD -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 + eval $set_cc_for_build + + # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating + # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler + # generating 64-bit code. GNU and HP use different nomenclature: + # + # $ CC_FOR_BUILD=cc ./config.guess + # => hppa2.0w-hp-hpux11.23 + # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess + # => hppa64-hp-hpux11.23 + + if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + grep -q __LP64__ + then + HP_ARCH="hppa2.0w" + else + HP_ARCH="hppa64" + fi + fi + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux${HPUX_REV} + exit ;; + 3050*:HI-UX:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include <unistd.h> + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + echo unknown-hitachi-hiuxwe2 + exit ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit ;; + i*86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*T3E:*:*:*) + echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + *:UNICOS/mp:*:*) + echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + 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 ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:FreeBSD:*:*) + case ${UNAME_MACHINE} in + pc98) + echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + amd64) + echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + *) + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + esac + exit ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit ;; + *:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit ;; + i*:windows32*:*) + # uname -m includes "-pc" on this system. + echo ${UNAME_MACHINE}-mingw32 + exit ;; + i*:PW*:*) + echo ${UNAME_MACHINE}-pc-pw32 + exit ;; + *:Interix*:*) + case ${UNAME_MACHINE} in + x86) + echo i586-pc-interix${UNAME_RELEASE} + exit ;; + authenticamd | genuineintel | EM64T) + echo x86_64-unknown-interix${UNAME_RELEASE} + exit ;; + IA64) + echo ia64-unknown-interix${UNAME_RELEASE} + exit ;; + esac ;; + [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) + echo i${UNAME_MACHINE}-pc-mks + exit ;; + 8664:Windows_NT:*) + echo x86_64-pc-mks + exit ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i586-pc-interix + exit ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit ;; + amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) + echo x86_64-unknown-cygwin + exit ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + *:GNU:*:*) + # the GNU system + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit ;; + *:GNU/*:*:*) + # other systems with GNU libc and userland + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu + exit ;; + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep -q ld.so.1 + if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + exit ;; + arm*:Linux:*:*) + eval $set_cc_for_build + if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_EABI__ + then + echo ${UNAME_MACHINE}-unknown-linux-gnu + else + echo ${UNAME_MACHINE}-unknown-linux-gnueabi + fi + exit ;; + avr32*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + cris:Linux:*:*) + echo cris-axis-linux-gnu + exit ;; + crisv32:Linux:*:*) + echo crisv32-axis-linux-gnu + exit ;; + frv:Linux:*:*) + echo frv-unknown-linux-gnu + exit ;; + i*86:Linux:*:*) + LIBC=gnu + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #ifdef __dietlibc__ + LIBC=dietlibc + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` + echo "${UNAME_MACHINE}-pc-linux-${LIBC}" + exit ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + m32r*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + mips:Linux:*:* | mips64:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef ${UNAME_MACHINE} + #undef ${UNAME_MACHINE}el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=${UNAME_MACHINE}el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=${UNAME_MACHINE} + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } + ;; + or32:Linux:*:*) + echo or32-unknown-linux-gnu + exit ;; + padre:Linux:*:*) + echo sparc-unknown-linux-gnu + exit ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-gnu + exit ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-gnu ;; + PA8*) echo hppa2.0-unknown-linux-gnu ;; + *) echo hppa-unknown-linux-gnu ;; + esac + exit ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-gnu + exit ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-gnu + exit ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux + exit ;; + sh64*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + sh*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + vax:Linux:*:*) + echo ${UNAME_MACHINE}-dec-linux-gnu + exit ;; + x86_64:Linux:*:*) + echo x86_64-unknown-linux-gnu + exit ;; + xtensa*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + echo i386-sequent-sysv4 + exit ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit ;; + 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 ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-unknown-atheos + exit ;; + i*86:syllable:*:*) + echo ${UNAME_MACHINE}-pc-syllable + exit ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit ;; + i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + fi + exit ;; + i*86:*:5:[678]*) + # UnixWare 7.x, OpenUNIX and OpenServer 6. + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + exit ;; + 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|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|grep '^Machine.*Pent *II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/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 ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i586. + # Note: whatever this is, it MUST be the same as what config.sub + # prints for the "djgpp" host, or else GDB configury will decide that + # this is a cross-build. + echo i586-pc-msdosdjgpp + exit ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit ;; + mc68k:UNIX:SYSTEM5:3.51m) + echo m68k-convergent-sysv + exit ;; + M680?0:D-NIX:5.3:*) + echo m68k-diab-dnix + exit ;; + M68*:*:R3V[5678]*:*) + test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; + NCR*:*:4.2:* | MPRAS*:*:4.2:*) + OS_REL='.3' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit ;; + rs6000:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) + echo powerpc-unknown-lynxos${UNAME_RELEASE} + exit ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says <Richard.M.Bartel@ccMail.Census.GOV> + echo i586-unisys-sysv4 + exit ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes <hewes@openmarket.com>. + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit ;; + i*86:VOS:*:*) + # From Paul.Green@stratus.com. + echo ${UNAME_MACHINE}-stratus-vos + exit ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + echo hppa1.1-stratus-vos + exit ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit ;; + news*:NEWS-OS:6*:*) + echo mips-sony-newsos6 + exit ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit ;; + BePC:Haiku:*:*) # Haiku running on Intel PC compatible. + echo i586-pc-haiku + exit ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit ;; + SX-6:SUPER-UX:*:*) + echo sx6-nec-superux${UNAME_RELEASE} + exit ;; + SX-7:SUPER-UX:*:*) + echo sx7-nec-superux${UNAME_RELEASE} + exit ;; + SX-8:SUPER-UX:*:*) + echo sx8-nec-superux${UNAME_RELEASE} + exit ;; + SX-8R:SUPER-UX:*:*) + echo sx8r-nec-superux${UNAME_RELEASE} + exit ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Darwin:*:*) + UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown + case $UNAME_PROCESSOR in + i386) + eval $set_cc_for_build + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + UNAME_PROCESSOR="x86_64" + fi + fi ;; + unknown) UNAME_PROCESSOR=powerpc ;; + esac + echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + exit ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = "x86"; then + UNAME_PROCESSOR=i386 + UNAME_MACHINE=pc + fi + echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + exit ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit ;; + NSE-?:NONSTOP_KERNEL:*:*) + echo nse-tandem-nsk${UNAME_RELEASE} + exit ;; + NSR-?:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = "386"; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo ${UNAME_MACHINE}-unknown-plan9 + exit ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit ;; + SEI:*:*:SEIUX) + echo mips-sei-seiux${UNAME_RELEASE} + exit ;; + *:DragonFly:*:*) + echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit ;; + *:*VMS:*:*) + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case "${UNAME_MACHINE}" in + A*) echo alpha-dec-vms ; exit ;; + I*) echo ia64-dec-vms ; exit ;; + V*) echo vax-dec-vms ; exit ;; + esac ;; + *:XENIX:*:SysV) + echo i386-pc-xenix + exit ;; + i*86:skyos:*:*) + echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' + exit ;; + i*86:rdos:*:*) + echo ${UNAME_MACHINE}-pc-rdos + exit ;; + i*86:AROS:*:*) + echo ${UNAME_MACHINE}-pc-aros + exit ;; +esac + +#echo '(No uname command or uname output not recognized.)' 1>&2 +#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> +# include <sys/utsname.h> +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include <sys/param.h> + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (__arm) && defined (__acorn) && defined (__unix) + printf ("arm-acorn-riscix\n"); exit (0); +#endif + +#if defined (hp300) && !defined (hpux) + printf ("m68k-hp-bsd\n"); exit (0); +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); + +#endif + +#if defined (vax) +# if !defined (ultrix) +# include <sys/param.h> +# if defined (BSD) +# if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +# else +# if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# endif +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# else + printf ("vax-dec-ultrix\n"); exit (0); +# endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + +# Apollos put the system type in the environment. + +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } + +# Convex versions that predate uname can use getsysinfo(1) + +if [ -x /usr/convex/getsysinfo ] +then + case `getsysinfo -f cpu_type` in + c1*) + echo c1-convex-bsd + exit ;; + c2*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + c34*) + echo c34-convex-bsd + exit ;; + c38*) + echo c38-convex-bsd + exit ;; + c4*) + echo c4-convex-bsd + exit ;; + esac +fi + +cat >&2 <<EOF +$0: unable to guess system type + +This script, last modified $timestamp, has failed to recognize +the operating system you are using. It is advised that you +download the most up to date version of the config scripts from + + http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD +and + http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD + +If the version you run ($0) is already up to date, please +send the following data and any information you think might be +pertinent to <config-patches@gnu.org> in order to provide the needed +information to handle your system. + +config.guess timestamp = $timestamp + +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = ${UNAME_MACHINE} +UNAME_RELEASE = ${UNAME_RELEASE} +UNAME_SYSTEM = ${UNAME_SYSTEM} +UNAME_VERSION = ${UNAME_VERSION} +EOF + +exit 1 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End:
diff --git a/tcpdump-4.3.0/config.h.in b/tcpdump-4.3.0/config.h.in new file mode 100644 index 0000000..9ee068b --- /dev/null +++ b/tcpdump-4.3.0/config.h.in
@@ -0,0 +1,320 @@ +/* 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 if you enable IPv6 support */ +#undef INET6 + +/* Define if you enable support for the libsmi. */ +#undef LIBSMI + +/* define if you have the addrinfo function. */ +#undef HAVE_ADDRINFO + +/* define if you need to include missing/addrinfoh.h. */ +#undef NEED_ADDRINFO_H + +/* define ifyou have the h_errno variable. */ +#undef HAVE_H_ERRNO + +/* 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 libpcap has pcap_dump_ftell() */ +#undef HAVE_PCAP_DUMP_FTELL + +/* define if you have getrpcbynumber() */ +#undef HAVE_GETRPCBYNUMBER + +/* Workaround for missing 64-bit formats */ +#undef PRId64 +#undef PRIo64 +#undef PRIx64 +#undef PRIu64 + +/* Whether or not to include the possibly-buggy SMB printer */ +#undef TCPDUMP_DO_SMB + +/* 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 + +/* define if should drop privileges by default */ +#undef WITH_USER + +/* define if should chroot when dropping privileges */ +#undef WITH_CHROOT + +/* Define to 1 if you have the `alarm' function. */ +#undef HAVE_ALARM + +/* Define to 1 if you have the `bpf_dump' function. */ +#undef HAVE_BPF_DUMP + +/* Define to 1 if you have the declaration of `ether_ntohost', and to 0 if you + don't. */ +#undef HAVE_DECL_ETHER_NTOHOST + +/* Define to 1 if you have the `ether_ntohost' function. */ +#undef HAVE_ETHER_NTOHOST + +/* Define to 1 if you have the <fcntl.h> header file. */ +#undef HAVE_FCNTL_H + +/* Define to 1 if you have the `fork' function. */ +#undef HAVE_FORK + +/* Define to 1 if you have the `getnameinfo' function. */ +#undef HAVE_GETNAMEINFO + +/* 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 to 1 if you have the <net/pfvar.h> header file. */ +#undef HAVE_NET_PFVAR_H + +/* Define to 1 if you have the <openssl/evp.h> header file. */ +#undef HAVE_OPENSSL_EVP_H + +/* if there's an os_proto.h for this platform, to use additional prototypes */ +#undef HAVE_OS_PROTO_H + +/* Define to 1 if you have the <pcap/bluetooth.h> header file. */ +#undef HAVE_PCAP_BLUETOOTH_H + +/* Define to 1 if you have the `pcap_breakloop' function. */ +#undef HAVE_PCAP_BREAKLOOP + +/* Define to 1 if you have the `pcap_create' function. */ +#undef HAVE_PCAP_CREATE + +/* 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 `pcap_set_tstamp_type' function. */ +#undef HAVE_PCAP_SET_TSTAMP_TYPE + +/* Define to 1 if you have the <pcap/usb.h> header file. */ +#undef HAVE_PCAP_USB_H + +/* Define to 1 if you have the `pfopen' function. */ +#undef HAVE_PFOPEN + +/* Define to 1 if you have the <rpc/rpcent.h> header file. */ +#undef HAVE_RPC_RPCENT_H + +/* Define to 1 if you have the <rpc/rpc.h> header file. */ +#undef HAVE_RPC_RPC_H + +/* Define to 1 if you have the `setlinebuf' function. */ +#undef HAVE_SETLINEBUF + +/* Define to 1 if you have the `sigaction' function. */ +#undef HAVE_SIGACTION + +/* Define to 1 if you have the `sigset' function. */ +#undef HAVE_SIGSET + +/* 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 + +/* if struct sockaddr has the sa_len member */ +#undef HAVE_SOCKADDR_SA_LEN + +/* Define to 1 if you have the <stdint.h> header file. */ +#undef HAVE_STDINT_H + +/* 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 to 1 if you have the `strdup' function. */ +#undef HAVE_STRDUP + +/* 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 to 1 if you have the `strlcpy' function. */ +#undef HAVE_STRLCPY + +/* Define to 1 if you have the `strsep' function. */ +#undef HAVE_STRSEP + +/* Define to 1 if the system has the type `struct ether_addr'. */ +#undef HAVE_STRUCT_ETHER_ADDR + +/* Define to 1 if you have the <sys/bitypes.h> header file. */ +#undef HAVE_SYS_BITYPES_H + +/* 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 `vfork' function. */ +#undef HAVE_VFORK + +/* Define to 1 if you have the `vfprintf' function. */ +#undef HAVE_VFPRINTF + +/* Define to 1 if you have the `vsnprintf' function. */ +#undef HAVE_VSNPRINTF + +/* define if your compiler has __attribute__ */ +#undef HAVE___ATTRIBUTE__ + +/* if unaligned access fails */ +#undef LBL_ALIGN + +/* Define to 1 if netinet/ether.h declares `ether_ntohost' */ +#undef NETINET_ETHER_H_DECLARES_ETHER_NTOHOST + +/* Define to 1 if netinet/if_ether.h declares `ether_ntohost' */ +#undef NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define as the return type of signal handlers (`int' or `void'). */ +#undef RETSIGTYPE + +/* return value of signal handlers */ +#undef RETSIGVAL + +/* 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 + +/* get BSD semantics on Irix */ +#undef _BSD_SIGNALS + +/* needed on HP-UX */ +#undef _HPUX_SOURCE + +/* define on AIX to get certain functions */ +#undef _SUN + +/* define if your compiler allows __attribute__((format)) to be applied to + function pointers */ +#undef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS + +/* to handle Ultrix compilers that don't support const in prototypes */ +#undef const + +/* Define as token for inline if inlining supported */ +#undef inline + +/* Define to `short' if int16_t not defined. */ +#undef int16_t + +/* Define to `int' if int32_t not defined. */ +#undef int32_t + +/* Define to `long long' if int64_t not defined. */ +#undef int64_t + +/* Define to `signed char' if int8_t not defined. */ +#undef int8_t + +/* Define to `unsigned short' if u_int16_t not defined. */ +#undef u_int16_t + +/* Define to `unsigned int' if u_int32_t not defined. */ +#undef u_int32_t + +/* Define to `unsigned long long' if u_int64_t not defined. */ +#undef u_int64_t + +/* Define to `unsigned char' if u_int8_t not defined. */ +#undef u_int8_t
diff --git a/tcpdump-4.3.0/config.sub b/tcpdump-4.3.0/config.sub new file mode 100755 index 0000000..8518609 --- /dev/null +++ b/tcpdump-4.3.0/config.sub
@@ -0,0 +1,1708 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 +# Free Software Foundation, Inc. + +timestamp='2009-12-31' + +# This file is (in principle) common to ALL GNU software. +# The presence of a machine in this file suggests that SOME GNU software +# can handle that machine. It does not imply ALL GNU software can. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA +# 02110-1301, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + + +# Please send patches to <config-patches@gnu.org>. Submit a context +# diff and a properly formatted GNU ChangeLog entry. +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS + $0 [OPTION] ALIAS + +Canonicalize a configuration name. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to <config-patches@gnu.org>." + +version="\ +GNU config.sub ($timestamp) + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, +2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free +Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo $1 + exit ;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ + uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ + kopensolaris*-gnu* | \ + storm-chaos* | os2-emx* | rtmk-nova*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple | -axis | -knuth | -cray | -microblaze) + os= + basic_machine=$1 + ;; + -bluegene*) + os=-cnk + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -chorusos*) + os=-chorusos + basic_machine=$1 + ;; + -chorusrdb) + os=-chorusrdb + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco6) + os=-sco5v6 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5) + os=-sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -udk*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + 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 | avr32 \ + | bfin \ + | c4x | clipper \ + | d10v | d30v | dlx | dsp16xx \ + | fido | fr30 | frv \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | i370 | i860 | i960 | ia64 \ + | ip2k | iq2000 \ + | lm32 \ + | m32c | m32r | m32rle | m68000 | m68k | m88k \ + | maxq | mb | microblaze | mcore | mep | metag \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64el \ + | mips64octeon | mips64octeonel \ + | mips64orion | mips64orionel \ + | mips64r5900 | mips64r5900el \ + | mips64vr | mips64vrel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | moxie \ + | mt \ + | msp430 \ + | nios | nios2 \ + | ns16k | ns32k \ + | or32 \ + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ + | pyramid \ + | rx \ + | score \ + | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ + | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ + | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ + | spu | strongarm \ + | tahoe | thumb | tic4x | tic80 | tron \ + | ubicom32 \ + | v850 | v850e \ + | we32k \ + | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ + | z8k | z80) + basic_machine=$basic_machine-unknown + ;; + m6811 | m68hc11 | m6812 | m68hc12 | picochip) + # Motorola 68HC11/12. + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + ;; + ms1) + basic_machine=mt-unknown + ;; + + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + 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-* | avr32-* \ + | bfin-* | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ + | clipper-* | craynv-* | cydra-* \ + | d10v-* | d30v-* | dlx-* \ + | elxsi-* \ + | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ + | h8300-* | h8500-* \ + | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | i*86-* | i860-* | i960-* | ia64-* \ + | ip2k-* | iq2000-* \ + | lm32-* \ + | m32c-* | m32r-* | m32rle-* \ + | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ + | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ + | mips16-* \ + | mips64-* | mips64el-* \ + | mips64octeon-* | mips64octeonel-* \ + | mips64orion-* | mips64orionel-* \ + | mips64r5900-* | mips64r5900el-* \ + | mips64vr-* | mips64vrel-* \ + | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* \ + | mips64vr5000-* | mips64vr5000el-* \ + | mips64vr5900-* | mips64vr5900el-* \ + | mipsisa32-* | mipsisa32el-* \ + | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa64-* | mipsisa64el-* \ + | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipstx39-* | mipstx39el-* \ + | mmix-* \ + | mt-* \ + | msp430-* \ + | nios-* | nios2-* \ + | none-* | np1-* | ns16k-* | ns32k-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ + | pyramid-* \ + | romp-* | rs6000-* | rx-* \ + | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ + | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ + | sparclite-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ + | tahoe-* | thumb-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \ + | tron-* \ + | ubicom32-* \ + | v850-* | v850e-* | vax-* \ + | we32k-* \ + | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ + | xstormy16-* | xtensa*-* \ + | ymp-* \ + | z8k-* | z80-*) + ;; + # Recognize the basic CPU types without company name, with glob match. + xtensa*) + basic_machine=$basic_machine-unknown + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) + basic_machine=i386-unknown + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) + basic_machine=a29k-amd + os=-udi + ;; + abacus) + basic_machine=abacus-unknown + ;; + adobe68k) + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amd64) + basic_machine=x86_64-pc + ;; + amd64-*) + basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-unknown + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aros) + basic_machine=i386-pc + os=-aros + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + blackfin) + basic_machine=bfin-unknown + os=-linux + ;; + blackfin-*) + basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + bluegene*) + basic_machine=powerpc-ibm + os=-cnk + ;; + c90) + basic_machine=c90-cray + os=-unicos + ;; + cegcc) + basic_machine=arm-unknown + os=-cegcc + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | j90) + basic_machine=j90-cray + os=-unicos + ;; + craynv) + basic_machine=craynv-cray + os=-unicosmp + ;; + cr16) + basic_machine=cr16-unknown + os=-elf + ;; + crds | unos) + basic_machine=m68k-crds + ;; + crisv32 | crisv32-* | etraxfs*) + basic_machine=crisv32-axis + ;; + cris | cris-* | etrax*) + basic_machine=cris-axis + ;; + crx) + basic_machine=crx-unknown + os=-elf + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + 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 + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + dicos) + basic_machine=i686-pc + os=-dicos + ;; + djgpp) + basic_machine=i586-pc + os=-msdosdjgpp + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + go32) + basic_machine=i386-pc + os=-go32 + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=-osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + ;; +# I'm not sure what "Sysv32" means. Should this be sysv3.2? + i*86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i*86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i*86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i*86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) + basic_machine=i386-mach + os=-mach + ;; + i386-vsta | vsta) + basic_machine=i386-unknown + os=-vsta + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + m68knommu) + basic_machine=m68k-unknown + os=-linux + ;; + m68knommu-*) + basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + microblaze) + basic_machine=microblaze-xilinx + ;; + mingw32) + basic_machine=i386-pc + os=-mingw32 + ;; + mingw32ce) + basic_machine=arm-unknown + os=-mingw32ce + ;; + miniframe) + basic_machine=m68000-convergent + ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + monitor) + basic_machine=m68k-rom68k + os=-coff + ;; + morphos) + basic_machine=powerpc-unknown + os=-morphos + ;; + msdos) + basic_machine=i386-pc + os=-msdos + ;; + ms1-*) + basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) + basic_machine=i960-intel + os=-mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=-nonstopux + ;; + np1) + basic_machine=np1-gould + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + openrisc | openrisc-*) + basic_machine=or32-unknown + ;; + os400) + basic_machine=powerpc-ibm + os=-os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + parisc) + basic_machine=hppa-unknown + os=-linux + ;; + parisc-*) + basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pc98) + basic_machine=i386-pc + ;; + pc98-*) + basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium | p5 | k5 | k6 | nexgen | viac3) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86 | athlon | athlon_*) + basic_machine=i686-pc + ;; + pentiumii | pentium2 | pentiumiii | pentium3) + basic_machine=i686-pc + ;; + 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-* | 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 + ;; + pw32) + basic_machine=i586-unknown + os=-pw32 + ;; + rdos) + basic_machine=i386-pc + os=-rdos + ;; + rom68k) + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + 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 + ;; + sde) + basic_machine=mipsisa32-sde + os=-elf + ;; + sei) + basic_machine=mips-sei + os=-seiux + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sh5el) + basic_machine=sh5le-unknown + ;; + sh64) + basic_machine=sh64-unknown + ;; + sparclite-wrs | simso-wrs) + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) + basic_machine=m68k-tandem + ;; + stratus) + basic_machine=i860-stratus + os=-sysv4 + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3e) + 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 + ;; + tile*) + basic_machine=tile-unknown + os=-linux-gnu + ;; + 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 + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf + ;; + xbox) + basic_machine=i686-pc + os=-mingw32 + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + ymp) + basic_machine=ymp-cray + os=-unicos + ;; + z8k-*-coff) + basic_machine=z8k-unknown + os=-sim + ;; + z80-*-coff) + basic_machine=z80-unknown + os=-sim + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) + basic_machine=hppa1.1-winbond + ;; + op50n) + basic_machine=hppa1.1-oki + ;; + op60c) + basic_machine=hppa1.1-oki + ;; + romp) + basic_machine=romp-ibm + ;; + mmix) + basic_machine=mmix-knuth + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp10) + # there are many clones, so DEC is not a safe bet + basic_machine=pdp10-unknown + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) + basic_machine=sh-unknown + ;; + sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) + basic_machine=powerpc-apple + ;; + *-unknown) + # Make sure to match an already-canonicalized machine name. + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -auroraux) + os=-auroraux + ;; + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* | -aros* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ + | -openbsd* | -solidbsd* \ + | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ + | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -chorusos* | -chorusrdb* | -cegcc* \ + | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ + | -uxpv* | -beos* | -mpeix* | -udk* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto-qnx*) + ;; + -nto*) + os=`echo $os | sed -e 's|nto|nto-qnx|'` + ;; + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + -linux-dietlibc) + os=-linux-dietlibc + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -opened*) + os=-openedition + ;; + -os400*) + os=-os400 + ;; + -wince*) + os=-wince + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -atheos*) + os=-atheos + ;; + -syllable*) + os=-syllable + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -nova*) + os=-rtmk-nova + ;; + -ns2 ) + os=-nextstep2 + ;; + -nsk*) + os=-nsk + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -tpf*) + os=-tpf + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) + os=-ose + ;; + -es1800*) + os=-ose + ;; + -xenix) + os=-xenix + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -aros*) + os=-aros + ;; + -kaos*) + os=-kaos + ;; + -zvmoe) + os=-zvmoe + ;; + -dicos*) + os=-dicos + ;; + -nacl*) + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + score-*) + os=-elf + ;; + spu-*) + os=-elf + ;; + *-acorn) + os=-riscix1.2 + ;; + arm*-rebel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + c4x-* | tic4x-*) + os=-coff + ;; + # This must come before the *-dec entry. + pdp10-*) + os=-tops20 + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + # This also exists in the configure program, but was not the + # default. + # os=-sunos4 + ;; + m68*-cisco) + os=-aout + ;; + mep-*) + os=-elf + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + or32-*) + os=-coff + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-be) + os=-beos + ;; + *-haiku) + os=-haiku + ;; + *-ibm) + os=-aix + ;; + *-knuth) + os=-mmixware + ;; + *-wec) + os=-proelf + ;; + *-winbond) + os=-proelf + ;; + *-oki) + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f30[01]-fujitsu | f700-fujitsu) + os=-uxpv + ;; + *-rom68k) + os=-coff + ;; + *-*bug) + os=-coff + ;; + *-apple) + os=-macos + ;; + *-atari*) + os=-mint + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -cnk*|-aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs* | -opened*) + vendor=ibm + ;; + -os400*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -tpf*) + vendor=ibm + ;; + -vxsim* | -vxworks* | -windiss*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + vendor=atari + ;; + -vos*) + vendor=stratus + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os +exit + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End:
diff --git a/tcpdump-4.3.0/configure b/tcpdump-4.3.0/configure new file mode 100755 index 0000000..b8027de --- /dev/null +++ b/tcpdump-4.3.0/configure
@@ -0,0 +1,13165 @@ +#! /bin/sh +# From configure.in Revision: 1.204 . +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.61. +# +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +# 2002, 2003, 2004, 2005, 2006 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 more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +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+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + + + +# PATH needs CR +# 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 + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +as_nl=' +' +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +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 +IFS=$as_save_IFS + + ;; +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_myself: error: cannot find myself; rerun with an absolute file name" >&2 + { (exit 1); exit 1; } +fi + +# Work around bugs in pre-3.0 UWIN ksh. +for as_var in ENV MAIL MAILPATH +do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +done +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 -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; 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'` + +# CDPATH. +$as_unset CDPATH + + +if test "x$CONFIG_SHELL" = x; then + if (eval ":") 2>/dev/null; then + as_have_required=yes +else + as_have_required=no +fi + + if test $as_have_required = yes && (eval ": +(as_func_return () { + (exit \$1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = \"\$1\" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test \$exitcode = 0) || { (exit 1); exit 1; } + +( + as_lineno_1=\$LINENO + as_lineno_2=\$LINENO + test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" && + test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; } +") 2> /dev/null; then + : +else + as_candidate_shells= + 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=. + case $as_dir in + /*) + for as_base in sh bash ksh sh5; do + as_candidate_shells="$as_candidate_shells $as_dir/$as_base" + done;; + esac +done +IFS=$as_save_IFS + + + for as_shell in $as_candidate_shells $SHELL; do + # Try only shells that exist, to save several forks. + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { ("$as_shell") 2> /dev/null <<\_ASEOF +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+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + +: +_ASEOF +}; then + CONFIG_SHELL=$as_shell + as_have_required=yes + if { "$as_shell" 2> /dev/null <<\_ASEOF +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+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + +: +(as_func_return () { + (exit $1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = "$1" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test $exitcode = 0) || { (exit 1); exit 1; } + +( + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; } + +_ASEOF +}; then + break +fi + +fi + + done + + if test "x$CONFIG_SHELL" != x; then + for as_var in BASH_ENV ENV + do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + done + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} +fi + + + if test $as_have_required = no; then + echo This script requires a shell more modern than all the + echo shells that I found on your system. Please install a + echo modern shell, or manually run the script under such a + echo shell if you do have one. + { (exit 1); exit 1; } +fi + + +fi + +fi + + + +(eval "as_func_return () { + (exit \$1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = \"\$1\" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test \$exitcode = 0") || { + echo No shell found that supports shell functions. + echo Please tell autoconf@gnu.org about your system, + echo including any error possibly output before this + echo message +} + + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { + + # 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 after each line using $LINENO; the second 'sed' + # does the real work. The second script uses 'N' to pair each + # line-number line with the line containing $LINENO, 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 + # scripts with optimization help from Paolo Bonzini. Blame Lee + # E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\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 sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in +-n*) + case `echo 'x\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + *) ECHO_C='\c';; + esac;; +*) + ECHO_N='-n';; +esac + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir +fi +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' +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$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval 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="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + + +exec 7<&0 </dev/null 6>&1 + +# 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` + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_clean_files= +ac_config_libobj_dir=. +LIBOBJS= +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} + +# 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> +#ifdef HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif +#ifdef HAVE_SYS_STAT_H +# include <sys/stat.h> +#endif +#ifdef STDC_HEADERS +# include <stdlib.h> +# include <stddef.h> +#else +# ifdef HAVE_STDLIB_H +# include <stdlib.h> +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H +# include <memory.h> +# endif +# include <string.h> +#endif +#ifdef HAVE_STRINGS_H +# include <strings.h> +#endif +#ifdef HAVE_INTTYPES_H +# include <inttypes.h> +#endif +#ifdef HAVE_STDINT_H +# include <stdint.h> +#endif +#ifdef 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 +datarootdir +datadir +sysconfdir +sharedstatedir +localstatedir +includedir +oldincludedir +docdir +infodir +htmldir +dvidir +pdfdir +psdir +libdir +localedir +mandir +DEFS +ECHO_C +ECHO_N +ECHO_T +LIBS +build_alias +host_alias +target_alias +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 +GREP +EGREP +LIBOBJS +PCAP_CONFIG +RANLIB +V_CCOPT +V_DEFS +V_GROUP +V_INCLS +V_PCAPDEP +LOCALSRC +MAN_FILE_FORMATS +MAN_MISC_INFO +INSTALL_PROGRAM +INSTALL_SCRIPT +INSTALL_DATA +LTLIBOBJS' +ac_subst_files='' + ac_precious_vars='build_alias +host_alias +target_alias +CC +CFLAGS +LDFLAGS +LIBS +CPPFLAGS +CPP' + + +# 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. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +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. +# (The list follows the same order as the GNU Coding Standards.) +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datarootdir='${prefix}/share' +datadir='${datarootdir}' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +includedir='${prefix}/include' +oldincludedir='/usr/include' +docdir='${datarootdir}/doc/${PACKAGE}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' + +ac_prev= +ac_dashdash= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval $ac_prev=\$ac_option + ac_prev= + continue + fi + + case $ac_option in + *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *) ac_optarg=yes ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + 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 ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=*) + datadir=$ac_optarg ;; + + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + 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 ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; + + -enable-* | --enable-*) + ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + 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=\$ac_optarg ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -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_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$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 ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + 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 ;; + + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst | --locals) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + 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 | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + 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-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-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + 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 ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + 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=\$ac_optarg ;; + + -without-* | --without-*) + ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + 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. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + 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-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 ;; + + -*) { 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; }; } + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; + + *) + # 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 + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + { echo "$as_me: error: missing argument to $ac_option" >&2 + { (exit 1); exit 1; }; } +fi + +# Be sure to have absolute directory names. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir +do + eval ac_val=\$$ac_var + case $ac_val in + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac + { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; } +done + +# 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 + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + { echo "$as_me: error: Working directory cannot be determined" >&2 + { (exit 1); exit 1; }; } +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + { echo "$as_me: error: pwd does not report name of working directory" >&2 + { (exit 1); exit 1; }; } + + +# 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 the parent directory. + ac_confdir=`$as_dirname -- "$0" || +$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=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 + { (exit 1); exit 1; }; } +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || { echo "$as_me: error: $ac_msg" >&2 + { (exit 1); exit 1; }; } + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. +fi +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done + +# +# 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 \`..'] + +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] + --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] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] +_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] + --disable-universal don't build universal on OS X + --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 + --with-smi link with libsmi (allows to load MIBs on the fly to decode SNMP packets. default=yes + --without-smi don't link with libsmi + --with-user=USERNAME drop privileges by default to USERNAME + --with-chroot=DIRECTORY when dropping privileges, chroot to DIRECTORY + --with-crypto[=PATH] use SSLeay libcrypto (located in directory PATH, if + supplied). [default=yes, if available] + +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> + LIBS libraries to pass to the linker, e.g. -l<library> + CPPFLAGS C/C++/Objective 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 +ac_status=$? +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d "$ac_dir" || continue + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for guested 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 + else + echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } + done +fi + +test -n "$ac_init_help" && exit $ac_status +if $ac_init_version; then + cat <<\_ACEOF +configure +generated by GNU Autoconf 2.61 + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +2002, 2003, 2004, 2005, 2006 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 +fi +cat >config.log <<_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.61. Invocation command line was + + $ $0 $@ + +_ACEOF +exec 5>>config.log +{ +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` +/usr/bin/hostinfo = `(/usr/bin/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 +IFS=$as_save_IFS + +} >&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_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_arg'" + ;; + 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: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. +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, +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 +echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + *) $as_unset $ac_var ;; + esac ;; + esac + done + (set) 2>&1 | + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + sed -n \ + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( + *) + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) + echo + + cat <<\_ASBOX +## ----------------- ## +## Output variables. ## +## ----------------- ## +_ASBOX + echo + for ac_var in $ac_subst_vars + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + echo "$ac_var='\''$ac_val'\''" + done | sort + echo + + if test -n "$ac_subst_files"; then + cat <<\_ASBOX +## ------------------- ## +## File substitutions. ## +## ------------------- ## +_ASBOX + echo + for ac_var in $ac_subst_files + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + echo "$ac_var='\''$ac_val'\''" + done | sort + echo + fi + + if test -s confdefs.h; then + cat <<\_ASBOX +## ----------- ## +## confdefs.h. ## +## ----------- ## +_ASBOX + echo + cat confdefs.h + 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.conftest.* && + rm -f -r 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 -f -r conftest* 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 -n "$CONFIG_SITE"; then + set x "$CONFIG_SITE" +elif test "x$prefix" != xNONE; then + set x "$prefix/share/config.site" "$prefix/etc/config.site" +else + set x "$ac_default_prefix/share/config.site" \ + "$ac_default_prefix/etc/config.site" +fi +shift +for ac_site_file +do + if test -r "$ac_site_file"; then + { 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 + # 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 "$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 $ac_precious_vars; 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 +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 + + + +ac_aux_dir= +for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do + if test -f "$ac_dir/install-sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f "$ac_dir/install.sh"; then + 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 "$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 + +# These three variables are undocumented and unsupported, +# and are intended to be withdrawn in a future Autoconf release. +# They can cause serious problems if a builder's source tree is in a directory +# whose full name contains unusual characters. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. +ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. +ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. + + +# Make sure we can run config.sub. +$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || + { { echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5 +echo "$as_me: error: cannot run $SHELL $ac_aux_dir/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_build_alias=$build_alias +test "x$ac_build_alias" = x && + ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` +test "x$ac_build_alias" = x && + { { 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=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || + { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&5 +echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_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; } +case $ac_cv_build in +*-*-*) ;; +*) { { echo "$as_me:$LINENO: error: invalid value of canonical build" >&5 +echo "$as_me: error: invalid value of canonical build" >&2;} + { (exit 1); exit 1; }; };; +esac +build=$ac_cv_build +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_build +shift +build_cpu=$1 +build_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +build_os=$* +IFS=$ac_save_IFS +case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; 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 + if test "x$host_alias" = x; then + ac_cv_host=$ac_cv_build +else + ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || + { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&5 +echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&2;} + { (exit 1); exit 1; }; } +fi + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_host" >&5 +echo "${ECHO_T}$ac_cv_host" >&6; } +case $ac_cv_host in +*-*-*) ;; +*) { { echo "$as_me:$LINENO: error: invalid value of canonical host" >&5 +echo "$as_me: error: invalid value of canonical host" >&2;} + { (exit 1); exit 1; }; };; +esac +host=$ac_cv_host +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_host +shift +host_cpu=$1 +host_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +host_os=$* +IFS=$ac_save_IFS +case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac + + + + + + + + + +# Check whether --with-gcc was given. +if test "${with_gcc+set}" = set; then + withval=$with_gcc; +fi + + V_CCOPT="-O" + V_INCLS="" + if test "${srcdir}" != "." ; then + V_INCLS="-I$srcdir" + fi + if test "${CFLAGS+set}" = set; then + LBL_CFLAGS="$CFLAGS" + fi + if test -z "$CC" ; then + case "$host_os" in + + bsdi*) + # Extract the first word of "shlicc2", so it can be a program name with args. +set dummy shlicc2; ac_word=$2 +{ echo "$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 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_SHLICC2="yes" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + + test -z "$ac_cv_prog_SHLICC2" && ac_cv_prog_SHLICC2="no" +fi +fi +SHLICC2=$ac_cv_prog_SHLICC2 +if test -n "$SHLICC2"; then + { echo "$as_me:$LINENO: result: $SHLICC2" >&5 +echo "${ECHO_T}$SHLICC2" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + if test $SHLICC2 = yes ; then + CC=shlicc2 + export CC + fi + ;; + esac + fi + if test -z "$CC" -a "$with_gcc" = no ; then + CC=cc + export CC + 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 +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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 +IFS=$as_save_IFS + +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 "$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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 +IFS=$as_save_IFS + +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 + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +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 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +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 +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 "$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 + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + 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 +IFS=$as_save_IFS + +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 $# != 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 + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +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 "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + 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 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_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 +IFS=$as_save_IFS + +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 + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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 +IFS=$as_save_IFS + +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 + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +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` +{ (ac_try="$ac_compiler --version >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler --version >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -v >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler -v >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -V >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler -V >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + 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 file name" >&5 +echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6; } +ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` +# +# List of possible output files, starting from the most likely. +# The algorithm is not robust to junk in `.', hence go to wildcards (a.*) +# only as a last resort. b.out is created by i960 compilers. +ac_files='a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out' +# +# The IRIX 6 linker writes into existing files which may not be +# executable, retaining their permissions. Remove them first so a +# subsequent execution test works. +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { (ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. + break;; + * ) + break;; + esac +done +test "$ac_cv_exeext" = no && ac_cv_exeext= + +else + ac_file='' +fi + +{ echo "$as_me:$LINENO: result: $ac_file" >&5 +echo "${ECHO_T}$ac_file" >&6; } +if test -z "$ac_file"; then + 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 + +# Check that 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' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cross_compiling=no + else + 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 +fi +{ 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 that 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 { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_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 | *.map | *.inf | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + break;; + * ) break;; + esac +done +else + { { 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 +/* 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.o conftest.obj +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + 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 +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_compiler_gnu=no +fi + +rm -f core conftest.err 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 +{ 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 + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* 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 { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + CFLAGS="" + cat >conftest.$ac_ext <<_ACEOF +/* 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 { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* 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 { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +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 +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 +echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; } +if test "${ac_cv_prog_cc_c89+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat >conftest.$ac_ext <<_ACEOF +/* 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; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +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 +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_c89=$ac_arg +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { echo "$as_me:$LINENO: result: none needed" >&5 +echo "${ECHO_T}none needed" >&6; } ;; + xno) + { echo "$as_me:$LINENO: result: unsupported" >&5 +echo "${ECHO_T}unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_c89" >&6; } ;; +esac + + +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 "$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' \ + -e 's/^gcc version //' \ + -e 's/ .*//' -e 's/^[^0-9]*//' \ + -e 's/\..*//'` +fi + + { 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 "$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 +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <sys/types.h> +int +main () +{ +int frob(int, char *) + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_lbl_cc_ansi_prototypes=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lbl_cc_ansi_prototypes=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + + { 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 "$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 test "${ac_cv_lbl_cc_hpux_cc_aa+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <sys/types.h> +int +main () +{ +int frob(int, char *) + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_lbl_cc_hpux_cc_aa=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lbl_cc_hpux_cc_aa=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + + { 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 "$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 <<\_ACEOF +#define _HPUX_SOURCE 1 +_ACEOF + + ;; + + osf*) + { echo "$as_me:$LINENO: checking for ansi mode in DEC compiler ($CC -std1)" >&5 +echo $ECHO_N "checking for ansi mode in DEC compiler ($CC -std1)... $ECHO_C" >&6; } + savedcflags="$CFLAGS" + CFLAGS="-std1" + if test "${ac_cv_lbl_cc_osf1_cc_std1+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <sys/types.h> +int +main () +{ +int frob(int, char *) + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_lbl_cc_osf1_cc_std1=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lbl_cc_osf1_cc_std1=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + + { echo "$as_me:$LINENO: result: $ac_cv_lbl_cc_osf1_cc_std1" >&5 +echo "${ECHO_T}$ac_cv_lbl_cc_osf1_cc_std1" >&6; } + if test $ac_cv_lbl_cc_osf1_cc_std1 = no ; then + { { echo "$as_me:$LINENO: error: see the INSTALL doc for more info" >&5 +echo "$as_me: error: see the INSTALL doc for more info" >&2;} + { (exit 1); exit 1; }; } + fi + CFLAGS="$savedcflags" + V_CCOPT="-std1 $V_CCOPT" + ;; + + *) + { { echo "$as_me:$LINENO: error: see the INSTALL doc for more info" >&5 +echo "$as_me: error: see the INSTALL doc for more info" >&2;} + { (exit 1); exit 1; }; } + ;; + esac + fi + V_INCLS="$V_INCLS -I/usr/local/include" + LDFLAGS="$LDFLAGS -L/usr/local/lib" + + case "$host_os" in + + irix*) + V_CCOPT="$V_CCOPT -xansi -signed -O" + ;; + + osf*) + # + # Presumed to be DEC OSF/1, Digital UNIX, or + # Tru64 UNIX. + # + V_CCOPT="$V_CCOPT -O" + ;; + + ultrix*) + { 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 +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <sys/types.h> +int +main () +{ +struct a { int b; }; + void c(const struct a *) + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_lbl_cc_const_proto=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lbl_cc_const_proto=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + + { echo "$as_me:$LINENO: result: $ac_cv_lbl_cc_const_proto" >&5 +echo "${ECHO_T}$ac_cv_lbl_cc_const_proto" >&6; } + if test $ac_cv_lbl_cc_const_proto = no ; then + +cat >>confdefs.h <<\_ACEOF +#define const +_ACEOF + + fi + ;; + esac + fi + +{ echo "$as_me:$LINENO: checking for inline" >&5 +echo $ECHO_N "checking for inline... $ECHO_C" >&6; } + save_CFLAGS="$CFLAGS" + CFLAGS="$V_CCOPT" + if test "${ac_cv_lbl_inline+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + + ac_cv_lbl_inline="" + ac_lbl_cc_inline=no + for ac_lbl_inline in inline __inline__ __inline + do + cat >conftest.$ac_ext <<_ACEOF +/* 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 { + int iltest1; + int iltest2; + }; + + static inline struct iltest * + foo() + { + static struct iltest xxx; + + return &xxx; + } +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_lbl_cc_inline=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + if test "$ac_lbl_cc_inline" = yes ; then + break; + fi + done + if test "$ac_lbl_cc_inline" = yes ; then + ac_cv_lbl_inline=$ac_lbl_inline + fi +fi + + CFLAGS="$save_CFLAGS" + if test ! -z "$ac_cv_lbl_inline" ; then + { echo "$as_me:$LINENO: result: $ac_cv_lbl_inline" >&5 +echo "${ECHO_T}$ac_cv_lbl_inline" >&6; } + else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + fi + +cat >>confdefs.h <<_ACEOF +#define inline $ac_cv_lbl_inline +_ACEOF + + +{ 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 <<_ACEOF + + /* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#include <stdlib.h> + +static void foo(void) __attribute__ ((noreturn)); + +static void +foo(void) +{ + exit(1); +} + +int +main(int argc, char **argv) +{ + foo(); +} + +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv___attribute__=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv___attribute__=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +if test "$ac_cv___attribute__" = "yes"; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE___ATTRIBUTE__ 1 +_ACEOF + + V_DEFS="$V_DEFS -D_U_=\"__attribute__((unused))\"" +else + V_DEFS="$V_DEFS -D_U_=\"\"" +fi +{ echo "$as_me:$LINENO: result: $ac_cv___attribute__" >&5 +echo "${ECHO_T}$ac_cv___attribute__" >&6; } + +if test "$ac_cv___attribute__" = "yes"; then + +{ echo "$as_me:$LINENO: checking whether __attribute__((format)) can be applied to function pointers" >&5 +echo $ECHO_N "checking whether __attribute__((format)) can be applied to function pointers... $ECHO_C" >&6; } +if test "${ac_cv___attribute___format_function_pointer+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + +cat >conftest.$ac_ext <<_ACEOF + + /* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#include <stdlib.h> + +extern int (*foo)(const char *fmt, ...) + __attribute__ ((format (printf, 1, 2))); + +int +main(int argc, char **argv) +{ + (*foo)("%s", "test"); +} + +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv___attribute___format_function_pointer=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv___attribute___format_function_pointer=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +if test "$ac_cv___attribute___format_function_pointer" = "yes"; then + +cat >>confdefs.h <<\_ACEOF +#define __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS 1 +_ACEOF + +fi +{ echo "$as_me:$LINENO: result: $ac_cv___attribute___format_function_pointer" >&5 +echo "${ECHO_T}$ac_cv___attribute___format_function_pointer" >&6; } + +fi +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +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 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 +/* 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 { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + : +else + 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 nonexistent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <ac_nonexistent.h> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + # 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. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* 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 { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + : +else + 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 nonexistent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <ac_nonexistent.h> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + # 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 "$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 grep that handles long lines and -e" >&5 +echo $ECHO_N "checking for grep that handles long lines and -e... $ECHO_C" >&6; } +if test "${ac_cv_path_GREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Extract the first word of "grep ggrep" to use in msg output +if test -z "$GREP"; then +set dummy grep ggrep; ac_prog_name=$2 +if test "${ac_cv_path_GREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_path_GREP_found=false +# Loop through the user's path and test for each of PROGNAME-LIST +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue + # Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + ac_count=`expr $ac_count + 1` + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + + $ac_path_GREP_found && break 3 + done +done + +done +IFS=$as_save_IFS + + +fi + +GREP="$ac_cv_path_GREP" +if test -z "$GREP"; then + { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + { (exit 1); exit 1; }; } +fi + +else + ac_cv_path_GREP=$GREP +fi + + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5 +echo "${ECHO_T}$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ echo "$as_me:$LINENO: checking for egrep" >&5 +echo $ECHO_N "checking for egrep... $ECHO_C" >&6; } +if test "${ac_cv_path_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_path_EGREP="$GREP -E" + else + # Extract the first word of "egrep" to use in msg output +if test -z "$EGREP"; then +set dummy egrep; ac_prog_name=$2 +if test "${ac_cv_path_EGREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_path_EGREP_found=false +# Loop through the user's path and test for each of PROGNAME-LIST +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue + # Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + ac_count=`expr $ac_count + 1` + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + + $ac_path_EGREP_found && break 3 + done +done + +done +IFS=$as_save_IFS + + +fi + +EGREP="$ac_cv_path_EGREP" +if test -z "$EGREP"; then + { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + { (exit 1); exit 1; }; } +fi + +else + ac_cv_path_EGREP=$EGREP +fi + + + fi +fi +{ echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5 +echo "${ECHO_T}$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_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 +/* 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 { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_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 core conftest.err 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 +/* 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 + ac_cv_header_stdc=no +fi +rm -f -r conftest* + +fi + +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 +/* 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 -r conftest* + +fi + +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 +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <ctype.h> +#include <stdlib.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)) + return 2; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +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 ) +ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +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 + +fi + +# 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 { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + 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 core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&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 + + + + + + +for ac_header in fcntl.h rpc/rpc.h rpc/rpcent.h netdnet/dnetdb.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +for ac_header in net/pfvar.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 { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <sys/types.h> +#include <sys/socket.h> +#include <net/if.h> + +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + 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 core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&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 + +if test "$ac_cv_header_net_pfvar_h" = yes; then + LOCALSRC="print-pflog.c $LOCALSRC" +fi + +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 { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <sys/types.h> +#include <sys/socket.h> + +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + 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 core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&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 + +if test "$ac_cv_header_netinet_if_ether_h" != yes; then + # + # The simple test didn't work. + # Do we need to include <net/if.h> first? + # Unset ac_cv_header_netinet_if_ether_h so we don't + # treat the previous failure as a cached value and + # suppress the next test. + # + { echo "$as_me:$LINENO: Rechecking with some additional includes" >&5 +echo "$as_me: Rechecking with some additional includes" >&6;} + unset ac_cv_header_netinet_if_ether_h + +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 { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <sys/types.h> +#include <sys/socket.h> +#include <netinet/in.h> +struct mbuf; +struct rtentry; +#include <net/if.h> + +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + 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 core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&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 + +fi + +{ 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 +/* 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 () +{ +if ((struct tm *) 0) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_header_time=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_header_time=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ 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 <<\_ACEOF +#define TIME_WITH_SYS_TIME 1 +_ACEOF + +fi + + +case "$host_os" in + +darwin*) + # Check whether --enable-universal was given. +if test "${enable_universal+set}" = set; then + enableval=$enable_universal; +fi + + if test "$enable_universal" != "no"; then + case "$host_os" in + + darwin9.*) + # + # Leopard. Build for x86 and 32-bit PowerPC, with + # x86 first. (That's what Apple does.) + # + V_CCOPT="$V_CCOPT -arch i386 -arch ppc" + LDFLAGS="$LDFLAGS -arch i386 -arch ppc" + ;; + + darwin10.*) + # + # Snow Leopard. Build for x86-64 and x86, with + # x86-64 first. (That's what Apple does.) + # + V_CCOPT="$V_CCOPT -arch x86_64 -arch i386" + LDFLAGS="$LDFLAGS -arch x86_64 -arch i386" + ;; + esac + fi + ;; + +linux*) + { 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 test "${ac_cv_linux_vers+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_linux_vers=unknown +fi + + else + 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 "$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 "$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 "$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 + ;; + +*) + ;; +esac + + + +# Check whether --with-smi was given. +if test "${with_smi+set}" = set; then + withval=$with_smi; +else + with_smi=yes +fi + + +if test "x$with_smi" != "xno" ; then + +for ac_header in smi.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +{ 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_check_lib_save_LIBS=$LIBS +LIBS="-lsmi $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char smiInit (); +int +main () +{ +return smiInit (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + 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" + +fi + +if test "$ac_cv_header_smi_h" = yes -a "$ac_cv_lib_smi_smiInit" = yes +then +{ 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 "$as_me:$LINENO: result: not when cross-compiling" >&5 +echo "${ECHO_T}not when cross-compiling" >&6; } + libsmi=no + +else + cat >conftest.$ac_ext <<_ACEOF +/* 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("")) + exit(1); + if (strcmp(SMI_LIBRARY_VERSION, smi_library_version)) + exit(2); + n = sscanf(smi_library_version, "%d:%d:%d", ¤t, &revision, &age); + if (n != 3) + exit(3); + if (required < current - age || required > current) + exit(4); + exit(0); +} + +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_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 +_ACEOF + + libsmi=yes +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 ) + 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 -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi +fi + +{ echo "$as_me:$LINENO: checking whether to enable the possibly-buggy SMB printer" >&5 +echo $ECHO_N "checking whether to enable the possibly-buggy SMB printer... $ECHO_C" >&6; } +# Check whether --enable-smb was given. +if test "${enable_smb+set}" = set; then + enableval=$enable_smb; +else + enableval=yes +fi + +case "$enableval" in +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 +_ACEOF + + LOCALSRC="print-smb.c smbutil.c $LOCALSRC" + ;; +*) { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + ;; +esac + + +# Check whether --with-user was given. +if test "${with_user+set}" = set; then + withval=$with_user; +fi + +{ echo "$as_me:$LINENO: checking whether to drop root privileges by default" >&5 +echo $ECHO_N "checking whether to drop root privileges by default... $ECHO_C" >&6; } +if test ! -z "$with_user" ; then + cat >>confdefs.h <<_ACEOF +#define WITH_USER "$withval" +_ACEOF + + { echo "$as_me:$LINENO: result: to \"$withval\"" >&5 +echo "${ECHO_T}to \"$withval\"" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + +# Check whether --with-chroot was given. +if test "${with_chroot+set}" = set; then + withval=$with_chroot; +fi + +{ echo "$as_me:$LINENO: checking whether to chroot" >&5 +echo $ECHO_N "checking whether to chroot... $ECHO_C" >&6; } +if test ! -z "$with_chroot" && test "$with_chroot" != "no" ; then + cat >>confdefs.h <<_ACEOF +#define WITH_CHROOT "$withval" +_ACEOF + + { echo "$as_me:$LINENO: result: to \"$withval\"" >&5 +echo "${ECHO_T}to \"$withval\"" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + +{ 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 was given. +if test "${enable_ipv6+set}" = set; then + enableval=$enable_ipv6; case "$enableval" in +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 print-babel.c $LOCALSRC" + cat >>confdefs.h <<\_ACEOF +#define INET6 1 +_ACEOF + + ipv6=yes + ;; +*) + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + ipv6=no + ;; + esac +else + if test "$cross_compiling" = yes; then + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + ipv6=no + +else + cat >conftest.$ac_ext <<_ACEOF +/* 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> +main() +{ + if (socket(AF_INET6, SOCK_STREAM, 0) < 0) + exit(1); + else + exit(0); +} + +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_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 print-babel.c $LOCALSRC" + cat >>confdefs.h <<\_ACEOF +#define INET6 1 +_ACEOF + + ipv6=yes +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: result: no" >&5 +echo "${ECHO_T}no" >&6; } + ipv6=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi + + +ipv6type=unknown +ipv6lib=none +ipv6trylibc=no + +if test "$ipv6" = "yes"; then + { 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 <<_ACEOF +/* 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 +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "yes" >/dev/null 2>&1; then + ipv6type=$i; + CFLAGS="-DINET6 $CFLAGS" +fi +rm -f -r conftest* + + ;; + kame) + cat >conftest.$ac_ext <<_ACEOF +/* 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 +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "yes" >/dev/null 2>&1; then + ipv6type=$i; + ipv6lib=inet6; + ipv6libdir=/usr/local/v6/lib; + ipv6trylibc=yes; + CFLAGS="-DINET6 $CFLAGS" +fi +rm -f -r conftest* + + ;; + linux-glibc) + cat >conftest.$ac_ext <<_ACEOF +/* 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 +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "yes" >/dev/null 2>&1; then + ipv6type=$i; + CFLAGS="-DINET6 $CFLAGS" +fi +rm -f -r conftest* + + ;; + linux-libinet6) + if test -d /usr/inet6 -o -f /usr/include/netinet/ip6.h; then + ipv6type=$i + ipv6lib=inet6 + ipv6libdir=/usr/inet6/lib + ipv6trylibc=yes; + CFLAGS="-DINET6 -I/usr/inet6/include $CFLAGS" + fi + ;; + toshiba) + cat >conftest.$ac_ext <<_ACEOF +/* 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 +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "yes" >/dev/null 2>&1; then + ipv6type=$i; + ipv6lib=inet6; + ipv6libdir=/usr/local/v6/lib; + CFLAGS="-DINET6 $CFLAGS" +fi +rm -f -r conftest* + + ;; + v6d) + cat >conftest.$ac_ext <<_ACEOF +/* 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 +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "yes" >/dev/null 2>&1; then + ipv6type=$i; + ipv6lib=v6; + ipv6libdir=/usr/local/v6/lib; + CFLAGS="-I/usr/local/v6/include $CFLAGS" +fi +rm -f -r conftest* + + ;; + zeta) + cat >conftest.$ac_ext <<_ACEOF +/* 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 +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "yes" >/dev/null 2>&1; then + ipv6type=$i; + ipv6lib=inet6; + ipv6libdir=/usr/local/v6/lib; + CFLAGS="-DINET6 $CFLAGS" +fi +rm -f -r conftest* + + ;; + esac + if test "$ipv6type" != "unknown"; then + break + fi + done + { echo "$as_me:$LINENO: result: $ipv6type" >&5 +echo "${ECHO_T}$ipv6type" >&6; } +fi + +if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then + if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then + LIBS="-L$ipv6libdir -l$ipv6lib $LIBS" + echo "You have $ipv6lib library, using it" + else + if test "$ipv6trylibc" = "yes"; then + echo "You do not have $ipv6lib library, using libc" + else + echo 'Fatal: no $ipv6lib library found. cannot continue.' + echo "You need to fetch lib$ipv6lib.a from appropriate" + echo 'ipv6 kit and compile beforehand.' + exit 1 + fi + fi +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. + # + { 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 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char getaddrinfo (); +int +main () +{ +return getaddrinfo (); + ; + return 0; +} +_ACEOF +for ac_lib in '' socket; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_search_getaddrinfo=$ac_res +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext + if test "${ac_cv_search_getaddrinfo+set}" = set; then + break +fi +done +if test "${ac_cv_search_getaddrinfo+set}" = set; then + : +else + ac_cv_search_getaddrinfo=no +fi +rm conftest.$ac_ext +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; } +ac_res=$ac_cv_search_getaddrinfo +if test "$ac_res" != no; then + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + { 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 + if test "$cross_compiling" = yes; then + td_cv_buggygetaddrinfo=yes +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#include <sys/types.h> +#include <netdb.h> +#include <string.h> +#include <sys/socket.h> +#include <netinet/in.h> + +main() +{ + int passive, gaierr, inet4 = 0, inet6 = 0; + struct addrinfo hints, *ai, *aitop; + char straddr[INET6_ADDRSTRLEN], strport[16]; + + for (passive = 0; passive <= 1; passive++) { + memset(&hints, 0, sizeof(hints)); + 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; + } + for (ai = aitop; ai; ai = ai->ai_next) { + if (ai->ai_addr == NULL || + ai->ai_addrlen == 0 || + getnameinfo(ai->ai_addr, ai->ai_addrlen, + straddr, sizeof(straddr), strport, sizeof(strport), + NI_NUMERICHOST|NI_NUMERICSERV) != 0) { + goto bad; + } + switch (ai->ai_family) { + case AF_INET: + if (strcmp(strport, "54321") != 0) { + goto bad; + } + if (passive) { + if (strcmp(straddr, "0.0.0.0") != 0) { + goto bad; + } + } else { + if (strcmp(straddr, "127.0.0.1") != 0) { + goto bad; + } + } + inet4++; + break; + case AF_INET6: + if (strcmp(strport, "54321") != 0) { + goto bad; + } + if (passive) { + if (strcmp(straddr, "::") != 0) { + goto bad; + } + } else { + if (strcmp(straddr, "::1") != 0) { + goto bad; + } + } + inet6++; + break; + case AF_UNSPEC: + goto bad; + break; +#ifdef AF_UNIX + case AF_UNIX: +#else +#ifdef AF_LOCAL + case AF_LOCAL: +#endif +#endif + default: + /* another family support? */ + break; + } + } + } + + /* supported family should be 2, unsupported family should be 0 */ + if (!(inet4 == 0 || inet4 == 2)) + goto bad; + if (!(inet6 == 0 || inet6 == 2)) + goto bad; + + if (aitop) + freeaddrinfo(aitop); + exit(0); + + bad: + if (aitop) + freeaddrinfo(aitop); + exit(1); +} + +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + td_cv_buggygetaddrinfo=no +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 ) +td_cv_buggygetaddrinfo=yes +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi + + 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 upgrade your system library to newest version' + echo ' of GNU C library (aka glibc).' + fi + fi + +fi + + +for ac_func in getnameinfo +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func. + For example, HP-UX 11i <limits.h> declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* 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 + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +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 +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&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 + case " $LIBOBJS " in + *" $ac_func.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS $ac_func.$ac_objext" + ;; +esac + +fi +done + + +fi + +{ 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 +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <netdnet/dnetdb.h> + +_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 + td_cv_decl_netdnet_dnetdb_h_dnet_htoa=no +fi +rm -f -r conftest* + +fi +{ 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 + + + { 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 <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +# include <netdb.h> +int +main () +{ +struct addrinfo a + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_addrinfo=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_addrinfo=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + + { 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 <<\_ACEOF +#define HAVE_ADDRINFO 1 +_ACEOF + + else + cat >>confdefs.h <<\_ACEOF +#define NEED_ADDRINFO_H 1 +_ACEOF + + fi + +if test "$ac_cv_addrinfo" = no; then + missing_includes=yes +fi + + + { 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 <<_ACEOF +/* 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 +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "yes" >/dev/null 2>&1; then + ac_cv_maxserv=yes +else + ac_cv_maxserv=no +fi +rm -f -r conftest* + +fi + + { 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 <<\_ACEOF +#define NEED_ADDRINFO_H 1 +_ACEOF + + fi + +if test "$ac_cv_maxserv" = no; then + missing_includes=yes +fi + + + { 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 <<_ACEOF +/* 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 +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "yes" >/dev/null 2>&1; then + ac_cv_namereqd=yes +else + ac_cv_namereqd=no +fi +rm -f -r conftest* + +fi + + { 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 <<\_ACEOF +#define NEED_ADDRINFO_H 1 +_ACEOF + + fi + +if test "$ac_cv_namereqd" = no; then + missing_includes=yes +fi + + + { 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 <<_ACEOF +/* 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 () +{ +struct sockaddr_storage s + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_sa_storage=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_sa_storage=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + + { 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 <<\_ACEOF +#define HAVE_SOCKADDR_STORAGE 1 +_ACEOF + + fi + +if test "$ac_cv_sa_storage" = no; then + missing_includes=yes +fi + + + + + + + +for ac_func in vfprintf strcasecmp strlcat strlcpy strdup strsep +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 { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func. + For example, HP-UX 11i <limits.h> declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* 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 + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +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 +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&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 + case " $LIBOBJS " in + *" $ac_func.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS $ac_func.$ac_objext" + ;; +esac + +fi +done + + + + + +for ac_func in fork vfork 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 { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func. + For example, HP-UX 11i <limits.h> declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* 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 + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +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 +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&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 + + + +for ac_func in setlinebuf alarm +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 { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func. + For example, HP-UX 11i <limits.h> declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* 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 + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +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 +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&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 + + +needsnprintf=no + + +for ac_func in vsnprintf snprintf +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 { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func. + For example, HP-UX 11i <limits.h> declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* 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 + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +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 +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&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 + case " $LIBOBJS " in + *" snprintf.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS snprintf.$ac_objext" + ;; +esac + +fi + + + { 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 <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <sys/types.h> +#include <signal.h> + +int +main () +{ +return *(signal (0, 0)) (0) == 1; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type_signal=int +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_signal=void +fi + +rm -f core conftest.err 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; } + +cat >>confdefs.h <<_ACEOF +#define RETSIGTYPE $ac_cv_type_signal +_ACEOF + + + if test "$ac_cv_type_signal" = void ; then + +cat >>confdefs.h <<\_ACEOF +#define RETSIGVAL +_ACEOF + + else + +cat >>confdefs.h <<\_ACEOF +#define RETSIGVAL (0) +_ACEOF + + fi + case "$host_os" in + + irix*) + +cat >>confdefs.h <<\_ACEOF +#define _BSD_SIGNALS 1 +_ACEOF + + ;; + + *) + +for ac_func in sigaction +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 { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func. + For example, HP-UX 11i <limits.h> declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* 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 + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +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 +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&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_sigaction = no ; then + +for ac_func in sigset +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 { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func. + For example, HP-UX 11i <limits.h> declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* 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 + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +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 +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&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 + + fi + ;; + esac + +{ 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 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dnet_htoa (); +int +main () +{ +return dnet_htoa (); + ; + return 0; +} +_ACEOF +for ac_lib in '' dnet; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_search_dnet_htoa=$ac_res +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext + if test "${ac_cv_search_dnet_htoa+set}" = set; then + break +fi +done +if test "${ac_cv_search_dnet_htoa+set}" = set; then + : +else + ac_cv_search_dnet_htoa=no +fi +rm conftest.$ac_ext +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; } +ac_res=$ac_cv_search_dnet_htoa +if test "$ac_res" != no; then + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + cat >>confdefs.h <<\_ACEOF +#define HAVE_DNET_HTOA 1 +_ACEOF + +fi + + + +{ 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_check_lib_save_LIBS=$LIBS +LIBS="-lrpc $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + +int +main () +{ +return main (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + 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" + +fi + +{ 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 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char getrpcbynumber (); +int +main () +{ +return getrpcbynumber (); + ; + return 0; +} +_ACEOF +for ac_lib in '' nsl; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_search_getrpcbynumber=$ac_res +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext + if test "${ac_cv_search_getrpcbynumber+set}" = set; then + break +fi +done +if test "${ac_cv_search_getrpcbynumber+set}" = set; then + : +else + ac_cv_search_getrpcbynumber=no +fi +rm conftest.$ac_ext +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; } +ac_res=$ac_cv_search_getrpcbynumber +if test "$ac_res" != no; then + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + cat >>confdefs.h <<\_ACEOF +#define HAVE_GETRPCBYNUMBER 1 +_ACEOF + +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 "$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 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char gethostbyname (); +int +main () +{ +return gethostbyname (); + ; + return 0; +} +_ACEOF +for ac_lib in '' nsl socket resolv; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_search_gethostbyname=$ac_res +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext + if test "${ac_cv_search_gethostbyname+set}" = set; then + break +fi +done +if test "${ac_cv_search_gethostbyname+set}" = set; then + : +else + ac_cv_search_gethostbyname=no +fi +rm conftest.$ac_ext +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; } +ac_res=$ac_cv_search_gethostbyname +if test "$ac_res" != no; then + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +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 "$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_check_lib_save_LIBS=$LIBS +LIBS="-lsocket -lnsl $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char gethostbyname (); +int +main () +{ +return gethostbyname (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + 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" +fi + + fi + { 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 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char socket (); +int +main () +{ +return socket (); + ; + return 0; +} +_ACEOF +for ac_lib in '' socket; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_search_socket=$ac_res +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext + if test "${ac_cv_search_socket+set}" = set; then + break +fi +done +if test "${ac_cv_search_socket+set}" = set; then + : +else + ac_cv_search_socket=no +fi +rm conftest.$ac_ext +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; } +ac_res=$ac_cv_search_socket +if test "$ac_res" != no; then + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +else + { 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 +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char socket (); +int +main () +{ +return socket (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + 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" +fi + +fi + + # DLPI needs putmsg under HPUX so test for -lstr while we're at it + { 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 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char putmsg (); +int +main () +{ +return putmsg (); + ; + return 0; +} +_ACEOF +for ac_lib in '' str; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_search_putmsg=$ac_res +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext + if test "${ac_cv_search_putmsg+set}" = set; then + break +fi +done +if test "${ac_cv_search_putmsg+set}" = set; then + : +else + ac_cv_search_putmsg=no +fi +rm conftest.$ac_ext +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; } +ac_res=$ac_cv_search_putmsg +if test "$ac_res" != no; then + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +fi + + + + LBL_LIBS="$LIBS" + pfopen=/usr/examples/packetfilter/pfopen.c + if test -f $pfopen ; then + +for ac_func in pfopen +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 { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func. + For example, HP-UX 11i <limits.h> declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* 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 + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +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 +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&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_pfopen = "no" ; then + { echo "$as_me:$LINENO: result: Using $pfopen" >&5 +echo "${ECHO_T}Using $pfopen" >&6; } + LIBS="$LIBS $pfopen" + fi + fi + { 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 $srcdir/.. | sed -e 's,/$,,' -e "s,^,$srcdir/../," | \ + egrep '/libpcap-[0-9]+\.[0-9]+(\.[0-9]*)?([ab][0-9]*|-PRE-GIT)?$'` + for dir in $places $srcdir/../libpcap $srcdir/libpcap ; do + basedir=`echo $dir | sed -e 's/[ab][0-9]*$//' | \ + sed -e 's/-PRE-GIT$//' ` + if test $lastdir = $basedir ; then + continue; + fi + lastdir=$dir + if test -r $dir/libpcap.a ; then + libpcap=$dir/libpcap.a + d=$dir + fi + done + if test $libpcap = FAIL ; then + { echo "$as_me:$LINENO: result: not found" >&5 +echo "${ECHO_T}not found" >&6; } + + # + # Look for pcap-config. + # + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}pcap-config", so it can be a program name with args. +set dummy ${ac_tool_prefix}pcap-config; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_path_PCAP_CONFIG+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $PCAP_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_PCAP_CONFIG="$PCAP_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_PCAP_CONFIG="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + + ;; +esac +fi +PCAP_CONFIG=$ac_cv_path_PCAP_CONFIG +if test -n "$PCAP_CONFIG"; then + { echo "$as_me:$LINENO: result: $PCAP_CONFIG" >&5 +echo "${ECHO_T}$PCAP_CONFIG" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + +fi +if test -z "$ac_cv_path_PCAP_CONFIG"; then + ac_pt_PCAP_CONFIG=$PCAP_CONFIG + # Extract the first word of "pcap-config", so it can be a program name with args. +set dummy pcap-config; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_path_ac_pt_PCAP_CONFIG+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $ac_pt_PCAP_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_ac_pt_PCAP_CONFIG="$ac_pt_PCAP_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_ac_pt_PCAP_CONFIG="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + + ;; +esac +fi +ac_pt_PCAP_CONFIG=$ac_cv_path_ac_pt_PCAP_CONFIG +if test -n "$ac_pt_PCAP_CONFIG"; then + { echo "$as_me:$LINENO: result: $ac_pt_PCAP_CONFIG" >&5 +echo "${ECHO_T}$ac_pt_PCAP_CONFIG" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + if test "x$ac_pt_PCAP_CONFIG" = x; then + PCAP_CONFIG="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + PCAP_CONFIG=$ac_pt_PCAP_CONFIG + fi +else + PCAP_CONFIG="$ac_cv_path_PCAP_CONFIG" +fi + + if test -n "$PCAP_CONFIG" ; then + # + # Found - use it to get the include flags for + # libpcap and the flags to link with libpcap. + # + # Please read section 11.6 "Shell Substitutions" + # in the autoconf manual before doing anything + # to this that involves quoting. Especially note + # the statement "There is just no portable way to use + # double-quoted strings inside double-quoted back-quoted + # expressions (pfew!)." + # + cflags=`"$PCAP_CONFIG" --cflags` + V_INCLS="$cflags $V_INCLS" + libpcap=`"$PCAP_CONFIG" --libs` + else + # + # Not found; look for pcap. + # + { echo "$as_me:$LINENO: checking for main in -lpcap" >&5 +echo $ECHO_N "checking for main in -lpcap... $ECHO_C" >&6; } +if test "${ac_cv_lib_pcap_main+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lpcap $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + +int +main () +{ +return main (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + 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" +fi + + if test $libpcap = FAIL ; then + { { echo "$as_me:$LINENO: error: see the INSTALL doc for more info" >&5 +echo "$as_me: error: see the INSTALL doc for more info" >&2;} + { (exit 1); exit 1; }; } + fi + { echo "$as_me:$LINENO: checking for extraneous pcap header directories" >&5 +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 + fi + else + V_PCAPDEP=$libpcap + places=`ls $srcdir/.. | sed -e 's,/$,,' -e "s,^,$srcdir/../," | \ + egrep '/libpcap-[0-9]*.[0-9]*(.[0-9]*)?([ab][0-9]*)?$'` + if test -r $d/pcap.h; then + V_INCLS="-I$d $V_INCLS" + elif test -r $places/pcap.h; then + V_INCLS="-I$places $V_INCLS" + else + { { 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 "$as_me:$LINENO: result: $libpcap" >&5 +echo "${ECHO_T}$libpcap" >&6; } + # Extract the first word of "pcap-config", so it can be a program name with args. +set dummy pcap-config; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_path_PCAP_CONFIG+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $PCAP_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_PCAP_CONFIG="$PCAP_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $d +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_PCAP_CONFIG="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + + ;; +esac +fi +PCAP_CONFIG=$ac_cv_path_PCAP_CONFIG +if test -n "$PCAP_CONFIG"; then + { echo "$as_me:$LINENO: result: $PCAP_CONFIG" >&5 +echo "${ECHO_T}$PCAP_CONFIG" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + if test -n "$PCAP_CONFIG"; then + # + # The libpcap directory has a pcap-config script. + # Use it to get any additioal libraries needed + # to link with the libpcap archive library in + # that directory. + # + # Please read section 11.6 "Shell Substitutions" + # in the autoconf manual before doing anything + # to this that involves quoting. Especially note + # the statement "There is just no portable way to use + # double-quoted strings inside double-quoted back-quoted + # expressions (pfew!)." + # + additional_libs=`"$PCAP_CONFIG" --additional-libs --static` + libpcap="$libpcap $additional_libs" + fi + fi + LIBS="$libpcap $LIBS" + if ! test -n "$PCAP_CONFIG" ; then + # + # We don't have pcap-config; find out any additional link flags + # we need. (If we have pcap-config, we assume it tells us what + # we need.) + # + case "$host_os" in + + aix*) + # + # If libpcap is DLPI-based, we have to use /lib/pse.exp if + # present, as we use the STREAMS routines. + # + # (XXX - true only if we're linking with a static libpcap?) + # + pseexe="/lib/pse.exp" + { echo "$as_me:$LINENO: checking for $pseexe" >&5 +echo $ECHO_N "checking for $pseexe... $ECHO_C" >&6; } + if test -f $pseexe ; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + LIBS="$LIBS -I:$pseexe" + fi + + # + # If libpcap is BPF-based, we need "-lodm" and "-lcfg", as + # we use them to load the BPF module. + # + # (XXX - true only if we're linking with a static libpcap?) + # + LIBS="$LIBS -lodm -lcfg" + ;; + esac + fi + + { echo "$as_me:$LINENO: checking for pcap_loop" >&5 +echo $ECHO_N "checking for pcap_loop... $ECHO_C" >&6; } +if test "${ac_cv_func_pcap_loop+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define pcap_loop to an innocuous variant, in case <limits.h> declares pcap_loop. + For example, HP-UX 11i <limits.h> declares gettimeofday. */ +#define pcap_loop innocuous_pcap_loop + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char pcap_loop (); 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 + +#undef pcap_loop + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char pcap_loop (); +/* 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_loop || defined __stub___pcap_loop +choke me +#endif + +int +main () +{ +return pcap_loop (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_func_pcap_loop=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_func_pcap_loop=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_func_pcap_loop" >&5 +echo "${ECHO_T}$ac_cv_func_pcap_loop" >&6; } +if test $ac_cv_func_pcap_loop = yes; then + : +else + + { { echo "$as_me:$LINENO: error: Report this to tcpdump-workers@lists.tcpdump.org, and include the +config.log file in your report. If you have downloaded libpcap from +tcpdump.org, and built it yourself, please also include the config.log +file from the libpcap source directory, the Makefile from the libpcap +source directory, and the output of the make process for libpcap, as +this could be a problem with the libpcap that was built, and we will +not be able to determine why this is happening, and thus will not be +able to fix it, without that information, as we have not been able to +reproduce this problem ourselves." >&5 +echo "$as_me: error: Report this to tcpdump-workers@lists.tcpdump.org, and include the +config.log file in your report. If you have downloaded libpcap from +tcpdump.org, and built it yourself, please also include the config.log +file from the libpcap source directory, the Makefile from the libpcap +source directory, and the output of the make process for libpcap, as +this could be a problem with the libpcap that was built, and we will +not be able to determine why this is happening, and thus will not be +able to fix it, without that information, as we have not been able to +reproduce this problem ourselves." >&2;} + { (exit 1); exit 1; }; } + +fi + + + { 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 +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define pcap_list_datalinks to an innocuous variant, in case <limits.h> declares pcap_list_datalinks. + For example, HP-UX 11i <limits.h> declares gettimeofday. */ +#define pcap_list_datalinks innocuous_pcap_list_datalinks + +/* System header to define __stub macros and hopefully few prototypes, + 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 + +#undef pcap_list_datalinks + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +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 +#endif + +int +main () +{ +return pcap_list_datalinks (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + 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 + + case " $LIBOBJS " in + *" datalinks.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS datalinks.$ac_objext" + ;; +esac + + +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 +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define pcap_set_datalink to an innocuous variant, in case <limits.h> declares pcap_set_datalink. + For example, HP-UX 11i <limits.h> declares gettimeofday. */ +#define pcap_set_datalink innocuous_pcap_set_datalink + +/* 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 + +#undef pcap_set_datalink + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +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 +#endif + +int +main () +{ +return pcap_set_datalink (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + 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 +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define pcap_datalink_name_to_val to an innocuous variant, in case <limits.h> declares pcap_datalink_name_to_val. + For example, HP-UX 11i <limits.h> declares gettimeofday. */ +#define pcap_datalink_name_to_val innocuous_pcap_datalink_name_to_val + +/* 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 + +#undef pcap_datalink_name_to_val + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +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 +#endif + +int +main () +{ +return pcap_datalink_name_to_val (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + 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 +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define pcap_datalink_val_to_description to an innocuous variant, in case <limits.h> declares pcap_datalink_val_to_description. + For example, HP-UX 11i <limits.h> declares gettimeofday. */ +#define pcap_datalink_val_to_description innocuous_pcap_datalink_val_to_description + +/* 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 + +#undef pcap_datalink_val_to_description + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +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 +#endif + +int +main () +{ +return pcap_datalink_val_to_description (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + 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 + + case " $LIBOBJS " in + *" dlnames.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS dlnames.$ac_objext" + ;; +esac + + +fi + + +else + + case " $LIBOBJS " in + *" dlnames.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS dlnames.$ac_objext" + ;; +esac + + +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 { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func. + For example, HP-UX 11i <limits.h> declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* 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 + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +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 +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&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 + + + { echo "$as_me:$LINENO: checking for pcap_dump_ftell" >&5 +echo $ECHO_N "checking for pcap_dump_ftell... $ECHO_C" >&6; } +if test "${ac_cv_func_pcap_dump_ftell+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define pcap_dump_ftell to an innocuous variant, in case <limits.h> declares pcap_dump_ftell. + For example, HP-UX 11i <limits.h> declares gettimeofday. */ +#define pcap_dump_ftell innocuous_pcap_dump_ftell + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char pcap_dump_ftell (); 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 + +#undef pcap_dump_ftell + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char pcap_dump_ftell (); +/* 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_dump_ftell || defined __stub___pcap_dump_ftell +choke me +#endif + +int +main () +{ +return pcap_dump_ftell (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_func_pcap_dump_ftell=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_func_pcap_dump_ftell=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_func_pcap_dump_ftell" >&5 +echo "${ECHO_T}$ac_cv_func_pcap_dump_ftell" >&6; } +if test $ac_cv_func_pcap_dump_ftell = yes; then + cat >>confdefs.h <<\_ACEOF +#define HAVE_PCAP_DUMP_FTELL 1 +_ACEOF + +else + + case " $LIBOBJS " in + *" pcap_dump_ftell.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS pcap_dump_ftell.$ac_objext" + ;; +esac + + +fi + + + +# +# 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 +/* 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 { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; 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; } + case " $LIBOBJS " in + *" inet_ntop.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS inet_ntop.$ac_objext" + ;; +esac + +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + 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 +/* 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 { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; 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; } + case " $LIBOBJS " in + *" inet_pton.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS inet_pton.$ac_objext" + ;; +esac + +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + 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 +/* 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 { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; 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; } + case " $LIBOBJS " in + *" inet_aton.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS inet_aton.$ac_objext" + ;; +esac + +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext + +# +# Check for these after AC_LBL_LIBPCAP, for the same reason. +# +# You are in a twisty little maze of UN*Xes, all different. +# Some might not have ether_ntohost(). +# Some might have it, but not declare it in any header file. +# Some might have it, but declare it in <netinet/if_ether.h>. +# Some might have it, but declare it in <netinet/ether.h> +# (And some might have it but document it as something declared in +# <netinet/ethernet.h>, although <netinet/if_ether.h> appears to work.) +# +# Before you is a C compiler. +# + +for ac_func in ether_ntohost +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 { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func. + For example, HP-UX 11i <limits.h> declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* 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 + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +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 +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&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 + + if test "$cross_compiling" = yes; then + ac_cv_buggy_ether_ntohost="not while cross-compiling" +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + #include <netdb.h> + #include <sys/types.h> + #include <sys/param.h> + #include <sys/socket.h> + + int + main(int argc, char **argv) + { + u_char ea[6] = { 0xff, 0xff, 0xff, 0xff, 0xff }; + char name[MAXHOSTNAMELEN]; + + ether_ntohost(name, (struct ether_addr *)ea); + exit(0); + } + +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_buggy_ether_ntohost=no +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 ) +ac_cv_buggy_ether_ntohost=yes +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi +{ 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 <<\_ACEOF +#define USE_ETHER_NTOHOST 1 +_ACEOF + + fi + +fi +done + +if test "$ac_cv_func_ether_ntohost" = yes -a \ + "$ac_cv_buggy_ether_ntohost" = "no"; then + # + # OK, we have ether_ntohost(). Do we have <netinet/if_ether.h>? + # + if test "$ac_cv_header_netinet_if_ether_h" = yes; then + # + # Yes. Does it declare ether_ntohost()? + # + { echo "$as_me:$LINENO: checking whether ether_ntohost is declared" >&5 +echo $ECHO_N "checking whether ether_ntohost is declared... $ECHO_C" >&6; } +if test "${ac_cv_have_decl_ether_ntohost+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#include <sys/types.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> +struct mbuf; +struct rtentry; +#include <net/if.h> +#include <netinet/if_ether.h> + + +int +main () +{ +#ifndef ether_ntohost + (void) ether_ntohost; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_have_decl_ether_ntohost=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_have_decl_ether_ntohost=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_have_decl_ether_ntohost" >&5 +echo "${ECHO_T}$ac_cv_have_decl_ether_ntohost" >&6; } +if test $ac_cv_have_decl_ether_ntohost = yes; then + + +cat >>confdefs.h <<\_ACEOF +#define NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST +_ACEOF + + +fi + + fi + # + # Did that succeed? + # + if test "$ac_cv_have_decl_ether_ntohost" != yes; then + # + # No, how about <netinet/ether.h>, as on Linux? + # + +for ac_header in netinet/ether.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + if test "$ac_cv_header_netinet_ether_h" = yes; then + # + # We have it - does it declare ether_ntohost()? + # Unset ac_cv_have_decl_ether_ntohost so we don't + # treat the previous failure as a cached value and + # suppress the next test. + # + unset ac_cv_have_decl_ether_ntohost + { echo "$as_me:$LINENO: checking whether ether_ntohost is declared" >&5 +echo $ECHO_N "checking whether ether_ntohost is declared... $ECHO_C" >&6; } +if test "${ac_cv_have_decl_ether_ntohost+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#include <netinet/ether.h> + + +int +main () +{ +#ifndef ether_ntohost + (void) ether_ntohost; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_have_decl_ether_ntohost=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_have_decl_ether_ntohost=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_have_decl_ether_ntohost" >&5 +echo "${ECHO_T}$ac_cv_have_decl_ether_ntohost" >&6; } +if test $ac_cv_have_decl_ether_ntohost = yes; then + + +cat >>confdefs.h <<\_ACEOF +#define NETINET_ETHER_H_DECLARES_ETHER_NTOHOST +_ACEOF + + +fi + + fi + fi + # + # Is ether_ntohost() declared? + # + if test "$ac_cv_have_decl_ether_ntohost" != yes; then + # + # No, we'll have to declare it ourselves. + # Do we have "struct ether_addr"? + # + { echo "$as_me:$LINENO: checking for struct ether_addr" >&5 +echo $ECHO_N "checking for struct ether_addr... $ECHO_C" >&6; } +if test "${ac_cv_type_struct_ether_addr+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#include <sys/types.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> +struct mbuf; +struct rtentry; +#include <net/if.h> +#include <netinet/if_ether.h> + + +typedef struct ether_addr ac__type_new_; +int +main () +{ +if ((ac__type_new_ *) 0) + return 0; +if (sizeof (ac__type_new_)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type_struct_ether_addr=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_struct_ether_addr=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_type_struct_ether_addr" >&5 +echo "${ECHO_T}$ac_cv_type_struct_ether_addr" >&6; } +if test $ac_cv_type_struct_ether_addr = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_ETHER_ADDR 1 +_ACEOF + + +fi + + +cat >>confdefs.h <<\_ACEOF +#define HAVE_DECL_ETHER_NTOHOST 0 +_ACEOF + + else + +cat >>confdefs.h <<\_ACEOF +#define HAVE_DECL_ETHER_NTOHOST 1 +_ACEOF + + fi +fi + +# libdlpi is needed for Solaris 11 and later. +{ echo "$as_me:$LINENO: checking for dlpi_walk in -ldlpi" >&5 +echo $ECHO_N "checking for dlpi_walk in -ldlpi... $ECHO_C" >&6; } +if test "${ac_cv_lib_dlpi_dlpi_walk+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldlpi -L/lib $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dlpi_walk (); +int +main () +{ +return dlpi_walk (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_lib_dlpi_dlpi_walk=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_dlpi_dlpi_walk=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_dlpi_dlpi_walk" >&5 +echo "${ECHO_T}$ac_cv_lib_dlpi_dlpi_walk" >&6; } +if test $ac_cv_lib_dlpi_dlpi_walk = yes; then + LIBS="$LIBS -ldlpi" LDFLAGS="-L/lib $LDFLAGS" +fi + + + + { echo "$as_me:$LINENO: checking if sockaddr struct has sa_len member" >&5 +echo $ECHO_N "checking if sockaddr struct has sa_len member... $ECHO_C" >&6; } + if test "${ac_cv_sockaddr_has_sa_len+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +# include <sys/types.h> +# include <sys/socket.h> +int +main () +{ +u_int i = sizeof(((struct sockaddr *)0)->sa_len) + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_sockaddr_has_sa_len=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_sockaddr_has_sa_len=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + + { 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 + +# +# Do we have the new open API? Check for pcap_create, and assume that, +# if we do, we also have pcap_activate() and the other new routines +# introduced in libpcap 1.0.0. +# + +for ac_func in pcap_create +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 { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func. + For example, HP-UX 11i <limits.h> declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* 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 + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +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 +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&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_create = "yes" ; then + # + # OK, do we have pcap_set_tstamp_type? If so, assume we have + # pcap_list_tstamp_types and pcap_free_tstamp_types as well. + # + +for ac_func in pcap_set_tstamp_type +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 { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func. + For example, HP-UX 11i <limits.h> declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* 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 + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +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 +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&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 + +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 { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func. + For example, HP-UX 11i <limits.h> declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* 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 + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +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 +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&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 + savedcppflags="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $V_INCLS" + { 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 +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <pcap.h> + +typedef pcap_if_t ac__type_new_; +int +main () +{ +if ((ac__type_new_ *) 0) + return 0; +if (sizeof (ac__type_new_)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type_pcap_if_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_pcap_if_t=no +fi + +rm -f core conftest.err 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 + + CPPFLAGS="$savedcppflags" +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 +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + extern char pcap_version[]; + + return (int)pcap_version; + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + 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 +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + extern int pcap_debug; + + return pcap_debug; + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + 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 +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + extern int yydebug; + + return yydebug; + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + 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 { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func. + For example, HP-UX 11i <limits.h> declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* 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 + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +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 +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&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 + case " $LIBOBJS " in + *" $ac_func.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS $ac_func.$ac_objext" + ;; +esac + +fi +done + + +V_GROUP=0 +if test -f /etc/group -a ! -z "`grep '^wheel:' /etc/group`" ; then + V_GROUP=wheel +fi +# +# Assume V7/BSD convention for man pages (file formats in section 5, +# miscellaneous info in section 7). +# +MAN_FILE_FORMATS=5 +MAN_MISC_INFO=7 +case "$host_os" in + +aix*) + +cat >>confdefs.h <<\_ACEOF +#define _SUN 1 +_ACEOF + + ;; + +hpux*) + # + # Use System V conventions for man pages. + # + MAN_FILE_FORMATS=4 + MAN_MISC_INFO=5 + ;; + +irix*) + V_GROUP=sys + + # + # Use System V conventions for man pages. + # + MAN_FILE_FORMATS=4 + MAN_MISC_INFO=5 + ;; + +osf*) + V_GROUP=system + + # + # Use System V conventions for man pages. + # + MAN_FILE_FORMATS=4 + MAN_MISC_INFO=5 + ;; + +solaris*) + V_GROUP=sys + + # + # Use System V conventions for man pages. + # + MAN_FILE_FORMATS=4 + MAN_MISC_INFO=5 + ;; +esac + +if test -f /dev/bpf0 ; then + V_GROUP=bpf +fi + + +for ac_header in sys/bitypes.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +{ echo "$as_me:$LINENO: checking for int8_t" >&5 +echo $ECHO_N "checking for int8_t... $ECHO_C" >&6; } +if test "${ac_cv_type_int8_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#ifdef HAVE_SYS_BITYPES_H +#include <sys/bitypes.h> +#endif + +typedef int8_t ac__type_new_; +int +main () +{ +if ((ac__type_new_ *) 0) + return 0; +if (sizeof (ac__type_new_)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type_int8_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_int8_t=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_type_int8_t" >&5 +echo "${ECHO_T}$ac_cv_type_int8_t" >&6; } +if test $ac_cv_type_int8_t = yes; then + : +else + +cat >>confdefs.h <<\_ACEOF +#define int8_t signed char +_ACEOF + +fi + +{ echo "$as_me:$LINENO: checking for u_int8_t" >&5 +echo $ECHO_N "checking for u_int8_t... $ECHO_C" >&6; } +if test "${ac_cv_type_u_int8_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#ifdef HAVE_SYS_BITYPES_H +#include <sys/bitypes.h> +#endif + +typedef u_int8_t ac__type_new_; +int +main () +{ +if ((ac__type_new_ *) 0) + return 0; +if (sizeof (ac__type_new_)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type_u_int8_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_u_int8_t=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_type_u_int8_t" >&5 +echo "${ECHO_T}$ac_cv_type_u_int8_t" >&6; } +if test $ac_cv_type_u_int8_t = yes; then + : +else + +cat >>confdefs.h <<\_ACEOF +#define u_int8_t unsigned char +_ACEOF + +fi + +{ echo "$as_me:$LINENO: checking for int16_t" >&5 +echo $ECHO_N "checking for int16_t... $ECHO_C" >&6; } +if test "${ac_cv_type_int16_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +typedef int16_t ac__type_new_; +int +main () +{ +if ((ac__type_new_ *) 0) + return 0; +if (sizeof (ac__type_new_)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type_int16_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_int16_t=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_type_int16_t" >&5 +echo "${ECHO_T}$ac_cv_type_int16_t" >&6; } +if test $ac_cv_type_int16_t = yes; then + : +else + +cat >>confdefs.h <<\_ACEOF +#define int16_t short +_ACEOF + + $ac_includes_default +#ifdef HAVE_SYS_BITYPES_H +#include <sys/bitypes.h> +#endif +fi + +{ echo "$as_me:$LINENO: checking for u_int16_t" >&5 +echo $ECHO_N "checking for u_int16_t... $ECHO_C" >&6; } +if test "${ac_cv_type_u_int16_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#ifdef HAVE_SYS_BITYPES_H +#include <sys/bitypes.h> +#endif + +typedef u_int16_t ac__type_new_; +int +main () +{ +if ((ac__type_new_ *) 0) + return 0; +if (sizeof (ac__type_new_)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type_u_int16_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_u_int16_t=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_type_u_int16_t" >&5 +echo "${ECHO_T}$ac_cv_type_u_int16_t" >&6; } +if test $ac_cv_type_u_int16_t = yes; then + : +else + +cat >>confdefs.h <<\_ACEOF +#define u_int16_t unsigned short +_ACEOF + +fi + +{ echo "$as_me:$LINENO: checking for int32_t" >&5 +echo $ECHO_N "checking for int32_t... $ECHO_C" >&6; } +if test "${ac_cv_type_int32_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#ifdef HAVE_SYS_BITYPES_H +#include <sys/bitypes.h> +#endif + +typedef int32_t ac__type_new_; +int +main () +{ +if ((ac__type_new_ *) 0) + return 0; +if (sizeof (ac__type_new_)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type_int32_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_int32_t=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_type_int32_t" >&5 +echo "${ECHO_T}$ac_cv_type_int32_t" >&6; } +if test $ac_cv_type_int32_t = yes; then + : +else + +cat >>confdefs.h <<\_ACEOF +#define int32_t int +_ACEOF + +fi + +{ echo "$as_me:$LINENO: checking for u_int32_t" >&5 +echo $ECHO_N "checking for u_int32_t... $ECHO_C" >&6; } +if test "${ac_cv_type_u_int32_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#ifdef HAVE_SYS_BITYPES_H +#include <sys/bitypes.h> +#endif + +typedef u_int32_t ac__type_new_; +int +main () +{ +if ((ac__type_new_ *) 0) + return 0; +if (sizeof (ac__type_new_)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type_u_int32_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_u_int32_t=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_type_u_int32_t" >&5 +echo "${ECHO_T}$ac_cv_type_u_int32_t" >&6; } +if test $ac_cv_type_u_int32_t = yes; then + : +else + +cat >>confdefs.h <<\_ACEOF +#define u_int32_t unsigned int +_ACEOF + +fi + +{ echo "$as_me:$LINENO: checking for int64_t" >&5 +echo $ECHO_N "checking for int64_t... $ECHO_C" >&6; } +if test "${ac_cv_type_int64_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#ifdef HAVE_SYS_BITYPES_H +#include <sys/bitypes.h> +#endif + +typedef int64_t ac__type_new_; +int +main () +{ +if ((ac__type_new_ *) 0) + return 0; +if (sizeof (ac__type_new_)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type_int64_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_int64_t=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_type_int64_t" >&5 +echo "${ECHO_T}$ac_cv_type_int64_t" >&6; } +if test $ac_cv_type_int64_t = yes; then + : +else + +cat >>confdefs.h <<\_ACEOF +#define int64_t long long +_ACEOF + +fi + +{ echo "$as_me:$LINENO: checking for u_int64_t" >&5 +echo $ECHO_N "checking for u_int64_t... $ECHO_C" >&6; } +if test "${ac_cv_type_u_int64_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#ifdef HAVE_SYS_BITYPES_H +#include <sys/bitypes.h> +#endif + +typedef u_int64_t ac__type_new_; +int +main () +{ +if ((ac__type_new_ *) 0) + return 0; +if (sizeof (ac__type_new_)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type_u_int64_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_u_int64_t=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_type_u_int64_t" >&5 +echo "${ECHO_T}$ac_cv_type_u_int64_t" >&6; } +if test $ac_cv_type_u_int64_t = yes; then + : +else + +cat >>confdefs.h <<\_ACEOF +#define u_int64_t unsigned long long +_ACEOF + +fi + + +# +# We can't just check for <inttypes.h> - some systems have one that +# doesn't define all the PRI[doxu]64 macros. +# + +for ac_header in inttypes.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + + # + # OK, we have inttypes.h, but does it define those macros? + # + { echo "$as_me:$LINENO: checking whether inttypes.h defines the PRI[doxu]64 macros" >&5 +echo $ECHO_N "checking whether inttypes.h defines the PRI[doxu]64 macros... $ECHO_C" >&6; } + cat >conftest.$ac_ext <<_ACEOF + + /* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + #include <inttypes.h> + #include <stdio.h> + #include <sys/types.h> + #ifdef HAVE_SYS_BITYPES_H + #include <sys/bitypes.h> + #endif + + main() + { + printf("%" PRId64 "\n", (u_int64_t)1); + printf("%" PRIo64 "\n", (u_int64_t)1); + printf("%" PRIx64 "\n", (u_int64_t)1); + printf("%" PRIu64 "\n", (u_int64_t)1); + } + + +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + ac_lbl_inttypes_h_defines_formats=yes + +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; } + ac_lbl_inttypes_h_defines_formats=no + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +else + + # + # We don't have inttypes.h, so it obviously can't define those + # macros. + # + ac_lbl_inttypes_h_defines_formats=no + +fi + +done + +if test "$ac_lbl_inttypes_h_defines_formats" = no; then + + { echo "$as_me:$LINENO: checking whether %lx can be used to format 64-bit integers" >&5 +echo $ECHO_N "checking whether %lx can be used to format 64-bit integers... $ECHO_C" >&6; } + 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 + + /* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +# ifdef HAVE_INTTYPES_H + #include <inttypes.h> +# endif +# ifdef HAVE_SYS_BITYPES_H + #include <sys/bitypes.h> +# endif + #include <stdio.h> + #include <sys/types.h> + + main() + { + u_int64_t t = 1; + char strbuf[16+1]; + sprintf(strbuf, "%016lx", t << 32); + if (strcmp(strbuf, "0000000100000000") == 0) + exit(0); + else + exit(1); + } + + +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + + cat >>confdefs.h <<\_ACEOF +#define PRId64 "ld" +_ACEOF + + cat >>confdefs.h <<\_ACEOF +#define PRIo64 "lo" +_ACEOF + + cat >>confdefs.h <<\_ACEOF +#define PRIx64 "lx" +_ACEOF + + cat >>confdefs.h <<\_ACEOF +#define PRIu64 "lu" +_ACEOF + + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + +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: result: no" >&5 +echo "${ECHO_T}no" >&6; } + + + { echo "$as_me:$LINENO: checking whether %llx can be used to format 64-bit integers" >&5 +echo $ECHO_N "checking whether %llx can be used to format 64-bit integers... $ECHO_C" >&6; } + 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 + + /* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +# ifdef HAVE_INTTYPES_H + #include <inttypes.h> +# endif +# ifdef HAVE_SYS_BITYPES_H + #include <sys/bitypes.h> +# endif + #include <stdio.h> + #include <sys/types.h> + + main() + { + u_int64_t t = 1; + char strbuf[16+1]; + sprintf(strbuf, "%016llx", t << 32); + if (strcmp(strbuf, "0000000100000000") == 0) + exit(0); + else + exit(1); + } + + +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + + cat >>confdefs.h <<\_ACEOF +#define PRId64 "lld" +_ACEOF + + cat >>confdefs.h <<\_ACEOF +#define PRIo64 "llo" +_ACEOF + + cat >>confdefs.h <<\_ACEOF +#define PRIx64 "llx" +_ACEOF + + cat >>confdefs.h <<\_ACEOF +#define PRIu64 "llu" +_ACEOF + + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + +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: result: no" >&5 +echo "${ECHO_T}no" >&6; } + + + { echo "$as_me:$LINENO: checking whether %Lx can be used to format 64-bit integers" >&5 +echo $ECHO_N "checking whether %Lx can be used to format 64-bit integers... $ECHO_C" >&6; } + 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 + + /* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +# ifdef HAVE_INTTYPES_H + #include <inttypes.h> +# endif +# ifdef HAVE_SYS_BITYPES_H + #include <sys/bitypes.h> +# endif + #include <stdio.h> + #include <sys/types.h> + + main() + { + u_int64_t t = 1; + char strbuf[16+1]; + sprintf(strbuf, "%016Lx", t << 32); + if (strcmp(strbuf, "0000000100000000") == 0) + exit(0); + else + exit(1); + } + + +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + + cat >>confdefs.h <<\_ACEOF +#define PRId64 "Ld" +_ACEOF + + cat >>confdefs.h <<\_ACEOF +#define PRIo64 "Lo" +_ACEOF + + cat >>confdefs.h <<\_ACEOF +#define PRIx64 "Lx" +_ACEOF + + cat >>confdefs.h <<\_ACEOF +#define PRIu64 "Lu" +_ACEOF + + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + +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: result: no" >&5 +echo "${ECHO_T}no" >&6; } + + + { echo "$as_me:$LINENO: checking whether %qx can be used to format 64-bit integers" >&5 +echo $ECHO_N "checking whether %qx can be used to format 64-bit integers... $ECHO_C" >&6; } + 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 + + /* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +# ifdef HAVE_INTTYPES_H + #include <inttypes.h> +# endif +# ifdef HAVE_SYS_BITYPES_H + #include <sys/bitypes.h> +# endif + #include <stdio.h> + #include <sys/types.h> + + main() + { + u_int64_t t = 1; + char strbuf[16+1]; + sprintf(strbuf, "%016qx", t << 32); + if (strcmp(strbuf, "0000000100000000") == 0) + exit(0); + else + exit(1); + } + + +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + + cat >>confdefs.h <<\_ACEOF +#define PRId64 "qd" +_ACEOF + + cat >>confdefs.h <<\_ACEOF +#define PRIo64 "qo" +_ACEOF + + cat >>confdefs.h <<\_ACEOF +#define PRIx64 "qx" +_ACEOF + + cat >>confdefs.h <<\_ACEOF +#define PRIu64 "qu" +_ACEOF + + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + +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: result: no" >&5 +echo "${ECHO_T}no" >&6; } + + { { echo "$as_me:$LINENO: error: neither %llx nor %Lx nor %qx worked on a 64-bit integer" >&5 +echo "$as_me: error: neither %llx nor %Lx nor %qx worked on a 64-bit integer" >&2;} + { (exit 1); exit 1; }; } + + +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + + + + +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + + + + +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + + + + +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + + +fi + +# +# Check for some headers introduced in later versions of libpcap +# and used by some printers. +# +# Those headers use the {u_}intN_t types, so we must do this after +# we check for what's needed to get them defined. +# +savedcppflags="$CPPFLAGS" +CPPFLAGS="$CPPFLAGS $V_INCLS" + +for ac_header in pcap/bluetooth.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 { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <tcpdump-stdinc.h> + +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + 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 core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&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 + + +for ac_header in pcap/usb.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 { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <tcpdump-stdinc.h> + +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + 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 core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&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 + +CPPFLAGS="$savedcppflags" + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ranlib; 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_RANLIB+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +RANLIB=$ac_cv_prog_RANLIB +if test -n "$RANLIB"; then + { echo "$as_me:$LINENO: result: $RANLIB" >&5 +echo "${ECHO_T}$RANLIB" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_RANLIB"; then + ac_ct_RANLIB=$RANLIB + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; 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_RANLIB+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_RANLIB"; then + ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_RANLIB="ranlib" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB +if test -n "$ac_ct_RANLIB"; then + { echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5 +echo "${ECHO_T}$ac_ct_RANLIB" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + if test "x$ac_ct_RANLIB" = x; then + RANLIB=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + RANLIB=$ac_ct_RANLIB + fi +else + RANLIB="$ac_cv_prog_RANLIB" +fi + + +rm -f os-proto.h + if test "${LBL_CFLAGS+set}" = set; then + V_CCOPT="$V_CCOPT ${LBL_CFLAGS}" + fi + if test -f .devel ; then + if test "$GCC" = yes ; then + if test "${LBL_CFLAGS+set}" != set; then + if test "$ac_cv_prog_cc_g" = yes ; then + V_CCOPT="-g $V_CCOPT" + fi + V_CCOPT="$V_CCOPT -Wall" + if test $ac_cv_lbl_gcc_vers -gt 1 ; then + V_CCOPT="$V_CCOPT -Wmissing-prototypes -Wstrict-prototypes -Wwrite-strings -Wpointer-arith -W" + fi + fi + else + case "$host_os" in + + irix6*) + V_CCOPT="$V_CCOPT -n32" + ;; + + *) + ;; + esac + fi + os=`echo $host_os | sed -e 's/\([0-9][0-9]*\)[^0-9].*$/\1/'` + name="lbl/os-$os.h" + if test -f $name ; then + ln -s $name os-proto.h + +cat >>confdefs.h <<\_ACEOF +#define HAVE_OS_PROTO_H 1 +_ACEOF + + else + { echo "$as_me:$LINENO: WARNING: can't find $name" >&5 +echo "$as_me: WARNING: can't find $name" >&2;} + fi + fi + +{ echo "$as_me:$LINENO: checking if sockaddr struct has the sa_len member" >&5 +echo $ECHO_N "checking if sockaddr struct has the sa_len member... $ECHO_C" >&6; } + if test "${ac_cv_lbl_sockaddr_has_sa_len+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +# include <sys/types.h> +# include <sys/socket.h> +int +main () +{ +u_int i = sizeof(((struct sockaddr *)0)->sa_len) + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_lbl_sockaddr_has_sa_len=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lbl_sockaddr_has_sa_len=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + + { echo "$as_me:$LINENO: result: $ac_cv_lbl_sockaddr_has_sa_len" >&5 +echo "${ECHO_T}$ac_cv_lbl_sockaddr_has_sa_len" >&6; } + if test $ac_cv_lbl_sockaddr_has_sa_len = yes ; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_SOCKADDR_SA_LEN 1 +_ACEOF + + fi + +{ 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) + # + # 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*|bfin*|hp*|mips*|sh*|sparc*|ia64|nv1) + ac_cv_lbl_unaligned_fail=yes + ;; + + *) + cat >conftest.c <<EOF +# include <sys/types.h> +# include <sys/wait.h> +# include <stdio.h> + unsigned char a[5] = { 1, 2, 3, 4, 5 }; + main() { + unsigned int i; + pid_t pid; + int status; + /* avoid "core dumped" message */ + pid = fork(); + if (pid < 0) + exit(2); + if (pid > 0) { + /* parent */ + pid = waitpid(pid, &status, 0); + if (pid < 0) + exit(3); + exit(!WIFEXITED(status)); + } + /* child */ + i = *(unsigned int *)&a[1]; + printf("%d\n", i); + exit(0); + } +EOF + ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \ + conftest.c $LIBS >/dev/null 2>&1 + if test ! -x conftest ; then + ac_cv_lbl_unaligned_fail=yes + else + ./conftest >conftest.out + if test ! -s conftest.out ; then + ac_cv_lbl_unaligned_fail=yes + else + ac_cv_lbl_unaligned_fail=no + fi + fi + rm -f -r conftest* core core.conftest + ;; + esac +fi + + { echo "$as_me:$LINENO: result: $ac_cv_lbl_unaligned_fail" >&5 +echo "${ECHO_T}$ac_cv_lbl_unaligned_fail" >&6; } + if test $ac_cv_lbl_unaligned_fail = yes ; then + +cat >>confdefs.h <<\_ACEOF +#define LBL_ALIGN 1 +_ACEOF + + fi + + + { 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 <<_ACEOF +/* 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 foo = h_errno; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_var_h_errno=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_var_h_errno=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + + { 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 <<\_ACEOF +#define HAVE_H_ERRNO 1 +_ACEOF + + fi + + +# Check for SSLeay +{ echo "$as_me:$LINENO: checking whether to use SSLeay libcrypto" >&5 +echo $ECHO_N "checking whether to use SSLeay libcrypto... $ECHO_C" >&6; } +# Specify location for both includes and libraries. +want_libcrypto=youmama + +# Check whether --with-crypto was given. +if test "${with_crypto+set}" = set; then + withval=$with_crypto; + if test $withval = no + then + want_libcrypto=no + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + elif test $withval = yes + then + want_libcrypto=yes + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + else + want_libcrypto=yes + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + crypto_dir=$withval + fi + +else + + # + # Use libcrypto if it's present, otherwise don't. + # + want_libcrypto=ifavailable + { echo "$as_me:$LINENO: result: yes, if available" >&5 +echo "${ECHO_T}yes, if available" >&6; } + +fi + +if test "$want_libcrypto" != "no"; then + ac_cv_ssleay_path=no + incdir=no + if test "x$crypto_dir" = x; then + # + # Location not specified; check the default locations. + # + { echo "$as_me:$LINENO: checking where SSLeay is located" >&5 +echo $ECHO_N "checking where SSLeay is located... $ECHO_C" >&6; } + dirs="/usr /usr/local /usr/local/ssl /usr/pkg" + if test "x${host_alias}" != x; then + dirs="/usr/${host_alias} $dirs" + fi + for dir in $dirs; do + + # + # Find the last component of $libdir; it's not necessarily + # "lib" - it might be "lib64" on, for example, x86-64 + # Linux systems. + # + # We assume the directory in which we're looking for + # libcrypto has a subdirectory with that as its name. + # + tmplib=`echo "$libdir" | sed 's,.*/,,'` + + # + # XXX - is there a better way to check if a given library is + # in a given directory than checking each of the possible + # shared library suffixes? + # + # 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/$tmplib" -a \( -f "$dir/$tmplib/libcrypto.a" -o \ + -f "$dir/$tmplib/libcrypto.so" -o \ + -f "$dir/$tmplib/libcrypto.sl" -o \ + -f "$dir/$tmplib/libcrypto.dylib" \); then + ac_cv_ssleay_path="$dir" + fi + + # + # Make sure we have the headers as well. + # + if test -d "$dir/include/openssl" -a -f "$dir/include/openssl/des.h"; then + incdir="-I$dir/include" + fi + + + if test "$ac_cv_ssleay_path" != "no" -a "$incdir" != "no"; then + break; + else + ac_cv_ssleay_path=no + incdir=no + fi + done + if test "$ac_cv_ssleay_path" != no; then + { echo "$as_me:$LINENO: result: $ac_cv_ssleay_path" >&5 +echo "${ECHO_T}$ac_cv_ssleay_path" >&6; } + fi + else + { echo "$as_me:$LINENO: checking for SSLeay in $crypto_dir" >&5 +echo $ECHO_N "checking for SSLeay in $crypto_dir... $ECHO_C" >&6; } + + # + # Find the last component of $libdir; it's not necessarily + # "lib" - it might be "lib64" on, for example, x86-64 + # Linux systems. + # + # We assume the directory in which we're looking for + # libcrypto has a subdirectory with that as its name. + # + tmplib=`echo "$libdir" | sed 's,.*/,,'` + + # + # XXX - is there a better way to check if a given library is + # in a given directory than checking each of the possible + # shared library suffixes? + # + # 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 "$crypto_dir/$tmplib" -a \( -f "$crypto_dir/$tmplib/libcrypto.a" -o \ + -f "$crypto_dir/$tmplib/libcrypto.so" -o \ + -f "$crypto_dir/$tmplib/libcrypto.sl" -o \ + -f "$crypto_dir/$tmplib/libcrypto.dylib" \); then + ac_cv_ssleay_path="$crypto_dir" + fi + + # + # Make sure we have the headers as well. + # + if test -d "$crypto_dir/include/openssl" -a -f "$crypto_dir/include/openssl/des.h"; then + incdir="-I$crypto_dir/include" + fi + + if test "$ac_cv_ssleay_path" != no; then + { echo "$as_me:$LINENO: result: found" >&5 +echo "${ECHO_T}found" >&6; } + fi + fi + if test "$ac_cv_ssleay_path" != no; then + V_INCLS="$V_INCLS $incdir" + if test "$dir" != "/usr"; then + LDFLAGS="-L$dir/lib $LDFLAGS" + fi + if test -f $ac_cv_ssleay_path/lib/libRSAglue.a; then + LIBS="$LIBS -lRSAglue" + fi + if test -f $ac_cv_ssleay_path/lib/librsaref.a; then + LIBS="$LIBS -lrsaref" + fi + +{ 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_check_lib_save_LIBS=$LIBS +LIBS="-lcrypto $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char DES_cbc_encrypt (); +int +main () +{ +return DES_cbc_encrypt (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; 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 core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + 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" + +fi + + + savedcppflags="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $V_INCLS" + +for ac_header in openssl/evp.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + CPPFLAGS="$savedcppflags" + else + # + # Not found. Did the user explicitly ask for it? + # + { echo "$as_me:$LINENO: result: not found" >&5 +echo "${ECHO_T}not found" >&6; } + if test "$want_libcrypto" = yes; then + { { echo "$as_me:$LINENO: error: SSLeay not found" >&5 +echo "$as_me: error: SSLeay not found" >&2;} + { (exit 1); exit 1; }; } + fi + fi +fi + +if test "$missing_includes" = "yes"; then + CPPFLAGS="$CPPFLAGS -I$srcdir/missing" + V_INCLS="$V_INCLS -I$srcdir/missing" +fi + + + + + + + + + + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# 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" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +{ 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 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/* | \ + ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ + /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 { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$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 + done + ;; +esac +done +IFS=$as_save_IFS + + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. Don't cache a + # value for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + INSTALL=$ac_install_sh + fi +fi +{ 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}' + +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" + +ac_config_files="$ac_config_files Makefile tcpdump.1" + +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, 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. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `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, we kill variables containing newlines. +# 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. +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 +echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + *) $as_unset $ac_var ;; + esac ;; + esac + done + + (set) 2>&1 | + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}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 "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) | + sed ' + /^ac_cv_env_/b end + t clear + :clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + test "x$cache_file" != "x/dev/null" && + { echo "$as_me:$LINENO: updating cache $cache_file" >&5 +echo "$as_me: updating cache $cache_file" >&6;} + cat confcache >$cache_file + else + { echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 +echo "$as_me: not updating unwritable cache $cache_file" >&6;} + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +DEFS=-DHAVE_CONFIG_H + +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_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" + ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +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. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false +SHELL=\${CONFIG_SHELL-$SHELL} +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +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+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + + + +# PATH needs CR +# 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 + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +as_nl=' +' +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +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 +IFS=$as_save_IFS + + ;; +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_myself: error: cannot find myself; rerun with an absolute file name" >&2 + { (exit 1); exit 1; } +fi + +# Work around bugs in pre-3.0 UWIN ksh. +for as_var in ENV MAIL MAILPATH +do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +done +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 -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; 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'` + +# CDPATH. +$as_unset CDPATH + + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { + + # 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 after each line using $LINENO; the second 'sed' + # does the real work. The second script uses 'N' to pair each + # line-number line with the line containing $LINENO, 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 + # scripts with optimization help from Paolo Bonzini. Blame Lee + # E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\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 sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in +-n*) + case `echo 'x\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + *) ECHO_C='\c';; + esac;; +*) + ECHO_N='-n';; +esac + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir +fi +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' +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$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval 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="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 + +# Save the log message, to keep $[0] and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by $as_me, which was +generated by GNU Autoconf 2.61. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF +# Files that config.status was made for. +config_files="$ac_config_files" +config_headers="$ac_config_headers" +config_commands="$ac_config_commands" + +_ACEOF + +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 and configuration settings, 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.61, + with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" + +Copyright (C) 2006 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='$ac_pwd' +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 + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + echo "$ac_cs_version"; exit ;; + --debug | --debu | --deb | --de | --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;; + --he | --h) + # Conflict between --help and --header + { 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 ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) { 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" + ac_need_defaults=false ;; + + esac + shift +done + +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 CONFIG_SHELL=$SHELL $SHELL $0 "$ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 + CONFIG_SHELL=$SHELL + export CONFIG_SHELL + exec $SHELL "$0"$ac_configure_args \$ac_configure_extra_args --no-create --no-recursion +fi + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + echo "$ac_log" +} >&5 + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +# +# INIT-COMMANDS +# + + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + "default-1") CONFIG_COMMANDS="$CONFIG_COMMANDS default-1" ;; + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "tcpdump.1") CONFIG_FILES="$CONFIG_FILES tcpdump.1" ;; + + *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 +echo "$as_me: error: invalid argument: $ac_config_target" >&2;} + { (exit 1); exit 1; }; };; + esac +done + + +# 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 against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= + trap 'exit_status=$? + { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status +' 0 + trap '{ (exit 1); exit 1; }' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || +{ + echo "$me: cannot create a temporary directory in ." >&2 + { (exit 1); exit 1; } +} + +# +# Set up the sed scripts for 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 + +_ACEOF + + + +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + cat >conf$$subs.sed <<_ACEOF +SHELL!$SHELL$ac_delim +PATH_SEPARATOR!$PATH_SEPARATOR$ac_delim +PACKAGE_NAME!$PACKAGE_NAME$ac_delim +PACKAGE_TARNAME!$PACKAGE_TARNAME$ac_delim +PACKAGE_VERSION!$PACKAGE_VERSION$ac_delim +PACKAGE_STRING!$PACKAGE_STRING$ac_delim +PACKAGE_BUGREPORT!$PACKAGE_BUGREPORT$ac_delim +exec_prefix!$exec_prefix$ac_delim +prefix!$prefix$ac_delim +program_transform_name!$program_transform_name$ac_delim +bindir!$bindir$ac_delim +sbindir!$sbindir$ac_delim +libexecdir!$libexecdir$ac_delim +datarootdir!$datarootdir$ac_delim +datadir!$datadir$ac_delim +sysconfdir!$sysconfdir$ac_delim +sharedstatedir!$sharedstatedir$ac_delim +localstatedir!$localstatedir$ac_delim +includedir!$includedir$ac_delim +oldincludedir!$oldincludedir$ac_delim +docdir!$docdir$ac_delim +infodir!$infodir$ac_delim +htmldir!$htmldir$ac_delim +dvidir!$dvidir$ac_delim +pdfdir!$pdfdir$ac_delim +psdir!$psdir$ac_delim +libdir!$libdir$ac_delim +localedir!$localedir$ac_delim +mandir!$mandir$ac_delim +DEFS!$DEFS$ac_delim +ECHO_C!$ECHO_C$ac_delim +ECHO_N!$ECHO_N$ac_delim +ECHO_T!$ECHO_T$ac_delim +LIBS!$LIBS$ac_delim +build_alias!$build_alias$ac_delim +host_alias!$host_alias$ac_delim +target_alias!$target_alias$ac_delim +build!$build$ac_delim +build_cpu!$build_cpu$ac_delim +build_vendor!$build_vendor$ac_delim +build_os!$build_os$ac_delim +host!$host$ac_delim +host_cpu!$host_cpu$ac_delim +host_vendor!$host_vendor$ac_delim +host_os!$host_os$ac_delim +SHLICC2!$SHLICC2$ac_delim +CC!$CC$ac_delim +CFLAGS!$CFLAGS$ac_delim +LDFLAGS!$LDFLAGS$ac_delim +CPPFLAGS!$CPPFLAGS$ac_delim +ac_ct_CC!$ac_ct_CC$ac_delim +EXEEXT!$EXEEXT$ac_delim +OBJEXT!$OBJEXT$ac_delim +CPP!$CPP$ac_delim +GREP!$GREP$ac_delim +EGREP!$EGREP$ac_delim +LIBOBJS!$LIBOBJS$ac_delim +PCAP_CONFIG!$PCAP_CONFIG$ac_delim +RANLIB!$RANLIB$ac_delim +V_CCOPT!$V_CCOPT$ac_delim +V_DEFS!$V_DEFS$ac_delim +V_GROUP!$V_GROUP$ac_delim +V_INCLS!$V_INCLS$ac_delim +V_PCAPDEP!$V_PCAPDEP$ac_delim +LOCALSRC!$LOCALSRC$ac_delim +MAN_FILE_FORMATS!$MAN_FILE_FORMATS$ac_delim +MAN_MISC_INFO!$MAN_MISC_INFO$ac_delim +INSTALL_PROGRAM!$INSTALL_PROGRAM$ac_delim +INSTALL_SCRIPT!$INSTALL_SCRIPT$ac_delim +INSTALL_DATA!$INSTALL_DATA$ac_delim +LTLIBOBJS!$LTLIBOBJS$ac_delim +_ACEOF + + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 71; then + break + elif $ac_last_try; then + { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 +echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} + { (exit 1); exit 1; }; } + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done + +ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed` +if test -n "$ac_eof"; then + ac_eof=`echo "$ac_eof" | sort -nru | sed 1q` + ac_eof=`expr $ac_eof + 1` +fi + +cat >>$CONFIG_STATUS <<_ACEOF +cat >"\$tmp/subs-1.sed" <<\CEOF$ac_eof +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b end +_ACEOF +sed ' +s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g +s/^/s,@/; s/!/@,|#_!!_#|/ +:n +t n +s/'"$ac_delim"'$/,g/; t +s/$/\\/; p +N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n +' >>$CONFIG_STATUS <conf$$subs.sed +rm -f conf$$subs.sed +cat >>$CONFIG_STATUS <<_ACEOF +:end +s/|#_!!_#|//g +CEOF$ac_eof +_ACEOF + + +# 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[ ]*=/{ +s/:*\$(srcdir):*/:/ +s/:*\${srcdir}:*/:/ +s/:*@srcdir@:*/:/ +s/^\([^=]*=[ ]*\):*/\1/ +s/:*$// +s/^[^=]*=[ ]*$// +}' +fi + +cat >>$CONFIG_STATUS <<\_ACEOF +fi # test -n "$CONFIG_FILES" + + +for ac_tag in :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) { { echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5 +echo "$as_me: error: Invalid tag $ac_tag." >&2;} + { (exit 1); exit 1; }; };; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + { { echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 +echo "$as_me: error: cannot find input file: $ac_f" >&2;} + { (exit 1); exit 1; }; };; + esac + ac_file_inputs="$ac_file_inputs $ac_f" + done + + # 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. */ + configure_input="Generated from "`IFS=: + echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure." + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + fi + + case $ac_tag in + *:-:* | *:-) cat >"$tmp/stdin";; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$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'` + { as_dir="$ac_dir" + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$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'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 +echo "$as_me: error: cannot create directory $as_dir" >&2;} + { (exit 1); exit 1; }; }; } + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + :F) + # + # CONFIG_FILE + # + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; + esac +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= + +case `sed -n '/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p +' $ac_file_inputs` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac +_ACEOF + +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? +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&@top_builddir@&$ac_top_builddir_sub&;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&@abs_top_builddir@&$ac_abs_top_builddir&;t t +s&@INSTALL@&$ac_INSTALL&;t t +$ac_datarootdir_hack +" $ac_file_inputs | sed -f "$tmp/subs-1.sed" >$tmp/out + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && + { echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined." >&5 +echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined." >&2;} + + rm -f "$tmp/stdin" + case $ac_file in + -) cat "$tmp/out"; rm -f "$tmp/out";; + *) rm -f "$ac_file"; mv "$tmp/out" $ac_file;; + esac + ;; + :H) + # + # CONFIG_HEADER + # +_ACEOF + +# Transform confdefs.h into a sed script `conftest.defines', that +# substitutes the proper values into config.h.in to produce config.h. +rm -f conftest.defines conftest.tail +# First, append a space to every undef/define line, to ease matching. +echo 's/$/ /' >conftest.defines +# Then, protect against being on the right side of a sed subst, or in +# an unquoted here document, in config.status. If some macros were +# called several times there might be several #defines for the same +# symbol, which is useless. But do not sort them, since the last +# AC_DEFINE must be honored. +ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* +# These sed commands are passed to sed as "A NAME B PARAMS C VALUE D", where +# NAME is the cpp macro being defined, VALUE is the value it is being given. +# PARAMS is the parameter list in the macro definition--in most cases, it's +# just an empty string. +ac_dA='s,^\\([ #]*\\)[^ ]*\\([ ]*' +ac_dB='\\)[ (].*,\\1define\\2' +ac_dC=' ' +ac_dD=' ,' + +uniq confdefs.h | + sed -n ' + t rset + :rset + s/^[ ]*#[ ]*define[ ][ ]*// + t ok + d + :ok + s/[\\&,]/\\&/g + s/^\('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/ '"$ac_dA"'\1'"$ac_dB"'\2'"${ac_dC}"'\3'"$ac_dD"'/p + s/^\('"$ac_word_re"'\)[ ]*\(.*\)/'"$ac_dA"'\1'"$ac_dB$ac_dC"'\2'"$ac_dD"'/p + ' >>conftest.defines + +# Remove the space that was appended to ease matching. +# Then replace #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. +# (The regexp can be short, since the line contains either #define or #undef.) +echo 's/ $// +s,^[ #]*u.*,/* & */,' >>conftest.defines + +# Break up conftest.defines: +ac_max_sed_lines=50 + +# First sed command is: sed -f defines.sed $ac_file_inputs >"$tmp/out1" +# Second one is: sed -f defines.sed "$tmp/out1" >"$tmp/out2" +# Third one will be: sed -f defines.sed "$tmp/out2" >"$tmp/out1" +# et cetera. +ac_in='$ac_file_inputs' +ac_out='"$tmp/out1"' +ac_nxt='"$tmp/out2"' + +while : +do + # Write a here document: + cat >>$CONFIG_STATUS <<_ACEOF + # First, check the format of the line: + cat >"\$tmp/defines.sed" <<\\CEOF +/^[ ]*#[ ]*undef[ ][ ]*$ac_word_re[ ]*\$/b def +/^[ ]*#[ ]*define[ ][ ]*$ac_word_re[( ]/b def +b +:def +_ACEOF + sed ${ac_max_sed_lines}q conftest.defines >>$CONFIG_STATUS + echo 'CEOF + sed -f "$tmp/defines.sed"' "$ac_in >$ac_out" >>$CONFIG_STATUS + ac_in=$ac_out; ac_out=$ac_nxt; ac_nxt=$ac_in + sed 1,${ac_max_sed_lines}d conftest.defines >conftest.tail + grep . conftest.tail >/dev/null || break + rm -f conftest.defines + mv conftest.tail conftest.defines +done +rm -f conftest.defines conftest.tail + +echo "ac_result=$ac_in" >>$CONFIG_STATUS +cat >>$CONFIG_STATUS <<\_ACEOF + if test x"$ac_file" != x-; then + echo "/* $configure_input */" >"$tmp/config.h" + cat "$ac_result" >>"$tmp/config.h" + 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 + rm -f $ac_file + mv "$tmp/config.h" $ac_file + fi + else + echo "/* $configure_input */" + cat "$ac_result" + fi + rm -f "$tmp/out12" + ;; + + :C) { echo "$as_me:$LINENO: executing $ac_file commands" >&5 +echo "$as_me: executing $ac_file commands" >&6;} + ;; + esac + + + case $ac_file$ac_mode in + "default-1":C) if test -f .devel; then + echo timestamp > stamp-h + cat Makefile-devel-adds >> Makefile + make depend +fi ;; + + esac +done # for ac_tag + + +{ (exit 0); exit 0; } +_ACEOF +chmod +x $CONFIG_STATUS +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/tcpdump-4.3.0/configure.in b/tcpdump-4.3.0/configure.in new file mode 100644 index 0000000..8864238 --- /dev/null +++ b/tcpdump-4.3.0/configure.in
@@ -0,0 +1,1111 @@ +dnl @(#) $Header: /tcpdump/master/tcpdump/configure.in,v 1.204 2008-11-18 07:39:20 guy Exp $ (LBL) +dnl +dnl Copyright (c) 1994, 1995, 1996, 1997 +dnl The Regents of the University of California. All rights reserved. +dnl +dnl Process this file with autoconf to produce a configure script. +dnl + +# +# See +# +# http://ftp.gnu.org/gnu/config/README +# +# for the URLs to use to fetch new versions of config.guess and +# config.sub. +# + +AC_REVISION($Revision: 1.204 $) +AC_PREREQ(2.50) +AC_INIT(tcpdump.c) + +AC_CANONICAL_HOST + +AC_LBL_C_INIT_BEFORE_CC(V_CCOPT, V_INCLS) +AC_PROG_CC +AC_LBL_C_INIT(V_CCOPT, V_INCLS) +AC_LBL_C_INLINE +AC_C___ATTRIBUTE__ +if test "$ac_cv___attribute__" = "yes"; then + AC_C___ATTRIBUTE___FORMAT_FUNCTION_POINTER +fi +AC_CHECK_HEADERS(fcntl.h rpc/rpc.h rpc/rpcent.h netdnet/dnetdb.h) +AC_CHECK_HEADERS(net/pfvar.h, , , [#include <sys/types.h> +#include <sys/socket.h> +#include <net/if.h>]) +if test "$ac_cv_header_net_pfvar_h" = yes; then + LOCALSRC="print-pflog.c $LOCALSRC" +fi +AC_CHECK_HEADERS(netinet/if_ether.h, , , [#include <sys/types.h> +#include <sys/socket.h>]) +if test "$ac_cv_header_netinet_if_ether_h" != yes; then + # + # The simple test didn't work. + # Do we need to include <net/if.h> first? + # Unset ac_cv_header_netinet_if_ether_h so we don't + # treat the previous failure as a cached value and + # suppress the next test. + # + AC_MSG_NOTICE([Rechecking with some additional includes]) + unset ac_cv_header_netinet_if_ether_h + AC_CHECK_HEADERS(netinet/if_ether.h, , , [#include <sys/types.h> +#include <sys/socket.h> +#include <netinet/in.h> +struct mbuf; +struct rtentry; +#include <net/if.h>]) +fi + +AC_HEADER_TIME + +case "$host_os" in + +darwin*) + AC_ARG_ENABLE(universal, + AC_HELP_STRING([--disable-universal],[don't build universal on OS X])) + if test "$enable_universal" != "no"; then + case "$host_os" in + + darwin9.*) + # + # Leopard. Build for x86 and 32-bit PowerPC, with + # x86 first. (That's what Apple does.) + # + V_CCOPT="$V_CCOPT -arch i386 -arch ppc" + LDFLAGS="$LDFLAGS -arch i386 -arch ppc" + ;; + + darwin10.*) + # + # Snow Leopard. Build for x86-64 and x86, with + # x86-64 first. (That's what Apple does.) + # + V_CCOPT="$V_CCOPT -arch x86_64 -arch i386" + LDFLAGS="$LDFLAGS -arch x86_64 -arch i386" + ;; + esac + fi + ;; + +linux*) + AC_MSG_CHECKING(Linux kernel version) + if test "$cross_compiling" = yes; then + AC_CACHE_VAL(ac_cv_linux_vers, + ac_cv_linux_vers=unknown) + else + AC_CACHE_VAL(ac_cv_linux_vers, + ac_cv_linux_vers=`uname -r 2>&1 | \ + sed -n -e '$s/.* //' -e '$s/\..*//p'`) + fi + AC_MSG_RESULT($ac_cv_linux_vers) + if test $ac_cv_linux_vers = unknown ; then + AC_MSG_ERROR(cannot determine linux version when cross-compiling) + fi + if test $ac_cv_linux_vers -lt 2 ; then + AC_MSG_ERROR(version 2 or higher required; see the INSTALL doc for more info) + fi + ;; + +*) + ;; +esac + + +AC_ARG_WITH(smi, +[ --with-smi link with libsmi (allows to load MIBs on the fly to decode SNMP packets. [default=yes] + --without-smi don't link with libsmi],, + with_smi=yes) + +if test "x$with_smi" != "xno" ; then +AC_CHECK_HEADERS(smi.h) +AC_CHECK_LIB(smi, smiInit) +if test "$ac_cv_header_smi_h" = yes -a "$ac_cv_lib_smi_smiInit" = yes +then +AC_MSG_CHECKING([whether to enable libsmi]) + AC_TRY_RUN([ /* libsmi available check */ +#include <smi.h> +main() +{ + int current, revision, age, n; + const int required = 2; + if (smiInit("")) + exit(1); + if (strcmp(SMI_LIBRARY_VERSION, smi_library_version)) + exit(2); + n = sscanf(smi_library_version, "%d:%d:%d", ¤t, &revision, &age); + if (n != 3) + exit(3); + if (required < current - age || required > current) + exit(4); + exit(0); +} +], +[ AC_MSG_RESULT(yes) + AC_DEFINE(LIBSMI) + libsmi=yes], +dnl autoconf documentation says that $? contains the exit value. +dnl reality is that it does not. We leave this in just in case +dnl autoconf ever comes back to match the documentation. +[ case $? in + 1) AC_MSG_RESULT(no - smiInit failed) ;; + 2) AC_MSG_RESULT(no - header/library version mismatch) ;; + 3) AC_MSG_RESULT(no - can't determine library version) ;; + 4) AC_MSG_RESULT(no - too old) ;; + *) AC_MSG_RESULT(no) ;; + esac + libsmi=no], +[ AC_MSG_RESULT(not when cross-compiling) + libsmi=no] +) +fi +fi + +AC_MSG_CHECKING([whether to enable the possibly-buggy SMB printer]) +AC_ARG_ENABLE(smb, +[ --enable-smb enable possibly-buggy SMB printer [default=yes] + --disable-smb disable possibly-buggy SMB printer],, + enableval=yes) +case "$enableval" in +yes) AC_MSG_RESULT(yes) + AC_WARN([The SMB printer may have exploitable buffer overflows!!!]) + AC_DEFINE(TCPDUMP_DO_SMB) + LOCALSRC="print-smb.c smbutil.c $LOCALSRC" + ;; +*) AC_MSG_RESULT(no) + ;; +esac + +AC_ARG_WITH(user, [ --with-user=USERNAME drop privileges by default to USERNAME]) +AC_MSG_CHECKING([whether to drop root privileges by default]) +if test ! -z "$with_user" ; then + AC_DEFINE_UNQUOTED(WITH_USER, "$withval") + AC_MSG_RESULT(to \"$withval\") +else + AC_MSG_RESULT(no) +fi + +AC_ARG_WITH(chroot, [ --with-chroot=DIRECTORY when dropping privileges, chroot to DIRECTORY]) +AC_MSG_CHECKING([whether to chroot]) +if test ! -z "$with_chroot" && test "$with_chroot" != "no" ; then + AC_DEFINE_UNQUOTED(WITH_CHROOT, "$withval") + AC_MSG_RESULT(to \"$withval\") +else + AC_MSG_RESULT(no) +fi + +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-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c print-babel.c $LOCALSRC" + AC_DEFINE(INET6) + ipv6=yes + ;; +*) + AC_MSG_RESULT(no) + ipv6=no + ;; + esac ], + + AC_TRY_RUN([ /* AF_INET6 available check */ +#include <sys/types.h> +#include <sys/socket.h> +main() +{ + if (socket(AF_INET6, SOCK_STREAM, 0) < 0) + exit(1); + else + exit(0); +} +], +[ AC_MSG_RESULT(yes) + 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 print-babel.c $LOCALSRC" + AC_DEFINE(INET6) + ipv6=yes], +[ AC_MSG_RESULT(no) + ipv6=no], +[ AC_MSG_RESULT(no) + ipv6=no] +)) + +ipv6type=unknown +ipv6lib=none +ipv6trylibc=no + +if test "$ipv6" = "yes"; then + AC_MSG_CHECKING([ipv6 stack type]) + for i in inria kame linux-glibc linux-libinet6 toshiba v6d zeta; do + case $i in + inria) + dnl http://www.kame.net/ + AC_EGREP_CPP(yes, +[#include <netinet/in.h> +#ifdef IPV6_INRIA_VERSION +yes +#endif], + [ipv6type=$i; + CFLAGS="-DINET6 $CFLAGS"]) + ;; + kame) + dnl http://www.kame.net/ + AC_EGREP_CPP(yes, +[#include <netinet/in.h> +#ifdef __KAME__ +yes +#endif], + [ipv6type=$i; + ipv6lib=inet6; + ipv6libdir=/usr/local/v6/lib; + ipv6trylibc=yes; + CFLAGS="-DINET6 $CFLAGS"]) + ;; + linux-glibc) + dnl http://www.v6.linux.or.jp/ + AC_EGREP_CPP(yes, +[#include <features.h> +#if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1 +yes +#endif], + [ipv6type=$i; + CFLAGS="-DINET6 $CFLAGS"]) + ;; + 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 + ipv6libdir=/usr/inet6/lib + ipv6trylibc=yes; + CFLAGS="-DINET6 -I/usr/inet6/include $CFLAGS" + fi + ;; + toshiba) + AC_EGREP_CPP(yes, +[#include <sys/param.h> +#ifdef _TOSHIBA_INET6 +yes +#endif], + [ipv6type=$i; + ipv6lib=inet6; + ipv6libdir=/usr/local/v6/lib; + CFLAGS="-DINET6 $CFLAGS"]) + ;; + v6d) + AC_EGREP_CPP(yes, +[#include </usr/local/v6/include/sys/v6config.h> +#ifdef __V6D__ +yes +#endif], + [ipv6type=$i; + ipv6lib=v6; + ipv6libdir=/usr/local/v6/lib; + CFLAGS="-I/usr/local/v6/include $CFLAGS"]) + ;; + zeta) + AC_EGREP_CPP(yes, +[#include <sys/param.h> +#ifdef _ZETA_MINAMI_INET6 +yes +#endif], + [ipv6type=$i; + ipv6lib=inet6; + ipv6libdir=/usr/local/v6/lib; + CFLAGS="-DINET6 $CFLAGS"]) + ;; + esac + if test "$ipv6type" != "unknown"; then + break + fi + done + AC_MSG_RESULT($ipv6type) +fi + +if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then + if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then + LIBS="-L$ipv6libdir -l$ipv6lib $LIBS" + echo "You have $ipv6lib library, using it" + else + if test "$ipv6trylibc" = "yes"; then + echo "You do not have $ipv6lib library, using libc" + else + echo 'Fatal: no $ipv6lib library found. cannot continue.' + echo "You need to fetch lib$ipv6lib.a from appropriate" + echo 'ipv6 kit and compile beforehand.' + exit 1 + fi + fi +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_CACHE_VAL(td_cv_buggygetaddrinfo, [AC_TRY_RUN([ +#include <sys/types.h> +#include <netdb.h> +#include <string.h> +#include <sys/socket.h> +#include <netinet/in.h> + +main() +{ + int passive, gaierr, inet4 = 0, inet6 = 0; + struct addrinfo hints, *ai, *aitop; + char straddr[INET6_ADDRSTRLEN], strport[16]; + + for (passive = 0; passive <= 1; passive++) { + memset(&hints, 0, sizeof(hints)); + 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; + } + for (ai = aitop; ai; ai = ai->ai_next) { + if (ai->ai_addr == NULL || + ai->ai_addrlen == 0 || + getnameinfo(ai->ai_addr, ai->ai_addrlen, + straddr, sizeof(straddr), strport, sizeof(strport), + NI_NUMERICHOST|NI_NUMERICSERV) != 0) { + goto bad; + } + switch (ai->ai_family) { + case AF_INET: + if (strcmp(strport, "54321") != 0) { + goto bad; + } + if (passive) { + if (strcmp(straddr, "0.0.0.0") != 0) { + goto bad; + } + } else { + if (strcmp(straddr, "127.0.0.1") != 0) { + goto bad; + } + } + inet4++; + break; + case AF_INET6: + if (strcmp(strport, "54321") != 0) { + goto bad; + } + if (passive) { + if (strcmp(straddr, "::") != 0) { + goto bad; + } + } else { + if (strcmp(straddr, "::1") != 0) { + goto bad; + } + } + inet6++; + break; + case AF_UNSPEC: + goto bad; + break; +#ifdef AF_UNIX + case AF_UNIX: +#else +#ifdef AF_LOCAL + case AF_LOCAL: +#endif +#endif + default: + /* another family support? */ + break; + } + } + } + + /* supported family should be 2, unsupported family should be 0 */ + if (!(inet4 == 0 || inet4 == 2)) + goto bad; + if (!(inet6 == 0 || inet6 == 2)) + goto bad; + + if (aitop) + freeaddrinfo(aitop); + exit(0); + + bad: + if (aitop) + freeaddrinfo(aitop); + exit(1); +} +], + 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 upgrade your system library to newest version' + echo ' of GNU C library (aka glibc).' + fi + fi + ]) + AC_REPLACE_FUNCS(getnameinfo) +fi + +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 +dnl Checks for addrinfo structure +AC_STRUCT_ADDRINFO(ac_cv_addrinfo) +if test "$ac_cv_addrinfo" = no; then + missing_includes=yes +fi + +dnl +dnl Checks for NI_MAXSERV +AC_NI_MAXSERV(ac_cv_maxserv) +if test "$ac_cv_maxserv" = no; then + missing_includes=yes +fi + +dnl +dnl Checks for NI_NAMEREQD +AC_NI_NAMEREQD(ac_cv_namereqd) +if test "$ac_cv_namereqd" = no; then + missing_includes=yes +fi + +dnl +dnl Checks for sockaddr_storage structure +AC_STRUCT_SA_STORAGE(ac_cv_sa_storage) +if test "$ac_cv_sa_storage" = no; then + missing_includes=yes +fi + +AC_REPLACE_FUNCS(vfprintf strcasecmp strlcat strlcpy strdup strsep) +AC_CHECK_FUNCS(fork vfork strftime) +AC_CHECK_FUNCS(setlinebuf alarm) + +needsnprintf=no +AC_CHECK_FUNCS(vsnprintf snprintf,, + [needsnprintf=yes]) +if test $needsnprintf = yes; then + AC_LIBOBJ(snprintf) +fi + +AC_LBL_TYPE_SIGNAL + +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 + +dnl Some platforms may need -lnsl for getrpcbynumber. +AC_SEARCH_LIBS(getrpcbynumber, nsl, AC_DEFINE(HAVE_GETRPCBYNUMBER)) + +dnl AC_CHECK_LIB(z, uncompress) +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)]) +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)]) +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)]) + +# +# Check for these after AC_LBL_LIBPCAP, for the same reason. +# +# You are in a twisty little maze of UN*Xes, all different. +# Some might not have ether_ntohost(). +# Some might have it, but not declare it in any header file. +# Some might have it, but declare it in <netinet/if_ether.h>. +# Some might have it, but declare it in <netinet/ether.h> +# (And some might have it but document it as something declared in +# <netinet/ethernet.h>, although <netinet/if_ether.h> appears to work.) +# +# Before you is a C compiler. +# +AC_CHECK_FUNCS(ether_ntohost, [ + AC_CACHE_CHECK(for buggy ether_ntohost, ac_cv_buggy_ether_ntohost, [ + AC_TRY_RUN([ + #include <netdb.h> + #include <sys/types.h> + #include <sys/param.h> + #include <sys/socket.h> + + int + main(int argc, char **argv) + { + u_char ea[6] = { 0xff, 0xff, 0xff, 0xff, 0xff }; + char name[MAXHOSTNAMELEN]; + + ether_ntohost(name, (struct ether_addr *)ea); + exit(0); + } + ], [ac_cv_buggy_ether_ntohost=no], + [ac_cv_buggy_ether_ntohost=yes], + [ac_cv_buggy_ether_ntohost="not while cross-compiling"])]) + if test "$ac_cv_buggy_ether_ntohost" = "no"; then + AC_DEFINE(USE_ETHER_NTOHOST) + fi +]) +if test "$ac_cv_func_ether_ntohost" = yes -a \ + "$ac_cv_buggy_ether_ntohost" = "no"; then + # + # OK, we have ether_ntohost(). Do we have <netinet/if_ether.h>? + # + if test "$ac_cv_header_netinet_if_ether_h" = yes; then + # + # Yes. Does it declare ether_ntohost()? + # + AC_CHECK_DECL(ether_ntohost, + [ + AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST,, + [Define to 1 if netinet/if_ether.h declares `ether_ntohost']) + ],, + [ +#include <sys/types.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> +struct mbuf; +struct rtentry; +#include <net/if.h> +#include <netinet/if_ether.h> + ]) + fi + # + # Did that succeed? + # + if test "$ac_cv_have_decl_ether_ntohost" != yes; then + # + # No, how about <netinet/ether.h>, as on Linux? + # + AC_CHECK_HEADERS(netinet/ether.h) + if test "$ac_cv_header_netinet_ether_h" = yes; then + # + # We have it - does it declare ether_ntohost()? + # Unset ac_cv_have_decl_ether_ntohost so we don't + # treat the previous failure as a cached value and + # suppress the next test. + # + unset ac_cv_have_decl_ether_ntohost + AC_CHECK_DECL(ether_ntohost, + [ + AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_NTOHOST,, + [Define to 1 if netinet/ether.h declares `ether_ntohost']) + ],, + [ +#include <netinet/ether.h> + ]) + fi + fi + # + # Is ether_ntohost() declared? + # + if test "$ac_cv_have_decl_ether_ntohost" != yes; then + # + # No, we'll have to declare it ourselves. + # Do we have "struct ether_addr"? + # + AC_CHECK_TYPES(struct ether_addr,,, + [ +#include <sys/types.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> +struct mbuf; +struct rtentry; +#include <net/if.h> +#include <netinet/if_ether.h> + ]) + AC_DEFINE(HAVE_DECL_ETHER_NTOHOST, 0, + [Define to 1 if you have the declaration of `ether_ntohost', and to 0 if you +don't.]) + else + AC_DEFINE(HAVE_DECL_ETHER_NTOHOST, 1, + [Define to 1 if you have the declaration of `ether_ntohost', and to 0 if you +don't.]) + fi +fi + +# libdlpi is needed for Solaris 11 and later. +AC_CHECK_LIB(dlpi, dlpi_walk, LIBS="$LIBS -ldlpi" LDFLAGS="-L/lib $LDFLAGS", ,-L/lib) + +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 + +# +# Do we have the new open API? Check for pcap_create, and assume that, +# if we do, we also have pcap_activate() and the other new routines +# introduced in libpcap 1.0.0. +# +AC_CHECK_FUNCS(pcap_create) +if test $ac_cv_func_pcap_create = "yes" ; then + # + # OK, do we have pcap_set_tstamp_type? If so, assume we have + # pcap_list_tstamp_types and pcap_free_tstamp_types as well. + # + AC_CHECK_FUNCS(pcap_set_tstamp_type) +fi + +AC_CHECK_FUNCS(pcap_findalldevs pcap_dump_flush pcap_lib_version) +if test $ac_cv_func_pcap_findalldevs = "yes" ; then +dnl Check for Mac OS 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. + savedcppflags="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $V_INCLS" + AC_CHECK_TYPES(pcap_if_t, , , [#include <pcap.h>]) + CPPFLAGS="$savedcppflags" +fi + +if test $ac_cv_func_pcap_lib_version = "no" ; then + AC_MSG_CHECKING(whether pcap_version is defined by libpcap) + AC_TRY_LINK([], + [ + extern char pcap_version[]; + + return (int)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([], + [ + 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([], + [ + 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 +if test -f /etc/group -a ! -z "`grep '^wheel:' /etc/group`" ; then + V_GROUP=wheel +fi +# +# Assume V7/BSD convention for man pages (file formats in section 5, +# miscellaneous info in section 7). +# +MAN_FILE_FORMATS=5 +MAN_MISC_INFO=7 +case "$host_os" in + +aix*) + dnl Workaround to enable certain features + AC_DEFINE(_SUN,1,[define on AIX to get certain functions]) + ;; + +hpux*) + # + # Use System V conventions for man pages. + # + MAN_FILE_FORMATS=4 + MAN_MISC_INFO=5 + ;; + +irix*) + V_GROUP=sys + + # + # Use System V conventions for man pages. + # + MAN_FILE_FORMATS=4 + MAN_MISC_INFO=5 + ;; + +osf*) + V_GROUP=system + + # + # Use System V conventions for man pages. + # + MAN_FILE_FORMATS=4 + MAN_MISC_INFO=5 + ;; + +solaris*) + V_GROUP=sys + + # + # Use System V conventions for man pages. + # + MAN_FILE_FORMATS=4 + MAN_MISC_INFO=5 + ;; +esac + +if test -f /dev/bpf0 ; then + V_GROUP=bpf +fi + +AC_CHECK_HEADERS(sys/bitypes.h) + +AC_CHECK_TYPE([int8_t], , + [AC_DEFINE([int8_t], [signed char], + [Define to `signed char' if int8_t not defined.])], + [AC_INCLUDES_DEFAULT +#ifdef HAVE_SYS_BITYPES_H +#include <sys/bitypes.h> +#endif]) +AC_CHECK_TYPE([u_int8_t], , + [AC_DEFINE([u_int8_t], [unsigned char], + [Define to `unsigned char' if u_int8_t not defined.])], + [AC_INCLUDES_DEFAULT +#ifdef HAVE_SYS_BITYPES_H +#include <sys/bitypes.h> +#endif]) +AC_CHECK_TYPE([int16_t], , + [AC_DEFINE([int16_t], [short], + [Define to `short' if int16_t not defined.])] + [AC_INCLUDES_DEFAULT +#ifdef HAVE_SYS_BITYPES_H +#include <sys/bitypes.h> +#endif]) +AC_CHECK_TYPE([u_int16_t], , + [AC_DEFINE([u_int16_t], [unsigned short], + [Define to `unsigned short' if u_int16_t not defined.])], + [AC_INCLUDES_DEFAULT +#ifdef HAVE_SYS_BITYPES_H +#include <sys/bitypes.h> +#endif]) +AC_CHECK_TYPE([int32_t], , + [AC_DEFINE([int32_t], [int], + [Define to `int' if int32_t not defined.])], + [AC_INCLUDES_DEFAULT +#ifdef HAVE_SYS_BITYPES_H +#include <sys/bitypes.h> +#endif]) +AC_CHECK_TYPE([u_int32_t], , + [AC_DEFINE([u_int32_t], [unsigned int], + [Define to `unsigned int' if u_int32_t not defined.])], + [AC_INCLUDES_DEFAULT +#ifdef HAVE_SYS_BITYPES_H +#include <sys/bitypes.h> +#endif]) +AC_CHECK_TYPE([int64_t], , + [AC_DEFINE([int64_t], [long long], + [Define to `long long' if int64_t not defined.])], + [AC_INCLUDES_DEFAULT +#ifdef HAVE_SYS_BITYPES_H +#include <sys/bitypes.h> +#endif]) +AC_CHECK_TYPE([u_int64_t], , + [AC_DEFINE([u_int64_t], [unsigned long long], + [Define to `unsigned long long' if u_int64_t not defined.])], + [AC_INCLUDES_DEFAULT +#ifdef HAVE_SYS_BITYPES_H +#include <sys/bitypes.h> +#endif]) + +# +# We can't just check for <inttypes.h> - some systems have one that +# doesn't define all the PRI[doxu]64 macros. +# +AC_CHECK_HEADERS(inttypes.h, + [ + # + # OK, we have inttypes.h, but does it define those macros? + # + AC_MSG_CHECKING([[whether inttypes.h defines the PRI[doxu]64 macros]]) + AC_COMPILE_IFELSE( + [ + AC_LANG_SOURCE( + [[ + #include <inttypes.h> + #include <stdio.h> + #include <sys/types.h> + #ifdef HAVE_SYS_BITYPES_H + #include <sys/bitypes.h> + #endif + + main() + { + printf("%" PRId64 "\n", (u_int64_t)1); + printf("%" PRIo64 "\n", (u_int64_t)1); + printf("%" PRIx64 "\n", (u_int64_t)1); + printf("%" PRIu64 "\n", (u_int64_t)1); + } + ]]) + ], + [ + AC_MSG_RESULT(yes) + ac_lbl_inttypes_h_defines_formats=yes + ], + [ + AC_MSG_RESULT(no) + ac_lbl_inttypes_h_defines_formats=no + ]) + ], + [ + # + # We don't have inttypes.h, so it obviously can't define those + # macros. + # + ac_lbl_inttypes_h_defines_formats=no + ]) +if test "$ac_lbl_inttypes_h_defines_formats" = no; then + AC_LBL_CHECK_64BIT_FORMAT(l, + [ + AC_LBL_CHECK_64BIT_FORMAT(ll, + [ + AC_LBL_CHECK_64BIT_FORMAT(L, + [ + AC_LBL_CHECK_64BIT_FORMAT(q, + [ + AC_MSG_ERROR([neither %llx nor %Lx nor %qx worked on a 64-bit integer]) + ]) + ]) + ]) + ]) +fi + +# +# Check for some headers introduced in later versions of libpcap +# and used by some printers. +# +# Those headers use the {u_}intN_t types, so we must do this after +# we check for what's needed to get them defined. +# +savedcppflags="$CPPFLAGS" +CPPFLAGS="$CPPFLAGS $V_INCLS" +AC_CHECK_HEADERS(pcap/bluetooth.h,,,[#include <tcpdump-stdinc.h>]) +AC_CHECK_HEADERS(pcap/usb.h,,,[#include <tcpdump-stdinc.h>]) +CPPFLAGS="$savedcppflags" + +AC_PROG_RANLIB + +AC_LBL_DEVEL(V_CCOPT) + +AC_LBL_SOCKADDR_SA_LEN + +AC_LBL_UNALIGNED_ACCESS + +AC_VAR_H_ERRNO + +# Check for SSLeay +AC_MSG_CHECKING(whether to use SSLeay libcrypto) +# Specify location for both includes and libraries. +want_libcrypto=youmama +AC_ARG_WITH(crypto, + AS_HELP_STRING([--with-crypto@<:@=PATH@:>@], + [use SSLeay libcrypto (located in directory PATH, if supplied). @<:@default=yes, if available@:>@]), +[ + if test $withval = no + then + want_libcrypto=no + AC_MSG_RESULT(no) + elif test $withval = yes + then + want_libcrypto=yes + AC_MSG_RESULT(yes) + else + want_libcrypto=yes + AC_MSG_RESULT(yes) + crypto_dir=$withval + fi +],[ + # + # Use libcrypto if it's present, otherwise don't. + # + want_libcrypto=ifavailable + AC_MSG_RESULT([yes, if available]) +]) +if test "$want_libcrypto" != "no"; then + ac_cv_ssleay_path=no + incdir=no + if test "x$crypto_dir" = x; then + # + # Location not specified; check the default locations. + # + AC_MSG_CHECKING(where SSLeay is located) + dirs="/usr /usr/local /usr/local/ssl /usr/pkg" + if test "x${host_alias}" != x; then + dirs="/usr/${host_alias} $dirs" + fi + for dir in $dirs; do + AC_LBL_SSLEAY($dir) + + if test "$ac_cv_ssleay_path" != "no" -a "$incdir" != "no"; then + break; + else + ac_cv_ssleay_path=no + incdir=no + fi + done + if test "$ac_cv_ssleay_path" != no; then + AC_MSG_RESULT($ac_cv_ssleay_path) + fi + else + AC_MSG_CHECKING(for SSLeay in $crypto_dir) + AC_LBL_SSLEAY($crypto_dir) + if test "$ac_cv_ssleay_path" != no; then + AC_MSG_RESULT(found) + fi + fi + if test "$ac_cv_ssleay_path" != no; then + V_INCLS="$V_INCLS $incdir" + if test "$dir" != "/usr"; then + LDFLAGS="-L$dir/lib $LDFLAGS" + fi + if test -f $ac_cv_ssleay_path/lib/libRSAglue.a; then + LIBS="$LIBS -lRSAglue" + fi + if test -f $ac_cv_ssleay_path/lib/librsaref.a; then + LIBS="$LIBS -lrsaref" + fi + AC_CHECK_LIB(crypto, DES_cbc_encrypt) + + savedcppflags="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $V_INCLS" + AC_CHECK_HEADERS(openssl/evp.h) + CPPFLAGS="$savedcppflags" + else + # + # Not found. Did the user explicitly ask for it? + # + AC_MSG_RESULT(not found) + if test "$want_libcrypto" = yes; then + AC_MSG_ERROR(SSLeay not found) + fi + fi +fi + +dnl +dnl set additional include path if necessary +if test "$missing_includes" = "yes"; then + CPPFLAGS="$CPPFLAGS -I$srcdir/missing" + V_INCLS="$V_INCLS -I$srcdir/missing" +fi + +AC_SUBST(V_CCOPT) +AC_SUBST(V_DEFS) +AC_SUBST(V_GROUP) +AC_SUBST(V_INCLS) +AC_SUBST(V_PCAPDEP) +AC_SUBST(LOCALSRC) +AC_SUBST(MAN_FILE_FORMATS) +AC_SUBST(MAN_MISC_INFO) + +AC_PROG_INSTALL + +AC_CONFIG_HEADER(config.h) + +AC_OUTPUT_COMMANDS([if test -f .devel; then + echo timestamp > stamp-h + cat Makefile-devel-adds >> Makefile + make depend +fi]) +AC_OUTPUT(Makefile tcpdump.1) +exit 0
diff --git a/tcpdump-4.3.0/cpack.c b/tcpdump-4.3.0/cpack.c new file mode 100644 index 0000000..c921b39 --- /dev/null +++ b/tcpdump-4.3.0/cpack.c
@@ -0,0 +1,144 @@ +/*- + * Copyright (c) 2003, 2004 David Young. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of David Young may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``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 DAVID + * YOUNG 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 + +#include <stdlib.h> +#include <string.h> +#include <tcpdump-stdinc.h> + +#include "cpack.h" +#include "extract.h" + +u_int8_t * +cpack_next_boundary(u_int8_t *buf, u_int8_t *p, size_t alignment) +{ + size_t misalignment = (size_t)(p - buf) % alignment; + + if (misalignment == 0) + return p; + + return p + (alignment - misalignment); +} + +/* Advance to the next wordsize boundary. Return NULL if fewer than + * wordsize bytes remain in the buffer after the boundary. Otherwise, + * return a pointer to the boundary. + */ +u_int8_t * +cpack_align_and_reserve(struct cpack_state *cs, size_t wordsize) +{ + u_int8_t *next; + + /* Ensure alignment. */ + next = cpack_next_boundary(cs->c_buf, cs->c_next, wordsize); + + /* Too little space for wordsize bytes? */ + if (next - cs->c_buf + wordsize > cs->c_len) + return NULL; + + return next; +} + +int +cpack_init(struct cpack_state *cs, u_int8_t *buf, size_t buflen) +{ + memset(cs, 0, sizeof(*cs)); + + cs->c_buf = buf; + cs->c_len = buflen; + cs->c_next = cs->c_buf; + + return 0; +} + +/* Unpack a 64-bit unsigned integer. */ +int +cpack_uint64(struct cpack_state *cs, u_int64_t *u) +{ + u_int8_t *next; + + if ((next = cpack_align_and_reserve(cs, sizeof(*u))) == NULL) + return -1; + + *u = EXTRACT_LE_64BITS(next); + + /* Move pointer past the u_int64_t. */ + cs->c_next = next + sizeof(*u); + return 0; +} + +/* Unpack a 32-bit unsigned integer. */ +int +cpack_uint32(struct cpack_state *cs, u_int32_t *u) +{ + u_int8_t *next; + + if ((next = cpack_align_and_reserve(cs, sizeof(*u))) == NULL) + return -1; + + *u = EXTRACT_LE_32BITS(next); + + /* Move pointer past the u_int32_t. */ + cs->c_next = next + sizeof(*u); + return 0; +} + +/* Unpack a 16-bit unsigned integer. */ +int +cpack_uint16(struct cpack_state *cs, u_int16_t *u) +{ + u_int8_t *next; + + if ((next = cpack_align_and_reserve(cs, sizeof(*u))) == NULL) + return -1; + + *u = EXTRACT_LE_16BITS(next); + + /* Move pointer past the u_int16_t. */ + cs->c_next = next + sizeof(*u); + return 0; +} + +/* Unpack an 8-bit unsigned integer. */ +int +cpack_uint8(struct cpack_state *cs, u_int8_t *u) +{ + /* No space left? */ + if ((size_t)(cs->c_next - cs->c_buf) >= cs->c_len) + return -1; + + *u = *cs->c_next; + + /* Move pointer past the u_int8_t. */ + cs->c_next++; + return 0; +}
diff --git a/tcpdump-4.3.0/cpack.h b/tcpdump-4.3.0/cpack.h new file mode 100644 index 0000000..74f9796 --- /dev/null +++ b/tcpdump-4.3.0/cpack.h
@@ -0,0 +1,54 @@ +/*- + * Copyright (c) 2003, 2004 David Young. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of David Young may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``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 DAVID + * YOUNG 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 _CPACK_H +#define _CPACK_H + +struct cpack_state { + u_int8_t *c_buf; + u_int8_t *c_next; + size_t c_len; +}; + +int cpack_init(struct cpack_state *, u_int8_t *, size_t); + +int cpack_uint8(struct cpack_state *, u_int8_t *); +int cpack_uint16(struct cpack_state *, u_int16_t *); +int cpack_uint32(struct cpack_state *, u_int32_t *); +int cpack_uint64(struct cpack_state *, u_int64_t *); + +u_int8_t *cpack_next_boundary(u_int8_t *buf, u_int8_t *p, size_t alignment); +u_int8_t *cpack_align_and_reserve(struct cpack_state *cs, size_t wordsize); + +#define cpack_int8(__s, __p) cpack_uint8((__s), (u_int8_t*)(__p)) +#define cpack_int16(__s, __p) cpack_uint16((__s), (u_int16_t*)(__p)) +#define cpack_int32(__s, __p) cpack_uint32((__s), (u_int32_t*)(__p)) +#define cpack_int64(__s, __p) cpack_uint64((__s), (u_int64_t*)(__p)) + +#endif /* _CPACK_H */
diff --git a/tcpdump-4.3.0/dccp.h b/tcpdump-4.3.0/dccp.h new file mode 100644 index 0000000..5c66e23 --- /dev/null +++ b/tcpdump-4.3.0/dccp.h
@@ -0,0 +1,139 @@ +/* @(#) $Header: /tcpdump/master/tcpdump/dccp.h,v 1.5 2006-11-02 09:05:23 hannes Exp $ (LBL) */ +/* + * Copyright (C) Arnaldo Carvalho de Melo 2004 + * Copyright (C) Ian McDonald 2005 <iam4@cs.waikato.ac.nz> + * Copyright (C) Yoshifumi Nishida 2005 + * + * This software may be distributed either under the terms of the + * BSD-style license that accompanies tcpdump or the GNU GPL version 2 + */ + +#ifndef __DCCP_HDR__ +#define __DCCP_HDR__ + +/** + * struct dccp_hdr - generic part of DCCP packet header + * + * @dccph_sport - Relevant port on the endpoint that sent this packet + * @dccph_dport - Relevant port on the other endpoint + * @dccph_doff - Data Offset from the start of the DCCP header, in 32-bit words + * @dccph_ccval - Used by the HC-Sender CCID + * @dccph_cscov - Parts of the packet that are covered by the Checksum field + * @dccph_checksum - Internet checksum, depends on dccph_cscov + * @dccph_x - 0 = 24 bit sequence number, 1 = 48 + * @dccph_type - packet type, see DCCP_PKT_ prefixed macros + * @dccph_seq - sequence number high or low order 24 bits, depends on dccph_x + */ +struct dccp_hdr { + u_int16_t dccph_sport, + dccph_dport; + u_int8_t dccph_doff; + u_int8_t dccph_ccval_cscov; + u_int16_t dccph_checksum; + union { + u_int8_t dccph_xtr; + u_int32_t dccph_seq; + } dccph_xtrs; +}; + +#define DCCPH_CCVAL(dh) (((dh)->dccph_ccval_cscov >> 4) & 0xF) +#define DCCPH_CSCOV(dh) (((dh)->dccph_ccval_cscov) & 0xF) + +#define DCCPH_X(dh) ((dh)->dccph_xtrs.dccph_xtr & 1) +#define DCCPH_TYPE(dh) (((dh)->dccph_xtrs.dccph_xtr >> 1) & 0xF) +#define DCCPH_SEQ(dh) (((dh)->dccph_xtrs.dccph_seq) >> 8) + +/** + * struct dccp_hdr_ext - the low bits of a 48 bit seq packet + * + * @dccph_seq_low - low 24 bits of a 48 bit seq packet + */ +struct dccp_hdr_ext { + u_int32_t dccph_seq_low; +}; + +/** + * struct dccp_hdr_request - Conection initiation request header + * + * @dccph_req_service - Service to which the client app wants to connect + */ +struct dccp_hdr_request { + u_int32_t dccph_req_service; +}; + +/** + * struct dccp_hdr_ack_bits - acknowledgment bits common to most packets + * + * @dccph_resp_ack_nr_high - 48 bit ack number high order bits, contains GSR + * @dccph_resp_ack_nr_low - 48 bit ack number low order bits, contains GSR + */ +struct dccp_hdr_ack_bits { + u_int32_t dccph_ra; + u_int32_t dccph_ack_nr_low; +}; + +#define DCCPH_ACK(dh_ack) ((dh_ack)->dccph_ra >> 8) + +/** + * struct dccp_hdr_response - Conection initiation response header + * + * @dccph_resp_ack_nr_high - 48 bit ack number high order bits, contains GSR + * @dccph_resp_ack_nr_low - 48 bit ack number low order bits, contains GSR + * @dccph_resp_service - Echoes the Service Code on a received DCCP-Request + */ +struct dccp_hdr_response { + struct dccp_hdr_ack_bits dccph_resp_ack; + u_int32_t dccph_resp_service; +}; + +#if 0 +static inline struct dccp_hdr_data *dccp_hdr_data(struct dccp_hdr *hdrg) +{ + const int ext = DCCPH_X(hdrg) ? sizeof(struct dccp_hdr_ext) : 0; + + return (struct dccp_hdr_data *)(((u_char *)hdrg) + sizeof(hdrg) + ext); +} +#endif + +/** + * struct dccp_hdr_reset - Unconditionally shut down a connection + * + * @dccph_reset_service - Echoes the Service Code on a received DCCP-Request + */ +struct dccp_hdr_reset { + struct dccp_hdr_ack_bits dccph_reset_ack; + u_int8_t dccph_reset_code, + dccph_reset_data[3]; +}; + +enum dccp_pkt_type { + DCCP_PKT_REQUEST = 0, + DCCP_PKT_RESPONSE, + DCCP_PKT_DATA, + DCCP_PKT_ACK, + DCCP_PKT_DATAACK, + DCCP_PKT_CLOSEREQ, + DCCP_PKT_CLOSE, + DCCP_PKT_RESET, + DCCP_PKT_SYNC, + DCCP_PKT_SYNCACK, + DCCP_PKT_INVALID +}; + +enum dccp_reset_codes { + DCCP_RESET_CODE_UNSPECIFIED = 0, + DCCP_RESET_CODE_CLOSED, + DCCP_RESET_CODE_ABORTED, + DCCP_RESET_CODE_NO_CONNECTION, + DCCP_RESET_CODE_PACKET_ERROR, + DCCP_RESET_CODE_OPTION_ERROR, + DCCP_RESET_CODE_MANDATORY_ERROR, + DCCP_RESET_CODE_CONNECTION_REFUSED, + DCCP_RESET_CODE_BAD_SERVICE_CODE, + DCCP_RESET_CODE_TOO_BUSY, + DCCP_RESET_CODE_BAD_INIT_COOKIE, + DCCP_RESET_CODE_AGGRESSION_PENALTY, + __DCCP_RESET_CODE_LAST +}; + +#endif /* __DCCP_HDR__ */
diff --git a/tcpdump-4.3.0/decnet.h b/tcpdump-4.3.0/decnet.h new file mode 100644 index 0000000..d25d157 --- /dev/null +++ b/tcpdump-4.3.0/decnet.h
@@ -0,0 +1,461 @@ +/* + * Copyright (c) 1992, 1994, 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/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 */ + +/* + * Definitions for DECNET Phase IV protocol headers + */ +union etheraddress { + u_int8_t dne_addr[6]; /* full ethernet address */ + struct { + u_int8_t dne_hiord[4]; /* DECnet HIORD prefix */ + u_int8_t dne_nodeaddr[2]; /* DECnet node address */ + } dne_remote; +}; + +typedef union etheraddress etheraddr; /* Ethernet address */ + +#define HIORD 0x000400aa /* high 32-bits of address (swapped) */ + +#define AREAMASK 0176000 /* mask for area field */ +#define AREASHIFT 10 /* bit-offset for area field */ +#define NODEMASK 01777 /* mask for node address field */ + +#define DN_MAXADDL 20 /* max size of DECnet address */ +struct dn_naddr { + u_int16_t a_len; /* length of address */ + u_int8_t a_addr[DN_MAXADDL]; /* address as bytes */ +}; + +/* + * Define long and short header formats. + */ +struct shorthdr + { + byte sh_flags; /* route flags */ + word sh_dst; /* destination node address */ + word sh_src; /* source node address */ + byte sh_visits; /* visit count */ + }; + +struct longhdr + { + byte lg_flags; /* route flags */ + byte lg_darea; /* destination area (reserved) */ + byte lg_dsarea; /* destination subarea (reserved) */ + etheraddr lg_dst; /* destination id */ + byte lg_sarea; /* source area (reserved) */ + byte lg_ssarea; /* source subarea (reserved) */ + etheraddr lg_src; /* source id */ + byte lg_nextl2; /* next level 2 router (reserved) */ + byte lg_visits; /* visit count */ + byte lg_service; /* service class (reserved) */ + byte lg_pt; /* protocol type (reserved) */ + }; + +union routehdr + { + struct shorthdr rh_short; /* short route header */ + struct longhdr rh_long; /* long route header */ + }; + +/* + * Define the values of various fields in the protocol messages. + * + * 1. Data packet formats. + */ +#define RMF_MASK 7 /* mask for message type */ +#define RMF_SHORT 2 /* short message format */ +#define RMF_LONG 6 /* long message format */ +#ifndef RMF_RQR +#define RMF_RQR 010 /* request return to sender */ +#define RMF_RTS 020 /* returning to sender */ +#define RMF_IE 040 /* intra-ethernet packet */ +#endif /* RMR_RQR */ +#define RMF_FVER 0100 /* future version flag */ +#define RMF_PAD 0200 /* pad field */ +#define RMF_PADMASK 0177 /* pad field mask */ + +#define VIS_MASK 077 /* visit field mask */ + +/* + * 2. Control packet formats. + */ +#define RMF_CTLMASK 017 /* mask for message type */ +#define RMF_CTLMSG 01 /* control message indicator */ +#define RMF_INIT 01 /* initialization message */ +#define RMF_VER 03 /* verification message */ +#define RMF_TEST 05 /* hello and test message */ +#define RMF_L1ROUT 07 /* level 1 routing message */ +#define RMF_L2ROUT 011 /* level 2 routing message */ +#define RMF_RHELLO 013 /* router hello message */ +#define RMF_EHELLO 015 /* endnode hello message */ + +#define TI_L2ROUT 01 /* level 2 router */ +#define TI_L1ROUT 02 /* level 1 router */ +#define TI_ENDNODE 03 /* endnode */ +#define TI_VERIF 04 /* verification required */ +#define TI_BLOCK 010 /* blocking requested */ + +#define VE_VERS 2 /* version number (2) */ +#define VE_ECO 0 /* ECO number */ +#define VE_UECO 0 /* user ECO number (0) */ + +#define P3_VERS 1 /* phase III version number (1) */ +#define P3_ECO 3 /* ECO number (3) */ +#define P3_UECO 0 /* user ECO number (0) */ + +#define II_L2ROUT 01 /* level 2 router */ +#define II_L1ROUT 02 /* level 1 router */ +#define II_ENDNODE 03 /* endnode */ +#define II_VERIF 04 /* verification required */ +#define II_NOMCAST 040 /* no multicast traffic accepted */ +#define II_BLOCK 0100 /* blocking requested */ +#define II_TYPEMASK 03 /* mask for node type */ + +#define TESTDATA 0252 /* test data bytes */ +#define TESTLEN 1 /* length of transmitted test data */ + +/* + * Define control message formats. + */ +struct initmsgIII /* phase III initialization message */ + { + byte inIII_flags; /* route flags */ + word inIII_src; /* source node address */ + byte inIII_info; /* routing layer information */ + word inIII_blksize; /* maximum data link block size */ + byte inIII_vers; /* version number */ + byte inIII_eco; /* ECO number */ + byte inIII_ueco; /* user ECO number */ + byte inIII_rsvd; /* reserved image field */ + }; + +struct initmsg /* initialization message */ + { + byte in_flags; /* route flags */ + word in_src; /* source node address */ + byte in_info; /* routing layer information */ + word in_blksize; /* maximum data link block size */ + byte in_vers; /* version number */ + byte in_eco; /* ECO number */ + byte in_ueco; /* user ECO number */ + word in_hello; /* hello timer */ + byte in_rsvd; /* reserved image field */ + }; + +struct verifmsg /* verification message */ + { + byte ve_flags; /* route flags */ + word ve_src; /* source node address */ + byte ve_fcnval; /* function value image field */ + }; + +struct testmsg /* hello and test message */ + { + byte te_flags; /* route flags */ + word te_src; /* source node address */ + byte te_data; /* test data image field */ + }; + +struct l1rout /* level 1 routing message */ + { + byte r1_flags; /* route flags */ + word r1_src; /* source node address */ + byte r1_rsvd; /* reserved field */ + }; + +struct l2rout /* level 2 routing message */ + { + byte r2_flags; /* route flags */ + word r2_src; /* source node address */ + byte r2_rsvd; /* reserved field */ + }; + +struct rhellomsg /* router hello message */ + { + byte rh_flags; /* route flags */ + byte rh_vers; /* version number */ + byte rh_eco; /* ECO number */ + byte rh_ueco; /* user ECO number */ + etheraddr rh_src; /* source id */ + byte rh_info; /* routing layer information */ + word rh_blksize; /* maximum data link block size */ + byte rh_priority; /* router's priority */ + byte rh_area; /* reserved */ + word rh_hello; /* hello timer */ + byte rh_mpd; /* reserved */ + }; + +struct ehellomsg /* endnode hello message */ + { + byte eh_flags; /* route flags */ + byte eh_vers; /* version number */ + byte eh_eco; /* ECO number */ + byte eh_ueco; /* user ECO number */ + etheraddr eh_src; /* source id */ + byte eh_info; /* routing layer information */ + word eh_blksize; /* maximum data link block size */ + byte eh_area; /* area (reserved) */ + byte eh_seed[8]; /* verification seed */ + etheraddr eh_router; /* designated router */ + word eh_hello; /* hello timer */ + byte eh_mpd; /* (reserved) */ + byte eh_data; /* test data image field */ + }; + +union controlmsg + { + struct initmsg cm_init; /* initialization message */ + struct verifmsg cm_ver; /* verification message */ + struct testmsg cm_test; /* hello and test message */ + struct l1rout cm_l1rou; /* level 1 routing message */ + struct l2rout cm_l2rout; /* level 2 routing message */ + struct rhellomsg cm_rhello; /* router hello message */ + struct ehellomsg cm_ehello; /* endnode hello message */ + }; + +/* Macros for decoding routing-info fields */ +#define RI_COST(x) ((x)&0777) +#define RI_HOPS(x) (((x)>>10)&037) + +/* + * NSP protocol fields and values. + */ + +#define NSP_TYPEMASK 014 /* mask to isolate type code */ +#define NSP_SUBMASK 0160 /* mask to isolate subtype code */ +#define NSP_SUBSHFT 4 /* shift to move subtype code */ + +#define MFT_DATA 0 /* data message */ +#define MFT_ACK 04 /* acknowledgement message */ +#define MFT_CTL 010 /* control message */ + +#define MFS_ILS 020 /* data or I/LS indicator */ +#define MFS_BOM 040 /* beginning of message (data) */ +#define MFS_MOM 0 /* middle of message (data) */ +#define MFS_EOM 0100 /* end of message (data) */ +#define MFS_INT 040 /* interrupt message */ + +#define MFS_DACK 0 /* data acknowledgement */ +#define MFS_IACK 020 /* I/LS acknowledgement */ +#define MFS_CACK 040 /* connect acknowledgement */ + +#define MFS_NOP 0 /* no operation */ +#define MFS_CI 020 /* connect initiate */ +#define MFS_CC 040 /* connect confirm */ +#define MFS_DI 060 /* disconnect initiate */ +#define MFS_DC 0100 /* disconnect confirm */ +#define MFS_RCI 0140 /* retransmitted connect initiate */ + +#define SGQ_ACK 0100000 /* ack */ +#define SGQ_NAK 0110000 /* negative ack */ +#define SGQ_OACK 0120000 /* other channel ack */ +#define SGQ_ONAK 0130000 /* other channel negative ack */ +#define SGQ_MASK 07777 /* mask to isolate seq # */ +#define SGQ_OTHER 020000 /* other channel qualifier */ +#define SGQ_DELAY 010000 /* ack delay flag */ + +#define SGQ_EOM 0100000 /* pseudo flag for end-of-message */ + +#define LSM_MASK 03 /* mask for modifier field */ +#define LSM_NOCHANGE 0 /* no change */ +#define LSM_DONOTSEND 1 /* do not send data */ +#define LSM_SEND 2 /* send data */ + +#define LSI_MASK 014 /* mask for interpretation field */ +#define LSI_DATA 0 /* data segment or message count */ +#define LSI_INTR 4 /* interrupt request count */ +#define LSI_INTM 0377 /* funny marker for int. message */ + +#define COS_MASK 014 /* mask for flow control field */ +#define COS_NONE 0 /* no flow control */ +#define COS_SEGMENT 04 /* segment flow control */ +#define COS_MESSAGE 010 /* message flow control */ +#define COS_CRYPTSER 020 /* cryptographic services requested */ +#define COS_DEFAULT 1 /* default value for field */ + +#define COI_MASK 3 /* mask for version field */ +#define COI_32 0 /* version 3.2 */ +#define COI_31 1 /* version 3.1 */ +#define COI_40 2 /* version 4.0 */ +#define COI_41 3 /* version 4.1 */ + +#define MNU_MASK 140 /* mask for session control version */ +#define MNU_10 000 /* session V1.0 */ +#define MNU_20 040 /* session V2.0 */ +#define MNU_ACCESS 1 /* access control present */ +#define MNU_USRDATA 2 /* user data field present */ +#define MNU_INVKPROXY 4 /* invoke proxy field present */ +#define MNU_UICPROXY 8 /* use uic-based proxy */ + +#define DC_NORESOURCES 1 /* no resource reason code */ +#define DC_NOLINK 41 /* no link terminate reason code */ +#define DC_COMPLETE 42 /* disconnect complete reason code */ + +#define DI_NOERROR 0 /* user disconnect */ +#define DI_SHUT 3 /* node is shutting down */ +#define DI_NOUSER 4 /* destination end user does not exist */ +#define DI_INVDEST 5 /* invalid end user destination */ +#define DI_REMRESRC 6 /* insufficient remote resources */ +#define DI_TPA 8 /* third party abort */ +#define DI_PROTOCOL 7 /* protocol error discovered */ +#define DI_ABORT 9 /* user abort */ +#define DI_LOCALRESRC 32 /* insufficient local resources */ +#define DI_REMUSERRESRC 33 /* insufficient remote user resources */ +#define DI_BADACCESS 34 /* bad access control information */ +#define DI_BADACCNT 36 /* bad ACCOUNT information */ +#define DI_CONNECTABORT 38 /* connect request cancelled */ +#define DI_TIMEDOUT 38 /* remote node or user crashed */ +#define DI_UNREACHABLE 39 /* local timers expired due to ... */ +#define DI_BADIMAGE 43 /* bad image data in connect */ +#define DI_SERVMISMATCH 54 /* cryptographic service mismatch */ + +#define UC_OBJREJECT 0 /* object rejected connect */ +#define UC_USERDISCONNECT 0 /* user disconnect */ +#define UC_RESOURCES 1 /* insufficient resources (local or remote) */ +#define UC_NOSUCHNODE 2 /* unrecognized node name */ +#define UC_REMOTESHUT 3 /* remote node shutting down */ +#define UC_NOSUCHOBJ 4 /* unrecognized object */ +#define UC_INVOBJFORMAT 5 /* invalid object name format */ +#define UC_OBJTOOBUSY 6 /* object too busy */ +#define UC_NETWORKABORT 8 /* network abort */ +#define UC_USERABORT 9 /* user abort */ +#define UC_INVNODEFORMAT 10 /* invalid node name format */ +#define UC_LOCALSHUT 11 /* local node shutting down */ +#define UC_ACCESSREJECT 34 /* invalid access control information */ +#define UC_NORESPONSE 38 /* no response from object */ +#define UC_UNREACHABLE 39 /* node unreachable */ + +/* + * NSP message formats. + */ +struct nsphdr /* general nsp header */ + { + byte nh_flags; /* message flags */ + word nh_dst; /* destination link address */ + word nh_src; /* source link address */ + }; + +struct seghdr /* data segment header */ + { + byte sh_flags; /* message flags */ + word sh_dst; /* destination link address */ + word sh_src; /* source link address */ + word sh_seq[3]; /* sequence numbers */ + }; + +struct minseghdr /* minimum data segment header */ + { + byte ms_flags; /* message flags */ + word ms_dst; /* destination link address */ + word ms_src; /* source link address */ + word ms_seq; /* sequence number */ + }; + +struct lsmsg /* link service message (after hdr) */ + { + byte ls_lsflags; /* link service flags */ + byte ls_fcval; /* flow control value */ + }; + +struct ackmsg /* acknowledgement message */ + { + byte ak_flags; /* message flags */ + word ak_dst; /* destination link address */ + word ak_src; /* source link address */ + word ak_acknum[2]; /* acknowledgement numbers */ + }; + +struct minackmsg /* minimum acknowledgement message */ + { + byte mk_flags; /* message flags */ + word mk_dst; /* destination link address */ + word mk_src; /* source link address */ + word mk_acknum; /* acknowledgement number */ + }; + +struct ciackmsg /* connect acknowledgement message */ + { + byte ck_flags; /* message flags */ + word ck_dst; /* destination link address */ + }; + +struct cimsg /* connect initiate message */ + { + byte ci_flags; /* message flags */ + word ci_dst; /* destination link address (0) */ + word ci_src; /* source link address */ + byte ci_services; /* requested services */ + byte ci_info; /* information */ + word ci_segsize; /* maximum segment size */ + }; + +struct ccmsg /* connect confirm message */ + { + byte cc_flags; /* message flags */ + word cc_dst; /* destination link address */ + word cc_src; /* source link address */ + byte cc_services; /* requested services */ + byte cc_info; /* information */ + word cc_segsize; /* maximum segment size */ + byte cc_optlen; /* optional data length */ + }; + +struct cnmsg /* generic connect message */ + { + byte cn_flags; /* message flags */ + word cn_dst; /* destination link address */ + word cn_src; /* source link address */ + byte cn_services; /* requested services */ + byte cn_info; /* information */ + word cn_segsize; /* maximum segment size */ + }; + +struct dimsg /* disconnect initiate message */ + { + byte di_flags; /* message flags */ + word di_dst; /* destination link address */ + word di_src; /* source link address */ + word di_reason; /* reason code */ + byte di_optlen; /* optional data length */ + }; + +struct dcmsg /* disconnect confirm message */ + { + byte dc_flags; /* message flags */ + word dc_dst; /* destination link address */ + word dc_src; /* source link address */ + word dc_reason; /* reason code */ + };
diff --git a/tcpdump-4.3.0/decode_prefix.h b/tcpdump-4.3.0/decode_prefix.h new file mode 100644 index 0000000..8bb4a76 --- /dev/null +++ b/tcpdump-4.3.0/decode_prefix.h
@@ -0,0 +1,41 @@ +/* + * 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: + * 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. + * + * Extensively modified by Hannes Gredler (hannes@juniper.net) for more + * complete BGP support. + */ + +#ifndef tcpdump_decode_prefix_h +#define tcpdump_decode_prefix_h + +extern int decode_prefix4(const u_char *pptr, u_int itemlen, char *buf, u_int buflen); +#ifdef INET6 +extern int decode_prefix6(const u_char *pd, u_int itemlen, char *buf, u_int buflen); +#endif + +#endif
diff --git a/tcpdump-4.3.0/enc.h b/tcpdump-4.3.0/enc.h new file mode 100644 index 0000000..2d57e2b --- /dev/null +++ b/tcpdump-4.3.0/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/tcpdump-4.3.0/esp.h b/tcpdump-4.3.0/esp.h new file mode 100644 index 0000000..56cdada --- /dev/null +++ b/tcpdump-4.3.0/esp.h
@@ -0,0 +1,68 @@ +/* $NetBSD: esp.h,v 1.13 2000/09/26 08:37:38 itojun Exp $ */ +/* $KAME: esp.h,v 1.15 2000/09/20 18:15:22 itojun Exp $ */ + +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * RFC1827/2406 Encapsulated Security Payload. + */ + +#ifndef _NETINET6_ESP_H_ +#define _NETINET6_ESP_H_ + +struct esp { + u_int32_t esp_spi; /* ESP */ + /*variable size, 32bit bound*/ /* Initialization Vector */ + /*variable size*/ /* Payload data */ + /*variable size*/ /* padding */ + /*8bit*/ /* pad size */ + /*8bit*/ /* next header */ + /*8bit*/ /* next header */ + /*variable size, 32bit bound*/ /* Authentication data (new IPsec) */ +}; + +struct newesp { + u_int32_t esp_spi; /* ESP */ + u_int32_t esp_seq; /* Sequence number */ + /*variable size*/ /* (IV and) Payload data */ + /*variable size*/ /* padding */ + /*8bit*/ /* pad size */ + /*8bit*/ /* next header */ + /*8bit*/ /* next header */ + /*variable size, 32bit bound*/ /* Authentication data */ +}; + +struct esptail { + u_int8_t esp_padlen; /* pad length */ + u_int8_t esp_nxt; /* Next header */ + /*variable size, 32bit bound*/ /* Authentication data (new IPsec)*/ +}; + +#endif /*_NETINET6_ESP_H_*/
diff --git a/tcpdump-4.3.0/ether.h b/tcpdump-4.3.0/ether.h new file mode 100644 index 0000000..e8b3a71 --- /dev/null +++ b/tcpdump-4.3.0/ether.h
@@ -0,0 +1,59 @@ +/* @(#) $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. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)if_ether.h 8.3 (Berkeley) 5/2/95 + */ + +#define ETHERMTU 1500 + +/* + * The number of bytes in an ethernet (MAC) address. + */ +#define ETHER_ADDR_LEN 6 + +/* + * Structure of a DEC/Intel/Xerox or 802.3 Ethernet header. + */ +struct ether_header { + u_int8_t ether_dhost[ETHER_ADDR_LEN]; + u_int8_t ether_shost[ETHER_ADDR_LEN]; + u_int16_t ether_type; +}; + +/* + * Length of a DEC/Intel/Xerox or 802.3 Ethernet header; note that some + * compilers may pad "struct ether_header" to a multiple of 4 bytes, + * for example, so "sizeof (struct ether_header)" may not give the right + * answer. + */ +#define ETHER_HDRLEN 14
diff --git a/tcpdump-4.3.0/ethertype.h b/tcpdump-4.3.0/ethertype.h new file mode 100644 index 0000000..8c06339 --- /dev/null +++ b/tcpdump-4.3.0/ethertype.h
@@ -0,0 +1,184 @@ +/* + * Copyright (c) 1993, 1994, 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/ethertype.h,v 1.30 2008-02-06 10:47:53 guy Exp $ (LBL) + */ + +/* + * Ethernet types. + * + * We wrap the declarations with #ifdef, so that if a file includes + * <netinet/if_ether.h>, which may declare some of these, we don't + * get a bunch of complaints from the C compiler about redefinitions + * of these values. + * + * We declare all of them here so that no file has to include + * <netinet/if_ether.h> if all it needs are ETHERTYPE_ values. + */ + +#ifndef ETHERTYPE_LEN +#define ETHERTYPE_LEN 2 +#endif + +#ifndef ETHERTYPE_GRE_ISO +#define ETHERTYPE_GRE_ISO 0x00FE /* not really an ethertype only used in GRE */ +#endif +#ifndef ETHERTYPE_PUP +#define ETHERTYPE_PUP 0x0200 /* PUP protocol */ +#endif +#ifndef ETHERTYPE_IP +#define ETHERTYPE_IP 0x0800 /* IP protocol */ +#endif +#ifndef ETHERTYPE_ARP +#define ETHERTYPE_ARP 0x0806 /* Addr. resolution protocol */ +#endif +#ifndef ETHERTYPE_REVARP +#define ETHERTYPE_REVARP 0x8035 /* reverse Addr. resolution protocol */ +#endif +#ifndef ETHERTYPE_NS +#define ETHERTYPE_NS 0x0600 +#endif +#ifndef ETHERTYPE_SPRITE +#define ETHERTYPE_SPRITE 0x0500 +#endif +#ifndef ETHERTYPE_TRAIL +#define ETHERTYPE_TRAIL 0x1000 +#endif +#ifndef ETHERTYPE_MOPDL +#define ETHERTYPE_MOPDL 0x6001 +#endif +#ifndef ETHERTYPE_MOPRC +#define ETHERTYPE_MOPRC 0x6002 +#endif +#ifndef ETHERTYPE_DN +#define ETHERTYPE_DN 0x6003 +#endif +#ifndef ETHERTYPE_LAT +#define ETHERTYPE_LAT 0x6004 +#endif +#ifndef ETHERTYPE_SCA +#define ETHERTYPE_SCA 0x6007 +#endif +#ifndef ETHERTYPE_TEB +#define ETHERTYPE_TEB 0x6558 +#endif +#ifndef ETHERTYPE_LANBRIDGE +#define ETHERTYPE_LANBRIDGE 0x8038 +#endif +#ifndef ETHERTYPE_DECDNS +#define ETHERTYPE_DECDNS 0x803c +#endif +#ifndef ETHERTYPE_DECDTS +#define ETHERTYPE_DECDTS 0x803e +#endif +#ifndef ETHERTYPE_VEXP +#define ETHERTYPE_VEXP 0x805b +#endif +#ifndef ETHERTYPE_VPROD +#define ETHERTYPE_VPROD 0x805c +#endif +#ifndef ETHERTYPE_ATALK +#define ETHERTYPE_ATALK 0x809b +#endif +#ifndef ETHERTYPE_AARP +#define ETHERTYPE_AARP 0x80f3 +#endif +#ifndef ETHERTYPE_TIPC +#define ETHERTYPE_TIPC 0x88ca +#endif +#ifndef ETHERTYPE_8021Q +#define ETHERTYPE_8021Q 0x8100 +#endif + +/* see: + http://en.wikipedia.org/wiki/IEEE_802.1Q + and http://en.wikipedia.org/wiki/QinQ +*/ +#ifndef ETHERTYPE_8021Q9100 +#define ETHERTYPE_8021Q9100 0x9100 +#endif +#ifndef ETHERTYPE_8021Q9200 +#define ETHERTYPE_8021Q9200 0x9200 +#endif +#ifndef ETHERTYPE_8021QinQ +#define ETHERTYPE_8021QinQ 0x88a8 +#endif +#ifndef ETHERTYPE_IPX +#define ETHERTYPE_IPX 0x8137 +#endif +#ifndef ETHERTYPE_IPV6 +#define ETHERTYPE_IPV6 0x86dd +#endif +#ifndef ETHERTYPE_PPP +#define ETHERTYPE_PPP 0x880b +#endif +#ifndef ETHERTYPE_MPCP +#define ETHERTYPE_MPCP 0x8808 +#endif +#ifndef ETHERTYPE_SLOW +#define ETHERTYPE_SLOW 0x8809 +#endif +#ifndef ETHERTYPE_MPLS +#define ETHERTYPE_MPLS 0x8847 +#endif +#ifndef ETHERTYPE_MPLS_MULTI +#define ETHERTYPE_MPLS_MULTI 0x8848 +#endif +#ifndef ETHERTYPE_PPPOED +#define ETHERTYPE_PPPOED 0x8863 +#endif +#ifndef ETHERTYPE_PPPOES +#define ETHERTYPE_PPPOES 0x8864 +#endif +#ifndef ETHERTYPE_PPPOED2 +#define ETHERTYPE_PPPOED2 0x3c12 +#endif +#ifndef ETHERTYPE_PPPOES2 +#define ETHERTYPE_PPPOES2 0x3c13 +#endif +#ifndef ETHERTYPE_JUMBO +#define ETHERTYPE_JUMBO 0x8870 +#endif +#ifndef ETHERTYPE_LLDP +#define ETHERTYPE_LLDP 0x88cc +#endif +#ifndef ETHERTYPE_EAPOL +#define ETHERTYPE_EAPOL 0x888e +#endif +#ifndef ETHERTYPE_RRCP +#define ETHERTYPE_RRCP 0x8899 +#endif +#ifndef ETHERTYPE_LOOPBACK +#define ETHERTYPE_LOOPBACK 0x9000 +#endif +#ifndef ETHERTYPE_VMAN +#define ETHERTYPE_VMAN 0x9100 /* Extreme VMAN Protocol */ +#endif +#ifndef ETHERTYPE_CFM_OLD +#define ETHERTYPE_CFM_OLD 0xabcd /* 802.1ag depreciated */ +#endif +#ifndef ETHERTYPE_CFM +#define ETHERTYPE_CFM 0x8902 /* 802.1ag */ +#endif +#ifndef ETHERTYPE_ISO +#define ETHERTYPE_ISO 0xfefe /* nonstandard - used in Cisco HDLC encapsulation */ +#endif + +extern const struct tok ethertype_values[];
diff --git a/tcpdump-4.3.0/extract.h b/tcpdump-4.3.0/extract.h new file mode 100644 index 0000000..bab63f2 --- /dev/null +++ b/tcpdump-4.3.0/extract.h
@@ -0,0 +1,130 @@ +/* + * 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/extract.h,v 1.25 2006-01-30 16:20:07 hannes Exp $ (LBL) + */ + +/* + * Macros to extract possibly-unaligned big-endian integral values. + */ +#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)ntohs(((const unaligned_u_int16_t *)(p))->val)) +#define EXTRACT_32BITS(p) \ + ((u_int32_t)ntohl(((const unaligned_u_int32_t *)(p))->val)) +#define EXTRACT_64BITS(p) \ + ((u_int64_t)(((u_int64_t)ntohl(((const unaligned_u_int32_t *)(p) + 0)->val)) << 32 | \ + ((u_int64_t)ntohl(((const unaligned_u_int32_t *)(p) + 1)->val)) << 0)) + +#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))) +#define EXTRACT_64BITS(p) \ + ((u_int64_t)((u_int64_t)*((const u_int8_t *)(p) + 0) << 56 | \ + (u_int64_t)*((const u_int8_t *)(p) + 1) << 48 | \ + (u_int64_t)*((const u_int8_t *)(p) + 2) << 40 | \ + (u_int64_t)*((const u_int8_t *)(p) + 3) << 32 | \ + (u_int64_t)*((const u_int8_t *)(p) + 4) << 24 | \ + (u_int64_t)*((const u_int8_t *)(p) + 5) << 16 | \ + (u_int64_t)*((const u_int8_t *)(p) + 6) << 8 | \ + (u_int64_t)*((const u_int8_t *)(p) + 7))) +#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))) +#define EXTRACT_64BITS(p) \ + ((u_int64_t)(((u_int64_t)ntohl(*((const u_int32_t *)(p) + 0))) << 32 | \ + ((u_int64_t)ntohl(*((const u_int32_t *)(p) + 1))) << 0)) +#endif /* LBL_ALIGN */ + +#define EXTRACT_24BITS(p) \ + ((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))) + +/* + * Macros to extract possibly-unaligned little-endian integral values. + * XXX - do loads on little-endian machines that support unaligned loads? + */ +#define EXTRACT_LE_8BITS(p) (*(p)) +#define EXTRACT_LE_16BITS(p) \ + ((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)((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))) +#define EXTRACT_LE_24BITS(p) \ + ((u_int32_t)((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))) +#define EXTRACT_LE_64BITS(p) \ + ((u_int64_t)((u_int64_t)*((const u_int8_t *)(p) + 7) << 56 | \ + (u_int64_t)*((const u_int8_t *)(p) + 6) << 48 | \ + (u_int64_t)*((const u_int8_t *)(p) + 5) << 40 | \ + (u_int64_t)*((const u_int8_t *)(p) + 4) << 32 | \ + (u_int64_t)*((const u_int8_t *)(p) + 3) << 24 | \ + (u_int64_t)*((const u_int8_t *)(p) + 2) << 16 | \ + (u_int64_t)*((const u_int8_t *)(p) + 1) << 8 | \ + (u_int64_t)*((const u_int8_t *)(p) + 0)))
diff --git a/tcpdump-4.3.0/fddi.h b/tcpdump-4.3.0/fddi.h new file mode 100644 index 0000000..df38c8e --- /dev/null +++ b/tcpdump-4.3.0/fddi.h
@@ -0,0 +1,76 @@ +/* + * 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/fddi.h,v 1.11 2002-12-11 07:13:51 guy Exp $ (LBL) + */ + +/* + * Based on Ultrix if_fddi.h + */ + +/* + * This stuff should come from a system header file, but there's no + * obviously portable way to do that and it's not really going + * to change from system to system (except for the padding business). + */ + +struct fddi_header { + u_char fddi_fc; /* frame control */ + u_char fddi_dhost[6]; + u_char fddi_shost[6]; +}; + +/* + * Length of an FDDI header; note that some compilers may pad + * "struct fddi_header" to a multiple of 4 bytes, for example, so + * "sizeof (struct fddi_header)" may not give the right + * answer. + */ +#define FDDI_HDRLEN 13 + +/* Useful values for fddi_fc (frame control) field */ + +/* + * FDDI Frame Control bits + */ +#define FDDIFC_C 0x80 /* Class bit */ +#define FDDIFC_L 0x40 /* Address length bit */ +#define FDDIFC_F 0x30 /* Frame format bits */ +#define FDDIFC_Z 0x0f /* Control bits */ + +/* + * FDDI Frame Control values. (48-bit addressing only). + */ +#define FDDIFC_VOID 0x40 /* Void frame */ +#define FDDIFC_NRT 0x80 /* Nonrestricted token */ +#define FDDIFC_RT 0xc0 /* Restricted token */ +#define FDDIFC_SMT_INFO 0x41 /* SMT Info */ +#define FDDIFC_SMT_NSA 0x4F /* SMT Next station adrs */ +#define FDDIFC_MAC_BEACON 0xc2 /* MAC Beacon frame */ +#define FDDIFC_MAC_CLAIM 0xc3 /* MAC Claim frame */ +#define FDDIFC_LLC_ASYNC 0x50 /* Async. LLC frame */ +#define FDDIFC_LLC_SYNC 0xd0 /* Sync. LLC frame */ +#define FDDIFC_IMP_ASYNC 0x60 /* Implementor Async. */ +#define FDDIFC_IMP_SYNC 0xe0 /* Implementor Synch. */ +#define FDDIFC_SMT 0x40 /* SMT frame */ +#define FDDIFC_MAC 0xc0 /* MAC frame */ + +#define FDDIFC_CLFF 0xF0 /* Class/Length/Format bits */ +#define FDDIFC_ZZZZ 0x0F /* Control bits */
diff --git a/tcpdump-4.3.0/forces.h b/tcpdump-4.3.0/forces.h new file mode 100644 index 0000000..d41475f --- /dev/null +++ b/tcpdump-4.3.0/forces.h
@@ -0,0 +1,679 @@ +/* + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * Copyright (c) 2009 Mojatatu Networks, Inc + * + */ + +/* + * Per draft-ietf-forces-protocol-22 +*/ +#define ForCES_VERS 1 +#define ForCES_HDRL 24 +#define ForCES_ALNL 4U +#define TLV_HDRL 4 +#define ILV_HDRL 8 + +#define TOM_RSVD 0x0 +#define TOM_ASSNSETUP 0x1 +#define TOM_ASSNTEARD 0x2 +#define TOM_CONFIG 0x3 +#define TOM_QUERY 0x4 +#define TOM_EVENTNOT 0x5 +#define TOM_PKTREDIR 0x6 +#define TOM_HEARTBT 0x0F +#define TOM_ASSNSETREP 0x11 +#define TOM_CONFIGREP 0x13 +#define TOM_QUERYREP 0x14 + +/* + * tom_h Flags: resv1(8b):maxtlvs(4b):resv2(2b):mintlv(2b) +*/ +#define ZERO_TTLV 0x01 +#define ZERO_MORE_TTLV 0x02 +#define ONE_MORE_TTLV 0x04 +#define ZERO_TLV 0x00 +#define ONE_TLV 0x10 +#define TWO_TLV 0x20 +#define MAX_TLV 0xF0 + +#define TTLV_T1 (ONE_MORE_TTLV|ONE_TLV) +#define TTLV_T2 (ONE_MORE_TTLV|MAX_TLV) + +struct tom_h { + u_int32_t v; + u_int16_t flags; + u_int16_t op_msk; + const char *s; + int (*print) (register const u_char * pptr, register u_int len, + u_int16_t op_msk, int indent); +}; + +enum { + TOM_RSV_I, + TOM_ASS_I, + TOM_AST_I, + TOM_CFG_I, + TOM_QRY_I, + TOM_EVN_I, + TOM_RED_I, + TOM_HBT_I, + TOM_ASR_I, + TOM_CNR_I, + TOM_QRR_I, + _TOM_RSV_MAX +}; +#define TOM_MAX_IND (_TOM_RSV_MAX - 1) + +int lfbselect_print(register const u_char * pptr, register u_int len, + u_int16_t op_msk, int indent); +int redirect_print(register const u_char * pptr, register u_int len, + u_int16_t op_msk, int indent); +int asrtlv_print(register const u_char * pptr, register u_int len, + u_int16_t op_msk, int indent); +int asttlv_print(register const u_char * pptr, register u_int len, + u_int16_t op_msk, int indent); +int gentltlv_print(register const u_char * pptr, register u_int len, + u_int16_t op_msk, int indent); +int print_metailv(register const u_char * pptr, register u_int len, + u_int16_t op_msk, int indent); +int print_metatlv(register const u_char * pptr, register u_int len, + u_int16_t op_msk, int indent); +int print_reddata(register const u_char * pptr, register u_int len, + u_int16_t op_msk, int indent); + +static inline int tom_valid(u_int8_t tom) +{ + if (tom > 0) { + if (tom >= 0x7 && tom <= 0xe) + return 0; + if (tom == 0x10) + return 0; + if (tom > 0x14) + return 0; + return 1; + } else + return 0; +} + +static inline const char *ForCES_node(u_int32_t node) +{ + if (node <= 0x3FFFFFFF) + return "FE"; + if (node >= 0x40000000 && node <= 0x7FFFFFFF) + return "CE"; + if (node >= 0xC0000000 && node <= 0xFFFFFFEF) + return "AllMulticast"; + if (node == 0xFFFFFFFD) + return "AllCEsBroadcast"; + if (node == 0xFFFFFFFE) + return "AllFEsBroadcast"; + if (node == 0xFFFFFFFF) + return "AllBroadcast"; + + return "ForCESreserved"; + +} + +static inline const char *ForCES_ACKp(u_int32_t flg) +{ + if (flg == 0x0) + return "NoACK"; + if (flg == 0x1) + return "SuccessACK"; + if (flg == 0x2) + return "FailureACK"; + if (flg == 0x3) + return "AlwaysACK"; + return "ACKUnknown"; +} + +static inline const char *ForCES_EMp(u_int32_t flg) +{ + if (flg == 0x0) + return "EMReserved"; + if (flg == 0x1) + return "execute-all-or-none"; + if (flg == 0x2) + return "execute-until-failure"; + if (flg == 0x3) + return "continue-execute-on-failure"; + return "EMUnknown"; +} + +static inline const char *ForCES_ATp(u_int32_t flg) +{ + if (flg == 0x0) + return "Standalone"; + if (flg == 0x1) + return "2PCtransaction"; + return "ATUnknown"; +} + +static inline const char *ForCES_TPp(u_int32_t flg) +{ + if (flg == 0x0) + return "StartofTransaction"; + if (flg == 0x1) + return "MiddleofTransaction"; + if (flg == 0x2) + return "EndofTransaction"; + if (flg == 0x3) + return "abort"; + return "TPUnknown"; +} + +/* + * Structure of forces header, naked of TLVs. + */ +struct forcesh { + u_int8_t fm_vrsvd; /* version and reserved */ +#define ForCES_V(forcesh) ((forcesh)->fm_vrsvd >> 4) + u_int8_t fm_tom; /* type of message */ + u_int16_t fm_len; /* total length * 4 bytes */ +#define ForCES_BLN(forcesh) ((u_int32_t)(EXTRACT_16BITS(&(forcesh)->fm_len) << 2)) + u_int32_t fm_sid; /* Source ID */ +#define ForCES_SID(forcesh) EXTRACT_32BITS(&(forcesh)->fm_sid) + u_int32_t fm_did; /* Destination ID */ +#define ForCES_DID(forcesh) EXTRACT_32BITS(&(forcesh)->fm_did) + u_int8_t fm_cor[8]; /* correlator */ + u_int32_t fm_flags; /* flags */ +#define ForCES_ACK(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0xC0000000) >> 30) +#define ForCES_PRI(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x38000000) >> 27) +#define ForCES_RS1(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x07000000) >> 24) +#define ForCES_EM(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x00C00000) >> 22) +#define ForCES_AT(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x00200000) >> 21) +#define ForCES_TP(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x00180000) >> 19) +#define ForCES_RS2(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x0007FFFF) >> 0) +}; + +#define ForCES_HLN_VALID(fhl,tlen) ((tlen) >= ForCES_HDRL && \ + (fhl) >= ForCES_HDRL && \ + (fhl) == (tlen)) + +#define F_LFB_RSVD 0x0 +#define F_LFB_FEO 0x1 +#define F_LFB_FEPO 0x2 +const struct tok ForCES_LFBs[] = { + {F_LFB_RSVD, "Invalid TLV"}, + {F_LFB_FEO, "FEObj LFB"}, + {F_LFB_FEPO, "FEProtoObj LFB"}, + {0, NULL} +}; + +int forces_type_print(register const u_char * pptr, const struct forcesh *fhdr, + register u_int mlen, const struct tom_h *tops); + +enum { + F_OP_RSV, + F_OP_SET, + F_OP_SETPROP, + F_OP_SETRESP, + F_OP_SETPRESP, + F_OP_DEL, + F_OP_DELRESP, + F_OP_GET, + F_OP_GETPROP, + F_OP_GETRESP, + F_OP_GETPRESP, + F_OP_REPORT, + F_OP_COMMIT, + F_OP_RCOMMIT, + F_OP_RTRCOMP, + _F_OP_MAX +}; + +#define F_OP_MAX (_F_OP_MAX - 1) +enum { + B_OP_SET = 1 << (F_OP_SET - 1), + B_OP_SETPROP = 1 << (F_OP_SETPROP - 1), + B_OP_SETRESP = 1 << (F_OP_SETRESP - 1), + B_OP_SETPRESP = 1 << (F_OP_SETPRESP - 1), + B_OP_DEL = 1 << (F_OP_DEL - 1), + B_OP_DELRESP = 1 << (F_OP_DELRESP - 1), + B_OP_GET = 1 << (F_OP_GET - 1), + B_OP_GETPROP = 1 << (F_OP_GETPROP - 1), + B_OP_GETRESP = 1 << (F_OP_GETRESP - 1), + B_OP_GETPRESP = 1 << (F_OP_GETPRESP - 1), + B_OP_REPORT = 1 << (F_OP_REPORT - 1), + B_OP_COMMIT = 1 << (F_OP_COMMIT - 1), + B_OP_RCOMMIT = 1 << (F_OP_RCOMMIT - 1), + B_OP_RTRCOMP = 1 << (F_OP_RTRCOMP - 1), +}; + +struct optlv_h { + u_int16_t flags; + u_int16_t op_msk; + const char *s; + int (*print) (register const u_char * pptr, register u_int len, + u_int16_t op_msk, int indent); +}; + +int genoptlv_print(register const u_char * pptr, register u_int len, + u_int16_t op_msk, int indent); +int recpdoptlv_print(register const u_char * pptr, register u_int len, + u_int16_t op_msk, int indent); +int invoptlv_print(register const u_char * pptr, register u_int len, + u_int16_t op_msk, int indent); + +#define OP_MIN_SIZ 8 +struct pathdata_h { + u_int16_t pflags; + u_int16_t pIDcnt; +}; + +#define B_FULLD 0x1 +#define B_SPARD 0x2 +#define B_RESTV 0x4 +#define B_KEYIN 0x8 + +static const struct optlv_h OPTLV_msg[F_OP_MAX + 1] = { + /* F_OP_RSV */ {ZERO_TTLV, 0, "Invalid OPTLV", invoptlv_print}, + /* F_OP_SET */ {TTLV_T2, B_FULLD | B_SPARD, " Set", recpdoptlv_print}, + /* F_OP_SETPROP */ + {TTLV_T2, B_FULLD | B_SPARD, " SetProp", recpdoptlv_print}, + /* F_OP_SETRESP */ {TTLV_T2, B_RESTV, " SetResp", recpdoptlv_print}, + /* F_OP_SETPRESP */ {TTLV_T2, B_RESTV, " SetPropResp", recpdoptlv_print}, + /* F_OP_DEL */ {ZERO_TTLV, 0, " Del", recpdoptlv_print}, + /* F_OP_DELRESP */ {TTLV_T2, B_RESTV, " DelResp", recpdoptlv_print}, + /* F_OP_GET */ {ZERO_TTLV, 0, " Get", recpdoptlv_print}, + /* F_OP_GETPROP */ {ZERO_TTLV, 0, " GetProp", recpdoptlv_print}, + /* F_OP_GETRESP */ + {TTLV_T2, B_FULLD | B_SPARD | B_RESTV, " GetResp", recpdoptlv_print}, + /* F_OP_GETPRESP */ + {TTLV_T2, B_FULLD | B_RESTV, " GetPropResp", recpdoptlv_print}, + /* F_OP_REPORT */ + {TTLV_T2, B_FULLD | B_SPARD, " Report", recpdoptlv_print}, + /* F_OP_COMMIT */ {ZERO_TTLV, 0, " Commit", NULL}, + /* F_OP_RCOMMIT */ {TTLV_T1, B_RESTV, " RCommit", genoptlv_print}, + /* F_OP_RTRCOMP */ {ZERO_TTLV, 0, " RTRCOMP", NULL}, +}; + +static inline const struct optlv_h *get_forces_optlv_h(u_int16_t opt) +{ + if (opt > F_OP_MAX || opt <= F_OP_RSV) + return &OPTLV_msg[F_OP_RSV]; + + return &OPTLV_msg[opt]; +} + +#define IND_SIZE 256 +#define IND_CHR ' ' +#define IND_PREF '\n' +#define IND_SUF 0x0 +char ind_buf[IND_SIZE]; + +static inline char *indent_pr(int indent, int nlpref) +{ + int i = 0; + char *r = ind_buf; + + if (indent > (IND_SIZE - 1)) + indent = IND_SIZE - 1; + + if (nlpref) { + r[i] = IND_PREF; + i++; + indent--; + } + + while (--indent >= 0) + r[i++] = IND_CHR; + + r[i] = IND_SUF; + return r; +} + +static inline int op_valid(u_int16_t op, u_int16_t mask) +{ + int opb = 1 << (op - 1); + + if (op == 0) + return 0; + if (opb & mask) + return 1; + /* I guess we should allow vendor operations? */ + if (op >= 0x8000) + return 1; + return 0; +} + +#define F_TLV_RSVD 0x0000 +#define F_TLV_REDR 0x0001 +#define F_TLV_ASRS 0x0010 +#define F_TLV_ASRT 0x0011 +#define F_TLV_LFBS 0x1000 +#define F_TLV_PDAT 0x0110 +#define F_TLV_KEYI 0x0111 +#define F_TLV_FULD 0x0112 +#define F_TLV_SPAD 0x0113 +#define F_TLV_REST 0x0114 +#define F_TLV_METD 0x0115 +#define F_TLV_REDD 0x0116 +#define F_TLV_VNST 0x8000 + +static const struct tok ForCES_TLV[] = { + {F_TLV_RSVD, "Invalid TLV"}, + {F_TLV_REDR, "REDIRECT TLV"}, + {F_TLV_ASRS, "ASResult TLV"}, + {F_TLV_ASRT, "ASTreason TLV"}, + {F_TLV_LFBS, "LFBselect TLV"}, + {F_TLV_PDAT, "PATH-DATA TLV"}, + {F_TLV_KEYI, "KEYINFO TLV"}, + {F_TLV_FULD, "FULLDATA TLV"}, + {F_TLV_SPAD, "SPARSEDATA TLV"}, + {F_TLV_REST, "RESULT TLV"}, + {F_TLV_METD, "METADATA TLV"}, + {F_TLV_REDD, "REDIRECTDATA TLV"}, + {0, NULL} +}; + +#define TLV_HLN 4 +static inline int ttlv_valid(u_int16_t ttlv) +{ + if (ttlv > 0) { + if (ttlv == 1 || ttlv == 0x1000) + return 1; + if (ttlv >= 0x10 && ttlv <= 0x11) + return 1; + if (ttlv >= 0x110 && ttlv <= 0x116) + return 1; + if (ttlv >= 0x8000) + return 0; /* XXX: */ + } + + return 0; +} + +struct forces_ilv { + u_int32_t type; + u_int32_t length; +}; + +struct forces_tlv { + u_int16_t type; + u_int16_t length; +}; + +int otlv_print(const struct forces_tlv *otlv, u_int16_t op_msk, int indent); + +#define F_ALN_LEN(len) ( ((len)+ForCES_ALNL-1) & ~(ForCES_ALNL-1) ) +#define GET_TOP_TLV(fhdr) ((struct forces_tlv *)((fhdr) + sizeof (struct forcesh))) +#define TLV_SET_LEN(len) (F_ALN_LEN(TLV_HDRL) + (len)) +#define TLV_ALN_LEN(len) F_ALN_LEN(TLV_SET_LEN(len)) +#define TLV_RDAT_LEN(tlv) ((int)(EXTRACT_16BITS(&(tlv)->length) - TLV_SET_LEN(0)) +#define TLV_DATA(tlvp) ((void*)(((char*)(tlvp)) + TLV_SET_LEN(0))) +#define GO_NXT_TLV(tlv,rlen) ((rlen) -= F_ALN_LEN(EXTRACT_16BITS(&(tlv)->length)), \ + (struct forces_tlv*)(((char*)(tlv)) \ + + F_ALN_LEN(EXTRACT_16BITS(&(tlv)->length)))) +#define ILV_SET_LEN(len) (F_ALN_LEN(ILV_HDRL) + (len)) +#define ILV_ALN_LEN(len) F_ALN_LEN(ILV_SET_LEN(len)) +#define ILV_RDAT_LEN(ilv) ((int)(EXTRACT_32BITS(&(ilv)->length)) - ILV_SET_LEN(0)) +#define ILV_DATA(ilvp) ((void*)(((char*)(ilvp)) + ILV_SET_LEN(0))) +#define GO_NXT_ILV(ilv,rlen) ((rlen) -= F_ALN_LEN(EXTRACT_32BITS(&(ilv)->length)), \ + (struct forces_ilv *)(((char*)(ilv)) \ + + F_ALN_LEN(EXTRACT_32BITS(&(ilv)->length)))) +#define INVALID_RLEN -1 +#define INVALID_STLN -2 +#define INVALID_LTLN -3 +#define INVALID_ALEN -4 + +static const struct tok ForCES_TLV_err[] = { + {INVALID_RLEN, "Invalid total length"}, + {INVALID_STLN, "xLV too short"}, + {INVALID_LTLN, "xLV too long"}, + {INVALID_ALEN, "data padding missing"}, + {0, NULL} +}; + +static inline int tlv_valid(const struct forces_tlv *tlv, u_int rlen) +{ + if (rlen < TLV_HDRL) + return INVALID_RLEN; + if (EXTRACT_16BITS(&tlv->length) < TLV_HDRL) + return INVALID_STLN; + if (EXTRACT_16BITS(&tlv->length) > rlen) + return INVALID_LTLN; + if (rlen < F_ALN_LEN(EXTRACT_16BITS(&tlv->length))) + return INVALID_ALEN; + + return 0; +} + +static inline int ilv_valid(const struct forces_ilv *ilv, u_int rlen) +{ + if (rlen < ILV_HDRL) + return INVALID_RLEN; + if (EXTRACT_32BITS(&ilv->length) < ILV_HDRL) + return INVALID_STLN; + if (EXTRACT_32BITS(&ilv->length) > rlen) + return INVALID_LTLN; + if (rlen < F_ALN_LEN(EXTRACT_32BITS(&ilv->length))) + return INVALID_ALEN; + + return 0; +} + +struct forces_lfbsh { + u_int32_t class; + u_int32_t instance; +}; + +#define ASSNS_OPS (B_OP_REPORT) +#define CFG_OPS (B_OP_SET|B_OP_SETPROP|B_OP_DEL|B_OP_COMMIT|B_OP_RTRCOMP) +#define CFG_ROPS (B_OP_SETRESP|B_OP_SETPRESP|B_OP_DELRESP|B_OP_RCOMMIT) +#define CFG_QY (B_OP_GET|B_OP_GETPROP) +#define CFG_QYR (B_OP_GETRESP|B_OP_GETPRESP) +#define CFG_EVN (B_OP_REPORT) + +static const struct tom_h ForCES_msg[TOM_MAX_IND + 1] = { + /* TOM_RSV_I */ {TOM_RSVD, ZERO_TTLV, 0, "Invalid message", NULL}, + /* TOM_ASS_I */ {TOM_ASSNSETUP, ZERO_MORE_TTLV | TWO_TLV, ASSNS_OPS, + "Association Setup", lfbselect_print}, + /* TOM_AST_I */ + {TOM_ASSNTEARD, TTLV_T1, 0, "Association TearDown", asttlv_print}, + /* TOM_CFG_I */ {TOM_CONFIG, TTLV_T2, CFG_OPS, "Config", lfbselect_print}, + /* TOM_QRY_I */ {TOM_QUERY, TTLV_T2, CFG_QY, "Query", lfbselect_print}, + /* TOM_EVN_I */ {TOM_EVENTNOT, TTLV_T1, CFG_EVN, "Event Notification", + lfbselect_print}, + /* TOM_RED_I */ + {TOM_PKTREDIR, TTLV_T2, 0, "Packet Redirect", redirect_print}, + /* TOM_HBT_I */ {TOM_HEARTBT, ZERO_TTLV, 0, "HeartBeat", NULL}, + /* TOM_ASR_I */ + {TOM_ASSNSETREP, TTLV_T1, 0, "Association Response", asrtlv_print}, + /* TOM_CNR_I */ {TOM_CONFIGREP, TTLV_T2, CFG_ROPS, "Config Response", + lfbselect_print}, + /* TOM_QRR_I */ + {TOM_QUERYREP, TTLV_T2, CFG_QYR, "Query Response", lfbselect_print}, +}; + +static inline const struct tom_h *get_forces_tom(u_int8_t tom) +{ + int i; + for (i = TOM_RSV_I; i <= TOM_MAX_IND; i++) { + const struct tom_h *th = &ForCES_msg[i]; + if (th->v == tom) + return th; + } + return &ForCES_msg[TOM_RSV_I]; +} + +struct pdata_ops { + u_int32_t v; + u_int16_t flags; + u_int16_t op_msk; + const char *s; + int (*print) (register const u_char * pptr, register u_int len, + u_int16_t op_msk, int indent); +}; + +enum { + PD_RSV_I, + PD_SEL_I, + PD_FDT_I, + PD_SDT_I, + PD_RES_I, + PD_PDT_I, + _PD_RSV_MAX +}; +#define PD_MAX_IND (_TOM_RSV_MAX - 1) + +static inline int pd_valid(u_int16_t pd) +{ + if (pd >= F_TLV_PDAT && pd <= F_TLV_REST) + return 1; + return 0; +} + +static inline void chk_op_type(u_int16_t type, u_int16_t msk, u_int16_t omsk) +{ + if (type != F_TLV_PDAT) { + if (msk & B_KEYIN) { + if (type != F_TLV_KEYI) { + printf + ("Based on flags expected KEYINFO TLV!\n"); + } + } else { + if (!(msk & omsk)) { + printf + ("Illegal DATA encoding for type 0x%x programmed %x got %x \n", + type, omsk, msk); + } + } + } + +} + +int fdatatlv_print(register const u_char * pptr, register u_int len, + u_int16_t op_msk, int indent); +int sdatailv_print(register const u_char * pptr, register u_int len, + u_int16_t op_msk, int indent); +int sdatatlv_print(register const u_char * pptr, register u_int len, + u_int16_t op_msk, int indent); +int pdatatlv_print(register const u_char * pptr, register u_int len, + u_int16_t op_msk, int indent); +int pkeyitlv_print(register const u_char * pptr, register u_int len, + u_int16_t op_msk, int indent); + +int pdatacnt_print(register const u_char * pptr, register u_int len, + u_int16_t IDcnt, u_int16_t op_msk, int indent); +int pdata_print(register const u_char * pptr, register u_int len, + u_int16_t op_msk, int indent); + +int prestlv_print(register const u_char * pptr, register u_int len, + u_int16_t op_msk, int indent); +#define F_SELKEY 1 + +struct res_val { + u_int8_t result; + u_int8_t resv1; + u_int16_t resv2; +}; + +static const struct pdata_ops ForCES_pdata[PD_MAX_IND + 1] = { + /* PD_RSV_I */ {0, 0, 0, "Invalid message", NULL}, + /* PD_SEL_I */ {F_TLV_KEYI, 0, 0, "KEYINFO TLV", pkeyitlv_print}, + /* PD_FDT_I */ {F_TLV_FULD, 0, B_FULLD, "FULLDATA TLV", fdatatlv_print}, + /* PD_SDT_I */ {F_TLV_SPAD, 0, B_SPARD, "SPARSEDATA TLV", sdatatlv_print}, + /* PD_RES_I */ {F_TLV_REST, 0, B_RESTV, "RESULT TLV", prestlv_print}, + /* PD_PDT_I */ + {F_TLV_PDAT, 0, 0, "Inner PATH-DATA TLV", recpdoptlv_print}, +}; + +static inline const struct pdata_ops *get_forces_pd(u_int16_t pd) +{ + int i; + for (i = PD_RSV_I + 1; i <= PD_MAX_IND; i++) { + const struct pdata_ops *pdo = &ForCES_pdata[i]; + if (pdo->v == pd) + return pdo; + } + return &ForCES_pdata[TOM_RSV_I]; +} + +enum { + E_SUCCESS, + E_INVALID_HEADER, + E_LENGTH_MISMATCH, + E_VERSION_MISMATCH, + E_INVALID_DESTINATION_PID, + E_LFB_UNKNOWN, + E_LFB_NOT_FOUND, + E_LFB_INSTANCE_ID_NOT_FOUND, + E_INVALID_PATH, + E_COMPONENT_DOES_NOT_EXIST, + E_EXISTS, + E_NOT_FOUND, + E_READ_ONLY, + E_INVALID_ARRAY_CREATION, + E_VALUE_OUT_OF_RANGE, + E_CONTENTS_TOO_LONG, + E_INVALID_PARAMETERS, + E_INVALID_MESSAGE_TYPE, + E_INVALID_FLAGS, + E_INVALID_TLV, + E_EVENT_ERROR, + E_NOT_SUPPORTED, + E_MEMORY_ERROR, + E_INTERNAL_ERROR, + /* 0x18-0xFE are reserved .. */ + E_UNSPECIFIED_ERROR = 0XFF +}; + +const struct tok ForCES_errs[] = { + {E_SUCCESS, "SUCCESS"}, + {E_INVALID_HEADER, "INVALID HEADER"}, + {E_LENGTH_MISMATCH, "LENGTH MISMATCH"}, + {E_VERSION_MISMATCH, "VERSION MISMATCH"}, + {E_INVALID_DESTINATION_PID, "INVALID DESTINATION PID"}, + {E_LFB_UNKNOWN, "LFB UNKNOWN"}, + {E_LFB_NOT_FOUND, "LFB NOT FOUND"}, + {E_LFB_INSTANCE_ID_NOT_FOUND, "LFB INSTANCE ID NOT FOUND"}, + {E_INVALID_PATH, "INVALID PATH"}, + {E_COMPONENT_DOES_NOT_EXIST, "COMPONENT DOES NOT EXIST"}, + {E_EXISTS, "EXISTS ALREADY"}, + {E_NOT_FOUND, "NOT FOUND"}, + {E_READ_ONLY, "READ ONLY"}, + {E_INVALID_ARRAY_CREATION, "INVALID ARRAY CREATION"}, + {E_VALUE_OUT_OF_RANGE, "VALUE OUT OF RANGE"}, + {E_CONTENTS_TOO_LONG, "CONTENTS TOO LONG"}, + {E_INVALID_PARAMETERS, "INVALID PARAMETERS"}, + {E_INVALID_MESSAGE_TYPE, "INVALID MESSAGE TYPE"}, + {E_INVALID_FLAGS, "INVALID FLAGS"}, + {E_INVALID_TLV, "INVALID TLV"}, + {E_EVENT_ERROR, "EVENT ERROR"}, + {E_NOT_SUPPORTED, "NOT SUPPORTED"}, + {E_MEMORY_ERROR, "MEMORY ERROR"}, + {E_INTERNAL_ERROR, "INTERNAL ERROR"}, + {E_UNSPECIFIED_ERROR, "UNSPECIFIED ERROR"}, + {0, NULL} +};
diff --git a/tcpdump-4.3.0/gmpls.c b/tcpdump-4.3.0/gmpls.c new file mode 100644 index 0000000..7391767 --- /dev/null +++ b/tcpdump-4.3.0/gmpls.c
@@ -0,0 +1,197 @@ +/* + * 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.7 2006-04-14 07:11:59 hannes Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include "interface.h" +#include "gmpls.h" + +/* rfc3471 */ +const 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 */ +const struct tok gmpls_switch_cap_values[] = { + { GMPLS_PSC1, "Packet-Switch Capable-1"}, + { GMPLS_PSC2, "Packet-Switch Capable-2"}, + { GMPLS_PSC3, "Packet-Switch Capable-3"}, + { GMPLS_PSC4, "Packet-Switch Capable-4"}, + { GMPLS_L2SC, "Layer-2 Switch Capable"}, + { GMPLS_TSC, "Time-Division-Multiplex"}, + { GMPLS_LSC, "Lambda-Switch Capable"}, + { GMPLS_FSC, "Fiber-Switch Capable"}, + { 0, NULL } +}; + +/* rfc4205 */ +const struct tok gmpls_switch_cap_tsc_indication_values[] = { + { 0, "Standard SONET/SDH" }, + { 1, "Arbitrary SONET/SDH" }, + { 0, NULL } +}; + +/* rfc3471 */ +const 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 */ +const 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 } +}; + +/* + * Link Type values used by LMP Service Discovery (specifically, the Client + * Port Service Attributes Object). See UNI 1.0 section 9.4.2 for details. + */ +const struct tok lmp_sd_service_config_cpsa_link_type_values[] = { + { 5, "SDH ITU-T G.707"}, + { 6, "SONET ANSI T1.105"}, + { 0, NULL} +}; + +/* + * Signal Type values for SDH links used by LMP Service Discovery (specifically, + * the Client Port Service Attributes Object). See UNI 1.0 section 9.4.2 for + * details. + */ +const struct tok lmp_sd_service_config_cpsa_signal_type_sdh_values[] = { + { 5, "VC-3"}, + { 6, "VC-4"}, + { 7, "STM-0"}, + { 8, "STM-1"}, + { 9, "STM-4"}, + { 10, "STM-16"}, + { 11, "STM-64"}, + { 12, "STM-256"}, + { 0, NULL} +}; + +/* + * Signal Type values for SONET links used by LMP Service Discovery (specifically, + * the Client Port Service Attributes Object). See UNI 1.0 section 9.4.2 for + * details. + */ +const struct tok lmp_sd_service_config_cpsa_signal_type_sonet_values[] = { + { 5, "STS-1 SPE"}, + { 6, "STS-3c SPE"}, + { 7, "STS-1"}, + { 8, "STM-3"}, + { 9, "STM-12"}, + { 10, "STM-48"}, + { 11, "STM-192"}, + { 12, "STM-768"}, + { 0, NULL} +}; + +#define DIFFSERV_BC_MODEL_RDM 0 /* draft-ietf-tewg-diff-te-proto-07 */ +#define DIFFSERV_BC_MODEL_MAM 1 /* draft-ietf-tewg-diff-te-proto-07 */ +#define DIFFSERV_BC_MODEL_EXTD_MAM 254 /* experimental */ + +const struct tok diffserv_te_bc_values[] = { + { DIFFSERV_BC_MODEL_RDM, "Russian dolls"}, + { DIFFSERV_BC_MODEL_MAM, "Maximum allocation"}, + { DIFFSERV_BC_MODEL_EXTD_MAM, "Maximum allocation with E-LSP support"}, + { 0, NULL } +};
diff --git a/tcpdump-4.3.0/gmpls.h b/tcpdump-4.3.0/gmpls.h new file mode 100644 index 0000000..8db99de --- /dev/null +++ b/tcpdump-4.3.0/gmpls.h
@@ -0,0 +1,34 @@ +/* @(#) $Header: /tcpdump/master/tcpdump/gmpls.h,v 1.5 2006-04-14 07:11:59 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) + */ + +#define GMPLS_PSC1 1 +#define GMPLS_PSC2 2 +#define GMPLS_PSC3 3 +#define GMPLS_PSC4 4 +#define GMPLS_L2SC 51 +#define GMPLS_TSC 100 +#define GMPLS_LSC 150 +#define GMPLS_FSC 200 + +extern const struct tok gmpls_link_prot_values[]; +extern const struct tok gmpls_switch_cap_values[]; +extern const struct tok gmpls_switch_cap_tsc_indication_values[]; +extern const struct tok gmpls_encoding_values[]; +extern const struct tok gmpls_payload_values[]; +extern const struct tok diffserv_te_bc_values[]; +extern const struct tok lmp_sd_service_config_cpsa_link_type_values[]; +extern const struct tok lmp_sd_service_config_cpsa_signal_type_sdh_values[]; +extern const struct tok lmp_sd_service_config_cpsa_signal_type_sonet_values[];
diff --git a/tcpdump-4.3.0/gmt2local.c b/tcpdump-4.3.0/gmt2local.c new file mode 100644 index 0000000..1fe0e8a --- /dev/null +++ b/tcpdump-4.3.0/gmt2local.c
@@ -0,0 +1,71 @@ +/* + * Copyright (c) 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/gmt2local.c,v 1.9 2003-11-16 09:36:09 guy Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> + +#ifdef HAVE_OS_PROTO_H +#include "os-proto.h" +#endif + +#include "gmt2local.h" + +/* + * Returns the difference between gmt and local time in seconds. + * Use gmtime() and localtime() to keep things simple. + */ +int32_t +gmt2local(time_t t) +{ + register int dt, dir; + register struct tm *gmt, *loc; + struct tm sgmt; + + if (t == 0) + t = time(NULL); + gmt = &sgmt; + *gmt = *gmtime(&t); + loc = localtime(&t); + dt = (loc->tm_hour - gmt->tm_hour) * 60 * 60 + + (loc->tm_min - gmt->tm_min) * 60; + + /* + * If the year or julian day is different, we span 00:00 GMT + * and must add or subtract a day. Check the year first to + * avoid problems when the julian day wraps. + */ + dir = loc->tm_year - gmt->tm_year; + if (dir == 0) + dir = loc->tm_yday - gmt->tm_yday; + dt += dir * 24 * 60 * 60; + + return (dt); +}
diff --git a/tcpdump-4.3.0/gmt2local.h b/tcpdump-4.3.0/gmt2local.h new file mode 100644 index 0000000..f7b3841 --- /dev/null +++ b/tcpdump-4.3.0/gmt2local.h
@@ -0,0 +1,27 @@ +/* + * Copyright (c) 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * @(#) $Header: /tcpdump/master/tcpdump/gmt2local.h,v 1.2 1999-10-07 23:47:10 mcr Exp $ (LBL) + */ +#ifndef gmt2local_h +#define gmt2local_h + +int32_t gmt2local(time_t); +#endif
diff --git a/tcpdump-4.3.0/icmp6.h b/tcpdump-4.3.0/icmp6.h new file mode 100644 index 0000000..168a708 --- /dev/null +++ b/tcpdump-4.3.0/icmp6.h
@@ -0,0 +1,464 @@ +/* @(#) $Header: /tcpdump/master/tcpdump/icmp6.h,v 1.18 2007-08-29 02:31:44 mcr Exp $ (LBL) */ +/* NetBSD: icmp6.h,v 1.13 2000/08/03 16:30:37 itojun Exp */ +/* $KAME: icmp6.h,v 1.22 2000/08/03 15:25:16 jinmei Exp $ */ + +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _NETINET_ICMP6_H_ +#define _NETINET_ICMP6_H_ + +struct icmp6_hdr { + u_int8_t icmp6_type; /* type field */ + u_int8_t icmp6_code; /* code field */ + u_int16_t icmp6_cksum; /* checksum field */ + union { + u_int32_t icmp6_un_data32[1]; /* type-specific field */ + u_int16_t icmp6_un_data16[2]; /* type-specific field */ + u_int8_t icmp6_un_data8[4]; /* type-specific field */ + } icmp6_dataun; +}; + +#define icmp6_data32 icmp6_dataun.icmp6_un_data32 +#define icmp6_data16 icmp6_dataun.icmp6_un_data16 +#define icmp6_data8 icmp6_dataun.icmp6_un_data8 +#define icmp6_pptr icmp6_data32[0] /* parameter prob */ +#define icmp6_mtu icmp6_data32[0] /* packet too big */ +#define icmp6_id icmp6_data16[0] /* echo request/reply */ +#define icmp6_seq icmp6_data16[1] /* echo request/reply */ +#define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */ + +#define ICMP6_DST_UNREACH 1 /* dest unreachable, codes: */ +#define ICMP6_PACKET_TOO_BIG 2 /* packet too big */ +#define ICMP6_TIME_EXCEEDED 3 /* time exceeded, code: */ +#define ICMP6_PARAM_PROB 4 /* ip6 header bad */ + +#define ICMP6_ECHO_REQUEST 128 /* echo service */ +#define ICMP6_ECHO_REPLY 129 /* echo reply */ +#define ICMP6_MEMBERSHIP_QUERY 130 /* group membership query */ +#define MLD6_LISTENER_QUERY 130 /* multicast listener query */ +#define ICMP6_MEMBERSHIP_REPORT 131 /* group membership report */ +#define MLD6_LISTENER_REPORT 131 /* multicast listener report */ +#define ICMP6_MEMBERSHIP_REDUCTION 132 /* group membership termination */ +#define MLD6_LISTENER_DONE 132 /* multicast listener done */ + +#define ND_ROUTER_SOLICIT 133 /* router solicitation */ +#define ND_ROUTER_ADVERT 134 /* router advertisement */ +#define ND_NEIGHBOR_SOLICIT 135 /* neighbor solicitation */ +#define ND_NEIGHBOR_ADVERT 136 /* neighbor advertisement */ +#define ND_REDIRECT 137 /* redirect */ + +#define ICMP6_ROUTER_RENUMBERING 138 /* router renumbering */ + +#define ICMP6_WRUREQUEST 139 /* who are you request */ +#define ICMP6_WRUREPLY 140 /* who are you reply */ +#define ICMP6_FQDN_QUERY 139 /* FQDN query */ +#define ICMP6_FQDN_REPLY 140 /* FQDN reply */ +#define ICMP6_NI_QUERY 139 /* node information request */ +#define ICMP6_NI_REPLY 140 /* node information reply */ +#define IND_SOLICIT 141 /* inverse neighbor solicitation */ +#define IND_ADVERT 142 /* inverse neighbor advertisement */ + +#define ICMP6_V2_MEMBERSHIP_REPORT 143 /* v2 membership report */ +#define MLDV2_LISTENER_REPORT 143 /* v2 multicast listener report */ +#define ICMP6_HADISCOV_REQUEST 144 +#define ICMP6_HADISCOV_REPLY 145 +#define ICMP6_MOBILEPREFIX_SOLICIT 146 +#define ICMP6_MOBILEPREFIX_ADVERT 147 + +#define MLD6_MTRACE_RESP 200 /* mtrace response(to sender) */ +#define MLD6_MTRACE 201 /* mtrace messages */ + +#define ICMP6_MAXTYPE 201 + +#define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */ +#define ICMP6_DST_UNREACH_ADMIN 1 /* administratively prohibited */ +#define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor(obsolete) */ +#define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */ +#define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */ +#define ICMP6_DST_UNREACH_NOPORT 4 /* port unreachable */ + +#define ICMP6_TIME_EXCEED_TRANSIT 0 /* ttl==0 in transit */ +#define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* ttl==0 in reass */ + +#define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */ +#define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized next header */ +#define ICMP6_PARAMPROB_OPTION 2 /* unrecognized option */ + +#define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */ + +#define ICMP6_NI_SUBJ_IPV6 0 /* Query Subject is an IPv6 address */ +#define ICMP6_NI_SUBJ_FQDN 1 /* Query Subject is a Domain name */ +#define ICMP6_NI_SUBJ_IPV4 2 /* Query Subject is an IPv4 address */ + +#define ICMP6_NI_SUCCESS 0 /* node information successful reply */ +#define ICMP6_NI_REFUSED 1 /* node information request is refused */ +#define ICMP6_NI_UNKNOWN 2 /* unknown Qtype */ + +#define ICMP6_ROUTER_RENUMBERING_COMMAND 0 /* rr command */ +#define ICMP6_ROUTER_RENUMBERING_RESULT 1 /* rr result */ +#define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 /* rr seq num reset */ + +/* Used in kernel only */ +#define ND_REDIRECT_ONLINK 0 /* redirect to an on-link node */ +#define ND_REDIRECT_ROUTER 1 /* redirect to a better router */ + +/* + * Multicast Listener Discovery + */ +struct mld6_hdr { + struct icmp6_hdr mld6_hdr; + struct in6_addr mld6_addr; /* multicast address */ +}; + +#define mld6_type mld6_hdr.icmp6_type +#define mld6_code mld6_hdr.icmp6_code +#define mld6_cksum mld6_hdr.icmp6_cksum +#define mld6_maxdelay mld6_hdr.icmp6_data16[0] +#define mld6_reserved mld6_hdr.icmp6_data16[1] + +#define MLD_MINLEN 24 +#define MLDV2_MINLEN 28 + +/* + * Neighbor Discovery + */ + +struct nd_router_solicit { /* router solicitation */ + struct icmp6_hdr nd_rs_hdr; + /* could be followed by options */ +}; + +#define nd_rs_type nd_rs_hdr.icmp6_type +#define nd_rs_code nd_rs_hdr.icmp6_code +#define nd_rs_cksum nd_rs_hdr.icmp6_cksum +#define nd_rs_reserved nd_rs_hdr.icmp6_data32[0] + +struct nd_router_advert { /* router advertisement */ + struct icmp6_hdr nd_ra_hdr; + u_int32_t nd_ra_reachable; /* reachable time */ + u_int32_t nd_ra_retransmit; /* retransmit timer */ + /* could be followed by options */ +}; + +#define nd_ra_type nd_ra_hdr.icmp6_type +#define nd_ra_code nd_ra_hdr.icmp6_code +#define nd_ra_cksum nd_ra_hdr.icmp6_cksum +#define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0] +#define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1] +#define ND_RA_FLAG_MANAGED 0x80 +#define ND_RA_FLAG_OTHER 0x40 +#define ND_RA_FLAG_HOME_AGENT 0x20 + +/* + * Router preference values based on draft-draves-ipngwg-router-selection-01. + * These are non-standard definitions. + */ +#define ND_RA_FLAG_RTPREF_MASK 0x18 /* 00011000 */ + +#define ND_RA_FLAG_RTPREF_HIGH 0x08 /* 00001000 */ +#define ND_RA_FLAG_RTPREF_MEDIUM 0x00 /* 00000000 */ +#define ND_RA_FLAG_RTPREF_LOW 0x18 /* 00011000 */ +#define ND_RA_FLAG_RTPREF_RSV 0x10 /* 00010000 */ + +#define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1] + +struct nd_neighbor_solicit { /* neighbor solicitation */ + struct icmp6_hdr nd_ns_hdr; + struct in6_addr nd_ns_target; /*target address */ + /* could be followed by options */ +}; + +#define nd_ns_type nd_ns_hdr.icmp6_type +#define nd_ns_code nd_ns_hdr.icmp6_code +#define nd_ns_cksum nd_ns_hdr.icmp6_cksum +#define nd_ns_reserved nd_ns_hdr.icmp6_data32[0] + +struct nd_neighbor_advert { /* neighbor advertisement */ + struct icmp6_hdr nd_na_hdr; + struct in6_addr nd_na_target; /* target address */ + /* could be followed by options */ +}; + +#define nd_na_type nd_na_hdr.icmp6_type +#define nd_na_code nd_na_hdr.icmp6_code +#define nd_na_cksum nd_na_hdr.icmp6_cksum +#define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0] + +#define ND_NA_FLAG_ROUTER 0x80000000 +#define ND_NA_FLAG_SOLICITED 0x40000000 +#define ND_NA_FLAG_OVERRIDE 0x20000000 + +struct nd_redirect { /* redirect */ + struct icmp6_hdr nd_rd_hdr; + struct in6_addr nd_rd_target; /* target address */ + struct in6_addr nd_rd_dst; /* destination address */ + /* could be followed by options */ +}; + +#define nd_rd_type nd_rd_hdr.icmp6_type +#define nd_rd_code nd_rd_hdr.icmp6_code +#define nd_rd_cksum nd_rd_hdr.icmp6_cksum +#define nd_rd_reserved nd_rd_hdr.icmp6_data32[0] + +struct nd_opt_hdr { /* Neighbor discovery option header */ + u_int8_t nd_opt_type; + u_int8_t nd_opt_len; + /* followed by option specific data*/ +}; + +#define ND_OPT_SOURCE_LINKADDR 1 +#define ND_OPT_TARGET_LINKADDR 2 +#define ND_OPT_PREFIX_INFORMATION 3 +#define ND_OPT_REDIRECTED_HEADER 4 +#define ND_OPT_MTU 5 +#define ND_OPT_ADVINTERVAL 7 +#define ND_OPT_HOMEAGENT_INFO 8 +#define ND_OPT_ROUTE_INFO 9 /* draft-ietf-ipngwg-router-preference, not officially assigned yet */ +#define ND_OPT_RDNSS 25 + +struct nd_opt_prefix_info { /* prefix information */ + u_int8_t nd_opt_pi_type; + u_int8_t nd_opt_pi_len; + u_int8_t nd_opt_pi_prefix_len; + u_int8_t nd_opt_pi_flags_reserved; + u_int8_t nd_opt_pi_valid_time[4]; + u_int8_t nd_opt_pi_preferred_time[4]; + u_int8_t nd_opt_pi_reserved2[4]; + struct in6_addr nd_opt_pi_prefix; +}; + +#define ND_OPT_PI_FLAG_ONLINK 0x80 +#define ND_OPT_PI_FLAG_AUTO 0x40 +#define ND_OPT_PI_FLAG_ROUTER 0x20 /*2292bis*/ + +struct nd_opt_rd_hdr { /* redirected header */ + u_int8_t nd_opt_rh_type; + u_int8_t nd_opt_rh_len; + u_int16_t nd_opt_rh_reserved1; + u_int32_t nd_opt_rh_reserved2; + /* followed by IP header and data */ +}; + +struct nd_opt_mtu { /* MTU option */ + u_int8_t nd_opt_mtu_type; + u_int8_t nd_opt_mtu_len; + u_int16_t nd_opt_mtu_reserved; + u_int32_t nd_opt_mtu_mtu; +}; + +struct nd_opt_rdnss { /* RDNSS RFC 5006 */ + u_int8_t nd_opt_rdnss_type; + u_int8_t nd_opt_rdnss_len; + u_int16_t nd_opt_rdnss_reserved; + u_int32_t nd_opt_rdnss_lifetime; + struct in6_addr nd_opt_rdnss_addr[1]; /* variable-length */ +}; + +struct nd_opt_advinterval { /* Advertisement interval option */ + u_int8_t nd_opt_adv_type; + u_int8_t nd_opt_adv_len; + u_int16_t nd_opt_adv_reserved; + u_int32_t nd_opt_adv_interval; +}; + +struct nd_opt_homeagent_info { /* Home Agent info */ + u_int8_t nd_opt_hai_type; + u_int8_t nd_opt_hai_len; + u_int16_t nd_opt_hai_reserved; + int16_t nd_opt_hai_preference; + u_int16_t nd_opt_hai_lifetime; +}; + +struct nd_opt_route_info { /* route info */ + u_int8_t nd_opt_rti_type; + u_int8_t nd_opt_rti_len; + u_int8_t nd_opt_rti_prefixlen; + u_int8_t nd_opt_rti_flags; + u_int32_t nd_opt_rti_lifetime; + /* prefix follows */ +}; + +/* + * icmp6 namelookup + */ + +struct icmp6_namelookup { + struct icmp6_hdr icmp6_nl_hdr; + u_int8_t icmp6_nl_nonce[8]; + int32_t icmp6_nl_ttl; +#if 0 + u_int8_t icmp6_nl_len; + u_int8_t icmp6_nl_name[3]; +#endif + /* could be followed by options */ +}; + +/* + * icmp6 node information + */ +struct icmp6_nodeinfo { + struct icmp6_hdr icmp6_ni_hdr; + u_int8_t icmp6_ni_nonce[8]; + /* could be followed by reply data */ +}; + +#define ni_type icmp6_ni_hdr.icmp6_type +#define ni_code icmp6_ni_hdr.icmp6_code +#define ni_cksum icmp6_ni_hdr.icmp6_cksum +#define ni_qtype icmp6_ni_hdr.icmp6_data16[0] +#define ni_flags icmp6_ni_hdr.icmp6_data16[1] + +#define NI_QTYPE_NOOP 0 /* NOOP */ +#define NI_QTYPE_SUPTYPES 1 /* Supported Qtypes */ +#define NI_QTYPE_FQDN 2 /* FQDN (draft 04) */ +#define NI_QTYPE_DNSNAME 2 /* DNS Name */ +#define NI_QTYPE_NODEADDR 3 /* Node Addresses */ +#define NI_QTYPE_IPV4ADDR 4 /* IPv4 Addresses */ + +/* network endian */ +#define NI_SUPTYPE_FLAG_COMPRESS ((u_int16_t)htons(0x1)) +#define NI_FQDN_FLAG_VALIDTTL ((u_int16_t)htons(0x1)) + +/* network endian */ +#define NI_NODEADDR_FLAG_TRUNCATE ((u_int16_t)htons(0x1)) +#define NI_NODEADDR_FLAG_ALL ((u_int16_t)htons(0x2)) +#define NI_NODEADDR_FLAG_COMPAT ((u_int16_t)htons(0x4)) +#define NI_NODEADDR_FLAG_LINKLOCAL ((u_int16_t)htons(0x8)) +#define NI_NODEADDR_FLAG_SITELOCAL ((u_int16_t)htons(0x10)) +#define NI_NODEADDR_FLAG_GLOBAL ((u_int16_t)htons(0x20)) +#define NI_NODEADDR_FLAG_ANYCAST ((u_int16_t)htons(0x40)) /* just experimental. not in spec */ + +struct ni_reply_fqdn { + u_int32_t ni_fqdn_ttl; /* TTL */ + u_int8_t ni_fqdn_namelen; /* length in octets of the FQDN */ + u_int8_t ni_fqdn_name[3]; /* XXX: alignment */ +}; + +/* + * Router Renumbering. as router-renum-08.txt + */ +struct icmp6_router_renum { /* router renumbering header */ + struct icmp6_hdr rr_hdr; + u_int8_t rr_segnum; + u_int8_t rr_flags; + u_int16_t rr_maxdelay; + u_int32_t rr_reserved; +}; +#define ICMP6_RR_FLAGS_TEST 0x80 +#define ICMP6_RR_FLAGS_REQRESULT 0x40 +#define ICMP6_RR_FLAGS_FORCEAPPLY 0x20 +#define ICMP6_RR_FLAGS_SPECSITE 0x10 +#define ICMP6_RR_FLAGS_PREVDONE 0x08 + +#define rr_type rr_hdr.icmp6_type +#define rr_code rr_hdr.icmp6_code +#define rr_cksum rr_hdr.icmp6_cksum +#define rr_seqnum rr_hdr.icmp6_data32[0] + +struct rr_pco_match { /* match prefix part */ + u_int8_t rpm_code; + u_int8_t rpm_len; + u_int8_t rpm_ordinal; + u_int8_t rpm_matchlen; + u_int8_t rpm_minlen; + u_int8_t rpm_maxlen; + u_int16_t rpm_reserved; + struct in6_addr rpm_prefix; +}; + +#define RPM_PCO_ADD 1 +#define RPM_PCO_CHANGE 2 +#define RPM_PCO_SETGLOBAL 3 +#define RPM_PCO_MAX 4 + +struct rr_pco_use { /* use prefix part */ + u_int8_t rpu_uselen; + u_int8_t rpu_keeplen; + u_int8_t rpu_ramask; + u_int8_t rpu_raflags; + u_int32_t rpu_vltime; + u_int32_t rpu_pltime; + u_int32_t rpu_flags; + struct in6_addr rpu_prefix; +}; +#define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x80 +#define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x40 + +/* network endian */ +#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME ((u_int32_t)htonl(0x80000000)) +#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME ((u_int32_t)htonl(0x40000000)) + +struct rr_result { /* router renumbering result message */ + u_int16_t rrr_flags; + u_int8_t rrr_ordinal; + u_int8_t rrr_matchedlen; + u_int32_t rrr_ifid; + struct in6_addr rrr_prefix; +}; +/* network endian */ +#define ICMP6_RR_RESULT_FLAGS_OOB ((u_int16_t)htons(0x0002)) +#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN ((u_int16_t)htons(0x0001)) + +#endif /* not _NETINET_ICMP6_H_ */
diff --git a/tcpdump-4.3.0/ieee802_11.h b/tcpdump-4.3.0/ieee802_11.h new file mode 100644 index 0000000..2aa1345 --- /dev/null +++ b/tcpdump-4.3.0/ieee802_11.h
@@ -0,0 +1,347 @@ +/* @(#) $Header: /tcpdump/master/tcpdump/ieee802_11.h,v 1.12 2007-07-22 19:59:06 guy Exp $ (LBL) */ +/* + * Copyright (c) 2001 + * Fortress Technologies + * Charlie Lenahan ( clenahan@fortresstech.com ) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +/* 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_CTL_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_ACTION 0xD +/* RESERVED 0xE */ +/* RESERVED 0xF */ + + +#define CTRL_CONTROL_WRAPPER 0x7 +#define CTRL_BAR 0x8 +#define CTRL_BA 0x9 +#define CTRL_PS_POLL 0xA +#define CTRL_RTS 0xB +#define CTRL_CTS 0xC +#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 + +#define DATA_QOS_DATA 0x8 +#define DATA_QOS_DATA_CF_ACK 0x9 +#define DATA_QOS_DATA_CF_POLL 0xA +#define DATA_QOS_DATA_CF_ACK_POLL 0xB +#define DATA_QOS_NODATA 0xC +#define DATA_QOS_CF_POLL_NODATA 0xE +#define DATA_QOS_CF_ACK_POLL_NODATA 0xF + +/* + * The subtype field of a data frame is, in effect, composed of 4 flag + * bits - CF-Ack, CF-Poll, Null (means the frame doesn't actually have + * any data), and QoS. + */ +#define DATA_FRAME_IS_CF_ACK(x) ((x) & 0x01) +#define DATA_FRAME_IS_CF_POLL(x) ((x) & 0x02) +#define DATA_FRAME_IS_NULL(x) ((x) & 0x04) +#define DATA_FRAME_IS_QOS(x) ((x) & 0x08) + +/* + * Bits in the frame control field. + */ +#define FC_VERSION(fc) ((fc) & 0x3) +#define FC_TYPE(fc) (((fc) >> 2) & 0x3) +#define FC_SUBTYPE(fc) (((fc) >> 4) & 0xF) +#define FC_TO_DS(fc) ((fc) & 0x0100) +#define FC_FROM_DS(fc) ((fc) & 0x0200) +#define FC_MORE_FLAG(fc) ((fc) & 0x0400) +#define FC_RETRY(fc) ((fc) & 0x0800) +#define FC_POWER_MGMT(fc) ((fc) & 0x1000) +#define FC_MORE_DATA(fc) ((fc) & 0x2000) +#define FC_WEP(fc) ((fc) & 0x4000) +#define FC_ORDER(fc) ((fc) & 0x8000) + +struct mgmt_header_t { + u_int16_t fc; + u_int16_t duration; + u_int8_t da[6]; + u_int8_t sa[6]; + u_int8_t bssid[6]; + u_int16_t seq_ctrl; +}; + +#define MGMT_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) + +struct ssid_t { + u_int8_t element_id; + u_int8_t length; + u_char ssid[33]; /* 32 + 1 for null */ +}; + +struct rates_t { + u_int8_t element_id; + u_int8_t length; + u_int8_t rate[16]; +}; + +struct challenge_t { + u_int8_t element_id; + u_int8_t length; + u_int8_t text[254]; /* 1-253 + 1 for null */ +}; + +struct fh_t { + u_int8_t element_id; + u_int8_t length; + u_int16_t dwell_time; + u_int8_t hop_set; + u_int8_t hop_pattern; + u_int8_t hop_index; +}; + +struct ds_t { + u_int8_t element_id; + u_int8_t length; + u_int8_t channel; +}; + +struct cf_t { + u_int8_t element_id; + u_int8_t length; + u_int8_t count; + u_int8_t period; + u_int16_t max_duration; + u_int16_t dur_remaing; +}; + +struct tim_t { + u_int8_t element_id; + u_int8_t length; + u_int8_t count; + u_int8_t period; + u_int8_t bitmap_control; + u_int8_t bitmap[251]; +}; + +#define E_SSID 0 +#define E_RATES 1 +#define E_FH 2 +#define E_DS 3 +#define E_CF 4 +#define E_TIM 5 +#define E_IBSS 6 +/* reserved 7 */ +/* reserved 8 */ +/* reserved 9 */ +/* reserved 10 */ +/* reserved 11 */ +/* reserved 12 */ +/* reserved 13 */ +/* reserved 14 */ +/* reserved 15 */ +/* reserved 16 */ + +#define E_CHALLENGE 16 +/* reserved 17 */ +/* reserved 18 */ +/* reserved 19 */ +/* reserved 16 */ +/* reserved 16 */ + + +struct mgmt_body_t { + u_int8_t timestamp[IEEE802_11_TSTAMP_LEN]; + u_int16_t beacon_interval; + u_int16_t listen_interval; + u_int16_t status_code; + u_int16_t aid; + u_char ap[IEEE802_11_AP_LEN]; + u_int16_t reason_code; + u_int16_t auth_alg; + u_int16_t auth_trans_seq_num; + int challenge_present; + struct challenge_t challenge; + u_int16_t capability_info; + int ssid_present; + struct ssid_t ssid; + int rates_present; + struct rates_t rates; + int ds_present; + struct ds_t ds; + int cf_present; + struct cf_t cf; + int fh_present; + struct fh_t fh; + int tim_present; + struct tim_t tim; +}; + +struct ctrl_rts_t { + u_int16_t fc; + u_int16_t duration; + u_int8_t ra[6]; + u_int8_t ta[6]; + u_int8_t fcs[4]; +}; + +#define CTRL_RTS_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; + u_int16_t duration; + u_int8_t ra[6]; + u_int8_t fcs[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; + u_int16_t duration; + u_int8_t ra[6]; + u_int8_t fcs[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; + u_int16_t aid; + u_int8_t bssid[6]; + u_int8_t ta[6]; + u_int8_t fcs[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; + u_int16_t duration; + u_int8_t ra[6]; + u_int8_t bssid[6]; + u_int8_t fcs[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; + u_int16_t duration; + u_int8_t ra[6]; + u_int8_t bssid[6]; + u_int8_t fcs[4]; +}; + +#define CTRL_END_ACK_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\ + IEEE802_11_RA_LEN+IEEE802_11_BSSID_LEN) + +struct ctrl_ba_t { + u_int16_t fc; + u_int16_t duration; + u_int8_t ra[6]; + u_int8_t fcs[4]; +}; + +#define CTRL_BA_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN) + +struct ctrl_bar_t { + u_int16_t fc; + u_int16_t dur; + u_int8_t ra[6]; + u_int8_t ta[6]; + u_int16_t ctl; + u_int16_t seq; + u_int8_t fcs[4]; +}; + +#define CTRL_BAR_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\ + IEEE802_11_RA_LEN+IEEE802_11_TA_LEN+\ + IEEE802_11_CTL_LEN+IEEE802_11_SEQ_LEN) + +struct meshcntl_t { + u_int8_t flags; + u_int8_t ttl; + u_int8_t seq[4]; + u_int8_t addr4[6]; + u_int8_t addr5[6]; + u_int8_t addr6[6]; +}; + +#define IV_IV(iv) ((iv) & 0xFFFFFF) +#define IV_PAD(iv) (((iv) >> 24) & 0x3F) +#define IV_KEYID(iv) (((iv) >> 30) & 0x03)
diff --git a/tcpdump-4.3.0/ieee802_11_radio.h b/tcpdump-4.3.0/ieee802_11_radio.h new file mode 100644 index 0000000..5aff137 --- /dev/null +++ b/tcpdump-4.3.0/ieee802_11_radio.h
@@ -0,0 +1,291 @@ +/* $FreeBSD: src/sys/net80211/ieee80211_radiotap.h,v 1.5 2005/01/22 20:12:05 sam Exp $ */ +/* NetBSD: ieee802_11_radio.h,v 1.2 2006/02/26 03:04:03 dyoung Exp */ +/* $Header: /tcpdump/master/tcpdump/ieee802_11_radio.h,v 1.3 2007-08-29 02:31:44 mcr Exp $ */ + +/*- + * Copyright (c) 2003, 2004 David Young. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of David Young may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``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 DAVID + * YOUNG 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 _NET_IF_IEEE80211RADIOTAP_H_ +#define _NET_IF_IEEE80211RADIOTAP_H_ + +/* A generic radio capture format is desirable. It must be + * rigidly defined (e.g., units for fields should be given), + * and easily extensible. + * + * The following is an extensible radio capture format. It is + * based on a bitmap indicating which fields are present. + * + * I am trying to describe precisely what the application programmer + * should expect in the following, and for that reason I tell the + * units and origin of each measurement (where it applies), or else I + * use sufficiently weaselly language ("is a monotonically nondecreasing + * function of...") that I cannot set false expectations for lawyerly + * readers. + */ + +/* + * The radio capture header precedes the 802.11 header. + * + * Note well: all radiotap fields are little-endian. + */ +struct ieee80211_radiotap_header { + u_int8_t it_version; /* Version 0. Only increases + * for drastic changes, + * introduction of compatible + * new fields does not count. + */ + u_int8_t it_pad; + u_int16_t it_len; /* length of the whole + * header in bytes, including + * it_version, it_pad, + * it_len, and data fields. + */ + u_int32_t it_present; /* A bitmap telling which + * fields are present. Set bit 31 + * (0x80000000) to extend the + * bitmap by another 32 bits. + * Additional extensions are made + * by setting bit 31. + */ +}; + +/* Name Data type Units + * ---- --------- ----- + * + * IEEE80211_RADIOTAP_TSFT u_int64_t microseconds + * + * Value in microseconds of the MAC's 64-bit 802.11 Time + * Synchronization Function timer when the first bit of the + * MPDU arrived at the MAC. For received frames, only. + * + * IEEE80211_RADIOTAP_CHANNEL 2 x u_int16_t MHz, bitmap + * + * Tx/Rx frequency in MHz, followed by flags (see below). + * Note that IEEE80211_RADIOTAP_XCHANNEL must be used to + * represent an HT channel as there is not enough room in + * the flags word. + * + * IEEE80211_RADIOTAP_FHSS u_int16_t see below + * + * For frequency-hopping radios, the hop set (first byte) + * and pattern (second byte). + * + * IEEE80211_RADIOTAP_RATE u_int8_t 500kb/s or index + * + * Tx/Rx data rate. If bit 0x80 is set then it represents an + * an MCS index and not an IEEE rate. + * + * IEEE80211_RADIOTAP_DBM_ANTSIGNAL int8_t decibels from + * one milliwatt (dBm) + * + * RF signal power at the antenna, decibel difference from + * one milliwatt. + * + * IEEE80211_RADIOTAP_DBM_ANTNOISE int8_t decibels from + * one milliwatt (dBm) + * + * RF noise power at the antenna, decibel difference from one + * milliwatt. + * + * IEEE80211_RADIOTAP_DB_ANTSIGNAL u_int8_t decibel (dB) + * + * RF signal power at the antenna, decibel difference from an + * arbitrary, fixed reference. + * + * IEEE80211_RADIOTAP_DB_ANTNOISE u_int8_t decibel (dB) + * + * RF noise power at the antenna, decibel difference from an + * arbitrary, fixed reference point. + * + * IEEE80211_RADIOTAP_LOCK_QUALITY u_int16_t unitless + * + * Quality of Barker code lock. Unitless. Monotonically + * nondecreasing with "better" lock strength. Called "Signal + * Quality" in datasheets. (Is there a standard way to measure + * this?) + * + * IEEE80211_RADIOTAP_TX_ATTENUATION u_int16_t unitless + * + * Transmit power expressed as unitless distance from max + * power set at factory calibration. 0 is max power. + * Monotonically nondecreasing with lower power levels. + * + * IEEE80211_RADIOTAP_DB_TX_ATTENUATION u_int16_t decibels (dB) + * + * Transmit power expressed as decibel distance from max power + * set at factory calibration. 0 is max power. Monotonically + * nondecreasing with lower power levels. + * + * IEEE80211_RADIOTAP_DBM_TX_POWER int8_t decibels from + * one milliwatt (dBm) + * + * Transmit power expressed as dBm (decibels from a 1 milliwatt + * reference). This is the absolute power level measured at + * the antenna port. + * + * IEEE80211_RADIOTAP_FLAGS u_int8_t bitmap + * + * Properties of transmitted and received frames. See flags + * defined below. + * + * IEEE80211_RADIOTAP_ANTENNA u_int8_t antenna index + * + * Unitless indication of the Rx/Tx antenna for this packet. + * The first antenna is antenna 0. + * + * IEEE80211_RADIOTAP_RX_FLAGS u_int16_t bitmap + * + * Properties of received frames. See flags defined below. + * + * IEEE80211_RADIOTAP_XCHANNEL u_int32_t bitmap + * u_int16_t MHz + * u_int8_t channel number + * u_int8_t .5 dBm + * + * Extended channel specification: flags (see below) followed by + * frequency in MHz, the corresponding IEEE channel number, and + * finally the maximum regulatory transmit power cap in .5 dBm + * units. This property supersedes IEEE80211_RADIOTAP_CHANNEL + * and only one of the two should be present. + * + * IEEE80211_RADIOTAP_MCS u_int8_t known + * u_int8_t flags + * u_int8_t mcs + * + * Bitset indicating which fields have known values, followed + * by bitset of flag values, followed by the MCS rate index as + * in IEEE 802.11n. + * + * IEEE80211_RADIOTAP_VENDOR_NAMESPACE + * u_int8_t OUI[3] + * u_int8_t subspace + * u_int16_t length + * + * The Vendor Namespace Field contains three sub-fields. The first + * sub-field is 3 bytes long. It contains the vendor's IEEE 802 + * Organizationally Unique Identifier (OUI). The fourth byte is a + * vendor-specific "namespace selector." + * + */ +enum ieee80211_radiotap_type { + IEEE80211_RADIOTAP_TSFT = 0, + IEEE80211_RADIOTAP_FLAGS = 1, + IEEE80211_RADIOTAP_RATE = 2, + IEEE80211_RADIOTAP_CHANNEL = 3, + IEEE80211_RADIOTAP_FHSS = 4, + IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5, + IEEE80211_RADIOTAP_DBM_ANTNOISE = 6, + IEEE80211_RADIOTAP_LOCK_QUALITY = 7, + IEEE80211_RADIOTAP_TX_ATTENUATION = 8, + IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9, + IEEE80211_RADIOTAP_DBM_TX_POWER = 10, + IEEE80211_RADIOTAP_ANTENNA = 11, + IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12, + IEEE80211_RADIOTAP_DB_ANTNOISE = 13, + IEEE80211_RADIOTAP_RX_FLAGS = 14, + /* NB: gap for netbsd definitions */ + IEEE80211_RADIOTAP_XCHANNEL = 18, + IEEE80211_RADIOTAP_MCS = 19, + IEEE80211_RADIOTAP_NAMESPACE = 29, + IEEE80211_RADIOTAP_VENDOR_NAMESPACE = 30, + IEEE80211_RADIOTAP_EXT = 31 +}; + +/* channel attributes */ +#define IEEE80211_CHAN_TURBO 0x00010 /* Turbo channel */ +#define IEEE80211_CHAN_CCK 0x00020 /* CCK channel */ +#define IEEE80211_CHAN_OFDM 0x00040 /* OFDM channel */ +#define IEEE80211_CHAN_2GHZ 0x00080 /* 2 GHz spectrum channel. */ +#define IEEE80211_CHAN_5GHZ 0x00100 /* 5 GHz spectrum channel */ +#define IEEE80211_CHAN_PASSIVE 0x00200 /* Only passive scan allowed */ +#define IEEE80211_CHAN_DYN 0x00400 /* Dynamic CCK-OFDM channel */ +#define IEEE80211_CHAN_GFSK 0x00800 /* GFSK channel (FHSS PHY) */ +#define IEEE80211_CHAN_GSM 0x01000 /* 900 MHz spectrum channel */ +#define IEEE80211_CHAN_STURBO 0x02000 /* 11a static turbo channel only */ +#define IEEE80211_CHAN_HALF 0x04000 /* Half rate channel */ +#define IEEE80211_CHAN_QUARTER 0x08000 /* Quarter rate channel */ +#define IEEE80211_CHAN_HT20 0x10000 /* HT 20 channel */ +#define IEEE80211_CHAN_HT40U 0x20000 /* HT 40 channel w/ ext above */ +#define IEEE80211_CHAN_HT40D 0x40000 /* HT 40 channel w/ ext below */ + +/* Useful combinations of channel characteristics, borrowed from Ethereal */ +#define IEEE80211_CHAN_A \ + (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM) +#define IEEE80211_CHAN_B \ + (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_CCK) +#define IEEE80211_CHAN_G \ + (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN) +#define IEEE80211_CHAN_TA \ + (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_TURBO) +#define IEEE80211_CHAN_TG \ + (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN | IEEE80211_CHAN_TURBO) + + +/* For IEEE80211_RADIOTAP_FLAGS */ +#define IEEE80211_RADIOTAP_F_CFP 0x01 /* sent/received + * during CFP + */ +#define IEEE80211_RADIOTAP_F_SHORTPRE 0x02 /* sent/received + * with short + * preamble + */ +#define IEEE80211_RADIOTAP_F_WEP 0x04 /* sent/received + * with WEP encryption + */ +#define IEEE80211_RADIOTAP_F_FRAG 0x08 /* sent/received + * with fragmentation + */ +#define IEEE80211_RADIOTAP_F_FCS 0x10 /* frame includes FCS */ +#define IEEE80211_RADIOTAP_F_DATAPAD 0x20 /* frame has padding between + * 802.11 header and payload + * (to 32-bit boundary) + */ +#define IEEE80211_RADIOTAP_F_BADFCS 0x40 /* does not pass FCS check */ + +/* For IEEE80211_RADIOTAP_RX_FLAGS */ +#define IEEE80211_RADIOTAP_F_RX_BADFCS 0x0001 /* frame failed crc check */ +#define IEEE80211_RADIOTAP_F_RX_PLCP_CRC 0x0002 /* frame failed PLCP CRC check */ + +/* For IEEE80211_RADIOTAP_MCS known */ +#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_KNOWN 0x01 +#define IEEE80211_RADIOTAP_MCS_MCS_INDEX_KNOWN 0x02 /* MCS index field */ +#define IEEE80211_RADIOTAP_MCS_GUARD_INTERVAL_KNOWN 0x04 +#define IEEE80211_RADIOTAP_MCS_HT_FORMAT_KNOWN 0x08 +#define IEEE80211_RADIOTAP_MCS_FEC_TYPE_KNOWN 0x10 + +/* For IEEE80211_RADIOTAP_MCS flags */ +#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK 0x03 +#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20 0 +#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_40 1 +#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20L 2 +#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20U 3 +#define IEEE80211_RADIOTAP_MCS_SHORT_GI 0x04 /* short guard interval */ +#define IEEE80211_RADIOTAP_MCS_HT_GREENFIELD 0x08 +#define IEEE80211_RADIOTAP_MCS_FEC_LDPC 0x10 + +#endif /* _NET_IF_IEEE80211RADIOTAP_H_ */
diff --git a/tcpdump-4.3.0/igrp.h b/tcpdump-4.3.0/igrp.h new file mode 100644 index 0000000..b5f133b --- /dev/null +++ b/tcpdump-4.3.0/igrp.h
@@ -0,0 +1,33 @@ +/* @(#) $Header: /tcpdump/master/tcpdump/igrp.h,v 1.6 2002-12-11 07:13:52 guy Exp $ (LBL) */ +/* Cisco IGRP definitions */ + +/* IGRP Header */ + +struct igrphdr { + u_int8_t ig_vop; /* protocol version number / opcode */ +#define IGRP_V(x) (((x) & 0xf0) >> 4) +#define IGRP_OP(x) ((x) & 0x0f) + u_int8_t ig_ed; /* edition number */ + u_int16_t ig_as; /* autonomous system number */ + u_int16_t ig_ni; /* number of subnet in local net */ + u_int16_t ig_ns; /* number of networks in AS */ + u_int16_t ig_nx; /* number of networks ouside AS */ + u_int16_t ig_sum; /* checksum of IGRP header & data */ +}; + +#define IGRP_UPDATE 1 +#define IGRP_REQUEST 2 + +/* IGRP routing entry */ + +struct igrprte { + u_int8_t igr_net[3]; /* 3 significant octets of IP address */ + u_int8_t igr_dly[3]; /* delay in tens of microseconds */ + u_int8_t igr_bw[3]; /* bandwidth in units of 1 kb/s */ + u_int8_t igr_mtu[2]; /* MTU in octets */ + u_int8_t igr_rel; /* percent packets successfully tx/rx */ + u_int8_t igr_ld; /* percent of channel occupied */ + u_int8_t igr_hct; /* hop count */ +}; + +#define IGRP_RTE_SIZE 14 /* don't believe sizeof ! */
diff --git a/tcpdump-4.3.0/in_cksum.c b/tcpdump-4.3.0/in_cksum.c new file mode 100644 index 0000000..93cdfc9 --- /dev/null +++ b/tcpdump-4.3.0/in_cksum.c
@@ -0,0 +1,200 @@ +/* in_cksum.c + * 4.4-Lite-2 Internet checksum routine, modified to take a vector of + * pointers/lengths giving the pieces to be checksummed. Also using + * Tahoe/CGI version of ADDCARRY(x) macro instead of from portable version. + */ + +/* + * Copyright (c) 1988, 1992, 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. 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. + * + * @(#)in_cksum.c 8.1 (Berkeley) 6/10/93 + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include "interface.h" + +/* + * Checksum routine for Internet Protocol family headers (Portable Version). + * + * This routine is very heavily used in the network + * code and should be modified for each CPU to be as fast as possible. + */ + +#define ADDCARRY(x) {if ((x) > 65535) (x) -= 65535;} +#define REDUCE {l_util.l = sum; sum = l_util.s[0] + l_util.s[1]; ADDCARRY(sum);} + +u_int16_t +in_cksum(const struct cksum_vec *vec, int veclen) +{ + register const u_int16_t *w; + register int sum = 0; + register int mlen = 0; + int byte_swapped = 0; + + union { + u_int8_t c[2]; + u_int16_t s; + } s_util; + union { + u_int16_t s[2]; + u_int32_t l; + } l_util; + + for (; veclen != 0; vec++, veclen--) { + if (vec->len == 0) + continue; + w = (const u_int16_t *)(void *)vec->ptr; + if (mlen == -1) { + /* + * The first byte of this chunk is the continuation + * of a word spanning between this chunk and the + * last chunk. + * + * s_util.c[0] is already saved when scanning previous + * chunk. + */ + s_util.c[1] = *(const u_int8_t *)w; + sum += s_util.s; + w = (const u_int16_t *)(void *)((const u_int8_t *)w + 1); + mlen = vec->len - 1; + } else + mlen = vec->len; + /* + * Force to even boundary. + */ + if ((1 & (unsigned long) w) && (mlen > 0)) { + REDUCE; + sum <<= 8; + s_util.c[0] = *(const u_int8_t *)w; + w = (const u_int16_t *)(void *)((const u_int8_t *)w + 1); + mlen--; + byte_swapped = 1; + } + /* + * Unroll the loop to make overhead from + * branches &c small. + */ + while ((mlen -= 32) >= 0) { + sum += w[0]; sum += w[1]; sum += w[2]; sum += w[3]; + sum += w[4]; sum += w[5]; sum += w[6]; sum += w[7]; + sum += w[8]; sum += w[9]; sum += w[10]; sum += w[11]; + sum += w[12]; sum += w[13]; sum += w[14]; sum += w[15]; + w += 16; + } + mlen += 32; + while ((mlen -= 8) >= 0) { + sum += w[0]; sum += w[1]; sum += w[2]; sum += w[3]; + w += 4; + } + mlen += 8; + if (mlen == 0 && byte_swapped == 0) + continue; + REDUCE; + while ((mlen -= 2) >= 0) { + sum += *w++; + } + if (byte_swapped) { + REDUCE; + sum <<= 8; + byte_swapped = 0; + if (mlen == -1) { + s_util.c[1] = *(const u_int8_t *)w; + sum += s_util.s; + mlen = 0; + } else + mlen = -1; + } else if (mlen == -1) + s_util.c[0] = *(const u_int8_t *)w; + } + if (mlen == -1) { + /* The last mbuf has odd # of bytes. Follow the + standard (the odd byte may be shifted left by 8 bits + or not as determined by endian-ness of the machine) */ + s_util.c[1] = 0; + sum += s_util.s; + } + REDUCE; + return (~sum & 0xffff); +} + +/* + * Given the host-byte-order value of the checksum field in a packet + * header, and the network-byte-order computed checksum of the data + * that the checksum covers (including the checksum itself), compute + * what the checksum field *should* have been. + */ +u_int16_t +in_cksum_shouldbe(u_int16_t sum, u_int16_t computed_sum) +{ + u_int32_t shouldbe; + + /* + * The value that should have gone into the checksum field + * is the negative of the value gotten by summing up everything + * *but* the checksum field. + * + * We can compute that by subtracting the value of the checksum + * field from the sum of all the data in the packet, and then + * computing the negative of that value. + * + * "sum" is the value of the checksum field, and "computed_sum" + * is the negative of the sum of all the data in the packets, + * so that's -(-computed_sum - sum), or (sum + computed_sum). + * + * All the arithmetic in question is one's complement, so the + * addition must include an end-around carry; we do this by + * doing the arithmetic in 32 bits (with no sign-extension), + * and then adding the upper 16 bits of the sum, which contain + * the carry, to the lower 16 bits of the sum, and then do it + * again in case *that* sum produced a carry. + * + * As RFC 1071 notes, the checksum can be computed without + * byte-swapping the 16-bit words; summing 16-bit words + * on a big-endian machine gives a big-endian checksum, which + * can be directly stuffed into the big-endian checksum fields + * in protocol headers, and summing words on a little-endian + * machine gives a little-endian checksum, which must be + * byte-swapped before being stuffed into a big-endian checksum + * field. + * + * "computed_sum" is a network-byte-order value, so we must put + * it in host byte order before subtracting it from the + * host-byte-order value from the header; the adjusted checksum + * will be in host byte order, which is what we'll return. + */ + shouldbe = sum; + shouldbe += ntohs(computed_sum); + shouldbe = (shouldbe & 0xFFFF) + (shouldbe >> 16); + shouldbe = (shouldbe & 0xFFFF) + (shouldbe >> 16); + return shouldbe; +}
diff --git a/tcpdump-4.3.0/install-sh b/tcpdump-4.3.0/install-sh new file mode 100755 index 0000000..ebc6691 --- /dev/null +++ b/tcpdump-4.3.0/install-sh
@@ -0,0 +1,250 @@ +#! /bin/sh +# +# install - install a program, script, or datafile +# This comes from X11R5 (mit/util/scripts/install.sh). +# +# Copyright 1991 by the Massachusetts Institute of Technology +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of M.I.T. not be used in advertising or +# publicity pertaining to distribution of the software without specific, +# written prior permission. M.I.T. makes no representations about the +# suitability of this software for any purpose. It is provided "as is" +# without express or implied warranty. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. It can only install one file at a time, a restriction +# shared with many OS's install programs. + + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit="${DOITPROG-}" + + +# put in absolute paths if you don't have them in your path; or use env. vars. + +mvprog="${MVPROG-mv}" +cpprog="${CPPROG-cp}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" + +transformbasename="" +transform_arg="" +instcmd="$mvprog" +chmodcmd="$chmodprog 0755" +chowncmd="" +chgrpcmd="" +stripcmd="" +rmcmd="$rmprog -f" +mvcmd="$mvprog" +src="" +dst="" +dir_arg="" + +while [ x"$1" != x ]; do + case $1 in + -c) instcmd="$cpprog" + shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -m) chmodcmd="$chmodprog $2" + shift + shift + continue;; + + -o) chowncmd="$chownprog $2" + shift + shift + continue;; + + -g) chgrpcmd="$chgrpprog $2" + shift + shift + continue;; + + -s) stripcmd="$stripprog" + shift + continue;; + + -t=*) transformarg=`echo $1 | sed 's/-t=//'` + shift + continue;; + + -b=*) transformbasename=`echo $1 | sed 's/-b=//'` + shift + continue;; + + *) if [ x"$src" = x ] + then + src=$1 + else + # this colon is to work around a 386BSD /bin/sh bug + : + dst=$1 + fi + shift + continue;; + esac +done + +if [ x"$src" = x ] +then + echo "install: no input file specified" + exit 1 +else + true +fi + +if [ x"$dir_arg" != x ]; then + dst=$src + src="" + + if [ -d $dst ]; then + instcmd=: + else + instcmd=mkdir + fi +else + +# Waiting for this to be detected by the "$instcmd $src $dsttmp" command +# might cause directories to be created, which would be especially bad +# if $src (and thus $dsttmp) contains '*'. + + if [ -f $src -o -d $src ] + then + true + else + echo "install: $src does not exist" + exit 1 + fi + + if [ x"$dst" = x ] + then + echo "install: no destination specified" + exit 1 + else + true + fi + +# If destination is a directory, append the input filename; if your system +# does not like double slashes in filenames, you may need to add some logic + + if [ -d $dst ] + then + dst="$dst"/`basename $src` + else + true + fi +fi + +## this sed command emulates the dirname command +dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` + +# Make sure that the destination directory exists. +# this part is taken from Noah Friedman's mkinstalldirs script + +# Skip lots of stat calls in the usual case. +if [ ! -d "$dstdir" ]; then +defaultIFS=' +' +IFS="${IFS-${defaultIFS}}" + +oIFS="${IFS}" +# Some sh's can't handle IFS=/ for some reason. +IFS='%' +set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` +IFS="${oIFS}" + +pathcomp='' + +while [ $# -ne 0 ] ; do + pathcomp="${pathcomp}${1}" + shift + + if [ ! -d "${pathcomp}" ] ; + then + $mkdirprog "${pathcomp}" + else + true + fi + + pathcomp="${pathcomp}/" +done +fi + +if [ x"$dir_arg" != x ] +then + $doit $instcmd $dst && + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi +else + +# If we're going to rename the final executable, determine the name now. + + if [ x"$transformarg" = x ] + then + dstfile=`basename $dst` + else + dstfile=`basename $dst $transformbasename | + sed $transformarg`$transformbasename + fi + +# don't allow the sed command to completely eliminate the filename + + if [ x"$dstfile" = x ] + then + dstfile=`basename $dst` + else + true + fi + +# Make a temp file name in the proper directory. + + dsttmp=$dstdir/#inst.$$# + +# Move or copy the file name to the temp name + + $doit $instcmd $src $dsttmp && + + trap "rm -f ${dsttmp}" 0 && + +# and set any options; do chmod last to preserve setuid bits + +# If any of these fail, we abort the whole thing. If we want to +# ignore errors from any of these, just make sure not to ignore +# errors from the above "$doit $instcmd $src $dsttmp" command. + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && + +# Now rename the file to the real destination. + + $doit $rmcmd -f $dstdir/$dstfile && + $doit $mvcmd $dsttmp $dstdir/$dstfile + +fi && + + +exit 0
diff --git a/tcpdump-4.3.0/interface.h b/tcpdump-4.3.0/interface.h new file mode 100644 index 0000000..18668a2 --- /dev/null +++ b/tcpdump-4.3.0/interface.h
@@ -0,0 +1,392 @@ +/* + * 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/interface.h,v 1.285 2008-08-16 11:36:20 hannes Exp $ (LBL) + */ + +#ifndef tcpdump_interface_h +#define tcpdump_interface_h + +#ifdef HAVE_OS_PROTO_H +#include "os-proto.h" +#endif + +/* snprintf et al */ + +#include <stdarg.h> + +#if HAVE_STDINT_H +#include <stdint.h> +#endif + +#if !defined(HAVE_SNPRINTF) +int snprintf(char *, size_t, const char *, ...) + __attribute__((format(printf, 3, 4))); +#endif + +#if !defined(HAVE_VSNPRINTF) +int vsnprintf(char *, size_t, const char *, va_list) + __attribute__((format(printf, 3, 0))); +#endif + +#ifndef HAVE_STRLCAT +extern size_t strlcat(char *, const char *, size_t); +#endif +#ifndef HAVE_STRLCPY +extern size_t strlcpy(char *, const char *, size_t); +#endif + +#ifndef HAVE_STRDUP +extern char *strdup(const char *); +#endif + +#ifndef HAVE_STRSEP +extern char *strsep(char **, const char *); +#endif + +#define PT_VAT 1 /* Visual Audio Tool */ +#define PT_WB 2 /* distributed White Board */ +#define PT_RPC 3 /* Remote Procedure Call */ +#define PT_RTP 4 /* Real-Time Applications protocol */ +#define PT_RTCP 5 /* Real-Time Applications control protocol */ +#define PT_SNMP 6 /* Simple Network Management Protocol */ +#define PT_CNFP 7 /* Cisco NetFlow protocol */ +#define PT_TFTP 8 /* trivial file transfer protocol */ +#define PT_AODV 9 /* Ad-hoc On-demand Distance Vector Protocol */ +#define PT_CARP 10 /* Common Address Redundancy Protocol */ + +#ifndef min +#define min(a,b) ((a)>(b)?(b):(a)) +#endif +#ifndef max +#define max(a,b) ((b)>(a)?(b):(a)) +#endif + +#define ESRC(ep) ((ep)->ether_shost) +#define EDST(ep) ((ep)->ether_dhost) + +#ifndef NTOHL +#define NTOHL(x) (x) = ntohl(x) +#define NTOHS(x) (x) = ntohs(x) +#define HTONL(x) (x) = htonl(x) +#define HTONS(x) (x) = htons(x) +#endif +#endif + +#ifndef MIN +#define MIN(a,b) ((a)<(b)?(a):(b)) +#endif + +extern char *program_name; /* used to generate self-identifying messages */ + +extern int32_t thiszone; /* seconds offset from gmt to local time */ + +/* + * True if "l" bytes of "var" were captured. + * + * The "snapend - (l) <= snapend" checks to make sure "l" isn't so large + * that "snapend - (l)" underflows. + * + * The check is for <= rather than < because "l" might be 0. + */ +#define TTEST2(var, l) (snapend - (l) <= snapend && \ + (const u_char *)&(var) <= snapend - (l)) + +/* True if "var" was captured */ +#define TTEST(var) TTEST2(var, sizeof(var)) + +/* Bail if "l" bytes of "var" were not captured */ +#define TCHECK2(var, l) if (!TTEST2(var, l)) goto trunc + +/* Bail if "var" was not captured */ +#define TCHECK(var) TCHECK2(var, sizeof(var)) + +extern void ts_print(const struct timeval *); +extern void relts_print(int); + +extern int fn_print(const u_char *, const u_char *); +extern int fn_printn(const u_char *, u_int, const u_char *); +extern int fn_printzp(const u_char *, u_int, const u_char *); +extern int mask2plen(u_int32_t); +extern const char *tok2strary_internal(const char **, int, const char *, int); +#define tok2strary(a,f,i) tok2strary_internal(a, sizeof(a)/sizeof(a[0]),f,i) + +extern const char *dnaddr_string(u_short); + +extern void error(const char *, ...) + __attribute__((noreturn, format (printf, 1, 2))); +extern void warning(const char *, ...) __attribute__ ((format (printf, 1, 2))); + +extern char *read_infile(char *); +extern char *copy_argv(char **); + +extern void safeputchar(int); +extern void safeputs(const char *, int); + +extern const char *isonsap_string(const u_char *, register u_int); +extern const char *protoid_string(const u_char *); +extern const char *ipxsap_string(u_short); +extern const char *dnname_string(u_short); +extern const char *dnnum_string(u_short); + +/* checksum routines */ +extern void init_checksum(void); +extern u_int16_t verify_crc10_cksum(u_int16_t, const u_char *, int); +extern u_int16_t create_osi_cksum(const u_int8_t *, int, int); + +/* The printer routines. */ + +#include <pcap.h> + +extern int print_unknown_data(const u_char *, const char *,int); +extern void ascii_print(const u_char *, u_int); +extern void hex_and_ascii_print_with_offset(const char *, const u_char *, + u_int, u_int); +extern void hex_and_ascii_print(const char *, const u_char *, u_int); +extern void hex_print_with_offset(const char *, const u_char *, u_int, u_int); +extern void hex_print(const char *, const u_char *, u_int); +extern void telnet_print(const u_char *, u_int); +extern int llc_print(const u_char *, u_int, u_int, const u_char *, + const u_char *, u_short *); +extern int snap_print(const u_char *, u_int, u_int, u_int); +extern void aarp_print(const u_char *, u_int); +extern void aodv_print(const u_char *, u_int, int); +extern void atalk_print(const u_char *, u_int); +extern void atm_print(u_int, u_int, u_int, const u_char *, u_int, u_int); +extern u_int atm_if_print(const struct pcap_pkthdr *, const u_char *); +extern u_int sunatm_if_print(const struct pcap_pkthdr *, const u_char *); +extern int oam_print(const u_char *, u_int, u_int); +extern void bootp_print(const u_char *, u_int); +extern void bgp_print(const u_char *, int); +extern void beep_print(const u_char *, u_int); +extern void cnfp_print(const u_char *, const u_char *); +extern void decnet_print(const u_char *, u_int, u_int); +extern void default_print(const u_char *, u_int); +extern void dvmrp_print(const u_char *, u_int); +extern void egp_print(const u_char *, u_int); +extern u_int enc_if_print(const struct pcap_pkthdr *, const u_char *); +extern u_int pflog_if_print(const struct pcap_pkthdr *, const u_char *); +extern u_int arcnet_if_print(const struct pcap_pkthdr *, const u_char *); +extern u_int arcnet_linux_if_print(const struct pcap_pkthdr *, const u_char *); +extern u_int token_print(const u_char *, u_int, u_int); +extern u_int token_if_print(const struct pcap_pkthdr *, const u_char *); +extern void fddi_print(const u_char *, u_int, u_int); +extern u_int fddi_if_print(const struct pcap_pkthdr *, const u_char *); +extern u_int fr_if_print(const struct pcap_pkthdr *, const u_char *); +extern u_int mfr_if_print(const struct pcap_pkthdr *, const u_char *); +extern u_int fr_print(register const u_char *, u_int); +extern u_int mfr_print(register const u_char *, u_int); +extern char *q922_string(const u_char *); +extern u_int ieee802_11_if_print(const struct pcap_pkthdr *, const u_char *); +extern u_int ieee802_11_radio_if_print(const struct pcap_pkthdr *, + const u_char *); +extern u_int ap1394_if_print(const struct pcap_pkthdr *, const u_char *); +extern u_int ieee802_11_radio_avs_if_print(const struct pcap_pkthdr *, + const u_char *); +extern void gre_print(const u_char *, u_int); +extern void icmp_print(const u_char *, u_int, const u_char *, int); +extern void igmp_print(const u_char *, u_int); +extern void igrp_print(const u_char *, u_int, const u_char *); +extern void ipN_print(const u_char *, u_int); +extern u_int ipfc_if_print(const struct pcap_pkthdr *, const u_char *); +extern void ipx_print(const u_char *, u_int); +extern void isoclns_print(const u_char *, u_int, u_int); +extern void krb_print(const u_char *); +extern u_int llap_print(const u_char *, u_int); +extern u_int ltalk_if_print(const struct pcap_pkthdr *, const u_char *); +extern void msdp_print(const unsigned char *, u_int); +extern void nfsreply_print(const u_char *, u_int, const u_char *); +extern void nfsreq_print(const u_char *, u_int, const u_char *); +extern void ns_print(const u_char *, u_int, int); +extern void ntp_print(const u_char *, u_int); +extern u_int null_if_print(const struct pcap_pkthdr *, const u_char *); +extern void ospf_print(const u_char *, u_int, const u_char *); +extern void olsr_print (const u_char *, u_int, int); +extern void pimv1_print(const u_char *, u_int); +extern void cisco_autorp_print(const u_char *, u_int); +extern void rsvp_print(const u_char *, u_int); +extern void ldp_print(const u_char *, u_int); +extern void lldp_print(const u_char *, u_int); +extern void rpki_rtr_print(const u_char *, u_int); +extern void lmp_print(const u_char *, u_int); +extern void lspping_print(const u_char *, u_int); +extern void lwapp_control_print(const u_char *, u_int, int); +extern void lwapp_data_print(const u_char *, u_int); +extern void eigrp_print(const u_char *, u_int); +extern void mobile_print(const u_char *, u_int); +extern void pim_print(const u_char *, u_int, u_int); +extern u_int pppoe_print(const u_char *, u_int); +extern u_int ppp_print(register const u_char *, u_int); +extern u_int ppp_if_print(const struct pcap_pkthdr *, const u_char *); +extern u_int ppp_hdlc_if_print(const struct pcap_pkthdr *, const u_char *); +extern u_int ppp_bsdos_if_print(const struct pcap_pkthdr *, const u_char *); +extern u_int pppoe_if_print(const struct pcap_pkthdr *, const u_char *); +extern u_int prism_if_print(const struct pcap_pkthdr *, const u_char *); +extern void q933_print(const u_char *, u_int); +extern int vjc_print(register const char *, u_short); +extern void vqp_print(register const u_char *, register u_int); +extern u_int raw_if_print(const struct pcap_pkthdr *, const u_char *); +extern void rip_print(const u_char *, u_int); +extern u_int sl_if_print(const struct pcap_pkthdr *, const u_char *); +extern void lane_print(const u_char *, u_int, u_int); +extern u_int lane_if_print(const struct pcap_pkthdr *, const u_char *); +extern u_int cip_if_print(const struct pcap_pkthdr *, const u_char *); +extern u_int sl_bsdos_if_print(const struct pcap_pkthdr *, const u_char *); +extern u_int chdlc_if_print(const struct pcap_pkthdr *, const u_char *); +extern u_int chdlc_print(register const u_char *, u_int); +extern u_int juniper_atm1_print(const struct pcap_pkthdr *, const u_char *); +extern u_int juniper_atm2_print(const struct pcap_pkthdr *, const u_char *); +extern u_int juniper_mfr_print(const struct pcap_pkthdr *, register const u_char *); +extern u_int juniper_mlfr_print(const struct pcap_pkthdr *, const u_char *); +extern u_int juniper_mlppp_print(const struct pcap_pkthdr *, const u_char *); +extern u_int juniper_pppoe_print(const struct pcap_pkthdr *, const u_char *); +extern u_int juniper_pppoe_atm_print(const struct pcap_pkthdr *, const u_char *); +extern u_int juniper_ggsn_print(const struct pcap_pkthdr *, const u_char *); +extern u_int juniper_es_print(const struct pcap_pkthdr *, const u_char *); +extern u_int juniper_monitor_print(const struct pcap_pkthdr *, const u_char *); +extern u_int juniper_services_print(const struct pcap_pkthdr *, const u_char *); +extern u_int juniper_ether_print(const struct pcap_pkthdr *, const u_char *); +extern u_int juniper_ppp_print(const struct pcap_pkthdr *, const u_char *); +extern u_int juniper_frelay_print(const struct pcap_pkthdr *, const u_char *); +extern u_int juniper_chdlc_print(const struct pcap_pkthdr *, const u_char *); +extern u_int sll_if_print(const struct pcap_pkthdr *, const u_char *); +extern void snmp_print(const u_char *, u_int); +extern void sunrpcrequest_print(const u_char *, u_int, const u_char *); +extern u_int symantec_if_print(const struct pcap_pkthdr *, const u_char *); +extern void tcp_print(const u_char *, u_int, const u_char *, int); +extern void tftp_print(const u_char *, u_int); +extern void timed_print(const u_char *); +extern void udld_print(const u_char *, u_int); +extern void udp_print(const u_char *, u_int, const u_char *, int); +extern void vtp_print(const u_char *, u_int); +extern void wb_print(const void *, u_int); +extern int ah_print(register const u_char *); +extern int ipcomp_print(register const u_char *, int *); +extern void rx_print(register const u_char *, int, int, int, u_char *); +extern void netbeui_print(u_short, const u_char *, int); +extern void ipx_netbios_print(const u_char *, u_int); +extern void nbt_tcp_print(const u_char *, int); +extern void nbt_udp137_print(const u_char *, int); +extern void nbt_udp138_print(const u_char *, int); +extern void smb_tcp_print(const u_char *, int); +extern char *smb_errstr(int, int); +extern const char *nt_errstr(u_int32_t); +extern void print_data(const unsigned char *, int); +extern void l2tp_print(const u_char *, u_int); +extern void vrrp_print(const u_char *, u_int, int); +extern void carp_print(const u_char *, u_int, int); +extern void slow_print(const u_char *, u_int); +extern void sflow_print(const u_char *, u_int); +extern void mpcp_print(const u_char *, u_int); +extern void cfm_print(const u_char *, u_int); +extern void pgm_print(const u_char *, u_int, const u_char *); +extern void cdp_print(const u_char *, u_int, u_int); +extern void dtp_print(const u_char *, u_int); +extern void stp_print(const u_char *, u_int); +extern void radius_print(const u_char *, u_int); +extern void lwres_print(const u_char *, u_int); +extern void pptp_print(const u_char *); +extern void dccp_print(const u_char *, const u_char *, u_int); +extern void sctp_print(const u_char *, const u_char *, u_int); +extern void forces_print(const u_char *, u_int); +extern void mpls_print(const u_char *, u_int); +extern void mpls_lsp_ping_print(const u_char *, u_int); +extern void zephyr_print(const u_char *, int); +extern void hsrp_print(const u_char *, u_int); +extern void bfd_print(const u_char *, u_int, u_int); +extern void sip_print(const u_char *, u_int); +extern void syslog_print(const u_char *, u_int); +extern u_int bt_if_print(const struct pcap_pkthdr *, const u_char *); +extern u_int usb_linux_48_byte_print(const struct pcap_pkthdr *, const u_char *); +extern u_int usb_linux_64_byte_print(const struct pcap_pkthdr *, const u_char *); + + +#ifdef INET6 +extern void ip6_opt_print(const u_char *, int); +extern int hbhopt_print(const u_char *); +extern int dstopt_print(const u_char *); +extern int frag6_print(const u_char *, const u_char *); +extern int mobility_print(const u_char *, const u_char *); +extern void ripng_print(const u_char *, unsigned int); +extern int rt6_print(const u_char *, const u_char *); +extern void ospf6_print(const u_char *, u_int); +extern void dhcp6_print(const u_char *, u_int); +extern void babel_print(const u_char *, u_int); +extern int mask62plen(const u_char *); +#endif /*INET6*/ + +struct cksum_vec { + const u_int8_t *ptr; + int len; +}; +extern u_int16_t in_cksum(const struct cksum_vec *, int); +extern u_int16_t in_cksum_shouldbe(u_int16_t, u_int16_t); + +#ifndef HAVE_BPF_DUMP +struct bpf_program; + +extern void bpf_dump(const struct bpf_program *, int); + +#endif + +#include "netdissect.h" + +/* forward compatibility */ + +#ifndef NETDISSECT_REWORKED +extern netdissect_options *gndo; + +#define bflag gndo->ndo_bflag +#define eflag gndo->ndo_eflag +#define fflag gndo->ndo_fflag +#define jflag gndo->ndo_jflag +#define Kflag gndo->ndo_Kflag +#define nflag gndo->ndo_nflag +#define Nflag gndo->ndo_Nflag +#define Oflag gndo->ndo_Oflag +#define pflag gndo->ndo_pflag +#define qflag gndo->ndo_qflag +#define Rflag gndo->ndo_Rflag +#define sflag gndo->ndo_sflag +#define Sflag gndo->ndo_Sflag +#define tflag gndo->ndo_tflag +#define Uflag gndo->ndo_Uflag +#define uflag gndo->ndo_uflag +#define vflag gndo->ndo_vflag +#define xflag gndo->ndo_xflag +#define Xflag gndo->ndo_Xflag +#define Cflag gndo->ndo_Cflag +#define Gflag gndo->ndo_Gflag +#define Aflag gndo->ndo_Aflag +#define Bflag gndo->ndo_Bflag +#define Iflag gndo->ndo_Iflag +#define suppress_default_print gndo->ndo_suppress_default_print +#define packettype gndo->ndo_packettype +#define sigsecret gndo->ndo_sigsecret +#define Wflag gndo->ndo_Wflag +#define WflagChars gndo->ndo_WflagChars +#define Cflag_count gndo->ndo_Cflag_count +#define Gflag_count gndo->ndo_Gflag_count +#define Gflag_time gndo->ndo_Gflag_time +#define Hflag gndo->ndo_Hflag +#define snaplen gndo->ndo_snaplen +#define snapend gndo->ndo_snapend + +#endif
diff --git a/tcpdump-4.3.0/ip.h b/tcpdump-4.3.0/ip.h new file mode 100644 index 0000000..8a97632 --- /dev/null +++ b/tcpdump-4.3.0/ip.h
@@ -0,0 +1,164 @@ +/* @(#) $Header: /tcpdump/master/tcpdump/ip.h,v 1.12 2007-09-14 01:29:28 guy Exp $ (LBL) */ +/* + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)ip.h 8.2 (Berkeley) 6/1/94 + */ + +/* + * Definitions for internet protocol version 4. + * Per RFC 791, September 1981. + */ +#define IPVERSION 4 + +/* + * Structure of an internet header, naked of options. + * + * We declare ip_len and ip_off to be short, rather than u_short + * pragmatically since otherwise unsigned comparisons can result + * against negative integers quite easily, and fail in subtle ways. + */ +struct ip { + u_int8_t ip_vhl; /* header length, version */ +#define IP_V(ip) (((ip)->ip_vhl & 0xf0) >> 4) +#define IP_HL(ip) ((ip)->ip_vhl & 0x0f) + u_int8_t ip_tos; /* type of service */ + u_int16_t ip_len; /* total length */ + u_int16_t ip_id; /* identification */ + u_int16_t ip_off; /* fragment offset field */ +#define IP_DF 0x4000 /* dont fragment flag */ +#define IP_MF 0x2000 /* more fragments flag */ +#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */ + u_int8_t ip_ttl; /* time to live */ + u_int8_t ip_p; /* protocol */ + u_int16_t ip_sum; /* checksum */ + struct in_addr ip_src,ip_dst; /* source and dest address */ +} UNALIGNED; + +#define IP_MAXPACKET 65535 /* maximum packet size */ + +/* + * Definitions for IP type of service (ip_tos) + */ +#define IPTOS_LOWDELAY 0x10 +#define IPTOS_THROUGHPUT 0x08 +#define IPTOS_RELIABILITY 0x04 + +/* + * Definitions for IP precedence (also in ip_tos) (hopefully unused) + */ +#define IPTOS_PREC_NETCONTROL 0xe0 +#define IPTOS_PREC_INTERNETCONTROL 0xc0 +#define IPTOS_PREC_CRITIC_ECP 0xa0 +#define IPTOS_PREC_FLASHOVERRIDE 0x80 +#define IPTOS_PREC_FLASH 0x60 +#define IPTOS_PREC_IMMEDIATE 0x40 +#define IPTOS_PREC_PRIORITY 0x20 +#define IPTOS_PREC_ROUTINE 0x00 + +/* + * Definitions for options. + */ +#define IPOPT_COPIED(o) ((o)&0x80) +#define IPOPT_CLASS(o) ((o)&0x60) +#define IPOPT_NUMBER(o) ((o)&0x1f) + +#define IPOPT_CONTROL 0x00 +#define IPOPT_RESERVED1 0x20 +#define IPOPT_DEBMEAS 0x40 +#define IPOPT_RESERVED2 0x60 + +#define IPOPT_EOL 0 /* end of option list */ +#define IPOPT_NOP 1 /* no operation */ + +#define IPOPT_RR 7 /* record packet route */ +#define IPOPT_TS 68 /* timestamp */ +#define IPOPT_RFC1393 82 /* traceroute RFC 1393 */ +#define IPOPT_SECURITY 130 /* provide s,c,h,tcc */ +#define IPOPT_LSRR 131 /* loose source route */ +#define IPOPT_SATID 136 /* satnet id */ +#define IPOPT_SSRR 137 /* strict source route */ +#define IPOPT_RA 148 /* router-alert, rfc2113 */ + +/* + * Offsets to fields in options other than EOL and NOP. + */ +#define IPOPT_OPTVAL 0 /* option ID */ +#define IPOPT_OLEN 1 /* option length */ +#define IPOPT_OFFSET 2 /* offset within option */ +#define IPOPT_MINOFF 4 /* min value of above */ + +/* + * Time stamp option structure. + */ +struct ip_timestamp { + u_int8_t ipt_code; /* IPOPT_TS */ + u_int8_t ipt_len; /* size of structure (variable) */ + u_int8_t ipt_ptr; /* index of current entry */ + u_int8_t ipt_oflwflg; /* flags, overflow counter */ +#define IPTS_OFLW(ip) (((ipt)->ipt_oflwflg & 0xf0) >> 4) +#define IPTS_FLG(ip) ((ipt)->ipt_oflwflg & 0x0f) + union ipt_timestamp { + u_int32_t ipt_time[1]; + struct ipt_ta { + struct in_addr ipt_addr; + u_int32_t ipt_time; + } ipt_ta[1]; + } ipt_timestamp; +} UNALIGNED; + +/* flag bits for ipt_flg */ +#define IPOPT_TS_TSONLY 0 /* timestamps only */ +#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */ +#define IPOPT_TS_PRESPEC 3 /* specified modules only */ + +/* bits for security (not byte swapped) */ +#define IPOPT_SECUR_UNCLASS 0x0000 +#define IPOPT_SECUR_CONFID 0xf135 +#define IPOPT_SECUR_EFTO 0x789a +#define IPOPT_SECUR_MMMM 0xbc4d +#define IPOPT_SECUR_RESTR 0xaf13 +#define IPOPT_SECUR_SECRET 0xd788 +#define IPOPT_SECUR_TOPSECRET 0x6bc5 + +/* + * Internet implementation parameters. + */ +#define MAXTTL 255 /* maximum time to live (seconds) */ +#define IPDEFTTL 64 /* default ttl, from RFC 1340 */ +#define IPFRAGTTL 60 /* time to live for frags, slowhz */ +#define IPTTLDEC 1 /* subtracted when forwarding */ + +#define IP_MSS 576 /* default maximum segment size */ + +/* in print-ip.c */ +extern int nextproto4_cksum(const struct ip *, const u_int8_t *, u_int, u_int);
diff --git a/tcpdump-4.3.0/ip6.h b/tcpdump-4.3.0/ip6.h new file mode 100644 index 0000000..12c87ad --- /dev/null +++ b/tcpdump-4.3.0/ip6.h
@@ -0,0 +1,192 @@ +/* @(#) $Header: /tcpdump/master/tcpdump/ip6.h,v 1.8 2007-08-29 02:31:44 mcr Exp $ (LBL) */ +/* NetBSD: ip6.h,v 1.9 2000/07/13 05:34:21 itojun Exp */ +/* $KAME: ip6.h,v 1.9 2000/07/02 21:01:32 itojun Exp $ */ + +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)ip.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _NETINET_IP6_H_ +#define _NETINET_IP6_H_ + +/* + * Definition for internet protocol version 6. + * RFC 2460 + */ + +struct ip6_hdr { + union { + struct ip6_hdrctl { + u_int32_t ip6_un1_flow; /* 20 bits of flow-ID */ + u_int16_t ip6_un1_plen; /* payload length */ + u_int8_t ip6_un1_nxt; /* next header */ + u_int8_t ip6_un1_hlim; /* hop limit */ + } ip6_un1; + u_int8_t ip6_un2_vfc; /* 4 bits version, top 4 bits class */ + } ip6_ctlun; + struct in6_addr ip6_src; /* source address */ + struct in6_addr ip6_dst; /* destination address */ +} UNALIGNED; + +#define ip6_vfc ip6_ctlun.ip6_un2_vfc +#define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow +#define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen +#define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt +#define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim +#define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim + +/* in network endian */ +#define IPV6_FLOWINFO_MASK ((u_int32_t)htonl(0x0fffffff)) /* flow info (28 bits) */ +#define IPV6_FLOWLABEL_MASK ((u_int32_t)htonl(0x000fffff)) /* flow label (20 bits) */ +#if 1 +/* ECN bits proposed by Sally Floyd */ +#define IP6TOS_CE 0x01 /* congestion experienced */ +#define IP6TOS_ECT 0x02 /* ECN-capable transport */ +#endif + +/* + * Extension Headers + */ + +struct ip6_ext { + u_int8_t ip6e_nxt; + u_int8_t ip6e_len; +} UNALIGNED; + +/* Hop-by-Hop options header */ +struct ip6_hbh { + u_int8_t ip6h_nxt; /* next header */ + u_int8_t ip6h_len; /* length in units of 8 octets */ + /* followed by options */ +} UNALIGNED; + +/* Destination options header */ +struct ip6_dest { + u_int8_t ip6d_nxt; /* next header */ + u_int8_t ip6d_len; /* length in units of 8 octets */ + /* followed by options */ +} UNALIGNED; + +/* Option types and related macros */ +#define IP6OPT_PAD1 0x00 /* 00 0 00000 */ +#define IP6OPT_PADN 0x01 /* 00 0 00001 */ +#define IP6OPT_JUMBO 0xC2 /* 11 0 00010 = 194 */ +#define IP6OPT_JUMBO_LEN 6 +#define IP6OPT_ROUTER_ALERT 0x05 /* 00 0 00101 */ + +#define IP6OPT_RTALERT_LEN 4 +#define IP6OPT_RTALERT_MLD 0 /* Datagram contains an MLD message */ +#define IP6OPT_RTALERT_RSVP 1 /* Datagram contains an RSVP message */ +#define IP6OPT_RTALERT_ACTNET 2 /* contains an Active Networks msg */ +#define IP6OPT_MINLEN 2 + +#define IP6OPT_BINDING_UPDATE 0xc6 /* 11 0 00110 */ +#define IP6OPT_BINDING_ACK 0x07 /* 00 0 00111 */ +#define IP6OPT_BINDING_REQ 0x08 /* 00 0 01000 */ +#define IP6OPT_HOME_ADDRESS 0xc9 /* 11 0 01001 */ +#define IP6OPT_EID 0x8a /* 10 0 01010 */ + +#define IP6OPT_TYPE(o) ((o) & 0xC0) +#define IP6OPT_TYPE_SKIP 0x00 +#define IP6OPT_TYPE_DISCARD 0x40 +#define IP6OPT_TYPE_FORCEICMP 0x80 +#define IP6OPT_TYPE_ICMP 0xC0 + +#define IP6OPT_MUTABLE 0x20 + +/* Routing header */ +struct ip6_rthdr { + u_int8_t ip6r_nxt; /* next header */ + u_int8_t ip6r_len; /* length in units of 8 octets */ + u_int8_t ip6r_type; /* routing type */ + u_int8_t ip6r_segleft; /* segments left */ + /* followed by routing type specific data */ +} UNALIGNED; + +/* Type 0 Routing header */ +struct ip6_rthdr0 { + u_int8_t ip6r0_nxt; /* next header */ + u_int8_t ip6r0_len; /* length in units of 8 octets */ + u_int8_t ip6r0_type; /* always zero */ + u_int8_t ip6r0_segleft; /* segments left */ + u_int8_t ip6r0_reserved; /* reserved field */ + u_int8_t ip6r0_slmap[3]; /* strict/loose bit map */ + struct in6_addr ip6r0_addr[1]; /* up to 23 addresses */ +} UNALIGNED; + +/* Fragment header */ +struct ip6_frag { + u_int8_t ip6f_nxt; /* next header */ + u_int8_t ip6f_reserved; /* reserved field */ + u_int16_t ip6f_offlg; /* offset, reserved, and flag */ + u_int32_t ip6f_ident; /* identification */ +} UNALIGNED; + +#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 */ + +/* in print-ip6.c */ +extern int nextproto6_cksum(const struct ip6_hdr *, const u_int8_t *, u_int, u_int); + +#endif /* not _NETINET_IP6_H_ */
diff --git a/tcpdump-4.3.0/ipfc.h b/tcpdump-4.3.0/ipfc.h new file mode 100644 index 0000000..438d115 --- /dev/null +++ b/tcpdump-4.3.0/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/tcpdump-4.3.0/ipnet.h b/tcpdump-4.3.0/ipnet.h new file mode 100644 index 0000000..ae69284 --- /dev/null +++ b/tcpdump-4.3.0/ipnet.h
@@ -0,0 +1,13 @@ +typedef struct ipnet_hdr { + uint8_t iph_version; + uint8_t iph_family; + uint16_t iph_htype; + uint32_t iph_pktlen; + uint32_t iph_ifindex; + uint32_t iph_grifindex; + uint32_t iph_zsrc; + uint32_t iph_zdst; +} ipnet_hdr_t; + +#define IPH_AF_INET 2 /* Matches Solaris's AF_INET */ +#define IPH_AF_INET6 26 /* Matches Solaris's AF_INET6 */
diff --git a/tcpdump-4.3.0/ipproto.c b/tcpdump-4.3.0/ipproto.c new file mode 100755 index 0000000..cbb9bf3 --- /dev/null +++ b/tcpdump-4.3.0/ipproto.c
@@ -0,0 +1,61 @@ +/* + * 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/ipproto.c,v 1.6 2005-09-20 06:01:22 guy Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include "interface.h" +#include "ipproto.h" + +const struct tok ipproto_values[] = { + { IPPROTO_HOPOPTS, "Options" }, + { IPPROTO_ICMP, "ICMP" }, + { IPPROTO_IGMP, "IGMP" }, + { IPPROTO_IPV4, "IPIP" }, + { IPPROTO_TCP, "TCP" }, + { IPPROTO_EGP, "EGP" }, + { IPPROTO_PIGP, "IGRP" }, + { IPPROTO_UDP, "UDP" }, + { IPPROTO_DCCP, "DCCP" }, + { IPPROTO_IPV6, "IPv6" }, + { IPPROTO_ROUTING, "Routing" }, + { IPPROTO_FRAGMENT, "Fragment" }, + { IPPROTO_RSVP, "RSVP" }, + { IPPROTO_GRE, "GRE" }, + { IPPROTO_ESP, "ESP" }, + { IPPROTO_AH, "AH" }, + { IPPROTO_MOBILE, "Mobile IP" }, + { IPPROTO_ICMPV6, "ICMPv6" }, + { IPPROTO_MOBILITY_OLD, "Mobile IP (old)" }, + { IPPROTO_EIGRP, "EIGRP" }, + { IPPROTO_OSPF, "OSPF" }, + { IPPROTO_PIM, "PIM" }, + { IPPROTO_IPCOMP, "Compressed IP" }, + { IPPROTO_VRRP, "VRRP" }, + { IPPROTO_PGM, "PGM" }, + { IPPROTO_SCTP, "SCTP" }, + { IPPROTO_MOBILITY, "Mobility" }, + { IPPROTO_CARP, "CARP" }, + { 0, NULL } +}; +
diff --git a/tcpdump-4.3.0/ipproto.h b/tcpdump-4.3.0/ipproto.h new file mode 100644 index 0000000..c9801a6 --- /dev/null +++ b/tcpdump-4.3.0/ipproto.h
@@ -0,0 +1,147 @@ +/* + * 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.6 2005-09-20 06:01:22 guy Exp $ (LBL) + * + * From: + * @(#)in.h 8.3 (Berkeley) 1/3/94 + * $FreeBSD: src/sys/netinet/in.h,v 1.38.2.3 1999/08/29 16:29:34 peter Exp $ + */ + +extern const struct tok ipproto_values[]; + +#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_PIGP +#define IPPROTO_PIGP 9 +#endif +#ifndef IPPROTO_UDP +#define IPPROTO_UDP 17 /* user datagram protocol */ +#endif +#ifndef IPPROTO_DCCP +#define IPPROTO_DCCP 33 /* datagram congestion control 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_EIGRP +#define IPPROTO_EIGRP 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_CARP +#define IPPROTO_CARP 112 +#endif +#ifndef IPPROTO_PGM +#define IPPROTO_PGM 113 +#endif +#ifndef IPPROTO_SCTP +#define IPPROTO_SCTP 132 +#endif +#ifndef IPPROTO_MOBILITY +#define IPPROTO_MOBILITY 135 +#endif
diff --git a/tcpdump-4.3.0/ipsec_doi.h b/tcpdump-4.3.0/ipsec_doi.h new file mode 100644 index 0000000..554a258 --- /dev/null +++ b/tcpdump-4.3.0/ipsec_doi.h
@@ -0,0 +1,151 @@ +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +/* YIPS @(#)$Id: ipsec_doi.h,v 1.7 2002-12-11 07:13:53 guy Exp $ */ + +/* refer to RFC 2407 */ + +#if !defined(_IPSEC_DOI_H_) +#define _IPSEC_DOI_H_ + +#define IPSEC_DOI 1 + +/* 4.2 IPSEC Situation Definition */ +#define IPSECDOI_SIT_IDENTITY_ONLY 0x00000001 +#define IPSECDOI_SIT_SECRECY 0x00000002 +#define IPSECDOI_SIT_INTEGRITY 0x00000004 + +/* 4.4.1 IPSEC Security Protocol Identifiers */ + /* 4.4.2 IPSEC ISAKMP Transform Values */ +#define IPSECDOI_PROTO_ISAKMP 1 +#define IPSECDOI_KEY_IKE 1 + +/* 4.4.1 IPSEC Security Protocol Identifiers */ +#define IPSECDOI_PROTO_IPSEC_AH 2 + /* 4.4.3 IPSEC AH Transform Values */ +#define IPSECDOI_AH_MD5 2 +#define IPSECDOI_AH_SHA 3 +#define IPSECDOI_AH_DES 4 +#define IPSECDOI_AH_SHA2_256 5 +#define IPSECDOI_AH_SHA2_384 6 +#define IPSECDOI_AH_SHA2_512 7 + +/* 4.4.1 IPSEC Security Protocol Identifiers */ +#define IPSECDOI_PROTO_IPSEC_ESP 3 + /* 4.4.4 IPSEC ESP Transform Identifiers */ +#define IPSECDOI_ESP_DES_IV64 1 +#define IPSECDOI_ESP_DES 2 +#define IPSECDOI_ESP_3DES 3 +#define IPSECDOI_ESP_RC5 4 +#define IPSECDOI_ESP_IDEA 5 +#define IPSECDOI_ESP_CAST 6 +#define IPSECDOI_ESP_BLOWFISH 7 +#define IPSECDOI_ESP_3IDEA 8 +#define IPSECDOI_ESP_DES_IV32 9 +#define IPSECDOI_ESP_RC4 10 +#define IPSECDOI_ESP_NULL 11 +#define IPSECDOI_ESP_RIJNDAEL 12 +#define IPSECDOI_ESP_AES 12 + +/* 4.4.1 IPSEC Security Protocol Identifiers */ +#define IPSECDOI_PROTO_IPCOMP 4 + /* 4.4.5 IPSEC IPCOMP Transform Identifiers */ +#define IPSECDOI_IPCOMP_OUI 1 +#define IPSECDOI_IPCOMP_DEFLATE 2 +#define IPSECDOI_IPCOMP_LZS 3 + +/* 4.5 IPSEC Security Association Attributes */ +#define IPSECDOI_ATTR_SA_LTYPE 1 /* B */ +#define IPSECDOI_ATTR_SA_LTYPE_DEFAULT 1 +#define IPSECDOI_ATTR_SA_LTYPE_SEC 1 +#define IPSECDOI_ATTR_SA_LTYPE_KB 2 +#define IPSECDOI_ATTR_SA_LDUR 2 /* V */ +#define IPSECDOI_ATTR_SA_LDUR_DEFAULT 28800 /* 8 hours */ +#define IPSECDOI_ATTR_GRP_DESC 3 /* B */ +#define IPSECDOI_ATTR_ENC_MODE 4 /* B */ + /* default value: host dependent */ +#define IPSECDOI_ATTR_ENC_MODE_TUNNEL 1 +#define IPSECDOI_ATTR_ENC_MODE_TRNS 2 +#define IPSECDOI_ATTR_AUTH 5 /* B */ + /* 0 means not to use authentication. */ +#define IPSECDOI_ATTR_AUTH_HMAC_MD5 1 +#define IPSECDOI_ATTR_AUTH_HMAC_SHA1 2 +#define IPSECDOI_ATTR_AUTH_DES_MAC 3 +#define IPSECDOI_ATTR_AUTH_KPDK 4 /*RFC-1826(Key/Pad/Data/Key)*/ + /* + * When negotiating ESP without authentication, the Auth + * Algorithm attribute MUST NOT be included in the proposal. + * When negotiating ESP without confidentiality, the Auth + * Algorithm attribute MUST be included in the proposal and + * the ESP transform ID must be ESP_NULL. + */ +#define IPSECDOI_ATTR_KEY_LENGTH 6 /* B */ +#define IPSECDOI_ATTR_KEY_ROUNDS 7 /* B */ +#define IPSECDOI_ATTR_COMP_DICT_SIZE 8 /* B */ +#define IPSECDOI_ATTR_COMP_PRIVALG 9 /* V */ + +/* 4.6.1 Security Association Payload */ +struct ipsecdoi_sa { + struct isakmp_gen h; + u_int32_t doi; /* Domain of Interpretation */ + u_int32_t sit; /* Situation */ +}; + +struct ipsecdoi_secrecy_h { + u_int16_t len; + u_int16_t reserved; +}; + +/* 4.6.2.1 Identification Type Values */ +struct ipsecdoi_id { + struct isakmp_gen h; + u_int8_t type; /* ID Type */ + u_int8_t proto_id; /* Protocol ID */ + u_int16_t port; /* Port */ + /* Identification Data */ +}; + +#define IPSECDOI_ID_IPV4_ADDR 1 +#define IPSECDOI_ID_FQDN 2 +#define IPSECDOI_ID_USER_FQDN 3 +#define IPSECDOI_ID_IPV4_ADDR_SUBNET 4 +#define IPSECDOI_ID_IPV6_ADDR 5 +#define IPSECDOI_ID_IPV6_ADDR_SUBNET 6 +#define IPSECDOI_ID_IPV4_ADDR_RANGE 7 +#define IPSECDOI_ID_IPV6_ADDR_RANGE 8 +#define IPSECDOI_ID_DER_ASN1_DN 9 +#define IPSECDOI_ID_DER_ASN1_GN 10 +#define IPSECDOI_ID_KEY_ID 11 + +/* 4.6.3 IPSEC DOI Notify Message Types */ +/* Notify Messages - Status Types */ +#define IPSECDOI_NTYPE_RESPONDER_LIFETIME 24576 +#define IPSECDOI_NTYPE_REPLAY_STATUS 24577 +#define IPSECDOI_NTYPE_INITIAL_CONTACT 24578 + +#endif /* !defined(_IPSEC_DOI_H_) */
diff --git a/tcpdump-4.3.0/ipx.h b/tcpdump-4.3.0/ipx.h new file mode 100644 index 0000000..bfc3019 --- /dev/null +++ b/tcpdump-4.3.0/ipx.h
@@ -0,0 +1,31 @@ +/* + * IPX protocol formats + * + * @(#) $Header: /tcpdump/master/tcpdump/ipx.h,v 1.8 2002-12-11 07:13:54 guy Exp $ + */ + +/* well-known sockets */ +#define IPX_SKT_NCP 0x0451 +#define IPX_SKT_SAP 0x0452 +#define IPX_SKT_RIP 0x0453 +#define IPX_SKT_NETBIOS 0x0455 +#define IPX_SKT_DIAGNOSTICS 0x0456 +#define IPX_SKT_NWLINK_DGM 0x0553 /* NWLink datagram, may contain SMB */ +#define IPX_SKT_EIGRP 0x85be /* Cisco EIGRP over IPX */ + +/* IPX transport header */ +struct ipxHdr { + u_int16_t cksum; /* Checksum */ + u_int16_t length; /* Length, in bytes, including header */ + u_int8_t tCtl; /* Transport Control (i.e. hop count) */ + u_int8_t pType; /* Packet Type (i.e. level 2 protocol) */ + u_int16_t dstNet[2]; /* destination net */ + u_int8_t dstNode[6]; /* destination node */ + u_int16_t dstSkt; /* destination socket */ + u_int16_t srcNet[2]; /* source net */ + u_int8_t srcNode[6]; /* source node */ + u_int16_t srcSkt; /* source socket */ +}; + +#define ipxSize 30 +
diff --git a/tcpdump-4.3.0/isakmp.h b/tcpdump-4.3.0/isakmp.h new file mode 100644 index 0000000..d628f7a --- /dev/null +++ b/tcpdump-4.3.0/isakmp.h
@@ -0,0 +1,501 @@ +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +/* YIPS @(#)$Id: isakmp.h,v 1.12 2007-11-24 18:13:33 mcr Exp $ */ + +/* refer to RFC 2408 */ + +/* must include <netinet/in.h> */ + +#if !defined(_ISAKMP_H_) +#define _ISAKMP_H_ + +typedef u_char cookie_t[8]; +typedef u_char msgid_t[4]; + +typedef struct { /* i_cookie + r_cookie */ + cookie_t i_ck; + cookie_t r_ck; +} isakmp_index; + +#define INITIATOR 1 +#define RESPONDER 2 + +#define PORT_ISAKMP 500 + +#define GENERATE 1 +#define VALIDATE 0 + +/* Phase of oakley definition */ +/* + 0000 0000 0000 0000 + | |||| |||| + | |||| ++++--> negosiation number in phase + | ++++-------> phase number + +---------------> expire ? + */ +#define ISAKMP_PH1 0x0010 +#define ISAKMP_PH2 0x0020 +#define ISAKMP_EXPIRED 0x0100 + +#define ISAKMP_NGP_0 0x0000 +#define ISAKMP_NGP_1 0x0001 +#define ISAKMP_NGP_2 0x0002 +#define ISAKMP_NGP_3 0x0003 +#define ISAKMP_NGP_4 0x0004 + +#define ISAKMP_PH1_N (ISAKMP_PH1 | ISAKMP_NGP_0) /* i.e. spawn */ +#define ISAKMP_PH1_1 (ISAKMP_PH1 | ISAKMP_NGP_1) +#define ISAKMP_PH1_2 (ISAKMP_PH1 | ISAKMP_NGP_2) +#define ISAKMP_PH1_3 (ISAKMP_PH1 | ISAKMP_NGP_3) +#define ISAKMP_PH2_N (ISAKMP_PH2 | ISAKMP_NGP_0) +#define ISAKMP_PH2_1 (ISAKMP_PH2 | ISAKMP_NGP_1) +#define ISAKMP_PH2_2 (ISAKMP_PH2 | ISAKMP_NGP_2) +#define ISAKMP_PH2_3 (ISAKMP_PH2 | ISAKMP_NGP_3) + +#define ISAKMP_TIMER_DEFAULT 10 /* seconds */ +#define ISAKMP_TRY_DEFAULT 3 /* times */ + +/* 3.1 ISAKMP Header Format (IKEv1 and IKEv2) + 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 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + ! Initiator ! + ! Cookie ! + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + ! Responder ! + ! Cookie ! + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + ! Next Payload ! MjVer ! MnVer ! Exchange Type ! Flags ! + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + ! Message ID ! + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + ! Length ! + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +*/ +struct isakmp { + cookie_t i_ck; /* Initiator Cookie */ + cookie_t r_ck; /* Responder Cookie */ + u_int8_t np; /* Next Payload Type */ + u_int8_t vers; +#define ISAKMP_VERS_MAJOR 0xf0 +#define ISAKMP_VERS_MAJOR_SHIFT 4 +#define ISAKMP_VERS_MINOR 0x0f +#define ISAKMP_VERS_MINOR_SHIFT 0 + u_int8_t etype; /* Exchange Type */ + u_int8_t flags; /* Flags */ + msgid_t msgid; + u_int32_t len; /* Length */ +}; + +/* Next Payload Type */ +#define ISAKMP_NPTYPE_NONE 0 /* NONE*/ +#define ISAKMP_NPTYPE_SA 1 /* Security Association */ +#define ISAKMP_NPTYPE_P 2 /* Proposal */ +#define ISAKMP_NPTYPE_T 3 /* Transform */ +#define ISAKMP_NPTYPE_KE 4 /* Key Exchange */ +#define ISAKMP_NPTYPE_ID 5 /* Identification */ +#define ISAKMP_NPTYPE_CERT 6 /* Certificate */ +#define ISAKMP_NPTYPE_CR 7 /* Certificate Request */ +#define ISAKMP_NPTYPE_HASH 8 /* Hash */ +#define ISAKMP_NPTYPE_SIG 9 /* Signature */ +#define ISAKMP_NPTYPE_NONCE 10 /* Nonce */ +#define ISAKMP_NPTYPE_N 11 /* Notification */ +#define ISAKMP_NPTYPE_D 12 /* Delete */ +#define ISAKMP_NPTYPE_VID 13 /* Vendor ID */ +#define ISAKMP_NPTYPE_v2E 46 /* v2 Encrypted payload */ + +#define IKEv1_MAJOR_VERSION 1 +#define IKEv1_MINOR_VERSION 0 + +#define IKEv2_MAJOR_VERSION 2 +#define IKEv2_MINOR_VERSION 0 + +/* Exchange Type */ +#define ISAKMP_ETYPE_NONE 0 /* NONE */ +#define ISAKMP_ETYPE_BASE 1 /* Base */ +#define ISAKMP_ETYPE_IDENT 2 /* Identity Proteciton */ +#define ISAKMP_ETYPE_AUTH 3 /* Authentication Only */ +#define ISAKMP_ETYPE_AGG 4 /* Aggressive */ +#define ISAKMP_ETYPE_INF 5 /* Informational */ + +/* Flags */ +#define ISAKMP_FLAG_E 0x01 /* Encryption Bit */ +#define ISAKMP_FLAG_C 0x02 /* Commit Bit */ +#define ISAKMP_FLAG_extra 0x04 + +/* IKEv2 */ +#define ISAKMP_FLAG_I (1 << 3) /* (I)nitiator */ +#define ISAKMP_FLAG_V (1 << 4) /* (V)ersion */ +#define ISAKMP_FLAG_R (1 << 5) /* (R)esponse */ + + +/* 3.2 Payload Generic Header + 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 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + ! Next Payload ! RESERVED ! Payload Length ! + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +*/ +struct isakmp_gen { + u_int8_t np; /* Next Payload */ + u_int8_t critical; /* bit 7 - critical, rest is RESERVED */ + u_int16_t len; /* Payload Length */ +}; + +/* 3.3 Data Attributes + 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 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + !A! Attribute Type ! AF=0 Attribute Length ! + !F! ! AF=1 Attribute Value ! + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + . AF=0 Attribute Value . + . AF=1 Not Transmitted . + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +*/ +struct isakmp_data { + u_int16_t type; /* defined by DOI-spec, and Attribute Format */ + u_int16_t lorv; /* if f equal 1, Attribute Length */ + /* if f equal 0, Attribute Value */ + /* if f equal 1, Attribute Value */ +}; +#define ISAKMP_GEN_TLV 0x0000 +#define ISAKMP_GEN_TV 0x8000 + /* mask for type of attribute format */ +#define ISAKMP_GEN_MASK 0x8000 + +/* 3.4 Security Association Payload */ + /* MAY NOT be used, because of being defined in ipsec-doi. */ + /* + If the current payload is the last in the message, + then the value of the next payload field will be 0. + This field MUST NOT contain the + values for the Proposal or Transform payloads as they are considered + part of the security association negotiation. For example, this + field would contain the value "10" (Nonce payload) in the first + message of a Base Exchange (see Section 4.4) and the value "0" in the + first message of an Identity Protect Exchange (see Section 4.5). + */ +struct ikev1_pl_sa { + struct isakmp_gen h; + u_int32_t doi; /* Domain of Interpretation */ + u_int32_t sit; /* Situation */ +}; + +/* 3.5 Proposal Payload */ + /* + The value of the next payload field MUST only contain the value "2" + or "0". If there are additional Proposal payloads in the message, + then this field will be 2. If the current Proposal payload is the + last within the security association proposal, then this field will + be 0. + */ +struct ikev1_pl_p { + struct isakmp_gen h; + u_int8_t p_no; /* Proposal # */ + u_int8_t prot_id; /* Protocol */ + u_int8_t spi_size; /* SPI Size */ + u_int8_t num_t; /* Number of Transforms */ + /* SPI */ +}; + +/* 3.6 Transform Payload */ + /* + The value of the next payload field MUST only contain the value "3" + or "0". If there are additional Transform payloads in the proposal, + then this field will be 3. If the current Transform payload is the + last within the proposal, then this field will be 0. + */ +struct ikev1_pl_t { + struct isakmp_gen h; + u_int8_t t_no; /* Transform # */ + u_int8_t t_id; /* Transform-Id */ + u_int16_t reserved; /* RESERVED2 */ + /* SA Attributes */ +}; + +/* 3.7 Key Exchange Payload */ +struct ikev1_pl_ke { + struct isakmp_gen h; + /* Key Exchange Data */ +}; + +/* 3.8 Identification Payload */ + /* MUST NOT to be used, because of being defined in ipsec-doi. */ +struct ikev1_pl_id { + struct isakmp_gen h; + union { + u_int8_t id_type; /* ID Type */ + u_int32_t doi_data; /* DOI Specific ID Data */ + } d; + /* Identification Data */ +}; + +/* 3.9 Certificate Payload */ +struct ikev1_pl_cert { + struct isakmp_gen h; + u_int8_t encode; /* Cert Encoding */ + char cert; /* Certificate Data */ + /* + This field indicates the type of + certificate or certificate-related information contained in the + Certificate Data field. + */ +}; + +/* Certificate Type */ +#define ISAKMP_CERT_NONE 0 +#define ISAKMP_CERT_PKCS 1 +#define ISAKMP_CERT_PGP 2 +#define ISAKMP_CERT_DNS 3 +#define ISAKMP_CERT_SIGN 4 +#define ISAKMP_CERT_KE 5 +#define ISAKMP_CERT_KT 6 +#define ISAKMP_CERT_CRL 7 +#define ISAKMP_CERT_ARL 8 +#define ISAKMP_CERT_SPKI 9 + +/* 3.10 Certificate Request Payload */ +struct ikev1_pl_cr { + struct isakmp_gen h; + u_int8_t num_cert; /* # Cert. Types */ + /* + Certificate Types (variable length) + -- Contains a list of the types of certificates requested, + sorted in order of preference. Each individual certificate + type is 1 octet. This field is NOT requiredo + */ + /* # Certificate Authorities (1 octet) */ + /* Certificate Authorities (variable length) */ +}; + +/* 3.11 Hash Payload */ + /* may not be used, because of having only data. */ +struct ikev1_pl_hash { + struct isakmp_gen h; + /* Hash Data */ +}; + +/* 3.12 Signature Payload */ + /* may not be used, because of having only data. */ +struct ikev1_pl_sig { + struct isakmp_gen h; + /* Signature Data */ +}; + +/* 3.13 Nonce Payload */ + /* may not be used, because of having only data. */ +struct ikev1_pl_nonce { + struct isakmp_gen h; + /* Nonce Data */ +}; + +/* 3.14 Notification Payload */ +struct ikev1_pl_n { + struct isakmp_gen h; + u_int32_t doi; /* Domain of Interpretation */ + u_int8_t prot_id; /* Protocol-ID */ + u_int8_t spi_size; /* SPI Size */ + u_int16_t type; /* Notify Message Type */ + /* SPI */ + /* Notification Data */ +}; + +/* 3.14.1 Notify Message Types */ +/* NOTIFY MESSAGES - ERROR TYPES */ +#define ISAKMP_NTYPE_INVALID_PAYLOAD_TYPE 1 +#define ISAKMP_NTYPE_DOI_NOT_SUPPORTED 2 +#define ISAKMP_NTYPE_SITUATION_NOT_SUPPORTED 3 +#define ISAKMP_NTYPE_INVALID_COOKIE 4 +#define ISAKMP_NTYPE_INVALID_MAJOR_VERSION 5 +#define ISAKMP_NTYPE_INVALID_MINOR_VERSION 6 +#define ISAKMP_NTYPE_INVALID_EXCHANGE_TYPE 7 +#define ISAKMP_NTYPE_INVALID_FLAGS 8 +#define ISAKMP_NTYPE_INVALID_MESSAGE_ID 9 +#define ISAKMP_NTYPE_INVALID_PROTOCOL_ID 10 +#define ISAKMP_NTYPE_INVALID_SPI 11 +#define ISAKMP_NTYPE_INVALID_TRANSFORM_ID 12 +#define ISAKMP_NTYPE_ATTRIBUTES_NOT_SUPPORTED 13 +#define ISAKMP_NTYPE_NO_PROPOSAL_CHOSEN 14 +#define ISAKMP_NTYPE_BAD_PROPOSAL_SYNTAX 15 +#define ISAKMP_NTYPE_PAYLOAD_MALFORMED 16 +#define ISAKMP_NTYPE_INVALID_KEY_INFORMATION 17 +#define ISAKMP_NTYPE_INVALID_ID_INFORMATION 18 +#define ISAKMP_NTYPE_INVALID_CERT_ENCODING 19 +#define ISAKMP_NTYPE_INVALID_CERTIFICATE 20 +#define ISAKMP_NTYPE_BAD_CERT_REQUEST_SYNTAX 21 +#define ISAKMP_NTYPE_INVALID_CERT_AUTHORITY 22 +#define ISAKMP_NTYPE_INVALID_HASH_INFORMATION 23 +#define ISAKMP_NTYPE_AUTHENTICATION_FAILED 24 +#define ISAKMP_NTYPE_INVALID_SIGNATURE 25 +#define ISAKMP_NTYPE_ADDRESS_NOTIFICATION 26 +/* NOTIFY MESSAGES - STATUS TYPES */ +#define ISAKMP_NTYPE_CONNECTED 16384 +/* using only to log */ +#define ISAKMP_LOG_RETRY_LIMIT_REACHED 65530 + +/* 3.15 Delete Payload */ +struct ikev1_pl_d { + struct isakmp_gen h; + u_int32_t doi; /* Domain of Interpretation */ + u_int8_t prot_id; /* Protocol-Id */ + u_int8_t spi_size; /* SPI Size */ + u_int16_t num_spi; /* # of SPIs */ + /* SPI(es) */ +}; + + +struct ikev1_ph1tab { + struct ikev1_ph1 *head; + struct ikev1_ph1 *tail; + int len; +}; + +struct isakmp_ph2tab { + struct ikev1_ph2 *head; + struct ikev1_ph2 *tail; + int len; +}; + +#define EXCHANGE_PROXY 1 +#define EXCHANGE_MYSELF 0 + +#define PFS_NEED 1 +#define PFS_NONEED 0 + +/* IKEv2 (RFC4306) */ + +/* 3.3 Security Association Payload -- generic header */ +/* 3.3.1. Proposal Substructure */ +struct ikev2_p { + struct isakmp_gen h; + u_int8_t p_no; /* Proposal # */ + u_int8_t prot_id; /* Protocol */ + u_int8_t spi_size; /* SPI Size */ + u_int8_t num_t; /* Number of Transforms */ +}; + +/* 3.3.2. Transform Substructure */ +struct ikev2_t { + struct isakmp_gen h; + u_int8_t t_type; /* Transform Type (ENCR,PRF,INTEG,etc.*/ + u_int8_t res2; /* reserved byte */ + u_int16_t t_id; /* Transform ID */ +}; + +enum ikev2_t_type { + IV2_T_ENCR = 1, + IV2_T_PRF = 2, + IV2_T_INTEG= 3, + IV2_T_DH = 4, + IV2_T_ESN = 5, +}; + +/* 3.4. Key Exchange Payload */ +struct ikev2_ke { + struct isakmp_gen h; + u_int16_t ke_group; + u_int16_t ke_res1; + /* KE data */ +}; + + +/* 3.5. Identification Payloads */ +enum ikev2_id_type { + ID_IPV4_ADDR=1, + ID_FQDN=2, + ID_RFC822_ADDR=3, + ID_IPV6_ADDR=5, + ID_DER_ASN1_DN=9, + ID_DER_ASN1_GN=10, + ID_KEY_ID=11, +}; +struct ikev2_id { + struct isakmp_gen h; + u_int8_t type; /* ID type */ + u_int8_t res1; + u_int16_t res2; + /* SPI */ + /* Notification Data */ +}; + +/* 3.10 Notification Payload */ +struct ikev2_n { + struct isakmp_gen h; + u_int8_t prot_id; /* Protocol-ID */ + u_int8_t spi_size; /* SPI Size */ + u_int16_t type; /* Notify Message Type */ +}; + +enum ikev2_n_type { + IV2_NOTIFY_UNSUPPORTED_CRITICAL_PAYLOAD = 1, + IV2_NOTIFY_INVALID_IKE_SPI = 4, + IV2_NOTIFY_INVALID_MAJOR_VERSION = 5, + IV2_NOTIFY_INVALID_SYNTAX = 7, + IV2_NOTIFY_INVALID_MESSAGE_ID = 9, + IV2_NOTIFY_INVALID_SPI =11, + IV2_NOTIFY_NO_PROPOSAL_CHOSEN =14, + IV2_NOTIFY_INVALID_KE_PAYLOAD =17, + IV2_NOTIFY_AUTHENTICATION_FAILED =24, + IV2_NOTIFY_SINGLE_PAIR_REQUIRED =34, + IV2_NOTIFY_NO_ADDITIONAL_SAS =35, + IV2_NOTIFY_INTERNAL_ADDRESS_FAILURE =36, + IV2_NOTIFY_FAILED_CP_REQUIRED =37, + IV2_NOTIFY_INVALID_SELECTORS =39, + IV2_NOTIFY_INITIAL_CONTACT =16384, + IV2_NOTIFY_SET_WINDOW_SIZE =16385, + IV2_NOTIFY_ADDITIONAL_TS_POSSIBLE =16386, + IV2_NOTIFY_IPCOMP_SUPPORTED =16387, + IV2_NOTIFY_NAT_DETECTION_SOURCE_IP =16388, + IV2_NOTIFY_NAT_DETECTION_DESTINATION_IP =16389, + IV2_NOTIFY_COOKIE =16390, + IV2_NOTIFY_USE_TRANSPORT_MODE =16391, + IV2_NOTIFY_HTTP_CERT_LOOKUP_SUPPORTED =16392, + IV2_NOTIFY_REKEY_SA =16393, + IV2_NOTIFY_ESP_TFC_PADDING_NOT_SUPPORTED =16394, + IV2_NOTIFY_NON_FIRST_FRAGMENTS_ALSO =16395 +}; + +struct notify_messages { + u_int16_t type; + char *msg; +}; + +/* 3.8 Notification Payload */ +struct ikev2_auth { + struct isakmp_gen h; + u_int8_t auth_method; /* Protocol-ID */ + u_int8_t reserved[3]; + /* authentication data */ +}; + +enum ikev2_auth_type { + IV2_RSA_SIG = 1, + IV2_SHARED = 2, + IV2_DSS_SIG = 3, +}; + +#endif /* !defined(_ISAKMP_H_) */
diff --git a/tcpdump-4.3.0/l2tp.h b/tcpdump-4.3.0/l2tp.h new file mode 100644 index 0000000..5be24b9 --- /dev/null +++ b/tcpdump-4.3.0/l2tp.h
@@ -0,0 +1,62 @@ +/* @(#) $Header: /tcpdump/master/tcpdump/l2tp.h,v 1.5 2001-11-05 10:03:27 guy Exp $ (LBL) */ +/* + * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * 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. + * + * L2TP support contributed by Motonori Shindo (mshindo@mshindo.net) + */ + + +#define L2TP_FLAG_TYPE 0x8000 /* Type (0=Data, 1=Control) */ +#define L2TP_FLAG_LENGTH 0x4000 /* Length */ +#define L2TP_FLAG_SEQUENCE 0x0800 /* Sequence */ +#define L2TP_FLAG_OFFSET 0x0200 /* Offset */ +#define L2TP_FLAG_PRIORITY 0x0100 /* Priority */ + +#define L2TP_VERSION_MASK 0x000f /* Version Mask */ +#define L2TP_VERSION_L2F 0x0001 /* L2F */ +#define L2TP_VERSION_L2TP 0x0002 /* L2TP */ + +#define L2TP_AVP_HDR_FLAG_MANDATORY 0x8000 /* Mandatory Flag */ +#define L2TP_AVP_HDR_FLAG_HIDDEN 0x4000 /* Hidden Flag */ +#define L2TP_AVP_HDR_LEN_MASK 0x03ff /* Length Mask */ + +#define L2TP_FRAMING_CAP_SYNC_MASK 0x00000001 /* Synchronous */ +#define L2TP_FRAMING_CAP_ASYNC_MASK 0x00000002 /* Asynchronous */ + +#define L2TP_FRAMING_TYPE_SYNC_MASK 0x00000001 /* Synchronous */ +#define L2TP_FRAMING_TYPE_ASYNC_MASK 0x00000002 /* Asynchronous */ + +#define L2TP_BEARER_CAP_DIGITAL_MASK 0x00000001 /* Digital */ +#define L2TP_BEARER_CAP_ANALOG_MASK 0x00000002 /* Analog */ + +#define L2TP_BEARER_TYPE_DIGITAL_MASK 0x00000001 /* Digital */ +#define L2TP_BEARER_TYPE_ANALOG_MASK 0x00000002 /* Analog */ + +/* Authen Type */ +#define L2TP_AUTHEN_TYPE_RESERVED 0x0000 /* Reserved */ +#define L2TP_AUTHEN_TYPE_TEXTUAL 0x0001 /* Textual username/password exchange */ +#define L2TP_AUTHEN_TYPE_CHAP 0x0002 /* PPP CHAP */ +#define L2TP_AUTHEN_TYPE_PAP 0x0003 /* PPP PAP */ +#define L2TP_AUTHEN_TYPE_NO_AUTH 0x0004 /* No Authentication */ +#define L2TP_AUTHEN_TYPE_MSCHAPv1 0x0005 /* MSCHAPv1 */ + +#define L2TP_PROXY_AUTH_ID_MASK 0x00ff + +
diff --git a/tcpdump-4.3.0/l2vpn.c b/tcpdump-4.3.0/l2vpn.c new file mode 100755 index 0000000..021e7f0 --- /dev/null +++ b/tcpdump-4.3.0/l2vpn.c
@@ -0,0 +1,58 @@ +/* + * 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/l2vpn.c,v 1.1 2004-06-15 09:42:40 hannes Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> +#include "interface.h" +#include "l2vpn.h" + +/* draft-ietf-pwe3-iana-allocation-04 */ +const struct tok l2vpn_encaps_values[] = { + { 0x00, "Reserved"}, + { 0x01, "Frame Relay"}, + { 0x02, "ATM AAL5 VCC transport"}, + { 0x03, "ATM transparent cell transport"}, + { 0x04, "Ethernet VLAN"}, + { 0x05, "Ethernet"}, + { 0x06, "Cisco-HDLC"}, + { 0x07, "PPP"}, + { 0x08, "SONET/SDH Circuit Emulation Service over MPLS"}, + { 0x09, "ATM n-to-one VCC cell transport"}, + { 0x0a, "ATM n-to-one VPC cell transport"}, + { 0x0b, "IP Layer2 Transport"}, + { 0x0c, "ATM one-to-one VCC Cell Mode"}, + { 0x0d, "ATM one-to-one VPC Cell Mode"}, + { 0x0e, "ATM AAL5 PDU VCC transport"}, + { 0x0f, "Frame-Relay Port mode"}, + { 0x10, "SONET/SDH Circuit Emulation over Packet"}, + { 0x11, "Structure-agnostic E1 over Packet"}, + { 0x12, "Structure-agnostic T1 (DS1) over Packet"}, + { 0x13, "Structure-agnostic E3 over Packet"}, + { 0x14, "Structure-agnostic T3 (DS3) over Packet"}, + { 0x15, "CESoPSN basic mode"}, + { 0x16, "TDMoIP basic mode"}, + { 0x17, "CESoPSN TDM with CAS"}, + { 0x18, "TDMoIP TDM with CAS"}, + { 0x40, "IP-interworking"}, + { 0, NULL} +};
diff --git a/tcpdump-4.3.0/l2vpn.h b/tcpdump-4.3.0/l2vpn.h new file mode 100755 index 0000000..871eca0 --- /dev/null +++ b/tcpdump-4.3.0/l2vpn.h
@@ -0,0 +1,17 @@ +/* @(#) $Header: /tcpdump/master/tcpdump/l2vpn.h,v 1.1 2004-06-15 09:42:41 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 const struct tok l2vpn_encaps_values[];
diff --git a/tcpdump-4.3.0/lane.h b/tcpdump-4.3.0/lane.h new file mode 100644 index 0000000..76cc020 --- /dev/null +++ b/tcpdump-4.3.0/lane.h
@@ -0,0 +1,41 @@ +/* + * Marko Kiiskila carnil@cs.tut.fi + * + * Tampere University of Technology - Telecommunications Laboratory + * + * Permission to use, copy, modify and distribute this + * software and its documentation is hereby granted, + * provided that both the copyright notice and this + * permission notice appear in all copies of the software, + * derivative works or modified versions, and any portions + * thereof, that both notices appear in supporting + * 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.7 2002-12-11 07:13:54 guy Exp $ */ + +#ifndef ETHER_ADDR_LEN +#define ETHER_ADDR_LEN 6 +#endif + +struct lecdatahdr_8023 { + u_int16_t le_header; + u_int8_t h_dest[ETHER_ADDR_LEN]; + u_int8_t h_source[ETHER_ADDR_LEN]; + u_int16_t h_type; +}; + +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/tcpdump-4.3.0/lbl/os-osf4.h b/tcpdump-4.3.0/lbl/os-osf4.h new file mode 100644 index 0000000..5682b7e --- /dev/null +++ b/tcpdump-4.3.0/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/tcpdump-4.3.0/lbl/os-solaris2.h b/tcpdump-4.3.0/lbl/os-solaris2.h new file mode 100644 index 0000000..5c01b87 --- /dev/null +++ b/tcpdump-4.3.0/lbl/os-solaris2.h
@@ -0,0 +1,30 @@ +/* + * 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-solaris2.h,v 1.19 2000-10-11 04:02:15 guy Exp $ (LBL) + */ + +/* Prototypes missing in SunOS 5 */ +#if defined(_STDIO_H) && defined(HAVE_SETLINEBUF) +int setlinebuf(FILE *); +#endif +char *strerror(int); +int snprintf(char *, size_t, const char *, ...); +int strcasecmp(const char *, const char *);
diff --git a/tcpdump-4.3.0/lbl/os-sunos4.h b/tcpdump-4.3.0/lbl/os-sunos4.h new file mode 100644 index 0000000..ab0a12c --- /dev/null +++ b/tcpdump-4.3.0/lbl/os-sunos4.h
@@ -0,0 +1,215 @@ +/* + * Copyright (c) 1989, 1990, 1993, 1994, 1995, 1996 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * @(#) $Header: /tcpdump/master/tcpdump/lbl/os-sunos4.h,v 1.32 1999-10-07 23:47:13 mcr Exp $ (LBL) + */ + +/* Prototypes missing in SunOS 4 */ +#ifdef FILE +int _filbuf(FILE *); +int _flsbuf(u_char, FILE *); +int fclose(FILE *); +int fflush(FILE *); +int fgetc(FILE *); +int fprintf(FILE *, const char *, ...); +int fputc(int, FILE *); +int fputs(const char *, FILE *); +u_int fread(void *, u_int, u_int, FILE *); +int fseek(FILE *, long, int); +u_int fwrite(const void *, u_int, u_int, FILE *); +int pclose(FILE *); +void rewind(FILE *); +void setbuf(FILE *, char *); +int setlinebuf(FILE *); +int ungetc(int, FILE *); +int vfprintf(FILE *, const char *, ...); +int vprintf(const char *, ...); +#endif + +#if __GNUC__ <= 1 +int read(int, char *, u_int); +int write(int, char *, u_int); +#endif + +long a64l(const char *); +#ifdef __STDC__ +struct sockaddr; +#endif +int accept(int, struct sockaddr *, int *); +int bind(int, struct sockaddr *, int); +int bcmp(const void *, const void *, u_int); +void bcopy(const void *, void *, u_int); +void bzero(void *, int); +int chroot(const char *); +int close(int); +void closelog(void); +int connect(int, struct sockaddr *, int); +char *crypt(const char *, const char *); +int daemon(int, int); +int fchmod(int, int); +int fchown(int, int, int); +void endgrent(void); +void endpwent(void); +void endservent(void); +#ifdef __STDC__ +struct ether_addr; +#endif +struct ether_addr *ether_aton(const char *); +int flock(int, int); +#ifdef __STDC__ +struct stat; +#endif +int fstat(int, struct stat *); +#ifdef __STDC__ +struct statfs; +#endif +int fstatfs(int, struct statfs *); +int fsync(int); +#ifdef __STDC__ +struct timeb; +#endif +int ftime(struct timeb *); +int ftruncate(int, off_t); +int getdtablesize(void); +long gethostid(void); +int gethostname(char *, int); +int getopt(int, char * const *, const char *); +int getpagesize(void); +char *getpass(char *); +int getpeername(int, struct sockaddr *, int *); +int getpriority(int, int); +#ifdef __STDC__ +struct rlimit; +#endif +int getrlimit(int, struct rlimit *); +int getsockname(int, struct sockaddr *, int *); +int getsockopt(int, int, int, char *, int *); +#ifdef __STDC__ +struct timeval; +struct timezone; +#endif +int gettimeofday(struct timeval *, struct timezone *); +char *getusershell(void); +char *getwd(char *); +int initgroups(const char *, int); +int ioctl(int, int, caddr_t); +int iruserok(u_long, int, char *, char *); +int isatty(int); +int killpg(int, int); +int listen(int, int); +#ifdef __STDC__ +struct utmp; +#endif +void login(struct utmp *); +int logout(const char *); +off_t lseek(int, off_t, int); +int lstat(const char *, struct stat *); +int mkstemp(char *); +char *mktemp(char *); +int munmap(caddr_t, int); +void openlog(const char *, int, int); +void perror(const char *); +int printf(const char *, ...); +int puts(const char *); +long random(void); +int readlink(const char *, char *, int); +#ifdef __STDC__ +struct iovec; +#endif +int readv(int, struct iovec *, int); +int recv(int, char *, u_int, int); +int recvfrom(int, char *, u_int, int, struct sockaddr *, int *); +int rename(const char *, const char *); +int rcmd(char **, u_short, char *, char *, char *, int *); +int rresvport(int *); +int send(int, char *, u_int, int); +int sendto(int, char *, u_int, int, struct sockaddr *, int); +int setenv(const char *, const char *, int); +int seteuid(int); +int setpriority(int, int, int); +int select(int, fd_set *, fd_set *, fd_set *, struct timeval *); +int setpgrp(int, int); +void setpwent(void); +int setrlimit(int, struct rlimit *); +void setservent(int); +int setsockopt(int, int, int, char *, int); +int shutdown(int, int); +int sigblock(int); +void (*signal (int, void (*) (int))) (int); +int sigpause(int); +int sigsetmask(int); +#ifdef __STDC__ +struct sigvec; +#endif +int sigvec(int, struct sigvec *, struct sigvec*); +int snprintf(char *, size_t, const char *, ...); +int socket(int, int, int); +int socketpair(int, int, int, int *); +int symlink(const char *, const char *); +void srandom(int); +int sscanf(char *, const char *, ...); +int stat(const char *, struct stat *); +int statfs(char *, struct statfs *); +char *strerror(int); +int strcasecmp(const char *, const char *); +#ifdef __STDC__ +struct tm; +#endif +int strftime(char *, int, char *, struct tm *); +int strncasecmp(const char *, const char *, int); +long strtol(const char *, char **, int); +void sync(void); +void syslog(int, const char *, ...); +int system(const char *); +long tell(int); +time_t time(time_t *); +char *timezone(int, int); +int tolower(int); +int toupper(int); +int truncate(char *, off_t); +void unsetenv(const char *); +int vfork(void); +int vsprintf(char *, const char *, ...); +int writev(int, struct iovec *, int); +#ifdef __STDC__ +struct rusage; +#endif +int utimes(const char *, struct timeval *); +#if __GNUC__ <= 1 +int wait(int *); +pid_t wait3(int *, int, struct rusage *); +#endif + +/* Ugly signal hacking */ +#ifdef SIG_ERR +#undef SIG_ERR +#define SIG_ERR (void (*)(int))-1 +#undef SIG_DFL +#define SIG_DFL (void (*)(int))0 +#undef SIG_IGN +#define SIG_IGN (void (*)(int))1 + +#ifdef KERNEL +#undef SIG_CATCH +#define SIG_CATCH (void (*)(int))2 +#endif +#undef SIG_HOLD +#define SIG_HOLD (void (*)(int))3 +#endif
diff --git a/tcpdump-4.3.0/lbl/os-ultrix4.h b/tcpdump-4.3.0/lbl/os-ultrix4.h new file mode 100644 index 0000000..347485e --- /dev/null +++ b/tcpdump-4.3.0/lbl/os-ultrix4.h
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 1990, 1993, 1994, 1995, 1996 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * @(#) $Header: /tcpdump/master/tcpdump/lbl/os-ultrix4.h,v 1.19 1999-10-07 23:47:13 mcr Exp $ (LBL) + */ + +/* Prototypes missing in Ultrix 4 */ +int bcmp(const char *, const char *, u_int); +void bcopy(const void *, void *, u_int); +void bzero(void *, u_int); +void endservent(void); +int getopt(int, char * const *, const char *); +#ifdef __STDC__ +struct timeval; +struct timezone; +#endif +int gettimeofday(struct timeval *, struct timezone *); +int ioctl(int, int, caddr_t); +int pfopen(char *, int); +int setlinebuf(FILE *); +int socket(int, int, int); +int strcasecmp(const char *, const char *);
diff --git a/tcpdump-4.3.0/llc.h b/tcpdump-4.3.0/llc.h new file mode 100644 index 0000000..faa7256 --- /dev/null +++ b/tcpdump-4.3.0/llc.h
@@ -0,0 +1,123 @@ +/* + * Copyright (c) 1993, 1994, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * 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/llc.h,v 1.23 2007-04-13 09:43:11 hannes Exp $ (LBL) + */ + +/* + * Definitions for information in the LLC header. + */ + +#define LLC_U_FMT 3 +#define LLC_GSAP 1 +#define LLC_IG 1 /* Individual / Group */ +#define LLC_S_FMT 1 + +#define LLC_U_POLL 0x10 +#define LLC_IS_POLL 0x0100 +#define LLC_XID_FI 0x81 + +#define LLC_U_CMD(u) ((u) & 0xef) +#define LLC_UI 0x03 +#define LLC_UA 0x63 +#define LLC_DISC 0x43 +#define LLC_DM 0x0f +#define LLC_SABME 0x6f +#define LLC_TEST 0xe3 +#define LLC_XID 0xaf +#define LLC_FRMR 0x87 + +#define LLC_S_CMD(is) (((is) >> 2) & 0x03) +#define LLC_RR 0x0001 +#define LLC_RNR 0x0005 +#define LLC_REJ 0x0009 + +#define LLC_IS_NR(is) (((is) >> 9) & 0x7f) +#define LLC_I_NS(is) (((is) >> 1) & 0x7f) + +#ifndef LLCSAP_NULL +#define LLCSAP_NULL 0x00 +#endif +#ifndef LLCSAP_GLOBAL +#define LLCSAP_GLOBAL 0xff +#endif +#ifndef LLCSAP_8021B_I +#define LLCSAP_8021B_I 0x02 +#endif +#ifndef LLCSAP_8021B_G +#define LLCSAP_8021B_G 0x03 +#endif +#ifndef LLCSAP_SNA +#define LLCSAP_SNA 0x04 +#endif +#ifndef LLCSAP_IP +#define LLCSAP_IP 0x06 +#endif +#ifndef LLCSAP_PROWAYNM +#define LLCSAP_PROWAYNM 0x0e +#endif +#ifndef LLCSAP_8021D +#define LLCSAP_8021D 0x42 +#endif +#ifndef LLCSAP_RS511 +#define LLCSAP_RS511 0x4e +#endif +#ifndef LLCSAP_ISO8208 +#define LLCSAP_ISO8208 0x7e +#endif +#ifndef LLCSAP_PROWAY +#define LLCSAP_PROWAY 0x8e +#endif +#ifndef LLCSAP_SNAP +#define LLCSAP_SNAP 0xaa +#endif +#ifndef LLCSAP_IPX +#define LLCSAP_IPX 0xe0 +#endif +#ifndef LLCSAP_NETBEUI +#define LLCSAP_NETBEUI 0xf0 +#endif +#ifndef LLCSAP_ISONS +#define LLCSAP_ISONS 0xfe +#endif + +/* + * PIDs for use with OUI_CISCO. + */ +#define PID_CISCO_CDP 0x2000 /* Cisco Discovery Protocol */ +#define PID_CISCO_VTP 0x2003 /* Cisco VLAN Trunk Protocol */ +#define PID_CISCO_DTP 0x2004 /* Cisco Dynamic Trunk Protocol */ +#define PID_CISCO_UDLD 0x0111 /* Unidirectional Link Detection */ +#define PID_CISCO_PVST 0x010b /* Per VLAN Spanning Tree+ and RPVST+ */ + +/* + * 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/tcpdump-4.3.0/machdep.c b/tcpdump-4.3.0/machdep.c new file mode 100644 index 0000000..2bcf317 --- /dev/null +++ b/tcpdump-4.3.0/machdep.c
@@ -0,0 +1,67 @@ +/* + * Copyright (c) 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/machdep.c,v 1.13 2003-12-15 03:53:21 guy Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +/* + * 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> + +#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) */ +#endif /* __osf__ */ + +#include "machdep.h" + +int +abort_on_misalignment(char *ebuf _U_, size_t ebufsiz _U_) +{ +#ifdef __osf__ + static int buf[2] = { SSIN_UACPROC, UAC_SIGBUS }; + + if (setsysinfo(SSI_NVPAIRS, (caddr_t)buf, 1, 0, 0) < 0) { + (void)snprintf(ebuf, ebufsiz, "setsysinfo: errno %d", errno); + return (-1); + } +#endif + return (0); +}
diff --git a/tcpdump-4.3.0/machdep.h b/tcpdump-4.3.0/machdep.h new file mode 100644 index 0000000..6328c82 --- /dev/null +++ b/tcpdump-4.3.0/machdep.h
@@ -0,0 +1,27 @@ +/* + * Copyright (c) 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/machdep.h,v 1.2 2000-01-17 06:24:24 itojun Exp $ (LBL) + */ +#ifndef tcpdump_machdep_h +#define tcpdump_machdep_h + +int abort_on_misalignment(char *, size_t); +#endif
diff --git a/tcpdump-4.3.0/makemib b/tcpdump-4.3.0/makemib new file mode 100755 index 0000000..b59e2f1 --- /dev/null +++ b/tcpdump-4.3.0/makemib
@@ -0,0 +1,249 @@ +#!/bin/sh +# +# Copyright (c) 1990, 1996 +# John Robert LoVerso. All rights reserved. +# SMIv2 parsing copyright (c) 1999 +# William C. Fenner. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notices, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notices, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# @(#) $Id: makemib,v 1.3 2001-09-17 22:16:52 fenner Exp $ (jlv) + +# +# This script will read either ASN.1-style MIB files or the ".defs" files +# created by the ISODE "mosy" program on such files. +# +# The output of this script is the "mib.h" file used by tcpdumps' ASN.1/SNMP +# decoding code. +# +# This script needs to be run by "gawk" (GNU awk). "nawk" will work, but +# dump will get a recursion error if you process LARGE mibs. While it would +# by farily easy to rewrite this not to use recursion (and also easy to +# eliminate use of gsub and functions to use classic "awk"), you have to +# order the structure declarations in defined-first order for the compiler +# not to barf; too bad tsort doesn't take arguments. +# + +cat << EOF +/* + * This file was generated by tcpdump/makemib on `date` + * You probably don't want to edit this by hand! + * + * struct mib somename = { desc, oid-octet, type, child-pointer, next-pointer +}; + */ + +EOF + +awk ' +BEGIN { + debug=0; + # for sanity, we prep the namespace with objects from RFC-1155 + # (we manually establish the root) + oid["iso"]=1 + oidadd("org", "iso", 3) + oidadd("dod", "org", 6) + oidadd("internet", "dod", 1) + oidadd("directory", "internet", 1) + oidadd("mgmt", "internet", 2) +#XXX oidadd("mib", "mgmt", 1) + oidadd("mib-2", "mgmt", 1) + oidadd("experimental", "internet", 3) + oidadd("private", "internet", 4) + oidadd("enterprises", "private", 1) + oidadd("ip", "mib-2", 4) + oidadd("transmission", "mib-2", 10) + + holddesc="none" +} + +# +# Read mosy "*.defs" file. mosy does all the parsing work; we just read +# its simple and straightforward output. It would not be too hard to make +# tcpdump directly read mosy output, but... +# +# Ignore these unless the current file is called something.defs; false +# positives are too common in DESCRIPTIONs. + +NF > 1 && index($2,".")>0 && FILENAME ~ /\.defs/ { + # currently ignore items of the form "{ iso.3.6.1 }" + if (split($2, p, ".") == 2) { + oidadd($1, p[1], p[2]) + } + next +} + +# +# Must be a MIB file +# Make it easier to parse - used to be done by sed +{ sub(/--\*.*\*--/, ""); sub(/--.*/, ""); gsub(/[{}]/, " & "); } + +# +# this next section is simple and naive, but does the job ok +# + +# foo OBJECT IDENTIFIER ::= { baz 17 } +# or +# foo OBJECT IDENTIFIER ::= +# { baz 17 } +$2$3$4 == "OBJECTIDENTIFIER::=" { + holddesc="none" + if (NF == 8) + oidadd($1, $6, $7) + if (NF == 4) + holddesc=$1 + next +} +$1 == "{" && holddesc != "none" && NF == 4 { + oidadd(holddesc, $2, $3) + holddesc="none" +} +# +# foo OBJECT IDENTIFIER +# ::= { bar 1 } +$2$3 == "OBJECTIDENTIFIER" && $1 != "SYNTAX" && NF == 3 { + holddesc=$1 +} +# +# foo +# OBJECT IDENTIFIER ::= { bar 1 } +# a couple of heuristics to exclude single words in e.g. long +# DESCRIPTION clauses +NF == 1 && $1 ~ "[a-z][a-z]*[A-Z]" && $1 !~ /[(){}.,]/ && holddesc == "none" { + holddesc=$1 +} +$1$2$3 == "OBJECTIDENTIFIER::=" && holddesc != "none" { + oidadd(holddesc, $5, $6) + holddesc="none" +} +# +# "normal" style +# foo OBJECT-TYPE ... +# ... +# ::= { baz 5 } +$2 == "MODULE-IDENTITY" || $2 == "MODULE-COMPLIANCE" || + $2 == "OBJECT-IDENTITY" || $2 == "OBJECT-TYPE" || + $2 == "OBJECT-GROUP" || + $2 == "NOTIFICATION-TYPE" || $2 == "NOTIFICATION-GROUP" { + holddesc=$1 +} +$1 == "::=" && holddesc != "none" && NF == 5 { + oidadd(holddesc, $3, $4) + holddesc="none" +} +# +# foo ::= { baz 17 } +$2$3 == "::={" { + oidadd($1,$4,$5) + holddesc="none" +} + + +# +# End of the road - output the data. +# + +END { + print "struct obj" + dump("iso") + print "*mibroot = &_iso_obj;" +} + +function inn(file) { + if (file == "" || file == "-") + return "" + return " in " file +} + +# +# add a new object to the tree +# +# new OBJECT IDENTIFIER ::= { parent value } +# + +function oidadd(new, parent, value) { + # Ignore 0.0 + if (parent == "0" && value == 0) + return + if (debug) + print "/* oidadd" inn(FILENAME) ":", new, "in", parent, "as", value, "line", $0, "*/" + # use safe C identifiers + gsub(/[-&\/]/,"",new) + gsub(/[-&\/]/,"",parent) + # check if parent missing + if (oid[parent] == "") { + printf "/* parse problem%s: no parent for %s.%s(%d) */\n", \ + inn(FILENAME), parent, new, value + return + } + # check if parent.value already exists + if (oid[new] > 0 && oid[new] != value) { + printf "/* parse problem%s: dup %s.%s(%d) != old (%d) */\n", \ + inn(FILENAME), parent, new, value, oid[new] + return + } + # check for new name for parent.value + if (child[parent] != "") { + for (sib = child[parent]; sib != ""; sib = sibling[sib]) + if (oid[sib] == value) { + if (new != sib) + printf "/* parse problem%s: new name" \ + " \"%s\"" \ + " for %s.%s(%d) ignored */\n", \ + inn(FILENAME), new, parent, \ + sib, value + return + } + } + + oid[new]=value + if (child[parent] == "") { + child[parent] = new + } else { + sibling[new] = child[parent] + child[parent] = new + } +} + +# +# old(?) routine to recurse down the tree (in postfix order for convenience) +# + +function dump(item, c, s) { +# newitem=sofar"."item"("oid[item]")" +# printf "/* %s c=%s s=%s */\n", newitem, child[item], sibling[item] + c="NULL" + if (child[item] != "") { + dump(child[item]) + c = "&_"child[item]"_obj" + } + s="NULL" + if (sibling[item] != "") { + dump(sibling[item]) + s = "&_"sibling[item]"_obj" + } + printf "_%s_obj = {\n\t\"%s\", %d, 0,\n\t%s, %s\n},\n", \ + item, item, oid[item], c, s +} +' $@ +exit 0
diff --git a/tcpdump-4.3.0/mib.h b/tcpdump-4.3.0/mib.h new file mode 100644 index 0000000..92c6c2c --- /dev/null +++ b/tcpdump-4.3.0/mib.h
@@ -0,0 +1,1460 @@ +/* + * This file was generated by tcpdump/makemib on Wed Sep 26 12:12:31 EDT 1990 + * You probably don't want to edit this by hand! + * + * struct mib somename = { desc, oid-octet, type, child-pointer, next-pointer +}; + */ + +/* parse problem: new name "mib" for mgmt.mib(1) ignored */ +/* parse problem: no parent for 0.nullSpecific(0) */ +struct obj +_proteon_obj = { + "proteon", 1, 0, + NULL, NULL +}, +_ibm_obj = { + "ibm", 2, 0, + NULL, &_proteon_obj +}, +_cmu_obj = { + "cmu", 3, 0, + NULL, &_ibm_obj +}, +_unix_obj = { + "unix", 4, 0, + NULL, &_cmu_obj +}, +_acc_obj = { + "acc", 5, 0, + NULL, &_unix_obj +}, +_twg_obj = { + "twg", 6, 0, + NULL, &_acc_obj +}, +_cayman_obj = { + "cayman", 7, 0, + NULL, &_twg_obj +}, +_nysernet_obj = { + "nysernet", 8, 0, + NULL, &_cayman_obj +}, +_cisco_obj = { + "cisco", 9, 0, + NULL, &_nysernet_obj +}, +_nsc_obj = { + "nsc", 10, 0, + NULL, &_cisco_obj +}, +_hp_obj = { + "hp", 11, 0, + NULL, &_nsc_obj +}, +_epilogue_obj = { + "epilogue", 12, 0, + NULL, &_hp_obj +}, +_utennessee_obj = { + "utennessee", 13, 0, + NULL, &_epilogue_obj +}, +_bbn_obj = { + "bbn", 14, 0, + NULL, &_utennessee_obj +}, +_xylogics_obj = { + "xylogics", 15, 0, + NULL, &_bbn_obj +}, +_unisys_obj = { + "unisys", 16, 0, + NULL, &_xylogics_obj +}, +_canstar_obj = { + "canstar", 17, 0, + NULL, &_unisys_obj +}, +_wellfleet_obj = { + "wellfleet", 18, 0, + NULL, &_canstar_obj +}, +_trw_obj = { + "trw", 19, 0, + NULL, &_wellfleet_obj +}, +_mit_obj = { + "mit", 20, 0, + NULL, &_trw_obj +}, +_eon_obj = { + "eon", 21, 0, + NULL, &_mit_obj +}, +_spartacus_obj = { + "spartacus", 22, 0, + NULL, &_eon_obj +}, +_excelan_obj = { + "excelan", 23, 0, + NULL, &_spartacus_obj +}, +_spider_obj = { + "spider", 24, 0, + NULL, &_excelan_obj +}, +_nsfnet_obj = { + "nsfnet", 25, 0, + NULL, &_spider_obj +}, +_sytek_obj = { + "sytek", 26, 0, + NULL, &_nsfnet_obj +}, +_intergraph_obj = { + "intergraph", 27, 0, + NULL, &_sytek_obj +}, +_interlan_obj = { + "interlan", 28, 0, + NULL, &_intergraph_obj +}, +_vitalink_obj = { + "vitalink", 29, 0, + NULL, &_interlan_obj +}, +_ulana_obj = { + "ulana", 30, 0, + NULL, &_vitalink_obj +}, +_nswc_obj = { + "nswc", 31, 0, + NULL, &_ulana_obj +}, +_santacruzoperation_obj = { + "santacruzoperation", 32, 0, + NULL, &_nswc_obj +}, +_xyplex_obj = { + "xyplex", 33, 0, + NULL, &_santacruzoperation_obj +}, +_cray_obj = { + "cray", 34, 0, + NULL, &_xyplex_obj +}, +_bellnorthernresearch_obj = { + "bellnorthernresearch", 35, 0, + NULL, &_cray_obj +}, +_dec_obj = { + "dec", 36, 0, + NULL, &_bellnorthernresearch_obj +}, +_touch_obj = { + "touch", 37, 0, + NULL, &_dec_obj +}, +_networkresearchcorp_obj = { + "networkresearchcorp", 38, 0, + NULL, &_touch_obj +}, +_baylor_obj = { + "baylor", 39, 0, + NULL, &_networkresearchcorp_obj +}, +_nmfeccllnl_obj = { + "nmfeccllnl", 40, 0, + NULL, &_baylor_obj +}, +_sri_obj = { + "sri", 41, 0, + NULL, &_nmfeccllnl_obj +}, +_sun_obj = { + "sun", 42, 0, + NULL, &_sri_obj +}, +_3com_obj = { + "3com", 43, 0, + NULL, &_sun_obj +}, +_cmc_obj = { + "cmc", 44, 0, + NULL, &_3com_obj +}, +_synoptics_obj = { + "synoptics", 45, 0, + NULL, &_cmc_obj +}, +_cheyenne_obj = { + "cheyenne", 46, 0, + NULL, &_synoptics_obj +}, +_prime_obj = { + "prime", 47, 0, + NULL, &_cheyenne_obj +}, +_mcnc_obj = { + "mcnc", 48, 0, + NULL, &_prime_obj +}, +_chipcom_obj = { + "chipcom", 49, 0, + NULL, &_mcnc_obj +}, +_opticaldatasystems_obj = { + "opticaldatasystems", 50, 0, + NULL, &_chipcom_obj +}, +_gated_obj = { + "gated", 51, 0, + NULL, &_opticaldatasystems_obj +}, +_cabletron_obj = { + "cabletron", 52, 0, + NULL, &_gated_obj +}, +_apollo_obj = { + "apollo", 53, 0, + NULL, &_cabletron_obj +}, +_desktalksystems_obj = { + "desktalksystems", 54, 0, + NULL, &_apollo_obj +}, +_ssds_obj = { + "ssds", 55, 0, + NULL, &_desktalksystems_obj +}, +_castlerock_obj = { + "castlerock", 56, 0, + NULL, &_ssds_obj +}, +_mips_obj = { + "mips", 57, 0, + NULL, &_castlerock_obj +}, +_tgv_obj = { + "tgv", 58, 0, + NULL, &_mips_obj +}, +_silicongraphics_obj = { + "silicongraphics", 59, 0, + NULL, &_tgv_obj +}, +_ubc_obj = { + "ubc", 60, 0, + NULL, &_silicongraphics_obj +}, +_merit_obj = { + "merit", 61, 0, + NULL, &_ubc_obj +}, +_fibercom_obj = { + "fibercom", 62, 0, + NULL, &_merit_obj +}, +_apple_obj = { + "apple", 63, 0, + NULL, &_fibercom_obj +}, +_gandalf_obj = { + "gandalf", 64, 0, + NULL, &_apple_obj +}, +_dartmouth_obj = { + "dartmouth", 65, 0, + NULL, &_gandalf_obj +}, +_davidsystems_obj = { + "davidsystems", 66, 0, + NULL, &_dartmouth_obj +}, +_reuter_obj = { + "reuter", 67, 0, + NULL, &_davidsystems_obj +}, +_cornell_obj = { + "cornell", 68, 0, + NULL, &_reuter_obj +}, +_tmac_obj = { + "tmac", 69, 0, + NULL, &_cornell_obj +}, +_locus_obj = { + "locus", 70, 0, + NULL, &_tmac_obj +}, +_nasa_obj = { + "nasa", 71, 0, + NULL, &_locus_obj +}, +_retix_obj = { + "retix", 72, 0, + NULL, &_nasa_obj +}, +_boeing_obj = { + "boeing", 73, 0, + NULL, &_retix_obj +}, +_att_obj = { + "att", 74, 0, + NULL, &_boeing_obj +}, +_ungermannbass_obj = { + "ungermannbass", 75, 0, + NULL, &_att_obj +}, +_digitalanalysis_obj = { + "digitalanalysis", 76, 0, + NULL, &_ungermannbass_obj +}, +_hplanman_obj = { + "hplanman", 77, 0, + NULL, &_digitalanalysis_obj +}, +_netlabs_obj = { + "netlabs", 78, 0, + NULL, &_hplanman_obj +}, +_icl_obj = { + "icl", 79, 0, + NULL, &_netlabs_obj +}, +_auspex_obj = { + "auspex", 80, 0, + NULL, &_icl_obj +}, +_lannet_obj = { + "lannet", 81, 0, + NULL, &_auspex_obj +}, +_ncd_obj = { + "ncd", 82, 0, + NULL, &_lannet_obj +}, +_raycom_obj = { + "raycom", 83, 0, + NULL, &_ncd_obj +}, +_pirellifocom_obj = { + "pirellifocom", 84, 0, + NULL, &_raycom_obj +}, +_datability_obj = { + "datability", 85, 0, + NULL, &_pirellifocom_obj +}, +_networkappltech_obj = { + "networkappltech", 86, 0, + NULL, &_datability_obj +}, +_link_obj = { + "link", 87, 0, + NULL, &_networkappltech_obj +}, +_nyu_obj = { + "nyu", 88, 0, + NULL, &_link_obj +}, +_rnd_obj = { + "rnd", 89, 0, + NULL, &_nyu_obj +}, +_intercon_obj = { + "intercon", 90, 0, + NULL, &_rnd_obj +}, +_learningtree_obj = { + "learningtree", 91, 0, + NULL, &_intercon_obj +}, +_webstercomputer_obj = { + "webstercomputer", 92, 0, + NULL, &_learningtree_obj +}, +_frontier_obj = { + "frontier", 93, 0, + NULL, &_webstercomputer_obj +}, +_nokia_obj = { + "nokia", 94, 0, + NULL, &_frontier_obj +}, +_allenbradley_obj = { + "allenbradley", 95, 0, + NULL, &_nokia_obj +}, +_cern_obj = { + "cern", 96, 0, + NULL, &_allenbradley_obj +}, +_sigma_obj = { + "sigma", 97, 0, + NULL, &_cern_obj +}, +_emergingtech_obj = { + "emergingtech", 98, 0, + NULL, &_sigma_obj +}, +_snmpresearch_obj = { + "snmpresearch", 99, 0, + NULL, &_emergingtech_obj +}, +_ohiostate_obj = { + "ohiostate", 100, 0, + NULL, &_snmpresearch_obj +}, +_ultra_obj = { + "ultra", 101, 0, + NULL, &_ohiostate_obj +}, +_ccur_obj = { + "ccur", 136, 0, + NULL, &_ultra_obj +}, +_enterprises_obj = { + "enterprises", 1, 0, + &_ccur_obj, NULL +}, +_snmpInPkts_obj = { + "snmpInPkts", 1, 0, + NULL, NULL +}, +_snmpOutPkts_obj = { + "snmpOutPkts", 2, 0, + NULL, &_snmpInPkts_obj +}, +_snmpInBadVersions_obj = { + "snmpInBadVersions", 3, 0, + NULL, &_snmpOutPkts_obj +}, +_snmpInBadCommunityNames_obj = { + "snmpInBadCommunityNames", 4, 0, + NULL, &_snmpInBadVersions_obj +}, +_snmpInBadCommunityUses_obj = { + "snmpInBadCommunityUses", 5, 0, + NULL, &_snmpInBadCommunityNames_obj +}, +_snmpInASNParseErrs_obj = { + "snmpInASNParseErrs", 6, 0, + NULL, &_snmpInBadCommunityUses_obj +}, +_snmpInBadTypes_obj = { + "snmpInBadTypes", 7, 0, + NULL, &_snmpInASNParseErrs_obj +}, +_snmpInTooBigs_obj = { + "snmpInTooBigs", 8, 0, + NULL, &_snmpInBadTypes_obj +}, +_snmpInNoSuchNames_obj = { + "snmpInNoSuchNames", 9, 0, + NULL, &_snmpInTooBigs_obj +}, +_snmpInBadValues_obj = { + "snmpInBadValues", 10, 0, + NULL, &_snmpInNoSuchNames_obj +}, +_snmpInReadOnlys_obj = { + "snmpInReadOnlys", 11, 0, + NULL, &_snmpInBadValues_obj +}, +_snmpInGenErrs_obj = { + "snmpInGenErrs", 12, 0, + NULL, &_snmpInReadOnlys_obj +}, +_snmpInTotalReqVars_obj = { + "snmpInTotalReqVars", 13, 0, + NULL, &_snmpInGenErrs_obj +}, +_snmpInTotalSetVars_obj = { + "snmpInTotalSetVars", 14, 0, + NULL, &_snmpInTotalReqVars_obj +}, +_snmpInGetRequests_obj = { + "snmpInGetRequests", 15, 0, + NULL, &_snmpInTotalSetVars_obj +}, +_snmpInGetNexts_obj = { + "snmpInGetNexts", 16, 0, + NULL, &_snmpInGetRequests_obj +}, +_snmpInSetRequests_obj = { + "snmpInSetRequests", 17, 0, + NULL, &_snmpInGetNexts_obj +}, +_snmpInGetResponses_obj = { + "snmpInGetResponses", 18, 0, + NULL, &_snmpInSetRequests_obj +}, +_snmpInTraps_obj = { + "snmpInTraps", 19, 0, + NULL, &_snmpInGetResponses_obj +}, +_snmpOutTooBigs_obj = { + "snmpOutTooBigs", 20, 0, + NULL, &_snmpInTraps_obj +}, +_snmpOutNoSuchNames_obj = { + "snmpOutNoSuchNames", 21, 0, + NULL, &_snmpOutTooBigs_obj +}, +_snmpOutBadValues_obj = { + "snmpOutBadValues", 22, 0, + NULL, &_snmpOutNoSuchNames_obj +}, +_snmpOutReadOnlys_obj = { + "snmpOutReadOnlys", 23, 0, + NULL, &_snmpOutBadValues_obj +}, +_snmpOutGenErrs_obj = { + "snmpOutGenErrs", 24, 0, + NULL, &_snmpOutReadOnlys_obj +}, +_snmpOutGetRequests_obj = { + "snmpOutGetRequests", 25, 0, + NULL, &_snmpOutGenErrs_obj +}, +_snmpOutGetNexts_obj = { + "snmpOutGetNexts", 26, 0, + NULL, &_snmpOutGetRequests_obj +}, +_snmpOutSetRequests_obj = { + "snmpOutSetRequests", 27, 0, + NULL, &_snmpOutGetNexts_obj +}, +_snmpOutGetResponses_obj = { + "snmpOutGetResponses", 28, 0, + NULL, &_snmpOutSetRequests_obj +}, +_snmpOutTraps_obj = { + "snmpOutTraps", 29, 0, + NULL, &_snmpOutGetResponses_obj +}, +_snmpEnableAuthTraps_obj = { + "snmpEnableAuthTraps", 30, 0, + NULL, &_snmpOutTraps_obj +}, +_egpNeighState_obj = { + "egpNeighState", 1, 0, + NULL, NULL +}, +_egpNeighAddr_obj = { + "egpNeighAddr", 2, 0, + NULL, &_egpNeighState_obj +}, +_egpNeighAs_obj = { + "egpNeighAs", 3, 0, + NULL, &_egpNeighAddr_obj +}, +_egpNeighInMsgs_obj = { + "egpNeighInMsgs", 4, 0, + NULL, &_egpNeighAs_obj +}, +_egpNeighInErrs_obj = { + "egpNeighInErrs", 5, 0, + NULL, &_egpNeighInMsgs_obj +}, +_egpNeighOutMsgs_obj = { + "egpNeighOutMsgs", 6, 0, + NULL, &_egpNeighInErrs_obj +}, +_egpNeighOutErrs_obj = { + "egpNeighOutErrs", 7, 0, + NULL, &_egpNeighOutMsgs_obj +}, +_egpNeighInErrMsgs_obj = { + "egpNeighInErrMsgs", 8, 0, + NULL, &_egpNeighOutErrs_obj +}, +_egpNeighOutErrMsgs_obj = { + "egpNeighOutErrMsgs", 9, 0, + NULL, &_egpNeighInErrMsgs_obj +}, +_egpNeighStateUps_obj = { + "egpNeighStateUps", 10, 0, + NULL, &_egpNeighOutErrMsgs_obj +}, +_egpNeighStateDowns_obj = { + "egpNeighStateDowns", 11, 0, + NULL, &_egpNeighStateUps_obj +}, +_egpNeighIntervalHello_obj = { + "egpNeighIntervalHello", 12, 0, + NULL, &_egpNeighStateDowns_obj +}, +_egpNeighIntervalPoll_obj = { + "egpNeighIntervalPoll", 13, 0, + NULL, &_egpNeighIntervalHello_obj +}, +_egpNeighMode_obj = { + "egpNeighMode", 14, 0, + NULL, &_egpNeighIntervalPoll_obj +}, +_egpNeighEventTrigger_obj = { + "egpNeighEventTrigger", 15, 0, + NULL, &_egpNeighMode_obj +}, +_egpNeighEntry_obj = { + "egpNeighEntry", 1, 0, + &_egpNeighEventTrigger_obj, NULL +}, +_egpInMsgs_obj = { + "egpInMsgs", 1, 0, + NULL, NULL +}, +_egpInErrors_obj = { + "egpInErrors", 2, 0, + NULL, &_egpInMsgs_obj +}, +_egpOutMsgs_obj = { + "egpOutMsgs", 3, 0, + NULL, &_egpInErrors_obj +}, +_egpOutErrors_obj = { + "egpOutErrors", 4, 0, + NULL, &_egpOutMsgs_obj +}, +_egpNeighTable_obj = { + "egpNeighTable", 5, 0, + &_egpNeighEntry_obj, &_egpOutErrors_obj +}, +_egpAs_obj = { + "egpAs", 6, 0, + NULL, &_egpNeighTable_obj +}, +_udpLocalAddress_obj = { + "udpLocalAddress", 1, 0, + NULL, NULL +}, +_udpLocalPort_obj = { + "udpLocalPort", 2, 0, + NULL, &_udpLocalAddress_obj +}, +_udpEntry_obj = { + "udpEntry", 1, 0, + &_udpLocalPort_obj, NULL +}, +_udpInDatagrams_obj = { + "udpInDatagrams", 1, 0, + NULL, NULL +}, +_udpNoPorts_obj = { + "udpNoPorts", 2, 0, + NULL, &_udpInDatagrams_obj +}, +_udpInErrors_obj = { + "udpInErrors", 3, 0, + NULL, &_udpNoPorts_obj +}, +_udpOutDatagrams_obj = { + "udpOutDatagrams", 4, 0, + NULL, &_udpInErrors_obj +}, +_udpTable_obj = { + "udpTable", 5, 0, + &_udpEntry_obj, &_udpOutDatagrams_obj +}, +_tcpConnState_obj = { + "tcpConnState", 1, 0, + NULL, NULL +}, +_tcpConnLocalAddress_obj = { + "tcpConnLocalAddress", 2, 0, + NULL, &_tcpConnState_obj +}, +_tcpConnLocalPort_obj = { + "tcpConnLocalPort", 3, 0, + NULL, &_tcpConnLocalAddress_obj +}, +_tcpConnRemAddress_obj = { + "tcpConnRemAddress", 4, 0, + NULL, &_tcpConnLocalPort_obj +}, +_tcpConnRemPort_obj = { + "tcpConnRemPort", 5, 0, + NULL, &_tcpConnRemAddress_obj +}, +_tcpConnEntry_obj = { + "tcpConnEntry", 1, 0, + &_tcpConnRemPort_obj, NULL +}, +_tcpRtoAlgorithm_obj = { + "tcpRtoAlgorithm", 1, 0, + NULL, NULL +}, +_tcpRtoMin_obj = { + "tcpRtoMin", 2, 0, + NULL, &_tcpRtoAlgorithm_obj +}, +_tcpRtoMax_obj = { + "tcpRtoMax", 3, 0, + NULL, &_tcpRtoMin_obj +}, +_tcpMaxConn_obj = { + "tcpMaxConn", 4, 0, + NULL, &_tcpRtoMax_obj +}, +_tcpActiveOpens_obj = { + "tcpActiveOpens", 5, 0, + NULL, &_tcpMaxConn_obj +}, +_tcpPassiveOpens_obj = { + "tcpPassiveOpens", 6, 0, + NULL, &_tcpActiveOpens_obj +}, +_tcpAttemptFails_obj = { + "tcpAttemptFails", 7, 0, + NULL, &_tcpPassiveOpens_obj +}, +_tcpEstabResets_obj = { + "tcpEstabResets", 8, 0, + NULL, &_tcpAttemptFails_obj +}, +_tcpCurrEstab_obj = { + "tcpCurrEstab", 9, 0, + NULL, &_tcpEstabResets_obj +}, +_tcpInSegs_obj = { + "tcpInSegs", 10, 0, + NULL, &_tcpCurrEstab_obj +}, +_tcpOutSegs_obj = { + "tcpOutSegs", 11, 0, + NULL, &_tcpInSegs_obj +}, +_tcpRetransSegs_obj = { + "tcpRetransSegs", 12, 0, + NULL, &_tcpOutSegs_obj +}, +_tcpConnTable_obj = { + "tcpConnTable", 13, 0, + &_tcpConnEntry_obj, &_tcpRetransSegs_obj +}, +_tcpInErrs_obj = { + "tcpInErrs", 14, 0, + NULL, &_tcpConnTable_obj +}, +_tcpOutRsts_obj = { + "tcpOutRsts", 15, 0, + NULL, &_tcpInErrs_obj +}, +_icmpInMsgs_obj = { + "icmpInMsgs", 1, 0, + NULL, NULL +}, +_icmpInErrors_obj = { + "icmpInErrors", 2, 0, + NULL, &_icmpInMsgs_obj +}, +_icmpInDestUnreachs_obj = { + "icmpInDestUnreachs", 3, 0, + NULL, &_icmpInErrors_obj +}, +_icmpInTimeExcds_obj = { + "icmpInTimeExcds", 4, 0, + NULL, &_icmpInDestUnreachs_obj +}, +_icmpInParmProbs_obj = { + "icmpInParmProbs", 5, 0, + NULL, &_icmpInTimeExcds_obj +}, +_icmpInSrcQuenchs_obj = { + "icmpInSrcQuenchs", 6, 0, + NULL, &_icmpInParmProbs_obj +}, +_icmpInRedirects_obj = { + "icmpInRedirects", 7, 0, + NULL, &_icmpInSrcQuenchs_obj +}, +_icmpInEchos_obj = { + "icmpInEchos", 8, 0, + NULL, &_icmpInRedirects_obj +}, +_icmpInEchoReps_obj = { + "icmpInEchoReps", 9, 0, + NULL, &_icmpInEchos_obj +}, +_icmpInTimestamps_obj = { + "icmpInTimestamps", 10, 0, + NULL, &_icmpInEchoReps_obj +}, +_icmpInTimestampReps_obj = { + "icmpInTimestampReps", 11, 0, + NULL, &_icmpInTimestamps_obj +}, +_icmpInAddrMasks_obj = { + "icmpInAddrMasks", 12, 0, + NULL, &_icmpInTimestampReps_obj +}, +_icmpInAddrMaskReps_obj = { + "icmpInAddrMaskReps", 13, 0, + NULL, &_icmpInAddrMasks_obj +}, +_icmpOutMsgs_obj = { + "icmpOutMsgs", 14, 0, + NULL, &_icmpInAddrMaskReps_obj +}, +_icmpOutErrors_obj = { + "icmpOutErrors", 15, 0, + NULL, &_icmpOutMsgs_obj +}, +_icmpOutDestUnreachs_obj = { + "icmpOutDestUnreachs", 16, 0, + NULL, &_icmpOutErrors_obj +}, +_icmpOutTimeExcds_obj = { + "icmpOutTimeExcds", 17, 0, + NULL, &_icmpOutDestUnreachs_obj +}, +_icmpOutParmProbs_obj = { + "icmpOutParmProbs", 18, 0, + NULL, &_icmpOutTimeExcds_obj +}, +_icmpOutSrcQuenchs_obj = { + "icmpOutSrcQuenchs", 19, 0, + NULL, &_icmpOutParmProbs_obj +}, +_icmpOutRedirects_obj = { + "icmpOutRedirects", 20, 0, + NULL, &_icmpOutSrcQuenchs_obj +}, +_icmpOutEchos_obj = { + "icmpOutEchos", 21, 0, + NULL, &_icmpOutRedirects_obj +}, +_icmpOutEchoReps_obj = { + "icmpOutEchoReps", 22, 0, + NULL, &_icmpOutEchos_obj +}, +_icmpOutTimestamps_obj = { + "icmpOutTimestamps", 23, 0, + NULL, &_icmpOutEchoReps_obj +}, +_icmpOutTimestampReps_obj = { + "icmpOutTimestampReps", 24, 0, + NULL, &_icmpOutTimestamps_obj +}, +_icmpOutAddrMasks_obj = { + "icmpOutAddrMasks", 25, 0, + NULL, &_icmpOutTimestampReps_obj +}, +_icmpOutAddrMaskReps_obj = { + "icmpOutAddrMaskReps", 26, 0, + NULL, &_icmpOutAddrMasks_obj +}, +_ipNetToMediaIfIndex_obj = { + "ipNetToMediaIfIndex", 1, 0, + NULL, NULL +}, +_ipNetToMediaPhysAddress_obj = { + "ipNetToMediaPhysAddress", 2, 0, + NULL, &_ipNetToMediaIfIndex_obj +}, +_ipNetToMediaNetAddress_obj = { + "ipNetToMediaNetAddress", 3, 0, + NULL, &_ipNetToMediaPhysAddress_obj +}, +_ipNetToMediaType_obj = { + "ipNetToMediaType", 4, 0, + NULL, &_ipNetToMediaNetAddress_obj +}, +_ipNetToMediaEntry_obj = { + "ipNetToMediaEntry", 1, 0, + &_ipNetToMediaType_obj, NULL +}, +_ipRouteDest_obj = { + "ipRouteDest", 1, 0, + NULL, NULL +}, +_ipRouteIfIndex_obj = { + "ipRouteIfIndex", 2, 0, + NULL, &_ipRouteDest_obj +}, +_ipRouteMetric1_obj = { + "ipRouteMetric1", 3, 0, + NULL, &_ipRouteIfIndex_obj +}, +_ipRouteMetric2_obj = { + "ipRouteMetric2", 4, 0, + NULL, &_ipRouteMetric1_obj +}, +_ipRouteMetric3_obj = { + "ipRouteMetric3", 5, 0, + NULL, &_ipRouteMetric2_obj +}, +_ipRouteMetric4_obj = { + "ipRouteMetric4", 6, 0, + NULL, &_ipRouteMetric3_obj +}, +_ipRouteNextHop_obj = { + "ipRouteNextHop", 7, 0, + NULL, &_ipRouteMetric4_obj +}, +_ipRouteType_obj = { + "ipRouteType", 8, 0, + NULL, &_ipRouteNextHop_obj +}, +_ipRouteProto_obj = { + "ipRouteProto", 9, 0, + NULL, &_ipRouteType_obj +}, +_ipRouteAge_obj = { + "ipRouteAge", 10, 0, + NULL, &_ipRouteProto_obj +}, +_ipRouteMask_obj = { + "ipRouteMask", 11, 0, + NULL, &_ipRouteAge_obj +}, +_ipRouteEntry_obj = { + "ipRouteEntry", 1, 0, + &_ipRouteMask_obj, NULL +}, +_ipAdEntAddr_obj = { + "ipAdEntAddr", 1, 0, + NULL, NULL +}, +_ipAdEntIfIndex_obj = { + "ipAdEntIfIndex", 2, 0, + NULL, &_ipAdEntAddr_obj +}, +_ipAdEntNetMask_obj = { + "ipAdEntNetMask", 3, 0, + NULL, &_ipAdEntIfIndex_obj +}, +_ipAdEntBcastAddr_obj = { + "ipAdEntBcastAddr", 4, 0, + NULL, &_ipAdEntNetMask_obj +}, +_ipAdEntReasmMaxSize_obj = { + "ipAdEntReasmMaxSize", 5, 0, + NULL, &_ipAdEntBcastAddr_obj +}, +_ipAddrEntry_obj = { + "ipAddrEntry", 1, 0, + &_ipAdEntReasmMaxSize_obj, NULL +}, +_ipForwarding_obj = { + "ipForwarding", 1, 0, + NULL, NULL +}, +_ipDefaultTTL_obj = { + "ipDefaultTTL", 2, 0, + NULL, &_ipForwarding_obj +}, +_ipInReceives_obj = { + "ipInReceives", 3, 0, + NULL, &_ipDefaultTTL_obj +}, +_ipInHdrErrors_obj = { + "ipInHdrErrors", 4, 0, + NULL, &_ipInReceives_obj +}, +_ipInAddrErrors_obj = { + "ipInAddrErrors", 5, 0, + NULL, &_ipInHdrErrors_obj +}, +_ipForwDatagrams_obj = { + "ipForwDatagrams", 6, 0, + NULL, &_ipInAddrErrors_obj +}, +_ipInUnknownProtos_obj = { + "ipInUnknownProtos", 7, 0, + NULL, &_ipForwDatagrams_obj +}, +_ipInDiscards_obj = { + "ipInDiscards", 8, 0, + NULL, &_ipInUnknownProtos_obj +}, +_ipInDelivers_obj = { + "ipInDelivers", 9, 0, + NULL, &_ipInDiscards_obj +}, +_ipOutRequests_obj = { + "ipOutRequests", 10, 0, + NULL, &_ipInDelivers_obj +}, +_ipOutDiscards_obj = { + "ipOutDiscards", 11, 0, + NULL, &_ipOutRequests_obj +}, +_ipOutNoRoutes_obj = { + "ipOutNoRoutes", 12, 0, + NULL, &_ipOutDiscards_obj +}, +_ipReasmTimeout_obj = { + "ipReasmTimeout", 13, 0, + NULL, &_ipOutNoRoutes_obj +}, +_ipReasmReqds_obj = { + "ipReasmReqds", 14, 0, + NULL, &_ipReasmTimeout_obj +}, +_ipReasmOKs_obj = { + "ipReasmOKs", 15, 0, + NULL, &_ipReasmReqds_obj +}, +_ipReasmFails_obj = { + "ipReasmFails", 16, 0, + NULL, &_ipReasmOKs_obj +}, +_ipFragOKs_obj = { + "ipFragOKs", 17, 0, + NULL, &_ipReasmFails_obj +}, +_ipFragFails_obj = { + "ipFragFails", 18, 0, + NULL, &_ipFragOKs_obj +}, +_ipFragCreates_obj = { + "ipFragCreates", 19, 0, + NULL, &_ipFragFails_obj +}, +_ipAddrTable_obj = { + "ipAddrTable", 20, 0, + &_ipAddrEntry_obj, &_ipFragCreates_obj +}, +_ipRoutingTable_obj = { + "ipRoutingTable", 21, 0, + &_ipRouteEntry_obj, &_ipAddrTable_obj +}, +_ipNetToMediaTable_obj = { + "ipNetToMediaTable", 22, 0, + &_ipNetToMediaEntry_obj, &_ipRoutingTable_obj +}, +_atIfIndex_obj = { + "atIfIndex", 1, 0, + NULL, NULL +}, +_atPhysAddress_obj = { + "atPhysAddress", 2, 0, + NULL, &_atIfIndex_obj +}, +_atNetAddress_obj = { + "atNetAddress", 3, 0, + NULL, &_atPhysAddress_obj +}, +_atEntry_obj = { + "atEntry", 1, 0, + &_atNetAddress_obj, NULL +}, +_atTable_obj = { + "atTable", 1, 0, + &_atEntry_obj, NULL +}, +_ifIndex_obj = { + "ifIndex", 1, 0, + NULL, NULL +}, +_ifDescr_obj = { + "ifDescr", 2, 0, + NULL, &_ifIndex_obj +}, +_ifType_obj = { + "ifType", 3, 0, + NULL, &_ifDescr_obj +}, +_ifMtu_obj = { + "ifMtu", 4, 0, + NULL, &_ifType_obj +}, +_ifSpeed_obj = { + "ifSpeed", 5, 0, + NULL, &_ifMtu_obj +}, +_ifPhysAddress_obj = { + "ifPhysAddress", 6, 0, + NULL, &_ifSpeed_obj +}, +_ifAdminStatus_obj = { + "ifAdminStatus", 7, 0, + NULL, &_ifPhysAddress_obj +}, +_ifOperStatus_obj = { + "ifOperStatus", 8, 0, + NULL, &_ifAdminStatus_obj +}, +_ifLastChange_obj = { + "ifLastChange", 9, 0, + NULL, &_ifOperStatus_obj +}, +_ifInOctets_obj = { + "ifInOctets", 10, 0, + NULL, &_ifLastChange_obj +}, +_ifInUcastPkts_obj = { + "ifInUcastPkts", 11, 0, + NULL, &_ifInOctets_obj +}, +_ifInNUcastPkts_obj = { + "ifInNUcastPkts", 12, 0, + NULL, &_ifInUcastPkts_obj +}, +_ifInDiscards_obj = { + "ifInDiscards", 13, 0, + NULL, &_ifInNUcastPkts_obj +}, +_ifInErrors_obj = { + "ifInErrors", 14, 0, + NULL, &_ifInDiscards_obj +}, +_ifInUnknownProtos_obj = { + "ifInUnknownProtos", 15, 0, + NULL, &_ifInErrors_obj +}, +_ifOutOctets_obj = { + "ifOutOctets", 16, 0, + NULL, &_ifInUnknownProtos_obj +}, +_ifOutUcastPkts_obj = { + "ifOutUcastPkts", 17, 0, + NULL, &_ifOutOctets_obj +}, +_ifOutNUcastPkts_obj = { + "ifOutNUcastPkts", 18, 0, + NULL, &_ifOutUcastPkts_obj +}, +_ifOutDiscards_obj = { + "ifOutDiscards", 19, 0, + NULL, &_ifOutNUcastPkts_obj +}, +_ifOutErrors_obj = { + "ifOutErrors", 20, 0, + NULL, &_ifOutDiscards_obj +}, +_ifOutQLen_obj = { + "ifOutQLen", 21, 0, + NULL, &_ifOutErrors_obj +}, +_ifSpecific_obj = { + "ifSpecific", 22, 0, + NULL, &_ifOutQLen_obj +}, +_ifEntry_obj = { + "ifEntry", 1, 0, + &_ifSpecific_obj, NULL +}, +_ifNumber_obj = { + "ifNumber", 1, 0, + NULL, NULL +}, +_ifTable_obj = { + "ifTable", 2, 0, + &_ifEntry_obj, &_ifNumber_obj +}, +_sysDescr_obj = { + "sysDescr", 1, 0, + NULL, NULL +}, +_sysObjectID_obj = { + "sysObjectID", 2, 0, + NULL, &_sysDescr_obj +}, +_sysUpTime_obj = { + "sysUpTime", 3, 0, + NULL, &_sysObjectID_obj +}, +_sysContact_obj = { + "sysContact", 4, 0, + NULL, &_sysUpTime_obj +}, +_sysName_obj = { + "sysName", 5, 0, + NULL, &_sysContact_obj +}, +_sysLocation_obj = { + "sysLocation", 6, 0, + NULL, &_sysName_obj +}, +_sysServices_obj = { + "sysServices", 7, 0, + NULL, &_sysLocation_obj +}, +_system_obj = { + "system", 1, 0, + &_sysServices_obj, NULL +}, +_interfaces_obj = { + "interfaces", 2, 0, + &_ifTable_obj, &_system_obj +}, +_at_obj = { + "at", 3, 0, + &_atTable_obj, &_interfaces_obj +}, +_ip_obj = { + "ip", 4, 0, + &_ipNetToMediaTable_obj, &_at_obj +}, +_icmp_obj = { + "icmp", 5, 0, + &_icmpOutAddrMaskReps_obj, &_ip_obj +}, +_tcp_obj = { + "tcp", 6, 0, + &_tcpOutRsts_obj, &_icmp_obj +}, +_udp_obj = { + "udp", 7, 0, + &_udpTable_obj, &_tcp_obj +}, +_egp_obj = { + "egp", 8, 0, + &_egpAs_obj, &_udp_obj +}, +_transmission_obj = { + "transmission", 10, 0, + NULL, &_egp_obj +}, +_snmp_obj = { + "snmp", 11, 0, + &_snmpEnableAuthTraps_obj, &_transmission_obj +}, +_usmMIBCompliances_obj = { + "usmMIBCompliances", 1, 0, + NULL, NULL +}, +_usmMIBGroups_obj = { + "usmMIBGroups", 2, 0, + NULL, &_usmMIBCompliances_obj +}, +_usmUserEngineID_obj = { + "usmUserEngineID", 1, 0, + NULL, NULL +}, +_usmUserName_obj = { + "usmUserName", 2, 0, + NULL, &_usmUserEngineID_obj +}, +_usmUserSecurityName_obj = { + "usmUserSecurityName", 3, 0, + NULL, &_usmUserName_obj +}, +_usmUserCloneFrom_obj = { + "usmUserCloneFrom", 4, 0, + NULL, &_usmUserSecurityName_obj +}, +_usmUserAuthProtocol_obj = { + "usmUserAuthProtocol", 5, 0, + NULL, &_usmUserCloneFrom_obj +}, +_usmUserAuthKeyChange_obj = { + "usmUserAuthKeyChange", 6, 0, + NULL, &_usmUserAuthProtocol_obj +}, +_usmUserOwnAuthKeyChange_obj = { + "usmUserOwnAuthKeyChange", 7, 0, + NULL, &_usmUserAuthKeyChange_obj +}, +_usmUserPrivProtocol_obj = { + "usmUserPrivProtocol", 8, 0, + NULL, &_usmUserOwnAuthKeyChange_obj +}, +_usmUserPrivKeyChange_obj = { + "usmUserPrivKeyChange", 9, 0, + NULL, &_usmUserPrivProtocol_obj +}, +_usmUserOwnPrivKeyChange_obj = { + "usmUserOwnPrivKeyChange", 10, 0, + NULL, &_usmUserPrivKeyChange_obj +}, +_usmUserPublic_obj = { + "usmUserPublic", 11, 0, + NULL, &_usmUserOwnPrivKeyChange_obj +}, +_usmUserStorageType_obj = { + "usmUserStorageType", 12, 0, + NULL, &_usmUserPublic_obj +}, +_usmUserStatus_obj = { + "usmUserStatus", 13, 0, + NULL, &_usmUserStorageType_obj +}, +_usmUserEntry_obj = { + "usmUserEntry", 1, 0, + &_usmUserStatus_obj, NULL +}, +_usmUserSpinLock_obj = { + "usmUserSpinLock", 1, 0, + NULL, NULL +}, +_usmUserTable_obj = { + "usmUserTable", 2, 0, + &_usmUserEntry_obj, &_usmUserSpinLock_obj +}, +_usmStatsUnsupportedSecLevels_obj = { + "usmStatsUnsupportedSecLevels", 1, 0, + NULL, NULL +}, +_usmStatsNotInTimeWindows_obj = { + "usmStatsNotInTimeWindows", 2, 0, + NULL, &_usmStatsUnsupportedSecLevels_obj +}, +_usmStatsUnknownUserNames_obj = { + "usmStatsUnknownUserNames", 3, 0, + NULL, &_usmStatsNotInTimeWindows_obj +}, +_usmStatsUnknownEngineIDs_obj = { + "usmStatsUnknownEngineIDs", 4, 0, + NULL, &_usmStatsUnknownUserNames_obj +}, +_usmStatsWrongDigests_obj = { + "usmStatsWrongDigests", 5, 0, + NULL, &_usmStatsUnknownEngineIDs_obj +}, +_usmStatsDecryptionErrors_obj = { + "usmStatsDecryptionErrors", 6, 0, + NULL, &_usmStatsWrongDigests_obj +}, +_usmStats_obj = { + "usmStats", 1, 0, + &_usmStatsDecryptionErrors_obj, NULL +}, +_usmUser_obj = { + "usmUser", 2, 0, + &_usmUserTable_obj, &_usmStats_obj +}, +_usmMIBObjects_obj = { + "usmMIBObjects", 1, 0, + &_usmUser_obj, NULL +}, +_usmMIBConformance_obj = { + "usmMIBConformance", 2, 0, + &_usmMIBGroups_obj, &_usmMIBObjects_obj +}, +_snmpMPDMIBCompliances_obj = { + "snmpMPDMIBCompliances", 1, 0, + NULL, NULL +}, +_snmpMPDMIBGroups_obj = { + "snmpMPDMIBGroups", 2, 0, + NULL, &_snmpMPDMIBCompliances_obj +}, +_snmpUnknownSecurityModels_obj = { + "snmpUnknownSecurityModels", 1, 0, + NULL, NULL +}, +_snmpInvalidMsgs_obj = { + "snmpInvalidMsgs", 2, 0, + NULL, &_snmpUnknownSecurityModels_obj +}, +_snmpUnknownPDUHandlers_obj = { + "snmpUnknownPDUHandlers", 3, 0, + NULL, &_snmpInvalidMsgs_obj +}, +_snmpMPDStats_obj = { + "snmpMPDStats", 1, 0, + &_snmpUnknownPDUHandlers_obj, NULL +}, +_snmpMPDAdmin_obj = { + "snmpMPDAdmin", 1, 0, + NULL, NULL +}, +_snmpMPDMIBObjects_obj = { + "snmpMPDMIBObjects", 2, 0, + &_snmpMPDStats_obj, &_snmpMPDAdmin_obj +}, +_snmpMPDMIBConformance_obj = { + "snmpMPDMIBConformance", 3, 0, + &_snmpMPDMIBGroups_obj, &_snmpMPDMIBObjects_obj +}, +_snmpEngineID_obj = { + "snmpEngineID", 1, 0, + NULL, NULL +}, +_snmpEngineBoots_obj = { + "snmpEngineBoots", 2, 0, + NULL, &_snmpEngineID_obj +}, +_snmpEngineTime_obj = { + "snmpEngineTime", 3, 0, + NULL, &_snmpEngineBoots_obj +}, +_snmpEngineMaxMessageSize_obj = { + "snmpEngineMaxMessageSize", 4, 0, + NULL, &_snmpEngineTime_obj +}, +_snmpEngine_obj = { + "snmpEngine", 1, 0, + &_snmpEngineMaxMessageSize_obj, NULL +}, +_snmpFrameworkAdmin_obj = { + "snmpFrameworkAdmin", 1, 0, + NULL, NULL +}, +_snmpFrameworkMIBObjects_obj = { + "snmpFrameworkMIBObjects", 2, 0, + &_snmpEngine_obj, &_snmpFrameworkAdmin_obj +}, +_snmpFrameworkMIBConformance_obj = { + "snmpFrameworkMIBConformance", 3, 0, + NULL, &_snmpFrameworkMIBObjects_obj +}, +_snmpFrameworkMIB_obj = { + "snmpFrameworkMIB", 10, 0, + &_snmpFrameworkMIBConformance_obj, NULL +}, +_snmpMPDMIB_obj = { + "snmpMPDMIB", 11, 0, + &_snmpMPDMIBConformance_obj, &_snmpFrameworkMIB_obj +}, +_snmpUsmMIB_obj = { + "snmpUsmMIB", 15, 0, + &_usmMIBConformance_obj, &_snmpMPDMIB_obj +}, +_snmpModules_obj = { + "snmpModules", 3, 0, + &_snmpUsmMIB_obj, NULL +}, +_mib_obj = { + "mib", 1, 0, + &_snmp_obj, NULL +}, +_directory_obj = { + "directory", 1, 0, + NULL, NULL +}, +_mgmt_obj = { + "mgmt", 2, 0, + &_mib_obj, &_directory_obj +}, +_experimental_obj = { + "experimental", 3, 0, + NULL, &_mgmt_obj +}, +_private_obj = { + "private", 4, 0, + &_enterprises_obj, &_experimental_obj +}, +_security_obj = { + "security", 5, 0, + NULL, &_private_obj +}, +_snmpV2_obj = { + "snmpV2", 6, 0, + &_snmpModules_obj, &_security_obj +}, +_internet_obj = { + "internet", 1, 0, + &_snmpV2_obj, NULL +}, +_dod_obj = { + "dod", 6, 0, + &_internet_obj, NULL +}, +_org_obj = { + "org", 3, 0, + &_dod_obj, NULL +}, +_iso_obj = { + "iso", 1, 0, + &_org_obj, NULL +}, +*mibroot = &_iso_obj;
diff --git a/tcpdump-4.3.0/missing/addrinfo.h b/tcpdump-4.3.0/missing/addrinfo.h new file mode 100644 index 0000000..d3d63cd --- /dev/null +++ b/tcpdump-4.3.0/missing/addrinfo.h
@@ -0,0 +1,119 @@ +/* + * 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: + * 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. + */ + +/* $Id: addrinfo.h,v 1.4 2002-06-11 17:13:36 itojun Exp $ */ + +#ifndef HAVE_ADDRINFO + +/* + * Error return codes from getaddrinfo() + */ +#define EAI_ADDRFAMILY 1 /* address family for hostname not supported */ +#define EAI_AGAIN 2 /* temporary failure in name resolution */ +#define EAI_BADFLAGS 3 /* invalid value for ai_flags */ +#define EAI_FAIL 4 /* non-recoverable failure in name resolution */ +#define EAI_FAMILY 5 /* ai_family not supported */ +#define EAI_MEMORY 6 /* memory allocation failure */ +#define EAI_NODATA 7 /* no address associated with hostname */ +#define EAI_NONAME 8 /* hostname nor servname provided, or not known */ +#define EAI_SERVICE 9 /* servname not supported for ai_socktype */ +#define EAI_SOCKTYPE 10 /* ai_socktype not supported */ +#define EAI_SYSTEM 11 /* system error returned in errno */ +#define EAI_BADHINTS 12 +#define EAI_PROTOCOL 13 +#define EAI_MAX 14 + +/* internal error */ +#define NETDB_INTERNAL -1 /* see errno */ + +/* + * Flag values for getaddrinfo() + */ +#define AI_PASSIVE 0x00000001 /* get address to use bind() */ +#define AI_CANONNAME 0x00000002 /* fill ai_canonname */ +#define AI_NUMERICHOST 0x00000004 /* prevent name resolution */ +/* valid flags for addrinfo */ +#define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST) + +#define AI_ALL 0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */ +#define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */ +#define AI_ADDRCONFIG 0x00000400 /* only if any address is assigned */ +#define AI_V4MAPPED 0x00000800 /* accept IPv4-mapped IPv6 address */ +/* special recommended flags for getipnodebyname */ +#define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG) + +struct addrinfo { + int ai_flags; /* AI_PASSIVE, AI_CANONNAME */ + int ai_family; /* PF_xxx */ + int ai_socktype; /* SOCK_xxx */ + int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ + size_t ai_addrlen; /* length of ai_addr */ + char *ai_canonname; /* canonical name for hostname */ + struct sockaddr *ai_addr; /* binary address */ + struct addrinfo *ai_next; /* next structure in linked list */ +}; + +extern void freeaddrinfo (struct addrinfo *); +extern void freehostent (struct hostent *); +extern int getnameinfo (const struct sockaddr *, size_t, char *, + size_t, char *, size_t, int); +extern struct hostent *getipnodebyaddr (const void *, size_t, int, int *); +extern struct hostent *getipnodebyname (const char *, int, int, int *); +extern int inet_pton (int, const char *, void *); +extern const char *inet_ntop (int, const void *, char *, size_t); +#endif /* HAVE_ADDRINFO */ + +/* + * Constants for getnameinfo() + */ +#ifndef NI_MAXHOST +#define NI_MAXHOST 1025 +#endif +#ifndef NI_MAXSERV +#define NI_MAXSERV 32 +#endif + +/* + * Flag values for getnameinfo() + */ +#ifndef NI_NOFQDN +#define NI_NOFQDN 0x00000001 +#endif +#ifndef NI_NUMERICHOST +#define NI_NUMERICHOST 0x00000002 +#endif +#ifndef NI_NAMEREQD +#define NI_NAMEREQD 0x00000004 +#endif +#ifndef NI_NUMERICSERV +#define NI_NUMERICSERV 0x00000008 +#endif +#ifndef NI_DGRAM +#define NI_DGRAM 0x00000010 +#endif
diff --git a/tcpdump-4.3.0/missing/datalinks.c b/tcpdump-4.3.0/missing/datalinks.c new file mode 100644 index 0000000..1bd8644 --- /dev/null +++ b/tcpdump-4.3.0/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.3 2003-11-16 09:36:47 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/tcpdump-4.3.0/missing/dlnames.c b/tcpdump-4.3.0/missing/dlnames.c new file mode 100644 index 0000000..32072b7 --- /dev/null +++ b/tcpdump-4.3.0/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.5 2003-11-18 23:09:43 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/tcpdump-4.3.0/missing/getnameinfo.c b/tcpdump-4.3.0/missing/getnameinfo.c new file mode 100644 index 0000000..c287221 --- /dev/null +++ b/tcpdump-4.3.0/missing/getnameinfo.c
@@ -0,0 +1,281 @@ +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Issues to be discussed: + * - Thread safe-ness must be checked + * - Return values. There seems to be no standard for return value (RFC2553) + * but INRIA implementation returns EAI_xxx defined for getaddrinfo(). + * - RFC2553 says that we should raise error on short buffer. X/Open says + * we need to truncate the result. We obey RFC2553 (and X/Open should be + * modified). + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/missing/getnameinfo.c,v 1.11 2003-11-16 09:36:49 guy Exp $"; +#endif + +#include <sys/types.h> +#include <sys/socket.h> +#include <net/if.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <arpa/nameser.h> +#include <netdb.h> +#include <resolv.h> +#include <string.h> +#include <stddef.h> +#include <errno.h> + +#ifdef NEED_ADDRINFO_H +#include "addrinfo.h" +#endif + +#define SUCCESS 0 +#define ANY 0 +#define YES 1 +#define NO 0 + +static struct afd { + int a_af; + int a_addrlen; + int a_socklen; + int a_off; +} afdl [] = { +#ifdef INET6 + {PF_INET6, sizeof(struct in6_addr), sizeof(struct sockaddr_in6), + offsetof(struct sockaddr_in6, sin6_addr)}, +#endif + {PF_INET, sizeof(struct in_addr), sizeof(struct sockaddr_in), + offsetof(struct sockaddr_in, sin_addr)}, + {0, 0, 0}, +}; + +struct sockinet { + u_char si_len; + u_char si_family; + u_short si_port; +}; + +#define ENI_NOSOCKET 0 +#define ENI_NOSERVNAME 1 +#define ENI_NOHOSTNAME 2 +#define ENI_MEMORY 3 +#define ENI_SYSTEM 4 +#define ENI_FAMILY 5 +#define ENI_SALEN 6 + +int +getnameinfo(sa, salen, host, hostlen, serv, servlen, flags) + const struct sockaddr *sa; + size_t salen; + char *host; + size_t hostlen; + char *serv; + size_t servlen; + int flags; +{ + struct afd *afd; + struct servent *sp; + struct hostent *hp; + u_short port; + int family, i; + char *addr, *p; + u_int32_t v4a; + int h_error; + char numserv[512]; + char numaddr[512]; + + if (sa == NULL) + return ENI_NOSOCKET; + +#ifdef HAVE_SA_LEN /*XXX*/ + 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) { + afd = &afdl[i]; + 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; + + if (serv == NULL || servlen == 0) { + /* + * do nothing in this case. + * in case you are wondering if "&&" is more correct than + * "||" here: RFC2553 says that serv == NULL OR servlen == 0 + * means that the caller does not want the result. + */ + } else { + if (flags & NI_NUMERICSERV) + sp = NULL; + else { + sp = getservbyport(port, + (flags & NI_DGRAM) ? "udp" : "tcp"); + } + if (sp) { + if (strlen(sp->s_name) + 1 > servlen) + return ENI_MEMORY; + strcpy(serv, sp->s_name); + } else { + snprintf(numserv, sizeof(numserv), "%d", ntohs(port)); + if (strlen(numserv) + 1 > servlen) + return ENI_MEMORY; + strcpy(serv, numserv); + } + } + + switch (sa->sa_family) { + case AF_INET: + v4a = (u_int32_t) + ntohl(((struct sockaddr_in *)sa)->sin_addr.s_addr); + if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a)) + flags |= NI_NUMERICHOST; + v4a >>= IN_CLASSA_NSHIFT; + if (v4a == 0) + flags |= NI_NUMERICHOST; + break; +#ifdef INET6 + case AF_INET6: + { + struct sockaddr_in6 *sin6; + sin6 = (struct sockaddr_in6 *)sa; + switch (sin6->sin6_addr.s6_addr[0]) { + case 0x00: + if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) + ; + else if (IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr)) + ; + else + flags |= NI_NUMERICHOST; + break; + default: + if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) { + flags |= NI_NUMERICHOST; + } + else if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) + flags |= NI_NUMERICHOST; + break; + } + } + break; +#endif + } + if (host == NULL || hostlen == 0) { + /* + * do nothing in this case. + * in case you are wondering if "&&" is more correct than + * "||" here: RFC2553 says that host == NULL OR hostlen == 0 + * means that the caller does not want the result. + */ + } else if (flags & NI_NUMERICHOST) { + /* NUMERICHOST and NAMEREQD conflicts with each other */ + if (flags & NI_NAMEREQD) + return ENI_NOHOSTNAME; + if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr)) + == NULL) + return ENI_SYSTEM; + if (strlen(numaddr) + 1 > hostlen) + return ENI_MEMORY; + strcpy(host, numaddr); +#if defined(INET6) && defined(NI_WITHSCOPEID) + if (afd->a_af == AF_INET6 && + (IN6_IS_ADDR_LINKLOCAL((struct in6_addr *)addr) || + IN6_IS_ADDR_MULTICAST((struct in6_addr *)addr)) && + ((struct sockaddr_in6 *)sa)->sin6_scope_id) { +#ifndef ALWAYS_WITHSCOPE + if (flags & NI_WITHSCOPEID) +#endif /* !ALWAYS_WITHSCOPE */ + { + char *ep = strchr(host, '\0'); + unsigned int ifindex = + ((struct sockaddr_in6 *)sa)->sin6_scope_id; + + *ep = SCOPE_DELIMITER; + if ((if_indextoname(ifindex, ep + 1)) == NULL) + /* XXX what should we do? */ + strncpy(ep + 1, "???", 3); + } + } +#endif /* INET6 */ + } else { +#ifdef USE_GETIPNODEBY + hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error); +#else + hp = gethostbyaddr(addr, afd->a_addrlen, afd->a_af); +#ifdef HAVE_H_ERRNO + h_error = h_errno; +#else + h_error = EINVAL; +#endif +#endif + + if (hp) { + if (flags & NI_NOFQDN) { + p = strchr(hp->h_name, '.'); + if (p) *p = '\0'; + } + if (strlen(hp->h_name) + 1 > hostlen) { +#ifdef USE_GETIPNODEBY + freehostent(hp); +#endif + return ENI_MEMORY; + } + strcpy(host, hp->h_name); +#ifdef USE_GETIPNODEBY + freehostent(hp); +#endif + } else { + if (flags & NI_NAMEREQD) + return ENI_NOHOSTNAME; + if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr)) + == NULL) + return ENI_NOHOSTNAME; + if (strlen(numaddr) + 1 > hostlen) + return ENI_MEMORY; + strcpy(host, numaddr); + } + } + return SUCCESS; +}
diff --git a/tcpdump-4.3.0/missing/inet_aton.c b/tcpdump-4.3.0/missing/inet_aton.c new file mode 100644 index 0000000..bc1461a --- /dev/null +++ b/tcpdump-4.3.0/missing/inet_aton.c
@@ -0,0 +1,60 @@ +/* + * 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 + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* $Id: inet_aton.c,v 1.6 2003-11-16 09:36:49 guy Exp $ */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/missing/inet_aton.c,v 1.6 2003-11-16 09:36:49 guy Exp $"; +#endif + +#include <tcpdump-stdinc.h> + +/* Minimal implementation of inet_aton. + * Cannot distinguish between failure and a local broadcast address. */ + +#ifndef INADDR_NONE +#define INADDR_NONE 0xffffffff +#endif + +int +inet_aton(const char *cp, struct in_addr *addr) +{ + addr->s_addr = inet_addr(cp); + return (addr->s_addr == INADDR_NONE) ? 0 : 1; +}
diff --git a/tcpdump-4.3.0/missing/inet_ntop.c b/tcpdump-4.3.0/missing/inet_ntop.c new file mode 100644 index 0000000..d17d592 --- /dev/null +++ b/tcpdump-4.3.0/missing/inet_ntop.c
@@ -0,0 +1,219 @@ +/* + * 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 + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* $Id: inet_ntop.c,v 1.8 2005-02-09 02:25:46 guy Exp $ */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/missing/inet_ntop.c,v 1.8 2005-02-09 02:25:46 guy Exp $"; +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> +#include <errno.h> + +/* + * + */ + +#ifndef IN6ADDRSZ +#define IN6ADDRSZ 16 /* IPv6 T_AAAA */ +#endif + +#ifndef INT16SZ +#define INT16SZ 2 /* word size */ +#endif + +static const char * +inet_ntop_v4 (const void *src, char *dst, size_t size) +{ + const char digits[] = "0123456789"; + int i; + struct in_addr *addr = (struct in_addr *)src; + u_long a = ntohl(addr->s_addr); + const char *orig_dst = dst; + + if (size < INET_ADDRSTRLEN) { + errno = ENOSPC; + return NULL; + } + for (i = 0; i < 4; ++i) { + int n = (a >> (24 - i * 8)) & 0xFF; + int non_zerop = 0; + + if (non_zerop || n / 100 > 0) { + *dst++ = digits[n / 100]; + n %= 100; + non_zerop = 1; + } + if (non_zerop || n / 10 > 0) { + *dst++ = digits[n / 10]; + n %= 10; + non_zerop = 1; + } + *dst++ = digits[n]; + if (i != 3) + *dst++ = '.'; + } + *dst++ = '\0'; + return orig_dst; +} + +#ifdef INET6 +/* + * Convert IPv6 binary address into presentation (printable) format. + */ +static const char * +inet_ntop_v6 (const u_char *src, char *dst, size_t size) +{ + /* + * Note that int32_t and int16_t need only be "at least" large enough + * to contain a value of the specified size. On some systems, like + * Crays, there is no such thing as an integer variable with 16 bits. + * Keep this in mind if you think this function should have been coded + * to use pointer overlays. All the world's not a VAX. + */ + char tmp [INET6_ADDRSTRLEN+1]; + char *tp; + struct { + long base; + long len; + } best, cur; + u_long words [IN6ADDRSZ / INT16SZ]; + int i; + + /* Preprocess: + * Copy the input (bytewise) array into a wordwise array. + * Find the longest run of 0x00's in src[] for :: shorthanding. + */ + memset (words, 0, sizeof(words)); + for (i = 0; i < IN6ADDRSZ; i++) + words[i/2] |= (src[i] << ((1 - (i % 2)) << 3)); + + best.base = -1; + cur.base = -1; + for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) + { + if (words[i] == 0) + { + if (cur.base == -1) + cur.base = i, cur.len = 1; + else cur.len++; + } + else if (cur.base != -1) + { + if (best.base == -1 || cur.len > best.len) + best = cur; + cur.base = -1; + } + } + if ((cur.base != -1) && (best.base == -1 || cur.len > best.len)) + best = cur; + if (best.base != -1 && best.len < 2) + best.base = -1; + + /* Format the result. + */ + tp = tmp; + for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) + { + /* Are we inside the best run of 0x00's? + */ + if (best.base != -1 && i >= best.base && i < (best.base + best.len)) + { + if (i == best.base) + *tp++ = ':'; + continue; + } + + /* Are we following an initial run of 0x00s or any real hex? + */ + if (i != 0) + *tp++ = ':'; + + /* Is this address an encapsulated IPv4? + */ + if (i == 6 && best.base == 0 && + (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) + { + if (!inet_ntop_v4(src+12, tp, sizeof(tmp) - (tp - tmp))) + { + errno = ENOSPC; + return (NULL); + } + tp += strlen(tp); + break; + } + tp += sprintf (tp, "%lX", words[i]); + } + + /* Was it a trailing run of 0x00's? + */ + if (best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ)) + *tp++ = ':'; + *tp++ = '\0'; + + /* Check for overflow, copy, and we're done. + */ + if ((size_t)(tp - tmp) > size) + { + errno = ENOSPC; + return (NULL); + } + return strcpy (dst, tmp); + return (NULL); +} +#endif /* INET6 */ + + +const char * +inet_ntop(int af, const void *src, char *dst, size_t size) +{ + switch (af) { + case AF_INET : + return inet_ntop_v4 (src, dst, size); +#ifdef INET6 + case AF_INET6: + return inet_ntop_v6 ((const u_char*)src, dst, size); +#endif + default : + errno = EAFNOSUPPORT; + return NULL; + } +}
diff --git a/tcpdump-4.3.0/missing/inet_pton.c b/tcpdump-4.3.0/missing/inet_pton.c new file mode 100644 index 0000000..83f67e1 --- /dev/null +++ b/tcpdump-4.3.0/missing/inet_pton.c
@@ -0,0 +1,58 @@ +/* + * 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 + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* $Id: inet_pton.c,v 1.6 2003-11-16 09:36:51 guy Exp $ */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/missing/inet_pton.c,v 1.6 2003-11-16 09:36:51 guy Exp $"; +#endif + +#include <tcpdump-stdinc.h> + +#include <errno.h> + +int +inet_pton(int af, const char *src, void *dst) +{ + if (af != AF_INET) { + errno = EAFNOSUPPORT; + return -1; + } + return inet_aton (src, dst); +}
diff --git a/tcpdump-4.3.0/missing/snprintf.c b/tcpdump-4.3.0/missing/snprintf.c new file mode 100644 index 0000000..7932997 --- /dev/null +++ b/tcpdump-4.3.0/missing/snprintf.c
@@ -0,0 +1,632 @@ +/* + * Copyright (c) 1995-1999 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* $Id: snprintf.c,v 1.8 2003-11-16 09:36:51 guy Exp $ */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/missing/snprintf.c,v 1.8 2003-11-16 09:36:51 guy Exp $"; +#endif + +#include <stdio.h> +#include <stdarg.h> +#include <stdlib.h> +#include <string.h> +#include <ctype.h> +#include <sys/types.h> + +#include <interface.h> + +enum format_flags { + minus_flag = 1, + plus_flag = 2, + space_flag = 4, + alternate_flag = 8, + zero_flag = 16 +}; + +/* + * Common state + */ + +struct state { + unsigned char *str; + unsigned char *s; + unsigned char *theend; + size_t sz; + size_t max_sz; + int (*append_char)(struct state *, unsigned char); + int (*reserve)(struct state *, size_t); + /* XXX - methods */ +}; + +#ifndef HAVE_VSNPRINTF +static int +sn_reserve (struct state *state, size_t n) +{ + return state->s + n > state->theend; +} + +static int +sn_append_char (struct state *state, unsigned char c) +{ + if (sn_reserve (state, 1)) { + return 1; + } else { + *state->s++ = c; + return 0; + } +} +#endif + +#if 0 +static int +as_reserve (struct state *state, size_t n) +{ + if (state->s + n > state->theend) { + int off = state->s - state->str; + unsigned char *tmp; + + if (state->max_sz && state->sz >= state->max_sz) + return 1; + + state->sz = max(state->sz * 2, state->sz + n); + if (state->max_sz) + state->sz = min(state->sz, state->max_sz); + tmp = realloc (state->str, state->sz); + if (tmp == NULL) + return 1; + state->str = tmp; + state->s = state->str + off; + state->theend = state->str + state->sz - 1; + } + return 0; +} + +static int +as_append_char (struct state *state, unsigned char c) +{ + if(as_reserve (state, 1)) + return 1; + else { + *state->s++ = c; + return 0; + } +} +#endif + +static int +append_number(struct state *state, + unsigned long num, unsigned base, char *rep, + int width, int prec, int flags, int minusp) +{ + int len = 0; + int i; + + /* given precision, ignore zero flag */ + if(prec != -1) + flags &= ~zero_flag; + else + prec = 1; + /* zero value with zero precision -> "" */ + if(prec == 0 && num == 0) + return 0; + do{ + if((*state->append_char)(state, rep[num % base])) + return 1; + len++; + num /= base; + }while(num); + prec -= len; + /* pad with prec zeros */ + while(prec-- > 0){ + if((*state->append_char)(state, '0')) + return 1; + len++; + } + /* add length of alternate prefix (added later) to len */ + if(flags & alternate_flag && (base == 16 || base == 8)) + len += base / 8; + /* pad with zeros */ + if(flags & zero_flag){ + width -= len; + if(minusp || (flags & space_flag) || (flags & plus_flag)) + width--; + while(width-- > 0){ + if((*state->append_char)(state, '0')) + return 1; + len++; + } + } + /* add alternate prefix */ + if(flags & alternate_flag && (base == 16 || base == 8)){ + if(base == 16) + if((*state->append_char)(state, rep[10] + 23)) /* XXX */ + return 1; + if((*state->append_char)(state, '0')) + return 1; + } + /* add sign */ + if(minusp){ + if((*state->append_char)(state, '-')) + return 1; + len++; + } else if(flags & plus_flag) { + if((*state->append_char)(state, '+')) + return 1; + len++; + } else if(flags & space_flag) { + if((*state->append_char)(state, ' ')) + return 1; + len++; + } + if(flags & minus_flag) + /* swap before padding with spaces */ + for(i = 0; i < len / 2; i++){ + char c = state->s[-i-1]; + state->s[-i-1] = state->s[-len+i]; + state->s[-len+i] = c; + } + width -= len; + while(width-- > 0){ + if((*state->append_char)(state, ' ')) + return 1; + len++; + } + if(!(flags & minus_flag)) + /* swap after padding with spaces */ + for(i = 0; i < len / 2; i++){ + char c = state->s[-i-1]; + state->s[-i-1] = state->s[-len+i]; + state->s[-len+i] = c; + } + + return 0; +} + +static int +append_string (struct state *state, + unsigned char *arg, + int width, + int prec, + int flags) +{ + if(prec != -1) + width -= prec; + else + width -= strlen((char *)arg); + if(!(flags & minus_flag)) + while(width-- > 0) + if((*state->append_char) (state, ' ')) + return 1; + if (prec != -1) { + while (*arg && prec--) + if ((*state->append_char) (state, *arg++)) + return 1; + } else { + while (*arg) + if ((*state->append_char) (state, *arg++)) + return 1; + } + if(flags & minus_flag) + while(width-- > 0) + if((*state->append_char) (state, ' ')) + return 1; + return 0; +} + +static int +append_char(struct state *state, + unsigned char arg, + int width, + int flags) +{ + while(!(flags & minus_flag) && --width > 0) + if((*state->append_char) (state, ' ')) + return 1; + + if((*state->append_char) (state, arg)) + return 1; + while((flags & minus_flag) && --width > 0) + if((*state->append_char) (state, ' ')) + return 1; + + return 0; +} + +/* + * This can't be made into a function... + */ + +#define PARSE_INT_FORMAT(res, arg, unsig) \ +if (long_flag) \ + res = (unsig long)va_arg(arg, unsig long); \ +else if (short_flag) \ + res = (unsig short)va_arg(arg, unsig int); \ +else \ + res = (unsig int)va_arg(arg, unsig int) + +/* + * zyxprintf - return 0 or -1 + */ + +static int +xyzprintf (struct state *state, const char *char_format, va_list ap) +{ + const unsigned char *format = (const unsigned char *)char_format; + unsigned char c; + + while((c = *format++)) { + if (c == '%') { + int flags = 0; + int width = 0; + int prec = -1; + int long_flag = 0; + int short_flag = 0; + + /* flags */ + while((c = *format++)){ + if(c == '-') + flags |= minus_flag; + else if(c == '+') + flags |= plus_flag; + else if(c == ' ') + flags |= space_flag; + else if(c == '#') + flags |= alternate_flag; + else if(c == '0') + flags |= zero_flag; + else + break; + } + + if((flags & space_flag) && (flags & plus_flag)) + flags ^= space_flag; + + if((flags & minus_flag) && (flags & zero_flag)) + flags ^= zero_flag; + + /* width */ + if (isdigit(c)) + do { + width = width * 10 + c - '0'; + c = *format++; + } while(isdigit(c)); + else if(c == '*') { + width = va_arg(ap, int); + c = *format++; + } + + /* precision */ + if (c == '.') { + prec = 0; + c = *format++; + if (isdigit(c)) + do { + prec = prec * 10 + c - '0'; + c = *format++; + } while(isdigit(c)); + else if (c == '*') { + prec = va_arg(ap, int); + c = *format++; + } + } + + /* size */ + + if (c == 'h') { + short_flag = 1; + c = *format++; + } else if (c == 'l') { + long_flag = 1; + c = *format++; + } + + switch (c) { + case 'c' : + if(append_char(state, va_arg(ap, int), width, flags)) + return -1; + break; + case 's' : + if (append_string(state, + va_arg(ap, unsigned char*), + width, + prec, + flags)) + return -1; + break; + case 'd' : + case 'i' : { + long arg; + unsigned long num; + int minusp = 0; + + PARSE_INT_FORMAT(arg, ap, signed); + + if (arg < 0) { + minusp = 1; + num = -arg; + } else + num = arg; + + if (append_number (state, num, 10, "0123456789", + width, prec, flags, minusp)) + return -1; + break; + } + case 'u' : { + unsigned long arg; + + PARSE_INT_FORMAT(arg, ap, unsigned); + + if (append_number (state, arg, 10, "0123456789", + width, prec, flags, 0)) + return -1; + break; + } + case 'o' : { + unsigned long arg; + + PARSE_INT_FORMAT(arg, ap, unsigned); + + if (append_number (state, arg, 010, "01234567", + width, prec, flags, 0)) + return -1; + break; + } + case 'x' : { + unsigned long arg; + + PARSE_INT_FORMAT(arg, ap, unsigned); + + if (append_number (state, arg, 0x10, "0123456789abcdef", + width, prec, flags, 0)) + return -1; + break; + } + case 'X' :{ + unsigned long arg; + + PARSE_INT_FORMAT(arg, ap, unsigned); + + if (append_number (state, arg, 0x10, "0123456789ABCDEF", + width, prec, flags, 0)) + return -1; + break; + } + case 'p' : { + unsigned long arg = (unsigned long)va_arg(ap, void*); + + if (append_number (state, arg, 0x10, "0123456789ABCDEF", + width, prec, flags, 0)) + return -1; + break; + } + case 'n' : { + int *arg = va_arg(ap, int*); + *arg = state->s - state->str; + break; + } + case '\0' : + --format; + /* FALLTHROUGH */ + case '%' : + if ((*state->append_char)(state, c)) + return -1; + break; + default : + if ( (*state->append_char)(state, '%') + || (*state->append_char)(state, c)) + return -1; + break; + } + } else + if ((*state->append_char) (state, c)) + return -1; + } + return 0; +} + +#ifndef HAVE_SNPRINTF +int +snprintf (char *str, size_t sz, const char *format, ...) +{ + va_list args; + int ret; + + va_start(args, format); + ret = vsnprintf (str, sz, format, args); + +#ifdef PARANOIA + { + int ret2; + char *tmp; + + tmp = malloc (sz); + if (tmp == NULL) + abort (); + + ret2 = vsprintf (tmp, format, args); + if (ret != ret2 || strcmp(str, tmp)) + abort (); + free (tmp); + } +#endif + + va_end(args); + return ret; +} +#endif + +#if 0 +#ifndef HAVE_ASPRINTF +int +asprintf (char **ret, const char *format, ...) +{ + va_list args; + int val; + + va_start(args, format); + val = vasprintf (ret, format, args); + +#ifdef PARANOIA + { + int ret2; + char *tmp; + tmp = malloc (val + 1); + if (tmp == NULL) + abort (); + + ret2 = vsprintf (tmp, format, args); + if (val != ret2 || strcmp(*ret, tmp)) + abort (); + free (tmp); + } +#endif + + va_end(args); + return val; +} +#endif + +#ifndef HAVE_ASNPRINTF +int +asnprintf (char **ret, size_t max_sz, const char *format, ...) +{ + va_list args; + int val; + + va_start(args, format); + val = vasnprintf (ret, max_sz, format, args); + +#ifdef PARANOIA + { + int ret2; + char *tmp; + tmp = malloc (val + 1); + if (tmp == NULL) + abort (); + + ret2 = vsprintf (tmp, format, args); + if (val != ret2 || strcmp(*ret, tmp)) + abort (); + free (tmp); + } +#endif + + va_end(args); + return val; +} +#endif + +#ifndef HAVE_VASPRINTF +int +vasprintf (char **ret, const char *format, va_list args) +{ + return vasnprintf (ret, 0, format, args); +} +#endif + + +#ifndef HAVE_VASNPRINTF +int +vasnprintf (char **ret, size_t max_sz, const char *format, va_list args) +{ + int st; + size_t len; + struct state state; + + state.max_sz = max_sz; + state.sz = 1; + state.str = malloc(state.sz); + if (state.str == NULL) { + *ret = NULL; + return -1; + } + state.s = state.str; + state.theend = state.s + state.sz - 1; + state.append_char = as_append_char; + state.reserve = as_reserve; + + st = xyzprintf (&state, format, args); + if (st) { + free (state.str); + *ret = NULL; + return -1; + } else { + char *tmp; + + *state.s = '\0'; + len = state.s - state.str; + tmp = realloc (state.str, len+1); + if (tmp == NULL) { + free (state.str); + *ret = NULL; + return -1; + } + *ret = tmp; + return len; + } +} +#endif +#endif + +#ifndef HAVE_VSNPRINTF +int +vsnprintf (char *str, size_t sz, const char *format, va_list args) +{ + struct state state; + int ret; + unsigned char *ustr = (unsigned char *)str; + + state.max_sz = 0; + state.sz = sz; + state.str = ustr; + state.s = ustr; + state.theend = ustr + sz - 1; + state.append_char = sn_append_char; + state.reserve = sn_reserve; + + ret = xyzprintf (&state, format, args); + *state.s = '\0'; + if (ret) + return sz; + else + return state.s - state.str; +} +#endif +
diff --git a/tcpdump-4.3.0/missing/sockstorage.h b/tcpdump-4.3.0/missing/sockstorage.h new file mode 100644 index 0000000..e733328 --- /dev/null +++ b/tcpdump-4.3.0/missing/sockstorage.h
@@ -0,0 +1,38 @@ +/* + * 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: + * 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. + */ +struct sockaddr_storage { +#ifdef HAVE_SOCKADDR_SA_LEN + u_int8_t ss_len; + u_int8_t ss_family; + u_int8_t fill[126]; +#else + u_int8_t ss_family; + u_int8_t fill[127]; +#endif /* HAVE_SOCKADDR_SA_LEN */ +};
diff --git a/tcpdump-4.3.0/missing/strdup.c b/tcpdump-4.3.0/missing/strdup.c new file mode 100644 index 0000000..079a8ff --- /dev/null +++ b/tcpdump-4.3.0/missing/strdup.c
@@ -0,0 +1,57 @@ +/* + * Copyright (c) 1988, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static const char rcsid[] = + "@(#) $Header: /tcpdump/master/tcpdump/missing/strdup.c,v 1.1 2001-01-20 07:26:08 guy Exp $ (LBL)"; +#endif /* LIBC_SCCS and not lint */ + +#include <stddef.h> +#include <stdlib.h> +#include <string.h> + +#include "interface.h" + +char * +strdup(str) + const char *str; +{ + size_t len; + char *copy; + + len = strlen(str) + 1; + if ((copy = malloc(len)) == NULL) + return (NULL); + memcpy(copy, str, len); + return (copy); +}
diff --git a/tcpdump-4.3.0/missing/strlcat.c b/tcpdump-4.3.0/missing/strlcat.c new file mode 100644 index 0000000..a3d3fac --- /dev/null +++ b/tcpdump-4.3.0/missing/strlcat.c
@@ -0,0 +1,76 @@ +/* $NetBSD: strlcat.c,v 1.5 1999/09/20 04:39:47 lukem Exp $ */ +/* from OpenBSD: strlcat.c,v 1.2 1999/06/17 16:28:58 millert Exp */ + +/* + * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/missing/strlcat.c,v 1.5 2003-11-16 09:36:51 guy Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <tcpdump-stdinc.h> + +#include <string.h> + +/* + * Appends src to string dst of size siz (unlike strncat, siz is the + * full size of dst, not space left). At most siz-1 characters + * will be copied. Always NUL terminates (unless siz == 0). + * Returns strlen(src); if retval >= siz, truncation occurred. + */ +size_t +strlcat(char *dst, const char *src, size_t siz) +{ + register char *d = dst; + register const char *s = src; + register size_t n = siz; + size_t dlen; + + /* Find the end of dst and adjust bytes left but don't go past end */ + while (*d != '\0' && n-- != 0) + d++; + dlen = d - dst; + n = siz - dlen; + + if (n == 0) + return(dlen + strlen(s)); + while (*s != '\0') { + if (n != 1) { + *d++ = *s; + n--; + } + s++; + } + *d = '\0'; + + return(dlen + (s - src)); /* count does not include NUL */ +}
diff --git a/tcpdump-4.3.0/missing/strlcpy.c b/tcpdump-4.3.0/missing/strlcpy.c new file mode 100644 index 0000000..a92e4d1 --- /dev/null +++ b/tcpdump-4.3.0/missing/strlcpy.c
@@ -0,0 +1,73 @@ +/* $NetBSD: strlcpy.c,v 1.5 1999/09/20 04:39:47 lukem Exp $ */ +/* from OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp */ + +/* + * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/missing/strlcpy.c,v 1.5 2003-11-16 09:36:52 guy Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <tcpdump-stdinc.h> + +#include <string.h> + +/* + * Copy src to string dst of size siz. At most siz-1 characters + * will be copied. Always NUL terminates (unless siz == 0). + * Returns strlen(src); if retval >= siz, truncation occurred. + */ +size_t +strlcpy(char *dst, const char *src, size_t siz) +{ + register char *d = dst; + register const char *s = src; + register size_t n = siz; + + /* Copy as many bytes as will fit */ + if (n != 0 && --n != 0) { + do { + if ((*d++ = *s++) == 0) + break; + } while (--n != 0); + } + + /* Not enough room in dst, add NUL and traverse rest of src */ + if (n == 0) { + if (siz != 0) + *d = '\0'; /* NUL-terminate dst */ + while (*s++) + ; + } + + return(s - src - 1); /* count does not include NUL */ +}
diff --git a/tcpdump-4.3.0/missing/strsep.c b/tcpdump-4.3.0/missing/strsep.c new file mode 100644 index 0000000..0362d1f --- /dev/null +++ b/tcpdump-4.3.0/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/tcpdump-4.3.0/mkdep b/tcpdump-4.3.0/mkdep new file mode 100755 index 0000000..2a9c221 --- /dev/null +++ b/tcpdump-4.3.0/mkdep
@@ -0,0 +1,109 @@ +#!/bin/sh - +# +# Copyright (c) 1994, 1996 +# The Regents of the University of California. All rights reserved. +# +# Redistribution and use in source and binary forms are permitted +# provided that this notice is preserved and that due credit is given +# to the University of California at Berkeley. The name of the University +# may not be used to endorse or promote products derived from this +# software without specific prior written permission. This software +# is provided ``as is'' without express or implied warranty. +# +# @(#)mkdep.sh 5.11 (Berkeley) 5/5/88 +# + +PATH=/bin:/usr/bin:/usr/ucb:/usr/local:/usr/local/bin +export PATH + +MAKE=Makefile # default makefile name is "Makefile" +CC=cc # default C compiler is "cc" + +while : + do case "$1" in + # -c allows you to specify the C compiler + -c) + CC=$2 + shift; shift ;; + + # -f allows you to select a makefile name + -f) + MAKE=$2 + shift; shift ;; + + # the -p flag produces "program: program.c" style dependencies + # so .o's don't get produced + -p) + SED='s;\.o;;' + shift ;; + *) + break ;; + esac +done + +if [ $# = 0 ] ; then + echo 'usage: mkdep [-p] [-c cc] [-f makefile] [flags] file ...' + exit 1 +fi + +if [ ! -w $MAKE ]; then + echo "mkdep: no writeable file \"$MAKE\"" + exit 1 +fi + +TMP=/tmp/mkdep$$ + +trap 'rm -f $TMP ; exit 1' 1 2 3 13 15 + +cp $MAKE ${MAKE}.bak + +sed -e '/DO NOT DELETE THIS LINE/,$d' < $MAKE > $TMP + +cat << _EOF_ >> $TMP +# DO NOT DELETE THIS LINE -- mkdep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +_EOF_ + +# If your compiler doesn't have -M, add it. If you can't, the next two +# lines will try and replace the "cc -M". The real problem is that this +# hack can't deal with anything that requires a search path, and doesn't +# even try for anything using bracket (<>) syntax. +# +# egrep '^#include[ ]*".*"' /dev/null $* | +# sed -e 's/:[^"]*"\([^"]*\)".*/: \1/' -e 's/\.c/.o/' | + +# XXX this doesn't work with things like "-DDECLWAITSTATUS=union\ wait" +$CC -M $* | +sed " + s; \./; ;g + $SED" | +awk '{ + if ($1 != prev) { + if (rec != "") + print rec; + rec = $0; + prev = $1; + } + else { + if (length(rec $2) > 78) { + print rec; + rec = $0; + } + else + rec = rec " " $2 + } +} +END { + print rec +}' >> $TMP + +cat << _EOF_ >> $TMP + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY +_EOF_ + +# copy to preserve permissions +cp $TMP $MAKE +rm -f ${MAKE}.bak $TMP +exit 0
diff --git a/tcpdump-4.3.0/mpls.h b/tcpdump-4.3.0/mpls.h new file mode 100644 index 0000000..ae1c97e --- /dev/null +++ b/tcpdump-4.3.0/mpls.h
@@ -0,0 +1,41 @@ +/* @(#) $Header: /tcpdump/master/tcpdump/mpls.h,v 1.1 2004-06-14 14:47:58 hannes Exp $ (LBL) + * Copyright (C) 2001 WIDE Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#define LABEL_MASK 0xfffff000 +#define LABEL_SHIFT 12 +#define EXP_MASK 0x00000e00 +#define EXP_SHIFT 9 +#define STACK_MASK 0x00000100 +#define STACK_SHIFT 8 +#define TTL_MASK 0x000000ff +#define TTL_SHIFT 0 + +#define MPLS_LABEL(x) (((x) & LABEL_MASK) >> LABEL_SHIFT) +#define MPLS_EXP(x) (((x) & EXP_MASK) >> EXP_SHIFT) +#define MPLS_STACK(x) (((x) & STACK_MASK) >> STACK_SHIFT) +#define MPLS_TTL(x) (((x) & TTL_MASK) >> TTL_SHIFT)
diff --git a/tcpdump-4.3.0/nameser.h b/tcpdump-4.3.0/nameser.h new file mode 100644 index 0000000..f441f3e --- /dev/null +++ b/tcpdump-4.3.0/nameser.h
@@ -0,0 +1,315 @@ +/* @(#) $Header: /tcpdump/master/tcpdump/nameser.h,v 1.16 2006-11-10 03:18:21 guy Exp $ (LBL) */ +/* + * Copyright (c) 1983, 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)nameser.h 8.2 (Berkeley) 2/16/94 + * - + * Portions Copyright (c) 1993 by Digital Equipment Corporation. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies, and that + * the name of Digital Equipment Corporation not be used in advertising or + * publicity pertaining to distribution of the document or software without + * specific, written prior permission. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL + * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT + * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * - + * --Copyright-- + */ + +#ifndef _NAMESER_H_ +#define _NAMESER_H_ + +#include <sys/types.h> + +/* + * Define constants based on rfc883 + */ +#define PACKETSZ 512 /* maximum packet size */ +#define MAXDNAME 256 /* maximum domain name */ +#define MAXCDNAME 255 /* maximum compressed domain name */ +#define MAXLABEL 63 /* maximum length of domain label */ + /* Number of bytes of fixed size data in query structure */ +#define QFIXEDSZ 4 + /* number of bytes of fixed size data in resource record */ +#define RRFIXEDSZ 10 + +/* + * Internet nameserver port number + */ +#define NAMESERVER_PORT 53 + +/* + * Port for multicast DNS; see + * + * http://files.multicastdns.org/draft-cheshire-dnsext-multicastdns.txt + * + * for the current mDNS spec. + */ +#define MULTICASTDNS_PORT 5353 + +/* + * Currently defined opcodes + */ +#define QUERY 0x0 /* standard query */ +#define IQUERY 0x1 /* inverse query */ +#define STATUS 0x2 /* nameserver status query */ +#if 0 +#define xxx 0x3 /* 0x3 reserved */ +#endif + /* non standard - supports ALLOW_UPDATES stuff from Mike Schwartz */ +#define UPDATEA 0x9 /* add resource record */ +#define UPDATED 0xa /* delete a specific resource record */ +#define UPDATEDA 0xb /* delete all named resource record */ +#define UPDATEM 0xc /* modify a specific resource record */ +#define UPDATEMA 0xd /* modify all named resource record */ + +#define ZONEINIT 0xe /* initial zone transfer */ +#define ZONEREF 0xf /* incremental zone referesh */ + +/* + * Undefine various #defines from various System V-flavored OSes (Solaris, + * SINIX, HP-UX) so the compiler doesn't whine that we redefine them. + */ +#ifdef T_NULL +#undef T_NULL +#endif +#ifdef T_OPT +#undef T_OPT +#endif +#ifdef T_UNSPEC +#undef T_UNSPEC +#endif +#ifdef NOERROR +#undef NOERROR +#endif + +/* + * Currently defined response codes + */ +#define NOERROR 0 /* no error */ +#define FORMERR 1 /* format error */ +#define SERVFAIL 2 /* server failure */ +#define NXDOMAIN 3 /* non existent domain */ +#define NOTIMP 4 /* not implemented */ +#define REFUSED 5 /* query refused */ + /* non standard */ +#define NOCHANGE 0xf /* update failed to change db */ + +/* + * Type values for resources and queries + */ +#define T_A 1 /* host address */ +#define T_NS 2 /* authoritative server */ +#define T_MD 3 /* mail destination */ +#define T_MF 4 /* mail forwarder */ +#define T_CNAME 5 /* connonical name */ +#define T_SOA 6 /* start of authority zone */ +#define T_MB 7 /* mailbox domain name */ +#define T_MG 8 /* mail group member */ +#define T_MR 9 /* mail rename name */ +#define T_NULL 10 /* null resource record */ +#define T_WKS 11 /* well known service */ +#define T_PTR 12 /* domain name pointer */ +#define T_HINFO 13 /* host information */ +#define T_MINFO 14 /* mailbox information */ +#define T_MX 15 /* mail routing information */ +#define T_TXT 16 /* text strings */ +#define T_RP 17 /* responsible person */ +#define T_AFSDB 18 /* AFS cell database */ +#define T_X25 19 /* X_25 calling address */ +#define T_ISDN 20 /* ISDN calling address */ +#define T_RT 21 /* router */ +#define T_NSAP 22 /* NSAP address */ +#define T_NSAP_PTR 23 /* reverse lookup for NSAP */ +#define T_SIG 24 /* security signature */ +#define T_KEY 25 /* security key */ +#define T_PX 26 /* X.400 mail mapping */ +#define T_GPOS 27 /* geographical position (withdrawn) */ +#define T_AAAA 28 /* IP6 Address */ +#define T_LOC 29 /* Location Information */ +#define T_NXT 30 /* Next Valid Name in Zone */ +#define T_EID 31 /* Endpoint identifier */ +#define T_NIMLOC 32 /* Nimrod locator */ +#define T_SRV 33 /* Server selection */ +#define T_ATMA 34 /* ATM Address */ +#define T_NAPTR 35 /* Naming Authority PoinTeR */ +#define T_KX 36 /* Key Exchanger */ +#define T_CERT 37 /* Certificates in the DNS */ +#define T_A6 38 /* IP6 address */ +#define T_DNAME 39 /* non-terminal redirection */ +#define T_SINK 40 /* unknown */ +#define T_OPT 41 /* EDNS0 option (meta-RR) */ +#define T_APL 42 /* lists of address prefixes */ +#define T_DS 43 /* Delegation Signer */ +#define T_SSHFP 44 /* SSH Fingerprint */ +#define T_IPSECKEY 45 /* IPsec keying material */ +#define T_RRSIG 46 /* new security signature */ +#define T_NSEC 47 /* provable insecure information */ +#define T_DNSKEY 48 /* new security key */ + /* non standard */ +#define T_SPF 99 /* sender policy framework */ +#define T_UINFO 100 /* user (finger) information */ +#define T_UID 101 /* user ID */ +#define T_GID 102 /* group ID */ +#define T_UNSPEC 103 /* Unspecified format (binary data) */ +#define T_UNSPECA 104 /* "unspecified ascii". Ugly MIT hack */ + /* Query type values which do not appear in resource records */ +#define T_TKEY 249 /* Transaction Key [RFC2930] */ +#define T_TSIG 250 /* Transaction Signature [RFC2845] */ +#define T_IXFR 251 /* incremental transfer [RFC1995] */ +#define T_AXFR 252 /* transfer zone of authority */ +#define T_MAILB 253 /* transfer mailbox records */ +#define T_MAILA 254 /* transfer mail agent records */ +#define T_ANY 255 /* wildcard match */ + +/* + * Values for class field + */ + +#define C_IN 1 /* the arpa internet */ +#define C_CHAOS 3 /* for chaos net (MIT) */ +#define C_HS 4 /* for Hesiod name server (MIT) (XXX) */ + /* Query class values which do not appear in resource records */ +#define C_ANY 255 /* wildcard match */ +#define C_QU 0x8000 /* mDNS QU flag in queries */ +#define C_CACHE_FLUSH 0x8000 /* mDNS cache flush flag in replies */ + +/* + * Status return codes for T_UNSPEC conversion routines + */ +#define CONV_SUCCESS 0 +#define CONV_OVERFLOW -1 +#define CONV_BADFMT -2 +#define CONV_BADCKSUM -3 +#define CONV_BADBUFLEN -4 + +/* + * Structure for query header. + */ +typedef struct { + u_int16_t id; /* query identification number */ + u_int8_t flags1; /* first byte of flags */ + u_int8_t flags2; /* second byte of flags */ + u_int16_t qdcount; /* number of question entries */ + u_int16_t ancount; /* number of answer entries */ + u_int16_t nscount; /* number of authority entries */ + u_int16_t arcount; /* number of resource entries */ +} HEADER; + +/* + * Macros for subfields of flag fields. + */ +#define DNS_QR(np) ((np)->flags1 & 0x80) /* response flag */ +#define DNS_OPCODE(np) ((((np)->flags1) >> 3) & 0xF) /* purpose of message */ +#define DNS_AA(np) ((np)->flags1 & 0x04) /* authoritative answer */ +#define DNS_TC(np) ((np)->flags1 & 0x02) /* truncated message */ +#define DNS_RD(np) ((np)->flags1 & 0x01) /* recursion desired */ + +#define DNS_RA(np) ((np)->flags2 & 0x80) /* recursion available */ +#define DNS_AD(np) ((np)->flags2 & 0x20) /* authentic data from named */ +#define DNS_CD(np) ((np)->flags2 & 0x10) /* checking disabled by resolver */ +#define DNS_RCODE(np) ((np)->flags2 & 0xF) /* response code */ + +/* + * Defines for handling compressed domain names, EDNS0 labels, etc. + */ +#define INDIR_MASK 0xc0 /* 11.... */ +#define EDNS0_MASK 0x40 /* 01.... */ +# define EDNS0_ELT_BITLABEL 0x01 + +/* + * Structure for passing resource records around. + */ +struct rrec { + int16_t r_zone; /* zone number */ + int16_t r_class; /* class number */ + int16_t r_type; /* type number */ + u_int32_t r_ttl; /* time to live */ + int r_size; /* size of data area */ + char *r_data; /* pointer to data */ +}; + +/* + * Inline versions of get/put short/long. Pointer is advanced. + * We also assume that a "u_int16_t" holds 2 "chars" + * and that a "u_int32_t" holds 4 "chars". + * + * These macros demonstrate the property of C whereby it can be + * portable or it can be elegant but never both. + */ +#define GETSHORT(s, cp) { \ + register u_char *t_cp = (u_char *)(cp); \ + (s) = ((u_int16_t)t_cp[0] << 8) | (u_int16_t)t_cp[1]; \ + (cp) += 2; \ +} + +#define GETLONG(l, cp) { \ + register u_char *t_cp = (u_char *)(cp); \ + (l) = (((u_int32_t)t_cp[0]) << 24) \ + | (((u_int32_t)t_cp[1]) << 16) \ + | (((u_int32_t)t_cp[2]) << 8) \ + | (((u_int32_t)t_cp[3])); \ + (cp) += 4; \ +} + +#define PUTSHORT(s, cp) { \ + register u_int16_t t_s = (u_int16_t)(s); \ + register u_char *t_cp = (u_char *)(cp); \ + *t_cp++ = t_s >> 8; \ + *t_cp = t_s; \ + (cp) += 2; \ +} + +/* + * Warning: PUTLONG --no-longer-- destroys its first argument. if you + * were depending on this "feature", you will lose. + */ +#define PUTLONG(l, cp) { \ + register u_int32_t t_l = (u_int32_t)(l); \ + register u_char *t_cp = (u_char *)(cp); \ + *t_cp++ = t_l >> 24; \ + *t_cp++ = t_l >> 16; \ + *t_cp++ = t_l >> 8; \ + *t_cp = t_l; \ + (cp) += 4; \ +} + +#endif /* !_NAMESER_H_ */
diff --git a/tcpdump-4.3.0/netbios.h b/tcpdump-4.3.0/netbios.h new file mode 100644 index 0000000..d3e2725 --- /dev/null +++ b/tcpdump-4.3.0/netbios.h
@@ -0,0 +1,16 @@ +/* + * NETBIOS protocol formats + * + * @(#) $Header: /tcpdump/master/tcpdump/netbios.h,v 1.3 2002-12-11 07:13:55 guy Exp $ + */ + +struct p8022Hdr { + u_char dsap; + u_char ssap; + u_char flags; +}; + +#define p8022Size 3 /* min 802.2 header size */ + +#define UI 0x03 /* 802.2 flags */ +
diff --git a/tcpdump-4.3.0/netdissect.h b/tcpdump-4.3.0/netdissect.h new file mode 100644 index 0000000..821949f --- /dev/null +++ b/tcpdump-4.3.0/netdissect.h
@@ -0,0 +1,508 @@ +/* + * Copyright (c) 1988-1997 + * The Regents of the University of California. All rights reserved. + * + * Copyright (c) 1998-2004 Michael Richardson <mcr@tcpdump.org> + * The TCPDUMP project + * + * 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/netdissect.h,v 1.27 2008-08-16 11:36:20 hannes Exp $ (LBL) + */ + +#ifndef netdissect_h +#define netdissect_h + +#ifdef HAVE_OS_PROTO_H +#include "os-proto.h" +#endif +#include <sys/types.h> + +#ifndef HAVE___ATTRIBUTE__ +#define __attribute__(x) +#endif + +/* snprintf et al */ + +#include <stdarg.h> + +#if !defined(HAVE_SNPRINTF) +int snprintf (char *str, size_t sz, const char *format, ...) + __attribute__ ((format (printf, 3, 4))); +#endif + +#if !defined(HAVE_VSNPRINTF) +int vsnprintf (char *str, size_t sz, const char *format, va_list ap) + __attribute__((format (printf, 3, 0))); +#endif + +#ifndef HAVE_STRLCAT +extern size_t strlcat (char *, const char *, size_t); +#endif +#ifndef HAVE_STRLCPY +extern size_t strlcpy (char *, const char *, size_t); +#endif + +#ifndef HAVE_STRDUP +extern char *strdup (const char *str); +#endif + +#ifndef HAVE_STRSEP +extern char *strsep(char **, const char *); +#endif + +struct tok { + int v; /* value */ + const char *s; /* string */ +}; + +#define TOKBUFSIZE 128 +extern const char *tok2strbuf(const struct tok *, const char *, int, + char *buf, size_t bufsize); + +/* tok2str is deprecated */ +extern const char *tok2str(const struct tok *, const char *, int); +extern char *bittok2str(const struct tok *, const char *, int); +extern char *bittok2str_nosep(const struct tok *, const char *, int); + + +typedef struct netdissect_options netdissect_options; + +struct netdissect_options { + int ndo_aflag; /* translate network and broadcast addresses */ + int ndo_bflag; /* print 4 byte ASes in ASDOT notation */ + int ndo_eflag; /* print ethernet header */ + int ndo_fflag; /* don't translate "foreign" IP address */ + int ndo_Kflag; /* don't check TCP checksums */ + int ndo_nflag; /* leave addresses as numbers */ + int ndo_Nflag; /* remove domains from printed host names */ + int ndo_qflag; /* quick (shorter) output */ + int ndo_Rflag; /* print sequence # field in AH/ESP*/ + int ndo_sflag; /* use the libsmi to translate OIDs */ + int ndo_Sflag; /* print raw TCP sequence numbers */ + int ndo_tflag; /* print packet arrival time */ + int ndo_Uflag; /* "unbuffered" output of dump files */ + int ndo_uflag; /* Print undecoded NFS handles */ + int ndo_vflag; /* verbose */ + int ndo_xflag; /* print packet in hex */ + int ndo_Xflag; /* print packet in hex/ascii */ + int ndo_Aflag; /* print packet only in ascii observing TAB, + * LF, CR and SPACE as graphical chars + */ + int ndo_Bflag; /* buffer size */ + int ndo_Iflag; /* rfmon (monitor) mode */ + int ndo_Oflag; /* run filter code optimizer */ + int ndo_dlt; /* if != -1, ask libpcap for the DLT it names*/ + int ndo_jflag; /* packet time stamp source */ + int ndo_pflag; /* don't go promiscuous */ + + int ndo_Cflag; /* rotate dump files after this many bytes */ + int ndo_Cflag_count; /* Keep track of which file number we're writing */ + int ndo_Gflag; /* rotate dump files after this many seconds */ + int ndo_Gflag_count; /* number of files created with Gflag rotation */ + time_t ndo_Gflag_time; /* The last time_t the dump file was rotated. */ + int ndo_Wflag; /* recycle output files after this number of files */ + int ndo_WflagChars; + int ndo_Hflag; /* dissect 802.11s draft mesh standard */ + int ndo_suppress_default_print; /* don't use default_print() for unknown packet types */ + const char *ndo_dltname; + + char *ndo_espsecret; + struct sa_list *ndo_sa_list_head; /* used by print-esp.c */ + struct sa_list *ndo_sa_default; + + char *ndo_sigsecret; /* Signature verification secret key */ + + struct esp_algorithm *ndo_espsecret_xform; /* cache of decoded */ + char *ndo_espsecret_key; + + int ndo_packettype; /* as specified by -T */ + + char *ndo_program_name; /*used to generate self-identifying messages */ + + int32_t ndo_thiszone; /* seconds offset from gmt to local time */ + + int ndo_snaplen; + + /*global pointers to beginning and end of current packet (during printing) */ + const u_char *ndo_packetp; + const u_char *ndo_snapend; + + /* bookkeeping for ^T output */ + int ndo_infodelay; + + /* pointer to void function to output stuff */ + void (*ndo_default_print)(netdissect_options *, + register const u_char *bp, register u_int length); + void (*ndo_info)(netdissect_options *, int verbose); + + int (*ndo_printf)(netdissect_options *, + const char *fmt, ...) +#ifdef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS + __attribute__ ((format (printf, 2, 3))) +#endif + ; + void (*ndo_error)(netdissect_options *, + const char *fmt, ...) +#ifdef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS + __attribute__ ((noreturn, format (printf, 2, 3))) +#endif + ; + void (*ndo_warning)(netdissect_options *, + const char *fmt, ...) +#ifdef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS + __attribute__ ((format (printf, 2, 3))) +#endif + ; +}; + +#define PT_VAT 1 /* Visual Audio Tool */ +#define PT_WB 2 /* distributed White Board */ +#define PT_RPC 3 /* Remote Procedure Call */ +#define PT_RTP 4 /* Real-Time Applications protocol */ +#define PT_RTCP 5 /* Real-Time Applications control protocol */ +#define PT_SNMP 6 /* Simple Network Management Protocol */ +#define PT_CNFP 7 /* Cisco NetFlow protocol */ + +#ifndef min +#define min(a,b) ((a)>(b)?(b):(a)) +#endif +#ifndef max +#define max(a,b) ((b)>(a)?(b):(a)) +#endif + +/* + * Maximum snapshot length. This should be enough to capture the full + * packet on most network interfaces. + * + * XXX - could it be larger? If so, should it? Some applications might + * use the snapshot length in a savefile header to control the size of + * the buffer they allocate, so a size of, say, 2^31-1 might not work + * well. + */ +#define MAXIMUM_SNAPLEN 65535 + +/* + * The default snapshot length is the maximum. + */ +#define DEFAULT_SNAPLEN MAXIMUM_SNAPLEN + +#define ESRC(ep) ((ep)->ether_shost) +#define EDST(ep) ((ep)->ether_dhost) + +#ifndef NTOHL +#define NTOHL(x) (x) = ntohl(x) +#define NTOHS(x) (x) = ntohs(x) +#define HTONL(x) (x) = htonl(x) +#define HTONS(x) (x) = htons(x) +#endif + +/* + * True if "l" bytes of "var" were captured. + * + * The "ndo->ndo_snapend - (l) <= ndo->ndo_snapend" checks to make sure + * "l" isn't so large that "ndo->ndo_snapend - (l)" underflows. + * + * The check is for <= rather than < because "l" might be 0. + */ +#define ND_TTEST2(var, l) (ndo->ndo_snapend - (l) <= ndo->ndo_snapend && \ + (const u_char *)&(var) <= ndo->ndo_snapend - (l)) + +/* True if "var" was captured */ +#define ND_TTEST(var) ND_TTEST2(var, sizeof(var)) + +/* Bail if "l" bytes of "var" were not captured */ +#define ND_TCHECK2(var, l) if (!ND_TTEST2(var, l)) goto trunc + +/* Bail if "var" was not captured */ +#define ND_TCHECK(var) ND_TCHECK2(var, sizeof(var)) + +#define ND_PRINT(STUFF) (*ndo->ndo_printf)STUFF +#define ND_DEFAULTPRINT(ap, length) (*ndo->ndo_default_print)(ndo, ap, length) + +#if 0 +extern void ts_print(netdissect_options *ipdo, + const struct timeval *); +extern void relts_print(int); +#endif + +extern int fn_print(const u_char *, const u_char *); +extern int fn_printn(const u_char *, u_int, const u_char *); +extern const char *tok2str(const struct tok *, const char *, int); + +extern void wrapup(int); + +#if 0 +extern char *read_infile(netdissect_options *, char *); +extern char *copy_argv(netdissect_options *, char **); +#endif + +extern void safeputchar(int); +extern void safeputs(const char *, int); + +#define PLURAL_SUFFIX(n) \ + (((n) != 1) ? "s" : "") + +#if 0 +extern const char *isonsap_string(netdissect_options *, const u_char *); +extern const char *protoid_string(netdissect_options *, const u_char *); +extern const char *dnname_string(netdissect_options *, u_short); +extern const char *dnnum_string(netdissect_options *, u_short); +#endif + +/* The printer routines. */ + +#include <pcap.h> + +typedef u_int (*if_ndo_printer)(struct netdissect_options *ndo, + const struct pcap_pkthdr *, const u_char *); +typedef u_int (*if_printer)(const struct pcap_pkthdr *, const u_char *); + +extern if_ndo_printer lookup_ndo_printer(int); +extern if_printer lookup_printer(int); + +extern void eap_print(netdissect_options *,const u_char *, u_int); +extern int esp_print(netdissect_options *, + register const u_char *bp, int len, register const u_char *bp2, + int *nhdr, int *padlen); +extern void arp_print(netdissect_options *,const u_char *, u_int, u_int); +extern void tipc_print(netdissect_options *, const u_char *, u_int, u_int); +extern void icmp6_print(netdissect_options *ndo, const u_char *, + u_int, const u_char *, int); +extern void isakmp_print(netdissect_options *,const u_char *, + u_int, const u_char *); +extern void isakmp_rfc3948_print(netdissect_options *,const u_char *, + u_int, const u_char *); +extern void ip_print(netdissect_options *,const u_char *, u_int); +extern void ip_print_inner(netdissect_options *ndo, + const u_char *bp, u_int length, u_int nh, + const u_char *bp2); +extern void rrcp_print(netdissect_options *,const u_char *, u_int); + +extern void ether_print(netdissect_options *, + const u_char *, u_int, u_int, + void (*)(netdissect_options *, const u_char *), + const u_char *); + +extern u_int ether_if_print(netdissect_options *, + const struct pcap_pkthdr *,const u_char *); +extern u_int netanalyzer_if_print(netdissect_options *, + const struct pcap_pkthdr *,const u_char *); +extern u_int netanalyzer_transparent_if_print(netdissect_options *, + const struct pcap_pkthdr *, + const u_char *); + +extern int ethertype_print(netdissect_options *,u_short, const u_char *, + u_int, u_int); + +/* stuff that has not yet been rototiled */ +#if 0 +extern void ascii_print(netdissect_options *,u_int); +extern void hex_and_ascii_print_with_offset(netdissect_options *,const char *, + u_int, u_int); +extern void hex_and_ascii_print(netdissect_options *,const char *, u_int); +extern void hex_print_with_offset(netdissect_options *,const char *, + u_int, u_int); +extern void hex_print(netdissect_options *,const char *, u_int); +extern void telnet_print(netdissect_options *,const u_char *, u_int); +extern int llc_print(netdissect_options *, + const u_char *, u_int, u_int, const u_char *, + const u_char *, u_short *); +extern void aarp_print(netdissect_options *,const u_char *, u_int); +extern void atalk_print(netdissect_options *,const u_char *, u_int); +extern void atm_if_print(u_char *,const struct pcap_pkthdr *, const u_char *); +extern void bootp_print(netdissect_options *,const u_char *, + u_int, u_short, u_short); +extern void bgp_print(netdissect_options *,const u_char *, int); +extern void bxxp_print(netdissect_options *,const u_char *, u_int); +extern void chdlc_if_print(u_char *user, const struct pcap_pkthdr *h, + register const u_char *p); +extern void chdlc_print(netdissect_options *ndo, + register const u_char *p, u_int length, u_int caplen); +extern void cisco_autorp_print(netdissect_options *, + const u_char *, u_int); +extern void cnfp_print(netdissect_options *,const u_char *cp, + u_int len, const u_char *bp); +extern void decnet_print(netdissect_options *,const u_char *, + u_int, u_int); +extern void default_print(netdissect_options *,const u_char *, u_int); +extern void dvmrp_print(netdissect_options *,const u_char *, u_int); +extern void egp_print(netdissect_options *,const u_char *, u_int, + const u_char *); + +extern void arcnet_if_print(u_char*,const struct pcap_pkthdr *,const u_char *); +extern void token_if_print(u_char *,const struct pcap_pkthdr *,const u_char *); +extern void fddi_if_print(u_char *,const struct pcap_pkthdr *, const u_char *); + +extern void gre_print(netdissect_options *,const u_char *, u_int); +extern void icmp_print(netdissect_options *,const u_char *, u_int, + const u_char *); +extern void hsrp_print(netdissect_options *ndo, + register const u_char *bp, register u_int len); +extern void ieee802_11_if_print(u_char *,const struct pcap_pkthdr *, const u_char *); +extern void igmp_print(netdissect_options *, + register const u_char *, u_int); +extern void igrp_print(netdissect_options *,const u_char *, u_int, + const u_char *); +extern int nextproto4_cksum(const struct ip *, const u_int8_t *, u_int, u_int); +extern void ipN_print(netdissect_options *,const u_char *, u_int); +extern void ipx_print(netdissect_options *,const u_char *, u_int); +extern void isoclns_print(netdissect_options *,const u_char *, + u_int, u_int, const u_char *, const u_char *); +extern void krb_print(netdissect_options *,const u_char *, u_int); +extern void llap_print(netdissect_options *,const u_char *, u_int); +extern const char *linkaddr_string(netdissect_options *ndo, + const u_char *ep, const unsigned int len); +extern void ltalk_if_print(netdissect_options *ndo, + u_char *user, const struct pcap_pkthdr *h, + const u_char *p); +extern void mpls_print(netdissect_options *ndo, + const u_char *bp, u_int length); +extern void msdp_print(netdissect_options *ndo, + const unsigned char *sp, u_int length); +extern void nfsreply_print(netdissect_options *,const u_char *, + u_int, const u_char *); +extern void nfsreq_print(netdissect_options *,const u_char *, + u_int, const u_char *); +extern void ns_print(netdissect_options *,const u_char *, u_int); +extern void ntp_print(netdissect_options *,const u_char *, u_int); +extern void null_if_print(u_char *,const struct pcap_pkthdr *, const u_char *); +extern void ospf_print(netdissect_options *,const u_char *, + u_int, const u_char *); +extern void pimv1_print(netdissect_options *,const u_char *, u_int); +extern void mobile_print(netdissect_options *,const u_char *, u_int); +extern void pim_print(netdissect_options *,const u_char *, u_int, u_int); +extern void pppoe_if_print(u_char *,const struct pcap_pkthdr *, const u_char *); +extern void pppoe_print(netdissect_options *,const u_char *, u_int); +extern void ppp_print(netdissect_options *, + register const u_char *, u_int); + +extern void ppp_if_print(u_char *,const struct pcap_pkthdr *, const u_char *); +extern void ppp_hdlc_if_print(u_char *, + const struct pcap_pkthdr *, const u_char *); +extern void ppp_bsdos_if_print(u_char *, + const struct pcap_pkthdr *, const u_char *); + +extern int vjc_print(netdissect_options *,register const char *, + register u_int, u_short); + +extern void raw_if_print(u_char *, + const struct pcap_pkthdr *, const u_char *); + +extern void rip_print(netdissect_options *,const u_char *, u_int); +extern void rpki_rtr_print(netdissect_options *,const u_char *, u_int); + +extern void sctp_print(netdissect_options *ndo, + const u_char *bp, const u_char *bp2, + u_int sctpPacketLength); + +extern void sl_if_print(u_char *,const struct pcap_pkthdr *, const u_char *); + +extern void lane_if_print(u_char *,const struct pcap_pkthdr *,const u_char *); +extern void cip_if_print(u_char *,const struct pcap_pkthdr *,const u_char *); +extern void sl_bsdos_if_print(u_char *, + const struct pcap_pkthdr *, const u_char *); +extern void sll_if_print(u_char *, + const struct pcap_pkthdr *, const u_char *); + +extern void snmp_print(netdissect_options *,const u_char *, u_int); +extern void sunrpcrequest_print(netdissect_options *,const u_char *, + u_int, const u_char *); +extern void tcp_print(netdissect_options *,const u_char *, u_int, + const u_char *, int); +extern void tftp_print(netdissect_options *,const u_char *, u_int); +extern void timed_print(netdissect_options *,const u_char *, u_int); +extern void udp_print(netdissect_options *,const u_char *, u_int, + const u_char *, int); +extern void wb_print(netdissect_options *,const void *, u_int); +extern int ah_print(netdissect_options *,register const u_char *, + register const u_char *); +extern void esp_print_decodesecret(netdissect_options *ndo); +extern int ipcomp_print(netdissect_options *,register const u_char *, + register const u_char *, int *); +extern void rx_print(netdissect_options *,register const u_char *, + int, int, int, u_char *); +extern void netbeui_print(netdissect_options *,u_short, + const u_char *, int); +extern void ipx_netbios_print(netdissect_options *,const u_char *, u_int); +extern void nbt_tcp_print(netdissect_options *,const u_char *, int); +extern void nbt_udp137_print(netdissect_options *, + const u_char *data, int); +extern void nbt_udp138_print(netdissect_options *, + const u_char *data, int); +extern char *smb_errstr(netdissect_options *,int, int); +extern const char *nt_errstr(netdissect_options *, u_int32_t); +extern void print_data(netdissect_options *,const unsigned char *, int); +extern void l2tp_print(netdissect_options *,const u_char *, u_int); +extern void lcp_print(netdissect_options *,const u_char *, u_int); +extern void vrrp_print(netdissect_options *,const u_char *bp, + u_int len, int ttl); +extern void carp_print(netdissect_options *,const u_char *bp, + u_int len, int ttl); +extern void cdp_print(netdissect_options *,const u_char *, + u_int, u_int, const u_char *, const u_char *); +extern void stp_print(netdissect_options *,const u_char *p, u_int length); +extern void radius_print(netdissect_options *,const u_char *, u_int); +extern void lwres_print(netdissect_options *,const u_char *, u_int); +extern void pptp_print(netdissect_options *,const u_char *, u_int); +#endif + +extern u_int ipnet_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *); +extern u_int ppi_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *); + +extern u_int ieee802_15_4_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *); + +#ifdef INET6 +extern void ip6_print(netdissect_options *,const u_char *, u_int); +#if 0 +extern void ip6_opt_print(netdissect_options *,const u_char *, int); +extern int nextproto6_cksum(const struct ip6_hdr *, const u_int8_t *, u_int, u_int); +extern int hbhopt_print(netdissect_options *,const u_char *); +extern int dstopt_print(netdissect_options *,const u_char *); +extern int frag6_print(netdissect_options *,const u_char *, + const u_char *); +extern void icmp6_print(netdissect_options *,const u_char *, + const u_char *); +extern void ripng_print(netdissect_options *,const u_char *, int); +extern int rt6_print(netdissect_options *,const u_char *, const u_char *); +extern void ospf6_print(netdissect_options *,const u_char *, u_int); +extern void dhcp6_print(netdissect_options *,const u_char *, + u_int, u_int16_t, u_int16_t); + +extern void zephyr_print(netdissect_options * ndo, + const u_char *cp, int length); +#endif /* 0 */ + +#endif /*INET6*/ + +#if 0 +struct cksum_vec { + const u_int8_t *ptr; + int len; +}; +extern u_int16_t in_cksum(const struct cksum_vec *, int); +extern u_int16_t in_cksum_shouldbe(u_int16_t, u_int16_t); +#endif + +extern void esp_print_decodesecret(netdissect_options *ndo); +extern int esp_print_decrypt_buffer_by_ikev2(netdissect_options *ndo, + int initiator, + u_char spii[8], u_char spir[8], + u_char *buf, u_char *end); + + +#endif /* netdissect_h */
diff --git a/tcpdump-4.3.0/nfs.h b/tcpdump-4.3.0/nfs.h new file mode 100644 index 0000000..a5b5025 --- /dev/null +++ b/tcpdump-4.3.0/nfs.h
@@ -0,0 +1,439 @@ +/* @(#) $Header: /tcpdump/master/tcpdump/nfs.h,v 1.9 2007-11-18 03:24:38 guy Exp $ (LBL) */ +/* NetBSD: nfs.h,v 1.1 1996/05/23 22:49:53 fvdl Exp */ + +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Rick Macklem at The University of Guelph. + * + * 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. + * + * @(#)nfsproto.h 8.2 (Berkeley) 3/30/95 + */ + +/* + * nfs definitions as per the Version 2 and 3 specs + */ + +/* + * Constants as defined in the Sun NFS Version 2 and 3 specs. + * "NFS: Network File System Protocol Specification" RFC1094 + * and in the "NFS: Network File System Version 3 Protocol + * Specification" + */ + +#define NFS_PORT 2049 +#define NFS_PROG 100003 +#define NFS_VER2 2 +#define NFS_VER3 3 +#define NFS_V2MAXDATA 8192 +#define NFS_MAXDGRAMDATA 16384 +#define NFS_MAXDATA 32768 +#define NFS_MAXPATHLEN 1024 +#define NFS_MAXNAMLEN 255 +#define NFS_MAXPKTHDR 404 +#define NFS_MAXPACKET (NFS_MAXPKTHDR + NFS_MAXDATA) +#define NFS_MINPACKET 20 +#define NFS_FABLKSIZE 512 /* Size in bytes of a block wrt fa_blocks */ + +/* Stat numbers for rpc returns (version 2 and 3) */ +#define NFS_OK 0 +#define NFSERR_PERM 1 +#define NFSERR_NOENT 2 +#define NFSERR_IO 5 +#define NFSERR_NXIO 6 +#define NFSERR_ACCES 13 +#define NFSERR_EXIST 17 +#define NFSERR_XDEV 18 /* Version 3 only */ +#define NFSERR_NODEV 19 +#define NFSERR_NOTDIR 20 +#define NFSERR_ISDIR 21 +#define NFSERR_INVAL 22 /* Version 3 only */ +#define NFSERR_FBIG 27 +#define NFSERR_NOSPC 28 +#define NFSERR_ROFS 30 +#define NFSERR_MLINK 31 /* Version 3 only */ +#define NFSERR_NAMETOL 63 +#define NFSERR_NOTEMPTY 66 +#define NFSERR_DQUOT 69 +#define NFSERR_STALE 70 +#define NFSERR_REMOTE 71 /* Version 3 only */ +#define NFSERR_WFLUSH 99 /* Version 2 only */ +#define NFSERR_BADHANDLE 10001 /* The rest Version 3 only */ +#define NFSERR_NOT_SYNC 10002 +#define NFSERR_BAD_COOKIE 10003 +#define NFSERR_NOTSUPP 10004 +#define NFSERR_TOOSMALL 10005 +#define NFSERR_SERVERFAULT 10006 +#define NFSERR_BADTYPE 10007 +#define NFSERR_JUKEBOX 10008 +#define NFSERR_TRYLATER NFSERR_JUKEBOX +#define NFSERR_STALEWRITEVERF 30001 /* Fake return for nfs_commit() */ + +#define NFSERR_RETVOID 0x20000000 /* Return void, not error */ +#define NFSERR_AUTHERR 0x40000000 /* Mark an authentication error */ +#define NFSERR_RETERR 0x80000000 /* Mark an error return for V3 */ + +/* Sizes in bytes of various nfs rpc components */ +#define NFSX_UNSIGNED 4 + +/* specific to NFS Version 2 */ +#define NFSX_V2FH 32 +#define NFSX_V2FATTR 68 +#define NFSX_V2SATTR 32 +#define NFSX_V2COOKIE 4 +#define NFSX_V2STATFS 20 + +/* specific to NFS Version 3 */ +#if 0 +#define NFSX_V3FH (sizeof (fhandle_t)) /* size this server uses */ +#endif +#define NFSX_V3FHMAX 64 /* max. allowed by protocol */ +#define NFSX_V3FATTR 84 +#define NFSX_V3SATTR 60 /* max. all fields filled in */ +#define NFSX_V3SRVSATTR (sizeof (struct nfsv3_sattr)) +#define NFSX_V3POSTOPATTR (NFSX_V3FATTR + NFSX_UNSIGNED) +#define NFSX_V3WCCDATA (NFSX_V3POSTOPATTR + 8 * NFSX_UNSIGNED) +#define NFSX_V3COOKIEVERF 8 +#define NFSX_V3WRITEVERF 8 +#define NFSX_V3CREATEVERF 8 +#define NFSX_V3STATFS 52 +#define NFSX_V3FSINFO 48 +#define NFSX_V3PATHCONF 24 + +/* variants for both versions */ +#define NFSX_FH(v3) ((v3) ? (NFSX_V3FHMAX + NFSX_UNSIGNED) : \ + NFSX_V2FH) +#define NFSX_SRVFH(v3) ((v3) ? NFSX_V3FH : NFSX_V2FH) +#define NFSX_FATTR(v3) ((v3) ? NFSX_V3FATTR : NFSX_V2FATTR) +#define NFSX_PREOPATTR(v3) ((v3) ? (7 * NFSX_UNSIGNED) : 0) +#define NFSX_POSTOPATTR(v3) ((v3) ? (NFSX_V3FATTR + NFSX_UNSIGNED) : 0) +#define NFSX_POSTOPORFATTR(v3) ((v3) ? (NFSX_V3FATTR + NFSX_UNSIGNED) : \ + NFSX_V2FATTR) +#define NFSX_WCCDATA(v3) ((v3) ? NFSX_V3WCCDATA : 0) +#define NFSX_WCCORFATTR(v3) ((v3) ? NFSX_V3WCCDATA : NFSX_V2FATTR) +#define NFSX_SATTR(v3) ((v3) ? NFSX_V3SATTR : NFSX_V2SATTR) +#define NFSX_COOKIEVERF(v3) ((v3) ? NFSX_V3COOKIEVERF : 0) +#define NFSX_WRITEVERF(v3) ((v3) ? NFSX_V3WRITEVERF : 0) +#define NFSX_READDIR(v3) ((v3) ? (5 * NFSX_UNSIGNED) : \ + (2 * NFSX_UNSIGNED)) +#define NFSX_STATFS(v3) ((v3) ? NFSX_V3STATFS : NFSX_V2STATFS) + +/* nfs rpc procedure numbers (before version mapping) */ +#define NFSPROC_NULL 0 +#define NFSPROC_GETATTR 1 +#define NFSPROC_SETATTR 2 +#define NFSPROC_LOOKUP 3 +#define NFSPROC_ACCESS 4 +#define NFSPROC_READLINK 5 +#define NFSPROC_READ 6 +#define NFSPROC_WRITE 7 +#define NFSPROC_CREATE 8 +#define NFSPROC_MKDIR 9 +#define NFSPROC_SYMLINK 10 +#define NFSPROC_MKNOD 11 +#define NFSPROC_REMOVE 12 +#define NFSPROC_RMDIR 13 +#define NFSPROC_RENAME 14 +#define NFSPROC_LINK 15 +#define NFSPROC_READDIR 16 +#define NFSPROC_READDIRPLUS 17 +#define NFSPROC_FSSTAT 18 +#define NFSPROC_FSINFO 19 +#define NFSPROC_PATHCONF 20 +#define NFSPROC_COMMIT 21 + +/* And leasing (nqnfs) procedure numbers (must be last) */ +#define NQNFSPROC_GETLEASE 22 +#define NQNFSPROC_VACATED 23 +#define NQNFSPROC_EVICTED 24 + +#define NFSPROC_NOOP 25 +#define NFS_NPROCS 26 + +/* Actual Version 2 procedure numbers */ +#define NFSV2PROC_NULL 0 +#define NFSV2PROC_GETATTR 1 +#define NFSV2PROC_SETATTR 2 +#define NFSV2PROC_NOOP 3 +#define NFSV2PROC_ROOT NFSV2PROC_NOOP /* Obsolete */ +#define NFSV2PROC_LOOKUP 4 +#define NFSV2PROC_READLINK 5 +#define NFSV2PROC_READ 6 +#define NFSV2PROC_WRITECACHE NFSV2PROC_NOOP /* Obsolete */ +#define NFSV2PROC_WRITE 8 +#define NFSV2PROC_CREATE 9 +#define NFSV2PROC_REMOVE 10 +#define NFSV2PROC_RENAME 11 +#define NFSV2PROC_LINK 12 +#define NFSV2PROC_SYMLINK 13 +#define NFSV2PROC_MKDIR 14 +#define NFSV2PROC_RMDIR 15 +#define NFSV2PROC_READDIR 16 +#define NFSV2PROC_STATFS 17 + +/* + * Constants used by the Version 3 protocol for various RPCs + */ +#define NFSV3SATTRTIME_DONTCHANGE 0 +#define NFSV3SATTRTIME_TOSERVER 1 +#define NFSV3SATTRTIME_TOCLIENT 2 + +#define NFSV3ATTRTIME_NMODES 3 + +#define NFSV3ACCESS_READ 0x01 +#define NFSV3ACCESS_LOOKUP 0x02 +#define NFSV3ACCESS_MODIFY 0x04 +#define NFSV3ACCESS_EXTEND 0x08 +#define NFSV3ACCESS_DELETE 0x10 +#define NFSV3ACCESS_EXECUTE 0x20 +#define NFSV3ACCESS_FULL 0x3f + +#define NFSV3WRITE_UNSTABLE 0 +#define NFSV3WRITE_DATASYNC 1 +#define NFSV3WRITE_FILESYNC 2 + +#define NFSV3WRITE_NMODES 3 + +#define NFSV3CREATE_UNCHECKED 0 +#define NFSV3CREATE_GUARDED 1 +#define NFSV3CREATE_EXCLUSIVE 2 + +#define NFSV3CREATE_NMODES 3 + +#define NFSV3FSINFO_LINK 0x01 +#define NFSV3FSINFO_SYMLINK 0x02 +#define NFSV3FSINFO_HOMOGENEOUS 0x08 +#define NFSV3FSINFO_CANSETTIME 0x10 + +/* Conversion macros */ +#define vtonfsv2_mode(t,m) \ + txdr_unsigned(((t) == VFIFO) ? MAKEIMODE(VCHR, (m)) : \ + MAKEIMODE((t), (m))) +#define vtonfsv3_mode(m) txdr_unsigned((m) & 07777) +#define nfstov_mode(a) (fxdr_unsigned(u_int16_t, (a))&07777) +#define vtonfsv2_type(a) txdr_unsigned(nfsv2_type[((int32_t)(a))]) +#define vtonfsv3_type(a) txdr_unsigned(nfsv3_type[((int32_t)(a))]) +#define nfsv2tov_type(a) nv2tov_type[fxdr_unsigned(u_int32_t,(a))&0x7] +#define nfsv3tov_type(a) nv3tov_type[fxdr_unsigned(u_int32_t,(a))&0x7] + +/* File types */ +typedef enum { NFNON=0, NFREG=1, NFDIR=2, NFBLK=3, NFCHR=4, NFLNK=5, + NFSOCK=6, NFFIFO=7 } nfs_type; + +/* Structs for common parts of the rpc's */ +/* + * File Handle (32 bytes for version 2), variable up to 64 for version 3. + * File Handles of up to NFS_SMALLFH in size are stored directly in the + * nfs node, whereas larger ones are malloc'd. (This never happens when + * NFS_SMALLFH is set to 64.) + * NFS_SMALLFH should be in the range of 32 to 64 and be divisible by 4. + */ +#ifndef NFS_SMALLFH +#define NFS_SMALLFH 64 +#endif +union nfsfh { +/* fhandle_t fh_generic; */ + u_char fh_bytes[NFS_SMALLFH]; +}; +typedef union nfsfh nfsfh_t; + +struct nfsv2_time { + u_int32_t nfsv2_sec; + u_int32_t nfsv2_usec; +}; +typedef struct nfsv2_time nfstime2; + +struct nfsv3_time { + u_int32_t nfsv3_sec; + u_int32_t nfsv3_nsec; +}; +typedef struct nfsv3_time nfstime3; + +/* + * Quads are defined as arrays of 2 longs to ensure dense packing for the + * protocol and to facilitate xdr conversion. + */ +struct nfs_uquad { + u_int32_t nfsuquad[2]; +}; +typedef struct nfs_uquad nfsuint64; + +/* + * NFS Version 3 special file number. + */ +struct nfsv3_spec { + u_int32_t specdata1; + u_int32_t specdata2; +}; +typedef struct nfsv3_spec nfsv3spec; + +/* + * File attributes and setable attributes. These structures cover both + * NFS version 2 and the version 3 protocol. Note that the union is only + * used so that one pointer can refer to both variants. These structures + * go out on the wire and must be densely packed, so no quad data types + * are used. (all fields are longs or u_longs or structures of same) + * NB: You can't do sizeof(struct nfs_fattr), you must use the + * NFSX_FATTR(v3) macro. + */ +struct nfs_fattr { + u_int32_t fa_type; + u_int32_t fa_mode; + u_int32_t fa_nlink; + u_int32_t fa_uid; + u_int32_t fa_gid; + union { + struct { + u_int32_t nfsv2fa_size; + u_int32_t nfsv2fa_blocksize; + u_int32_t nfsv2fa_rdev; + u_int32_t nfsv2fa_blocks; + u_int32_t nfsv2fa_fsid; + u_int32_t nfsv2fa_fileid; + nfstime2 nfsv2fa_atime; + nfstime2 nfsv2fa_mtime; + nfstime2 nfsv2fa_ctime; + } fa_nfsv2; + struct { + nfsuint64 nfsv3fa_size; + nfsuint64 nfsv3fa_used; + nfsv3spec nfsv3fa_rdev; + nfsuint64 nfsv3fa_fsid; + nfsuint64 nfsv3fa_fileid; + nfstime3 nfsv3fa_atime; + nfstime3 nfsv3fa_mtime; + nfstime3 nfsv3fa_ctime; + } fa_nfsv3; + } fa_un; +}; + +/* and some ugly defines for accessing union components */ +#define fa2_size fa_un.fa_nfsv2.nfsv2fa_size +#define fa2_blocksize fa_un.fa_nfsv2.nfsv2fa_blocksize +#define fa2_rdev fa_un.fa_nfsv2.nfsv2fa_rdev +#define fa2_blocks fa_un.fa_nfsv2.nfsv2fa_blocks +#define fa2_fsid fa_un.fa_nfsv2.nfsv2fa_fsid +#define fa2_fileid fa_un.fa_nfsv2.nfsv2fa_fileid +#define fa2_atime fa_un.fa_nfsv2.nfsv2fa_atime +#define fa2_mtime fa_un.fa_nfsv2.nfsv2fa_mtime +#define fa2_ctime fa_un.fa_nfsv2.nfsv2fa_ctime +#define fa3_size fa_un.fa_nfsv3.nfsv3fa_size +#define fa3_used fa_un.fa_nfsv3.nfsv3fa_used +#define fa3_rdev fa_un.fa_nfsv3.nfsv3fa_rdev +#define fa3_fsid fa_un.fa_nfsv3.nfsv3fa_fsid +#define fa3_fileid fa_un.fa_nfsv3.nfsv3fa_fileid +#define fa3_atime fa_un.fa_nfsv3.nfsv3fa_atime +#define fa3_mtime fa_un.fa_nfsv3.nfsv3fa_mtime +#define fa3_ctime fa_un.fa_nfsv3.nfsv3fa_ctime + +struct nfsv2_sattr { + u_int32_t sa_mode; + u_int32_t sa_uid; + u_int32_t sa_gid; + u_int32_t sa_size; + nfstime2 sa_atime; + nfstime2 sa_mtime; +}; + +/* + * NFS Version 3 sattr structure for the new node creation case. + */ +struct nfsv3_sattr { + u_int32_t sa_modeset; + u_int32_t sa_mode; + u_int32_t sa_uidset; + u_int32_t sa_uid; + u_int32_t sa_gidset; + u_int32_t sa_gid; + u_int32_t sa_sizeset; + u_int32_t sa_size; + u_int32_t sa_atimetype; + nfstime3 sa_atime; + u_int32_t sa_mtimetype; + nfstime3 sa_mtime; +}; + +struct nfs_statfs { + union { + struct { + u_int32_t nfsv2sf_tsize; + u_int32_t nfsv2sf_bsize; + u_int32_t nfsv2sf_blocks; + u_int32_t nfsv2sf_bfree; + u_int32_t nfsv2sf_bavail; + } sf_nfsv2; + struct { + nfsuint64 nfsv3sf_tbytes; + nfsuint64 nfsv3sf_fbytes; + nfsuint64 nfsv3sf_abytes; + nfsuint64 nfsv3sf_tfiles; + nfsuint64 nfsv3sf_ffiles; + nfsuint64 nfsv3sf_afiles; + u_int32_t nfsv3sf_invarsec; + } sf_nfsv3; + } sf_un; +}; + +#define sf_tsize sf_un.sf_nfsv2.nfsv2sf_tsize +#define sf_bsize sf_un.sf_nfsv2.nfsv2sf_bsize +#define sf_blocks sf_un.sf_nfsv2.nfsv2sf_blocks +#define sf_bfree sf_un.sf_nfsv2.nfsv2sf_bfree +#define sf_bavail sf_un.sf_nfsv2.nfsv2sf_bavail +#define sf_tbytes sf_un.sf_nfsv3.nfsv3sf_tbytes +#define sf_fbytes sf_un.sf_nfsv3.nfsv3sf_fbytes +#define sf_abytes sf_un.sf_nfsv3.nfsv3sf_abytes +#define sf_tfiles sf_un.sf_nfsv3.nfsv3sf_tfiles +#define sf_ffiles sf_un.sf_nfsv3.nfsv3sf_ffiles +#define sf_afiles sf_un.sf_nfsv3.nfsv3sf_afiles +#define sf_invarsec sf_un.sf_nfsv3.nfsv3sf_invarsec + +struct nfsv3_fsinfo { + u_int32_t fs_rtmax; + u_int32_t fs_rtpref; + u_int32_t fs_rtmult; + u_int32_t fs_wtmax; + u_int32_t fs_wtpref; + u_int32_t fs_wtmult; + u_int32_t fs_dtpref; + nfsuint64 fs_maxfilesize; + nfstime3 fs_timedelta; + u_int32_t fs_properties; +}; + +struct nfsv3_pathconf { + u_int32_t pc_linkmax; + u_int32_t pc_namemax; + u_int32_t pc_notrunc; + u_int32_t pc_chownrestricted; + u_int32_t pc_caseinsensitive; + u_int32_t pc_casepreserving; +};
diff --git a/tcpdump-4.3.0/nfsfh.h b/tcpdump-4.3.0/nfsfh.h new file mode 100644 index 0000000..0bca424 --- /dev/null +++ b/tcpdump-4.3.0/nfsfh.h
@@ -0,0 +1,68 @@ +/* @(#) $Header: /tcpdump/master/tcpdump/nfsfh.h,v 1.13 2002-04-24 06:27:05 guy Exp $ (LBL) */ + +/* + * Copyright (c) 1993, 1994 Jeffrey C. Mogul, Digital Equipment Corporation, + * Western Research Laboratory. All rights reserved. + * Copyright (c) 2001 Compaq Computer Corporation. All rights reserved. + * + * Permission to use, copy, and modify this software and its + * documentation is hereby granted only under the following terms and + * conditions. Both the above copyright notice and this permission + * notice must appear in all copies of the software, derivative works + * or modified versions, and any portions thereof, and both notices + * must appear in supporting documentation. + * + * 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. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND COMPAQ COMPUTER CORPORATION + * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO + * EVENT SHALL COMPAQ COMPUTER CORPORATION BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +/* + * nfsfh.h - NFS file handle definitions (for portable use) + * + * Jeffrey C. Mogul + * Digital Equipment Corporation + * Western Research Laboratory + */ + +/* + * Internal representation of dev_t, because different NFS servers + * that we might be spying upon use different external representations. + */ +typedef struct { + u_int32_t Minor; /* upper case to avoid clashing with macro names */ + u_int32_t Major; +} my_devt; + +#define dev_eq(a,b) ((a.Minor == b.Minor) && (a.Major == b.Major)) + +/* + * Many file servers now use a large file system ID. This is + * our internal representation of that. + */ +typedef struct { + my_devt Fsid_dev; /* XXX avoid name conflict with AIX */ + char Opaque_Handle[2 * 32 + 1]; + u_int32_t fsid_code; +} my_fsid; + +#define fsid_eq(a,b) ((a.fsid_code == b.fsid_code) &&\ + dev_eq(a.Fsid_dev, b.Fsid_dev)) + +extern void Parse_fh(const unsigned char *, int, my_fsid *, ino_t *, const char **, const char **, int);
diff --git a/tcpdump-4.3.0/nlpid.c b/tcpdump-4.3.0/nlpid.c new file mode 100755 index 0000000..64a359b --- /dev/null +++ b/tcpdump-4.3.0/nlpid.c
@@ -0,0 +1,45 @@ +/* + * 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/nlpid.c,v 1.4 2004-10-19 15:27:55 hannes Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> +#include "interface.h" +#include "nlpid.h" + +const struct tok nlpid_values[] = { + { NLPID_NULLNS, "NULL" }, + { NLPID_Q933, "Q.933" }, + { NLPID_LMI, "LMI" }, + { NLPID_SNAP, "SNAP" }, + { NLPID_CLNP, "CLNP" }, + { NLPID_ESIS, "ES-IS" }, + { NLPID_ISIS, "IS-IS" }, + { NLPID_CONS, "CONS" }, + { NLPID_IDRP, "IDRP" }, + { NLPID_MFR, "FRF.15" }, + { NLPID_IP, "IPv4" }, + { NLPID_PPP, "PPP" }, + { NLPID_X25_ESIS, "X25 ES-IS" }, + { NLPID_IP6, "IPv6" }, + { 0, NULL } +};
diff --git a/tcpdump-4.3.0/nlpid.h b/tcpdump-4.3.0/nlpid.h new file mode 100644 index 0000000..8931835 --- /dev/null +++ b/tcpdump-4.3.0/nlpid.h
@@ -0,0 +1,32 @@ +/* @(#) $Header: /tcpdump/master/tcpdump/nlpid.h,v 1.4 2004-10-19 15:27:55 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 const struct tok nlpid_values[]; + +#define NLPID_NULLNS 0x00 +#define NLPID_Q933 0x08 /* ANSI T1.617 Annex D or ITU-T Q.933 Annex A */ +#define NLPID_LMI 0x09 /* The original, aka Cisco, aka Gang of Four */ +#define NLPID_SNAP 0x80 +#define NLPID_CLNP 0x81 /* iso9577 */ +#define NLPID_ESIS 0x82 /* iso9577 */ +#define NLPID_ISIS 0x83 /* iso9577 */ +#define NLPID_CONS 0x84 +#define NLPID_IDRP 0x85 +#define NLPID_MFR 0xb1 /* FRF.15 */ +#define NLPID_IP 0xcc +#define NLPID_PPP 0xcf +#define NLPID_X25_ESIS 0x8a +#define NLPID_IP6 0x8e
diff --git a/tcpdump-4.3.0/ntp.h b/tcpdump-4.3.0/ntp.h new file mode 100644 index 0000000..0614f73 --- /dev/null +++ b/tcpdump-4.3.0/ntp.h
@@ -0,0 +1,127 @@ +/* $Header: /tcpdump/master/tcpdump/ntp.h,v 1.8 2004-01-28 14:34:50 hannes Exp $ */ + +/* + * Based on ntp.h from the U of MD implementation + * This file is based on Version 2 of the NTP spec (RFC1119). + */ + +/* + * Definitions for the masses + */ +#define JAN_1970 2208988800U /* 1970 - 1900 in seconds */ + +/* + * Structure definitions for NTP fixed point values + * + * 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 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Integer Part | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Fraction Part | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * + * 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 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Integer Part | Fraction Part | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +*/ +struct l_fixedpt { + u_int32_t int_part; + u_int32_t fraction; +}; + +struct s_fixedpt { + u_int16_t int_part; + u_int16_t fraction; +}; + +/* rfc2030 + * 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 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * |LI | VN |Mode | Stratum | Poll | Precision | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Root Delay | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Root Dispersion | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Reference Identifier | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | | + * | Reference Timestamp (64) | + * | | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | | + * | Originate Timestamp (64) | + * | | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | | + * | Receive Timestamp (64) | + * | | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | | + * | Transmit Timestamp (64) | + * | | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Key Identifier (optional) (32) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | | + * | | + * | Message Digest (optional) (128) | + * | | + * | | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ + +struct ntpdata { + u_char status; /* status of local clock and leap info */ + u_char stratum; /* Stratum level */ + u_char ppoll; /* poll value */ + int precision:8; + struct s_fixedpt root_delay; + struct s_fixedpt root_dispersion; + u_int32_t refid; + struct l_fixedpt ref_timestamp; + struct l_fixedpt org_timestamp; + struct l_fixedpt rec_timestamp; + struct l_fixedpt xmt_timestamp; + u_int32_t key_id; + u_int8_t message_digest[16]; +}; +/* + * Leap Second Codes (high order two bits) + */ +#define NO_WARNING 0x00 /* no warning */ +#define PLUS_SEC 0x40 /* add a second (61 seconds) */ +#define MINUS_SEC 0x80 /* minus a second (59 seconds) */ +#define ALARM 0xc0 /* alarm condition (clock unsynchronized) */ + +/* + * Clock Status Bits that Encode Version + */ +#define NTPVERSION_1 0x08 +#define VERSIONMASK 0x38 +#define LEAPMASK 0xc0 +#define MODEMASK 0x07 + +/* + * Code values + */ +#define MODE_UNSPEC 0 /* unspecified */ +#define MODE_SYM_ACT 1 /* symmetric active */ +#define MODE_SYM_PAS 2 /* symmetric passive */ +#define MODE_CLIENT 3 /* client */ +#define MODE_SERVER 4 /* server */ +#define MODE_BROADCAST 5 /* broadcast */ +#define MODE_RES1 6 /* reserved */ +#define MODE_RES2 7 /* reserved */ + +/* + * Stratum Definitions + */ +#define UNSPECIFIED 0 +#define PRIM_REF 1 /* radio clock */ +#define INFO_QUERY 62 /* **** THIS implementation dependent **** */ +#define INFO_REPLY 63 /* **** THIS implementation dependent **** */
diff --git a/tcpdump-4.3.0/oakley.h b/tcpdump-4.3.0/oakley.h new file mode 100644 index 0000000..ad32817 --- /dev/null +++ b/tcpdump-4.3.0/oakley.h
@@ -0,0 +1,126 @@ +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +/* YIPS @(#)$Id: oakley.h,v 1.4 2002-12-11 07:13:56 guy Exp $ */ + +/* refer to RFC 2409 */ + +#if !defined(_ISAKMP_OAKLEY_H_) +#define _ISAKMP_OAKLEY_H_ + +/* Attribute Classes */ +#define OAKLEY_ATTR_ENC_ALG 1 /* B */ +#define OAKLEY_ATTR_ENC_ALG_DES 1 +#define OAKLEY_ATTR_ENC_ALG_IDEA 2 +#define OAKLEY_ATTR_ENC_ALG_BL 3 +#define OAKLEY_ATTR_ENC_ALG_RC5 4 +#define OAKLEY_ATTR_ENC_ALG_3DES 5 +#define OAKLEY_ATTR_ENC_ALG_CAST 6 +#define OAKLEY_ATTR_HASH_ALG 2 /* B */ +#define OAKLEY_ATTR_HASH_ALG_MD5 1 +#define OAKLEY_ATTR_HASH_ALG_SHA 2 +#define OAKLEY_ATTR_HASH_ALG_TIGER 3 +#define OAKLEY_ATTR_AUTH_METHOD 3 /* B */ +#define OAKLEY_ATTR_AUTH_METHOD_PSKEY 1 +#define OAKLEY_ATTR_AUTH_METHOD_DSS 2 +#define OAKLEY_ATTR_AUTH_METHOD_RSA 3 +#define OAKLEY_ATTR_AUTH_METHOD_RSAENC 4 +#define OAKLEY_ATTR_AUTH_METHOD_RSAREV 5 +#define OAKLEY_ATTR_GRP_DESC 4 /* B */ +#define OAKLEY_ATTR_GRP_DESC_MODP768 1 +#define OAKLEY_ATTR_GRP_DESC_MODP1024 2 +#define OAKLEY_ATTR_GRP_DESC_EC2N155 3 +#define OAKLEY_ATTR_GRP_DESC_EC2N185 4 +#define OAKLEY_ATTR_GRP_TYPE 5 /* B */ +#define OAKLEY_ATTR_GRP_TYPE_MODP 1 +#define OAKLEY_ATTR_GRP_TYPE_ECP 2 +#define OAKLEY_ATTR_GRP_TYPE_EC2N 3 +#define OAKLEY_ATTR_GRP_PI 6 /* V */ +#define OAKLEY_ATTR_GRP_GEN_ONE 7 /* V */ +#define OAKLEY_ATTR_GRP_GEN_TWO 8 /* V */ +#define OAKLEY_ATTR_GRP_CURVE_A 9 /* V */ +#define OAKLEY_ATTR_GRP_CURVE_B 10 /* V */ +#define OAKLEY_ATTR_SA_LTYPE 11 /* B */ +#define OAKLEY_ATTR_SA_LTYPE_DEFAULT 1 +#define OAKLEY_ATTR_SA_LTYPE_SEC 1 +#define OAKLEY_ATTR_SA_LTYPE_KB 2 +#define OAKLEY_ATTR_SA_LDUR 12 /* V */ +#define OAKLEY_ATTR_SA_LDUR_DEFAULT 28800 /* 8 hours */ +#define OAKLEY_ATTR_PRF 13 /* B */ +#define OAKLEY_ATTR_KEY_LEN 14 /* B */ +#define OAKLEY_ATTR_FIELD_SIZE 15 /* B */ +#define OAKLEY_ATTR_GRP_ORDER 16 /* V */ + +#define OAKLEY_ID_IPV4_ADDR 0 +#define OAKLEY_ID_IPV4_ADDR_SUBNET 1 +#define OAKLEY_ID_IPV6_ADDR 2 +#define OAKLEY_ID_IPV6_ADDR_SUBNET 3 + +/* Additional Exchange Type */ +#define ISAKMP_ETYPE_QUICK 32 +#define ISAKMP_ETYPE_NEWGRP 33 + +/* The use for checking proposal payload. This is not exchange type. */ +#define OAKLEY_MAIN_MODE 0 +#define OAKLEY_QUICK_MODE 1 + +#define OAKLEY_PRIME_MODP768 "\ + FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1 \ + 29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD \ + EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245 \ + E485B576 625E7EC6 F44C42E9 A63A3620 FFFFFFFF FFFFFFFF" + +#define OAKLEY_PRIME_MODP1024 "\ + FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1 \ + 29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD \ + EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245 \ + E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED \ + EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE65381 \ + FFFFFFFF FFFFFFFF" + +#define DEFAULTSECRETSIZE ( 128 / 8 ) /* 128 bits */ +#define DEFAULTNONCESIZE ( 128 / 8 ) /* 128 bits */ + +#define MAXPADLWORD 20 + +#if 0 +/* isakmp sa structure */ +struct oakley_sa { + u_int8_t proto_id; /* OAKLEY */ + vchar_t *spi; /* spi */ + u_int8_t dhgrp; /* DH; group */ + u_int8_t auth_t; /* method of authentication */ + u_int8_t prf_t; /* type of prf */ + u_int8_t hash_t; /* type of hash */ + u_int8_t enc_t; /* type of cipher */ + u_int8_t life_t; /* type of duration of lifetime */ + u_int32_t ldur; /* life duration */ +}; +#endif + +#endif /* !defined(_ISAKMP_OAKLEY_H_) */
diff --git a/tcpdump-4.3.0/ospf.h b/tcpdump-4.3.0/ospf.h new file mode 100644 index 0000000..b86458b --- /dev/null +++ b/tcpdump-4.3.0/ospf.h
@@ -0,0 +1,328 @@ +/* @(#) $Header: /tcpdump/master/tcpdump/ospf.h,v 1.23 2007-10-08 07:53:21 hannes Exp $ (LBL) */ +/* + * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * 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_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 + * + * +------------------------------------+ + * | DN | O | DC | L | 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_L 0x10 /* L bit: Packet contains LLS data block */ +#define OSPF_OPTION_DC 0x20 /* DC bit: Demand circuit capable */ +#define OSPF_OPTION_O 0x40 /* O bit: Opaque LSA capable */ +#define OSPF_OPTION_DN 0x80 /* DN bit: Up/Down Bit capable - draft-ietf-ospf-2547-dnbit-04 */ + +/* ospf_authtype */ +#define OSPF_AUTH_NONE 0 /* No auth-data */ +#define OSPF_AUTH_SIMPLE 1 /* Simple password */ +#define OSPF_AUTH_SIMPLE_LEN 8 /* max length of simple authentication */ +#define OSPF_AUTH_MD5 2 /* MD5 authentication */ +#define OSPF_AUTH_MD5_LEN 16 /* length of MD5 authentication */ + +/* db_flags */ +#define OSPF_DB_INIT 0x04 +#define OSPF_DB_MORE 0x02 +#define OSPF_DB_MASTER 0x01 +#define OSPF_DB_RESYNC 0x08 /* RFC4811 */ + +/* ls_type */ +#define LS_TYPE_ROUTER 1 /* router link */ +#define LS_TYPE_NETWORK 2 /* network link */ +#define LS_TYPE_SUM_IP 3 /* summary link */ +#define LS_TYPE_SUM_ABR 4 /* summary area link */ +#define LS_TYPE_ASE 5 /* ASE */ +#define LS_TYPE_GROUP 6 /* Group membership (multicast */ + /* extensions 23 July 1991) */ +#define LS_TYPE_NSSA 7 /* rfc3101 - 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 /* rfc3623 */ +#define LS_OPAQUE_TYPE_RI 4 /* draft-ietf-ospf-cap-03 */ + +#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 /* rfc4203 */ +#define LS_OPAQUE_TE_LINK_SUBTLV_LINK_PROTECTION_TYPE 14 /* rfc4203 */ +#define LS_OPAQUE_TE_LINK_SUBTLV_INTF_SW_CAP_DESCR 15 /* rfc4203 */ +#define LS_OPAQUE_TE_LINK_SUBTLV_SHARED_RISK_GROUP 16 /* rfc4203 */ +#define LS_OPAQUE_TE_LINK_SUBTLV_BW_CONSTRAINTS 17 /* rfc4124 */ + +#define LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE_PTP 1 /* rfc3630 */ +#define LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE_MA 2 /* rfc3630 */ + +#define LS_OPAQUE_GRACE_TLV_PERIOD 1 /* rfc3623 */ +#define LS_OPAQUE_GRACE_TLV_REASON 2 /* rfc3623 */ +#define LS_OPAQUE_GRACE_TLV_INT_ADDRESS 3 /* rfc3623 */ + +#define LS_OPAQUE_GRACE_TLV_REASON_UNKNOWN 0 /* rfc3623 */ +#define LS_OPAQUE_GRACE_TLV_REASON_SW_RESTART 1 /* rfc3623 */ +#define LS_OPAQUE_GRACE_TLV_REASON_SW_UPGRADE 2 /* rfc3623 */ +#define LS_OPAQUE_GRACE_TLV_REASON_CP_SWITCH 3 /* rfc3623 */ + +#define LS_OPAQUE_RI_TLV_CAP 1 /* draft-ietf-ospf-cap-03 */ + + +/* rla_link.link_type */ +#define RLA_TYPE_ROUTER 1 /* point-to-point to another router */ +#define RLA_TYPE_TRANSIT 2 /* connection to transit network */ +#define RLA_TYPE_STUB 3 /* connection to stub network */ +#define RLA_TYPE_VIRTUAL 4 /* virtual link */ + +/* rla_flags */ +#define RLA_FLAG_B 0x01 +#define RLA_FLAG_E 0x02 +#define RLA_FLAG_W1 0x04 +#define RLA_FLAG_W2 0x08 + +/* sla_tosmetric breakdown */ +#define SLA_MASK_TOS 0x7f000000 +#define SLA_MASK_METRIC 0x00ffffff +#define SLA_SHIFT_TOS 24 + +/* asla_tosmetric breakdown */ +#define ASLA_FLAG_EXTERNAL 0x80000000 +#define ASLA_MASK_TOS 0x7f000000 +#define ASLA_SHIFT_TOS 24 +#define ASLA_MASK_METRIC 0x00ffffff + +/* multicast vertex type */ +#define MCLA_VERTEX_ROUTER 1 +#define MCLA_VERTEX_NETWORK 2 + +/* Link-Local-Signaling */ +#define OSPF_LLS_EO 1 /* RFC4811, RFC4812 */ +#define OSPF_LLS_MD5 2 /* RFC4813 */ + +#define OSPF_LLS_EO_LR 0x00000001 /* RFC4811 */ +#define OSPF_LLS_EO_RS 0x00000002 /* RFC4812 */ + +/* + * TOS metric struct (will be 0 or more in router links update) + */ +struct tos_metric { + u_int8_t tos_type; + u_int8_t reserved; + u_int8_t tos_metric[2]; +}; +struct tos_link { + u_int8_t link_type; + u_int8_t link_tos_count; + u_int8_t tos_metric[2]; +}; +union un_tos { + struct tos_link link; + struct tos_metric metrics; +}; + +/* link state advertisement header */ +struct lsa_hdr { + u_int16_t ls_age; + u_int8_t ls_options; + u_int8_t ls_type; + 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 { + struct lsa_hdr ls_hdr; + + /* Link state types */ + union { + /* Router links advertisements */ + struct { + u_int8_t rla_flags; + u_int8_t rla_zero[1]; + u_int16_t rla_count; + struct rlalink { + struct in_addr link_id; + struct in_addr link_data; + union un_tos un_tos; + } rla_link[1]; /* may repeat */ + } un_rla; + + /* Network links advertisements */ + struct { + struct in_addr nla_mask; + struct in_addr nla_router[1]; /* may repeat */ + } un_nla; + + /* Summary links advertisements */ + struct { + struct in_addr sla_mask; + u_int32_t sla_tosmetric[1]; /* may repeat */ + } un_sla; + + /* AS external links advertisements */ + struct { + struct in_addr asla_mask; + struct aslametric { + u_int32_t asla_tosmetric; + struct in_addr asla_forward; + struct in_addr asla_tag; + } asla_metric[1]; /* may repeat */ + } un_asla; + + /* Multicast group membership */ + struct mcla { + u_int32_t mcla_vtype; + 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; + + /* Opaque Grace LSA */ + struct { + u_int16_t type; + u_int16_t length; + u_int8_t data[1]; /* may repeat */ + } un_grace_tlv; + + /* Opaque Router information LSA */ + struct { + u_int16_t type; + u_int16_t length; + u_int8_t data[1]; /* may repeat */ + } un_ri_tlv; + + /* Unknown LSA */ + struct unknown { + u_int8_t data[1]; /* may repeat */ + } un_unknown[1]; + + } lsa_un; +}; + +#define OSPF_AUTH_SIZE 8 + +/* + * the main header + */ +struct ospfhdr { + u_int8_t ospf_version; + u_int8_t ospf_type; + u_int16_t ospf_len; + struct in_addr ospf_routerid; + struct in_addr ospf_areaid; + u_int16_t ospf_chksum; + u_int16_t ospf_authtype; + u_int8_t ospf_authdata[OSPF_AUTH_SIZE]; + union { + + /* Hello packet */ + struct { + struct in_addr hello_mask; + u_int16_t hello_helloint; + u_int8_t hello_options; + u_int8_t hello_priority; + u_int32_t hello_deadint; + struct in_addr hello_dr; + struct in_addr hello_bdr; + struct in_addr hello_neighbor[1]; /* may repeat */ + } un_hello; + + /* Database Description packet */ + struct { + u_int16_t db_ifmtu; + u_int8_t db_options; + u_int8_t db_flags; + u_int32_t db_seq; + struct lsa_hdr db_lshdr[1]; /* may repeat */ + } un_db; + + /* Link State Request */ + struct lsr { + 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 */ + + /* Link State Update */ + struct { + u_int32_t lsu_count; + struct lsa lsu_lsa[1]; /* may repeat */ + } un_lsu; + + /* Link State Acknowledgement */ + struct { + 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 +#define ospf_lsr ospf_un.un_lsr +#define ospf_lsu ospf_un.un_lsu +#define ospf_lsa ospf_un.un_lsa + +/* Functions shared by ospf and ospf6 */ +extern int ospf_print_te_lsa(const u_int8_t *, u_int); +extern int ospf_print_grace_lsa(const u_int8_t *, u_int);
diff --git a/tcpdump-4.3.0/ospf6.h b/tcpdump-4.3.0/ospf6.h new file mode 100644 index 0000000..e2eabee --- /dev/null +++ b/tcpdump-4.3.0/ospf6.h
@@ -0,0 +1,265 @@ +/* @(#) $Header: /tcpdump/master/tcpdump/ospf6.h,v 1.7 2006-09-05 15:50:26 hannes Exp $ (LBL) */ +/* + * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * OSPF support contributed by Jeffrey Honig (jch@mitchell.cit.cornell.edu) + */ +#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 *_options */ +#define OSPF6_OPTION_V6 0x01 /* V6 bit: A bit for peeping tom */ +#define OSPF6_OPTION_E 0x02 /* E bit: External routes advertised */ +#define OSPF6_OPTION_MC 0x04 /* MC bit: Multicast capable */ +#define OSPF6_OPTION_N 0x08 /* N bit: For type-7 LSA */ +#define OSPF6_OPTION_R 0x10 /* R bit: Router bit */ +#define OSPF6_OPTION_DC 0x20 /* DC bit: Demand circuits */ + + +/* db_flags */ +#define OSPF6_DB_INIT 0x04 /* */ +#define OSPF6_DB_MORE 0x02 +#define OSPF6_DB_MASTER 0x01 + +/* ls_type */ +#define LS_TYPE_ROUTER 1 /* router link */ +#define LS_TYPE_NETWORK 2 /* network link */ +#define LS_TYPE_INTER_AP 3 /* Inter-Area-Prefix */ +#define LS_TYPE_INTER_AR 4 /* Inter-Area-Router */ +#define LS_TYPE_ASE 5 /* ASE */ +#define LS_TYPE_GROUP 6 /* Group membership */ +#define LS_TYPE_NSSA 7 /* NSSA */ +#define LS_TYPE_LINK 8 /* Link LSA */ +#define LS_TYPE_INTRA_AP 9 /* Intra-Area-Prefix */ +#define LS_TYPE_INTRA_ATE 10 /* Intra-Area-TE */ +#define LS_TYPE_GRACE 11 /* Grace LSA */ +#define LS_TYPE_MASK 0x1fff + +#define LS_SCOPE_LINKLOCAL 0x0000 +#define LS_SCOPE_AREA 0x2000 +#define LS_SCOPE_AS 0x4000 +#define LS_SCOPE_MASK 0x6000 +#define LS_SCOPE_U 0x8000 + +/* rla_link.link_type */ +#define RLA_TYPE_ROUTER 1 /* point-to-point to another router */ +#define RLA_TYPE_TRANSIT 2 /* connection to transit network */ +#define RLA_TYPE_VIRTUAL 4 /* virtual link */ + +/* rla_flags */ +#define RLA_FLAG_B 0x01 +#define RLA_FLAG_E 0x02 +#define RLA_FLAG_V 0x04 +#define RLA_FLAG_W 0x08 +#define RLA_FLAG_N 0x10 + +/* lsa_prefix options */ +#define LSA_PREFIX_OPT_NU 0x01 +#define LSA_PREFIX_OPT_LA 0x02 +#define LSA_PREFIX_OPT_MC 0x04 +#define LSA_PREFIX_OPT_P 0x08 +#define LSA_PREFIX_OPT_DN 0x10 + +/* sla_tosmetric breakdown */ +#define SLA_MASK_TOS 0x7f000000 +#define SLA_MASK_METRIC 0x00ffffff +#define SLA_SHIFT_TOS 24 + +/* asla_metric */ +#define ASLA_FLAG_FWDADDR 0x02000000 +#define ASLA_FLAG_ROUTETAG 0x01000000 +#define ASLA_MASK_METRIC 0x00ffffff + +typedef u_int32_t rtrid_t; + +/* link state advertisement header */ +struct lsa6_hdr { + u_int16_t ls_age; + u_int16_t ls_type; + rtrid_t ls_stateid; + rtrid_t ls_router; + u_int32_t ls_seq; + u_int16_t ls_chksum; + u_int16_t ls_length; +}; + +struct lsa6_prefix { + u_int8_t lsa_p_len; + u_int8_t lsa_p_opt; + u_int16_t lsa_p_metric; + u_int8_t lsa_p_prefix[4]; +}; + +/* link state advertisement */ +struct lsa6 { + struct lsa6_hdr ls_hdr; + + /* Link state types */ + union { + /* Router links advertisements */ + struct { + union { + u_int8_t flg; + u_int32_t opt; + } rla_flgandopt; +#define rla_flags rla_flgandopt.flg +#define rla_options rla_flgandopt.opt + struct rlalink6 { + u_int8_t link_type; + u_int8_t link_zero[1]; + u_int16_t link_metric; + u_int32_t link_ifid; + u_int32_t link_nifid; + rtrid_t link_nrtid; + } rla_link[1]; /* may repeat */ + } un_rla; + + /* Network links advertisements */ + struct { + u_int32_t nla_options; + rtrid_t nla_router[1]; /* may repeat */ + } un_nla; + + /* Inter Area Prefix LSA */ + struct { + u_int32_t inter_ap_metric; + struct lsa6_prefix inter_ap_prefix[1]; + } un_inter_ap; + + /* AS external links advertisements */ + struct { + u_int32_t asla_metric; + struct lsa6_prefix asla_prefix[1]; + /* some optional fields follow */ + } un_asla; + +#if 0 + /* Summary links advertisements */ + struct { + struct in_addr sla_mask; + u_int32_t sla_tosmetric[1]; /* may repeat */ + } un_sla; + + /* Multicast group membership */ + struct mcla { + u_int32_t mcla_vtype; + struct in_addr mcla_vid; + } un_mcla[1]; +#endif + + /* Type 7 LSA */ + + /* Link LSA */ + struct llsa { + union { + u_int8_t pri; + u_int32_t opt; + } llsa_priandopt; +#define llsa_priority llsa_priandopt.pri +#define llsa_options llsa_priandopt.opt + struct in6_addr llsa_lladdr; + u_int32_t llsa_nprefix; + struct lsa6_prefix llsa_prefix[1]; + } un_llsa; + + /* Intra-Area-Prefix */ + struct { + u_int16_t intra_ap_nprefix; + u_int16_t intra_ap_lstype; + rtrid_t intra_ap_lsid; + rtrid_t intra_ap_rtid; + struct lsa6_prefix intra_ap_prefix[1]; + } un_intra_ap; + } lsa_un; +}; + + +#define OSPF_AUTH_SIZE 8 + +/* + * the main header + */ +struct ospf6hdr { + u_int8_t ospf6_version; + u_int8_t ospf6_type; + u_int16_t ospf6_len; + rtrid_t ospf6_routerid; + rtrid_t ospf6_areaid; + u_int16_t ospf6_chksum; + u_int8_t ospf6_instanceid; + u_int8_t ospf6_rsvd; + union { + + /* Hello packet */ + struct { + u_int32_t hello_ifid; + union { + u_int8_t pri; + u_int32_t opt; + } hello_priandopt; +#define hello_priority hello_priandopt.pri +#define hello_options hello_priandopt.opt + u_int16_t hello_helloint; + u_int16_t hello_deadint; + rtrid_t hello_dr; + rtrid_t hello_bdr; + rtrid_t hello_neighbor[1]; /* may repeat */ + } un_hello; + + /* Database Description packet */ + struct { + u_int32_t db_options; + u_int16_t db_mtu; + u_int8_t db_mbz; + u_int8_t db_flags; + u_int32_t db_seq; + struct lsa6_hdr db_lshdr[1]; /* may repeat */ + } un_db; + + /* Link State Request */ + struct lsr6 { + u_int16_t ls_mbz; + u_int16_t ls_type; + rtrid_t ls_stateid; + rtrid_t ls_router; + } un_lsr[1]; /* may repeat */ + + /* Link State Update */ + struct { + u_int32_t lsu_count; + struct lsa6 lsu_lsa[1]; /* may repeat */ + } un_lsu; + + /* Link State Acknowledgement */ + struct { + struct lsa6_hdr lsa_lshdr[1]; /* may repeat */ + } un_lsa ; + } ospf6_un ; +}; + +#define ospf6_hello ospf6_un.un_hello +#define ospf6_db ospf6_un.un_db +#define ospf6_lsr ospf6_un.un_lsr +#define ospf6_lsu ospf6_un.un_lsu +#define ospf6_lsa ospf6_un.un_lsa +
diff --git a/tcpdump-4.3.0/oui.c b/tcpdump-4.3.0/oui.c new file mode 100644 index 0000000..1067aa1 --- /dev/null +++ b/tcpdump-4.3.0/oui.c
@@ -0,0 +1,99 @@ +/* + * 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.9 2008-01-09 09:40:47 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 */ + +const struct tok oui_values[] = { + { OUI_ENCAP_ETHER, "Ethernet" }, + { OUI_CISCO, "Cisco" }, + { OUI_NORTEL, "Nortel Networks SONMP" }, + { OUI_CISCO_90, "Cisco bridged" }, + { OUI_RFC2684, "Ethernet bridged" }, + { OUI_ATM_FORUM, "ATM Forum" }, + { OUI_CABLE_BPDU, "DOCSIS Spanning Tree" }, + { OUI_APPLETALK, "Appletalk" }, + { OUI_JUNIPER, "Juniper" }, + { OUI_HP, "Hewlett-Packard" }, + { OUI_IEEE_8021_PRIVATE, "IEEE 802.1 Private"}, + { OUI_IEEE_8023_PRIVATE, "IEEE 802.3 Private"}, + { OUI_TIA, "ANSI/TIA"}, + { OUI_DCBX, "DCBX"}, + { 0, NULL } +}; + +/* + * SMI Network Management Private Enterprise Codes for organizations. + * + * XXX - these also appear in FreeRadius dictionary files, with items such + * as + * + * VENDOR Cisco 9 + * + * List taken from Ethereal's epan/sminmpec.c. + */ +const struct tok smi_values[] = { + { SMI_IETF, "IETF (reserved)"}, + { SMI_ACC, "ACC"}, + { SMI_CISCO, "Cisco"}, + { SMI_HEWLETT_PACKARD, "Hewlett Packard"}, + { SMI_SUN_MICROSYSTEMS, "Sun Microsystems"}, + { SMI_MERIT, "Merit"}, + { SMI_SHIVA, "Shiva"}, + { SMI_ERICSSON, "Ericsson AB"}, + { SMI_CISCO_VPN5000, "Cisco VPN 5000"}, + { SMI_LIVINGSTON, "Livingston"}, + { SMI_MICROSOFT, "Microsoft"}, + { 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_CISCO_VPN3000, "Cisco VPN 3000"}, + { SMI_COSINE, "CoSine Communications"}, + { SMI_NETSCREEN, "Netscreen"}, + { SMI_SHASTA, "Shasta"}, + { SMI_NOMADIX, "Nomadix"}, + { SMI_SIEMENS, "Siemens"}, + { SMI_CABLELABS, "CableLabs"}, + { SMI_UNISPHERE, "Unisphere Networks"}, + { SMI_CISCO_BBSM, "Cisco BBSM"}, + { SMI_THE3GPP2, "3rd Generation Partnership Project 2 (3GPP2)"}, + { SMI_IP_UNPLUGGED, "ipUnplugged"}, + { SMI_ISSANNI, "Issanni Communications"}, + { SMI_QUINTUM, "Quintum"}, + { SMI_INTERLINK, "Interlink"}, + { SMI_COLUBRIS, "Colubris"}, + { SMI_COLUMBIA_UNIVERSITY, "Columbia University"}, + { SMI_THE3GPP, "3GPP"}, + { SMI_GEMTEK_SYSTEMS, "Gemtek-Systems"}, + { SMI_WIFI_ALLIANCE, "Wi-Fi Alliance"}, + { 0, NULL} +};
diff --git a/tcpdump-4.3.0/oui.h b/tcpdump-4.3.0/oui.h new file mode 100644 index 0000000..d39cb6c --- /dev/null +++ b/tcpdump-4.3.0/oui.h
@@ -0,0 +1,82 @@ +/* @(#) $Header: /tcpdump/master/tcpdump/oui.h,v 1.8 2008-01-09 09:40:47 hannes Exp $ (LBL) */ +/* + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code + * 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 const struct tok oui_values[]; +extern const struct tok smi_values[]; + +#define OUI_ENCAP_ETHER 0x000000 /* encapsulated Ethernet */ +#define OUI_CISCO 0x00000c /* Cisco protocols */ +#define OUI_NORTEL 0x000081 /* Nortel SONMP */ +#define OUI_CISCO_90 0x0000f8 /* Cisco bridging */ +#define OUI_RFC2684 0x0080c2 /* RFC 2427/2684 bridged Ethernet */ +#define OUI_ATM_FORUM 0x00A03E /* ATM Forum */ +#define OUI_CABLE_BPDU 0x00E02F /* DOCSIS spanning tree BPDU */ +#define OUI_APPLETALK 0x080007 /* Appletalk */ +#define OUI_JUNIPER 0x009069 /* Juniper */ +#define OUI_HP 0x080009 /* Hewlett-Packard */ +#define OUI_IEEE_8021_PRIVATE 0x0080c2 /* IEEE 802.1 Organisation Specific - Annex F */ +#define OUI_IEEE_8023_PRIVATE 0x00120f /* IEEE 802.3 Organisation Specific - Annex G */ +#define OUI_TIA 0x0012bb /* TIA - Telecommunications Industry Association - ANSI/TIA-1057- 2006 */ +#define OUI_DCBX 0x001B21 /* DCBX */ + +/* + * These are SMI Network Management Private Enterprise Codes for + * organizations; see + * + * http://www.iana.org/assignments/enterprise-numbers + * + * for a list. + * + * List taken from Ethereal's epan/sminmpec.h. + */ +#define SMI_IETF 0 /* reserved - used by the IETF in L2TP? */ +#define SMI_ACC 5 +#define SMI_CISCO 9 +#define SMI_HEWLETT_PACKARD 11 +#define SMI_SUN_MICROSYSTEMS 42 +#define SMI_MERIT 61 +#define SMI_SHIVA 166 +#define SMI_ERICSSON 193 +#define SMI_CISCO_VPN5000 255 +#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_CISCO_VPN3000 3076 +#define SMI_COSINE 3085 +#define SMI_SHASTA 3199 +#define SMI_NETSCREEN 3224 +#define SMI_NOMADIX 3309 +#define SMI_SIEMENS 4329 +#define SMI_CABLELABS 4491 +#define SMI_UNISPHERE 4874 +#define SMI_CISCO_BBSM 5263 +#define SMI_THE3GPP2 5535 +#define SMI_IP_UNPLUGGED 5925 +#define SMI_ISSANNI 5948 +#define SMI_QUINTUM 6618 +#define SMI_INTERLINK 6728 +#define SMI_COLUBRIS 8744 +#define SMI_COLUMBIA_UNIVERSITY 11862 +#define SMI_THE3GPP 10415 +#define SMI_GEMTEK_SYSTEMS 10529 +#define SMI_WIFI_ALLIANCE 14122
diff --git a/tcpdump-4.3.0/packetdat.awk b/tcpdump-4.3.0/packetdat.awk new file mode 100644 index 0000000..292e219 --- /dev/null +++ b/tcpdump-4.3.0/packetdat.awk
@@ -0,0 +1,61 @@ +BEGIN { + # we need to know (usual) packet size to convert byte numbers + # to packet numbers + if (packetsize <= 0) + packetsize = 512 + } +$5 !~ /[SR]/ { + # print out per-packet data in the form: + # <packet #> + # <start sequence #> + # <1st send time> + # <last send time> + # <1st ack time> + # <last ack time> + # <# sends> + # <# acks> + + n = split ($1,t,":") + tim = t[1]*3600 + t[2]*60 + t[3] + if ($6 != "ack") { + i = index($6,":") + strtSeq = substr($6,1,i-1) + id = 1.5 + (strtSeq - 1) / packetsize + id -= id % 1 + if (maxId < id) + maxId = id + if (firstSend[id] == 0) { + firstSend[id] = tim + seqNo[id] = strtSeq + } + lastSend[id] = tim + timesSent[id]++ + totalPackets++ + } else { + id = 1 + ($7 - 2) / packetsize + id -= id % 1 + timesAcked[id]++ + if (firstAck[id] == 0) + firstAck[id] = tim + lastAck[id] = tim + totalAcks++ + } + } +END { + print "# " maxId " chunks. " totalPackets " packets sent. " \ + totalAcks " acks." + # for packets that were implicitly acked, make the ack time + # be the ack time of next explicitly acked packet. + for (i = maxId-1; i > 0; --i) + while (i > 0 && firstAck[i] == 0) { + lastAck[i] = firstAck[i] = firstAck[i+1] + --i + } + tzero = firstSend[1] + for (i = 1; i <= maxId; i++) + printf "%d\t%d\t%.2f\t%.2f\t%.2f\t%.2f\t%d\t%d\n",\ + i, seqNo[i], \ + firstSend[i] - tzero, lastSend[i] - tzero,\ + firstAck[i] - tzero, lastAck[i] - tzero,\ + timesSent[i], timesAcked[i] + }
diff --git a/tcpdump-4.3.0/parsenfsfh.c b/tcpdump-4.3.0/parsenfsfh.c new file mode 100644 index 0000000..d5f877d --- /dev/null +++ b/tcpdump-4.3.0/parsenfsfh.c
@@ -0,0 +1,484 @@ +/* + * Copyright (c) 1993, 1994 Jeffrey C. Mogul, Digital Equipment Corporation, + * Western Research Laboratory. All rights reserved. + * Copyright (c) 2001 Compaq Computer Corporation. All rights reserved. + * + * Permission to use, copy, and modify this software and its + * documentation is hereby granted only under the following terms and + * conditions. Both the above copyright notice and this permission + * notice must appear in all copies of the software, derivative works + * or modified versions, and any portions thereof, and both notices + * must appear in supporting documentation. + * + * 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. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND COMPAQ COMPUTER CORPORATION + * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO + * EVENT SHALL COMPAQ COMPUTER CORPORATION BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +/* + * parsenfsfh.c - portable parser for NFS file handles + * uses all sorts of heuristics + * + * Jeffrey C. Mogul + * Digital Equipment Corporation + * Western Research Laboratory + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/parsenfsfh.c,v 1.29 2006-06-13 22:21:38 guy Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> +#include <string.h> + +#include "interface.h" +#include "nfsfh.h" + +/* + * This routine attempts to parse a file handle (in network byte order), + * using heuristics to guess what kind of format it is in. See the + * file "fhandle_layouts" for a detailed description of the various + * patterns we know about. + * + * The file handle is parsed into our internal representation of a + * file-system id, and an internal representation of an inode-number. + */ + +#define FHT_UNKNOWN 0 +#define FHT_AUSPEX 1 +#define FHT_DECOSF 2 +#define FHT_IRIX4 3 +#define FHT_IRIX5 4 +#define FHT_SUNOS3 5 +#define FHT_SUNOS4 6 +#define FHT_ULTRIX 7 +#define FHT_VMSUCX 8 +#define FHT_SUNOS5 9 +#define FHT_AIX32 10 +#define FHT_HPUX9 11 +#define FHT_BSD44 12 + +#ifdef ultrix +/* Nasty hack to keep the Ultrix C compiler from emitting bogus warnings */ +#define XFF(x) ((u_int32_t)(x)) +#else +#define XFF(x) (x) +#endif + +#define make_uint32(msb,b,c,lsb)\ + (XFF(lsb) + (XFF(c)<<8) + (XFF(b)<<16) + (XFF(msb)<<24)) + +#define make_uint24(msb,b, lsb)\ + (XFF(lsb) + (XFF(b)<<8) + (XFF(msb)<<16)) + +#define make_uint16(msb,lsb)\ + (XFF(lsb) + (XFF(msb)<<8)) + +#ifdef __alpha + /* or other 64-bit systems */ +#define make_uint48(msb,b,c,d,e,lsb)\ + ((lsb) + ((e)<<8) + ((d)<<16) + ((c)<<24) + ((b)<<32) + ((msb)<<40)) +#else + /* on 32-bit systems ignore high-order bits */ +#define make_uint48(msb,b,c,d,e,lsb)\ + ((lsb) + ((e)<<8) + ((d)<<16) + ((c)<<24)) +#endif + +static int is_UCX(const unsigned char *); + +void +Parse_fh(fh, len, fsidp, inop, osnamep, fsnamep, ourself) +register const unsigned char *fh; +int len _U_; +my_fsid *fsidp; +ino_t *inop; +const char **osnamep; /* if non-NULL, return OS name here */ +const char **fsnamep; /* if non-NULL, return server fs name here (for VMS) */ +int ourself; /* true if file handle was generated on this host */ +{ + register const unsigned char *fhp = fh; + u_int32_t temp; + int fhtype = FHT_UNKNOWN; + int i; + + if (ourself) { + /* File handle generated on this host, no need for guessing */ +#if defined(IRIX40) + fhtype = FHT_IRIX4; +#endif +#if defined(IRIX50) + fhtype = FHT_IRIX5; +#endif +#if defined(IRIX51) + fhtype = FHT_IRIX5; +#endif +#if defined(SUNOS4) + fhtype = FHT_SUNOS4; +#endif +#if defined(SUNOS5) + fhtype = FHT_SUNOS5; +#endif +#if defined(ultrix) + fhtype = FHT_ULTRIX; +#endif +#if defined(__osf__) + fhtype = FHT_DECOSF; +#endif +#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) \ + || defined(__OpenBSD__) + fhtype = FHT_BSD44; +#endif + } + /* + * This is basically a big decision tree + */ + else if ((fhp[0] == 0) && (fhp[1] == 0)) { + /* bytes[0,1] == (0,0); rules out Ultrix, IRIX5, SUNOS5 */ + /* probably rules out HP-UX, AIX unless they allow major=0 */ + if ((fhp[2] == 0) && (fhp[3] == 0)) { + /* bytes[2,3] == (0,0); must be Auspex */ + /* XXX or could be Ultrix+MASSBUS "hp" disk? */ + fhtype = FHT_AUSPEX; + } + else { + /* + * bytes[2,3] != (0,0); rules out Auspex, could be + * DECOSF, SUNOS4, or IRIX4 + */ + if ((fhp[4] != 0) && (fhp[5] == 0) && + (fhp[8] == 12) && (fhp[9] == 0)) { + /* seems to be DECOSF, with minor == 0 */ + fhtype = FHT_DECOSF; + } + else { + /* could be SUNOS4 or IRIX4 */ + /* XXX the test of fhp[5] == 8 could be wrong */ + if ((fhp[4] == 0) && (fhp[5] == 8) && (fhp[6] == 0) && + (fhp[7] == 0)) { + /* looks like a length, not a file system typecode */ + fhtype = FHT_IRIX4; + } + else { + /* by elimination */ + fhtype = FHT_SUNOS4; + } + } + } + } + else { + /* + * bytes[0,1] != (0,0); rules out Auspex, IRIX4, SUNOS4 + * could be IRIX5, DECOSF, UCX, Ultrix, SUNOS5 + * could be AIX, HP-UX + */ + if ((fhp[2] == 0) && (fhp[3] == 0)) { + /* + * bytes[2,3] == (0,0); rules out OSF, probably not UCX + * (unless the exported device name is just one letter!), + * could be Ultrix, IRIX5, AIX, or SUNOS5 + * might be HP-UX (depends on their values for minor devs) + */ + if ((fhp[6] == 0) && (fhp[7] == 0)) { + fhtype = FHT_BSD44; + } + /*XXX we probably only need to test of these two bytes */ + else if ((fhp[21] == 0) && (fhp[23] == 0)) { + fhtype = FHT_ULTRIX; + } + else { + /* Could be SUNOS5/IRIX5, maybe AIX */ + /* XXX no obvious difference between SUNOS5 and IRIX5 */ + if (fhp[9] == 10) + fhtype = FHT_SUNOS5; + /* XXX what about AIX? */ + } + } + else { + /* + * bytes[2,3] != (0,0); rules out Ultrix, could be + * DECOSF, SUNOS5, IRIX5, AIX, HP-UX, or UCX + */ + if ((fhp[8] == 12) && (fhp[9] == 0)) { + fhtype = FHT_DECOSF; + } + else if ((fhp[8] == 0) && (fhp[9] == 10)) { + /* could be SUNOS5/IRIX5, AIX, HP-UX */ + if ((fhp[7] == 0) && (fhp[6] == 0) && + (fhp[5] == 0) && (fhp[4] == 0)) { + /* XXX is this always true of HP-UX? */ + fhtype = FHT_HPUX9; + } + else if (fhp[7] == 2) { + /* This would be MNT_NFS on AIX, which is impossible */ + fhtype = FHT_SUNOS5; /* or maybe IRIX5 */ + } + else { + /* + * XXX Could be SUNOS5/IRIX5 or AIX. I don't + * XXX see any way to disambiguate these, so + * XXX I'm going with the more likely guess. + * XXX Sorry, Big Blue. + */ + fhtype = FHT_SUNOS5; /* or maybe IRIX5 */ + } + } + else { + if (is_UCX(fhp)) { + fhtype = FHT_VMSUCX; + } + else { + fhtype = FHT_UNKNOWN; + } + } + } + } + + /* XXX still needs to handle SUNOS3 */ + + switch (fhtype) { + case FHT_AUSPEX: + fsidp->Fsid_dev.Minor = fhp[7]; + fsidp->Fsid_dev.Major = fhp[6]; + fsidp->fsid_code = 0; + + temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]); + *inop = temp; + + if (osnamep) + *osnamep = "Auspex"; + break; + + case FHT_BSD44: + fsidp->Fsid_dev.Minor = fhp[0]; + fsidp->Fsid_dev.Major = fhp[1]; + fsidp->fsid_code = 0; + + temp = make_uint32(fhp[15], fhp[14], fhp[13], fhp[12]); + *inop = temp; + + if (osnamep) + *osnamep = "BSD 4.4"; + break; + + case FHT_DECOSF: + fsidp->fsid_code = make_uint32(fhp[7], fhp[6], fhp[5], fhp[4]); + /* XXX could ignore 3 high-order bytes */ + + temp = make_uint32(fhp[3], fhp[2], fhp[1], fhp[0]); + fsidp->Fsid_dev.Minor = temp & 0xFFFFF; + fsidp->Fsid_dev.Major = (temp>>20) & 0xFFF; + + temp = make_uint32(fhp[15], fhp[14], fhp[13], fhp[12]); + *inop = temp; + if (osnamep) + *osnamep = "OSF"; + break; + + case FHT_IRIX4: + fsidp->Fsid_dev.Minor = fhp[3]; + fsidp->Fsid_dev.Major = fhp[2]; + fsidp->fsid_code = 0; + + temp = make_uint32(fhp[8], fhp[9], fhp[10], fhp[11]); + *inop = temp; + + if (osnamep) + *osnamep = "IRIX4"; + break; + + case FHT_IRIX5: + fsidp->Fsid_dev.Minor = make_uint16(fhp[2], fhp[3]); + fsidp->Fsid_dev.Major = make_uint16(fhp[0], fhp[1]); + fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]); + + temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]); + *inop = temp; + + if (osnamep) + *osnamep = "IRIX5"; + break; + +#ifdef notdef + case FHT_SUNOS3: + /* + * XXX - none of the heuristics above return this. + * Are there any SunOS 3.x systems around to care about? + */ + if (osnamep) + *osnamep = "SUNOS3"; + break; +#endif + + case FHT_SUNOS4: + fsidp->Fsid_dev.Minor = fhp[3]; + fsidp->Fsid_dev.Major = fhp[2]; + fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]); + + temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]); + *inop = temp; + + if (osnamep) + *osnamep = "SUNOS4"; + break; + + case FHT_SUNOS5: + temp = make_uint16(fhp[0], fhp[1]); + fsidp->Fsid_dev.Major = (temp>>2) & 0x3FFF; + temp = make_uint24(fhp[1], fhp[2], fhp[3]); + fsidp->Fsid_dev.Minor = temp & 0x3FFFF; + fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]); + + temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]); + *inop = temp; + + if (osnamep) + *osnamep = "SUNOS5"; + break; + + case FHT_ULTRIX: + fsidp->fsid_code = 0; + fsidp->Fsid_dev.Minor = fhp[0]; + fsidp->Fsid_dev.Major = fhp[1]; + + temp = make_uint32(fhp[7], fhp[6], fhp[5], fhp[4]); + *inop = temp; + if (osnamep) + *osnamep = "Ultrix"; + break; + + case FHT_VMSUCX: + /* No numeric file system ID, so hash on the device-name */ + if (sizeof(*fsidp) >= 14) { + if (sizeof(*fsidp) > 14) + memset((char *)fsidp, 0, sizeof(*fsidp)); + /* just use the whole thing */ + memcpy((char *)fsidp, (char *)fh, 14); + } + else { + u_int32_t tempa[4]; /* at least 16 bytes, maybe more */ + + memset((char *)tempa, 0, sizeof(tempa)); + memcpy((char *)tempa, (char *)fh, 14); /* ensure alignment */ + fsidp->Fsid_dev.Minor = tempa[0] + (tempa[1]<<1); + fsidp->Fsid_dev.Major = tempa[2] + (tempa[3]<<1); + fsidp->fsid_code = 0; + } + + /* VMS file ID is: (RVN, FidHi, FidLo) */ + *inop = make_uint32(fhp[26], fhp[27], fhp[23], fhp[22]); + + /* Caller must save (and null-terminate?) this value */ + if (fsnamep) + *fsnamep = (char *)&(fhp[1]); + + if (osnamep) + *osnamep = "VMS"; + break; + + case FHT_AIX32: + fsidp->Fsid_dev.Minor = make_uint16(fhp[2], fhp[3]); + fsidp->Fsid_dev.Major = make_uint16(fhp[0], fhp[1]); + fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]); + + temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]); + *inop = temp; + + if (osnamep) + *osnamep = "AIX32"; + break; + + case FHT_HPUX9: + fsidp->Fsid_dev.Major = fhp[0]; + temp = make_uint24(fhp[1], fhp[2], fhp[3]); + fsidp->Fsid_dev.Minor = temp; + fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]); + + temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]); + *inop = temp; + + if (osnamep) + *osnamep = "HPUX9"; + break; + + case FHT_UNKNOWN: +#ifdef DEBUG + /* XXX debugging */ + for (i = 0; i < 32; i++) + (void)fprintf(stderr, "%x.", fhp[i]); + (void)fprintf(stderr, "\n"); +#endif + /* Save the actual handle, so it can be display with -u */ + for (i = 0; i < 32; i++) + (void)snprintf(&(fsidp->Opaque_Handle[i*2]), 3, "%.2X", fhp[i]); + + /* XXX for now, give "bogus" values to aid debugging */ + fsidp->fsid_code = 0; + fsidp->Fsid_dev.Minor = 257; + fsidp->Fsid_dev.Major = 257; + *inop = 1; + + /* display will show this string instead of (257,257) */ + if (fsnamep) + *fsnamep = "Unknown"; + + if (osnamep) + *osnamep = "Unknown"; + break; + + } +} + +/* + * Is this a VMS UCX file handle? + * Check for: + * (1) leading code byte [XXX not yet] + * (2) followed by string of printing chars & spaces + * (3) followed by string of nulls + */ +static int +is_UCX(fhp) +const unsigned char *fhp; +{ + register int i; + int seen_null = 0; + + for (i = 1; i < 14; i++) { + if (isprint(fhp[i])) { + if (seen_null) + return(0); + else + continue; + } + else if (fhp[i] == 0) { + seen_null = 1; + continue; + } + else + return(0); + } + + return(1); +}
diff --git a/tcpdump-4.3.0/pcap-missing.h b/tcpdump-4.3.0/pcap-missing.h new file mode 100644 index 0000000..5c0ece2 --- /dev/null +++ b/tcpdump-4.3.0/pcap-missing.h
@@ -0,0 +1,60 @@ +/* + * 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.3 2005-06-03 22:08:52 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 + +#ifndef HAVE_PCAP_DUMP_FTELL +extern long pcap_dump_ftell(pcap_dumper_t *); +#endif + +#endif + + + + + + + + +
diff --git a/tcpdump-4.3.0/pcap_dump_ftell.c b/tcpdump-4.3.0/pcap_dump_ftell.c new file mode 100644 index 0000000..6eb3a4a --- /dev/null +++ b/tcpdump-4.3.0/pcap_dump_ftell.c
@@ -0,0 +1,36 @@ +/* + * 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. + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/pcap_dump_ftell.c,v 1.1 2005-06-03 22:08:52 guy Exp $ (LBL)"; +#endif + +#include <stdio.h> +#include <pcap.h> + +#include "pcap-missing.h" + +long +pcap_dump_ftell(pcap_dumper_t *p) +{ + return (ftell((FILE *)p)); +}
diff --git a/tcpdump-4.3.0/pmap_prot.h b/tcpdump-4.3.0/pmap_prot.h new file mode 100644 index 0000000..67ad626 --- /dev/null +++ b/tcpdump-4.3.0/pmap_prot.h
@@ -0,0 +1,89 @@ +/* @(#) $Header: /tcpdump/master/tcpdump/pmap_prot.h,v 1.3 2005-04-27 21:43:48 guy Exp $ (LBL) */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + * + * from: @(#)pmap_prot.h 1.14 88/02/08 SMI + * from: @(#)pmap_prot.h 2.1 88/07/29 4.0 RPCSRC + * $FreeBSD: src/include/rpc/pmap_prot.h,v 1.9.2.1 1999/08/29 14:39:05 peter Exp $ + */ + +/* + * pmap_prot.h + * Protocol for the local binder service, or pmap. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + * + * The following procedures are supported by the protocol: + * + * PMAPPROC_NULL() returns () + * takes nothing, returns nothing + * + * PMAPPROC_SET(struct pmap) returns (bool_t) + * TRUE is success, FALSE is failure. Registers the tuple + * [prog, vers, prot, port]. + * + * PMAPPROC_UNSET(struct pmap) returns (bool_t) + * TRUE is success, FALSE is failure. Un-registers pair + * [prog, vers]. prot and port are ignored. + * + * PMAPPROC_GETPORT(struct pmap) returns (long unsigned). + * 0 is failure. Otherwise returns the port number where the pair + * [prog, vers] is registered. It may lie! + * + * PMAPPROC_DUMP() RETURNS (struct pmaplist *) + * + * PMAPPROC_CALLIT(unsigned, unsigned, unsigned, string<>) + * RETURNS (port, string<>); + * usage: encapsulatedresults = PMAPPROC_CALLIT(prog, vers, proc, encapsulatedargs); + * Calls the procedure on the local machine. If it is not registered, + * this procedure is quite; ie it does not return error information!!! + * This procedure only is supported on rpc/udp and calls via + * rpc/udp. This routine only passes null authentication parameters. + * This file has no interface to xdr routines for PMAPPROC_CALLIT. + * + * The service supports remote procedure calls on udp/ip or tcp/ip socket 111. + */ + +#define SUNRPC_PMAPPORT ((u_int16_t)111) +#define SUNRPC_PMAPPROG ((u_int32_t)100000) +#define SUNRPC_PMAPVERS ((u_int32_t)2) +#define SUNRPC_PMAPVERS_PROTO ((u_int32_t)2) +#define SUNRPC_PMAPVERS_ORIG ((u_int32_t)1) +#define SUNRPC_PMAPPROC_NULL ((u_int32_t)0) +#define SUNRPC_PMAPPROC_SET ((u_int32_t)1) +#define SUNRPC_PMAPPROC_UNSET ((u_int32_t)2) +#define SUNRPC_PMAPPROC_GETPORT ((u_int32_t)3) +#define SUNRPC_PMAPPROC_DUMP ((u_int32_t)4) +#define SUNRPC_PMAPPROC_CALLIT ((u_int32_t)5) + +struct sunrpc_pmap { + u_int32_t pm_prog; + u_int32_t pm_vers; + u_int32_t pm_prot; + u_int32_t pm_port; +};
diff --git a/tcpdump-4.3.0/ppi.h b/tcpdump-4.3.0/ppi.h new file mode 100644 index 0000000..733eb95 --- /dev/null +++ b/tcpdump-4.3.0/ppi.h
@@ -0,0 +1,9 @@ +typedef struct ppi_header { + uint8_t ppi_ver; + uint8_t ppi_flags; + uint16_t ppi_len; + uint32_t ppi_dlt; +} ppi_header_t; + +#define PPI_HDRLEN 8 +
diff --git a/tcpdump-4.3.0/ppp.h b/tcpdump-4.3.0/ppp.h new file mode 100644 index 0000000..f1a2c48 --- /dev/null +++ b/tcpdump-4.3.0/ppp.h
@@ -0,0 +1,71 @@ +/* @(#) $Header: /tcpdump/master/tcpdump/ppp.h,v 1.16 2004-10-20 16:14:16 hannes Exp $ (LBL) */ +/* + * Point to Point Protocol (PPP) RFC1331 + * + * Copyright 1989 by Carnegie Mellon. + * + * Permission to use, copy, modify, and distribute this program for any + * purpose and without fee is hereby granted, provided that this copyright + * and permission notice appear on all copies and supporting documentation, + * the name of Carnegie Mellon not be used in advertising or publicity + * pertaining to distribution of the program without specific prior + * permission, and notice be given in supporting documentation that copying + * and distribution is by permission of Carnegie Mellon and Stanford + * University. Carnegie Mellon makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + */ +#define PPP_HDRLEN 4 /* length of PPP header */ + +#define PPP_ADDRESS 0xff /* The address byte value */ +#define PPP_CONTROL 0x03 /* The control byte value */ + +#define PPP_WITHDIRECTION_IN 0x00 /* non-standard for DLT_PPP_WITHDIRECTION */ +#define PPP_WITHDIRECTION_OUT 0x01 /* non-standard for DLT_PPP_WITHDIRECTION */ + +/* Protocol numbers */ +#define PPP_IP 0x0021 /* Raw IP */ +#define PPP_OSI 0x0023 /* OSI Network Layer */ +#define PPP_NS 0x0025 /* Xerox NS IDP */ +#define PPP_DECNET 0x0027 /* DECnet Phase IV */ +#define PPP_APPLE 0x0029 /* Appletalk */ +#define PPP_IPX 0x002b /* Novell IPX */ +#define PPP_VJC 0x002d /* Van Jacobson Compressed TCP/IP */ +#define PPP_VJNC 0x002f /* Van Jacobson Uncompressed TCP/IP */ +#define PPP_BRPDU 0x0031 /* Bridging PDU */ +#define PPP_STII 0x0033 /* Stream Protocol (ST-II) */ +#define PPP_VINES 0x0035 /* Banyan Vines */ +#define PPP_ML 0x003d /* Multi-Link PPP */ +#define PPP_IPV6 0x0057 /* IPv6 */ +#define PPP_COMP 0x00fd /* Compressed Datagram */ + +#define PPP_HELLO 0x0201 /* 802.1d Hello Packets */ +#define PPP_LUXCOM 0x0231 /* Luxcom */ +#define PPP_SNS 0x0233 /* Sigma Network Systems */ +#define PPP_MPLS_UCAST 0x0281 /* rfc 3032 */ +#define PPP_MPLS_MCAST 0x0283 /* rfc 3022 */ + +#define PPP_IPCP 0x8021 /* IP Control Protocol */ +#define PPP_OSICP 0x8023 /* OSI Network Layer Control Protocol */ +#define PPP_NSCP 0x8025 /* Xerox NS IDP Control Protocol */ +#define PPP_DECNETCP 0x8027 /* DECnet Control Protocol */ +#define PPP_APPLECP 0x8029 /* Appletalk Control Protocol */ +#define PPP_IPXCP 0x802b /* Novell IPX Control Protocol */ +#define PPP_STIICP 0x8033 /* Strean Protocol Control Protocol */ +#define PPP_VINESCP 0x8035 /* Banyan Vines Control Protocol */ +#define PPP_IPV6CP 0x8057 /* IPv6 Control Protocol */ +#define PPP_CCP 0x80fd /* Compress Control Protocol */ +#define PPP_MPLSCP 0x8281 /* rfc 3022 */ + +#define PPP_LCP 0xc021 /* Link Control Protocol */ +#define PPP_PAP 0xc023 /* Password Authentication Protocol */ +#define PPP_LQM 0xc025 /* Link Quality Monitoring */ +#define PPP_SPAP 0xc027 +#define PPP_CHAP 0xc223 /* Challenge Handshake Authentication Protocol */ +#define PPP_BACP 0xc02b /* Bandwidth Allocation Control Protocol */ +#define PPP_BAP 0xc02d /* BAP */ +#define PPP_MPCP 0xc03d /* Multi-Link */ +#define PPP_SPAP_OLD 0xc123 +#define PPP_EAP 0xc227 + +extern struct tok ppptype2str[];
diff --git a/tcpdump-4.3.0/print-802_11.c b/tcpdump-4.3.0/print-802_11.c new file mode 100644 index 0000000..6f2231d --- /dev/null +++ b/tcpdump-4.3.0/print-802_11.c
@@ -0,0 +1,2358 @@ +/* + * Copyright (c) 2001 + * Fortress Technologies, Inc. All rights reserved. + * Charlie Lenahan (clenahan@fortresstech.com) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-802_11.c,v 1.49 2007-12-29 23:25:02 guy Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> +#include <pcap.h> +#include <string.h> + +#include "interface.h" +#include "addrtoname.h" +#include "ethertype.h" + +#include "extract.h" + +#include "cpack.h" + +#include "ieee802_11.h" +#include "ieee802_11_radio.h" + +/* Radiotap state */ +/* This is used to save state when parsing/processing parameters */ +struct radiotap_state +{ + u_int32_t present; + + u_int8_t rate; +}; + +#define PRINT_SSID(p) \ + if (p.ssid_present) { \ + printf(" ("); \ + fn_print(p.ssid.ssid, NULL); \ + printf(")"); \ + } + +#define PRINT_RATE(_sep, _r, _suf) \ + printf("%s%2.1f%s", _sep, (.5 * ((_r) & 0x7f)), _suf) +#define PRINT_RATES(p) \ + if (p.rates_present) { \ + int z; \ + const char *sep = " ["; \ + for (z = 0; z < p.rates.length ; z++) { \ + PRINT_RATE(sep, p.rates.rate[z], \ + (p.rates.rate[z] & 0x80 ? "*" : "")); \ + sep = " "; \ + } \ + if (p.rates.length != 0) \ + printf(" Mbit]"); \ + } + +#define PRINT_DS_CHANNEL(p) \ + if (p.ds_present) \ + printf(" CH: %u", p.ds.channel); \ + printf("%s", \ + CAPABILITY_PRIVACY(p.capability_info) ? ", PRIVACY" : "" ); + +#define MAX_MCS_INDEX 76 + +/* + * Indices are: + * + * the MCS index (0-76); + * + * 0 for 20 MHz, 1 for 40 MHz; + * + * 0 for a long guard interval, 1 for a short guard interval. + */ +static const float ieee80211_float_htrates[MAX_MCS_INDEX+1][2][2] = { + /* MCS 0 */ + { /* 20 Mhz */ { 6.5, /* SGI */ 7.2, }, + /* 40 Mhz */ { 13.5, /* SGI */ 15.0, }, + }, + + /* MCS 1 */ + { /* 20 Mhz */ { 13.0, /* SGI */ 14.4, }, + /* 40 Mhz */ { 27.0, /* SGI */ 30.0, }, + }, + + /* MCS 2 */ + { /* 20 Mhz */ { 19.5, /* SGI */ 21.7, }, + /* 40 Mhz */ { 40.5, /* SGI */ 45.0, }, + }, + + /* MCS 3 */ + { /* 20 Mhz */ { 26.0, /* SGI */ 28.9, }, + /* 40 Mhz */ { 54.0, /* SGI */ 60.0, }, + }, + + /* MCS 4 */ + { /* 20 Mhz */ { 39.0, /* SGI */ 43.3, }, + /* 40 Mhz */ { 81.0, /* SGI */ 90.0, }, + }, + + /* MCS 5 */ + { /* 20 Mhz */ { 52.0, /* SGI */ 57.8, }, + /* 40 Mhz */ { 108.0, /* SGI */ 120.0, }, + }, + + /* MCS 6 */ + { /* 20 Mhz */ { 58.5, /* SGI */ 65.0, }, + /* 40 Mhz */ { 121.5, /* SGI */ 135.0, }, + }, + + /* MCS 7 */ + { /* 20 Mhz */ { 65.0, /* SGI */ 72.2, }, + /* 40 Mhz */ { 135.0, /* SGI */ 150.0, }, + }, + + /* MCS 8 */ + { /* 20 Mhz */ { 13.0, /* SGI */ 14.4, }, + /* 40 Mhz */ { 27.0, /* SGI */ 30.0, }, + }, + + /* MCS 9 */ + { /* 20 Mhz */ { 26.0, /* SGI */ 28.9, }, + /* 40 Mhz */ { 54.0, /* SGI */ 60.0, }, + }, + + /* MCS 10 */ + { /* 20 Mhz */ { 39.0, /* SGI */ 43.3, }, + /* 40 Mhz */ { 81.0, /* SGI */ 90.0, }, + }, + + /* MCS 11 */ + { /* 20 Mhz */ { 52.0, /* SGI */ 57.8, }, + /* 40 Mhz */ { 108.0, /* SGI */ 120.0, }, + }, + + /* MCS 12 */ + { /* 20 Mhz */ { 78.0, /* SGI */ 86.7, }, + /* 40 Mhz */ { 162.0, /* SGI */ 180.0, }, + }, + + /* MCS 13 */ + { /* 20 Mhz */ { 104.0, /* SGI */ 115.6, }, + /* 40 Mhz */ { 216.0, /* SGI */ 240.0, }, + }, + + /* MCS 14 */ + { /* 20 Mhz */ { 117.0, /* SGI */ 130.0, }, + /* 40 Mhz */ { 243.0, /* SGI */ 270.0, }, + }, + + /* MCS 15 */ + { /* 20 Mhz */ { 130.0, /* SGI */ 144.4, }, + /* 40 Mhz */ { 270.0, /* SGI */ 300.0, }, + }, + + /* MCS 16 */ + { /* 20 Mhz */ { 19.5, /* SGI */ 21.7, }, + /* 40 Mhz */ { 40.5, /* SGI */ 45.0, }, + }, + + /* MCS 17 */ + { /* 20 Mhz */ { 39.0, /* SGI */ 43.3, }, + /* 40 Mhz */ { 81.0, /* SGI */ 90.0, }, + }, + + /* MCS 18 */ + { /* 20 Mhz */ { 58.5, /* SGI */ 65.0, }, + /* 40 Mhz */ { 121.5, /* SGI */ 135.0, }, + }, + + /* MCS 19 */ + { /* 20 Mhz */ { 78.0, /* SGI */ 86.7, }, + /* 40 Mhz */ { 162.0, /* SGI */ 180.0, }, + }, + + /* MCS 20 */ + { /* 20 Mhz */ { 117.0, /* SGI */ 130.0, }, + /* 40 Mhz */ { 243.0, /* SGI */ 270.0, }, + }, + + /* MCS 21 */ + { /* 20 Mhz */ { 156.0, /* SGI */ 173.3, }, + /* 40 Mhz */ { 324.0, /* SGI */ 360.0, }, + }, + + /* MCS 22 */ + { /* 20 Mhz */ { 175.5, /* SGI */ 195.0, }, + /* 40 Mhz */ { 364.5, /* SGI */ 405.0, }, + }, + + /* MCS 23 */ + { /* 20 Mhz */ { 195.0, /* SGI */ 216.7, }, + /* 40 Mhz */ { 405.0, /* SGI */ 450.0, }, + }, + + /* MCS 24 */ + { /* 20 Mhz */ { 26.0, /* SGI */ 28.9, }, + /* 40 Mhz */ { 54.0, /* SGI */ 60.0, }, + }, + + /* MCS 25 */ + { /* 20 Mhz */ { 52.0, /* SGI */ 57.8, }, + /* 40 Mhz */ { 108.0, /* SGI */ 120.0, }, + }, + + /* MCS 26 */ + { /* 20 Mhz */ { 78.0, /* SGI */ 86.7, }, + /* 40 Mhz */ { 162.0, /* SGI */ 180.0, }, + }, + + /* MCS 27 */ + { /* 20 Mhz */ { 104.0, /* SGI */ 115.6, }, + /* 40 Mhz */ { 216.0, /* SGI */ 240.0, }, + }, + + /* MCS 28 */ + { /* 20 Mhz */ { 156.0, /* SGI */ 173.3, }, + /* 40 Mhz */ { 324.0, /* SGI */ 360.0, }, + }, + + /* MCS 29 */ + { /* 20 Mhz */ { 208.0, /* SGI */ 231.1, }, + /* 40 Mhz */ { 432.0, /* SGI */ 480.0, }, + }, + + /* MCS 30 */ + { /* 20 Mhz */ { 234.0, /* SGI */ 260.0, }, + /* 40 Mhz */ { 486.0, /* SGI */ 540.0, }, + }, + + /* MCS 31 */ + { /* 20 Mhz */ { 260.0, /* SGI */ 288.9, }, + /* 40 Mhz */ { 540.0, /* SGI */ 600.0, }, + }, + + /* MCS 32 */ + { /* 20 Mhz */ { 0.0, /* SGI */ 0.0, }, /* not valid */ + /* 40 Mhz */ { 6.0, /* SGI */ 6.7, }, + }, + + /* MCS 33 */ + { /* 20 Mhz */ { 39.0, /* SGI */ 43.3, }, + /* 40 Mhz */ { 81.0, /* SGI */ 90.0, }, + }, + + /* MCS 34 */ + { /* 20 Mhz */ { 52.0, /* SGI */ 57.8, }, + /* 40 Mhz */ { 108.0, /* SGI */ 120.0, }, + }, + + /* MCS 35 */ + { /* 20 Mhz */ { 65.0, /* SGI */ 72.2, }, + /* 40 Mhz */ { 135.0, /* SGI */ 150.0, }, + }, + + /* MCS 36 */ + { /* 20 Mhz */ { 58.5, /* SGI */ 65.0, }, + /* 40 Mhz */ { 121.5, /* SGI */ 135.0, }, + }, + + /* MCS 37 */ + { /* 20 Mhz */ { 78.0, /* SGI */ 86.7, }, + /* 40 Mhz */ { 162.0, /* SGI */ 180.0, }, + }, + + /* MCS 38 */ + { /* 20 Mhz */ { 97.5, /* SGI */ 108.3, }, + /* 40 Mhz */ { 202.5, /* SGI */ 225.0, }, + }, + + /* MCS 39 */ + { /* 20 Mhz */ { 52.0, /* SGI */ 57.8, }, + /* 40 Mhz */ { 108.0, /* SGI */ 120.0, }, + }, + + /* MCS 40 */ + { /* 20 Mhz */ { 65.0, /* SGI */ 72.2, }, + /* 40 Mhz */ { 135.0, /* SGI */ 150.0, }, + }, + + /* MCS 41 */ + { /* 20 Mhz */ { 65.0, /* SGI */ 72.2, }, + /* 40 Mhz */ { 135.0, /* SGI */ 150.0, }, + }, + + /* MCS 42 */ + { /* 20 Mhz */ { 78.0, /* SGI */ 86.7, }, + /* 40 Mhz */ { 162.0, /* SGI */ 180.0, }, + }, + + /* MCS 43 */ + { /* 20 Mhz */ { 91.0, /* SGI */ 101.1, }, + /* 40 Mhz */ { 189.0, /* SGI */ 210.0, }, + }, + + /* MCS 44 */ + { /* 20 Mhz */ { 91.0, /* SGI */ 101.1, }, + /* 40 Mhz */ { 189.0, /* SGI */ 210.0, }, + }, + + /* MCS 45 */ + { /* 20 Mhz */ { 104.0, /* SGI */ 115.6, }, + /* 40 Mhz */ { 216.0, /* SGI */ 240.0, }, + }, + + /* MCS 46 */ + { /* 20 Mhz */ { 78.0, /* SGI */ 86.7, }, + /* 40 Mhz */ { 162.0, /* SGI */ 180.0, }, + }, + + /* MCS 47 */ + { /* 20 Mhz */ { 97.5, /* SGI */ 108.3, }, + /* 40 Mhz */ { 202.5, /* SGI */ 225.0, }, + }, + + /* MCS 48 */ + { /* 20 Mhz */ { 97.5, /* SGI */ 108.3, }, + /* 40 Mhz */ { 202.5, /* SGI */ 225.0, }, + }, + + /* MCS 49 */ + { /* 20 Mhz */ { 117.0, /* SGI */ 130.0, }, + /* 40 Mhz */ { 243.0, /* SGI */ 270.0, }, + }, + + /* MCS 50 */ + { /* 20 Mhz */ { 136.5, /* SGI */ 151.7, }, + /* 40 Mhz */ { 283.5, /* SGI */ 315.0, }, + }, + + /* MCS 51 */ + { /* 20 Mhz */ { 136.5, /* SGI */ 151.7, }, + /* 40 Mhz */ { 283.5, /* SGI */ 315.0, }, + }, + + /* MCS 52 */ + { /* 20 Mhz */ { 156.0, /* SGI */ 173.3, }, + /* 40 Mhz */ { 324.0, /* SGI */ 360.0, }, + }, + + /* MCS 53 */ + { /* 20 Mhz */ { 65.0, /* SGI */ 72.2, }, + /* 40 Mhz */ { 135.0, /* SGI */ 150.0, }, + }, + + /* MCS 54 */ + { /* 20 Mhz */ { 78.0, /* SGI */ 86.7, }, + /* 40 Mhz */ { 162.0, /* SGI */ 180.0, }, + }, + + /* MCS 55 */ + { /* 20 Mhz */ { 91.0, /* SGI */ 101.1, }, + /* 40 Mhz */ { 189.0, /* SGI */ 210.0, }, + }, + + /* MCS 56 */ + { /* 20 Mhz */ { 78.0, /* SGI */ 86.7, }, + /* 40 Mhz */ { 162.0, /* SGI */ 180.0, }, + }, + + /* MCS 57 */ + { /* 20 Mhz */ { 91.0, /* SGI */ 101.1, }, + /* 40 Mhz */ { 189.0, /* SGI */ 210.0, }, + }, + + /* MCS 58 */ + { /* 20 Mhz */ { 104.0, /* SGI */ 115.6, }, + /* 40 Mhz */ { 216.0, /* SGI */ 240.0, }, + }, + + /* MCS 59 */ + { /* 20 Mhz */ { 117.0, /* SGI */ 130.0, }, + /* 40 Mhz */ { 243.0, /* SGI */ 270.0, }, + }, + + /* MCS 60 */ + { /* 20 Mhz */ { 104.0, /* SGI */ 115.6, }, + /* 40 Mhz */ { 216.0, /* SGI */ 240.0, }, + }, + + /* MCS 61 */ + { /* 20 Mhz */ { 117.0, /* SGI */ 130.0, }, + /* 40 Mhz */ { 243.0, /* SGI */ 270.0, }, + }, + + /* MCS 62 */ + { /* 20 Mhz */ { 130.0, /* SGI */ 144.4, }, + /* 40 Mhz */ { 270.0, /* SGI */ 300.0, }, + }, + + /* MCS 63 */ + { /* 20 Mhz */ { 130.0, /* SGI */ 144.4, }, + /* 40 Mhz */ { 270.0, /* SGI */ 300.0, }, + }, + + /* MCS 64 */ + { /* 20 Mhz */ { 143.0, /* SGI */ 158.9, }, + /* 40 Mhz */ { 297.0, /* SGI */ 330.0, }, + }, + + /* MCS 65 */ + { /* 20 Mhz */ { 97.5, /* SGI */ 108.3, }, + /* 40 Mhz */ { 202.5, /* SGI */ 225.0, }, + }, + + /* MCS 66 */ + { /* 20 Mhz */ { 117.0, /* SGI */ 130.0, }, + /* 40 Mhz */ { 243.0, /* SGI */ 270.0, }, + }, + + /* MCS 67 */ + { /* 20 Mhz */ { 136.5, /* SGI */ 151.7, }, + /* 40 Mhz */ { 283.5, /* SGI */ 315.0, }, + }, + + /* MCS 68 */ + { /* 20 Mhz */ { 117.0, /* SGI */ 130.0, }, + /* 40 Mhz */ { 243.0, /* SGI */ 270.0, }, + }, + + /* MCS 69 */ + { /* 20 Mhz */ { 136.5, /* SGI */ 151.7, }, + /* 40 Mhz */ { 283.5, /* SGI */ 315.0, }, + }, + + /* MCS 70 */ + { /* 20 Mhz */ { 156.0, /* SGI */ 173.3, }, + /* 40 Mhz */ { 324.0, /* SGI */ 360.0, }, + }, + + /* MCS 71 */ + { /* 20 Mhz */ { 175.5, /* SGI */ 195.0, }, + /* 40 Mhz */ { 364.5, /* SGI */ 405.0, }, + }, + + /* MCS 72 */ + { /* 20 Mhz */ { 156.0, /* SGI */ 173.3, }, + /* 40 Mhz */ { 324.0, /* SGI */ 360.0, }, + }, + + /* MCS 73 */ + { /* 20 Mhz */ { 175.5, /* SGI */ 195.0, }, + /* 40 Mhz */ { 364.5, /* SGI */ 405.0, }, + }, + + /* MCS 74 */ + { /* 20 Mhz */ { 195.0, /* SGI */ 216.7, }, + /* 40 Mhz */ { 405.0, /* SGI */ 450.0, }, + }, + + /* MCS 75 */ + { /* 20 Mhz */ { 195.0, /* SGI */ 216.7, }, + /* 40 Mhz */ { 405.0, /* SGI */ 450.0, }, + }, + + /* MCS 76 */ + { /* 20 Mhz */ { 214.5, /* SGI */ 238.3, }, + /* 40 Mhz */ { 445.5, /* SGI */ 495.0, }, + }, +}; + +static const char *auth_alg_text[]={"Open System","Shared Key","EAP"}; +#define NUM_AUTH_ALGS (sizeof auth_alg_text / sizeof auth_alg_text[0]) + +static const char *status_text[] = { + "Successful", /* 0 */ + "Unspecified failure", /* 1 */ + "Reserved", /* 2 */ + "Reserved", /* 3 */ + "Reserved", /* 4 */ + "Reserved", /* 5 */ + "Reserved", /* 6 */ + "Reserved", /* 7 */ + "Reserved", /* 8 */ + "Reserved", /* 9 */ + "Cannot Support all requested capabilities in the Capability " + "Information field", /* 10 */ + "Reassociation denied due to inability to confirm that association " + "exists", /* 11 */ + "Association denied due to reason outside the scope of the " + "standard", /* 12 */ + "Responding station does not support the specified authentication " + "algorithm ", /* 13 */ + "Received an Authentication frame with authentication transaction " + "sequence number out of expected sequence", /* 14 */ + "Authentication rejected because of challenge failure", /* 15 */ + "Authentication rejected due to timeout waiting for next frame in " + "sequence", /* 16 */ + "Association denied because AP is unable to handle additional" + "associated stations", /* 17 */ + "Association denied due to requesting station not supporting all of " + "the data rates in BSSBasicRateSet parameter", /* 18 */ + "Association denied due to requesting station not supporting " + "short preamble operation", /* 19 */ + "Association denied due to requesting station not supporting " + "PBCC encoding", /* 20 */ + "Association denied due to requesting station not supporting " + "channel agility", /* 21 */ + "Association request rejected because Spectrum Management " + "capability is required", /* 22 */ + "Association request rejected because the information in the " + "Power Capability element is unacceptable", /* 23 */ + "Association request rejected because the information in the " + "Supported Channels element is unacceptable", /* 24 */ + "Association denied due to requesting station not supporting " + "short slot operation", /* 25 */ + "Association denied due to requesting station not supporting " + "DSSS-OFDM operation", /* 26 */ + "Association denied because the requested STA does not support HT " + "features", /* 27 */ + "Reserved", /* 28 */ + "Association denied because the requested STA does not support " + "the PCO transition time required by the AP", /* 29 */ + "Reserved", /* 30 */ + "Reserved", /* 31 */ + "Unspecified, QoS-related failure", /* 32 */ + "Association denied due to QAP having insufficient bandwidth " + "to handle another QSTA", /* 33 */ + "Association denied due to excessive frame loss rates and/or " + "poor conditions on current operating channel", /* 34 */ + "Association (with QBSS) denied due to requesting station not " + "supporting the QoS facility", /* 35 */ + "Association denied due to requesting station not supporting " + "Block Ack", /* 36 */ + "The request has been declined", /* 37 */ + "The request has not been successful as one or more parameters " + "have invalid values", /* 38 */ + "The TS has not been created because the request cannot be honored. " + "However, a suggested TSPEC is provided so that the initiating QSTA" + "may attempt to set another TS with the suggested changes to the " + "TSPEC", /* 39 */ + "Invalid Information Element", /* 40 */ + "Group Cipher is not valid", /* 41 */ + "Pairwise Cipher is not valid", /* 42 */ + "AKMP is not valid", /* 43 */ + "Unsupported RSN IE version", /* 44 */ + "Invalid RSN IE Capabilities", /* 45 */ + "Cipher suite is rejected per security policy", /* 46 */ + "The TS has not been created. However, the HC may be capable of " + "creating a TS, in response to a request, after the time indicated " + "in the TS Delay element", /* 47 */ + "Direct Link is not allowed in the BSS by policy", /* 48 */ + "Destination STA is not present within this QBSS.", /* 49 */ + "The Destination STA is not a QSTA.", /* 50 */ + +}; +#define NUM_STATUSES (sizeof status_text / sizeof status_text[0]) + +static const char *reason_text[] = { + "Reserved", /* 0 */ + "Unspecified reason", /* 1 */ + "Previous authentication no longer valid", /* 2 */ + "Deauthenticated because sending station is leaving (or has left) " + "IBSS or ESS", /* 3 */ + "Disassociated due to inactivity", /* 4 */ + "Disassociated because AP is unable to handle all currently " + " associated stations", /* 5 */ + "Class 2 frame received from nonauthenticated station", /* 6 */ + "Class 3 frame received from nonassociated station", /* 7 */ + "Disassociated because sending station is leaving " + "(or has left) BSS", /* 8 */ + "Station requesting (re)association is not authenticated with " + "responding station", /* 9 */ + "Disassociated because the information in the Power Capability " + "element is unacceptable", /* 10 */ + "Disassociated because the information in the SupportedChannels " + "element is unacceptable", /* 11 */ + "Invalid Information Element", /* 12 */ + "Reserved", /* 13 */ + "Michael MIC failure", /* 14 */ + "4-Way Handshake timeout", /* 15 */ + "Group key update timeout", /* 16 */ + "Information element in 4-Way Handshake different from (Re)Association" + "Request/Probe Response/Beacon", /* 17 */ + "Group Cipher is not valid", /* 18 */ + "AKMP is not valid", /* 20 */ + "Unsupported RSN IE version", /* 21 */ + "Invalid RSN IE Capabilities", /* 22 */ + "IEEE 802.1X Authentication failed", /* 23 */ + "Cipher suite is rejected per security policy", /* 24 */ + "Reserved", /* 25 */ + "Reserved", /* 26 */ + "Reserved", /* 27 */ + "Reserved", /* 28 */ + "Reserved", /* 29 */ + "Reserved", /* 30 */ + "TS deleted because QoS AP lacks sufficient bandwidth for this " + "QoS STA due to a change in BSS service characteristics or " + "operational mode (e.g. an HT BSS change from 40 MHz channel " + "to 20 MHz channel)", /* 31 */ + "Disassociated for unspecified, QoS-related reason", /* 32 */ + "Disassociated because QoS AP lacks sufficient bandwidth for this " + "QoS STA", /* 33 */ + "Disassociated because of excessive number of frames that need to be " + "acknowledged, but are not acknowledged for AP transmissions " + "and/or poor channel conditions", /* 34 */ + "Disassociated because STA is transmitting outside the limits " + "of its TXOPs", /* 35 */ + "Requested from peer STA as the STA is leaving the BSS " + "(or resetting)", /* 36 */ + "Requested from peer STA as it does not want to use the " + "mechanism", /* 37 */ + "Requested from peer STA as the STA received frames using the " + "mechanism for which a set up is required", /* 38 */ + "Requested from peer STA due to time out", /* 39 */ + "Reserved", /* 40 */ + "Reserved", /* 41 */ + "Reserved", /* 42 */ + "Reserved", /* 43 */ + "Reserved", /* 44 */ + "Peer STA does not support the requested cipher suite", /* 45 */ + "Association denied due to requesting STA not supporting HT " + "features", /* 46 */ +}; +#define NUM_REASONS (sizeof reason_text / sizeof reason_text[0]) + +static int +wep_print(const u_char *p) +{ + u_int32_t iv; + + if (!TTEST2(*p, IEEE802_11_IV_LEN + IEEE802_11_KID_LEN)) + return 0; + iv = EXTRACT_LE_32BITS(p); + + printf("Data IV:%3x Pad %x KeyID %x", IV_IV(iv), IV_PAD(iv), + IV_KEYID(iv)); + + return 1; +} + +static int +parse_elements(struct mgmt_body_t *pbody, const u_char *p, int offset, + u_int length) +{ + u_int elementlen; + struct ssid_t ssid; + struct challenge_t challenge; + struct rates_t rates; + struct ds_t ds; + struct cf_t cf; + struct tim_t tim; + + /* + * We haven't seen any elements yet. + */ + pbody->challenge_present = 0; + pbody->ssid_present = 0; + pbody->rates_present = 0; + pbody->ds_present = 0; + pbody->cf_present = 0; + pbody->tim_present = 0; + + while (length != 0) { + if (!TTEST2(*(p + offset), 1)) + return 0; + if (length < 1) + return 0; + switch (*(p + offset)) { + case E_SSID: + if (!TTEST2(*(p + offset), 2)) + return 0; + if (length < 2) + return 0; + memcpy(&ssid, p + offset, 2); + offset += 2; + length -= 2; + if (ssid.length != 0) { + if (ssid.length > sizeof(ssid.ssid) - 1) + return 0; + if (!TTEST2(*(p + offset), ssid.length)) + return 0; + if (length < ssid.length) + return 0; + memcpy(&ssid.ssid, p + offset, ssid.length); + offset += ssid.length; + length -= ssid.length; + } + ssid.ssid[ssid.length] = '\0'; + /* + * Present and not truncated. + * + * If we haven't already seen an SSID IE, + * copy this one, otherwise ignore this one, + * so we later report the first one we saw. + */ + if (!pbody->ssid_present) { + pbody->ssid = ssid; + pbody->ssid_present = 1; + } + break; + case E_CHALLENGE: + if (!TTEST2(*(p + offset), 2)) + return 0; + if (length < 2) + return 0; + memcpy(&challenge, p + offset, 2); + offset += 2; + length -= 2; + if (challenge.length != 0) { + if (challenge.length > + sizeof(challenge.text) - 1) + return 0; + if (!TTEST2(*(p + offset), challenge.length)) + return 0; + if (length < challenge.length) + return 0; + memcpy(&challenge.text, p + offset, + challenge.length); + offset += challenge.length; + length -= challenge.length; + } + challenge.text[challenge.length] = '\0'; + /* + * Present and not truncated. + * + * If we haven't already seen a challenge IE, + * copy this one, otherwise ignore this one, + * so we later report the first one we saw. + */ + if (!pbody->challenge_present) { + pbody->challenge = challenge; + pbody->challenge_present = 1; + } + break; + case E_RATES: + if (!TTEST2(*(p + offset), 2)) + return 0; + if (length < 2) + return 0; + memcpy(&rates, p + offset, 2); + offset += 2; + length -= 2; + if (rates.length != 0) { + if (rates.length > sizeof rates.rate) + return 0; + if (!TTEST2(*(p + offset), rates.length)) + return 0; + if (length < rates.length) + return 0; + memcpy(&rates.rate, p + offset, rates.length); + offset += rates.length; + length -= rates.length; + } + /* + * Present and not truncated. + * + * If we haven't already seen a rates IE, + * copy this one if it's not zero-length, + * otherwise ignore this one, so we later + * report the first one we saw. + * + * We ignore zero-length rates IEs as some + * devices seem to put a zero-length rates + * IE, followed by an SSID IE, followed by + * a non-zero-length rates IE into frames, + * even though IEEE Std 802.11-2007 doesn't + * seem to indicate that a zero-length rates + * IE is valid. + */ + if (!pbody->rates_present && rates.length != 0) { + pbody->rates = rates; + pbody->rates_present = 1; + } + break; + case E_DS: + if (!TTEST2(*(p + offset), 3)) + return 0; + if (length < 3) + return 0; + memcpy(&ds, p + offset, 3); + offset += 3; + length -= 3; + /* + * Present and not truncated. + * + * If we haven't already seen a DS IE, + * copy this one, otherwise ignore this one, + * so we later report the first one we saw. + */ + if (!pbody->ds_present) { + pbody->ds = ds; + pbody->ds_present = 1; + } + break; + case E_CF: + if (!TTEST2(*(p + offset), 8)) + return 0; + if (length < 8) + return 0; + memcpy(&cf, p + offset, 8); + offset += 8; + length -= 8; + /* + * Present and not truncated. + * + * If we haven't already seen a CF IE, + * copy this one, otherwise ignore this one, + * so we later report the first one we saw. + */ + if (!pbody->cf_present) { + pbody->cf = cf; + pbody->cf_present = 1; + } + break; + case E_TIM: + if (!TTEST2(*(p + offset), 2)) + return 0; + if (length < 2) + return 0; + memcpy(&tim, p + offset, 2); + offset += 2; + length -= 2; + if (!TTEST2(*(p + offset), 3)) + return 0; + if (length < 3) + return 0; + memcpy(&tim.count, p + offset, 3); + offset += 3; + length -= 3; + + if (tim.length <= 3) + break; + if (tim.length - 3 > (int)sizeof tim.bitmap) + return 0; + if (!TTEST2(*(p + offset), tim.length - 3)) + return 0; + if (length < (u_int)(tim.length - 3)) + return 0; + memcpy(tim.bitmap, p + (tim.length - 3), + (tim.length - 3)); + offset += tim.length - 3; + length -= tim.length - 3; + /* + * Present and not truncated. + * + * If we haven't already seen a TIM IE, + * copy this one, otherwise ignore this one, + * so we later report the first one we saw. + */ + if (!pbody->tim_present) { + pbody->tim = tim; + pbody->tim_present = 1; + } + break; + default: +#if 0 + printf("(1) unhandled element_id (%d) ", + *(p + offset)); +#endif + if (!TTEST2(*(p + offset), 2)) + return 0; + if (length < 2) + return 0; + elementlen = *(p + offset + 1); + if (!TTEST2(*(p + offset + 2), elementlen)) + return 0; + if (length < elementlen + 2) + return 0; + offset += elementlen + 2; + length -= elementlen + 2; + break; + } + } + + /* No problems found. */ + return 1; +} + +/********************************************************************************* + * Print Handle functions for the management frame types + *********************************************************************************/ + +static int +handle_beacon(const u_char *p, u_int length) +{ + struct mgmt_body_t pbody; + int offset = 0; + int ret; + + memset(&pbody, 0, sizeof(pbody)); + + if (!TTEST2(*p, IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN + + IEEE802_11_CAPINFO_LEN)) + return 0; + if (length < IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN + + IEEE802_11_CAPINFO_LEN) + return 0; + memcpy(&pbody.timestamp, p, IEEE802_11_TSTAMP_LEN); + offset += IEEE802_11_TSTAMP_LEN; + length -= IEEE802_11_TSTAMP_LEN; + pbody.beacon_interval = EXTRACT_LE_16BITS(p+offset); + offset += IEEE802_11_BCNINT_LEN; + length -= IEEE802_11_BCNINT_LEN; + pbody.capability_info = EXTRACT_LE_16BITS(p+offset); + offset += IEEE802_11_CAPINFO_LEN; + length -= IEEE802_11_CAPINFO_LEN; + + ret = parse_elements(&pbody, p, offset, length); + + PRINT_SSID(pbody); + PRINT_RATES(pbody); + printf(" %s", + CAPABILITY_ESS(pbody.capability_info) ? "ESS" : "IBSS"); + PRINT_DS_CHANNEL(pbody); + + return ret; +} + +static int +handle_assoc_request(const u_char *p, u_int length) +{ + struct mgmt_body_t pbody; + int offset = 0; + int ret; + + memset(&pbody, 0, sizeof(pbody)); + + if (!TTEST2(*p, IEEE802_11_CAPINFO_LEN + IEEE802_11_LISTENINT_LEN)) + return 0; + if (length < IEEE802_11_CAPINFO_LEN + IEEE802_11_LISTENINT_LEN) + return 0; + pbody.capability_info = EXTRACT_LE_16BITS(p); + offset += IEEE802_11_CAPINFO_LEN; + length -= IEEE802_11_CAPINFO_LEN; + pbody.listen_interval = EXTRACT_LE_16BITS(p+offset); + offset += IEEE802_11_LISTENINT_LEN; + length -= IEEE802_11_LISTENINT_LEN; + + ret = parse_elements(&pbody, p, offset, length); + + PRINT_SSID(pbody); + PRINT_RATES(pbody); + return ret; +} + +static int +handle_assoc_response(const u_char *p, u_int length) +{ + struct mgmt_body_t pbody; + int offset = 0; + int ret; + + memset(&pbody, 0, sizeof(pbody)); + + if (!TTEST2(*p, IEEE802_11_CAPINFO_LEN + IEEE802_11_STATUS_LEN + + IEEE802_11_AID_LEN)) + return 0; + if (length < IEEE802_11_CAPINFO_LEN + IEEE802_11_STATUS_LEN + + IEEE802_11_AID_LEN) + return 0; + pbody.capability_info = EXTRACT_LE_16BITS(p); + offset += IEEE802_11_CAPINFO_LEN; + length -= IEEE802_11_CAPINFO_LEN; + pbody.status_code = EXTRACT_LE_16BITS(p+offset); + offset += IEEE802_11_STATUS_LEN; + length -= IEEE802_11_STATUS_LEN; + pbody.aid = EXTRACT_LE_16BITS(p+offset); + offset += IEEE802_11_AID_LEN; + length -= IEEE802_11_AID_LEN; + + ret = parse_elements(&pbody, p, offset, length); + + printf(" AID(%x) :%s: %s", ((u_int16_t)(pbody.aid << 2 )) >> 2 , + CAPABILITY_PRIVACY(pbody.capability_info) ? " PRIVACY " : "", + (pbody.status_code < NUM_STATUSES + ? status_text[pbody.status_code] + : "n/a")); + + return ret; +} + +static int +handle_reassoc_request(const u_char *p, u_int length) +{ + struct mgmt_body_t pbody; + int offset = 0; + int ret; + + memset(&pbody, 0, sizeof(pbody)); + + if (!TTEST2(*p, IEEE802_11_CAPINFO_LEN + IEEE802_11_LISTENINT_LEN + + IEEE802_11_AP_LEN)) + return 0; + if (length < IEEE802_11_CAPINFO_LEN + IEEE802_11_LISTENINT_LEN + + IEEE802_11_AP_LEN) + return 0; + pbody.capability_info = EXTRACT_LE_16BITS(p); + offset += IEEE802_11_CAPINFO_LEN; + length -= IEEE802_11_CAPINFO_LEN; + pbody.listen_interval = EXTRACT_LE_16BITS(p+offset); + offset += IEEE802_11_LISTENINT_LEN; + length -= IEEE802_11_LISTENINT_LEN; + memcpy(&pbody.ap, p+offset, IEEE802_11_AP_LEN); + offset += IEEE802_11_AP_LEN; + length -= IEEE802_11_AP_LEN; + + ret = parse_elements(&pbody, p, offset, length); + + PRINT_SSID(pbody); + printf(" AP : %s", etheraddr_string( pbody.ap )); + + return ret; +} + +static int +handle_reassoc_response(const u_char *p, u_int length) +{ + /* Same as a Association Reponse */ + return handle_assoc_response(p, length); +} + +static int +handle_probe_request(const u_char *p, u_int length) +{ + struct mgmt_body_t pbody; + int offset = 0; + int ret; + + memset(&pbody, 0, sizeof(pbody)); + + ret = parse_elements(&pbody, p, offset, length); + + PRINT_SSID(pbody); + PRINT_RATES(pbody); + + return ret; +} + +static int +handle_probe_response(const u_char *p, u_int length) +{ + struct mgmt_body_t pbody; + int offset = 0; + int ret; + + memset(&pbody, 0, sizeof(pbody)); + + if (!TTEST2(*p, IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN + + IEEE802_11_CAPINFO_LEN)) + return 0; + if (length < IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN + + IEEE802_11_CAPINFO_LEN) + return 0; + memcpy(&pbody.timestamp, p, IEEE802_11_TSTAMP_LEN); + offset += IEEE802_11_TSTAMP_LEN; + length -= IEEE802_11_TSTAMP_LEN; + pbody.beacon_interval = EXTRACT_LE_16BITS(p+offset); + offset += IEEE802_11_BCNINT_LEN; + length -= IEEE802_11_BCNINT_LEN; + pbody.capability_info = EXTRACT_LE_16BITS(p+offset); + offset += IEEE802_11_CAPINFO_LEN; + length -= IEEE802_11_CAPINFO_LEN; + + ret = parse_elements(&pbody, p, offset, length); + + PRINT_SSID(pbody); + PRINT_RATES(pbody); + PRINT_DS_CHANNEL(pbody); + + return ret; +} + +static int +handle_atim(void) +{ + /* the frame body for ATIM is null. */ + return 1; +} + +static int +handle_disassoc(const u_char *p, u_int length) +{ + struct mgmt_body_t pbody; + + memset(&pbody, 0, sizeof(pbody)); + + if (!TTEST2(*p, IEEE802_11_REASON_LEN)) + return 0; + if (length < IEEE802_11_REASON_LEN) + return 0; + pbody.reason_code = EXTRACT_LE_16BITS(p); + + printf(": %s", + (pbody.reason_code < NUM_REASONS) + ? reason_text[pbody.reason_code] + : "Reserved" ); + + return 1; +} + +static int +handle_auth(const u_char *p, u_int length) +{ + struct mgmt_body_t pbody; + int offset = 0; + int ret; + + memset(&pbody, 0, sizeof(pbody)); + + if (!TTEST2(*p, 6)) + return 0; + if (length < 6) + return 0; + pbody.auth_alg = EXTRACT_LE_16BITS(p); + offset += 2; + length -= 2; + pbody.auth_trans_seq_num = EXTRACT_LE_16BITS(p + offset); + offset += 2; + length -= 2; + pbody.status_code = EXTRACT_LE_16BITS(p + offset); + offset += 2; + length -= 2; + + ret = parse_elements(&pbody, p, offset, length); + + if ((pbody.auth_alg == 1) && + ((pbody.auth_trans_seq_num == 2) || + (pbody.auth_trans_seq_num == 3))) { + printf(" (%s)-%x [Challenge Text] %s", + (pbody.auth_alg < NUM_AUTH_ALGS) + ? auth_alg_text[pbody.auth_alg] + : "Reserved", + pbody.auth_trans_seq_num, + ((pbody.auth_trans_seq_num % 2) + ? ((pbody.status_code < NUM_STATUSES) + ? status_text[pbody.status_code] + : "n/a") : "")); + return ret; + } + printf(" (%s)-%x: %s", + (pbody.auth_alg < NUM_AUTH_ALGS) + ? auth_alg_text[pbody.auth_alg] + : "Reserved", + pbody.auth_trans_seq_num, + (pbody.auth_trans_seq_num % 2) + ? ((pbody.status_code < NUM_STATUSES) + ? status_text[pbody.status_code] + : "n/a") + : ""); + + return ret; +} + +static int +handle_deauth(const struct mgmt_header_t *pmh, const u_char *p, u_int length) +{ + struct mgmt_body_t pbody; + int offset = 0; + const char *reason = NULL; + + memset(&pbody, 0, sizeof(pbody)); + + if (!TTEST2(*p, IEEE802_11_REASON_LEN)) + return 0; + if (length < IEEE802_11_REASON_LEN) + return 0; + pbody.reason_code = EXTRACT_LE_16BITS(p); + offset += IEEE802_11_REASON_LEN; + length -= IEEE802_11_REASON_LEN; + + reason = (pbody.reason_code < NUM_REASONS) + ? reason_text[pbody.reason_code] + : "Reserved"; + + if (eflag) { + printf(": %s", reason); + } else { + printf(" (%s): %s", etheraddr_string(pmh->sa), reason); + } + return 1; +} + +#define PRINT_HT_ACTION(v) (\ + (v) == 0 ? printf("TxChWidth") : \ + (v) == 1 ? printf("MIMOPwrSave") : \ + printf("Act#%d", (v)) \ +) +#define PRINT_BA_ACTION(v) (\ + (v) == 0 ? printf("ADDBA Request") : \ + (v) == 1 ? printf("ADDBA Response") : \ + (v) == 2 ? printf("DELBA") : \ + printf("Act#%d", (v)) \ +) +#define PRINT_MESHLINK_ACTION(v) (\ + (v) == 0 ? printf("Request") : \ + (v) == 1 ? printf("Report") : \ + printf("Act#%d", (v)) \ +) +#define PRINT_MESHPEERING_ACTION(v) (\ + (v) == 0 ? printf("Open") : \ + (v) == 1 ? printf("Confirm") : \ + (v) == 2 ? printf("Close") : \ + printf("Act#%d", (v)) \ +) +#define PRINT_MESHPATH_ACTION(v) (\ + (v) == 0 ? printf("Request") : \ + (v) == 1 ? printf("Report") : \ + (v) == 2 ? printf("Error") : \ + (v) == 3 ? printf("RootAnnouncement") : \ + printf("Act#%d", (v)) \ +) + +static int +handle_action(const struct mgmt_header_t *pmh, const u_char *p, u_int length) +{ + if (!TTEST2(*p, 2)) + return 0; + if (length < 2) + return 0; + if (eflag) { + printf(": "); + } else { + printf(" (%s): ", etheraddr_string(pmh->sa)); + } + switch (p[0]) { + case 0: printf("Spectrum Management Act#%d", p[1]); break; + case 1: printf("QoS Act#%d", p[1]); break; + case 2: printf("DLS Act#%d", p[1]); break; + case 3: printf("BA "); PRINT_BA_ACTION(p[1]); break; + case 7: printf("HT "); PRINT_HT_ACTION(p[1]); break; + case 13: printf("MeshLMetric "); PRINT_MESHLINK_ACTION(p[1]); break; + case 15: printf("Interwork Act#%d", p[1]); break; + case 16: printf("Resource Act#%d", p[1]); break; + case 17: printf("Proxy Act#%d", p[1]); break; + case 30: printf("MeshPeering "); PRINT_MESHPEERING_ACTION(p[1]); break; + case 32: printf("MeshPath "); PRINT_MESHPATH_ACTION(p[1]); break; + case 127: printf("Vendor Act#%d", p[1]); break; + default: + printf("Reserved(%d) Act#%d", p[0], p[1]); + break; + } + return 1; +} + + +/********************************************************************************* + * Print Body funcs + *********************************************************************************/ + + +static int +mgmt_body_print(u_int16_t fc, const struct mgmt_header_t *pmh, + const u_char *p, u_int length) +{ + switch (FC_SUBTYPE(fc)) { + case ST_ASSOC_REQUEST: + printf("Assoc Request"); + return handle_assoc_request(p, length); + case ST_ASSOC_RESPONSE: + printf("Assoc Response"); + return handle_assoc_response(p, length); + case ST_REASSOC_REQUEST: + printf("ReAssoc Request"); + return handle_reassoc_request(p, length); + case ST_REASSOC_RESPONSE: + printf("ReAssoc Response"); + return handle_reassoc_response(p, length); + case ST_PROBE_REQUEST: + printf("Probe Request"); + return handle_probe_request(p, length); + case ST_PROBE_RESPONSE: + printf("Probe Response"); + return handle_probe_response(p, length); + case ST_BEACON: + printf("Beacon"); + return handle_beacon(p, length); + case ST_ATIM: + printf("ATIM"); + return handle_atim(); + case ST_DISASSOC: + printf("Disassociation"); + return handle_disassoc(p, length); + case ST_AUTH: + printf("Authentication"); + 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); + } + return handle_auth(p, length); + case ST_DEAUTH: + printf("DeAuthentication"); + return handle_deauth(pmh, p, length); + break; + case ST_ACTION: + printf("Action"); + return handle_action(pmh, p, length); + break; + default: + printf("Unhandled Management subtype(%x)", + FC_SUBTYPE(fc)); + return 1; + } +} + + +/********************************************************************************* + * Handles printing all the control frame types + *********************************************************************************/ + +static int +ctrl_body_print(u_int16_t fc, const u_char *p) +{ + switch (FC_SUBTYPE(fc)) { + case CTRL_CONTROL_WRAPPER: + printf("Control Wrapper"); + /* XXX - requires special handling */ + break; + case CTRL_BAR: + printf("BAR"); + if (!TTEST2(*p, CTRL_BAR_HDRLEN)) + return 0; + if (!eflag) + printf(" RA:%s TA:%s CTL(%x) SEQ(%u) ", + etheraddr_string(((const struct ctrl_bar_t *)p)->ra), + etheraddr_string(((const struct ctrl_bar_t *)p)->ta), + EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t *)p)->ctl)), + EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t *)p)->seq))); + break; + case CTRL_BA: + printf("BA"); + if (!TTEST2(*p, CTRL_BA_HDRLEN)) + return 0; + if (!eflag) + printf(" RA:%s ", + etheraddr_string(((const struct ctrl_ba_t *)p)->ra)); + break; + case CTRL_PS_POLL: + printf("Power Save-Poll"); + if (!TTEST2(*p, CTRL_PS_POLL_HDRLEN)) + return 0; + printf(" AID(%x)", + EXTRACT_LE_16BITS(&(((const struct ctrl_ps_poll_t *)p)->aid))); + break; + case CTRL_RTS: + printf("Request-To-Send"); + if (!TTEST2(*p, CTRL_RTS_HDRLEN)) + return 0; + if (!eflag) + printf(" TA:%s ", + etheraddr_string(((const struct ctrl_rts_t *)p)->ta)); + break; + case CTRL_CTS: + printf("Clear-To-Send"); + if (!TTEST2(*p, CTRL_CTS_HDRLEN)) + return 0; + if (!eflag) + printf(" RA:%s ", + etheraddr_string(((const struct ctrl_cts_t *)p)->ra)); + break; + case CTRL_ACK: + printf("Acknowledgment"); + if (!TTEST2(*p, CTRL_ACK_HDRLEN)) + return 0; + if (!eflag) + printf(" RA:%s ", + etheraddr_string(((const struct ctrl_ack_t *)p)->ra)); + break; + case CTRL_CF_END: + printf("CF-End"); + if (!TTEST2(*p, CTRL_END_HDRLEN)) + return 0; + if (!eflag) + printf(" RA:%s ", + etheraddr_string(((const struct ctrl_end_t *)p)->ra)); + break; + case CTRL_END_ACK: + printf("CF-End+CF-Ack"); + if (!TTEST2(*p, CTRL_END_ACK_HDRLEN)) + return 0; + if (!eflag) + printf(" RA:%s ", + etheraddr_string(((const struct ctrl_end_ack_t *)p)->ra)); + break; + default: + printf("Unknown Ctrl Subtype"); + } + return 1; +} + +/* + * Print Header funcs + */ + +/* + * Data Frame - Address field contents + * + * To Ds | From DS | Addr 1 | Addr 2 | Addr 3 | Addr 4 + * 0 | 0 | DA | SA | BSSID | n/a + * 0 | 1 | DA | BSSID | SA | n/a + * 1 | 0 | BSSID | SA | DA | n/a + * 1 | 1 | RA | TA | DA | SA + */ + +static void +data_header_print(u_int16_t fc, const u_char *p, const u_int8_t **srcp, + const u_int8_t **dstp) +{ + u_int subtype = FC_SUBTYPE(fc); + + if (DATA_FRAME_IS_CF_ACK(subtype) || DATA_FRAME_IS_CF_POLL(subtype) || + DATA_FRAME_IS_QOS(subtype)) { + printf("CF "); + if (DATA_FRAME_IS_CF_ACK(subtype)) { + if (DATA_FRAME_IS_CF_POLL(subtype)) + printf("Ack/Poll"); + else + printf("Ack"); + } else { + if (DATA_FRAME_IS_CF_POLL(subtype)) + printf("Poll"); + } + if (DATA_FRAME_IS_QOS(subtype)) + printf("+QoS"); + printf(" "); + } + +#define ADDR1 (p + 4) +#define ADDR2 (p + 10) +#define ADDR3 (p + 16) +#define ADDR4 (p + 24) + + 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 +#undef ADDR2 +#undef ADDR3 +#undef ADDR4 +} + +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, 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_BAR: + printf(" RA:%s TA:%s CTL(%x) SEQ(%u) ", + etheraddr_string(((const struct ctrl_bar_t *)p)->ra), + etheraddr_string(((const struct ctrl_bar_t *)p)->ta), + EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t *)p)->ctl)), + EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t *)p)->seq))); + break; + case CTRL_BA: + printf("RA:%s ", + etheraddr_string(((const struct ctrl_ba_t *)p)->ra)); + break; + case CTRL_PS_POLL: + printf("BSSID:%s TA:%s ", + etheraddr_string(((const struct ctrl_ps_poll_t *)p)->bssid), + etheraddr_string(((const struct ctrl_ps_poll_t *)p)->ta)); + break; + case CTRL_RTS: + printf("RA:%s TA:%s ", + etheraddr_string(((const struct ctrl_rts_t *)p)->ra), + etheraddr_string(((const struct ctrl_rts_t *)p)->ta)); + break; + case CTRL_CTS: + printf("RA:%s ", + etheraddr_string(((const struct ctrl_cts_t *)p)->ra)); + break; + case CTRL_ACK: + printf("RA:%s ", + etheraddr_string(((const struct ctrl_ack_t *)p)->ra)); + break; + case CTRL_CF_END: + printf("RA:%s BSSID:%s ", + etheraddr_string(((const struct ctrl_end_t *)p)->ra), + etheraddr_string(((const struct ctrl_end_t *)p)->bssid)); + break; + case CTRL_END_ACK: + printf("RA:%s BSSID:%s ", + etheraddr_string(((const struct ctrl_end_ack_t *)p)->ra), + etheraddr_string(((const struct ctrl_end_ack_t *)p)->bssid)); + break; + default: + printf("(H) Unknown Ctrl Subtype"); + break; + } +} + +static int +extract_header_length(u_int16_t fc) +{ + int len; + + switch (FC_TYPE(fc)) { + case T_MGMT: + return MGMT_HDRLEN; + case T_CTRL: + switch (FC_SUBTYPE(fc)) { + case CTRL_BAR: + return CTRL_BAR_HDRLEN; + case CTRL_PS_POLL: + return CTRL_PS_POLL_HDRLEN; + case CTRL_RTS: + return CTRL_RTS_HDRLEN; + case CTRL_CTS: + return CTRL_CTS_HDRLEN; + case CTRL_ACK: + return CTRL_ACK_HDRLEN; + case CTRL_CF_END: + return CTRL_END_HDRLEN; + case CTRL_END_ACK: + return CTRL_END_ACK_HDRLEN; + default: + return 0; + } + case T_DATA: + len = (FC_TO_DS(fc) && FC_FROM_DS(fc)) ? 30 : 24; + if (DATA_FRAME_IS_QOS(FC_SUBTYPE(fc))) + len += 2; + return len; + default: + printf("unknown IEEE802.11 frame type (%d)", FC_TYPE(fc)); + return 0; + } +} + +static int +extract_mesh_header_length(const u_char *p) +{ + return (p[0] &~ 3) ? 0 : 6*(1 + (p[0] & 3)); +} + +/* + * Print the 802.11 MAC header if eflag is set, and set "*srcp" and "*dstp" + * to point to the source and destination MAC addresses in any case if + * "srcp" and "dstp" aren't null. + */ +static void +ieee_802_11_hdr_print(u_int16_t fc, const u_char *p, u_int hdrlen, + u_int meshdrlen, const u_int8_t **srcp, const u_int8_t **dstp) +{ + if (vflag) { + if (FC_MORE_DATA(fc)) + 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)); + } + if (meshdrlen != 0) { + const struct meshcntl_t *mc = + (const struct meshcntl_t *)&p[hdrlen - meshdrlen]; + int ae = mc->flags & 3; + + printf("MeshData (AE %d TTL %u seq %u", ae, mc->ttl, + EXTRACT_LE_32BITS(mc->seq)); + if (ae > 0) + printf(" A4:%s", etheraddr_string(mc->addr4)); + if (ae > 1) + printf(" A5:%s", etheraddr_string(mc->addr5)); + if (ae > 2) + printf(" A6:%s", etheraddr_string(mc->addr6)); + printf(") "); + } + + switch (FC_TYPE(fc)) { + case T_MGMT: + mgmt_header_print(p, srcp, dstp); + break; + case T_CTRL: + ctrl_header_print(fc, p, srcp, dstp); + break; + case T_DATA: + 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; + } +} + +#ifndef roundup2 +#define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */ +#endif + +static u_int +ieee802_11_print(const u_char *p, u_int length, u_int orig_caplen, int pad, + u_int fcslen) +{ + u_int16_t fc; + u_int caplen, hdrlen, meshdrlen; + const u_int8_t *src, *dst; + u_short extracted_ethertype; + + caplen = orig_caplen; + /* Remove FCS, if present */ + if (length < fcslen) { + printf("[|802.11]"); + return caplen; + } + length -= fcslen; + if (caplen > length) { + /* Amount of FCS in actual packet data, if any */ + fcslen = caplen - length; + caplen -= fcslen; + snapend -= fcslen; + } + + if (caplen < IEEE802_11_FC_LEN) { + printf("[|802.11]"); + return orig_caplen; + } + + fc = EXTRACT_LE_16BITS(p); + hdrlen = extract_header_length(fc); + if (pad) + hdrlen = roundup2(hdrlen, 4); + if (Hflag && FC_TYPE(fc) == T_DATA && + DATA_FRAME_IS_QOS(FC_SUBTYPE(fc))) { + meshdrlen = extract_mesh_header_length(p+hdrlen); + hdrlen += meshdrlen; + } else + meshdrlen = 0; + + + if (caplen < hdrlen) { + printf("[|802.11]"); + return hdrlen; + } + + ieee_802_11_hdr_print(fc, p, hdrlen, meshdrlen, &src, &dst); + + /* + * Go past the 802.11 header. + */ + length -= hdrlen; + caplen -= hdrlen; + p += hdrlen; + + switch (FC_TYPE(fc)) { + case T_MGMT: + if (!mgmt_body_print(fc, + (const struct mgmt_header_t *)(p - hdrlen), p, length)) { + printf("[|802.11]"); + return hdrlen; + } + break; + case T_CTRL: + if (!ctrl_body_print(fc, p - hdrlen)) { + printf("[|802.11]"); + return hdrlen; + } + break; + case T_DATA: + if (DATA_FRAME_IS_NULL(FC_SUBTYPE(fc))) + return hdrlen; /* no-data frame */ + /* There may be a problem w/ AP not having this bit set */ + if (FC_WEP(fc)) { + if (!wep_print(p)) { + printf("[|802.11]"); + 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, hdrlen, + meshdrlen, NULL, NULL); + if (extracted_ethertype) + printf("(LLC %s) ", + etherproto_string( + htons(extracted_ethertype))); + if (!suppress_default_print) + default_print(p, caplen); + } + break; + default: + printf("unknown 802.11 frame type (%d)", FC_TYPE(fc)); + break; + } + + 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->len' 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, 0, 0); +} + +#define IEEE80211_CHAN_FHSS \ + (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_GFSK) +#define IEEE80211_CHAN_A \ + (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM) +#define IEEE80211_CHAN_B \ + (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_CCK) +#define IEEE80211_CHAN_PUREG \ + (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_OFDM) +#define IEEE80211_CHAN_G \ + (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN) + +#define IS_CHAN_FHSS(flags) \ + ((flags & IEEE80211_CHAN_FHSS) == IEEE80211_CHAN_FHSS) +#define IS_CHAN_A(flags) \ + ((flags & IEEE80211_CHAN_A) == IEEE80211_CHAN_A) +#define IS_CHAN_B(flags) \ + ((flags & IEEE80211_CHAN_B) == IEEE80211_CHAN_B) +#define IS_CHAN_PUREG(flags) \ + ((flags & IEEE80211_CHAN_PUREG) == IEEE80211_CHAN_PUREG) +#define IS_CHAN_G(flags) \ + ((flags & IEEE80211_CHAN_G) == IEEE80211_CHAN_G) +#define IS_CHAN_ANYG(flags) \ + (IS_CHAN_PUREG(flags) || IS_CHAN_G(flags)) + +static void +print_chaninfo(int freq, int flags) +{ + printf("%u MHz", freq); + if (IS_CHAN_FHSS(flags)) + printf(" FHSS"); + if (IS_CHAN_A(flags)) { + if (flags & IEEE80211_CHAN_HALF) + printf(" 11a/10Mhz"); + else if (flags & IEEE80211_CHAN_QUARTER) + printf(" 11a/5Mhz"); + else + printf(" 11a"); + } + if (IS_CHAN_ANYG(flags)) { + if (flags & IEEE80211_CHAN_HALF) + printf(" 11g/10Mhz"); + else if (flags & IEEE80211_CHAN_QUARTER) + printf(" 11g/5Mhz"); + else + printf(" 11g"); + } else if (IS_CHAN_B(flags)) + printf(" 11b"); + if (flags & IEEE80211_CHAN_TURBO) + printf(" Turbo"); + if (flags & IEEE80211_CHAN_HT20) + printf(" ht/20"); + else if (flags & IEEE80211_CHAN_HT40D) + printf(" ht/40-"); + else if (flags & IEEE80211_CHAN_HT40U) + printf(" ht/40+"); + printf(" "); +} + +static int +print_radiotap_field(struct cpack_state *s, u_int32_t bit, u_int8_t *flags, + struct radiotap_state *state, u_int32_t presentflags) +{ + union { + int8_t i8; + u_int8_t u8; + int16_t i16; + u_int16_t u16; + u_int32_t u32; + u_int64_t u64; + } u, u2, u3, u4; + int rc; + + switch (bit) { + case IEEE80211_RADIOTAP_FLAGS: + rc = cpack_uint8(s, &u.u8); + if (rc != 0) + break; + *flags = u.u8; + break; + case IEEE80211_RADIOTAP_RATE: + rc = cpack_uint8(s, &u.u8); + if (rc != 0) + break; + + /* Save state rate */ + state->rate = u.u8; + break; + case IEEE80211_RADIOTAP_DB_ANTSIGNAL: + case IEEE80211_RADIOTAP_DB_ANTNOISE: + case IEEE80211_RADIOTAP_ANTENNA: + rc = cpack_uint8(s, &u.u8); + break; + case IEEE80211_RADIOTAP_DBM_ANTSIGNAL: + case IEEE80211_RADIOTAP_DBM_ANTNOISE: + rc = cpack_int8(s, &u.i8); + break; + case IEEE80211_RADIOTAP_CHANNEL: + rc = cpack_uint16(s, &u.u16); + if (rc != 0) + break; + rc = cpack_uint16(s, &u2.u16); + break; + case IEEE80211_RADIOTAP_FHSS: + case IEEE80211_RADIOTAP_LOCK_QUALITY: + case IEEE80211_RADIOTAP_TX_ATTENUATION: + case IEEE80211_RADIOTAP_RX_FLAGS: + rc = cpack_uint16(s, &u.u16); + break; + case IEEE80211_RADIOTAP_DB_TX_ATTENUATION: + rc = cpack_uint8(s, &u.u8); + break; + case IEEE80211_RADIOTAP_DBM_TX_POWER: + rc = cpack_int8(s, &u.i8); + break; + case IEEE80211_RADIOTAP_TSFT: + rc = cpack_uint64(s, &u.u64); + break; + case IEEE80211_RADIOTAP_XCHANNEL: + rc = cpack_uint32(s, &u.u32); + if (rc != 0) + break; + rc = cpack_uint16(s, &u2.u16); + if (rc != 0) + break; + rc = cpack_uint8(s, &u3.u8); + if (rc != 0) + break; + rc = cpack_uint8(s, &u4.u8); + break; + case IEEE80211_RADIOTAP_MCS: + rc = cpack_uint8(s, &u.u8); + if (rc != 0) + break; + rc = cpack_uint8(s, &u2.u8); + if (rc != 0) + break; + rc = cpack_uint8(s, &u3.u8); + break; + case IEEE80211_RADIOTAP_VENDOR_NAMESPACE: { + u_int8_t vns[3]; + u_int16_t length; + u_int8_t subspace; + + if ((cpack_align_and_reserve(s, 2)) == NULL) { + rc = -1; + break; + } + + rc = cpack_uint8(s, &vns[0]); + if (rc != 0) + break; + rc = cpack_uint8(s, &vns[1]); + if (rc != 0) + break; + rc = cpack_uint8(s, &vns[2]); + if (rc != 0) + break; + rc = cpack_uint8(s, &subspace); + if (rc != 0) + break; + rc = cpack_uint16(s, &length); + if (rc != 0) + break; + + /* Skip up to length */ + s->c_next += length; + break; + } + default: + /* this bit indicates a field whose + * size we do not know, so we cannot + * proceed. Just print the bit number. + */ + printf("[bit %u] ", bit); + return -1; + } + + if (rc != 0) { + printf("[|802.11]"); + return rc; + } + + /* Preserve the state present flags */ + state->present = presentflags; + + switch (bit) { + case IEEE80211_RADIOTAP_CHANNEL: + /* + * If CHANNEL and XCHANNEL are both present, skip + * CHANNEL. + */ + if (presentflags & (1 << IEEE80211_RADIOTAP_XCHANNEL)) + break; + print_chaninfo(u.u16, u2.u16); + break; + case IEEE80211_RADIOTAP_FHSS: + printf("fhset %d fhpat %d ", u.u16 & 0xff, (u.u16 >> 8) & 0xff); + break; + case IEEE80211_RADIOTAP_RATE: + /* + * XXX On FreeBSD rate & 0x80 means we have an MCS. On + * Linux and AirPcap it does not. (What about + * Mac OS X, NetBSD, OpenBSD, and DragonFly BSD?) + * + * This is an issue either for proprietary extensions + * to 11a or 11g, which do exist, or for 11n + * implementations that stuff a rate value into + * this field, which also appear to exist. + * + * We currently handle that by assuming that + * if the 0x80 bit is set *and* the remaining + * bits have a value between 0 and 15 it's + * an MCS value, otherwise it's a rate. If + * there are cases where systems that use + * "0x80 + MCS index" for MCS indices > 15, + * or stuff a rate value here between 64 and + * 71.5 Mb/s in here, we'll need a preference + * setting. Such rates do exist, e.g. 11n + * MCS 7 at 20 MHz with a long guard interval. + */ + if (u.u8 >= 0x80 && u.u8 <= 0x8f) { + /* + * XXX - we don't know the channel width + * or guard interval length, so we can't + * convert this to a data rate. + * + * If you want us to show a data rate, + * use the MCS field, not the Rate field; + * the MCS field includes not only the + * MCS index, it also includes bandwidth + * and guard interval information. + * + * XXX - can we get the channel width + * from XChannel and the guard interval + * information from Flags, at least on + * FreeBSD? + */ + printf("MCS %u ", u.u8 & 0x7f); + } else + printf("%2.1f Mb/s ", .5*u.u8); + break; + case IEEE80211_RADIOTAP_DBM_ANTSIGNAL: + printf("%ddB signal ", u.i8); + break; + case IEEE80211_RADIOTAP_DBM_ANTNOISE: + printf("%ddB noise ", u.i8); + break; + case IEEE80211_RADIOTAP_DB_ANTSIGNAL: + printf("%ddB signal ", u.u8); + break; + case IEEE80211_RADIOTAP_DB_ANTNOISE: + printf("%ddB noise ", u.u8); + break; + case IEEE80211_RADIOTAP_LOCK_QUALITY: + printf("%u sq ", u.u16); + break; + case IEEE80211_RADIOTAP_TX_ATTENUATION: + printf("%d tx power ", -(int)u.u16); + break; + case IEEE80211_RADIOTAP_DB_TX_ATTENUATION: + printf("%ddB tx power ", -(int)u.u8); + break; + case IEEE80211_RADIOTAP_DBM_TX_POWER: + printf("%ddBm tx power ", u.i8); + break; + case IEEE80211_RADIOTAP_FLAGS: + if (u.u8 & IEEE80211_RADIOTAP_F_CFP) + printf("cfp "); + if (u.u8 & IEEE80211_RADIOTAP_F_SHORTPRE) + printf("short preamble "); + if (u.u8 & IEEE80211_RADIOTAP_F_WEP) + printf("wep "); + if (u.u8 & IEEE80211_RADIOTAP_F_FRAG) + printf("fragmented "); + if (u.u8 & IEEE80211_RADIOTAP_F_BADFCS) + printf("bad-fcs "); + break; + case IEEE80211_RADIOTAP_ANTENNA: + printf("antenna %d ", u.u8); + break; + case IEEE80211_RADIOTAP_TSFT: + printf("%" PRIu64 "us tsft ", u.u64); + break; + case IEEE80211_RADIOTAP_RX_FLAGS: + /* Do nothing for now */ + break; + case IEEE80211_RADIOTAP_XCHANNEL: + print_chaninfo(u2.u16, u.u32); + break; + case IEEE80211_RADIOTAP_MCS: { + static const char *bandwidth[4] = { + "20 MHz", + "40 MHz", + "20 MHz (L)", + "20 MHz (U)" + }; + float htrate; + + if (u.u8 & IEEE80211_RADIOTAP_MCS_MCS_INDEX_KNOWN) { + /* + * We know the MCS index. + */ + if (u3.u8 <= MAX_MCS_INDEX) { + /* + * And it's in-range. + */ + if (u.u8 & (IEEE80211_RADIOTAP_MCS_BANDWIDTH_KNOWN|IEEE80211_RADIOTAP_MCS_GUARD_INTERVAL_KNOWN)) { + /* + * And we know both the bandwidth and + * the guard interval, so we can look + * up the rate. + */ + htrate = + ieee80211_float_htrates \ + [u3.u8] \ + [((u2.u8 & IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK) == IEEE80211_RADIOTAP_MCS_BANDWIDTH_40 ? 1 : 0)] \ + [((u2.u8 & IEEE80211_RADIOTAP_MCS_SHORT_GI) ? 1 : 0)]; + } else { + /* + * We don't know both the bandwidth + * and the guard interval, so we can + * only report the MCS index. + */ + htrate = 0.0; + } + } else { + /* + * The MCS value is out of range. + */ + htrate = 0.0; + } + if (htrate != 0.0) { + /* + * We have the rate. + * Print it. + */ + printf("%.1f Mb/s MCS %u ", htrate, u3.u8); + } else { + /* + * We at least have the MCS index. + * Print it. + */ + printf("MCS %u ", u3.u8); + } + } + if (u.u8 & IEEE80211_RADIOTAP_MCS_BANDWIDTH_KNOWN) { + printf("%s ", + bandwidth[u2.u8 & IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK]); + } + if (u.u8 & IEEE80211_RADIOTAP_MCS_GUARD_INTERVAL_KNOWN) { + printf("%s GI ", + (u2.u8 & IEEE80211_RADIOTAP_MCS_SHORT_GI) ? + "short" : "lon"); + } + if (u.u8 & IEEE80211_RADIOTAP_MCS_HT_FORMAT_KNOWN) { + printf("%s ", + (u2.u8 & IEEE80211_RADIOTAP_MCS_HT_GREENFIELD) ? + "greenfield" : "mixed"); + } + if (u.u8 & IEEE80211_RADIOTAP_MCS_FEC_TYPE_KNOWN) { + printf("%s FEC ", + (u2.u8 & IEEE80211_RADIOTAP_MCS_FEC_LDPC) ? + "LDPC" : "BCC"); + } + break; + } + } + return 0; +} + +static u_int +ieee802_11_radio_print(const u_char *p, u_int length, u_int caplen) +{ +#define BITNO_32(x) (((x) >> 16) ? 16 + BITNO_16((x) >> 16) : BITNO_16((x))) +#define BITNO_16(x) (((x) >> 8) ? 8 + BITNO_8((x) >> 8) : BITNO_8((x))) +#define BITNO_8(x) (((x) >> 4) ? 4 + BITNO_4((x) >> 4) : BITNO_4((x))) +#define BITNO_4(x) (((x) >> 2) ? 2 + BITNO_2((x) >> 2) : BITNO_2((x))) +#define BITNO_2(x) (((x) & 2) ? 1 : 0) +#define BIT(n) (1U << n) +#define IS_EXTENDED(__p) \ + (EXTRACT_LE_32BITS(__p) & BIT(IEEE80211_RADIOTAP_EXT)) != 0 + + struct cpack_state cpacker; + struct ieee80211_radiotap_header *hdr; + u_int32_t present, next_present; + u_int32_t presentflags = 0; + u_int32_t *presentp, *last_presentp; + enum ieee80211_radiotap_type bit; + int bit0; + const u_char *iter; + u_int len; + u_int8_t flags; + int pad; + u_int fcslen; + struct radiotap_state state; + + if (caplen < sizeof(*hdr)) { + printf("[|802.11]"); + return caplen; + } + + hdr = (struct ieee80211_radiotap_header *)p; + + len = EXTRACT_LE_16BITS(&hdr->it_len); + + if (caplen < len) { + printf("[|802.11]"); + return caplen; + } + for (last_presentp = &hdr->it_present; + IS_EXTENDED(last_presentp) && + (u_char*)(last_presentp + 1) <= p + len; + last_presentp++); + + /* are there more bitmap extensions than bytes in header? */ + if (IS_EXTENDED(last_presentp)) { + printf("[|802.11]"); + return caplen; + } + + iter = (u_char*)(last_presentp + 1); + + if (cpack_init(&cpacker, (u_int8_t*)iter, len - (iter - p)) != 0) { + /* XXX */ + printf("[|802.11]"); + return caplen; + } + + /* Assume no flags */ + flags = 0; + /* Assume no Atheros padding between 802.11 header and body */ + pad = 0; + /* Assume no FCS at end of frame */ + fcslen = 0; + for (bit0 = 0, presentp = &hdr->it_present; presentp <= last_presentp; + presentp++, bit0 += 32) { + presentflags = EXTRACT_LE_32BITS(presentp); + + /* Clear state. */ + memset(&state, 0, sizeof(state)); + + for (present = EXTRACT_LE_32BITS(presentp); present; + present = next_present) { + /* clear the least significant bit that is set */ + next_present = present & (present - 1); + + /* extract the least significant bit that is set */ + bit = (enum ieee80211_radiotap_type) + (bit0 + BITNO_32(present ^ next_present)); + + if (print_radiotap_field(&cpacker, bit, &flags, &state, presentflags) != 0) + goto out; + } + } + +out: + if (flags & IEEE80211_RADIOTAP_F_DATAPAD) + pad = 1; /* Atheros padding */ + if (flags & IEEE80211_RADIOTAP_F_FCS) + fcslen = 4; /* FCS at end of packet */ + return len + ieee802_11_print(p + len, length - len, caplen - len, pad, + fcslen); +#undef BITNO_32 +#undef BITNO_16 +#undef BITNO_8 +#undef BITNO_4 +#undef BITNO_2 +#undef BIT +} + +static u_int +ieee802_11_avs_radio_print(const u_char *p, u_int length, u_int caplen) +{ + u_int32_t caphdr_len; + + if (caplen < 8) { + printf("[|802.11]"); + return caplen; + } + + 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, 0, 0); +} + +#define PRISM_HDR_LEN 144 + +#define WLANCAP_MAGIC_COOKIE_BASE 0x80211000 +#define WLANCAP_MAGIC_COOKIE_V1 0x80211001 +#define WLANCAP_MAGIC_COOKIE_V2 0x80211002 + +/* + * 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 or + * WLANCAP_MAGIC_COOKIE_V2, it's really DLT_IEEE802_11_RADIO_AVS + * (currently, on Linux, there's no ARPHRD_ type for + * DLT_IEEE802_11_RADIO_AVS, as there is a ARPHRD_IEEE80211_PRISM + * for DLT_PRISM_HEADER, so ARPHRD_IEEE80211_PRISM is used for + * the AVS header, and the first 4 bytes of the header are used to + * indicate whether it's a Prism header or an AVS header). + */ +u_int +prism_if_print(const struct pcap_pkthdr *h, const u_char *p) +{ + u_int caplen = h->caplen; + u_int length = h->len; + u_int32_t msgcode; + + if (caplen < 4) { + printf("[|802.11]"); + return caplen; + } + + msgcode = EXTRACT_32BITS(p); + if (msgcode == WLANCAP_MAGIC_COOKIE_V1 || + msgcode == WLANCAP_MAGIC_COOKIE_V2) + return ieee802_11_avs_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, 0, 0); +} + +/* + * For DLT_IEEE802_11_RADIO; like DLT_IEEE802_11, but with an extra + * header, containing information such as radio information. + */ +u_int +ieee802_11_radio_if_print(const struct pcap_pkthdr *h, const u_char *p) +{ + return ieee802_11_radio_print(p, h->len, h->caplen); +} + +/* + * For DLT_IEEE802_11_RADIO_AVS; like DLT_IEEE802_11, but with an + * extra header, containing information such as radio information, + * which we currently ignore. + */ +u_int +ieee802_11_radio_avs_if_print(const struct pcap_pkthdr *h, const u_char *p) +{ + return ieee802_11_avs_radio_print(p, h->len, h->caplen); +}
diff --git a/tcpdump-4.3.0/print-802_15_4.c b/tcpdump-4.3.0/print-802_15_4.c new file mode 100644 index 0000000..2016552 --- /dev/null +++ b/tcpdump-4.3.0/print-802_15_4.c
@@ -0,0 +1,183 @@ +/* + * Copyright (c) 2009 + * Siemens AG, All rights reserved. + * Dmitry Eremin-Solenikov (dbaryshkov@gmail.com) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> +#include <pcap.h> +#include <string.h> + +#include "interface.h" +#include "addrtoname.h" + +#include "extract.h" + +static const char *ftypes[] = { + "Beacon", /* 0 */ + "Data", /* 1 */ + "ACK", /* 2 */ + "Command", /* 3 */ + "Reserved", /* 4 */ + "Reserved", /* 5 */ + "Reserved", /* 6 */ + "Reserved", /* 7 */ +}; + +static int +extract_header_length(u_int16_t fc) +{ + int len = 0; + + switch ((fc >> 10) & 0x3) { + case 0x00: + if (fc & (1 << 6)) /* intra-PAN with none dest addr */ + return -1; + break; + case 0x01: + return -1; + case 0x02: + len += 4; + break; + case 0x03: + len += 10; + break; + } + + switch ((fc >> 14) & 0x3) { + case 0x00: + break; + case 0x01: + return -1; + case 0x02: + len += 4; + break; + case 0x03: + len += 10; + break; + } + + if (fc & (1 << 6)) { + if (len < 2) + return -1; + len -= 2; + } + + return len; +} + + +u_int +ieee802_15_4_if_print(struct netdissect_options *ndo, + const struct pcap_pkthdr *h, const u_char *p) +{ + u_int caplen = h->caplen; + int hdrlen; + u_int16_t fc; + u_int8_t seq; + + if (caplen < 3) { + ND_PRINT((ndo, "[|802.15.4] %x", caplen)); + return caplen; + } + + fc = EXTRACT_LE_16BITS(p); + hdrlen = extract_header_length(fc); + + seq = EXTRACT_LE_8BITS(p + 2); + + p += 3; + caplen -= 3; + + ND_PRINT((ndo,"IEEE 802.15.4 %s packet ", ftypes[fc & 0x7])); + if (vflag) + ND_PRINT((ndo,"seq %02x ", seq)); + if (hdrlen == -1) { + ND_PRINT((ndo,"malformed! ")); + return caplen; + } + + + if (!vflag) { + p+= hdrlen; + caplen -= hdrlen; + } else { + u_int16_t panid = 0; + + switch ((fc >> 10) & 0x3) { + case 0x00: + ND_PRINT((ndo,"none ")); + break; + case 0x01: + ND_PRINT((ndo,"reserved destination addressing mode")); + return 0; + case 0x02: + panid = EXTRACT_LE_16BITS(p); + p += 2; + ND_PRINT((ndo,"%04x:%04x ", panid, EXTRACT_LE_16BITS(p))); + p += 2; + break; + case 0x03: + panid = EXTRACT_LE_16BITS(p); + p += 2; + ND_PRINT((ndo,"%04x:%s ", panid, le64addr_string(p))); + p += 8; + break; + } + ND_PRINT((ndo,"< "); + + switch ((fc >> 14) & 0x3) { + case 0x00: + ND_PRINT((ndo,"none ")); + break; + case 0x01: + ND_PRINT((ndo,"reserved source addressing mode")); + return 0; + case 0x02: + if (!(fc & (1 << 6))) { + panid = EXTRACT_LE_16BITS(p); + p += 2; + } + ND_PRINT((ndo,"%04x:%04x ", panid, EXTRACT_LE_16BITS(p))); + p += 2; + break; + case 0x03: + if (!(fc & (1 << 6))) { + panid = EXTRACT_LE_16BITS(p); + p += 2; + } + ND_PRINT((ndo,"%04x:%s ", panid, le64addr_string(p)))); + p += 8; + break; + } + + caplen -= hdrlen; + } + + if (!suppress_default_print) + (ndo->ndo_default_print)(ndo, p, caplen); + + return 0; +}
diff --git a/tcpdump-4.3.0/print-ah.c b/tcpdump-4.3.0/print-ah.c new file mode 100644 index 0000000..ecd106b --- /dev/null +++ b/tcpdump-4.3.0/print-ah.c
@@ -0,0 +1,71 @@ +/* $NetBSD: print-ah.c,v 1.4 1996/05/20 00:41:16 fvdl Exp $ */ + +/* + * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 + * 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-ah.c,v 1.22 2003-11-19 00:36:06 guy Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> + +#include "ah.h" + +#include "interface.h" +#include "addrtoname.h" +#include "extract.h" + +int +ah_print(register const u_char *bp) +{ + register const struct ah *ah; + register const u_char *ep; + int sumlen; + u_int32_t spi; + + ah = (const struct ah *)bp; + ep = snapend; /* 'ep' points to the end of available data. */ + + TCHECK(*ah); + + sumlen = ah->ah_len << 2; + spi = EXTRACT_32BITS(&ah->ah_spi); + + printf("AH(spi=0x%08x", spi); + if (vflag) + printf(",sumlen=%d", sumlen); + 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 -1; +}
diff --git a/tcpdump-4.3.0/print-aodv.c b/tcpdump-4.3.0/print-aodv.c new file mode 100644 index 0000000..c5f6622 --- /dev/null +++ b/tcpdump-4.3.0/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.11 2004-03-24 00:30:19 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/tcpdump-4.3.0/print-ap1394.c b/tcpdump-4.3.0/print-ap1394.c new file mode 100644 index 0000000..ab0713b --- /dev/null +++ b/tcpdump-4.3.0/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.5 2006-02-11 22:12:06 hannes 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 "extract.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; + u_int16_t firewire_type; + + fp = (const struct firewire_header *)bp; + + (void)printf("%s > %s", + linkaddr_string(fp->firewire_dhost, LINKADDR_IEEE1394, FIREWIRE_EUI64_LEN), + linkaddr_string(fp->firewire_shost, LINKADDR_IEEE1394, FIREWIRE_EUI64_LEN)); + + firewire_type = EXTRACT_16BITS(&fp->firewire_type); + if (!qflag) { + (void)printf(", ethertype %s (0x%04x)", + tok2str(ethertype_values,"Unknown", firewire_type), + firewire_type); + } else { + (void)printf(", %s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", 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->len' 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; + + 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 = EXTRACT_16BITS(&fp->firewire_type); + if (ethertype_print(gndo, ether_type, p, length, caplen) == 0) { + /* ether_type not known, print raw packet */ + if (!eflag) + ap1394_hdr_print((u_char *)fp, length + FIREWIRE_HDRLEN); + + if (!suppress_default_print) + default_print(p, caplen); + } + + return FIREWIRE_HDRLEN; +}
diff --git a/tcpdump-4.3.0/print-arcnet.c b/tcpdump-4.3.0/print-arcnet.c new file mode 100644 index 0000000..9531f34 --- /dev/null +++ b/tcpdump-4.3.0/print-arcnet.c
@@ -0,0 +1,298 @@ +/* + * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * From: NetBSD: print-arcnet.c,v 1.2 2000/04/24 13:02:28 itojun Exp + */ +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-arcnet.c,v 1.20 2005-04-06 21:32:38 mcr 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 "extract.h" +#include "arcnet.h" + +static int arcnet_encap_print(u_char arctype, const u_char *p, + u_int length, u_int caplen); + +struct tok arctypemap[] = { + { ARCTYPE_IP_OLD, "oldip" }, + { ARCTYPE_ARP_OLD, "oldarp" }, + { ARCTYPE_IP, "ip" }, + { ARCTYPE_ARP, "arp" }, + { ARCTYPE_REVARP, "rarp" }, + { ARCTYPE_ATALK, "atalk" }, + { ARCTYPE_BANIAN, "banyan" }, + { ARCTYPE_IPX, "ipx" }, + { ARCTYPE_INET6, "ipv6" }, + { ARCTYPE_DIAGNOSE, "diag" }, + { 0, 0 } +}; + +static inline void +arcnet_print(const u_char *bp, u_int length, int phds, int flag, u_int seqid) +{ + const struct arc_header *ap; + const char *arctypename; + + + ap = (const struct arc_header *)bp; + + + if (qflag) { + (void)printf("%02x %02x %d: ", + ap->arc_shost, + ap->arc_dhost, + length); + return; + } + + arctypename = tok2str(arctypemap, "%02x", ap->arc_type); + + if (!phds) { + (void)printf("%02x %02x %s %d: ", + ap->arc_shost, ap->arc_dhost, arctypename, + length); + return; + } + + if (flag == 0) { + (void)printf("%02x %02x %s seqid %04x %d: ", + ap->arc_shost, ap->arc_dhost, arctypename, seqid, + length); + return; + } + + if (flag & 1) + (void)printf("%02x %02x %s seqid %04x " + "(first of %d fragments) %d: ", + ap->arc_shost, ap->arc_dhost, arctypename, seqid, + (flag + 3) / 2, length); + else + (void)printf("%02x %02x %s seqid %04x " + "(fragment %d) %d: ", + ap->arc_shost, ap->arc_dhost, arctypename, seqid, + flag/2 + 1, length); +} + +/* + * This is the top level routine of the printer. 'p' points + * to the ARCNET header of the packet, 'h->ts' is the timestamp, + * 'h->len' is the length of the packet off the wire, and 'h->caplen' + * is the number of bytes actually captured. + */ +u_int +arcnet_if_print(const struct pcap_pkthdr *h, const u_char *p) +{ + u_int caplen = h->caplen; + u_int length = h->len; + const struct arc_header *ap; + + int phds, flag = 0, archdrlen = 0; + u_int seqid = 0; + u_char arc_type; + + if (caplen < ARC_HDRLEN) { + printf("[|arcnet]"); + return (caplen); + } + + ap = (const struct arc_header *)p; + arc_type = ap->arc_type; + + switch (arc_type) { + default: + phds = 1; + break; + case ARCTYPE_IP_OLD: + case ARCTYPE_ARP_OLD: + case ARCTYPE_DIAGNOSE: + phds = 0; + archdrlen = ARC_HDRLEN; + break; + } + + if (phds) { + if (caplen < ARC_HDRNEWLEN) { + arcnet_print(p, length, 0, 0, 0); + printf("[|phds]"); + return (caplen); + } + + if (ap->arc_flag == 0xff) { + if (caplen < ARC_HDRNEWLEN_EXC) { + arcnet_print(p, length, 0, 0, 0); + printf("[|phds extended]"); + return (caplen); + } + flag = ap->arc_flag2; + seqid = EXTRACT_16BITS(&ap->arc_seqid2); + archdrlen = ARC_HDRNEWLEN_EXC; + } else { + flag = ap->arc_flag; + seqid = EXTRACT_16BITS(&ap->arc_seqid); + archdrlen = ARC_HDRNEWLEN; + } + } + + + if (eflag) + arcnet_print(p, length, phds, flag, seqid); + + /* + * Go past the ARCNET header. + */ + length -= archdrlen; + caplen -= archdrlen; + p += archdrlen; + + if (phds && flag && (flag & 1) == 0) { + /* + * This is a middle fragment. + */ + return (archdrlen); + } + + if (!arcnet_encap_print(arc_type, p, length, caplen)) + default_print(p, caplen); + + 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->len' 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); + } + + 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); + + return (archdrlen); +} + +/* + * Prints the packet encapsulated in an ARCnet data field, + * given the ARCnet system code. + * + * Returns non-zero if it can do so, zero if the system code is unknown. + */ + + +static int +arcnet_encap_print(u_char arctype, const u_char *p, + u_int length, u_int caplen) +{ + switch (arctype) { + + case ARCTYPE_IP_OLD: + case ARCTYPE_IP: + ip_print(gndo, p, length); + return (1); + +#ifdef INET6 + case ARCTYPE_INET6: + ip6_print(gndo, p, length); + return (1); +#endif /*INET6*/ + + case ARCTYPE_ARP_OLD: + case ARCTYPE_ARP: + case ARCTYPE_REVARP: + arp_print(gndo, p, length, caplen); + return (1); + + case ARCTYPE_ATALK: /* XXX was this ever used? */ + if (vflag) + fputs("et1 ", stdout); + atalk_print(p, length); + return (1); + + case ARCTYPE_IPX: + ipx_print(p, length); + return (1); + + default: + return (0); + } +} + +/* + * Local Variables: + * c-style: bsd + * End: + */ +
diff --git a/tcpdump-4.3.0/print-arp.c b/tcpdump-4.3.0/print-arp.c new file mode 100644 index 0000000..905ef46 --- /dev/null +++ b/tcpdump-4.3.0/print-arp.c
@@ -0,0 +1,417 @@ +/* + * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-arp.c,v 1.66 2006-03-03 22:53:21 hannes Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> +#include <string.h> + +#include "netdissect.h" +#include "addrtoname.h" +#include "ether.h" +#include "ethertype.h" +#include "extract.h" /* must come after interface.h */ + +/* + * Address Resolution Protocol. + * + * See RFC 826 for protocol description. ARP packets are variable + * in size; the arphdr structure defines the fixed-length portion. + * Protocol type values are the same as those for 10 Mb/s Ethernet. + * It is followed by the variable-sized fields ar_sha, arp_spa, + * arp_tha and arp_tpa in that order, according to the lengths + * specified. Field names used correspond to RFC 826. + */ +struct arp_pkthdr { + u_short ar_hrd; /* format of hardware address */ +#define ARPHRD_ETHER 1 /* ethernet hardware format */ +#define ARPHRD_IEEE802 6 /* token-ring hardware format */ +#define ARPHRD_ARCNET 7 /* arcnet hardware format */ +#define ARPHRD_FRELAY 15 /* frame relay hardware format */ +#define ARPHRD_ATM2225 19 /* ATM (RFC 2225) */ +#define ARPHRD_STRIP 23 /* Ricochet Starmode Radio hardware format */ +#define ARPHRD_IEEE1394 24 /* IEEE 1394 (FireWire) hardware format */ + u_short ar_pro; /* format of protocol address */ + u_char ar_hln; /* length of hardware address */ + u_char ar_pln; /* length of protocol address */ + u_short ar_op; /* one of: */ +#define ARPOP_REQUEST 1 /* request to resolve address */ +#define ARPOP_REPLY 2 /* response to previous request */ +#define ARPOP_REVREQUEST 3 /* request protocol address given hardware */ +#define ARPOP_REVREPLY 4 /* response giving protocol address */ +#define ARPOP_INVREQUEST 8 /* request to identify peer */ +#define ARPOP_INVREPLY 9 /* response identifying peer */ +#define ARPOP_NAK 10 /* NAK - only valif for ATM ARP */ + +/* + * The remaining fields are variable in size, + * according to the sizes above. + */ +#ifdef COMMENT_ONLY + u_char ar_sha[]; /* sender hardware address */ + u_char ar_spa[]; /* sender protocol address */ + u_char ar_tha[]; /* target hardware address */ + u_char ar_tpa[]; /* target protocol address */ +#endif +#define ar_sha(ap) (((const u_char *)((ap)+1))+0) +#define ar_spa(ap) (((const u_char *)((ap)+1))+ (ap)->ar_hln) +#define ar_tha(ap) (((const u_char *)((ap)+1))+ (ap)->ar_hln+(ap)->ar_pln) +#define ar_tpa(ap) (((const u_char *)((ap)+1))+2*(ap)->ar_hln+(ap)->ar_pln) +}; + +#define ARP_HDRLEN 8 + +#define HRD(ap) EXTRACT_16BITS(&(ap)->ar_hrd) +#define HRD_LEN(ap) ((ap)->ar_hln) +#define PROTO_LEN(ap) ((ap)->ar_pln) +#define OP(ap) EXTRACT_16BITS(&(ap)->ar_op) +#define PRO(ap) EXTRACT_16BITS(&(ap)->ar_pro) +#define SHA(ap) (ar_sha(ap)) +#define SPA(ap) (ar_spa(ap)) +#define THA(ap) (ar_tha(ap)) +#define TPA(ap) (ar_tpa(ap)) + + +struct tok arpop_values[] = { + { ARPOP_REQUEST, "Request" }, + { ARPOP_REPLY, "Reply" }, + { ARPOP_REVREQUEST, "Reverse Request" }, + { ARPOP_REVREPLY, "Reverse Reply" }, + { ARPOP_INVREQUEST, "Inverse Request" }, + { ARPOP_INVREPLY, "Inverse Reply" }, + { ARPOP_NAK, "NACK Reply" }, + { 0, NULL } +}; + +struct tok arphrd_values[] = { + { ARPHRD_ETHER, "Ethernet" }, + { ARPHRD_IEEE802, "TokenRing" }, + { ARPHRD_ARCNET, "ArcNet" }, + { ARPHRD_FRELAY, "FrameRelay" }, + { ARPHRD_STRIP, "Strip" }, + { ARPHRD_IEEE1394, "IEEE 1394" }, + { ARPHRD_ATM2225, "ATM" }, + { 0, NULL } +}; + +/* + * ATM Address Resolution Protocol. + * + * See RFC 2225 for protocol description. ATMARP packets are similar + * to ARP packets, except that there are no length fields for the + * protocol address - instead, there are type/length fields for + * the ATM number and subaddress - and the hardware addresses consist + * of an ATM number and an ATM subaddress. + */ +struct atmarp_pkthdr { + u_short aar_hrd; /* format of hardware address */ + u_short aar_pro; /* format of protocol address */ + u_char aar_shtl; /* length of source ATM number */ + u_char aar_sstl; /* length of source ATM subaddress */ +#define ATMARP_IS_E164 0x40 /* bit in type/length for E.164 format */ +#define ATMARP_LEN_MASK 0x3F /* length of {sub}address in type/length */ + u_short aar_op; /* same as regular ARP */ + u_char aar_spln; /* length of source protocol address */ + u_char aar_thtl; /* length of target ATM number */ + u_char aar_tstl; /* length of target ATM subaddress */ + u_char aar_tpln; /* length of target protocol address */ +/* + * The remaining fields are variable in size, + * according to the sizes above. + */ +#ifdef COMMENT_ONLY + u_char aar_sha[]; /* source ATM number */ + u_char aar_ssa[]; /* source ATM subaddress */ + u_char aar_spa[]; /* sender protocol address */ + u_char aar_tha[]; /* target ATM number */ + u_char aar_tsa[]; /* target ATM subaddress */ + u_char aar_tpa[]; /* target protocol address */ +#endif + +#define ATMHRD(ap) EXTRACT_16BITS(&(ap)->aar_hrd) +#define ATMSHRD_LEN(ap) ((ap)->aar_shtl & ATMARP_LEN_MASK) +#define ATMSSLN(ap) ((ap)->aar_sstl & ATMARP_LEN_MASK) +#define ATMSPROTO_LEN(ap) ((ap)->aar_spln) +#define ATMOP(ap) EXTRACT_16BITS(&(ap)->aar_op) +#define ATMPRO(ap) EXTRACT_16BITS(&(ap)->aar_pro) +#define ATMTHRD_LEN(ap) ((ap)->aar_thtl & ATMARP_LEN_MASK) +#define ATMTSLN(ap) ((ap)->aar_tstl & ATMARP_LEN_MASK) +#define ATMTPROTO_LEN(ap) ((ap)->aar_tpln) +#define aar_sha(ap) ((const u_char *)((ap)+1)) +#define aar_ssa(ap) (aar_sha(ap) + ATMSHRD_LEN(ap)) +#define aar_spa(ap) (aar_ssa(ap) + ATMSSLN(ap)) +#define aar_tha(ap) (aar_spa(ap) + ATMSPROTO_LEN(ap)) +#define aar_tsa(ap) (aar_tha(ap) + ATMTHRD_LEN(ap)) +#define aar_tpa(ap) (aar_tsa(ap) + ATMTSLN(ap)) +}; + +#define ATMSHA(ap) (aar_sha(ap)) +#define ATMSSA(ap) (aar_ssa(ap)) +#define ATMSPA(ap) (aar_spa(ap)) +#define ATMTHA(ap) (aar_tha(ap)) +#define ATMTSA(ap) (aar_tsa(ap)) +#define ATMTPA(ap) (aar_tpa(ap)) + +static u_char ezero[6]; + +static void +atmarp_addr_print(netdissect_options *ndo, + const u_char *ha, u_int ha_len, const u_char *srca, + u_int srca_len) +{ + if (ha_len == 0) + ND_PRINT((ndo, "<No address>")); + else { + ND_PRINT((ndo, "%s", linkaddr_string(ha, LINKADDR_ATM, ha_len))); + if (srca_len != 0) + ND_PRINT((ndo, ",%s", + linkaddr_string(srca, LINKADDR_ATM, srca_len))); + } +} + +static void +atmarp_print(netdissect_options *ndo, + const u_char *bp, u_int length, u_int caplen) +{ + const struct atmarp_pkthdr *ap; + u_short pro, hrd, op; + + ap = (const struct atmarp_pkthdr *)bp; + ND_TCHECK(*ap); + + hrd = ATMHRD(ap); + pro = ATMPRO(ap); + op = ATMOP(ap); + + if (!ND_TTEST2(*aar_tpa(ap), ATMTPROTO_LEN(ap))) { + ND_PRINT((ndo, "[|ARP]")); + ND_DEFAULTPRINT((const u_char *)ap, length); + return; + } + + if (!ndo->ndo_eflag) { + ND_PRINT((ndo, "ARP, ")); + } + + if ((pro != ETHERTYPE_IP && pro != ETHERTYPE_TRAIL) || + ATMSPROTO_LEN(ap) != 4 || + ATMTPROTO_LEN(ap) != 4 || + ndo->ndo_vflag) { + ND_PRINT((ndo, "%s, %s (len %u/%u)", + tok2str(arphrd_values, "Unknown Hardware (%u)", hrd), + tok2str(ethertype_values, "Unknown Protocol (0x%04x)", pro), + ATMSPROTO_LEN(ap), + ATMTPROTO_LEN(ap))); + + /* don't know know about the address formats */ + if (!ndo->ndo_vflag) { + goto out; + } + } + + /* print operation */ + printf("%s%s ", + ndo->ndo_vflag ? ", " : "", + tok2str(arpop_values, "Unknown (%u)", op)); + + switch (op) { + + case ARPOP_REQUEST: + ND_PRINT((ndo, "who-has %s", ipaddr_string(ATMTPA(ap)))); + if (ATMTHRD_LEN(ap) != 0) { + ND_PRINT((ndo, " (")); + atmarp_addr_print(ndo, ATMTHA(ap), ATMTHRD_LEN(ap), + ATMTSA(ap), ATMTSLN(ap)); + ND_PRINT((ndo, ")")); + } + ND_PRINT((ndo, "tell %s", ipaddr_string(ATMSPA(ap)))); + break; + + case ARPOP_REPLY: + ND_PRINT((ndo, "%s is-at ", ipaddr_string(ATMSPA(ap)))); + atmarp_addr_print(ndo, ATMSHA(ap), ATMSHRD_LEN(ap), ATMSSA(ap), + ATMSSLN(ap)); + break; + + case ARPOP_INVREQUEST: + ND_PRINT((ndo, "who-is ")); + atmarp_addr_print(ndo, ATMTHA(ap), ATMTHRD_LEN(ap), ATMTSA(ap), + ATMTSLN(ap)); + ND_PRINT((ndo, " tell ")); + atmarp_addr_print(ndo, ATMSHA(ap), ATMSHRD_LEN(ap), ATMSSA(ap), + ATMSSLN(ap)); + break; + + case ARPOP_INVREPLY: + atmarp_addr_print(ndo, ATMSHA(ap), ATMSHRD_LEN(ap), ATMSSA(ap), + ATMSSLN(ap)); + ND_PRINT((ndo, "at %s", ipaddr_string(ATMSPA(ap)))); + break; + + case ARPOP_NAK: + ND_PRINT((ndo, "for %s", ipaddr_string(ATMSPA(ap)))); + break; + + default: + ND_DEFAULTPRINT((const u_char *)ap, caplen); + return; + } + + out: + ND_PRINT((ndo, ", length %u", length)); + return; + +trunc: + ND_PRINT((ndo, "[|ARP]")); +} + +void +arp_print(netdissect_options *ndo, + const u_char *bp, u_int length, u_int caplen) +{ + const struct arp_pkthdr *ap; + u_short pro, hrd, op, linkaddr; + + ap = (const struct arp_pkthdr *)bp; + ND_TCHECK(*ap); + + hrd = HRD(ap); + pro = PRO(ap); + op = OP(ap); + + + /* if its ATM then call the ATM ARP printer + for Frame-relay ARP most of the fields + are similar to Ethernet so overload the Ethernet Printer + and set the linkaddr type for linkaddr_string() accordingly */ + + switch(hrd) { + case ARPHRD_ATM2225: + atmarp_print(ndo, bp, length, caplen); + return; + case ARPHRD_FRELAY: + linkaddr = LINKADDR_FRELAY; + break; + default: + linkaddr = LINKADDR_ETHER; + break; + } + + if (!ND_TTEST2(*ar_tpa(ap), PROTO_LEN(ap))) { + ND_PRINT((ndo, "[|ARP]")); + ND_DEFAULTPRINT((const u_char *)ap, length); + return; + } + + if (!ndo->ndo_eflag) { + ND_PRINT((ndo, "ARP, ")); + } + + /* print hardware type/len and proto type/len */ + if ((pro != ETHERTYPE_IP && pro != ETHERTYPE_TRAIL) || + PROTO_LEN(ap) != 4 || + HRD_LEN(ap) == 0 || + ndo->ndo_vflag) { + ND_PRINT((ndo, "%s (len %u), %s (len %u)", + tok2str(arphrd_values, "Unknown Hardware (%u)", hrd), + HRD_LEN(ap), + tok2str(ethertype_values, "Unknown Protocol (0x%04x)", pro), + PROTO_LEN(ap))); + + /* don't know know about the address formats */ + if (!ndo->ndo_vflag) { + goto out; + } + } + + /* print operation */ + printf("%s%s ", + ndo->ndo_vflag ? ", " : "", + tok2str(arpop_values, "Unknown (%u)", op)); + + switch (op) { + + case ARPOP_REQUEST: + ND_PRINT((ndo, "who-has %s", ipaddr_string(TPA(ap)))); + if (memcmp((const char *)ezero, (const char *)THA(ap), HRD_LEN(ap)) != 0) + ND_PRINT((ndo, " (%s)", + linkaddr_string(THA(ap), linkaddr, HRD_LEN(ap)))); + ND_PRINT((ndo, " tell %s", ipaddr_string(SPA(ap)))); + break; + + case ARPOP_REPLY: + ND_PRINT((ndo, "%s is-at %s", + ipaddr_string(SPA(ap)), + linkaddr_string(SHA(ap), linkaddr, HRD_LEN(ap)))); + break; + + case ARPOP_REVREQUEST: + ND_PRINT((ndo, "who-is %s tell %s", + linkaddr_string(THA(ap), linkaddr, HRD_LEN(ap)), + linkaddr_string(SHA(ap), linkaddr, HRD_LEN(ap)))); + break; + + case ARPOP_REVREPLY: + ND_PRINT((ndo, "%s at %s", + linkaddr_string(THA(ap), linkaddr, HRD_LEN(ap)), + ipaddr_string(TPA(ap)))); + break; + + case ARPOP_INVREQUEST: + ND_PRINT((ndo, "who-is %s tell %s", + linkaddr_string(THA(ap), linkaddr, HRD_LEN(ap)), + linkaddr_string(SHA(ap), linkaddr, HRD_LEN(ap)))); + break; + + case ARPOP_INVREPLY: + ND_PRINT((ndo,"%s at %s", + linkaddr_string(THA(ap), linkaddr, HRD_LEN(ap)), + ipaddr_string(TPA(ap)))); + break; + + default: + ND_DEFAULTPRINT((const u_char *)ap, caplen); + return; + } + + out: + ND_PRINT((ndo, ", length %u", length)); + + return; +trunc: + ND_PRINT((ndo, "[|ARP]")); +} + +/* + * Local Variables: + * c-style: bsd + * End: + */ +
diff --git a/tcpdump-4.3.0/print-ascii.c b/tcpdump-4.3.0/print-ascii.c new file mode 100644 index 0000000..fa8793c --- /dev/null +++ b/tcpdump-4.3.0/print-ascii.c
@@ -0,0 +1,183 @@ +/* $NetBSD: print-ascii.c,v 1.1 1999/09/30 14:49:12 sjg Exp $ */ + +/*- + * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Alan Barrett and Simon J. Gerraty. + * + * 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 NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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-ascii.c,v 1.17 2005-07-06 20:53:32 guy Exp $"; +#endif +#include <tcpdump-stdinc.h> +#include <stdio.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(register const u_char *cp, register u_int length) +{ + register int s; + + putchar('\n'); + while (length > 0) { + s = *cp++; + length--; + if (!isgraph(s) && + (s != '\t' && s != ' ' && s != '\n' && s != '\r')) + putchar('.'); + else + putchar(s); + } +} + +void +hex_and_ascii_print_with_offset(register const 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[ASCII_LINELENGTH+1], *asp; + + nshorts = length / sizeof(u_short); + i = 0; + hsp = hexstuff; asp = asciistuff; + 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 : '.'); + i++; + if (i >= HEXDUMP_SHORTS_PER_LINE) { + *hsp = *asp = '\0'; + (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 : '.'); + ++i; + } + if (i > 0) { + *hsp = *asp = '\0'; + (void)printf("%s0x%04x: %-*s %s", + ident, oset, HEXDUMP_HEXSTUFF_PER_LINE, + hexstuff, asciistuff); + } +} + +void +hex_and_ascii_print(register const char *ident, register const u_char *cp, + register u_int length) +{ + hex_and_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 char *ident, register const u_char *cp, register u_int length, + register u_int oset) +{ + register u_int i, s; + register int nshorts; + + nshorts = (u_int) length / sizeof(u_short); + i = 0; + while (--nshorts >= 0) { + if ((i++ % 8) == 0) { + (void)printf("%s0x%04x: ", ident, oset); + oset += HEXDUMP_BYTES_PER_LINE; + } + s = *cp++; + (void)printf(" %02x%02x", s, *cp++); + } + if (length & 1) { + if ((i % 8) == 0) + (void)printf("%s0x%04x: ", ident, oset); + (void)printf(" %02x", *cp); + } +} + +/* + * just for completeness + */ +void +hex_print(register const char *ident, register const u_char *cp, register u_int length) +{ + hex_print_with_offset(ident, cp, length, 0); +} + +#ifdef MAIN +int +main(int argc, char *argv[]) +{ + hex_print("\n\t", "Hello, World!\n", 14); + printf("\n"); + hex_and_ascii_print("\n\t", "Hello, World!\n", 14); + printf("\n"); + ascii_print("Hello, World!\n", 14); + printf("\n"); +#define TMSG "Now is the winter of our discontent...\n" + hex_print_with_offset("\n\t", TMSG, sizeof(TMSG) - 1, 0x100); + printf("\n"); + hex_and_ascii_print_with_offset("\n\t", TMSG, sizeof(TMSG) - 1, 0x100); + printf("\n"); + exit(0); +} +#endif /* MAIN */
diff --git a/tcpdump-4.3.0/print-atalk.c b/tcpdump-4.3.0/print-atalk.c new file mode 100644 index 0000000..0a08ef9 --- /dev/null +++ b/tcpdump-4.3.0/print-atalk.c
@@ -0,0 +1,623 @@ +/* + * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * Format and print AppleTalk packets. + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-atalk.c,v 1.81 2004-05-01 09:41:50 hannes Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <pcap.h> + +#include "interface.h" +#include "addrtoname.h" +#include "ethertype.h" +#include "extract.h" /* must come after interface.h */ +#include "appletalk.h" + +static struct tok type2str[] = { + { ddpRTMP, "rtmp" }, + { ddpRTMPrequest, "rtmpReq" }, + { ddpECHO, "echo" }, + { ddpIP, "IP" }, + { ddpARP, "ARP" }, + { ddpKLAP, "KLAP" }, + { 0, NULL } +}; + +struct aarp { + u_int16_t htype, ptype; + u_int8_t halen, palen; + u_int16_t op; + u_int8_t hsaddr[6]; + u_int8_t psaddr[4]; + u_int8_t hdaddr[6]; + u_int8_t pdaddr[4]; +}; + +static char tstr[] = "[|atalk]"; + +static void atp_print(const struct atATP *, u_int); +static void atp_bitmap_print(u_char); +static void nbp_print(const struct atNBP *, u_int, u_short, u_char, u_char); +static const char *print_cstring(const char *, const u_char *); +static const struct atNBPtuple *nbp_tuple_print(const struct atNBPtuple *, + const u_char *, + u_short, u_char, u_char); +static const struct atNBPtuple *nbp_name_print(const struct atNBPtuple *, + const u_char *); +static const char *ataddr_string(u_short, u_char); +static void ddp_print(const u_char *, u_int, int, u_short, u_char, u_char); +static const char *ddpskt_string(int); + +/* + * Print LLAP packets received on a physical LocalTalk interface. + */ +u_int +ltalk_if_print(const struct pcap_pkthdr *h, const u_char *p) +{ + return (llap_print(p, h->caplen)); +} + +/* + * Print AppleTalk LLAP packets. + */ +u_int +llap_print(register const u_char *bp, u_int length) +{ + register const struct LAP *lp; + register const struct atDDP *dp; + register const struct atShortDDP *sdp; + u_short snet; + u_int hdrlen; + + if (length < sizeof(*lp)) { + (void)printf(" [|llap %u]", length); + return (length); + } + lp = (const struct LAP *)bp; + bp += sizeof(*lp); + length -= sizeof(*lp); + hdrlen = sizeof(*lp); + switch (lp->type) { + + case lapShortDDP: + if (length < ddpSSize) { + (void)printf(" [|sddp %u]", length); + return (length); + } + sdp = (const struct atShortDDP *)bp; + printf("%s.%s", + ataddr_string(0, lp->src), ddpskt_string(sdp->srcSkt)); + printf(" > %s.%s:", + ataddr_string(0, lp->dst), ddpskt_string(sdp->dstSkt)); + bp += ddpSSize; + length -= ddpSSize; + hdrlen += ddpSSize; + ddp_print(bp, length, sdp->type, 0, lp->src, sdp->srcSkt); + break; + + case lapDDP: + if (length < ddpSize) { + (void)printf(" [|ddp %u]", length); + return (length); + } + dp = (const struct atDDP *)bp; + snet = EXTRACT_16BITS(&dp->srcNet); + printf("%s.%s", ataddr_string(snet, dp->srcNode), + ddpskt_string(dp->srcSkt)); + printf(" > %s.%s:", + ataddr_string(EXTRACT_16BITS(&dp->dstNet), dp->dstNode), + ddpskt_string(dp->dstSkt)); + bp += ddpSize; + length -= ddpSize; + hdrlen += ddpSize; + ddp_print(bp, length, dp->type, snet, dp->srcNode, dp->srcSkt); + break; + +#ifdef notdef + case lapKLAP: + klap_print(bp, length); + break; +#endif + + default: + printf("%d > %d at-lap#%d %u", + lp->src, lp->dst, lp->type, length); + break; + } + return (hdrlen); +} + +/* + * Print EtherTalk/TokenTalk packets (or FDDITalk, or whatever it's called + * when it runs over FDDI; yes, I've seen FDDI captures with AppleTalk + * packets in them). + */ +void +atalk_print(register const u_char *bp, u_int length) +{ + register const struct atDDP *dp; + u_short snet; + + if(!eflag) + printf("AT "); + + if (length < ddpSize) { + (void)printf(" [|ddp %u]", length); + return; + } + dp = (const struct atDDP *)bp; + snet = EXTRACT_16BITS(&dp->srcNet); + printf("%s.%s", ataddr_string(snet, dp->srcNode), + ddpskt_string(dp->srcSkt)); + printf(" > %s.%s: ", + ataddr_string(EXTRACT_16BITS(&dp->dstNet), dp->dstNode), + ddpskt_string(dp->dstSkt)); + bp += ddpSize; + length -= ddpSize; + ddp_print(bp, length, dp->type, snet, dp->srcNode, dp->srcSkt); +} + +/* XXX should probably pass in the snap header and do checks like arp_print() */ +void +aarp_print(register const u_char *bp, u_int length) +{ + register const struct aarp *ap; + +#define AT(member) ataddr_string((ap->member[1]<<8)|ap->member[2],ap->member[3]) + + printf("aarp "); + ap = (const struct aarp *)bp; + if (EXTRACT_16BITS(&ap->htype) == 1 && + EXTRACT_16BITS(&ap->ptype) == ETHERTYPE_ATALK && + ap->halen == 6 && ap->palen == 4 ) + switch (EXTRACT_16BITS(&ap->op)) { + + case 1: /* request */ + (void)printf("who-has %s tell %s", + AT(pdaddr), AT(psaddr)); + return; + + case 2: /* response */ + (void)printf("reply %s is-at %s", + AT(psaddr), etheraddr_string(ap->hsaddr)); + return; + + case 3: /* probe (oy!) */ + (void)printf("probe %s tell %s", + AT(pdaddr), AT(psaddr)); + return; + } + (void)printf("len %u op %u htype %u ptype %#x halen %u palen %u", + length, EXTRACT_16BITS(&ap->op), EXTRACT_16BITS(&ap->htype), + EXTRACT_16BITS(&ap->ptype), ap->halen, ap->palen); +} + +/* + * Print AppleTalk Datagram Delivery Protocol packets. + */ +static void +ddp_print(register const u_char *bp, register u_int length, register int t, + register u_short snet, register u_char snode, u_char skt) +{ + + switch (t) { + + case ddpNBP: + nbp_print((const struct atNBP *)bp, length, snet, snode, skt); + break; + + case ddpATP: + atp_print((const struct atATP *)bp, length); + break; + + case ddpEIGRP: + eigrp_print(bp, length); + break; + + default: + (void)printf(" at-%s %d", tok2str(type2str, NULL, t), length); + break; + } +} + +static void +atp_print(register const struct atATP *ap, u_int length) +{ + char c; + u_int32_t data; + + if ((const u_char *)(ap + 1) > snapend) { + /* Just bail if we don't have the whole chunk. */ + fputs(tstr, stdout); + return; + } + if (length < sizeof(*ap)) { + (void)printf(" [|atp %u]", length); + return; + } + length -= sizeof(*ap); + switch (ap->control & 0xc0) { + + case atpReqCode: + (void)printf(" atp-req%s %d", + ap->control & atpXO? " " : "*", + EXTRACT_16BITS(&ap->transID)); + + atp_bitmap_print(ap->bitmap); + + if (length != 0) + (void)printf(" [len=%u]", length); + + switch (ap->control & (atpEOM|atpSTS)) { + case atpEOM: + (void)printf(" [EOM]"); + break; + case atpSTS: + (void)printf(" [STS]"); + break; + case atpEOM|atpSTS: + (void)printf(" [EOM,STS]"); + break; + } + break; + + case atpRspCode: + (void)printf(" atp-resp%s%d:%d (%u)", + ap->control & atpEOM? "*" : " ", + EXTRACT_16BITS(&ap->transID), ap->bitmap, length); + switch (ap->control & (atpXO|atpSTS)) { + case atpXO: + (void)printf(" [XO]"); + break; + case atpSTS: + (void)printf(" [STS]"); + break; + case atpXO|atpSTS: + (void)printf(" [XO,STS]"); + break; + } + break; + + case atpRelCode: + (void)printf(" atp-rel %d", EXTRACT_16BITS(&ap->transID)); + + atp_bitmap_print(ap->bitmap); + + /* length should be zero */ + if (length) + (void)printf(" [len=%u]", length); + + /* there shouldn't be any control flags */ + if (ap->control & (atpXO|atpEOM|atpSTS)) { + c = '['; + if (ap->control & atpXO) { + (void)printf("%cXO", c); + c = ','; + } + if (ap->control & atpEOM) { + (void)printf("%cEOM", c); + c = ','; + } + if (ap->control & atpSTS) { + (void)printf("%cSTS", c); + c = ','; + } + (void)printf("]"); + } + break; + + default: + (void)printf(" atp-0x%x %d (%u)", ap->control, + EXTRACT_16BITS(&ap->transID), length); + break; + } + data = EXTRACT_32BITS(&ap->userData); + if (data != 0) + (void)printf(" 0x%x", data); +} + +static void +atp_bitmap_print(register u_char bm) +{ + register char c; + register int i; + + /* + * The '& 0xff' below is needed for compilers that want to sign + * extend a u_char, which is the case with the Ultrix compiler. + * (gcc is smart enough to eliminate it, at least on the Sparc). + */ + if ((bm + 1) & (bm & 0xff)) { + c = '<'; + for (i = 0; bm; ++i) { + if (bm & 1) { + (void)printf("%c%d", c, i); + c = ','; + } + bm >>= 1; + } + (void)printf(">"); + } else { + for (i = 0; bm; ++i) + bm >>= 1; + if (i > 1) + (void)printf("<0-%d>", i - 1); + else + (void)printf("<0>"); + } +} + +static void +nbp_print(register const struct atNBP *np, u_int length, register u_short snet, + register u_char snode, register u_char skt) +{ + register const struct atNBPtuple *tp = + (const struct atNBPtuple *)((u_char *)np + nbpHeaderSize); + int i; + const u_char *ep; + + if (length < nbpHeaderSize) { + (void)printf(" truncated-nbp %u", length); + return; + } + + length -= nbpHeaderSize; + if (length < 8) { + /* must be room for at least one tuple */ + (void)printf(" truncated-nbp %u", length + nbpHeaderSize); + return; + } + /* ep points to end of available data */ + ep = snapend; + if ((const u_char *)tp > ep) { + fputs(tstr, stdout); + return; + } + switch (i = np->control & 0xf0) { + + case nbpBrRq: + case nbpLkUp: + (void)printf(i == nbpLkUp? " nbp-lkup %d:":" nbp-brRq %d:", + np->id); + if ((const u_char *)(tp + 1) > ep) { + fputs(tstr, stdout); + return; + } + (void)nbp_name_print(tp, ep); + /* + * look for anomalies: the spec says there can only + * be one tuple, the address must match the source + * address and the enumerator should be zero. + */ + if ((np->control & 0xf) != 1) + (void)printf(" [ntup=%d]", np->control & 0xf); + if (tp->enumerator) + (void)printf(" [enum=%d]", tp->enumerator); + if (EXTRACT_16BITS(&tp->net) != snet || + tp->node != snode || tp->skt != skt) + (void)printf(" [addr=%s.%d]", + ataddr_string(EXTRACT_16BITS(&tp->net), + tp->node), tp->skt); + break; + + case nbpLkUpReply: + (void)printf(" nbp-reply %d:", np->id); + + /* print each of the tuples in the reply */ + for (i = np->control & 0xf; --i >= 0 && tp; ) + tp = nbp_tuple_print(tp, ep, snet, snode, skt); + break; + + default: + (void)printf(" nbp-0x%x %d (%u)", np->control, np->id, + length); + break; + } +} + +/* print a counted string */ +static const char * +print_cstring(register const char *cp, register const u_char *ep) +{ + register u_int length; + + if (cp >= (const char *)ep) { + fputs(tstr, stdout); + return (0); + } + length = *cp++; + + /* Spec says string can be at most 32 bytes long */ + if (length > 32) { + (void)printf("[len=%u]", length); + return (0); + } + while ((int)--length >= 0) { + if (cp >= (const char *)ep) { + fputs(tstr, stdout); + return (0); + } + putchar(*cp++); + } + return (cp); +} + +static const struct atNBPtuple * +nbp_tuple_print(register const struct atNBPtuple *tp, + register const u_char *ep, + register u_short snet, register u_char snode, + register u_char skt) +{ + register const struct atNBPtuple *tpn; + + if ((const u_char *)(tp + 1) > ep) { + fputs(tstr, stdout); + return 0; + } + tpn = nbp_name_print(tp, ep); + + /* if the enumerator isn't 1, print it */ + if (tp->enumerator != 1) + (void)printf("(%d)", tp->enumerator); + + /* if the socket doesn't match the src socket, print it */ + if (tp->skt != skt) + (void)printf(" %d", tp->skt); + + /* if the address doesn't match the src address, it's an anomaly */ + if (EXTRACT_16BITS(&tp->net) != snet || tp->node != snode) + (void)printf(" [addr=%s]", + ataddr_string(EXTRACT_16BITS(&tp->net), tp->node)); + + return (tpn); +} + +static const struct atNBPtuple * +nbp_name_print(const struct atNBPtuple *tp, register const u_char *ep) +{ + register const char *cp = (const char *)tp + nbpTupleSize; + + putchar(' '); + + /* Object */ + putchar('"'); + if ((cp = print_cstring(cp, ep)) != NULL) { + /* Type */ + putchar(':'); + if ((cp = print_cstring(cp, ep)) != NULL) { + /* Zone */ + putchar('@'); + if ((cp = print_cstring(cp, ep)) != NULL) + putchar('"'); + } + } + return ((const struct atNBPtuple *)cp); +} + + +#define HASHNAMESIZE 4096 + +struct hnamemem { + int addr; + char *name; + struct hnamemem *nxt; +}; + +static struct hnamemem hnametable[HASHNAMESIZE]; + +static const char * +ataddr_string(u_short atnet, u_char athost) +{ + register struct hnamemem *tp, *tp2; + register int i = (atnet << 8) | athost; + char nambuf[MAXHOSTNAMELEN + 20]; + static int first = 1; + FILE *fp; + + /* + * if this is the first call, see if there's an AppleTalk + * number to name map file. + */ + if (first && (first = 0, !nflag) + && (fp = fopen("/etc/atalk.names", "r"))) { + char line[256]; + int i1, i2; + + while (fgets(line, sizeof(line), fp)) { + if (line[0] == '\n' || line[0] == 0 || line[0] == '#') + continue; + if (sscanf(line, "%d.%d %256s", &i1, &i2, nambuf) == 3) + /* got a hostname. */ + i2 |= (i1 << 8); + else if (sscanf(line, "%d %256s", &i1, nambuf) == 2) + /* got a net name */ + i2 = (i1 << 8) | 255; + else + continue; + + for (tp = &hnametable[i2 & (HASHNAMESIZE-1)]; + tp->nxt; tp = tp->nxt) + ; + tp->addr = i2; + tp->nxt = newhnamemem(); + tp->name = strdup(nambuf); + } + fclose(fp); + } + + for (tp = &hnametable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt) + if (tp->addr == i) + return (tp->name); + + /* didn't have the node name -- see if we've got the net name */ + i |= 255; + for (tp2 = &hnametable[i & (HASHNAMESIZE-1)]; tp2->nxt; tp2 = tp2->nxt) + if (tp2->addr == i) { + tp->addr = (atnet << 8) | athost; + tp->nxt = newhnamemem(); + (void)snprintf(nambuf, sizeof(nambuf), "%s.%d", + tp2->name, athost); + tp->name = strdup(nambuf); + return (tp->name); + } + + tp->addr = (atnet << 8) | athost; + tp->nxt = newhnamemem(); + if (athost != 255) + (void)snprintf(nambuf, sizeof(nambuf), "%d.%d", atnet, athost); + else + (void)snprintf(nambuf, sizeof(nambuf), "%d", atnet); + tp->name = strdup(nambuf); + + return (tp->name); +} + +static struct tok skt2str[] = { + { rtmpSkt, "rtmp" }, /* routing table maintenance */ + { nbpSkt, "nis" }, /* name info socket */ + { echoSkt, "echo" }, /* AppleTalk echo protocol */ + { zipSkt, "zip" }, /* zone info protocol */ + { 0, NULL } +}; + +static const char * +ddpskt_string(register int skt) +{ + static char buf[8]; + + if (nflag) { + (void)snprintf(buf, sizeof(buf), "%d", skt); + return (buf); + } + return (tok2str(skt2str, "%d", skt)); +}
diff --git a/tcpdump-4.3.0/print-atm.c b/tcpdump-4.3.0/print-atm.c new file mode 100644 index 0000000..935d182 --- /dev/null +++ b/tcpdump-4.3.0/print-atm.c
@@ -0,0 +1,451 @@ +/* + * Copyright (c) 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-atm.c,v 1.49 2007-10-22 19:37:51 guy Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> +#include <pcap.h> +#include <string.h> + +#include "interface.h" +#include "extract.h" +#include "addrtoname.h" +#include "ethertype.h" +#include "atm.h" +#include "atmuni31.h" +#include "llc.h" + +#include "ether.h" + +#define OAM_CRC10_MASK 0x3ff +#define OAM_PAYLOAD_LEN 48 +#define OAM_FUNCTION_SPECIFIC_LEN 45 /* this excludes crc10 and cell-type/function-type */ +#define OAM_CELLTYPE_FUNCTYPE_LEN 1 + +struct tok oam_f_values[] = { + { VCI_OAMF4SC, "OAM F4 (segment)" }, + { VCI_OAMF4EC, "OAM F4 (end)" }, + { 0, NULL } +}; + +struct tok atm_pty_values[] = { + { 0x0, "user data, uncongested, SDU 0" }, + { 0x1, "user data, uncongested, SDU 1" }, + { 0x2, "user data, congested, SDU 0" }, + { 0x3, "user data, congested, SDU 1" }, + { 0x4, "VCC OAM F5 flow segment" }, + { 0x5, "VCC OAM F5 flow end-to-end" }, + { 0x6, "Traffic Control and resource Mgmt" }, + { 0, NULL } +}; + +#define OAM_CELLTYPE_FM 0x1 +#define OAM_CELLTYPE_PM 0x2 +#define OAM_CELLTYPE_AD 0x8 +#define OAM_CELLTYPE_SM 0xf + +struct tok oam_celltype_values[] = { + { OAM_CELLTYPE_FM, "Fault Management" }, + { OAM_CELLTYPE_PM, "Performance Management" }, + { OAM_CELLTYPE_AD, "activate/deactivate" }, + { OAM_CELLTYPE_SM, "System Management" }, + { 0, NULL } +}; + +#define OAM_FM_FUNCTYPE_AIS 0x0 +#define OAM_FM_FUNCTYPE_RDI 0x1 +#define OAM_FM_FUNCTYPE_CONTCHECK 0x4 +#define OAM_FM_FUNCTYPE_LOOPBACK 0x8 + +struct tok oam_fm_functype_values[] = { + { OAM_FM_FUNCTYPE_AIS, "AIS" }, + { OAM_FM_FUNCTYPE_RDI, "RDI" }, + { OAM_FM_FUNCTYPE_CONTCHECK, "Continuity Check" }, + { OAM_FM_FUNCTYPE_LOOPBACK, "Loopback" }, + { 0, NULL } +}; + +struct tok oam_pm_functype_values[] = { + { 0x0, "Forward Monitoring" }, + { 0x1, "Backward Reporting" }, + { 0x2, "Monitoring and Reporting" }, + { 0, NULL } +}; + +struct tok oam_ad_functype_values[] = { + { 0x0, "Performance Monitoring" }, + { 0x1, "Continuity Check" }, + { 0, NULL } +}; + +#define OAM_FM_LOOPBACK_INDICATOR_MASK 0x1 + +struct tok oam_fm_loopback_indicator_values[] = { + { 0x0, "Reply" }, + { 0x1, "Request" }, + { 0, NULL } +}; + +static const struct tok *oam_functype_values[16] = { + NULL, + oam_fm_functype_values, /* 1 */ + oam_pm_functype_values, /* 2 */ + NULL, + NULL, + NULL, + NULL, + NULL, + oam_ad_functype_values, /* 8 */ + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL +}; + +/* + * Print an RFC 1483 LLC-encapsulated ATM frame. + */ +static void +atm_llc_print(const u_char *p, int length, int caplen) +{ + u_short extracted_ethertype; + + if (!llc_print(p, length, caplen, NULL, NULL, + &extracted_ethertype)) { + /* ether_type not known, print raw packet */ + if (extracted_ethertype) { + printf("(LLC %s) ", + etherproto_string(htons(extracted_ethertype))); + } + if (!suppress_default_print) + default_print(p, caplen); + } +} + +/* + * Given a SAP value, generate the LLC header value for a UI packet + * with that SAP as the source and destination SAP. + */ +#define LLC_UI_HDR(sap) ((sap)<<16 | (sap<<8) | 0x03) + +/* + * This is the top level routine of the printer. 'p' points + * to the LLC/SNAP header of the packet, 'h->ts' is the timestamp, + * 'h->len' is the length of the packet off the wire, and 'h->caplen' + * is the number of bytes actually captured. + */ +u_int +atm_if_print(const struct pcap_pkthdr *h, const u_char *p) +{ + u_int caplen = h->caplen; + u_int length = h->len; + u_int32_t llchdr; + u_int hdrlen = 0; + + if (caplen < 8) { + printf("[|atm]"); + return (caplen); + } + + /* Cisco Style NLPID ? */ + if (*p == LLC_UI) { + if (eflag) + printf("CNLPID "); + isoclns_print(p+1, length-1, caplen-1); + return hdrlen; + } + + /* + * Extract the presumed LLC header into a variable, for quick + * testing. + * Then check for a header that's neither a header for a SNAP + * packet nor an RFC 2684 routed NLPID-formatted PDU nor + * an 802.2-but-no-SNAP IP packet. + */ + llchdr = EXTRACT_24BITS(p); + if (llchdr != LLC_UI_HDR(LLCSAP_SNAP) && + llchdr != LLC_UI_HDR(LLCSAP_ISONS) && + llchdr != LLC_UI_HDR(LLCSAP_IP)) { + /* + * XXX - assume 802.6 MAC header from Fore driver. + * + * Unfortunately, the above list doesn't check for + * all known SAPs, doesn't check for headers where + * the source and destination SAP aren't the same, + * and doesn't check for non-UI frames. It also + * runs the risk of an 802.6 MAC header that happens + * to begin with one of those values being + * incorrectly treated as an 802.2 header. + * + * So is that Fore driver still around? And, if so, + * is it still putting 802.6 MAC headers on ATM + * packets? If so, could it be changed to use a + * new DLT_IEEE802_6 value if we added it? + */ + if (eflag) + printf("%08x%08x %08x%08x ", + EXTRACT_32BITS(p), + EXTRACT_32BITS(p+4), + EXTRACT_32BITS(p+8), + EXTRACT_32BITS(p+12)); + p += 20; + length -= 20; + caplen -= 20; + hdrlen += 20; + } + atm_llc_print(p, length, caplen); + return (hdrlen); +} + +/* + * ATM signalling. + */ +static struct tok msgtype2str[] = { + { CALL_PROCEED, "Call_proceeding" }, + { CONNECT, "Connect" }, + { CONNECT_ACK, "Connect_ack" }, + { SETUP, "Setup" }, + { RELEASE, "Release" }, + { RELEASE_DONE, "Release_complete" }, + { RESTART, "Restart" }, + { RESTART_ACK, "Restart_ack" }, + { STATUS, "Status" }, + { STATUS_ENQ, "Status_enquiry" }, + { ADD_PARTY, "Add_party" }, + { ADD_PARTY_ACK, "Add_party_ack" }, + { ADD_PARTY_REJ, "Add_party_reject" }, + { DROP_PARTY, "Drop_party" }, + { DROP_PARTY_ACK, "Drop_party_ack" }, + { 0, NULL } +}; + +static void +sig_print(const u_char *p, int caplen) +{ + bpf_u_int32 call_ref; + + if (caplen < PROTO_POS) { + printf("[|atm]"); + return; + } + if (p[PROTO_POS] == Q2931) { + /* + * protocol:Q.2931 for User to Network Interface + * (UNI 3.1) signalling + */ + printf("Q.2931"); + if (caplen < MSG_TYPE_POS) { + printf(" [|atm]"); + return; + } + printf(":%s ", + tok2str(msgtype2str, "msgtype#%d", p[MSG_TYPE_POS])); + + /* + * The call reference comes before the message type, + * so if we know we have the message type, which we + * do from the caplen test above, we also know we have + * the call reference. + */ + call_ref = EXTRACT_24BITS(&p[CALL_REF_POS]); + printf("CALL_REF:0x%06x", call_ref); + } else { + /* SCCOP with some unknown protocol atop it */ + printf("SSCOP, proto %d ", p[PROTO_POS]); + } +} + +/* + * Print an ATM PDU (such as an AAL5 PDU). + */ +void +atm_print(u_int vpi, u_int vci, u_int traftype, const u_char *p, u_int length, + u_int caplen) +{ + if (eflag) + printf("VPI:%u VCI:%u ", vpi, vci); + + if (vpi == 0) { + switch (vci) { + + case VCI_PPC: + sig_print(p, caplen); + return; + + case VCI_BCC: + printf("broadcast sig: "); + return; + + case VCI_OAMF4SC: /* fall through */ + case VCI_OAMF4EC: + oam_print(p, length, ATM_OAM_HEC); + return; + + case VCI_METAC: + printf("meta: "); + return; + + case VCI_ILMIC: + printf("ilmi: "); + snmp_print(p, length); + return; + } + } + + switch (traftype) { + + case ATM_LLC: + default: + /* + * Assumes traffic is LLC if unknown. + */ + atm_llc_print(p, length, caplen); + break; + + case ATM_LANE: + lane_print(p, length, caplen); + break; + } +} + +struct oam_fm_loopback_t { + u_int8_t loopback_indicator; + u_int8_t correlation_tag[4]; + u_int8_t loopback_id[12]; + u_int8_t source_id[12]; + u_int8_t unused[16]; +}; + +struct oam_fm_ais_rdi_t { + u_int8_t failure_type; + u_int8_t failure_location[16]; + u_int8_t unused[28]; +}; + +int +oam_print (const u_char *p, u_int length, u_int hec) { + + u_int32_t cell_header; + u_int16_t vpi, vci, cksum, cksum_shouldbe, idx; + u_int8_t cell_type, func_type, payload, clp; + + union { + const struct oam_fm_loopback_t *oam_fm_loopback; + const struct oam_fm_ais_rdi_t *oam_fm_ais_rdi; + } oam_ptr; + + + cell_header = EXTRACT_32BITS(p+hec); + cell_type = ((*(p+ATM_HDR_LEN_NOHEC+hec))>>4) & 0x0f; + func_type = (*(p+ATM_HDR_LEN_NOHEC+hec)) & 0x0f; + + vpi = (cell_header>>20)&0xff; + vci = (cell_header>>4)&0xffff; + payload = (cell_header>>1)&0x7; + clp = cell_header&0x1; + + printf("%s, vpi %u, vci %u, payload [ %s ], clp %u, length %u", + tok2str(oam_f_values, "OAM F5", vci), + vpi, vci, + tok2str(atm_pty_values, "Unknown", payload), + clp, length); + + if (!vflag) { + return 1; + } + + printf("\n\tcell-type %s (%u)", + tok2str(oam_celltype_values, "unknown", cell_type), + cell_type); + + if (oam_functype_values[cell_type] == NULL) + printf(", func-type unknown (%u)", func_type); + else + printf(", func-type %s (%u)", + tok2str(oam_functype_values[cell_type],"none",func_type), + func_type); + + p += ATM_HDR_LEN_NOHEC + hec; + + switch (cell_type << 4 | func_type) { + case (OAM_CELLTYPE_FM << 4 | OAM_FM_FUNCTYPE_LOOPBACK): + oam_ptr.oam_fm_loopback = (const struct oam_fm_loopback_t *)(p + OAM_CELLTYPE_FUNCTYPE_LEN); + printf("\n\tLoopback-Indicator %s, Correlation-Tag 0x%08x", + tok2str(oam_fm_loopback_indicator_values, + "Unknown", + oam_ptr.oam_fm_loopback->loopback_indicator & OAM_FM_LOOPBACK_INDICATOR_MASK), + EXTRACT_32BITS(&oam_ptr.oam_fm_loopback->correlation_tag)); + printf("\n\tLocation-ID "); + for (idx = 0; idx < sizeof(oam_ptr.oam_fm_loopback->loopback_id); idx++) { + if (idx % 2) { + printf("%04x ", EXTRACT_16BITS(&oam_ptr.oam_fm_loopback->loopback_id[idx])); + } + } + printf("\n\tSource-ID "); + for (idx = 0; idx < sizeof(oam_ptr.oam_fm_loopback->source_id); idx++) { + if (idx % 2) { + printf("%04x ", EXTRACT_16BITS(&oam_ptr.oam_fm_loopback->source_id[idx])); + } + } + break; + + case (OAM_CELLTYPE_FM << 4 | OAM_FM_FUNCTYPE_AIS): + case (OAM_CELLTYPE_FM << 4 | OAM_FM_FUNCTYPE_RDI): + oam_ptr.oam_fm_ais_rdi = (const struct oam_fm_ais_rdi_t *)(p + OAM_CELLTYPE_FUNCTYPE_LEN); + printf("\n\tFailure-type 0x%02x", oam_ptr.oam_fm_ais_rdi->failure_type); + printf("\n\tLocation-ID "); + for (idx = 0; idx < sizeof(oam_ptr.oam_fm_ais_rdi->failure_location); idx++) { + if (idx % 2) { + printf("%04x ", EXTRACT_16BITS(&oam_ptr.oam_fm_ais_rdi->failure_location[idx])); + } + } + break; + + case (OAM_CELLTYPE_FM << 4 | OAM_FM_FUNCTYPE_CONTCHECK): + /* FIXME */ + break; + + default: + break; + } + + /* crc10 checksum verification */ + cksum = EXTRACT_16BITS(p + OAM_CELLTYPE_FUNCTYPE_LEN + OAM_FUNCTION_SPECIFIC_LEN) + & OAM_CRC10_MASK; + cksum_shouldbe = verify_crc10_cksum(0, p, OAM_PAYLOAD_LEN); + + printf("\n\tcksum 0x%03x (%scorrect)", + cksum, + cksum_shouldbe == 0 ? "" : "in"); + + return 1; +}
diff --git a/tcpdump-4.3.0/print-babel.c b/tcpdump-4.3.0/print-babel.c new file mode 100644 index 0000000..e787f8b --- /dev/null +++ b/tcpdump-4.3.0/print-babel.c
@@ -0,0 +1,414 @@ +/* + * Copyright (c) 2007-2011 Grégoire Henry, Juliusz Chroboczek + * + * 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 + +#include <tcpdump-stdinc.h> + +#include <stdio.h> +#include <string.h> + +#include "addrtoname.h" +#include "interface.h" +#include "extract.h" + +static void babel_print_v2(const u_char *cp, u_int length); + +void +babel_print(const u_char *cp, u_int length) { + printf("babel"); + + TCHECK2(*cp, 4); + + if(cp[0] != 42) { + printf(" malformed header"); + return; + } else { + printf(" %d", cp[1]); + } + + switch(cp[1]) { + case 2: + babel_print_v2(cp,length); + break; + default: + printf(" unknown version"); + break; + } + + return; + + trunc: + printf(" [|babel]"); + return; +} + +#define MESSAGE_PAD1 0 +#define MESSAGE_PADN 1 +#define MESSAGE_ACK_REQ 2 +#define MESSAGE_ACK 3 +#define MESSAGE_HELLO 4 +#define MESSAGE_IHU 5 +#define MESSAGE_ROUTER_ID 6 +#define MESSAGE_NH 7 +#define MESSAGE_UPDATE 8 +#define MESSAGE_REQUEST 9 +#define MESSAGE_MH_REQUEST 10 + +static const char * +format_id(const u_char *id) +{ + static char buf[25]; + snprintf(buf, 25, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", + id[0], id[1], id[2], id[3], id[4], id[5], id[6], id[7]); + buf[24] = '\0'; + return buf; +} + +static const unsigned char v4prefix[16] = + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 0, 0 }; + +static const char * +format_prefix(const u_char *prefix, unsigned char plen) +{ + static char buf[50]; + if(plen >= 96 && memcmp(prefix, v4prefix, 12) == 0) + snprintf(buf, 50, "%s/%u", ipaddr_string(prefix + 12), plen - 96); + else + snprintf(buf, 50, "%s/%u", ip6addr_string(prefix), plen); + buf[49] = '\0'; + return buf; +} + +static const char * +format_address(const u_char *prefix) +{ + if(memcmp(prefix, v4prefix, 12) == 0) + return ipaddr_string(prefix + 12); + else + return ip6addr_string(prefix); +} + +static int +network_prefix(int ae, int plen, unsigned int omitted, + const unsigned char *p, const unsigned char *dp, + unsigned int len, unsigned char *p_r) +{ + unsigned pb; + unsigned char prefix[16]; + + if(plen >= 0) + pb = (plen + 7) / 8; + else if(ae == 1) + pb = 4; + else + pb = 16; + + if(pb > 16) + return -1; + + memset(prefix, 0, 16); + + switch(ae) { + case 0: break; + case 1: + if(omitted > 4 || pb > 4 || (pb > omitted && len < pb - omitted)) + return -1; + memcpy(prefix, v4prefix, 12); + if(omitted) { + if (dp == NULL) return -1; + memcpy(prefix, dp, 12 + omitted); + } + if(pb > omitted) memcpy(prefix + 12 + omitted, p, pb - omitted); + break; + case 2: + if(omitted > 16 || (pb > omitted && len < pb - omitted)) + return -1; + if(omitted) { + if (dp == NULL) return -1; + memcpy(prefix, dp, omitted); + } + if(pb > omitted) memcpy(prefix + omitted, p, pb - omitted); + break; + case 3: + if(pb > 8 && len < pb - 8) return -1; + prefix[0] = 0xfe; + prefix[1] = 0x80; + if(pb > 8) memcpy(prefix + 8, p, pb - 8); + break; + default: + return -1; + } + + memcpy(p_r, prefix, 16); + return 1; +} + +static int +network_address(int ae, const unsigned char *a, unsigned int len, + unsigned char *a_r) +{ + return network_prefix(ae, -1, 0, a, NULL, len, a_r); +} + +#define ICHECK(i, l) \ + if ((i) + (l) > bodylen || (i) + (l) > length) goto corrupt; + +static void +babel_print_v2(const u_char *cp, u_int length) { + u_int i; + u_short bodylen; + u_char v4_prefix[16] = + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 0, 0 }; + u_char v6_prefix[16] = {0}; + + TCHECK2(*cp, 4); + if (length < 4) + goto corrupt; + bodylen = EXTRACT_16BITS(cp + 2); + printf(" (%u)", bodylen); + + /* Process the TLVs in the body */ + i = 0; + while(i < bodylen) { + const u_char *message; + u_char type, len; + + message = cp + 4 + i; + TCHECK2(*message, 2); + ICHECK(i, 2); + type = message[0]; + len = message[1]; + + TCHECK2(*message, 2 + len); + ICHECK(i, 2 + len); + + switch(type) { + case MESSAGE_PAD1: { + if(!vflag) + printf(" pad1"); + else + printf("\n\tPad 1"); + } + break; + + case MESSAGE_PADN: { + if(!vflag) + printf(" padN"); + else + printf("\n\tPad %d", len + 2); + } + break; + + case MESSAGE_ACK_REQ: { + u_short nonce, interval; + if(!vflag) + printf(" ack-req"); + else { + printf("\n\tAcknowledgment Request "); + if(len < 6) goto corrupt; + nonce = EXTRACT_16BITS(message + 4); + interval = EXTRACT_16BITS(message + 6); + printf("%04x %d", nonce, interval); + } + } + break; + + case MESSAGE_ACK: { + u_short nonce; + if(!vflag) + printf(" ack"); + else { + printf("\n\tAcknowledgment "); + if(len < 2) goto corrupt; + nonce = EXTRACT_16BITS(message + 2); + printf("%04x", nonce); + } + } + break; + + case MESSAGE_HELLO: { + u_short seqno, interval; + if(!vflag) + printf(" hello"); + else { + printf("\n\tHello "); + if(len < 6) goto corrupt; + seqno = EXTRACT_16BITS(message + 4); + interval = EXTRACT_16BITS(message + 6); + printf("seqno %u interval %u", seqno, interval); + } + } + break; + + case MESSAGE_IHU: { + unsigned short txcost, interval; + if(!vflag) + printf(" ihu"); + else { + u_char address[16]; + int rc; + printf("\n\tIHU "); + if(len < 6) goto corrupt; + txcost = EXTRACT_16BITS(message + 4); + interval = EXTRACT_16BITS(message + 6); + rc = network_address(message[2], message + 8, len - 6, address); + if(rc < 0) { printf("[|babel]"); break; } + printf("%s txcost %u interval %d", + format_address(address), txcost, interval); + } + } + break; + + case MESSAGE_ROUTER_ID: { + if(!vflag) + printf(" router-id"); + else { + printf("\n\tRouter Id"); + if(len < 10) goto corrupt; + printf(" %s", format_id(message + 4)); + } + } + break; + + case MESSAGE_NH: { + if(!vflag) + printf(" nh"); + else { + int rc; + u_char nh[16]; + printf("\n\tNext Hop"); + if(len < 2) goto corrupt; + rc = network_address(message[2], message + 4, len - 2, nh); + if(rc < 0) goto corrupt; + printf(" %s", format_address(nh)); + } + } + break; + + case MESSAGE_UPDATE: { + if(!vflag) { + printf(" update"); + if(len < 1) + printf("/truncated"); + else + printf("%s%s%s", + (message[3] & 0x80) ? "/prefix": "", + (message[3] & 0x40) ? "/id" : "", + (message[3] & 0x3f) ? "/unknown" : ""); + } else { + u_short interval, seqno, metric; + u_char plen; + int rc; + u_char prefix[16]; + printf("\n\tUpdate"); + if(len < 10) goto corrupt; + plen = message[4] + (message[2] == 1 ? 96 : 0); + rc = network_prefix(message[2], message[4], message[5], + message + 12, + message[2] == 1 ? v4_prefix : v6_prefix, + len - 10, prefix); + if(rc < 0) goto corrupt; + interval = EXTRACT_16BITS(message + 6); + seqno = EXTRACT_16BITS(message + 8); + metric = EXTRACT_16BITS(message + 10); + printf("%s%s%s %s metric %u seqno %u interval %u", + (message[3] & 0x80) ? "/prefix": "", + (message[3] & 0x40) ? "/id" : "", + (message[3] & 0x3f) ? "/unknown" : "", + format_prefix(prefix, plen), + metric, seqno, interval); + if(message[3] & 0x80) { + if(message[2] == 1) + memcpy(v4_prefix, prefix, 16); + else + memcpy(v6_prefix, prefix, 16); + } + } + } + break; + + case MESSAGE_REQUEST: { + if(!vflag) + printf(" request"); + else { + int rc; + u_char prefix[16], plen; + printf("\n\tRequest "); + if(len < 2) goto corrupt; + plen = message[3] + (message[2] == 1 ? 96 : 0); + rc = network_prefix(message[2], message[3], 0, + message + 4, NULL, len - 2, prefix); + if(rc < 0) goto corrupt; + plen = message[3] + (message[2] == 1 ? 96 : 0); + printf("for %s", + message[2] == 0 ? "any" : format_prefix(prefix, plen)); + } + } + break; + + case MESSAGE_MH_REQUEST : { + if(!vflag) + printf(" mh-request"); + else { + int rc; + u_short seqno; + u_char prefix[16], plen; + printf("\n\tMH-Request "); + if(len < 14) goto corrupt; + seqno = EXTRACT_16BITS(message + 4); + rc = network_prefix(message[2], message[3], 0, + message + 16, NULL, len - 14, prefix); + if(rc < 0) goto corrupt; + plen = message[3] + (message[2] == 1 ? 96 : 0); + printf("(%u hops) for %s seqno %u id %s", + message[6], format_prefix(prefix, plen), + seqno, format_id(message + 8)); + } + } + break; + default: + if(!vflag) + printf(" unknown"); + else + printf("\n\tUnknown message type %d", type); + } + i += len + 2; + } + return; + + trunc: + printf(" [|babel]"); + return; + + corrupt: + printf(" (corrupt)"); + return; +}
diff --git a/tcpdump-4.3.0/print-beep.c b/tcpdump-4.3.0/print-beep.c new file mode 100644 index 0000000..b476dbf --- /dev/null +++ b/tcpdump-4.3.0/print-beep.c
@@ -0,0 +1,71 @@ +/* + * Copyright (C) 2000, Richard Sharpe + * + * This software may be distributed either under the terms of the + * BSD-style licence that accompanies tcpdump or under the GNU GPL + * version 2 or later. + * + * print-beep.c + * + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-beep.c,v 1.6 2003-11-16 09:36:13 guy Exp $"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#ifdef HAVE_MEMORY_H +#include <memory.h> +#endif +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "interface.h" +#include "extract.h" + +/* Check for a string but not go beyond length + * Return TRUE on match, FALSE otherwise + * + * Looks at the first few chars up to tl1 ... + */ + +static int l_strnstart(const char *, u_int, const char *, u_int); + +static int +l_strnstart(const char *tstr1, u_int tl1, const char *str2, u_int l2) +{ + + if (tl1 > l2) + return 0; + + return (strncmp(tstr1, str2, tl1) == 0 ? 1 : 0); +} + +void +beep_print(const u_char *bp, u_int length) +{ + + if (l_strnstart("MSG", 4, (const char *)bp, length)) /* A REQuest */ + printf(" BEEP MSG"); + else if (l_strnstart("RPY ", 4, (const char *)bp, length)) + printf(" BEEP RPY"); + else if (l_strnstart("ERR ", 4, (const char *)bp, length)) + printf(" BEEP ERR"); + else if (l_strnstart("ANS ", 4, (const char *)bp, length)) + printf(" BEEP ANS"); + else if (l_strnstart("NUL ", 4, (const char *)bp, length)) + printf(" BEEP NUL"); + else if (l_strnstart("SEQ ", 4, (const char *)bp, length)) + printf(" BEEP SEQ"); + else if (l_strnstart("END", 4, (const char *)bp, length)) + printf(" BEEP END"); + else + printf(" BEEP (payload or undecoded)"); +}
diff --git a/tcpdump-4.3.0/print-bfd.c b/tcpdump-4.3.0/print-bfd.c new file mode 100644 index 0000000..f157684 --- /dev/null +++ b/tcpdump-4.3.0/print-bfd.c
@@ -0,0 +1,283 @@ +/* + * 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.10 2006-02-02 06:35:52 hannes 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, BFDv0, 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 | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ + +/* + * Control packet, BFDv1, draft-ietf-bfd-base-02.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 |Sta|P|F|C|A|D|R| 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]; +}; + +/* + * An optional Authentication Header may be present + * + * 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 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Auth Type | Auth Len | Authentication Data... | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ + +struct bfd_auth_header_t { + u_int8_t auth_type; + u_int8_t auth_len; + u_int8_t auth_data; +}; + +static const struct tok bfd_v1_authentication_values[] = { + { 0, "Reserved" }, + { 1, "Simple Password" }, + { 2, "Keyed MD5" }, + { 3, "Meticulous Keyed MD5" }, + { 4, "Keyed SHA1" }, + { 5, "Meticulous Keyed SHA1" }, + { 0, NULL } +}; + +#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" }, + { 8, "Reverse Concatenated Path Down" }, + { 0, NULL } +}; + +static const struct tok bfd_v0_flag_values[] = { + { 0x80, "I Hear You" }, + { 0x40, "Demand" }, + { 0x20, "Poll" }, + { 0x10, "Final" }, + { 0x08, "Reserved" }, + { 0x04, "Reserved" }, + { 0x02, "Reserved" }, + { 0x01, "Reserved" }, + { 0, NULL } +}; + +#define BFD_FLAG_AUTH 0x04 + +static const struct tok bfd_v1_flag_values[] = { + { 0x20, "Poll" }, + { 0x10, "Final" }, + { 0x08, "Control Plane Independent" }, + { BFD_FLAG_AUTH, "Authentication Present" }, + { 0x02, "Demand" }, + { 0x01, "Reserved" }, + { 0, NULL } +}; + +static const struct tok bfd_v1_state_values[] = { + { 0, "AdminDown" }, + { 1, "Down" }, + { 2, "Init" }, + { 3, "Up" }, + { 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; + const struct bfd_auth_header_t *bfd_auth_header; + u_int8_t version = 0; + + bfd_header = (const struct bfd_header_t *)pptr; + if (port == BFD_CONTROL_PORT) { + TCHECK(*bfd_header); + version = BFD_EXTRACT_VERSION(bfd_header->version_diag); + } else if (port == BFD_ECHO_PORT) { + /* Echo is BFD v1 only */ + version = 1; + } + switch ((port << 8) | version) { + + /* BFDv0 */ + case (BFD_CONTROL_PORT << 8): + if (vflag < 1 ) + { + printf("BFDv%u, %s, Flags: [%s], length: %u", + version, + tok2str(bfd_port_values, "unknown (%u)", port), + bittok2str(bfd_v0_flag_values, "none", bfd_header->flags), + len); + return; + } + + printf("BFDv%u, length: %u\n\t%s, Flags: [%s], Diagnostic: %s (0x%02x)", + version, + len, + tok2str(bfd_port_values, "unknown (%u)", port), + bittok2str(bfd_v0_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; + + /* BFDv1 */ + case (BFD_CONTROL_PORT << 8 | 1): + if (vflag < 1 ) + { + printf("BFDv%u, %s, State %s, Flags: [%s], length: %u", + version, + tok2str(bfd_port_values, "unknown (%u)", port), + tok2str(bfd_v1_state_values, "unknown (%u)", (bfd_header->flags & 0xc0) >> 6), + bittok2str(bfd_v1_flag_values, "none", bfd_header->flags & 0x3f), + len); + return; + } + + printf("BFDv%u, length: %u\n\t%s, State %s, Flags: [%s], Diagnostic: %s (0x%02x)", + version, + len, + tok2str(bfd_port_values, "unknown (%u)", port), + tok2str(bfd_v1_state_values, "unknown (%u)", (bfd_header->flags & 0xc0) >> 6), + bittok2str(bfd_v1_flag_values, "none", bfd_header->flags & 0x3f), + 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); + + if (bfd_header->flags & BFD_FLAG_AUTH) { + pptr += sizeof (const struct bfd_header_t); + bfd_auth_header = (const struct bfd_auth_header_t *)pptr; + TCHECK2(*bfd_auth_header, sizeof(const struct bfd_auth_header_t)); + printf("\n\t%s (%u) Authentication, length %u present", + tok2str(bfd_v1_authentication_values,"Unknown",bfd_auth_header->auth_type), + bfd_auth_header->auth_type, + bfd_auth_header->auth_len); + } + break; + + /* BFDv0 */ + case (BFD_ECHO_PORT << 8): /* not yet supported - fall through */ + /* BFDv1 */ + case (BFD_ECHO_PORT << 8 | 1): + + 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/tcpdump-4.3.0/print-bgp.c b/tcpdump-4.3.0/print-bgp.c new file mode 100644 index 0000000..c1e382f --- /dev/null +++ b/tcpdump-4.3.0/print-bgp.c
@@ -0,0 +1,2757 @@ +/* + * 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: + * 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. + * + * Extensively modified by Hannes Gredler (hannes@juniper.net) for more + * complete BGP support. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.118 2007-12-07 15:54:52 hannes Exp $"; +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> +#include <string.h> + +#include "interface.h" +#include "decode_prefix.h" +#include "addrtoname.h" +#include "extract.h" +#include "bgp.h" +#include "af.h" +#include "l2vpn.h" + +struct bgp { + u_int8_t bgp_marker[16]; + u_int16_t bgp_len; + u_int8_t bgp_type; +}; +#define BGP_SIZE 19 /* unaligned */ + +#define BGP_OPEN 1 +#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]; + u_int16_t bgpo_len; + u_int8_t bgpo_type; + u_int8_t bgpo_version; + u_int16_t bgpo_myas; + u_int16_t bgpo_holdtime; + u_int32_t bgpo_id; + u_int8_t bgpo_optlen; + /* options should follow */ +}; +#define BGP_OPEN_SIZE 29 /* unaligned */ + +struct bgp_opt { + u_int8_t bgpopt_type; + u_int8_t bgpopt_len; + /* variable length */ +}; +#define BGP_OPT_SIZE 2 /* some compilers may pad to 4 bytes */ +#define BGP_CAP_HEADER_SIZE 2 /* some compilers may pad to 4 bytes */ + +struct bgp_notification { + u_int8_t bgpn_marker[16]; + u_int16_t bgpn_len; + u_int8_t bgpn_type; + u_int8_t bgpn_major; + u_int8_t bgpn_minor; +}; +#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 + +#define bgp_attr_lenlen(flags, p) \ + (((flags) & 0x10) ? 2 : 1) +#define bgp_attr_len(flags, p) \ + (((flags) & 0x10) ? EXTRACT_16BITS(p) : *(p)) + +#define BGPTYPE_ORIGIN 1 +#define BGPTYPE_AS_PATH 2 +#define BGPTYPE_NEXT_HOP 3 +#define BGPTYPE_MULTI_EXIT_DISC 4 +#define BGPTYPE_LOCAL_PREF 5 +#define BGPTYPE_ATOMIC_AGGREGATE 6 +#define BGPTYPE_AGGREGATOR 7 +#define BGPTYPE_COMMUNITIES 8 /* RFC1997 */ +#define BGPTYPE_ORIGINATOR_ID 9 /* RFC1998 */ +#define BGPTYPE_CLUSTER_LIST 10 /* RFC1998 */ +#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 */ +#define BGPTYPE_AS4_PATH 17 /* RFC4893 */ +#define BGPTYPE_AGGREGATOR4 18 /* RFC4893 */ +#define BGPTYPE_PMSI_TUNNEL 22 /* draft-ietf-l3vpn-2547bis-mcast-bgp-02.txt */ +#define BGPTYPE_ATTR_SET 128 /* draft-marques-ppvpn-ibgp */ + +#define BGP_MP_NLRI_MINSIZE 3 /* End of RIB Marker detection */ + +static struct tok bgp_attr_values[] = { + { BGPTYPE_ORIGIN, "Origin"}, + { BGPTYPE_AS_PATH, "AS Path"}, + { BGPTYPE_AS4_PATH, "AS4 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_AGGREGATOR4, "Aggregator4"}, + { 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"}, + { BGPTYPE_PMSI_TUNNEL, "PMSI Tunnel"}, + { BGPTYPE_ATTR_SET, "Attribute Set"}, + { 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 */ + +#define BGP_AS_SEG_TYPE_MIN BGP_AS_SET +#define BGP_AS_SEG_TYPE_MAX BGP_CONFED_AS_SET + +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 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_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_CAPCODE_MP 1 +#define BGP_CAPCODE_RR 2 +#define BGP_CAPCODE_ORF 3 /* XXX */ +#define BGP_CAPCODE_RESTART 64 /* draft-ietf-idr-restart-05 */ +#define BGP_CAPCODE_AS_NEW 65 /* XXX */ +#define BGP_CAPCODE_DYN_CAP 67 /* XXX */ +#define BGP_CAPCODE_RR_CISCO 128 + +static struct tok bgp_capcode_values[] = { + { BGP_CAPCODE_MP, "Multiprotocol Extensions"}, + { BGP_CAPCODE_RR, "Route Refresh"}, + { BGP_CAPCODE_ORF, "Cooperative Route Filtering"}, + { BGP_CAPCODE_RESTART, "Graceful Restart"}, + { BGP_CAPCODE_AS_NEW, "32-Bit AS Number"}, + { BGP_CAPCODE_DYN_CAP, "Dynamic Capability"}, + { BGP_CAPCODE_RR_CISCO, "Route Refresh (Cisco)"}, + { 0, NULL} +}; + +#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} +}; + +/* 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 struct tok bgp_notify_minor_msg_values[] = { + { 1, "Connection Not Synchronized"}, + { 2, "Bad Message Length"}, + { 3, "Bad Message Type"}, + { 0, NULL} +}; + +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"}, + { 7, "Capability Message Error"}, + { 0, NULL} +}; + +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 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 } +}; + +static struct tok bgp_origin_values[] = { + { 0, "IGP"}, + { 1, "EGP"}, + { 2, "Incomplete"}, + { 0, NULL} +}; + +#define BGP_PMSI_TUNNEL_RSVP_P2MP 1 +#define BGP_PMSI_TUNNEL_LDP_P2MP 2 +#define BGP_PMSI_TUNNEL_PIM_SSM 3 +#define BGP_PMSI_TUNNEL_PIM_SM 4 +#define BGP_PMSI_TUNNEL_PIM_BIDIR 5 +#define BGP_PMSI_TUNNEL_INGRESS 6 +#define BGP_PMSI_TUNNEL_LDP_MP2MP 7 + +static struct tok bgp_pmsi_tunnel_values[] = { + { BGP_PMSI_TUNNEL_RSVP_P2MP, "RSVP-TE P2MP LSP"}, + { BGP_PMSI_TUNNEL_LDP_P2MP, "LDP P2MP LSP"}, + { BGP_PMSI_TUNNEL_PIM_SSM, "PIM-SSM Tree"}, + { BGP_PMSI_TUNNEL_PIM_SM, "PIM-SM Tree"}, + { BGP_PMSI_TUNNEL_PIM_BIDIR, "PIM-Bidir Tree"}, + { BGP_PMSI_TUNNEL_INGRESS, "Ingress Replication"}, + { BGP_PMSI_TUNNEL_LDP_MP2MP, "LDP MP2MP LSP"}, + { 0, NULL} +}; + +static struct tok bgp_pmsi_flag_values[] = { + { 0x01, "Leaf Information required"}, + { 0, NULL} +}; + + +/* Subsequent address family identifier, RFC2283 section 7 */ +#define SAFNUM_RES 0 +#define SAFNUM_UNICAST 1 +#define SAFNUM_MULTICAST 2 +#define SAFNUM_UNIMULTICAST 3 +/* labeled BGP RFC3107 */ +#define SAFNUM_LABUNICAST 4 +/* draft-ietf-l3vpn-2547bis-mcast-bgp-02.txt */ +#define SAFNUM_MULTICAST_VPN 5 +#define SAFNUM_TUNNEL 64 /* XXX */ +#define SAFNUM_VPLS 65 /* XXX */ +/* draft-nalawade-idr-mdt-safi-03 */ +#define SAFNUM_MDT 66 +/* Section 4.3.4 of draft-rosen-rfc2547bis-03.txt */ +#define SAFNUM_VPNUNICAST 128 +#define SAFNUM_VPNMULTICAST 129 +#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_TUNNEL, "Tunnel"}, + { SAFNUM_VPLS, "VPLS"}, + { SAFNUM_MDT, "MDT"}, + { SAFNUM_VPNUNICAST, "labeled VPN Unicast"}, + { SAFNUM_VPNMULTICAST, "labeled VPN Multicast"}, + { SAFNUM_VPNUNIMULTICAST, "labeled VPN Unicast+Multicast"}, + { SAFNUM_RT_ROUTING_INFO, "Route Target Routing Information"}, + { SAFNUM_MULTICAST_VPN, "Multicast VPN"}, + { 0, NULL } +}; + +/* well-known community */ +#define BGP_COMMUNITY_NO_EXPORT 0xffffff01 +#define BGP_COMMUNITY_NO_ADVERT 0xffffff02 +#define BGP_COMMUNITY_NO_EXPORT_SUBCONFED 0xffffff03 + +/* 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 */ + +#define BGP_EXT_COM_SOURCE_AS 0x0009 /* RFC-ietf-l3vpn-2547bis-mcast-bgp-08.txt */ +#define BGP_EXT_COM_VRF_RT_IMP 0x010b /* RFC-ietf-l3vpn-2547bis-mcast-bgp-08.txt */ +#define BGP_EXT_COM_L2VPN_RT_0 0x000a /* L2VPN Identifier,Format AS(2bytes):AN(4bytes) */ +#define BGP_EXT_COM_L2VPN_RT_1 0xF10a /* L2VPN Identifier,Format IP address:AN(2bytes) */ + + +/* http://www.cisco.com/en/US/tech/tk436/tk428/technologies_tech_note09186a00801eb09a.shtml */ +#define BGP_EXT_COM_EIGRP_GEN 0x8800 +#define BGP_EXT_COM_EIGRP_METRIC_AS_DELAY 0x8801 +#define BGP_EXT_COM_EIGRP_METRIC_REL_NH_BW 0x8802 +#define BGP_EXT_COM_EIGRP_METRIC_LOAD_MTU 0x8803 +#define BGP_EXT_COM_EIGRP_EXT_REMAS_REMID 0x8804 +#define BGP_EXT_COM_EIGRP_EXT_REMPROTO_REMMETRIC 0x8805 + +static struct tok bgp_extd_comm_flag_values[] = { + { 0x8000, "vendor-specific"}, + { 0x4000, "non-transitive"}, + { 0, NULL}, +}; + +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"}, + { BGP_EXT_COM_EIGRP_GEN , "eigrp-general-route (flag, tag)" }, + { BGP_EXT_COM_EIGRP_METRIC_AS_DELAY , "eigrp-route-metric (AS, delay)" }, + { BGP_EXT_COM_EIGRP_METRIC_REL_NH_BW , "eigrp-route-metric (reliability, nexthop, bandwidth)" }, + { BGP_EXT_COM_EIGRP_METRIC_LOAD_MTU , "eigrp-route-metric (load, MTU)" }, + { BGP_EXT_COM_EIGRP_EXT_REMAS_REMID , "eigrp-external-route (remote-AS, remote-ID)" }, + { BGP_EXT_COM_EIGRP_EXT_REMPROTO_REMMETRIC , "eigrp-external-route (remote-proto, remote-metric)" }, + { BGP_EXT_COM_SOURCE_AS, "source-AS" }, + { BGP_EXT_COM_VRF_RT_IMP, "vrf-route-import"}, + { BGP_EXT_COM_L2VPN_RT_0, "l2vpn-id"}, + { BGP_EXT_COM_L2VPN_RT_1, "l2vpn-id"}, + { 0, NULL}, +}; + +/* 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 }, +}; + +#define TOKBUFSIZE 128 +static char astostr[20]; + +/* + * as_printf + * + * Convert an AS number into a string and return string pointer. + * + * Bepending on bflag is set or not, AS number is converted into ASDOT notation + * or plain number notation. + * + */ +static char * +as_printf (char *str, int size, u_int asnum) +{ + if (!bflag || asnum <= 0xFFFF) { + snprintf(str, size, "%u", asnum); + } else { + snprintf(str, size, "%u.%u", asnum >> 16, asnum & 0xFFFF); + } + return str; +} + +#define ITEMCHECK(minlen) if (itemlen < minlen) goto badtlv; + +int +decode_prefix4(const u_char *pptr, u_int itemlen, char *buf, u_int buflen) +{ + struct in_addr addr; + u_int plen, plenbytes; + + TCHECK(pptr[0]); + ITEMCHECK(1); + plen = pptr[0]; + if (32 < plen) + return -1; + itemlen -= 1; + + memset(&addr, 0, sizeof(addr)); + plenbytes = (plen + 7) / 8; + TCHECK2(pptr[1], plenbytes); + ITEMCHECK(plenbytes); + memcpy(&addr, &pptr[1], plenbytes); + if (plen % 8) { + ((u_char *)&addr)[plenbytes - 1] &= + ((0xff00 >> (plen % 8)) & 0xff); + } + snprintf(buf, buflen, "%s/%d", getname((u_char *)&addr), plen); + return 1 + plenbytes; + +trunc: + return -2; + +badtlv: + return -3; +} + +static int +decode_labeled_prefix4(const u_char *pptr, u_int itemlen, char *buf, u_int buflen) +{ + struct in_addr addr; + u_int plen, plenbytes; + + /* prefix length and label = 4 bytes */ + TCHECK2(pptr[0], 4); + ITEMCHECK(4); + 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 + */ + + if (24 > plen) + return -1; + + plen-=24; /* adjust prefixlen - labellength */ + + if (32 < plen) + return -1; + itemlen -= 4; + + memset(&addr, 0, sizeof(addr)); + plenbytes = (plen + 7) / 8; + TCHECK2(pptr[4], plenbytes); + ITEMCHECK(plenbytes); + memcpy(&addr, &pptr[4], plenbytes); + if (plen % 8) { + ((u_char *)&addr)[plenbytes - 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 + plenbytes; + +trunc: + return -2; + +badtlv: + return -3; +} + +/* + * bgp_vpn_ip_print + * + * print an ipv4 or ipv6 address into a buffer dependend on address length. + */ +static char * +bgp_vpn_ip_print (const u_char *pptr, u_int addr_length) { + + /* worst case string is s fully formatted v6 address */ + static char addr[sizeof("1234:5678:89ab:cdef:1234:5678:89ab:cdef")]; + char *pos = addr; + + switch(addr_length) { + case (sizeof(struct in_addr) << 3): /* 32 */ + TCHECK2(pptr[0], sizeof(struct in_addr)); + snprintf(pos, sizeof(addr), "%s", ipaddr_string(pptr)); + break; +#ifdef INET6 + case (sizeof(struct in6_addr) << 3): /* 128 */ + TCHECK2(pptr[0], sizeof(struct in6_addr)); + snprintf(pos, sizeof(addr), "%s", ip6addr_string(pptr)); + break; +#endif + default: + snprintf(pos, sizeof(addr), "bogus address length %u", addr_length); + break; + } + pos += strlen(pos); + +trunc: + *(pos) = '\0'; + return (addr); +} + +/* + * bgp_vpn_sg_print + * + * print an multicast s,g entry into a buffer. + * the s,g entry is encoded like this. + * + * +-----------------------------------+ + * | Multicast Source Length (1 octet) | + * +-----------------------------------+ + * | Multicast Source (Variable) | + * +-----------------------------------+ + * | Multicast Group Length (1 octet) | + * +-----------------------------------+ + * | Multicast Group (Variable) | + * +-----------------------------------+ + * + * return the number of bytes read from the wire. + */ +static int +bgp_vpn_sg_print (const u_char *pptr, char *buf, u_int buflen) { + + u_int8_t addr_length; + u_int total_length, offset; + + total_length = 0; + + /* Source address length, encoded in bits */ + TCHECK2(pptr[0], 1); + addr_length = *pptr++; + + /* Source address */ + TCHECK2(pptr[0], (addr_length >> 3)); + total_length += (addr_length >> 3) + 1; + offset = strlen(buf); + if (addr_length) { + snprintf(buf + offset, buflen - offset, ", Source %s", + bgp_vpn_ip_print(pptr, addr_length)); + pptr += (addr_length >> 3); + } + + /* Group address length, encoded in bits */ + TCHECK2(pptr[0], 1); + addr_length = *pptr++; + + /* Group address */ + TCHECK2(pptr[0], (addr_length >> 3)); + total_length += (addr_length >> 3) + 1; + offset = strlen(buf); + if (addr_length) { + snprintf(buf + offset, buflen - offset, ", Group %s", + bgp_vpn_ip_print(pptr, addr_length)); + pptr += (addr_length >> 3); + } + +trunc: + return (total_length); +} + + +/* RDs and RTs share the same semantics + * we use bgp_vpn_rd_print for + * printing route targets inside a NLRI */ +char * +bgp_vpn_rd_print (const u_char *pptr) { + + /* allocate space for the largest possible string */ + static char rd[sizeof("xxxxxxxxxx:xxxxx (xxx.xxx.xxx.xxx:xxxxx)")]; + char *pos = rd; + + /* ok lets load the RD format */ + switch (EXTRACT_16BITS(pptr)) { + + /* 2-byte-AS:number fmt*/ + case 0: + snprintf(pos, sizeof(rd) - (pos - rd), "%u:%u (= %u.%u.%u.%u)", + EXTRACT_16BITS(pptr+2), + EXTRACT_32BITS(pptr+4), + *(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), "%s:%u (%u.%u.%u.%u:%u)", + as_printf(astostr, sizeof(astostr), EXTRACT_32BITS(pptr+2)), + EXTRACT_16BITS(pptr+6), *(pptr+2), *(pptr+3), *(pptr+4), + *(pptr+5), EXTRACT_16BITS(pptr+6)); + break; + default: + snprintf(pos, sizeof(rd) - (pos - rd), "unknown RD format"); + break; + } + pos += strlen(pos); + *(pos) = '\0'; + return (rd); +} + +static int +decode_rt_routing_info(const u_char *pptr, char *buf, u_int buflen) +{ + u_int8_t route_target[8]; + u_int plen; + + TCHECK(pptr[0]); + plen = pptr[0]; /* get prefix length */ + + if (0 == plen) + return 1; /* default route target */ + + if (32 > plen) + return -1; + + plen-=32; /* adjust prefix length */ + + if (64 < 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: %s, route target %s", + as_printf(astostr, sizeof(astostr), EXTRACT_32BITS(pptr+1)), + bgp_vpn_rd_print((u_char *)&route_target)); + + return 5 + (plen + 7) / 8; + +trunc: + return -2; +} + +static int +decode_labeled_vpn_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 */ + + if ((24+64) > plen) + return -1; + + plen-=(24+64); /* adjust prefixlen - labellength - RD len*/ + + if (32 < plen) + return -1; + + memset(&addr, 0, sizeof(addr)); + 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); + } + /* 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; +} + +/* + * +-------------------------------+ + * | | + * | RD:IPv4-address (12 octets) | + * | | + * +-------------------------------+ + * | MDT Group-address (4 octets) | + * +-------------------------------+ + */ + +#define MDT_VPN_NLRI_LEN 16 + +static int +decode_mdt_vpn_nlri(const u_char *pptr, char *buf, u_int buflen) +{ + + const u_char *rd; + const u_char *vpn_ip; + + TCHECK(pptr[0]); + + /* if the NLRI is not predefined length, quit.*/ + if (*pptr != MDT_VPN_NLRI_LEN * NBBY) + return -1; + pptr++; + + /* RD */ + TCHECK2(pptr[0], 8); + rd = pptr; + pptr+=8; + + /* IPv4 address */ + TCHECK2(pptr[0], sizeof(struct in_addr)); + vpn_ip = pptr; + pptr+=sizeof(struct in_addr); + + /* MDT Group Address */ + TCHECK2(pptr[0], sizeof(struct in_addr)); + + snprintf(buf, buflen, "RD: %s, VPN IP Address: %s, MC Group Address: %s", + bgp_vpn_rd_print(rd), ipaddr_string(vpn_ip), ipaddr_string(pptr)); + + return MDT_VPN_NLRI_LEN + 1; + + trunc: + +return -2; +} + +#define BGP_MULTICAST_VPN_ROUTE_TYPE_INTRA_AS_I_PMSI 1 +#define BGP_MULTICAST_VPN_ROUTE_TYPE_INTER_AS_I_PMSI 2 +#define BGP_MULTICAST_VPN_ROUTE_TYPE_S_PMSI 3 +#define BGP_MULTICAST_VPN_ROUTE_TYPE_INTRA_AS_SEG_LEAF 4 +#define BGP_MULTICAST_VPN_ROUTE_TYPE_SOURCE_ACTIVE 5 +#define BGP_MULTICAST_VPN_ROUTE_TYPE_SHARED_TREE_JOIN 6 +#define BGP_MULTICAST_VPN_ROUTE_TYPE_SOURCE_TREE_JOIN 7 + +static struct tok bgp_multicast_vpn_route_type_values[] = { + { BGP_MULTICAST_VPN_ROUTE_TYPE_INTRA_AS_I_PMSI, "Intra-AS I-PMSI"}, + { BGP_MULTICAST_VPN_ROUTE_TYPE_INTER_AS_I_PMSI, "Inter-AS I-PMSI"}, + { BGP_MULTICAST_VPN_ROUTE_TYPE_S_PMSI, "S-PMSI"}, + { BGP_MULTICAST_VPN_ROUTE_TYPE_INTRA_AS_SEG_LEAF, "Intra-AS Segment-Leaf"}, + { BGP_MULTICAST_VPN_ROUTE_TYPE_SOURCE_ACTIVE, "Source-Active"}, + { BGP_MULTICAST_VPN_ROUTE_TYPE_SHARED_TREE_JOIN, "Shared Tree Join"}, + { BGP_MULTICAST_VPN_ROUTE_TYPE_SOURCE_TREE_JOIN, "Source Tree Join"}, +}; + +static int +decode_multicast_vpn(const u_char *pptr, char *buf, u_int buflen) +{ + u_int8_t route_type, route_length, addr_length, sg_length; + u_int offset; + + TCHECK2(pptr[0], 2); + route_type = *pptr++; + route_length = *pptr++; + + snprintf(buf, buflen, "Route-Type: %s (%u), length: %u", + tok2str(bgp_multicast_vpn_route_type_values, + "Unknown", route_type), + route_type, route_length); + + switch(route_type) { + case BGP_MULTICAST_VPN_ROUTE_TYPE_INTRA_AS_I_PMSI: + TCHECK2(pptr[0], BGP_VPN_RD_LEN); + offset = strlen(buf); + snprintf(buf + offset, buflen - offset, ", RD: %s, Originator %s", + bgp_vpn_rd_print(pptr), + bgp_vpn_ip_print(pptr + BGP_VPN_RD_LEN, + (route_length - BGP_VPN_RD_LEN) << 3)); + break; + case BGP_MULTICAST_VPN_ROUTE_TYPE_INTER_AS_I_PMSI: + TCHECK2(pptr[0], BGP_VPN_RD_LEN + 4); + offset = strlen(buf); + snprintf(buf + offset, buflen - offset, ", RD: %s, Source-AS %s", + bgp_vpn_rd_print(pptr), + as_printf(astostr, sizeof(astostr), + EXTRACT_32BITS(pptr + BGP_VPN_RD_LEN))); + break; + + case BGP_MULTICAST_VPN_ROUTE_TYPE_S_PMSI: + TCHECK2(pptr[0], BGP_VPN_RD_LEN); + offset = strlen(buf); + snprintf(buf + offset, buflen - offset, ", RD: %s", + bgp_vpn_rd_print(pptr)); + pptr += BGP_VPN_RD_LEN; + + sg_length = bgp_vpn_sg_print(pptr, buf, buflen); + addr_length = route_length - sg_length; + + TCHECK2(pptr[0], addr_length); + offset = strlen(buf); + snprintf(buf + offset, buflen - offset, ", Originator %s", + bgp_vpn_ip_print(pptr, addr_length << 3)); + break; + + case BGP_MULTICAST_VPN_ROUTE_TYPE_SOURCE_ACTIVE: + TCHECK2(pptr[0], BGP_VPN_RD_LEN); + offset = strlen(buf); + snprintf(buf + offset, buflen - offset, ", RD: %s", + bgp_vpn_rd_print(pptr)); + pptr += BGP_VPN_RD_LEN; + + bgp_vpn_sg_print(pptr, buf, buflen); + break; + + case BGP_MULTICAST_VPN_ROUTE_TYPE_SHARED_TREE_JOIN: /* fall through */ + case BGP_MULTICAST_VPN_ROUTE_TYPE_SOURCE_TREE_JOIN: + TCHECK2(pptr[0], BGP_VPN_RD_LEN); + offset = strlen(buf); + snprintf(buf + offset, buflen - offset, ", RD: %s, Source-AS %s", + bgp_vpn_rd_print(pptr), + as_printf(astostr, sizeof(astostr), + EXTRACT_32BITS(pptr + BGP_VPN_RD_LEN))); + pptr += BGP_VPN_RD_LEN; + + bgp_vpn_sg_print(pptr, buf, buflen); + break; + + /* + * no per route-type printing yet. + */ + case BGP_MULTICAST_VPN_ROUTE_TYPE_INTRA_AS_SEG_LEAF: + default: + break; + } + + return route_length + 2; + +trunc: + return -2; +} + +/* + * As I remember, some versions of systems have an snprintf() that + * returns -1 if the buffer would have overflowed. If the return + * value is negative, set buflen to 0, to indicate that we've filled + * the buffer up. + * + * If the return value is greater than buflen, that means that + * the buffer would have overflowed; again, set buflen to 0 in + * that case. + */ +#define UPDATE_BUF_BUFLEN(buf, buflen, strlen) \ + if (strlen<0) \ + buflen=0; \ + else if ((u_int)strlen>buflen) \ + buflen=0; \ + else { \ + buflen-=strlen; \ + buf+=strlen; \ + } + +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; + /* Old and new L2VPN NLRI share AFI/SAFI + * -> Assume a 12 Byte-length NLRI is auto-discovery-only + * and > 17 as old format. Complain for the middle case + */ + if (plen==12) { + /* assume AD-only with RD, BGPNH */ + TCHECK2(pptr[0],12); + buf[0]='\0'; + strlen=snprintf(buf, buflen, "RD: %s, BGPNH: %s", + bgp_vpn_rd_print(pptr), + /* need something like getname() here */ + getname(pptr+8) + ); + UPDATE_BUF_BUFLEN(buf, buflen, strlen); + pptr+=12; + tlen-=12; + return plen; + } else if (plen>17) { + /* assume old format */ + /* RD, ID, LBLKOFF, LBLBASE */ + + TCHECK2(pptr[0],15); + buf[0]='\0'; + 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 */ + UPDATE_BUF_BUFLEN(buf, buflen, strlen); + 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: + if (buflen!=0) { + strlen=snprintf(buf,buflen, "\n\t\tcircuit status vector (%u) length: %u: 0x", + tlv_type, + tlv_len); + UPDATE_BUF_BUFLEN(buf, buflen, strlen); + } + ttlv_len=ttlv_len/8+1; /* how many bytes do we need to read ? */ + while (ttlv_len>0) { + TCHECK(pptr[0]); + if (buflen!=0) { + strlen=snprintf(buf,buflen, "%02x",*pptr++); + UPDATE_BUF_BUFLEN(buf, buflen, strlen); + } + ttlv_len--; + } + break; + default: + if (buflen!=0) { + strlen=snprintf(buf,buflen, "\n\t\tunknown TLV #%u, length: %u", + tlv_type, + tlv_len); + UPDATE_BUF_BUFLEN(buf, buflen, strlen); + } + break; + } + tlen-=(tlv_len<<3); /* the tlv-length is expressed in bits so lets shift it right */ + } + return plen+2; + + } else { + /* complain bitterly ? */ + /* fall through */ + goto trunc; + } + +trunc: + return -2; +} + +#ifdef INET6 +int +decode_prefix6(const u_char *pd, u_int itemlen, char *buf, u_int buflen) +{ + struct in6_addr addr; + u_int plen, plenbytes; + + TCHECK(pd[0]); + ITEMCHECK(1); + plen = pd[0]; + if (128 < plen) + return -1; + itemlen -= 1; + + memset(&addr, 0, sizeof(addr)); + plenbytes = (plen + 7) / 8; + TCHECK2(pd[1], plenbytes); + ITEMCHECK(plenbytes); + memcpy(&addr, &pd[1], plenbytes); + if (plen % 8) { + addr.s6_addr[plenbytes - 1] &= + ((0xff00 >> (plen % 8)) & 0xff); + } + snprintf(buf, buflen, "%s/%d", getname6((u_char *)&addr), plen); + return 1 + plenbytes; + +trunc: + return -2; + +badtlv: + return -3; +} + +static int +decode_labeled_prefix6(const u_char *pptr, u_int itemlen, char *buf, u_int buflen) +{ + struct in6_addr addr; + u_int plen, plenbytes; + + /* prefix length and label = 4 bytes */ + TCHECK2(pptr[0], 4); + ITEMCHECK(4); + plen = pptr[0]; /* get prefix length */ + + if (24 > plen) + return -1; + + plen-=24; /* adjust prefixlen - labellength */ + + if (128 < plen) + return -1; + itemlen -= 4; + + memset(&addr, 0, sizeof(addr)); + plenbytes = (plen + 7) / 8; + TCHECK2(pptr[4], plenbytes); + memcpy(&addr, &pptr[4], plenbytes); + if (plen % 8) { + addr.s6_addr[plenbytes - 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 + plenbytes; + +trunc: + return -2; + +badtlv: + return -3; +} + +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 */ + + if ((24+64) > plen) + return -1; + + 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 int +decode_clnp_prefix(const u_char *pptr, char *buf, u_int buflen) +{ + u_int8_t addr[19]; + u_int plen; + + TCHECK(pptr[0]); + plen = pptr[0]; /* get prefix length */ + + if (152 < 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[(plen + 7) / 8 - 1] &= + ((0xff00 >> (plen % 8)) & 0xff); + } + snprintf(buf, buflen, "%s/%d", + isonsap_string(addr,(plen + 7) / 8), + plen); + + return 1 + (plen + 7) / 8; + +trunc: + return -2; +} + +static int +decode_labeled_vpn_clnp_prefix(const u_char *pptr, char *buf, u_int buflen) +{ + u_int8_t addr[19]; + u_int plen; + + TCHECK(pptr[0]); + plen = pptr[0]; /* get prefix length */ + + if ((24+64) > plen) + return -1; + + plen-=(24+64); /* adjust prefixlen - labellength - RD len*/ + + if (152 < 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[(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), + isonsap_string(addr,(plen + 7) / 8), + 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; +} + +/* + * bgp_attr_get_as_size + * + * Try to find the size of the ASs encoded in an as-path. It is not obvious, as + * both Old speakers that do not support 4 byte AS, and the new speakers that do + * support, exchange AS-Path with the same path-attribute type value 0x02. + */ +static int +bgp_attr_get_as_size (u_int8_t bgpa_type, const u_char *pptr, int len) +{ + const u_char *tptr = pptr; + + /* + * If the path attribute is the optional AS4 path type, then we already + * know, that ASs must be encoded in 4 byte format. + */ + if (bgpa_type == BGPTYPE_AS4_PATH) { + return 4; + } + + /* + * Let us assume that ASs are of 2 bytes in size, and check if the AS-Path + * TLV is good. If not, ask the caller to try with AS encoded as 4 bytes + * each. + */ + while (tptr < pptr + len) { + TCHECK(tptr[0]); + + /* + * If we do not find a valid segment type, our guess might be wrong. + */ + if (tptr[0] < BGP_AS_SEG_TYPE_MIN || tptr[0] > BGP_AS_SEG_TYPE_MAX) { + goto trunc; + } + TCHECK(tptr[1]); + tptr += 2 + tptr[1] * 2; + } + + /* + * If we correctly reached end of the AS path attribute data content, + * then most likely ASs were indeed encoded as 2 bytes. + */ + if (tptr == pptr + len) { + return 2; + } + +trunc: + + /* + * We can come here, either we did not have enough data, or if we + * try to decode 4 byte ASs in 2 byte format. Either way, return 4, + * so that calller can try to decode each AS as of 4 bytes. If indeed + * there was not enough data, it will crib and end the parse anyways. + */ + return 4; +} + +static int +bgp_attr_print(u_int atype, const u_char *pptr, u_int len) +{ + int i; + u_int16_t af; + u_int8_t safi, snpa, nhlen; + union { /* copy buffer for bandwidth values */ + float f; + u_int32_t i; + } bw; + int advance; + u_int tlen; + const u_char *tptr; + char buf[MAXHOSTNAMELEN + 100]; + char tokbuf[TOKBUFSIZE]; + int as_size; + + tptr = pptr; + tlen=len; + + switch (atype) { + case BGPTYPE_ORIGIN: + if (len != 1) + printf("invalid len"); + else { + TCHECK(*tptr); + printf("%s", tok2strbuf(bgp_origin_values, + "Unknown Origin Typecode", + tptr[0], + tokbuf, sizeof(tokbuf))); + } + break; + + + /* + * Process AS4 byte path and AS2 byte path attributes here. + */ + case BGPTYPE_AS4_PATH: + case BGPTYPE_AS_PATH: + if (len % 2) { + printf("invalid len"); + break; + } + if (!len) { + printf("empty"); + break; + } + + /* + * BGP updates exchanged between New speakers that support 4 + * byte AS, ASs are always encoded in 4 bytes. There is no + * definitive way to find this, just by the packet's + * contents. So, check for packet's TLV's sanity assuming + * 2 bytes first, and it does not pass, assume that ASs are + * encoded in 4 bytes format and move on. + */ + as_size = bgp_attr_get_as_size(atype, pptr, len); + + while (tptr < pptr + len) { + TCHECK(tptr[0]); + printf("%s", tok2strbuf(bgp_as_path_segment_open_values, + "?", tptr[0], + tokbuf, sizeof(tokbuf))); + for (i = 0; i < tptr[1] * as_size; i += as_size) { + TCHECK2(tptr[2 + i], as_size); + printf("%s ", + as_printf(astostr, sizeof(astostr), + as_size == 2 ? + EXTRACT_16BITS(&tptr[2 + i]) : + EXTRACT_32BITS(&tptr[2 + i]))); + } + TCHECK(tptr[0]); + printf("%s", tok2strbuf(bgp_as_path_segment_close_values, + "?", tptr[0], + tokbuf, sizeof(tokbuf))); + TCHECK(tptr[1]); + tptr += 2 + tptr[1] * as_size; + } + break; + case BGPTYPE_NEXT_HOP: + if (len != 4) + 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 { + TCHECK2(tptr[0], 4); + printf("%u", EXTRACT_32BITS(tptr)); + } + break; + case BGPTYPE_ATOMIC_AGGREGATE: + if (len != 0) + printf("invalid len"); + break; + case BGPTYPE_AGGREGATOR: + + /* + * Depending on the AS encoded is of 2 bytes or of 4 bytes, + * the length of this PA can be either 6 bytes or 8 bytes. + */ + if (len != 6 && len != 8) { + printf("invalid len"); + break; + } + TCHECK2(tptr[0], len); + if (len == 6) { + printf(" AS #%s, origin %s", + as_printf(astostr, sizeof(astostr), EXTRACT_16BITS(tptr)), + getname(tptr + 2)); + } else { + printf(" AS #%s, origin %s", + as_printf(astostr, sizeof(astostr), + EXTRACT_32BITS(tptr)), getname(tptr + 4)); + } + break; + case BGPTYPE_AGGREGATOR4: + if (len != 8) { + printf("invalid len"); + break; + } + TCHECK2(tptr[0], 8); + printf(" AS #%s, origin %s", + as_printf(astostr, sizeof(astostr), EXTRACT_32BITS(tptr)), + getname(tptr + 4)); + break; + case BGPTYPE_COMMUNITIES: + if (len % 4) { + printf("invalid len"); + break; + } + while (tlen>0) { + u_int32_t comm; + TCHECK2(tptr[0], 4); + comm = EXTRACT_32BITS(tptr); + switch (comm) { + case BGP_COMMUNITY_NO_EXPORT: + printf(" NO_EXPORT"); + break; + case BGP_COMMUNITY_NO_ADVERT: + printf(" NO_ADVERTISE"); + break; + case BGP_COMMUNITY_NO_EXPORT_SUBCONFED: + printf(" NO_EXPORT_SUBCONFED"); + break; + default: + printf("%u:%u%s", + (comm >> 16) & 0xffff, + comm & 0xffff, + (tlen>4) ? ", " : ""); + break; + } + tlen -=4; + tptr +=4; + } + break; + case BGPTYPE_ORIGINATOR_ID: + if (len != 4) { + printf("invalid len"); + break; + } + 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)", + tok2strbuf(af_values, "Unknown AFI", af, + tokbuf, sizeof(tokbuf)), + af, + (safi>128) ? "vendor specific " : "", /* 128 is meanwhile wellknown */ + tok2strbuf(bgp_safi_values, "Unknown SAFI", safi, + tokbuf, sizeof(tokbuf)), + safi); + + switch(af<<8 | safi) { + case (AFNUM_INET<<8 | SAFNUM_UNICAST): + case (AFNUM_INET<<8 | SAFNUM_MULTICAST): + case (AFNUM_INET<<8 | SAFNUM_UNIMULTICAST): + case (AFNUM_INET<<8 | SAFNUM_LABUNICAST): + case (AFNUM_INET<<8 | SAFNUM_RT_ROUTING_INFO): + case (AFNUM_INET<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST): + case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN): + case (AFNUM_INET<<8 | SAFNUM_MDT): +#ifdef INET6 + case (AFNUM_INET6<<8 | SAFNUM_UNICAST): + case (AFNUM_INET6<<8 | SAFNUM_MULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_LABUNICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNUNIMULTICAST): +#endif + case (AFNUM_NSAP<<8 | SAFNUM_UNICAST): + case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNUNIMULTICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNIMULTICAST): + case (AFNUM_VPLS<<8 | SAFNUM_VPLS): + break; + default: + TCHECK2(tptr[0], tlen); + printf("\n\t no AFI %u / SAFI %u decoder",af,safi); + if (vflag <= 1) + print_unknown_data(tptr,"\n\t ",tlen); + goto done; + break; + } + + tptr +=3; + + TCHECK(tptr[0]); + nhlen = tptr[0]; + tlen = nhlen; + tptr++; + + if (tlen) { + printf("\n\t nexthop: "); + while (tlen > 0) { + switch(af<<8 | safi) { + case (AFNUM_INET<<8 | SAFNUM_UNICAST): + case (AFNUM_INET<<8 | SAFNUM_MULTICAST): + case (AFNUM_INET<<8 | SAFNUM_UNIMULTICAST): + case (AFNUM_INET<<8 | SAFNUM_LABUNICAST): + case (AFNUM_INET<<8 | SAFNUM_RT_ROUTING_INFO): + case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN): + case (AFNUM_INET<<8 | SAFNUM_MDT): + 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 (AFNUM_INET<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_INET<<8 | 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; +#ifdef INET6 + case (AFNUM_INET6<<8 | SAFNUM_UNICAST): + case (AFNUM_INET6<<8 | SAFNUM_MULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_LABUNICAST): + 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 (AFNUM_INET6<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_INET6<<8 | 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; +#endif + case (AFNUM_VPLS<<8 | SAFNUM_VPLS): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_L2VPN<<8 | 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; + case (AFNUM_NSAP<<8 | SAFNUM_UNICAST): + case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST): + TCHECK2(tptr[0], tlen); + printf("%s",isonsap_string(tptr,tlen)); + tptr += tlen; + tlen = 0; + break; + + case (AFNUM_NSAP<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNUNIMULTICAST): + if (tlen < BGP_VPN_RD_LEN+1) { + printf("invalid len"); + tlen = 0; + } else { + TCHECK2(tptr[0], tlen); + printf("RD: %s, %s", + bgp_vpn_rd_print(tptr), + isonsap_string(tptr+BGP_VPN_RD_LEN,tlen-BGP_VPN_RD_LEN)); + /* rfc986 mapped IPv4 address ? */ + if (EXTRACT_32BITS(tptr+BGP_VPN_RD_LEN) == 0x47000601) + printf(" = %s", getname(tptr+BGP_VPN_RD_LEN+4)); +#ifdef INET6 + /* rfc1888 mapped IPv6 address ? */ + else if (EXTRACT_24BITS(tptr+BGP_VPN_RD_LEN) == 0x350000) + printf(" = %s", getname6(tptr+BGP_VPN_RD_LEN+3)); +#endif + tptr += tlen; + tlen = 0; + } + break; + default: + TCHECK2(tptr[0], tlen); + printf("no AFI %u/SAFI %u decoder",af,safi); + if (vflag <= 1) + print_unknown_data(tptr,"\n\t ",tlen); + tptr += tlen; + tlen = 0; + goto done; + break; + } + } + } + printf(", nh-length: %u", nhlen); + tptr += tlen; + + TCHECK(tptr[0]); + snpa = tptr[0]; + tptr++; + + if (snpa) { + printf("\n\t %u SNPA", snpa); + for (/*nothing*/; snpa > 0; snpa--) { + TCHECK(tptr[0]); + printf("\n\t %d bytes", tptr[0]); + tptr += tptr[0] + 1; + } + } else { + printf(", no SNPA"); + } + + while (len - (tptr - pptr) > 0) { + switch (af<<8 | safi) { + case (AFNUM_INET<<8 | SAFNUM_UNICAST): + case (AFNUM_INET<<8 | SAFNUM_MULTICAST): + case (AFNUM_INET<<8 | SAFNUM_UNIMULTICAST): + advance = decode_prefix4(tptr, len, buf, sizeof(buf)); + if (advance == -1) + printf("\n\t (illegal prefix length)"); + else if (advance == -2) + goto trunc; + else if (advance == -3) + break; /* bytes left, but not enough */ + else + printf("\n\t %s", buf); + break; + case (AFNUM_INET<<8 | SAFNUM_LABUNICAST): + advance = decode_labeled_prefix4(tptr, len, buf, sizeof(buf)); + if (advance == -1) + printf("\n\t (illegal prefix length)"); + else if (advance == -2) + goto trunc; + else if (advance == -3) + break; /* bytes left, but not enough */ + else + printf("\n\t %s", buf); + break; + case (AFNUM_INET<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_INET<<8 | 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 (AFNUM_INET<<8 | 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; + case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN): /* fall through */ + case (AFNUM_INET6<<8 | SAFNUM_MULTICAST_VPN): + advance = decode_multicast_vpn(tptr, buf, sizeof(buf)); + if (advance == -1) + printf("\n\t (illegal prefix length)"); + else if (advance == -2) + goto trunc; + else + printf("\n\t %s", buf); + break; + + case (AFNUM_INET<<8 | SAFNUM_MDT): + advance = decode_mdt_vpn_nlri(tptr, buf, sizeof(buf)); + if (advance == -1) + printf("\n\t (illegal prefix length)"); + else if (advance == -2) + goto trunc; + else + printf("\n\t %s", buf); + break; +#ifdef INET6 + case (AFNUM_INET6<<8 | SAFNUM_UNICAST): + case (AFNUM_INET6<<8 | SAFNUM_MULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST): + advance = decode_prefix6(tptr, len, buf, sizeof(buf)); + if (advance == -1) + printf("\n\t (illegal prefix length)"); + else if (advance == -2) + goto trunc; + else if (advance == -3) + break; /* bytes left, but not enough */ + else + printf("\n\t %s", buf); + break; + case (AFNUM_INET6<<8 | SAFNUM_LABUNICAST): + advance = decode_labeled_prefix6(tptr, len, buf, sizeof(buf)); + if (advance == -1) + printf("\n\t (illegal prefix length)"); + else if (advance == -2) + goto trunc; + else if (advance == -3) + break; /* bytes left, but not enough */ + else + printf("\n\t %s", buf); + break; + case (AFNUM_INET6<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_INET6<<8 | 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; +#endif + case (AFNUM_VPLS<<8 | SAFNUM_VPLS): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_L2VPN<<8 | 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; + case (AFNUM_NSAP<<8 | SAFNUM_UNICAST): + case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST): + advance = decode_clnp_prefix(tptr, buf, sizeof(buf)); + if (advance == -1) + printf("\n\t (illegal prefix length)"); + else if (advance == -2) + goto trunc; + else + printf("\n\t %s", buf); + break; + case (AFNUM_NSAP<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNUNIMULTICAST): + advance = decode_labeled_vpn_clnp_prefix(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,tlen); + printf("\n\t no AFI %u / SAFI %u decoder",af,safi); + if (vflag <= 1) + print_unknown_data(tptr,"\n\t ",tlen); + advance = 0; + tptr = pptr + len; + break; + } + if (advance < 0) + break; + tptr += advance; + } + done: + break; + + case BGPTYPE_MP_UNREACH_NLRI: + TCHECK2(tptr[0], BGP_MP_NLRI_MINSIZE); + af = EXTRACT_16BITS(tptr); + safi = tptr[2]; + + printf("\n\t AFI: %s (%u), %sSAFI: %s (%u)", + tok2strbuf(af_values, "Unknown AFI", af, + tokbuf, sizeof(tokbuf)), + af, + (safi>128) ? "vendor specific " : "", /* 128 is meanwhile wellknown */ + tok2strbuf(bgp_safi_values, "Unknown SAFI", safi, + tokbuf, sizeof(tokbuf)), + safi); + + if (len == BGP_MP_NLRI_MINSIZE) + printf("\n\t End-of-Rib Marker (empty NLRI)"); + + tptr += 3; + + while (len - (tptr - pptr) > 0) { + switch (af<<8 | safi) { + case (AFNUM_INET<<8 | SAFNUM_UNICAST): + case (AFNUM_INET<<8 | SAFNUM_MULTICAST): + case (AFNUM_INET<<8 | SAFNUM_UNIMULTICAST): + advance = decode_prefix4(tptr, len, buf, sizeof(buf)); + if (advance == -1) + printf("\n\t (illegal prefix length)"); + else if (advance == -2) + goto trunc; + else if (advance == -3) + break; /* bytes left, but not enough */ + else + printf("\n\t %s", buf); + break; + case (AFNUM_INET<<8 | SAFNUM_LABUNICAST): + advance = decode_labeled_prefix4(tptr, len, buf, sizeof(buf)); + if (advance == -1) + printf("\n\t (illegal prefix length)"); + else if (advance == -2) + goto trunc; + else if (advance == -3) + break; /* bytes left, but not enough */ + else + printf("\n\t %s", buf); + break; + case (AFNUM_INET<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_INET<<8 | 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; +#ifdef INET6 + case (AFNUM_INET6<<8 | SAFNUM_UNICAST): + case (AFNUM_INET6<<8 | SAFNUM_MULTICAST): + case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST): + advance = decode_prefix6(tptr, len, buf, sizeof(buf)); + if (advance == -1) + printf("\n\t (illegal prefix length)"); + else if (advance == -2) + goto trunc; + else if (advance == -3) + break; /* bytes left, but not enough */ + else + printf("\n\t %s", buf); + break; + case (AFNUM_INET6<<8 | SAFNUM_LABUNICAST): + advance = decode_labeled_prefix6(tptr, len, buf, sizeof(buf)); + if (advance == -1) + printf("\n\t (illegal prefix length)"); + else if (advance == -2) + goto trunc; + else if (advance == -3) + break; /* bytes left, but not enough */ + else + printf("\n\t %s", buf); + break; + case (AFNUM_INET6<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_INET6<<8 | 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; +#endif + case (AFNUM_VPLS<<8 | SAFNUM_VPLS): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_L2VPN<<8 | 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; + case (AFNUM_NSAP<<8 | SAFNUM_UNICAST): + case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST): + advance = decode_clnp_prefix(tptr, buf, sizeof(buf)); + if (advance == -1) + printf("\n\t (illegal prefix length)"); + else if (advance == -2) + goto trunc; + else + printf("\n\t %s", buf); + break; + case (AFNUM_NSAP<<8 | SAFNUM_VPNUNICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNMULTICAST): + case (AFNUM_NSAP<<8 | SAFNUM_VPNUNIMULTICAST): + advance = decode_labeled_vpn_clnp_prefix(tptr, buf, sizeof(buf)); + if (advance == -1) + printf("\n\t (illegal prefix length)"); + else if (advance == -2) + goto trunc; + else + printf("\n\t %s", buf); + break; + case (AFNUM_INET<<8 | SAFNUM_MDT): + advance = decode_mdt_vpn_nlri(tptr, buf, sizeof(buf)); + if (advance == -1) + printf("\n\t (illegal prefix length)"); + else if (advance == -2) + goto trunc; + else + printf("\n\t %s", buf); + break; + case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN): /* fall through */ + case (AFNUM_INET6<<8 | SAFNUM_MULTICAST_VPN): + advance = decode_multicast_vpn(tptr, buf, sizeof(buf)); + 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("no AFI %u / SAFI %u decoder",af,safi); + if (vflag <= 1) + print_unknown_data(tptr-3,"\n\t ",tlen); + advance = 0; + tptr = pptr + len; + break; + } + if (advance < 0) + break; + 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]", + tok2strbuf(bgp_extd_comm_subtype_values, + "unknown extd community typecode", + extd_comm, tokbuf, sizeof(tokbuf)), + 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: + case BGP_EXT_COM_L2VPN_RT_0: + printf(": %u:%u (= %s)", + EXTRACT_16BITS(tptr+2), + EXTRACT_32BITS(tptr+4), + getname(tptr+4)); + break; + case BGP_EXT_COM_RT_1: + case BGP_EXT_COM_RO_1: + case BGP_EXT_COM_L2VPN_RT_1: + case BGP_EXT_COM_VRF_RT_IMP: + printf(": %s:%u", + getname(tptr+2), + EXTRACT_16BITS(tptr+6)); + break; + case BGP_EXT_COM_RT_2: + case BGP_EXT_COM_RO_2: + printf(": %s:%u", + as_printf(astostr, sizeof(astostr), + EXTRACT_32BITS(tptr+2)), EXTRACT_16BITS(tptr+6)); + break; + case BGP_EXT_COM_LINKBAND: + bw.i = EXTRACT_32BITS(tptr+2); + printf(": bandwidth: %.3f Mbps", + 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), + tok2strbuf(bgp_extd_comm_ospf_rtype_values, + "unknown (0x%02x)", + *(tptr+6), + tokbuf, sizeof(tokbuf)), + (*(tptr+7) & BGP_OSPF_RTYPE_METRIC_TYPE) ? "E2" : "", + ((*(tptr+6) == BGP_OSPF_RTYPE_EXT) || (*(tptr+6) == BGP_OSPF_RTYPE_NSSA)) ? "E1" : ""); + break; + case BGP_EXT_COM_L2INFO: + printf(": %s Control Flags [0x%02x]:MTU %u", + tok2strbuf(l2vpn_encaps_values, + "unknown encaps", + *(tptr+2), + tokbuf, sizeof(tokbuf)), + *(tptr+3), + EXTRACT_16BITS(tptr+4)); + break; + case BGP_EXT_COM_SOURCE_AS: + printf(": AS %u", EXTRACT_16BITS(tptr+2)); + break; + default: + TCHECK2(*tptr,8); + print_unknown_data(tptr,"\n\t ",8); + break; + } + tlen -=8; + tptr +=8; + } + break; + + case BGPTYPE_PMSI_TUNNEL: + { + u_int8_t tunnel_type, flags; + + tunnel_type = *(tptr+1); + flags = *tptr; + tlen = len; + + TCHECK2(tptr[0], 5); + printf("\n\t Tunnel-type %s (%u), Flags [%s], MPLS Label %u", + tok2str(bgp_pmsi_tunnel_values, "Unknown", tunnel_type), + tunnel_type, + bittok2str(bgp_pmsi_flag_values, "none", flags), + EXTRACT_24BITS(tptr+2)>>4); + + tptr +=5; + tlen -= 5; + + switch (tunnel_type) { + case BGP_PMSI_TUNNEL_PIM_SM: /* fall through */ + case BGP_PMSI_TUNNEL_PIM_BIDIR: + TCHECK2(tptr[0], 8); + printf("\n\t Sender %s, P-Group %s", + ipaddr_string(tptr), + ipaddr_string(tptr+4)); + break; + + case BGP_PMSI_TUNNEL_PIM_SSM: + TCHECK2(tptr[0], 8); + printf("\n\t Root-Node %s, P-Group %s", + ipaddr_string(tptr), + ipaddr_string(tptr+4)); + break; + case BGP_PMSI_TUNNEL_INGRESS: + TCHECK2(tptr[0], 4); + printf("\n\t Tunnel-Endpoint %s", + ipaddr_string(tptr)); + break; + case BGP_PMSI_TUNNEL_LDP_P2MP: /* fall through */ + case BGP_PMSI_TUNNEL_LDP_MP2MP: + TCHECK2(tptr[0], 8); + printf("\n\t Root-Node %s, LSP-ID 0x%08x", + ipaddr_string(tptr), + EXTRACT_32BITS(tptr+4)); + break; + case BGP_PMSI_TUNNEL_RSVP_P2MP: + TCHECK2(tptr[0], 8); + printf("\n\t Extended-Tunnel-ID %s, P2MP-ID 0x%08x", + ipaddr_string(tptr), + EXTRACT_32BITS(tptr+4)); + break; + default: + if (vflag <= 1) { + print_unknown_data(tptr,"\n\t ",tlen); + } + } + break; + } + case BGPTYPE_ATTR_SET: + TCHECK2(tptr[0], 4); + if (len < 4) + goto trunc; + printf("\n\t Origin AS: %s", + as_printf(astostr, sizeof(astostr), EXTRACT_32BITS(tptr))); + tptr+=4; + len -=4; + + while (len) { + u_int aflags, atype, alenlen, alen; + + TCHECK2(tptr[0], 2); + if (len < 2) + goto trunc; + aflags = *tptr; + atype = *(tptr + 1); + tptr += 2; + len -= 2; + alenlen = bgp_attr_lenlen(aflags, tptr); + TCHECK2(tptr[0], alenlen); + if (len < alenlen) + goto trunc; + alen = bgp_attr_len(aflags, tptr); + tptr += alenlen; + len -= alenlen; + + printf("\n\t %s (%u), length: %u", + tok2strbuf(bgp_attr_values, + "Unknown Attribute", atype, + tokbuf, sizeof(tokbuf)), + atype, + alen); + + if (aflags) { + printf(", Flags [%s%s%s%s", + aflags & 0x80 ? "O" : "", + aflags & 0x40 ? "T" : "", + aflags & 0x20 ? "P" : "", + aflags & 0x10 ? "E" : ""); + if (aflags & 0xf) + printf("+%x", aflags & 0xf); + printf("]: "); + } + /* FIXME check for recursion */ + if (!bgp_attr_print(atype, tptr, alen)) + return 0; + tptr += alen; + len -= alen; + } + break; + + + default: + TCHECK2(*pptr,len); + printf("\n\t no Attribute %u decoder",atype); /* 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*/ + TCHECK2(*pptr,len); + print_unknown_data(pptr,"\n\t ",len); + } + return 1; + +trunc: + return 0; +} + +static void +bgp_capabilities_print(const u_char *opt, int caps_len) +{ + char tokbuf[TOKBUFSIZE]; + char tokbuf2[TOKBUFSIZE]; + int cap_type, cap_len, tcap_len, cap_offset; + int i = 0; + + while (i < caps_len) { + TCHECK2(opt[i], BGP_CAP_HEADER_SIZE); + cap_type=opt[i]; + cap_len=opt[i+1]; + tcap_len=cap_len; + printf("\n\t %s (%u), length: %u", + tok2strbuf(bgp_capcode_values, "Unknown", + cap_type, tokbuf, sizeof(tokbuf)), + cap_type, + cap_len); + TCHECK2(opt[i+2], cap_len); + switch (cap_type) { + case BGP_CAPCODE_MP: + printf("\n\t\tAFI %s (%u), SAFI %s (%u)", + tok2strbuf(af_values, "Unknown", + EXTRACT_16BITS(opt+i+2), + tokbuf, sizeof(tokbuf)), + EXTRACT_16BITS(opt+i+2), + tok2strbuf(bgp_safi_values, "Unknown", + opt[i+5], + tokbuf, sizeof(tokbuf)), + opt[i+5]); + break; + case BGP_CAPCODE_RESTART: + printf("\n\t\tRestart Flags: [%s], Restart Time %us", + ((opt[i+2])&0x80) ? "R" : "none", + EXTRACT_16BITS(opt+i+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", + tok2strbuf(af_values,"Unknown", + EXTRACT_16BITS(opt+i+cap_offset), + tokbuf, sizeof(tokbuf)), + EXTRACT_16BITS(opt+i+cap_offset), + tok2strbuf(bgp_safi_values,"Unknown", + opt[i+cap_offset+2], + tokbuf2, sizeof(tokbuf2)), + opt[i+cap_offset+2], + ((opt[i+cap_offset+3])&0x80) ? "yes" : "no" ); + tcap_len-=4; + cap_offset+=4; + } + break; + case BGP_CAPCODE_RR: + case BGP_CAPCODE_RR_CISCO: + break; + case BGP_CAPCODE_AS_NEW: + + /* + * Extract the 4 byte AS number encoded. + */ + if (cap_len == 4) { + printf("\n\t\t 4 Byte AS %s", + as_printf(astostr, sizeof(astostr), + EXTRACT_32BITS(opt + i + 2))); + } + break; + default: + printf("\n\t\tno decoder for Capability %u", + cap_type); + if (vflag <= 1) + print_unknown_data(&opt[i+2],"\n\t\t",cap_len); + break; + } + if (vflag > 1 && cap_len > 0) { + print_unknown_data(&opt[i+2],"\n\t\t",cap_len); + } + i += BGP_CAP_HEADER_SIZE + cap_len; + } + return; + +trunc: + printf("[|BGP]"); +} + +static void +bgp_open_print(const u_char *dat, int length) +{ + struct bgp_open bgpo; + struct bgp_opt bgpopt; + const u_char *opt; + int i; + char tokbuf[TOKBUFSIZE]; + + TCHECK2(dat[0], BGP_OPEN_SIZE); + memcpy(&bgpo, dat, BGP_OPEN_SIZE); + + printf("\n\t Version %d, ", bgpo.bgpo_version); + printf("my AS %s, ", + as_printf(astostr, sizeof(astostr), ntohs(bgpo.bgpo_myas))); + printf("Holdtime %us, ", ntohs(bgpo.bgpo_holdtime)); + printf("ID %s", getname((u_char *)&bgpo.bgpo_id)); + printf("\n\t Optional parameters, length: %u", bgpo.bgpo_optlen); + + /* some little sanity checking */ + if (length < bgpo.bgpo_optlen+BGP_OPEN_SIZE) + return; + + /* ugly! */ + opt = &((const struct bgp_open *)dat)->bgpo_optlen; + opt++; + + i = 0; + while (i < bgpo.bgpo_optlen) { + TCHECK2(opt[i], BGP_OPT_SIZE); + memcpy(&bgpopt, &opt[i], BGP_OPT_SIZE); + if (i + 2 + bgpopt.bgpopt_len > bgpo.bgpo_optlen) { + printf("\n\t Option %d, length: %u", bgpopt.bgpopt_type, bgpopt.bgpopt_len); + break; + } + + printf("\n\t Option %s (%u), length: %u", + tok2strbuf(bgp_opt_values,"Unknown", + bgpopt.bgpopt_type, + tokbuf, sizeof(tokbuf)), + bgpopt.bgpopt_type, + bgpopt.bgpopt_len); + + /* now let's decode the options we know*/ + switch(bgpopt.bgpopt_type) { + + case BGP_OPT_CAP: + bgp_capabilities_print(&opt[i+BGP_OPT_SIZE], + bgpopt.bgpopt_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; +trunc: + printf("[|BGP]"); +} + +static void +bgp_update_print(const u_char *dat, int length) +{ + struct bgp bgp; + const u_char *p; + int withdrawn_routes_len; + int len; + int i; + char tokbuf[TOKBUFSIZE]; +#ifndef INET6 + char buf[MAXHOSTNAMELEN + 100]; + int wpfx; +#endif + + TCHECK2(dat[0], BGP_SIZE); + if (length < BGP_SIZE) + goto trunc; + memcpy(&bgp, dat, BGP_SIZE); + p = dat + BGP_SIZE; /*XXX*/ + length -= BGP_SIZE; + + /* Unfeasible routes */ + TCHECK2(p[0], 2); + if (length < 2) + goto trunc; + withdrawn_routes_len = EXTRACT_16BITS(p); + p += 2; + length -= 2; + if (withdrawn_routes_len) { + /* + * Without keeping state from the original NLRI message, + * it's not possible to tell if this a v4 or v6 route, + * so only try to decode it if we're not v6 enabled. + */ + TCHECK2(p[0], withdrawn_routes_len); + if (length < withdrawn_routes_len) + goto trunc; +#ifdef INET6 + printf("\n\t Withdrawn routes: %d bytes", withdrawn_routes_len); + p += withdrawn_routes_len; + length -= withdrawn_routes_len; +#else + if (withdrawn_routes_len < 2) + goto trunc; + length -= 2; + withdrawn_routes_len -= 2; + + + printf("\n\t Withdrawn routes:"); + + while(withdrawn_routes_len > 0) { + wpfx = decode_prefix4(p, withdrawn_routes_len, buf, sizeof(buf)); + if (wpfx == -1) { + printf("\n\t (illegal prefix length)"); + break; + } else if (wpfx == -2) + goto trunc; + else if (wpfx == -3) + goto trunc; /* bytes left, but not enough */ + else { + printf("\n\t %s", buf); + p += wpfx; + length -= wpfx; + withdrawn_routes_len -= wpfx; + } + } +#endif + } + + TCHECK2(p[0], 2); + if (length < 2) + goto trunc; + len = EXTRACT_16BITS(p); + p += 2; + length -= 2; + + if (withdrawn_routes_len == 0 && len == 0 && length == 0) { + /* No withdrawn routes, no path attributes, no NLRI */ + printf("\n\t End-of-Rib Marker (empty NLRI)"); + return; + } + + if (len) { + /* do something more useful!*/ + while (len) { + int aflags, atype, alenlen, alen; + + TCHECK2(p[0], 2); + if (len < 2) + goto trunc; + if (length < 2) + goto trunc; + aflags = *p; + atype = *(p + 1); + p += 2; + len -= 2; + length -= 2; + alenlen = bgp_attr_lenlen(aflags, p); + TCHECK2(p[0], alenlen); + if (len < alenlen) + goto trunc; + if (length < alenlen) + goto trunc; + alen = bgp_attr_len(aflags, p); + p += alenlen; + len -= alenlen; + length -= alenlen; + + printf("\n\t %s (%u), length: %u", + tok2strbuf(bgp_attr_values, "Unknown Attribute", + atype, + tokbuf, sizeof(tokbuf)), + atype, + alen); + + if (aflags) { + printf(", Flags [%s%s%s%s", + aflags & 0x80 ? "O" : "", + aflags & 0x40 ? "T" : "", + aflags & 0x20 ? "P" : "", + aflags & 0x10 ? "E" : ""); + if (aflags & 0xf) + printf("+%x", aflags & 0xf); + printf("]: "); + } + if (len < alen) + goto trunc; + if (length < alen) + goto trunc; + if (!bgp_attr_print(atype, p, alen)) + goto trunc; + p += alen; + len -= alen; + length -= alen; + } + } + + if (length) { + /* + * XXX - what if they're using the "Advertisement of + * Multiple Paths in BGP" feature: + * + * https://datatracker.ietf.org/doc/draft-ietf-idr-add-paths/ + * + * http://tools.ietf.org/html/draft-ietf-idr-add-paths-06 + */ + printf("\n\t Updated routes:"); + while (length) { + char buf[MAXHOSTNAMELEN + 100]; + i = decode_prefix4(p, length, buf, sizeof(buf)); + if (i == -1) { + printf("\n\t (illegal prefix length)"); + break; + } else if (i == -2) + goto trunc; + else if (i == -3) + goto trunc; /* bytes left, but not enough */ + else { + printf("\n\t %s", buf); + p += i; + length -= i; + } + } + } + return; +trunc: + printf("[|BGP]"); +} + +static void +bgp_notification_print(const u_char *dat, int length) +{ + struct bgp_notification bgpn; + const u_char *tptr; + char tokbuf[TOKBUFSIZE]; + char tokbuf2[TOKBUFSIZE]; + + TCHECK2(dat[0], BGP_NOTIFICATION_SIZE); + memcpy(&bgpn, dat, BGP_NOTIFICATION_SIZE); + + /* some little sanity checking */ + if (length<BGP_NOTIFICATION_SIZE) + return; + + printf(", %s (%u)", + tok2strbuf(bgp_notify_major_values, "Unknown Error", + bgpn.bgpn_major, tokbuf, sizeof(tokbuf)), + bgpn.bgpn_major); + + switch (bgpn.bgpn_major) { + + case BGP_NOTIFY_MAJOR_MSG: + printf(", subcode %s (%u)", + tok2strbuf(bgp_notify_minor_msg_values, "Unknown", + bgpn.bgpn_minor, tokbuf, sizeof(tokbuf)), + bgpn.bgpn_minor); + break; + case BGP_NOTIFY_MAJOR_OPEN: + printf(", subcode %s (%u)", + tok2strbuf(bgp_notify_minor_open_values, "Unknown", + bgpn.bgpn_minor, tokbuf, sizeof(tokbuf)), + bgpn.bgpn_minor); + break; + case BGP_NOTIFY_MAJOR_UPDATE: + printf(", subcode %s (%u)", + tok2strbuf(bgp_notify_minor_update_values, "Unknown", + bgpn.bgpn_minor, tokbuf, sizeof(tokbuf)), + bgpn.bgpn_minor); + break; + case BGP_NOTIFY_MAJOR_CAP: + printf(" subcode %s (%u)", + tok2strbuf(bgp_notify_minor_cap_values, "Unknown", + bgpn.bgpn_minor, tokbuf, sizeof(tokbuf)), + bgpn.bgpn_minor); + case BGP_NOTIFY_MAJOR_CEASE: + printf(", subcode %s (%u)", + tok2strbuf(bgp_notify_minor_cease_values, "Unknown", + bgpn.bgpn_minor, tokbuf, sizeof(tokbuf)), + 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", + tok2strbuf(af_values, "Unknown", + EXTRACT_16BITS(tptr), tokbuf, sizeof(tokbuf)), + EXTRACT_16BITS(tptr), + tok2strbuf(bgp_safi_values, "Unknown", *(tptr+2), + tokbuf2, sizeof(tokbuf)), + *(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; + char tokbuf[TOKBUFSIZE]; + char tokbuf2[TOKBUFSIZE]; + + TCHECK2(pptr[0], BGP_ROUTE_REFRESH_SIZE); + + /* some little sanity checking */ + if (len<BGP_ROUTE_REFRESH_SIZE) + return; + + bgp_route_refresh_header = (const struct bgp_route_refresh *)pptr; + + printf("\n\t AFI %s (%u), SAFI %s (%u)", + tok2strbuf(af_values,"Unknown", + /* this stinks but the compiler pads the structure + * weird */ + EXTRACT_16BITS(&bgp_route_refresh_header->afi), + tokbuf, sizeof(tokbuf)), + EXTRACT_16BITS(&bgp_route_refresh_header->afi), + tok2strbuf(bgp_safi_values,"Unknown", + bgp_route_refresh_header->safi, + tokbuf2, sizeof(tokbuf2)), + bgp_route_refresh_header->safi); + + if (vflag > 1) { + TCHECK2(*pptr, len); + print_unknown_data(pptr,"\n\t ", len); + } + + return; +trunc: + printf("[|BGP]"); +} + +static int +bgp_header_print(const u_char *dat, int length) +{ + struct bgp bgp; + char tokbuf[TOKBUFSIZE]; + + TCHECK2(dat[0], BGP_SIZE); + memcpy(&bgp, dat, BGP_SIZE); + printf("\n\t%s Message (%u), length: %u", + tok2strbuf(bgp_msg_values, "Unknown", bgp.bgp_type, + tokbuf, sizeof(tokbuf)), + bgp.bgp_type, + length); + + switch (bgp.bgp_type) { + case BGP_OPEN: + bgp_open_print(dat, length); + break; + case BGP_UPDATE: + bgp_update_print(dat, length); + break; + 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 */ + TCHECK2(*dat, length); + printf("\n\t no Message %u decoder",bgp.bgp_type); + print_unknown_data(dat,"\n\t ",length); + break; + } + return 1; +trunc: + printf("[|BGP]"); + return 0; +} + +void +bgp_print(const u_char *dat, int length) +{ + const u_char *p; + 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, + }; + struct bgp bgp; + u_int16_t hlen; + char tokbuf[TOKBUFSIZE]; + + ep = dat + length; + if (snapend < dat + length) + ep = snapend; + + printf(": BGP, length: %u",length); + + if (vflag < 1) /* lets be less chatty */ + return; + + p = dat; + start = p; + while (p < ep) { + if (!TTEST2(p[0], 1)) + break; + if (p[0] != 0xff) { + p++; + continue; + } + + if (!TTEST2(p[0], sizeof(marker))) + break; + if (memcmp(p, marker, sizeof(marker)) != 0) { + p++; + continue; + } + + /* found BGP header */ + TCHECK2(p[0], BGP_SIZE); /*XXX*/ + memcpy(&bgp, p, BGP_SIZE); + + if (start != p) + printf(" [|BGP]"); + + hlen = ntohs(bgp.bgp_len); + if (hlen < BGP_SIZE) { + printf("\n[|BGP Bogus header length %u < %u]", hlen, + BGP_SIZE); + break; + } + + if (TTEST2(p[0], hlen)) { + if (!bgp_header_print(p, hlen)) + return; + p += hlen; + start = p; + } else { + printf("\n[|BGP %s]", + tok2strbuf(bgp_msg_values, + "Unknown Message Type", + bgp.bgp_type, + tokbuf, sizeof(tokbuf))); + break; + } + } + + return; + +trunc: + printf(" [|BGP]"); +} + +/* + * Local Variables: + * c-style: whitesmith + * c-basic-offset: 4 + * End: + */
diff --git a/tcpdump-4.3.0/print-bootp.c b/tcpdump-4.3.0/print-bootp.c new file mode 100644 index 0000000..c7538ff --- /dev/null +++ b/tcpdump-4.3.0/print-bootp.c
@@ -0,0 +1,825 @@ +/* + * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * Format and print bootp packets. + */ +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.89 2008-04-22 09:45:08 hannes Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> +#include <string.h> + +#include "interface.h" +#include "addrtoname.h" +#include "extract.h" +#include "ether.h" +#include "bootp.h" + +static void rfc1048_print(const u_char *); +static void cmu_print(const u_char *); +static char *client_fqdn_flags(u_int flags); + +static char tstr[] = " [|bootp]"; + +static const struct tok bootp_flag_values[] = { + { 0x8000, "Broadcast" }, + { 0, NULL} +}; + +static const struct tok bootp_op_values[] = { + { BOOTPREQUEST, "Request" }, + { BOOTPREPLY, "Reply" }, + { 0, NULL} +}; + +/* + * Print bootp requests + */ +void +bootp_print(register const u_char *cp, u_int length) +{ + register const struct bootp *bp; + static const u_char vm_cmu[4] = VM_CMU; + static const u_char vm_rfc1048[4] = VM_RFC1048; + + bp = (const struct bootp *)cp; + TCHECK(bp->bp_op); + + printf("BOOTP/DHCP, %s", + tok2str(bootp_op_values, "unknown (0x%02x)", bp->bp_op)); + + if (bp->bp_htype == 1 && bp->bp_hlen == 6 && bp->bp_op == BOOTPREQUEST) { + TCHECK2(bp->bp_chaddr[0], 6); + printf(" from %s", etheraddr_string(bp->bp_chaddr)); + } + + printf(", length %u", length); + + if (!vflag) + return; + + TCHECK(bp->bp_secs); + + /* The usual hardware address type is 1 (10Mb Ethernet) */ + if (bp->bp_htype != 1) + printf(", htype %d", bp->bp_htype); + + /* The usual length for 10Mb Ethernet address is 6 bytes */ + if (bp->bp_htype != 1 || bp->bp_hlen != 6) + printf(", hlen %d", bp->bp_hlen); + + /* Only print interesting fields */ + if (bp->bp_hops) + printf(", hops %d", bp->bp_hops); + if (bp->bp_xid) + printf(", xid 0x%x", EXTRACT_32BITS(&bp->bp_xid)); + if (bp->bp_secs) + printf(", secs %d", EXTRACT_16BITS(&bp->bp_secs)); + + printf(", Flags [%s]", + bittok2str(bootp_flag_values, "none", EXTRACT_16BITS(&bp->bp_flags))); + if (vflag > 1) + printf(" (0x%04x)", EXTRACT_16BITS(&bp->bp_flags)); + + /* Client's ip address */ + TCHECK(bp->bp_ciaddr); + if (bp->bp_ciaddr.s_addr) + printf("\n\t Client-IP %s", ipaddr_string(&bp->bp_ciaddr)); + + /* 'your' ip address (bootp client) */ + TCHECK(bp->bp_yiaddr); + if (bp->bp_yiaddr.s_addr) + printf("\n\t Your-IP %s", ipaddr_string(&bp->bp_yiaddr)); + + /* Server's ip address */ + TCHECK(bp->bp_siaddr); + if (bp->bp_siaddr.s_addr) + printf("\n\t Server-IP %s", ipaddr_string(&bp->bp_siaddr)); + + /* Gateway's ip address */ + TCHECK(bp->bp_giaddr); + if (bp->bp_giaddr.s_addr) + printf("\n\t Gateway-IP %s", ipaddr_string(&bp->bp_giaddr)); + + /* Client's Ethernet address */ + if (bp->bp_htype == 1 && bp->bp_hlen == 6) { + TCHECK2(bp->bp_chaddr[0], 6); + printf("\n\t Client-Ethernet-Address %s", etheraddr_string(bp->bp_chaddr)); + } + + TCHECK2(bp->bp_sname[0], 1); /* check first char only */ + if (*bp->bp_sname) { + printf("\n\t sname \""); + if (fn_print(bp->bp_sname, snapend)) { + putchar('"'); + fputs(tstr + 1, stdout); + return; + } + putchar('"'); + } + TCHECK2(bp->bp_file[0], 1); /* check first char only */ + if (*bp->bp_file) { + printf("\n\t file \""); + if (fn_print(bp->bp_file, snapend)) { + putchar('"'); + fputs(tstr + 1, stdout); + return; + } + putchar('"'); + } + + /* Decode the vendor buffer */ + TCHECK(bp->bp_vend[0]); + if (memcmp((const char *)bp->bp_vend, vm_rfc1048, + sizeof(u_int32_t)) == 0) + rfc1048_print(bp->bp_vend); + else if (memcmp((const char *)bp->bp_vend, vm_cmu, + sizeof(u_int32_t)) == 0) + cmu_print(bp->bp_vend); + else { + u_int32_t ul; + + ul = EXTRACT_32BITS(&bp->bp_vend); + if (ul != 0) + printf("\n\t Vendor-#0x%x", ul); + } + + return; +trunc: + fputs(tstr, stdout); +} + +/* + * The first character specifies the format to print: + * i - ip address (32 bits) + * p - ip address pairs (32 bits + 32 bits) + * l - long (32 bits) + * L - unsigned long (32 bits) + * s - short (16 bits) + * b - period-seperated decimal bytes (variable length) + * x - colon-seperated hex bytes (variable length) + * a - ascii string (variable length) + * B - on/off (8 bits) + * $ - special (explicit code to handle) + */ +static struct tok tag2str[] = { +/* RFC1048 tags */ + { TAG_PAD, " PAD" }, + { TAG_SUBNET_MASK, "iSubnet-Mask" }, /* subnet mask (RFC950) */ + { TAG_TIME_OFFSET, "LTime-Zone" }, /* seconds from UTC */ + { TAG_GATEWAY, "iDefault-Gateway" }, /* default gateway */ + { TAG_TIME_SERVER, "iTime-Server" }, /* time servers (RFC868) */ + { TAG_NAME_SERVER, "iIEN-Name-Server" }, /* IEN name servers (IEN116) */ + { TAG_DOMAIN_SERVER, "iDomain-Name-Server" }, /* domain name (RFC1035) */ + { TAG_LOG_SERVER, "iLOG" }, /* MIT log servers */ + { TAG_COOKIE_SERVER, "iCS" }, /* cookie servers (RFC865) */ + { TAG_LPR_SERVER, "iLPR-Server" }, /* lpr server (RFC1179) */ + { TAG_IMPRESS_SERVER, "iIM" }, /* impress servers (Imagen) */ + { TAG_RLP_SERVER, "iRL" }, /* resource location (RFC887) */ + { TAG_HOSTNAME, "aHostname" }, /* ascii hostname */ + { TAG_BOOTSIZE, "sBS" }, /* 512 byte blocks */ + { TAG_END, " END" }, +/* RFC1497 tags */ + { TAG_DUMPPATH, "aDP" }, + { TAG_DOMAINNAME, "aDomain-Name" }, + { TAG_SWAP_SERVER, "iSS" }, + { TAG_ROOTPATH, "aRP" }, + { TAG_EXTPATH, "aEP" }, +/* RFC2132 tags */ + { TAG_IP_FORWARD, "BIPF" }, + { TAG_NL_SRCRT, "BSRT" }, + { TAG_PFILTERS, "pPF" }, + { TAG_REASS_SIZE, "sRSZ" }, + { TAG_DEF_TTL, "bTTL" }, + { TAG_MTU_TIMEOUT, "lMTU-Timeout" }, + { TAG_MTU_TABLE, "sMTU-Table" }, + { TAG_INT_MTU, "sMTU" }, + { TAG_LOCAL_SUBNETS, "BLSN" }, + { TAG_BROAD_ADDR, "iBR" }, + { TAG_DO_MASK_DISC, "BMD" }, + { TAG_SUPPLY_MASK, "BMS" }, + { TAG_DO_RDISC, "BRouter-Discovery" }, + { TAG_RTR_SOL_ADDR, "iRSA" }, + { TAG_STATIC_ROUTE, "pStatic-Route" }, + { TAG_USE_TRAILERS, "BUT" }, + { TAG_ARP_TIMEOUT, "lAT" }, + { TAG_ETH_ENCAP, "BIE" }, + { TAG_TCP_TTL, "bTT" }, + { TAG_TCP_KEEPALIVE, "lKI" }, + { TAG_KEEPALIVE_GO, "BKG" }, + { TAG_NIS_DOMAIN, "aYD" }, + { TAG_NIS_SERVERS, "iYS" }, + { TAG_NTP_SERVERS, "iNTP" }, + { TAG_VENDOR_OPTS, "bVendor-Option" }, + { TAG_NETBIOS_NS, "iNetbios-Name-Server" }, + { TAG_NETBIOS_DDS, "iWDD" }, + { TAG_NETBIOS_NODE, "$Netbios-Node" }, + { TAG_NETBIOS_SCOPE, "aNetbios-Scope" }, + { TAG_XWIN_FS, "iXFS" }, + { TAG_XWIN_DM, "iXDM" }, + { TAG_NIS_P_DOMAIN, "sN+D" }, + { TAG_NIS_P_SERVERS, "iN+S" }, + { TAG_MOBILE_HOME, "iMH" }, + { TAG_SMPT_SERVER, "iSMTP" }, + { TAG_POP3_SERVER, "iPOP3" }, + { TAG_NNTP_SERVER, "iNNTP" }, + { TAG_WWW_SERVER, "iWWW" }, + { TAG_FINGER_SERVER, "iFG" }, + { TAG_IRC_SERVER, "iIRC" }, + { TAG_STREETTALK_SRVR, "iSTS" }, + { TAG_STREETTALK_STDA, "iSTDA" }, + { TAG_REQUESTED_IP, "iRequested-IP" }, + { TAG_IP_LEASE, "lLease-Time" }, + { TAG_OPT_OVERLOAD, "$OO" }, + { TAG_TFTP_SERVER, "aTFTP" }, + { TAG_BOOTFILENAME, "aBF" }, + { TAG_DHCP_MESSAGE, " DHCP-Message" }, + { TAG_SERVER_ID, "iServer-ID" }, + { TAG_PARM_REQUEST, "bParameter-Request" }, + { TAG_MESSAGE, "aMSG" }, + { TAG_MAX_MSG_SIZE, "sMSZ" }, + { TAG_RENEWAL_TIME, "lRN" }, + { TAG_REBIND_TIME, "lRB" }, + { TAG_VENDOR_CLASS, "aVendor-Class" }, + { TAG_CLIENT_ID, "$Client-ID" }, +/* RFC 2485 */ + { TAG_OPEN_GROUP_UAP, "aUAP" }, +/* RFC 2563 */ + { TAG_DISABLE_AUTOCONF, "BNOAUTO" }, +/* RFC 2610 */ + { TAG_SLP_DA, "bSLP-DA" }, /*"b" is a little wrong */ + { TAG_SLP_SCOPE, "bSLP-SCOPE" }, /*"b" is a little wrong */ +/* RFC 2937 */ + { TAG_NS_SEARCH, "sNSSEARCH" }, /* XXX 's' */ +/* RFC 3011 */ + { TAG_IP4_SUBNET_SELECT, "iSUBNET" }, +/* RFC 3442 */ + { TAG_CLASSLESS_STATIC_RT, "$Classless-Static-Route" }, + { TAG_CLASSLESS_STA_RT_MS, "$Classless-Static-Route-Microsoft" }, +/* http://www.iana.org/assignments/bootp-dhcp-extensions/index.htm */ + { TAG_USER_CLASS, "aCLASS" }, + { TAG_SLP_NAMING_AUTH, "aSLP-NA" }, + { TAG_CLIENT_FQDN, "$FQDN" }, + { TAG_AGENT_CIRCUIT, "$Agent-Information" }, + { TAG_AGENT_REMOTE, "bARMT" }, + { TAG_AGENT_MASK, "bAMSK" }, + { TAG_TZ_STRING, "aTZSTR" }, + { TAG_FQDN_OPTION, "bFQDNS" }, /* XXX 'b' */ + { TAG_AUTH, "bAUTH" }, /* XXX 'b' */ + { TAG_VINES_SERVERS, "iVINES" }, + { TAG_SERVER_RANK, "sRANK" }, + { TAG_CLIENT_ARCH, "sARCH" }, + { TAG_CLIENT_NDI, "bNDI" }, /* XXX 'b' */ + { TAG_CLIENT_GUID, "bGUID" }, /* XXX 'b' */ + { TAG_LDAP_URL, "aLDAP" }, + { TAG_6OVER4, "i6o4" }, + { TAG_PRINTER_NAME, "aPRTR" }, + { TAG_MDHCP_SERVER, "bMDHCP" }, /* XXX 'b' */ + { TAG_IPX_COMPAT, "bIPX" }, /* XXX 'b' */ + { TAG_NETINFO_PARENT, "iNI" }, + { TAG_NETINFO_PARENT_TAG, "aNITAG" }, + { TAG_URL, "aURL" }, + { TAG_FAILOVER, "bFAIL" }, /* XXX 'b' */ + { 0, NULL } +}; +/* 2-byte extended tags */ +static struct tok xtag2str[] = { + { 0, NULL } +}; + +/* DHCP "options overload" types */ +static struct tok oo2str[] = { + { 1, "file" }, + { 2, "sname" }, + { 3, "file+sname" }, + { 0, NULL } +}; + +/* NETBIOS over TCP/IP node type options */ +static struct tok nbo2str[] = { + { 0x1, "b-node" }, + { 0x2, "p-node" }, + { 0x4, "m-node" }, + { 0x8, "h-node" }, + { 0, NULL } +}; + +/* ARP Hardware types, for Client-ID option */ +static struct tok arp2str[] = { + { 0x1, "ether" }, + { 0x6, "ieee802" }, + { 0x7, "arcnet" }, + { 0xf, "frelay" }, + { 0x17, "strip" }, + { 0x18, "ieee1394" }, + { 0, NULL } +}; + +static struct tok dhcp_msg_values[] = { + { DHCPDISCOVER, "Discover" }, + { DHCPOFFER, "Offer" }, + { DHCPREQUEST, "Request" }, + { DHCPDECLINE, "Decline" }, + { DHCPACK, "ACK" }, + { DHCPNAK, "NACK" }, + { DHCPRELEASE, "Release" }, + { DHCPINFORM, "Inform" }, + { 0, NULL } +}; + +#define AGENT_SUBOPTION_CIRCUIT_ID 1 /* RFC 3046 */ +#define AGENT_SUBOPTION_REMOTE_ID 2 /* RFC 3046 */ +#define AGENT_SUBOPTION_SUBSCRIBER_ID 6 /* RFC 3993 */ +static struct tok agent_suboption_values[] = { + { AGENT_SUBOPTION_CIRCUIT_ID, "Circuit-ID" }, + { AGENT_SUBOPTION_REMOTE_ID, "Remote-ID" }, + { AGENT_SUBOPTION_SUBSCRIBER_ID, "Subscriber-ID" }, + { 0, NULL } +}; + + +static void +rfc1048_print(register const u_char *bp) +{ + register u_int16_t tag; + register u_int len; + register const char *cp; + register char c; + int first, idx; + u_int32_t ul; + u_int16_t us; + u_int8_t uc, subopt, suboptlen; + + printf("\n\t Vendor-rfc1048 Extensions"); + + /* Step over magic cookie */ + printf("\n\t Magic Cookie 0x%08x", EXTRACT_32BITS(bp)); + bp += sizeof(int32_t); + + /* Loop while we there is a tag left in the buffer */ + while (TTEST2(*bp, 1)) { + tag = *bp++; + if (tag == TAG_PAD && vflag < 3) + continue; + if (tag == TAG_END && vflag < 3) + return; + if (tag == TAG_EXTENDED_OPTION) { + TCHECK2(*(bp + 1), 2); + tag = EXTRACT_16BITS(bp + 1); + /* XXX we don't know yet if the IANA will + * preclude overlap of 1-byte and 2-byte spaces. + * If not, we need to offset tag after this step. + */ + cp = tok2str(xtag2str, "?xT%u", tag); + } else + cp = tok2str(tag2str, "?T%u", tag); + c = *cp++; + + if (tag == TAG_PAD || tag == TAG_END) + len = 0; + else { + /* Get the length; check for truncation */ + TCHECK2(*bp, 1); + len = *bp++; + } + + printf("\n\t %s Option %u, length %u%s", cp, tag, len, + len > 0 ? ": " : ""); + + if (tag == TAG_PAD && vflag > 2) { + u_int ntag = 1; + while (TTEST2(*bp, 1) && *bp == TAG_PAD) { + bp++; + ntag++; + } + if (ntag > 1) + printf(", occurs %u", ntag); + } + + if (!TTEST2(*bp, len)) { + printf("[|rfc1048 %u]", len); + return; + } + + if (tag == TAG_DHCP_MESSAGE && len == 1) { + uc = *bp++; + printf("%s", tok2str(dhcp_msg_values, "Unknown (%u)", uc)); + continue; + } + + if (tag == TAG_PARM_REQUEST) { + idx = 0; + while (len-- > 0) { + uc = *bp++; + cp = tok2str(tag2str, "?Option %u", uc); + if (idx % 4 == 0) + printf("\n\t "); + else + printf(", "); + printf("%s", cp + 1); + idx++; + } + continue; + } + + if (tag == TAG_EXTENDED_REQUEST) { + first = 1; + while (len > 1) { + len -= 2; + us = EXTRACT_16BITS(bp); + bp += 2; + cp = tok2str(xtag2str, "?xT%u", us); + if (!first) + putchar('+'); + printf("%s", cp + 1); + first = 0; + } + continue; + } + + /* Print data */ + if (c == '?') { + /* Base default formats for unknown tags on data size */ + if (len & 1) + c = 'b'; + else if (len & 2) + c = 's'; + else + c = 'l'; + } + first = 1; + switch (c) { + + case 'a': + /* ascii strings */ + putchar('"'); + if (fn_printn(bp, len, snapend)) { + putchar('"'); + goto trunc; + } + putchar('"'); + bp += len; + len = 0; + break; + + case 'i': + case 'l': + case 'L': + /* ip addresses/32-bit words */ + while (len >= sizeof(ul)) { + if (!first) + putchar(','); + ul = EXTRACT_32BITS(bp); + if (c == 'i') { + ul = htonl(ul); + printf("%s", ipaddr_string(&ul)); + } else if (c == 'L') + printf("%d", ul); + else + printf("%u", ul); + bp += sizeof(ul); + len -= sizeof(ul); + first = 0; + } + break; + + case 'p': + /* IP address pairs */ + while (len >= 2*sizeof(ul)) { + if (!first) + putchar(','); + memcpy((char *)&ul, (const char *)bp, sizeof(ul)); + printf("(%s:", ipaddr_string(&ul)); + bp += sizeof(ul); + memcpy((char *)&ul, (const char *)bp, sizeof(ul)); + printf("%s)", ipaddr_string(&ul)); + bp += sizeof(ul); + len -= 2*sizeof(ul); + first = 0; + } + break; + + case 's': + /* shorts */ + while (len >= sizeof(us)) { + if (!first) + putchar(','); + us = EXTRACT_16BITS(bp); + printf("%u", us); + bp += sizeof(us); + len -= sizeof(us); + first = 0; + } + break; + + case 'B': + /* boolean */ + while (len > 0) { + if (!first) + putchar(','); + switch (*bp) { + case 0: + putchar('N'); + break; + case 1: + putchar('Y'); + break; + default: + printf("%u?", *bp); + break; + } + ++bp; + --len; + first = 0; + } + break; + + case 'b': + case 'x': + default: + /* Bytes */ + while (len > 0) { + if (!first) + putchar(c == 'x' ? ':' : '.'); + if (c == 'x') + printf("%02x", *bp); + else + printf("%u", *bp); + ++bp; + --len; + first = 0; + } + break; + + case '$': + /* Guys we can't handle with one of the usual cases */ + switch (tag) { + + case TAG_NETBIOS_NODE: + /* this option should be at least 1 byte long */ + if (len < 1) { + printf("ERROR: option %u len %u < 1 bytes", + TAG_NETBIOS_NODE, len); + break; + } + tag = *bp++; + --len; + fputs(tok2str(nbo2str, NULL, tag), stdout); + break; + + case TAG_OPT_OVERLOAD: + /* this option should be at least 1 byte long */ + if (len < 1) { + printf("ERROR: option %u len %u < 1 bytes", + TAG_OPT_OVERLOAD, len); + break; + } + tag = *bp++; + --len; + fputs(tok2str(oo2str, NULL, tag), stdout); + break; + + case TAG_CLIENT_FQDN: + /* this option should be at least 3 bytes long */ + if (len < 3) { + printf("ERROR: option %u len %u < 3 bytes", + TAG_CLIENT_FQDN, len); + bp += len; + len = 0; + break; + } + if (*bp) + printf("[%s] ", client_fqdn_flags(*bp)); + bp++; + if (*bp || *(bp+1)) + printf("%u/%u ", *bp, *(bp+1)); + bp += 2; + putchar('"'); + if (fn_printn(bp, len - 3, snapend)) { + putchar('"'); + goto trunc; + } + putchar('"'); + bp += len - 3; + len = 0; + break; + + case TAG_CLIENT_ID: + { int type; + + /* this option should be at least 1 byte long */ + if (len < 1) { + printf("ERROR: option %u len %u < 1 bytes", + TAG_CLIENT_ID, len); + break; + } + type = *bp++; + len--; + if (type == 0) { + putchar('"'); + if (fn_printn(bp, len, snapend)) { + putchar('"'); + goto trunc; + } + putchar('"'); + bp += len; + len = 0; + break; + } else { + printf("%s ", tok2str(arp2str, "hardware-type %u,", type)); + while (len > 0) { + if (!first) + putchar(':'); + printf("%02x", *bp); + ++bp; + --len; + first = 0; + } + } + break; + } + + case TAG_AGENT_CIRCUIT: + while (len >= 2) { + subopt = *bp++; + suboptlen = *bp++; + len -= 2; + if (suboptlen > len) { + printf("\n\t %s SubOption %u, length %u: length goes past end of option", + tok2str(agent_suboption_values, "Unknown", subopt), + subopt, + suboptlen); + bp += len; + len = 0; + break; + } + printf("\n\t %s SubOption %u, length %u: ", + tok2str(agent_suboption_values, "Unknown", subopt), + subopt, + suboptlen); + switch (subopt) { + + case AGENT_SUBOPTION_CIRCUIT_ID: /* fall through */ + case AGENT_SUBOPTION_REMOTE_ID: + case AGENT_SUBOPTION_SUBSCRIBER_ID: + fn_printn(bp, suboptlen, NULL); + break; + + default: + print_unknown_data(bp, "\n\t\t", suboptlen); + } + + len -= suboptlen; + bp += suboptlen; + } + break; + + case TAG_CLASSLESS_STATIC_RT: + case TAG_CLASSLESS_STA_RT_MS: + { + u_int mask_width, significant_octets, i; + + /* this option should be at least 5 bytes long */ + if (len < 5) { + printf("ERROR: option %u len %u < 5 bytes", + TAG_CLASSLESS_STATIC_RT, len); + bp += len; + len = 0; + break; + } + while (len > 0) { + if (!first) + putchar(','); + mask_width = *bp++; + len--; + /* mask_width <= 32 */ + if (mask_width > 32) { + printf("[ERROR: Mask width (%d) > 32]", mask_width); + bp += len; + len = 0; + break; + } + significant_octets = (mask_width + 7) / 8; + /* significant octets + router(4) */ + if (len < significant_octets + 4) { + printf("[ERROR: Remaining length (%u) < %u bytes]", len, significant_octets + 4); + bp += len; + len = 0; + break; + } + putchar('('); + if (mask_width == 0) + printf("default"); + else { + for (i = 0; i < significant_octets ; i++) { + if (i > 0) + putchar('.'); + printf("%d", *bp++); + } + for (i = significant_octets ; i < 4 ; i++) + printf(".0"); + printf("/%d", mask_width); + } + memcpy((char *)&ul, (const char *)bp, sizeof(ul)); + printf(":%s)", ipaddr_string(&ul)); + bp += sizeof(ul); + len -= (significant_octets + 4); + first = 0; + } + } + break; + + default: + printf("[unknown special tag %u, size %u]", + tag, len); + bp += len; + len = 0; + break; + } + break; + } + /* Data left over? */ + if (len) { + printf("\n\t trailing data length %u", len); + bp += len; + } + } + return; +trunc: + printf("|[rfc1048]"); +} + +static void +cmu_print(register const u_char *bp) +{ + register const struct cmu_vend *cmu; + +#define PRINTCMUADDR(m, s) { TCHECK(cmu->m); \ + if (cmu->m.s_addr != 0) \ + printf(" %s:%s", s, ipaddr_string(&cmu->m.s_addr)); } + + printf(" vend-cmu"); + cmu = (const struct cmu_vend *)bp; + + /* Only print if there are unknown bits */ + TCHECK(cmu->v_flags); + if ((cmu->v_flags & ~(VF_SMASK)) != 0) + printf(" F:0x%x", cmu->v_flags); + PRINTCMUADDR(v_dgate, "DG"); + PRINTCMUADDR(v_smask, cmu->v_flags & VF_SMASK ? "SM" : "SM*"); + PRINTCMUADDR(v_dns1, "NS1"); + PRINTCMUADDR(v_dns2, "NS2"); + PRINTCMUADDR(v_ins1, "IEN1"); + PRINTCMUADDR(v_ins2, "IEN2"); + PRINTCMUADDR(v_ts1, "TS1"); + PRINTCMUADDR(v_ts2, "TS2"); + return; + +trunc: + fputs(tstr, stdout); +#undef PRINTCMUADDR +} + +static char * +client_fqdn_flags(u_int flags) +{ + static char buf[8+1]; + int i = 0; + + if (flags & CLIENT_FQDN_FLAGS_S) + buf[i++] = 'S'; + if (flags & CLIENT_FQDN_FLAGS_O) + buf[i++] = 'O'; + if (flags & CLIENT_FQDN_FLAGS_E) + buf[i++] = 'E'; + if (flags & CLIENT_FQDN_FLAGS_N) + buf[i++] = 'N'; + buf[i] = '\0'; + + return buf; +}
diff --git a/tcpdump-4.3.0/print-bt.c b/tcpdump-4.3.0/print-bt.c new file mode 100644 index 0000000..259f3e5 --- /dev/null +++ b/tcpdump-4.3.0/print-bt.c
@@ -0,0 +1,79 @@ +/* + * Copyright (c) 2007 + * paolo.abeni@email.it 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 Paolo Abeni.'' + * The name of author may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-bt.c,v 1.2 2008-09-25 21:45:50 guy Exp $"; +#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 "extract.h" +#include "addrtoname.h" + +#if defined(DLT_BLUETOOTH_HCI_H4_WITH_PHDR) && defined(HAVE_PCAP_BLUETOOTH_H) +#include <pcap/bluetooth.h> + +#define BT_HDRLEN sizeof(pcap_bluetooth_h4_header) +/* + * This is the top level routine of the printer. 'p' points + * to the bluetooth header of the packet, 'h->ts' is the timestamp, + * 'h->len' is the length of the packet off the wire, and 'h->caplen' + * is the number of bytes actually captured. + */ +u_int +bt_if_print(const struct pcap_pkthdr *h, const u_char *p) +{ + u_int length = h->len; + u_int caplen = h->caplen; + const pcap_bluetooth_h4_header* hdr = (const pcap_bluetooth_h4_header*)p; + + if (caplen < BT_HDRLEN) { + printf("[|bt]"); + return (BT_HDRLEN); + } + caplen -= BT_HDRLEN; + length -= BT_HDRLEN; + p += BT_HDRLEN; + if (eflag) + (void)printf("hci length %d, direction %s, ", length, (EXTRACT_32BITS(&hdr->direction)&0x1)?"in":"out"); + + if (!suppress_default_print) + default_print(p, caplen); + + return (BT_HDRLEN); +} +#endif + + +/* + * Local Variables: + * c-style: whitesmith + * c-basic-offset: 8 + * End: + */
diff --git a/tcpdump-4.3.0/print-carp.c b/tcpdump-4.3.0/print-carp.c new file mode 100644 index 0000000..ba5be7c --- /dev/null +++ b/tcpdump-4.3.0/print-carp.c
@@ -0,0 +1,88 @@ +/* $OpenBSD: print-carp.c,v 1.6 2009/10/27 23:59:55 deraadt Exp $ */ + +/* + * Copyright (c) 2000 William C. Fenner. + * All rights reserved. + * + * Kevin Steves <ks@hp.se> July 2000 + * Modified to: + * - print version, type string and packet length + * - print IP address count if > 1 (-v) + * - verify checksum (-v) + * - print authentication string (-v) + * + * Copyright (c) 2011 Advanced Computing Technologies + * George V. Neille-Neil + * + * Modified to: + * - work correctly with CARP + * - compile into the latest tcpdump + * - print out the counter + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code + * distributions retain the above copyright notice and this paragraph + * in its entirety, and (2) distributions including binary code include + * the above copyright notice and this paragraph in its entirety in + * the documentation or other materials provided with the distribution. + * The name of William C. Fenner may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. THIS SOFTWARE IS PROVIDED ``AS IS'' AND + * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT + * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + */ + +#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" +#include "addrtoname.h" + +void +carp_print(register const u_char *bp, register u_int len, int ttl) +{ + int version, type; + const char *type_s; + + TCHECK(bp[0]); + version = (bp[0] & 0xf0) >> 4; + type = bp[0] & 0x0f; + if (type == 1) + type_s = "advertise"; + else + type_s = "unknown"; + printf("CARPv%d-%s %d: ", version, type_s, len); + if (ttl != 255) + printf("[ttl=%d!] ", ttl); + if (version != 2 || type != 1) + return; + TCHECK(bp[2]); + TCHECK(bp[5]); + printf("vhid=%d advbase=%d advskew=%d authlen=%d ", + bp[1], bp[5], bp[2], bp[3]); + if (vflag) { + struct cksum_vec vec[1]; + vec[0].ptr = (const u_int8_t *)bp; + vec[0].len = len; + if (TTEST2(bp[0], len) && in_cksum(vec, 1)) + printf(" (bad carp cksum %x!)", + EXTRACT_16BITS(&bp[6])); + } + printf("counter=%" PRIu64, EXTRACT_64BITS(&bp[8])); + + return; +trunc: + printf("[|carp]"); +}
diff --git a/tcpdump-4.3.0/print-cdp.c b/tcpdump-4.3.0/print-cdp.c new file mode 100644 index 0000000..7bc617a --- /dev/null +++ b/tcpdump-4.3.0/print-cdp.c
@@ -0,0 +1,379 @@ +/* + * Copyright (c) 1992, 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * Code by Gert Doering, SpaceNet GmbH, gert@space.net + * + * Reference documentation: + * http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/frames.htm + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-cdp.c,v 1.25 2004-10-07 14:53:11 hannes Exp $"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> +#include <string.h> + +#include "interface.h" +#include "addrtoname.h" +#include "extract.h" /* must come after interface.h */ +#include "nlpid.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 *pptr, u_int length, u_int caplen) +{ + int type, len, i, j; + const u_char *tptr; + + if (caplen < CDP_HEADER_LEN) { + (void)printf("[|cdp]"); + return; + } + + tptr = pptr; /* temporary pointer */ + + 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; + + while (tptr < (pptr+length)) { + + 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 (!TTEST2(*tptr, len)) + goto trunc; + + 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, + PLURAL_SUFFIX(len)); /* plural */ + + switch (type) { + + case 0x01: /* Device-ID */ + if (!vflag) + printf(", Device-ID "); + printf("'"); + fn_printn(tptr, len, NULL); + printf("'"); + break; + case 0x02: /* Address */ + if (cdp_print_addr(tptr, len) < 0) + goto trunc; + break; + case 0x03: /* Port-ID */ + printf("'"); + fn_printn(tptr, len, NULL); + printf("'"); + break; + case 0x04: /* Capabilities */ + printf("(0x%08x): %s", + EXTRACT_32BITS(tptr), + bittok2str(cdp_capability_values, "none",EXTRACT_32BITS(tptr))); + break; + 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: /* Platform */ + printf("'"); + fn_printn(tptr, len, NULL); + printf("'"); + break; + case 0x07: /* Prefixes */ + if (cdp_print_prefixes(tptr, len) < 0) + goto trunc; + break; + case 0x08: /* Protocol Hello Option - not documented */ + break; + case 0x09: /* VTP Mgmt Domain - not documented */ + printf("'"); + fn_printn(tptr, len, NULL); + printf("'"); + break; + case 0x0a: /* Native VLAN ID - not documented */ + printf("%d",EXTRACT_16BITS(tptr)); + break; + 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("'"); + fn_printn(tptr, len, NULL); + printf("'"); + break; + case 0x16: /* System Object ID - not documented */ + if (cdp_print_addr(tptr, len) < 0) + goto trunc; + break; + case 0x17: /* Physical Location - not documented */ + printf("0x%02x", *(tptr)); + if (len > 1) { + printf("/"); + fn_printn(tptr + 1, len - 1, NULL); + } + break; + default: + print_unknown_data(tptr,"\n\t ",len); + break; + } + } + /* avoid infinite loop */ + if (len == 0) + break; + tptr = tptr+len; + } + if (vflag < 1) + printf(", length %u",caplen); + + return; +trunc: + printf("[|cdp]"); +} + +/* + * Protocol type values. + * + * PT_NLPID means that the protocol type field contains an OSI NLPID. + * + * PT_IEEE_802_2 means that the protocol type field contains an IEEE 802.2 + * LLC header that specifies that the payload is for that protocol. + */ +#define PT_NLPID 1 /* OSI NLPID */ +#define PT_IEEE_802_2 2 /* IEEE 802.2 LLC header */ + +static int +cdp_print_addr(const u_char * p, int l) +{ + int pt, pl, al, num; + const u_char *endp = p + l; +#ifdef INET6 + static u_char prot_ipv6[] = { + 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00, 0x86, 0xdd + }; +#endif + + TCHECK2(*p, 2); + num = EXTRACT_32BITS(p); + p += 4; + + 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 */ + + if (pt == PT_NLPID && pl == 1 && *p == NLPID_IP && al == 4) { + /* + * IPv4: protocol type = NLPID, protocol length = 1 + * (1-byte NLPID), protocol = 0xcc (NLPID for IPv4), + * address length = 4 + */ + p += 3; + + TCHECK2(*p, 4); + if (p + 4 > endp) + goto trunc; + printf("IPv4 (%u) %s", + num, + ipaddr_string(p)); + p += 4; + } +#ifdef INET6 + else if (pt == PT_IEEE_802_2 && pl == 8 && + memcmp(p, prot_ipv6, 8) == 0 && al == 16) { + /* + * IPv6: protocol type = IEEE 802.2 header, + * protocol length = 8 (size of LLC+SNAP header), + * protocol = LLC+SNAP header with the IPv6 + * Ethertype, address length = 16 + */ + p += 10; + TCHECK2(*p, al); + if (p + al > endp) + goto trunc; + + printf("IPv6 (%u) %s", + num, + ip6addr_string(p)); + p += al; + } +#endif + else { + /* + * 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) + printf(" %02x", *p++); + } + num--; + if (num) + printf(" "); + } + + return 0; + +trunc: + return -1; +} + + +static int +cdp_print_prefixes(const u_char * p, int l) +{ + if (l % 5) + goto trunc; + + printf(" IPv4 Prefixes (%d):", l / 5); + + while (l > 0) { + printf(" %u.%u.%u.%u/%u", p[0], p[1], p[2], p[3], p[4]); + l -= 5; + p += 5; + } + + return 0; + +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/tcpdump-4.3.0/print-cfm.c b/tcpdump-4.3.0/print-cfm.c new file mode 100644 index 0000000..fb0476f --- /dev/null +++ b/tcpdump-4.3.0/print-cfm.c
@@ -0,0 +1,645 @@ +/* + * Copyright (c) 1998-2006 The TCPDUMP project + * + * 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. + * + * Support for the IEEE Connectivity Fault Management Protocols as per 802.1ag. + * + * Original code by Hannes Gredler (hannes@juniper.net) + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-cfm.c,v 1.5 2007-07-24 16:01:42 hannes 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 "ether.h" +#include "addrtoname.h" +#include "oui.h" +#include "af.h" + +/* + * Prototypes + */ +const char * cfm_egress_id_string(register const u_char *); +int cfm_mgmt_addr_print(register const u_char *); + +struct cfm_common_header_t { + u_int8_t mdlevel_version; + u_int8_t opcode; + u_int8_t flags; + u_int8_t first_tlv_offset; +}; + +#define CFM_VERSION 0 +#define CFM_EXTRACT_VERSION(x) (((x)&0x1f)) +#define CFM_EXTRACT_MD_LEVEL(x) (((x)&0xe0)>>5) + +#define CFM_OPCODE_CCM 1 +#define CFM_OPCODE_LBR 2 +#define CFM_OPCODE_LBM 3 +#define CFM_OPCODE_LTR 4 +#define CFM_OPCODE_LTM 5 + +static const struct tok cfm_opcode_values[] = { + { CFM_OPCODE_CCM, "Continouity Check Message"}, + { CFM_OPCODE_LBR, "Loopback Reply"}, + { CFM_OPCODE_LBM, "Loopback Message"}, + { CFM_OPCODE_LTR, "Linktrace Reply"}, + { CFM_OPCODE_LTM, "Linktrace Message"}, + { 0, NULL} +}; + +/* + * Message Formats. + */ +struct cfm_ccm_t { + u_int8_t sequence[4]; + u_int8_t ma_epi[2]; + u_int8_t md_nameformat; + u_int8_t md_namelength; + u_int8_t md_name[46]; /* md name and short ma name */ + u_int8_t reserved_itu[16]; + u_int8_t reserved[6]; +}; + +/* + * Timer Bases for the CCM Interval field. + * Expressed in units of seconds. + */ +const float ccm_interval_base[8] = {0, 0.003333, 0.01, 0.1, 1, 10, 60, 600}; +#define CCM_INTERVAL_MIN_MULTIPLIER 3.25 +#define CCM_INTERVAL_MAX_MULTIPLIER 3.5 + +#define CFM_CCM_RDI_FLAG 0x80 +#define CFM_EXTRACT_CCM_INTERVAL(x) (((x)&0x07)) + +#define CFM_CCM_MD_FORMAT_8021 0 +#define CFM_CCM_MD_FORMAT_NONE 1 +#define CFM_CCM_MD_FORMAT_DNS 2 +#define CFM_CCM_MD_FORMAT_MAC 3 +#define CFM_CCM_MD_FORMAT_CHAR 4 + +static const struct tok cfm_md_nameformat_values[] = { + { CFM_CCM_MD_FORMAT_8021, "IEEE 802.1"}, + { CFM_CCM_MD_FORMAT_NONE, "No MD Name present"}, + { CFM_CCM_MD_FORMAT_DNS, "DNS string"}, + { CFM_CCM_MD_FORMAT_MAC, "MAC + 16Bit Integer"}, + { CFM_CCM_MD_FORMAT_CHAR, "Character string"}, + { 0, NULL} +}; + +#define CFM_CCM_MA_FORMAT_8021 0 +#define CFM_CCM_MA_FORMAT_VID 1 +#define CFM_CCM_MA_FORMAT_CHAR 2 +#define CFM_CCM_MA_FORMAT_INT 3 +#define CFM_CCM_MA_FORMAT_VPN 4 + +static const struct tok cfm_ma_nameformat_values[] = { + { CFM_CCM_MA_FORMAT_8021, "IEEE 802.1"}, + { CFM_CCM_MA_FORMAT_VID, "Primary VID"}, + { CFM_CCM_MA_FORMAT_CHAR, "Character string"}, + { CFM_CCM_MA_FORMAT_INT, "16Bit Integer"}, + { CFM_CCM_MA_FORMAT_VPN, "RFC2685 VPN-ID"}, + { 0, NULL} +}; + +struct cfm_lbm_t { + u_int8_t transaction_id[4]; + u_int8_t reserved[4]; +}; + +struct cfm_ltm_t { + u_int8_t transaction_id[4]; + u_int8_t egress_id[8]; + u_int8_t ttl; + u_int8_t original_mac[ETHER_ADDR_LEN]; + u_int8_t target_mac[ETHER_ADDR_LEN]; + u_int8_t reserved[3]; +}; + +static const struct tok cfm_ltm_flag_values[] = { + { 0x80, "Use Forwarding-DB only"}, + { 0, NULL} +}; + +struct cfm_ltr_t { + u_int8_t transaction_id[4]; + u_int8_t last_egress_id[8]; + u_int8_t next_egress_id[8]; + u_int8_t ttl; + u_int8_t replay_action; + u_int8_t reserved[6]; +}; + +static const struct tok cfm_ltr_flag_values[] = { + { 0x80, "Forwarded"}, + { 0x40, "Terminal MEP"}, + { 0, NULL} +}; + +static const struct tok cfm_ltr_replay_action_values[] = { + { 1, "Exact Match"}, + { 2, "Filtering DB"}, + { 3, "MIP CCM DB"}, + { 0, NULL} +}; + + +#define CFM_TLV_END 0 +#define CFM_TLV_SENDER_ID 1 +#define CFM_TLV_PORT_STATUS 2 +#define CFM_TLV_INTERFACE_STATUS 3 +#define CFM_TLV_DATA 4 +#define CFM_TLV_REPLY_INGRESS 5 +#define CFM_TLV_REPLY_EGRESS 6 +#define CFM_TLV_PRIVATE 31 + +static const struct tok cfm_tlv_values[] = { + { CFM_TLV_END, "End"}, + { CFM_TLV_SENDER_ID, "Sender ID"}, + { CFM_TLV_PORT_STATUS, "Port status"}, + { CFM_TLV_INTERFACE_STATUS, "Interface status"}, + { CFM_TLV_DATA, "Data"}, + { CFM_TLV_REPLY_INGRESS, "Reply Ingress"}, + { CFM_TLV_REPLY_EGRESS, "Reply Egress"}, + { CFM_TLV_PRIVATE, "Organization Specific"}, + { 0, NULL} +}; + +/* + * TLVs + */ + +struct cfm_tlv_header_t { + u_int8_t type; + u_int8_t length[2]; +}; + +/* FIXME define TLV formats */ + +static const struct tok cfm_tlv_port_status_values[] = { + { 1, "Blocked"}, + { 2, "Up"}, + { 0, NULL} +}; + +static const struct tok cfm_tlv_interface_status_values[] = { + { 1, "Up"}, + { 2, "Down"}, + { 3, "Testing"}, + { 5, "Dormant"}, + { 6, "not present"}, + { 7, "lower Layer down"}, + { 0, NULL} +}; + +#define CFM_CHASSIS_ID_CHASSIS_COMPONENT 1 +#define CFM_CHASSIS_ID_INTERFACE_ALIAS 2 +#define CFM_CHASSIS_ID_PORT_COMPONENT 3 +#define CFM_CHASSIS_ID_MAC_ADDRESS 4 +#define CFM_CHASSIS_ID_NETWORK_ADDRESS 5 +#define CFM_CHASSIS_ID_INTERFACE_NAME 6 +#define CFM_CHASSIS_ID_LOCAL 7 + +static const struct tok cfm_tlv_senderid_chassisid_values[] = { + { 0, "Reserved"}, + { CFM_CHASSIS_ID_CHASSIS_COMPONENT, "Chassis component"}, + { CFM_CHASSIS_ID_INTERFACE_ALIAS, "Interface alias"}, + { CFM_CHASSIS_ID_PORT_COMPONENT, "Port component"}, + { CFM_CHASSIS_ID_MAC_ADDRESS, "MAC address"}, + { CFM_CHASSIS_ID_NETWORK_ADDRESS, "Network address"}, + { CFM_CHASSIS_ID_INTERFACE_NAME, "Interface name"}, + { CFM_CHASSIS_ID_LOCAL, "Locally assigned"}, + { 0, NULL} +}; + + +int +cfm_mgmt_addr_print(register const u_char *tptr) { + + u_int mgmt_addr_type; + u_int hexdump = FALSE; + + /* + * Altough AFIs are tpically 2 octects wide, + * 802.1ab specifies that this field width + * is only once octet + */ + mgmt_addr_type = *tptr; + printf("\n\t Management Address Type %s (%u)", + tok2str(af_values, "Unknown", mgmt_addr_type), + mgmt_addr_type); + + /* + * Resolve the passed in Address. + */ + switch(mgmt_addr_type) { + case AFNUM_INET: + printf(", %s", ipaddr_string(tptr + 1)); + break; + +#ifdef INET6 + case AFNUM_INET6: + printf(", %s", ip6addr_string(tptr + 1)); + break; +#endif + + default: + hexdump = TRUE; + break; + } + + return hexdump; +} + +/* + * The egress-ID string is a 16-Bit string plus a MAC address. + */ +const char * +cfm_egress_id_string(register const u_char *tptr) { + static char egress_id_buffer[80]; + + snprintf(egress_id_buffer, sizeof(egress_id_buffer), + "MAC %0x4x-%s", + EXTRACT_16BITS(tptr), + etheraddr_string(tptr+2)); + + return egress_id_buffer; +} + +void +cfm_print(register const u_char *pptr, register u_int length) { + + const struct cfm_common_header_t *cfm_common_header; + const struct cfm_tlv_header_t *cfm_tlv_header; + const u_int8_t *tptr, *tlv_ptr, *ma_name, *ma_nameformat, *ma_namelength; + u_int hexdump, tlen, cfm_tlv_len, cfm_tlv_type, ccm_interval; + + + union { + const struct cfm_ccm_t *cfm_ccm; + const struct cfm_lbm_t *cfm_lbm; + const struct cfm_ltm_t *cfm_ltm; + const struct cfm_ltr_t *cfm_ltr; + } msg_ptr; + + tptr=pptr; + cfm_common_header = (const struct cfm_common_header_t *)pptr; + TCHECK(*cfm_common_header); + + /* + * Sanity checking of the header. + */ + if (CFM_EXTRACT_VERSION(cfm_common_header->mdlevel_version) != CFM_VERSION) { + printf("CFMv%u not supported, length %u", + CFM_EXTRACT_VERSION(cfm_common_header->mdlevel_version), length); + return; + } + + printf("CFMv%u %s, MD Level %u, length %u", + CFM_EXTRACT_VERSION(cfm_common_header->mdlevel_version), + tok2str(cfm_opcode_values, "unknown (%u)", cfm_common_header->opcode), + CFM_EXTRACT_MD_LEVEL(cfm_common_header->mdlevel_version), + length); + + /* + * In non-verbose mode just print the opcode and md-level. + */ + if (vflag < 1) { + return; + } + + printf("\n\tFirst TLV offset %u", cfm_common_header->first_tlv_offset); + + tptr += sizeof(const struct cfm_common_header_t); + tlen = length - sizeof(struct cfm_common_header_t); + + switch (cfm_common_header->opcode) { + case CFM_OPCODE_CCM: + msg_ptr.cfm_ccm = (const struct cfm_ccm_t *)tptr; + + ccm_interval = CFM_EXTRACT_CCM_INTERVAL(cfm_common_header->flags); + printf(", Flags [CCM Interval %u%s]", + ccm_interval, + cfm_common_header->flags & CFM_CCM_RDI_FLAG ? + ", RDI" : ""); + + /* + * Resolve the CCM interval field. + */ + if (ccm_interval) { + printf("\n\t CCM Interval %.3fs" + ", min CCM Lifetime %.3fs, max CCM Lifetime %.3fs", + ccm_interval_base[ccm_interval], + ccm_interval_base[ccm_interval] * CCM_INTERVAL_MIN_MULTIPLIER, + ccm_interval_base[ccm_interval] * CCM_INTERVAL_MAX_MULTIPLIER); + } + + printf("\n\t Sequence Number 0x%08x, MA-End-Point-ID 0x%04x", + EXTRACT_32BITS(msg_ptr.cfm_ccm->sequence), + EXTRACT_16BITS(msg_ptr.cfm_ccm->ma_epi)); + + + /* + * Resolve the MD fields. + */ + printf("\n\t MD Name Format %s (%u), MD Name length %u", + tok2str(cfm_md_nameformat_values, "Unknown", + msg_ptr.cfm_ccm->md_nameformat), + msg_ptr.cfm_ccm->md_nameformat, + msg_ptr.cfm_ccm->md_namelength); + + if (msg_ptr.cfm_ccm->md_nameformat != CFM_CCM_MD_FORMAT_NONE) { + printf("\n\t MD Name: "); + switch (msg_ptr.cfm_ccm->md_nameformat) { + case CFM_CCM_MD_FORMAT_DNS: + case CFM_CCM_MD_FORMAT_CHAR: + safeputs((const char *)msg_ptr.cfm_ccm->md_name, msg_ptr.cfm_ccm->md_namelength); + break; + + case CFM_CCM_MD_FORMAT_MAC: + printf("\n\t MAC %s", etheraddr_string( + msg_ptr.cfm_ccm->md_name)); + break; + + /* FIXME add printers for those MD formats - hexdump for now */ + case CFM_CCM_MA_FORMAT_8021: + default: + print_unknown_data(msg_ptr.cfm_ccm->md_name, "\n\t ", + msg_ptr.cfm_ccm->md_namelength); + } + } + + + /* + * Resolve the MA fields. + */ + ma_nameformat = msg_ptr.cfm_ccm->md_name + msg_ptr.cfm_ccm->md_namelength; + ma_namelength = msg_ptr.cfm_ccm->md_name + msg_ptr.cfm_ccm->md_namelength + 1; + ma_name = msg_ptr.cfm_ccm->md_name + msg_ptr.cfm_ccm->md_namelength + 2; + + printf("\n\t MA Name-Format %s (%u), MA name length %u", + tok2str(cfm_ma_nameformat_values, "Unknown", + *ma_nameformat), + *ma_nameformat, + *ma_namelength); + + printf("\n\t MA Name: "); + switch (*ma_nameformat) { + case CFM_CCM_MA_FORMAT_CHAR: + safeputs((const char *)ma_name, *ma_namelength); + break; + + /* FIXME add printers for those MA formats - hexdump for now */ + case CFM_CCM_MA_FORMAT_8021: + case CFM_CCM_MA_FORMAT_VID: + case CFM_CCM_MA_FORMAT_INT: + case CFM_CCM_MA_FORMAT_VPN: + default: + print_unknown_data(ma_name, "\n\t ", *ma_namelength); + } + break; + + case CFM_OPCODE_LTM: + msg_ptr.cfm_ltm = (const struct cfm_ltm_t *)tptr; + + printf(", Flags [%s]", + bittok2str(cfm_ltm_flag_values, "none", cfm_common_header->flags)); + + printf("\n\t Transaction-ID 0x%08x, Egress-ID %s, ttl %u", + EXTRACT_32BITS(msg_ptr.cfm_ltm->transaction_id), + cfm_egress_id_string(msg_ptr.cfm_ltm->egress_id), + msg_ptr.cfm_ltm->ttl); + + printf("\n\t Original-MAC %s, Target-MAC %s", + etheraddr_string(msg_ptr.cfm_ltm->original_mac), + etheraddr_string(msg_ptr.cfm_ltm->target_mac)); + break; + + case CFM_OPCODE_LTR: + msg_ptr.cfm_ltr = (const struct cfm_ltr_t *)tptr; + + printf(", Flags [%s]", + bittok2str(cfm_ltr_flag_values, "none", cfm_common_header->flags)); + + printf("\n\t Transaction-ID 0x%08x, Last-Egress-ID %s", + EXTRACT_32BITS(msg_ptr.cfm_ltr->transaction_id), + cfm_egress_id_string(msg_ptr.cfm_ltr->last_egress_id)); + + printf("\n\t Next-Egress-ID %s, ttl %u", + cfm_egress_id_string(msg_ptr.cfm_ltr->next_egress_id), + msg_ptr.cfm_ltr->ttl); + + printf("\n\t Replay-Action %s (%u)", + tok2str(cfm_ltr_replay_action_values, + "Unknown", + msg_ptr.cfm_ltr->replay_action), + msg_ptr.cfm_ltr->replay_action); + break; + + /* + * No message decoder yet. + * Hexdump everything up until the start of the TLVs + */ + case CFM_OPCODE_LBR: + case CFM_OPCODE_LBM: + default: + if (tlen > cfm_common_header->first_tlv_offset) { + print_unknown_data(tptr, "\n\t ", + tlen - cfm_common_header->first_tlv_offset); + } + break; + } + + /* + * Sanity check for not walking off. + */ + if (tlen <= cfm_common_header->first_tlv_offset) { + return; + } + + tptr += cfm_common_header->first_tlv_offset; + tlen -= cfm_common_header->first_tlv_offset; + + while (tlen > 0) { + cfm_tlv_header = (const struct cfm_tlv_header_t *)tptr; + + /* Enough to read the tlv type ? */ + TCHECK2(*tptr, 1); + cfm_tlv_type=cfm_tlv_header->type; + + if (cfm_tlv_type != CFM_TLV_END) { + /* did we capture enough for fully decoding the object header ? */ + TCHECK2(*tptr, sizeof(struct cfm_tlv_header_t)); + cfm_tlv_len=EXTRACT_16BITS(&cfm_tlv_header->length); + } else { + cfm_tlv_len = 0; + } + + printf("\n\t%s TLV (0x%02x), length %u", + tok2str(cfm_tlv_values, "Unknown", cfm_tlv_type), + cfm_tlv_type, + cfm_tlv_len); + + /* sanity check for not walking off and infinite loop check. */ + if ((cfm_tlv_type != CFM_TLV_END) && + ((cfm_tlv_len + sizeof(struct cfm_tlv_header_t) > tlen) || + (!cfm_tlv_len))) { + print_unknown_data(tptr,"\n\t ",tlen); + return; + } + + tptr += sizeof(struct cfm_tlv_header_t); + tlen -= sizeof(struct cfm_tlv_header_t); + tlv_ptr = tptr; + + /* did we capture enough for fully decoding the object ? */ + if (cfm_tlv_type != CFM_TLV_END) { + TCHECK2(*tptr, cfm_tlv_len); + } + hexdump = FALSE; + + switch(cfm_tlv_type) { + case CFM_TLV_END: + /* we are done - bail out */ + return; + + case CFM_TLV_PORT_STATUS: + printf(", Status: %s (%u)", + tok2str(cfm_tlv_port_status_values, "Unknown", *tptr), + *tptr); + break; + + case CFM_TLV_INTERFACE_STATUS: + printf(", Status: %s (%u)", + tok2str(cfm_tlv_interface_status_values, "Unknown", *tptr), + *tptr); + break; + + case CFM_TLV_PRIVATE: + printf(", Vendor: %s (%u), Sub-Type %u", + tok2str(oui_values,"Unknown", EXTRACT_24BITS(tptr)), + EXTRACT_24BITS(tptr), + *(tptr+3)); + hexdump = TRUE; + break; + + case CFM_TLV_SENDER_ID: + { + u_int chassis_id_type, chassis_id_length; + u_int mgmt_addr_length; + + /* + * Check if there is a Chassis-ID. + */ + chassis_id_length = *tptr; + if (chassis_id_length > tlen) { + hexdump = TRUE; + break; + } + + tptr++; + tlen--; + + if (chassis_id_length) { + chassis_id_type = *tptr; + printf("\n\t Chassis-ID Type %s (%u), Chassis-ID length %u", + tok2str(cfm_tlv_senderid_chassisid_values, + "Unknown", + chassis_id_type), + chassis_id_type, + chassis_id_length); + + switch (chassis_id_type) { + case CFM_CHASSIS_ID_MAC_ADDRESS: + printf("\n\t MAC %s", etheraddr_string(tptr+1)); + break; + + case CFM_CHASSIS_ID_NETWORK_ADDRESS: + hexdump |= cfm_mgmt_addr_print(tptr); + break; + + case CFM_CHASSIS_ID_INTERFACE_NAME: /* fall through */ + case CFM_CHASSIS_ID_INTERFACE_ALIAS: + case CFM_CHASSIS_ID_LOCAL: + case CFM_CHASSIS_ID_CHASSIS_COMPONENT: + case CFM_CHASSIS_ID_PORT_COMPONENT: + safeputs((const char *)tptr+1, chassis_id_length); + break; + + default: + hexdump = TRUE; + break; + } + } + + tptr += chassis_id_length; + tlen -= chassis_id_length; + + /* + * Check if there is a Management Address. + */ + mgmt_addr_length = *tptr; + if (mgmt_addr_length > tlen) { + hexdump = TRUE; + break; + } + + tptr++; + tlen--; + + if (mgmt_addr_length) { + hexdump |= cfm_mgmt_addr_print(tptr); + } + + tptr += mgmt_addr_length; + tlen -= mgmt_addr_length; + + } + break; + + /* + * FIXME those are the defined TLVs that lack a decoder + * you are welcome to contribute code ;-) + */ + + case CFM_TLV_DATA: + case CFM_TLV_REPLY_INGRESS: + case CFM_TLV_REPLY_EGRESS: + default: + hexdump = TRUE; + break; + } + /* do we want to see an additional hexdump ? */ + if (hexdump || vflag > 1) + print_unknown_data(tlv_ptr, "\n\t ", cfm_tlv_len); + + tptr+=cfm_tlv_len; + tlen-=cfm_tlv_len; + } + return; +trunc: + printf("\n\t\t packet exceeded snapshot"); +}
diff --git a/tcpdump-4.3.0/print-chdlc.c b/tcpdump-4.3.0/print-chdlc.c new file mode 100644 index 0000000..261b15a --- /dev/null +++ b/tcpdump-4.3.0/print-chdlc.c
@@ -0,0 +1,215 @@ +/* + * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.43 2005-11-29 08:56:19 hannes Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <pcap.h> +#include <stdio.h> + +#include "interface.h" +#include "addrtoname.h" +#include "ethertype.h" +#include "extract.h" +#include "ppp.h" +#include "chdlc.h" + +static void chdlc_slarp_print(const u_char *, u_int); + +const struct tok chdlc_cast_values[] = { + { CHDLC_UNICAST, "unicast" }, + { CHDLC_BCAST, "bcast" }, + { 0, NULL} +}; + + +/* Standard CHDLC printer */ +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; + + if (caplen < CHDLC_HDRLEN) { + printf("[|chdlc]"); + return (caplen); + } + return (chdlc_print(p,length)); +} + +u_int +chdlc_print(register const u_char *p, u_int length) { + u_int proto; + + proto = EXTRACT_16BITS(&p[2]); + if (eflag) { + printf("%s, ethertype %s (0x%04x), length %u: ", + tok2str(chdlc_cast_values, "0x%02x", p[0]), + tok2str(ethertype_values, "Unknown", proto), + proto, + length); + } + + length -= CHDLC_HDRLEN; + p += CHDLC_HDRLEN; + + switch (proto) { + case ETHERTYPE_IP: + ip_print(gndo, p, length); + break; +#ifdef INET6 + case ETHERTYPE_IPV6: + ip6_print(gndo, p, length); + break; +#endif + case CHDLC_TYPE_SLARP: + chdlc_slarp_print(p, length); + break; +#if 0 + case CHDLC_TYPE_CDP: + chdlc_cdp_print(p, length); + break; +#endif + case ETHERTYPE_MPLS: + case ETHERTYPE_MPLS_MULTI: + mpls_print(p, length); + break; + case ETHERTYPE_ISO: + /* is the fudge byte set ? lets verify by spotting ISO headers */ + if (*(p+1) == 0x81 || + *(p+1) == 0x82 || + *(p+1) == 0x83) + isoclns_print(p+1, length-1, length-1); + else + isoclns_print(p, length, length); + break; + default: + if (!eflag) + printf("unknown CHDLC protocol (0x%04x)", proto); + break; + } + + return (CHDLC_HDRLEN); +} + +/* + * The fixed-length portion of a SLARP packet. + */ +struct cisco_slarp { + u_int8_t code[4]; +#define SLARP_REQUEST 0 +#define SLARP_REPLY 1 +#define SLARP_KEEPALIVE 2 + union { + struct { + u_int8_t addr[4]; + u_int8_t mask[4]; + } addr; + struct { + u_int8_t myseq[4]; + u_int8_t yourseq[4]; + u_int8_t rel[2]; + } keep; + } un; +}; + +#define SLARP_MIN_LEN 14 +#define SLARP_MAX_LEN 18 + +static void +chdlc_slarp_print(const u_char *cp, u_int length) +{ + const struct cisco_slarp *slarp; + u_int sec,min,hrs,days; + + printf("SLARP (length: %u), ",length); + if (length < SLARP_MIN_LEN) + goto trunc; + + slarp = (const struct cisco_slarp *)cp; + TCHECK2(*slarp, SLARP_MIN_LEN); + switch (EXTRACT_32BITS(&slarp->code)) { + case SLARP_REQUEST: + printf("request"); + /* + * At least according to William "Chops" Westfield's + * message in + * + * http://www.nethelp.no/net/cisco-hdlc.txt + * + * the address and mask aren't used in requests - + * they're just zero. + */ + break; + case SLARP_REPLY: + printf("reply %s/%s", + ipaddr_string(&slarp->un.addr.addr), + ipaddr_string(&slarp->un.addr.mask)); + break; + case SLARP_KEEPALIVE: + printf("keepalive: mineseen=0x%08x, yourseen=0x%08x, reliability=0x%04x", + EXTRACT_32BITS(&slarp->un.keep.myseq), + EXTRACT_32BITS(&slarp->un.keep.yourseq), + EXTRACT_16BITS(&slarp->un.keep.rel)); + + if (length >= SLARP_MAX_LEN) { /* uptime-stamp is optional */ + cp += SLARP_MIN_LEN; + if (!TTEST2(*cp, 4)) + goto trunc; + sec = EXTRACT_32BITS(cp) / 1000; + min = sec / 60; sec -= min * 60; + hrs = min / 60; min -= hrs * 60; + days = hrs / 24; hrs -= days * 24; + printf(", link uptime=%ud%uh%um%us",days,hrs,min,sec); + } + break; + default: + printf("0x%02x unknown", EXTRACT_32BITS(&slarp->code)); + if (vflag <= 1) + print_unknown_data(cp+4,"\n\t",length-4); + break; + } + + if (SLARP_MAX_LEN < length && vflag) + printf(", (trailing junk: %d bytes)", length - SLARP_MAX_LEN); + if (vflag > 1) + print_unknown_data(cp+4,"\n\t",length-4); + return; + +trunc: + printf("[|slarp]"); +} + + +/* + * Local Variables: + * c-style: whitesmith + * c-basic-offset: 8 + * End: + */
diff --git a/tcpdump-4.3.0/print-cip.c b/tcpdump-4.3.0/print-cip.c new file mode 100644 index 0000000..e9d672f --- /dev/null +++ b/tcpdump-4.3.0/print-cip.c
@@ -0,0 +1,116 @@ +/* + * Marko Kiiskila carnil@cs.tut.fi + * + * Tampere University of Technology - Telecommunications Laboratory + * + * Permission to use, copy, modify and distribute this + * software and its documentation is hereby granted, + * provided that both the copyright notice and this + * permission notice appear in all copies of the software, + * derivative works or modified versions, and any portions + * thereof, that both notices appear in supporting + * 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[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-cip.c,v 1.26 2005-07-07 01:22:17 guy Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <string.h> + +#include <tcpdump-stdinc.h> + +#include <stdio.h> +#include <pcap.h> + +#include "interface.h" +#include "addrtoname.h" +#include "ethertype.h" +#include "ether.h" + +#define RFC1483LLC_LEN 8 + +static unsigned char rfcllc[] = { + 0xaa, /* DSAP: non-ISO */ + 0xaa, /* SSAP: non-ISO */ + 0x03, /* Ctrl: Unnumbered Information Command PDU */ + 0x00, /* OUI: EtherType */ + 0x00, + 0x00 }; + +static inline void +cip_print(int length) +{ + /* + * There is no MAC-layer header, so just print the length. + */ + printf("%d: ", length); +} + +/* + * 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->len' is the length of the packet off the wire, and 'h->caplen' + * is the number of bytes actually captured. + */ +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; + + if (memcmp(rfcllc, p, sizeof(rfcllc))==0 && caplen < RFC1483LLC_LEN) { + printf("[|cip]"); + return (0); + } + + if (eflag) + cip_print(length); + + if (memcmp(rfcllc, p, sizeof(rfcllc)) == 0) { + /* + * LLC header is present. Try to print it & higher layers. + */ + if (llc_print(p, length, caplen, NULL, NULL, + &extracted_ethertype) == 0) { + /* ether_type not known, print raw packet */ + if (!eflag) + cip_print(length); + if (extracted_ethertype) { + printf("(LLC %s) ", + etherproto_string(htons(extracted_ethertype))); + } + if (!suppress_default_print) + default_print(p, caplen); + } + } else { + /* + * LLC header is absent; treat it as just IP. + */ + ip_print(gndo, p, length); + } + + return (0); +} + + +/* + * Local Variables: + * c-style: whitesmith + * c-basic-offset: 8 + * End: + */
diff --git a/tcpdump-4.3.0/print-cnfp.c b/tcpdump-4.3.0/print-cnfp.c new file mode 100644 index 0000000..86d7128 --- /dev/null +++ b/tcpdump-4.3.0/print-cnfp.c
@@ -0,0 +1,190 @@ +/* $OpenBSD: print-cnfp.c,v 1.2 1998/06/25 20:26:59 mickey Exp $ */ + +/* + * Copyright (c) 1998 Michael Shalayeff + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Michael Shalayeff. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* Cisco NetFlow protocol */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-cnfp.c,v 1.17 2005-04-20 20:53:18 guy Exp $"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#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 */ + u_int32_t msys_uptime; + u_int32_t utc_sec; + u_int32_t utc_nsec; + u_int32_t sequence; /* v5 flow sequence number */ + u_int32_t reserved; /* v5 only */ +}; + +struct nfrec { + struct in_addr src_ina; + struct in_addr dst_ina; + struct in_addr nhop_ina; + u_int32_t ifaces; /* src,dst ifaces */ + u_int32_t packets; + u_int32_t octets; + u_int32_t start_time; /* sys_uptime value */ + u_int32_t last_time; /* sys_uptime value */ + u_int32_t ports; /* src,dst ports */ + u_int32_t proto_tos; /* proto, tos, pad, flags(v5) */ + u_int32_t asses; /* v1: flags; v5: src,dst AS */ + u_int32_t masks; /* src,dst addr prefix; v6: encaps */ + struct in_addr peer_nexthop; /* v6: IP address of the nexthop within the peer (FIB)*/ +}; + +void +cnfp_print(const u_char *cp, const u_char *bp _U_) +{ + register const struct nfhdr *nh; + register const struct nfrec *nr; + struct protoent *pent; + int nrecs, ver; +#if 0 + time_t t; +#endif + + nh = (const struct nfhdr *)cp; + + if ((const u_char *)(nh + 1) > snapend) + return; + + nrecs = EXTRACT_32BITS(&nh->ver_cnt) & 0xffff; + ver = (EXTRACT_32BITS(&nh->ver_cnt) & 0xffff0000) >> 16; +#if 0 + /* + * This is seconds since the UN*X epoch, and is followed by + * nanoseconds. XXX - format it, rather than just dumping the + * raw seconds-since-the-Epoch. + */ + t = EXTRACT_32BITS(&nh->utc_sec); +#endif + + printf("NetFlow v%x, %u.%03u uptime, %u.%09u, ", ver, + 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, ", EXTRACT_32BITS(&nh->sequence)); + nr = (const struct nfrec *)&nh[1]; + snaplen -= 24; + } else { + nr = (const struct nfrec *)&nh->sequence; + snaplen -= 16; + } + + printf("%2u recs", nrecs); + + for (; nrecs-- && (const u_char *)(nr + 1) <= snapend; nr++) { + char buf[20]; + char asbuf[20]; + + printf("\n started %u.%03u, last %u.%03u", + 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", + (EXTRACT_32BITS(&nr->masks) >> 24) & 0xff); + snprintf(asbuf, sizeof(asbuf), ":%u", + (EXTRACT_32BITS(&nr->asses) >> 16) & 0xffff); + } + 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", + (EXTRACT_32BITS(&nr->masks) >> 16) & 0xff); + snprintf(asbuf, sizeof(asbuf), ":%u", + EXTRACT_32BITS(&nr->asses) & 0xffff); + } + printf("> %s%s%s:%u ", intoa(nr->dst_ina.s_addr), buf, asbuf, + EXTRACT_32BITS(&nr->ports) & 0xffff); + + printf(">> %s\n ", intoa(nr->nhop_ina.s_addr)); + + pent = getprotobynumber((EXTRACT_32BITS(&nr->proto_tos) >> 8) & 0xff); + if (!pent || nflag) + printf("%u ", + (EXTRACT_32BITS(&nr->proto_tos) >> 8) & 0xff); + else + printf("%s ", pent->p_name); + + /* tcp flags for tcp only */ + if (pent && pent->p_proto == IPPROTO_TCP) { + int flags; + if (ver == 1) + flags = (EXTRACT_32BITS(&nr->asses) >> 24) & 0xff; + else + 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'); + if (flags & TH_PUSH) putchar('P'); + if (flags & TH_ACK) putchar('A'); + if (flags & TH_URG) putchar('U'); + if (flags) + putchar(' '); + } + + buf[0]='\0'; + if (ver == 6) { + snprintf(buf, sizeof(buf), "(%u<>%u encaps)", + (EXTRACT_32BITS(&nr->masks) >> 8) & 0xff, + (EXTRACT_32BITS(&nr->masks)) & 0xff); + } + printf("tos %u, %u (%u octets) %s", + EXTRACT_32BITS(&nr->proto_tos) & 0xff, + EXTRACT_32BITS(&nr->packets), + EXTRACT_32BITS(&nr->octets), buf); + } +}
diff --git a/tcpdump-4.3.0/print-dccp.c b/tcpdump-4.3.0/print-dccp.c new file mode 100644 index 0000000..79ea5f7 --- /dev/null +++ b/tcpdump-4.3.0/print-dccp.c
@@ -0,0 +1,464 @@ +/* + * Copyright (C) Arnaldo Carvalho de Melo 2004 + * Copyright (C) Ian McDonald 2005 + * Copyright (C) Yoshifumi Nishida 2005 + * + * This software may be distributed either under the terms of the + * BSD-style license that accompanies tcpdump or the GNU GPL version 2 + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-dccp.c,v 1.8 2007-11-09 00:44:09 guy Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include "dccp.h" + +#include <stdio.h> +#include <string.h> + +#include "interface.h" +#include "addrtoname.h" +#include "extract.h" /* must come after interface.h */ +#include "ip.h" +#ifdef INET6 +#include "ip6.h" +#endif +#include "ipproto.h" + +static const char *dccp_reset_codes[] = { + "unspecified", + "closed", + "aborted", + "no_connection", + "packet_error", + "option_error", + "mandatory_error", + "connection_refused", + "bad_service_code", + "too_busy", + "bad_init_cookie", + "aggression_penalty", +}; + +static const char *dccp_feature_nums[] = { + "reserved", + "ccid", + "allow_short_seqno", + "sequence_window", + "ecn_incapable", + "ack_ratio", + "send_ack_vector", + "send_ndp_count", + "minimum checksum coverage", + "check data checksum", +}; + +static inline u_int dccp_csum_coverage(const struct dccp_hdr* dh, u_int len) +{ + u_int cov; + + if (DCCPH_CSCOV(dh) == 0) + return len; + cov = (dh->dccph_doff + DCCPH_CSCOV(dh) - 1) * sizeof(u_int32_t); + return (cov > len)? len : cov; +} + +static int dccp_cksum(const struct ip *ip, + const struct dccp_hdr *dh, u_int len) +{ + return nextproto4_cksum(ip, (const u_int8_t *)(void *)dh, + dccp_csum_coverage(dh, len), IPPROTO_DCCP); +} + +#ifdef INET6 +static int dccp6_cksum(const struct ip6_hdr *ip6, const struct dccp_hdr *dh, u_int len) +{ + return nextproto6_cksum(ip6, (const u_int8_t *)(void *)dh, + dccp_csum_coverage(dh, len), IPPROTO_DCCP); +} +#endif + +static const char *dccp_reset_code(u_int8_t code) +{ + if (code >= __DCCP_RESET_CODE_LAST) + return "invalid"; + return dccp_reset_codes[code]; +} + +static u_int64_t dccp_seqno(const struct dccp_hdr *dh) +{ + u_int32_t seq_high = DCCPH_SEQ(dh); + u_int64_t seqno = EXTRACT_24BITS(&seq_high) & 0xFFFFFF; + + if (DCCPH_X(dh) != 0) { + const struct dccp_hdr_ext *dhx = (void *)(dh + 1); + u_int32_t seq_low = dhx->dccph_seq_low; + seqno &= 0x00FFFF; /* clear reserved field */ + seqno = (seqno << 32) + EXTRACT_32BITS(&seq_low); + } + + return seqno; +} + +static inline unsigned int dccp_basic_hdr_len(const struct dccp_hdr *dh) +{ + return sizeof(*dh) + (DCCPH_X(dh) ? sizeof(struct dccp_hdr_ext) : 0); +} + +static void dccp_print_ack_no(const u_char *bp) +{ + const struct dccp_hdr *dh = (const struct dccp_hdr *)bp; + const struct dccp_hdr_ack_bits *dh_ack = + (struct dccp_hdr_ack_bits *)(bp + dccp_basic_hdr_len(dh)); + u_int32_t ack_high; + u_int64_t ackno; + + TCHECK2(*dh_ack,4); + ack_high = DCCPH_ACK(dh_ack); + ackno = EXTRACT_24BITS(&ack_high) & 0xFFFFFF; + + if (DCCPH_X(dh) != 0) { + u_int32_t ack_low; + + TCHECK2(*dh_ack,8); + ack_low = dh_ack->dccph_ack_nr_low; + + ackno &= 0x00FFFF; /* clear reserved field */ + ackno = (ackno << 32) + EXTRACT_32BITS(&ack_low); + } + + (void)printf("(ack=%" PRIu64 ") ", ackno); +trunc: + return; +} + +static inline unsigned int dccp_packet_hdr_len(const u_int8_t type) +{ + if (type == DCCP_PKT_DATA) + return 0; + if (type == DCCP_PKT_DATAACK || + type == DCCP_PKT_ACK || + type == DCCP_PKT_SYNC || + type == DCCP_PKT_SYNCACK || + type == DCCP_PKT_CLOSE || + type == DCCP_PKT_CLOSEREQ) + return sizeof(struct dccp_hdr_ack_bits); + if (type == DCCP_PKT_REQUEST) + return sizeof(struct dccp_hdr_request); + if (type == DCCP_PKT_RESPONSE) + return sizeof(struct dccp_hdr_response); + return sizeof(struct dccp_hdr_reset); +} + +static int dccp_print_option(const u_char *option); + +/** + * dccp_print - show dccp packet + * @bp - beginning of dccp packet + * @data2 - beginning of enclosing + * @len - lenght of ip packet + */ +void dccp_print(const u_char *bp, const u_char *data2, u_int len) +{ + const struct dccp_hdr *dh; + const struct ip *ip; +#ifdef INET6 + const struct ip6_hdr *ip6; +#endif + const u_char *cp; + u_short sport, dport; + u_int hlen; + u_int extlen = 0; + + dh = (const struct dccp_hdr *)bp; + + ip = (struct ip *)data2; +#ifdef INET6 + if (IP_V(ip) == 6) + ip6 = (const struct ip6_hdr *)data2; + else + ip6 = NULL; +#endif /*INET6*/ + cp = (const u_char *)(dh + 1); + if (cp > snapend) { + printf("[Invalid packet|dccp]"); + return; + } + + if (len < sizeof(struct dccp_hdr)) { + printf("truncated-dccp - %ld bytes missing!", + (long)len - sizeof(struct dccp_hdr)); + return; + } + + sport = EXTRACT_16BITS(&dh->dccph_sport); + dport = EXTRACT_16BITS(&dh->dccph_dport); + hlen = dh->dccph_doff * 4; + +#ifdef INET6 + if (ip6) { + (void)printf("%s.%d > %s.%d: ", + ip6addr_string(&ip6->ip6_src), sport, + ip6addr_string(&ip6->ip6_dst), dport); + } else +#endif /*INET6*/ + { + (void)printf("%s.%d > %s.%d: ", + ipaddr_string(&ip->ip_src), sport, + ipaddr_string(&ip->ip_dst), dport); + } + fflush(stdout); + + if (qflag) { + (void)printf(" %d", len - hlen); + if (hlen > len) { + (void)printf("dccp [bad hdr length %u - too long, > %u]", + hlen, len); + } + return; + } + + /* other variables in generic header */ + if (vflag) { + (void)printf("CCVal %d, CsCov %d, ", DCCPH_CCVAL(dh), DCCPH_CSCOV(dh)); + } + + /* checksum calculation */ + if (vflag && TTEST2(bp[0], len)) { + u_int16_t sum = 0, dccp_sum; + + dccp_sum = EXTRACT_16BITS(&dh->dccph_checksum); + (void)printf("cksum 0x%04x ", dccp_sum); + if (IP_V(ip) == 4) + sum = dccp_cksum(ip, dh, len); +#ifdef INET6 + else if (IP_V(ip) == 6) + sum = dccp6_cksum(ip6, dh, len); +#endif + if (sum != 0) + (void)printf("(incorrect -> 0x%04x), ",in_cksum_shouldbe(dccp_sum, sum)); + else + (void)printf("(correct), "); + } + + switch (DCCPH_TYPE(dh)) { + case DCCP_PKT_REQUEST: { + struct dccp_hdr_request *dhr = + (struct dccp_hdr_request *)(bp + dccp_basic_hdr_len(dh)); + TCHECK(*dhr); + (void)printf("request (service=%d) ", + EXTRACT_32BITS(&dhr->dccph_req_service)); + extlen += 4; + break; + } + case DCCP_PKT_RESPONSE: { + struct dccp_hdr_response *dhr = + (struct dccp_hdr_response *)(bp + dccp_basic_hdr_len(dh)); + TCHECK(*dhr); + (void)printf("response (service=%d) ", + EXTRACT_32BITS(&dhr->dccph_resp_service)); + extlen += 12; + break; + } + case DCCP_PKT_DATA: + (void)printf("data "); + break; + case DCCP_PKT_ACK: { + (void)printf("ack "); + extlen += 8; + break; + } + case DCCP_PKT_DATAACK: { + (void)printf("dataack "); + extlen += 8; + break; + } + case DCCP_PKT_CLOSEREQ: + (void)printf("closereq "); + extlen += 8; + break; + case DCCP_PKT_CLOSE: + (void)printf("close "); + extlen += 8; + break; + case DCCP_PKT_RESET: { + struct dccp_hdr_reset *dhr = + (struct dccp_hdr_reset *)(bp + dccp_basic_hdr_len(dh)); + TCHECK(*dhr); + (void)printf("reset (code=%s) ", + dccp_reset_code(dhr->dccph_reset_code)); + extlen += 12; + break; + } + case DCCP_PKT_SYNC: + (void)printf("sync "); + extlen += 8; + break; + case DCCP_PKT_SYNCACK: + (void)printf("syncack "); + extlen += 8; + break; + default: + (void)printf("invalid "); + break; + } + + if ((DCCPH_TYPE(dh) != DCCP_PKT_DATA) && + (DCCPH_TYPE(dh) != DCCP_PKT_REQUEST)) + dccp_print_ack_no(bp); + + if (vflag < 2) + return; + + (void)printf("seq %" PRIu64, dccp_seqno(dh)); + + /* process options */ + if (hlen > dccp_basic_hdr_len(dh) + extlen){ + const u_char *cp; + u_int optlen; + cp = bp + dccp_basic_hdr_len(dh) + extlen; + printf(" <"); + + hlen -= dccp_basic_hdr_len(dh) + extlen; + while(1){ + TCHECK(*cp); + optlen = dccp_print_option(cp); + if (!optlen) goto trunc2; + if (hlen <= optlen) break; + hlen -= optlen; + cp += optlen; + printf(", "); + } + printf(">"); + } + return; +trunc: + printf("[|dccp]"); +trunc2: + return; +} + +static int dccp_print_option(const u_char *option) +{ + u_int8_t optlen, i; + + TCHECK(*option); + + if (*option >= 32) { + TCHECK(*(option+1)); + optlen = *(option +1); + if (optlen < 2) { + printf("Option %d optlen too short",*option); + return 1; + } + } else optlen = 1; + + TCHECK2(*option,optlen); + + switch (*option){ + case 0: + printf("nop"); + break; + case 1: + printf("mandatory"); + break; + case 2: + printf("slowreceiver"); + break; + case 32: + printf("change_l"); + if (*(option +2) < 10){ + printf(" %s", dccp_feature_nums[*(option +2)]); + for (i = 0; i < optlen -3; i ++) printf(" %d", *(option +3 + i)); + } + break; + case 33: + printf("confirm_l"); + if (*(option +2) < 10){ + printf(" %s", dccp_feature_nums[*(option +2)]); + for (i = 0; i < optlen -3; i ++) printf(" %d", *(option +3 + i)); + } + break; + case 34: + printf("change_r"); + if (*(option +2) < 10){ + printf(" %s", dccp_feature_nums[*(option +2)]); + for (i = 0; i < optlen -3; i ++) printf(" %d", *(option +3 + i)); + } + break; + case 35: + printf("confirm_r"); + if (*(option +2) < 10){ + printf(" %s", dccp_feature_nums[*(option +2)]); + for (i = 0; i < optlen -3; i ++) printf(" %d", *(option +3 + i)); + } + break; + case 36: + printf("initcookie 0x"); + for (i = 0; i < optlen -2; i ++) printf("%02x", *(option +2 + i)); + break; + case 37: + printf("ndp_count"); + for (i = 0; i < optlen -2; i ++) printf(" %d", *(option +2 + i)); + break; + case 38: + printf("ack_vector0 0x"); + for (i = 0; i < optlen -2; i ++) printf("%02x", *(option +2 + i)); + break; + case 39: + printf("ack_vector1 0x"); + for (i = 0; i < optlen -2; i ++) printf("%02x", *(option +2 + i)); + break; + case 40: + printf("data_dropped 0x"); + for (i = 0; i < optlen -2; i ++) printf("%02x", *(option +2 + i)); + break; + case 41: + printf("timestamp %u", EXTRACT_32BITS(option + 2)); + break; + case 42: + printf("timestamp_echo %u", EXTRACT_32BITS(option + 2)); + break; + case 43: + printf("elapsed_time "); + if (optlen == 6) + printf("%u", EXTRACT_32BITS(option + 2)); + else + printf("%u", EXTRACT_16BITS(option + 2)); + break; + case 44: + printf("data_checksum "); + for (i = 0; i < optlen -2; i ++) printf("%02x", *(option +2 + i)); + break; + default : + if (*option >= 128) { + printf("CCID option %d",*option); + switch (optlen) { + case 4: + printf(" %u", EXTRACT_16BITS(option + 2)); + break; + case 6: + printf(" %u", EXTRACT_32BITS(option + 2)); + break; + default: + break; + } + break; + } + + printf("unknown_opt %d", *option); + break; + } + + return optlen; +trunc: + printf("[|dccp]"); + return 0; +}
diff --git a/tcpdump-4.3.0/print-decnet.c b/tcpdump-4.3.0/print-decnet.c new file mode 100644 index 0000000..7fea582 --- /dev/null +++ b/tcpdump-4.3.0/print-decnet.c
@@ -0,0 +1,895 @@ +/* + * Copyright (c) 1992, 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-decnet.c,v 1.39 2005-05-06 02:16:26 guy Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +struct mbuf; +struct rtentry; + +#ifdef HAVE_NETDNET_DNETDB_H +#include <netdnet/dnetdb.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "decnet.h" +#include "extract.h" +#include "interface.h" +#include "addrtoname.h" + +/* Forwards */ +static int print_decnet_ctlmsg(const union routehdr *, u_int, u_int); +static void print_t_info(int); +static int print_l1_routes(const char *, u_int); +static int print_l2_routes(const char *, u_int); +static void print_i_info(int); +static int print_elist(const char *, u_int); +static int print_nsp(const u_char *, u_int); +static void print_reason(int); +#ifdef PRINT_NSPDATA +static void pdata(u_char *, int); +#endif + +#ifndef HAVE_NETDNET_DNETDB_H_DNET_HTOA +extern char *dnet_htoa(struct dn_naddr *); +#endif + +void +decnet_print(register const u_char *ap, register u_int length, + register u_int caplen) +{ + register const union routehdr *rhp; + register int mflags; + int dst, src, hops; + u_int nsplen, pktlen; + const u_char *nspp; + + if (length < sizeof(struct shorthdr)) { + (void)printf("[|decnet]"); + return; + } + + TCHECK2(*ap, sizeof(short)); + pktlen = EXTRACT_LE_16BITS(ap); + if (pktlen < sizeof(struct shorthdr)) { + (void)printf("[|decnet]"); + return; + } + if (pktlen > length) { + (void)printf("[|decnet]"); + return; + } + length = pktlen; + + rhp = (const union routehdr *)&(ap[sizeof(short)]); + TCHECK(rhp->rh_short.sh_flags); + mflags = EXTRACT_LE_8BITS(rhp->rh_short.sh_flags); + + if (mflags & RMF_PAD) { + /* pad bytes of some sort in front of message */ + u_int padlen = mflags & RMF_PADMASK; + if (vflag) + (void) printf("[pad:%d] ", padlen); + if (length < padlen + 2) { + (void)printf("[|decnet]"); + return; + } + TCHECK2(ap[sizeof(short)], padlen); + ap += padlen; + length -= padlen; + caplen -= padlen; + rhp = (const union routehdr *)&(ap[sizeof(short)]); + mflags = EXTRACT_LE_8BITS(rhp->rh_short.sh_flags); + } + + if (mflags & RMF_FVER) { + (void) printf("future-version-decnet"); + default_print(ap, min(length, caplen)); + return; + } + + /* is it a control message? */ + if (mflags & RMF_CTLMSG) { + if (!print_decnet_ctlmsg(rhp, length, caplen)) + goto trunc; + return; + } + + switch (mflags & RMF_MASK) { + case RMF_LONG: + if (length < sizeof(struct longhdr)) { + (void)printf("[|decnet]"); + return; + } + TCHECK(rhp->rh_long); + dst = + EXTRACT_LE_16BITS(rhp->rh_long.lg_dst.dne_remote.dne_nodeaddr); + src = + EXTRACT_LE_16BITS(rhp->rh_long.lg_src.dne_remote.dne_nodeaddr); + hops = EXTRACT_LE_8BITS(rhp->rh_long.lg_visits); + nspp = &(ap[sizeof(short) + sizeof(struct longhdr)]); + nsplen = length - sizeof(struct longhdr); + break; + case RMF_SHORT: + TCHECK(rhp->rh_short); + dst = EXTRACT_LE_16BITS(rhp->rh_short.sh_dst); + src = EXTRACT_LE_16BITS(rhp->rh_short.sh_src); + hops = (EXTRACT_LE_8BITS(rhp->rh_short.sh_visits) & VIS_MASK)+1; + nspp = &(ap[sizeof(short) + sizeof(struct shorthdr)]); + nsplen = length - sizeof(struct shorthdr); + break; + default: + (void) printf("unknown message flags under mask"); + default_print((u_char *)ap, min(length, caplen)); + return; + } + + (void)printf("%s > %s %d ", + dnaddr_string(src), dnaddr_string(dst), pktlen); + if (vflag) { + if (mflags & RMF_RQR) + (void)printf("RQR "); + if (mflags & RMF_RTS) + (void)printf("RTS "); + if (mflags & RMF_IE) + (void)printf("IE "); + (void)printf("%d hops ", hops); + } + + if (!print_nsp(nspp, nsplen)) + goto trunc; + return; + +trunc: + (void)printf("[|decnet]"); + return; +} + +static int +print_decnet_ctlmsg(register const union routehdr *rhp, u_int length, + u_int caplen) +{ + int mflags = EXTRACT_LE_8BITS(rhp->rh_short.sh_flags); + register union controlmsg *cmp = (union controlmsg *)rhp; + int src, dst, info, blksize, eco, ueco, hello, other, vers; + etheraddr srcea, rtea; + int priority; + char *rhpx = (char *)rhp; + int ret; + + switch (mflags & RMF_CTLMASK) { + case RMF_INIT: + (void)printf("init "); + if (length < sizeof(struct initmsg)) + goto trunc; + TCHECK(cmp->cm_init); + src = EXTRACT_LE_16BITS(cmp->cm_init.in_src); + info = EXTRACT_LE_8BITS(cmp->cm_init.in_info); + blksize = EXTRACT_LE_16BITS(cmp->cm_init.in_blksize); + vers = EXTRACT_LE_8BITS(cmp->cm_init.in_vers); + eco = EXTRACT_LE_8BITS(cmp->cm_init.in_eco); + ueco = EXTRACT_LE_8BITS(cmp->cm_init.in_ueco); + hello = EXTRACT_LE_16BITS(cmp->cm_init.in_hello); + print_t_info(info); + (void)printf( + "src %sblksize %d vers %d eco %d ueco %d hello %d", + dnaddr_string(src), blksize, vers, eco, ueco, + hello); + ret = 1; + break; + case RMF_VER: + (void)printf("verification "); + if (length < sizeof(struct verifmsg)) + goto trunc; + TCHECK(cmp->cm_ver); + src = EXTRACT_LE_16BITS(cmp->cm_ver.ve_src); + other = EXTRACT_LE_8BITS(cmp->cm_ver.ve_fcnval); + (void)printf("src %s fcnval %o", dnaddr_string(src), other); + ret = 1; + break; + case RMF_TEST: + (void)printf("test "); + if (length < sizeof(struct testmsg)) + goto trunc; + TCHECK(cmp->cm_test); + src = EXTRACT_LE_16BITS(cmp->cm_test.te_src); + other = EXTRACT_LE_8BITS(cmp->cm_test.te_data); + (void)printf("src %s data %o", dnaddr_string(src), other); + ret = 1; + break; + case RMF_L1ROUT: + (void)printf("lev-1-routing "); + if (length < sizeof(struct l1rout)) + goto trunc; + TCHECK(cmp->cm_l1rou); + src = EXTRACT_LE_16BITS(cmp->cm_l1rou.r1_src); + (void)printf("src %s ", dnaddr_string(src)); + ret = print_l1_routes(&(rhpx[sizeof(struct l1rout)]), + length - sizeof(struct l1rout)); + break; + case RMF_L2ROUT: + (void)printf("lev-2-routing "); + if (length < sizeof(struct l2rout)) + goto trunc; + TCHECK(cmp->cm_l2rout); + src = EXTRACT_LE_16BITS(cmp->cm_l2rout.r2_src); + (void)printf("src %s ", dnaddr_string(src)); + ret = print_l2_routes(&(rhpx[sizeof(struct l2rout)]), + length - sizeof(struct l2rout)); + break; + case RMF_RHELLO: + (void)printf("router-hello "); + if (length < sizeof(struct rhellomsg)) + goto trunc; + TCHECK(cmp->cm_rhello); + vers = EXTRACT_LE_8BITS(cmp->cm_rhello.rh_vers); + eco = EXTRACT_LE_8BITS(cmp->cm_rhello.rh_eco); + ueco = EXTRACT_LE_8BITS(cmp->cm_rhello.rh_ueco); + memcpy((char *)&srcea, (char *)&(cmp->cm_rhello.rh_src), + sizeof(srcea)); + src = EXTRACT_LE_16BITS(srcea.dne_remote.dne_nodeaddr); + info = EXTRACT_LE_8BITS(cmp->cm_rhello.rh_info); + blksize = EXTRACT_LE_16BITS(cmp->cm_rhello.rh_blksize); + priority = EXTRACT_LE_8BITS(cmp->cm_rhello.rh_priority); + hello = EXTRACT_LE_16BITS(cmp->cm_rhello.rh_hello); + print_i_info(info); + (void)printf( + "vers %d eco %d ueco %d src %s blksize %d pri %d hello %d", + vers, eco, ueco, dnaddr_string(src), + blksize, priority, hello); + ret = print_elist(&(rhpx[sizeof(struct rhellomsg)]), + length - sizeof(struct rhellomsg)); + break; + case RMF_EHELLO: + (void)printf("endnode-hello "); + if (length < sizeof(struct ehellomsg)) + goto trunc; + TCHECK(cmp->cm_ehello); + vers = EXTRACT_LE_8BITS(cmp->cm_ehello.eh_vers); + eco = EXTRACT_LE_8BITS(cmp->cm_ehello.eh_eco); + ueco = EXTRACT_LE_8BITS(cmp->cm_ehello.eh_ueco); + memcpy((char *)&srcea, (char *)&(cmp->cm_ehello.eh_src), + sizeof(srcea)); + src = EXTRACT_LE_16BITS(srcea.dne_remote.dne_nodeaddr); + info = EXTRACT_LE_8BITS(cmp->cm_ehello.eh_info); + blksize = EXTRACT_LE_16BITS(cmp->cm_ehello.eh_blksize); + /*seed*/ + memcpy((char *)&rtea, (char *)&(cmp->cm_ehello.eh_router), + sizeof(rtea)); + dst = EXTRACT_LE_16BITS(rtea.dne_remote.dne_nodeaddr); + hello = EXTRACT_LE_16BITS(cmp->cm_ehello.eh_hello); + other = EXTRACT_LE_8BITS(cmp->cm_ehello.eh_data); + print_i_info(info); + (void)printf( + "vers %d eco %d ueco %d src %s blksize %d rtr %s hello %d data %o", + vers, eco, ueco, dnaddr_string(src), + blksize, dnaddr_string(dst), hello, other); + ret = 1; + break; + + default: + (void)printf("unknown control message"); + default_print((u_char *)rhp, min(length, caplen)); + ret = 1; + break; + } + return (ret); + +trunc: + return (0); +} + +static void +print_t_info(int info) +{ + int ntype = info & 3; + switch (ntype) { + case 0: (void)printf("reserved-ntype? "); break; + case TI_L2ROUT: (void)printf("l2rout "); break; + case TI_L1ROUT: (void)printf("l1rout "); break; + case TI_ENDNODE: (void)printf("endnode "); break; + } + if (info & TI_VERIF) + (void)printf("verif "); + if (info & TI_BLOCK) + (void)printf("blo "); +} + +static int +print_l1_routes(const char *rp, u_int len) +{ + int count; + int id; + int info; + + /* The last short is a checksum */ + while (len > (3 * sizeof(short))) { + TCHECK2(*rp, 3 * sizeof(short)); + count = EXTRACT_LE_16BITS(rp); + if (count > 1024) + return (1); /* seems to be bogus from here on */ + rp += sizeof(short); + len -= sizeof(short); + id = EXTRACT_LE_16BITS(rp); + rp += sizeof(short); + len -= sizeof(short); + info = EXTRACT_LE_16BITS(rp); + rp += sizeof(short); + len -= sizeof(short); + (void)printf("{ids %d-%d cost %d hops %d} ", id, id + count, + RI_COST(info), RI_HOPS(info)); + } + return (1); + +trunc: + return (0); +} + +static int +print_l2_routes(const char *rp, u_int len) +{ + int count; + int area; + int info; + + /* The last short is a checksum */ + while (len > (3 * sizeof(short))) { + TCHECK2(*rp, 3 * sizeof(short)); + count = EXTRACT_LE_16BITS(rp); + if (count > 1024) + return (1); /* seems to be bogus from here on */ + rp += sizeof(short); + len -= sizeof(short); + area = EXTRACT_LE_16BITS(rp); + rp += sizeof(short); + len -= sizeof(short); + info = EXTRACT_LE_16BITS(rp); + rp += sizeof(short); + len -= sizeof(short); + (void)printf("{areas %d-%d cost %d hops %d} ", area, area + count, + RI_COST(info), RI_HOPS(info)); + } + return (1); + +trunc: + return (0); +} + +static void +print_i_info(int info) +{ + int ntype = info & II_TYPEMASK; + switch (ntype) { + case 0: (void)printf("reserved-ntype? "); break; + case II_L2ROUT: (void)printf("l2rout "); break; + case II_L1ROUT: (void)printf("l1rout "); break; + case II_ENDNODE: (void)printf("endnode "); break; + } + if (info & II_VERIF) + (void)printf("verif "); + if (info & II_NOMCAST) + (void)printf("nomcast "); + if (info & II_BLOCK) + (void)printf("blo "); +} + +static int +print_elist(const char *elp _U_, u_int len _U_) +{ + /* Not enough examples available for me to debug this */ + return (1); +} + +static int +print_nsp(const u_char *nspp, u_int nsplen) +{ + const struct nsphdr *nsphp = (struct nsphdr *)nspp; + int dst, src, flags; + + if (nsplen < sizeof(struct nsphdr)) + goto trunc; + TCHECK(*nsphp); + flags = EXTRACT_LE_8BITS(nsphp->nh_flags); + dst = EXTRACT_LE_16BITS(nsphp->nh_dst); + src = EXTRACT_LE_16BITS(nsphp->nh_src); + + switch (flags & NSP_TYPEMASK) { + case MFT_DATA: + switch (flags & NSP_SUBMASK) { + case MFS_BOM: + case MFS_MOM: + case MFS_EOM: + case MFS_BOM+MFS_EOM: + printf("data %d>%d ", src, dst); + { + struct seghdr *shp = (struct seghdr *)nspp; + int ack; +#ifdef PRINT_NSPDATA + u_char *dp; +#endif + u_int data_off = sizeof(struct minseghdr); + + if (nsplen < data_off) + goto trunc; + TCHECK(shp->sh_seq[0]); + ack = EXTRACT_LE_16BITS(shp->sh_seq[0]); + if (ack & SGQ_ACK) { /* acknum field */ + if ((ack & SGQ_NAK) == SGQ_NAK) + (void)printf("nak %d ", ack & SGQ_MASK); + else + (void)printf("ack %d ", ack & SGQ_MASK); + data_off += sizeof(short); + if (nsplen < data_off) + goto trunc; + TCHECK(shp->sh_seq[1]); + ack = EXTRACT_LE_16BITS(shp->sh_seq[1]); + if (ack & SGQ_OACK) { /* ackoth field */ + if ((ack & SGQ_ONAK) == SGQ_ONAK) + (void)printf("onak %d ", ack & SGQ_MASK); + else + (void)printf("oack %d ", ack & SGQ_MASK); + data_off += sizeof(short); + if (nsplen < data_off) + goto trunc; + TCHECK(shp->sh_seq[2]); + ack = EXTRACT_LE_16BITS(shp->sh_seq[2]); + } + } + (void)printf("seg %d ", ack & SGQ_MASK); +#ifdef PRINT_NSPDATA + if (nsplen > data_off) { + dp = &(nspp[data_off]); + TCHECK2(*dp, nsplen - data_off); + pdata(dp, nsplen - data_off); + } +#endif + } + break; + case MFS_ILS+MFS_INT: + printf("intr "); + { + struct seghdr *shp = (struct seghdr *)nspp; + int ack; +#ifdef PRINT_NSPDATA + u_char *dp; +#endif + u_int data_off = sizeof(struct minseghdr); + + if (nsplen < data_off) + goto trunc; + TCHECK(shp->sh_seq[0]); + ack = EXTRACT_LE_16BITS(shp->sh_seq[0]); + if (ack & SGQ_ACK) { /* acknum field */ + if ((ack & SGQ_NAK) == SGQ_NAK) + (void)printf("nak %d ", ack & SGQ_MASK); + else + (void)printf("ack %d ", ack & SGQ_MASK); + data_off += sizeof(short); + if (nsplen < data_off) + goto trunc; + TCHECK(shp->sh_seq[1]); + ack = EXTRACT_LE_16BITS(shp->sh_seq[1]); + if (ack & SGQ_OACK) { /* ackdat field */ + if ((ack & SGQ_ONAK) == SGQ_ONAK) + (void)printf("nakdat %d ", ack & SGQ_MASK); + else + (void)printf("ackdat %d ", ack & SGQ_MASK); + data_off += sizeof(short); + if (nsplen < data_off) + goto trunc; + TCHECK(shp->sh_seq[2]); + ack = EXTRACT_LE_16BITS(shp->sh_seq[2]); + } + } + (void)printf("seg %d ", ack & SGQ_MASK); +#ifdef PRINT_NSPDATA + if (nsplen > data_off) { + dp = &(nspp[data_off]); + TCHECK2(*dp, nsplen - data_off); + pdata(dp, nsplen - data_off); + } +#endif + } + break; + case MFS_ILS: + (void)printf("link-service %d>%d ", src, dst); + { + struct seghdr *shp = (struct seghdr *)nspp; + struct lsmsg *lsmp = + (struct lsmsg *)&(nspp[sizeof(struct seghdr)]); + int ack; + int lsflags, fcval; + + if (nsplen < sizeof(struct seghdr) + sizeof(struct lsmsg)) + goto trunc; + TCHECK(shp->sh_seq[0]); + ack = EXTRACT_LE_16BITS(shp->sh_seq[0]); + if (ack & SGQ_ACK) { /* acknum field */ + if ((ack & SGQ_NAK) == SGQ_NAK) + (void)printf("nak %d ", ack & SGQ_MASK); + else + (void)printf("ack %d ", ack & SGQ_MASK); + TCHECK(shp->sh_seq[1]); + ack = EXTRACT_LE_16BITS(shp->sh_seq[1]); + if (ack & SGQ_OACK) { /* ackdat field */ + if ((ack & SGQ_ONAK) == SGQ_ONAK) + (void)printf("nakdat %d ", ack & SGQ_MASK); + else + (void)printf("ackdat %d ", ack & SGQ_MASK); + TCHECK(shp->sh_seq[2]); + ack = EXTRACT_LE_16BITS(shp->sh_seq[2]); + } + } + (void)printf("seg %d ", ack & SGQ_MASK); + TCHECK(*lsmp); + lsflags = EXTRACT_LE_8BITS(lsmp->ls_lsflags); + fcval = EXTRACT_LE_8BITS(lsmp->ls_fcval); + switch (lsflags & LSI_MASK) { + case LSI_DATA: + (void)printf("dat seg count %d ", fcval); + switch (lsflags & LSM_MASK) { + case LSM_NOCHANGE: + break; + case LSM_DONOTSEND: + (void)printf("donotsend-data "); + break; + case LSM_SEND: + (void)printf("send-data "); + break; + default: + (void)printf("reserved-fcmod? %x", lsflags); + break; + } + break; + case LSI_INTR: + (void)printf("intr req count %d ", fcval); + break; + default: + (void)printf("reserved-fcval-int? %x", lsflags); + break; + } + } + break; + default: + (void)printf("reserved-subtype? %x %d > %d", flags, src, dst); + break; + } + break; + case MFT_ACK: + switch (flags & NSP_SUBMASK) { + case MFS_DACK: + (void)printf("data-ack %d>%d ", src, dst); + { + struct ackmsg *amp = (struct ackmsg *)nspp; + int ack; + + if (nsplen < sizeof(struct ackmsg)) + goto trunc; + TCHECK(*amp); + ack = EXTRACT_LE_16BITS(amp->ak_acknum[0]); + if (ack & SGQ_ACK) { /* acknum field */ + if ((ack & SGQ_NAK) == SGQ_NAK) + (void)printf("nak %d ", ack & SGQ_MASK); + else + (void)printf("ack %d ", ack & SGQ_MASK); + ack = EXTRACT_LE_16BITS(amp->ak_acknum[1]); + if (ack & SGQ_OACK) { /* ackoth field */ + if ((ack & SGQ_ONAK) == SGQ_ONAK) + (void)printf("onak %d ", ack & SGQ_MASK); + else + (void)printf("oack %d ", ack & SGQ_MASK); + } + } + } + break; + case MFS_IACK: + (void)printf("ils-ack %d>%d ", src, dst); + { + struct ackmsg *amp = (struct ackmsg *)nspp; + int ack; + + if (nsplen < sizeof(struct ackmsg)) + goto trunc; + TCHECK(*amp); + ack = EXTRACT_LE_16BITS(amp->ak_acknum[0]); + if (ack & SGQ_ACK) { /* acknum field */ + if ((ack & SGQ_NAK) == SGQ_NAK) + (void)printf("nak %d ", ack & SGQ_MASK); + else + (void)printf("ack %d ", ack & SGQ_MASK); + TCHECK(amp->ak_acknum[1]); + ack = EXTRACT_LE_16BITS(amp->ak_acknum[1]); + if (ack & SGQ_OACK) { /* ackdat field */ + if ((ack & SGQ_ONAK) == SGQ_ONAK) + (void)printf("nakdat %d ", ack & SGQ_MASK); + else + (void)printf("ackdat %d ", ack & SGQ_MASK); + } + } + } + break; + case MFS_CACK: + (void)printf("conn-ack %d", dst); + break; + default: + (void)printf("reserved-acktype? %x %d > %d", flags, src, dst); + break; + } + break; + case MFT_CTL: + switch (flags & NSP_SUBMASK) { + case MFS_CI: + case MFS_RCI: + if ((flags & NSP_SUBMASK) == MFS_CI) + (void)printf("conn-initiate "); + else + (void)printf("retrans-conn-initiate "); + (void)printf("%d>%d ", src, dst); + { + struct cimsg *cimp = (struct cimsg *)nspp; + int services, info, segsize; +#ifdef PRINT_NSPDATA + u_char *dp; +#endif + + if (nsplen < sizeof(struct cimsg)) + goto trunc; + TCHECK(*cimp); + services = EXTRACT_LE_8BITS(cimp->ci_services); + info = EXTRACT_LE_8BITS(cimp->ci_info); + segsize = EXTRACT_LE_16BITS(cimp->ci_segsize); + + switch (services & COS_MASK) { + case COS_NONE: + break; + case COS_SEGMENT: + (void)printf("seg "); + break; + case COS_MESSAGE: + (void)printf("msg "); + break; + case COS_CRYPTSER: + (void)printf("crypt "); + break; + } + switch (info & COI_MASK) { + case COI_32: + (void)printf("ver 3.2 "); + break; + case COI_31: + (void)printf("ver 3.1 "); + break; + case COI_40: + (void)printf("ver 4.0 "); + break; + case COI_41: + (void)printf("ver 4.1 "); + break; + } + (void)printf("segsize %d ", segsize); +#ifdef PRINT_NSPDATA + if (nsplen > sizeof(struct cimsg)) { + dp = &(nspp[sizeof(struct cimsg)]); + TCHECK2(*dp, nsplen - sizeof(struct cimsg)); + pdata(dp, nsplen - sizeof(struct cimsg)); + } +#endif + } + break; + case MFS_CC: + (void)printf("conn-confirm %d>%d ", src, dst); + { + struct ccmsg *ccmp = (struct ccmsg *)nspp; + int services, info; + u_int segsize, optlen; +#ifdef PRINT_NSPDATA + u_char *dp; +#endif + + if (nsplen < sizeof(struct ccmsg)) + goto trunc; + TCHECK(*ccmp); + services = EXTRACT_LE_8BITS(ccmp->cc_services); + info = EXTRACT_LE_8BITS(ccmp->cc_info); + segsize = EXTRACT_LE_16BITS(ccmp->cc_segsize); + optlen = EXTRACT_LE_8BITS(ccmp->cc_optlen); + + switch (services & COS_MASK) { + case COS_NONE: + break; + case COS_SEGMENT: + (void)printf("seg "); + break; + case COS_MESSAGE: + (void)printf("msg "); + break; + case COS_CRYPTSER: + (void)printf("crypt "); + break; + } + switch (info & COI_MASK) { + case COI_32: + (void)printf("ver 3.2 "); + break; + case COI_31: + (void)printf("ver 3.1 "); + break; + case COI_40: + (void)printf("ver 4.0 "); + break; + case COI_41: + (void)printf("ver 4.1 "); + break; + } + (void)printf("segsize %d ", segsize); + if (optlen) { + (void)printf("optlen %d ", optlen); +#ifdef PRINT_NSPDATA + if (optlen > nsplen - sizeof(struct ccmsg)) + goto trunc; + dp = &(nspp[sizeof(struct ccmsg)]); + TCHECK2(*dp, optlen); + pdata(dp, optlen); +#endif + } + } + break; + case MFS_DI: + (void)printf("disconn-initiate %d>%d ", src, dst); + { + struct dimsg *dimp = (struct dimsg *)nspp; + int reason; + u_int optlen; +#ifdef PRINT_NSPDATA + u_char *dp; +#endif + + if (nsplen < sizeof(struct dimsg)) + goto trunc; + TCHECK(*dimp); + reason = EXTRACT_LE_16BITS(dimp->di_reason); + optlen = EXTRACT_LE_8BITS(dimp->di_optlen); + + print_reason(reason); + if (optlen) { + (void)printf("optlen %d ", optlen); +#ifdef PRINT_NSPDATA + if (optlen > nsplen - sizeof(struct dimsg)) + goto trunc; + dp = &(nspp[sizeof(struct dimsg)]); + TCHECK2(*dp, optlen); + pdata(dp, optlen); +#endif + } + } + break; + case MFS_DC: + (void)printf("disconn-confirm %d>%d ", src, dst); + { + struct dcmsg *dcmp = (struct dcmsg *)nspp; + int reason; + + TCHECK(*dcmp); + reason = EXTRACT_LE_16BITS(dcmp->dc_reason); + + print_reason(reason); + } + break; + default: + (void)printf("reserved-ctltype? %x %d > %d", flags, src, dst); + break; + } + break; + default: + (void)printf("reserved-type? %x %d > %d", flags, src, dst); + break; + } + return (1); + +trunc: + return (0); +} + +static struct tok reason2str[] = { + { UC_OBJREJECT, "object rejected connect" }, + { UC_RESOURCES, "insufficient resources" }, + { UC_NOSUCHNODE, "unrecognized node name" }, + { DI_SHUT, "node is shutting down" }, + { UC_NOSUCHOBJ, "unrecognized object" }, + { UC_INVOBJFORMAT, "invalid object name format" }, + { UC_OBJTOOBUSY, "object too busy" }, + { DI_PROTOCOL, "protocol error discovered" }, + { DI_TPA, "third party abort" }, + { UC_USERABORT, "user abort" }, + { UC_INVNODEFORMAT, "invalid node name format" }, + { UC_LOCALSHUT, "local node shutting down" }, + { DI_LOCALRESRC, "insufficient local resources" }, + { DI_REMUSERRESRC, "insufficient remote user resources" }, + { UC_ACCESSREJECT, "invalid access control information" }, + { DI_BADACCNT, "bad ACCOUNT information" }, + { UC_NORESPONSE, "no response from object" }, + { UC_UNREACHABLE, "node unreachable" }, + { DC_NOLINK, "no link terminate" }, + { DC_COMPLETE, "disconnect complete" }, + { DI_BADIMAGE, "bad image data in connect" }, + { DI_SERVMISMATCH, "cryptographic service mismatch" }, + { 0, NULL } +}; + +static void +print_reason(register int reason) +{ + printf("%s ", tok2str(reason2str, "reason-%d", reason)); +} + +const char * +dnnum_string(u_short dnaddr) +{ + char *str; + size_t siz; + int area = (u_short)(dnaddr & AREAMASK) >> AREASHIFT; + int node = dnaddr & NODEMASK; + + str = (char *)malloc(siz = sizeof("00.0000")); + if (str == NULL) + error("dnnum_string: malloc"); + snprintf(str, siz, "%d.%d", area, node); + return(str); +} + +const char * +dnname_string(u_short dnaddr) +{ +#ifdef HAVE_DNET_HTOA + struct dn_naddr dna; + + dna.a_len = sizeof(short); + memcpy((char *)dna.a_addr, (char *)&dnaddr, sizeof(short)); + return (strdup(dnet_htoa(&dna))); +#else + return(dnnum_string(dnaddr)); /* punt */ +#endif +} + +#ifdef PRINT_NSPDATA +static void +pdata(u_char *dp, u_int maxlen) +{ + char c; + u_int x = maxlen; + + while (x-- > 0) { + c = *dp++; + safeputchar(c); + } +} +#endif
diff --git a/tcpdump-4.3.0/print-dhcp6.c b/tcpdump-4.3.0/print-dhcp6.c new file mode 100644 index 0000000..a75da82 --- /dev/null +++ b/tcpdump-4.3.0/print-dhcp6.c
@@ -0,0 +1,840 @@ +/* + * 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: + * 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. + */ +/* + * RFC3315: DHCPv6 + * supported DHCPv6 options: + * RFC3319, + * RFC3633, + * RFC3646, + * RFC3898, + * RFC4075, + * RFC4242, + * RFC4280, + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-dhcp6.c,v 1.37 2008-02-06 10:26:09 guy Exp $"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> +#include <string.h> + +#include "interface.h" +#include "addrtoname.h" +#include "extract.h" + +/* lease duration */ +#define DHCP6_DURATITION_INFINITE 0xffffffff + +/* Error Values */ +#define DH6ERR_FAILURE 16 +#define DH6ERR_AUTHFAIL 17 +#define DH6ERR_POORLYFORMED 18 +#define DH6ERR_UNAVAIL 19 +#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 +#define DH6_LEASEQUERY 14 +#define DH6_LQ_REPLY 15 + +/* DHCP6 base packet format */ +struct dhcp6 { + union { + u_int8_t m; + u_int32_t x; + } dh6_msgtypexid; + /* options follow */ +}; +#define dh6_msgtype dh6_msgtypexid.m +#define dh6_xid dh6_msgtypexid.x +#define DH6_XIDMASK 0x00ffffff + +/* 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_TA 4 +#define DH6OPT_IA_ADDR 5 +#define DH6OPT_ORO 6 +#define DH6OPT_PREFERENCE 7 +# 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_AUTHPROTO_DELAYED 2 +# define DH6OPT_AUTHPROTO_RECONFIG 3 +# define DH6OPT_AUTHALG_HMACMD5 1 +# define DH6OPT_AUTHRDM_MONOCOUNTER 0 +# define DH6OPT_AUTHRECONFIG_KEY 1 +# define DH6OPT_AUTHRECONFIG_HMACMD5 2 +#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_STCODE_UNKNOWNQUERYTYPE 7 +# define DH6OPT_STCODE_MALFORMEDQUERY 8 +# define DH6OPT_STCODE_NOTCONFIGURED 9 +# define DH6OPT_STCODE_NOTALLOWED 10 +#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 +#define DH6OPT_IA_PD 25 +#define DH6OPT_IA_PD_PREFIX 26 +#define DH6OPT_NIS_SERVERS 27 +#define DH6OPT_NISP_SERVERS 28 +#define DH6OPT_NIS_NAME 29 +#define DH6OPT_NISP_NAME 30 +#define DH6OPT_NTP_SERVERS 31 +#define DH6OPT_LIFETIME 32 +#define DH6OPT_BCMCS_SERVER_D 33 +#define DH6OPT_BCMCS_SERVER_A 34 +#define DH6OPT_GEOCONF_CIVIC 36 +#define DH6OPT_REMOTE_ID 37 +#define DH6OPT_SUBSCRIBER_ID 38 +#define DH6OPT_CLIENT_FQDN 39 +#define DH6OPT_PANA_AGENT 40 +#define DH6OPT_NEW_POSIX_TIMEZONE 41 +#define DH6OPT_NEW_TZDB_TIMEZONE 42 +#define DH6OPT_ERO 43 +#define DH6OPT_LQ_QUERY 44 +#define DH6OPT_CLIENT_DATA 45 +#define DH6OPT_CLT_TIME 46 +#define DH6OPT_LQ_RELAY_DATA 47 +#define DH6OPT_LQ_CLIENT_LINK 48 + +struct dhcp6opt { + u_int16_t dh6opt_type; + u_int16_t dh6opt_len; + /* type-dependent data follows */ +}; + +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_IA_TA: + return "IA_TA"; + case DH6OPT_IA_ADDR: + return "IA_ADDR"; + 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_AUTH: + return "authentication"; + case DH6OPT_UNICAST: + return "server-unicast"; + case DH6OPT_STATUS_CODE: + return "status-code"; + case DH6OPT_RAPID_COMMIT: + return "rapid-commit"; + case DH6OPT_USER_CLASS: + return "user-class"; + case DH6OPT_VENDOR_CLASS: + return "vendor-class"; + case DH6OPT_VENDOR_OPTS: + return "vendor-specific-info"; + 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-server"; + case DH6OPT_DNSNAME: + return "DNS-search-list"; + case DH6OPT_IA_PD: + return "IA_PD"; + case DH6OPT_IA_PD_PREFIX: + return "IA_PD-prefix"; + case DH6OPT_NTP_SERVERS: + return "NTP-server"; + case DH6OPT_LIFETIME: + return "lifetime"; + case DH6OPT_NIS_SERVERS: + return "NIS-server"; + case DH6OPT_NISP_SERVERS: + return "NIS+-server"; + case DH6OPT_NIS_NAME: + return "NIS-domain-name"; + case DH6OPT_NISP_NAME: + return "NIS+-domain-name"; + case DH6OPT_BCMCS_SERVER_D: + return "BCMCS-domain-name"; + case DH6OPT_BCMCS_SERVER_A: + return "BCMCS-server"; + case DH6OPT_GEOCONF_CIVIC: + return "Geoconf-Civic"; + case DH6OPT_REMOTE_ID: + return "Remote-ID"; + case DH6OPT_SUBSCRIBER_ID: + return "Subscriber-ID"; + case DH6OPT_CLIENT_FQDN: + return "Client-FQDN"; + case DH6OPT_PANA_AGENT: + return "PANA-agent"; + case DH6OPT_NEW_POSIX_TIMEZONE: + return "POSIX-timezone"; + case DH6OPT_NEW_TZDB_TIMEZONE: + return "POSIX-tz-database"; + case DH6OPT_ERO: + return "Echo-request-option"; + case DH6OPT_LQ_QUERY: + return "Lease-query"; + case DH6OPT_CLIENT_DATA: + return "LQ-client-data"; + case DH6OPT_CLT_TIME: + return "Clt-time"; + case DH6OPT_LQ_RELAY_DATA: + return "LQ-relay-data"; + case DH6OPT_LQ_CLIENT_LINK: + return "LQ-client-link"; + 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"; + case DH6OPT_STCODE_UNKNOWNQUERYTYPE: + return "unknown query type"; + case DH6OPT_STCODE_MALFORMEDQUERY: + return "malformed query"; + case DH6OPT_STCODE_NOTCONFIGURED: + return "not configured"; + case DH6OPT_STCODE_NOTALLOWED: + return "not allowed"; + default: + snprintf(genstr, sizeof(genstr), "code%d", code); + return(genstr); + } +} + +static void +dhcp6opt_print(const u_char *cp, const u_char *ep) +{ + struct dhcp6opt *dh6o; + u_char *tp; + size_t i; + u_int16_t opttype; + size_t optlen; + u_int8_t auth_proto; + u_int authinfolen, authrealmlen; + + if (cp == ep) + return; + while (cp < ep) { + if (ep < cp + sizeof(*dh6o)) + goto trunc; + dh6o = (struct dhcp6opt *)cp; + optlen = EXTRACT_16BITS(&dh6o->dh6opt_len); + if (ep < cp + sizeof(*dh6o) + optlen) + goto trunc; + opttype = EXTRACT_16BITS(&dh6o->dh6opt_type); + printf(" (%s", dhcp6opt_name(opttype)); + switch (opttype) { + case DH6OPT_CLIENTID: + case DH6OPT_SERVERID: + if (optlen < 2) { + /*(*/ + printf(" ?)"); + break; + } + tp = (u_char *)(dh6o + 1); + switch (EXTRACT_16BITS(tp)) { + case 1: + if (optlen >= 2 + 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(" ?)"); + } + break; + case 2: + if (optlen >= 2 + 8) { + printf(" vid "); + for (i = 2; i < 2 + 8; i++) + printf("%02x", tp[i]); + /*(*/ + printf(")"); + } else { + /*(*/ + printf(" ?)"); + } + break; + case 3: + if (optlen >= 2 + 2) { + printf(" hwaddr type %u ", + EXTRACT_16BITS(&tp[2])); + for (i = 4; i < optlen; i++) + printf("%02x", tp[i]); + /*(*/ + printf(")"); + } else { + /*(*/ + printf(" ?)"); + } + break; + default: + printf(" type %d)", EXTRACT_16BITS(tp)); + break; + } + break; + case DH6OPT_IA_ADDR: + if (optlen < 24) { + /*(*/ + printf(" ?)"); + break; + } + tp = (u_char *)(dh6o + 1); + printf(" %s", ip6addr_string(&tp[0])); + printf(" pltime:%u vltime:%u", + EXTRACT_32BITS(&tp[16]), + EXTRACT_32BITS(&tp[20])); + if (optlen > 24) { + /* there are sub-options */ + dhcp6opt_print(tp + 24, tp + 24 + optlen); + } + printf(")"); + break; + case DH6OPT_ORO: + case DH6OPT_ERO: + if (optlen % 2) { + printf(" ?)"); + break; + } + tp = (u_char *)(dh6o + 1); + for (i = 0; i < optlen; i += 2) { + printf(" %s", + dhcp6opt_name(EXTRACT_16BITS(&tp[i]))); + } + printf(")"); + break; + case DH6OPT_PREFERENCE: + if (optlen != 1) { + printf(" ?)"); + break; + } + tp = (u_char *)(dh6o + 1); + printf(" %d)", *tp); + break; + case DH6OPT_ELAPSED_TIME: + if (optlen != 2) { + printf(" ?)"); + break; + } + tp = (u_char *)(dh6o + 1); + printf(" %d)", EXTRACT_16BITS(tp)); + break; + case DH6OPT_RELAY_MSG: + printf(" ("); + tp = (u_char *)(dh6o + 1); + dhcp6_print(tp, optlen); + printf(")"); + break; + case DH6OPT_AUTH: + if (optlen < 11) { + printf(" ?)"); + break; + } + tp = (u_char *)(dh6o + 1); + auth_proto = *tp; + switch (auth_proto) { + case DH6OPT_AUTHPROTO_DELAYED: + printf(" proto: delayed"); + break; + case DH6OPT_AUTHPROTO_RECONFIG: + printf(" proto: reconfigure"); + break; + default: + printf(" proto: %d", auth_proto); + break; + } + tp++; + switch (*tp) { + case DH6OPT_AUTHALG_HMACMD5: + /* XXX: may depend on the protocol */ + printf(", alg: HMAC-MD5"); + break; + default: + printf(", alg: %d", *tp); + break; + } + tp++; + switch (*tp) { + case DH6OPT_AUTHRDM_MONOCOUNTER: + printf(", RDM: mono"); + break; + default: + printf(", RDM: %d", *tp); + break; + } + tp++; + printf(", RD:"); + for (i = 0; i < 4; i++, tp += 2) + printf(" %04x", EXTRACT_16BITS(tp)); + + /* protocol dependent part */ + authinfolen = optlen - 11; + switch (auth_proto) { + case DH6OPT_AUTHPROTO_DELAYED: + if (authinfolen == 0) + break; + if (authinfolen < 20) { + printf(" ??"); + break; + } + authrealmlen = authinfolen - 20; + if (authrealmlen > 0) { + printf(", realm: "); + } + for (i = 0; i < authrealmlen; i++, tp++) + printf("%02x", *tp); + printf(", key ID: %08x", EXTRACT_32BITS(tp)); + tp += 4; + printf(", HMAC-MD5:"); + for (i = 0; i < 4; i++, tp+= 4) + printf(" %08x", EXTRACT_32BITS(tp)); + break; + case DH6OPT_AUTHPROTO_RECONFIG: + if (authinfolen != 17) { + printf(" ??"); + break; + } + switch (*tp++) { + case DH6OPT_AUTHRECONFIG_KEY: + printf(" reconfig-key"); + break; + case DH6OPT_AUTHRECONFIG_HMACMD5: + printf(" type: HMAC-MD5"); + break; + default: + printf(" type: ??"); + break; + } + printf(" value:"); + for (i = 0; i < 4; i++, tp+= 4) + printf(" %08x", EXTRACT_32BITS(tp)); + break; + default: + printf(" ??"); + break; + } + + printf(")"); + break; + case DH6OPT_RAPID_COMMIT: /* nothing todo */ + printf(")"); + break; + case DH6OPT_INTERFACE_ID: + case DH6OPT_SUBSCRIBER_ID: + /* + * Since we cannot predict the encoding, print hex dump + * at most 10 characters. + */ + tp = (u_char *)(dh6o + 1); + printf(" "); + for (i = 0; i < optlen && i < 10; i++) + printf("%02x", tp[i]); + printf("...)"); + 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: + case DH6OPT_NTP_SERVERS: + case DH6OPT_NIS_SERVERS: + case DH6OPT_NISP_SERVERS: + case DH6OPT_BCMCS_SERVER_A: + case DH6OPT_PANA_AGENT: + case DH6OPT_LQ_CLIENT_LINK: + if (optlen % 16) { + printf(" ?)"); + break; + } + tp = (u_char *)(dh6o + 1); + for (i = 0; i < optlen; i += 16) + printf(" %s", ip6addr_string(&tp[i])); + printf(")"); + break; + case DH6OPT_STATUS_CODE: + if (optlen < 2) { + printf(" ?)"); + break; + } + tp = (u_char *)(dh6o + 1); + printf(" %s)", dhcp6stcode(EXTRACT_16BITS(&tp[0]))); + break; + case DH6OPT_IA_NA: + case DH6OPT_IA_PD: + if (optlen < 12) { + printf(" ?)"); + break; + } + tp = (u_char *)(dh6o + 1); + printf(" IAID:%u T1:%u T2:%u", + EXTRACT_32BITS(&tp[0]), + EXTRACT_32BITS(&tp[4]), + EXTRACT_32BITS(&tp[8])); + if (optlen > 12) { + /* there are sub-options */ + dhcp6opt_print(tp + 12, tp + 12 + optlen); + } + printf(")"); + break; + case DH6OPT_IA_TA: + if (optlen < 4) { + printf(" ?)"); + break; + } + tp = (u_char *)(dh6o + 1); + printf(" IAID:%u", EXTRACT_32BITS(tp)); + if (optlen > 4) { + /* there are sub-options */ + dhcp6opt_print(tp + 4, tp + 4 + optlen); + } + printf(")"); + break; + case DH6OPT_IA_PD_PREFIX: + if (optlen < 25) { + printf(" ?)"); + break; + } + tp = (u_char *)(dh6o + 1); + printf(" %s/%d", ip6addr_string(&tp[9]), tp[8]); + printf(" pltime:%u vltime:%u", + EXTRACT_32BITS(&tp[0]), + EXTRACT_32BITS(&tp[4])); + if (optlen > 25) { + /* there are sub-options */ + dhcp6opt_print(tp + 25, tp + 25 + optlen); + } + printf(")"); + break; + case DH6OPT_LIFETIME: + case DH6OPT_CLT_TIME: + if (optlen != 4) { + printf(" ?)"); + break; + } + tp = (u_char *)(dh6o + 1); + printf(" %d)", EXTRACT_32BITS(tp)); + break; + case DH6OPT_REMOTE_ID: + if (optlen < 4) { + printf(" ?)"); + break; + } + tp = (u_char *)(dh6o + 1); + printf(" %d ", EXTRACT_32BITS(tp)); + /* + * Print hex dump first 10 characters. + */ + for (i = 4; i < optlen && i < 14; i++) + printf("%02x", tp[i]); + printf("...)"); + break; + case DH6OPT_LQ_QUERY: + if (optlen < 17) { + printf(" ?)"); + break; + } + tp = (u_char *)(dh6o + 1); + switch (*tp) { + case 1: + printf(" by-address"); + break; + case 2: + printf(" by-clientID"); + break; + default: + printf(" type_%d", (int)*tp); + break; + } + printf(" %s", ip6addr_string(&tp[1])); + if (optlen > 17) { + /* there are query-options */ + dhcp6opt_print(tp + 17, tp + optlen); + } + printf(")"); + break; + case DH6OPT_CLIENT_DATA: + tp = (u_char *)(dh6o + 1); + if (optlen > 0) { + /* there are encapsulated options */ + dhcp6opt_print(tp, tp + optlen); + } + printf(")"); + break; + case DH6OPT_LQ_RELAY_DATA: + if (optlen < 16) { + printf(" ?)"); + break; + } + tp = (u_char *)(dh6o + 1); + printf(" %s ", ip6addr_string(&tp[0])); + /* + * Print hex dump first 10 characters. + */ + for (i = 16; i < optlen && i < 26; i++) + printf("%02x", tp[i]); + printf("...)"); + break; + default: + printf(")"); + break; + } + + cp += sizeof(*dh6o) + optlen; + } + return; + +trunc: + printf("[|dhcp6ext]"); +} + +/* + * Print dhcp6 packets + */ +void +dhcp6_print(const u_char *cp, u_int length) +{ + struct dhcp6 *dh6; + 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; + 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; + case DH6_LEASEQUERY: + name= "leasequery"; + break; + case DH6_LQ_REPLY: + name= "leasequery-reply"; + break; + default: + name = NULL; + break; + } + + if (!vflag) { + if (name) + printf(" %s", name); + else if (dh6->dh6_msgtype != DH6_RELAY_FORW && + dh6->dh6_msgtype != DH6_RELAY_REPLY) { + printf(" msgtype-%u", dh6->dh6_msgtype); + } + return; + } + + /* XXX relay agent messages have to be handled differently */ + + if (name) + printf(" %s (", name); /*)*/ + else + printf(" msgtype-%u (", dh6->dh6_msgtype); /*)*/ + 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; + +trunc: + printf("[|dhcp6]"); +}
diff --git a/tcpdump-4.3.0/print-domain.c b/tcpdump-4.3.0/print-domain.c new file mode 100644 index 0000000..43e8f41 --- /dev/null +++ b/tcpdump-4.3.0/print-domain.c
@@ -0,0 +1,751 @@ +/* + * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.98 2007-12-09 01:40:32 guy Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include "nameser.h" + +#include <stdio.h> +#include <string.h> + +#include "interface.h" +#include "addrtoname.h" +#include "extract.h" /* must come after interface.h */ + +static const char *ns_ops[] = { + "", " inv_q", " stat", " op3", " notify", " update", " op6", " op7", + " op8", " updataA", " updateD", " updateDA", + " updateM", " updateMA", " zoneInit", " zoneRef", +}; + +static const char *ns_resp[] = { + "", " FormErr", " ServFail", " NXDomain", + " NotImp", " Refused", " YXDomain", " YXRRSet", + " NXRRSet", " NotAuth", " NotZone", " Resp11", + " Resp12", " Resp13", " Resp14", " NoChange", +}; + +/* skip over a domain name */ +static const u_char * +ns_nskip(register const u_char *cp) +{ + register u_char i; + + if (!TTEST2(*cp, 1)) + return (NULL); + i = *cp++; + while (i) { + if ((i & INDIR_MASK) == INDIR_MASK) + return (cp + 1); + if ((i & INDIR_MASK) == EDNS0_MASK) { + int bitlen, bytelen; + + if ((i & ~INDIR_MASK) != EDNS0_ELT_BITLABEL) + return(NULL); /* unknown ELT */ + if (!TTEST2(*cp, 1)) + return (NULL); + if ((bitlen = *cp++) == 0) + bitlen = 256; + bytelen = (bitlen + 7) / 8; + cp += bytelen; + } else + cp += i; + if (!TTEST2(*cp, 1)) + return (NULL); + i = *cp++; + } + return (cp); +} + +/* print a <domain-name> */ +static const u_char * +blabel_print(const u_char *cp) +{ + int bitlen, slen, b; + const u_char *bitp, *lim; + char tc; + + if (!TTEST2(*cp, 1)) + return(NULL); + if ((bitlen = *cp) == 0) + bitlen = 256; + slen = (bitlen + 3) / 4; + lim = cp + 1 + slen; + + /* print the bit string as a hex string */ + printf("\\[x"); + for (bitp = cp + 1, b = bitlen; bitp < lim && b > 7; b -= 8, bitp++) { + TCHECK(*bitp); + printf("%02x", *bitp); + } + if (b > 4) { + TCHECK(*bitp); + tc = *bitp++; + printf("%02x", tc & (0xff << (8 - b))); + } else if (b > 0) { + TCHECK(*bitp); + tc = *bitp++; + printf("%1x", ((tc >> 4) & 0x0f) & (0x0f << (4 - b))); + } + printf("/%d]", bitlen); + return lim; +trunc: + printf(".../%d]", bitlen); + return NULL; +} + +static int +labellen(const u_char *cp) +{ + register u_int i; + + if (!TTEST2(*cp, 1)) + return(-1); + i = *cp; + if ((i & INDIR_MASK) == EDNS0_MASK) { + int bitlen, elt; + if ((elt = (i & ~INDIR_MASK)) != EDNS0_ELT_BITLABEL) { + printf("<ELT %d>", elt); + return(-1); + } + if (!TTEST2(*(cp + 1), 1)) + return(-1); + if ((bitlen = *(cp + 1)) == 0) + bitlen = 256; + return(((bitlen + 7) / 8) + 1); + } else + return(i); +} + +static const u_char * +ns_nprint(register const u_char *cp, register const u_char *bp) +{ + register u_int i, l; + register const u_char *rp = NULL; + register int compress = 0; + int chars_processed; + int elt; + int data_size = snapend - bp; + + if ((l = labellen(cp)) == (u_int)-1) + return(NULL); + if (!TTEST2(*cp, 1)) + return(NULL); + chars_processed = 1; + if (((i = *cp++) & INDIR_MASK) != INDIR_MASK) { + compress = 0; + rp = cp + l; + } + + if (i != 0) + while (i && cp < snapend) { + if ((i & INDIR_MASK) == INDIR_MASK) { + if (!compress) { + rp = cp + 1; + compress = 1; + } + if (!TTEST2(*cp, 1)) + return(NULL); + cp = bp + (((i << 8) | *cp) & 0x3fff); + if ((l = labellen(cp)) == (u_int)-1) + return(NULL); + if (!TTEST2(*cp, 1)) + return(NULL); + i = *cp++; + chars_processed++; + + /* + * If we've looked at every character in + * the message, this pointer will make + * us look at some character again, + * which means we're looping. + */ + if (chars_processed >= data_size) { + printf("<LOOP>"); + return (NULL); + } + continue; + } + if ((i & INDIR_MASK) == EDNS0_MASK) { + elt = (i & ~INDIR_MASK); + switch(elt) { + case EDNS0_ELT_BITLABEL: + if (blabel_print(cp) == NULL) + return (NULL); + break; + default: + /* unknown ELT */ + printf("<ELT %d>", elt); + return(NULL); + } + } else { + if (fn_printn(cp, l, snapend)) + return(NULL); + } + + cp += l; + chars_processed += l; + putchar('.'); + if ((l = labellen(cp)) == (u_int)-1) + return(NULL); + if (!TTEST2(*cp, 1)) + return(NULL); + i = *cp++; + chars_processed++; + if (!compress) + rp += l + 1; + } + else + putchar('.'); + return (rp); +} + +/* print a <character-string> */ +static const u_char * +ns_cprint(register const u_char *cp) +{ + register u_int i; + + if (!TTEST2(*cp, 1)) + return (NULL); + i = *cp++; + if (fn_printn(cp, i, snapend)) + return (NULL); + return (cp + i); +} + +/* http://www.iana.org/assignments/dns-parameters */ +struct tok ns_type2str[] = { + { T_A, "A" }, /* RFC 1035 */ + { T_NS, "NS" }, /* RFC 1035 */ + { T_MD, "MD" }, /* RFC 1035 */ + { T_MF, "MF" }, /* RFC 1035 */ + { T_CNAME, "CNAME" }, /* RFC 1035 */ + { T_SOA, "SOA" }, /* RFC 1035 */ + { T_MB, "MB" }, /* RFC 1035 */ + { T_MG, "MG" }, /* RFC 1035 */ + { T_MR, "MR" }, /* RFC 1035 */ + { T_NULL, "NULL" }, /* RFC 1035 */ + { T_WKS, "WKS" }, /* RFC 1035 */ + { T_PTR, "PTR" }, /* RFC 1035 */ + { T_HINFO, "HINFO" }, /* RFC 1035 */ + { T_MINFO, "MINFO" }, /* RFC 1035 */ + { T_MX, "MX" }, /* RFC 1035 */ + { T_TXT, "TXT" }, /* RFC 1035 */ + { T_RP, "RP" }, /* RFC 1183 */ + { T_AFSDB, "AFSDB" }, /* RFC 1183 */ + { T_X25, "X25" }, /* RFC 1183 */ + { T_ISDN, "ISDN" }, /* RFC 1183 */ + { T_RT, "RT" }, /* RFC 1183 */ + { T_NSAP, "NSAP" }, /* RFC 1706 */ + { T_NSAP_PTR, "NSAP_PTR" }, + { T_SIG, "SIG" }, /* RFC 2535 */ + { T_KEY, "KEY" }, /* RFC 2535 */ + { T_PX, "PX" }, /* RFC 2163 */ + { T_GPOS, "GPOS" }, /* RFC 1712 */ + { T_AAAA, "AAAA" }, /* RFC 1886 */ + { T_LOC, "LOC" }, /* RFC 1876 */ + { T_NXT, "NXT" }, /* RFC 2535 */ + { T_EID, "EID" }, /* Nimrod */ + { T_NIMLOC, "NIMLOC" }, /* Nimrod */ + { T_SRV, "SRV" }, /* RFC 2782 */ + { T_ATMA, "ATMA" }, /* ATM Forum */ + { T_NAPTR, "NAPTR" }, /* RFC 2168, RFC 2915 */ + { T_KX, "KX" }, /* RFC 2230 */ + { T_CERT, "CERT" }, /* RFC 2538 */ + { T_A6, "A6" }, /* RFC 2874 */ + { T_DNAME, "DNAME" }, /* RFC 2672 */ + { T_SINK, "SINK" }, + { T_OPT, "OPT" }, /* RFC 2671 */ + { T_APL, "APL" }, /* RFC 3123 */ + { T_DS, "DS" }, /* RFC 4034 */ + { T_SSHFP, "SSHFP" }, /* RFC 4255 */ + { T_IPSECKEY, "IPSECKEY" }, /* RFC 4025 */ + { T_RRSIG, "RRSIG" }, /* RFC 4034 */ + { T_NSEC, "NSEC" }, /* RFC 4034 */ + { T_DNSKEY, "DNSKEY" }, /* RFC 4034 */ + { T_SPF, "SPF" }, /* RFC-schlitt-spf-classic-02.txt */ + { T_UINFO, "UINFO" }, + { T_UID, "UID" }, + { T_GID, "GID" }, + { T_UNSPEC, "UNSPEC" }, + { T_UNSPECA, "UNSPECA" }, + { T_TKEY, "TKEY" }, /* RFC 2930 */ + { T_TSIG, "TSIG" }, /* RFC 2845 */ + { T_IXFR, "IXFR" }, /* RFC 1995 */ + { T_AXFR, "AXFR" }, /* RFC 1035 */ + { T_MAILB, "MAILB" }, /* RFC 1035 */ + { T_MAILA, "MAILA" }, /* RFC 1035 */ + { T_ANY, "ANY" }, + { 0, NULL } +}; + +struct tok ns_class2str[] = { + { C_IN, "IN" }, /* Not used */ + { C_CHAOS, "CHAOS" }, + { C_HS, "HS" }, + { C_ANY, "ANY" }, + { 0, NULL } +}; + +/* print a query */ +static const u_char * +ns_qprint(register const u_char *cp, register const u_char *bp, int is_mdns) +{ + register const u_char *np = cp; + register u_int i, class; + + cp = ns_nskip(cp); + + if (cp == NULL || !TTEST2(*cp, 4)) + return(NULL); + + /* print the qtype */ + i = EXTRACT_16BITS(cp); + cp += 2; + printf(" %s", tok2str(ns_type2str, "Type%d", i)); + /* print the qclass (if it's not IN) */ + i = EXTRACT_16BITS(cp); + cp += 2; + if (is_mdns) + class = (i & ~C_QU); + else + class = i; + if (class != C_IN) + printf(" %s", tok2str(ns_class2str, "(Class %d)", class)); + if (is_mdns) { + if (i & C_QU) + printf(" (QU)"); + else + printf(" (QM)"); + } + + fputs("? ", stdout); + cp = ns_nprint(np, bp); + return(cp ? cp + 4 : NULL); +} + +/* print a reply */ +static const u_char * +ns_rprint(register const u_char *cp, register const u_char *bp, int is_mdns) +{ + register u_int i, class, opt_flags = 0; + register u_short typ, len; + register const u_char *rp; + + if (vflag) { + putchar(' '); + if ((cp = ns_nprint(cp, bp)) == NULL) + return NULL; + } else + cp = ns_nskip(cp); + + if (cp == NULL || !TTEST2(*cp, 10)) + return (snapend); + + /* print the type/qtype */ + typ = EXTRACT_16BITS(cp); + cp += 2; + /* print the class (if it's not IN and the type isn't OPT) */ + i = EXTRACT_16BITS(cp); + cp += 2; + if (is_mdns) + class = (i & ~C_CACHE_FLUSH); + else + class = i; + if (class != C_IN && typ != T_OPT) + printf(" %s", tok2str(ns_class2str, "(Class %d)", class)); + if (is_mdns) { + if (i & C_CACHE_FLUSH) + printf(" (Cache flush)"); + } + + if (typ == T_OPT) { + /* get opt flags */ + cp += 2; + opt_flags = EXTRACT_16BITS(cp); + /* ignore rest of ttl field */ + cp += 2; + } else if (vflag > 2) { + /* print ttl */ + printf(" ["); + relts_print(EXTRACT_32BITS(cp)); + printf("]"); + cp += 4; + } else { + /* ignore ttl */ + cp += 4; + } + + len = EXTRACT_16BITS(cp); + cp += 2; + + rp = cp + len; + + printf(" %s", tok2str(ns_type2str, "Type%d", typ)); + if (rp > snapend) + return(NULL); + + switch (typ) { + case T_A: + if (!TTEST2(*cp, sizeof(struct in_addr))) + return(NULL); + printf(" %s", intoa(htonl(EXTRACT_32BITS(cp)))); + break; + + case T_NS: + case T_CNAME: + case T_PTR: +#ifdef T_DNAME + case T_DNAME: +#endif + putchar(' '); + if (ns_nprint(cp, bp) == NULL) + return(NULL); + break; + + case T_SOA: + if (!vflag) + break; + putchar(' '); + if ((cp = ns_nprint(cp, bp)) == NULL) + return(NULL); + putchar(' '); + if ((cp = ns_nprint(cp, bp)) == NULL) + return(NULL); + if (!TTEST2(*cp, 5 * 4)) + return(NULL); + printf(" %u", EXTRACT_32BITS(cp)); + cp += 4; + printf(" %u", EXTRACT_32BITS(cp)); + cp += 4; + printf(" %u", EXTRACT_32BITS(cp)); + cp += 4; + printf(" %u", EXTRACT_32BITS(cp)); + cp += 4; + printf(" %u", EXTRACT_32BITS(cp)); + cp += 4; + break; + case T_MX: + putchar(' '); + if (!TTEST2(*cp, 2)) + return(NULL); + if (ns_nprint(cp + 2, bp) == NULL) + return(NULL); + printf(" %d", EXTRACT_16BITS(cp)); + break; + + case T_TXT: + while (cp < rp) { + printf(" \""); + cp = ns_cprint(cp); + if (cp == NULL) + return(NULL); + putchar('"'); + } + break; + + case T_SRV: + putchar(' '); + if (!TTEST2(*cp, 6)) + return(NULL); + if (ns_nprint(cp + 6, bp) == NULL) + return(NULL); + printf(":%d %d %d", EXTRACT_16BITS(cp + 4), + EXTRACT_16BITS(cp), EXTRACT_16BITS(cp + 2)); + break; + +#ifdef INET6 + case T_AAAA: + { + struct in6_addr addr; + char ntop_buf[INET6_ADDRSTRLEN]; + + if (!TTEST2(*cp, sizeof(struct in6_addr))) + return(NULL); + memcpy(&addr, cp, sizeof(struct in6_addr)); + printf(" %s", + inet_ntop(AF_INET6, &addr, ntop_buf, sizeof(ntop_buf))); + + break; + } + + case T_A6: + { + struct in6_addr a; + int pbit, pbyte; + char ntop_buf[INET6_ADDRSTRLEN]; + + if (!TTEST2(*cp, 1)) + return(NULL); + pbit = *cp; + pbyte = (pbit & ~7) / 8; + if (pbit > 128) { + printf(" %u(bad plen)", pbit); + break; + } else if (pbit < 128) { + if (!TTEST2(*(cp + 1), sizeof(a) - pbyte)) + return(NULL); + memset(&a, 0, sizeof(a)); + memcpy(&a.s6_addr[pbyte], cp + 1, sizeof(a) - pbyte); + printf(" %u %s", pbit, + inet_ntop(AF_INET6, &a, ntop_buf, sizeof(ntop_buf))); + } + if (pbit > 0) { + putchar(' '); + if (ns_nprint(cp + 1 + sizeof(a) - pbyte, bp) == NULL) + return(NULL); + } + break; + } +#endif /*INET6*/ + + case T_OPT: + printf(" UDPsize=%u", class); + if (opt_flags & 0x8000) + printf(" OK"); + break; + + case T_UNSPECA: /* One long string */ + if (!TTEST2(*cp, len)) + return(NULL); + if (fn_printn(cp, len, snapend)) + return(NULL); + break; + + case T_TSIG: + { + if (cp + len > snapend) + return(NULL); + if (!vflag) + break; + putchar(' '); + if ((cp = ns_nprint(cp, bp)) == NULL) + return(NULL); + cp += 6; + if (!TTEST2(*cp, 2)) + return(NULL); + printf(" fudge=%u", EXTRACT_16BITS(cp)); + cp += 2; + if (!TTEST2(*cp, 2)) + return(NULL); + printf(" maclen=%u", EXTRACT_16BITS(cp)); + cp += 2 + EXTRACT_16BITS(cp); + if (!TTEST2(*cp, 2)) + return(NULL); + printf(" origid=%u", EXTRACT_16BITS(cp)); + cp += 2; + if (!TTEST2(*cp, 2)) + return(NULL); + printf(" error=%u", EXTRACT_16BITS(cp)); + cp += 2; + if (!TTEST2(*cp, 2)) + return(NULL); + printf(" otherlen=%u", EXTRACT_16BITS(cp)); + cp += 2; + } + } + return (rp); /* XXX This isn't always right */ +} + +void +ns_print(register const u_char *bp, u_int length, int is_mdns) +{ + register const HEADER *np; + register int qdcount, ancount, nscount, arcount; + register const u_char *cp; + u_int16_t b2; + + np = (const HEADER *)bp; + TCHECK(*np); + /* get the byte-order right */ + qdcount = EXTRACT_16BITS(&np->qdcount); + ancount = EXTRACT_16BITS(&np->ancount); + nscount = EXTRACT_16BITS(&np->nscount); + arcount = EXTRACT_16BITS(&np->arcount); + + if (DNS_QR(np)) { + /* this is a response */ + printf("%d%s%s%s%s%s%s", + EXTRACT_16BITS(&np->id), + ns_ops[DNS_OPCODE(np)], + ns_resp[DNS_RCODE(np)], + DNS_AA(np)? "*" : "", + DNS_RA(np)? "" : "-", + DNS_TC(np)? "|" : "", + DNS_AD(np)? "$" : ""); + + if (qdcount != 1) + printf(" [%dq]", qdcount); + /* Print QUESTION section on -vv */ + cp = (const u_char *)(np + 1); + while (qdcount--) { + if (qdcount < EXTRACT_16BITS(&np->qdcount) - 1) + putchar(','); + if (vflag > 1) { + fputs(" q:", stdout); + if ((cp = ns_qprint(cp, bp, is_mdns)) == NULL) + goto trunc; + } else { + if ((cp = ns_nskip(cp)) == NULL) + goto trunc; + cp += 4; /* skip QTYPE and QCLASS */ + } + } + printf(" %d/%d/%d", ancount, nscount, arcount); + if (ancount--) { + if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL) + goto trunc; + while (cp < snapend && ancount--) { + putchar(','); + if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL) + goto trunc; + } + } + if (ancount > 0) + goto trunc; + /* Print NS and AR sections on -vv */ + if (vflag > 1) { + if (cp < snapend && nscount--) { + fputs(" ns:", stdout); + if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL) + goto trunc; + while (cp < snapend && nscount--) { + putchar(','); + if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL) + goto trunc; + } + } + if (nscount > 0) + goto trunc; + if (cp < snapend && arcount--) { + fputs(" ar:", stdout); + if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL) + goto trunc; + while (cp < snapend && arcount--) { + putchar(','); + if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL) + goto trunc; + } + } + if (arcount > 0) + goto trunc; + } + } + else { + /* this is a request */ + printf("%d%s%s%s", EXTRACT_16BITS(&np->id), ns_ops[DNS_OPCODE(np)], + DNS_RD(np) ? "+" : "", + DNS_CD(np) ? "%" : ""); + + /* any weirdness? */ + b2 = EXTRACT_16BITS(((u_short *)np)+1); + if (b2 & 0x6cf) + printf(" [b2&3=0x%x]", b2); + + if (DNS_OPCODE(np) == IQUERY) { + if (qdcount) + printf(" [%dq]", qdcount); + if (ancount != 1) + printf(" [%da]", ancount); + } + else { + if (ancount) + printf(" [%da]", ancount); + if (qdcount != 1) + printf(" [%dq]", qdcount); + } + if (nscount) + printf(" [%dn]", nscount); + if (arcount) + printf(" [%dau]", arcount); + + cp = (const u_char *)(np + 1); + if (qdcount--) { + cp = ns_qprint(cp, (const u_char *)np, is_mdns); + if (!cp) + goto trunc; + while (cp < snapend && qdcount--) { + cp = ns_qprint((const u_char *)cp, + (const u_char *)np, + is_mdns); + if (!cp) + goto trunc; + } + } + if (qdcount > 0) + goto trunc; + + /* Print remaining sections on -vv */ + if (vflag > 1) { + if (ancount--) { + if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL) + goto trunc; + while (cp < snapend && ancount--) { + putchar(','); + if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL) + goto trunc; + } + } + if (ancount > 0) + goto trunc; + if (cp < snapend && nscount--) { + fputs(" ns:", stdout); + if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL) + goto trunc; + while (nscount-- && cp < snapend) { + putchar(','); + if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL) + goto trunc; + } + } + if (nscount > 0) + goto trunc; + if (cp < snapend && arcount--) { + fputs(" ar:", stdout); + if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL) + goto trunc; + while (cp < snapend && arcount--) { + putchar(','); + if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL) + goto trunc; + } + } + if (arcount > 0) + goto trunc; + } + } + printf(" (%d)", length); + return; + + trunc: + printf("[|domain]"); + return; +}
diff --git a/tcpdump-4.3.0/print-dtp.c b/tcpdump-4.3.0/print-dtp.c new file mode 100644 index 0000000..c358a89 --- /dev/null +++ b/tcpdump-4.3.0/print-dtp.c
@@ -0,0 +1,123 @@ +/* + * Copyright (c) 1998-2007 The TCPDUMP project + * + * 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. + * + * Dynamic Trunk Protocol (DTP) + * + * Original code by Carles Kishimoto <carles.kishimoto@gmail.com> + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> +#include <string.h> + +#include "interface.h" +#include "addrtoname.h" +#include "extract.h" +#include "nlpid.h" + +#define DTP_HEADER_LEN 1 +#define DTP_DOMAIN_TLV 0x0001 +#define DTP_STATUS_TLV 0x0002 +#define DTP_DTP_TYPE_TLV 0x0003 +#define DTP_NEIGHBOR_TLV 0x0004 + +static struct tok dtp_tlv_values[] = { + { DTP_DOMAIN_TLV, "Domain TLV"}, + { DTP_STATUS_TLV, "Status TLV"}, + { DTP_DTP_TYPE_TLV, "DTP type TLV"}, + { DTP_NEIGHBOR_TLV, "Neighbor TLV"}, + { 0, NULL} +}; + +void +dtp_print (const u_char *pptr, u_int length) +{ + int type, len; + const u_char *tptr; + + if (length < DTP_HEADER_LEN) + goto trunc; + + tptr = pptr; + + if (!TTEST2(*tptr, DTP_HEADER_LEN)) + goto trunc; + + printf("DTPv%u, length %u", + (*tptr), + length); + + /* + * In non-verbose mode, just print version. + */ + if (vflag < 1) { + return; + } + + tptr += DTP_HEADER_LEN; + + while (tptr < (pptr+length)) { + + if (!TTEST2(*tptr, 4)) + goto trunc; + + type = EXTRACT_16BITS(tptr); + len = EXTRACT_16BITS(tptr+2); + + /* infinite loop check */ + if (type == 0 || len == 0) { + return; + } + + printf("\n\t%s (0x%04x) TLV, length %u", + tok2str(dtp_tlv_values, "Unknown", type), + type, len); + + switch (type) { + case DTP_DOMAIN_TLV: + printf(", %s", tptr+4); + break; + + case DTP_STATUS_TLV: + case DTP_DTP_TYPE_TLV: + printf(", 0x%x", *(tptr+4)); + break; + + case DTP_NEIGHBOR_TLV: + printf(", %s", etheraddr_string(tptr+4)); + break; + + default: + break; + } + tptr += len; + } + + return; + + trunc: + printf("[|dtp]"); +} + +/* + * Local Variables: + * c-style: whitesmith + * c-basic-offset: 4 + * End: + */
diff --git a/tcpdump-4.3.0/print-dvmrp.c b/tcpdump-4.3.0/print-dvmrp.c new file mode 100644 index 0000000..437e716 --- /dev/null +++ b/tcpdump-4.3.0/print-dvmrp.c
@@ -0,0 +1,369 @@ +/* + * Copyright (c) 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-dvmrp.c,v 1.27 2003-11-19 09:42:04 guy Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + +#include "interface.h" +#include "extract.h" +#include "addrtoname.h" + +/* + * DVMRP message types and flag values shamelessly stolen from + * mrouted/dvmrp.h. + */ +#define DVMRP_PROBE 1 /* for finding neighbors */ +#define DVMRP_REPORT 2 /* for reporting some or all routes */ +#define DVMRP_ASK_NEIGHBORS 3 /* sent by mapper, asking for a list */ + /* of this router's neighbors */ +#define DVMRP_NEIGHBORS 4 /* response to such a request */ +#define DVMRP_ASK_NEIGHBORS2 5 /* as above, want new format reply */ +#define DVMRP_NEIGHBORS2 6 +#define DVMRP_PRUNE 7 /* prune message */ +#define DVMRP_GRAFT 8 /* graft message */ +#define DVMRP_GRAFT_ACK 9 /* graft acknowledgement */ + +/* + * 'flags' byte values in DVMRP_NEIGHBORS2 reply. + */ +#define DVMRP_NF_TUNNEL 0x01 /* neighbors reached via tunnel */ +#define DVMRP_NF_SRCRT 0x02 /* tunnel uses IP source routing */ +#define DVMRP_NF_DOWN 0x10 /* kernel state of interface */ +#define DVMRP_NF_DISABLED 0x20 /* administratively disabled */ +#define DVMRP_NF_QUERIER 0x40 /* I am the subnet's querier */ + +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; + +void +dvmrp_print(register const u_char *bp, register u_int len) +{ + register const u_char *ep; + register u_char type; + + ep = (const u_char *)snapend; + if (bp >= ep) + return; + + TCHECK(bp[1]); + type = bp[1]; + + /* Skip IGMP header */ + bp += 8; + len -= 8; + + switch (type) { + + case DVMRP_PROBE: + printf(" Probe"); + if (vflag) { + if (print_probe(bp, ep, len) < 0) + goto trunc; + } + break; + + case DVMRP_REPORT: + printf(" Report"); + if (vflag > 1) { + if (print_report(bp, ep, len) < 0) + goto trunc; + } + break; + + case DVMRP_ASK_NEIGHBORS: + printf(" Ask-neighbors(old)"); + break; + + case DVMRP_NEIGHBORS: + printf(" Neighbors(old)"); + if (print_neighbors(bp, ep, len) < 0) + goto trunc; + break; + + case DVMRP_ASK_NEIGHBORS2: + printf(" Ask-neighbors2"); + break; + + case DVMRP_NEIGHBORS2: + printf(" Neighbors2"); + /* + * extract version and capabilities from IGMP group + * address field + */ + bp -= 4; + TCHECK2(bp[0], 4); + target_level = (bp[0] << 24) | (bp[1] << 16) | + (bp[2] << 8) | bp[3]; + bp += 4; + if (print_neighbors2(bp, ep, len) < 0) + goto trunc; + break; + + case DVMRP_PRUNE: + printf(" Prune"); + if (print_prune(bp) < 0) + goto trunc; + break; + + case DVMRP_GRAFT: + printf(" Graft"); + if (print_graft(bp) < 0) + goto trunc; + break; + + case DVMRP_GRAFT_ACK: + printf(" Graft-ACK"); + if (print_graft_ack(bp) < 0) + goto trunc; + break; + + default: + printf(" [type %d]", type); + break; + } + return; + +trunc: + printf("[|dvmrp]"); + return; +} + +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, done; + register u_int i, width; + + while (len > 0) { + if (len < 3) { + printf(" [|]"); + 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]) + width = 2; + if (bp[1]) + width = 3; + if (bp[2]) + width = 4; + + printf("\n\tMask %s", intoa(htonl(mask))); + bp += 3; + len -= 3; + do { + if (bp + width + 1 > ep) { + printf(" [|]"); + return (0); + } + if (len < width + 1) { + printf("\n\t [Truncated Report]"); + return (0); + } + origin = 0; + 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; + printf("\n\t %s metric %d", intoa(htonl(origin)), + metric); + len -= width + 1; + } while (!done); + } + return (0); +trunc: + return (-1); +} + +static int +print_probe(register const u_char *bp, register const u_char *ep, + register u_int len) +{ + register u_int32_t genid; + + TCHECK2(bp[0], 4); + if ((len < 4) || ((bp + 4) > ep)) { + /* { (ctags) */ + printf(" [|}"); + return (0); + } + genid = (bp[0] << 24) | (bp[1] << 16) | (bp[2] << 8) | bp[3]; + bp += 4; + len -= 4; + if (vflag > 1) + printf("\n\t"); + else + printf(" "); + printf("genid %u", genid); + if (vflag < 2) + return (0); + + while ((len > 0) && (bp < ep)) { + TCHECK2(bp[0], 4); + printf("\n\tneighbor %s", ipaddr_string(bp)); + bp += 4; len -= 4; + } + return (0); +trunc: + return (-1); +} + +static int +print_neighbors(register const u_char *bp, register const u_char *ep, + register u_int len) +{ + const u_char *laddr; + register u_char metric; + register u_char thresh; + register int ncount; + + while (len > 0 && bp < ep) { + TCHECK2(bp[0], 7); + laddr = bp; + bp += 4; + metric = *bp++; + thresh = *bp++; + ncount = *bp++; + len -= 7; + while (--ncount >= 0) { + TCHECK2(bp[0], 4); + printf(" [%s ->", ipaddr_string(laddr)); + printf(" %s, (%d/%d)]", + ipaddr_string(bp), metric, thresh); + bp += 4; + len -= 4; + } + } + return (0); +trunc: + return (-1); +} + +static int +print_neighbors2(register const u_char *bp, register const u_char *ep, + register u_int len) +{ + const u_char *laddr; + register u_char metric, thresh, flags; + register int ncount; + + printf(" (v %d.%d):", + (int)target_level & 0xff, + (int)(target_level >> 8) & 0xff); + + while (len > 0 && bp < ep) { + TCHECK2(bp[0], 8); + laddr = bp; + bp += 4; + metric = *bp++; + thresh = *bp++; + flags = *bp++; + ncount = *bp++; + len -= 8; + while (--ncount >= 0 && (len >= 4) && (bp + 4) <= ep) { + printf(" [%s -> ", ipaddr_string(laddr)); + printf("%s (%d/%d", ipaddr_string(bp), + metric, thresh); + if (flags & DVMRP_NF_TUNNEL) + printf("/tunnel"); + if (flags & DVMRP_NF_SRCRT) + printf("/srcrt"); + if (flags & DVMRP_NF_QUERIER) + printf("/querier"); + if (flags & DVMRP_NF_DISABLED) + printf("/disabled"); + if (flags & DVMRP_NF_DOWN) + printf("/down"); + printf(")]"); + bp += 4; + len -= 4; + } + if (ncount != -1) { + printf(" [|]"); + return (0); + } + } + return (0); +trunc: + return (-1); +} + +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 (0); +trunc: + return (-1); +} + +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 (0); +trunc: + return (-1); +} + +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 (0); +trunc: + return (-1); +}
diff --git a/tcpdump-4.3.0/print-eap.c b/tcpdump-4.3.0/print-eap.c new file mode 100644 index 0000000..9fb333a --- /dev/null +++ b/tcpdump-4.3.0/print-eap.c
@@ -0,0 +1,307 @@ +/* + * Copyright (c) 2004 - Michael Richardson <mcr@xelerance.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * Format and print EAP packets. + * + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-eap.c,v 1.5 2007-10-04 16:41:33 hannes Exp $"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> +#include <string.h> + +#include "netdissect.h" +#include "interface.h" +#include "addrtoname.h" +#include "extract.h" +#include "ether.h" + +#define EAP_FRAME_TYPE_PACKET 0 +#define EAP_FRAME_TYPE_START 1 +#define EAP_FRAME_TYPE_LOGOFF 2 +#define EAP_FRAME_TYPE_KEY 3 +#define EAP_FRAME_TYPE_ENCAP_ASF_ALERT 4 + +struct eap_frame_t { + unsigned char version; + unsigned char type; + unsigned char length[2]; +}; + +static const struct tok eap_frame_type_values[] = { + { EAP_FRAME_TYPE_PACKET, "EAP packet" }, + { EAP_FRAME_TYPE_START, "EAPOL start" }, + { EAP_FRAME_TYPE_LOGOFF, "EAPOL logoff" }, + { EAP_FRAME_TYPE_KEY, "EAPOL key" }, + { EAP_FRAME_TYPE_ENCAP_ASF_ALERT, "Encapsulated ASF alert" }, + { 0, NULL} +}; + +/* RFC 3748 */ +struct eap_packet_t { + unsigned char code; + unsigned char id; + unsigned char length[2]; +}; + +#define EAP_REQUEST 1 +#define EAP_RESPONSE 2 +#define EAP_SUCCESS 3 +#define EAP_FAILURE 4 + +static const struct tok eap_code_values[] = { + { EAP_REQUEST, "Request" }, + { EAP_RESPONSE, "Response" }, + { EAP_SUCCESS, "Success" }, + { EAP_FAILURE, "Failure" }, + { 0, NULL} +}; + +#define EAP_TYPE_NO_PROPOSED 0 +#define EAP_TYPE_IDENTITY 1 +#define EAP_TYPE_NOTIFICATION 2 +#define EAP_TYPE_NAK 3 +#define EAP_TYPE_MD5_CHALLENGE 4 +#define EAP_TYPE_OTP 5 +#define EAP_TYPE_GTC 6 +#define EAP_TYPE_TLS 13 /* RFC 2716 */ +#define EAP_TYPE_SIM 18 /* RFC 4186 */ +#define EAP_TYPE_TTLS 21 /* draft-funk-eap-ttls-v0-01.txt */ +#define EAP_TYPE_AKA 23 /* RFC 4187 */ +#define EAP_TYPE_FAST 43 /* RFC 4851 */ +#define EAP_TYPE_EXPANDED_TYPES 254 +#define EAP_TYPE_EXPERIMENTAL 255 + +static const struct tok eap_type_values[] = { + { EAP_TYPE_NO_PROPOSED, "No proposed" }, + { EAP_TYPE_IDENTITY, "Identity" }, + { EAP_TYPE_NOTIFICATION, "Notification" }, + { EAP_TYPE_NAK, "Nak" }, + { EAP_TYPE_MD5_CHALLENGE, "MD5-challenge" }, + { EAP_TYPE_OTP, "OTP" }, + { EAP_TYPE_GTC, "GTC" }, + { EAP_TYPE_TLS, "TLS" }, + { EAP_TYPE_SIM, "SIM" }, + { EAP_TYPE_TTLS, "TTLS" }, + { EAP_TYPE_AKA, "AKA" }, + { EAP_TYPE_FAST, "FAST" }, + { EAP_TYPE_EXPANDED_TYPES, "Expanded types" }, + { EAP_TYPE_EXPERIMENTAL, "Experimental" }, + { 0, NULL} +}; + +#define EAP_TLS_EXTRACT_BIT_L(x) (((x)&0x80)>>7) + +/* RFC 2716 - EAP TLS bits */ +#define EAP_TLS_FLAGS_LEN_INCLUDED (1 << 7) +#define EAP_TLS_FLAGS_MORE_FRAGMENTS (1 << 6) +#define EAP_TLS_FLAGS_START (1 << 5) + +static const struct tok eap_tls_flags_values[] = { + { EAP_TLS_FLAGS_LEN_INCLUDED, "L bit" }, + { EAP_TLS_FLAGS_MORE_FRAGMENTS, "More fragments bit"}, + { EAP_TLS_FLAGS_START, "Start bit"}, + { 0, NULL} +}; + +#define EAP_TTLS_VERSION(x) ((x)&0x07) + +/* EAP-AKA and EAP-SIM - RFC 4187 */ +#define EAP_AKA_CHALLENGE 1 +#define EAP_AKA_AUTH_REJECT 2 +#define EAP_AKA_SYNC_FAILURE 4 +#define EAP_AKA_IDENTITY 5 +#define EAP_SIM_START 10 +#define EAP_SIM_CHALLENGE 11 +#define EAP_AKA_NOTIFICATION 12 +#define EAP_AKA_REAUTH 13 +#define EAP_AKA_CLIENT_ERROR 14 + +static const struct tok eap_aka_subtype_values[] = { + { EAP_AKA_CHALLENGE, "Challenge" }, + { EAP_AKA_AUTH_REJECT, "Auth reject" }, + { EAP_AKA_SYNC_FAILURE, "Sync failure" }, + { EAP_AKA_IDENTITY, "Identity" }, + { EAP_SIM_START, "Start" }, + { EAP_SIM_CHALLENGE, "Challenge" }, + { EAP_AKA_NOTIFICATION, "Notification" }, + { EAP_AKA_REAUTH, "Reauth" }, + { EAP_AKA_CLIENT_ERROR, "Client error" }, + { 0, NULL} +}; + +/* + * Print EAP requests / responses + */ +void +eap_print(netdissect_options *ndo _U_, + register const u_char *cp, + u_int length _U_) +{ + const struct eap_frame_t *eap; + const u_char *tptr; + u_int tlen, type, subtype; + int count=0, len; + + tptr = cp; + tlen = length; + eap = (const struct eap_frame_t *)cp; + TCHECK(*eap); + + /* in non-verbose mode just lets print the basic info */ + if (vflag < 1) { + printf("%s (%u) v%u, len %u", + tok2str(eap_frame_type_values, "unknown", eap->type), + eap->type, + eap->version, + EXTRACT_16BITS(eap->length)); + return; + } + + printf("%s (%u) v%u, len %u", + tok2str(eap_frame_type_values, "unknown", eap->type), + eap->type, + eap->version, + EXTRACT_16BITS(eap->length)); + + tptr += sizeof(const struct eap_frame_t); + tlen -= sizeof(const struct eap_frame_t); + + switch (eap->type) { + case EAP_FRAME_TYPE_PACKET: + type = *(tptr); + len = EXTRACT_16BITS(tptr+2); + printf(", %s (%u), id %u, len %u", + tok2str(eap_code_values, "unknown", type), + type, + *(tptr+1), + len); + + if (!TTEST2(*tptr, len)) + goto trunc; + + if (type <= 2) { /* For EAP_REQUEST and EAP_RESPONSE only */ + subtype = *(tptr+4); + printf("\n\t\t Type %s (%u)", + tok2str(eap_type_values, "unknown", *(tptr+4)), + *(tptr+4)); + + switch (subtype) { + case EAP_TYPE_IDENTITY: + if (len - 5 > 0) { + printf(", Identity: "); + safeputs((const char *)tptr+5, len-5); + } + break; + + case EAP_TYPE_NOTIFICATION: + if (len - 5 > 0) { + printf(", Notification: "); + safeputs((const char *)tptr+5, len-5); + } + break; + + case EAP_TYPE_NAK: + count = 5; + + /* + * one or more octets indicating + * the desired authentication + * type one octet per type + */ + while (count < len) { + printf(" %s (%u),", + tok2str(eap_type_values, "unknown", *(tptr+count)), + *(tptr+count)); + count++; + } + break; + + case EAP_TYPE_TTLS: + printf(" TTLSv%u", + EAP_TTLS_VERSION(*(tptr+5))); /* fall through */ + case EAP_TYPE_TLS: + printf(" flags [%s] 0x%02x,", + bittok2str(eap_tls_flags_values, "none", *(tptr+5)), + *(tptr+5)); + + if (EAP_TLS_EXTRACT_BIT_L(*(tptr+5))) { + printf(" len %u", EXTRACT_32BITS(tptr+6)); + } + break; + + case EAP_TYPE_FAST: + printf(" FASTv%u", + EAP_TTLS_VERSION(*(tptr+5))); + printf(" flags [%s] 0x%02x,", + bittok2str(eap_tls_flags_values, "none", *(tptr+5)), + *(tptr+5)); + + if (EAP_TLS_EXTRACT_BIT_L(*(tptr+5))) { + printf(" len %u", EXTRACT_32BITS(tptr+6)); + } + + /* FIXME - TLV attributes follow */ + break; + + case EAP_TYPE_AKA: + case EAP_TYPE_SIM: + printf(" subtype [%s] 0x%02x,", + tok2str(eap_aka_subtype_values, "unknown", *(tptr+5)), + *(tptr+5)); + + /* FIXME - TLV attributes follow */ + break; + + case EAP_TYPE_MD5_CHALLENGE: + case EAP_TYPE_OTP: + case EAP_TYPE_GTC: + case EAP_TYPE_EXPANDED_TYPES: + case EAP_TYPE_EXPERIMENTAL: + default: + break; + } + } + break; + + case EAP_FRAME_TYPE_LOGOFF: + case EAP_FRAME_TYPE_ENCAP_ASF_ALERT: + default: + break; + } + return; + + trunc: + printf("\n\t[|EAP]"); +} + +/* + * Local Variables: + * c-basic-offset: 4 + * End: + */
diff --git a/tcpdump-4.3.0/print-egp.c b/tcpdump-4.3.0/print-egp.c new file mode 100644 index 0000000..4a1d046 --- /dev/null +++ b/tcpdump-4.3.0/print-egp.c
@@ -0,0 +1,362 @@ +/* + * Copyright (c) 1991, 1992, 1993, 1994, 1995, 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 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * Initial contribution from Jeff Honig (jch@MITCHELL.CIT.CORNELL.EDU). + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-egp.c,v 1.38 2006-02-11 22:13:24 hannes Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> + +#include "interface.h" +#include "addrtoname.h" +#include "extract.h" + +#include "ip.h" + +struct egp_packet { + u_int8_t egp_version; +#define EGP_VERSION 2 + 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_int8_t egp_code; +#define EGPC_REQUEST 0 +#define EGPC_CONFIRM 1 +#define EGPC_REFUSE 2 +#define EGPC_CEASE 3 +#define EGPC_CEASEACK 4 +#define EGPC_HELLO 0 +#define EGPC_HEARDU 1 + u_int8_t egp_status; +#define EGPS_UNSPEC 0 +#define EGPS_ACTIVE 1 +#define EGPS_PASSIVE 2 +#define EGPS_NORES 3 +#define EGPS_ADMIN 4 +#define EGPS_GODOWN 5 +#define EGPS_PARAM 6 +#define EGPS_PROTO 7 +#define EGPS_INDET 0 +#define EGPS_UP 1 +#define EGPS_DOWN 2 +#define EGPS_UNSOL 0x80 + u_int16_t egp_checksum; + u_int16_t egp_as; + u_int16_t egp_sequence; + union { + 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 +#define EGPR_NOREACH 3 +#define EGPR_XSPOLL 4 +#define EGPR_NORESP 5 +#define EGPR_UVERSION 6 + } egp_handg; +#define egp_hello egp_handg.egpu_hello +#define egp_intgw egp_handg.egpu_gws[0] +#define egp_extgw egp_handg.egpu_gws[1] +#define egp_reason egp_handg.egpu_reason + union { + u_int16_t egpu_poll; + u_int32_t egpu_sourcenet; + } egp_pands; +#define egp_poll egp_pands.egpu_poll +#define egp_sourcenet egp_pands.egpu_sourcenet +}; + +const char *egp_acquire_codes[] = { + "request", + "confirm", + "refuse", + "cease", + "cease_ack" +}; + +const char *egp_acquire_status[] = { + "unspecified", + "active_mode", + "passive_mode", + "insufficient_resources", + "administratively_prohibited", + "going_down", + "parameter_violation", + "protocol_violation" +}; + +const char *egp_reach_codes[] = { + "hello", + "i-h-u" +}; + +const char *egp_status_updown[] = { + "indeterminate", + "up", + "down" +}; + +const char *egp_reasons[] = { + "unspecified", + "bad_EGP_header_format", + "bad_EGP_data_field_format", + "reachability_info_unavailable", + "excessive_polling_rate", + "no_response", + "unsupported_version" +}; + +static void +egpnrprint(register const struct egp_packet *egp) +{ + 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; + const char *comma; + + addr = egp->egp_sourcenet; + if (IN_CLASSA(addr)) { + net = addr & IN_CLASSA_NET; + netlen = 1; + } else if (IN_CLASSB(addr)) { + net = addr & IN_CLASSB_NET; + netlen = 2; + } else if (IN_CLASSC(addr)) { + net = addr & IN_CLASSC_NET; + netlen = 3; + } else { + net = 0; + netlen = 0; + } + cp = (u_int8_t *)(egp + 1); + + t_gateways = egp->egp_intgw + egp->egp_extgw; + for (gateways = 0; gateways < t_gateways; ++gateways) { + /* Pickup host part of gateway address */ + addr = 0; + TCHECK2(cp[0], 4 - netlen); + switch (netlen) { + + case 1: + addr = *cp++; + /* fall through */ + case 2: + addr = (addr << 8) | *cp++; + /* fall through */ + case 3: + addr = (addr << 8) | *cp++; + } + addr |= net; + TCHECK2(cp[0], 1); + distances = *cp++; + printf(" %s %s ", + gateways < (int)egp->egp_intgw ? "int" : "ext", + ipaddr_string(&addr)); + + comma = ""; + putchar('('); + while (--distances >= 0) { + TCHECK2(cp[0], 2); + printf("%sd%d:", comma, (int)*cp++); + comma = ", "; + networks = *cp++; + while (--networks >= 0) { + /* Pickup network number */ + TCHECK2(cp[0], 1); + addr = (u_int32_t)*cp++ << 24; + if (IN_CLASSB(addr)) { + TCHECK2(cp[0], 1); + addr |= (u_int32_t)*cp++ << 16; + } else if (!IN_CLASSA(addr)) { + TCHECK2(cp[0], 2); + addr |= (u_int32_t)*cp++ << 16; + addr |= (u_int32_t)*cp++ << 8; + } + printf(" %s", ipaddr_string(&addr)); + } + } + putchar(')'); + } + return; +trunc: + fputs("[|]", stdout); +} + +void +egp_print(register const u_int8_t *bp, register u_int length) +{ + register const struct egp_packet *egp; + register int status; + register int code; + register int type; + + egp = (struct egp_packet *)bp; + if (!TTEST2(*egp, length)) { + printf("[|egp]"); + return; + } + + if (!vflag) { + printf("EGPv%u, AS %u, seq %u, length %u", + egp->egp_version, + EXTRACT_16BITS(&egp->egp_as), + EXTRACT_16BITS(&egp->egp_sequence), + length); + return; + } else + printf("EGPv%u, length %u", + egp->egp_version, + length); + + if (egp->egp_version != EGP_VERSION) { + printf("[version %d]", egp->egp_version); + return; + } + + type = egp->egp_type; + code = egp->egp_code; + status = egp->egp_status; + + switch (type) { + case EGPT_ACQUIRE: + printf(" acquire"); + switch (code) { + case EGPC_REQUEST: + case EGPC_CONFIRM: + printf(" %s", egp_acquire_codes[code]); + switch (status) { + case EGPS_UNSPEC: + case EGPS_ACTIVE: + case EGPS_PASSIVE: + printf(" %s", egp_acquire_status[status]); + break; + + default: + printf(" [status %d]", status); + break; + } + printf(" hello:%d poll:%d", + EXTRACT_16BITS(&egp->egp_hello), + EXTRACT_16BITS(&egp->egp_poll)); + break; + + case EGPC_REFUSE: + case EGPC_CEASE: + case EGPC_CEASEACK: + printf(" %s", egp_acquire_codes[code]); + switch (status ) { + case EGPS_UNSPEC: + case EGPS_NORES: + case EGPS_ADMIN: + case EGPS_GODOWN: + case EGPS_PARAM: + case EGPS_PROTO: + printf(" %s", egp_acquire_status[status]); + break; + + default: + printf("[status %d]", status); + break; + } + break; + + default: + printf("[code %d]", code); + break; + } + break; + + case EGPT_REACH: + switch (code) { + + case EGPC_HELLO: + case EGPC_HEARDU: + printf(" %s", egp_reach_codes[code]); + if (status <= EGPS_DOWN) + printf(" state:%s", egp_status_updown[status]); + else + printf(" [status %d]", status); + break; + + default: + printf("[reach code %d]", code); + break; + } + break; + + case EGPT_POLL: + printf(" poll"); + if (egp->egp_status <= EGPS_DOWN) + printf(" state:%s", egp_status_updown[status]); + else + printf(" [status %d]", status); + printf(" net:%s", ipaddr_string(&egp->egp_sourcenet)); + break; + + case EGPT_UPDATE: + printf(" update"); + if (status & EGPS_UNSOL) { + status &= ~EGPS_UNSOL; + printf(" unsolicited"); + } + if (status <= EGPS_DOWN) + printf(" state:%s", egp_status_updown[status]); + else + printf(" [status %d]", status); + printf(" %s int %d ext %d", + ipaddr_string(&egp->egp_sourcenet), + egp->egp_intgw, + egp->egp_extgw); + if (vflag) + egpnrprint(egp); + break; + + case EGPT_ERROR: + printf(" error"); + if (status <= EGPS_DOWN) + printf(" state:%s", egp_status_updown[status]); + else + printf(" [status %d]", status); + + if (EXTRACT_16BITS(&egp->egp_reason) <= EGPR_UVERSION) + printf(" %s", egp_reasons[EXTRACT_16BITS(&egp->egp_reason)]); + else + printf(" [reason %d]", EXTRACT_16BITS(&egp->egp_reason)); + break; + + default: + printf("[type %d]", type); + break; + } +}
diff --git a/tcpdump-4.3.0/print-eigrp.c b/tcpdump-4.3.0/print-eigrp.c new file mode 100644 index 0000000..4f941d9 --- /dev/null +++ b/tcpdump-4.3.0/print-eigrp.c
@@ -0,0 +1,480 @@ +/* + * Copyright (c) 1998-2004 Hannes Gredler <hannes@tcpdump.org> + * The TCPDUMP project + * + * 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. + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-eigrp.c,v 1.7 2005-05-06 02:53:26 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" + +/* + * packet format documented at + * http://www.rhyshaden.com/eigrp.htm + */ + +struct eigrp_common_header { + u_int8_t version; + u_int8_t opcode; + u_int8_t checksum[2]; + u_int8_t flags[4]; + u_int8_t seq[4]; + u_int8_t ack[4]; + u_int8_t asn[4]; +}; + +#define EIGRP_VERSION 2 + +#define EIGRP_OPCODE_UPDATE 1 +#define EIGRP_OPCODE_QUERY 3 +#define EIGRP_OPCODE_REPLY 4 +#define EIGRP_OPCODE_HELLO 5 +#define EIGRP_OPCODE_IPXSAP 6 +#define EIGRP_OPCODE_PROBE 7 + +static const struct tok eigrp_opcode_values[] = { + { EIGRP_OPCODE_UPDATE, "Update" }, + { EIGRP_OPCODE_QUERY, "Query" }, + { EIGRP_OPCODE_REPLY, "Reply" }, + { EIGRP_OPCODE_HELLO, "Hello" }, + { EIGRP_OPCODE_IPXSAP, "IPX SAP" }, + { EIGRP_OPCODE_PROBE, "Probe" }, + { 0, NULL} +}; + +static const struct tok eigrp_common_header_flag_values[] = { + { 0x01, "Init" }, + { 0x02, "Conditionally Received" }, + { 0, NULL} +}; + +struct eigrp_tlv_header { + u_int8_t type[2]; + u_int8_t length[2]; +}; + +#define EIGRP_TLV_GENERAL_PARM 0x0001 +#define EIGRP_TLV_AUTH 0x0002 +#define EIGRP_TLV_SEQ 0x0003 +#define EIGRP_TLV_SW_VERSION 0x0004 +#define EIGRP_TLV_MCAST_SEQ 0x0005 +#define EIGRP_TLV_IP_INT 0x0102 +#define EIGRP_TLV_IP_EXT 0x0103 +#define EIGRP_TLV_AT_INT 0x0202 +#define EIGRP_TLV_AT_EXT 0x0203 +#define EIGRP_TLV_AT_CABLE_SETUP 0x0204 +#define EIGRP_TLV_IPX_INT 0x0302 +#define EIGRP_TLV_IPX_EXT 0x0303 + +static const struct tok eigrp_tlv_values[] = { + { EIGRP_TLV_GENERAL_PARM, "General Parameters"}, + { EIGRP_TLV_AUTH, "Authentication"}, + { EIGRP_TLV_SEQ, "Sequence"}, + { EIGRP_TLV_SW_VERSION, "Software Version"}, + { EIGRP_TLV_MCAST_SEQ, "Next Multicast Sequence"}, + { EIGRP_TLV_IP_INT, "IP Internal routes"}, + { EIGRP_TLV_IP_EXT, "IP External routes"}, + { EIGRP_TLV_AT_INT, "AppleTalk Internal routes"}, + { EIGRP_TLV_AT_EXT, "AppleTalk External routes"}, + { EIGRP_TLV_AT_CABLE_SETUP, "AppleTalk Cable setup"}, + { EIGRP_TLV_IPX_INT, "IPX Internal routes"}, + { EIGRP_TLV_IPX_EXT, "IPX External routes"}, + { 0, NULL} +}; + +struct eigrp_tlv_general_parm_t { + u_int8_t k1; + u_int8_t k2; + u_int8_t k3; + u_int8_t k4; + u_int8_t k5; + u_int8_t res; + u_int8_t holdtime[2]; +}; + +struct eigrp_tlv_sw_version_t { + u_int8_t ios_major; + u_int8_t ios_minor; + u_int8_t eigrp_major; + u_int8_t eigrp_minor; +}; + +struct eigrp_tlv_ip_int_t { + u_int8_t nexthop[4]; + u_int8_t delay[4]; + u_int8_t bandwidth[4]; + u_int8_t mtu[3]; + u_int8_t hopcount; + u_int8_t reliability; + u_int8_t load; + u_int8_t reserved[2]; + u_int8_t plen; + u_int8_t destination; /* variable length [1-4] bytes encoding */ +}; + +struct eigrp_tlv_ip_ext_t { + u_int8_t nexthop[4]; + u_int8_t origin_router[4]; + u_int8_t origin_as[4]; + u_int8_t tag[4]; + u_int8_t metric[4]; + u_int8_t reserved[2]; + u_int8_t proto_id; + u_int8_t flags; + u_int8_t delay[4]; + u_int8_t bandwidth[4]; + u_int8_t mtu[3]; + u_int8_t hopcount; + u_int8_t reliability; + u_int8_t load; + u_int8_t reserved2[2]; + u_int8_t plen; + u_int8_t destination; /* variable length [1-4] bytes encoding */ +}; + +struct eigrp_tlv_at_cable_setup_t { + u_int8_t cable_start[2]; + u_int8_t cable_end[2]; + u_int8_t router_id[4]; +}; + +struct eigrp_tlv_at_int_t { + u_int8_t nexthop[4]; + u_int8_t delay[4]; + u_int8_t bandwidth[4]; + u_int8_t mtu[3]; + u_int8_t hopcount; + u_int8_t reliability; + u_int8_t load; + u_int8_t reserved[2]; + u_int8_t cable_start[2]; + u_int8_t cable_end[2]; +}; + +struct eigrp_tlv_at_ext_t { + u_int8_t nexthop[4]; + u_int8_t origin_router[4]; + u_int8_t origin_as[4]; + u_int8_t tag[4]; + u_int8_t proto_id; + u_int8_t flags; + u_int8_t metric[2]; + u_int8_t delay[4]; + u_int8_t bandwidth[4]; + u_int8_t mtu[3]; + u_int8_t hopcount; + u_int8_t reliability; + u_int8_t load; + u_int8_t reserved2[2]; + u_int8_t cable_start[2]; + u_int8_t cable_end[2]; +}; + +static const struct tok eigrp_ext_proto_id_values[] = { + { 0x01, "IGRP" }, + { 0x02, "EIGRP" }, + { 0x03, "Static" }, + { 0x04, "RIP" }, + { 0x05, "Hello" }, + { 0x06, "OSPF" }, + { 0x07, "IS-IS" }, + { 0x08, "EGP" }, + { 0x09, "BGP" }, + { 0x0a, "IDRP" }, + { 0x0b, "Connected" }, + { 0, NULL} +}; + +void +eigrp_print(register const u_char *pptr, register u_int len) { + + const struct eigrp_common_header *eigrp_com_header; + const struct eigrp_tlv_header *eigrp_tlv_header; + const u_char *tptr,*tlv_tptr; + u_int tlen,eigrp_tlv_len,eigrp_tlv_type,tlv_tlen, byte_length, bit_length; + u_int8_t prefix[4]; + + union { + const struct eigrp_tlv_general_parm_t *eigrp_tlv_general_parm; + const struct eigrp_tlv_sw_version_t *eigrp_tlv_sw_version; + const struct eigrp_tlv_ip_int_t *eigrp_tlv_ip_int; + const struct eigrp_tlv_ip_ext_t *eigrp_tlv_ip_ext; + const struct eigrp_tlv_at_cable_setup_t *eigrp_tlv_at_cable_setup; + const struct eigrp_tlv_at_int_t *eigrp_tlv_at_int; + const struct eigrp_tlv_at_ext_t *eigrp_tlv_at_ext; + } tlv_ptr; + + tptr=pptr; + eigrp_com_header = (const struct eigrp_common_header *)pptr; + TCHECK(*eigrp_com_header); + + /* + * Sanity checking of the header. + */ + if (eigrp_com_header->version != EIGRP_VERSION) { + printf("EIGRP version %u packet not supported",eigrp_com_header->version); + return; + } + + /* in non-verbose mode just lets print the basic Message Type*/ + if (vflag < 1) { + printf("EIGRP %s, length: %u", + tok2str(eigrp_opcode_values, "unknown (%u)",eigrp_com_header->opcode), + len); + return; + } + + /* ok they seem to want to know everything - lets fully decode it */ + + tlen=len-sizeof(struct eigrp_common_header); + + /* FIXME print other header info */ + printf("\n\tEIGRP v%u, opcode: %s (%u), chksum: 0x%04x, Flags: [%s]\n\tseq: 0x%08x, ack: 0x%08x, AS: %u, length: %u", + eigrp_com_header->version, + tok2str(eigrp_opcode_values, "unknown, type: %u",eigrp_com_header->opcode), + eigrp_com_header->opcode, + EXTRACT_16BITS(&eigrp_com_header->checksum), + tok2str(eigrp_common_header_flag_values, + "none", + EXTRACT_32BITS(&eigrp_com_header->flags)), + EXTRACT_32BITS(&eigrp_com_header->seq), + EXTRACT_32BITS(&eigrp_com_header->ack), + EXTRACT_32BITS(&eigrp_com_header->asn), + tlen); + + tptr+=sizeof(const struct eigrp_common_header); + + while(tlen>0) { + /* did we capture enough for fully decoding the object header ? */ + TCHECK2(*tptr, sizeof(struct eigrp_tlv_header)); + + eigrp_tlv_header = (const struct eigrp_tlv_header *)tptr; + eigrp_tlv_len=EXTRACT_16BITS(&eigrp_tlv_header->length); + eigrp_tlv_type=EXTRACT_16BITS(&eigrp_tlv_header->type); + + + if (eigrp_tlv_len < sizeof(struct eigrp_tlv_header) || + eigrp_tlv_len > tlen) { + print_unknown_data(tptr+sizeof(struct eigrp_tlv_header),"\n\t ",tlen); + return; + } + + printf("\n\t %s TLV (0x%04x), length: %u", + tok2str(eigrp_tlv_values, + "Unknown", + eigrp_tlv_type), + eigrp_tlv_type, + eigrp_tlv_len); + + tlv_tptr=tptr+sizeof(struct eigrp_tlv_header); + tlv_tlen=eigrp_tlv_len-sizeof(struct eigrp_tlv_header); + + /* did we capture enough for fully decoding the object ? */ + TCHECK2(*tptr, eigrp_tlv_len); + + switch(eigrp_tlv_type) { + + case EIGRP_TLV_GENERAL_PARM: + tlv_ptr.eigrp_tlv_general_parm = (const struct eigrp_tlv_general_parm_t *)tlv_tptr; + + printf("\n\t holdtime: %us, k1 %u, k2 %u, k3 %u, k4 %u, k5 %u", + EXTRACT_16BITS(tlv_ptr.eigrp_tlv_general_parm->holdtime), + tlv_ptr.eigrp_tlv_general_parm->k1, + tlv_ptr.eigrp_tlv_general_parm->k2, + tlv_ptr.eigrp_tlv_general_parm->k3, + tlv_ptr.eigrp_tlv_general_parm->k4, + tlv_ptr.eigrp_tlv_general_parm->k5); + break; + + case EIGRP_TLV_SW_VERSION: + tlv_ptr.eigrp_tlv_sw_version = (const struct eigrp_tlv_sw_version_t *)tlv_tptr; + + printf("\n\t IOS version: %u.%u, EIGRP version %u.%u", + tlv_ptr.eigrp_tlv_sw_version->ios_major, + tlv_ptr.eigrp_tlv_sw_version->ios_minor, + tlv_ptr.eigrp_tlv_sw_version->eigrp_major, + tlv_ptr.eigrp_tlv_sw_version->eigrp_minor); + break; + + case EIGRP_TLV_IP_INT: + tlv_ptr.eigrp_tlv_ip_int = (const struct eigrp_tlv_ip_int_t *)tlv_tptr; + + bit_length = tlv_ptr.eigrp_tlv_ip_int->plen; + if (bit_length > 32) { + printf("\n\t illegal prefix length %u",bit_length); + break; + } + byte_length = (bit_length + 7) / 8; /* variable length encoding */ + memset(prefix, 0, 4); + memcpy(prefix,&tlv_ptr.eigrp_tlv_ip_int->destination,byte_length); + + printf("\n\t IPv4 prefix: %15s/%u, nexthop: ", + ipaddr_string(prefix), + bit_length); + if (EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_ip_int->nexthop) == 0) + printf("self"); + else + printf("%s",ipaddr_string(&tlv_ptr.eigrp_tlv_ip_int->nexthop)); + + printf("\n\t delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u", + (EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_ip_int->delay)/100), + EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_ip_int->bandwidth), + EXTRACT_24BITS(&tlv_ptr.eigrp_tlv_ip_int->mtu), + tlv_ptr.eigrp_tlv_ip_int->hopcount, + tlv_ptr.eigrp_tlv_ip_int->reliability, + tlv_ptr.eigrp_tlv_ip_int->load); + break; + + case EIGRP_TLV_IP_EXT: + tlv_ptr.eigrp_tlv_ip_ext = (const struct eigrp_tlv_ip_ext_t *)tlv_tptr; + + bit_length = tlv_ptr.eigrp_tlv_ip_ext->plen; + if (bit_length > 32) { + printf("\n\t illegal prefix length %u",bit_length); + break; + } + byte_length = (bit_length + 7) / 8; /* variable length encoding */ + memset(prefix, 0, 4); + memcpy(prefix,&tlv_ptr.eigrp_tlv_ip_ext->destination,byte_length); + + printf("\n\t IPv4 prefix: %15s/%u, nexthop: ", + ipaddr_string(prefix), + bit_length); + if (EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_ip_ext->nexthop) == 0) + printf("self"); + else + printf("%s",ipaddr_string(&tlv_ptr.eigrp_tlv_ip_ext->nexthop)); + + printf("\n\t origin-router %s, origin-as %u, origin-proto %s, flags [0x%02x], tag 0x%08x, metric %u", + ipaddr_string(tlv_ptr.eigrp_tlv_ip_ext->origin_router), + EXTRACT_32BITS(tlv_ptr.eigrp_tlv_ip_ext->origin_as), + tok2str(eigrp_ext_proto_id_values,"unknown",tlv_ptr.eigrp_tlv_ip_ext->proto_id), + tlv_ptr.eigrp_tlv_ip_ext->flags, + EXTRACT_32BITS(tlv_ptr.eigrp_tlv_ip_ext->tag), + EXTRACT_32BITS(tlv_ptr.eigrp_tlv_ip_ext->metric)); + + printf("\n\t delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u", + (EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_ip_ext->delay)/100), + EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_ip_ext->bandwidth), + EXTRACT_24BITS(&tlv_ptr.eigrp_tlv_ip_ext->mtu), + tlv_ptr.eigrp_tlv_ip_ext->hopcount, + tlv_ptr.eigrp_tlv_ip_ext->reliability, + tlv_ptr.eigrp_tlv_ip_ext->load); + break; + + case EIGRP_TLV_AT_CABLE_SETUP: + tlv_ptr.eigrp_tlv_at_cable_setup = (const struct eigrp_tlv_at_cable_setup_t *)tlv_tptr; + + printf("\n\t Cable-range: %u-%u, Router-ID %u", + EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_cable_setup->cable_start), + EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_cable_setup->cable_end), + EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_at_cable_setup->router_id)); + break; + + case EIGRP_TLV_AT_INT: + tlv_ptr.eigrp_tlv_at_int = (const struct eigrp_tlv_at_int_t *)tlv_tptr; + + printf("\n\t Cable-Range: %u-%u, nexthop: ", + EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_int->cable_start), + EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_int->cable_end)); + + if (EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_at_int->nexthop) == 0) + printf("self"); + else + printf("%u.%u", + EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_int->nexthop), + EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_int->nexthop[2])); + + printf("\n\t delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u", + (EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_at_int->delay)/100), + EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_at_int->bandwidth), + EXTRACT_24BITS(&tlv_ptr.eigrp_tlv_at_int->mtu), + tlv_ptr.eigrp_tlv_at_int->hopcount, + tlv_ptr.eigrp_tlv_at_int->reliability, + tlv_ptr.eigrp_tlv_at_int->load); + break; + + case EIGRP_TLV_AT_EXT: + tlv_ptr.eigrp_tlv_at_ext = (const struct eigrp_tlv_at_ext_t *)tlv_tptr; + + printf("\n\t Cable-Range: %u-%u, nexthop: ", + EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_ext->cable_start), + EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_ext->cable_end)); + + if (EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_at_ext->nexthop) == 0) + printf("self"); + else + printf("%u.%u", + EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_ext->nexthop), + EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_ext->nexthop[2])); + + printf("\n\t origin-router %u, origin-as %u, origin-proto %s, flags [0x%02x], tag 0x%08x, metric %u", + EXTRACT_32BITS(tlv_ptr.eigrp_tlv_at_ext->origin_router), + EXTRACT_32BITS(tlv_ptr.eigrp_tlv_at_ext->origin_as), + tok2str(eigrp_ext_proto_id_values,"unknown",tlv_ptr.eigrp_tlv_at_ext->proto_id), + tlv_ptr.eigrp_tlv_at_ext->flags, + EXTRACT_32BITS(tlv_ptr.eigrp_tlv_at_ext->tag), + EXTRACT_16BITS(tlv_ptr.eigrp_tlv_at_ext->metric)); + + printf("\n\t delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u", + (EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_at_ext->delay)/100), + EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_at_ext->bandwidth), + EXTRACT_24BITS(&tlv_ptr.eigrp_tlv_at_ext->mtu), + tlv_ptr.eigrp_tlv_at_ext->hopcount, + tlv_ptr.eigrp_tlv_at_ext->reliability, + tlv_ptr.eigrp_tlv_at_ext->load); + break; + + /* + * FIXME those are the defined TLVs that lack a decoder + * you are welcome to contribute code ;-) + */ + + case EIGRP_TLV_AUTH: + case EIGRP_TLV_SEQ: + case EIGRP_TLV_MCAST_SEQ: + case EIGRP_TLV_IPX_INT: + case EIGRP_TLV_IPX_EXT: + + default: + if (vflag <= 1) + print_unknown_data(tlv_tptr,"\n\t ",tlv_tlen); + break; + } + /* do we want to see an additionally hexdump ? */ + if (vflag > 1) + print_unknown_data(tptr+sizeof(struct eigrp_tlv_header),"\n\t ", + eigrp_tlv_len-sizeof(struct eigrp_tlv_header)); + + tptr+=eigrp_tlv_len; + tlen-=eigrp_tlv_len; + } + return; +trunc: + printf("\n\t\t packet exceeded snapshot"); +}
diff --git a/tcpdump-4.3.0/print-enc.c b/tcpdump-4.3.0/print-enc.c new file mode 100644 index 0000000..5c01f3e --- /dev/null +++ b/tcpdump-4.3.0/print-enc.c
@@ -0,0 +1,98 @@ +/* $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.6 2008-11-18 07:35:32 guy Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <pcap.h> + +#include "interface.h" +#include "extract.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: ", EXTRACT_32BITS(&hdr->spi)); + + length -= ENC_HDRLEN; + caplen -= ENC_HDRLEN; + p += ENC_HDRLEN; + + switch (hdr->af) { + case AF_INET: + ip_print(gndo, p, length); + break; +#ifdef INET6 + case AF_INET6: + ip6_print(gndo, p, length); + break; +#endif /*INET6*/ + } + +out: + return (ENC_HDRLEN); +} + + +/* + * Local Variables: + * c-style: whitesmith + * c-basic-offset: 8 + * End: + */
diff --git a/tcpdump-4.3.0/print-esp.c b/tcpdump-4.3.0/print-esp.c new file mode 100644 index 0000000..ade654a --- /dev/null +++ b/tcpdump-4.3.0/print-esp.c
@@ -0,0 +1,694 @@ +/* $NetBSD: print-ah.c,v 1.4 1996/05/20 00:41:16 fvdl Exp $ */ + +/* + * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 + * 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-esp.c,v 1.58 2007-12-07 00:03:07 mcr Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <string.h> + +#include <tcpdump-stdinc.h> + +#include <stdlib.h> + +#ifdef HAVE_LIBCRYPTO +#ifdef HAVE_OPENSSL_EVP_H +#include <openssl/evp.h> +#endif +#endif + +#include <stdio.h> + +#include "ip.h" +#include "esp.h" +#ifdef INET6 +#include "ip6.h" +#endif + +#include "netdissect.h" +#include "addrtoname.h" +#include "extract.h" + +#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; /* if == 0, then IKEv2 */ + int initiator; + u_char spii[8]; /* for IKEv2 */ + u_char spir[8]; + const EVP_CIPHER *evp; + int ivlen; + int authlen; + u_char authsecret[256]; + int authsecret_len; + u_char secret[256]; /* is that big enough for all secrets? */ + int secretlen; +}; + +/* + * this will adjust ndo_packetp and ndo_snapend to new buffer! + */ +int esp_print_decrypt_buffer_by_ikev2(netdissect_options *ndo, + int initiator, + u_char spii[8], u_char spir[8], + u_char *buf, u_char *end) +{ + struct sa_list *sa; + u_char *iv; + int len; + EVP_CIPHER_CTX ctx; + + /* initiator arg is any non-zero value */ + if(initiator) initiator=1; + + /* see if we can find the SA, and if so, decode it */ + for (sa = ndo->ndo_sa_list_head; sa != NULL; sa = sa->next) { + if (sa->spi == 0 + && initiator == sa->initiator + && memcmp(spii, sa->spii, 8) == 0 + && memcmp(spir, sa->spir, 8) == 0) + break; + } + + if(sa == NULL) return 0; + if(sa->evp == NULL) return 0; + + /* + * remove authenticator, and see if we still have something to + * work with + */ + end = end - sa->authlen; + iv = buf; + buf = buf + sa->ivlen; + len = end-buf; + + if(end <= buf) return 0; + + memset(&ctx, 0, sizeof(ctx)); + if (EVP_CipherInit(&ctx, sa->evp, sa->secret, NULL, 0) < 0) + (*ndo->ndo_warning)(ndo, "espkey init failed"); + EVP_CipherInit(&ctx, NULL, NULL, iv, 0); + EVP_Cipher(&ctx, buf, buf, len); + EVP_CIPHER_CTX_cleanup(&ctx); + + ndo->ndo_packetp = buf; + ndo->ndo_snapend = end; + + return 1; + +} + +static void esp_print_addsa(netdissect_options *ndo, + struct sa_list *sa, int sa_def) +{ + /* copy the "sa" */ + + struct sa_list *nsa; + + nsa = (struct sa_list *)malloc(sizeof(struct sa_list)); + if (nsa == NULL) + (*ndo->ndo_error)(ndo, "ran out of memory to allocate sa structure"); + + *nsa = *sa; + + if (sa_def) + ndo->ndo_sa_default = nsa; + + nsa->next = ndo->ndo_sa_list_head; + ndo->ndo_sa_list_head = nsa; +} + + +static u_int hexdigit(netdissect_options *ndo, char hex) +{ + if (hex >= '0' && hex <= '9') + return (hex - '0'); + else if (hex >= 'A' && hex <= 'F') + return (hex - 'A' + 10); + else if (hex >= 'a' && hex <= 'f') + return (hex - 'a' + 10); + else { + (*ndo->ndo_error)(ndo, "invalid hex digit %c in espsecret\n", hex); + return 0; + } +} + +static u_int hex2byte(netdissect_options *ndo, char *hexstring) +{ + u_int byte; + + byte = (hexdigit(ndo, hexstring[0]) << 4) + hexdigit(ndo, hexstring[1]); + return byte; +} + +/* + * returns size of binary, 0 on failure. + */ +static +int espprint_decode_hex(netdissect_options *ndo, + u_char *binbuf, unsigned int binbuf_len, + char *hex) +{ + unsigned int len; + int i; + + len = strlen(hex) / 2; + + if (len > binbuf_len) { + (*ndo->ndo_warning)(ndo, "secret is too big: %d\n", len); + return 0; + } + + i = 0; + while (hex[0] != '\0' && hex[1]!='\0') { + binbuf[i] = hex2byte(ndo, hex); + hex += 2; + i++; + } + + return i; +} + +/* + * decode the form: SPINUM@IP <tab> ALGONAME:0xsecret + */ + +static int +espprint_decode_encalgo(netdissect_options *ndo, + char *decode, struct sa_list *sa) +{ + int len; + size_t i; + const EVP_CIPHER *evp; + int authlen = 0; + char *colon, *p; + + colon = strchr(decode, ':'); + if (colon == NULL) { + (*ndo->ndo_warning)(ndo, "failed to decode espsecret: %s\n", decode); + return 0; + } + *colon = '\0'; + + len = colon - decode; + if (strlen(decode) > strlen("-hmac96") && + !strcmp(decode + strlen(decode) - strlen("-hmac96"), + "-hmac96")) { + p = strstr(decode, "-hmac96"); + *p = '\0'; + authlen = 12; + } + if (strlen(decode) > strlen("-cbc") && + !strcmp(decode + strlen(decode) - strlen("-cbc"), "-cbc")) { + p = strstr(decode, "-cbc"); + *p = '\0'; + } + evp = EVP_get_cipherbyname(decode); + + if (!evp) { + (*ndo->ndo_warning)(ndo, "failed to find cipher algo %s\n", decode); + sa->evp = NULL; + sa->authlen = 0; + sa->ivlen = 0; + return 0; + } + + sa->evp = evp; + sa->authlen = authlen; + sa->ivlen = EVP_CIPHER_iv_length(evp); + + colon++; + if (colon[0] == '0' && colon[1] == 'x') { + /* decode some hex! */ + + colon += 2; + sa->secretlen = espprint_decode_hex(ndo, sa->secret, sizeof(sa->secret), colon); + if(sa->secretlen == 0) return 0; + } else { + i = strlen(colon); + + if (i < sizeof(sa->secret)) { + memcpy(sa->secret, colon, i); + sa->secretlen = i; + } else { + memcpy(sa->secret, colon, sizeof(sa->secret)); + sa->secretlen = sizeof(sa->secret); + } + } + + return 1; +} + +/* + * for the moment, ignore the auth algorith, just hard code the authenticator + * length. Need to research how openssl looks up HMAC stuff. + */ +static int +espprint_decode_authalgo(netdissect_options *ndo, + char *decode, struct sa_list *sa) +{ + char *colon; + + colon = strchr(decode, ':'); + if (colon == NULL) { + (*ndo->ndo_warning)(ndo, "failed to decode espsecret: %s\n", decode); + return 0; + } + *colon = '\0'; + + if(strcasecmp(colon,"sha1") == 0 || + strcasecmp(colon,"md5") == 0) { + sa->authlen = 12; + } + return 1; +} + +static void esp_print_decode_ikeline(netdissect_options *ndo, char *line, + const char *file, int lineno) +{ + /* it's an IKEv2 secret, store it instead */ + struct sa_list sa1; + + char *init; + char *icookie, *rcookie; + int ilen, rlen; + char *authkey; + char *enckey; + + init = strsep(&line, " \t"); + icookie = strsep(&line, " \t"); + rcookie = strsep(&line, " \t"); + authkey = strsep(&line, " \t"); + enckey = strsep(&line, " \t"); + + /* if any fields are missing */ + if(!init || !icookie || !rcookie || !authkey || !enckey) { + (*ndo->ndo_warning)(ndo, "print_esp: failed to find all fields for ikev2 at %s:%u", + file, lineno); + + return; + } + + ilen = strlen(icookie); + rlen = strlen(rcookie); + + if((init[0]!='I' && init[0]!='R') + || icookie[0]!='0' || icookie[1]!='x' + || rcookie[0]!='0' || rcookie[1]!='x' + || ilen!=18 + || rlen!=18) { + (*ndo->ndo_warning)(ndo, "print_esp: line %s:%u improperly formatted.", + file, lineno); + + (*ndo->ndo_warning)(ndo, "init=%s icookie=%s(%u) rcookie=%s(%u)", + init, icookie, ilen, rcookie, rlen); + + return; + } + + sa1.spi = 0; + sa1.initiator = (init[0] == 'I'); + if(espprint_decode_hex(ndo, sa1.spii, sizeof(sa1.spii), icookie+2)!=8) + return; + + if(espprint_decode_hex(ndo, sa1.spir, sizeof(sa1.spir), rcookie+2)!=8) + return; + + if(!espprint_decode_encalgo(ndo, enckey, &sa1)) return; + + if(!espprint_decode_authalgo(ndo, authkey, &sa1)) return; + + esp_print_addsa(ndo, &sa1, FALSE); +} + +/* + * + * special form: file /name + * causes us to go read from this file instead. + * + */ +static void esp_print_decode_onesecret(netdissect_options *ndo, char *line, + const char *file, int lineno) +{ + 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]; + int lineno=0; + char *nl; + char *filename = line; + + secretfile = fopen(filename, FOPEN_READ_TXT); + if (secretfile == NULL) { + perror(filename); + exit(3); + } + + while (fgets(fileline, sizeof(fileline)-1, secretfile) != NULL) { + lineno++; + /* 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(ndo, fileline, filename, lineno); + } + fclose(secretfile); + + return; + } + + if (spikey && strcasecmp(spikey, "ikev2") == 0) { + esp_print_decode_ikeline(ndo, line, file, lineno); + return; + } + + if (spikey) { + + char *spistr, *foo; + u_int32_t spino; + struct sockaddr_in *sin; +#ifdef INET6 + struct sockaddr_in6 *sin6; +#endif + + spistr = strsep(&spikey, "@"); + + spino = strtoul(spistr, &foo, 0); + if (spistr == foo || !spikey) { + (*ndo->ndo_warning)(ndo, "print_esp: failed to decode spi# %s\n", foo); + return; + } + + sa1.spi = spino; + + sin = (struct sockaddr_in *)&sa1.daddr; +#ifdef INET6 + sin6 = (struct sockaddr_in6 *)&sa1.daddr; + 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 { + (*ndo->ndo_warning)(ndo, "print_esp: can not decode IP# %s\n", spikey); + return; + } + } + + if (decode) { + /* skip any blank spaces */ + while (isspace((unsigned char)*decode)) + decode++; + + if(!espprint_decode_encalgo(ndo, decode, &sa1)) { + return; + } + } + + esp_print_addsa(ndo, &sa1, sa_def); +} + +static void esp_init(netdissect_options *ndo _U_) +{ + + OpenSSL_add_all_algorithms(); + EVP_add_cipher_alias(SN_des_ede3_cbc, "3des"); +} + +void esp_print_decodesecret(netdissect_options *ndo) +{ + char *line; + char *p; + static int initialized = 0; + + if (!initialized) { + esp_init(ndo); + initialized = 1; + } + + p = ndo->ndo_espsecret; + + while (p && p[0] != '\0') { + /* pick out the first line or first thing until a comma */ + if ((line = strsep(&p, "\n,")) == NULL) { + line = p; + p = NULL; + } + + esp_print_decode_onesecret(ndo, line, "cmdline", 0); + } + + ndo->ndo_espsecret = NULL; +} + +#endif + +int +esp_print(netdissect_options *ndo, + const u_char *bp, const int length, 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 newesp *esp; + register const u_char *ep; +#ifdef HAVE_LIBCRYPTO + struct ip *ip; + struct sa_list *sa = NULL; + int espsecret_keylen; +#ifdef INET6 + struct ip6_hdr *ip6 = NULL; +#endif + int advance; + int len; + u_char *secret; + int ivlen = 0; + u_char *ivoff; + u_char *p; + EVP_CIPHER_CTX ctx; + int blocksz; +#endif + + esp = (struct newesp *)bp; + +#ifdef HAVE_LIBCRYPTO + secret = NULL; + advance = 0; +#endif + +#if 0 + /* keep secret out of a register */ + p = (u_char *)&secret; +#endif + + /* 'ep' points to the end of available data. */ + ep = ndo->ndo_snapend; + + if ((u_char *)(esp + 1) >= ep) { + fputs("[|ESP]", stdout); + goto fail; + } + (*ndo->ndo_printf)(ndo, "ESP(spi=0x%08x", EXTRACT_32BITS(&esp->esp_spi)); + (*ndo->ndo_printf)(ndo, ",seq=0x%x)", EXTRACT_32BITS(&esp->esp_seq)); + (*ndo->ndo_printf)(ndo, ", length %u", length); + +#ifndef HAVE_LIBCRYPTO + goto fail; +#else + /* initiailize SAs */ + if (ndo->ndo_sa_list_head == NULL) { + if (!ndo->ndo_espsecret) + goto fail; + + esp_print_decodesecret(ndo); + } + + if (ndo->ndo_sa_list_head == NULL) + goto fail; + + ip = (struct ip *)bp2; + switch (IP_V(ip)) { +#ifdef INET6 + case 6: + ip6 = (struct ip6_hdr *)bp2; + /* we do not attempt to decrypt jumbograms */ + 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) + EXTRACT_16BITS(&ip6->ip6_plen); + + /* see if we can find the SA, and if so, decode it */ + for (sa = ndo->ndo_sa_list_head; sa != NULL; sa = sa->next) { + struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&sa->daddr; + if (sa->spi == EXTRACT_32BITS(&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 (EXTRACT_16BITS(&ip->ip_off) & IP_MF) + goto fail; + len = EXTRACT_16BITS(&ip->ip_len); + + /* see if we can find the SA, and if so, decode it */ + for (sa = ndo->ndo_sa_list_head; sa != NULL; sa = sa->next) { + struct sockaddr_in *sin = (struct sockaddr_in *)&sa->daddr; + if (sa->spi == EXTRACT_32BITS(&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 didn't find the specific one, then look for + * an unspecified one. + */ + if (sa == NULL) + sa = ndo->ndo_sa_default; + + /* if not found fail */ + if (sa == NULL) + goto fail; + + /* if we can't get nexthdr, we do not need to decrypt it */ + if (ep - bp2 < len) + goto fail; + if (ep - bp2 > len) { + /* FCS included at end of frame (NetBSD 1.6 or later) */ + ep = bp2 + len; + } + + ivoff = (u_char *)(esp + 1) + 0; + ivlen = sa->ivlen; + secret = sa->secret; + espsecret_keylen = sa->secretlen; + ep = ep - sa->authlen; + + if (sa->evp) { + memset(&ctx, 0, sizeof(ctx)); + if (EVP_CipherInit(&ctx, sa->evp, secret, NULL, 0) < 0) + (*ndo->ndo_warning)(ndo, "espkey init failed"); + + blocksz = EVP_CIPHER_CTX_block_size(&ctx); + + p = ivoff; + EVP_CipherInit(&ctx, NULL, NULL, p, 0); + EVP_Cipher(&ctx, p + ivlen, p + ivlen, ep - (p + ivlen)); + EVP_CIPHER_CTX_cleanup(&ctx); + advance = ivoff - (u_char *)esp + ivlen; + } else + advance = sizeof(struct newesp); + + /* sanity check for pad length */ + if (ep - bp < *(ep - 2)) + goto fail; + + if (padlen) + *padlen = *(ep - 2) + 2; + + if (nhdr) + *nhdr = *(ep - 1); + + (ndo->ndo_printf)(ndo, ": "); + return advance; +#endif + +fail: + return -1; +} + +/* + * Local Variables: + * c-style: whitesmith + * c-basic-offset: 8 + * End: + */
diff --git a/tcpdump-4.3.0/print-ether.c b/tcpdump-4.3.0/print-ether.c new file mode 100644 index 0000000..e2f487c --- /dev/null +++ b/tcpdump-4.3.0/print-ether.c
@@ -0,0 +1,432 @@ +/* + * 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-ether.c,v 1.106 2008-02-06 10:47:53 guy Exp $ (LBL)"; +#endif + +#define NETDISSECT_REWORKED +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> +#include <pcap.h> + +#include "interface.h" +#include "extract.h" +#include "addrtoname.h" +#include "ethertype.h" +#include "ether.h" + +const struct tok ethertype_values[] = { + { ETHERTYPE_IP, "IPv4" }, + { ETHERTYPE_MPLS, "MPLS unicast" }, + { ETHERTYPE_MPLS_MULTI, "MPLS multicast" }, + { ETHERTYPE_IPV6, "IPv6" }, + { ETHERTYPE_8021Q, "802.1Q" }, + { ETHERTYPE_8021Q9100, "802.1Q-9100" }, + { ETHERTYPE_8021QinQ, "802.1Q-QinQ" }, + { ETHERTYPE_8021Q9200, "802.1Q-9200" }, + { ETHERTYPE_VMAN, "VMAN" }, + { ETHERTYPE_PUP, "PUP" }, + { ETHERTYPE_ARP, "ARP"}, + { ETHERTYPE_REVARP, "Reverse ARP"}, + { ETHERTYPE_NS, "NS" }, + { ETHERTYPE_SPRITE, "Sprite" }, + { ETHERTYPE_TRAIL, "Trail" }, + { ETHERTYPE_MOPDL, "MOP DL" }, + { ETHERTYPE_MOPRC, "MOP RC" }, + { ETHERTYPE_DN, "DN" }, + { ETHERTYPE_LAT, "LAT" }, + { ETHERTYPE_SCA, "SCA" }, + { ETHERTYPE_TEB, "TEB" }, + { ETHERTYPE_LANBRIDGE, "Lanbridge" }, + { ETHERTYPE_DECDNS, "DEC DNS" }, + { ETHERTYPE_DECDTS, "DEC DTS" }, + { ETHERTYPE_VEXP, "VEXP" }, + { ETHERTYPE_VPROD, "VPROD" }, + { ETHERTYPE_ATALK, "Appletalk" }, + { ETHERTYPE_AARP, "Appletalk ARP" }, + { ETHERTYPE_IPX, "IPX" }, + { ETHERTYPE_PPP, "PPP" }, + { ETHERTYPE_MPCP, "MPCP" }, + { ETHERTYPE_SLOW, "Slow Protocols" }, + { ETHERTYPE_PPPOED, "PPPoE D" }, + { ETHERTYPE_PPPOES, "PPPoE S" }, + { ETHERTYPE_EAPOL, "EAPOL" }, + { ETHERTYPE_RRCP, "RRCP" }, + { ETHERTYPE_JUMBO, "Jumbo" }, + { ETHERTYPE_LOOPBACK, "Loopback" }, + { ETHERTYPE_ISO, "OSI" }, + { ETHERTYPE_GRE_ISO, "GRE-OSI" }, + { ETHERTYPE_CFM_OLD, "CFM (old)" }, + { ETHERTYPE_CFM, "CFM" }, + { ETHERTYPE_LLDP, "LLDP" }, + { ETHERTYPE_TIPC, "TIPC"}, + { 0, NULL} +}; + +static inline void +ether_hdr_print(netdissect_options *ndo, + const u_char *bp, u_int length) +{ + register const struct ether_header *ep; + u_int16_t ether_type; + + ep = (const struct ether_header *)bp; + + (void)ND_PRINT((ndo, "%s > %s", + etheraddr_string(ESRC(ep)), + etheraddr_string(EDST(ep)))); + + ether_type = EXTRACT_16BITS(&ep->ether_type); + if (!ndo->ndo_qflag) { + if (ether_type <= ETHERMTU) + (void)ND_PRINT((ndo, ", 802.3")); + else + (void)ND_PRINT((ndo, ", ethertype %s (0x%04x)", + tok2str(ethertype_values,"Unknown", ether_type), + ether_type)); + } else { + if (ether_type <= ETHERMTU) + (void)ND_PRINT((ndo, ", 802.3")); + else + (void)ND_PRINT((ndo, ", %s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", ether_type))); + } + + (void)ND_PRINT((ndo, ", length %u: ", length)); +} + +/* + * Print an Ethernet frame. + * This might be encapsulated within another frame; we might be passed + * a pointer to a function that can print header information for that + * frame's protocol, and an argument to pass to that function. + */ +void +ether_print(netdissect_options *ndo, + const u_char *p, u_int length, u_int caplen, + void (*print_encap_header)(netdissect_options *ndo, const u_char *), const u_char *encap_header_arg) +{ + struct ether_header *ep; + u_int orig_length; + u_short ether_type; + u_short extracted_ether_type; + + if (caplen < ETHER_HDRLEN || length < ETHER_HDRLEN) { + ND_PRINT((ndo, "[|ether]")); + return; + } + + if (ndo->ndo_eflag) { + if (print_encap_header != NULL) + (*print_encap_header)(ndo, encap_header_arg); + ether_hdr_print(ndo, p, length); + } + orig_length = length; + + length -= ETHER_HDRLEN; + caplen -= ETHER_HDRLEN; + ep = (struct ether_header *)p; + p += ETHER_HDRLEN; + + ether_type = EXTRACT_16BITS(&ep->ether_type); + +recurse: + /* + * Is it (gag) an 802.3 encapsulation? + */ + if (ether_type <= ETHERMTU) { + /* Try to print the LLC-layer header & higher layers */ + if (llc_print(p, length, caplen, ESRC(ep), EDST(ep), + &extracted_ether_type) == 0) { + /* ether_type not known, print raw packet */ + if (!ndo->ndo_eflag) { + if (print_encap_header != NULL) + (*print_encap_header)(ndo, encap_header_arg); + ether_hdr_print(ndo, (u_char *)ep, orig_length); + } + + if (!ndo->ndo_suppress_default_print) + ndo->ndo_default_print(ndo, p, caplen); + } + } else if (ether_type == ETHERTYPE_8021Q || + ether_type == ETHERTYPE_8021Q9100 || + ether_type == ETHERTYPE_8021Q9200 || + ether_type == ETHERTYPE_8021QinQ) { + /* + * Print VLAN information, and then go back and process + * the enclosed type field. + */ + if (caplen < 4 || length < 4) { + ND_PRINT((ndo, "[|vlan]")); + return; + } + if (ndo->ndo_eflag) { + u_int16_t tag = EXTRACT_16BITS(p); + + ND_PRINT((ndo, "vlan %u, p %u%s, ", + tag & 0xfff, + tag >> 13, + (tag & 0x1000) ? ", CFI" : "")); + } + + ether_type = EXTRACT_16BITS(p + 2); + if (ndo->ndo_eflag && ether_type > ETHERMTU) + ND_PRINT((ndo, "ethertype %s, ", tok2str(ethertype_values,"0x%04x", ether_type))); + p += 4; + length -= 4; + caplen -= 4; + goto recurse; + } else if (ether_type == ETHERTYPE_JUMBO) { + /* + * Alteon jumbo frames. + * See + * + * http://tools.ietf.org/html/draft-ietf-isis-ext-eth-01 + * + * which indicates that, following the type field, + * there's an LLC header and payload. + */ + /* Try to print the LLC-layer header & higher layers */ + if (llc_print(p, length, caplen, ESRC(ep), EDST(ep), + &extracted_ether_type) == 0) { + /* ether_type not known, print raw packet */ + if (!ndo->ndo_eflag) { + if (print_encap_header != NULL) + (*print_encap_header)(ndo, encap_header_arg); + ether_hdr_print(ndo, (u_char *)ep, orig_length); + } + + if (!ndo->ndo_suppress_default_print) + ndo->ndo_default_print(ndo, p, caplen); + } + } else { + if (ethertype_print(ndo, ether_type, p, length, caplen) == 0) { + /* ether_type not known, print raw packet */ + if (!ndo->ndo_eflag) { + if (print_encap_header != NULL) + (*print_encap_header)(ndo, encap_header_arg); + ether_hdr_print(ndo, (u_char *)ep, orig_length); + } + + if (!ndo->ndo_suppress_default_print) + ndo->ndo_default_print(ndo, p, caplen); + } + } +} + +/* + * This is the top level routine of the printer. 'p' points + * to the ether header of the packet, 'h->ts' is the timestamp, + * 'h->len' is the length of the packet off the wire, and 'h->caplen' + * is the number of bytes actually captured. + */ +u_int +ether_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, + const u_char *p) +{ + ether_print(ndo, p, h->len, h->caplen, NULL, NULL); + + return (ETHER_HDRLEN); +} + +/* + * This is the top level routine of the printer. 'p' points + * to the ether header of the packet, 'h->ts' is the timestamp, + * 'h->len' is the length of the packet off the wire, and 'h->caplen' + * is the number of bytes actually captured. + * + * This is for DLT_NETANALYZER, which has a 4-byte pseudo-header + * before the Ethernet header. + */ +u_int +netanalyzer_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, + const u_char *p) +{ + /* + * Fail if we don't have enough data for the Hilscher pseudo-header. + */ + if (h->len < 4 || h->caplen < 4) { + printf("[|netanalyzer]"); + return (h->caplen); + } + + /* Skip the pseudo-header. */ + ether_print(ndo, p + 4, h->len - 4, h->caplen - 4, NULL, NULL); + + return (4 + ETHER_HDRLEN); +} + +/* + * This is the top level routine of the printer. 'p' points + * to the ether header of the packet, 'h->ts' is the timestamp, + * 'h->len' is the length of the packet off the wire, and 'h->caplen' + * is the number of bytes actually captured. + * + * This is for DLT_NETANALYZER_TRANSPARENT, which has a 4-byte + * pseudo-header, a 7-byte Ethernet preamble, and a 1-byte Ethernet SOF + * before the Ethernet header. + */ +u_int +netanalyzer_transparent_if_print(netdissect_options *ndo, + const struct pcap_pkthdr *h, + const u_char *p) +{ + /* + * Fail if we don't have enough data for the Hilscher pseudo-header, + * preamble, and SOF. + */ + if (h->len < 12 || h->caplen < 12) { + printf("[|netanalyzer-transparent]"); + return (h->caplen); + } + + /* Skip the pseudo-header, preamble, and SOF. */ + ether_print(ndo, p + 12, h->len - 12, h->caplen - 12, NULL, NULL); + + return (12 + ETHER_HDRLEN); +} + +/* + * Prints the packet payload, given an Ethernet type code for the payload's + * protocol. + * + * Returns non-zero if it can do so, zero if the ethertype is unknown. + */ + +int +ethertype_print(netdissect_options *ndo, + u_short ether_type, const u_char *p, + u_int length, u_int caplen) +{ + switch (ether_type) { + + case ETHERTYPE_IP: + ip_print(ndo, p, length); + return (1); + +#ifdef INET6 + case ETHERTYPE_IPV6: + ip6_print(ndo, p, length); + return (1); +#endif /*INET6*/ + + case ETHERTYPE_ARP: + case ETHERTYPE_REVARP: + arp_print(ndo, p, length, caplen); + return (1); + + case ETHERTYPE_DN: + decnet_print(/*ndo,*/p, length, caplen); + return (1); + + case ETHERTYPE_ATALK: + if (ndo->ndo_vflag) + fputs("et1 ", stdout); + atalk_print(/*ndo,*/p, length); + return (1); + + case ETHERTYPE_AARP: + aarp_print(/*ndo,*/p, length); + return (1); + + case ETHERTYPE_IPX: + ND_PRINT((ndo, "(NOV-ETHII) ")); + ipx_print(/*ndo,*/p, length); + return (1); + + case ETHERTYPE_ISO: + isoclns_print(/*ndo,*/p+1, length-1, length-1); + return(1); + + case ETHERTYPE_PPPOED: + case ETHERTYPE_PPPOES: + case ETHERTYPE_PPPOED2: + case ETHERTYPE_PPPOES2: + pppoe_print(/*ndo,*/p, length); + return (1); + + case ETHERTYPE_EAPOL: + eap_print(ndo, p, length); + return (1); + + case ETHERTYPE_RRCP: + rrcp_print(ndo, p - 14 , length + 14); + return (1); + + case ETHERTYPE_PPP: + if (length) { + printf(": "); + ppp_print(/*ndo,*/p, length); + } + return (1); + + case ETHERTYPE_MPCP: + mpcp_print(/*ndo,*/p, length); + return (1); + + case ETHERTYPE_SLOW: + slow_print(/*ndo,*/p, length); + return (1); + + case ETHERTYPE_CFM: + case ETHERTYPE_CFM_OLD: + cfm_print(/*ndo,*/p, length); + return (1); + + case ETHERTYPE_LLDP: + lldp_print(/*ndo,*/p, length); + return (1); + + case ETHERTYPE_LOOPBACK: + return (1); + + case ETHERTYPE_MPLS: + case ETHERTYPE_MPLS_MULTI: + mpls_print(/*ndo,*/p, length); + return (1); + + case ETHERTYPE_TIPC: + tipc_print(ndo, p, length, caplen); + return (1); + + case ETHERTYPE_LAT: + case ETHERTYPE_SCA: + case ETHERTYPE_MOPRC: + case ETHERTYPE_MOPDL: + /* default_print for now */ + default: + return (0); + } +} + + +/* + * Local Variables: + * c-style: whitesmith + * c-basic-offset: 8 + * End: + */ +
diff --git a/tcpdump-4.3.0/print-fddi.c b/tcpdump-4.3.0/print-fddi.c new file mode 100644 index 0000000..1e7d554 --- /dev/null +++ b/tcpdump-4.3.0/print-fddi.c
@@ -0,0 +1,309 @@ +/* + * 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-fddi.c,v 1.66 2005-11-13 12:12:41 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 "fddi.h" + +/* + * Some FDDI interfaces use bit-swapped addresses. + */ +#if defined(ultrix) || defined(__alpha) || defined(__bsdi) || defined(__NetBSD__) || defined(__linux__) +int fddi_bitswap = 0; +#else +int fddi_bitswap = 1; +#endif + +/* + * FDDI support for tcpdump, by Jeffrey Mogul [DECWRL], June 1992 + * + * Based in part on code by Van Jacobson, which bears this note: + * + * NOTE: This is a very preliminary hack for FDDI support. + * There are all sorts of wired in constants & nothing (yet) + * to print SMT packets as anything other than hex dumps. + * Most of the necessary changes are waiting on my redoing + * the "header" that a kernel fddi driver supplies to bpf: I + * want it to look like one byte of 'direction' (0 or 1 + * depending on whether the packet was inbound or outbound), + * two bytes of system/driver dependent data (anything an + * implementor thinks would be useful to filter on and/or + * save per-packet, then the real 21-byte FDDI header. + * Steve McCanne & I have also talked about adding the + * 'direction' byte to all bpf headers (e.g., in the two + * bytes of padding on an ethernet header). It's not clear + * we could do this in a backwards compatible way & we hate + * the idea of an incompatible bpf change. Discussions are + * proceeding. + * + * Also, to really support FDDI (and better support 802.2 + * over ethernet) we really need to re-think the rather simple + * minded assumptions about fixed length & fixed format link + * level headers made in gencode.c. One day... + * + * - vj + */ + +static u_char fddi_bit_swap[] = { + 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, + 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, + 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, + 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, + 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, + 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, + 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, + 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, + 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, + 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, + 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, + 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, + 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, + 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, + 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, + 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, + 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, + 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, + 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, + 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, + 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, + 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, + 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, + 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, + 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, + 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, + 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, + 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, + 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, + 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, + 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, + 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff, +}; + +/* + * Print FDDI frame-control bits + */ +static inline void +print_fddi_fc(u_char fc) +{ + switch (fc) { + + case FDDIFC_VOID: /* Void frame */ + printf("void "); + break; + + case FDDIFC_NRT: /* Nonrestricted token */ + printf("nrt "); + break; + + case FDDIFC_RT: /* Restricted token */ + printf("rt "); + break; + + case FDDIFC_SMT_INFO: /* SMT Info */ + printf("info "); + break; + + case FDDIFC_SMT_NSA: /* SMT Next station adrs */ + printf("nsa "); + break; + + case FDDIFC_MAC_BEACON: /* MAC Beacon frame */ + printf("beacon "); + break; + + case FDDIFC_MAC_CLAIM: /* MAC Claim frame */ + printf("claim "); + break; + + default: + switch (fc & FDDIFC_CLFF) { + + case FDDIFC_MAC: + printf("mac%1x ", fc & FDDIFC_ZZZZ); + break; + + case FDDIFC_SMT: + printf("smt%1x ", fc & FDDIFC_ZZZZ); + break; + + case FDDIFC_LLC_ASYNC: + printf("async%1x ", fc & FDDIFC_ZZZZ); + break; + + case FDDIFC_LLC_SYNC: + printf("sync%1x ", fc & FDDIFC_ZZZZ); + break; + + case FDDIFC_IMP_ASYNC: + printf("imp_async%1x ", fc & FDDIFC_ZZZZ); + break; + + case FDDIFC_IMP_SYNC: + printf("imp_sync%1x ", fc & FDDIFC_ZZZZ); + break; + + default: + printf("%02x ", fc); + break; + } + } +} + +/* Extract src, dst addresses */ +static inline void +extract_fddi_addrs(const struct fddi_header *fddip, char *fsrc, char *fdst) +{ + register int i; + + if (fddi_bitswap) { + /* + * bit-swap the fddi addresses (isn't the IEEE standards + * process wonderful!) then convert them to names. + */ + for (i = 0; i < 6; ++i) + fdst[i] = fddi_bit_swap[fddip->fddi_dhost[i]]; + for (i = 0; i < 6; ++i) + fsrc[i] = fddi_bit_swap[fddip->fddi_shost[i]]; + } + else { + memcpy(fdst, (const char *)fddip->fddi_dhost, 6); + memcpy(fsrc, (const char *)fddip->fddi_shost, 6); + } +} + +/* + * Print the FDDI MAC header + */ +static inline void +fddi_hdr_print(register const struct fddi_header *fddip, register u_int length, + register const u_char *fsrc, register const u_char *fdst) +{ + const char *srcname, *dstname; + + srcname = etheraddr_string(fsrc); + dstname = etheraddr_string(fdst); + + if (vflag) + (void) printf("%02x %s %s %d: ", + fddip->fddi_fc, + srcname, dstname, + length); + else if (qflag) + printf("%s %s %d: ", srcname, dstname, length); + else { + (void) print_fddi_fc(fddip->fddi_fc); + (void) printf("%s %s %d: ", srcname, dstname, length); + } +} + +static inline void +fddi_smt_print(const u_char *p _U_, u_int length _U_) +{ + printf("<SMT printer not yet implemented>"); +} + +void +fddi_print(const u_char *p, u_int length, u_int caplen) +{ + const struct fddi_header *fddip = (const struct fddi_header *)p; + struct ether_header ehdr; + u_short extracted_ethertype; + + if (caplen < FDDI_HDRLEN) { + printf("[|fddi]"); + return; + } + + /* + * Get the FDDI addresses into a canonical form + */ + extract_fddi_addrs(fddip, (char *)ESRC(&ehdr), (char *)EDST(&ehdr)); + + if (eflag) + fddi_hdr_print(fddip, length, ESRC(&ehdr), EDST(&ehdr)); + + /* Skip over FDDI MAC header */ + length -= FDDI_HDRLEN; + p += FDDI_HDRLEN; + caplen -= FDDI_HDRLEN; + + /* Frame Control field determines interpretation of packet */ + if ((fddip->fddi_fc & FDDIFC_CLFF) == FDDIFC_LLC_ASYNC) { + /* Try to print the LLC-layer header & higher layers */ + if (llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr), + &extracted_ethertype) == 0) { + /* + * Some kinds of LLC packet we cannot + * handle intelligently + */ + if (!eflag) + fddi_hdr_print(fddip, length + FDDI_HDRLEN, + ESRC(&ehdr), EDST(&ehdr)); + if (extracted_ethertype) { + printf("(LLC %s) ", + etherproto_string(htons(extracted_ethertype))); + } + if (!suppress_default_print) + default_print(p, caplen); + } + } else if ((fddip->fddi_fc & FDDIFC_CLFF) == FDDIFC_SMT) + fddi_smt_print(p, caplen); + else { + /* Some kinds of FDDI packet we cannot handle intelligently */ + if (!eflag) + fddi_hdr_print(fddip, length + FDDI_HDRLEN, ESRC(&ehdr), + EDST(&ehdr)); + if (!suppress_default_print) + default_print(p, caplen); + } +} + +/* + * This is the top level routine of the printer. 'p' points + * to the FDDI header of the packet, 'h->ts' is the timestamp, + * 'h->len' is the length of the packet off the wire, and 'h->caplen' + * is the number of bytes actually captured. + */ +u_int +fddi_if_print(const struct pcap_pkthdr *h, register const u_char *p) +{ + fddi_print(p, h->len, h->caplen); + + return (FDDI_HDRLEN); +}
diff --git a/tcpdump-4.3.0/print-forces.c b/tcpdump-4.3.0/print-forces.c new file mode 100644 index 0000000..438aa27 --- /dev/null +++ b/tcpdump-4.3.0/print-forces.c
@@ -0,0 +1,1055 @@ +/* + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code + * distributions retain the above copyright notice and this paragraph + * in its entirety, and (2) distributions including binary code include + * the above copyright notice and this paragraph in its entirety in + * the documentation or other materials provided with the distribution. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND + * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT + * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * Copyright (c) 2009 Mojatatu Networks, Inc + * + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> +#include <stdlib.h> + +#include "interface.h" +#include "extract.h" + +#include "forces.h" + +#define RESLEN 4 + +int +prestlv_print(register const u_char * pptr, register u_int len, + u_int16_t op_msk _U_, int indent) +{ + const struct forces_tlv *tlv = (struct forces_tlv *)pptr; + register const u_char *tdp = (u_char *) TLV_DATA(tlv); + struct res_val *r = (struct res_val *)tdp; + u_int dlen; + + /* + * pdatacnt_print() has ensured that len (the TLV length) + * >= TLV_HDRL. + */ + dlen = len - TLV_HDRL; + if (dlen != RESLEN) { + printf("illegal RESULT-TLV: %d bytes!\n", dlen); + return -1; + } + + TCHECK(*r); + if (r->result >= 0x18 && r->result <= 0xFE) { + printf("illegal reserved result code: 0x%x!\n", r->result); + return -1; + } + + if (vflag >= 3) { + char *ib = indent_pr(indent, 0); + printf("%s Result: %s (code 0x%x)\n", ib, + tok2str(ForCES_errs, NULL, r->result), r->result); + } + return 0; + +trunc: + fputs("[|forces]", stdout); + return -1; +} + +int +fdatatlv_print(register const u_char * pptr, register u_int len, + u_int16_t op_msk _U_, int indent) +{ + const struct forces_tlv *tlv = (struct forces_tlv *)pptr; + u_int rlen; + register const u_char *tdp = (u_char *) TLV_DATA(tlv); + u_int16_t type; + + /* + * pdatacnt_print() or pkeyitlv_print() has ensured that len + * (the TLV length) >= TLV_HDRL. + */ + rlen = len - TLV_HDRL; + TCHECK(*tlv); + type = EXTRACT_16BITS(&tlv->type); + if (type != F_TLV_FULD) { + printf("Error: expecting FULLDATA!\n"); + return -1; + } + + if (vflag >= 3) { + char *ib = indent_pr(indent + 2, 1); + printf("%s[", &ib[1]); + hex_print_with_offset(ib, tdp, rlen, 0); + printf("\n%s]\n", &ib[1]); + } + return 0; + +trunc: + fputs("[|forces]", stdout); + return -1; +} + +int +sdatailv_print(register const u_char * pptr, register u_int len, + u_int16_t op_msk _U_, int indent) +{ + u_int rlen; + const struct forces_ilv *ilv = (struct forces_ilv *)pptr; + int invilv; + + if (len < ILV_HDRL) { + printf("Error: BAD SPARSEDATA-TLV!\n"); + return -1; + } + rlen = len; + indent += 1; + while (rlen != 0) { + char *ib = indent_pr(indent, 1); + register const u_char *tdp = (u_char *) ILV_DATA(ilv); + TCHECK(*ilv); + invilv = ilv_valid(ilv, rlen); + if (invilv) { + printf("%s[", &ib[1]); + hex_print_with_offset(ib, tdp, rlen, 0); + printf("\n%s]\n", &ib[1]); + return -1; + } + if (vflag >= 3) { + int ilvl = EXTRACT_32BITS(&ilv->length); + printf("\n%s ILV: type %x length %d\n", &ib[1], + EXTRACT_32BITS(&ilv->type), ilvl); + hex_print_with_offset("\t\t[", tdp, ilvl-ILV_HDRL, 0); + } + + ilv = GO_NXT_ILV(ilv, rlen); + } + + return 0; + +trunc: + fputs("[|forces]", stdout); + return -1; +} + +int +sdatatlv_print(register const u_char * pptr, register u_int len, + u_int16_t op_msk, int indent) +{ + const struct forces_tlv *tlv = (struct forces_tlv *)pptr; + u_int rlen; + register const u_char *tdp = (u_char *) TLV_DATA(tlv); + u_int16_t type; + + /* + * pdatacnt_print() has ensured that len (the TLV length) + * >= TLV_HDRL. + */ + rlen = len - TLV_HDRL; + TCHECK(*tlv); + type = EXTRACT_16BITS(&tlv->type); + if (type != F_TLV_SPAD) { + printf("Error: expecting SPARSEDATA!\n"); + return -1; + } + + return sdatailv_print(tdp, rlen, op_msk, indent); + +trunc: + fputs("[|forces]", stdout); + return -1; +} + +int +pkeyitlv_print(register const u_char * pptr, register u_int len, + u_int16_t op_msk, int indent) +{ + const struct forces_tlv *tlv = (struct forces_tlv *)pptr; + register const u_char *tdp = (u_char *) TLV_DATA(tlv); + register const u_char *dp = tdp + 4; + const struct forces_tlv *kdtlv = (struct forces_tlv *)dp; + u_int32_t id; + char *ib = indent_pr(indent, 0); + u_int16_t type, tll; + int invtlv; + + TCHECK(*tdp); + id = EXTRACT_32BITS(tdp); + printf("%sKeyinfo: Key 0x%x\n", ib, id); + TCHECK(*kdtlv); + type = EXTRACT_16BITS(&kdtlv->type); + invtlv = tlv_valid(kdtlv, len); + + if (invtlv) { + printf("%s TLV type 0x%x len %d\n", + tok2str(ForCES_TLV_err, NULL, invtlv), type, + EXTRACT_16BITS(&kdtlv->length)); + return -1; + } + /* + * At this point, tlv_valid() has ensured that the TLV + * length is large enough but not too large (it doesn't + * go past the end of the containing TLV). + */ + tll = EXTRACT_16BITS(&kdtlv->length); + dp = (u_char *) TLV_DATA(kdtlv); + return fdatatlv_print(dp, tll, op_msk, indent); + +trunc: + fputs("[|forces]", stdout); + return -1; +} + +int +pdatacnt_print(register const u_char * pptr, register u_int len, + u_int16_t IDcnt, u_int16_t op_msk, int indent) +{ + u_int i; + u_int32_t id; + char *ib = indent_pr(indent, 0); + + for (i = 0; i < IDcnt; i++) { + TCHECK2(*pptr, 4); + if (len < 4) + goto trunc; + id = EXTRACT_32BITS(pptr); + if (vflag >= 3) + printf("%s ID#%02u: %d\n", ib, i + 1, id); + len -= 4; + pptr += 4; + } + if (len) { + const struct forces_tlv *pdtlv = (struct forces_tlv *)pptr; + u_int16_t type; + u_int16_t tll; + int pad = 0; + u_int aln; + int invtlv; + + TCHECK(*pdtlv); + type = EXTRACT_16BITS(&pdtlv->type); + invtlv = tlv_valid(pdtlv, len); + if (invtlv) { + printf + ("%s Outstanding bytes %d for TLV type 0x%x TLV len %d\n", + tok2str(ForCES_TLV_err, NULL, invtlv), len, type, + EXTRACT_16BITS(&pdtlv->length)); + goto pd_err; + } + /* + * At this point, tlv_valid() has ensured that the TLV + * length is large enough but not too large (it doesn't + * go past the end of the containing TLV). + */ + tll = EXTRACT_16BITS(&pdtlv->length) - TLV_HDRL; + aln = F_ALN_LEN(EXTRACT_16BITS(&pdtlv->length)); + if (aln > EXTRACT_16BITS(&pdtlv->length)) { + if (aln > len) { + printf + ("Invalid padded pathdata TLV type 0x%x len %d missing %d pad bytes\n", + type, EXTRACT_16BITS(&pdtlv->length), aln - len); + } else { + pad = aln - EXTRACT_16BITS(&pdtlv->length); + } + } + if (pd_valid(type)) { + const struct pdata_ops *ops = get_forces_pd(type); + + if (vflag >= 3 && ops->v != F_TLV_PDAT) { + if (pad) + printf + ("%s %s (Length %d DataLen %d pad %d Bytes)\n", + ib, ops->s, EXTRACT_16BITS(&pdtlv->length), + tll, pad); + else + printf + ("%s %s (Length %d DataLen %d Bytes)\n", + ib, ops->s, EXTRACT_16BITS(&pdtlv->length), + tll); + } + + chk_op_type(type, op_msk, ops->op_msk); + + if (ops->print((const u_char *)pdtlv, + tll + pad + TLV_HDRL, op_msk, + indent + 2) == -1) + return -1; + len -= (TLV_HDRL + pad + tll); + } else { + printf("Invalid path data content type 0x%x len %d\n", + type, EXTRACT_16BITS(&pdtlv->length)); +pd_err: + if (EXTRACT_16BITS(&pdtlv->length)) { + hex_print_with_offset("Bad Data val\n\t [", + pptr, len, 0); + printf("]\n"); + + return -1; + } + } + } + return len; + +trunc: + fputs("[|forces]", stdout); + return -1; +} + +int +pdata_print(register const u_char * pptr, register u_int len, + u_int16_t op_msk, int indent) +{ + const struct pathdata_h *pdh = (struct pathdata_h *)pptr; + char *ib = indent_pr(indent, 0); + u_int minsize = 0; + int more_pd = 0; + u_int16_t idcnt = 0; + + TCHECK(*pdh); + if (len < sizeof(struct pathdata_h)) + goto trunc; + if (vflag >= 3) { + printf("\n%sPathdata: Flags 0x%x ID count %d\n", + ib, EXTRACT_16BITS(&pdh->pflags), EXTRACT_16BITS(&pdh->pIDcnt)); + } + + if (EXTRACT_16BITS(&pdh->pflags) & F_SELKEY) { + op_msk |= B_KEYIN; + } + pptr += sizeof(struct pathdata_h); + len -= sizeof(struct pathdata_h); + idcnt = EXTRACT_16BITS(&pdh->pIDcnt); + minsize = idcnt * 4; + if (len < minsize) { + printf("\t\t\ttruncated IDs expected %uB got %uB\n", minsize, + len); + hex_print_with_offset("\t\t\tID Data[", pptr, len, 0); + printf("]\n"); + return -1; + } + more_pd = pdatacnt_print(pptr, len, idcnt, op_msk, indent); + if (more_pd > 0) { + int consumed = len - more_pd; + pptr += consumed; + len = more_pd; + /* XXX: Argh, recurse some more */ + return recpdoptlv_print(pptr, len, op_msk, indent+1); + } else + return 0; + +trunc: + fputs("[|forces]", stdout); + return -1; +} + +int +genoptlv_print(register const u_char * pptr, register u_int len, + u_int16_t op_msk, int indent) +{ + const struct forces_tlv *pdtlv = (struct forces_tlv *)pptr; + u_int16_t type; + int tll; + int invtlv; + char *ib = indent_pr(indent, 0); + + TCHECK(*pdtlv); + type = EXTRACT_16BITS(&pdtlv->type); + tll = EXTRACT_16BITS(&pdtlv->length) - TLV_HDRL; + invtlv = tlv_valid(pdtlv, len); + printf("genoptlvprint - %s TLV type 0x%x len %d\n", + tok2str(ForCES_TLV, NULL, type), type, EXTRACT_16BITS(&pdtlv->length)); + if (!invtlv) { + /* + * At this point, tlv_valid() has ensured that the TLV + * length is large enough but not too large (it doesn't + * go past the end of the containing TLV). + */ + register const u_char *dp = (u_char *) TLV_DATA(pdtlv); + if (!ttlv_valid(type)) { + printf("%s TLV type 0x%x len %d\n", + tok2str(ForCES_TLV_err, NULL, invtlv), type, + EXTRACT_16BITS(&pdtlv->length)); + return -1; + } + if (vflag >= 3) + printf("%s%s, length %d (data length %d Bytes)", + ib, tok2str(ForCES_TLV, NULL, type), + EXTRACT_16BITS(&pdtlv->length), tll); + + return pdata_print(dp, tll, op_msk, indent + 1); + } else { + printf("\t\t\tInvalid ForCES TLV type=%x", type); + return -1; + } + +trunc: + fputs("[|forces]", stdout); + return -1; +} + +int +recpdoptlv_print(register const u_char * pptr, register u_int len, + u_int16_t op_msk, int indent) +{ + const struct forces_tlv *pdtlv = (struct forces_tlv *)pptr; + int tll; + int invtlv; + u_int16_t type; + register const u_char *dp; + char *ib; + + while (len != 0) { + TCHECK(*pdtlv); + invtlv = tlv_valid(pdtlv, len); + if (invtlv) { + break; + } + + /* + * At this point, tlv_valid() has ensured that the TLV + * length is large enough but not too large (it doesn't + * go past the end of the containing TLV). + */ + ib = indent_pr(indent, 0); + type = EXTRACT_16BITS(&pdtlv->type); + dp = (u_char *) TLV_DATA(pdtlv); + tll = EXTRACT_16BITS(&pdtlv->length) - TLV_HDRL; + + if (vflag >= 3) + printf + ("%s%s, length %d (data encapsulated %d Bytes)", + ib, tok2str(ForCES_TLV, NULL, type), + EXTRACT_16BITS(&pdtlv->length), + EXTRACT_16BITS(&pdtlv->length) - TLV_HDRL); + + if (pdata_print(dp, tll, op_msk, indent + 1) == -1) + return -1; + pdtlv = GO_NXT_TLV(pdtlv, len); + } + + if (len) { + printf + ("\n\t\tMessy PATHDATA TLV header, type (0x%x)\n\t\texcess of %d Bytes ", + EXTRACT_16BITS(&pdtlv->type), len - EXTRACT_16BITS(&pdtlv->length)); + return -1; + } + + return 0; + +trunc: + fputs("[|forces]", stdout); + return -1; +} + +int +invoptlv_print(register const u_char * pptr, register u_int len, + u_int16_t op_msk _U_, int indent) +{ + char *ib = indent_pr(indent, 1); + + if (vflag >= 3) { + printf("%sData[", &ib[1]); + hex_print_with_offset(ib, pptr, len, 0); + printf("%s]\n", ib); + } + return -1; +} + +int otlv_print(const struct forces_tlv *otlv, u_int16_t op_msk _U_, int indent) +{ + int rc = 0; + register const u_char *dp = (u_char *) TLV_DATA(otlv); + u_int16_t type; + int tll; + char *ib = indent_pr(indent, 0); + const struct optlv_h *ops; + + /* + * lfbselect_print() has ensured that EXTRACT_16BITS(&otlv->length) + * >= TLV_HDRL. + */ + TCHECK(*otlv); + type = EXTRACT_16BITS(&otlv->type); + tll = EXTRACT_16BITS(&otlv->length) - TLV_HDRL; + ops = get_forces_optlv_h(type); + if (vflag >= 3) { + printf("%sOper TLV %s(0x%x) length %d\n", ib, ops->s, type, + EXTRACT_16BITS(&otlv->length)); + } + /* empty TLVs like COMMIT and TRCOMMIT are empty, we stop here .. */ + if (!ops->flags & ZERO_TTLV) { + if (tll != 0) /* instead of "if (tll)" - for readability .. */ + printf("%s: Illegal - MUST be empty\n", ops->s); + return rc; + } + /* rest of ops must at least have 12B {pathinfo} */ + if (tll < OP_MIN_SIZ) { + printf("\t\tOper TLV %s(0x%x) length %d\n", ops->s, type, + EXTRACT_16BITS(&otlv->length)); + printf("\t\tTruncated data size %d minimum required %d\n", tll, + OP_MIN_SIZ); + return invoptlv_print(dp, tll, ops->op_msk, indent); + + } + + rc = ops->print(dp, tll, ops->op_msk, indent + 1); + return rc; + +trunc: + fputs("[|forces]", stdout); + return -1; +} + +#define ASTDLN 4 +#define ASTMCD 255 +int +asttlv_print(register const u_char * pptr, register u_int len, + u_int16_t op_msk _U_, int indent) +{ + u_int32_t rescode; + u_int dlen; + char *ib = indent_pr(indent, 0); + + /* + * forces_type_print() has ensured that len (the TLV length) + * >= TLV_HDRL. + */ + dlen = len - TLV_HDRL; + if (dlen != ASTDLN) { + printf("illegal ASTresult-TLV: %d bytes!\n", dlen); + return -1; + } + TCHECK2(*pptr, 4); + rescode = EXTRACT_32BITS(pptr); + if (rescode > ASTMCD) { + printf("illegal ASTresult result code: %d!\n", rescode); + return -1; + } + + if (vflag >= 3) { + printf("Teardown reason:\n%s", ib); + switch (rescode) { + case 0: + printf("Normal Teardown"); + break; + case 1: + printf("Loss of Heartbeats"); + break; + case 2: + printf("Out of bandwidth"); + break; + case 3: + printf("Out of Memory"); + break; + case 4: + printf("Application Crash"); + break; + default: + printf("Unknown Teardown reason"); + break; + } + printf("(%x)\n%s", rescode, ib); + } + return 0; + +trunc: + fputs("[|forces]", stdout); + return -1; +} + +#define ASRDLN 4 +#define ASRMCD 3 +int +asrtlv_print(register const u_char * pptr, register u_int len, + u_int16_t op_msk _U_, int indent) +{ + u_int32_t rescode; + u_int dlen; + char *ib = indent_pr(indent, 0); + + /* + * forces_type_print() has ensured that len (the TLV length) + * >= TLV_HDRL. + */ + dlen = len - TLV_HDRL; + if (dlen != ASRDLN) { /* id, instance, oper tlv */ + printf("illegal ASRresult-TLV: %d bytes!\n", dlen); + return -1; + } + TCHECK2(*pptr, 4); + rescode = EXTRACT_32BITS(pptr); + + if (rescode > ASRMCD) { + printf("illegal ASRresult result code: %d!\n", rescode); + return -1; + } + + if (vflag >= 3) { + printf("\n%s", ib); + switch (rescode) { + case 0: + printf("Success "); + break; + case 1: + printf("FE ID invalid "); + break; + case 2: + printf("permission denied "); + break; + default: + printf("Unknown "); + break; + } + printf("(%x)\n%s", rescode, ib); + } + return 0; + +trunc: + fputs("[|forces]", stdout); + return -1; +} + +/* + * XXX - not used. + */ +int +gentltlv_print(register const u_char * pptr _U_, register u_int len, + u_int16_t op_msk _U_, int indent _U_) +{ + u_int dlen = len - TLV_HDRL; + + if (dlen < 4) { /* at least 32 bits must exist */ + printf("truncated TLV: %d bytes missing! ", 4 - dlen); + return -1; + } + return 0; +} + +#define RD_MIN 8 +int +print_metailv(register const u_char * pptr, register u_int len, + u_int16_t op_msk _U_, int indent) +{ + u_int dlen; + u_int rlen; + char *ib = indent_pr(indent, 0); + /* XXX: check header length */ + const struct forces_ilv *ilv = (struct forces_ilv *)pptr; + + /* + * print_metatlv() has ensured that len (what remains in the + * ILV) >= ILV_HDRL. + */ + dlen = len - ILV_HDRL; + rlen = dlen; + TCHECK(*ilv); + printf("\n%sMetaID 0x%x length %d\n", ib, EXTRACT_32BITS(&ilv->type), + EXTRACT_32BITS(&ilv->length)); + hex_print_with_offset("\n\t\t\t\t[", ILV_DATA(ilv), rlen, 0); + return 0; + +trunc: + fputs("[|forces]", stdout); + return -1; +} + +int +print_metatlv(register const u_char * pptr, register u_int len, + u_int16_t op_msk _U_, int indent) +{ + u_int dlen; + char *ib = indent_pr(indent, 0); + u_int rlen; + const struct forces_ilv *ilv = (struct forces_ilv *)pptr; + int invilv; + + /* + * redirect_print() has ensured that len (what remains in the + * TLV) >= TLV_HDRL. + */ + dlen = len - TLV_HDRL; + rlen = dlen; + printf("\n%s METADATA\n", ib); + while (rlen != 0) { + TCHECK(*ilv); + invilv = ilv_valid(ilv, rlen); + if (invilv) + break; + + /* + * At this point, ilv_valid() has ensured that the ILV + * length is large enough but not too large (it doesn't + * go past the end of the containing TLV). + */ + print_metailv((u_char *) ilv, rlen, 0, indent + 1); + + ilv = GO_NXT_ILV(ilv, rlen); + } + + return 0; + +trunc: + fputs("[|forces]", stdout); + return -1; +} + +/* +*/ +int +print_reddata(register const u_char * pptr, register u_int len, + u_int16_t op_msk _U_, int indent _U_) +{ + u_int dlen; + u_int rlen; + int invtlv; + const struct forces_tlv *tlv = (struct forces_tlv *)pptr; + + /* + * redirect_print() has ensured that len (what remains in the + * TLV) >= TLV_HDRL. + */ + dlen = len - TLV_HDRL; + printf("\n\t\t Redirect DATA\n"); + if (dlen <= RD_MIN) { + printf("\n\t\ttruncated Redirect data: %d bytes missing! ", + RD_MIN - dlen); + return -1; + } + + rlen = dlen; + TCHECK(*tlv); + invtlv = tlv_valid(tlv, rlen); + + if (invtlv) { + printf("Redir data type 0x%x len %d\n", EXTRACT_16BITS(&tlv->type), + EXTRACT_16BITS(&tlv->length)); + return -1; + } + + /* + * At this point, tlv_valid() has ensured that the TLV + * length is large enough but not too large (it doesn't + * go past the end of the containing TLV). + */ + rlen -= TLV_HDRL; + hex_print_with_offset("\n\t\t\t[", TLV_DATA(tlv), rlen, 0); + return 0; + +trunc: + fputs("[|forces]", stdout); + return -1; +} + +int +redirect_print(register const u_char * pptr, register u_int len, + u_int16_t op_msk _U_, int indent) +{ + const struct forces_tlv *tlv = (struct forces_tlv *)pptr; + u_int dlen; + u_int rlen; + int invtlv; + + /* + * forces_type_print() has ensured that len (the TLV length) + * >= TLV_HDRL. + */ + dlen = len - TLV_HDRL; + if (dlen <= RD_MIN) { + printf("\n\t\ttruncated Redirect TLV: %d bytes missing! ", + RD_MIN - dlen); + return -1; + } + + rlen = dlen; + indent += 1; + while (rlen != 0) { + TCHECK(*tlv); + invtlv = tlv_valid(tlv, rlen); + if (invtlv) + break; + + /* + * At this point, tlv_valid() has ensured that the TLV + * length is large enough but not too large (it doesn't + * go past the end of the containing TLV). + */ + if (EXTRACT_16BITS(&tlv->type) == F_TLV_METD) { + print_metatlv((u_char *) TLV_DATA(tlv), rlen, 0, indent); + } else if ((EXTRACT_16BITS(&tlv->type) == F_TLV_REDD)) { + print_reddata((u_char *) TLV_DATA(tlv), rlen, 0, indent); + } else { + printf("Unknown REDIRECT TLV 0x%x len %d\n", + EXTRACT_16BITS(&tlv->type), EXTRACT_16BITS(&tlv->length)); + } + + tlv = GO_NXT_TLV(tlv, rlen); + } + + if (rlen) { + printf + ("\n\t\tMessy Redirect TLV header, type (0x%x)\n\t\texcess of %d Bytes ", + EXTRACT_16BITS(&tlv->type), rlen - EXTRACT_16BITS(&tlv->length)); + return -1; + } + + return 0; + +trunc: + fputs("[|forces]", stdout); + return -1; +} + +#define OP_OFF 8 +#define OP_MIN 12 + +int +lfbselect_print(register const u_char * pptr, register u_int len, + u_int16_t op_msk, int indent) +{ + const struct forces_lfbsh *lfbs; + const struct forces_tlv *otlv; + char *ib = indent_pr(indent, 0); + u_int dlen; + u_int rlen; + int invtlv; + + /* + * forces_type_print() has ensured that len (the TLV length) + * >= TLV_HDRL. + */ + dlen = len - TLV_HDRL; + if (dlen <= OP_MIN) { /* id, instance, oper tlv header .. */ + printf("\n\t\ttruncated lfb selector: %d bytes missing! ", + OP_MIN - dlen); + return -1; + } + + /* + * At this point, we know that dlen > OP_MIN; OP_OFF < OP_MIN, so + * we also know that it's > OP_OFF. + */ + rlen = dlen - OP_OFF; + + lfbs = (const struct forces_lfbsh *)pptr; + TCHECK(*lfbs); + if (vflag >= 3) { + printf("\n%s%s(Classid %x) instance %x\n", + ib, tok2str(ForCES_LFBs, NULL, EXTRACT_32BITS(&lfbs->class)), + EXTRACT_32BITS(&lfbs->class), + EXTRACT_32BITS(&lfbs->instance)); + } + + otlv = (struct forces_tlv *)(lfbs + 1); + + indent += 1; + while (rlen != 0) { + TCHECK(*otlv); + invtlv = tlv_valid(otlv, rlen); + if (invtlv) + break; + + /* + * At this point, tlv_valid() has ensured that the TLV + * length is large enough but not too large (it doesn't + * go past the end of the containing TLV). + */ + if (op_valid(EXTRACT_16BITS(&otlv->type), op_msk)) { + otlv_print(otlv, 0, indent); + } else { + if (vflag < 3) + printf("\n"); + printf + ("\t\tINValid oper-TLV type 0x%x length %d for this ForCES message\n", + EXTRACT_16BITS(&otlv->type), EXTRACT_16BITS(&otlv->length)); + invoptlv_print((u_char *)otlv, rlen, 0, indent); + } + otlv = GO_NXT_TLV(otlv, rlen); + } + + if (rlen) { + printf + ("\n\t\tMessy oper TLV header, type (0x%x)\n\t\texcess of %d Bytes ", + EXTRACT_16BITS(&otlv->type), rlen - EXTRACT_16BITS(&otlv->length)); + return -1; + } + + return 0; + +trunc: + fputs("[|forces]", stdout); + return -1; +} + +int +forces_type_print(register const u_char * pptr, const struct forcesh *fhdr _U_, + register u_int mlen, const struct tom_h *tops) +{ + const struct forces_tlv *tltlv; + u_int rlen; + int invtlv; + int rc = 0; + int ttlv = 0; + + /* + * forces_print() has already checked that mlen >= ForCES_HDRL + * by calling ForCES_HLN_VALID(). + */ + rlen = mlen - ForCES_HDRL; + + if (rlen > TLV_HLN) { + if (tops->flags & ZERO_TTLV) { + printf("<0x%x>Illegal Top level TLV!\n", tops->flags); + return -1; + } + } else { + if (tops->flags & ZERO_MORE_TTLV) + return 0; + if (tops->flags & ONE_MORE_TTLV) { + printf("\tTop level TLV Data missing!\n"); + return -1; + } + } + + if (tops->flags & ZERO_TTLV) { + return 0; + } + + ttlv = tops->flags >> 4; + tltlv = GET_TOP_TLV(pptr); + + /*XXX: 15 top level tlvs will probably be fine + You are nuts if you send more ;-> */ + while (rlen != 0) { + TCHECK(*tltlv); + invtlv = tlv_valid(tltlv, rlen); + if (invtlv) + break; + + /* + * At this point, tlv_valid() has ensured that the TLV + * length is large enough but not too large (it doesn't + * go past the end of the packet). + */ + if (!ttlv_valid(EXTRACT_16BITS(&tltlv->type))) { + printf("\n\tInvalid ForCES Top TLV type=0x%x", + EXTRACT_16BITS(&tltlv->type)); + return -1; + } + + if (vflag >= 3) + printf("\t%s, length %d (data length %d Bytes)", + tok2str(ForCES_TLV, NULL, EXTRACT_16BITS(&tltlv->type)), + EXTRACT_16BITS(&tltlv->length), + EXTRACT_16BITS(&tltlv->length) - TLV_HDRL); + + rc = tops->print((u_char *) TLV_DATA(tltlv), + EXTRACT_16BITS(&tltlv->length), tops->op_msk, 9); + if (rc < 0) { + return -1; + } + tltlv = GO_NXT_TLV(tltlv, rlen); + ttlv--; + if (ttlv <= 0) + break; + } + /* + * XXX - if ttlv != 0, does that mean that the packet was too + * short, and didn't have *enough* TLVs in it? + */ + if (rlen) { + printf("\tMess TopTLV header: min %u, total %d advertised %d ", + TLV_HDRL, rlen, EXTRACT_16BITS(&tltlv->length)); + return -1; + } + + return 0; + +trunc: + fputs("[|forces]", stdout); + return -1; +} + +void forces_print(register const u_char * pptr, register u_int len) +{ + const struct forcesh *fhdr; + u_int mlen; + u_int32_t flg_raw; + const struct tom_h *tops; + int rc = 0; + + fhdr = (const struct forcesh *)pptr; + TCHECK(*fhdr); + if (!tom_valid(fhdr->fm_tom)) { + printf("Invalid ForCES message type %d\n", fhdr->fm_tom); + goto error; + } + + mlen = ForCES_BLN(fhdr); + + tops = get_forces_tom(fhdr->fm_tom); + if (tops->v == TOM_RSVD) { + printf("\n\tUnknown ForCES message type=0x%x", fhdr->fm_tom); + goto error; + } + + printf("\n\tForCES %s ", tops->s); + if (!ForCES_HLN_VALID(mlen, len)) { + printf + ("Illegal ForCES pkt len - min %u, total recvd %d, advertised %d ", + ForCES_HDRL, len, ForCES_BLN(fhdr)); + goto error; + } + + TCHECK2(*(pptr + 20), 4); + flg_raw = EXTRACT_32BITS(pptr + 20); + if (vflag >= 1) { + printf("\n\tForCES Version %d len %uB flags 0x%08x ", + ForCES_V(fhdr), mlen, flg_raw); + printf("\n\tSrcID 0x%x(%s) DstID 0x%x(%s) Correlator 0x%" PRIx64, + ForCES_SID(fhdr), ForCES_node(ForCES_SID(fhdr)), + ForCES_DID(fhdr), ForCES_node(ForCES_DID(fhdr)), + EXTRACT_64BITS(fhdr->fm_cor)); + + } + if (vflag >= 2) { + printf + ("\n\tForCES flags:\n\t %s(0x%x), prio=%d, %s(0x%x),\n\t %s(0x%x), %s(0x%x)\n", + ForCES_ACKp(ForCES_ACK(fhdr)), ForCES_ACK(fhdr), + ForCES_PRI(fhdr), + ForCES_EMp(ForCES_EM(fhdr)), ForCES_EM(fhdr), + ForCES_ATp(ForCES_AT(fhdr)), ForCES_AT(fhdr), + ForCES_TPp(ForCES_TP(fhdr)), ForCES_TP(fhdr)); + printf + ("\t Extra flags: rsv(b5-7) 0x%x rsv(b13-31) 0x%x\n", + ForCES_RS1(fhdr), ForCES_RS2(fhdr)); + } + rc = forces_type_print(pptr, fhdr, mlen, tops); + if (rc < 0) { +error: + hex_print_with_offset("\n\t[", pptr, len, 0); + printf("\n\t]"); + return; + } + + if (vflag >= 4) { + printf("\n\t Raw ForCES message\n\t ["); + hex_print_with_offset("\n\t ", pptr, len, 0); + printf("\n\t ]"); + } + printf("\n"); + return; + +trunc: + fputs("[|forces]", stdout); +}
diff --git a/tcpdump-4.3.0/print-fr.c b/tcpdump-4.3.0/print-fr.c new file mode 100644 index 0000000..5126306 --- /dev/null +++ b/tcpdump-4.3.0/print-fr.c
@@ -0,0 +1,883 @@ +/* + * 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-fr.c,v 1.51 2006-06-23 22:20:32 hannes Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> +#include <string.h> +#include <pcap.h> + +#include "addrtoname.h" +#include "interface.h" +#include "ethertype.h" +#include "nlpid.h" +#include "extract.h" +#include "oui.h" + +static void frf15_print(const u_char *, u_int); + +/* + * the frame relay header has a variable length + * + * the EA bit determines if there is another byte + * in the header + * + * minimum header length is 2 bytes + * maximum header length is 4 bytes + * + * 7 6 5 4 3 2 1 0 + * +----+----+----+----+----+----+----+----+ + * | DLCI (6 bits) | CR | EA | + * +----+----+----+----+----+----+----+----+ + * | DLCI (4 bits) |FECN|BECN| DE | EA | + * +----+----+----+----+----+----+----+----+ + * | DLCI (7 bits) | EA | + * +----+----+----+----+----+----+----+----+ + * | DLCI (6 bits) |SDLC| EA | + * +----+----+----+----+----+----+----+----+ + */ + +#define FR_EA_BIT 0x01 + +#define FR_CR_BIT 0x02000000 +#define FR_DE_BIT 0x00020000 +#define FR_BECN_BIT 0x00040000 +#define FR_FECN_BIT 0x00080000 +#define FR_SDLC_BIT 0x00000002 + + +struct tok fr_header_flag_values[] = { + { FR_CR_BIT, "C!" }, + { FR_DE_BIT, "DE" }, + { FR_BECN_BIT, "BECN" }, + { FR_FECN_BIT, "FECN" }, + { FR_SDLC_BIT, "sdlcore" }, + { 0, NULL } +}; + +/* FRF.15 / FRF.16 */ +#define MFR_B_BIT 0x80 +#define MFR_E_BIT 0x40 +#define MFR_C_BIT 0x20 +#define MFR_BEC_MASK (MFR_B_BIT | MFR_E_BIT | MFR_C_BIT) +#define MFR_CTRL_FRAME (MFR_B_BIT | MFR_E_BIT | MFR_C_BIT) +#define MFR_FRAG_FRAME (MFR_B_BIT | MFR_E_BIT ) + +struct tok frf_flag_values[] = { + { MFR_B_BIT, "Begin" }, + { MFR_E_BIT, "End" }, + { MFR_C_BIT, "Control" }, + { 0, NULL } +}; + +/* Finds out Q.922 address length, DLCI and flags. Returns 0 on success + * save the flags dep. on address length + */ +static int parse_q922_addr(const u_char *p, u_int *dlci, + u_int *addr_len, u_int8_t *flags) +{ + if ((p[0] & FR_EA_BIT)) + return -1; + + *addr_len = 2; + *dlci = ((p[0] & 0xFC) << 2) | ((p[1] & 0xF0) >> 4); + + flags[0] = p[0] & 0x02; /* populate the first flag fields */ + flags[1] = p[1] & 0x0c; + flags[2] = 0; /* clear the rest of the flags */ + flags[3] = 0; + + if (p[1] & FR_EA_BIT) + return 0; /* 2-byte Q.922 address */ + + p += 2; + (*addr_len)++; /* 3- or 4-byte Q.922 address */ + if ((p[0] & FR_EA_BIT) == 0) { + *dlci = (*dlci << 7) | (p[0] >> 1); + (*addr_len)++; /* 4-byte Q.922 address */ + p++; + } + + if ((p[0] & FR_EA_BIT) == 0) + return -1; /* more than 4 bytes of Q.922 address? */ + + flags[3] = p[0] & 0x02; + + *dlci = (*dlci << 6) | (p[0] >> 2); + + return 0; +} + +char *q922_string(const u_char *p) { + + static u_int dlci, addr_len; + static u_int8_t flags[4]; + static char buffer[sizeof("DLCI xxxxxxxxxx")]; + memset(buffer, 0, sizeof(buffer)); + + if (parse_q922_addr(p, &dlci, &addr_len, flags) == 0){ + snprintf(buffer, sizeof(buffer), "DLCI %u", dlci); + } + + return buffer; +} + + +/* Frame Relay packet structure, with flags and CRC removed + + +---------------------------+ + | Q.922 Address* | + +-- --+ + | | + +---------------------------+ + | Control (UI = 0x03) | + +---------------------------+ + | Optional Pad (0x00) | + +---------------------------+ + | NLPID | + +---------------------------+ + | . | + | . | + | . | + | Data | + | . | + | . | + +---------------------------+ + + * Q.922 addresses, as presently defined, are two octets and + contain a 10-bit DLCI. In some networks Q.922 addresses + may optionally be increased to three or four octets. +*/ + +static u_int +fr_hdrlen(const u_char *p, u_int addr_len) +{ + if (!p[addr_len + 1] /* pad exist */) + return addr_len + 1 /* UI */ + 1 /* pad */ + 1 /* NLPID */; + else + return addr_len + 1 /* UI */ + 1 /* NLPID */; +} + +static void +fr_hdr_print(int length, u_int addr_len, u_int dlci, u_int8_t *flags, u_int16_t nlpid) +{ + if (qflag) { + (void)printf("Q.922, DLCI %u, length %u: ", + dlci, + length); + } else { + if (nlpid <= 0xff) /* if its smaller than 256 then its a NLPID */ + (void)printf("Q.922, hdr-len %u, DLCI %u, Flags [%s], NLPID %s (0x%02x), length %u: ", + addr_len, + dlci, + bittok2str(fr_header_flag_values, "none", EXTRACT_32BITS(flags)), + tok2str(nlpid_values,"unknown", nlpid), + nlpid, + length); + else /* must be an ethertype */ + (void)printf("Q.922, hdr-len %u, DLCI %u, Flags [%s], cisco-ethertype %s (0x%04x), length %u: ", + addr_len, + dlci, + bittok2str(fr_header_flag_values, "none", EXTRACT_32BITS(flags)), + tok2str(ethertype_values, "unknown", nlpid), + nlpid, + length); + } +} + +u_int +fr_if_print(const struct pcap_pkthdr *h, register const u_char *p) +{ + register u_int length = h->len; + register u_int caplen = h->caplen; + + TCHECK2(*p, 4); /* minimum frame header length */ + + if ((length = fr_print(p, length)) == 0) + return (0); + else + return length; + trunc: + printf("[|fr]"); + return caplen; +} + +u_int +fr_print(register const u_char *p, u_int length) +{ + u_int16_t extracted_ethertype; + u_int dlci; + u_int addr_len; + u_int16_t nlpid; + u_int hdr_len; + u_int8_t flags[4]; + + if (parse_q922_addr(p, &dlci, &addr_len, flags)) { + printf("Q.922, invalid address"); + return 0; + } + + TCHECK2(*p,addr_len+1+1); + hdr_len = fr_hdrlen(p, addr_len); + TCHECK2(*p,hdr_len); + + if (p[addr_len] != 0x03 && dlci != 0) { + + /* lets figure out if we have cisco style encapsulation: */ + extracted_ethertype = EXTRACT_16BITS(p+addr_len); + + if (eflag) + fr_hdr_print(length, addr_len, dlci, flags, extracted_ethertype); + + if (ethertype_print(gndo, extracted_ethertype, + p+addr_len+ETHERTYPE_LEN, + length-addr_len-ETHERTYPE_LEN, + length-addr_len-ETHERTYPE_LEN) == 0) + /* ether_type not known, probably it wasn't one */ + printf("UI %02x! ", p[addr_len]); + else + return hdr_len; + } + + if (!p[addr_len + 1]) { /* pad byte should be used with 3-byte Q.922 */ + if (addr_len != 3) + printf("Pad! "); + } else if (addr_len == 3) + printf("No pad! "); + + nlpid = p[hdr_len - 1]; + + if (eflag) + fr_hdr_print(length, addr_len, dlci, flags, nlpid); + p += hdr_len; + length -= hdr_len; + + switch (nlpid) { + case NLPID_IP: + ip_print(gndo, p, length); + break; + +#ifdef INET6 + case NLPID_IP6: + ip6_print(gndo, p, length); + break; +#endif + case NLPID_CLNP: + case NLPID_ESIS: + case NLPID_ISIS: + isoclns_print(p-1, length+1, length+1); /* OSI printers need the NLPID field */ + break; + + case NLPID_SNAP: + if (snap_print(p, length, length, 0) == 0) { + /* ether_type not known, print raw packet */ + if (!eflag) + fr_hdr_print(length + hdr_len, hdr_len, + dlci, flags, nlpid); + if (!suppress_default_print) + default_print(p - hdr_len, length + hdr_len); + } + break; + + case NLPID_Q933: + q933_print(p, length); + break; + + case NLPID_MFR: + frf15_print(p, length); + break; + + case NLPID_PPP: + ppp_print(p, length); + break; + + default: + if (!eflag) + fr_hdr_print(length + hdr_len, addr_len, + dlci, flags, nlpid); + if (!xflag) + default_print(p, length); + } + + return hdr_len; + + trunc: + printf("[|fr]"); + return 0; + +} + +u_int +mfr_if_print(const struct pcap_pkthdr *h, register const u_char *p) +{ + register u_int length = h->len; + register u_int caplen = h->caplen; + + TCHECK2(*p, 2); /* minimum frame header length */ + + if ((length = mfr_print(p, length)) == 0) + return (0); + else + return length; + trunc: + printf("[|mfr]"); + return caplen; +} + + +#define MFR_CTRL_MSG_ADD_LINK 1 +#define MFR_CTRL_MSG_ADD_LINK_ACK 2 +#define MFR_CTRL_MSG_ADD_LINK_REJ 3 +#define MFR_CTRL_MSG_HELLO 4 +#define MFR_CTRL_MSG_HELLO_ACK 5 +#define MFR_CTRL_MSG_REMOVE_LINK 6 +#define MFR_CTRL_MSG_REMOVE_LINK_ACK 7 + +struct tok mfr_ctrl_msg_values[] = { + { MFR_CTRL_MSG_ADD_LINK, "Add Link" }, + { MFR_CTRL_MSG_ADD_LINK_ACK, "Add Link ACK" }, + { MFR_CTRL_MSG_ADD_LINK_REJ, "Add Link Reject" }, + { MFR_CTRL_MSG_HELLO, "Hello" }, + { MFR_CTRL_MSG_HELLO_ACK, "Hello ACK" }, + { MFR_CTRL_MSG_REMOVE_LINK, "Remove Link" }, + { MFR_CTRL_MSG_REMOVE_LINK_ACK, "Remove Link ACK" }, + { 0, NULL } +}; + +#define MFR_CTRL_IE_BUNDLE_ID 1 +#define MFR_CTRL_IE_LINK_ID 2 +#define MFR_CTRL_IE_MAGIC_NUM 3 +#define MFR_CTRL_IE_TIMESTAMP 5 +#define MFR_CTRL_IE_VENDOR_EXT 6 +#define MFR_CTRL_IE_CAUSE 7 + +struct tok mfr_ctrl_ie_values[] = { + { MFR_CTRL_IE_BUNDLE_ID, "Bundle ID"}, + { MFR_CTRL_IE_LINK_ID, "Link ID"}, + { MFR_CTRL_IE_MAGIC_NUM, "Magic Number"}, + { MFR_CTRL_IE_TIMESTAMP, "Timestamp"}, + { MFR_CTRL_IE_VENDOR_EXT, "Vendor Extension"}, + { MFR_CTRL_IE_CAUSE, "Cause"}, + { 0, NULL } +}; + +#define MFR_ID_STRING_MAXLEN 50 + +struct ie_tlv_header_t { + u_int8_t ie_type; + u_int8_t ie_len; +}; + +u_int +mfr_print(register const u_char *p, u_int length) +{ + u_int tlen,idx,hdr_len = 0; + u_int16_t sequence_num; + u_int8_t ie_type,ie_len; + const u_int8_t *tptr; + + +/* + * FRF.16 Link Integrity Control Frame + * + * 7 6 5 4 3 2 1 0 + * +----+----+----+----+----+----+----+----+ + * | B | E | C=1| 0 0 0 0 | EA | + * +----+----+----+----+----+----+----+----+ + * | 0 0 0 0 0 0 0 0 | + * +----+----+----+----+----+----+----+----+ + * | message type | + * +----+----+----+----+----+----+----+----+ + */ + + TCHECK2(*p, 4); /* minimum frame header length */ + + if ((p[0] & MFR_BEC_MASK) == MFR_CTRL_FRAME && p[1] == 0) { + printf("FRF.16 Control, Flags [%s], %s, length %u", + bittok2str(frf_flag_values,"none",(p[0] & MFR_BEC_MASK)), + tok2str(mfr_ctrl_msg_values,"Unknown Message (0x%02x)",p[2]), + length); + tptr = p + 3; + tlen = length -3; + hdr_len = 3; + + if (!vflag) + return hdr_len; + + while (tlen>sizeof(struct ie_tlv_header_t)) { + TCHECK2(*tptr, sizeof(struct ie_tlv_header_t)); + ie_type=tptr[0]; + ie_len=tptr[1]; + + printf("\n\tIE %s (%u), length %u: ", + tok2str(mfr_ctrl_ie_values,"Unknown",ie_type), + ie_type, + ie_len); + + /* infinite loop check */ + if (ie_type == 0 || ie_len <= sizeof(struct ie_tlv_header_t)) + return hdr_len; + + TCHECK2(*tptr,ie_len); + tptr+=sizeof(struct ie_tlv_header_t); + /* tlv len includes header */ + ie_len-=sizeof(struct ie_tlv_header_t); + tlen-=sizeof(struct ie_tlv_header_t); + + switch (ie_type) { + + case MFR_CTRL_IE_MAGIC_NUM: + printf("0x%08x",EXTRACT_32BITS(tptr)); + break; + + case MFR_CTRL_IE_BUNDLE_ID: /* same message format */ + case MFR_CTRL_IE_LINK_ID: + for (idx = 0; idx < ie_len && idx < MFR_ID_STRING_MAXLEN; idx++) { + if (*(tptr+idx) != 0) /* don't print null termination */ + safeputchar(*(tptr+idx)); + else + break; + } + break; + + case MFR_CTRL_IE_TIMESTAMP: + if (ie_len == sizeof(struct timeval)) { + ts_print((const struct timeval *)tptr); + break; + } + /* fall through and hexdump if no unix timestamp */ + + /* + * FIXME those are the defined IEs that lack a decoder + * you are welcome to contribute code ;-) + */ + + case MFR_CTRL_IE_VENDOR_EXT: + case MFR_CTRL_IE_CAUSE: + + default: + if (vflag <= 1) + print_unknown_data(tptr,"\n\t ",ie_len); + break; + } + + /* do we want to see a hexdump of the IE ? */ + if (vflag > 1 ) + print_unknown_data(tptr,"\n\t ",ie_len); + + tlen-=ie_len; + tptr+=ie_len; + } + return hdr_len; + } +/* + * FRF.16 Fragmentation Frame + * + * 7 6 5 4 3 2 1 0 + * +----+----+----+----+----+----+----+----+ + * | B | E | C=0|seq. (high 4 bits) | EA | + * +----+----+----+----+----+----+----+----+ + * | sequence (low 8 bits) | + * +----+----+----+----+----+----+----+----+ + * | DLCI (6 bits) | CR | EA | + * +----+----+----+----+----+----+----+----+ + * | DLCI (4 bits) |FECN|BECN| DE | EA | + * +----+----+----+----+----+----+----+----+ + */ + + sequence_num = (p[0]&0x1e)<<7 | p[1]; + /* whole packet or first fragment ? */ + if ((p[0] & MFR_BEC_MASK) == MFR_FRAG_FRAME || + (p[0] & MFR_BEC_MASK) == MFR_B_BIT) { + printf("FRF.16 Frag, seq %u, Flags [%s], ", + sequence_num, + bittok2str(frf_flag_values,"none",(p[0] & MFR_BEC_MASK))); + hdr_len = 2; + fr_print(p+hdr_len,length-hdr_len); + return hdr_len; + } + + /* must be a middle or the last fragment */ + printf("FRF.16 Frag, seq %u, Flags [%s]", + sequence_num, + bittok2str(frf_flag_values,"none",(p[0] & MFR_BEC_MASK))); + print_unknown_data(p,"\n\t",length); + + return hdr_len; + + trunc: + printf("[|mfr]"); + return length; +} + +/* an NLPID of 0xb1 indicates a 2-byte + * FRF.15 header + * + * 7 6 5 4 3 2 1 0 + * +----+----+----+----+----+----+----+----+ + * ~ Q.922 header ~ + * +----+----+----+----+----+----+----+----+ + * | NLPID (8 bits) | NLPID=0xb1 + * +----+----+----+----+----+----+----+----+ + * | B | E | C |seq. (high 4 bits) | R | + * +----+----+----+----+----+----+----+----+ + * | sequence (low 8 bits) | + * +----+----+----+----+----+----+----+----+ + */ + +#define FR_FRF15_FRAGTYPE 0x01 + +static void +frf15_print (const u_char *p, u_int length) { + + u_int16_t sequence_num, flags; + + flags = p[0]&MFR_BEC_MASK; + sequence_num = (p[0]&0x1e)<<7 | p[1]; + + printf("FRF.15, seq 0x%03x, Flags [%s],%s Fragmentation, length %u", + sequence_num, + bittok2str(frf_flag_values,"none",flags), + p[0]&FR_FRF15_FRAGTYPE ? "Interface" : "End-to-End", + length); + +/* TODO: + * depending on all permutations of the B, E and C bit + * dig as deep as we can - e.g. on the first (B) fragment + * there is enough payload to print the IP header + * on non (B) fragments it depends if the fragmentation + * model is end-to-end or interface based wether we want to print + * another Q.922 header + */ + +} + +/* + * Q.933 decoding portion for framerelay specific. + */ + +/* Q.933 packet format + Format of Other Protocols + using Q.933 NLPID + +-------------------------------+ + | Q.922 Address | + +---------------+---------------+ + |Control 0x03 | NLPID 0x08 | + +---------------+---------------+ + | L2 Protocol ID | + | octet 1 | octet 2 | + +-------------------------------+ + | L3 Protocol ID | + | octet 2 | octet 2 | + +-------------------------------+ + | Protocol Data | + +-------------------------------+ + | FCS | + +-------------------------------+ + */ + +/* L2 (Octet 1)- Call Reference Usually is 0x0 */ + +/* + * L2 (Octet 2)- Message Types definition 1 byte long. + */ +/* Call Establish */ +#define MSG_TYPE_ESC_TO_NATIONAL 0x00 +#define MSG_TYPE_ALERT 0x01 +#define MSG_TYPE_CALL_PROCEEDING 0x02 +#define MSG_TYPE_CONNECT 0x07 +#define MSG_TYPE_CONNECT_ACK 0x0F +#define MSG_TYPE_PROGRESS 0x03 +#define MSG_TYPE_SETUP 0x05 +/* Call Clear */ +#define MSG_TYPE_DISCONNECT 0x45 +#define MSG_TYPE_RELEASE 0x4D +#define MSG_TYPE_RELEASE_COMPLETE 0x5A +#define MSG_TYPE_RESTART 0x46 +#define MSG_TYPE_RESTART_ACK 0x4E +/* Status */ +#define MSG_TYPE_STATUS 0x7D +#define MSG_TYPE_STATUS_ENQ 0x75 + +struct tok fr_q933_msg_values[] = { + { MSG_TYPE_ESC_TO_NATIONAL, "ESC to National" }, + { MSG_TYPE_ALERT, "Alert" }, + { MSG_TYPE_CALL_PROCEEDING, "Call proceeding" }, + { MSG_TYPE_CONNECT, "Connect" }, + { MSG_TYPE_CONNECT_ACK, "Connect ACK" }, + { MSG_TYPE_PROGRESS, "Progress" }, + { MSG_TYPE_SETUP, "Setup" }, + { MSG_TYPE_DISCONNECT, "Disconnect" }, + { MSG_TYPE_RELEASE, "Release" }, + { MSG_TYPE_RELEASE_COMPLETE, "Release Complete" }, + { MSG_TYPE_RESTART, "Restart" }, + { MSG_TYPE_RESTART_ACK, "Restart ACK" }, + { MSG_TYPE_STATUS, "Status Reply" }, + { MSG_TYPE_STATUS_ENQ, "Status Enquiry" }, + { 0, NULL } +}; + +#define MSG_ANSI_LOCKING_SHIFT 0x95 + +#define FR_LMI_ANSI_REPORT_TYPE_IE 0x01 +#define FR_LMI_ANSI_LINK_VERIFY_IE_91 0x19 /* details? */ +#define FR_LMI_ANSI_LINK_VERIFY_IE 0x03 +#define FR_LMI_ANSI_PVC_STATUS_IE 0x07 + +#define FR_LMI_CCITT_REPORT_TYPE_IE 0x51 +#define FR_LMI_CCITT_LINK_VERIFY_IE 0x53 +#define FR_LMI_CCITT_PVC_STATUS_IE 0x57 + +struct tok fr_q933_ie_values_codeset5[] = { + { FR_LMI_ANSI_REPORT_TYPE_IE, "ANSI Report Type" }, + { FR_LMI_ANSI_LINK_VERIFY_IE_91, "ANSI Link Verify" }, + { FR_LMI_ANSI_LINK_VERIFY_IE, "ANSI Link Verify" }, + { FR_LMI_ANSI_PVC_STATUS_IE, "ANSI PVC Status" }, + { FR_LMI_CCITT_REPORT_TYPE_IE, "CCITT Report Type" }, + { FR_LMI_CCITT_LINK_VERIFY_IE, "CCITT Link Verify" }, + { FR_LMI_CCITT_PVC_STATUS_IE, "CCITT PVC Status" }, + { 0, NULL } +}; + +#define FR_LMI_REPORT_TYPE_IE_FULL_STATUS 0 +#define FR_LMI_REPORT_TYPE_IE_LINK_VERIFY 1 +#define FR_LMI_REPORT_TYPE_IE_ASYNC_PVC 2 + +struct tok fr_lmi_report_type_ie_values[] = { + { FR_LMI_REPORT_TYPE_IE_FULL_STATUS, "Full Status" }, + { FR_LMI_REPORT_TYPE_IE_LINK_VERIFY, "Link verify" }, + { FR_LMI_REPORT_TYPE_IE_ASYNC_PVC, "Async PVC Status" }, + { 0, NULL } +}; + +/* array of 16 codepages - currently we only support codepage 1,5 */ +static struct tok *fr_q933_ie_codesets[] = { + NULL, + fr_q933_ie_values_codeset5, + NULL, + NULL, + NULL, + fr_q933_ie_values_codeset5, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL +}; + +static int fr_q933_print_ie_codeset5(const struct ie_tlv_header_t *ie_p, + const u_char *p); + +typedef int (*codeset_pr_func_t)(const struct ie_tlv_header_t *ie_p, + const u_char *p); + +/* array of 16 codepages - currently we only support codepage 1,5 */ +static codeset_pr_func_t fr_q933_print_ie_codeset[] = { + NULL, + fr_q933_print_ie_codeset5, + NULL, + NULL, + NULL, + fr_q933_print_ie_codeset5, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL +}; + +void +q933_print(const u_char *p, u_int length) +{ + const u_char *ptemp = p; + struct ie_tlv_header_t *ie_p; + int olen; + int is_ansi = 0; + u_int codeset; + u_int ie_is_known = 0; + + if (length < 9) { /* shortest: Q.933a LINK VERIFY */ + printf("[|q.933]"); + return; + } + + codeset = p[2]&0x0f; /* extract the codeset */ + + if (p[2] == MSG_ANSI_LOCKING_SHIFT) { + is_ansi = 1; + } + + printf("%s", eflag ? "" : "Q.933, "); + + /* printing out header part */ + printf("%s, codeset %u", is_ansi ? "ANSI" : "CCITT", codeset); + + if (p[0]) { + printf(", Call Ref: 0x%02x", p[0]); + } + if (vflag) { + printf(", %s (0x%02x), length %u", + tok2str(fr_q933_msg_values, + "unknown message", p[1]), + p[1], + length); + } else { + printf(", %s", + tok2str(fr_q933_msg_values, + "unknown message 0x%02x", p[1])); + } + + olen = length; /* preserve the original length for non verbose mode */ + + if (length < (u_int)(2 - is_ansi)) { + printf("[|q.933]"); + return; + } + length -= 2 + is_ansi; + ptemp += 2 + is_ansi; + + /* Loop through the rest of IE */ + while (length > sizeof(struct ie_tlv_header_t)) { + ie_p = (struct ie_tlv_header_t *)ptemp; + if (length < sizeof(struct ie_tlv_header_t) || + length < sizeof(struct ie_tlv_header_t) + ie_p->ie_len) { + if (vflag) { /* not bark if there is just a trailer */ + printf("\n[|q.933]"); + } else { + printf(", length %u",olen); + } + return; + } + + /* lets do the full IE parsing only in verbose mode + * however some IEs (DLCI Status, Link Verify) + * are also interestting in non-verbose mode */ + if (vflag) { + printf("\n\t%s IE (0x%02x), length %u: ", + tok2str(fr_q933_ie_codesets[codeset], + "unknown", ie_p->ie_type), + ie_p->ie_type, + ie_p->ie_len); + } + + /* sanity check */ + if (ie_p->ie_type == 0 || ie_p->ie_len == 0) { + return; + } + + if (fr_q933_print_ie_codeset[codeset] != NULL) { + ie_is_known = fr_q933_print_ie_codeset[codeset](ie_p, ptemp); + } + + if (vflag >= 1 && !ie_is_known) { + print_unknown_data(ptemp+2,"\n\t",ie_p->ie_len); + } + + /* do we want to see a hexdump of the IE ? */ + if (vflag> 1 && ie_is_known) { + print_unknown_data(ptemp+2,"\n\t ",ie_p->ie_len); + } + + length = length - ie_p->ie_len - 2; + ptemp = ptemp + ie_p->ie_len + 2; + } + if (!vflag) { + printf(", length %u",olen); + } +} + +static int +fr_q933_print_ie_codeset5(const struct ie_tlv_header_t *ie_p, const u_char *p) +{ + u_int dlci; + + switch (ie_p->ie_type) { + + case FR_LMI_ANSI_REPORT_TYPE_IE: /* fall through */ + case FR_LMI_CCITT_REPORT_TYPE_IE: + if (vflag) { + printf("%s (%u)", + tok2str(fr_lmi_report_type_ie_values,"unknown",p[2]), + p[2]); + } + return 1; + + case FR_LMI_ANSI_LINK_VERIFY_IE: /* fall through */ + case FR_LMI_CCITT_LINK_VERIFY_IE: + case FR_LMI_ANSI_LINK_VERIFY_IE_91: + if (!vflag) { + printf(", "); + } + printf("TX Seq: %3d, RX Seq: %3d", p[2], p[3]); + return 1; + + case FR_LMI_ANSI_PVC_STATUS_IE: /* fall through */ + case FR_LMI_CCITT_PVC_STATUS_IE: + if (!vflag) { + printf(", "); + } + /* now parse the DLCI information element. */ + if ((ie_p->ie_len < 3) || + (p[2] & 0x80) || + ((ie_p->ie_len == 3) && !(p[3] & 0x80)) || + ((ie_p->ie_len == 4) && ((p[3] & 0x80) || !(p[4] & 0x80))) || + ((ie_p->ie_len == 5) && ((p[3] & 0x80) || (p[4] & 0x80) || + !(p[5] & 0x80))) || + (ie_p->ie_len > 5) || + !(p[ie_p->ie_len + 1] & 0x80)) { + printf("Invalid DLCI IE"); + } + + dlci = ((p[2] & 0x3F) << 4) | ((p[3] & 0x78) >> 3); + if (ie_p->ie_len == 4) { + dlci = (dlci << 6) | ((p[4] & 0x7E) >> 1); + } + else if (ie_p->ie_len == 5) { + dlci = (dlci << 13) | (p[4] & 0x7F) | ((p[5] & 0x7E) >> 1); + } + + printf("DLCI %u: status %s%s", dlci, + p[ie_p->ie_len + 1] & 0x8 ? "New, " : "", + p[ie_p->ie_len + 1] & 0x2 ? "Active" : "Inactive"); + return 1; + } + + return 0; +}
diff --git a/tcpdump-4.3.0/print-frag6.c b/tcpdump-4.3.0/print-frag6.c new file mode 100644 index 0000000..e125bd3 --- /dev/null +++ b/tcpdump-4.3.0/print-frag6.c
@@ -0,0 +1,82 @@ +/* + * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994 + * 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-frag6.c,v 1.20 2005-04-20 22:33:06 guy Exp $"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifdef INET6 + +#include <tcpdump-stdinc.h> + +#include <stdio.h> + +#include "ip6.h" + +#include "interface.h" +#include "addrtoname.h" +#include "extract.h" + +int +frag6_print(register const u_char *bp, register const u_char *bp2) +{ + register const struct ip6_frag *dp; + register const struct ip6_hdr *ip6; + + dp = (const struct ip6_frag *)bp; + ip6 = (const struct ip6_hdr *)bp2; + + TCHECK(dp->ip6f_offlg); + + if (vflag) { + printf("frag (0x%08x:%d|%ld)", + 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)", + 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 ((EXTRACT_16BITS(&dp->ip6f_offlg) & IP6F_OFF_MASK) != 0) + return -1; + else +#endif + { + fputs(" ", stdout); + return sizeof(struct ip6_frag); + } +trunc: + fputs("[|frag]", stdout); + return -1; +#undef TCHECK +} +#endif /* INET6 */
diff --git a/tcpdump-4.3.0/print-gre.c b/tcpdump-4.3.0/print-gre.c new file mode 100644 index 0000000..b6fa522 --- /dev/null +++ b/tcpdump-4.3.0/print-gre.c
@@ -0,0 +1,403 @@ +/* $OpenBSD: print-gre.c,v 1.6 2002/10/30 03:04:04 fgsch Exp $ */ + +/* + * Copyright (c) 2002 Jason L. Wright (jason@thought.net) + * 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 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 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[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-gre.c,v 1.28 2005-04-06 21:32:39 mcr Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> +#include <string.h> + +#include "interface.h" +#include "addrtoname.h" +#include "extract.h" + +#include "ip.h" +#include "ethertype.h" + +#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 */ + +struct tok gre_flag_values[] = { + { GRE_CP, "checksum present"}, + { GRE_RP, "routing present"}, + { GRE_KP, "key present"}, + { GRE_SP, "sequence# present"}, + { GRE_sP, "source routing present"}, + { GRE_RECRS, "recursion count"}, + { GRE_AP, "ack present"}, + { 0, NULL } +}; + +#define GRE_VERS_MASK 0x0007 /* protocol version */ + +/* source route entry types */ +#define GRESRE_IP 0x0800 /* IP */ +#define GRESRE_ASN 0xfffe /* ASN */ + +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); + +void +gre_print(const u_char *bp, u_int length) +{ + u_int len = length, vers; + + if (len < 2) { + printf("[|gre]"); + return; + } + vers = EXTRACT_16BITS(bp) & GRE_VERS_MASK; + printf("GREv%u",vers); + + switch(vers) { + case 0: + gre_print_0(bp, len); + break; + case 1: + gre_print_1(bp, len); + break; + default: + printf(" ERROR: unknown-version"); + break; + } + return; + +} + +void +gre_print_0(const u_char *bp, u_int length) +{ + u_int len = length; + u_int16_t flags, prot; + + flags = EXTRACT_16BITS(bp); + if (vflag) + printf(", Flags [%s]", + bittok2str(gre_flag_values,"none",flags)); + + 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) { + if (len < 4) + goto trunc; + printf(", key=0x%x", EXTRACT_32BITS(bp)); + bp += 4; + len -= 4; + } + + if (flags & GRE_SP) { + 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; + } + } + + if (eflag) + printf(", proto %s (0x%04x)", + tok2str(ethertype_values,"unknown",prot), + prot); + + printf(", length %u",length); + + if (vflag < 1) + printf(": "); /* put in a colon as protocol demarc */ + else + printf("\n\t"); /* if verbose go multiline */ + + switch (prot) { + case ETHERTYPE_IP: + ip_print(gndo, bp, len); + break; +#ifdef INET6 + case ETHERTYPE_IPV6: + ip6_print(gndo, bp, len); + break; +#endif + case ETHERTYPE_MPLS: + mpls_print(bp, len); + break; + case ETHERTYPE_IPX: + ipx_print(bp, len); + break; + case ETHERTYPE_ATALK: + atalk_print(bp, len); + break; + case ETHERTYPE_GRE_ISO: + isoclns_print(bp, len, len); + break; + case ETHERTYPE_TEB: + ether_print(gndo, bp, len, len, NULL, NULL); + 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(", Flags [%s]", + bittok2str(gre_flag_values,"none",flags)); + + if (len < 2) + goto trunc; + prot = EXTRACT_16BITS(bp); + len -= 2; + bp += 2; + + + if (flags & GRE_KP) { + u_int32_t k; + + 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; + } + + if ((flags & GRE_SP) == 0) + printf(", no-payload"); + + if (eflag) + printf(", proto %s (0x%04x)", + tok2str(ethertype_values,"unknown",prot), + prot); + + printf(", length %u",length); + + if ((flags & GRE_SP) == 0) + return; + + if (vflag < 1) + printf(": "); /* put in a colon as protocol demarc */ + else + printf("\n\t"); /* if verbose go multiline */ + + switch (prot) { + case ETHERTYPE_PPP: + ppp_print(bp, len); + break; + default: + printf("gre-proto-0x%x", prot); + break; + } + return; + +trunc: + 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/tcpdump-4.3.0/print-hsrp.c b/tcpdump-4.3.0/print-hsrp.c new file mode 100644 index 0000000..06304fd --- /dev/null +++ b/tcpdump-4.3.0/print-hsrp.c
@@ -0,0 +1,140 @@ +/* + * Copyright (C) 2001 Julian Cowley + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* Cisco Hot Standby Router Protocol (HSRP). */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-hsrp.c,v 1.10 2005-05-06 07:56:52 guy Exp $"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> + +#include "interface.h" +#include "addrtoname.h" + +/* HSRP op code types. */ +static const char *op_code_str[] = { + "hello", + "coup", + "resign" +}; + +/* HSRP states and associated names. */ +static struct tok states[] = { + { 0, "initial" }, + { 1, "learn" }, + { 2, "listen" }, + { 4, "speak" }, + { 8, "standby" }, + { 16, "active" }, + { 0, NULL } +}; + +/* + * RFC 2281: + * + * 0 1 2 3 + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Version | Op Code | State | Hellotime | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Holdtime | Priority | Group | Reserved | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Authentication Data | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Authentication Data | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Virtual IP Address | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ + +#define HSRP_AUTH_SIZE 8 + +/* HSRP protocol header. */ +struct hsrp { + u_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_int8_t *bp, register u_int len) +{ + struct hsrp *hp = (struct hsrp *) bp; + + TCHECK(hp->hsrp_version); + printf("HSRPv%d", hp->hsrp_version); + if (hp->hsrp_version != 0) + return; + TCHECK(hp->hsrp_op_code); + printf("-"); + printf("%s ", tok2strary(op_code_str, "unknown (%d)", hp->hsrp_op_code)); + printf("%d: ", len); + TCHECK(hp->hsrp_state); + printf("state=%s ", tok2str(states, "Unknown (%d)", hp->hsrp_state)); + TCHECK(hp->hsrp_group); + printf("group=%d ", hp->hsrp_group); + TCHECK(hp->hsrp_reserved); + if (hp->hsrp_reserved != 0) { + printf("[reserved=%d!] ", hp->hsrp_reserved); + } + TCHECK(hp->hsrp_virtaddr); + printf("addr=%s", ipaddr_string(&hp->hsrp_virtaddr)); + if (vflag) { + printf(" hellotime="); + relts_print(hp->hsrp_hellotime); + printf(" holdtime="); + relts_print(hp->hsrp_holdtime); + printf(" priority=%d", hp->hsrp_priority); + printf(" auth=\""); + if (fn_printn(hp->hsrp_authdata, sizeof(hp->hsrp_authdata), + snapend)) { + printf("\""); + goto trunc; + } + printf("\""); + } + return; +trunc: + printf("[|hsrp]"); +}
diff --git a/tcpdump-4.3.0/print-icmp.c b/tcpdump-4.3.0/print-icmp.c new file mode 100644 index 0000000..03b9505 --- /dev/null +++ b/tcpdump-4.3.0/print-icmp.c
@@ -0,0 +1,695 @@ +/* + * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994, 1995, 1996 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.87 2007-09-13 17:42:31 guy Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> +#include <string.h> + +#include "interface.h" +#include "addrtoname.h" +#include "extract.h" /* must come after interface.h */ + +#include "ip.h" +#include "udp.h" +#include "ipproto.h" +#include "mpls.h" + +/* + * Interface Control Message Protocol Definitions. + * Per RFC 792, September 1981. + */ + +/* + * Structure of an icmp header. + */ +struct icmp { + u_int8_t icmp_type; /* type of message, see below */ + u_int8_t icmp_code; /* type sub code */ + u_int16_t icmp_cksum; /* ones complement cksum of struct */ + union { + u_int8_t ih_pptr; /* ICMP_PARAMPROB */ + struct in_addr ih_gwaddr; /* ICMP_REDIRECT */ + struct ih_idseq { + u_int16_t icd_id; + u_int16_t icd_seq; + } ih_idseq; + u_int32_t ih_void; + } icmp_hun; +#define icmp_pptr icmp_hun.ih_pptr +#define icmp_gwaddr icmp_hun.ih_gwaddr +#define icmp_id icmp_hun.ih_idseq.icd_id +#define icmp_seq icmp_hun.ih_idseq.icd_seq +#define icmp_void icmp_hun.ih_void + union { + struct id_ts { + u_int32_t its_otime; + u_int32_t its_rtime; + u_int32_t its_ttime; + } id_ts; + struct id_ip { + struct ip idi_ip; + /* options and then 64 bits of data */ + } id_ip; + u_int32_t id_mask; + u_int8_t id_data[1]; + } icmp_dun; +#define icmp_otime icmp_dun.id_ts.its_otime +#define icmp_rtime icmp_dun.id_ts.its_rtime +#define icmp_ttime icmp_dun.id_ts.its_ttime +#define icmp_ip icmp_dun.id_ip.idi_ip +#define icmp_mask icmp_dun.id_mask +#define icmp_data icmp_dun.id_data +}; + +#define ICMP_MPLS_EXT_EXTRACT_VERSION(x) (((x)&0xf0)>>4) +#define ICMP_MPLS_EXT_VERSION 2 + +/* + * Lower bounds on packet lengths for various types. + * For the error advice packets must first insure that the + * packet is large enought to contain the returned ip header. + * Only then can we do the check to see if 64 bits of packet + * data have been returned, since we need to check the returned + * ip header length. + */ +#define ICMP_MINLEN 8 /* abs minimum */ +#define ICMP_EXTD_MINLEN (156 - sizeof (struct ip)) /* draft-bonica-internet-icmp-08 */ +#define ICMP_TSLEN (8 + 3 * sizeof (u_int32_t)) /* timestamp */ +#define ICMP_MASKLEN 12 /* address mask */ +#define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */ +#define ICMP_ADVLEN(p) (8 + (IP_HL(&(p)->icmp_ip) << 2) + 8) + /* N.B.: must separately check that ip_hl >= 5 */ + +/* + * Definition of type and code field values. + */ +#define ICMP_ECHOREPLY 0 /* echo reply */ +#define ICMP_UNREACH 3 /* dest unreachable, codes: */ +#define ICMP_UNREACH_NET 0 /* bad net */ +#define ICMP_UNREACH_HOST 1 /* bad host */ +#define ICMP_UNREACH_PROTOCOL 2 /* bad protocol */ +#define ICMP_UNREACH_PORT 3 /* bad port */ +#define ICMP_UNREACH_NEEDFRAG 4 /* IP_DF caused drop */ +#define ICMP_UNREACH_SRCFAIL 5 /* src route failed */ +#define ICMP_UNREACH_NET_UNKNOWN 6 /* unknown net */ +#define ICMP_UNREACH_HOST_UNKNOWN 7 /* unknown host */ +#define ICMP_UNREACH_ISOLATED 8 /* src host isolated */ +#define ICMP_UNREACH_NET_PROHIB 9 /* prohibited access */ +#define ICMP_UNREACH_HOST_PROHIB 10 /* ditto */ +#define ICMP_UNREACH_TOSNET 11 /* bad tos for net */ +#define ICMP_UNREACH_TOSHOST 12 /* bad tos for host */ +#define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */ +#define ICMP_REDIRECT 5 /* shorter route, codes: */ +#define ICMP_REDIRECT_NET 0 /* for network */ +#define ICMP_REDIRECT_HOST 1 /* for host */ +#define ICMP_REDIRECT_TOSNET 2 /* for tos and net */ +#define ICMP_REDIRECT_TOSHOST 3 /* for tos and host */ +#define ICMP_ECHO 8 /* echo service */ +#define ICMP_ROUTERADVERT 9 /* router advertisement */ +#define ICMP_ROUTERSOLICIT 10 /* router solicitation */ +#define ICMP_TIMXCEED 11 /* time exceeded, code: */ +#define ICMP_TIMXCEED_INTRANS 0 /* ttl==0 in transit */ +#define ICMP_TIMXCEED_REASS 1 /* ttl==0 in reass */ +#define ICMP_PARAMPROB 12 /* ip header bad */ +#define ICMP_PARAMPROB_OPTABSENT 1 /* req. opt. absent */ +#define ICMP_TSTAMP 13 /* timestamp request */ +#define ICMP_TSTAMPREPLY 14 /* timestamp reply */ +#define ICMP_IREQ 15 /* information request */ +#define ICMP_IREQREPLY 16 /* information reply */ +#define ICMP_MASKREQ 17 /* address mask request */ +#define ICMP_MASKREPLY 18 /* address mask reply */ + +#define ICMP_MAXTYPE 18 + +#define ICMP_INFOTYPE(type) \ + ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \ + (type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \ + (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \ + (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \ + (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY) +#define ICMP_MPLS_EXT_TYPE(type) \ + ((type) == ICMP_UNREACH || \ + (type) == ICMP_TIMXCEED || \ + (type) == ICMP_PARAMPROB) +/* rfc1700 */ +#ifndef ICMP_UNREACH_NET_UNKNOWN +#define ICMP_UNREACH_NET_UNKNOWN 6 /* destination net unknown */ +#endif +#ifndef ICMP_UNREACH_HOST_UNKNOWN +#define ICMP_UNREACH_HOST_UNKNOWN 7 /* destination host unknown */ +#endif +#ifndef ICMP_UNREACH_ISOLATED +#define ICMP_UNREACH_ISOLATED 8 /* source host isolated */ +#endif +#ifndef ICMP_UNREACH_NET_PROHIB +#define ICMP_UNREACH_NET_PROHIB 9 /* admin prohibited net */ +#endif +#ifndef ICMP_UNREACH_HOST_PROHIB +#define ICMP_UNREACH_HOST_PROHIB 10 /* admin prohibited host */ +#endif +#ifndef ICMP_UNREACH_TOSNET +#define ICMP_UNREACH_TOSNET 11 /* tos prohibited net */ +#endif +#ifndef ICMP_UNREACH_TOSHOST +#define ICMP_UNREACH_TOSHOST 12 /* tos prohibited host */ +#endif + +/* rfc1716 */ +#ifndef ICMP_UNREACH_FILTER_PROHIB +#define ICMP_UNREACH_FILTER_PROHIB 13 /* admin prohibited filter */ +#endif +#ifndef ICMP_UNREACH_HOST_PRECEDENCE +#define ICMP_UNREACH_HOST_PRECEDENCE 14 /* host precedence violation */ +#endif +#ifndef ICMP_UNREACH_PRECEDENCE_CUTOFF +#define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 /* precedence cutoff */ +#endif + +/* Most of the icmp types */ +static struct tok icmp2str[] = { + { ICMP_ECHOREPLY, "echo reply" }, + { ICMP_SOURCEQUENCH, "source quench" }, + { ICMP_ECHO, "echo request" }, + { ICMP_ROUTERSOLICIT, "router solicitation" }, + { ICMP_TSTAMP, "time stamp request" }, + { ICMP_TSTAMPREPLY, "time stamp reply" }, + { ICMP_IREQ, "information request" }, + { ICMP_IREQREPLY, "information reply" }, + { ICMP_MASKREQ, "address mask request" }, + { 0, NULL } +}; + +/* Formats for most of the ICMP_UNREACH codes */ +static struct tok unreach2str[] = { + { ICMP_UNREACH_NET, "net %s unreachable" }, + { ICMP_UNREACH_HOST, "host %s unreachable" }, + { ICMP_UNREACH_SRCFAIL, + "%s unreachable - source route failed" }, + { ICMP_UNREACH_NET_UNKNOWN, "net %s unreachable - unknown" }, + { ICMP_UNREACH_HOST_UNKNOWN, "host %s unreachable - unknown" }, + { ICMP_UNREACH_ISOLATED, + "%s unreachable - source host isolated" }, + { ICMP_UNREACH_NET_PROHIB, + "net %s unreachable - admin prohibited" }, + { ICMP_UNREACH_HOST_PROHIB, + "host %s unreachable - admin prohibited" }, + { ICMP_UNREACH_TOSNET, + "net %s unreachable - tos prohibited" }, + { ICMP_UNREACH_TOSHOST, + "host %s unreachable - tos prohibited" }, + { ICMP_UNREACH_FILTER_PROHIB, + "host %s unreachable - admin prohibited filter" }, + { ICMP_UNREACH_HOST_PRECEDENCE, + "host %s unreachable - host precedence violation" }, + { ICMP_UNREACH_PRECEDENCE_CUTOFF, + "host %s unreachable - precedence cutoff" }, + { 0, NULL } +}; + +/* Formats for the ICMP_REDIRECT codes */ +static struct tok type2str[] = { + { ICMP_REDIRECT_NET, "redirect %s to net %s" }, + { ICMP_REDIRECT_HOST, "redirect %s to host %s" }, + { ICMP_REDIRECT_TOSNET, "redirect-tos %s to net %s" }, + { ICMP_REDIRECT_TOSHOST, "redirect-tos %s to host %s" }, + { 0, NULL } +}; + +/* rfc1191 */ +struct mtu_discovery { + u_int16_t unused; + u_int16_t nexthopmtu; +}; + +/* rfc1256 */ +struct ih_rdiscovery { + u_int8_t ird_addrnum; + u_int8_t ird_addrsiz; + u_int16_t ird_lifetime; +}; + +struct id_rdiscovery { + u_int32_t ird_addr; + u_int32_t ird_pref; +}; + +/* + * draft-bonica-internet-icmp-08 + * + * The Destination Unreachable, Time Exceeded + * and Parameter Problem messages are slighly changed as per + * the above draft. A new Length field gets added to give + * the caller an idea about the length of the piggypacked + * IP packet before the MPLS extension header starts. + * + * The Length field represents length of the padded "original datagram" + * field measured in 32-bit words. + * + * 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 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Type | Code | Checksum | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | unused | Length | unused | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Internet Header + leading octets of original datagram | + * | | + * | // | + * | | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ + +struct icmp_ext_t { + u_int8_t icmp_type; + u_int8_t icmp_code; + u_int8_t icmp_checksum[2]; + u_int8_t icmp_reserved; + u_int8_t icmp_length; + u_int8_t icmp_reserved2[2]; + u_int8_t icmp_ext_legacy_header[128]; /* extension header starts 128 bytes after ICMP header */ + u_int8_t icmp_ext_version_res[2]; + u_int8_t icmp_ext_checksum[2]; + u_int8_t icmp_ext_data[1]; +}; + +struct icmp_mpls_ext_object_header_t { + u_int8_t length[2]; + u_int8_t class_num; + u_int8_t ctype; +}; + +static const struct tok icmp_mpls_ext_obj_values[] = { + { 1, "MPLS Stack Entry" }, + { 2, "Extended Payload" }, + { 0, NULL} +}; + +/* prototypes */ +const char *icmp_tstamp_print(u_int); + +/* print the milliseconds since midnight UTC */ +const char * +icmp_tstamp_print(u_int tstamp) { + u_int msec,sec,min,hrs; + + static char buf[64]; + + msec = tstamp % 1000; + sec = tstamp / 1000; + min = sec / 60; sec -= min * 60; + hrs = min / 60; min -= hrs * 60; + snprintf(buf, sizeof(buf), "%02u:%02u:%02u.%03u",hrs,min,sec,msec); + return buf; +} + +void +icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented) +{ + char *cp; + const struct icmp *dp; + const struct icmp_ext_t *ext_dp; + const struct ip *ip; + const char *str, *fmt; + const struct ip *oip; + const struct udphdr *ouh; + const u_int8_t *obj_tptr; + u_int32_t raw_label; + const u_char *snapend_save; + const struct icmp_mpls_ext_object_header_t *icmp_mpls_ext_object_header; + u_int hlen, dport, mtu, obj_tlen, obj_class_num, obj_ctype; + char buf[MAXHOSTNAMELEN + 100]; + struct cksum_vec vec[1]; + + dp = (struct icmp *)bp; + ext_dp = (struct icmp_ext_t *)bp; + ip = (struct ip *)bp2; + str = buf; + + TCHECK(dp->icmp_code); + switch (dp->icmp_type) { + + case ICMP_ECHO: + case ICMP_ECHOREPLY: + TCHECK(dp->icmp_seq); + (void)snprintf(buf, sizeof(buf), "echo %s, id %u, seq %u", + dp->icmp_type == ICMP_ECHO ? + "request" : "reply", + EXTRACT_16BITS(&dp->icmp_id), + EXTRACT_16BITS(&dp->icmp_seq)); + break; + + case ICMP_UNREACH: + TCHECK(dp->icmp_ip.ip_dst); + switch (dp->icmp_code) { + + case ICMP_UNREACH_PROTOCOL: + TCHECK(dp->icmp_ip.ip_p); + (void)snprintf(buf, sizeof(buf), + "%s protocol %d unreachable", + ipaddr_string(&dp->icmp_ip.ip_dst), + dp->icmp_ip.ip_p); + break; + + case ICMP_UNREACH_PORT: + TCHECK(dp->icmp_ip.ip_p); + oip = &dp->icmp_ip; + hlen = IP_HL(oip) * 4; + ouh = (struct udphdr *)(((u_char *)oip) + hlen); + TCHECK(ouh->uh_dport); + dport = EXTRACT_16BITS(&ouh->uh_dport); + switch (oip->ip_p) { + + case IPPROTO_TCP: + (void)snprintf(buf, sizeof(buf), + "%s tcp port %s unreachable", + ipaddr_string(&oip->ip_dst), + tcpport_string(dport)); + break; + + case IPPROTO_UDP: + (void)snprintf(buf, sizeof(buf), + "%s udp port %s unreachable", + ipaddr_string(&oip->ip_dst), + udpport_string(dport)); + break; + + default: + (void)snprintf(buf, sizeof(buf), + "%s protocol %d port %d unreachable", + ipaddr_string(&oip->ip_dst), + oip->ip_p, dport); + break; + } + break; + + case ICMP_UNREACH_NEEDFRAG: + { + register const struct mtu_discovery *mp; + mp = (struct mtu_discovery *)(u_char *)&dp->icmp_void; + mtu = EXTRACT_16BITS(&mp->nexthopmtu); + if (mtu) { + (void)snprintf(buf, sizeof(buf), + "%s unreachable - need to frag (mtu %d)", + ipaddr_string(&dp->icmp_ip.ip_dst), mtu); + } else { + (void)snprintf(buf, sizeof(buf), + "%s unreachable - need to frag", + ipaddr_string(&dp->icmp_ip.ip_dst)); + } + } + break; + + default: + fmt = tok2str(unreach2str, "#%d %%s unreachable", + dp->icmp_code); + (void)snprintf(buf, sizeof(buf), fmt, + ipaddr_string(&dp->icmp_ip.ip_dst)); + break; + } + break; + + case ICMP_REDIRECT: + TCHECK(dp->icmp_ip.ip_dst); + fmt = tok2str(type2str, "redirect-#%d %%s to net %%s", + dp->icmp_code); + (void)snprintf(buf, sizeof(buf), fmt, + ipaddr_string(&dp->icmp_ip.ip_dst), + ipaddr_string(&dp->icmp_gwaddr)); + break; + + case ICMP_ROUTERADVERT: + { + register const struct ih_rdiscovery *ihp; + register const struct id_rdiscovery *idp; + u_int lifetime, num, size; + + (void)snprintf(buf, sizeof(buf), "router advertisement"); + cp = buf + strlen(buf); + + ihp = (struct ih_rdiscovery *)&dp->icmp_void; + TCHECK(*ihp); + (void)strncpy(cp, " lifetime ", sizeof(buf) - (cp - buf)); + cp = buf + strlen(buf); + lifetime = EXTRACT_16BITS(&ihp->ird_lifetime); + if (lifetime < 60) { + (void)snprintf(cp, sizeof(buf) - (cp - buf), "%u", + lifetime); + } else if (lifetime < 60 * 60) { + (void)snprintf(cp, sizeof(buf) - (cp - buf), "%u:%02u", + lifetime / 60, lifetime % 60); + } else { + (void)snprintf(cp, sizeof(buf) - (cp - buf), + "%u:%02u:%02u", + lifetime / 3600, + (lifetime % 3600) / 60, + lifetime % 60); + } + cp = buf + strlen(buf); + + num = ihp->ird_addrnum; + (void)snprintf(cp, sizeof(buf) - (cp - buf), " %d:", num); + cp = buf + strlen(buf); + + size = ihp->ird_addrsiz; + if (size != 2) { + (void)snprintf(cp, sizeof(buf) - (cp - buf), + " [size %d]", size); + break; + } + idp = (struct id_rdiscovery *)&dp->icmp_data; + while (num-- > 0) { + TCHECK(*idp); + (void)snprintf(cp, sizeof(buf) - (cp - buf), " {%s %u}", + ipaddr_string(&idp->ird_addr), + EXTRACT_32BITS(&idp->ird_pref)); + cp = buf + strlen(buf); + ++idp; + } + } + break; + + case ICMP_TIMXCEED: + TCHECK(dp->icmp_ip.ip_dst); + switch (dp->icmp_code) { + + case ICMP_TIMXCEED_INTRANS: + str = "time exceeded in-transit"; + break; + + case ICMP_TIMXCEED_REASS: + str = "ip reassembly time exceeded"; + break; + + default: + (void)snprintf(buf, sizeof(buf), "time exceeded-#%d", + dp->icmp_code); + break; + } + break; + + case ICMP_PARAMPROB: + if (dp->icmp_code) + (void)snprintf(buf, sizeof(buf), + "parameter problem - code %d", dp->icmp_code); + else { + TCHECK(dp->icmp_pptr); + (void)snprintf(buf, sizeof(buf), + "parameter problem - octet %d", dp->icmp_pptr); + } + break; + + case ICMP_MASKREPLY: + TCHECK(dp->icmp_mask); + (void)snprintf(buf, sizeof(buf), "address mask is 0x%08x", + EXTRACT_32BITS(&dp->icmp_mask)); + break; + + case ICMP_TSTAMP: + TCHECK(dp->icmp_seq); + (void)snprintf(buf, sizeof(buf), + "time stamp query id %u seq %u", + EXTRACT_16BITS(&dp->icmp_id), + EXTRACT_16BITS(&dp->icmp_seq)); + break; + + case ICMP_TSTAMPREPLY: + TCHECK(dp->icmp_ttime); + (void)snprintf(buf, sizeof(buf), + "time stamp reply id %u seq %u: org %s", + EXTRACT_16BITS(&dp->icmp_id), + EXTRACT_16BITS(&dp->icmp_seq), + icmp_tstamp_print(EXTRACT_32BITS(&dp->icmp_otime))); + + (void)snprintf(buf+strlen(buf),sizeof(buf)-strlen(buf),", recv %s", + icmp_tstamp_print(EXTRACT_32BITS(&dp->icmp_rtime))); + (void)snprintf(buf+strlen(buf),sizeof(buf)-strlen(buf),", xmit %s", + icmp_tstamp_print(EXTRACT_32BITS(&dp->icmp_ttime))); + break; + + default: + str = tok2str(icmp2str, "type-#%d", dp->icmp_type); + break; + } + (void)printf("ICMP %s, length %u", str, plen); + if (vflag && !fragmented) { /* don't attempt checksumming if this is a frag */ + u_int16_t sum, icmp_sum; + struct cksum_vec vec[1]; + if (TTEST2(*bp, plen)) { + vec[0].ptr = (const u_int8_t *)(void *)dp; + vec[0].len = plen; + sum = in_cksum(vec, 1); + if (sum != 0) { + icmp_sum = EXTRACT_16BITS(&dp->icmp_cksum); + (void)printf(" (wrong icmp cksum %x (->%x)!)", + icmp_sum, + in_cksum_shouldbe(icmp_sum, sum)); + } + } + } + + /* + * print the remnants of the IP packet. + * save the snaplength as this may get overidden in the IP printer. + */ + if (vflag >= 1 && !ICMP_INFOTYPE(dp->icmp_type)) { + bp += 8; + (void)printf("\n\t"); + ip = (struct ip *)bp; + snaplen = snapend - bp; + snapend_save = snapend; + ip_print(gndo, bp, EXTRACT_16BITS(&ip->ip_len)); + snapend = snapend_save; + } + + /* + * Attempt to decode the MPLS extensions only for some ICMP types. + */ + if (vflag >= 1 && plen > ICMP_EXTD_MINLEN && ICMP_MPLS_EXT_TYPE(dp->icmp_type)) { + + TCHECK(*ext_dp); + + /* + * Check first if the mpls extension header shows a non-zero length. + * If the length field is not set then silently verify the checksum + * to check if an extension header is present. This is expedient, + * however not all implementations set the length field proper. + */ + if (!ext_dp->icmp_length) { + vec[0].ptr = (const u_int8_t *)(void *)&ext_dp->icmp_ext_version_res; + vec[0].len = plen - ICMP_EXTD_MINLEN; + if (in_cksum(vec, 1)) { + return; + } + } + + printf("\n\tMPLS extension v%u", + ICMP_MPLS_EXT_EXTRACT_VERSION(*(ext_dp->icmp_ext_version_res))); + + /* + * Sanity checking of the header. + */ + if (ICMP_MPLS_EXT_EXTRACT_VERSION(*(ext_dp->icmp_ext_version_res)) != + ICMP_MPLS_EXT_VERSION) { + printf(" packet not supported"); + return; + } + + hlen = plen - ICMP_EXTD_MINLEN; + vec[0].ptr = (const u_int8_t *)(void *)&ext_dp->icmp_ext_version_res; + vec[0].len = hlen; + printf(", checksum 0x%04x (%scorrect), length %u", + EXTRACT_16BITS(ext_dp->icmp_ext_checksum), + in_cksum(vec, 1) ? "in" : "", + hlen); + + hlen -= 4; /* subtract common header size */ + obj_tptr = (u_int8_t *)ext_dp->icmp_ext_data; + + while (hlen > sizeof(struct icmp_mpls_ext_object_header_t)) { + + icmp_mpls_ext_object_header = (struct icmp_mpls_ext_object_header_t *)obj_tptr; + TCHECK(*icmp_mpls_ext_object_header); + obj_tlen = EXTRACT_16BITS(icmp_mpls_ext_object_header->length); + obj_class_num = icmp_mpls_ext_object_header->class_num; + obj_ctype = icmp_mpls_ext_object_header->ctype; + obj_tptr += sizeof(struct icmp_mpls_ext_object_header_t); + + printf("\n\t %s Object (%u), Class-Type: %u, length %u", + tok2str(icmp_mpls_ext_obj_values,"unknown",obj_class_num), + obj_class_num, + obj_ctype, + obj_tlen); + + hlen-=sizeof(struct icmp_mpls_ext_object_header_t); /* length field includes tlv header */ + + /* infinite loop protection */ + if ((obj_class_num == 0) || + (obj_tlen < sizeof(struct icmp_mpls_ext_object_header_t))) { + return; + } + obj_tlen-=sizeof(struct icmp_mpls_ext_object_header_t); + + switch (obj_class_num) { + case 1: + switch(obj_ctype) { + case 1: + TCHECK2(*obj_tptr, 4); + raw_label = EXTRACT_32BITS(obj_tptr); + printf("\n\t label %u, exp %u", MPLS_LABEL(raw_label), MPLS_EXP(raw_label)); + if (MPLS_STACK(raw_label)) + printf(", [S]"); + printf(", ttl %u", MPLS_TTL(raw_label)); + break; + default: + print_unknown_data(obj_tptr, "\n\t ", obj_tlen); + } + break; + + /* + * FIXME those are the defined objects that lack a decoder + * you are welcome to contribute code ;-) + */ + case 2: + default: + print_unknown_data(obj_tptr, "\n\t ", obj_tlen); + break; + } + if (hlen < obj_tlen) + break; + hlen -= obj_tlen; + obj_tptr += obj_tlen; + } + } + + return; +trunc: + fputs("[|icmp]", stdout); +}
diff --git a/tcpdump-4.3.0/print-icmp6.c b/tcpdump-4.3.0/print-icmp6.c new file mode 100644 index 0000000..176c15c --- /dev/null +++ b/tcpdump-4.3.0/print-icmp6.c
@@ -0,0 +1,1372 @@ +/* + * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994 + * 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-icmp6.c,v 1.86 2008-02-05 19:36:13 guy Exp $"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifdef INET6 + +#include <tcpdump-stdinc.h> + +#include <stdio.h> +#include <string.h> + +#include "interface.h" +#include "addrtoname.h" +#include "extract.h" + +#include "ip6.h" +#include "icmp6.h" +#include "ipproto.h" + +#include "udp.h" +#include "ah.h" + +static const char *get_rtpref(u_int); +static const char *get_lifetime(u_int32_t); +static void print_lladdr(const u_char *, size_t); +static void icmp6_opt_print(const u_char *, int); +static void mld6_print(const u_char *); +static void mldv2_report_print(const u_char *, u_int); +static void mldv2_query_print(const u_char *, u_int); +static struct udphdr *get_upperlayer(u_char *, u_int *); +static void dnsname_print(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)) +#endif + +/* inline the various RPL definitions */ +#define ND_RPL_MESSAGE 0x9B + +static struct tok icmp6_type_values[] = { + { ICMP6_DST_UNREACH, "destination unreachable"}, + { ICMP6_PACKET_TOO_BIG, "packet too big"}, + { ICMP6_TIME_EXCEEDED, "time exceeded in-transit"}, + { ICMP6_PARAM_PROB, "parameter problem"}, + { ICMP6_ECHO_REQUEST, "echo request"}, + { ICMP6_ECHO_REPLY, "echo reply"}, + { MLD6_LISTENER_QUERY, "multicast listener query"}, + { MLD6_LISTENER_REPORT, "multicast listener report"}, + { MLD6_LISTENER_DONE, "multicast listener done"}, + { ND_ROUTER_SOLICIT, "router solicitation"}, + { ND_ROUTER_ADVERT, "router advertisement"}, + { ND_NEIGHBOR_SOLICIT, "neighbor solicitation"}, + { ND_NEIGHBOR_ADVERT, "neighbor advertisement"}, + { ND_REDIRECT, "redirect"}, + { ICMP6_ROUTER_RENUMBERING, "router renumbering"}, + { IND_SOLICIT, "inverse neighbor solicitation"}, + { IND_ADVERT, "inverse neighbor advertisement"}, + { MLDV2_LISTENER_REPORT, "multicast listener report v2"}, + { ICMP6_HADISCOV_REQUEST, "ha discovery request"}, + { ICMP6_HADISCOV_REPLY, "ha discovery reply"}, + { ICMP6_MOBILEPREFIX_SOLICIT, "mobile router solicitation"}, + { ICMP6_MOBILEPREFIX_ADVERT, "mobile router advertisement"}, + { ICMP6_WRUREQUEST, "who-are-you request"}, + { ICMP6_WRUREPLY, "who-are-you reply"}, + { ICMP6_NI_QUERY, "node information query"}, + { ICMP6_NI_REPLY, "node information reply"}, + { MLD6_MTRACE, "mtrace message"}, + { MLD6_MTRACE_RESP, "mtrace response"}, + { ND_RPL_MESSAGE, "RPL"}, + { 0, NULL } +}; + +static struct tok icmp6_dst_unreach_code_values[] = { + { ICMP6_DST_UNREACH_NOROUTE, "unreachable route" }, + { ICMP6_DST_UNREACH_ADMIN, " unreachable prohibited"}, + { ICMP6_DST_UNREACH_BEYONDSCOPE, "beyond scope"}, + { ICMP6_DST_UNREACH_ADDR, "unreachable address"}, + { ICMP6_DST_UNREACH_NOPORT, "unreachable port"}, + { 0, NULL } +}; + +static struct tok icmp6_opt_pi_flag_values[] = { + { ND_OPT_PI_FLAG_ONLINK, "onlink" }, + { ND_OPT_PI_FLAG_AUTO, "auto" }, + { ND_OPT_PI_FLAG_ROUTER, "router" }, + { 0, NULL } +}; + +static struct tok icmp6_opt_ra_flag_values[] = { + { ND_RA_FLAG_MANAGED, "managed" }, + { ND_RA_FLAG_OTHER, "other stateful"}, + { ND_RA_FLAG_HOME_AGENT, "home agent"}, + { 0, NULL } +}; + +static struct tok icmp6_nd_na_flag_values[] = { + { ND_NA_FLAG_ROUTER, "router" }, + { ND_NA_FLAG_SOLICITED, "solicited" }, + { ND_NA_FLAG_OVERRIDE, "override" }, + { 0, NULL } +}; + + +static struct tok icmp6_opt_values[] = { + { ND_OPT_SOURCE_LINKADDR, "source link-address"}, + { ND_OPT_TARGET_LINKADDR, "destination link-address"}, + { ND_OPT_PREFIX_INFORMATION, "prefix info"}, + { ND_OPT_REDIRECTED_HEADER, "redirected header"}, + { ND_OPT_MTU, "mtu"}, + { ND_OPT_RDNSS, "rdnss"}, + { ND_OPT_ADVINTERVAL, "advertisement interval"}, + { ND_OPT_HOMEAGENT_INFO, "homeagent information"}, + { ND_OPT_ROUTE_INFO, "route info"}, + { 0, NULL } +}; + +/* mldv2 report types */ +static struct tok mldv2report2str[] = { + { 1, "is_in" }, + { 2, "is_ex" }, + { 3, "to_in" }, + { 4, "to_ex" }, + { 5, "allow" }, + { 6, "block" }, + { 0, NULL } +}; + +static const char * +get_rtpref(u_int v) +{ + static const char *rtpref_str[] = { + "medium", /* 00 */ + "high", /* 01 */ + "rsv", /* 10 */ + "low" /* 11 */ + }; + + return rtpref_str[((v & ND_RA_FLAG_RTPREF_MASK) >> 3) & 0xff]; +} + +static const char * +get_lifetime(u_int32_t v) +{ + static char buf[20]; + + if (v == (u_int32_t)~0UL) + return "infinity"; + else { + snprintf(buf, sizeof(buf), "%u", v); + return buf; + } +} + +static void +print_lladdr(const u_int8_t *p, size_t l) +{ + const u_int8_t *ep, *q; + + q = p; + ep = p + l; + while (l > 0 && q < ep) { + if (q > p) + printf(":"); + printf("%02x", *q++); + l--; + } +} + +static int icmp6_cksum(const struct ip6_hdr *ip6, const struct icmp6_hdr *icp, + u_int len) +{ + return (nextproto6_cksum(ip6, (const u_int8_t *)(void *)icp, len, + IPPROTO_ICMPV6)); +} + +enum ND_RPL_CODE { + ND_RPL_DIS =0x00, + ND_RPL_DIO =0x01, + ND_RPL_DAO =0x02, + ND_RPL_DAO_ACK=0x03, + ND_RPL_SDIS =0x80, + ND_RPL_SDIO =0x81, + ND_RPL_SDAO =0x82, + ND_RPL_SDAO_ACK=0x83, + ND_RPL_SCC =0x8A, +}; + +enum ND_RPL_DIO_FLAGS { + ND_RPL_DIO_GROUNDED = 0x80, + ND_RPL_DIO_DATRIG = 0x40, + ND_RPL_DIO_DASUPPORT= 0x20, + ND_RPL_DIO_RES4 = 0x10, + ND_RPL_DIO_RES3 = 0x08, + ND_RPL_DIO_PRF_MASK = 0x07, /* 3-bit preference */ +}; + +struct nd_rpl_dio { + u_int8_t rpl_flags; + u_int8_t rpl_seq; + u_int8_t rpl_instanceid; + u_int8_t rpl_dagrank; + u_int8_t rpl_dagid[16]; +}; + +static void +rpl_print(netdissect_options *ndo, + const struct icmp6_hdr *hdr, + const u_char *bp, u_int length _U_) +{ + struct nd_rpl_dio *dio = (struct nd_rpl_dio *)bp; + int secured = hdr->icmp6_code & 0x80; + int basecode= hdr->icmp6_code & 0x7f; + + ND_TCHECK(dio->rpl_dagid); + + if(secured) { + ND_PRINT((ndo, ", (SEC)")); + } else { + ND_PRINT((ndo, ", (CLR)")); + } + + switch(basecode) { + case ND_RPL_DIS: + ND_PRINT((ndo, "DODAG Information Solicitation")); + if(ndo->ndo_vflag) { + } + break; + case ND_RPL_DIO: + ND_PRINT((ndo, "DODAG Information Object")); + if(ndo->ndo_vflag) { + char dagid[65]; + char *d = dagid; + int i; + for(i=0;i<16;i++) { + if(isprint(dio->rpl_dagid[i])) { + *d++ = dio->rpl_dagid[i]; + } else { + int cnt=snprintf(d,4,"0x%02x", + dio->rpl_dagid[i]); + d += cnt; + } + } + *d++ = '\0'; + ND_PRINT((ndo, " [seq:%u,instance:%u,rank:%u,dagid:%s]", + dio->rpl_seq, + dio->rpl_instanceid, + dio->rpl_dagrank, + dagid)); + } + break; + case ND_RPL_DAO: + ND_PRINT((ndo, "Destination Advertisement Object")); + if(ndo->ndo_vflag) { + } + break; + case ND_RPL_DAO_ACK: + ND_PRINT((ndo, "Destination Advertisement Object Ack")); + if(ndo->ndo_vflag) { + } + break; + default: + ND_PRINT((ndo, "RPL message, unknown code %u",hdr->icmp6_code)); + break; + } + return; +trunc: + ND_PRINT((ndo," [|truncated]")); + return; + +} + + +void +icmp6_print(netdissect_options *ndo, + const u_char *bp, u_int length, const u_char *bp2, int fragmented) +{ + const struct icmp6_hdr *dp; + const struct ip6_hdr *ip; + const struct ip6_hdr *oip; + const struct udphdr *ouh; + int dport; + const u_char *ep; + u_int prot; + + dp = (struct icmp6_hdr *)bp; + ip = (struct ip6_hdr *)bp2; + oip = (struct ip6_hdr *)(dp + 1); + /* 'ep' points to the end of available data. */ + ep = snapend; + + TCHECK(dp->icmp6_cksum); + + if (vflag && !fragmented) { + u_int16_t sum, udp_sum; + + if (TTEST2(bp[0], length)) { + udp_sum = EXTRACT_16BITS(&dp->icmp6_cksum); + sum = icmp6_cksum(ip, dp, length); + if (sum != 0) + (void)printf("[bad icmp6 cksum 0x%04x -> 0x%04x!] ", + udp_sum, + in_cksum_shouldbe(udp_sum, sum)); + else + (void)printf("[icmp6 sum ok] "); + } + } + + printf("ICMP6, %s", tok2str(icmp6_type_values,"unknown icmp6 type (%u)",dp->icmp6_type)); + + /* display cosmetics: print the packet length for printer that use the vflag now */ + if (vflag && (dp->icmp6_type == ND_ROUTER_SOLICIT || + dp->icmp6_type == ND_ROUTER_ADVERT || + dp->icmp6_type == ND_NEIGHBOR_ADVERT || + dp->icmp6_type == ND_NEIGHBOR_SOLICIT || + dp->icmp6_type == ND_REDIRECT || + dp->icmp6_type == ICMP6_HADISCOV_REPLY || + dp->icmp6_type == ICMP6_MOBILEPREFIX_ADVERT )) + printf(", length %u", length); + + switch (dp->icmp6_type) { + case ICMP6_DST_UNREACH: + TCHECK(oip->ip6_dst); + printf(", %s", tok2str(icmp6_dst_unreach_code_values,"unknown unreach code (%u)",dp->icmp6_code)); + switch (dp->icmp6_code) { + + case ICMP6_DST_UNREACH_NOROUTE: /* fall through */ + case ICMP6_DST_UNREACH_ADMIN: + case ICMP6_DST_UNREACH_ADDR: + printf(" %s",ip6addr_string(&oip->ip6_dst)); + break; + case ICMP6_DST_UNREACH_BEYONDSCOPE: + printf(" %s, source address %s", + ip6addr_string(&oip->ip6_dst), + ip6addr_string(&oip->ip6_src)); + break; + case ICMP6_DST_UNREACH_NOPORT: + if ((ouh = get_upperlayer((u_char *)oip, &prot)) + == NULL) + goto trunc; + + dport = EXTRACT_16BITS(&ouh->uh_dport); + switch (prot) { + case IPPROTO_TCP: + printf(", %s tcp port %s", + ip6addr_string(&oip->ip6_dst), + tcpport_string(dport)); + break; + case IPPROTO_UDP: + printf(", %s udp port %s", + ip6addr_string(&oip->ip6_dst), + udpport_string(dport)); + break; + default: + printf(", %s protocol %d port %d unreachable", + ip6addr_string(&oip->ip6_dst), + oip->ip6_nxt, dport); + break; + } + break; + default: + if (vflag <= 1) { + print_unknown_data(bp,"\n\t",length); + return; + } + break; + } + break; + case ICMP6_PACKET_TOO_BIG: + TCHECK(dp->icmp6_mtu); + printf(", mtu %u", EXTRACT_32BITS(&dp->icmp6_mtu)); + break; + case ICMP6_TIME_EXCEEDED: + TCHECK(oip->ip6_dst); + switch (dp->icmp6_code) { + case ICMP6_TIME_EXCEED_TRANSIT: + printf(" for %s", + ip6addr_string(&oip->ip6_dst)); + break; + case ICMP6_TIME_EXCEED_REASSEMBLY: + printf(" (reassembly)"); + break; + default: + printf(", unknown code (%u)", dp->icmp6_code); + break; + } + break; + case ICMP6_PARAM_PROB: + TCHECK(oip->ip6_dst); + switch (dp->icmp6_code) { + case ICMP6_PARAMPROB_HEADER: + printf(", errorneous - octet %u", EXTRACT_32BITS(&dp->icmp6_pptr)); + break; + case ICMP6_PARAMPROB_NEXTHEADER: + printf(", next header - octet %u", EXTRACT_32BITS(&dp->icmp6_pptr)); + break; + case ICMP6_PARAMPROB_OPTION: + printf(", option - octet %u", EXTRACT_32BITS(&dp->icmp6_pptr)); + break; + default: + printf(", code-#%d", + dp->icmp6_code); + break; + } + break; + case ICMP6_ECHO_REQUEST: + case ICMP6_ECHO_REPLY: + TCHECK(dp->icmp6_seq); + printf(", seq %u", EXTRACT_16BITS(&dp->icmp6_seq)); + break; + case ICMP6_MEMBERSHIP_QUERY: + if (length == MLD_MINLEN) { + mld6_print((const u_char *)dp); + } else if (length >= MLDV2_MINLEN) { + printf("v2 "); + mldv2_query_print((const u_char *)dp, length); + } else { + printf(" unknown-version (len %u) ", length); + } + break; + case ICMP6_MEMBERSHIP_REPORT: + mld6_print((const u_char *)dp); + break; + case ICMP6_MEMBERSHIP_REDUCTION: + mld6_print((const u_char *)dp); + break; + case ND_ROUTER_SOLICIT: +#define RTSOLLEN 8 + if (vflag) { + icmp6_opt_print((const u_char *)dp + RTSOLLEN, + length - RTSOLLEN); + } + break; + case ND_ROUTER_ADVERT: +#define RTADVLEN 16 + if (vflag) { + struct nd_router_advert *p; + + p = (struct nd_router_advert *)dp; + TCHECK(p->nd_ra_retransmit); + printf("\n\thop limit %u, Flags [%s]" \ + ", pref %s, router lifetime %us, reachable time %us, retrans time %us", + (u_int)p->nd_ra_curhoplimit, + bittok2str(icmp6_opt_ra_flag_values,"none",(p->nd_ra_flags_reserved)), + get_rtpref(p->nd_ra_flags_reserved), + EXTRACT_16BITS(&p->nd_ra_router_lifetime), + EXTRACT_32BITS(&p->nd_ra_reachable), + EXTRACT_32BITS(&p->nd_ra_retransmit)); + + icmp6_opt_print((const u_char *)dp + RTADVLEN, + length - RTADVLEN); + } + break; + case ND_NEIGHBOR_SOLICIT: + { + struct nd_neighbor_solicit *p; + p = (struct nd_neighbor_solicit *)dp; + TCHECK(p->nd_ns_target); + printf(", who has %s", ip6addr_string(&p->nd_ns_target)); + if (vflag) { +#define NDSOLLEN 24 + icmp6_opt_print((const u_char *)dp + NDSOLLEN, + length - NDSOLLEN); + } + } + break; + case ND_NEIGHBOR_ADVERT: + { + struct nd_neighbor_advert *p; + + p = (struct nd_neighbor_advert *)dp; + TCHECK(p->nd_na_target); + printf(", tgt is %s", + ip6addr_string(&p->nd_na_target)); + if (vflag) { + printf(", Flags [%s]", + bittok2str(icmp6_nd_na_flag_values, + "none", + EXTRACT_32BITS(&p->nd_na_flags_reserved))); +#define NDADVLEN 24 + icmp6_opt_print((const u_char *)dp + NDADVLEN, + length - NDADVLEN); +#undef NDADVLEN + } + } + break; + case ND_REDIRECT: +#define RDR(i) ((struct nd_redirect *)(i)) + TCHECK(RDR(dp)->nd_rd_dst); + printf(", %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, + length - REDIRECTLEN); + } + break; +#undef REDIRECTLEN +#undef RDR + case ICMP6_ROUTER_RENUMBERING: + icmp6_rrenum_print(bp, ep); + break; + case ICMP6_NI_QUERY: + case ICMP6_NI_REPLY: + icmp6_nodeinfo_print(length, bp, ep); + break; + case IND_SOLICIT: + case IND_ADVERT: + break; + case ICMP6_V2_MEMBERSHIP_REPORT: + mldv2_report_print((const u_char *) dp, length); + break; + case ICMP6_MOBILEPREFIX_SOLICIT: /* fall through */ + case ICMP6_HADISCOV_REQUEST: + TCHECK(dp->icmp6_data16[0]); + printf(", id 0x%04x", EXTRACT_16BITS(&dp->icmp6_data16[0])); + break; + case ICMP6_HADISCOV_REPLY: + if (vflag) { + struct in6_addr *in6; + u_char *cp; + + TCHECK(dp->icmp6_data16[0]); + printf(", id 0x%04x", 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)); + } + } + break; + case ICMP6_MOBILEPREFIX_ADVERT: + if (vflag) { + TCHECK(dp->icmp6_data16[0]); + printf(", id 0x%04x", 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"); +#define MPADVLEN 8 + icmp6_opt_print((const u_char *)dp + MPADVLEN, + length - MPADVLEN); + } + break; + case ND_RPL_MESSAGE: + rpl_print(ndo, dp, &dp->icmp6_data8[0], length); + break; + default: + printf(", length %u", length); + if (vflag <= 1) + print_unknown_data(bp,"\n\t", length); + return; + } + if (!vflag) + printf(", length %u", length); + return; +trunc: + fputs("[|icmp6]", stdout); +} + +static struct udphdr * +get_upperlayer(u_char *bp, u_int *prot) +{ + const u_char *ep; + struct ip6_hdr *ip6 = (struct ip6_hdr *)bp; + struct udphdr *uh; + struct ip6_hbh *hbh; + struct ip6_frag *fragh; + struct ah *ah; + u_int nh; + int hlen; + + /* 'ep' points to the end of available data. */ + ep = snapend; + + if (!TTEST(ip6->ip6_nxt)) + return NULL; + + nh = ip6->ip6_nxt; + hlen = sizeof(struct ip6_hdr); + + while (bp < ep) { + bp += hlen; + + switch(nh) { + case IPPROTO_UDP: + case IPPROTO_TCP: + uh = (struct udphdr *)bp; + if (TTEST(uh->uh_dport)) { + *prot = nh; + return(uh); + } + else + return(NULL); + /* NOTREACHED */ + + case IPPROTO_HOPOPTS: + case IPPROTO_DSTOPTS: + case IPPROTO_ROUTING: + hbh = (struct ip6_hbh *)bp; + if (!TTEST(hbh->ip6h_len)) + return(NULL); + nh = hbh->ip6h_nxt; + hlen = (hbh->ip6h_len + 1) << 3; + break; + + case IPPROTO_FRAGMENT: /* this should be odd, but try anyway */ + fragh = (struct ip6_frag *)bp; + if (!TTEST(fragh->ip6f_offlg)) + return(NULL); + /* fragments with non-zero offset are meaningless */ + if ((EXTRACT_16BITS(&fragh->ip6f_offlg) & IP6F_OFF_MASK) != 0) + return(NULL); + nh = fragh->ip6f_nxt; + hlen = sizeof(struct ip6_frag); + break; + + case IPPROTO_AH: + ah = (struct ah *)bp; + if (!TTEST(ah->ah_len)) + return(NULL); + nh = ah->ah_nxt; + hlen = (ah->ah_len + 2) << 2; + break; + + default: /* unknown or undecodable header */ + *prot = nh; /* meaningless, but set here anyway */ + return(NULL); + } + } + + return(NULL); /* should be notreached, though */ +} + +static void +icmp6_opt_print(const u_char *bp, int resid) +{ + const struct nd_opt_hdr *op; + const struct nd_opt_hdr *opl; /* why there's no struct? */ + const struct nd_opt_prefix_info *opp; + const struct icmp6_opts_redirect *opr; + const struct nd_opt_mtu *opm; + const struct nd_opt_rdnss *oprd; + const struct nd_opt_advinterval *opa; + const struct nd_opt_homeagent_info *oph; + const struct nd_opt_route_info *opri; + const u_char *cp, *ep; + struct in6_addr in6, *in6p; + size_t l; + u_int i; + +#define ECHECK(var) if ((u_char *)&(var) > ep - sizeof(var)) return + + cp = bp; + /* 'ep' points to the end of available data. */ + ep = snapend; + + while (cp < ep) { + op = (struct nd_opt_hdr *)cp; + + ECHECK(op->nd_opt_len); + if (resid <= 0) + return; + if (op->nd_opt_len == 0) + goto trunc; + if (cp + (op->nd_opt_len << 3) > ep) + goto trunc; + + printf("\n\t %s option (%u), length %u (%u): ", + tok2str(icmp6_opt_values, "unknown", op->nd_opt_type), + op->nd_opt_type, + op->nd_opt_len << 3, + op->nd_opt_len); + + switch (op->nd_opt_type) { + case ND_OPT_SOURCE_LINKADDR: + opl = (struct nd_opt_hdr *)op; + l = (op->nd_opt_len << 3) - 2; + print_lladdr(cp + 2, l); + break; + case ND_OPT_TARGET_LINKADDR: + opl = (struct nd_opt_hdr *)op; + l = (op->nd_opt_len << 3) - 2; + print_lladdr(cp + 2, l); + break; + case ND_OPT_PREFIX_INFORMATION: + opp = (struct nd_opt_prefix_info *)op; + TCHECK(opp->nd_opt_pi_prefix); + printf("%s/%u%s, Flags [%s], valid time %ss", + ip6addr_string(&opp->nd_opt_pi_prefix), + opp->nd_opt_pi_prefix_len, + (op->nd_opt_len != 4) ? "badlen" : "", + bittok2str(icmp6_opt_pi_flag_values, "none", opp->nd_opt_pi_flags_reserved), + get_lifetime(EXTRACT_32BITS(&opp->nd_opt_pi_valid_time))); + printf(", pref. time %ss", get_lifetime(EXTRACT_32BITS(&opp->nd_opt_pi_preferred_time))); + break; + case ND_OPT_REDIRECTED_HEADER: + opr = (struct icmp6_opts_redirect *)op; + print_unknown_data(bp,"\n\t ",op->nd_opt_len<<3); + /* xxx */ + break; + case ND_OPT_MTU: + opm = (struct nd_opt_mtu *)op; + TCHECK(opm->nd_opt_mtu_mtu); + printf(" %u%s", + EXTRACT_32BITS(&opm->nd_opt_mtu_mtu), + (op->nd_opt_len != 1) ? "bad option length" : "" ); + break; + case ND_OPT_RDNSS: + oprd = (struct nd_opt_rdnss *)op; + l = (op->nd_opt_len - 1) / 2; + printf(" lifetime %us,", + EXTRACT_32BITS(&oprd->nd_opt_rdnss_lifetime)); + for (i = 0; i < l; i++) { + TCHECK(oprd->nd_opt_rdnss_addr[i]); + printf(" addr: %s", + ip6addr_string(&oprd->nd_opt_rdnss_addr[i])); + } + break; + case ND_OPT_ADVINTERVAL: + opa = (struct nd_opt_advinterval *)op; + TCHECK(opa->nd_opt_adv_interval); + printf(" %ums", EXTRACT_32BITS(&opa->nd_opt_adv_interval)); + break; + case ND_OPT_HOMEAGENT_INFO: + oph = (struct nd_opt_homeagent_info *)op; + TCHECK(oph->nd_opt_hai_lifetime); + printf(" preference %u, lifetime %u", + EXTRACT_16BITS(&oph->nd_opt_hai_preference), + EXTRACT_16BITS(&oph->nd_opt_hai_lifetime)); + break; + case ND_OPT_ROUTE_INFO: + opri = (struct nd_opt_route_info *)op; + TCHECK(opri->nd_opt_rti_lifetime); + memset(&in6, 0, sizeof(in6)); + in6p = (struct in6_addr *)(opri + 1); + switch (op->nd_opt_len) { + case 1: + break; + case 2: + TCHECK2(*in6p, 8); + memcpy(&in6, opri + 1, 8); + break; + case 3: + TCHECK(*in6p); + memcpy(&in6, opri + 1, sizeof(in6)); + break; + default: + goto trunc; + } + printf(" %s/%u", ip6addr_string(&in6), + opri->nd_opt_rti_prefixlen); + printf(", pref=%s", get_rtpref(opri->nd_opt_rti_flags)); + printf(", lifetime=%s", + get_lifetime(EXTRACT_32BITS(&opri->nd_opt_rti_lifetime))); + break; + default: + if (vflag <= 1) { + print_unknown_data(cp+2,"\n\t ", (op->nd_opt_len << 3) - 2); /* skip option header */ + return; + } + break; + } + /* do we want to see an additional hexdump ? */ + if (vflag> 1) + print_unknown_data(cp+2,"\n\t ", (op->nd_opt_len << 3) - 2); /* skip option header */ + + cp += op->nd_opt_len << 3; + resid -= op->nd_opt_len << 3; + } + return; + + trunc: + fputs("[ndp opt]", stdout); + return; +#undef ECHECK +} + +static void +mld6_print(const u_char *bp) +{ + struct mld6_hdr *mp = (struct mld6_hdr *)bp; + const u_char *ep; + + /* 'ep' points to the end of available data. */ + ep = snapend; + + if ((u_char *)mp + sizeof(*mp) > ep) + return; + + printf("max resp delay: %d ", EXTRACT_16BITS(&mp->mld6_maxdelay)); + printf("addr: %s", ip6addr_string(&mp->mld6_addr)); +} + +static void +mldv2_report_print(const u_char *bp, u_int len) +{ + struct icmp6_hdr *icp = (struct icmp6_hdr *) bp; + u_int group, nsrcs, ngroups; + u_int i, j; + + /* Minimum len is 8 */ + if (len < 8) { + printf(" [invalid len %d]", len); + return; + } + + TCHECK(icp->icmp6_data16[1]); + ngroups = EXTRACT_16BITS(&icp->icmp6_data16[1]); + printf(", %d group record(s)", ngroups); + if (vflag > 0) { + /* Print the group records */ + group = 8; + for (i = 0; i < ngroups; i++) { + /* type(1) + auxlen(1) + numsrc(2) + grp(16) */ + if (len < group + 20) { + printf(" [invalid number of groups]"); + return; + } + TCHECK2(bp[group + 4], sizeof(struct in6_addr)); + printf(" [gaddr %s", ip6addr_string(&bp[group + 4])); + printf(" %s", tok2str(mldv2report2str, " [v2-report-#%d]", + bp[group])); + nsrcs = (bp[group + 2] << 8) + bp[group + 3]; + /* Check the number of sources and print them */ + if (len < group + 20 + (nsrcs * sizeof(struct in6_addr))) { + printf(" [invalid number of sources %d]", nsrcs); + return; + } + if (vflag == 1) + printf(", %d source(s)", nsrcs); + else { + /* Print the sources */ + (void)printf(" {"); + for (j = 0; j < nsrcs; j++) { + TCHECK2(bp[group + 20 + j * sizeof(struct in6_addr)], + sizeof(struct in6_addr)); + printf(" %s", ip6addr_string(&bp[group + 20 + j * sizeof(struct in6_addr)])); + } + (void)printf(" }"); + } + /* Next group record */ + group += 20 + nsrcs * sizeof(struct in6_addr); + printf("]"); + } + } + return; +trunc: + (void)printf("[|icmp6]"); + return; +} + +static void +mldv2_query_print(const u_char *bp, u_int len) +{ + struct icmp6_hdr *icp = (struct icmp6_hdr *) bp; + u_int mrc; + int mrt, qqi; + u_int nsrcs; + register u_int i; + + /* Minimum len is 28 */ + if (len < 28) { + printf(" [invalid len %d]", len); + return; + } + TCHECK(icp->icmp6_data16[0]); + mrc = EXTRACT_16BITS(&icp->icmp6_data16[0]); + if (mrc < 32768) { + mrt = mrc; + } else { + mrt = ((mrc & 0x0fff) | 0x1000) << (((mrc & 0x7000) >> 12) + 3); + } + if (vflag) { + (void)printf(" [max resp delay=%d]", mrt); + } + TCHECK2(bp[8], sizeof(struct in6_addr)); + printf(" [gaddr %s", ip6addr_string(&bp[8])); + + if (vflag) { + TCHECK(bp[25]); + if (bp[24] & 0x08) { + printf(" sflag"); + } + if (bp[24] & 0x07) { + printf(" robustness=%d", bp[24] & 0x07); + } + if (bp[25] < 128) { + qqi = bp[25]; + } else { + qqi = ((bp[25] & 0x0f) | 0x10) << (((bp[25] & 0x70) >> 4) + 3); + } + printf(" qqi=%d", qqi); + } + + TCHECK2(bp[26], 2); + nsrcs = EXTRACT_16BITS(&bp[26]); + if (nsrcs > 0) { + if (len < 28 + nsrcs * sizeof(struct in6_addr)) + printf(" [invalid number of sources]"); + else if (vflag > 1) { + printf(" {"); + for (i = 0; i < nsrcs; i++) { + TCHECK2(bp[28 + i * sizeof(struct in6_addr)], + sizeof(struct in6_addr)); + printf(" %s", ip6addr_string(&bp[28 + i * sizeof(struct in6_addr)])); + } + printf(" }"); + } else + printf(", %d source(s)", nsrcs); + } + printf("]"); + return; +trunc: + (void)printf("[|icmp6]"); + return; +} + +static void +dnsname_print(const u_char *cp, const u_char *ep) +{ + int i; + + /* DNS name decoding - no decompression */ + printf(", \""); + while (cp < ep) { + i = *cp++; + if (i) { + if (i > ep - cp) { + printf("???"); + break; + } + while (i-- && cp < ep) { + safeputchar(*cp); + cp++; + } + if (cp + 1 < ep && *cp) + printf("."); + } else { + if (cp == ep) { + /* FQDN */ + printf("."); + } else if (cp + 1 == ep && *cp == '\0') { + /* truncated */ + } else { + /* invalid */ + printf("???"); + } + break; + } + } + printf("\""); +} + +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; + size_t siz, i; + int needcomma; + + if (ep < bp) + return; + dp = (struct icmp6_hdr *)bp; + ni6 = (struct icmp6_nodeinfo *)bp; + siz = ep - bp; + + switch (ni6->ni_type) { + case ICMP6_NI_QUERY: + if (siz == sizeof(*dp) + 4) { + /* KAME who-are-you */ + printf(" who-are-you request"); + break; + } + printf(" node information query"); + + TCHECK2(*dp, sizeof(*ni6)); + ni6 = (struct icmp6_nodeinfo *)dp; + printf(" ("); /*)*/ + switch (EXTRACT_16BITS(&ni6->ni_qtype)) { + case NI_QTYPE_NOOP: + printf("noop"); + break; + case NI_QTYPE_SUPTYPES: + printf("supported qtypes"); + i = EXTRACT_16BITS(&ni6->ni_flags); + if (i) + printf(" [%s]", (i & 0x01) ? "C" : ""); + break; + break; + case NI_QTYPE_FQDN: + printf("DNS name"); + break; + case NI_QTYPE_NODEADDR: + printf("node addresses"); + i = ni6->ni_flags; + if (!i) + break; + /* NI_NODEADDR_FLAG_TRUNCATE undefined for query */ + printf(" [%s%s%s%s%s%s]", + (i & NI_NODEADDR_FLAG_ANYCAST) ? "a" : "", + (i & NI_NODEADDR_FLAG_GLOBAL) ? "G" : "", + (i & NI_NODEADDR_FLAG_SITELOCAL) ? "S" : "", + (i & NI_NODEADDR_FLAG_LINKLOCAL) ? "L" : "", + (i & NI_NODEADDR_FLAG_COMPAT) ? "C" : "", + (i & NI_NODEADDR_FLAG_ALL) ? "A" : ""); + break; + default: + printf("unknown"); + break; + } + + if (ni6->ni_qtype == NI_QTYPE_NOOP || + ni6->ni_qtype == NI_QTYPE_SUPTYPES) { + if (siz != sizeof(*ni6)) + if (vflag) + printf(", invalid len"); + /*(*/ + printf(")"); + break; + } + + + /* XXX backward compat, icmp-name-lookup-03 */ + if (siz == sizeof(*ni6)) { + printf(", 03 draft"); + /*(*/ + printf(")"); + break; + } + + switch (ni6->ni_code) { + case ICMP6_NI_SUBJ_IPV6: + if (!TTEST2(*dp, + sizeof(*ni6) + sizeof(struct in6_addr))) + break; + if (siz != sizeof(*ni6) + sizeof(struct in6_addr)) { + if (vflag) + printf(", invalid subject len"); + break; + } + printf(", subject=%s", + getname6((const u_char *)(ni6 + 1))); + break; + case ICMP6_NI_SUBJ_FQDN: + printf(", subject=DNS name"); + cp = (const u_char *)(ni6 + 1); + if (cp[0] == ep - cp - 1) { + /* icmp-name-lookup-03, pascal string */ + if (vflag) + printf(", 03 draft"); + cp++; + printf(", \""); + while (cp < ep) { + safeputchar(*cp); + cp++; + } + printf("\""); + } else + dnsname_print(cp, ep); + break; + case ICMP6_NI_SUBJ_IPV4: + if (!TTEST2(*dp, sizeof(*ni6) + sizeof(struct in_addr))) + break; + if (siz != sizeof(*ni6) + sizeof(struct in_addr)) { + if (vflag) + printf(", invalid subject len"); + break; + } + printf(", subject=%s", + getname((const u_char *)(ni6 + 1))); + break; + default: + printf(", unknown subject"); + break; + } + + /*(*/ + printf(")"); + break; + + case ICMP6_NI_REPLY: + if (icmp6len > siz) { + printf("[|icmp6: node information reply]"); + break; + } + + needcomma = 0; + + ni6 = (struct icmp6_nodeinfo *)dp; + printf(" node information reply"); + printf(" ("); /*)*/ + switch (ni6->ni_code) { + case ICMP6_NI_SUCCESS: + if (vflag) { + printf("success"); + needcomma++; + } + break; + case ICMP6_NI_REFUSED: + printf("refused"); + needcomma++; + if (siz != sizeof(*ni6)) + if (vflag) + printf(", invalid length"); + break; + case ICMP6_NI_UNKNOWN: + printf("unknown"); + needcomma++; + if (siz != sizeof(*ni6)) + if (vflag) + printf(", invalid length"); + break; + } + + if (ni6->ni_code != ICMP6_NI_SUCCESS) { + /*(*/ + printf(")"); + break; + } + + switch (EXTRACT_16BITS(&ni6->ni_qtype)) { + case NI_QTYPE_NOOP: + if (needcomma) + printf(", "); + printf("noop"); + if (siz != sizeof(*ni6)) + if (vflag) + printf(", invalid length"); + break; + case NI_QTYPE_SUPTYPES: + if (needcomma) + printf(", "); + printf("supported qtypes"); + i = EXTRACT_16BITS(&ni6->ni_flags); + if (i) + printf(" [%s]", (i & 0x01) ? "C" : ""); + break; + case NI_QTYPE_FQDN: + if (needcomma) + printf(", "); + printf("DNS name"); + cp = (const u_char *)(ni6 + 1) + 4; + if (cp[0] == ep - cp - 1) { + /* icmp-name-lookup-03, pascal string */ + if (vflag) + printf(", 03 draft"); + cp++; + printf(", \""); + while (cp < ep) { + safeputchar(*cp); + cp++; + } + printf("\""); + } else + dnsname_print(cp, ep); + if ((EXTRACT_16BITS(&ni6->ni_flags) & 0x01) != 0) + printf(" [TTL=%u]", *(u_int32_t *)(ni6 + 1)); + break; + case NI_QTYPE_NODEADDR: + if (needcomma) + printf(", "); + printf("node addresses"); + i = sizeof(*ni6); + while (i < siz) { + if (i + sizeof(struct in6_addr) + sizeof(int32_t) > siz) + break; + printf(" %s", getname6(bp + i)); + i += sizeof(struct in6_addr); + printf("(%d)", (int32_t)EXTRACT_32BITS(bp + i)); + i += sizeof(int32_t); + } + i = ni6->ni_flags; + if (!i) + break; + printf(" [%s%s%s%s%s%s%s]", + (i & NI_NODEADDR_FLAG_ANYCAST) ? "a" : "", + (i & NI_NODEADDR_FLAG_GLOBAL) ? "G" : "", + (i & NI_NODEADDR_FLAG_SITELOCAL) ? "S" : "", + (i & NI_NODEADDR_FLAG_LINKLOCAL) ? "L" : "", + (i & NI_NODEADDR_FLAG_COMPAT) ? "C" : "", + (i & NI_NODEADDR_FLAG_ALL) ? "A" : "", + (i & NI_NODEADDR_FLAG_TRUNCATE) ? "T" : ""); + break; + default: + if (needcomma) + printf(", "); + printf("unknown"); + break; + } + + /*(*/ + printf(")"); + break; + } + return; + +trunc: + fputs("[|icmp6]", stdout); +} + +static void +icmp6_rrenum_print(const u_char *bp, const u_char *ep) +{ + struct icmp6_router_renum *rr6; + const char *cp; + struct rr_pco_match *match; + struct rr_pco_use *use; + char hbuf[NI_MAXHOST]; + int n; + + if (ep < bp) + return; + rr6 = (struct icmp6_router_renum *)bp; + cp = (const char *)(rr6 + 1); + + TCHECK(rr6->rr_reserved); + switch (rr6->rr_code) { + case ICMP6_ROUTER_RENUMBERING_COMMAND: + printf("router renum: command"); + break; + case ICMP6_ROUTER_RENUMBERING_RESULT: + printf("router renum: result"); + break; + case ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET: + printf("router renum: sequence number reset"); + break; + default: + printf("router renum: code-#%d", rr6->rr_code); + break; + } + + printf(", seq=%u", EXTRACT_32BITS(&rr6->rr_seqnum)); + + if (vflag) { +#define F(x, y) ((rr6->rr_flags) & (x) ? (y) : "") + printf("["); /*]*/ + if (rr6->rr_flags) { + printf("%s%s%s%s%s,", F(ICMP6_RR_FLAGS_TEST, "T"), + F(ICMP6_RR_FLAGS_REQRESULT, "R"), + F(ICMP6_RR_FLAGS_FORCEAPPLY, "A"), + F(ICMP6_RR_FLAGS_SPECSITE, "S"), + F(ICMP6_RR_FLAGS_PREVDONE, "P")); + } + printf("seg=%u,", rr6->rr_segnum); + printf("maxdelay=%u", EXTRACT_16BITS(&rr6->rr_maxdelay)); + if (rr6->rr_reserved) + printf("rsvd=0x%x", EXTRACT_32BITS(&rr6->rr_reserved)); + /*[*/ + printf("]"); +#undef F + } + + if (rr6->rr_code == ICMP6_ROUTER_RENUMBERING_COMMAND) { + match = (struct rr_pco_match *)cp; + cp = (const char *)(match + 1); + + TCHECK(match->rpm_prefix); + + if (vflag > 1) + printf("\n\t"); + else + printf(" "); + printf("match("); /*)*/ + switch (match->rpm_code) { + case RPM_PCO_ADD: printf("add"); break; + case RPM_PCO_CHANGE: printf("change"); break; + case RPM_PCO_SETGLOBAL: printf("setglobal"); break; + default: printf("#%u", match->rpm_code); break; + } + + if (vflag) { + printf(",ord=%u", match->rpm_ordinal); + printf(",min=%u", match->rpm_minlen); + printf(",max=%u", match->rpm_maxlen); + } + if (inet_ntop(AF_INET6, &match->rpm_prefix, hbuf, sizeof(hbuf))) + printf(",%s/%u", hbuf, match->rpm_matchlen); + else + printf(",?/%u", match->rpm_matchlen); + /*(*/ + printf(")"); + + n = match->rpm_len - 3; + if (n % 4) + goto trunc; + n /= 4; + while (n-- > 0) { + use = (struct rr_pco_use *)cp; + cp = (const char *)(use + 1); + + TCHECK(use->rpu_prefix); + + if (vflag > 1) + printf("\n\t"); + else + printf(" "); + printf("use("); /*)*/ + if (use->rpu_flags) { +#define F(x, y) ((use->rpu_flags) & (x) ? (y) : "") + printf("%s%s,", + F(ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME, "V"), + F(ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME, "P")); +#undef F + } + if (vflag) { + printf("mask=0x%x,", use->rpu_ramask); + printf("raflags=0x%x,", use->rpu_raflags); + if (~use->rpu_vltime == 0) + printf("vltime=infty,"); + else + printf("vltime=%u,", + EXTRACT_32BITS(&use->rpu_vltime)); + if (~use->rpu_pltime == 0) + printf("pltime=infty,"); + else + printf("pltime=%u,", + EXTRACT_32BITS(&use->rpu_pltime)); + } + if (inet_ntop(AF_INET6, &use->rpu_prefix, hbuf, + sizeof(hbuf))) + printf("%s/%u/%u", hbuf, use->rpu_uselen, + use->rpu_keeplen); + else + printf("?/%u/%u", use->rpu_uselen, + use->rpu_keeplen); + /*(*/ + printf(")"); + } + } + + return; + +trunc: + fputs("[|icmp6]", stdout); +} + +#endif /* INET6 */
diff --git a/tcpdump-4.3.0/print-igmp.c b/tcpdump-4.3.0/print-igmp.c new file mode 100644 index 0000000..4087ee0 --- /dev/null +++ b/tcpdump-4.3.0/print-igmp.c
@@ -0,0 +1,344 @@ +/* + * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994, 1995, 1996 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-igmp.c,v 1.15 2004-03-24 00:59:16 guy Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> +#include <string.h> + +#include "interface.h" +#include "addrtoname.h" +#include "extract.h" /* must come after interface.h */ + +#ifndef IN_CLASSD +#define IN_CLASSD(i) (((int32_t)(i) & 0xf0000000) == 0xe0000000) +#endif + +/* (following from ipmulti/mrouted/prune.h) */ + +/* + * The packet format for a traceroute request. + */ +struct tr_query { + u_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) +#define TR_GETQID(x) ((x) & 0x00ffffff) + +/* + * Traceroute response format. A traceroute response has a tr_query at the + * beginning, followed by one tr_resp for each hop taken. + */ +struct tr_resp { + u_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 */ +#define TR_QUERY 1 +#define TR_RESP 2 + +/* fields for tr_rflags (forwarding error codes) */ +#define TR_NO_ERR 0 +#define TR_WRONG_IF 1 +#define TR_PRUNED 2 +#define TR_OPRUNED 3 +#define TR_SCOPED 4 +#define TR_NO_RTE 5 +#define TR_NO_FWD 7 +#define TR_NO_SPACE 0x81 +#define TR_OLD_ROUTER 0x82 + +/* fields for tr_rproto (routing protocol) */ +#define TR_PROTO_DVMRP 1 +#define TR_PROTO_MOSPF 2 +#define TR_PROTO_PIM 3 +#define TR_PROTO_CBT 4 + +/* igmpv3 report types */ +static struct tok igmpv3report2str[] = { + { 1, "is_in" }, + { 2, "is_ex" }, + { 3, "to_in" }, + { 4, "to_ex" }, + { 5, "allow" }, + { 6, "block" }, + { 0, NULL } +}; + +static void +print_mtrace(register const u_char *bp, register u_int len) +{ + register 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("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(EXTRACT_32BITS(&tr->tr_raddr))) + printf(" with-ttl %d", TR_GETTTL(EXTRACT_32BITS(&tr->tr_rttlqid))); + return; +trunc: + (void)printf("[|igmp]"); + return; +} + +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(EXTRACT_32BITS(&tr->tr_rttlqid)), + ipaddr_string(&tr->tr_src), ipaddr_string(&tr->tr_dst), + ipaddr_string(&tr->tr_raddr)); + 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 +print_igmpv3_report(register const u_char *bp, register u_int len) +{ + u_int group, nsrcs, ngroups; + register u_int i, j; + + /* Minimum len is 16, and should be a multiple of 4 */ + if (len < 16 || len & 0x03) { + (void)printf(" [invalid len %d]", len); + return; + } + TCHECK2(bp[6], 2); + ngroups = EXTRACT_16BITS(&bp[6]); + (void)printf(", %d group record(s)", ngroups); + if (vflag > 0) { + /* Print the group records */ + group = 8; + for (i=0; i<ngroups; i++) { + if (len < group+8) { + (void)printf(" [invalid number of groups]"); + return; + } + TCHECK2(bp[group+4], 4); + (void)printf(" [gaddr %s", ipaddr_string(&bp[group+4])); + (void)printf(" %s", tok2str(igmpv3report2str, " [v3-report-#%d]", + bp[group])); + nsrcs = EXTRACT_16BITS(&bp[group+2]); + /* Check the number of sources and print them */ + if (len < group+8+(nsrcs<<2)) { + (void)printf(" [invalid number of sources %d]", nsrcs); + return; + } + if (vflag == 1) + (void)printf(", %d source(s)", nsrcs); + else { + /* Print the sources */ + (void)printf(" {"); + for (j=0; j<nsrcs; j++) { + TCHECK2(bp[group+8+(j<<2)], 4); + (void)printf(" %s", ipaddr_string(&bp[group+8+(j<<2)])); + } + (void)printf(" }"); + } + /* Next group record */ + group += 8 + (nsrcs << 2); + (void)printf("]"); + } + } + return; +trunc: + (void)printf("[|igmp]"); + return; +} + +static void +print_igmpv3_query(register const u_char *bp, register u_int len) +{ + u_int mrc; + int mrt; + u_int nsrcs; + register u_int i; + + (void)printf(" v3"); + /* Minimum len is 12, and should be a multiple of 4 */ + if (len < 12 || len & 0x03) { + (void)printf(" [invalid len %d]", len); + return; + } + TCHECK(bp[1]); + mrc = bp[1]; + if (mrc < 128) { + mrt = mrc; + } else { + mrt = ((mrc & 0x0f) | 0x10) << (((mrc & 0x70) >> 4) + 3); + } + if (mrc != 100) { + (void)printf(" [max resp time "); + if (mrt < 600) { + (void)printf("%.1fs", mrt * 0.1); + } else { + relts_print(mrt / 10); + } + (void)printf("]"); + } + TCHECK2(bp[4], 4); + if (EXTRACT_32BITS(&bp[4]) == 0) + return; + (void)printf(" [gaddr %s", ipaddr_string(&bp[4])); + TCHECK2(bp[10], 2); + nsrcs = EXTRACT_16BITS(&bp[10]); + if (nsrcs > 0) { + if (len < 12 + (nsrcs << 2)) + (void)printf(" [invalid number of sources]"); + else if (vflag > 1) { + (void)printf(" {"); + for (i=0; i<nsrcs; i++) { + TCHECK2(bp[12+(i<<2)], 4); + (void)printf(" %s", ipaddr_string(&bp[12+(i<<2)])); + } + (void)printf(" }"); + } else + (void)printf(", %d source(s)", nsrcs); + } + (void)printf("]"); + return; +trunc: + (void)printf("[|igmp]"); + return; +} + +void +igmp_print(register const u_char *bp, register u_int len) +{ + struct cksum_vec vec[1]; + + if (qflag) { + (void)printf("igmp"); + return; + } + + 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"); + 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: + (void)printf("igmp v3 report"); + print_igmpv3_report(bp, len); + break; + case 0x17: + TCHECK2(bp[4], 4); + (void)printf("igmp leave %s", ipaddr_string(&bp[4])); + break; + case 0x13: + (void)printf("igmp dvmrp"); + if (len < 8) + (void)printf(" [len %d]", len); + else + dvmrp_print(bp, len); + break; + case 0x14: + (void)printf("igmp pimv1"); + pimv1_print(bp, len); + break; + case 0x1e: + print_mresp(bp, len); + break; + case 0x1f: + print_mtrace(bp, len); + break; + default: + (void)printf("igmp-%d", bp[0]); + break; + } + + if (vflag && TTEST2(bp[0], len)) { + /* Check the IGMP checksum */ + vec[0].ptr = bp; + vec[0].len = len; + if (in_cksum(vec, 1)) + printf(" bad igmp cksum %x!", EXTRACT_16BITS(&bp[2])); + } + return; +trunc: + fputs("[|igmp]", stdout); +}
diff --git a/tcpdump-4.3.0/print-igrp.c b/tcpdump-4.3.0/print-igrp.c new file mode 100644 index 0000000..3cede7e --- /dev/null +++ b/tcpdump-4.3.0/print-igrp.c
@@ -0,0 +1,130 @@ +/* + * Copyright (c) 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. + * + * Initial contribution from Francis Dupont (francis.dupont@inria.fr) + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-igrp.c,v 1.21 2005-04-20 21:01:56 guy Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> + +#include "interface.h" +#include "addrtoname.h" +#include "igrp.h" +#include "ip.h" +#include "extract.h" /* must come after interface.h */ + +static void +igrp_entry_print(register struct igrprte *igr, register int is_interior, + register int is_exterior) +{ + register u_int delay, bandwidth; + u_int metric, mtu; + + if (is_interior) + printf(" *.%d.%d.%d", igr->igr_net[0], + igr->igr_net[1], igr->igr_net[2]); + else if (is_exterior) + printf(" X%d.%d.%d.0", igr->igr_net[0], + igr->igr_net[1], igr->igr_net[2]); + else + printf(" %d.%d.%d.0", igr->igr_net[0], + igr->igr_net[1], igr->igr_net[2]); + + delay = EXTRACT_24BITS(igr->igr_dly); + bandwidth = EXTRACT_24BITS(igr->igr_bw); + metric = bandwidth + delay; + if (metric > 0xffffff) + metric = 0xffffff; + mtu = EXTRACT_16BITS(igr->igr_mtu); + + printf(" d=%d b=%d r=%d l=%d M=%d mtu=%d in %d hops", + 10 * delay, bandwidth == 0 ? 0 : 10000000 / bandwidth, + igr->igr_rel, igr->igr_ld, metric, + mtu, igr->igr_hct); +} + +static struct tok op2str[] = { + { IGRP_UPDATE, "update" }, + { IGRP_REQUEST, "request" }, + { 0, NULL } +}; + +void +igrp_print(register const u_char *bp, u_int length, const u_char *bp2 _U_) +{ + register struct igrphdr *hdr; + register u_char *cp; + u_int nint, nsys, next; + + hdr = (struct igrphdr *)bp; + cp = (u_char *)(hdr + 1); + (void)printf("igrp:"); + + /* Header */ + TCHECK(*hdr); + nint = EXTRACT_16BITS(&hdr->ig_ni); + nsys = EXTRACT_16BITS(&hdr->ig_ns); + next = EXTRACT_16BITS(&hdr->ig_nx); + + (void)printf(" %s V%d edit=%d AS=%d (%d/%d/%d)", + tok2str(op2str, "op-#%d", IGRP_OP(hdr->ig_vop)), + IGRP_V(hdr->ig_vop), + hdr->ig_ed, + EXTRACT_16BITS(&hdr->ig_as), + nint, + nsys, + next); + + length -= sizeof(*hdr); + while (length >= IGRP_RTE_SIZE) { + if (nint > 0) { + TCHECK2(*cp, IGRP_RTE_SIZE); + igrp_entry_print((struct igrprte *)cp, 1, 0); + --nint; + } else if (nsys > 0) { + TCHECK2(*cp, IGRP_RTE_SIZE); + igrp_entry_print((struct igrprte *)cp, 0, 0); + --nsys; + } else if (next > 0) { + TCHECK2(*cp, IGRP_RTE_SIZE); + igrp_entry_print((struct igrprte *)cp, 0, 1); + --next; + } else { + (void)printf(" [extra bytes %d]", length); + break; + } + cp += IGRP_RTE_SIZE; + length -= IGRP_RTE_SIZE; + } + if (nint == 0 && nsys == 0 && next == 0) + return; +trunc: + fputs(" [|igrp]", stdout); +}
diff --git a/tcpdump-4.3.0/print-ip.c b/tcpdump-4.3.0/print-ip.c new file mode 100644 index 0000000..494eb29 --- /dev/null +++ b/tcpdump-4.3.0/print-ip.c
@@ -0,0 +1,705 @@ +/* + * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.159 2007-09-14 01:29:28 guy Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "addrtoname.h" +#include "interface.h" +#include "extract.h" /* must come after interface.h */ + +#include "ip.h" +#include "ipproto.h" + +struct tok ip_option_values[] = { + { IPOPT_EOL, "EOL" }, + { IPOPT_NOP, "NOP" }, + { IPOPT_TS, "timestamp" }, + { IPOPT_SECURITY, "security" }, + { IPOPT_RR, "RR" }, + { IPOPT_SSRR, "SSRR" }, + { IPOPT_LSRR, "LSRR" }, + { IPOPT_RA, "RA" }, + { IPOPT_RFC1393, "traceroute" }, + { 0, NULL } +}; + +/* + * print the recorded route in an IP RR, LSRR or SSRR option. + */ +static void +ip_printroute(register const u_char *cp, u_int length) +{ + register u_int ptr; + register u_int len; + + if (length < 3) { + printf(" [bad length %u]", length); + return; + } + if ((length + 1) & 3) + printf(" [bad length %u]", length); + ptr = cp[2] - 1; + if (ptr < 3 || ((ptr + 1) & 3) || ptr > length + 1) + printf(" [bad ptr %u]", cp[2]); + + for (len = 3; len < length; len += 4) { + printf(" %s", ipaddr_string(&cp[len])); + if (ptr > len) + printf(","); + } +} + +/* + * If source-routing is present and valid, return the final destination. + * Otherwise, return IP destination. + * + * This is used for UDP and TCP pseudo-header in the checksum + * calculation. + */ +static u_int32_t +ip_finddst(const struct ip *ip) +{ + int length; + int len; + const u_char *cp; + u_int32_t retval; + + cp = (const u_char *)(ip + 1); + length = (IP_HL(ip) << 2) - sizeof(struct ip); + + for (; length > 0; cp += len, length -= len) { + int tt; + + TCHECK(*cp); + tt = *cp; + if (tt == IPOPT_EOL) + break; + else if (tt == IPOPT_NOP) + len = 1; + else { + TCHECK(cp[1]); + len = cp[1]; + if (len < 2) + break; + } + TCHECK2(*cp, len); + switch (tt) { + + case IPOPT_SSRR: + case IPOPT_LSRR: + if (len < 7) + break; + memcpy(&retval, cp + len - 4, 4); + return retval; + } + } +trunc: + memcpy(&retval, &ip->ip_dst.s_addr, sizeof(u_int32_t)); + return retval; +} + +/* + * Compute a V4-style checksum by building a pseudoheader. + */ +int +nextproto4_cksum(const struct ip *ip, const u_int8_t *data, + u_int len, u_int next_proto) +{ + struct phdr { + u_int32_t src; + u_int32_t dst; + u_char mbz; + u_char proto; + u_int16_t len; + } ph; + struct cksum_vec vec[2]; + + /* pseudo-header.. */ + ph.len = htons((u_int16_t)len); + ph.mbz = 0; + ph.proto = next_proto; + memcpy(&ph.src, &ip->ip_src.s_addr, sizeof(u_int32_t)); + if (IP_HL(ip) == 5) + memcpy(&ph.dst, &ip->ip_dst.s_addr, sizeof(u_int32_t)); + else + ph.dst = ip_finddst(ip); + + vec[0].ptr = (const u_int8_t *)(void *)&ph; + vec[0].len = sizeof(ph); + vec[1].ptr = data; + vec[1].len = len; + return (in_cksum(vec, 2)); +} + +static void +ip_printts(register const u_char *cp, u_int length) +{ + register u_int ptr; + register u_int len; + int hoplen; + const char *type; + + if (length < 4) { + printf("[bad length %u]", length); + return; + } + printf(" TS{"); + hoplen = ((cp[3]&0xF) != IPOPT_TS_TSONLY) ? 8 : 4; + if ((length - 4) & (hoplen-1)) + printf("[bad length %u]", length); + ptr = cp[2] - 1; + len = 0; + if (ptr < 4 || ((ptr - 4) & (hoplen-1)) || ptr > length + 1) + printf("[bad ptr %u]", cp[2]); + switch (cp[3]&0xF) { + case IPOPT_TS_TSONLY: + printf("TSONLY"); + break; + case IPOPT_TS_TSANDADDR: + printf("TS+ADDR"); + break; + /* + * prespecified should really be 3, but some ones might send 2 + * instead, and the IPOPT_TS_PRESPEC constant can apparently + * have both values, so we have to hard-code it here. + */ + + case 2: + printf("PRESPEC2.0"); + break; + case 3: /* IPOPT_TS_PRESPEC */ + printf("PRESPEC"); + break; + default: + printf("[bad ts type %d]", cp[3]&0xF); + goto done; + } + + type = " "; + for (len = 4; len < length; len += hoplen) { + if (ptr == len) + type = " ^ "; + printf("%s%d@%s", type, EXTRACT_32BITS(&cp[len+hoplen-4]), + hoplen!=8 ? "" : ipaddr_string(&cp[len])); + type = " "; + } + +done: + printf("%s", ptr == len ? " ^ " : ""); + + if (cp[3]>>4) + printf(" [%d hops not recorded]} ", cp[3]>>4); + else + printf("}"); +} + +/* + * print IP options. + */ +static void +ip_optprint(register const u_char *cp, u_int length) +{ + register u_int option_len; + const char *sep = ""; + + for (; length > 0; cp += option_len, length -= option_len) { + u_int option_code; + + printf("%s", sep); + sep = ","; + + TCHECK(*cp); + option_code = *cp; + + printf("%s", + tok2str(ip_option_values,"unknown %u",option_code)); + + if (option_code == IPOPT_NOP || + option_code == IPOPT_EOL) + option_len = 1; + + else { + TCHECK(cp[1]); + option_len = cp[1]; + if (option_len < 2) { + printf(" [bad length %u]", option_len); + return; + } + } + + if (option_len > length) { + printf(" [bad length %u]", option_len); + return; + } + + TCHECK2(*cp, option_len); + + switch (option_code) { + case IPOPT_EOL: + return; + + case IPOPT_TS: + ip_printts(cp, option_len); + break; + + case IPOPT_RR: /* fall through */ + case IPOPT_SSRR: + case IPOPT_LSRR: + ip_printroute(cp, option_len); + break; + + case IPOPT_RA: + if (option_len < 4) { + printf(" [bad length %u]", option_len); + break; + } + TCHECK(cp[3]); + if (EXTRACT_16BITS(&cp[2]) != 0) + printf(" value %u", EXTRACT_16BITS(&cp[2])); + break; + + case IPOPT_NOP: /* nothing to print - fall through */ + case IPOPT_SECURITY: + default: + break; + } + } + return; + +trunc: + printf("[|ip]"); +} + +#define IP_RES 0x8000 + +static struct tok ip_frag_values[] = { + { IP_MF, "+" }, + { IP_DF, "DF" }, + { IP_RES, "rsvd" }, /* The RFC3514 evil ;-) bit */ + { 0, NULL } +}; + +struct ip_print_demux_state { + const struct ip *ip; + const u_char *cp; + u_int len, off; + u_char nh; + int advance; +}; + +static void +ip_print_demux(netdissect_options *ndo, + struct ip_print_demux_state *ipds) +{ + struct protoent *proto; + struct cksum_vec vec[1]; + +again: + switch (ipds->nh) { + + case IPPROTO_AH: + ipds->nh = *ipds->cp; + ipds->advance = ah_print(ipds->cp); + if (ipds->advance <= 0) + break; + ipds->cp += ipds->advance; + ipds->len -= ipds->advance; + goto again; + + case IPPROTO_ESP: + { + int enh, padlen; + ipds->advance = esp_print(ndo, ipds->cp, ipds->len, + (const u_char *)ipds->ip, + &enh, &padlen); + if (ipds->advance <= 0) + break; + ipds->cp += ipds->advance; + ipds->len -= ipds->advance + padlen; + ipds->nh = enh & 0xff; + goto again; + } + + case IPPROTO_IPCOMP: + { + int enh; + ipds->advance = ipcomp_print(ipds->cp, &enh); + if (ipds->advance <= 0) + break; + ipds->cp += ipds->advance; + ipds->len -= ipds->advance; + ipds->nh = enh & 0xff; + goto again; + } + + case IPPROTO_SCTP: + sctp_print(ipds->cp, (const u_char *)ipds->ip, ipds->len); + break; + + case IPPROTO_DCCP: + dccp_print(ipds->cp, (const u_char *)ipds->ip, ipds->len); + break; + + case IPPROTO_TCP: + /* pass on the MF bit plus the offset to detect fragments */ + tcp_print(ipds->cp, ipds->len, (const u_char *)ipds->ip, + ipds->off & (IP_MF|IP_OFFMASK)); + break; + + case IPPROTO_UDP: + /* pass on the MF bit plus the offset to detect fragments */ + udp_print(ipds->cp, ipds->len, (const u_char *)ipds->ip, + ipds->off & (IP_MF|IP_OFFMASK)); + break; + + case IPPROTO_ICMP: + /* pass on the MF bit plus the offset to detect fragments */ + icmp_print(ipds->cp, ipds->len, (const u_char *)ipds->ip, + ipds->off & (IP_MF|IP_OFFMASK)); + break; + + case IPPROTO_PIGP: + /* + * XXX - the current IANA protocol number assignments + * page lists 9 as "any private interior gateway + * (used by Cisco for their IGRP)" and 88 as + * "EIGRP" from Cisco. + * + * Recent BSD <netinet/in.h> headers define + * IP_PROTO_PIGP as 9 and IP_PROTO_IGRP as 88. + * We define IP_PROTO_PIGP as 9 and + * IP_PROTO_EIGRP as 88; those names better + * match was the current protocol number + * assignments say. + */ + igrp_print(ipds->cp, ipds->len, (const u_char *)ipds->ip); + break; + + case IPPROTO_EIGRP: + eigrp_print(ipds->cp, ipds->len); + break; + + case IPPROTO_ND: + ND_PRINT((ndo, " nd %d", ipds->len)); + break; + + case IPPROTO_EGP: + egp_print(ipds->cp, ipds->len); + break; + + case IPPROTO_OSPF: + ospf_print(ipds->cp, ipds->len, (const u_char *)ipds->ip); + break; + + case IPPROTO_IGMP: + igmp_print(ipds->cp, ipds->len); + break; + + case IPPROTO_IPV4: + /* DVMRP multicast tunnel (ip-in-ip encapsulation) */ + ip_print(ndo, ipds->cp, ipds->len); + if (! vflag) { + ND_PRINT((ndo, " (ipip-proto-4)")); + return; + } + break; + +#ifdef INET6 + case IPPROTO_IPV6: + /* ip6-in-ip encapsulation */ + ip6_print(ndo, ipds->cp, ipds->len); + break; +#endif /*INET6*/ + + case IPPROTO_RSVP: + rsvp_print(ipds->cp, ipds->len); + break; + + case IPPROTO_GRE: + /* do it */ + gre_print(ipds->cp, ipds->len); + break; + + case IPPROTO_MOBILE: + mobile_print(ipds->cp, ipds->len); + break; + + case IPPROTO_PIM: + vec[0].ptr = ipds->cp; + vec[0].len = ipds->len; + pim_print(ipds->cp, ipds->len, in_cksum(vec, 1)); + break; + + case IPPROTO_VRRP: + if (packettype == PT_CARP) { + if (vflag) + (void)printf("carp %s > %s: ", + ipaddr_string(&ipds->ip->ip_src), + ipaddr_string(&ipds->ip->ip_dst)); + carp_print(ipds->cp, ipds->len, ipds->ip->ip_ttl); + } else { + if (vflag) + (void)printf("vrrp %s > %s: ", + ipaddr_string(&ipds->ip->ip_src), + ipaddr_string(&ipds->ip->ip_dst)); + vrrp_print(ipds->cp, ipds->len, ipds->ip->ip_ttl); + } + break; + + case IPPROTO_PGM: + pgm_print(ipds->cp, ipds->len, (const u_char *)ipds->ip); + break; + + default: + if (ndo->ndo_nflag==0 && (proto = getprotobynumber(ipds->nh)) != NULL) + ND_PRINT((ndo, " %s", proto->p_name)); + else + ND_PRINT((ndo, " ip-proto-%d", ipds->nh)); + ND_PRINT((ndo, " %d", ipds->len)); + break; + } +} + +void +ip_print_inner(netdissect_options *ndo, + const u_char *bp, + u_int length, u_int nh, + const u_char *bp2) +{ + struct ip_print_demux_state ipd; + + ipd.ip = (const struct ip *)bp2; + ipd.cp = bp; + ipd.len = length; + ipd.off = 0; + ipd.nh = nh; + ipd.advance = 0; + + ip_print_demux(ndo, &ipd); +} + + +/* + * print an IP datagram. + */ +void +ip_print(netdissect_options *ndo, + const u_char *bp, + u_int length) +{ + struct ip_print_demux_state ipd; + struct ip_print_demux_state *ipds=&ipd; + const u_char *ipend; + u_int hlen; + struct cksum_vec vec[1]; + u_int16_t sum, ip_sum; + struct protoent *proto; + + ipds->ip = (const struct ip *)bp; + if (IP_V(ipds->ip) != 4) { /* print version if != 4 */ + printf("IP%u ", IP_V(ipds->ip)); + if (IP_V(ipds->ip) == 6) + printf(", wrong link-layer encapsulation"); + } + else if (!eflag) + printf("IP "); + + if ((u_char *)(ipds->ip + 1) > ndo->ndo_snapend) { + printf("[|ip]"); + return; + } + if (length < sizeof (struct ip)) { + (void)printf("truncated-ip %u", length); + return; + } + hlen = IP_HL(ipds->ip) * 4; + if (hlen < sizeof (struct ip)) { + (void)printf("bad-hlen %u", hlen); + return; + } + + ipds->len = EXTRACT_16BITS(&ipds->ip->ip_len); + if (length < ipds->len) + (void)printf("truncated-ip - %u bytes missing! ", + ipds->len - length); + if (ipds->len < hlen) { +#ifdef GUESS_TSO + if (ipds->len) { + (void)printf("bad-len %u", ipds->len); + return; + } + else { + /* we guess that it is a TSO send */ + ipds->len = length; + } +#else + (void)printf("bad-len %u", ipds->len); + return; +#endif /* GUESS_TSO */ + } + + /* + * Cut off the snapshot length to the end of the IP payload. + */ + ipend = bp + ipds->len; + if (ipend < ndo->ndo_snapend) + ndo->ndo_snapend = ipend; + + ipds->len -= hlen; + + ipds->off = EXTRACT_16BITS(&ipds->ip->ip_off); + + if (vflag) { + (void)printf("(tos 0x%x", (int)ipds->ip->ip_tos); + /* ECN bits */ + if (ipds->ip->ip_tos & 0x03) { + switch (ipds->ip->ip_tos & 0x03) { + case 1: + (void)printf(",ECT(1)"); + break; + case 2: + (void)printf(",ECT(0)"); + break; + case 3: + (void)printf(",CE"); + } + } + + if (ipds->ip->ip_ttl >= 1) + (void)printf(", ttl %u", ipds->ip->ip_ttl); + + /* + * for the firewall guys, print id, offset. + * On all but the last stick a "+" in the flags portion. + * For unfragmented datagrams, note the don't fragment flag. + */ + + (void)printf(", id %u, offset %u, flags [%s], proto %s (%u)", + EXTRACT_16BITS(&ipds->ip->ip_id), + (ipds->off & 0x1fff) * 8, + bittok2str(ip_frag_values, "none", ipds->off&0xe000), + tok2str(ipproto_values,"unknown",ipds->ip->ip_p), + ipds->ip->ip_p); + + (void)printf(", length %u", EXTRACT_16BITS(&ipds->ip->ip_len)); + + if ((hlen - sizeof(struct ip)) > 0) { + printf(", options ("); + ip_optprint((u_char *)(ipds->ip + 1), hlen - sizeof(struct ip)); + printf(")"); + } + + if (!Kflag && (u_char *)ipds->ip + hlen <= ndo->ndo_snapend) { + vec[0].ptr = (const u_int8_t *)(void *)ipds->ip; + vec[0].len = hlen; + sum = in_cksum(vec, 1); + if (sum != 0) { + ip_sum = EXTRACT_16BITS(&ipds->ip->ip_sum); + (void)printf(", bad cksum %x (->%x)!", ip_sum, + in_cksum_shouldbe(ip_sum, sum)); + } + } + + printf(")\n "); + } + + /* + * If this is fragment zero, hand it to the next higher + * level protocol. + */ + if ((ipds->off & 0x1fff) == 0) { + ipds->cp = (const u_char *)ipds->ip + hlen; + ipds->nh = ipds->ip->ip_p; + + if (ipds->nh != IPPROTO_TCP && ipds->nh != IPPROTO_UDP && + ipds->nh != IPPROTO_SCTP && ipds->nh != IPPROTO_DCCP) { + (void)printf("%s > %s: ", + ipaddr_string(&ipds->ip->ip_src), + ipaddr_string(&ipds->ip->ip_dst)); + } + ip_print_demux(ndo, ipds); + } else { + /* Ultra quiet now means that all this stuff should be suppressed */ + if (qflag > 1) return; + + /* + * if this isn't the first frag, we're missing the + * next level protocol header. print the ip addr + * and the protocol. + */ + if (ipds->off & 0x1fff) { + (void)printf("%s > %s:", ipaddr_string(&ipds->ip->ip_src), + ipaddr_string(&ipds->ip->ip_dst)); + if (!ndo->ndo_nflag && (proto = getprotobynumber(ipds->ip->ip_p)) != NULL) + (void)printf(" %s", proto->p_name); + else + (void)printf(" ip-proto-%d", ipds->ip->ip_p); + } + } +} + +void +ipN_print(register const u_char *bp, register u_int length) +{ + struct ip *ip, hdr; + + ip = (struct ip *)bp; + if (length < 4) { + (void)printf("truncated-ip %d", length); + return; + } + memcpy (&hdr, (char *)ip, 4); + switch (IP_V(&hdr)) { + case 4: + ip_print (gndo, bp, length); + return; +#ifdef INET6 + case 6: + ip6_print (gndo, bp, length); + return; +#endif + default: + (void)printf("unknown ip %d", IP_V(&hdr)); + return; + } +} + +/* + * Local Variables: + * c-style: whitesmith + * c-basic-offset: 8 + * End: + */ + +
diff --git a/tcpdump-4.3.0/print-ip6.c b/tcpdump-4.3.0/print-ip6.c new file mode 100644 index 0000000..f5e6244 --- /dev/null +++ b/tcpdump-4.3.0/print-ip6.c
@@ -0,0 +1,271 @@ +/* + * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 + * 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-ip6.c,v 1.52 2007-09-21 07:05:33 hannes Exp $"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifdef INET6 + +#include <tcpdump-stdinc.h> + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "netdissect.h" +#include "interface.h" +#include "addrtoname.h" +#include "extract.h" + +#include "ip6.h" +#include "ipproto.h" + +/* + * Compute a V6-style checksum by building a pseudoheader. + */ +int +nextproto6_cksum(const struct ip6_hdr *ip6, const u_int8_t *data, + u_int len, u_int next_proto) +{ + 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; + struct cksum_vec vec[2]; + + /* pseudo-header */ + memset(&ph, 0, sizeof(ph)); + ph.ph_src = ip6->ip6_src; + ph.ph_dst = ip6->ip6_dst; + ph.ph_len = htonl(len); + ph.ph_nxt = next_proto; + + vec[0].ptr = (const u_int8_t *)(void *)&ph; + vec[0].len = sizeof(ph); + vec[1].ptr = data; + vec[1].len = len; + + return in_cksum(vec, 2); +} + +/* + * print an IP6 datagram. + */ +void +ip6_print(netdissect_options *ndo, const u_char *bp, u_int length) +{ + register const struct ip6_hdr *ip6; + register int advance; + u_int len; + const u_char *ipend; + register const u_char *cp; + register u_int payload_len; + int nh; + int fragmented = 0; + u_int flow; + + ip6 = (const struct ip6_hdr *)bp; + + TCHECK(*ip6); + if (length < sizeof (struct ip6_hdr)) { + (void)ND_PRINT((ndo, "truncated-ip6 %u", length)); + return; + } + + if (!ndo->ndo_eflag) + ND_PRINT((ndo, "IP6 ")); + + payload_len = EXTRACT_16BITS(&ip6->ip6_plen); + len = payload_len + sizeof(struct ip6_hdr); + if (length < len) + (void)ND_PRINT((ndo, "truncated-ip6 - %u bytes missing!", + len - length)); + + if (ndo->ndo_vflag) { + flow = EXTRACT_32BITS(&ip6->ip6_flow); + ND_PRINT((ndo, "(")); +#if 0 + /* rfc1883 */ + if (flow & 0x0f000000) + (void)ND_PRINT((ndo, "pri 0x%02x, ", (flow & 0x0f000000) >> 24)); + if (flow & 0x00ffffff) + (void)ND_PRINT((ndo, "flowlabel 0x%06x, ", flow & 0x00ffffff)); +#else + /* RFC 2460 */ + if (flow & 0x0ff00000) + (void)ND_PRINT((ndo, "class 0x%02x, ", (flow & 0x0ff00000) >> 20)); + if (flow & 0x000fffff) + (void)ND_PRINT((ndo, "flowlabel 0x%05x, ", flow & 0x000fffff)); +#endif + + (void)ND_PRINT((ndo, "hlim %u, next-header %s (%u) payload length: %u) ", + ip6->ip6_hlim, + tok2str(ipproto_values,"unknown",ip6->ip6_nxt), + ip6->ip6_nxt, + payload_len)); + } + + /* + * Cut off the snapshot length to the end of the IP payload. + */ + ipend = bp + len; + if (ipend < ndo->ndo_snapend) + ndo->ndo_snapend = ipend; + + cp = (const u_char *)ip6; + advance = sizeof(struct ip6_hdr); + nh = ip6->ip6_nxt; + while (cp < ndo->ndo_snapend && advance > 0) { + cp += advance; + len -= advance; + + if (cp == (const u_char *)(ip6 + 1) && + nh != IPPROTO_TCP && nh != IPPROTO_UDP && + nh != IPPROTO_DCCP && nh != IPPROTO_SCTP) { + (void)ND_PRINT((ndo, "%s > %s: ", ip6addr_string(&ip6->ip6_src), + ip6addr_string(&ip6->ip6_dst))); + } + + switch (nh) { + case IPPROTO_HOPOPTS: + advance = hbhopt_print(cp); + nh = *cp; + break; + case IPPROTO_DSTOPTS: + advance = dstopt_print(cp); + nh = *cp; + break; + case IPPROTO_FRAGMENT: + advance = frag6_print(cp, (const u_char *)ip6); + if (ndo->ndo_snapend <= cp + advance) + return; + nh = *cp; + fragmented = 1; + break; + + case IPPROTO_MOBILITY_OLD: + case IPPROTO_MOBILITY: + /* + * XXX - we don't use "advance"; the current + * "Mobility Support in IPv6" draft + * (draft-ietf-mobileip-ipv6-24) says that + * the next header field in a mobility header + * should be IPPROTO_NONE, but speaks of + * the possiblity of a future extension in + * which payload can be piggybacked atop a + * mobility header. + */ + advance = mobility_print(cp, (const u_char *)ip6); + nh = *cp; + return; + case IPPROTO_ROUTING: + advance = rt6_print(cp, (const u_char *)ip6); + nh = *cp; + break; + case IPPROTO_SCTP: + sctp_print(cp, (const u_char *)ip6, len); + return; + case IPPROTO_DCCP: + dccp_print(cp, (const u_char *)ip6, len); + return; + case IPPROTO_TCP: + tcp_print(cp, len, (const u_char *)ip6, fragmented); + return; + case IPPROTO_UDP: + udp_print(cp, len, (const u_char *)ip6, fragmented); + return; + case IPPROTO_ICMPV6: + icmp6_print(ndo, cp, len, (const u_char *)ip6, fragmented); + return; + case IPPROTO_AH: + advance = ah_print(cp); + nh = *cp; + break; + case IPPROTO_ESP: + { + int enh, padlen; + advance = esp_print(ndo, cp, len, (const u_char *)ip6, &enh, &padlen); + nh = enh & 0xff; + len -= padlen; + break; + } + case IPPROTO_IPCOMP: + { + int enh; + advance = ipcomp_print(cp, &enh); + nh = enh & 0xff; + break; + } + + case IPPROTO_PIM: + pim_print(cp, len, nextproto6_cksum(ip6, cp, len, + IPPROTO_PIM)); + return; + + case IPPROTO_OSPF: + ospf6_print(cp, len); + return; + + case IPPROTO_IPV6: + ip6_print(ndo, cp, len); + return; + + case IPPROTO_IPV4: + ip_print(ndo, cp, len); + return; + + case IPPROTO_PGM: + pgm_print(cp, len, (const u_char *)ip6); + return; + + case IPPROTO_GRE: + gre_print(cp, len); + return; + + case IPPROTO_RSVP: + rsvp_print(cp, len); + return; + + case IPPROTO_NONE: + (void)ND_PRINT((ndo, "no next header")); + return; + + default: + (void)ND_PRINT((ndo, "ip-proto-%d %d", nh, len)); + return; + } + } + + return; +trunc: + (void)ND_PRINT((ndo, "[|ip6]")); +} + +#endif /* INET6 */
diff --git a/tcpdump-4.3.0/print-ip6opts.c b/tcpdump-4.3.0/print-ip6opts.c new file mode 100644 index 0000000..2121b46 --- /dev/null +++ b/tcpdump-4.3.0/print-ip6opts.c
@@ -0,0 +1,332 @@ +/* + * 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: + * 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-ip6opts.c,v 1.18 2005-04-20 22:18:50 guy Exp $"; +#endif + +#ifdef INET6 +#include <tcpdump-stdinc.h> + +#include <stdio.h> + +#include "ip6.h" + +#include "interface.h" +#include "addrtoname.h" +#include "extract.h" + +/* items outside of rfc2292bis */ +#ifndef IP6OPT_MINLEN +#define IP6OPT_MINLEN 2 +#endif +#ifndef IP6OPT_RTALERT_LEN +#define IP6OPT_RTALERT_LEN 4 +#endif +#ifndef IP6OPT_JUMBO_LEN +#define IP6OPT_JUMBO_LEN 6 +#endif +#define IP6OPT_HOMEADDR_MINLEN 18 +#define IP6OPT_BU_MINLEN 10 +#define IP6OPT_BA_MINLEN 13 +#define IP6OPT_BR_MINLEN 2 +#define IP6SOPT_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); + +static void +ip6_sopt_print(const u_char *bp, int len) +{ + int i; + int optlen; + + for (i = 0; i < len; i += optlen) { + if (bp[i] == IP6OPT_PAD1) + optlen = 1; + else { + if (i + 1 < len) + optlen = bp[i + 1] + 2; + else + goto trunc; + } + if (i + optlen > len) + goto trunc; + + switch (bp[i]) { + case IP6OPT_PAD1: + printf(", pad1"); + break; + case IP6OPT_PADN: + if (len - i < IP6OPT_MINLEN) { + printf(", padn: trunc"); + goto trunc; + } + 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"); + goto trunc; + } + printf(", alt-CoA: %s", ip6addr_string(&bp[i+2])); + break; + case IP6SOPT_AUTH: + if (len - i < IP6SOPT_AUTH_MINLEN) { + printf(", auth: trunc"); + goto trunc; + } + printf(", auth spi: 0x%08x", EXTRACT_32BITS(&bp[i + 2])); + break; + default: + if (len - i < IP6OPT_MINLEN) { + printf(", sopt_type %d: trunc)", bp[i]); + goto trunc; + } + printf(", sopt_type 0x%02x: len=%d", bp[i], bp[i + 1]); + break; + } + } + return; + +trunc: + printf("[trunc] "); +} + +void +ip6_opt_print(const u_char *bp, int len) +{ + int i; + int optlen = 0; + + if (len == 0) + return; + for (i = 0; i < len; i += optlen) { + if (bp[i] == IP6OPT_PAD1) + optlen = 1; + else { + if (i + 1 < len) + optlen = bp[i + 1] + 2; + else + goto trunc; + } + if (i + optlen > len) + goto trunc; + + switch (bp[i]) { + case IP6OPT_PAD1: + printf("(pad1)"); + break; + case IP6OPT_PADN: + if (len - i < IP6OPT_MINLEN) { + printf("(padn: trunc)"); + goto trunc; + } + printf("(padn)"); + break; + case IP6OPT_ROUTER_ALERT: + if (len - i < IP6OPT_RTALERT_LEN) { + printf("(rtalert: trunc)"); + goto trunc; + } + if (bp[i + 1] != IP6OPT_RTALERT_LEN - 2) { + printf("(rtalert: invalid len %d)", bp[i + 1]); + goto trunc; + } + printf("(rtalert: 0x%04x) ", EXTRACT_16BITS(&bp[i + 2])); + break; + case IP6OPT_JUMBO: + if (len - i < IP6OPT_JUMBO_LEN) { + printf("(jumbo: trunc)"); + goto trunc; + } + if (bp[i + 1] != IP6OPT_JUMBO_LEN - 2) { + printf("(jumbo: invalid len %d)", bp[i + 1]); + goto trunc; + } + printf("(jumbo: %u) ", EXTRACT_32BITS(&bp[i + 2])); + break; + case IP6OPT_HOME_ADDRESS: + if (len - i < IP6OPT_HOMEADDR_MINLEN) { + printf("(homeaddr: trunc)"); + goto trunc; + } + if (bp[i + 1] < IP6OPT_HOMEADDR_MINLEN - 2) { + printf("(homeaddr: invalid len %d)", bp[i + 1]); + goto trunc; + } + printf("(homeaddr: %s", ip6addr_string(&bp[i + 2])); + if (bp[i + 1] > IP6OPT_HOMEADDR_MINLEN - 2) { + ip6_sopt_print(&bp[i + IP6OPT_HOMEADDR_MINLEN], + (optlen - IP6OPT_HOMEADDR_MINLEN)); + } + printf(")"); + break; + case IP6OPT_BINDING_UPDATE: + if (len - i < IP6OPT_BU_MINLEN) { + printf("(bu: trunc)"); + goto trunc; + } + if (bp[i + 1] < IP6OPT_BU_MINLEN - 2) { + printf("(bu: invalid len %d)", bp[i + 1]); + goto trunc; + } + printf("(bu: "); + if (bp[i + 2] & 0x80) + printf("A"); + if (bp[i + 2] & 0x40) + printf("H"); + if (bp[i + 2] & 0x20) + printf("S"); + if (bp[i + 2] & 0x10) + printf("D"); + if ((bp[i + 2] & 0x0f) || bp[i + 3] || bp[i + 4]) + printf("res"); + 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], + (optlen - IP6OPT_BU_MINLEN)); + } + printf(")"); + break; + case IP6OPT_BINDING_ACK: + if (len - i < IP6OPT_BA_MINLEN) { + printf("(ba: trunc)"); + goto trunc; + } + if (bp[i + 1] < IP6OPT_BA_MINLEN - 2) { + printf("(ba: invalid len %d)", bp[i + 1]); + goto trunc; + } + printf("(ba: "); + printf("status: %u", bp[i + 2]); + 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], + (optlen - IP6OPT_BA_MINLEN)); + } + printf(")"); + break; + case IP6OPT_BINDING_REQ: + if (len - i < IP6OPT_BR_MINLEN) { + printf("(br: trunc)"); + goto trunc; + } + printf("(br"); + if (bp[i + 1] > IP6OPT_BR_MINLEN - 2) { + ip6_sopt_print(&bp[i + IP6OPT_BR_MINLEN], + (optlen - IP6OPT_BR_MINLEN)); + } + printf(")"); + break; + default: + if (len - i < IP6OPT_MINLEN) { + printf("(type %d: trunc)", bp[i]); + goto trunc; + } + printf("(opt_type 0x%02x: len=%d)", bp[i], bp[i + 1]); + break; + } + } + printf(" "); + +#if 0 +end: +#endif + return; + +trunc: + printf("[trunc] "); +} + +int +hbhopt_print(register const u_char *bp) +{ + const struct ip6_hbh *dp = (struct ip6_hbh *)bp; + int hbhlen = 0; + + TCHECK(dp->ip6h_len); + hbhlen = (int)((dp->ip6h_len + 1) << 3); + TCHECK2(*dp, hbhlen); + printf("HBH "); + if (vflag) + ip6_opt_print((const u_char *)dp + sizeof(*dp), hbhlen - sizeof(*dp)); + + return(hbhlen); + + trunc: + fputs("[|HBH]", stdout); + return(-1); +} + +int +dstopt_print(register const u_char *bp) +{ + const struct ip6_dest *dp = (struct ip6_dest *)bp; + int dstoptlen = 0; + + TCHECK(dp->ip6d_len); + dstoptlen = (int)((dp->ip6d_len + 1) << 3); + TCHECK2(*dp, dstoptlen); + printf("DSTOPT "); + if (vflag) { + ip6_opt_print((const u_char *)dp + sizeof(*dp), + dstoptlen - sizeof(*dp)); + } + + return(dstoptlen); + + trunc: + fputs("[|DSTOPT]", stdout); + return(-1); +} +#endif /* INET6 */
diff --git a/tcpdump-4.3.0/print-ipcomp.c b/tcpdump-4.3.0/print-ipcomp.c new file mode 100644 index 0000000..89130a3 --- /dev/null +++ b/tcpdump-4.3.0/print-ipcomp.c
@@ -0,0 +1,91 @@ +/* + * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994 + * 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-ipcomp.c,v 1.20 2003-11-19 00:36:08 guy Exp $"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <string.h> +#include <tcpdump-stdinc.h> + +#include <stdio.h> + +struct ipcomp { + u_int8_t comp_nxt; /* Next Header */ + u_int8_t comp_flags; /* Length of data, in 32bit */ + u_int16_t comp_cpi; /* Compression parameter index */ +}; + +#if defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H) +#include <zlib.h> +#endif + +#include "interface.h" +#include "addrtoname.h" +#include "extract.h" + +int +ipcomp_print(register const u_char *bp, int *nhdr _U_) +{ + register const struct ipcomp *ipcomp; + register const u_char *ep; + u_int16_t cpi; +#if defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H) + int advance; +#endif + + ipcomp = (struct ipcomp *)bp; + cpi = EXTRACT_16BITS(&ipcomp->comp_cpi); + + /* 'ep' points to the end of available data. */ + ep = snapend; + + if ((u_char *)(ipcomp + 1) >= ep - sizeof(struct ipcomp)) { + fputs("[|IPCOMP]", stdout); + goto fail; + } + printf("IPComp(cpi=0x%04x)", cpi); + +#if defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H) + if (1) + goto fail; + + /* + * We may want to decompress the packet here. Packet buffer + * management is a headache (if we decompress, packet will become + * larger). + */ + if (nhdr) + *nhdr = ipcomp->comp_nxt; + advance = sizeof(struct ipcomp); + + printf(": "); + return advance; + +#endif +fail: + return -1; +}
diff --git a/tcpdump-4.3.0/print-ipfc.c b/tcpdump-4.3.0/print-ipfc.c new file mode 100644 index 0000000..c980765 --- /dev/null +++ b/tcpdump-4.3.0/print-ipfc.c
@@ -0,0 +1,135 @@ +/* + * 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.9 2005-11-13 12:12:42 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; + + /* 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 (!suppress_default_print) + 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->len' 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/tcpdump-4.3.0/print-ipnet.c b/tcpdump-4.3.0/print-ipnet.c new file mode 100644 index 0000000..187f939 --- /dev/null +++ b/tcpdump-4.3.0/print-ipnet.c
@@ -0,0 +1,109 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> +#include <pcap.h> + +#include "netdissect.h" +#include "interface.h" +#include "addrtoname.h" +#include "ipnet.h" + +#ifdef DLT_IPNET + +const struct tok ipnet_values[] = { + { IPH_AF_INET, "IPv4" }, + { IPH_AF_INET6, "IPv6" }, + { 0, NULL } +}; + +static inline void +ipnet_hdr_print(struct netdissect_options *ndo, const u_char *bp, u_int length) +{ + const ipnet_hdr_t *hdr; + hdr = (const ipnet_hdr_t *)bp; + + ND_PRINT((ndo, "%d > %d", hdr->iph_zsrc, hdr->iph_zdst)); + + if (!ndo->ndo_qflag) { + ND_PRINT((ndo,", family %s (%d)", + tok2str(ipnet_values, "Unknown", + hdr->iph_family), + hdr->iph_family)); + } else { + ND_PRINT((ndo,", %s", + tok2str(ipnet_values, + "Unknown Ethertype (0x%04x)", + hdr->iph_family))); + } + + ND_PRINT((ndo, ", length %u: ", length)); +} + +static void +ipnet_print(struct netdissect_options *ndo, const u_char *p, u_int length, u_int caplen) +{ + ipnet_hdr_t *hdr; + + if (caplen < sizeof(ipnet_hdr_t)) { + ND_PRINT((ndo, "[|ipnet]")); + return; + } + + if (ndo->ndo_eflag) + ipnet_hdr_print(ndo, p, length); + + length -= sizeof(ipnet_hdr_t); + caplen -= sizeof(ipnet_hdr_t); + hdr = (ipnet_hdr_t *)p; + p += sizeof(ipnet_hdr_t); + + switch (hdr->iph_family) { + + case IPH_AF_INET: + ip_print(ndo, p, length); + break; + +#ifdef INET6 + case IPH_AF_INET6: + ip6_print(ndo, p, length); + break; +#endif /*INET6*/ + + default: + if (!ndo->ndo_eflag) + ipnet_hdr_print(ndo, (u_char *)hdr, + length + sizeof(ipnet_hdr_t)); + + if (!ndo->ndo_suppress_default_print) + ndo->ndo_default_print(ndo, p, caplen); + break; + } +} + +/* + * This is the top level routine of the printer. 'p' points + * to the ether header of the packet, 'h->ts' is the timestamp, + * 'h->len' is the length of the packet off the wire, and 'h->caplen' + * is the number of bytes actually captured. + */ +u_int +ipnet_if_print(struct netdissect_options *ndo, + const struct pcap_pkthdr *h, const u_char *p) +{ + ipnet_print(ndo, p, h->len, h->caplen); + + return (sizeof(ipnet_hdr_t)); +} + +/* + * Local Variables: + * c-style: whitesmith + * c-basic-offset: 8 + * End: + */ + +#endif /* DLT_IPNET */
diff --git a/tcpdump-4.3.0/print-ipx.c b/tcpdump-4.3.0/print-ipx.c new file mode 100644 index 0000000..c9bde23 --- /dev/null +++ b/tcpdump-4.3.0/print-ipx.c
@@ -0,0 +1,221 @@ +/* + * Copyright (c) 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. + * + * Format and print Novell IPX packets. + * Contributed by Brad Parker (brad@fcr.com). + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-ipx.c,v 1.42 2005-05-06 08:26:44 guy Exp $"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +#include "interface.h" +#include "addrtoname.h" +#include "ipx.h" +#include "extract.h" + + +static const char *ipxaddr_string(u_int32_t, const u_char *); +void ipx_decode(const struct ipxHdr *, const u_char *, u_int); +void ipx_sap_print(const u_short *, u_int); +void ipx_rip_print(const u_short *, u_int); + +/* + * Print IPX datagram packets. + */ +void +ipx_print(const u_char *p, u_int length) +{ + const struct ipxHdr *ipx = (const struct ipxHdr *)p; + + if (!eflag) + printf("IPX "); + + TCHECK(ipx->srcSkt); + (void)printf("%s.%04x > ", + ipxaddr_string(EXTRACT_32BITS(ipx->srcNet), ipx->srcNode), + EXTRACT_16BITS(&ipx->srcSkt)); + + (void)printf("%s.%04x: ", + ipxaddr_string(EXTRACT_32BITS(ipx->dstNet), ipx->dstNode), + EXTRACT_16BITS(&ipx->dstSkt)); + + /* take length from ipx header */ + TCHECK(ipx->length); + length = EXTRACT_16BITS(&ipx->length); + + ipx_decode(ipx, (u_char *)ipx + ipxSize, length - ipxSize); + return; +trunc: + printf("[|ipx %d]", length); +} + +static const char * +ipxaddr_string(u_int32_t net, const u_char *node) +{ + static char line[256]; + + snprintf(line, sizeof(line), "%08x.%02x:%02x:%02x:%02x:%02x:%02x", + net, node[0], node[1], node[2], node[3], node[4], node[5]); + + return line; +} + +void +ipx_decode(const struct ipxHdr *ipx, const u_char *datap, u_int length) +{ + register u_short dstSkt; + + dstSkt = EXTRACT_16BITS(&ipx->dstSkt); + switch (dstSkt) { + case IPX_SKT_NCP: + (void)printf("ipx-ncp %d", length); + break; + case IPX_SKT_SAP: + ipx_sap_print((u_short *)datap, length); + break; + case IPX_SKT_RIP: + ipx_rip_print((u_short *)datap, length); + break; + case IPX_SKT_NETBIOS: + (void)printf("ipx-netbios %d", length); +#ifdef TCPDUMP_DO_SMB + ipx_netbios_print(datap, length); +#endif + break; + case IPX_SKT_DIAGNOSTICS: + (void)printf("ipx-diags %d", length); + break; + case IPX_SKT_NWLINK_DGM: + (void)printf("ipx-nwlink-dgm %d", length); +#ifdef TCPDUMP_DO_SMB + ipx_netbios_print(datap, length); +#endif + break; + case IPX_SKT_EIGRP: + eigrp_print(datap, length); + break; + default: + (void)printf("ipx-#%x %d", dstSkt, length); + break; + } +} + +void +ipx_sap_print(const u_short *ipx, u_int length) +{ + int command, i; + + TCHECK(ipx[0]); + command = EXTRACT_16BITS(ipx); + ipx++; + length -= 2; + + switch (command) { + case 1: + case 3: + if (command == 1) + (void)printf("ipx-sap-req"); + else + (void)printf("ipx-sap-nearest-req"); + + TCHECK(ipx[0]); + (void)printf(" %s", ipxsap_string(htons(EXTRACT_16BITS(&ipx[0])))); + break; + + case 2: + case 4: + if (command == 2) + (void)printf("ipx-sap-resp"); + else + (void)printf("ipx-sap-nearest-resp"); + + for (i = 0; i < 8 && length > 0; i++) { + TCHECK(ipx[0]); + (void)printf(" %s '", ipxsap_string(htons(EXTRACT_16BITS(&ipx[0])))); + if (fn_printzp((u_char *)&ipx[1], 48, snapend)) { + printf("'"); + goto trunc; + } + TCHECK2(ipx[25], 10); + printf("' addr %s", + ipxaddr_string(EXTRACT_32BITS(&ipx[25]), (u_char *)&ipx[27])); + ipx += 32; + length -= 64; + } + break; + default: + (void)printf("ipx-sap-?%x", command); + break; + } + return; +trunc: + printf("[|ipx %d]", length); +} + +void +ipx_rip_print(const u_short *ipx, u_int length) +{ + int command, i; + + TCHECK(ipx[0]); + command = EXTRACT_16BITS(ipx); + ipx++; + length -= 2; + + switch (command) { + case 1: + (void)printf("ipx-rip-req"); + if (length > 0) { + TCHECK(ipx[3]); + (void)printf(" %08x/%d.%d", EXTRACT_32BITS(&ipx[0]), + EXTRACT_16BITS(&ipx[2]), EXTRACT_16BITS(&ipx[3])); + } + break; + case 2: + (void)printf("ipx-rip-resp"); + for (i = 0; i < 50 && length > 0; i++) { + TCHECK(ipx[3]); + (void)printf(" %08x/%d.%d", EXTRACT_32BITS(&ipx[0]), + EXTRACT_16BITS(&ipx[2]), EXTRACT_16BITS(&ipx[3])); + + ipx += 4; + length -= 8; + } + break; + default: + (void)printf("ipx-rip-?%x", command); + break; + } + return; +trunc: + printf("[|ipx %d]", length); +}
diff --git a/tcpdump-4.3.0/print-isakmp.c b/tcpdump-4.3.0/print-isakmp.c new file mode 100644 index 0000000..4f96afe --- /dev/null +++ b/tcpdump-4.3.0/print-isakmp.c
@@ -0,0 +1,2570 @@ +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-isakmp.c,v 1.61 2008-02-05 19:34:25 guy Exp $ (LBL)"; +#endif + +#define NETDISSECT_REWORKED +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <string.h> + +#include <stdio.h> + +#include "isakmp.h" +#include "ipsec_doi.h" +#include "oakley.h" +#include "interface.h" +#include "addrtoname.h" +#include "extract.h" /* must come after interface.h */ + +#include "ip.h" +#ifdef INET6 +#include "ip6.h" +#endif + +#ifndef HAVE_SOCKADDR_STORAGE +#define sockaddr_storage sockaddr +#endif + +#define DECLARE_PRINTER(func) static const u_char *ike##func##_print( \ + netdissect_options *ndo, u_char tpay, \ + const struct isakmp_gen *ext, \ + u_int item_len, \ + const u_char *end_pointer, \ + u_int32_t phase,\ + u_int32_t doi0, \ + u_int32_t proto0, int depth) + +DECLARE_PRINTER(v1_sa); +DECLARE_PRINTER(v1_p); +DECLARE_PRINTER(v1_t); +DECLARE_PRINTER(v1_ke); +DECLARE_PRINTER(v1_id); +DECLARE_PRINTER(v1_cert); +DECLARE_PRINTER(v1_cr); +DECLARE_PRINTER(v1_sig); +DECLARE_PRINTER(v1_hash); +DECLARE_PRINTER(v1_nonce); +DECLARE_PRINTER(v1_n); +DECLARE_PRINTER(v1_d); +DECLARE_PRINTER(v1_vid); + +DECLARE_PRINTER(v2_sa); +DECLARE_PRINTER(v2_ke); +DECLARE_PRINTER(v2_ID); +DECLARE_PRINTER(v2_cert); +DECLARE_PRINTER(v2_cr); +DECLARE_PRINTER(v2_auth); +DECLARE_PRINTER(v2_nonce); +DECLARE_PRINTER(v2_n); +DECLARE_PRINTER(v2_d); +DECLARE_PRINTER(v2_vid); +DECLARE_PRINTER(v2_TS); +DECLARE_PRINTER(v2_cp); +DECLARE_PRINTER(v2_eap); + +static const u_char *ikev2_e_print(netdissect_options *ndo, + struct isakmp *base, + u_char tpay, + const struct isakmp_gen *ext, + u_int item_len, + const u_char *end_pointer, + u_int32_t phase, + u_int32_t doi0, + u_int32_t proto0, int depth); + + +static const u_char *ike_sub0_print(netdissect_options *ndo,u_char, const struct isakmp_gen *, + const u_char *, u_int32_t, u_int32_t, u_int32_t, int); +static const u_char *ikev1_sub_print(netdissect_options *ndo,u_char, const struct isakmp_gen *, + const u_char *, u_int32_t, u_int32_t, u_int32_t, int); + +static const u_char *ikev2_sub_print(netdissect_options *ndo, + struct isakmp *base, + u_char np, const struct isakmp_gen *ext, + const u_char *ep, u_int32_t phase, + u_int32_t doi, u_int32_t proto, + int depth); + + +static char *numstr(int); +static void safememcpy(void *, const void *, size_t); + +static void +ikev1_print(netdissect_options *ndo, + const u_char *bp, u_int length, + const u_char *bp2, struct isakmp *base); + +#define MAXINITIATORS 20 +int ninitiator = 0; +struct { + cookie_t initiator; + struct sockaddr_storage iaddr; + struct sockaddr_storage raddr; +} cookiecache[MAXINITIATORS]; + +/* protocol id */ +static const char *protoidstr[] = { + NULL, "isakmp", "ipsec-ah", "ipsec-esp", "ipcomp", +}; + +/* isakmp->np */ +static const char *npstr[] = { + "none", "sa", "p", "t", "ke", "id", "cert", "cr", "hash", /* 0 - 8 */ + "sig", "nonce", "n", "d", "vid", /* 9 - 13 */ + "pay14", "pay15", "pay16", "pay17", "pay18", /* 14- 18 */ + "pay19", "pay20", "pay21", "pay22", "pay23", /* 19- 23 */ + "pay24", "pay25", "pay26", "pay27", "pay28", /* 24- 28 */ + "pay29", "pay30", "pay31", "pay32", /* 29- 32 */ + "v2sa", "v2ke", "v2IDi", "v2IDr", "v2cert",/* 33- 37 */ + "v2cr", "v2auth","v2nonce", "v2n", "v2d", /* 38- 42 */ + "v2vid", "v2TSi", "v2TSr", "v2e", "v2cp", /* 43- 47 */ + "v2eap", /* 48 */ + +}; + +/* isakmp->np */ +static const u_char *(*npfunc[])(netdissect_options *ndo, u_char tpay, + const struct isakmp_gen *ext, + u_int item_len, + const u_char *end_pointer, + u_int32_t phase, + u_int32_t doi0, + u_int32_t proto0, int depth) = { + NULL, + ikev1_sa_print, + ikev1_p_print, + ikev1_t_print, + ikev1_ke_print, + ikev1_id_print, + ikev1_cert_print, + ikev1_cr_print, + ikev1_hash_print, + ikev1_sig_print, + ikev1_nonce_print, + ikev1_n_print, + ikev1_d_print, + ikev1_vid_print, /* 13 */ + NULL, NULL, NULL, NULL, NULL, /* 14- 18 */ + NULL, NULL, NULL, NULL, NULL, /* 19- 23 */ + NULL, NULL, NULL, NULL, NULL, /* 24- 28 */ + NULL, NULL, NULL, NULL, /* 29- 32 */ + ikev2_sa_print, /* 33 */ + ikev2_ke_print, /* 34 */ + ikev2_ID_print, /* 35 */ + ikev2_ID_print, /* 36 */ + ikev2_cert_print, /* 37 */ + ikev2_cr_print, /* 38 */ + ikev2_auth_print, /* 39 */ + ikev2_nonce_print, /* 40 */ + ikev2_n_print, /* 41 */ + ikev2_d_print, /* 42 */ + ikev2_vid_print, /* 43 */ + ikev2_TS_print, /* 44 */ + ikev2_TS_print, /* 45 */ + NULL, /* ikev2_e_print,*/ /* 46 - special */ + ikev2_cp_print, /* 47 */ + ikev2_eap_print, /* 48 */ +}; + +/* isakmp->etype */ +static const char *etypestr[] = { +/* IKEv1 exchange types */ + "none", "base", "ident", "auth", "agg", "inf", NULL, NULL, /* 0-7 */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 8-15 */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 16-23 */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 24-31 */ + "oakley-quick", "oakley-newgroup", /* 32-33 */ +/* IKEv2 exchange types */ + "ikev2_init", "ikev2_auth", "child_sa", "inf2" /* 34-37 */ +}; + +#define STR_OR_ID(x, tab) \ + (((x) < sizeof(tab)/sizeof(tab[0]) && tab[(x)]) ? tab[(x)] : numstr(x)) +#define PROTOIDSTR(x) STR_OR_ID(x, protoidstr) +#define NPSTR(x) STR_OR_ID(x, npstr) +#define ETYPESTR(x) STR_OR_ID(x, etypestr) + +#define CHECKLEN(p, np) \ + if (ep < (u_char *)(p)) { \ + ND_PRINT((ndo," [|%s]", NPSTR(np))); \ + goto done; \ + } + + +#define NPFUNC(x) \ + (((x) < sizeof(npfunc)/sizeof(npfunc[0]) && npfunc[(x)]) \ + ? npfunc[(x)] : NULL) + +static int +iszero(u_char *p, size_t l) +{ + while (l--) { + if (*p++) + return 0; + } + return 1; +} + +/* find cookie from initiator cache */ +static int +cookie_find(cookie_t *in) +{ + int i; + + for (i = 0; i < MAXINITIATORS; i++) { + if (memcmp(in, &cookiecache[i].initiator, sizeof(*in)) == 0) + return i; + } + + return -1; +} + +/* record initiator */ +static void +cookie_record(cookie_t *in, const u_char *bp2) +{ + int i; + struct ip *ip; + struct sockaddr_in *sin; +#ifdef INET6 + struct ip6_hdr *ip6; + struct sockaddr_in6 *sin6; +#endif + + i = cookie_find(in); + if (0 <= i) { + ninitiator = (i + 1) % MAXINITIATORS; + return; + } + + ip = (struct ip *)bp2; + switch (IP_V(ip)) { + case 4: + memset(&cookiecache[ninitiator].iaddr, 0, + sizeof(cookiecache[ninitiator].iaddr)); + memset(&cookiecache[ninitiator].raddr, 0, + sizeof(cookiecache[ninitiator].raddr)); + + sin = (struct sockaddr_in *)&cookiecache[ninitiator].iaddr; +#ifdef HAVE_SOCKADDR_SA_LEN + sin->sin_len = sizeof(struct sockaddr_in); +#endif + sin->sin_family = AF_INET; + memcpy(&sin->sin_addr, &ip->ip_src, sizeof(ip->ip_src)); + sin = (struct sockaddr_in *)&cookiecache[ninitiator].raddr; +#ifdef HAVE_SOCKADDR_SA_LEN + sin->sin_len = sizeof(struct sockaddr_in); +#endif + sin->sin_family = AF_INET; + memcpy(&sin->sin_addr, &ip->ip_dst, sizeof(ip->ip_dst)); + break; +#ifdef INET6 + case 6: + memset(&cookiecache[ninitiator].iaddr, 0, + sizeof(cookiecache[ninitiator].iaddr)); + memset(&cookiecache[ninitiator].raddr, 0, + sizeof(cookiecache[ninitiator].raddr)); + + ip6 = (struct ip6_hdr *)bp2; + sin6 = (struct sockaddr_in6 *)&cookiecache[ninitiator].iaddr; +#ifdef HAVE_SOCKADDR_SA_LEN + sin6->sin6_len = sizeof(struct sockaddr_in6); +#endif + sin6->sin6_family = AF_INET6; + memcpy(&sin6->sin6_addr, &ip6->ip6_src, sizeof(ip6->ip6_src)); + sin6 = (struct sockaddr_in6 *)&cookiecache[ninitiator].raddr; +#ifdef HAVE_SOCKADDR_SA_LEN + sin6->sin6_len = sizeof(struct sockaddr_in6); +#endif + sin6->sin6_family = AF_INET6; + memcpy(&sin6->sin6_addr, &ip6->ip6_dst, sizeof(ip6->ip6_dst)); + break; +#endif + default: + return; + } + memcpy(&cookiecache[ninitiator].initiator, in, sizeof(*in)); + ninitiator = (ninitiator + 1) % MAXINITIATORS; +} + +#define cookie_isinitiator(x, y) cookie_sidecheck((x), (y), 1) +#define cookie_isresponder(x, y) cookie_sidecheck((x), (y), 0) +static int +cookie_sidecheck(int i, const u_char *bp2, int initiator) +{ + struct sockaddr_storage ss; + struct sockaddr *sa; + struct ip *ip; + struct sockaddr_in *sin; +#ifdef INET6 + struct ip6_hdr *ip6; + struct sockaddr_in6 *sin6; +#endif + int salen; + + memset(&ss, 0, sizeof(ss)); + ip = (struct ip *)bp2; + switch (IP_V(ip)) { + case 4: + sin = (struct sockaddr_in *)&ss; +#ifdef HAVE_SOCKADDR_SA_LEN + sin->sin_len = sizeof(struct sockaddr_in); +#endif + sin->sin_family = AF_INET; + memcpy(&sin->sin_addr, &ip->ip_src, sizeof(ip->ip_src)); + break; +#ifdef INET6 + case 6: + ip6 = (struct ip6_hdr *)bp2; + sin6 = (struct sockaddr_in6 *)&ss; +#ifdef HAVE_SOCKADDR_SA_LEN + sin6->sin6_len = sizeof(struct sockaddr_in6); +#endif + sin6->sin6_family = AF_INET6; + memcpy(&sin6->sin6_addr, &ip6->ip6_src, sizeof(ip6->ip6_src)); + break; +#endif + default: + return 0; + } + + sa = (struct sockaddr *)&ss; + if (initiator) { + if (sa->sa_family != ((struct sockaddr *)&cookiecache[i].iaddr)->sa_family) + return 0; +#ifdef HAVE_SOCKADDR_SA_LEN + salen = sa->sa_len; +#else +#ifdef INET6 + if (sa->sa_family == AF_INET6) + salen = sizeof(struct sockaddr_in6); + else + salen = sizeof(struct sockaddr); +#else + salen = sizeof(struct sockaddr); +#endif +#endif + if (memcmp(&ss, &cookiecache[i].iaddr, salen) == 0) + return 1; + } else { + if (sa->sa_family != ((struct sockaddr *)&cookiecache[i].raddr)->sa_family) + return 0; +#ifdef HAVE_SOCKADDR_SA_LEN + salen = sa->sa_len; +#else +#ifdef INET6 + if (sa->sa_family == AF_INET6) + salen = sizeof(struct sockaddr_in6); + else + salen = sizeof(struct sockaddr); +#else + salen = sizeof(struct sockaddr); +#endif +#endif + if (memcmp(&ss, &cookiecache[i].raddr, salen) == 0) + return 1; + } + return 0; +} + +static void +hexprint(netdissect_options *ndo, caddr_t loc, size_t len) +{ + u_char *p; + size_t i; + + p = (u_char *)loc; + for (i = 0; i < len; i++) + ND_PRINT((ndo,"%02x", p[i] & 0xff)); +} + +static int +rawprint(netdissect_options *ndo, caddr_t loc, size_t len) +{ + ND_TCHECK2(*loc, len); + + hexprint(ndo, loc, len); + return 1; +trunc: + return 0; +} + + +/* + * returns false if we run out of data buffer + */ +static int ike_show_somedata(struct netdissect_options *ndo, + const u_char *cp, const u_char *ep) +{ + /* there is too much data, just show some of it */ + const u_char *end = ep - 20; + int elen = 20; + int len = ep - cp; + if(len > 10) { + len = 10; + } + + /* really shouldn't happen because of above */ + if(end < cp + len) { + end = cp+len; + elen = ep - end; + } + + ND_PRINT((ndo," data=(")); + if(!rawprint(ndo, (caddr_t)(cp), len)) goto trunc; + ND_PRINT((ndo, "...")); + if(elen) { + if(!rawprint(ndo, (caddr_t)(end), elen)) goto trunc; + } + ND_PRINT((ndo,")")); + return 1; + +trunc: + return 0; +} + +struct attrmap { + const char *type; + u_int nvalue; + const char *value[30]; /*XXX*/ +}; + +static const u_char * +ikev1_attrmap_print(netdissect_options *ndo, + const u_char *p, const u_char *ep, + const struct attrmap *map, size_t nmap) +{ + u_int16_t *q; + int totlen; + u_int32_t t, v; + + q = (u_int16_t *)p; + if (p[0] & 0x80) + totlen = 4; + else + totlen = 4 + EXTRACT_16BITS(&q[1]); + if (ep < p + totlen) { + ND_PRINT((ndo,"[|attr]")); + return ep + 1; + } + + ND_PRINT((ndo,"(")); + t = EXTRACT_16BITS(&q[0]) & 0x7fff; + if (map && t < nmap && map[t].type) + ND_PRINT((ndo,"type=%s ", map[t].type)); + else + ND_PRINT((ndo,"type=#%d ", t)); + if (p[0] & 0x80) { + ND_PRINT((ndo,"value=")); + v = EXTRACT_16BITS(&q[1]); + if (map && t < nmap && v < map[t].nvalue && map[t].value[v]) + ND_PRINT((ndo,"%s", map[t].value[v])); + else + rawprint(ndo, (caddr_t)&q[1], 2); + } else { + ND_PRINT((ndo,"len=%d value=", EXTRACT_16BITS(&q[1]))); + rawprint(ndo, (caddr_t)&p[4], EXTRACT_16BITS(&q[1])); + } + ND_PRINT((ndo,")")); + return p + totlen; +} + +static const u_char * +ikev1_attr_print(netdissect_options *ndo, const u_char *p, const u_char *ep) +{ + u_int16_t *q; + int totlen; + u_int32_t t; + + q = (u_int16_t *)p; + if (p[0] & 0x80) + totlen = 4; + else + totlen = 4 + EXTRACT_16BITS(&q[1]); + if (ep < p + totlen) { + ND_PRINT((ndo,"[|attr]")); + return ep + 1; + } + + ND_PRINT((ndo,"(")); + t = EXTRACT_16BITS(&q[0]) & 0x7fff; + ND_PRINT((ndo,"type=#%d ", t)); + if (p[0] & 0x80) { + ND_PRINT((ndo,"value=")); + t = q[1]; + rawprint(ndo, (caddr_t)&q[1], 2); + } else { + ND_PRINT((ndo,"len=%d value=", EXTRACT_16BITS(&q[1]))); + rawprint(ndo, (caddr_t)&p[2], EXTRACT_16BITS(&q[1])); + } + ND_PRINT((ndo,")")); + return p + totlen; +} + +static const u_char * +ikev1_sa_print(netdissect_options *ndo, u_char tpay _U_, + const struct isakmp_gen *ext, + u_int item_len _U_, + const u_char *ep, u_int32_t phase, u_int32_t doi0 _U_, + u_int32_t proto0, int depth) +{ + const struct ikev1_pl_sa *p; + struct ikev1_pl_sa sa; + const u_int32_t *q; + u_int32_t doi, sit, ident; + const u_char *cp, *np; + int t; + + ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_SA))); + + p = (struct ikev1_pl_sa *)ext; + ND_TCHECK(*p); + safememcpy(&sa, ext, sizeof(sa)); + doi = ntohl(sa.doi); + sit = ntohl(sa.sit); + if (doi != 1) { + ND_PRINT((ndo," doi=%d", doi)); + ND_PRINT((ndo," situation=%u", (u_int32_t)ntohl(sa.sit))); + return (u_char *)(p + 1); + } + + ND_PRINT((ndo," doi=ipsec")); + q = (u_int32_t *)&sa.sit; + ND_PRINT((ndo," situation=")); + t = 0; + if (sit & 0x01) { + ND_PRINT((ndo,"identity")); + t++; + } + if (sit & 0x02) { + ND_PRINT((ndo,"%ssecrecy", t ? "+" : "")); + t++; + } + if (sit & 0x04) + ND_PRINT((ndo,"%sintegrity", t ? "+" : "")); + + np = (u_char *)ext + sizeof(sa); + if (sit != 0x01) { + ND_TCHECK2(*(ext + 1), sizeof(ident)); + safememcpy(&ident, ext + 1, sizeof(ident)); + ND_PRINT((ndo," ident=%u", (u_int32_t)ntohl(ident))); + np += sizeof(ident); + } + + ext = (struct isakmp_gen *)np; + ND_TCHECK(*ext); + + cp = ikev1_sub_print(ndo, ISAKMP_NPTYPE_P, ext, ep, phase, doi, proto0, + depth); + + return cp; +trunc: + ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_SA))); + return NULL; +} + +static const u_char * +ikev1_p_print(netdissect_options *ndo, u_char tpay _U_, + const struct isakmp_gen *ext, u_int item_len _U_, + const u_char *ep, u_int32_t phase, u_int32_t doi0, + u_int32_t proto0 _U_, int depth) +{ + const struct ikev1_pl_p *p; + struct ikev1_pl_p prop; + const u_char *cp; + + ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_P))); + + p = (struct ikev1_pl_p *)ext; + ND_TCHECK(*p); + safememcpy(&prop, ext, sizeof(prop)); + ND_PRINT((ndo," #%d protoid=%s transform=%d", + prop.p_no, PROTOIDSTR(prop.prot_id), prop.num_t)); + if (prop.spi_size) { + ND_PRINT((ndo," spi=")); + if (!rawprint(ndo, (caddr_t)(p + 1), prop.spi_size)) + goto trunc; + } + + ext = (struct isakmp_gen *)((u_char *)(p + 1) + prop.spi_size); + ND_TCHECK(*ext); + + cp = ikev1_sub_print(ndo, ISAKMP_NPTYPE_T, ext, ep, phase, doi0, + prop.prot_id, depth); + + return cp; +trunc: + ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_P))); + return NULL; +} + +static const char *ikev1_p_map[] = { + NULL, "ike", +}; + +static const char *ikev2_t_type_map[]={ + NULL, "encr", "prf", "integ", "dh", "esn" +}; + +static const char *ah_p_map[] = { + NULL, "(reserved)", "md5", "sha", "1des", + "sha2-256", "sha2-384", "sha2-512", +}; + +static const char *prf_p_map[] = { + NULL, "hmac-md5", "hmac-sha", "hmac-tiger", + "aes128_xcbc" +}; + +static const char *integ_p_map[] = { + NULL, "hmac-md5", "hmac-sha", "dec-mac", + "kpdk-md5", "aes-xcbc" +}; + +static const char *esn_p_map[] = { + "no-esn", "esn" +}; + +static const char *dh_p_map[] = { + NULL, "modp768", + "modp1024", /* group 2 */ + "EC2N 2^155", /* group 3 */ + "EC2N 2^185", /* group 4 */ + "modp1536", /* group 5 */ + "iana-grp06", "iana-grp07", /* reserved */ + "iana-grp08", "iana-grp09", + "iana-grp10", "iana-grp11", + "iana-grp12", "iana-grp13", + "modp2048", /* group 14 */ + "modp3072", /* group 15 */ + "modp4096", /* group 16 */ + "modp6144", /* group 17 */ + "modp8192", /* group 18 */ +}; + +static const char *esp_p_map[] = { + NULL, "1des-iv64", "1des", "3des", "rc5", "idea", "cast", + "blowfish", "3idea", "1des-iv32", "rc4", "null", "aes" +}; + +static const char *ipcomp_p_map[] = { + NULL, "oui", "deflate", "lzs", +}; + +const struct attrmap ipsec_t_map[] = { + { NULL, 0, { NULL } }, + { "lifetype", 3, { NULL, "sec", "kb", }, }, + { "life", 0, { NULL } }, + { "group desc", 18, { NULL, "modp768", + "modp1024", /* group 2 */ + "EC2N 2^155", /* group 3 */ + "EC2N 2^185", /* group 4 */ + "modp1536", /* group 5 */ + "iana-grp06", "iana-grp07", /* reserved */ + "iana-grp08", "iana-grp09", + "iana-grp10", "iana-grp11", + "iana-grp12", "iana-grp13", + "modp2048", /* group 14 */ + "modp3072", /* group 15 */ + "modp4096", /* group 16 */ + "modp6144", /* group 17 */ + "modp8192", /* group 18 */ + }, }, + { "enc mode", 3, { NULL, "tunnel", "transport", }, }, + { "auth", 5, { NULL, "hmac-md5", "hmac-sha1", "1des-mac", "keyed", }, }, + { "keylen", 0, { NULL } }, + { "rounds", 0, { NULL } }, + { "dictsize", 0, { NULL } }, + { "privalg", 0, { NULL } }, +}; + +const struct attrmap encr_t_map[] = { + { NULL, 0, { NULL } }, { NULL, 0, { NULL } }, /* 0, 1 */ + { NULL, 0, { NULL } }, { NULL, 0, { NULL } }, /* 2, 3 */ + { NULL, 0, { NULL } }, { NULL, 0, { NULL } }, /* 4, 5 */ + { NULL, 0, { NULL } }, { NULL, 0, { NULL } }, /* 6, 7 */ + { NULL, 0, { NULL } }, { NULL, 0, { NULL } }, /* 8, 9 */ + { NULL, 0, { NULL } }, { NULL, 0, { NULL } }, /* 10,11*/ + { NULL, 0, { NULL } }, { NULL, 0, { NULL } }, /* 12,13*/ + { "keylen", 14, { NULL }}, +}; + +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", + "sha2-256", "sha2-384", "sha2-512", }, }, + { "auth", 6, { NULL, "preshared", "dss", "rsa sig", "rsa enc", + "rsa enc revised", }, }, + { "group desc", 18, { NULL, "modp768", + "modp1024", /* group 2 */ + "EC2N 2^155", /* group 3 */ + "EC2N 2^185", /* group 4 */ + "modp1536", /* group 5 */ + "iana-grp06", "iana-grp07", /* reserved */ + "iana-grp08", "iana-grp09", + "iana-grp10", "iana-grp11", + "iana-grp12", "iana-grp13", + "modp2048", /* group 14 */ + "modp3072", /* group 15 */ + "modp4096", /* group 16 */ + "modp6144", /* group 17 */ + "modp8192", /* group 18 */ + }, }, + { "group type", 4, { NULL, "MODP", "ECP", "EC2N", }, }, + { "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, { NULL } }, + { "prf", 0, { NULL } }, + { "keylen", 0, { NULL } }, + { "field", 0, { NULL } }, + { "order", 0, { NULL } }, +}; + +static const u_char * +ikev1_t_print(netdissect_options *ndo, u_char tpay _U_, + 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_) +{ + const struct ikev1_pl_t *p; + struct ikev1_pl_t t; + const u_char *cp; + const char *idstr; + const struct attrmap *map; + size_t nmap; + const u_char *ep2; + + ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_T))); + + p = (struct ikev1_pl_t *)ext; + ND_TCHECK(*p); + safememcpy(&t, ext, sizeof(t)); + + switch (proto) { + case 1: + idstr = STR_OR_ID(t.t_id, ikev1_p_map); + map = oakley_t_map; + nmap = sizeof(oakley_t_map)/sizeof(oakley_t_map[0]); + break; + case 2: + idstr = STR_OR_ID(t.t_id, ah_p_map); + map = ipsec_t_map; + nmap = sizeof(ipsec_t_map)/sizeof(ipsec_t_map[0]); + break; + case 3: + idstr = STR_OR_ID(t.t_id, esp_p_map); + map = ipsec_t_map; + nmap = sizeof(ipsec_t_map)/sizeof(ipsec_t_map[0]); + break; + case 4: + idstr = STR_OR_ID(t.t_id, ipcomp_p_map); + map = ipsec_t_map; + nmap = sizeof(ipsec_t_map)/sizeof(ipsec_t_map[0]); + break; + default: + idstr = NULL; + map = NULL; + nmap = 0; + break; + } + + if (idstr) + ND_PRINT((ndo," #%d id=%s ", t.t_no, idstr)); + else + ND_PRINT((ndo," #%d id=%d ", t.t_no, t.t_id)); + cp = (u_char *)(p + 1); + ep2 = (u_char *)p + item_len; + while (cp < ep && cp < ep2) { + if (map && nmap) { + cp = ikev1_attrmap_print(ndo, cp, (ep < ep2) ? ep : ep2, + map, nmap); + } else + cp = ikev1_attr_print(ndo, cp, (ep < ep2) ? ep : ep2); + } + if (ep < ep2) + ND_PRINT((ndo,"...")); + return cp; +trunc: + ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_T))); + return NULL; +} + +static const u_char * +ikev1_ke_print(netdissect_options *ndo, u_char tpay _U_, + const struct isakmp_gen *ext, u_int item_len _U_, + const u_char *ep _U_, u_int32_t phase _U_, u_int32_t doi _U_, + u_int32_t proto _U_, int depth _U_) +{ + struct isakmp_gen e; + + ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_KE))); + + ND_TCHECK(*ext); + safememcpy(&e, ext, sizeof(e)); + ND_PRINT((ndo," key len=%d", ntohs(e.len) - 4)); + if (2 < ndo->ndo_vflag && 4 < ntohs(e.len)) { + ND_PRINT((ndo," ")); + if (!rawprint(ndo, (caddr_t)(ext + 1), ntohs(e.len) - 4)) + goto trunc; + } + return (u_char *)ext + ntohs(e.len); +trunc: + ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_KE))); + return NULL; +} + +static const u_char * +ikev1_id_print(netdissect_options *ndo, u_char tpay _U_, + const struct isakmp_gen *ext, u_int item_len _U_, + const u_char *ep _U_, u_int32_t phase, u_int32_t doi _U_, + u_int32_t proto _U_, int depth _U_) +{ +#define USE_IPSECDOI_IN_PHASE1 1 + const struct ikev1_pl_id *p; + struct ikev1_pl_id id; + static const char *idtypestr[] = { + "IPv4", "IPv4net", "IPv6", "IPv6net", + }; + static const char *ipsecidtypestr[] = { + NULL, "IPv4", "FQDN", "user FQDN", "IPv4net", "IPv6", + "IPv6net", "IPv4range", "IPv6range", "ASN1 DN", "ASN1 GN", + "keyid", + }; + int len; + const u_char *data; + + ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_ID))); + + p = (struct ikev1_pl_id *)ext; + ND_TCHECK(*p); + safememcpy(&id, ext, sizeof(id)); + if (sizeof(*p) < item_len) { + data = (u_char *)(p + 1); + len = item_len - sizeof(*p); + } else { + data = NULL; + len = 0; + } + +#if 0 /*debug*/ + ND_PRINT((ndo," [phase=%d doi=%d proto=%d]", phase, doi, proto)); +#endif + switch (phase) { +#ifndef USE_IPSECDOI_IN_PHASE1 + case 1: +#endif + default: + ND_PRINT((ndo," idtype=%s", STR_OR_ID(id.d.id_type, idtypestr))); + ND_PRINT((ndo," doi_data=%u", + (u_int32_t)(ntohl(id.d.doi_data) & 0xffffff))); + break; + +#ifdef USE_IPSECDOI_IN_PHASE1 + case 1: +#endif + case 2: + { + const struct ipsecdoi_id *p; + struct ipsecdoi_id id; + struct protoent *pe; + + p = (struct ipsecdoi_id *)ext; + ND_TCHECK(*p); + safememcpy(&id, ext, sizeof(id)); + ND_PRINT((ndo," 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) + ND_PRINT((ndo," protoid=%s", pe->p_name)); +#ifndef WIN32 + endprotoent(); +#endif /* WIN32 */ + } else { + /* it DOES NOT mean IPPROTO_IP! */ + ND_PRINT((ndo," protoid=%s", "0")); + } + ND_PRINT((ndo," port=%d", ntohs(id.port))); + if (!len) + break; + if (data == NULL) + goto trunc; + ND_TCHECK2(*data, len); + switch (id.type) { + case IPSECDOI_ID_IPV4_ADDR: + if (len < 4) + ND_PRINT((ndo," len=%d [bad: < 4]", len)); + else + ND_PRINT((ndo," len=%d %s", len, ipaddr_string(data))); + len = 0; + break; + case IPSECDOI_ID_FQDN: + case IPSECDOI_ID_USER_FQDN: + { + int i; + ND_PRINT((ndo," len=%d ", len)); + for (i = 0; i < len; i++) + safeputchar(data[i]); + len = 0; + break; + } + case IPSECDOI_ID_IPV4_ADDR_SUBNET: + { + const u_char *mask; + if (len < 8) + ND_PRINT((ndo," len=%d [bad: < 8]", len)); + else { + mask = data + sizeof(struct in_addr); + ND_PRINT((ndo," 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: + if (len < 16) + ND_PRINT((ndo," len=%d [bad: < 16]", len)); + else + ND_PRINT((ndo," len=%d %s", len, ip6addr_string(data))); + len = 0; + break; + case IPSECDOI_ID_IPV6_ADDR_SUBNET: + { + const u_int32_t *mask; + if (len < 20) + ND_PRINT((ndo," len=%d [bad: < 20]", len)); + else { + mask = (u_int32_t *)(data + sizeof(struct in6_addr)); + /*XXX*/ + ND_PRINT((ndo," 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: + if (len < 8) + ND_PRINT((ndo," len=%d [bad: < 8]", len)); + else { + ND_PRINT((ndo," 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: + if (len < 32) + ND_PRINT((ndo," len=%d [bad: < 32]", len)); + else { + ND_PRINT((ndo," len=%d %s-%s", len, + ip6addr_string(data), + ip6addr_string(data + sizeof(struct in6_addr)))); + } + len = 0; + break; +#endif /*INET6*/ + case IPSECDOI_ID_DER_ASN1_DN: + case IPSECDOI_ID_DER_ASN1_GN: + case IPSECDOI_ID_KEY_ID: + break; + } + break; + } + } + if (data && len) { + ND_PRINT((ndo," len=%d", len)); + if (2 < ndo->ndo_vflag) { + ND_PRINT((ndo," ")); + if (!rawprint(ndo, (caddr_t)data, len)) + goto trunc; + } + } + return (u_char *)ext + item_len; +trunc: + ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_ID))); + return NULL; +} + +static const u_char * +ikev1_cert_print(netdissect_options *ndo, u_char tpay _U_, + const struct isakmp_gen *ext, u_int item_len _U_, + const u_char *ep _U_, u_int32_t phase _U_, + u_int32_t doi0 _U_, + u_int32_t proto0 _U_, int depth _U_) +{ + const struct ikev1_pl_cert *p; + struct ikev1_pl_cert cert; + static const char *certstr[] = { + "none", "pkcs7", "pgp", "dns", + "x509sign", "x509ke", "kerberos", "crl", + "arl", "spki", "x509attr", + }; + + ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_CERT))); + + p = (struct ikev1_pl_cert *)ext; + ND_TCHECK(*p); + safememcpy(&cert, ext, sizeof(cert)); + ND_PRINT((ndo," len=%d", item_len - 4)); + ND_PRINT((ndo," type=%s", STR_OR_ID((cert.encode), certstr))); + if (2 < ndo->ndo_vflag && 4 < item_len) { + ND_PRINT((ndo," ")); + if (!rawprint(ndo, (caddr_t)(ext + 1), item_len - 4)) + goto trunc; + } + return (u_char *)ext + item_len; +trunc: + ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_CERT))); + return NULL; +} + +static const u_char * +ikev1_cr_print(netdissect_options *ndo, u_char tpay _U_, + const struct isakmp_gen *ext, u_int item_len _U_, + const u_char *ep _U_, u_int32_t phase _U_, u_int32_t doi0 _U_, + u_int32_t proto0 _U_, int depth _U_) +{ + const struct ikev1_pl_cert *p; + struct ikev1_pl_cert cert; + static const char *certstr[] = { + "none", "pkcs7", "pgp", "dns", + "x509sign", "x509ke", "kerberos", "crl", + "arl", "spki", "x509attr", + }; + + ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_CR))); + + p = (struct ikev1_pl_cert *)ext; + ND_TCHECK(*p); + safememcpy(&cert, ext, sizeof(cert)); + ND_PRINT((ndo," len=%d", item_len - 4)); + ND_PRINT((ndo," type=%s", STR_OR_ID((cert.encode), certstr))); + if (2 < ndo->ndo_vflag && 4 < item_len) { + ND_PRINT((ndo," ")); + if (!rawprint(ndo, (caddr_t)(ext + 1), item_len - 4)) + goto trunc; + } + return (u_char *)ext + item_len; +trunc: + ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_CR))); + return NULL; +} + +static const u_char * +ikev1_hash_print(netdissect_options *ndo, u_char tpay _U_, + const struct isakmp_gen *ext, u_int item_len _U_, + const u_char *ep _U_, u_int32_t phase _U_, u_int32_t doi _U_, + u_int32_t proto _U_, int depth _U_) +{ + struct isakmp_gen e; + + ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_HASH))); + + ND_TCHECK(*ext); + safememcpy(&e, ext, sizeof(e)); + ND_PRINT((ndo," len=%d", ntohs(e.len) - 4)); + if (2 < ndo->ndo_vflag && 4 < ntohs(e.len)) { + ND_PRINT((ndo," ")); + if (!rawprint(ndo, (caddr_t)(ext + 1), ntohs(e.len) - 4)) + goto trunc; + } + return (u_char *)ext + ntohs(e.len); +trunc: + ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_HASH))); + return NULL; +} + +static const u_char * +ikev1_sig_print(netdissect_options *ndo, u_char tpay _U_, + const struct isakmp_gen *ext, u_int item_len _U_, + const u_char *ep _U_, u_int32_t phase _U_, u_int32_t doi _U_, + u_int32_t proto _U_, int depth _U_) +{ + struct isakmp_gen e; + + ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_SIG))); + + ND_TCHECK(*ext); + safememcpy(&e, ext, sizeof(e)); + ND_PRINT((ndo," len=%d", ntohs(e.len) - 4)); + if (2 < ndo->ndo_vflag && 4 < ntohs(e.len)) { + ND_PRINT((ndo," ")); + if (!rawprint(ndo, (caddr_t)(ext + 1), ntohs(e.len) - 4)) + goto trunc; + } + return (u_char *)ext + ntohs(e.len); +trunc: + ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_SIG))); + return NULL; +} + +static const u_char * +ikev1_nonce_print(netdissect_options *ndo, u_char tpay _U_, + const struct isakmp_gen *ext, + u_int item_len _U_, + const u_char *ep _U_, + u_int32_t phase _U_, u_int32_t doi _U_, + u_int32_t proto _U_, int depth _U_) +{ + struct isakmp_gen e; + + ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_NONCE))); + + ND_TCHECK(*ext); + safememcpy(&e, ext, sizeof(e)); + ND_PRINT((ndo," n len=%d", ntohs(e.len) - 4)); + if (2 < ndo->ndo_vflag && 4 < ntohs(e.len)) { + ND_PRINT((ndo," ")); + if (!rawprint(ndo, (caddr_t)(ext + 1), ntohs(e.len) - 4)) + goto trunc; + } else if (1 < ndo->ndo_vflag && 4 < ntohs(e.len)) { + ND_PRINT((ndo," ")); + if (!ike_show_somedata(ndo, (u_char *)(caddr_t)(ext + 1), ep)) + goto trunc; + } + return (u_char *)ext + ntohs(e.len); +trunc: + ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_NONCE))); + return NULL; +} + +static const u_char * +ikev1_n_print(netdissect_options *ndo, u_char tpay _U_, + 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 ikev1_pl_n *p, n; + const u_char *cp; + u_char *ep2; + u_int32_t doi; + u_int32_t proto; + static const char *notify_error_str[] = { + NULL, "INVALID-PAYLOAD-TYPE", + "DOI-NOT-SUPPORTED", "SITUATION-NOT-SUPPORTED", + "INVALID-COOKIE", "INVALID-MAJOR-VERSION", + "INVALID-MINOR-VERSION", "INVALID-EXCHANGE-TYPE", + "INVALID-FLAGS", "INVALID-MESSAGE-ID", + "INVALID-PROTOCOL-ID", "INVALID-SPI", + "INVALID-TRANSFORM-ID", "ATTRIBUTES-NOT-SUPPORTED", + "NO-PROPOSAL-CHOSEN", "BAD-PROPOSAL-SYNTAX", + "PAYLOAD-MALFORMED", "INVALID-KEY-INFORMATION", + "INVALID-ID-INFORMATION", "INVALID-CERT-ENCODING", + "INVALID-CERTIFICATE", "CERT-TYPE-UNSUPPORTED", + "INVALID-CERT-AUTHORITY", "INVALID-HASH-INFORMATION", + "AUTHENTICATION-FAILED", "INVALID-SIGNATURE", + "ADDRESS-NOTIFICATION", "NOTIFY-SA-LIFETIME", + "CERTIFICATE-UNAVAILABLE", "UNSUPPORTED-EXCHANGE-TYPE", + "UNEQUAL-PAYLOAD-LENGTHS", + }; + 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 */ + +/* 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) + + ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_N))); + + p = (struct ikev1_pl_n *)ext; + ND_TCHECK(*p); + safememcpy(&n, ext, sizeof(n)); + doi = ntohl(n.doi); + proto = n.prot_id; + if (doi != 1) { + ND_PRINT((ndo," doi=%d", doi)); + ND_PRINT((ndo," proto=%d", proto)); + if (ntohs(n.type) < 8192) + ND_PRINT((ndo," type=%s", NOTIFY_ERROR_STR(ntohs(n.type)))); + else if (ntohs(n.type) < 16384) + ND_PRINT((ndo," type=%s", numstr(ntohs(n.type)))); + else if (ntohs(n.type) < 24576) + ND_PRINT((ndo," type=%s", NOTIFY_STATUS_STR(ntohs(n.type)))); + else + ND_PRINT((ndo," type=%s", numstr(ntohs(n.type)))); + if (n.spi_size) { + ND_PRINT((ndo," spi=")); + if (!rawprint(ndo, (caddr_t)(p + 1), n.spi_size)) + goto trunc; + } + return (u_char *)(p + 1) + n.spi_size; + } + + ND_PRINT((ndo," doi=ipsec")); + ND_PRINT((ndo," proto=%s", PROTOIDSTR(proto))); + if (ntohs(n.type) < 8192) + ND_PRINT((ndo," type=%s", NOTIFY_ERROR_STR(ntohs(n.type)))); + else if (ntohs(n.type) < 16384) + ND_PRINT((ndo," type=%s", IPSEC_NOTIFY_ERROR_STR(ntohs(n.type)))); + else if (ntohs(n.type) < 24576) + ND_PRINT((ndo," type=%s", NOTIFY_STATUS_STR(ntohs(n.type)))); + else if (ntohs(n.type) < 32768) + ND_PRINT((ndo," type=%s", IPSEC_NOTIFY_STATUS_STR(ntohs(n.type)))); + else + ND_PRINT((ndo," type=%s", numstr(ntohs(n.type)))); + if (n.spi_size) { + ND_PRINT((ndo," spi=")); + if (!rawprint(ndo, (caddr_t)(p + 1), n.spi_size)) + goto trunc; + } + + cp = (u_char *)(p + 1) + n.spi_size; + ep2 = (u_char *)p + item_len; + + if (cp < ep) { + ND_PRINT((ndo," orig=(")); + switch (ntohs(n.type)) { + case IPSECDOI_NTYPE_RESPONDER_LIFETIME: + { + 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 = ikev1_attrmap_print(ndo, cp, + (ep < ep2) ? ep : ep2, map, nmap); + } + break; + } + case IPSECDOI_NTYPE_REPLAY_STATUS: + ND_PRINT((ndo,"replay detection %sabled", + (*(u_int32_t *)cp) ? "en" : "dis")); + break; + case ISAKMP_NTYPE_NO_PROPOSAL_CHOSEN: + if (ikev1_sub_print(ndo, ISAKMP_NPTYPE_SA, + (struct isakmp_gen *)cp, ep, phase, doi, proto, + depth) == NULL) + return NULL; + break; + default: + /* NULL is dummy */ + isakmp_print(ndo, cp, + item_len - sizeof(*p) - n.spi_size, + NULL); + } + ND_PRINT((ndo,")")); + } + return (u_char *)ext + item_len; +trunc: + ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_N))); + return NULL; +} + +static const u_char * +ikev1_d_print(netdissect_options *ndo, u_char tpay _U_, + const struct isakmp_gen *ext, u_int item_len _U_, + const u_char *ep _U_, u_int32_t phase _U_, u_int32_t doi0 _U_, + u_int32_t proto0 _U_, int depth _U_) +{ + const struct ikev1_pl_d *p; + struct ikev1_pl_d d; + const u_int8_t *q; + u_int32_t doi; + u_int32_t proto; + int i; + + ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_D))); + + p = (struct ikev1_pl_d *)ext; + ND_TCHECK(*p); + safememcpy(&d, ext, sizeof(d)); + doi = ntohl(d.doi); + proto = d.prot_id; + if (doi != 1) { + ND_PRINT((ndo," doi=%u", doi)); + ND_PRINT((ndo," proto=%u", proto)); + } else { + ND_PRINT((ndo," doi=ipsec")); + ND_PRINT((ndo," proto=%s", PROTOIDSTR(proto))); + } + ND_PRINT((ndo," spilen=%u", d.spi_size)); + ND_PRINT((ndo," nspi=%u", ntohs(d.num_spi))); + ND_PRINT((ndo," spi=")); + q = (u_int8_t *)(p + 1); + for (i = 0; i < ntohs(d.num_spi); i++) { + if (i != 0) + ND_PRINT((ndo,",")); + if (!rawprint(ndo, (caddr_t)q, d.spi_size)) + goto trunc; + q += d.spi_size; + } + return q; +trunc: + ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_D))); + return NULL; +} + +static const u_char * +ikev1_vid_print(netdissect_options *ndo, u_char tpay _U_, + const struct isakmp_gen *ext, + u_int item_len _U_, const u_char *ep _U_, + u_int32_t phase _U_, u_int32_t doi _U_, + u_int32_t proto _U_, int depth _U_) +{ + struct isakmp_gen e; + + ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_VID))); + + ND_TCHECK(*ext); + safememcpy(&e, ext, sizeof(e)); + ND_PRINT((ndo," len=%d", ntohs(e.len) - 4)); + if (2 < ndo->ndo_vflag && 4 < ntohs(e.len)) { + ND_PRINT((ndo," ")); + if (!rawprint(ndo, (caddr_t)(ext + 1), ntohs(e.len) - 4)) + goto trunc; + } + return (u_char *)ext + ntohs(e.len); +trunc: + ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_VID))); + return NULL; +} + +/************************************************************/ +/* */ +/* IKE v2 - rfc4306 - dissector */ +/* */ +/************************************************************/ + +static void +ikev2_pay_print(netdissect_options *ndo, const char *payname, int critical) +{ + ND_PRINT((ndo,"%s%s:", payname, critical&0x80 ? "[C]" : "")); +} + +static const u_char * +ikev2_gen_print(netdissect_options *ndo, u_char tpay, + const struct isakmp_gen *ext) +{ + struct isakmp_gen e; + + ND_TCHECK(*ext); + safememcpy(&e, ext, sizeof(e)); + ikev2_pay_print(ndo, NPSTR(tpay), e.critical); + + ND_PRINT((ndo," len=%d", ntohs(e.len) - 4)); + if (2 < ndo->ndo_vflag && 4 < ntohs(e.len)) { + ND_PRINT((ndo," ")); + if (!rawprint(ndo, (caddr_t)(ext + 1), ntohs(e.len) - 4)) + goto trunc; + } + return (u_char *)ext + ntohs(e.len); +trunc: + ND_PRINT((ndo," [|%s]", NPSTR(tpay))); + return NULL; +} + +static const u_char * +ikev2_t_print(netdissect_options *ndo, u_char tpay _U_, int pcount, + 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_) +{ + const struct ikev2_t *p; + struct ikev2_t t; + u_int16_t t_id; + const u_char *cp; + const char *idstr; + const struct attrmap *map; + size_t nmap; + const u_char *ep2; + + p = (struct ikev2_t *)ext; + ND_TCHECK(*p); + safememcpy(&t, ext, sizeof(t)); + ikev2_pay_print(ndo, NPSTR(ISAKMP_NPTYPE_T), t.h.critical); + + t_id = ntohs(t.t_id); + + map = NULL; + nmap = 0; + + switch (t.t_type) { + case IV2_T_ENCR: + idstr = STR_OR_ID(t_id, esp_p_map); + map = encr_t_map; + nmap = sizeof(encr_t_map)/sizeof(encr_t_map[0]); + break; + + case IV2_T_PRF: + idstr = STR_OR_ID(t_id, prf_p_map); + break; + + case IV2_T_INTEG: + idstr = STR_OR_ID(t_id, integ_p_map); + break; + + case IV2_T_DH: + idstr = STR_OR_ID(t_id, dh_p_map); + break; + + case IV2_T_ESN: + idstr = STR_OR_ID(t_id, esn_p_map); + break; + + default: + idstr = NULL; + break; + } + + if (idstr) + ND_PRINT((ndo," #%u type=%s id=%s ", pcount, + STR_OR_ID(t.t_type, ikev2_t_type_map), + idstr)); + else + ND_PRINT((ndo," #%u type=%s id=%u ", pcount, + STR_OR_ID(t.t_type, ikev2_t_type_map), + t.t_id)); + cp = (u_char *)(p + 1); + ep2 = (u_char *)p + item_len; + while (cp < ep && cp < ep2) { + if (map && nmap) { + cp = ikev1_attrmap_print(ndo, cp, (ep < ep2) ? ep : ep2, + map, nmap); + } else + cp = ikev1_attr_print(ndo, cp, (ep < ep2) ? ep : ep2); + } + if (ep < ep2) + ND_PRINT((ndo,"...")); + return cp; +trunc: + ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_T))); + return NULL; +} + +static const u_char * +ikev2_p_print(netdissect_options *ndo, u_char tpay _U_, int pcount _U_, + const struct isakmp_gen *ext, u_int item_len _U_, + const u_char *ep, u_int32_t phase, u_int32_t doi0, + u_int32_t proto0 _U_, int depth) +{ + const struct ikev2_p *p; + struct ikev2_p prop; + const u_char *cp; + + p = (struct ikev2_p *)ext; + ND_TCHECK(*p); + safememcpy(&prop, ext, sizeof(prop)); + ikev2_pay_print(ndo, NPSTR(ISAKMP_NPTYPE_P), prop.h.critical); + + ND_PRINT((ndo," #%u protoid=%s transform=%d len=%u", + prop.p_no, PROTOIDSTR(prop.prot_id), + prop.num_t, ntohs(prop.h.len))); + if (prop.spi_size) { + ND_PRINT((ndo," spi=")); + if (!rawprint(ndo, (caddr_t)(p + 1), prop.spi_size)) + goto trunc; + } + + ext = (struct isakmp_gen *)((u_char *)(p + 1) + prop.spi_size); + ND_TCHECK(*ext); + + cp = ikev2_sub_print(ndo, NULL, ISAKMP_NPTYPE_T, ext, ep, phase, doi0, + prop.prot_id, depth); + + return cp; +trunc: + ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_P))); + return NULL; +} + +static const u_char * +ikev2_sa_print(netdissect_options *ndo, u_char tpay, + const struct isakmp_gen *ext1, + u_int item_len _U_, const u_char *ep _U_, + u_int32_t phase _U_, u_int32_t doi _U_, + u_int32_t proto _U_, int depth _U_) +{ + struct isakmp_gen e; + int osa_length, sa_length; + + ND_TCHECK(*ext1); + safememcpy(&e, ext1, sizeof(e)); + ikev2_pay_print(ndo, "sa", e.critical); + + osa_length= ntohs(e.len); + sa_length = osa_length - 4; + ND_PRINT((ndo," len=%d", sa_length)); + + ikev2_sub_print(ndo, NULL, ISAKMP_NPTYPE_P, + ext1+1, ep, + 0, 0, 0, depth); + + return (u_char *)ext1 + osa_length; +trunc: + ND_PRINT((ndo," [|%s]", NPSTR(tpay))); + return NULL; +} + +static const u_char * +ikev2_ke_print(netdissect_options *ndo, u_char tpay, + const struct isakmp_gen *ext, + u_int item_len _U_, const u_char *ep _U_, + u_int32_t phase _U_, u_int32_t doi _U_, + u_int32_t proto _U_, int depth _U_) +{ + struct ikev2_ke ke; + struct ikev2_ke *k; + + k = (struct ikev2_ke *)ext; + ND_TCHECK(*ext); + safememcpy(&ke, ext, sizeof(ke)); + ikev2_pay_print(ndo, NPSTR(tpay), ke.h.critical); + + ND_PRINT((ndo," len=%u group=%s", ntohs(ke.h.len) - 8, + STR_OR_ID(ntohs(ke.ke_group), dh_p_map))); + + if (2 < ndo->ndo_vflag && 8 < ntohs(ke.h.len)) { + ND_PRINT((ndo," ")); + if (!rawprint(ndo, (caddr_t)(k + 1), ntohs(ke.h.len) - 8)) + goto trunc; + } + return (u_char *)ext + ntohs(ke.h.len); +trunc: + ND_PRINT((ndo," [|%s]", NPSTR(tpay))); + return NULL; +} + +static const u_char * +ikev2_ID_print(netdissect_options *ndo, u_char tpay, + const struct isakmp_gen *ext, + u_int item_len _U_, const u_char *ep _U_, + u_int32_t phase _U_, u_int32_t doi _U_, + u_int32_t proto _U_, int depth _U_) +{ + struct ikev2_id id; + int id_len, idtype_len, i; + unsigned int dumpascii, dumphex; + unsigned char *typedata; + + ND_TCHECK(*ext); + safememcpy(&id, ext, sizeof(id)); + ikev2_pay_print(ndo, NPSTR(tpay), id.h.critical); + + id_len = ntohs(id.h.len); + + ND_PRINT((ndo," len=%d", id_len - 4)); + if (2 < ndo->ndo_vflag && 4 < id_len) { + ND_PRINT((ndo," ")); + if (!rawprint(ndo, (caddr_t)(ext + 1), id_len - 4)) + goto trunc; + } + + idtype_len =id_len - sizeof(struct ikev2_id); + dumpascii = 0; + dumphex = 0; + typedata = (unsigned char *)(ext)+sizeof(struct ikev2_id); + + switch(id.type) { + case ID_IPV4_ADDR: + ND_PRINT((ndo, " ipv4:")); + dumphex=1; + break; + case ID_FQDN: + ND_PRINT((ndo, " fqdn:")); + dumpascii=1; + break; + case ID_RFC822_ADDR: + ND_PRINT((ndo, " rfc822:")); + dumpascii=1; + break; + case ID_IPV6_ADDR: + ND_PRINT((ndo, " ipv6:")); + dumphex=1; + break; + case ID_DER_ASN1_DN: + ND_PRINT((ndo, " dn:")); + dumphex=1; + break; + case ID_DER_ASN1_GN: + ND_PRINT((ndo, " gn:")); + dumphex=1; + break; + case ID_KEY_ID: + ND_PRINT((ndo, " keyid:")); + dumphex=1; + break; + } + + if(dumpascii) { + ND_TCHECK2(*typedata, idtype_len); + for(i=0; i<idtype_len; i++) { + if(isprint(typedata[i])) { + ND_PRINT((ndo, "%c", typedata[i])); + } else { + ND_PRINT((ndo, ".")); + } + } + } + if(dumphex) { + if (!rawprint(ndo, (caddr_t)typedata, idtype_len)) + goto trunc; + } + + return (u_char *)ext + id_len; +trunc: + ND_PRINT((ndo," [|%s]", NPSTR(tpay))); + return NULL; +} + +static const u_char * +ikev2_cert_print(netdissect_options *ndo, u_char tpay, + const struct isakmp_gen *ext, + u_int item_len _U_, const u_char *ep _U_, + u_int32_t phase _U_, u_int32_t doi _U_, + u_int32_t proto _U_, int depth _U_) +{ + return ikev2_gen_print(ndo, tpay, ext); +} + +static const u_char * +ikev2_cr_print(netdissect_options *ndo, u_char tpay, + const struct isakmp_gen *ext, + u_int item_len _U_, const u_char *ep _U_, + u_int32_t phase _U_, u_int32_t doi _U_, + u_int32_t proto _U_, int depth _U_) +{ + return ikev2_gen_print(ndo, tpay, ext); +} + +static const u_char * +ikev2_auth_print(netdissect_options *ndo, u_char tpay, + const struct isakmp_gen *ext, + u_int item_len _U_, const u_char *ep _U_, + u_int32_t phase _U_, u_int32_t doi _U_, + u_int32_t proto _U_, int depth _U_) +{ + struct ikev2_auth a; + const char *v2_auth[]={ "invalid", "rsasig", + "shared-secret", "dsssig" }; + u_char *authdata = (u_char*)ext + sizeof(a); + unsigned int len; + + ND_TCHECK(*ext); + safememcpy(&a, ext, sizeof(a)); + ikev2_pay_print(ndo, NPSTR(tpay), a.h.critical); + len = ntohs(a.h.len); + + ND_PRINT((ndo," len=%d method=%s", len-4, + STR_OR_ID(a.auth_method, v2_auth))); + + if (1 < ndo->ndo_vflag && 4 < len) { + ND_PRINT((ndo," authdata=(")); + if (!rawprint(ndo, (caddr_t)authdata, len - sizeof(a))) + goto trunc; + ND_PRINT((ndo,") ")); + } else if(ndo->ndo_vflag && 4 < len) { + if(!ike_show_somedata(ndo, authdata, ep)) goto trunc; + } + + return (u_char *)ext + len; +trunc: + ND_PRINT((ndo," [|%s]", NPSTR(tpay))); + return NULL; +} + +static const u_char * +ikev2_nonce_print(netdissect_options *ndo, u_char tpay, + const struct isakmp_gen *ext, + u_int item_len _U_, const u_char *ep _U_, + u_int32_t phase _U_, u_int32_t doi _U_, + u_int32_t proto _U_, int depth _U_) +{ + struct isakmp_gen e; + + ND_TCHECK(*ext); + safememcpy(&e, ext, sizeof(e)); + ikev2_pay_print(ndo, "nonce", e.critical); + + ND_PRINT((ndo," len=%d", ntohs(e.len) - 4)); + if (1 < ndo->ndo_vflag && 4 < ntohs(e.len)) { + ND_PRINT((ndo," nonce=(")); + if (!rawprint(ndo, (caddr_t)(ext + 1), ntohs(e.len) - 4)) + goto trunc; + ND_PRINT((ndo,") ")); + } else if(ndo->ndo_vflag && 4 < ntohs(e.len)) { + if(!ike_show_somedata(ndo, (const u_char *)(ext+1), ep)) goto trunc; + } + + return (u_char *)ext + ntohs(e.len); +trunc: + ND_PRINT((ndo," [|%s]", NPSTR(tpay))); + return NULL; +} + +/* notify payloads */ +static const u_char * +ikev2_n_print(netdissect_options *ndo, u_char tpay _U_, + const struct isakmp_gen *ext, + u_int item_len _U_, const u_char *ep _U_, + u_int32_t phase _U_, u_int32_t doi _U_, + u_int32_t proto _U_, int depth _U_) +{ + struct ikev2_n *p, n; + const u_char *cp; + u_char *ep2; + u_char showspi, showdata, showsomedata; + const char *notify_name; + u_int32_t type; + + p = (struct ikev2_n *)ext; + ND_TCHECK(*p); + safememcpy(&n, ext, sizeof(n)); + ikev2_pay_print(ndo, NPSTR(ISAKMP_NPTYPE_N), n.h.critical); + + showspi = 1; + showdata = 0; + showsomedata=0; + notify_name=NULL; + + ND_PRINT((ndo," prot_id=%s", PROTOIDSTR(n.prot_id))); + + type = ntohs(n.type); + + /* notify space is annoying sparse */ + switch(type) { + case IV2_NOTIFY_UNSUPPORTED_CRITICAL_PAYLOAD: + notify_name = "unsupported_critical_payload"; + showspi = 0; + break; + + case IV2_NOTIFY_INVALID_IKE_SPI: + notify_name = "invalid_ike_spi"; + showspi = 1; + break; + + case IV2_NOTIFY_INVALID_MAJOR_VERSION: + notify_name = "invalid_major_version"; + showspi = 0; + break; + + case IV2_NOTIFY_INVALID_SYNTAX: + notify_name = "invalid_syntax"; + showspi = 1; + break; + + case IV2_NOTIFY_INVALID_MESSAGE_ID: + notify_name = "invalid_message_id"; + showspi = 1; + break; + + case IV2_NOTIFY_INVALID_SPI: + notify_name = "invalid_spi"; + showspi = 1; + break; + + case IV2_NOTIFY_NO_PROPOSAL_CHOSEN: + notify_name = "no_protocol_chosen"; + showspi = 1; + break; + + case IV2_NOTIFY_INVALID_KE_PAYLOAD: + notify_name = "invalid_ke_payload"; + showspi = 1; + break; + + case IV2_NOTIFY_AUTHENTICATION_FAILED: + notify_name = "authentication_failed"; + showspi = 1; + break; + + case IV2_NOTIFY_SINGLE_PAIR_REQUIRED: + notify_name = "single_pair_required"; + showspi = 1; + break; + + case IV2_NOTIFY_NO_ADDITIONAL_SAS: + notify_name = "no_additional_sas"; + showspi = 0; + break; + + case IV2_NOTIFY_INTERNAL_ADDRESS_FAILURE: + notify_name = "internal_address_failure"; + showspi = 0; + break; + + case IV2_NOTIFY_FAILED_CP_REQUIRED: + notify_name = "failed:cp_required"; + showspi = 0; + break; + + case IV2_NOTIFY_INVALID_SELECTORS: + notify_name = "invalid_selectors"; + showspi = 0; + break; + + case IV2_NOTIFY_INITIAL_CONTACT: + notify_name = "initial_contact"; + showspi = 0; + break; + + case IV2_NOTIFY_SET_WINDOW_SIZE: + notify_name = "set_window_size"; + showspi = 0; + break; + + case IV2_NOTIFY_ADDITIONAL_TS_POSSIBLE: + notify_name = "additional_ts_possible"; + showspi = 0; + break; + + case IV2_NOTIFY_IPCOMP_SUPPORTED: + notify_name = "ipcomp_supported"; + showspi = 0; + break; + + case IV2_NOTIFY_NAT_DETECTION_SOURCE_IP: + notify_name = "nat_detection_source_ip"; + showspi = 1; + break; + + case IV2_NOTIFY_NAT_DETECTION_DESTINATION_IP: + notify_name = "nat_detection_destination_ip"; + showspi = 1; + break; + + case IV2_NOTIFY_COOKIE: + notify_name = "cookie"; + showspi = 1; + showsomedata= 1; + showdata= 0; + break; + + case IV2_NOTIFY_USE_TRANSPORT_MODE: + notify_name = "use_transport_mode"; + showspi = 0; + break; + + case IV2_NOTIFY_HTTP_CERT_LOOKUP_SUPPORTED: + notify_name = "http_cert_lookup_supported"; + showspi = 0; + break; + + case IV2_NOTIFY_REKEY_SA: + notify_name = "rekey_sa"; + showspi = 1; + break; + + case IV2_NOTIFY_ESP_TFC_PADDING_NOT_SUPPORTED: + notify_name = "tfc_padding_not_supported"; + showspi = 0; + break; + + case IV2_NOTIFY_NON_FIRST_FRAGMENTS_ALSO: + notify_name = "non_first_fragment_also"; + showspi = 0; + break; + + default: + if (type < 8192) { + notify_name="error"; + } else if(type < 16384) { + notify_name="private-error"; + } else if(type < 40960) { + notify_name="status"; + } else { + notify_name="private-status"; + } + } + + if(notify_name) { + ND_PRINT((ndo," type=%u(%s)", type, notify_name)); + } + + + if (showspi && n.spi_size) { + ND_PRINT((ndo," spi=")); + if (!rawprint(ndo, (caddr_t)(p + 1), n.spi_size)) + goto trunc; + } + + cp = (u_char *)(p + 1) + n.spi_size; + ep2 = (u_char *)p + item_len; + + if(3 < ndo->ndo_vflag) { + showdata = 1; + } + + if ((showdata || (showsomedata && ep-cp < 30)) && cp < ep) { + ND_PRINT((ndo," data=(")); + if (!rawprint(ndo, (caddr_t)(cp), ep - cp)) + goto trunc; + + ND_PRINT((ndo,")")); + + } else if(showsomedata && cp < ep) { + if(!ike_show_somedata(ndo, cp, ep)) goto trunc; + } + + return (u_char *)ext + item_len; +trunc: + ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_N))); + return NULL; +} + +static const u_char * +ikev2_d_print(netdissect_options *ndo, u_char tpay, + const struct isakmp_gen *ext, + u_int item_len _U_, const u_char *ep _U_, + u_int32_t phase _U_, u_int32_t doi _U_, + u_int32_t proto _U_, int depth _U_) +{ + return ikev2_gen_print(ndo, tpay, ext); +} + +static const u_char * +ikev2_vid_print(netdissect_options *ndo, u_char tpay, + const struct isakmp_gen *ext, + u_int item_len _U_, const u_char *ep _U_, + u_int32_t phase _U_, u_int32_t doi _U_, + u_int32_t proto _U_, int depth _U_) +{ + struct isakmp_gen e; + const u_char *vid; + int i, len; + + ND_TCHECK(*ext); + safememcpy(&e, ext, sizeof(e)); + ikev2_pay_print(ndo, NPSTR(tpay), e.critical); + ND_PRINT((ndo," len=%d vid=", ntohs(e.len) - 4)); + + vid = (const u_char *)(ext+1); + len = ntohs(e.len) - 4; + ND_TCHECK2(*vid, len); + for(i=0; i<len; i++) { + if(isprint(vid[i])) ND_PRINT((ndo, "%c", vid[i])); + else ND_PRINT((ndo, ".")); + } + if (2 < ndo->ndo_vflag && 4 < len) { + ND_PRINT((ndo," ")); + if (!rawprint(ndo, (caddr_t)(ext + 1), ntohs(e.len) - 4)) + goto trunc; + } + return (u_char *)ext + ntohs(e.len); +trunc: + ND_PRINT((ndo," [|%s]", NPSTR(tpay))); + return NULL; +} + +static const u_char * +ikev2_TS_print(netdissect_options *ndo, u_char tpay, + const struct isakmp_gen *ext, + u_int item_len _U_, const u_char *ep _U_, + u_int32_t phase _U_, u_int32_t doi _U_, + u_int32_t proto _U_, int depth _U_) +{ + return ikev2_gen_print(ndo, tpay, ext); +} + +static const u_char * +ikev2_e_print(netdissect_options *ndo, +#ifndef HAVE_LIBCRYPTO + _U_ +#endif + struct isakmp *base, + u_char tpay, + const struct isakmp_gen *ext, + u_int item_len _U_, const u_char *ep _U_, +#ifndef HAVE_LIBCRYPTO + _U_ +#endif + u_int32_t phase, +#ifndef HAVE_LIBCRYPTO + _U_ +#endif + u_int32_t doi, +#ifndef HAVE_LIBCRYPTO + _U_ +#endif + u_int32_t proto, +#ifndef HAVE_LIBCRYPTO + _U_ +#endif + int depth) +{ + struct isakmp_gen e; + u_char *dat; + volatile int dlen; + + ND_TCHECK(*ext); + safememcpy(&e, ext, sizeof(e)); + ikev2_pay_print(ndo, NPSTR(tpay), e.critical); + + dlen = ntohs(e.len)-4; + + ND_PRINT((ndo," len=%d", dlen)); + if (2 < ndo->ndo_vflag && 4 < dlen) { + ND_PRINT((ndo," ")); + if (!rawprint(ndo, (caddr_t)(ext + 1), dlen)) + goto trunc; + } + + dat = (u_char *)(ext+1); + ND_TCHECK2(*dat, dlen); + +#ifdef HAVE_LIBCRYPTO + /* try to decypt it! */ + if(esp_print_decrypt_buffer_by_ikev2(ndo, + base->flags & ISAKMP_FLAG_I, + base->i_ck, base->r_ck, + dat, dat+dlen)) { + + ext = (const struct isakmp_gen *)ndo->ndo_packetp; + + /* got it decrypted, print stuff inside. */ + ikev2_sub_print(ndo, base, e.np, ext, ndo->ndo_snapend, + phase, doi, proto, depth+1); + } +#endif + + + /* always return NULL, because E must be at end, and NP refers + * to what was inside. + */ + return NULL; +trunc: + ND_PRINT((ndo," [|%s]", NPSTR(tpay))); + return NULL; +} + +static const u_char * +ikev2_cp_print(netdissect_options *ndo, u_char tpay, + const struct isakmp_gen *ext, + u_int item_len _U_, const u_char *ep _U_, + u_int32_t phase _U_, u_int32_t doi _U_, + u_int32_t proto _U_, int depth _U_) +{ + return ikev2_gen_print(ndo, tpay, ext); +} + +static const u_char * +ikev2_eap_print(netdissect_options *ndo, u_char tpay, + const struct isakmp_gen *ext, + u_int item_len _U_, const u_char *ep _U_, + u_int32_t phase _U_, u_int32_t doi _U_, + u_int32_t proto _U_, int depth _U_) +{ + return ikev2_gen_print(ndo, tpay, ext); +} + +static const u_char * +ike_sub0_print(netdissect_options *ndo, + u_char np, const struct isakmp_gen *ext, const u_char *ep, + + u_int32_t phase, u_int32_t doi, u_int32_t proto, int depth) +{ + const u_char *cp; + struct isakmp_gen e; + u_int item_len; + + cp = (u_char *)ext; + ND_TCHECK(*ext); + safememcpy(&e, ext, sizeof(e)); + + /* + * 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])(ndo, np, ext, item_len, ep, phase, doi, proto, depth); + } else { + ND_PRINT((ndo,"%s", NPSTR(np))); + cp += item_len; + } + + return cp; +trunc: + ND_PRINT((ndo," [|isakmp]")); + return NULL; +} + +static const u_char * +ikev1_sub_print(netdissect_options *ndo, + u_char np, const struct isakmp_gen *ext, const u_char *ep, + u_int32_t phase, u_int32_t doi, u_int32_t proto, int depth) +{ + const u_char *cp; + int i; + struct isakmp_gen e; + + cp = (const u_char *)ext; + + while (np) { + ND_TCHECK(*ext); + + safememcpy(&e, ext, sizeof(e)); + + ND_TCHECK2(*ext, ntohs(e.len)); + + depth++; + ND_PRINT((ndo,"\n")); + for (i = 0; i < depth; i++) + ND_PRINT((ndo," ")); + ND_PRINT((ndo,"(")); + cp = ike_sub0_print(ndo, np, ext, ep, phase, doi, proto, depth); + ND_PRINT((ndo,")")); + depth--; + + if (cp == NULL) { + /* Zero-length subitem */ + return NULL; + } + + np = e.np; + ext = (struct isakmp_gen *)cp; + } + return cp; +trunc: + ND_PRINT((ndo," [|%s]", NPSTR(np))); + return NULL; +} + +static char * +numstr(int x) +{ + static char buf[20]; + snprintf(buf, sizeof(buf), "#%d", x); + return buf; +} + +/* + * some compiler tries to optimize memcpy(), using the alignment constraint + * on the argument pointer type. by using this function, we try to avoid the + * optimization. + */ +static void +safememcpy(void *p, const void *q, size_t l) +{ + memcpy(p, q, l); +} + +static void +ikev1_print(netdissect_options *ndo, + const u_char *bp, u_int length, + const u_char *bp2, struct isakmp *base) +{ + const struct isakmp *p; + const u_char *ep; + u_char np; + int i; + int phase; + + p = (const struct isakmp *)bp; + ep = ndo->ndo_snapend; + + phase = (*(u_int32_t *)base->msgid == 0) ? 1 : 2; + if (phase == 1) + ND_PRINT((ndo," phase %d", phase)); + else + ND_PRINT((ndo," phase %d/others", phase)); + + i = cookie_find(&base->i_ck); + if (i < 0) { + if (iszero((u_char *)&base->r_ck, sizeof(base->r_ck))) { + /* the first packet */ + ND_PRINT((ndo," I")); + if (bp2) + cookie_record(&base->i_ck, bp2); + } else + ND_PRINT((ndo," ?")); + } else { + if (bp2 && cookie_isinitiator(i, bp2)) + ND_PRINT((ndo," I")); + else if (bp2 && cookie_isresponder(i, bp2)) + ND_PRINT((ndo," R")); + else + ND_PRINT((ndo," ?")); + } + + ND_PRINT((ndo," %s", ETYPESTR(base->etype))); + if (base->flags) { + ND_PRINT((ndo,"[%s%s]", base->flags & ISAKMP_FLAG_E ? "E" : "", + base->flags & ISAKMP_FLAG_C ? "C" : "")); + } + + if (ndo->ndo_vflag) { + const struct isakmp_gen *ext; + int nparen; + + ND_PRINT((ndo,":")); + + /* 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... + */ + ND_PRINT((ndo," [encrypted %s]", NPSTR(base->np))); + goto done; + } + + nparen = 0; + CHECKLEN(p + 1, base->np); + np = base->np; + ext = (struct isakmp_gen *)(p + 1); + ikev1_sub_print(ndo, np, ext, ep, phase, 0, 0, 0); + } + +done: + if (ndo->ndo_vflag) { + if (ntohl(base->len) != length) { + ND_PRINT((ndo," (len mismatch: isakmp %u/ip %u)", + (u_int32_t)ntohl(base->len), length)); + } + } +} + +static const u_char * +ikev2_sub0_print(netdissect_options *ndo, struct isakmp *base, + u_char np, int pcount, + const struct isakmp_gen *ext, const u_char *ep, + u_int32_t phase, u_int32_t doi, u_int32_t proto, int depth) +{ + const u_char *cp; + struct isakmp_gen e; + u_int item_len; + + cp = (u_char *)ext; + ND_TCHECK(*ext); + safememcpy(&e, ext, sizeof(e)); + + /* + * 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(np == ISAKMP_NPTYPE_P) { + cp = ikev2_p_print(ndo, np, pcount, ext, item_len, + ep, phase, doi, proto, depth); + } else if(np == ISAKMP_NPTYPE_T) { + cp = ikev2_t_print(ndo, np, pcount, ext, item_len, + ep, phase, doi, proto, depth); + } else if(np == ISAKMP_NPTYPE_v2E) { + cp = ikev2_e_print(ndo, base, np, ext, item_len, + ep, phase, doi, proto, depth); + } else if (NPFUNC(np)) { + /* + * XXX - what if item_len is too short, or too long, + * for this payload type? + */ + cp = (*npfunc[np])(ndo, np, /*pcount,*/ ext, item_len, + ep, phase, doi, proto, depth); + } else { + ND_PRINT((ndo,"%s", NPSTR(np))); + cp += item_len; + } + + return cp; +trunc: + ND_PRINT((ndo," [|isakmp]")); + return NULL; +} + +static const u_char * +ikev2_sub_print(netdissect_options *ndo, + struct isakmp *base, + u_char np, const struct isakmp_gen *ext, const u_char *ep, + u_int32_t phase, u_int32_t doi, u_int32_t proto, int depth) +{ + const u_char *cp; + int i; + int pcount; + struct isakmp_gen e; + + cp = (const u_char *)ext; + pcount = 0; + while (np) { + pcount++; + ND_TCHECK(*ext); + + safememcpy(&e, ext, sizeof(e)); + + ND_TCHECK2(*ext, ntohs(e.len)); + + depth++; + ND_PRINT((ndo,"\n")); + for (i = 0; i < depth; i++) + ND_PRINT((ndo," ")); + ND_PRINT((ndo,"(")); + cp = ikev2_sub0_print(ndo, base, np, pcount, + ext, ep, phase, doi, proto, depth); + ND_PRINT((ndo,")")); + depth--; + + if (cp == NULL) { + /* Zero-length subitem */ + return NULL; + } + + np = e.np; + ext = (struct isakmp_gen *)cp; + } + return cp; +trunc: + ND_PRINT((ndo," [|%s]", NPSTR(np))); + return NULL; +} + +static void +ikev2_print(netdissect_options *ndo, + const u_char *bp, u_int length, + const u_char *bp2 _U_, struct isakmp *base) +{ + const struct isakmp *p; + const u_char *ep; + u_char np; + int phase; + + p = (const struct isakmp *)bp; + ep = ndo->ndo_snapend; + + phase = (*(u_int32_t *)base->msgid == 0) ? 1 : 2; + if (phase == 1) + ND_PRINT((ndo, " parent_sa")); + else + ND_PRINT((ndo, " child_sa ")); + + ND_PRINT((ndo, " %s", ETYPESTR(base->etype))); + if (base->flags) { + ND_PRINT((ndo, "[%s%s%s]", + base->flags & ISAKMP_FLAG_I ? "I" : "", + base->flags & ISAKMP_FLAG_V ? "V" : "", + base->flags & ISAKMP_FLAG_R ? "R" : "")); + } + + if (ndo->ndo_vflag) { + const struct isakmp_gen *ext; + int nparen; + + ND_PRINT((ndo, ":")); + + /* 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... + */ + ND_PRINT((ndo, " [encrypted %s]", NPSTR(base->np))); + goto done; + } + + nparen = 0; + CHECKLEN(p + 1, base->np) + + np = base->np; + ext = (struct isakmp_gen *)(p + 1); + ikev2_sub_print(ndo, base, np, ext, ep, phase, 0, 0, 0); + } + +done: + if (ndo->ndo_vflag) { + if (ntohl(base->len) != length) { + ND_PRINT((ndo, " (len mismatch: isakmp %u/ip %u)", + (u_int32_t)ntohl(base->len), length)); + } + } +} + +void +isakmp_print(netdissect_options *ndo, + const u_char *bp, u_int length, + const u_char *bp2) +{ + const struct isakmp *p; + struct isakmp base; + const u_char *ep; + int major, minor; + +#ifdef HAVE_LIBCRYPTO + /* initialize SAs */ + if (ndo->ndo_sa_list_head == NULL) { + if (ndo->ndo_espsecret) + esp_print_decodesecret(ndo); + } +#endif + + p = (const struct isakmp *)bp; + ep = ndo->ndo_snapend; + + if ((struct isakmp *)ep < p + 1) { + ND_PRINT((ndo,"[|isakmp]")); + return; + } + + safememcpy(&base, p, sizeof(base)); + + ND_PRINT((ndo,"isakmp")); + major = (base.vers & ISAKMP_VERS_MAJOR) + >> ISAKMP_VERS_MAJOR_SHIFT; + minor = (base.vers & ISAKMP_VERS_MINOR) + >> ISAKMP_VERS_MINOR_SHIFT; + + if (ndo->ndo_vflag) { + ND_PRINT((ndo," %d.%d", major, minor)); + } + + if (ndo->ndo_vflag) { + ND_PRINT((ndo," msgid ")); + hexprint(ndo, (caddr_t)&base.msgid, sizeof(base.msgid)); + } + + if (1 < ndo->ndo_vflag) { + ND_PRINT((ndo," cookie ")); + hexprint(ndo, (caddr_t)&base.i_ck, sizeof(base.i_ck)); + ND_PRINT((ndo,"->")); + hexprint(ndo, (caddr_t)&base.r_ck, sizeof(base.r_ck)); + } + ND_PRINT((ndo,":")); + + switch(major) { + case IKEv1_MAJOR_VERSION: + ikev1_print(ndo, bp, length, bp2, &base); + break; + + case IKEv2_MAJOR_VERSION: + ikev2_print(ndo, bp, length, bp2, &base); + break; + } +} + +void +isakmp_rfc3948_print(netdissect_options *ndo, + const u_char *bp, u_int length, + const u_char *bp2) +{ + const u_char *ep; + ep = ndo->ndo_snapend; + + if(length == 1 && bp[0]==0xff) { + ND_PRINT((ndo, "isakmp-nat-keep-alive")); + return; + } + + if(length < 4) { + goto trunc; + } + + /* + * see if this is an IKE packet + */ + if(bp[0]==0 && bp[1]==0 && bp[2]==0 && bp[3]==0) { + ND_PRINT((ndo, "NONESP-encap: ")); + isakmp_print(ndo, bp+4, length-4, bp2); + return; + } + + /* must be an ESP packet */ + { + int nh, enh, padlen; + int advance; + + ND_PRINT((ndo, "UDP-encap: ")); + + advance = esp_print(ndo, bp, length, bp2, &enh, &padlen); + if(advance <= 0) + return; + + bp += advance; + length -= advance + padlen; + nh = enh & 0xff; + + ip_print_inner(ndo, bp, length, nh, bp2); + return; + } + +trunc: + ND_PRINT((ndo,"[|isakmp]")); + return; +} + +/* + * Local Variables: + * c-style: whitesmith + * c-basic-offset: 8 + * End: + */ + + + +
diff --git a/tcpdump-4.3.0/print-isoclns.c b/tcpdump-4.3.0/print-isoclns.c new file mode 100644 index 0000000..5763705 --- /dev/null +++ b/tcpdump-4.3.0/print-isoclns.c
@@ -0,0 +1,2763 @@ +/* + * 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. + * + * Original code by Matt Thomas, Digital Equipment Corporation + * + * Extensively modified by Hannes Gredler (hannes@juniper.net) for more + * complete IS-IS & CLNP support. + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.165 2008-08-16 13:38:15 hannes Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> +#include <string.h> + +#include "interface.h" +#include "addrtoname.h" +#include "ethertype.h" +#include "ether.h" +#include "nlpid.h" +#include "extract.h" +#include "gmpls.h" +#include "oui.h" +#include "signature.h" + +/* + * IS-IS is defined in ISO 10589. Look there for protocol definitions. + */ + +#define SYSTEM_ID_LEN ETHER_ADDR_LEN +#define NODE_ID_LEN SYSTEM_ID_LEN+1 +#define LSP_ID_LEN SYSTEM_ID_LEN+2 + +#define ISIS_VERSION 1 +#define ESIS_VERSION 1 +#define CLNP_VERSION 1 + +#define ISIS_PDU_TYPE_MASK 0x1F +#define ESIS_PDU_TYPE_MASK 0x1F +#define CLNP_PDU_TYPE_MASK 0x1F +#define CLNP_FLAG_MASK 0xE0 +#define ISIS_LAN_PRIORITY_MASK 0x7F + +#define ISIS_PDU_L1_LAN_IIH 15 +#define ISIS_PDU_L2_LAN_IIH 16 +#define ISIS_PDU_PTP_IIH 17 +#define ISIS_PDU_L1_LSP 18 +#define ISIS_PDU_L2_LSP 20 +#define ISIS_PDU_L1_CSNP 24 +#define ISIS_PDU_L2_CSNP 25 +#define ISIS_PDU_L1_PSNP 26 +#define ISIS_PDU_L2_PSNP 27 + +static struct tok isis_pdu_values[] = { + { ISIS_PDU_L1_LAN_IIH, "L1 Lan IIH"}, + { ISIS_PDU_L2_LAN_IIH, "L2 Lan IIH"}, + { ISIS_PDU_PTP_IIH, "p2p IIH"}, + { ISIS_PDU_L1_LSP, "L1 LSP"}, + { ISIS_PDU_L2_LSP, "L2 LSP"}, + { ISIS_PDU_L1_CSNP, "L1 CSNP"}, + { ISIS_PDU_L2_CSNP, "L2 CSNP"}, + { ISIS_PDU_L1_PSNP, "L1 PSNP"}, + { ISIS_PDU_L2_PSNP, "L2 PSNP"}, + { 0, NULL} +}; + +/* + * A TLV is a tuple of a type, length and a value and is normally used for + * encoding information in all sorts of places. This is an enumeration of + * the well known types. + * + * list taken from rfc3359 plus some memory from veterans ;-) + */ + +#define ISIS_TLV_AREA_ADDR 1 /* iso10589 */ +#define ISIS_TLV_IS_REACH 2 /* iso10589 */ +#define ISIS_TLV_ESNEIGH 3 /* iso10589 */ +#define ISIS_TLV_PART_DIS 4 /* iso10589 */ +#define ISIS_TLV_PREFIX_NEIGH 5 /* iso10589 */ +#define ISIS_TLV_ISNEIGH 6 /* iso10589 */ +#define ISIS_TLV_ISNEIGH_VARLEN 7 /* iso10589 */ +#define ISIS_TLV_PADDING 8 /* iso10589 */ +#define ISIS_TLV_LSP 9 /* iso10589 */ +#define ISIS_TLV_AUTH 10 /* iso10589, rfc3567 */ +#define ISIS_TLV_CHECKSUM 12 /* rfc3358 */ +#define ISIS_TLV_CHECKSUM_MINLEN 2 +#define ISIS_TLV_LSP_BUFFERSIZE 14 /* iso10589 rev2 */ +#define ISIS_TLV_LSP_BUFFERSIZE_MINLEN 2 +#define ISIS_TLV_EXT_IS_REACH 22 /* draft-ietf-isis-traffic-05 */ +#define ISIS_TLV_IS_ALIAS_ID 24 /* draft-ietf-isis-ext-lsp-frags-02 */ +#define ISIS_TLV_DECNET_PHASE4 42 +#define ISIS_TLV_LUCENT_PRIVATE 66 +#define ISIS_TLV_INT_IP_REACH 128 /* rfc1195, rfc2966 */ +#define ISIS_TLV_PROTOCOLS 129 /* rfc1195 */ +#define ISIS_TLV_EXT_IP_REACH 130 /* rfc1195, rfc2966 */ +#define ISIS_TLV_IDRP_INFO 131 /* rfc1195 */ +#define ISIS_TLV_IDRP_INFO_MINLEN 1 +#define ISIS_TLV_IPADDR 132 /* rfc1195 */ +#define ISIS_TLV_IPAUTH 133 /* rfc1195 */ +#define ISIS_TLV_TE_ROUTER_ID 134 /* draft-ietf-isis-traffic-05 */ +#define ISIS_TLV_EXTD_IP_REACH 135 /* draft-ietf-isis-traffic-05 */ +#define ISIS_TLV_HOSTNAME 137 /* rfc2763 */ +#define ISIS_TLV_SHARED_RISK_GROUP 138 /* draft-ietf-isis-gmpls-extensions */ +#define ISIS_TLV_NORTEL_PRIVATE1 176 +#define ISIS_TLV_NORTEL_PRIVATE2 177 +#define ISIS_TLV_RESTART_SIGNALING 211 /* rfc3847 */ +#define ISIS_TLV_RESTART_SIGNALING_FLAGLEN 1 +#define ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN 2 +#define ISIS_TLV_MT_IS_REACH 222 /* draft-ietf-isis-wg-multi-topology-05 */ +#define ISIS_TLV_MT_SUPPORTED 229 /* draft-ietf-isis-wg-multi-topology-05 */ +#define ISIS_TLV_MT_SUPPORTED_MINLEN 2 +#define ISIS_TLV_IP6ADDR 232 /* draft-ietf-isis-ipv6-02 */ +#define ISIS_TLV_MT_IP_REACH 235 /* draft-ietf-isis-wg-multi-topology-05 */ +#define ISIS_TLV_IP6_REACH 236 /* draft-ietf-isis-ipv6-02 */ +#define ISIS_TLV_MT_IP6_REACH 237 /* draft-ietf-isis-wg-multi-topology-05 */ +#define ISIS_TLV_PTP_ADJ 240 /* rfc3373 */ +#define ISIS_TLV_IIH_SEQNR 241 /* draft-shen-isis-iih-sequence-00 */ +#define ISIS_TLV_IIH_SEQNR_MINLEN 4 +#define ISIS_TLV_VENDOR_PRIVATE 250 /* draft-ietf-isis-experimental-tlv-01 */ +#define ISIS_TLV_VENDOR_PRIVATE_MINLEN 3 + +static struct tok isis_tlv_values[] = { + { ISIS_TLV_AREA_ADDR, "Area address(es)"}, + { ISIS_TLV_IS_REACH, "IS Reachability"}, + { ISIS_TLV_ESNEIGH, "ES Neighbor(s)"}, + { ISIS_TLV_PART_DIS, "Partition DIS"}, + { ISIS_TLV_PREFIX_NEIGH, "Prefix Neighbors"}, + { ISIS_TLV_ISNEIGH, "IS Neighbor(s)"}, + { ISIS_TLV_ISNEIGH_VARLEN, "IS Neighbor(s) (variable length)"}, + { ISIS_TLV_PADDING, "Padding"}, + { ISIS_TLV_LSP, "LSP entries"}, + { ISIS_TLV_AUTH, "Authentication"}, + { ISIS_TLV_CHECKSUM, "Checksum"}, + { ISIS_TLV_LSP_BUFFERSIZE, "LSP Buffersize"}, + { ISIS_TLV_EXT_IS_REACH, "Extended IS Reachability"}, + { ISIS_TLV_IS_ALIAS_ID, "IS Alias ID"}, + { ISIS_TLV_DECNET_PHASE4, "DECnet Phase IV"}, + { ISIS_TLV_LUCENT_PRIVATE, "Lucent Proprietary"}, + { ISIS_TLV_INT_IP_REACH, "IPv4 Internal Reachability"}, + { ISIS_TLV_PROTOCOLS, "Protocols supported"}, + { ISIS_TLV_EXT_IP_REACH, "IPv4 External Reachability"}, + { ISIS_TLV_IDRP_INFO, "Inter-Domain Information Type"}, + { ISIS_TLV_IPADDR, "IPv4 Interface address(es)"}, + { ISIS_TLV_IPAUTH, "IPv4 authentication (deprecated)"}, + { ISIS_TLV_TE_ROUTER_ID, "Traffic Engineering Router ID"}, + { ISIS_TLV_EXTD_IP_REACH, "Extended IPv4 Reachability"}, + { ISIS_TLV_SHARED_RISK_GROUP, "Shared Risk Link Group"}, + { ISIS_TLV_NORTEL_PRIVATE1, "Nortel Proprietary"}, + { ISIS_TLV_NORTEL_PRIVATE2, "Nortel Proprietary"}, + { ISIS_TLV_HOSTNAME, "Hostname"}, + { ISIS_TLV_RESTART_SIGNALING, "Restart Signaling"}, + { ISIS_TLV_MT_IS_REACH, "Multi Topology IS Reachability"}, + { ISIS_TLV_MT_SUPPORTED, "Multi Topology"}, + { ISIS_TLV_IP6ADDR, "IPv6 Interface address(es)"}, + { ISIS_TLV_MT_IP_REACH, "Multi-Topology IPv4 Reachability"}, + { ISIS_TLV_IP6_REACH, "IPv6 reachability"}, + { ISIS_TLV_MT_IP6_REACH, "Multi-Topology IP6 Reachability"}, + { ISIS_TLV_PTP_ADJ, "Point-to-point Adjacency State"}, + { ISIS_TLV_IIH_SEQNR, "Hello PDU Sequence Number"}, + { ISIS_TLV_VENDOR_PRIVATE, "Vendor Private"}, + { 0, NULL } +}; + +#define ESIS_OPTION_PROTOCOLS 129 +#define ESIS_OPTION_QOS_MAINTENANCE 195 /* iso9542 */ +#define ESIS_OPTION_SECURITY 197 /* iso9542 */ +#define ESIS_OPTION_ES_CONF_TIME 198 /* iso9542 */ +#define ESIS_OPTION_PRIORITY 205 /* iso9542 */ +#define ESIS_OPTION_ADDRESS_MASK 225 /* iso9542 */ +#define ESIS_OPTION_SNPA_MASK 226 /* iso9542 */ + +static struct tok esis_option_values[] = { + { ESIS_OPTION_PROTOCOLS, "Protocols supported"}, + { ESIS_OPTION_QOS_MAINTENANCE, "QoS Maintenance" }, + { ESIS_OPTION_SECURITY, "Security" }, + { ESIS_OPTION_ES_CONF_TIME, "ES Configuration Time" }, + { ESIS_OPTION_PRIORITY, "Priority" }, + { ESIS_OPTION_ADDRESS_MASK, "Addressk Mask" }, + { ESIS_OPTION_SNPA_MASK, "SNPA Mask" }, + { 0, NULL } +}; + +#define CLNP_OPTION_DISCARD_REASON 193 +#define CLNP_OPTION_QOS_MAINTENANCE 195 /* iso8473 */ +#define CLNP_OPTION_SECURITY 197 /* iso8473 */ +#define CLNP_OPTION_SOURCE_ROUTING 200 /* iso8473 */ +#define CLNP_OPTION_ROUTE_RECORDING 203 /* iso8473 */ +#define CLNP_OPTION_PADDING 204 /* iso8473 */ +#define CLNP_OPTION_PRIORITY 205 /* iso8473 */ + +static struct tok clnp_option_values[] = { + { CLNP_OPTION_DISCARD_REASON, "Discard Reason"}, + { CLNP_OPTION_PRIORITY, "Priority"}, + { CLNP_OPTION_QOS_MAINTENANCE, "QoS Maintenance"}, + { CLNP_OPTION_SECURITY, "Security"}, + { CLNP_OPTION_SOURCE_ROUTING, "Source Routing"}, + { CLNP_OPTION_ROUTE_RECORDING, "Route Recording"}, + { CLNP_OPTION_PADDING, "Padding"}, + { 0, NULL } +}; + +static struct tok clnp_option_rfd_class_values[] = { + { 0x0, "General"}, + { 0x8, "Address"}, + { 0x9, "Source Routeing"}, + { 0xa, "Lifetime"}, + { 0xb, "PDU Discarded"}, + { 0xc, "Reassembly"}, + { 0, NULL } +}; + +static struct tok clnp_option_rfd_general_values[] = { + { 0x0, "Reason not specified"}, + { 0x1, "Protocol procedure error"}, + { 0x2, "Incorrect checksum"}, + { 0x3, "PDU discarded due to congestion"}, + { 0x4, "Header syntax error (cannot be parsed)"}, + { 0x5, "Segmentation needed but not permitted"}, + { 0x6, "Incomplete PDU received"}, + { 0x7, "Duplicate option"}, + { 0, NULL } +}; + +static struct tok clnp_option_rfd_address_values[] = { + { 0x0, "Destination address unreachable"}, + { 0x1, "Destination address unknown"}, + { 0, NULL } +}; + +static struct tok clnp_option_rfd_source_routeing_values[] = { + { 0x0, "Unspecified source routeing error"}, + { 0x1, "Syntax error in source routeing field"}, + { 0x2, "Unknown address in source routeing field"}, + { 0x3, "Path not acceptable"}, + { 0, NULL } +}; + +static struct tok clnp_option_rfd_lifetime_values[] = { + { 0x0, "Lifetime expired while data unit in transit"}, + { 0x1, "Lifetime expired during reassembly"}, + { 0, NULL } +}; + +static struct tok clnp_option_rfd_pdu_discard_values[] = { + { 0x0, "Unsupported option not specified"}, + { 0x1, "Unsupported protocol version"}, + { 0x2, "Unsupported security option"}, + { 0x3, "Unsupported source routeing option"}, + { 0x4, "Unsupported recording of route option"}, + { 0, NULL } +}; + +static struct tok clnp_option_rfd_reassembly_values[] = { + { 0x0, "Reassembly interference"}, + { 0, NULL } +}; + +/* array of 16 error-classes */ +static struct tok *clnp_option_rfd_error_class[] = { + clnp_option_rfd_general_values, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + clnp_option_rfd_address_values, + clnp_option_rfd_source_routeing_values, + clnp_option_rfd_lifetime_values, + clnp_option_rfd_pdu_discard_values, + clnp_option_rfd_reassembly_values, + NULL, + NULL, + NULL +}; + +#define CLNP_OPTION_OPTION_QOS_MASK 0x3f +#define CLNP_OPTION_SCOPE_MASK 0xc0 +#define CLNP_OPTION_SCOPE_SA_SPEC 0x40 +#define CLNP_OPTION_SCOPE_DA_SPEC 0x80 +#define CLNP_OPTION_SCOPE_GLOBAL 0xc0 + +static struct tok clnp_option_scope_values[] = { + { CLNP_OPTION_SCOPE_SA_SPEC, "Source Address Specific"}, + { CLNP_OPTION_SCOPE_DA_SPEC, "Destination Address Specific"}, + { CLNP_OPTION_SCOPE_GLOBAL, "Globally unique"}, + { 0, NULL } +}; + +static struct tok clnp_option_sr_rr_values[] = { + { 0x0, "partial"}, + { 0x1, "complete"}, + { 0, NULL } +}; + +static struct tok clnp_option_sr_rr_string_values[] = { + { CLNP_OPTION_SOURCE_ROUTING, "source routing"}, + { CLNP_OPTION_ROUTE_RECORDING, "recording of route in progress"}, + { 0, NULL } +}; + +static struct tok clnp_option_qos_global_values[] = { + { 0x20, "reserved"}, + { 0x10, "sequencing vs. delay"}, + { 0x08, "congested"}, + { 0x04, "delay vs. cost"}, + { 0x02, "error vs. delay"}, + { 0x01, "error vs. cost"}, + { 0, NULL } +}; + +#define ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP 3 /* draft-ietf-isis-traffic-05 */ +#define ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID 4 /* rfc4205 */ +#define ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID 5 /* draft-ietf-isis-traffic-05 */ +#define ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR 6 /* draft-ietf-isis-traffic-05 */ +#define ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR 8 /* draft-ietf-isis-traffic-05 */ +#define ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW 9 /* draft-ietf-isis-traffic-05 */ +#define ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW 10 /* draft-ietf-isis-traffic-05 */ +#define ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW 11 /* rfc4124 */ +#define ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD 12 /* draft-ietf-tewg-diff-te-proto-06 */ +#define ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC 18 /* draft-ietf-isis-traffic-05 */ +#define ISIS_SUBTLV_EXT_IS_REACH_LINK_ATTRIBUTE 19 /* draft-ietf-isis-link-attr-01 */ +#define ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE 20 /* rfc4205 */ +#define ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR 21 /* rfc4205 */ +#define ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS 22 /* rfc4124 */ + +static struct tok isis_ext_is_reach_subtlv_values[] = { + { ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP, "Administrative groups" }, + { ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID, "Link Local/Remote Identifier" }, + { ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID, "Link Remote Identifier" }, + { ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR, "IPv4 interface address" }, + { ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR, "IPv4 neighbor address" }, + { ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW, "Maximum link bandwidth" }, + { ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW, "Reservable link bandwidth" }, + { ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW, "Unreserved bandwidth" }, + { ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC, "Traffic Engineering Metric" }, + { ISIS_SUBTLV_EXT_IS_REACH_LINK_ATTRIBUTE, "Link Attribute" }, + { ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE, "Link Protection Type" }, + { ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR, "Interface Switching Capability" }, + { ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD, "Bandwidth Constraints (old)" }, + { ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS, "Bandwidth Constraints" }, + { 250, "Reserved for cisco specific extensions" }, + { 251, "Reserved for cisco specific extensions" }, + { 252, "Reserved for cisco specific extensions" }, + { 253, "Reserved for cisco specific extensions" }, + { 254, "Reserved for cisco specific extensions" }, + { 255, "Reserved for future expansion" }, + { 0, NULL } +}; + +#define ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32 1 /* draft-ietf-isis-admin-tags-01 */ +#define ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64 2 /* draft-ietf-isis-admin-tags-01 */ +#define ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR 117 /* draft-ietf-isis-wg-multi-topology-05 */ + +static struct tok isis_ext_ip_reach_subtlv_values[] = { + { ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32, "32-Bit Administrative tag" }, + { ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64, "64-Bit Administrative tag" }, + { ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR, "Management Prefix Color" }, + { 0, NULL } +}; + +static struct tok isis_subtlv_link_attribute_values[] = { + { 0x01, "Local Protection Available" }, + { 0x02, "Link excluded from local protection path" }, + { 0x04, "Local maintenance required"}, + { 0, NULL } +}; + +#define ISIS_SUBTLV_AUTH_SIMPLE 1 +#define ISIS_SUBTLV_AUTH_GENERIC 3 /* rfc 5310 */ +#define ISIS_SUBTLV_AUTH_MD5 54 +#define ISIS_SUBTLV_AUTH_MD5_LEN 16 +#define ISIS_SUBTLV_AUTH_PRIVATE 255 + +static struct tok isis_subtlv_auth_values[] = { + { ISIS_SUBTLV_AUTH_SIMPLE, "simple text password"}, + { ISIS_SUBTLV_AUTH_GENERIC, "Generic Crypto key-id"}, + { ISIS_SUBTLV_AUTH_MD5, "HMAC-MD5 password"}, + { ISIS_SUBTLV_AUTH_PRIVATE, "Routing Domain private password"}, + { 0, NULL } +}; + +#define ISIS_SUBTLV_IDRP_RES 0 +#define ISIS_SUBTLV_IDRP_LOCAL 1 +#define ISIS_SUBTLV_IDRP_ASN 2 + +static struct tok isis_subtlv_idrp_values[] = { + { ISIS_SUBTLV_IDRP_RES, "Reserved"}, + { ISIS_SUBTLV_IDRP_LOCAL, "Routing-Domain Specific"}, + { ISIS_SUBTLV_IDRP_ASN, "AS Number Tag"}, + { 0, NULL} +}; + +#define CLNP_SEGMENT_PART 0x80 +#define CLNP_MORE_SEGMENTS 0x40 +#define CLNP_REQUEST_ER 0x20 + +static struct tok clnp_flag_values[] = { + { CLNP_SEGMENT_PART, "Segmentation permitted"}, + { CLNP_MORE_SEGMENTS, "more Segments"}, + { CLNP_REQUEST_ER, "request Error Report"}, + { 0, NULL} +}; + +#define ISIS_MASK_LSP_OL_BIT(x) ((x)&0x4) +#define ISIS_MASK_LSP_ISTYPE_BITS(x) ((x)&0x3) +#define ISIS_MASK_LSP_PARTITION_BIT(x) ((x)&0x80) +#define ISIS_MASK_LSP_ATT_BITS(x) ((x)&0x78) +#define ISIS_MASK_LSP_ATT_ERROR_BIT(x) ((x)&0x40) +#define ISIS_MASK_LSP_ATT_EXPENSE_BIT(x) ((x)&0x20) +#define ISIS_MASK_LSP_ATT_DELAY_BIT(x) ((x)&0x10) +#define ISIS_MASK_LSP_ATT_DEFAULT_BIT(x) ((x)&0x8) + +#define ISIS_MASK_MTID(x) ((x)&0x0fff) +#define ISIS_MASK_MTFLAGS(x) ((x)&0xf000) + +static struct tok isis_mt_flag_values[] = { + { 0x4000, "ATT bit set"}, + { 0x8000, "Overload bit set"}, + { 0, NULL} +}; + +#define ISIS_MASK_TLV_EXTD_IP_UPDOWN(x) ((x)&0x80) +#define ISIS_MASK_TLV_EXTD_IP_SUBTLV(x) ((x)&0x40) + +#define ISIS_MASK_TLV_EXTD_IP6_IE(x) ((x)&0x40) +#define ISIS_MASK_TLV_EXTD_IP6_SUBTLV(x) ((x)&0x20) + +#define ISIS_LSP_TLV_METRIC_SUPPORTED(x) ((x)&0x80) +#define ISIS_LSP_TLV_METRIC_IE(x) ((x)&0x40) +#define ISIS_LSP_TLV_METRIC_UPDOWN(x) ((x)&0x80) +#define ISIS_LSP_TLV_METRIC_VALUE(x) ((x)&0x3f) + +#define ISIS_MASK_TLV_SHARED_RISK_GROUP(x) ((x)&0x1) + +static struct tok isis_mt_values[] = { + { 0, "IPv4 unicast"}, + { 1, "In-Band Management"}, + { 2, "IPv6 unicast"}, + { 3, "Multicast"}, + { 4095, "Development, Experimental or Proprietary"}, + { 0, NULL } +}; + +static struct tok isis_iih_circuit_type_values[] = { + { 1, "Level 1 only"}, + { 2, "Level 2 only"}, + { 3, "Level 1, Level 2"}, + { 0, NULL} +}; + +#define ISIS_LSP_TYPE_UNUSED0 0 +#define ISIS_LSP_TYPE_LEVEL_1 1 +#define ISIS_LSP_TYPE_UNUSED2 2 +#define ISIS_LSP_TYPE_LEVEL_2 3 + +static struct tok isis_lsp_istype_values[] = { + { ISIS_LSP_TYPE_UNUSED0, "Unused 0x0 (invalid)"}, + { ISIS_LSP_TYPE_LEVEL_1, "L1 IS"}, + { ISIS_LSP_TYPE_UNUSED2, "Unused 0x2 (invalid)"}, + { ISIS_LSP_TYPE_LEVEL_2, "L2 IS"}, + { 0, NULL } +}; + +/* + * Katz's point to point adjacency TLV uses codes to tell us the state of + * the remote adjacency. Enumerate them. + */ + +#define ISIS_PTP_ADJ_UP 0 +#define ISIS_PTP_ADJ_INIT 1 +#define ISIS_PTP_ADJ_DOWN 2 + +static struct tok isis_ptp_adjancey_values[] = { + { ISIS_PTP_ADJ_UP, "Up" }, + { ISIS_PTP_ADJ_INIT, "Initializing" }, + { ISIS_PTP_ADJ_DOWN, "Down" }, + { 0, NULL} +}; + +struct isis_tlv_ptp_adj { + u_int8_t adjacency_state; + u_int8_t extd_local_circuit_id[4]; + u_int8_t neighbor_sysid[SYSTEM_ID_LEN]; + u_int8_t neighbor_extd_local_circuit_id[4]; +}; + +static void osi_print_cksum(const u_int8_t *pptr, u_int16_t checksum, + u_int checksum_offset, u_int length); +static int clnp_print(const u_int8_t *, u_int); +static void esis_print(const u_int8_t *, u_int); +static int isis_print(const u_int8_t *, u_int); + +struct isis_metric_block { + u_int8_t metric_default; + u_int8_t metric_delay; + u_int8_t metric_expense; + u_int8_t metric_error; +}; + +struct isis_tlv_is_reach { + struct isis_metric_block isis_metric_block; + u_int8_t neighbor_nodeid[NODE_ID_LEN]; +}; + +struct isis_tlv_es_reach { + struct isis_metric_block isis_metric_block; + u_int8_t neighbor_sysid[SYSTEM_ID_LEN]; +}; + +struct isis_tlv_ip_reach { + struct isis_metric_block isis_metric_block; + u_int8_t prefix[4]; + u_int8_t mask[4]; +}; + +static struct tok isis_is_reach_virtual_values[] = { + { 0, "IsNotVirtual"}, + { 1, "IsVirtual"}, + { 0, NULL } +}; + +static struct tok isis_restart_flag_values[] = { + { 0x1, "Restart Request"}, + { 0x2, "Restart Acknowledgement"}, + { 0x4, "Suppress adjacency advertisement"}, + { 0, NULL } +}; + +struct isis_common_header { + u_int8_t nlpid; + u_int8_t fixed_len; + u_int8_t version; /* Protocol version */ + u_int8_t id_length; + u_int8_t pdu_type; /* 3 MSbits are reserved */ + u_int8_t pdu_version; /* Packet format version */ + u_int8_t reserved; + u_int8_t max_area; +}; + +struct isis_iih_lan_header { + u_int8_t circuit_type; + u_int8_t source_id[SYSTEM_ID_LEN]; + u_int8_t holding_time[2]; + u_int8_t pdu_len[2]; + u_int8_t priority; + u_int8_t lan_id[NODE_ID_LEN]; +}; + +struct isis_iih_ptp_header { + u_int8_t circuit_type; + u_int8_t source_id[SYSTEM_ID_LEN]; + u_int8_t holding_time[2]; + u_int8_t pdu_len[2]; + u_int8_t circuit_id; +}; + +struct isis_lsp_header { + u_int8_t pdu_len[2]; + u_int8_t remaining_lifetime[2]; + u_int8_t lsp_id[LSP_ID_LEN]; + u_int8_t sequence_number[4]; + u_int8_t checksum[2]; + u_int8_t typeblock; +}; + +struct isis_csnp_header { + u_int8_t pdu_len[2]; + u_int8_t source_id[NODE_ID_LEN]; + u_int8_t start_lsp_id[LSP_ID_LEN]; + u_int8_t end_lsp_id[LSP_ID_LEN]; +}; + +struct isis_psnp_header { + u_int8_t pdu_len[2]; + u_int8_t source_id[NODE_ID_LEN]; +}; + +struct isis_tlv_lsp { + u_int8_t remaining_lifetime[2]; + u_int8_t lsp_id[LSP_ID_LEN]; + u_int8_t sequence_number[4]; + u_int8_t checksum[2]; +}; + +#define ISIS_COMMON_HEADER_SIZE (sizeof(struct isis_common_header)) +#define ISIS_IIH_LAN_HEADER_SIZE (sizeof(struct isis_iih_lan_header)) +#define ISIS_IIH_PTP_HEADER_SIZE (sizeof(struct isis_iih_ptp_header)) +#define ISIS_LSP_HEADER_SIZE (sizeof(struct isis_lsp_header)) +#define ISIS_CSNP_HEADER_SIZE (sizeof(struct isis_csnp_header)) +#define ISIS_PSNP_HEADER_SIZE (sizeof(struct isis_psnp_header)) + +void isoclns_print(const u_int8_t *p, u_int length, u_int caplen) +{ + if (caplen <= 1) { /* enough bytes on the wire ? */ + printf("|OSI"); + return; + } + + if (eflag) + printf("OSI NLPID %s (0x%02x): ", + tok2str(nlpid_values,"Unknown",*p), + *p); + + switch (*p) { + + case NLPID_CLNP: + if (!clnp_print(p, length)) + print_unknown_data(p,"\n\t",caplen); + break; + + case NLPID_ESIS: + esis_print(p, length); + return; + + case NLPID_ISIS: + if (!isis_print(p, length)) + print_unknown_data(p,"\n\t",caplen); + break; + + case NLPID_NULLNS: + (void)printf("%slength: %u", + eflag ? "" : ", ", + length); + break; + + case NLPID_Q933: + q933_print(p+1, length-1); + break; + + case NLPID_IP: + ip_print(gndo, p+1, length-1); + break; + +#ifdef INET6 + case NLPID_IP6: + ip6_print(gndo, p+1, length-1); + break; +#endif + + case NLPID_PPP: + ppp_print(p+1, length-1); + break; + + default: + if (!eflag) + printf("OSI NLPID 0x%02x unknown",*p); + (void)printf("%slength: %u", + eflag ? "" : ", ", + length); + if (caplen > 1) + print_unknown_data(p,"\n\t",caplen); + break; + } +} + +#define CLNP_PDU_ER 1 +#define CLNP_PDU_DT 28 +#define CLNP_PDU_MD 29 +#define CLNP_PDU_ERQ 30 +#define CLNP_PDU_ERP 31 + +static struct tok clnp_pdu_values[] = { + { CLNP_PDU_ER, "Error Report"}, + { CLNP_PDU_MD, "MD"}, + { CLNP_PDU_DT, "Data"}, + { CLNP_PDU_ERQ, "Echo Request"}, + { CLNP_PDU_ERP, "Echo Response"}, + { 0, NULL } +}; + +struct clnp_header_t { + u_int8_t nlpid; + u_int8_t length_indicator; + u_int8_t version; + u_int8_t lifetime; /* units of 500ms */ + u_int8_t type; + u_int8_t segment_length[2]; + u_int8_t cksum[2]; +}; + +struct clnp_segment_header_t { + u_int8_t data_unit_id[2]; + u_int8_t segment_offset[2]; + u_int8_t total_length[2]; +}; + +/* + * clnp_print + * Decode CLNP packets. Return 0 on error. + */ + +static int clnp_print (const u_int8_t *pptr, u_int length) +{ + const u_int8_t *optr,*source_address,*dest_address; + u_int li,tlen,nsap_offset,source_address_length,dest_address_length, clnp_pdu_type, clnp_flags; + const struct clnp_header_t *clnp_header; + const struct clnp_segment_header_t *clnp_segment_header; + u_int8_t rfd_error_major,rfd_error_minor; + + clnp_header = (const struct clnp_header_t *) pptr; + TCHECK(*clnp_header); + + li = clnp_header->length_indicator; + optr = pptr; + + if (!eflag) + printf("CLNP"); + + /* + * Sanity checking of the header. + */ + + if (clnp_header->version != CLNP_VERSION) { + printf("version %d packet not supported", clnp_header->version); + return (0); + } + + /* FIXME further header sanity checking */ + + clnp_pdu_type = clnp_header->type & CLNP_PDU_TYPE_MASK; + clnp_flags = clnp_header->type & CLNP_FLAG_MASK; + + pptr += sizeof(struct clnp_header_t); + li -= sizeof(struct clnp_header_t); + dest_address_length = *pptr; + dest_address = pptr + 1; + + pptr += (1 + dest_address_length); + li -= (1 + dest_address_length); + source_address_length = *pptr; + source_address = pptr +1; + + pptr += (1 + source_address_length); + li -= (1 + source_address_length); + + if (vflag < 1) { + printf("%s%s > %s, %s, length %u", + eflag ? "" : ", ", + isonsap_string(source_address, source_address_length), + isonsap_string(dest_address, dest_address_length), + tok2str(clnp_pdu_values,"unknown (%u)",clnp_pdu_type), + length); + return (1); + } + printf("%slength %u",eflag ? "" : ", ",length); + + printf("\n\t%s PDU, hlen: %u, v: %u, lifetime: %u.%us, Segment PDU length: %u, checksum: 0x%04x", + tok2str(clnp_pdu_values, "unknown (%u)",clnp_pdu_type), + clnp_header->length_indicator, + clnp_header->version, + clnp_header->lifetime/2, + (clnp_header->lifetime%2)*5, + EXTRACT_16BITS(clnp_header->segment_length), + EXTRACT_16BITS(clnp_header->cksum)); + + osi_print_cksum(optr, EXTRACT_16BITS(clnp_header->cksum), 7, + clnp_header->length_indicator); + + printf("\n\tFlags [%s]", + bittok2str(clnp_flag_values,"none",clnp_flags)); + + printf("\n\tsource address (length %u): %s\n\tdest address (length %u): %s", + source_address_length, + isonsap_string(source_address, source_address_length), + dest_address_length, + isonsap_string(dest_address,dest_address_length)); + + if (clnp_flags & CLNP_SEGMENT_PART) { + clnp_segment_header = (const struct clnp_segment_header_t *) pptr; + TCHECK(*clnp_segment_header); + printf("\n\tData Unit ID: 0x%04x, Segment Offset: %u, Total PDU Length: %u", + EXTRACT_16BITS(clnp_segment_header->data_unit_id), + EXTRACT_16BITS(clnp_segment_header->segment_offset), + EXTRACT_16BITS(clnp_segment_header->total_length)); + pptr+=sizeof(const struct clnp_segment_header_t); + li-=sizeof(const struct clnp_segment_header_t); + } + + /* now walk the options */ + while (li >= 2) { + u_int op, opli; + const u_int8_t *tptr; + + TCHECK2(*pptr, 2); + if (li < 2) { + printf(", bad opts/li"); + return (0); + } + op = *pptr++; + opli = *pptr++; + li -= 2; + TCHECK2(*pptr, opli); + if (opli > li) { + printf(", opt (%d) too long", op); + return (0); + } + li -= opli; + tptr = pptr; + tlen = opli; + + printf("\n\t %s Option #%u, length %u, value: ", + tok2str(clnp_option_values,"Unknown",op), + op, + opli); + + switch (op) { + + + case CLNP_OPTION_ROUTE_RECORDING: /* those two options share the format */ + case CLNP_OPTION_SOURCE_ROUTING: + printf("%s %s", + tok2str(clnp_option_sr_rr_values,"Unknown",*tptr), + tok2str(clnp_option_sr_rr_string_values,"Unknown Option %u",op)); + nsap_offset=*(tptr+1); + if (nsap_offset == 0) { + printf(" Bad NSAP offset (0)"); + break; + } + nsap_offset-=1; /* offset to nsap list */ + if (nsap_offset > tlen) { + printf(" Bad NSAP offset (past end of option)"); + break; + } + tptr+=nsap_offset; + tlen-=nsap_offset; + while (tlen > 0) { + source_address_length=*tptr; + if (tlen < source_address_length+1) { + printf("\n\t NSAP address goes past end of option"); + break; + } + if (source_address_length > 0) { + source_address=(tptr+1); + TCHECK2(*source_address, source_address_length); + printf("\n\t NSAP address (length %u): %s", + source_address_length, + isonsap_string(source_address, source_address_length)); + } + tlen-=source_address_length+1; + } + break; + + case CLNP_OPTION_PRIORITY: + printf("0x%1x", *tptr&0x0f); + break; + + case CLNP_OPTION_QOS_MAINTENANCE: + printf("\n\t Format Code: %s", + tok2str(clnp_option_scope_values,"Reserved",*tptr&CLNP_OPTION_SCOPE_MASK)); + + if ((*tptr&CLNP_OPTION_SCOPE_MASK) == CLNP_OPTION_SCOPE_GLOBAL) + printf("\n\t QoS Flags [%s]", + bittok2str(clnp_option_qos_global_values, + "none", + *tptr&CLNP_OPTION_OPTION_QOS_MASK)); + break; + + case CLNP_OPTION_SECURITY: + printf("\n\t Format Code: %s, Security-Level %u", + tok2str(clnp_option_scope_values,"Reserved",*tptr&CLNP_OPTION_SCOPE_MASK), + *(tptr+1)); + break; + + case CLNP_OPTION_DISCARD_REASON: + rfd_error_major = (*tptr&0xf0) >> 4; + rfd_error_minor = *tptr&0x0f; + printf("\n\t Class: %s Error (0x%01x), %s (0x%01x)", + tok2str(clnp_option_rfd_class_values,"Unknown",rfd_error_major), + rfd_error_major, + tok2str(clnp_option_rfd_error_class[rfd_error_major],"Unknown",rfd_error_minor), + rfd_error_minor); + break; + + case CLNP_OPTION_PADDING: + printf("padding data"); + break; + + /* + * FIXME those are the defined Options that lack a decoder + * you are welcome to contribute code ;-) + */ + + default: + print_unknown_data(tptr,"\n\t ",opli); + break; + } + if (vflag > 1) + print_unknown_data(pptr,"\n\t ",opli); + pptr += opli; + } + + switch (clnp_pdu_type) { + + case CLNP_PDU_ER: /* fall through */ + case CLNP_PDU_ERP: + TCHECK(*pptr); + if (*(pptr) == NLPID_CLNP) { + printf("\n\t-----original packet-----\n\t"); + /* FIXME recursion protection */ + clnp_print(pptr, length-clnp_header->length_indicator); + break; + } + + case CLNP_PDU_DT: + case CLNP_PDU_MD: + case CLNP_PDU_ERQ: + + default: + /* dump the PDU specific data */ + if (length-(pptr-optr) > 0) { + printf("\n\t undecoded non-header data, length %u",length-clnp_header->length_indicator); + print_unknown_data(pptr,"\n\t ",length-(pptr-optr)); + } + } + + return (1); + + trunc: + fputs("[|clnp]", stdout); + return (1); + +} + + +#define ESIS_PDU_REDIRECT 6 +#define ESIS_PDU_ESH 2 +#define ESIS_PDU_ISH 4 + +static struct tok esis_pdu_values[] = { + { ESIS_PDU_REDIRECT, "redirect"}, + { ESIS_PDU_ESH, "ESH"}, + { ESIS_PDU_ISH, "ISH"}, + { 0, NULL } +}; + +struct esis_header_t { + u_int8_t nlpid; + u_int8_t length_indicator; + u_int8_t version; + u_int8_t reserved; + u_int8_t type; + u_int8_t holdtime[2]; + u_int8_t cksum[2]; +}; + +static void +esis_print(const u_int8_t *pptr, u_int length) +{ + const u_int8_t *optr; + u_int li,esis_pdu_type,source_address_length, source_address_number; + const struct esis_header_t *esis_header; + + if (!eflag) + printf("ES-IS"); + + if (length <= 2) { + if (qflag) + printf("bad pkt!"); + else + printf("no header at all!"); + return; + } + + esis_header = (const struct esis_header_t *) pptr; + TCHECK(*esis_header); + li = esis_header->length_indicator; + optr = pptr; + + /* + * Sanity checking of the header. + */ + + if (esis_header->nlpid != NLPID_ESIS) { + printf(" nlpid 0x%02x packet not supported", esis_header->nlpid); + return; + } + + if (esis_header->version != ESIS_VERSION) { + printf(" version %d packet not supported", esis_header->version); + return; + } + + if (li > length) { + printf(" length indicator(%d) > PDU size (%d)!", li, length); + return; + } + + if (li < sizeof(struct esis_header_t) + 2) { + printf(" length indicator < min PDU size %d:", li); + while (--length != 0) + printf("%02X", *pptr++); + return; + } + + esis_pdu_type = esis_header->type & ESIS_PDU_TYPE_MASK; + + if (vflag < 1) { + printf("%s%s, length %u", + eflag ? "" : ", ", + tok2str(esis_pdu_values,"unknown type (%u)",esis_pdu_type), + length); + return; + } else + printf("%slength %u\n\t%s (%u)", + eflag ? "" : ", ", + length, + tok2str(esis_pdu_values,"unknown type: %u", esis_pdu_type), + esis_pdu_type); + + printf(", v: %u%s", esis_header->version, esis_header->version == ESIS_VERSION ? "" : "unsupported" ); + printf(", checksum: 0x%04x", EXTRACT_16BITS(esis_header->cksum)); + + osi_print_cksum(pptr, EXTRACT_16BITS(esis_header->cksum), 7, li); + + printf(", holding time: %us, length indicator: %u",EXTRACT_16BITS(esis_header->holdtime),li); + + if (vflag > 1) + print_unknown_data(optr,"\n\t",sizeof(struct esis_header_t)); + + pptr += sizeof(struct esis_header_t); + li -= sizeof(struct esis_header_t); + + switch (esis_pdu_type) { + case ESIS_PDU_REDIRECT: { + const u_int8_t *dst, *snpa, *neta; + u_int dstl, snpal, netal; + + TCHECK(*pptr); + if (li < 1) { + printf(", bad redirect/li"); + return; + } + dstl = *pptr; + pptr++; + li--; + TCHECK2(*pptr, dstl); + if (li < dstl) { + printf(", bad redirect/li"); + return; + } + dst = pptr; + pptr += dstl; + li -= dstl; + printf("\n\t %s", isonsap_string(dst,dstl)); + + TCHECK(*pptr); + if (li < 1) { + printf(", bad redirect/li"); + return; + } + snpal = *pptr; + pptr++; + li--; + TCHECK2(*pptr, snpal); + if (li < snpal) { + printf(", bad redirect/li"); + return; + } + snpa = pptr; + pptr += snpal; + li -= snpal; + TCHECK(*pptr); + if (li < 1) { + printf(", bad redirect/li"); + return; + } + netal = *pptr; + pptr++; + TCHECK2(*pptr, netal); + if (li < netal) { + printf(", bad redirect/li"); + return; + } + neta = pptr; + pptr += netal; + li -= netal; + + if (netal == 0) + printf("\n\t %s", etheraddr_string(snpa)); + else + printf("\n\t %s", isonsap_string(neta,netal)); + break; + } + + case ESIS_PDU_ESH: + TCHECK(*pptr); + if (li < 1) { + printf(", bad esh/li"); + return; + } + source_address_number = *pptr; + pptr++; + li--; + + printf("\n\t Number of Source Addresses: %u", source_address_number); + + while (source_address_number > 0) { + TCHECK(*pptr); + if (li < 1) { + printf(", bad esh/li"); + return; + } + source_address_length = *pptr; + pptr++; + li--; + + TCHECK2(*pptr, source_address_length); + if (li < source_address_length) { + printf(", bad esh/li"); + return; + } + printf("\n\t NET (length: %u): %s", + source_address_length, + isonsap_string(pptr,source_address_length)); + pptr += source_address_length; + li -= source_address_length; + source_address_number--; + } + + break; + + case ESIS_PDU_ISH: { + TCHECK(*pptr); + if (li < 1) { + printf(", bad ish/li"); + return; + } + source_address_length = *pptr; + pptr++; + li--; + TCHECK2(*pptr, source_address_length); + if (li < source_address_length) { + printf(", bad ish/li"); + return; + } + printf("\n\t NET (length: %u): %s", source_address_length, isonsap_string(pptr, source_address_length)); + pptr += source_address_length; + li -= source_address_length; + break; + } + + default: + if (vflag <= 1) { + if (pptr < snapend) + print_unknown_data(pptr,"\n\t ",snapend-pptr); + } + return; + } + + /* now walk the options */ + while (li != 0) { + u_int op, opli; + const u_int8_t *tptr; + + if (li < 2) { + printf(", bad opts/li"); + return; + } + TCHECK2(*pptr, 2); + op = *pptr++; + opli = *pptr++; + li -= 2; + if (opli > li) { + printf(", opt (%d) too long", op); + return; + } + li -= opli; + tptr = pptr; + + printf("\n\t %s Option #%u, length %u, value: ", + tok2str(esis_option_values,"Unknown",op), + op, + opli); + + switch (op) { + + case ESIS_OPTION_ES_CONF_TIME: + if (opli == 2) { + TCHECK2(*pptr, 2); + printf("%us", EXTRACT_16BITS(tptr)); + } else + printf("(bad length)"); + break; + + case ESIS_OPTION_PROTOCOLS: + while (opli>0) { + TCHECK(*pptr); + printf("%s (0x%02x)", + tok2str(nlpid_values, + "unknown", + *tptr), + *tptr); + if (opli>1) /* further NPLIDs ? - put comma */ + printf(", "); + tptr++; + opli--; + } + break; + + /* + * FIXME those are the defined Options that lack a decoder + * you are welcome to contribute code ;-) + */ + + case ESIS_OPTION_QOS_MAINTENANCE: + case ESIS_OPTION_SECURITY: + case ESIS_OPTION_PRIORITY: + case ESIS_OPTION_ADDRESS_MASK: + case ESIS_OPTION_SNPA_MASK: + + default: + print_unknown_data(tptr,"\n\t ",opli); + break; + } + if (vflag > 1) + print_unknown_data(pptr,"\n\t ",opli); + pptr += opli; + } +trunc: + return; +} + +/* shared routine for printing system, node and lsp-ids */ +static char * +isis_print_id(const u_int8_t *cp, int id_len) +{ + int i; + static char id[sizeof("xxxx.xxxx.xxxx.yy-zz")]; + char *pos = id; + + for (i = 1; i <= SYSTEM_ID_LEN; i++) { + snprintf(pos, sizeof(id) - (pos - id), "%02x", *cp++); + pos += strlen(pos); + if (i == 2 || i == 4) + *pos++ = '.'; + } + if (id_len >= NODE_ID_LEN) { + snprintf(pos, sizeof(id) - (pos - id), ".%02x", *cp++); + pos += strlen(pos); + } + if (id_len == LSP_ID_LEN) + snprintf(pos, sizeof(id) - (pos - id), "-%02x", *cp); + return (id); +} + +/* print the 4-byte metric block which is common found in the old-style TLVs */ +static int +isis_print_metric_block (const struct isis_metric_block *isis_metric_block) +{ + printf(", Default Metric: %d, %s", + ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_default), + ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_default) ? "External" : "Internal"); + if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block->metric_delay)) + printf("\n\t\t Delay Metric: %d, %s", + ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_delay), + ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_delay) ? "External" : "Internal"); + if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block->metric_expense)) + printf("\n\t\t Expense Metric: %d, %s", + ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_expense), + ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_expense) ? "External" : "Internal"); + if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block->metric_error)) + printf("\n\t\t Error Metric: %d, %s", + ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_error), + ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_error) ? "External" : "Internal"); + + return(1); /* everything is ok */ +} + +static int +isis_print_tlv_ip_reach (const u_int8_t *cp, const char *ident, int length) +{ + int prefix_len; + const struct isis_tlv_ip_reach *tlv_ip_reach; + + tlv_ip_reach = (const struct isis_tlv_ip_reach *)cp; + + while (length > 0) { + if ((size_t)length < sizeof(*tlv_ip_reach)) { + printf("short IPv4 Reachability (%d vs %lu)", + length, + (unsigned long)sizeof(*tlv_ip_reach)); + return (0); + } + + if (!TTEST(*tlv_ip_reach)) + return (0); + + prefix_len = mask2plen(EXTRACT_32BITS(tlv_ip_reach->mask)); + + if (prefix_len == -1) + printf("%sIPv4 prefix: %s mask %s", + ident, + ipaddr_string((tlv_ip_reach->prefix)), + ipaddr_string((tlv_ip_reach->mask))); + else + printf("%sIPv4 prefix: %15s/%u", + ident, + ipaddr_string((tlv_ip_reach->prefix)), + prefix_len); + + printf(", Distribution: %s, Metric: %u, %s", + ISIS_LSP_TLV_METRIC_UPDOWN(tlv_ip_reach->isis_metric_block.metric_default) ? "down" : "up", + ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_default), + ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_default) ? "External" : "Internal"); + + if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach->isis_metric_block.metric_delay)) + printf("%s Delay Metric: %u, %s", + ident, + ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_delay), + ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_delay) ? "External" : "Internal"); + + if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach->isis_metric_block.metric_expense)) + printf("%s Expense Metric: %u, %s", + ident, + ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_expense), + ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_expense) ? "External" : "Internal"); + + if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach->isis_metric_block.metric_error)) + printf("%s Error Metric: %u, %s", + ident, + ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_error), + ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_error) ? "External" : "Internal"); + + length -= sizeof(struct isis_tlv_ip_reach); + tlv_ip_reach++; + } + return (1); +} + +/* + * this is the common IP-REACH subTLV decoder it is called + * from various EXTD-IP REACH TLVs (135,235,236,237) + */ + +static int +isis_print_ip_reach_subtlv (const u_int8_t *tptr,int subt,int subl,const char *ident) { + + /* first lets see if we know the subTLVs name*/ + printf("%s%s subTLV #%u, length: %u", + ident, + tok2str(isis_ext_ip_reach_subtlv_values, + "unknown", + subt), + subt, + subl); + + if (!TTEST2(*tptr,subl)) + goto trunctlv; + + switch(subt) { + case ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR: /* fall through */ + case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32: + while (subl >= 4) { + printf(", 0x%08x (=%u)", + EXTRACT_32BITS(tptr), + EXTRACT_32BITS(tptr)); + tptr+=4; + subl-=4; + } + break; + case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64: + while (subl >= 8) { + printf(", 0x%08x%08x", + EXTRACT_32BITS(tptr), + EXTRACT_32BITS(tptr+4)); + tptr+=8; + subl-=8; + } + break; + default: + if(!print_unknown_data(tptr,"\n\t\t ", + subl)) + return(0); + break; + } + return(1); + +trunctlv: + printf("%spacket exceeded snapshot",ident); + return(0); +} + +/* + * this is the common IS-REACH subTLV decoder it is called + * from isis_print_ext_is_reach() + */ + +static int +isis_print_is_reach_subtlv (const u_int8_t *tptr,u_int subt,u_int subl,const char *ident) { + + u_int te_class,priority_level,gmpls_switch_cap; + union { /* int to float conversion buffer for several subTLVs */ + float f; + u_int32_t i; + } bw; + + /* first lets see if we know the subTLVs name*/ + printf("%s%s subTLV #%u, length: %u", + ident, + tok2str(isis_ext_is_reach_subtlv_values, + "unknown", + subt), + subt, + subl); + + if (!TTEST2(*tptr,subl)) + goto trunctlv; + + switch(subt) { + case ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP: + case ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID: + case ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID: + if (subl >= 4) { + printf(", 0x%08x", EXTRACT_32BITS(tptr)); + if (subl == 8) /* rfc4205 */ + printf(", 0x%08x", EXTRACT_32BITS(tptr+4)); + } + break; + case ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR: + case ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR: + if (subl >= sizeof(struct in_addr)) + printf(", %s", ipaddr_string(tptr)); + break; + case ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW : + case ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW: + if (subl >= 4) { + bw.i = EXTRACT_32BITS(tptr); + printf(", %.3f Mbps", bw.f*8/1000000 ); + } + break; + case ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW : + if (subl >= 32) { + for (te_class = 0; te_class < 8; te_class++) { + bw.i = EXTRACT_32BITS(tptr); + printf("%s TE-Class %u: %.3f Mbps", + ident, + te_class, + bw.f*8/1000000 ); + tptr+=4; + } + } + break; + case ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS: /* fall through */ + case ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD: + printf("%sBandwidth Constraints Model ID: %s (%u)", + ident, + tok2str(diffserv_te_bc_values, "unknown", *tptr), + *tptr); + tptr++; + /* decode BCs until the subTLV ends */ + for (te_class = 0; te_class < (subl-1)/4; te_class++) { + bw.i = EXTRACT_32BITS(tptr); + printf("%s Bandwidth constraint CT%u: %.3f Mbps", + ident, + te_class, + bw.f*8/1000000 ); + tptr+=4; + } + break; + case ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC: + if (subl >= 3) + printf(", %u", EXTRACT_24BITS(tptr)); + break; + case ISIS_SUBTLV_EXT_IS_REACH_LINK_ATTRIBUTE: + if (subl == 2) { + printf(", [ %s ] (0x%04x)", + bittok2str(isis_subtlv_link_attribute_values, + "Unknown", + EXTRACT_16BITS(tptr)), + EXTRACT_16BITS(tptr)); + } + break; + case ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE: + if (subl >= 2) { + printf(", %s, Priority %u", + bittok2str(gmpls_link_prot_values, "none", *tptr), + *(tptr+1)); + } + break; + case ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR: + if (subl >= 36) { + gmpls_switch_cap = *tptr; + printf("%s Interface Switching Capability:%s", + ident, + tok2str(gmpls_switch_cap_values, "Unknown", gmpls_switch_cap)); + printf(", LSP Encoding: %s", + tok2str(gmpls_encoding_values, "Unknown", *(tptr+1))); + tptr+=4; + printf("%s Max LSP Bandwidth:",ident); + for (priority_level = 0; priority_level < 8; priority_level++) { + bw.i = EXTRACT_32BITS(tptr); + printf("%s priority level %d: %.3f Mbps", + ident, + priority_level, + bw.f*8/1000000 ); + tptr+=4; + } + subl-=36; + switch (gmpls_switch_cap) { + case GMPLS_PSC1: + case GMPLS_PSC2: + case GMPLS_PSC3: + case GMPLS_PSC4: + bw.i = EXTRACT_32BITS(tptr); + printf("%s Min LSP Bandwidth: %.3f Mbps", ident, bw.f*8/1000000); + printf("%s Interface MTU: %u", ident, EXTRACT_16BITS(tptr+4)); + break; + case GMPLS_TSC: + bw.i = EXTRACT_32BITS(tptr); + printf("%s Min LSP Bandwidth: %.3f Mbps", ident, bw.f*8/1000000); + printf("%s Indication %s", ident, + tok2str(gmpls_switch_cap_tsc_indication_values, "Unknown (%u)", *(tptr+4))); + break; + default: + /* there is some optional stuff left to decode but this is as of yet + not specified so just lets hexdump what is left */ + if(subl>0){ + if(!print_unknown_data(tptr,"\n\t\t ", + subl)) + return(0); + } + } + } + break; + default: + if(!print_unknown_data(tptr,"\n\t\t ", + subl)) + return(0); + break; + } + return(1); + +trunctlv: + printf("%spacket exceeded snapshot",ident); + return(0); +} + + +/* + * this is the common IS-REACH decoder it is called + * from various EXTD-IS REACH style TLVs (22,24,222) + */ + +static int +isis_print_ext_is_reach (const u_int8_t *tptr,const char *ident, int tlv_type) { + + char ident_buffer[20]; + int subtlv_type,subtlv_len,subtlv_sum_len; + int proc_bytes = 0; /* how many bytes did we process ? */ + + if (!TTEST2(*tptr, NODE_ID_LEN)) + return(0); + + printf("%sIS Neighbor: %s", ident, isis_print_id(tptr, NODE_ID_LEN)); + tptr+=(NODE_ID_LEN); + + if (tlv_type != ISIS_TLV_IS_ALIAS_ID) { /* the Alias TLV Metric field is implicit 0 */ + if (!TTEST2(*tptr, 3)) /* and is therefore skipped */ + return(0); + printf(", Metric: %d",EXTRACT_24BITS(tptr)); + tptr+=3; + } + + if (!TTEST2(*tptr, 1)) + return(0); + subtlv_sum_len=*(tptr++); /* read out subTLV length */ + proc_bytes=NODE_ID_LEN+3+1; + printf(", %ssub-TLVs present",subtlv_sum_len ? "" : "no "); + if (subtlv_sum_len) { + printf(" (%u)",subtlv_sum_len); + while (subtlv_sum_len>0) { + if (!TTEST2(*tptr,2)) + return(0); + subtlv_type=*(tptr++); + subtlv_len=*(tptr++); + /* prepend the ident string */ + snprintf(ident_buffer, sizeof(ident_buffer), "%s ",ident); + if(!isis_print_is_reach_subtlv(tptr,subtlv_type,subtlv_len,ident_buffer)) + return(0); + tptr+=subtlv_len; + subtlv_sum_len-=(subtlv_len+2); + proc_bytes+=(subtlv_len+2); + } + } + return(proc_bytes); +} + +/* + * this is the common Multi Topology ID decoder + * it is called from various MT-TLVs (222,229,235,237) + */ + +static int +isis_print_mtid (const u_int8_t *tptr,const char *ident) { + + if (!TTEST2(*tptr, 2)) + return(0); + + printf("%s%s", + ident, + tok2str(isis_mt_values, + "Reserved for IETF Consensus", + ISIS_MASK_MTID(EXTRACT_16BITS(tptr)))); + + printf(" Topology (0x%03x), Flags: [%s]", + ISIS_MASK_MTID(EXTRACT_16BITS(tptr)), + bittok2str(isis_mt_flag_values, "none",ISIS_MASK_MTFLAGS(EXTRACT_16BITS(tptr)))); + + return(2); +} + +/* + * this is the common extended IP reach decoder + * it is called from TLVs (135,235,236,237) + * we process the TLV and optional subTLVs and return + * the amount of processed bytes + */ + +static int +isis_print_extd_ip_reach (const u_int8_t *tptr, const char *ident, u_int16_t afi) { + + char ident_buffer[20]; +#ifdef INET6 + u_int8_t prefix[sizeof(struct in6_addr)]; /* shared copy buffer for IPv4 and IPv6 prefixes */ +#else + u_int8_t prefix[sizeof(struct in_addr)]; /* shared copy buffer for IPv4 prefixes */ +#endif + u_int metric, status_byte, bit_length, byte_length, sublen, processed, subtlvtype, subtlvlen; + + if (!TTEST2(*tptr, 4)) + return (0); + metric = EXTRACT_32BITS(tptr); + processed=4; + tptr+=4; + + if (afi == AF_INET) { + if (!TTEST2(*tptr, 1)) /* fetch status byte */ + return (0); + status_byte=*(tptr++); + bit_length = status_byte&0x3f; + if (bit_length > 32) { + printf("%sIPv4 prefix: bad bit length %u", + ident, + bit_length); + return (0); + } + processed++; +#ifdef INET6 + } else if (afi == AF_INET6) { + if (!TTEST2(*tptr, 1)) /* fetch status & prefix_len byte */ + return (0); + status_byte=*(tptr++); + bit_length=*(tptr++); + if (bit_length > 128) { + printf("%sIPv6 prefix: bad bit length %u", + ident, + bit_length); + return (0); + } + processed+=2; +#endif + } else + return (0); /* somebody is fooling us */ + + byte_length = (bit_length + 7) / 8; /* prefix has variable length encoding */ + + if (!TTEST2(*tptr, byte_length)) + return (0); + memset(prefix, 0, sizeof prefix); /* clear the copy buffer */ + memcpy(prefix,tptr,byte_length); /* copy as much as is stored in the TLV */ + tptr+=byte_length; + processed+=byte_length; + + if (afi == AF_INET) + printf("%sIPv4 prefix: %15s/%u", + ident, + ipaddr_string(prefix), + bit_length); +#ifdef INET6 + if (afi == AF_INET6) + printf("%sIPv6 prefix: %s/%u", + ident, + ip6addr_string(prefix), + bit_length); +#endif + + printf(", Distribution: %s, Metric: %u", + ISIS_MASK_TLV_EXTD_IP_UPDOWN(status_byte) ? "down" : "up", + metric); + + if (afi == AF_INET && ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte)) + printf(", sub-TLVs present"); +#ifdef INET6 + if (afi == AF_INET6) + printf(", %s%s", + ISIS_MASK_TLV_EXTD_IP6_IE(status_byte) ? "External" : "Internal", + ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte) ? ", sub-TLVs present" : ""); +#endif + + if ((afi == AF_INET && ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte)) +#ifdef INET6 + || (afi == AF_INET6 && ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte)) +#endif + ) { + /* assume that one prefix can hold more + than one subTLV - therefore the first byte must reflect + the aggregate bytecount of the subTLVs for this prefix + */ + if (!TTEST2(*tptr, 1)) + return (0); + sublen=*(tptr++); + processed+=sublen+1; + printf(" (%u)",sublen); /* print out subTLV length */ + + while (sublen>0) { + if (!TTEST2(*tptr,2)) + return (0); + subtlvtype=*(tptr++); + subtlvlen=*(tptr++); + /* prepend the ident string */ + snprintf(ident_buffer, sizeof(ident_buffer), "%s ",ident); + if(!isis_print_ip_reach_subtlv(tptr,subtlvtype,subtlvlen,ident_buffer)) + return(0); + tptr+=subtlvlen; + sublen-=(subtlvlen+2); + } + } + return (processed); +} + +/* + * isis_print + * Decode IS-IS packets. Return 0 on error. + */ + +static int isis_print (const u_int8_t *p, u_int length) +{ + const struct isis_common_header *isis_header; + + const struct isis_iih_lan_header *header_iih_lan; + const struct isis_iih_ptp_header *header_iih_ptp; + struct isis_lsp_header *header_lsp; + const struct isis_csnp_header *header_csnp; + const struct isis_psnp_header *header_psnp; + + const struct isis_tlv_lsp *tlv_lsp; + const struct isis_tlv_ptp_adj *tlv_ptp_adj; + const struct isis_tlv_is_reach *tlv_is_reach; + const struct isis_tlv_es_reach *tlv_es_reach; + + u_int8_t pdu_type, max_area, id_length, tlv_type, tlv_len, tmp, alen, lan_alen, prefix_len; + u_int8_t ext_is_len, ext_ip_len, mt_len; + const u_int8_t *optr, *pptr, *tptr; + u_short packet_len,pdu_len, key_id; + u_int i,vendor_id; + int sigcheck; + + packet_len=length; + optr = p; /* initialize the _o_riginal pointer to the packet start - + need it for parsing the checksum TLV and authentication + TLV verification */ + isis_header = (const struct isis_common_header *)p; + TCHECK(*isis_header); + pptr = p+(ISIS_COMMON_HEADER_SIZE); + header_iih_lan = (const struct isis_iih_lan_header *)pptr; + header_iih_ptp = (const struct isis_iih_ptp_header *)pptr; + header_lsp = (struct isis_lsp_header *)pptr; + header_csnp = (const struct isis_csnp_header *)pptr; + header_psnp = (const struct isis_psnp_header *)pptr; + + if (!eflag) + printf("IS-IS"); + + /* + * Sanity checking of the header. + */ + + if (isis_header->version != ISIS_VERSION) { + printf("version %d packet not supported", isis_header->version); + return (0); + } + + if ((isis_header->id_length != SYSTEM_ID_LEN) && (isis_header->id_length != 0)) { + printf("system ID length of %d is not supported", + isis_header->id_length); + return (0); + } + + if (isis_header->pdu_version != ISIS_VERSION) { + printf("version %d packet not supported", isis_header->pdu_version); + return (0); + } + + max_area = isis_header->max_area; + switch(max_area) { + case 0: + max_area = 3; /* silly shit */ + break; + case 255: + printf("bad packet -- 255 areas"); + return (0); + default: + break; + } + + id_length = isis_header->id_length; + switch(id_length) { + case 0: + id_length = 6; /* silly shit again */ + break; + case 1: /* 1-8 are valid sys-ID lenghts */ + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + break; + case 255: + id_length = 0; /* entirely useless */ + break; + default: + break; + } + + /* toss any non 6-byte sys-ID len PDUs */ + if (id_length != 6 ) { + printf("bad packet -- illegal sys-ID length (%u)", id_length); + return (0); + } + + pdu_type=isis_header->pdu_type; + + /* in non-verbose mode print the basic PDU Type plus PDU specific brief information*/ + if (vflag < 1) { + printf("%s%s", + eflag ? "" : ", ", + tok2str(isis_pdu_values,"unknown PDU-Type %u",pdu_type)); + + switch (pdu_type) { + + case ISIS_PDU_L1_LAN_IIH: + case ISIS_PDU_L2_LAN_IIH: + printf(", src-id %s", + isis_print_id(header_iih_lan->source_id,SYSTEM_ID_LEN)); + printf(", lan-id %s, prio %u", + isis_print_id(header_iih_lan->lan_id,NODE_ID_LEN), + header_iih_lan->priority); + break; + case ISIS_PDU_PTP_IIH: + printf(", src-id %s", isis_print_id(header_iih_ptp->source_id,SYSTEM_ID_LEN)); + break; + case ISIS_PDU_L1_LSP: + case ISIS_PDU_L2_LSP: + printf(", lsp-id %s, seq 0x%08x, lifetime %5us", + isis_print_id(header_lsp->lsp_id, LSP_ID_LEN), + EXTRACT_32BITS(header_lsp->sequence_number), + EXTRACT_16BITS(header_lsp->remaining_lifetime)); + break; + case ISIS_PDU_L1_CSNP: + case ISIS_PDU_L2_CSNP: + printf(", src-id %s", isis_print_id(header_csnp->source_id,NODE_ID_LEN)); + break; + case ISIS_PDU_L1_PSNP: + case ISIS_PDU_L2_PSNP: + printf(", src-id %s", isis_print_id(header_psnp->source_id,NODE_ID_LEN)); + break; + + } + printf(", length %u", length); + + return(1); + } + + /* ok they seem to want to know everything - lets fully decode it */ + printf("%slength %u", eflag ? "" : ", ",length); + + printf("\n\t%s, hlen: %u, v: %u, pdu-v: %u, sys-id-len: %u (%u), max-area: %u (%u)", + tok2str(isis_pdu_values, + "unknown, type %u", + pdu_type), + isis_header->fixed_len, + isis_header->version, + isis_header->pdu_version, + id_length, + isis_header->id_length, + max_area, + isis_header->max_area); + + if (vflag > 1) { + if(!print_unknown_data(optr,"\n\t",8)) /* provide the _o_riginal pointer */ + return(0); /* for optionally debugging the common header */ + } + + switch (pdu_type) { + + case ISIS_PDU_L1_LAN_IIH: + case ISIS_PDU_L2_LAN_IIH: + if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE)) { + printf(", bogus fixed header length %u should be %lu", + isis_header->fixed_len, (unsigned long)ISIS_IIH_LAN_HEADER_SIZE); + return (0); + } + + pdu_len=EXTRACT_16BITS(header_iih_lan->pdu_len); + if (packet_len>pdu_len) { + packet_len=pdu_len; /* do TLV decoding as long as it makes sense */ + length=pdu_len; + } + + TCHECK(*header_iih_lan); + printf("\n\t source-id: %s, holding time: %us, Flags: [%s]", + isis_print_id(header_iih_lan->source_id,SYSTEM_ID_LEN), + EXTRACT_16BITS(header_iih_lan->holding_time), + tok2str(isis_iih_circuit_type_values, + "unknown circuit type 0x%02x", + header_iih_lan->circuit_type)); + + printf("\n\t lan-id: %s, Priority: %u, PDU length: %u", + isis_print_id(header_iih_lan->lan_id, NODE_ID_LEN), + (header_iih_lan->priority) & ISIS_LAN_PRIORITY_MASK, + pdu_len); + + if (vflag > 1) { + if(!print_unknown_data(pptr,"\n\t ",ISIS_IIH_LAN_HEADER_SIZE)) + return(0); + } + + packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE); + pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE); + break; + + case ISIS_PDU_PTP_IIH: + if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE)) { + printf(", bogus fixed header length %u should be %lu", + isis_header->fixed_len, (unsigned long)ISIS_IIH_PTP_HEADER_SIZE); + return (0); + } + + pdu_len=EXTRACT_16BITS(header_iih_ptp->pdu_len); + if (packet_len>pdu_len) { + packet_len=pdu_len; /* do TLV decoding as long as it makes sense */ + length=pdu_len; + } + + TCHECK(*header_iih_ptp); + printf("\n\t source-id: %s, holding time: %us, Flags: [%s]", + isis_print_id(header_iih_ptp->source_id,SYSTEM_ID_LEN), + EXTRACT_16BITS(header_iih_ptp->holding_time), + tok2str(isis_iih_circuit_type_values, + "unknown circuit type 0x%02x", + header_iih_ptp->circuit_type)); + + printf("\n\t circuit-id: 0x%02x, PDU length: %u", + header_iih_ptp->circuit_id, + pdu_len); + + if (vflag > 1) { + if(!print_unknown_data(pptr,"\n\t ",ISIS_IIH_PTP_HEADER_SIZE)) + return(0); + } + + packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE); + pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE); + break; + + case ISIS_PDU_L1_LSP: + case ISIS_PDU_L2_LSP: + if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE)) { + printf(", bogus fixed header length %u should be %lu", + isis_header->fixed_len, (unsigned long)ISIS_LSP_HEADER_SIZE); + return (0); + } + + pdu_len=EXTRACT_16BITS(header_lsp->pdu_len); + if (packet_len>pdu_len) { + packet_len=pdu_len; /* do TLV decoding as long as it makes sense */ + length=pdu_len; + } + + TCHECK(*header_lsp); + printf("\n\t lsp-id: %s, seq: 0x%08x, lifetime: %5us\n\t chksum: 0x%04x", + isis_print_id(header_lsp->lsp_id, LSP_ID_LEN), + EXTRACT_32BITS(header_lsp->sequence_number), + EXTRACT_16BITS(header_lsp->remaining_lifetime), + EXTRACT_16BITS(header_lsp->checksum)); + + + osi_print_cksum((u_int8_t *)header_lsp->lsp_id, + EXTRACT_16BITS(header_lsp->checksum), 12, length-12); + + /* + * Clear checksum and lifetime prior to signature verification. + */ + header_lsp->checksum[0] = 0; + header_lsp->checksum[1] = 0; + header_lsp->remaining_lifetime[0] = 0; + header_lsp->remaining_lifetime[1] = 0; + + + printf(", PDU length: %u, Flags: [ %s", + pdu_len, + ISIS_MASK_LSP_OL_BIT(header_lsp->typeblock) ? "Overload bit set, " : ""); + + if (ISIS_MASK_LSP_ATT_BITS(header_lsp->typeblock)) { + printf("%s", ISIS_MASK_LSP_ATT_DEFAULT_BIT(header_lsp->typeblock) ? "default " : ""); + printf("%s", ISIS_MASK_LSP_ATT_DELAY_BIT(header_lsp->typeblock) ? "delay " : ""); + printf("%s", ISIS_MASK_LSP_ATT_EXPENSE_BIT(header_lsp->typeblock) ? "expense " : ""); + printf("%s", ISIS_MASK_LSP_ATT_ERROR_BIT(header_lsp->typeblock) ? "error " : ""); + printf("ATT bit set, "); + } + printf("%s", ISIS_MASK_LSP_PARTITION_BIT(header_lsp->typeblock) ? "P bit set, " : ""); + printf("%s ]", tok2str(isis_lsp_istype_values,"Unknown(0x%x)",ISIS_MASK_LSP_ISTYPE_BITS(header_lsp->typeblock))); + + if (vflag > 1) { + if(!print_unknown_data(pptr,"\n\t ",ISIS_LSP_HEADER_SIZE)) + return(0); + } + + packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE); + pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE); + break; + + case ISIS_PDU_L1_CSNP: + case ISIS_PDU_L2_CSNP: + if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE)) { + printf(", bogus fixed header length %u should be %lu", + isis_header->fixed_len, (unsigned long)ISIS_CSNP_HEADER_SIZE); + return (0); + } + + pdu_len=EXTRACT_16BITS(header_csnp->pdu_len); + if (packet_len>pdu_len) { + packet_len=pdu_len; /* do TLV decoding as long as it makes sense */ + length=pdu_len; + } + + TCHECK(*header_csnp); + printf("\n\t source-id: %s, PDU length: %u", + isis_print_id(header_csnp->source_id, NODE_ID_LEN), + pdu_len); + printf("\n\t start lsp-id: %s", + isis_print_id(header_csnp->start_lsp_id, LSP_ID_LEN)); + printf("\n\t end lsp-id: %s", + isis_print_id(header_csnp->end_lsp_id, LSP_ID_LEN)); + + if (vflag > 1) { + if(!print_unknown_data(pptr,"\n\t ",ISIS_CSNP_HEADER_SIZE)) + return(0); + } + + packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE); + pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE); + break; + + case ISIS_PDU_L1_PSNP: + case ISIS_PDU_L2_PSNP: + if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE)) { + printf("- bogus fixed header length %u should be %lu", + isis_header->fixed_len, (unsigned long)ISIS_PSNP_HEADER_SIZE); + return (0); + } + + pdu_len=EXTRACT_16BITS(header_psnp->pdu_len); + if (packet_len>pdu_len) { + packet_len=pdu_len; /* do TLV decoding as long as it makes sense */ + length=pdu_len; + } + + TCHECK(*header_psnp); + printf("\n\t source-id: %s, PDU length: %u", + isis_print_id(header_psnp->source_id, NODE_ID_LEN), + pdu_len); + + if (vflag > 1) { + if(!print_unknown_data(pptr,"\n\t ",ISIS_PSNP_HEADER_SIZE)) + return(0); + } + + packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE); + pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE); + break; + + default: + if(!print_unknown_data(pptr,"\n\t ",length)) + return(0); + return (0); + } + + /* + * Now print the TLV's. + */ + + while (packet_len >= 2) { + if (pptr == snapend) { + return (1); + } + + if (!TTEST2(*pptr, 2)) { + printf("\n\t\t packet exceeded snapshot (%ld) bytes", + (long)(pptr-snapend)); + return (1); + } + tlv_type = *pptr++; + tlv_len = *pptr++; + tmp =tlv_len; /* copy temporary len & pointer to packet data */ + tptr = pptr; + packet_len -= 2; + if (tlv_len > packet_len) { + break; + } + + /* first lets see if we know the TLVs name*/ + printf("\n\t %s TLV #%u, length: %u", + tok2str(isis_tlv_values, + "unknown", + tlv_type), + tlv_type, + tlv_len); + + if (tlv_len == 0) /* something is malformed */ + continue; + + /* now check if we have a decoder otherwise do a hexdump at the end*/ + switch (tlv_type) { + case ISIS_TLV_AREA_ADDR: + if (!TTEST2(*tptr, 1)) + goto trunctlv; + alen = *tptr++; + while (tmp && alen < tmp) { + printf("\n\t Area address (length: %u): %s", + alen, + isonsap_string(tptr,alen)); + tptr += alen; + tmp -= alen + 1; + if (tmp==0) /* if this is the last area address do not attemt a boundary check */ + break; + if (!TTEST2(*tptr, 1)) + goto trunctlv; + alen = *tptr++; + } + break; + case ISIS_TLV_ISNEIGH: + while (tmp >= ETHER_ADDR_LEN) { + if (!TTEST2(*tptr, ETHER_ADDR_LEN)) + goto trunctlv; + printf("\n\t SNPA: %s",isis_print_id(tptr,ETHER_ADDR_LEN)); + tmp -= ETHER_ADDR_LEN; + tptr += ETHER_ADDR_LEN; + } + break; + + case ISIS_TLV_ISNEIGH_VARLEN: + if (!TTEST2(*tptr, 1) || tmp < 3) /* min. TLV length */ + goto trunctlv; + lan_alen = *tptr++; /* LAN address length */ + if (lan_alen == 0) { + printf("\n\t LAN address length 0 bytes (invalid)"); + break; + } + tmp --; + printf("\n\t LAN address length %u bytes ",lan_alen); + while (tmp >= lan_alen) { + if (!TTEST2(*tptr, lan_alen)) + goto trunctlv; + printf("\n\t\tIS Neighbor: %s",isis_print_id(tptr,lan_alen)); + tmp -= lan_alen; + tptr +=lan_alen; + } + break; + + case ISIS_TLV_PADDING: + break; + + case ISIS_TLV_MT_IS_REACH: + mt_len = isis_print_mtid(tptr, "\n\t "); + if (mt_len == 0) /* did something go wrong ? */ + goto trunctlv; + tptr+=mt_len; + tmp-=mt_len; + while (tmp >= 2+NODE_ID_LEN+3+1) { + ext_is_len = isis_print_ext_is_reach(tptr,"\n\t ",tlv_type); + if (ext_is_len == 0) /* did something go wrong ? */ + goto trunctlv; + + tmp-=ext_is_len; + tptr+=ext_is_len; + } + break; + + case ISIS_TLV_IS_ALIAS_ID: + while (tmp >= NODE_ID_LEN+1) { /* is it worth attempting a decode ? */ + ext_is_len = isis_print_ext_is_reach(tptr,"\n\t ",tlv_type); + if (ext_is_len == 0) /* did something go wrong ? */ + goto trunctlv; + tmp-=ext_is_len; + tptr+=ext_is_len; + } + break; + + case ISIS_TLV_EXT_IS_REACH: + while (tmp >= NODE_ID_LEN+3+1) { /* is it worth attempting a decode ? */ + ext_is_len = isis_print_ext_is_reach(tptr,"\n\t ",tlv_type); + if (ext_is_len == 0) /* did something go wrong ? */ + goto trunctlv; + tmp-=ext_is_len; + tptr+=ext_is_len; + } + break; + case ISIS_TLV_IS_REACH: + if (!TTEST2(*tptr,1)) /* check if there is one byte left to read out the virtual flag */ + goto trunctlv; + printf("\n\t %s", + tok2str(isis_is_reach_virtual_values, + "bogus virtual flag 0x%02x", + *tptr++)); + tlv_is_reach = (const struct isis_tlv_is_reach *)tptr; + while (tmp >= sizeof(struct isis_tlv_is_reach)) { + if (!TTEST(*tlv_is_reach)) + goto trunctlv; + printf("\n\t IS Neighbor: %s", + isis_print_id(tlv_is_reach->neighbor_nodeid, NODE_ID_LEN)); + isis_print_metric_block(&tlv_is_reach->isis_metric_block); + tmp -= sizeof(struct isis_tlv_is_reach); + tlv_is_reach++; + } + break; + + case ISIS_TLV_ESNEIGH: + tlv_es_reach = (const struct isis_tlv_es_reach *)tptr; + while (tmp >= sizeof(struct isis_tlv_es_reach)) { + if (!TTEST(*tlv_es_reach)) + goto trunctlv; + printf("\n\t ES Neighbor: %s", + isis_print_id(tlv_es_reach->neighbor_sysid,SYSTEM_ID_LEN)); + isis_print_metric_block(&tlv_es_reach->isis_metric_block); + tmp -= sizeof(struct isis_tlv_es_reach); + tlv_es_reach++; + } + break; + + /* those two TLVs share the same format */ + case ISIS_TLV_INT_IP_REACH: + case ISIS_TLV_EXT_IP_REACH: + if (!isis_print_tlv_ip_reach(pptr, "\n\t ", tlv_len)) + return (1); + break; + + case ISIS_TLV_EXTD_IP_REACH: + while (tmp>0) { + ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", AF_INET); + if (ext_ip_len == 0) /* did something go wrong ? */ + goto trunctlv; + tptr+=ext_ip_len; + tmp-=ext_ip_len; + } + break; + + case ISIS_TLV_MT_IP_REACH: + mt_len = isis_print_mtid(tptr, "\n\t "); + if (mt_len == 0) { /* did something go wrong ? */ + goto trunctlv; + } + tptr+=mt_len; + tmp-=mt_len; + + while (tmp>0) { + ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", AF_INET); + if (ext_ip_len == 0) /* did something go wrong ? */ + goto trunctlv; + tptr+=ext_ip_len; + tmp-=ext_ip_len; + } + break; + +#ifdef INET6 + case ISIS_TLV_IP6_REACH: + while (tmp>0) { + ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", AF_INET6); + if (ext_ip_len == 0) /* did something go wrong ? */ + goto trunctlv; + tptr+=ext_ip_len; + tmp-=ext_ip_len; + } + break; + + case ISIS_TLV_MT_IP6_REACH: + mt_len = isis_print_mtid(tptr, "\n\t "); + if (mt_len == 0) { /* did something go wrong ? */ + goto trunctlv; + } + tptr+=mt_len; + tmp-=mt_len; + + while (tmp>0) { + ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", AF_INET6); + if (ext_ip_len == 0) /* did something go wrong ? */ + goto trunctlv; + tptr+=ext_ip_len; + tmp-=ext_ip_len; + } + break; + + case ISIS_TLV_IP6ADDR: + while (tmp>=sizeof(struct in6_addr)) { + if (!TTEST2(*tptr, sizeof(struct in6_addr))) + goto trunctlv; + + printf("\n\t IPv6 interface address: %s", + ip6addr_string(tptr)); + + tptr += sizeof(struct in6_addr); + tmp -= sizeof(struct in6_addr); + } + break; +#endif + case ISIS_TLV_AUTH: + if (!TTEST2(*tptr, 1)) + goto trunctlv; + + printf("\n\t %s: ", + tok2str(isis_subtlv_auth_values, + "unknown Authentication type 0x%02x", + *tptr)); + + switch (*tptr) { + case ISIS_SUBTLV_AUTH_SIMPLE: + for(i=1;i<tlv_len;i++) { + if (!TTEST2(*(tptr+i), 1)) + goto trunctlv; + printf("%c",*(tptr+i)); + } + break; + case ISIS_SUBTLV_AUTH_MD5: + for(i=1;i<tlv_len;i++) { + if (!TTEST2(*(tptr+i), 1)) + goto trunctlv; + printf("%02x",*(tptr+i)); + } + if (tlv_len != ISIS_SUBTLV_AUTH_MD5_LEN+1) + printf(", (malformed subTLV) "); + +#ifdef HAVE_LIBCRYPTO + sigcheck = signature_verify(optr, length, + (unsigned char *)tptr + 1); +#else + sigcheck = CANT_CHECK_SIGNATURE; +#endif + printf(" (%s)", tok2str(signature_check_values, "Unknown", sigcheck)); + + break; + case ISIS_SUBTLV_AUTH_GENERIC: + key_id = EXTRACT_16BITS((tptr+1)); + printf("%u, password: ", key_id); + for(i=1 + sizeof(u_int16_t);i<tlv_len;i++) { + if (!TTEST2(*(tptr+i), 1)) + goto trunctlv; + printf("%02x",*(tptr+i)); + } + break; + case ISIS_SUBTLV_AUTH_PRIVATE: + default: + if(!print_unknown_data(tptr+1,"\n\t\t ",tlv_len-1)) + return(0); + break; + } + break; + + case ISIS_TLV_PTP_ADJ: + tlv_ptp_adj = (const struct isis_tlv_ptp_adj *)tptr; + if(tmp>=1) { + if (!TTEST2(*tptr, 1)) + goto trunctlv; + printf("\n\t Adjacency State: %s (%u)", + tok2str(isis_ptp_adjancey_values, "unknown", *tptr), + *tptr); + tmp--; + } + if(tmp>sizeof(tlv_ptp_adj->extd_local_circuit_id)) { + if (!TTEST2(tlv_ptp_adj->extd_local_circuit_id, + sizeof(tlv_ptp_adj->extd_local_circuit_id))) + goto trunctlv; + printf("\n\t Extended Local circuit-ID: 0x%08x", + EXTRACT_32BITS(tlv_ptp_adj->extd_local_circuit_id)); + tmp-=sizeof(tlv_ptp_adj->extd_local_circuit_id); + } + if(tmp>=SYSTEM_ID_LEN) { + if (!TTEST2(tlv_ptp_adj->neighbor_sysid, SYSTEM_ID_LEN)) + goto trunctlv; + printf("\n\t Neighbor System-ID: %s", + isis_print_id(tlv_ptp_adj->neighbor_sysid,SYSTEM_ID_LEN)); + tmp-=SYSTEM_ID_LEN; + } + if(tmp>=sizeof(tlv_ptp_adj->neighbor_extd_local_circuit_id)) { + if (!TTEST2(tlv_ptp_adj->neighbor_extd_local_circuit_id, + sizeof(tlv_ptp_adj->neighbor_extd_local_circuit_id))) + goto trunctlv; + printf("\n\t Neighbor Extended Local circuit-ID: 0x%08x", + EXTRACT_32BITS(tlv_ptp_adj->neighbor_extd_local_circuit_id)); + } + break; + + case ISIS_TLV_PROTOCOLS: + printf("\n\t NLPID(s): "); + while (tmp>0) { + if (!TTEST2(*(tptr), 1)) + goto trunctlv; + printf("%s (0x%02x)", + tok2str(nlpid_values, + "unknown", + *tptr), + *tptr); + if (tmp>1) /* further NPLIDs ? - put comma */ + printf(", "); + tptr++; + tmp--; + } + break; + + case ISIS_TLV_TE_ROUTER_ID: + if (!TTEST2(*pptr, sizeof(struct in_addr))) + goto trunctlv; + printf("\n\t Traffic Engineering Router ID: %s", ipaddr_string(pptr)); + break; + + case ISIS_TLV_IPADDR: + while (tmp>=sizeof(struct in_addr)) { + if (!TTEST2(*tptr, sizeof(struct in_addr))) + goto trunctlv; + printf("\n\t IPv4 interface address: %s", ipaddr_string(tptr)); + tptr += sizeof(struct in_addr); + tmp -= sizeof(struct in_addr); + } + break; + + case ISIS_TLV_HOSTNAME: + printf("\n\t Hostname: "); + while (tmp>0) { + if (!TTEST2(*tptr, 1)) + goto trunctlv; + printf("%c",*tptr++); + tmp--; + } + break; + + case ISIS_TLV_SHARED_RISK_GROUP: + if (tmp < NODE_ID_LEN) + break; + if (!TTEST2(*tptr, NODE_ID_LEN)) + goto trunctlv; + printf("\n\t IS Neighbor: %s", isis_print_id(tptr, NODE_ID_LEN)); + tptr+=(NODE_ID_LEN); + tmp-=(NODE_ID_LEN); + + if (tmp < 1) + break; + if (!TTEST2(*tptr, 1)) + goto trunctlv; + printf(", Flags: [%s]", ISIS_MASK_TLV_SHARED_RISK_GROUP(*tptr++) ? "numbered" : "unnumbered"); + tmp--; + + if (tmp < sizeof(struct in_addr)) + break; + if (!TTEST2(*tptr,sizeof(struct in_addr))) + goto trunctlv; + printf("\n\t IPv4 interface address: %s", ipaddr_string(tptr)); + tptr+=sizeof(struct in_addr); + tmp-=sizeof(struct in_addr); + + if (tmp < sizeof(struct in_addr)) + break; + if (!TTEST2(*tptr,sizeof(struct in_addr))) + goto trunctlv; + printf("\n\t IPv4 neighbor address: %s", ipaddr_string(tptr)); + tptr+=sizeof(struct in_addr); + tmp-=sizeof(struct in_addr); + + while (tmp>=4) { + if (!TTEST2(*tptr, 4)) + goto trunctlv; + printf("\n\t Link-ID: 0x%08x", EXTRACT_32BITS(tptr)); + tptr+=4; + tmp-=4; + } + break; + + case ISIS_TLV_LSP: + tlv_lsp = (const struct isis_tlv_lsp *)tptr; + while(tmp>=sizeof(struct isis_tlv_lsp)) { + if (!TTEST((tlv_lsp->lsp_id)[LSP_ID_LEN-1])) + goto trunctlv; + printf("\n\t lsp-id: %s", + isis_print_id(tlv_lsp->lsp_id, LSP_ID_LEN)); + if (!TTEST2(tlv_lsp->sequence_number, 4)) + goto trunctlv; + printf(", seq: 0x%08x",EXTRACT_32BITS(tlv_lsp->sequence_number)); + if (!TTEST2(tlv_lsp->remaining_lifetime, 2)) + goto trunctlv; + printf(", lifetime: %5ds",EXTRACT_16BITS(tlv_lsp->remaining_lifetime)); + if (!TTEST2(tlv_lsp->checksum, 2)) + goto trunctlv; + printf(", chksum: 0x%04x",EXTRACT_16BITS(tlv_lsp->checksum)); + tmp-=sizeof(struct isis_tlv_lsp); + tlv_lsp++; + } + break; + + case ISIS_TLV_CHECKSUM: + if (tmp < ISIS_TLV_CHECKSUM_MINLEN) + break; + if (!TTEST2(*tptr, ISIS_TLV_CHECKSUM_MINLEN)) + goto trunctlv; + printf("\n\t checksum: 0x%04x ", EXTRACT_16BITS(tptr)); + /* do not attempt to verify the checksum if it is zero + * most likely a HMAC-MD5 TLV is also present and + * to avoid conflicts the checksum TLV is zeroed. + * see rfc3358 for details + */ + osi_print_cksum(optr, EXTRACT_16BITS(tptr), tptr-optr, length); + break; + + case ISIS_TLV_MT_SUPPORTED: + if (tmp < ISIS_TLV_MT_SUPPORTED_MINLEN) + break; + while (tmp>1) { + /* length can only be a multiple of 2, otherwise there is + something broken -> so decode down until length is 1 */ + if (tmp!=1) { + mt_len = isis_print_mtid(tptr, "\n\t "); + if (mt_len == 0) /* did something go wrong ? */ + goto trunctlv; + tptr+=mt_len; + tmp-=mt_len; + } else { + printf("\n\t malformed MT-ID"); + break; + } + } + break; + + case ISIS_TLV_RESTART_SIGNALING: + /* first attempt to decode the flags */ + if (tmp < ISIS_TLV_RESTART_SIGNALING_FLAGLEN) + break; + if (!TTEST2(*tptr, ISIS_TLV_RESTART_SIGNALING_FLAGLEN)) + goto trunctlv; + printf("\n\t Flags [%s]", + bittok2str(isis_restart_flag_values, "none", *tptr)); + tptr+=ISIS_TLV_RESTART_SIGNALING_FLAGLEN; + tmp-=ISIS_TLV_RESTART_SIGNALING_FLAGLEN; + + /* is there anything other than the flags field? */ + if (tmp == 0) + break; + + if (tmp < ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN) + break; + if (!TTEST2(*tptr, ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN)) + goto trunctlv; + + printf(", Remaining holding time %us", EXTRACT_16BITS(tptr)); + tptr+=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN; + tmp-=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN; + + /* is there an additional sysid field present ?*/ + if (tmp == SYSTEM_ID_LEN) { + if (!TTEST2(*tptr, SYSTEM_ID_LEN)) + goto trunctlv; + printf(", for %s",isis_print_id(tptr,SYSTEM_ID_LEN)); + } + break; + + case ISIS_TLV_IDRP_INFO: + if (tmp < ISIS_TLV_IDRP_INFO_MINLEN) + break; + if (!TTEST2(*tptr, ISIS_TLV_IDRP_INFO_MINLEN)) + goto trunctlv; + printf("\n\t Inter-Domain Information Type: %s", + tok2str(isis_subtlv_idrp_values, + "Unknown (0x%02x)", + *tptr)); + switch (*tptr++) { + case ISIS_SUBTLV_IDRP_ASN: + if (!TTEST2(*tptr, 2)) /* fetch AS number */ + goto trunctlv; + printf("AS Number: %u",EXTRACT_16BITS(tptr)); + break; + case ISIS_SUBTLV_IDRP_LOCAL: + case ISIS_SUBTLV_IDRP_RES: + default: + if(!print_unknown_data(tptr,"\n\t ",tlv_len-1)) + return(0); + break; + } + break; + + case ISIS_TLV_LSP_BUFFERSIZE: + if (tmp < ISIS_TLV_LSP_BUFFERSIZE_MINLEN) + break; + if (!TTEST2(*tptr, ISIS_TLV_LSP_BUFFERSIZE_MINLEN)) + goto trunctlv; + printf("\n\t LSP Buffersize: %u",EXTRACT_16BITS(tptr)); + break; + + case ISIS_TLV_PART_DIS: + while (tmp >= SYSTEM_ID_LEN) { + if (!TTEST2(*tptr, SYSTEM_ID_LEN)) + goto trunctlv; + printf("\n\t %s",isis_print_id(tptr,SYSTEM_ID_LEN)); + tptr+=SYSTEM_ID_LEN; + tmp-=SYSTEM_ID_LEN; + } + break; + + case ISIS_TLV_PREFIX_NEIGH: + if (tmp < sizeof(struct isis_metric_block)) + break; + if (!TTEST2(*tptr, sizeof(struct isis_metric_block))) + goto trunctlv; + printf("\n\t Metric Block"); + isis_print_metric_block((const struct isis_metric_block *)tptr); + tptr+=sizeof(struct isis_metric_block); + tmp-=sizeof(struct isis_metric_block); + + while(tmp>0) { + if (!TTEST2(*tptr, 1)) + goto trunctlv; + prefix_len=*tptr++; /* read out prefix length in semioctets*/ + if (prefix_len < 2) { + printf("\n\t\tAddress: prefix length %u < 2", prefix_len); + break; + } + tmp--; + if (tmp < prefix_len/2) + break; + if (!TTEST2(*tptr, prefix_len/2)) + goto trunctlv; + printf("\n\t\tAddress: %s/%u", + isonsap_string(tptr,prefix_len/2), + prefix_len*4); + tptr+=prefix_len/2; + tmp-=prefix_len/2; + } + break; + + case ISIS_TLV_IIH_SEQNR: + if (tmp < ISIS_TLV_IIH_SEQNR_MINLEN) + break; + if (!TTEST2(*tptr, ISIS_TLV_IIH_SEQNR_MINLEN)) /* check if four bytes are on the wire */ + goto trunctlv; + printf("\n\t Sequence number: %u", EXTRACT_32BITS(tptr) ); + break; + + case ISIS_TLV_VENDOR_PRIVATE: + if (tmp < ISIS_TLV_VENDOR_PRIVATE_MINLEN) + break; + if (!TTEST2(*tptr, ISIS_TLV_VENDOR_PRIVATE_MINLEN)) /* check if enough byte for a full oui */ + goto trunctlv; + vendor_id = EXTRACT_24BITS(tptr); + printf("\n\t Vendor: %s (%u)", + tok2str(oui_values,"Unknown",vendor_id), + vendor_id); + tptr+=3; + tmp-=3; + if (tmp > 0) /* hexdump the rest */ + if(!print_unknown_data(tptr,"\n\t\t",tmp)) + return(0); + break; + /* + * FIXME those are the defined TLVs that lack a decoder + * you are welcome to contribute code ;-) + */ + + case ISIS_TLV_DECNET_PHASE4: + case ISIS_TLV_LUCENT_PRIVATE: + case ISIS_TLV_IPAUTH: + case ISIS_TLV_NORTEL_PRIVATE1: + case ISIS_TLV_NORTEL_PRIVATE2: + + default: + if (vflag <= 1) { + if(!print_unknown_data(pptr,"\n\t\t",tlv_len)) + return(0); + } + break; + } + /* do we want to see an additionally hexdump ? */ + if (vflag> 1) { + if(!print_unknown_data(pptr,"\n\t ",tlv_len)) + return(0); + } + + pptr += tlv_len; + packet_len -= tlv_len; + } + + if (packet_len != 0) { + printf("\n\t %u straggler bytes", packet_len); + } + return (1); + + trunc: + fputs("[|isis]", stdout); + return (1); + + trunctlv: + printf("\n\t\t packet exceeded snapshot"); + return(1); +} + +static void +osi_print_cksum (const u_int8_t *pptr, u_int16_t checksum, + u_int checksum_offset, u_int length) +{ + u_int16_t calculated_checksum; + + /* do not attempt to verify the checksum if it is zero */ + if (!checksum) { + printf("(unverified)"); + } else { + calculated_checksum = create_osi_cksum(pptr, checksum_offset, length); + if (checksum == calculated_checksum) { + printf(" (correct)"); + } else { + printf(" (incorrect should be 0x%04x)", calculated_checksum); + } + } +} + +/* + * Local Variables: + * c-style: whitesmith + * c-basic-offset: 8 + * End: + */
diff --git a/tcpdump-4.3.0/print-juniper.c b/tcpdump-4.3.0/print-juniper.c new file mode 100644 index 0000000..3bf68c3 --- /dev/null +++ b/tcpdump-4.3.0/print-juniper.c
@@ -0,0 +1,1456 @@ +/* NetBSD: print-juniper.c,v 1.2 2007/07/24 11:53:45 drochner Exp */ + +/* + * 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-juniper.c,v 1.34 2007-08-29 02:31:44 mcr Exp $ (LBL)"; +#else +__RCSID("NetBSD: print-juniper.c,v 1.3 2007/07/25 06:31:32 dogcow Exp "); +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <pcap.h> +#include <stdio.h> + +#include "interface.h" +#include "addrtoname.h" +#include "extract.h" +#include "ppp.h" +#include "llc.h" +#include "nlpid.h" +#include "ethertype.h" +#include "atm.h" + +#define JUNIPER_BPF_OUT 0 /* Outgoing packet */ +#define JUNIPER_BPF_IN 1 /* Incoming packet */ +#define JUNIPER_BPF_PKT_IN 0x1 /* Incoming packet */ +#define JUNIPER_BPF_NO_L2 0x2 /* L2 header stripped */ +#define JUNIPER_BPF_IIF 0x4 /* IIF is valid */ +#define JUNIPER_BPF_FILTER 0x40 /* BPF filtering is supported */ +#define JUNIPER_BPF_EXT 0x80 /* extensions present */ +#define JUNIPER_MGC_NUMBER 0x4d4743 /* = "MGC" */ + +#define JUNIPER_LSQ_COOKIE_RE (1 << 3) +#define JUNIPER_LSQ_COOKIE_DIR (1 << 2) +#define JUNIPER_LSQ_L3_PROTO_SHIFT 4 +#define JUNIPER_LSQ_L3_PROTO_MASK (0x17 << JUNIPER_LSQ_L3_PROTO_SHIFT) +#define JUNIPER_LSQ_L3_PROTO_IPV4 (0 << JUNIPER_LSQ_L3_PROTO_SHIFT) +#define JUNIPER_LSQ_L3_PROTO_IPV6 (1 << JUNIPER_LSQ_L3_PROTO_SHIFT) +#define JUNIPER_LSQ_L3_PROTO_MPLS (2 << JUNIPER_LSQ_L3_PROTO_SHIFT) +#define JUNIPER_LSQ_L3_PROTO_ISO (3 << JUNIPER_LSQ_L3_PROTO_SHIFT) +#define AS_PIC_COOKIE_LEN 8 + +#define JUNIPER_IPSEC_O_ESP_ENCRYPT_ESP_AUTHEN_TYPE 1 +#define JUNIPER_IPSEC_O_ESP_ENCRYPT_AH_AUTHEN_TYPE 2 +#define JUNIPER_IPSEC_O_ESP_AUTHENTICATION_TYPE 3 +#define JUNIPER_IPSEC_O_AH_AUTHENTICATION_TYPE 4 +#define JUNIPER_IPSEC_O_ESP_ENCRYPTION_TYPE 5 + +static struct tok juniper_ipsec_type_values[] = { + { JUNIPER_IPSEC_O_ESP_ENCRYPT_ESP_AUTHEN_TYPE, "ESP ENCR-AUTH" }, + { JUNIPER_IPSEC_O_ESP_ENCRYPT_AH_AUTHEN_TYPE, "ESP ENCR-AH AUTH" }, + { JUNIPER_IPSEC_O_ESP_AUTHENTICATION_TYPE, "ESP AUTH" }, + { JUNIPER_IPSEC_O_AH_AUTHENTICATION_TYPE, "AH AUTH" }, + { JUNIPER_IPSEC_O_ESP_ENCRYPTION_TYPE, "ESP ENCR" }, + { 0, NULL} +}; + +static struct tok juniper_direction_values[] = { + { JUNIPER_BPF_IN, "In"}, + { JUNIPER_BPF_OUT, "Out"}, + { 0, NULL} +}; + +/* codepoints for encoding extensions to a .pcap file */ +enum { + JUNIPER_EXT_TLV_IFD_IDX = 1, + JUNIPER_EXT_TLV_IFD_NAME = 2, + JUNIPER_EXT_TLV_IFD_MEDIATYPE = 3, + JUNIPER_EXT_TLV_IFL_IDX = 4, + JUNIPER_EXT_TLV_IFL_UNIT = 5, + JUNIPER_EXT_TLV_IFL_ENCAPS = 6, + JUNIPER_EXT_TLV_TTP_IFD_MEDIATYPE = 7, + JUNIPER_EXT_TLV_TTP_IFL_ENCAPS = 8 +}; + +/* 1 byte type and 1-byte length */ +#define JUNIPER_EXT_TLV_OVERHEAD 2 + +struct tok jnx_ext_tlv_values[] = { + { JUNIPER_EXT_TLV_IFD_IDX, "Device Interface Index" }, + { JUNIPER_EXT_TLV_IFD_NAME,"Device Interface Name" }, + { JUNIPER_EXT_TLV_IFD_MEDIATYPE, "Device Media Type" }, + { JUNIPER_EXT_TLV_IFL_IDX, "Logical Interface Index" }, + { JUNIPER_EXT_TLV_IFL_UNIT,"Logical Unit Number" }, + { JUNIPER_EXT_TLV_IFL_ENCAPS, "Logical Interface Encapsulation" }, + { JUNIPER_EXT_TLV_TTP_IFD_MEDIATYPE, "TTP derived Device Media Type" }, + { JUNIPER_EXT_TLV_TTP_IFL_ENCAPS, "TTP derived Logical Interface Encapsulation" }, + { 0, NULL } +}; + +struct tok jnx_flag_values[] = { + { JUNIPER_BPF_EXT, "Ext" }, + { JUNIPER_BPF_FILTER, "Filter" }, + { JUNIPER_BPF_IIF, "IIF" }, + { JUNIPER_BPF_NO_L2, "no-L2" }, + { JUNIPER_BPF_PKT_IN, "In" }, + { 0, NULL } +}; + +#define JUNIPER_IFML_ETHER 1 +#define JUNIPER_IFML_FDDI 2 +#define JUNIPER_IFML_TOKENRING 3 +#define JUNIPER_IFML_PPP 4 +#define JUNIPER_IFML_FRAMERELAY 5 +#define JUNIPER_IFML_CISCOHDLC 6 +#define JUNIPER_IFML_SMDSDXI 7 +#define JUNIPER_IFML_ATMPVC 8 +#define JUNIPER_IFML_PPP_CCC 9 +#define JUNIPER_IFML_FRAMERELAY_CCC 10 +#define JUNIPER_IFML_IPIP 11 +#define JUNIPER_IFML_GRE 12 +#define JUNIPER_IFML_PIM 13 +#define JUNIPER_IFML_PIMD 14 +#define JUNIPER_IFML_CISCOHDLC_CCC 15 +#define JUNIPER_IFML_VLAN_CCC 16 +#define JUNIPER_IFML_MLPPP 17 +#define JUNIPER_IFML_MLFR 18 +#define JUNIPER_IFML_ML 19 +#define JUNIPER_IFML_LSI 20 +#define JUNIPER_IFML_DFE 21 +#define JUNIPER_IFML_ATM_CELLRELAY_CCC 22 +#define JUNIPER_IFML_CRYPTO 23 +#define JUNIPER_IFML_GGSN 24 +#define JUNIPER_IFML_LSI_PPP 25 +#define JUNIPER_IFML_LSI_CISCOHDLC 26 +#define JUNIPER_IFML_PPP_TCC 27 +#define JUNIPER_IFML_FRAMERELAY_TCC 28 +#define JUNIPER_IFML_CISCOHDLC_TCC 29 +#define JUNIPER_IFML_ETHERNET_CCC 30 +#define JUNIPER_IFML_VT 31 +#define JUNIPER_IFML_EXTENDED_VLAN_CCC 32 +#define JUNIPER_IFML_ETHER_OVER_ATM 33 +#define JUNIPER_IFML_MONITOR 34 +#define JUNIPER_IFML_ETHERNET_TCC 35 +#define JUNIPER_IFML_VLAN_TCC 36 +#define JUNIPER_IFML_EXTENDED_VLAN_TCC 37 +#define JUNIPER_IFML_CONTROLLER 38 +#define JUNIPER_IFML_MFR 39 +#define JUNIPER_IFML_LS 40 +#define JUNIPER_IFML_ETHERNET_VPLS 41 +#define JUNIPER_IFML_ETHERNET_VLAN_VPLS 42 +#define JUNIPER_IFML_ETHERNET_EXTENDED_VLAN_VPLS 43 +#define JUNIPER_IFML_LT 44 +#define JUNIPER_IFML_SERVICES 45 +#define JUNIPER_IFML_ETHER_VPLS_OVER_ATM 46 +#define JUNIPER_IFML_FR_PORT_CCC 47 +#define JUNIPER_IFML_FRAMERELAY_EXT_CCC 48 +#define JUNIPER_IFML_FRAMERELAY_EXT_TCC 49 +#define JUNIPER_IFML_FRAMERELAY_FLEX 50 +#define JUNIPER_IFML_GGSNI 51 +#define JUNIPER_IFML_ETHERNET_FLEX 52 +#define JUNIPER_IFML_COLLECTOR 53 +#define JUNIPER_IFML_AGGREGATOR 54 +#define JUNIPER_IFML_LAPD 55 +#define JUNIPER_IFML_PPPOE 56 +#define JUNIPER_IFML_PPP_SUBORDINATE 57 +#define JUNIPER_IFML_CISCOHDLC_SUBORDINATE 58 +#define JUNIPER_IFML_DFC 59 +#define JUNIPER_IFML_PICPEER 60 + +struct tok juniper_ifmt_values[] = { + { JUNIPER_IFML_ETHER, "Ethernet" }, + { JUNIPER_IFML_FDDI, "FDDI" }, + { JUNIPER_IFML_TOKENRING, "Token-Ring" }, + { JUNIPER_IFML_PPP, "PPP" }, + { JUNIPER_IFML_PPP_SUBORDINATE, "PPP-Subordinate" }, + { JUNIPER_IFML_FRAMERELAY, "Frame-Relay" }, + { JUNIPER_IFML_CISCOHDLC, "Cisco-HDLC" }, + { JUNIPER_IFML_SMDSDXI, "SMDS-DXI" }, + { JUNIPER_IFML_ATMPVC, "ATM-PVC" }, + { JUNIPER_IFML_PPP_CCC, "PPP-CCC" }, + { JUNIPER_IFML_FRAMERELAY_CCC, "Frame-Relay-CCC" }, + { JUNIPER_IFML_FRAMERELAY_EXT_CCC, "Extended FR-CCC" }, + { JUNIPER_IFML_IPIP, "IP-over-IP" }, + { JUNIPER_IFML_GRE, "GRE" }, + { JUNIPER_IFML_PIM, "PIM-Encapsulator" }, + { JUNIPER_IFML_PIMD, "PIM-Decapsulator" }, + { JUNIPER_IFML_CISCOHDLC_CCC, "Cisco-HDLC-CCC" }, + { JUNIPER_IFML_VLAN_CCC, "VLAN-CCC" }, + { JUNIPER_IFML_EXTENDED_VLAN_CCC, "Extended-VLAN-CCC" }, + { JUNIPER_IFML_MLPPP, "Multilink-PPP" }, + { JUNIPER_IFML_MLFR, "Multilink-FR" }, + { JUNIPER_IFML_MFR, "Multilink-FR-UNI-NNI" }, + { JUNIPER_IFML_ML, "Multilink" }, + { JUNIPER_IFML_LS, "LinkService" }, + { JUNIPER_IFML_LSI, "LSI" }, + { JUNIPER_IFML_ATM_CELLRELAY_CCC, "ATM-CCC-Cell-Relay" }, + { JUNIPER_IFML_CRYPTO, "IPSEC-over-IP" }, + { JUNIPER_IFML_GGSN, "GGSN" }, + { JUNIPER_IFML_PPP_TCC, "PPP-TCC" }, + { JUNIPER_IFML_FRAMERELAY_TCC, "Frame-Relay-TCC" }, + { JUNIPER_IFML_FRAMERELAY_EXT_TCC, "Extended FR-TCC" }, + { JUNIPER_IFML_CISCOHDLC_TCC, "Cisco-HDLC-TCC" }, + { JUNIPER_IFML_ETHERNET_CCC, "Ethernet-CCC" }, + { JUNIPER_IFML_VT, "VPN-Loopback-tunnel" }, + { JUNIPER_IFML_ETHER_OVER_ATM, "Ethernet-over-ATM" }, + { JUNIPER_IFML_ETHER_VPLS_OVER_ATM, "Ethernet-VPLS-over-ATM" }, + { JUNIPER_IFML_MONITOR, "Monitor" }, + { JUNIPER_IFML_ETHERNET_TCC, "Ethernet-TCC" }, + { JUNIPER_IFML_VLAN_TCC, "VLAN-TCC" }, + { JUNIPER_IFML_EXTENDED_VLAN_TCC, "Extended-VLAN-TCC" }, + { JUNIPER_IFML_CONTROLLER, "Controller" }, + { JUNIPER_IFML_ETHERNET_VPLS, "VPLS" }, + { JUNIPER_IFML_ETHERNET_VLAN_VPLS, "VLAN-VPLS" }, + { JUNIPER_IFML_ETHERNET_EXTENDED_VLAN_VPLS, "Extended-VLAN-VPLS" }, + { JUNIPER_IFML_LT, "Logical-tunnel" }, + { JUNIPER_IFML_SERVICES, "General-Services" }, + { JUNIPER_IFML_PPPOE, "PPPoE" }, + { JUNIPER_IFML_ETHERNET_FLEX, "Flexible-Ethernet-Services" }, + { JUNIPER_IFML_FRAMERELAY_FLEX, "Flexible-FrameRelay" }, + { JUNIPER_IFML_COLLECTOR, "Flow-collection" }, + { JUNIPER_IFML_PICPEER, "PIC Peer" }, + { JUNIPER_IFML_DFC, "Dynamic-Flow-Capture" }, + {0, NULL} +}; + +#define JUNIPER_IFLE_ATM_SNAP 2 +#define JUNIPER_IFLE_ATM_NLPID 3 +#define JUNIPER_IFLE_ATM_VCMUX 4 +#define JUNIPER_IFLE_ATM_LLC 5 +#define JUNIPER_IFLE_ATM_PPP_VCMUX 6 +#define JUNIPER_IFLE_ATM_PPP_LLC 7 +#define JUNIPER_IFLE_ATM_PPP_FUNI 8 +#define JUNIPER_IFLE_ATM_CCC 9 +#define JUNIPER_IFLE_FR_NLPID 10 +#define JUNIPER_IFLE_FR_SNAP 11 +#define JUNIPER_IFLE_FR_PPP 12 +#define JUNIPER_IFLE_FR_CCC 13 +#define JUNIPER_IFLE_ENET2 14 +#define JUNIPER_IFLE_IEEE8023_SNAP 15 +#define JUNIPER_IFLE_IEEE8023_LLC 16 +#define JUNIPER_IFLE_PPP 17 +#define JUNIPER_IFLE_CISCOHDLC 18 +#define JUNIPER_IFLE_PPP_CCC 19 +#define JUNIPER_IFLE_IPIP_NULL 20 +#define JUNIPER_IFLE_PIM_NULL 21 +#define JUNIPER_IFLE_GRE_NULL 22 +#define JUNIPER_IFLE_GRE_PPP 23 +#define JUNIPER_IFLE_PIMD_DECAPS 24 +#define JUNIPER_IFLE_CISCOHDLC_CCC 25 +#define JUNIPER_IFLE_ATM_CISCO_NLPID 26 +#define JUNIPER_IFLE_VLAN_CCC 27 +#define JUNIPER_IFLE_MLPPP 28 +#define JUNIPER_IFLE_MLFR 29 +#define JUNIPER_IFLE_LSI_NULL 30 +#define JUNIPER_IFLE_AGGREGATE_UNUSED 31 +#define JUNIPER_IFLE_ATM_CELLRELAY_CCC 32 +#define JUNIPER_IFLE_CRYPTO 33 +#define JUNIPER_IFLE_GGSN 34 +#define JUNIPER_IFLE_ATM_TCC 35 +#define JUNIPER_IFLE_FR_TCC 36 +#define JUNIPER_IFLE_PPP_TCC 37 +#define JUNIPER_IFLE_CISCOHDLC_TCC 38 +#define JUNIPER_IFLE_ETHERNET_CCC 39 +#define JUNIPER_IFLE_VT 40 +#define JUNIPER_IFLE_ATM_EOA_LLC 41 +#define JUNIPER_IFLE_EXTENDED_VLAN_CCC 42 +#define JUNIPER_IFLE_ATM_SNAP_TCC 43 +#define JUNIPER_IFLE_MONITOR 44 +#define JUNIPER_IFLE_ETHERNET_TCC 45 +#define JUNIPER_IFLE_VLAN_TCC 46 +#define JUNIPER_IFLE_EXTENDED_VLAN_TCC 47 +#define JUNIPER_IFLE_MFR 48 +#define JUNIPER_IFLE_ETHERNET_VPLS 49 +#define JUNIPER_IFLE_ETHERNET_VLAN_VPLS 50 +#define JUNIPER_IFLE_ETHERNET_EXTENDED_VLAN_VPLS 51 +#define JUNIPER_IFLE_SERVICES 52 +#define JUNIPER_IFLE_ATM_ETHER_VPLS_ATM_LLC 53 +#define JUNIPER_IFLE_FR_PORT_CCC 54 +#define JUNIPER_IFLE_ATM_MLPPP_LLC 55 +#define JUNIPER_IFLE_ATM_EOA_CCC 56 +#define JUNIPER_IFLE_LT_VLAN 57 +#define JUNIPER_IFLE_COLLECTOR 58 +#define JUNIPER_IFLE_AGGREGATOR 59 +#define JUNIPER_IFLE_LAPD 60 +#define JUNIPER_IFLE_ATM_PPPOE_LLC 61 +#define JUNIPER_IFLE_ETHERNET_PPPOE 62 +#define JUNIPER_IFLE_PPPOE 63 +#define JUNIPER_IFLE_PPP_SUBORDINATE 64 +#define JUNIPER_IFLE_CISCOHDLC_SUBORDINATE 65 +#define JUNIPER_IFLE_DFC 66 +#define JUNIPER_IFLE_PICPEER 67 + +struct tok juniper_ifle_values[] = { + { JUNIPER_IFLE_AGGREGATOR, "Aggregator" }, + { JUNIPER_IFLE_ATM_CCC, "CCC over ATM" }, + { JUNIPER_IFLE_ATM_CELLRELAY_CCC, "ATM CCC Cell Relay" }, + { JUNIPER_IFLE_ATM_CISCO_NLPID, "CISCO compatible NLPID" }, + { JUNIPER_IFLE_ATM_EOA_CCC, "Ethernet over ATM CCC" }, + { JUNIPER_IFLE_ATM_EOA_LLC, "Ethernet over ATM LLC" }, + { JUNIPER_IFLE_ATM_ETHER_VPLS_ATM_LLC, "Ethernet VPLS over ATM LLC" }, + { JUNIPER_IFLE_ATM_LLC, "ATM LLC" }, + { JUNIPER_IFLE_ATM_MLPPP_LLC, "MLPPP over ATM LLC" }, + { JUNIPER_IFLE_ATM_NLPID, "ATM NLPID" }, + { JUNIPER_IFLE_ATM_PPPOE_LLC, "PPPoE over ATM LLC" }, + { JUNIPER_IFLE_ATM_PPP_FUNI, "PPP over FUNI" }, + { JUNIPER_IFLE_ATM_PPP_LLC, "PPP over ATM LLC" }, + { JUNIPER_IFLE_ATM_PPP_VCMUX, "PPP over ATM VCMUX" }, + { JUNIPER_IFLE_ATM_SNAP, "ATM SNAP" }, + { JUNIPER_IFLE_ATM_SNAP_TCC, "ATM SNAP TCC" }, + { JUNIPER_IFLE_ATM_TCC, "ATM VCMUX TCC" }, + { JUNIPER_IFLE_ATM_VCMUX, "ATM VCMUX" }, + { JUNIPER_IFLE_CISCOHDLC, "C-HDLC" }, + { JUNIPER_IFLE_CISCOHDLC_CCC, "C-HDLC CCC" }, + { JUNIPER_IFLE_CISCOHDLC_SUBORDINATE, "C-HDLC via dialer" }, + { JUNIPER_IFLE_CISCOHDLC_TCC, "C-HDLC TCC" }, + { JUNIPER_IFLE_COLLECTOR, "Collector" }, + { JUNIPER_IFLE_CRYPTO, "Crypto" }, + { JUNIPER_IFLE_ENET2, "Ethernet" }, + { JUNIPER_IFLE_ETHERNET_CCC, "Ethernet CCC" }, + { JUNIPER_IFLE_ETHERNET_EXTENDED_VLAN_VPLS, "Extended VLAN VPLS" }, + { JUNIPER_IFLE_ETHERNET_PPPOE, "PPPoE over Ethernet" }, + { JUNIPER_IFLE_ETHERNET_TCC, "Ethernet TCC" }, + { JUNIPER_IFLE_ETHERNET_VLAN_VPLS, "VLAN VPLS" }, + { JUNIPER_IFLE_ETHERNET_VPLS, "VPLS" }, + { JUNIPER_IFLE_EXTENDED_VLAN_CCC, "Extended VLAN CCC" }, + { JUNIPER_IFLE_EXTENDED_VLAN_TCC, "Extended VLAN TCC" }, + { JUNIPER_IFLE_FR_CCC, "FR CCC" }, + { JUNIPER_IFLE_FR_NLPID, "FR NLPID" }, + { JUNIPER_IFLE_FR_PORT_CCC, "FR CCC" }, + { JUNIPER_IFLE_FR_PPP, "FR PPP" }, + { JUNIPER_IFLE_FR_SNAP, "FR SNAP" }, + { JUNIPER_IFLE_FR_TCC, "FR TCC" }, + { JUNIPER_IFLE_GGSN, "GGSN" }, + { JUNIPER_IFLE_GRE_NULL, "GRE NULL" }, + { JUNIPER_IFLE_GRE_PPP, "PPP over GRE" }, + { JUNIPER_IFLE_IPIP_NULL, "IPIP" }, + { JUNIPER_IFLE_LAPD, "LAPD" }, + { JUNIPER_IFLE_LSI_NULL, "LSI Null" }, + { JUNIPER_IFLE_LT_VLAN, "LT VLAN" }, + { JUNIPER_IFLE_MFR, "MFR" }, + { JUNIPER_IFLE_MLFR, "MLFR" }, + { JUNIPER_IFLE_MLPPP, "MLPPP" }, + { JUNIPER_IFLE_MONITOR, "Monitor" }, + { JUNIPER_IFLE_PIMD_DECAPS, "PIMd" }, + { JUNIPER_IFLE_PIM_NULL, "PIM Null" }, + { JUNIPER_IFLE_PPP, "PPP" }, + { JUNIPER_IFLE_PPPOE, "PPPoE" }, + { JUNIPER_IFLE_PPP_CCC, "PPP CCC" }, + { JUNIPER_IFLE_PPP_SUBORDINATE, "" }, + { JUNIPER_IFLE_PPP_TCC, "PPP TCC" }, + { JUNIPER_IFLE_SERVICES, "General Services" }, + { JUNIPER_IFLE_VLAN_CCC, "VLAN CCC" }, + { JUNIPER_IFLE_VLAN_TCC, "VLAN TCC" }, + { JUNIPER_IFLE_VT, "VT" }, + {0, NULL} +}; + +struct juniper_cookie_table_t { + u_int32_t pictype; /* pic type */ + u_int8_t cookie_len; /* cookie len */ + const char *s; /* pic name */ +}; + +static struct juniper_cookie_table_t juniper_cookie_table[] = { +#ifdef DLT_JUNIPER_ATM1 + { DLT_JUNIPER_ATM1, 4, "ATM1"}, +#endif +#ifdef DLT_JUNIPER_ATM2 + { DLT_JUNIPER_ATM2, 8, "ATM2"}, +#endif +#ifdef DLT_JUNIPER_MLPPP + { DLT_JUNIPER_MLPPP, 2, "MLPPP"}, +#endif +#ifdef DLT_JUNIPER_MLFR + { DLT_JUNIPER_MLFR, 2, "MLFR"}, +#endif +#ifdef DLT_JUNIPER_MFR + { DLT_JUNIPER_MFR, 4, "MFR"}, +#endif +#ifdef DLT_JUNIPER_PPPOE + { DLT_JUNIPER_PPPOE, 0, "PPPoE"}, +#endif +#ifdef DLT_JUNIPER_PPPOE_ATM + { DLT_JUNIPER_PPPOE_ATM, 0, "PPPoE ATM"}, +#endif +#ifdef DLT_JUNIPER_GGSN + { DLT_JUNIPER_GGSN, 8, "GGSN"}, +#endif +#ifdef DLT_JUNIPER_MONITOR + { DLT_JUNIPER_MONITOR, 8, "MONITOR"}, +#endif +#ifdef DLT_JUNIPER_SERVICES + { DLT_JUNIPER_SERVICES, 8, "AS"}, +#endif +#ifdef DLT_JUNIPER_ES + { DLT_JUNIPER_ES, 0, "ES"}, +#endif + { 0, 0, NULL } +}; + +struct juniper_l2info_t { + u_int32_t length; + u_int32_t caplen; + u_int32_t pictype; + u_int8_t direction; + u_int8_t header_len; + u_int8_t cookie_len; + u_int8_t cookie_type; + u_int8_t cookie[8]; + u_int8_t bundle; + u_int16_t proto; + u_int8_t flags; +}; + +#define LS_COOKIE_ID 0x54 +#define AS_COOKIE_ID 0x47 +#define LS_MLFR_COOKIE_LEN 4 +#define ML_MLFR_COOKIE_LEN 2 +#define LS_MFR_COOKIE_LEN 6 +#define ATM1_COOKIE_LEN 4 +#define ATM2_COOKIE_LEN 8 + +#define ATM2_PKT_TYPE_MASK 0x70 +#define ATM2_GAP_COUNT_MASK 0x3F + +#define JUNIPER_PROTO_NULL 1 +#define JUNIPER_PROTO_IPV4 2 +#define JUNIPER_PROTO_IPV6 6 + +#define MFR_BE_MASK 0xc0 + +static struct tok juniper_protocol_values[] = { + { JUNIPER_PROTO_NULL, "Null" }, + { JUNIPER_PROTO_IPV4, "IPv4" }, + { JUNIPER_PROTO_IPV6, "IPv6" }, + { 0, NULL} +}; + +int ip_heuristic_guess(register const u_char *, u_int); +int juniper_ppp_heuristic_guess(register const u_char *, u_int); +int juniper_read_tlv_value(const u_char *, u_int, u_int); +static int juniper_parse_header (const u_char *, const struct pcap_pkthdr *, struct juniper_l2info_t *); + +#ifdef DLT_JUNIPER_GGSN +u_int +juniper_ggsn_print(const struct pcap_pkthdr *h, register const u_char *p) +{ + struct juniper_l2info_t l2info; + struct juniper_ggsn_header { + u_int8_t svc_id; + u_int8_t flags_len; + u_int8_t proto; + u_int8_t flags; + u_int8_t vlan_id[2]; + u_int8_t res[2]; + }; + const struct juniper_ggsn_header *gh; + + l2info.pictype = DLT_JUNIPER_GGSN; + if(juniper_parse_header(p, h, &l2info) == 0) + return l2info.header_len; + + p+=l2info.header_len; + gh = (struct juniper_ggsn_header *)&l2info.cookie; + + if (eflag) { + printf("proto %s (%u), vlan %u: ", + tok2str(juniper_protocol_values,"Unknown",gh->proto), + gh->proto, + EXTRACT_16BITS(&gh->vlan_id[0])); + } + + switch (gh->proto) { + case JUNIPER_PROTO_IPV4: + ip_print(gndo, p, l2info.length); + break; +#ifdef INET6 + case JUNIPER_PROTO_IPV6: + ip6_print(gndo, p, l2info.length); + break; +#endif /* INET6 */ + default: + if (!eflag) + printf("unknown GGSN proto (%u)", gh->proto); + } + + return l2info.header_len; +} +#endif + +#ifdef DLT_JUNIPER_ES +u_int +juniper_es_print(const struct pcap_pkthdr *h, register const u_char *p) +{ + struct juniper_l2info_t l2info; + struct juniper_ipsec_header { + u_int8_t sa_index[2]; + u_int8_t ttl; + u_int8_t type; + u_int8_t spi[4]; + u_int8_t src_ip[4]; + u_int8_t dst_ip[4]; + }; + u_int rewrite_len,es_type_bundle; + const struct juniper_ipsec_header *ih; + + l2info.pictype = DLT_JUNIPER_ES; + if(juniper_parse_header(p, h, &l2info) == 0) + return l2info.header_len; + + p+=l2info.header_len; + ih = (struct juniper_ipsec_header *)p; + + switch (ih->type) { + case JUNIPER_IPSEC_O_ESP_ENCRYPT_ESP_AUTHEN_TYPE: + case JUNIPER_IPSEC_O_ESP_ENCRYPT_AH_AUTHEN_TYPE: + rewrite_len = 0; + es_type_bundle = 1; + break; + case JUNIPER_IPSEC_O_ESP_AUTHENTICATION_TYPE: + case JUNIPER_IPSEC_O_AH_AUTHENTICATION_TYPE: + case JUNIPER_IPSEC_O_ESP_ENCRYPTION_TYPE: + rewrite_len = 16; + es_type_bundle = 0; + default: + printf("ES Invalid type %u, length %u", + ih->type, + l2info.length); + return l2info.header_len; + } + + l2info.length-=rewrite_len; + p+=rewrite_len; + + if (eflag) { + if (!es_type_bundle) { + printf("ES SA, index %u, ttl %u type %s (%u), spi %u, Tunnel %s > %s, length %u\n", + EXTRACT_16BITS(&ih->sa_index), + ih->ttl, + tok2str(juniper_ipsec_type_values,"Unknown",ih->type), + ih->type, + EXTRACT_32BITS(&ih->spi), + ipaddr_string(&ih->src_ip), + ipaddr_string(&ih->dst_ip), + l2info.length); + } else { + printf("ES SA, index %u, ttl %u type %s (%u), length %u\n", + EXTRACT_16BITS(&ih->sa_index), + ih->ttl, + tok2str(juniper_ipsec_type_values,"Unknown",ih->type), + ih->type, + l2info.length); + } + } + + ip_print(gndo, p, l2info.length); + return l2info.header_len; +} +#endif + +#ifdef DLT_JUNIPER_MONITOR +u_int +juniper_monitor_print(const struct pcap_pkthdr *h, register const u_char *p) +{ + struct juniper_l2info_t l2info; + struct juniper_monitor_header { + u_int8_t pkt_type; + u_int8_t padding; + u_int8_t iif[2]; + u_int8_t service_id[4]; + }; + const struct juniper_monitor_header *mh; + + l2info.pictype = DLT_JUNIPER_MONITOR; + if(juniper_parse_header(p, h, &l2info) == 0) + return l2info.header_len; + + p+=l2info.header_len; + mh = (struct juniper_monitor_header *)p; + + if (eflag) + printf("service-id %u, iif %u, pkt-type %u: ", + EXTRACT_32BITS(&mh->service_id), + EXTRACT_16BITS(&mh->iif), + mh->pkt_type); + + /* no proto field - lets guess by first byte of IP header*/ + ip_heuristic_guess(p, l2info.length); + + return l2info.header_len; +} +#endif + +#ifdef DLT_JUNIPER_SERVICES +u_int +juniper_services_print(const struct pcap_pkthdr *h, register const u_char *p) +{ + struct juniper_l2info_t l2info; + struct juniper_services_header { + u_int8_t svc_id; + u_int8_t flags_len; + u_int8_t svc_set_id[2]; + u_int8_t dir_iif[4]; + }; + const struct juniper_services_header *sh; + + l2info.pictype = DLT_JUNIPER_SERVICES; + if(juniper_parse_header(p, h, &l2info) == 0) + return l2info.header_len; + + p+=l2info.header_len; + sh = (struct juniper_services_header *)p; + + if (eflag) + printf("service-id %u flags 0x%02x service-set-id 0x%04x iif %u: ", + sh->svc_id, + sh->flags_len, + EXTRACT_16BITS(&sh->svc_set_id), + EXTRACT_24BITS(&sh->dir_iif[1])); + + /* no proto field - lets guess by first byte of IP header*/ + ip_heuristic_guess(p, l2info.length); + + return l2info.header_len; +} +#endif + +#ifdef DLT_JUNIPER_PPPOE +u_int +juniper_pppoe_print(const struct pcap_pkthdr *h, register const u_char *p) +{ + struct juniper_l2info_t l2info; + + l2info.pictype = DLT_JUNIPER_PPPOE; + if(juniper_parse_header(p, h, &l2info) == 0) + return l2info.header_len; + + p+=l2info.header_len; + /* this DLT contains nothing but raw ethernet frames */ + ether_print(gndo, p, l2info.length, l2info.caplen, NULL, NULL); + return l2info.header_len; +} +#endif + +#ifdef DLT_JUNIPER_ETHER +u_int +juniper_ether_print(const struct pcap_pkthdr *h, register const u_char *p) +{ + struct juniper_l2info_t l2info; + + l2info.pictype = DLT_JUNIPER_ETHER; + if(juniper_parse_header(p, h, &l2info) == 0) + return l2info.header_len; + + p+=l2info.header_len; + /* this DLT contains nothing but raw Ethernet frames */ + ether_print(gndo, p, l2info.length, l2info.caplen, NULL, NULL); + return l2info.header_len; +} +#endif + +#ifdef DLT_JUNIPER_PPP +u_int +juniper_ppp_print(const struct pcap_pkthdr *h, register const u_char *p) +{ + struct juniper_l2info_t l2info; + + l2info.pictype = DLT_JUNIPER_PPP; + if(juniper_parse_header(p, h, &l2info) == 0) + return l2info.header_len; + + p+=l2info.header_len; + /* this DLT contains nothing but raw ppp frames */ + ppp_print(p, l2info.length); + return l2info.header_len; +} +#endif + +#ifdef DLT_JUNIPER_FRELAY +u_int +juniper_frelay_print(const struct pcap_pkthdr *h, register const u_char *p) +{ + struct juniper_l2info_t l2info; + + l2info.pictype = DLT_JUNIPER_FRELAY; + if(juniper_parse_header(p, h, &l2info) == 0) + return l2info.header_len; + + p+=l2info.header_len; + /* this DLT contains nothing but raw frame-relay frames */ + fr_print(p, l2info.length); + return l2info.header_len; +} +#endif + +#ifdef DLT_JUNIPER_CHDLC +u_int +juniper_chdlc_print(const struct pcap_pkthdr *h, register const u_char *p) +{ + struct juniper_l2info_t l2info; + + l2info.pictype = DLT_JUNIPER_CHDLC; + if(juniper_parse_header(p, h, &l2info) == 0) + return l2info.header_len; + + p+=l2info.header_len; + /* this DLT contains nothing but raw c-hdlc frames */ + chdlc_print(p, l2info.length); + return l2info.header_len; +} +#endif + +#ifdef DLT_JUNIPER_PPPOE_ATM +u_int +juniper_pppoe_atm_print(const struct pcap_pkthdr *h, register const u_char *p) +{ + struct juniper_l2info_t l2info; + u_int16_t extracted_ethertype; + + l2info.pictype = DLT_JUNIPER_PPPOE_ATM; + if(juniper_parse_header(p, h, &l2info) == 0) + return l2info.header_len; + + p+=l2info.header_len; + + extracted_ethertype = EXTRACT_16BITS(p); + /* this DLT contains nothing but raw PPPoE frames, + * prepended with a type field*/ + if (ethertype_print(gndo, extracted_ethertype, + p+ETHERTYPE_LEN, + l2info.length-ETHERTYPE_LEN, + l2info.caplen-ETHERTYPE_LEN) == 0) + /* ether_type not known, probably it wasn't one */ + printf("unknown ethertype 0x%04x", extracted_ethertype); + + return l2info.header_len; +} +#endif + +#ifdef DLT_JUNIPER_MLPPP +u_int +juniper_mlppp_print(const struct pcap_pkthdr *h, register const u_char *p) +{ + struct juniper_l2info_t l2info; + + l2info.pictype = DLT_JUNIPER_MLPPP; + if(juniper_parse_header(p, h, &l2info) == 0) + return l2info.header_len; + + /* suppress Bundle-ID if frame was captured on a child-link + * best indicator if the cookie looks like a proto */ + if (eflag && + EXTRACT_16BITS(&l2info.cookie) != PPP_OSI && + EXTRACT_16BITS(&l2info.cookie) != (PPP_ADDRESS << 8 | PPP_CONTROL)) + printf("Bundle-ID %u: ",l2info.bundle); + + p+=l2info.header_len; + + /* first try the LSQ protos */ + switch(l2info.proto) { + case JUNIPER_LSQ_L3_PROTO_IPV4: + /* IP traffic going to the RE would not have a cookie + * -> this must be incoming IS-IS over PPP + */ + if (l2info.cookie[4] == (JUNIPER_LSQ_COOKIE_RE|JUNIPER_LSQ_COOKIE_DIR)) + ppp_print(p, l2info.length); + else + ip_print(gndo, p, l2info.length); + return l2info.header_len; +#ifdef INET6 + case JUNIPER_LSQ_L3_PROTO_IPV6: + ip6_print(gndo, p,l2info.length); + return l2info.header_len; +#endif + case JUNIPER_LSQ_L3_PROTO_MPLS: + mpls_print(p,l2info.length); + return l2info.header_len; + case JUNIPER_LSQ_L3_PROTO_ISO: + isoclns_print(p,l2info.length,l2info.caplen); + return l2info.header_len; + default: + break; + } + + /* zero length cookie ? */ + switch (EXTRACT_16BITS(&l2info.cookie)) { + case PPP_OSI: + ppp_print(p-2,l2info.length+2); + break; + case (PPP_ADDRESS << 8 | PPP_CONTROL): /* fall through */ + default: + ppp_print(p,l2info.length); + break; + } + + return l2info.header_len; +} +#endif + + +#ifdef DLT_JUNIPER_MFR +u_int +juniper_mfr_print(const struct pcap_pkthdr *h, register const u_char *p) +{ + struct juniper_l2info_t l2info; + + l2info.pictype = DLT_JUNIPER_MFR; + if(juniper_parse_header(p, h, &l2info) == 0) + return l2info.header_len; + + p+=l2info.header_len; + + /* child-link ? */ + if (l2info.cookie_len == 0) { + mfr_print(p,l2info.length); + return l2info.header_len; + } + + /* first try the LSQ protos */ + if (l2info.cookie_len == AS_PIC_COOKIE_LEN) { + switch(l2info.proto) { + case JUNIPER_LSQ_L3_PROTO_IPV4: + ip_print(gndo, p, l2info.length); + return l2info.header_len; +#ifdef INET6 + case JUNIPER_LSQ_L3_PROTO_IPV6: + ip6_print(gndo, p,l2info.length); + return l2info.header_len; +#endif + case JUNIPER_LSQ_L3_PROTO_MPLS: + mpls_print(p,l2info.length); + return l2info.header_len; + case JUNIPER_LSQ_L3_PROTO_ISO: + isoclns_print(p,l2info.length,l2info.caplen); + return l2info.header_len; + default: + break; + } + return l2info.header_len; + } + + /* suppress Bundle-ID if frame was captured on a child-link */ + if (eflag && EXTRACT_32BITS(l2info.cookie) != 1) printf("Bundle-ID %u, ",l2info.bundle); + switch (l2info.proto) { + case (LLCSAP_ISONS<<8 | LLCSAP_ISONS): + isoclns_print(p+1, l2info.length-1, l2info.caplen-1); + break; + case (LLC_UI<<8 | NLPID_Q933): + case (LLC_UI<<8 | NLPID_IP): + case (LLC_UI<<8 | NLPID_IP6): + /* pass IP{4,6} to the OSI layer for proper link-layer printing */ + isoclns_print(p-1, l2info.length+1, l2info.caplen+1); + break; + default: + printf("unknown protocol 0x%04x, length %u",l2info.proto, l2info.length); + } + + return l2info.header_len; +} +#endif + +#ifdef DLT_JUNIPER_MLFR +u_int +juniper_mlfr_print(const struct pcap_pkthdr *h, register const u_char *p) +{ + struct juniper_l2info_t l2info; + + l2info.pictype = DLT_JUNIPER_MLFR; + if(juniper_parse_header(p, h, &l2info) == 0) + return l2info.header_len; + + p+=l2info.header_len; + + /* suppress Bundle-ID if frame was captured on a child-link */ + if (eflag && EXTRACT_32BITS(l2info.cookie) != 1) printf("Bundle-ID %u, ",l2info.bundle); + switch (l2info.proto) { + case (LLC_UI): + case (LLC_UI<<8): + isoclns_print(p, l2info.length, l2info.caplen); + break; + case (LLC_UI<<8 | NLPID_Q933): + case (LLC_UI<<8 | NLPID_IP): + case (LLC_UI<<8 | NLPID_IP6): + /* pass IP{4,6} to the OSI layer for proper link-layer printing */ + isoclns_print(p-1, l2info.length+1, l2info.caplen+1); + break; + default: + printf("unknown protocol 0x%04x, length %u",l2info.proto, l2info.length); + } + + return l2info.header_len; +} +#endif + +/* + * ATM1 PIC cookie format + * + * +-----+-------------------------+-------------------------------+ + * |fmtid| vc index | channel ID | + * +-----+-------------------------+-------------------------------+ + */ + +#ifdef DLT_JUNIPER_ATM1 +u_int +juniper_atm1_print(const struct pcap_pkthdr *h, register const u_char *p) +{ + u_int16_t extracted_ethertype; + + struct juniper_l2info_t l2info; + + l2info.pictype = DLT_JUNIPER_ATM1; + if(juniper_parse_header(p, h, &l2info) == 0) + return l2info.header_len; + + p+=l2info.header_len; + + if (l2info.cookie[0] == 0x80) { /* OAM cell ? */ + oam_print(p,l2info.length,ATM_OAM_NOHEC); + return l2info.header_len; + } + + if (EXTRACT_24BITS(p) == 0xfefe03 || /* NLPID encaps ? */ + EXTRACT_24BITS(p) == 0xaaaa03) { /* SNAP encaps ? */ + + if (llc_print(p, l2info.length, l2info.caplen, NULL, NULL, + &extracted_ethertype) != 0) + return l2info.header_len; + } + + if (p[0] == 0x03) { /* Cisco style NLPID encaps ? */ + isoclns_print(p + 1, l2info.length - 1, l2info.caplen - 1); + /* FIXME check if frame was recognized */ + return l2info.header_len; + } + + if(ip_heuristic_guess(p, l2info.length) != 0) /* last try - vcmux encaps ? */ + return l2info.header_len; + + return l2info.header_len; +} +#endif + +/* + * ATM2 PIC cookie format + * + * +-------------------------------+---------+---+-----+-----------+ + * | channel ID | reserv |AAL| CCRQ| gap cnt | + * +-------------------------------+---------+---+-----+-----------+ + */ + +#ifdef DLT_JUNIPER_ATM2 +u_int +juniper_atm2_print(const struct pcap_pkthdr *h, register const u_char *p) +{ + u_int16_t extracted_ethertype; + + struct juniper_l2info_t l2info; + + l2info.pictype = DLT_JUNIPER_ATM2; + if(juniper_parse_header(p, h, &l2info) == 0) + return l2info.header_len; + + p+=l2info.header_len; + + if (l2info.cookie[7] & ATM2_PKT_TYPE_MASK) { /* OAM cell ? */ + oam_print(p,l2info.length,ATM_OAM_NOHEC); + return l2info.header_len; + } + + if (EXTRACT_24BITS(p) == 0xfefe03 || /* NLPID encaps ? */ + EXTRACT_24BITS(p) == 0xaaaa03) { /* SNAP encaps ? */ + + if (llc_print(p, l2info.length, l2info.caplen, NULL, NULL, + &extracted_ethertype) != 0) + return l2info.header_len; + } + + if (l2info.direction != JUNIPER_BPF_PKT_IN && /* ether-over-1483 encaps ? */ + (EXTRACT_32BITS(l2info.cookie) & ATM2_GAP_COUNT_MASK)) { + ether_print(gndo, p, l2info.length, l2info.caplen, NULL, NULL); + return l2info.header_len; + } + + if (p[0] == 0x03) { /* Cisco style NLPID encaps ? */ + isoclns_print(p + 1, l2info.length - 1, l2info.caplen - 1); + /* FIXME check if frame was recognized */ + return l2info.header_len; + } + + if(juniper_ppp_heuristic_guess(p, l2info.length) != 0) /* PPPoA vcmux encaps ? */ + return l2info.header_len; + + if(ip_heuristic_guess(p, l2info.length) != 0) /* last try - vcmux encaps ? */ + return l2info.header_len; + + return l2info.header_len; +} +#endif + + +/* try to guess, based on all PPP protos that are supported in + * a juniper router if the payload data is encapsulated using PPP */ +int +juniper_ppp_heuristic_guess(register const u_char *p, u_int length) { + + switch(EXTRACT_16BITS(p)) { + case PPP_IP : + case PPP_OSI : + case PPP_MPLS_UCAST : + case PPP_MPLS_MCAST : + case PPP_IPCP : + case PPP_OSICP : + case PPP_MPLSCP : + case PPP_LCP : + case PPP_PAP : + case PPP_CHAP : + case PPP_ML : +#ifdef INET6 + case PPP_IPV6 : + case PPP_IPV6CP : +#endif + ppp_print(p, length); + break; + + default: + return 0; /* did not find a ppp header */ + break; + } + return 1; /* we printed a ppp packet */ +} + +int +ip_heuristic_guess(register const u_char *p, u_int length) { + + switch(p[0]) { + case 0x45: + case 0x46: + case 0x47: + case 0x48: + case 0x49: + case 0x4a: + case 0x4b: + case 0x4c: + case 0x4d: + case 0x4e: + case 0x4f: + ip_print(gndo, p, 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: + ip6_print(gndo, p, length); + break; +#endif + default: + return 0; /* did not find a ip header */ + break; + } + return 1; /* we printed an v4/v6 packet */ +} + +int +juniper_read_tlv_value(const u_char *p, u_int tlv_type, u_int tlv_len) { + + int tlv_value; + + /* TLVs < 128 are little endian encoded */ + if (tlv_type < 128) { + switch (tlv_len) { + case 1: + tlv_value = *p; + break; + case 2: + tlv_value = EXTRACT_LE_16BITS(p); + break; + case 3: + tlv_value = EXTRACT_LE_24BITS(p); + break; + case 4: + tlv_value = EXTRACT_LE_32BITS(p); + break; + default: + tlv_value = -1; + break; + } + } else { + /* TLVs >= 128 are big endian encoded */ + switch (tlv_len) { + case 1: + tlv_value = *p; + break; + case 2: + tlv_value = EXTRACT_16BITS(p); + break; + case 3: + tlv_value = EXTRACT_24BITS(p); + break; + case 4: + tlv_value = EXTRACT_32BITS(p); + break; + default: + tlv_value = -1; + break; + } + } + return tlv_value; +} + +static int +juniper_parse_header (const u_char *p, const struct pcap_pkthdr *h, struct juniper_l2info_t *l2info) { + + struct juniper_cookie_table_t *lp = juniper_cookie_table; + u_int idx, jnx_ext_len, jnx_header_len = 0; + u_int8_t tlv_type,tlv_len; + u_int32_t control_word; + int tlv_value; + const u_char *tptr; + + + l2info->header_len = 0; + l2info->cookie_len = 0; + l2info->proto = 0; + + + l2info->length = h->len; + l2info->caplen = h->caplen; + TCHECK2(p[0],4); + l2info->flags = p[3]; + l2info->direction = p[3]&JUNIPER_BPF_PKT_IN; + + if (EXTRACT_24BITS(p) != JUNIPER_MGC_NUMBER) { /* magic number found ? */ + printf("no magic-number found!"); + return 0; + } + + if (eflag) /* print direction */ + printf("%3s ",tok2str(juniper_direction_values,"---",l2info->direction)); + + /* magic number + flags */ + jnx_header_len = 4; + + if (vflag>1) + printf("\n\tJuniper PCAP Flags [%s]", + bittok2str(jnx_flag_values, "none", l2info->flags)); + + /* extensions present ? - calculate how much bytes to skip */ + if ((l2info->flags & JUNIPER_BPF_EXT ) == JUNIPER_BPF_EXT ) { + + tptr = p+jnx_header_len; + + /* ok to read extension length ? */ + TCHECK2(tptr[0], 2); + jnx_ext_len = EXTRACT_16BITS(tptr); + jnx_header_len += 2; + tptr +=2; + + /* nail up the total length - + * just in case something goes wrong + * with TLV parsing */ + jnx_header_len += jnx_ext_len; + + if (vflag>1) + printf(", PCAP Extension(s) total length %u", + jnx_ext_len); + + TCHECK2(tptr[0], jnx_ext_len); + while (jnx_ext_len > JUNIPER_EXT_TLV_OVERHEAD) { + tlv_type = *(tptr++); + tlv_len = *(tptr++); + tlv_value = 0; + + /* sanity check */ + if (tlv_type == 0 || tlv_len == 0) + break; + + if (vflag>1) + printf("\n\t %s Extension TLV #%u, length %u, value ", + tok2str(jnx_ext_tlv_values,"Unknown",tlv_type), + tlv_type, + tlv_len); + + tlv_value = juniper_read_tlv_value(tptr, tlv_type, tlv_len); + switch (tlv_type) { + case JUNIPER_EXT_TLV_IFD_NAME: + /* FIXME */ + break; + case JUNIPER_EXT_TLV_IFD_MEDIATYPE: + case JUNIPER_EXT_TLV_TTP_IFD_MEDIATYPE: + if (tlv_value != -1) { + if (vflag>1) + printf("%s (%u)", + tok2str(juniper_ifmt_values, "Unknown", tlv_value), + tlv_value); + } + break; + case JUNIPER_EXT_TLV_IFL_ENCAPS: + case JUNIPER_EXT_TLV_TTP_IFL_ENCAPS: + if (tlv_value != -1) { + if (vflag>1) + printf("%s (%u)", + tok2str(juniper_ifle_values, "Unknown", tlv_value), + tlv_value); + } + break; + case JUNIPER_EXT_TLV_IFL_IDX: /* fall through */ + case JUNIPER_EXT_TLV_IFL_UNIT: + case JUNIPER_EXT_TLV_IFD_IDX: + default: + if (tlv_value != -1) { + if (vflag>1) + printf("%u",tlv_value); + } + break; + } + + tptr+=tlv_len; + jnx_ext_len -= tlv_len+JUNIPER_EXT_TLV_OVERHEAD; + } + + if (vflag>1) + printf("\n\t-----original packet-----\n\t"); + } + + if ((l2info->flags & JUNIPER_BPF_NO_L2 ) == JUNIPER_BPF_NO_L2 ) { + if (eflag) + printf("no-L2-hdr, "); + + /* there is no link-layer present - + * perform the v4/v6 heuristics + * to figure out what it is + */ + TCHECK2(p[jnx_header_len+4],1); + if(ip_heuristic_guess(p+jnx_header_len+4,l2info->length-(jnx_header_len+4)) == 0) + printf("no IP-hdr found!"); + + l2info->header_len=jnx_header_len+4; + return 0; /* stop parsing the output further */ + + } + l2info->header_len = jnx_header_len; + p+=l2info->header_len; + l2info->length -= l2info->header_len; + l2info->caplen -= l2info->header_len; + + /* search through the cookie table and copy values matching for our PIC type */ + while (lp->s != NULL) { + if (lp->pictype == l2info->pictype) { + + l2info->cookie_len += lp->cookie_len; + + switch (p[0]) { + case LS_COOKIE_ID: + l2info->cookie_type = LS_COOKIE_ID; + l2info->cookie_len += 2; + break; + case AS_COOKIE_ID: + l2info->cookie_type = AS_COOKIE_ID; + l2info->cookie_len = 8; + break; + + default: + l2info->bundle = l2info->cookie[0]; + break; + } + + +#ifdef DLT_JUNIPER_MFR + /* MFR child links don't carry cookies */ + if (l2info->pictype == DLT_JUNIPER_MFR && + (p[0] & MFR_BE_MASK) == MFR_BE_MASK) { + l2info->cookie_len = 0; + } +#endif + + l2info->header_len += l2info->cookie_len; + l2info->length -= l2info->cookie_len; + l2info->caplen -= l2info->cookie_len; + + if (eflag) + printf("%s-PIC, cookie-len %u", + lp->s, + l2info->cookie_len); + + if (l2info->cookie_len > 0) { + TCHECK2(p[0],l2info->cookie_len); + if (eflag) + printf(", cookie 0x"); + for (idx = 0; idx < l2info->cookie_len; idx++) { + l2info->cookie[idx] = p[idx]; /* copy cookie data */ + if (eflag) printf("%02x",p[idx]); + } + } + + if (eflag) printf(": "); /* print demarc b/w L2/L3*/ + + + l2info->proto = EXTRACT_16BITS(p+l2info->cookie_len); + break; + } + ++lp; + } + p+=l2info->cookie_len; + + /* DLT_ specific parsing */ + switch(l2info->pictype) { +#ifdef DLT_JUNIPER_MLPPP + case DLT_JUNIPER_MLPPP: + switch (l2info->cookie_type) { + case LS_COOKIE_ID: + l2info->bundle = l2info->cookie[1]; + break; + case AS_COOKIE_ID: + l2info->bundle = (EXTRACT_16BITS(&l2info->cookie[6])>>3)&0xfff; + l2info->proto = (l2info->cookie[5])&JUNIPER_LSQ_L3_PROTO_MASK; + break; + default: + l2info->bundle = l2info->cookie[0]; + break; + } + break; +#endif +#ifdef DLT_JUNIPER_MLFR + case DLT_JUNIPER_MLFR: + switch (l2info->cookie_type) { + case LS_COOKIE_ID: + l2info->bundle = l2info->cookie[1]; + l2info->proto = EXTRACT_16BITS(p); + l2info->header_len += 2; + l2info->length -= 2; + l2info->caplen -= 2; + break; + case AS_COOKIE_ID: + l2info->bundle = (EXTRACT_16BITS(&l2info->cookie[6])>>3)&0xfff; + l2info->proto = (l2info->cookie[5])&JUNIPER_LSQ_L3_PROTO_MASK; + break; + default: + l2info->bundle = l2info->cookie[0]; + l2info->header_len += 2; + l2info->length -= 2; + l2info->caplen -= 2; + break; + } + break; +#endif +#ifdef DLT_JUNIPER_MFR + case DLT_JUNIPER_MFR: + switch (l2info->cookie_type) { + case LS_COOKIE_ID: + l2info->bundle = l2info->cookie[1]; + l2info->proto = EXTRACT_16BITS(p); + l2info->header_len += 2; + l2info->length -= 2; + l2info->caplen -= 2; + break; + case AS_COOKIE_ID: + l2info->bundle = (EXTRACT_16BITS(&l2info->cookie[6])>>3)&0xfff; + l2info->proto = (l2info->cookie[5])&JUNIPER_LSQ_L3_PROTO_MASK; + break; + default: + l2info->bundle = l2info->cookie[0]; + break; + } + break; +#endif +#ifdef DLT_JUNIPER_ATM2 + case DLT_JUNIPER_ATM2: + TCHECK2(p[0],4); + /* ATM cell relay control word present ? */ + if (l2info->cookie[7] & ATM2_PKT_TYPE_MASK) { + control_word = EXTRACT_32BITS(p); + /* some control word heuristics */ + switch(control_word) { + case 0: /* zero control word */ + case 0x08000000: /* < JUNOS 7.4 control-word */ + case 0x08380000: /* cntl word plus cell length (56) >= JUNOS 7.4*/ + l2info->header_len += 4; + break; + default: + break; + } + + if (eflag) + printf("control-word 0x%08x ", control_word); + } + break; +#endif +#ifdef DLT_JUNIPER_GGSN + case DLT_JUNIPER_GGSN: + break; +#endif +#ifdef DLT_JUNIPER_ATM1 + case DLT_JUNIPER_ATM1: + break; +#endif +#ifdef DLT_JUNIPER_PPP + case DLT_JUNIPER_PPP: + break; +#endif +#ifdef DLT_JUNIPER_CHDLC + case DLT_JUNIPER_CHDLC: + break; +#endif +#ifdef DLT_JUNIPER_ETHER + case DLT_JUNIPER_ETHER: + break; +#endif +#ifdef DLT_JUNIPER_FRELAY + case DLT_JUNIPER_FRELAY: + break; +#endif + + default: + printf("Unknown Juniper DLT_ type %u: ", l2info->pictype); + break; + } + + if (eflag > 1) + printf("hlen %u, proto 0x%04x, ",l2info->header_len,l2info->proto); + + return 1; /* everything went ok so far. continue parsing */ + trunc: + printf("[|juniper_hdr], length %u",h->len); + return 0; +} + + +/* + * Local Variables: + * c-style: whitesmith + * c-basic-offset: 4 + * End: + */
diff --git a/tcpdump-4.3.0/print-krb.c b/tcpdump-4.3.0/print-krb.c new file mode 100644 index 0000000..213db64 --- /dev/null +++ b/tcpdump-4.3.0/print-krb.c
@@ -0,0 +1,261 @@ +/* + * Copyright (c) 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. + * + * Initial contribution from John Hawkinson (jhawk@mit.edu). + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-krb.c,v 1.23 2003-11-16 09:36:26 guy Exp $"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> + +#include "interface.h" +#include "addrtoname.h" +#include "extract.h" + +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 +#define AUTH_MSG_APPL_REQUEST 3<<1 +#define AUTH_MSG_APPL_REQUEST_MUTUAL 4<<1 +#define AUTH_MSG_ERR_REPLY 5<<1 +#define AUTH_MSG_PRIVATE 6<<1 +#define AUTH_MSG_SAFE 7<<1 +#define AUTH_MSG_APPL_ERR 8<<1 +#define AUTH_MSG_DIE 63<<1 + +#define KERB_ERR_OK 0 +#define KERB_ERR_NAME_EXP 1 +#define KERB_ERR_SERVICE_EXP 2 +#define KERB_ERR_AUTH_EXP 3 +#define KERB_ERR_PKT_VER 4 +#define KERB_ERR_NAME_MAST_KEY_VER 5 +#define KERB_ERR_SERV_MAST_KEY_VER 6 +#define KERB_ERR_BYTE_ORDER 7 +#define KERB_ERR_PRINCIPAL_UNKNOWN 8 +#define KERB_ERR_PRINCIPAL_NOT_UNIQUE 9 +#define KERB_ERR_NULL_KEY 10 + +struct krb { + u_int8_t pvno; /* Protocol Version */ + u_int8_t type; /* Type+B */ +}; + +static char tstr[] = " [|kerberos]"; + +static struct tok type2str[] = { + { AUTH_MSG_KDC_REQUEST, "KDC_REQUEST" }, + { AUTH_MSG_KDC_REPLY, "KDC_REPLY" }, + { AUTH_MSG_APPL_REQUEST, "APPL_REQUEST" }, + { AUTH_MSG_APPL_REQUEST_MUTUAL, "APPL_REQUEST_MUTUAL" }, + { AUTH_MSG_ERR_REPLY, "ERR_REPLY" }, + { AUTH_MSG_PRIVATE, "PRIVATE" }, + { AUTH_MSG_SAFE, "SAFE" }, + { AUTH_MSG_APPL_ERR, "APPL_ERR" }, + { AUTH_MSG_DIE, "DIE" }, + { 0, NULL } +}; + +static struct tok kerr2str[] = { + { KERB_ERR_OK, "OK" }, + { KERB_ERR_NAME_EXP, "NAME_EXP" }, + { KERB_ERR_SERVICE_EXP, "SERVICE_EXP" }, + { KERB_ERR_AUTH_EXP, "AUTH_EXP" }, + { KERB_ERR_PKT_VER, "PKT_VER" }, + { KERB_ERR_NAME_MAST_KEY_VER, "NAME_MAST_KEY_VER" }, + { KERB_ERR_SERV_MAST_KEY_VER, "SERV_MAST_KEY_VER" }, + { KERB_ERR_BYTE_ORDER, "BYTE_ORDER" }, + { KERB_ERR_PRINCIPAL_UNKNOWN, "PRINCIPAL_UNKNOWN" }, + { KERB_ERR_PRINCIPAL_NOT_UNIQUE,"PRINCIPAL_NOT_UNIQUE" }, + { KERB_ERR_NULL_KEY, "NULL_KEY"}, + { 0, NULL} +}; + +static const u_char * +c_print(register const u_char *s, register const u_char *ep) +{ + register u_char c; + register int flag; + + flag = 1; + while (s < ep) { + c = *s++; + if (c == '\0') { + flag = 0; + break; + } + if (!isascii(c)) { + c = toascii(c); + putchar('M'); + putchar('-'); + } + if (!isprint(c)) { + c ^= 0x40; /* DEL to ?, others to alpha */ + putchar('^'); + } + putchar(c); + } + if (flag) + return NULL; + return (s); +} + +static const u_char * +krb4_print_hdr(const u_char *cp) +{ + cp += 2; + +#define PRINT if ((cp = c_print(cp, snapend)) == NULL) goto trunc + + PRINT; + putchar('.'); + PRINT; + putchar('@'); + PRINT; + return (cp); + +trunc: + fputs(tstr, stdout); + return (NULL); + +#undef PRINT +} + +static void +krb4_print(const u_char *cp) +{ + register const struct krb *kp; + u_char type; + u_short len; + +#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) ? EXTRACT_LE_16BITS(cp) : EXTRACT_16BITS(cp)) + + kp = (struct krb *)cp; + + if ((&kp->type) >= snapend) { + fputs(tstr, stdout); + return; + } + + type = kp->type & (0xFF << 1); + + printf(" %s %s: ", + IS_LENDIAN(kp) ? "le" : "be", tok2str(type2str, NULL, type)); + + switch (type) { + + case AUTH_MSG_KDC_REQUEST: + if ((cp = krb4_print_hdr(cp)) == NULL) + return; + cp += 4; /* ctime */ + TCHECK(*cp); + printf(" %dmin ", *cp++ * 5); + PRINT; + putchar('.'); + PRINT; + break; + + case AUTH_MSG_APPL_REQUEST: + cp += 2; + TCHECK(*cp); + printf("v%d ", *cp++); + PRINT; + TCHECK(*cp); + printf(" (%d)", *cp++); + TCHECK(*cp); + printf(" (%d)", *cp); + break; + + case AUTH_MSG_KDC_REPLY: + if ((cp = krb4_print_hdr(cp)) == NULL) + return; + cp += 10; /* timestamp + n + exp + kvno */ + TCHECK2(*cp, sizeof(short)); + len = KTOHSP(kp, cp); + printf(" (%d)", len); + break; + + case AUTH_MSG_ERR_REPLY: + if ((cp = krb4_print_hdr(cp)) == NULL) + return; + cp += 4; /* timestamp */ + TCHECK2(*cp, sizeof(short)); + printf(" %s ", tok2str(kerr2str, NULL, KTOHSP(kp, cp))); + cp += 4; + PRINT; + break; + + default: + fputs("(unknown)", stdout); + break; + } + + return; +trunc: + fputs(tstr, stdout); +} + +void +krb_print(const u_char *dat) +{ + register const struct krb *kp; + + kp = (struct krb *)dat; + + if (dat >= snapend) { + fputs(tstr, stdout); + return; + } + + switch (kp->pvno) { + + case 1: + case 2: + case 3: + printf(" v%d", kp->pvno); + break; + + case 4: + printf(" v%d", kp->pvno); + krb4_print((const u_char *)kp); + break; + + case 106: + case 107: + fputs(" v5", stdout); + /* Decode ASN.1 here "someday" */ + break; + } + return; +}
diff --git a/tcpdump-4.3.0/print-l2tp.c b/tcpdump-4.3.0/print-l2tp.c new file mode 100644 index 0000000..2f72657 --- /dev/null +++ b/tcpdump-4.3.0/print-l2tp.c
@@ -0,0 +1,719 @@ +/* + * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * L2TP support contributed by Motonori Shindo (mshindo@mshindo.net) + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-l2tp.c,v 1.20 2006-06-23 02:03:09 hannes Exp $"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> + +#include "l2tp.h" +#include "interface.h" +#include "extract.h" + +static char tstr[] = " [|l2tp]"; + +#define L2TP_MSGTYPE_SCCRQ 1 /* Start-Control-Connection-Request */ +#define L2TP_MSGTYPE_SCCRP 2 /* Start-Control-Connection-Reply */ +#define L2TP_MSGTYPE_SCCCN 3 /* Start-Control-Connection-Connected */ +#define L2TP_MSGTYPE_STOPCCN 4 /* Stop-Control-Connection-Notification */ +#define L2TP_MSGTYPE_HELLO 6 /* Hello */ +#define L2TP_MSGTYPE_OCRQ 7 /* Outgoing-Call-Request */ +#define L2TP_MSGTYPE_OCRP 8 /* Outgoing-Call-Reply */ +#define L2TP_MSGTYPE_OCCN 9 /* Outgoing-Call-Connected */ +#define L2TP_MSGTYPE_ICRQ 10 /* Incoming-Call-Request */ +#define L2TP_MSGTYPE_ICRP 11 /* Incoming-Call-Reply */ +#define L2TP_MSGTYPE_ICCN 12 /* Incoming-Call-Connected */ +#define L2TP_MSGTYPE_CDN 14 /* Call-Disconnect-Notify */ +#define L2TP_MSGTYPE_WEN 15 /* WAN-Error-Notify */ +#define L2TP_MSGTYPE_SLI 16 /* Set-Link-Info */ + +static struct tok l2tp_msgtype2str[] = { + { L2TP_MSGTYPE_SCCRQ, "SCCRQ" }, + { L2TP_MSGTYPE_SCCRP, "SCCRP" }, + { L2TP_MSGTYPE_SCCCN, "SCCCN" }, + { L2TP_MSGTYPE_STOPCCN, "StopCCN" }, + { L2TP_MSGTYPE_HELLO, "HELLO" }, + { L2TP_MSGTYPE_OCRQ, "OCRQ" }, + { L2TP_MSGTYPE_OCRP, "OCRP" }, + { L2TP_MSGTYPE_OCCN, "OCCN" }, + { L2TP_MSGTYPE_ICRQ, "ICRQ" }, + { L2TP_MSGTYPE_ICRP, "ICRP" }, + { L2TP_MSGTYPE_ICCN, "ICCN" }, + { L2TP_MSGTYPE_CDN, "CDN" }, + { L2TP_MSGTYPE_WEN, "WEN" }, + { L2TP_MSGTYPE_SLI, "SLI" }, + { 0, NULL } +}; + +#define L2TP_AVP_MSGTYPE 0 /* Message Type */ +#define L2TP_AVP_RESULT_CODE 1 /* Result Code */ +#define L2TP_AVP_PROTO_VER 2 /* Protocol Version */ +#define L2TP_AVP_FRAMING_CAP 3 /* Framing Capabilities */ +#define L2TP_AVP_BEARER_CAP 4 /* Bearer Capabilities */ +#define L2TP_AVP_TIE_BREAKER 5 /* Tie Breaker */ +#define L2TP_AVP_FIRM_VER 6 /* Firmware Revision */ +#define L2TP_AVP_HOST_NAME 7 /* Host Name */ +#define L2TP_AVP_VENDOR_NAME 8 /* Vendor Name */ +#define L2TP_AVP_ASSND_TUN_ID 9 /* Assigned Tunnel ID */ +#define L2TP_AVP_RECV_WIN_SIZE 10 /* Receive Window Size */ +#define L2TP_AVP_CHALLENGE 11 /* Challenge */ +#define L2TP_AVP_Q931_CC 12 /* Q.931 Cause Code */ +#define L2TP_AVP_CHALLENGE_RESP 13 /* Challenge Response */ +#define L2TP_AVP_ASSND_SESS_ID 14 /* Assigned Session ID */ +#define L2TP_AVP_CALL_SER_NUM 15 /* Call Serial Number */ +#define L2TP_AVP_MINIMUM_BPS 16 /* Minimum BPS */ +#define L2TP_AVP_MAXIMUM_BPS 17 /* Maximum BPS */ +#define L2TP_AVP_BEARER_TYPE 18 /* Bearer Type */ +#define L2TP_AVP_FRAMING_TYPE 19 /* Framing Type */ +#define L2TP_AVP_PACKET_PROC_DELAY 20 /* Packet Processing Delay (OBSOLETE) */ +#define L2TP_AVP_CALLED_NUMBER 21 /* Called Number */ +#define L2TP_AVP_CALLING_NUMBER 22 /* Calling Number */ +#define L2TP_AVP_SUB_ADDRESS 23 /* Sub-Address */ +#define L2TP_AVP_TX_CONN_SPEED 24 /* (Tx) Connect Speed */ +#define L2TP_AVP_PHY_CHANNEL_ID 25 /* Physical Channel ID */ +#define L2TP_AVP_INI_RECV_LCP 26 /* Initial Received LCP CONFREQ */ +#define L2TP_AVP_LAST_SENT_LCP 27 /* Last Sent LCP CONFREQ */ +#define L2TP_AVP_LAST_RECV_LCP 28 /* Last Received LCP CONFREQ */ +#define L2TP_AVP_PROXY_AUTH_TYPE 29 /* Proxy Authen Type */ +#define L2TP_AVP_PROXY_AUTH_NAME 30 /* Proxy Authen Name */ +#define L2TP_AVP_PROXY_AUTH_CHAL 31 /* Proxy Authen Challenge */ +#define L2TP_AVP_PROXY_AUTH_ID 32 /* Proxy Authen ID */ +#define L2TP_AVP_PROXY_AUTH_RESP 33 /* Proxy Authen Response */ +#define L2TP_AVP_CALL_ERRORS 34 /* Call Errors */ +#define L2TP_AVP_ACCM 35 /* ACCM */ +#define L2TP_AVP_RANDOM_VECTOR 36 /* Random Vector */ +#define L2TP_AVP_PRIVATE_GRP_ID 37 /* Private Group ID */ +#define L2TP_AVP_RX_CONN_SPEED 38 /* (Rx) Connect Speed */ +#define L2TP_AVP_SEQ_REQUIRED 39 /* Sequencing Required */ +#define L2TP_AVP_PPP_DISCON_CC 46 /* PPP Disconnect Cause Code */ + +static struct tok l2tp_avp2str[] = { + { L2TP_AVP_MSGTYPE, "MSGTYPE" }, + { L2TP_AVP_RESULT_CODE, "RESULT_CODE" }, + { L2TP_AVP_PROTO_VER, "PROTO_VER" }, + { L2TP_AVP_FRAMING_CAP, "FRAMING_CAP" }, + { L2TP_AVP_BEARER_CAP, "BEARER_CAP" }, + { L2TP_AVP_TIE_BREAKER, "TIE_BREAKER" }, + { L2TP_AVP_FIRM_VER, "FIRM_VER" }, + { L2TP_AVP_HOST_NAME, "HOST_NAME" }, + { L2TP_AVP_VENDOR_NAME, "VENDOR_NAME" }, + { L2TP_AVP_ASSND_TUN_ID, "ASSND_TUN_ID" }, + { L2TP_AVP_RECV_WIN_SIZE, "RECV_WIN_SIZE" }, + { L2TP_AVP_CHALLENGE, "CHALLENGE" }, + { L2TP_AVP_Q931_CC, "Q931_CC", }, + { L2TP_AVP_CHALLENGE_RESP, "CHALLENGE_RESP" }, + { L2TP_AVP_ASSND_SESS_ID, "ASSND_SESS_ID" }, + { L2TP_AVP_CALL_SER_NUM, "CALL_SER_NUM" }, + { L2TP_AVP_MINIMUM_BPS, "MINIMUM_BPS" }, + { L2TP_AVP_MAXIMUM_BPS, "MAXIMUM_BPS" }, + { L2TP_AVP_BEARER_TYPE, "BEARER_TYPE" }, + { L2TP_AVP_FRAMING_TYPE, "FRAMING_TYPE" }, + { L2TP_AVP_PACKET_PROC_DELAY, "PACKET_PROC_DELAY" }, + { L2TP_AVP_CALLED_NUMBER, "CALLED_NUMBER" }, + { L2TP_AVP_CALLING_NUMBER, "CALLING_NUMBER" }, + { L2TP_AVP_SUB_ADDRESS, "SUB_ADDRESS" }, + { L2TP_AVP_TX_CONN_SPEED, "TX_CONN_SPEED" }, + { L2TP_AVP_PHY_CHANNEL_ID, "PHY_CHANNEL_ID" }, + { L2TP_AVP_INI_RECV_LCP, "INI_RECV_LCP" }, + { L2TP_AVP_LAST_SENT_LCP, "LAST_SENT_LCP" }, + { L2TP_AVP_LAST_RECV_LCP, "LAST_RECV_LCP" }, + { L2TP_AVP_PROXY_AUTH_TYPE, "PROXY_AUTH_TYPE" }, + { L2TP_AVP_PROXY_AUTH_NAME, "PROXY_AUTH_NAME" }, + { L2TP_AVP_PROXY_AUTH_CHAL, "PROXY_AUTH_CHAL" }, + { L2TP_AVP_PROXY_AUTH_ID, "PROXY_AUTH_ID" }, + { L2TP_AVP_PROXY_AUTH_RESP, "PROXY_AUTH_RESP" }, + { L2TP_AVP_CALL_ERRORS, "CALL_ERRORS" }, + { L2TP_AVP_ACCM, "ACCM" }, + { L2TP_AVP_RANDOM_VECTOR, "RANDOM_VECTOR" }, + { L2TP_AVP_PRIVATE_GRP_ID, "PRIVATE_GRP_ID" }, + { L2TP_AVP_RX_CONN_SPEED, "RX_CONN_SPEED" }, + { L2TP_AVP_SEQ_REQUIRED, "SEQ_REQUIRED" }, + { L2TP_AVP_PPP_DISCON_CC, "PPP_DISCON_CC" }, + { 0, NULL } +}; + +static struct tok l2tp_authentype2str[] = { + { L2TP_AUTHEN_TYPE_RESERVED, "Reserved" }, + { L2TP_AUTHEN_TYPE_TEXTUAL, "Textual" }, + { L2TP_AUTHEN_TYPE_CHAP, "CHAP" }, + { L2TP_AUTHEN_TYPE_PAP, "PAP" }, + { L2TP_AUTHEN_TYPE_NO_AUTH, "No Auth" }, + { L2TP_AUTHEN_TYPE_MSCHAPv1, "MS-CHAPv1" }, + { 0, NULL } +}; + +#define L2TP_PPP_DISCON_CC_DIRECTION_GLOBAL 0 +#define L2TP_PPP_DISCON_CC_DIRECTION_AT_PEER 1 +#define L2TP_PPP_DISCON_CC_DIRECTION_AT_LOCAL 2 + +static struct tok l2tp_cc_direction2str[] = { + { L2TP_PPP_DISCON_CC_DIRECTION_GLOBAL, "global error" }, + { L2TP_PPP_DISCON_CC_DIRECTION_AT_PEER, "at peer" }, + { L2TP_PPP_DISCON_CC_DIRECTION_AT_LOCAL,"at local" }, + { 0, NULL } +}; + +#if 0 +static char *l2tp_result_code_StopCCN[] = { + "Reserved", + "General request to clear control connection", + "General error--Error Code indicates the problem", + "Control channel already exists", + "Requester is not authorized to establish a control channel", + "The protocol version of the requester is not supported", + "Requester is being shut down", + "Finite State Machine error" +#define L2TP_MAX_RESULT_CODE_STOPCC_INDEX 8 +}; +#endif + +#if 0 +static char *l2tp_result_code_CDN[] = { + "Reserved", + "Call disconnected due to loss of carrier", + "Call disconnected for the reason indicated in error code", + "Call disconnected for administrative reasons", + "Call failed due to lack of appropriate facilities being " \ + "available (temporary condition)", + "Call failed due to lack of appropriate facilities being " \ + "available (permanent condition)", + "Invalid destination", + "Call failed due to no carrier detected", + "Call failed due to detection of a busy signal", + "Call failed due to lack of a dial tone", + "Call was not established within time allotted by LAC", + "Call was connected but no appropriate framing was detected" +#define L2TP_MAX_RESULT_CODE_CDN_INDEX 12 +}; +#endif + +#if 0 +static char *l2tp_error_code_general[] = { + "No general error", + "No control connection exists yet for this LAC-LNS pair", + "Length is wrong", + "One of the field values was out of range or " \ + "reserved field was non-zero" + "Insufficient resources to handle this operation now", + "The Session ID is invalid in this context", + "A generic vendor-specific error occurred in the LAC", + "Try another" +#define L2TP_MAX_ERROR_CODE_GENERAL_INDEX 8 +}; +#endif + +/******************************/ +/* generic print out routines */ +/******************************/ +static void +print_string(const u_char *dat, u_int length) +{ + u_int i; + for (i=0; i<length; i++) { + printf("%c", *dat++); + } +} + +static void +print_octets(const u_char *dat, u_int length) +{ + u_int i; + for (i=0; i<length; i++) { + printf("%02x", *dat++); + } +} + +static void +print_16bits_val(const u_int16_t *dat) +{ + printf("%u", EXTRACT_16BITS(dat)); +} + +static void +print_32bits_val(const u_int32_t *dat) +{ + printf("%lu", (u_long)EXTRACT_32BITS(dat)); +} + +/***********************************/ +/* AVP-specific print out routines */ +/***********************************/ +static void +l2tp_msgtype_print(const u_char *dat) +{ + u_int16_t *ptr = (u_int16_t*)dat; + + printf("%s", tok2str(l2tp_msgtype2str, "MSGTYPE-#%u", + EXTRACT_16BITS(ptr))); +} + +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++; + } + if (length > 4) { /* Error Message (opt) */ + printf(" "); + print_string((u_char *)ptr, length - 4); + } +} + +static void +l2tp_proto_ver_print(const u_int16_t *dat) +{ + printf("%u.%u", (EXTRACT_16BITS(dat) >> 8), + (EXTRACT_16BITS(dat) & 0xff)); +} + +static void +l2tp_framing_cap_print(const u_char *dat) +{ + u_int32_t *ptr = (u_int32_t *)dat; + + if (EXTRACT_32BITS(ptr) & L2TP_FRAMING_CAP_ASYNC_MASK) { + printf("A"); + } + if (EXTRACT_32BITS(ptr) & L2TP_FRAMING_CAP_SYNC_MASK) { + printf("S"); + } +} + +static void +l2tp_bearer_cap_print(const u_char *dat) +{ + u_int32_t *ptr = (u_int32_t *)dat; + + if (EXTRACT_32BITS(ptr) & L2TP_BEARER_CAP_ANALOG_MASK) { + printf("A"); + } + if (EXTRACT_32BITS(ptr) & L2TP_BEARER_CAP_DIGITAL_MASK) { + printf("D"); + } +} + +static void +l2tp_q931_cc_print(const u_char *dat, u_int length) +{ + print_16bits_val((u_int16_t *)dat); + printf(", %02x", dat[2]); + if (length > 3) { + printf(" "); + print_string(dat+3, length-3); + } +} + +static void +l2tp_bearer_type_print(const u_char *dat) +{ + u_int32_t *ptr = (u_int32_t *)dat; + + if (EXTRACT_32BITS(ptr) & L2TP_BEARER_TYPE_ANALOG_MASK) { + printf("A"); + } + if (EXTRACT_32BITS(ptr) & L2TP_BEARER_TYPE_DIGITAL_MASK) { + printf("D"); + } +} + +static void +l2tp_framing_type_print(const u_char *dat) +{ + u_int32_t *ptr = (u_int32_t *)dat; + + if (EXTRACT_32BITS(ptr) & L2TP_FRAMING_TYPE_ASYNC_MASK) { + printf("A"); + } + if (EXTRACT_32BITS(ptr) & L2TP_FRAMING_TYPE_SYNC_MASK) { + printf("S"); + } +} + +static void +l2tp_packet_proc_delay_print(void) +{ + printf("obsolete"); +} + +static void +l2tp_proxy_auth_type_print(const u_char *dat) +{ + u_int16_t *ptr = (u_int16_t *)dat; + + printf("%s", tok2str(l2tp_authentype2str, + "AuthType-#%u", EXTRACT_16BITS(ptr))); +} + +static void +l2tp_proxy_auth_id_print(const u_char *dat) +{ + u_int16_t *ptr = (u_int16_t *)dat; + + printf("%u", EXTRACT_16BITS(ptr) & L2TP_PROXY_AUTH_ID_MASK); +} + +static void +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++; + val_l = EXTRACT_16BITS(ptr); ptr++; + printf("CRCErr=%u ", (val_h<<16) + val_l); + + val_h = EXTRACT_16BITS(ptr); ptr++; + val_l = EXTRACT_16BITS(ptr); ptr++; + printf("FrameErr=%u ", (val_h<<16) + val_l); + + val_h = EXTRACT_16BITS(ptr); ptr++; + val_l = EXTRACT_16BITS(ptr); ptr++; + printf("HardOver=%u ", (val_h<<16) + val_l); + + val_h = EXTRACT_16BITS(ptr); ptr++; + val_l = EXTRACT_16BITS(ptr); ptr++; + printf("BufOver=%u ", (val_h<<16) + val_l); + + val_h = EXTRACT_16BITS(ptr); ptr++; + val_l = EXTRACT_16BITS(ptr); ptr++; + printf("Timeout=%u ", (val_h<<16) + val_l); + + val_h = EXTRACT_16BITS(ptr); ptr++; + val_l = EXTRACT_16BITS(ptr); ptr++; + printf("AlignErr=%u ", (val_h<<16) + val_l); +} + +static void +l2tp_accm_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++; + 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); +} + +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, + "Direction-#%u", *((u_char *)ptr++))); + + if (length > 5) { + printf(" "); + print_string((const u_char *)ptr, length-5); + } +} + +static void +l2tp_avp_print(const u_char *dat, int length) +{ + u_int len; + const u_int16_t *ptr = (u_int16_t *)dat; + u_int16_t attr_type; + int hidden = FALSE; + + if (length <= 0) { + return; + } + + printf(" "); + + TCHECK(*ptr); /* Flags & Length */ + len = EXTRACT_16BITS(ptr) & L2TP_AVP_HDR_LEN_MASK; + + /* If it is not long enough to contain the header, we'll give up. */ + if (len < 6) + goto trunc; + + /* If it goes past the end of the remaining length of the packet, + we'll give up. */ + if (len > (u_int)length) + goto trunc; + + /* If it goes past the end of the remaining length of the captured + data, we'll give up. */ + TCHECK2(*ptr, len); + /* After this point, no need to worry about truncation */ + + if (EXTRACT_16BITS(ptr) & L2TP_AVP_HDR_FLAG_MANDATORY) { + printf("*"); + } + if (EXTRACT_16BITS(ptr) & L2TP_AVP_HDR_FLAG_HIDDEN) { + hidden = TRUE; + printf("?"); + } + ptr++; + + if (EXTRACT_16BITS(ptr)) { + /* Vendor Specific Attribute */ + printf("VENDOR%04x:", EXTRACT_16BITS(ptr)); ptr++; + printf("ATTR%04x", EXTRACT_16BITS(ptr)); ptr++; + printf("("); + print_octets((u_char *)ptr, len-6); + printf(")"); + } else { + /* IETF-defined Attributes */ + ptr++; + attr_type = EXTRACT_16BITS(ptr); ptr++; + printf("%s", tok2str(l2tp_avp2str, "AVP-#%u", attr_type)); + printf("("); + if (hidden) { + printf("???"); + } else { + switch (attr_type) { + case L2TP_AVP_MSGTYPE: + l2tp_msgtype_print((u_char *)ptr); + break; + case L2TP_AVP_RESULT_CODE: + l2tp_result_code_print((u_char *)ptr, len-6); + break; + case L2TP_AVP_PROTO_VER: + l2tp_proto_ver_print(ptr); + break; + case L2TP_AVP_FRAMING_CAP: + l2tp_framing_cap_print((u_char *)ptr); + break; + case L2TP_AVP_BEARER_CAP: + l2tp_bearer_cap_print((u_char *)ptr); + break; + case L2TP_AVP_TIE_BREAKER: + print_octets((u_char *)ptr, 8); + break; + case L2TP_AVP_FIRM_VER: + case L2TP_AVP_ASSND_TUN_ID: + case L2TP_AVP_RECV_WIN_SIZE: + case L2TP_AVP_ASSND_SESS_ID: + print_16bits_val(ptr); + break; + case L2TP_AVP_HOST_NAME: + case L2TP_AVP_VENDOR_NAME: + case L2TP_AVP_CALLING_NUMBER: + case L2TP_AVP_CALLED_NUMBER: + case L2TP_AVP_SUB_ADDRESS: + case L2TP_AVP_PROXY_AUTH_NAME: + case L2TP_AVP_PRIVATE_GRP_ID: + print_string((u_char *)ptr, len-6); + break; + case L2TP_AVP_CHALLENGE: + case L2TP_AVP_INI_RECV_LCP: + case L2TP_AVP_LAST_SENT_LCP: + case L2TP_AVP_LAST_RECV_LCP: + case L2TP_AVP_PROXY_AUTH_CHAL: + case L2TP_AVP_PROXY_AUTH_RESP: + case L2TP_AVP_RANDOM_VECTOR: + print_octets((u_char *)ptr, len-6); + break; + case L2TP_AVP_Q931_CC: + l2tp_q931_cc_print((u_char *)ptr, len-6); + break; + case L2TP_AVP_CHALLENGE_RESP: + print_octets((u_char *)ptr, 16); + break; + case L2TP_AVP_CALL_SER_NUM: + case L2TP_AVP_MINIMUM_BPS: + case L2TP_AVP_MAXIMUM_BPS: + case L2TP_AVP_TX_CONN_SPEED: + case L2TP_AVP_PHY_CHANNEL_ID: + case L2TP_AVP_RX_CONN_SPEED: + print_32bits_val((u_int32_t *)ptr); + break; + case L2TP_AVP_BEARER_TYPE: + l2tp_bearer_type_print((u_char *)ptr); + break; + case L2TP_AVP_FRAMING_TYPE: + l2tp_framing_type_print((u_char *)ptr); + break; + case L2TP_AVP_PACKET_PROC_DELAY: + l2tp_packet_proc_delay_print(); + break; + case L2TP_AVP_PROXY_AUTH_TYPE: + l2tp_proxy_auth_type_print((u_char *)ptr); + break; + case L2TP_AVP_PROXY_AUTH_ID: + l2tp_proxy_auth_id_print((u_char *)ptr); + break; + case L2TP_AVP_CALL_ERRORS: + l2tp_call_errors_print((u_char *)ptr); + break; + case L2TP_AVP_ACCM: + l2tp_accm_print((u_char *)ptr); + break; + case L2TP_AVP_SEQ_REQUIRED: + break; /* No Attribute Value */ + case L2TP_AVP_PPP_DISCON_CC: + l2tp_ppp_discon_cc_print((u_char *)ptr, len-6); + break; + default: + break; + } + } + printf(")"); + } + + l2tp_avp_print(dat+len, length-len); + return; + + trunc: + printf("|..."); +} + + +void +l2tp_print(const u_char *dat, u_int length) +{ + const u_char *ptr = dat; + u_int cnt = 0; /* total octets consumed */ + u_int16_t pad; + int flag_t, flag_l, flag_s, flag_o; + u_int16_t l2tp_len; + + flag_t = flag_l = flag_s = flag_o = FALSE; + + TCHECK2(*ptr, 2); /* Flags & Version */ + if ((EXTRACT_16BITS(ptr) & L2TP_VERSION_MASK) == L2TP_VERSION_L2TP) { + printf(" l2tp:"); + } else if ((EXTRACT_16BITS(ptr) & L2TP_VERSION_MASK) == L2TP_VERSION_L2F) { + printf(" l2f:"); + return; /* nothing to do */ + } else { + printf(" Unknown Version, neither L2F(1) nor L2TP(2)"); + return; /* nothing we can do */ + } + + printf("["); + if (EXTRACT_16BITS(ptr) & L2TP_FLAG_TYPE) { + flag_t = TRUE; + printf("T"); + } + if (EXTRACT_16BITS(ptr) & L2TP_FLAG_LENGTH) { + flag_l = TRUE; + printf("L"); + } + if (EXTRACT_16BITS(ptr) & L2TP_FLAG_SEQUENCE) { + flag_s = TRUE; + printf("S"); + } + if (EXTRACT_16BITS(ptr) & L2TP_FLAG_OFFSET) { + flag_o = TRUE; + printf("O"); + } + if (EXTRACT_16BITS(ptr) & L2TP_FLAG_PRIORITY) + printf("P"); + printf("]"); + + ptr += 2; + cnt += 2; + + if (flag_l) { + TCHECK2(*ptr, 2); /* Length */ + l2tp_len = EXTRACT_16BITS(ptr); + ptr += 2; + cnt += 2; + } else { + l2tp_len = 0; + } + + TCHECK2(*ptr, 2); /* Tunnel ID */ + printf("(%u/", EXTRACT_16BITS(ptr)); + ptr += 2; + cnt += 2; + TCHECK2(*ptr, 2); /* Session ID */ + printf("%u)", EXTRACT_16BITS(ptr)); + ptr += 2; + cnt += 2; + + if (flag_s) { + TCHECK2(*ptr, 2); /* Ns */ + printf("Ns=%u,", EXTRACT_16BITS(ptr)); + ptr += 2; + cnt += 2; + TCHECK2(*ptr, 2); /* Nr */ + printf("Nr=%u", EXTRACT_16BITS(ptr)); + ptr += 2; + cnt += 2; + } + + if (flag_o) { + TCHECK2(*ptr, 2); /* Offset Size */ + pad = EXTRACT_16BITS(ptr); + ptr += (2 + pad); + cnt += (2 + pad); + } + + if (flag_l) { + if (length < l2tp_len) { + printf(" Length %u larger than packet", l2tp_len); + return; + } + length = l2tp_len; + } + if (length < cnt) { + printf(" Length %u smaller than header length", length); + return; + } + if (flag_t) { + if (!flag_l) { + printf(" No length"); + return; + } + if (length - cnt == 0) { + printf(" ZLB"); + } else { + l2tp_avp_print(ptr, length - cnt); + } + } else { + printf(" {"); + ppp_print(ptr, length - cnt); + printf("}"); + } + + return; + + trunc: + printf("%s", tstr); +}
diff --git a/tcpdump-4.3.0/print-lane.c b/tcpdump-4.3.0/print-lane.c new file mode 100644 index 0000000..aa79311 --- /dev/null +++ b/tcpdump-4.3.0/print-lane.c
@@ -0,0 +1,118 @@ +/* + * Marko Kiiskila carnil@cs.tut.fi + * + * Tampere University of Technology - Telecommunications Laboratory + * + * Permission to use, copy, modify and distribute this + * software and its documentation is hereby granted, + * provided that both the copyright notice and this + * permission notice appear in all copies of the software, + * derivative works or modified versions, and any portions + * thereof, that both notices appear in supporting + * 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[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.25 2005-11-13 12:12:42 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 "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 void +lane_hdr_print(netdissect_options *ndo, const u_char *bp) +{ + (void)ND_PRINT((ndo, "lecid:%x ", EXTRACT_16BITS(bp))); +} + +/* + * This is the top level routine of the printer. 'p' points + * to the LANE header of the packet, 'h->ts' is the timestamp, + * 'h->len' is the length of the packet off the wire, and 'h->caplen' + * is the number of bytes actually captured. + * + * This assumes 802.3, not 802.5, LAN emulation. + */ +void +lane_print(const u_char *p, u_int length, u_int caplen) +{ + struct lane_controlhdr *lec; + + 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; + } + + /* + * Go past the LE header. + */ + length -= 2; + caplen -= 2; + p += 2; + + /* + * Now print the encapsulated frame, under the assumption + * that it's an Ethernet frame. + */ + ether_print(gndo, p, length, caplen, lane_hdr_print, p - 2); +} + +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/tcpdump-4.3.0/print-ldp.c b/tcpdump-4.3.0/print-ldp.c new file mode 100644 index 0000000..262c9bd --- /dev/null +++ b/tcpdump-4.3.0/print-ldp.c
@@ -0,0 +1,676 @@ +/* + * 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) + * and Steinar Haug (sthaug@nethelp.no) + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-ldp.c,v 1.20 2006-06-23 02:03:09 hannes 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 "decode_prefix.h" +#include "extract.h" +#include "addrtoname.h" + +#include "l2vpn.h" +#include "af.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 Withdraw" }, + { 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_ADDRESS_LIST_AFNUM_LEN 2 +#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_FT_SESSION 0x0503 +#define LDP_TLV_LABEL_REQUEST_MSG_ID 0x0600 +#define LDP_TLV_MTU 0x0601 /* rfc 3988 */ + +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_FT_SESSION, "Fault-Tolerant Session Parameters" }, + { LDP_TLV_LABEL_REQUEST_MSG_ID, "Label Request Message ID" }, + { LDP_TLV_MTU, "MTU" }, + { 0, NULL} +}; + +#define LDP_FEC_WILDCARD 0x01 +#define LDP_FEC_PREFIX 0x02 +#define LDP_FEC_HOSTADDRESS 0x03 +/* From RFC 4906; should probably be updated to RFC 4447 (e.g., VC -> PW) */ +#define LDP_FEC_MARTINI_VC 0x80 + +static const struct tok ldp_fec_values[] = { + { LDP_FEC_WILDCARD, "Wildcard" }, + { LDP_FEC_PREFIX, "Prefix" }, + { LDP_FEC_HOSTADDRESS, "Host address" }, + { LDP_FEC_MARTINI_VC, "Martini VC" }, + { 0, NULL} +}; + +#define LDP_FEC_MARTINI_IFPARM_MTU 0x01 +#define LDP_FEC_MARTINI_IFPARM_DESC 0x03 +#define LDP_FEC_MARTINI_IFPARM_VCCV 0x0c + +static const struct tok ldp_fec_martini_ifparm_values[] = { + { LDP_FEC_MARTINI_IFPARM_MTU, "MTU" }, + { LDP_FEC_MARTINI_IFPARM_DESC, "Description" }, + { LDP_FEC_MARTINI_IFPARM_VCCV, "VCCV" }, + { 0, NULL} +}; + +/* draft-ietf-pwe3-vccv-04.txt */ +static const struct tok ldp_fec_martini_ifparm_vccv_cc_values[] = { + { 0x01, "PWE3 control word" }, + { 0x02, "MPLS Router Alert Label" }, + { 0x04, "MPLS inner label TTL = 1" }, + { 0, NULL} +}; + +/* draft-ietf-pwe3-vccv-04.txt */ +static const struct tok ldp_fec_martini_ifparm_vccv_cv_values[] = { + { 0x01, "ICMP Ping" }, + { 0x02, "LSP Ping" }, + { 0x04, "BFD" }, + { 0, NULL} +}; + +int ldp_msg_print(register const u_char *); +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 | + * ~ ~ + * | | + * | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ + +#define TLV_TCHECK(minlen) \ + TCHECK2(*tptr, minlen); if (tlv_tlen < minlen) goto badtlv; + +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,af,ft_flags; + u_char fec_type; + u_int ui,vc_info_len, vc_info_tlv_type, vc_info_tlv_len,idx; + char buf[100]; + int i; + + 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: + TLV_TCHECK(4); + 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: + TLV_TCHECK(4); + printf("\n\t IPv4 Transport Address: %s", ipaddr_string(tptr)); + break; +#ifdef INET6 + case LDP_TLV_IPV6_TRANSPORT_ADDR: + TLV_TCHECK(16); + printf("\n\t IPv6 Transport Address: %s", ip6addr_string(tptr)); + break; +#endif + case LDP_TLV_CONFIG_SEQ_NUMBER: + TLV_TCHECK(4); + printf("\n\t Sequence Number: %u", EXTRACT_32BITS(tptr)); + break; + + case LDP_TLV_ADDRESS_LIST: + TLV_TCHECK(LDP_TLV_ADDRESS_LIST_AFNUM_LEN); + af = EXTRACT_16BITS(tptr); + tptr+=LDP_TLV_ADDRESS_LIST_AFNUM_LEN; + tlv_tlen -= LDP_TLV_ADDRESS_LIST_AFNUM_LEN; + printf("\n\t Address Family: %s, addresses", + tok2str(af_values, "Unknown (%u)", af)); + switch (af) { + case AFNUM_INET: + while(tlv_tlen >= sizeof(struct in_addr)) { + TCHECK2(*tptr, sizeof(struct in_addr)); + printf(" %s",ipaddr_string(tptr)); + tlv_tlen-=sizeof(struct in_addr); + tptr+=sizeof(struct in_addr); + } + break; +#ifdef INET6 + case AFNUM_INET6: + while(tlv_tlen >= sizeof(struct in6_addr)) { + TCHECK2(*tptr, sizeof(struct in6_addr)); + printf(" %s",ip6addr_string(tptr)); + tlv_tlen-=sizeof(struct in6_addr); + tptr+=sizeof(struct in6_addr); + } + break; +#endif + default: + /* unknown AF */ + break; + } + break; + + case LDP_TLV_COMMON_SESSION: + TLV_TCHECK(8); + printf("\n\t Version: %u, Keepalive: %us, Flags: [Downstream %s, Loop Detection %s]", + EXTRACT_16BITS(tptr), EXTRACT_16BITS(tptr+2), + (EXTRACT_16BITS(tptr+6)&0x8000) ? "On Demand" : "Unsolicited", + (EXTRACT_16BITS(tptr+6)&0x4000) ? "Enabled" : "Disabled" + ); + break; + + case LDP_TLV_FEC: + TLV_TCHECK(1); + fec_type = *tptr; + printf("\n\t %s FEC (0x%02x)", + tok2str(ldp_fec_values, "Unknown", fec_type), + fec_type); + + tptr+=1; + tlv_tlen-=1; + switch(fec_type) { + + case LDP_FEC_WILDCARD: + break; + case LDP_FEC_PREFIX: + TLV_TCHECK(2); + af = EXTRACT_16BITS(tptr); + tptr+=LDP_TLV_ADDRESS_LIST_AFNUM_LEN; + tlv_tlen-=LDP_TLV_ADDRESS_LIST_AFNUM_LEN; + if (af == AFNUM_INET) { + i=decode_prefix4(tptr,tlv_tlen,buf,sizeof(buf)); + if (i == -2) + goto trunc; + if (i == -3) + printf(": IPv4 prefix (goes past end of TLV)"); + else if (i == -1) + printf(": IPv4 prefix (invalid length)"); + else + printf(": IPv4 prefix %s",buf); + } +#ifdef INET6 + else if (af == AFNUM_INET6) { + i=decode_prefix6(tptr,tlv_tlen,buf,sizeof(buf)); + if (i == -2) + goto trunc; + if (i == -3) + printf(": IPv4 prefix (goes past end of TLV)"); + else if (i == -1) + printf(": IPv6 prefix (invalid length)"); + else + printf(": IPv6 prefix %s",buf); + } +#endif + else + printf(": Address family %u prefix", af); + break; + case LDP_FEC_HOSTADDRESS: + break; + case LDP_FEC_MARTINI_VC: + /* + * According to RFC 4908, the VC info Length field can be zero, + * in which case not only are there no interface parameters, + * there's no VC ID. + */ + TLV_TCHECK(7); + vc_info_len = *(tptr+2); + + if (vc_info_len == 0) { + printf(": %s, %scontrol word, group-ID %u, VC-info-length: %u", + tok2str(l2vpn_encaps_values, "Unknown", EXTRACT_16BITS(tptr)&0x7fff), + EXTRACT_16BITS(tptr)&0x8000 ? "" : "no ", + EXTRACT_32BITS(tptr+3), + vc_info_len); + break; + } + + /* Make sure we have the VC ID as well */ + TLV_TCHECK(11); + printf(": %s, %scontrol word, group-ID %u, VC-ID %u, VC-info-length: %u", + tok2str(l2vpn_encaps_values, "Unknown", EXTRACT_16BITS(tptr)&0x7fff), + EXTRACT_16BITS(tptr)&0x8000 ? "" : "no ", + EXTRACT_32BITS(tptr+3), + EXTRACT_32BITS(tptr+7), + vc_info_len); + if (vc_info_len < 4) + goto trunc; /* minimum 4, for the VC ID */ + vc_info_len -= 4; /* subtract out the VC ID, giving the length of the interface parameters */ + + /* Skip past the fixed information and the VC ID */ + tptr+=11; + tlv_tlen-=11; + TLV_TCHECK(vc_info_len); + + while (vc_info_len > 2) { + vc_info_tlv_type = *tptr; + vc_info_tlv_len = *(tptr+1); + if (vc_info_tlv_len < 2) + break; + if (vc_info_len < vc_info_tlv_len) + break; + + printf("\n\t\tInterface Parameter: %s (0x%02x), len %u", + tok2str(ldp_fec_martini_ifparm_values,"Unknown",vc_info_tlv_type), + vc_info_tlv_type, + vc_info_tlv_len); + + switch(vc_info_tlv_type) { + case LDP_FEC_MARTINI_IFPARM_MTU: + printf(": %u",EXTRACT_16BITS(tptr+2)); + break; + + case LDP_FEC_MARTINI_IFPARM_DESC: + printf(": "); + for (idx = 2; idx < vc_info_tlv_len; idx++) + safeputchar(*(tptr+idx)); + break; + + case LDP_FEC_MARTINI_IFPARM_VCCV: + printf("\n\t\t Control Channels (0x%02x) = [%s]", + *(tptr+2), + bittok2str(ldp_fec_martini_ifparm_vccv_cc_values,"none",*(tptr+2))); + printf("\n\t\t CV Types (0x%02x) = [%s]", + *(tptr+3), + bittok2str(ldp_fec_martini_ifparm_vccv_cv_values,"none",*(tptr+3))); + break; + + default: + print_unknown_data(tptr+2,"\n\t\t ",vc_info_tlv_len-2); + break; + } + + vc_info_len -= vc_info_tlv_len; + tptr += vc_info_tlv_len; + } + break; + } + + break; + + case LDP_TLV_GENERIC_LABEL: + TLV_TCHECK(4); + printf("\n\t Label: %u", EXTRACT_32BITS(tptr) & 0xfffff); + break; + + case LDP_TLV_STATUS: + TLV_TCHECK(8); + ui = EXTRACT_32BITS(tptr); + tptr+=4; + printf("\n\t Status: 0x%02x, Flags: [%s and %s forward]", + ui&0x3fffffff, + ui&0x80000000 ? "Fatal error" : "Advisory Notification", + ui&0x40000000 ? "do" : "don't"); + ui = EXTRACT_32BITS(tptr); + tptr+=4; + if (ui) + printf(", causing Message ID: 0x%08x", ui); + break; + + case LDP_TLV_FT_SESSION: + TLV_TCHECK(8); + ft_flags = EXTRACT_16BITS(tptr); + printf("\n\t Flags: [%sReconnect, %sSave State, %sAll-Label Protection, %s Checkpoint, %sRe-Learn State]", + ft_flags&0x8000 ? "" : "No ", + ft_flags&0x8 ? "" : "Don't ", + ft_flags&0x4 ? "" : "No ", + ft_flags&0x2 ? "Sequence Numbered Label" : "All Labels", + ft_flags&0x1 ? "" : "Don't "); + tptr+=4; + ui = EXTRACT_32BITS(tptr); + if (ui) + printf(", Reconnect Timeout: %ums", ui); + tptr+=4; + ui = EXTRACT_32BITS(tptr); + if (ui) + printf(", Recovery Time: %ums", ui); + break; + + case LDP_TLV_MTU: + TLV_TCHECK(2); + printf("\n\t MTU: %u", EXTRACT_16BITS(tptr)); + break; + + + /* + * FIXME those are the defined TLVs that lack a decoder + * you are welcome to contribute code ;-) + */ + + case LDP_TLV_HOP_COUNT: + case LDP_TLV_PATH_VECTOR: + case LDP_TLV_ATM_LABEL: + case LDP_TLV_FR_LABEL: + case LDP_TLV_EXTD_STATUS: + case LDP_TLV_RETURNED_PDU: + case LDP_TLV_RETURNED_MSG: + 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 */ + +trunc: + printf("\n\t\t packet exceeded snapshot"); + return 0; + +badtlv: + printf("\n\t\t TLV contents go past end of TLV"); + return(tlv_len+4); /* Type & Length fields not included */ +} + +void +ldp_print(register const u_char *pptr, register u_int len) { + + int processed; + while (len > (sizeof(struct ldp_common_header) + sizeof(struct ldp_msg_header))) { + processed = ldp_msg_print(pptr); + if (processed == 0) + return; + len -= processed; + pptr += processed; + } +} + + +int +ldp_msg_print(register const u_char *pptr) { + + 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 pdu_len,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("%sLDP version %u packet not supported", + (vflag < 1) ? "" : "\n\t", + EXTRACT_16BITS(&ldp_com_header->version)); + return 0; + } + + /* print the LSR-ID, label-space & length */ + pdu_len = EXTRACT_16BITS(&ldp_com_header->pdu_length); + printf("%sLDP, Label-Space-ID: %s:%u, pdu-length: %u", + (vflag < 1) ? "" : "\n\t", + ipaddr_string(&ldp_com_header->lsr_id), + EXTRACT_16BITS(&ldp_com_header->label_space), + pdu_len); + + /* bail out if non-verbose */ + if (vflag < 1) + return 0; + + /* ok they seem to want to know everything - lets fully decode it */ + tlen=pdu_len; + + tptr += sizeof(const struct ldp_common_header); + tlen -= sizeof(const struct ldp_common_header)-4; /* Type & Length fields not included */ + + while(tlen>0) { + /* did we capture enough for fully decoding the msg header ? */ + TCHECK2(*tptr, sizeof(struct ldp_msg_header)); + + 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"); + + if (msg_len == 0) /* infinite loop protection */ + return 0; + + 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 ? */ + TCHECK2(*tptr, msg_len); + hexdump=FALSE; + + switch(msg_type) { + + case LDP_MSG_NOTIF: + case LDP_MSG_HELLO: + case LDP_MSG_INIT: + case LDP_MSG_KEEPALIVE: + case LDP_MSG_ADDRESS: + case LDP_MSG_LABEL_MAPPING: + case LDP_MSG_ADDRESS_WITHDRAW: + case LDP_MSG_LABEL_WITHDRAW: + 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_LABEL_REQUEST: + 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(struct ldp_msg_header),"\n\t ", + msg_len); + + tptr += msg_len+4; + tlen -= msg_len+4; + } + return pdu_len+4; +trunc: + printf("\n\t\t packet exceeded snapshot"); + return 0; +} +
diff --git a/tcpdump-4.3.0/print-llc.c b/tcpdump-4.3.0/print-llc.c new file mode 100644 index 0000000..a193471 --- /dev/null +++ b/tcpdump-4.3.0/print-llc.c
@@ -0,0 +1,545 @@ +/* + * Copyright (c) 1992, 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * Code by Matt Thomas, Digital Equipment Corporation + * with an awful lot of hacking by Jeffrey Mogul, DECWRL + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.75 2007-04-13 09:43:11 hannes Exp $"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> +#include <string.h> + +#include "interface.h" +#include "addrtoname.h" +#include "extract.h" /* must come after interface.h */ + +#include "llc.h" +#include "ethertype.h" +#include "oui.h" + +static struct tok llc_values[] = { + { LLCSAP_NULL, "Null" }, + { LLCSAP_GLOBAL, "Global" }, + { LLCSAP_8021B_I, "802.1B I" }, + { LLCSAP_8021B_G, "802.1B G" }, + { LLCSAP_IP, "IP" }, + { LLCSAP_SNA, "SNA" }, + { LLCSAP_PROWAYNM, "ProWay NM" }, + { LLCSAP_8021D, "STP" }, + { LLCSAP_RS511, "RS511" }, + { LLCSAP_ISO8208, "ISO8208" }, + { LLCSAP_PROWAY, "ProWay" }, + { LLCSAP_SNAP, "SNAP" }, + { LLCSAP_IPX, "IPX" }, + { LLCSAP_NETBEUI, "NetBeui" }, + { LLCSAP_ISONS, "OSI" }, + { 0, NULL }, +}; + +static struct tok llc_cmd_values[] = { + { LLC_UI, "ui" }, + { LLC_TEST, "test" }, + { LLC_XID, "xid" }, + { LLC_UA, "ua" }, + { LLC_DISC, "disc" }, + { LLC_DM, "dm" }, + { LLC_SABME, "sabme" }, + { LLC_FRMR, "frmr" }, + { 0, NULL } +}; + +static const struct tok llc_flag_values[] = { + { 0, "Command" }, + { LLC_GSAP, "Response" }, + { LLC_U_POLL, "Poll" }, + { LLC_GSAP|LLC_U_POLL, "Final" }, + { LLC_IS_POLL, "Poll" }, + { LLC_GSAP|LLC_IS_POLL, "Final" }, + { 0, NULL } +}; + + +static const struct tok llc_ig_flag_values[] = { + { 0, "Individual" }, + { LLC_IG, "Group" }, + { 0, NULL } +}; + + +static const struct tok llc_supervisory_values[] = { + { 0, "Receiver Ready" }, + { 1, "Receiver not Ready" }, + { 2, "Reject" }, + { 0, NULL } +}; + + +static const struct tok cisco_values[] = { + { PID_CISCO_CDP, "CDP" }, + { PID_CISCO_VTP, "VTP" }, + { PID_CISCO_DTP, "DTP" }, + { PID_CISCO_UDLD, "UDLD" }, + { PID_CISCO_PVST, "PVST" }, + { 0, NULL } +}; + +static const struct tok bridged_values[] = { + { PID_RFC2684_ETH_FCS, "Ethernet + FCS" }, + { PID_RFC2684_ETH_NOFCS, "Ethernet w/o FCS" }, + { PID_RFC2684_802_4_FCS, "802.4 + FCS" }, + { PID_RFC2684_802_4_NOFCS, "802.4 w/o FCS" }, + { PID_RFC2684_802_5_FCS, "Token Ring + FCS" }, + { PID_RFC2684_802_5_NOFCS, "Token Ring w/o FCS" }, + { PID_RFC2684_FDDI_FCS, "FDDI + FCS" }, + { PID_RFC2684_FDDI_NOFCS, "FDDI w/o FCS" }, + { PID_RFC2684_802_6_FCS, "802.6 + FCS" }, + { PID_RFC2684_802_6_NOFCS, "802.6 w/o FCS" }, + { PID_RFC2684_BPDU, "BPDU" }, + { 0, NULL }, +}; + +static const struct tok null_values[] = { + { 0, NULL } +}; + +struct oui_tok { + u_int32_t oui; + const struct tok *tok; +}; + +static const struct oui_tok oui_to_tok[] = { + { OUI_ENCAP_ETHER, ethertype_values }, + { OUI_CISCO_90, ethertype_values }, /* uses some Ethertype values */ + { OUI_APPLETALK, ethertype_values }, /* uses some Ethertype values */ + { OUI_CISCO, cisco_values }, + { OUI_RFC2684, bridged_values }, /* bridged, RFC 2427 FR or RFC 2864 ATM */ + { 0, NULL } +}; + +/* + * Returns non-zero IFF it succeeds in printing the header + */ +int +llc_print(const u_char *p, u_int length, u_int caplen, + const u_char *esrc, const u_char *edst, u_short *extracted_ethertype) +{ + u_int8_t dsap_field, dsap, ssap_field, ssap; + u_int16_t control; + int is_u; + register int ret; + + *extracted_ethertype = 0; + + if (caplen < 3) { + (void)printf("[|llc]"); + default_print((u_char *)p, caplen); + return(0); + } + + dsap_field = *p; + ssap_field = *(p + 1); + + /* + * OK, what type of LLC frame is this? The length + * of the control field depends on that - I frames + * have a two-byte control field, and U frames have + * a one-byte control field. + */ + control = *(p + 2); + if ((control & LLC_U_FMT) == LLC_U_FMT) { + /* + * U frame. + */ + is_u = 1; + } else { + /* + * The control field in I and S frames is + * 2 bytes... + */ + if (caplen < 4) { + (void)printf("[|llc]"); + default_print((u_char *)p, caplen); + return(0); + } + + /* + * ...and is little-endian. + */ + control = EXTRACT_LE_16BITS(p + 2); + is_u = 0; + } + + if (ssap_field == LLCSAP_GLOBAL && dsap_field == LLCSAP_GLOBAL) { + /* + * This is an Ethernet_802.3 IPX frame; it has an + * 802.3 header (i.e., an Ethernet header where the + * type/length field is <= ETHERMTU, i.e. it's a length + * field, not a type field), but has no 802.2 header - + * the IPX packet starts right after the Ethernet header, + * with a signature of two bytes of 0xFF (which is + * LLCSAP_GLOBAL). + * + * (It might also have been an Ethernet_802.3 IPX at + * one time, but got bridged onto another network, + * such as an 802.11 network; this has appeared in at + * least one capture file.) + */ + + if (eflag) + printf("IPX 802.3: "); + + ipx_print(p, length); + return (1); + } + + dsap = dsap_field & ~LLC_IG; + ssap = ssap_field & ~LLC_GSAP; + + if (eflag) { + printf("LLC, dsap %s (0x%02x) %s, ssap %s (0x%02x) %s", + tok2str(llc_values, "Unknown", dsap), + dsap, + tok2str(llc_ig_flag_values, "Unknown", dsap_field & LLC_IG), + tok2str(llc_values, "Unknown", ssap), + ssap, + tok2str(llc_flag_values, "Unknown", ssap_field & LLC_GSAP)); + + if (is_u) { + printf(", ctrl 0x%02x: ", control); + } else { + printf(", ctrl 0x%04x: ", control); + } + } + + if (ssap == LLCSAP_8021D && dsap == LLCSAP_8021D && + control == LLC_UI) { + stp_print(p+3, length-3); + return (1); + } + + if (ssap == LLCSAP_IP && dsap == LLCSAP_IP && + control == LLC_UI) { + ip_print(gndo, p+4, length-4); + return (1); + } + + if (ssap == LLCSAP_IPX && dsap == LLCSAP_IPX && + control == LLC_UI) { + /* + * This is an Ethernet_802.2 IPX frame, with an 802.3 + * header and an 802.2 LLC header with the source and + * destination SAPs being the IPX SAP. + * + * Skip DSAP, LSAP, and control field. + */ + if (eflag) + printf("IPX 802.2: "); + + ipx_print(p+3, length-3); + return (1); + } + +#ifdef TCPDUMP_DO_SMB + if (ssap == LLCSAP_NETBEUI && dsap == LLCSAP_NETBEUI + && (!(control & LLC_S_FMT) || control == LLC_U_FMT)) { + /* + * we don't actually have a full netbeui parser yet, but the + * smb parser can handle many smb-in-netbeui packets, which + * is very useful, so we call that + * + * We don't call it for S frames, however, just I frames + * (which are frames that don't have the low-order bit, + * LLC_S_FMT, set in the first byte of the control field) + * and UI frames (whose control field is just 3, LLC_U_FMT). + */ + + /* + * Skip the LLC header. + */ + if (is_u) { + p += 3; + length -= 3; + caplen -= 3; + } else { + p += 4; + length -= 4; + caplen -= 4; + } + netbeui_print(control, p, length); + return (1); + } +#endif + if (ssap == LLCSAP_ISONS && dsap == LLCSAP_ISONS + && control == LLC_UI) { + isoclns_print(p + 3, length - 3, caplen - 3); + return (1); + } + + if (ssap == LLCSAP_SNAP && dsap == LLCSAP_SNAP + && control == LLC_UI) { + /* + * XXX - what *is* the right bridge pad value here? + * Does anybody ever bridge one form of LAN traffic + * over a networking type that uses 802.2 LLC? + */ + ret = snap_print(p+3, length-3, caplen-3, 2); + if (ret) + return (ret); + } + + if (!eflag) { + if (ssap == dsap) { + if (esrc == NULL || edst == NULL) + (void)printf("%s ", tok2str(llc_values, "Unknown DSAP 0x%02x", dsap)); + else + (void)printf("%s > %s %s ", + etheraddr_string(esrc), + etheraddr_string(edst), + tok2str(llc_values, "Unknown DSAP 0x%02x", dsap)); + } else { + if (esrc == NULL || edst == NULL) + (void)printf("%s > %s ", + tok2str(llc_values, "Unknown SSAP 0x%02x", ssap), + tok2str(llc_values, "Unknown DSAP 0x%02x", dsap)); + else + (void)printf("%s %s > %s %s ", + etheraddr_string(esrc), + tok2str(llc_values, "Unknown SSAP 0x%02x", ssap), + etheraddr_string(edst), + tok2str(llc_values, "Unknown DSAP 0x%02x", dsap)); + } + } + + if (is_u) { + printf("Unnumbered, %s, Flags [%s], length %u", + tok2str(llc_cmd_values, "%02x", LLC_U_CMD(control)), + tok2str(llc_flag_values,"?",(ssap_field & LLC_GSAP) | (control & LLC_U_POLL)), + length); + + p += 3; + length -= 3; + caplen -= 3; + + if ((control & ~LLC_U_POLL) == LLC_XID) { + if (*p == LLC_XID_FI) { + printf(": %02x %02x", p[1], p[2]); + p += 3; + length -= 3; + caplen -= 3; + } + } + } else { + if ((control & LLC_S_FMT) == LLC_S_FMT) { + (void)printf("Supervisory, %s, rcv seq %u, Flags [%s], length %u", + tok2str(llc_supervisory_values,"?",LLC_S_CMD(control)), + LLC_IS_NR(control), + tok2str(llc_flag_values,"?",(ssap_field & LLC_GSAP) | (control & LLC_IS_POLL)), + length); + } else { + (void)printf("Information, send seq %u, rcv seq %u, Flags [%s], length %u", + LLC_I_NS(control), + LLC_IS_NR(control), + tok2str(llc_flag_values,"?",(ssap_field & LLC_GSAP) | (control & LLC_IS_POLL)), + length); + } + p += 4; + length -= 4; + caplen -= 4; + } + return(1); +} + +int +snap_print(const u_char *p, u_int length, u_int caplen, u_int bridge_pad) +{ + u_int32_t orgcode; + register u_short et; + register int ret; + + TCHECK2(*p, 5); + orgcode = EXTRACT_24BITS(p); + et = EXTRACT_16BITS(p + 3); + + if (eflag) { + const struct tok *tok = null_values; + const struct oui_tok *otp; + + for (otp = &oui_to_tok[0]; otp->tok != NULL; otp++) { + if (otp->oui == orgcode) { + tok = otp->tok; + break; + } + } + (void)printf("oui %s (0x%06x), %s %s (0x%04x): ", + tok2str(oui_values, "Unknown", orgcode), + orgcode, + (orgcode == 0x000000 ? "ethertype" : "pid"), + tok2str(tok, "Unknown", et), + et); + } + p += 5; + length -= 5; + caplen -= 5; + + switch (orgcode) { + case OUI_ENCAP_ETHER: + case OUI_CISCO_90: + /* + * This is an encapsulated Ethernet packet, + * or a packet bridged by some piece of + * Cisco hardware; the protocol ID is + * an Ethernet protocol type. + */ + ret = ethertype_print(gndo, et, p, length, caplen); + if (ret) + return (ret); + break; + + case OUI_APPLETALK: + if (et == ETHERTYPE_ATALK) { + /* + * No, I have no idea why Apple used one + * of their own OUIs, rather than + * 0x000000, and an Ethernet packet + * type, for Appletalk data packets, + * but used 0x000000 and an Ethernet + * packet type for AARP packets. + */ + ret = ethertype_print(gndo, et, p, length, caplen); + if (ret) + return (ret); + } + break; + + case OUI_CISCO: + switch (et) { + case PID_CISCO_CDP: + cdp_print(p, length, caplen); + return (1); + case PID_CISCO_DTP: + dtp_print(p, length); + return (1); + case PID_CISCO_UDLD: + udld_print(p, length); + return (1); + case PID_CISCO_VTP: + vtp_print(p, length); + return (1); + case PID_CISCO_PVST: + stp_print(p, length); + return (1); + default: + break; + } + + case OUI_RFC2684: + switch (et) { + + case PID_RFC2684_ETH_FCS: + case PID_RFC2684_ETH_NOFCS: + /* + * XXX - remove the last two bytes for + * PID_RFC2684_ETH_FCS? + */ + /* + * Skip the padding. + */ + TCHECK2(*p, bridge_pad); + caplen -= bridge_pad; + length -= bridge_pad; + p += bridge_pad; + + /* + * What remains is an Ethernet packet. + */ + ether_print(gndo, p, length, caplen, NULL, NULL); + return (1); + + case PID_RFC2684_802_5_FCS: + case PID_RFC2684_802_5_NOFCS: + /* + * XXX - remove the last two bytes for + * PID_RFC2684_ETH_FCS? + */ + /* + * Skip the padding, but not the Access + * Control field. + */ + TCHECK2(*p, bridge_pad); + caplen -= bridge_pad; + length -= bridge_pad; + p += bridge_pad; + + /* + * What remains is an 802.5 Token Ring + * packet. + */ + token_print(p, length, caplen); + return (1); + + case PID_RFC2684_FDDI_FCS: + case PID_RFC2684_FDDI_NOFCS: + /* + * XXX - remove the last two bytes for + * PID_RFC2684_ETH_FCS? + */ + /* + * Skip the padding. + */ + TCHECK2(*p, bridge_pad + 1); + caplen -= bridge_pad + 1; + length -= bridge_pad + 1; + p += bridge_pad + 1; + + /* + * What remains is an FDDI packet. + */ + fddi_print(p, length, caplen); + return (1); + + case PID_RFC2684_BPDU: + stp_print(p, length); + return (1); + } + } + return (0); + +trunc: + (void)printf("[|snap]"); + return (1); +} + + +/* + * Local Variables: + * c-style: whitesmith + * c-basic-offset: 8 + * End: + */
diff --git a/tcpdump-4.3.0/print-lldp.c b/tcpdump-4.3.0/print-lldp.c new file mode 100644 index 0000000..8735e58 --- /dev/null +++ b/tcpdump-4.3.0/print-lldp.c
@@ -0,0 +1,1421 @@ +/* + * Copyright (c) 1998-2007 The TCPDUMP project + * + * 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. + * + * support for the IEEE Link Discovery Protocol as per 802.1AB + * + * Original code by Hannes Gredler (hannes@juniper.net) + * IEEE and TIA extensions by Carles Kishimoto <carles.kishimoto@gmail.com> + * DCBX extensions by Kaladhar Musunuru <kaladharm@sourceforge.net> + */ + +#ifndef lint +static const char rcsid[] _U_ = +"@(#) $Header: /tcpdump/master/tcpdump/print-lldp.c,v 1.10 2008-03-20 09:30:56 hannes 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 "af.h" +#include "oui.h" + +#define LLDP_EXTRACT_TYPE(x) (((x)&0xfe00)>>9) +#define LLDP_EXTRACT_LEN(x) ((x)&0x01ff) + +/* + * TLV type codes + */ +#define LLDP_END_TLV 0 +#define LLDP_CHASSIS_ID_TLV 1 +#define LLDP_PORT_ID_TLV 2 +#define LLDP_TTL_TLV 3 +#define LLDP_PORT_DESCR_TLV 4 +#define LLDP_SYSTEM_NAME_TLV 5 +#define LLDP_SYSTEM_DESCR_TLV 6 +#define LLDP_SYSTEM_CAP_TLV 7 +#define LLDP_MGMT_ADDR_TLV 8 +#define LLDP_PRIVATE_TLV 127 + +static const struct tok lldp_tlv_values[] = { + { LLDP_END_TLV, "End" }, + { LLDP_CHASSIS_ID_TLV, "Chassis ID" }, + { LLDP_PORT_ID_TLV, "Port ID" }, + { LLDP_TTL_TLV, "Time to Live" }, + { LLDP_PORT_DESCR_TLV, "Port Description" }, + { LLDP_SYSTEM_NAME_TLV, "System Name" }, + { LLDP_SYSTEM_DESCR_TLV, "System Description" }, + { LLDP_SYSTEM_CAP_TLV, "System Capabilities" }, + { LLDP_MGMT_ADDR_TLV, "Management Address" }, + { LLDP_PRIVATE_TLV, "Organization specific" }, + { 0, NULL} +}; + +/* + * Chassis ID subtypes + */ +#define LLDP_CHASSIS_CHASSIS_COMP_SUBTYPE 1 +#define LLDP_CHASSIS_INTF_ALIAS_SUBTYPE 2 +#define LLDP_CHASSIS_PORT_COMP_SUBTYPE 3 +#define LLDP_CHASSIS_MAC_ADDR_SUBTYPE 4 +#define LLDP_CHASSIS_NETWORK_ADDR_SUBTYPE 5 +#define LLDP_CHASSIS_INTF_NAME_SUBTYPE 6 +#define LLDP_CHASSIS_LOCAL_SUBTYPE 7 + +static const struct tok lldp_chassis_subtype_values[] = { + { LLDP_CHASSIS_CHASSIS_COMP_SUBTYPE, "Chassis component"}, + { LLDP_CHASSIS_INTF_ALIAS_SUBTYPE, "Interface alias"}, + { LLDP_CHASSIS_PORT_COMP_SUBTYPE, "Port component"}, + { LLDP_CHASSIS_MAC_ADDR_SUBTYPE, "MAC address"}, + { LLDP_CHASSIS_NETWORK_ADDR_SUBTYPE, "Network address"}, + { LLDP_CHASSIS_INTF_NAME_SUBTYPE, "Interface name"}, + { LLDP_CHASSIS_LOCAL_SUBTYPE, "Local"}, + { 0, NULL} +}; + +/* + * Port ID subtypes + */ +#define LLDP_PORT_INTF_ALIAS_SUBTYPE 1 +#define LLDP_PORT_PORT_COMP_SUBTYPE 2 +#define LLDP_PORT_MAC_ADDR_SUBTYPE 3 +#define LLDP_PORT_NETWORK_ADDR_SUBTYPE 4 +#define LLDP_PORT_INTF_NAME_SUBTYPE 5 +#define LLDP_PORT_AGENT_CIRC_ID_SUBTYPE 6 +#define LLDP_PORT_LOCAL_SUBTYPE 7 + +static const struct tok lldp_port_subtype_values[] = { + { LLDP_PORT_INTF_ALIAS_SUBTYPE, "Interface alias"}, + { LLDP_PORT_PORT_COMP_SUBTYPE, "Port component"}, + { LLDP_PORT_MAC_ADDR_SUBTYPE, "MAC address"}, + { LLDP_PORT_NETWORK_ADDR_SUBTYPE, "Network Address"}, + { LLDP_PORT_INTF_NAME_SUBTYPE, "Interface Name"}, + { LLDP_PORT_AGENT_CIRC_ID_SUBTYPE, "Agent circuit ID"}, + { LLDP_PORT_LOCAL_SUBTYPE, "Local"}, + { 0, NULL} +}; + +/* + * System Capabilities + */ +#define LLDP_CAP_OTHER (1 << 0) +#define LLDP_CAP_REPEATER (1 << 1) +#define LLDP_CAP_BRIDGE (1 << 2) +#define LLDP_CAP_WLAN_AP (1 << 3) +#define LLDP_CAP_ROUTER (1 << 4) +#define LLDP_CAP_PHONE (1 << 5) +#define LLDP_CAP_DOCSIS (1 << 6) +#define LLDP_CAP_STATION_ONLY (1 << 7) + +static const struct tok lldp_cap_values[] = { + { LLDP_CAP_OTHER, "Other"}, + { LLDP_CAP_REPEATER, "Repeater"}, + { LLDP_CAP_BRIDGE, "Bridge"}, + { LLDP_CAP_WLAN_AP, "WLAN AP"}, + { LLDP_CAP_ROUTER, "Router"}, + { LLDP_CAP_PHONE, "Telephone"}, + { LLDP_CAP_DOCSIS, "Docsis"}, + { LLDP_CAP_STATION_ONLY, "Station Only"}, + { 0, NULL} +}; + +#define LLDP_PRIVATE_8021_SUBTYPE_PORT_VLAN_ID 1 +#define LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_VLAN_ID 2 +#define LLDP_PRIVATE_8021_SUBTYPE_VLAN_NAME 3 +#define LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_IDENTITY 4 + +static const struct tok lldp_8021_subtype_values[] = { + { LLDP_PRIVATE_8021_SUBTYPE_PORT_VLAN_ID, "Port VLAN Id"}, + { LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_VLAN_ID, "Port and Protocol VLAN ID"}, + { LLDP_PRIVATE_8021_SUBTYPE_VLAN_NAME, "VLAN name"}, + { LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_IDENTITY, "Protocol Identity"}, + { 0, NULL} +}; + +#define LLDP_8021_PORT_PROTOCOL_VLAN_SUPPORT (1 << 1) +#define LLDP_8021_PORT_PROTOCOL_VLAN_STATUS (1 << 2) + +static const struct tok lldp_8021_port_protocol_id_values[] = { + { LLDP_8021_PORT_PROTOCOL_VLAN_SUPPORT, "supported"}, + { LLDP_8021_PORT_PROTOCOL_VLAN_STATUS, "enabled"}, + { 0, NULL} +}; + +#define LLDP_PRIVATE_8023_SUBTYPE_MACPHY 1 +#define LLDP_PRIVATE_8023_SUBTYPE_MDIPOWER 2 +#define LLDP_PRIVATE_8023_SUBTYPE_LINKAGGR 3 +#define LLDP_PRIVATE_8023_SUBTYPE_MTU 4 + +static const struct tok lldp_8023_subtype_values[] = { + { LLDP_PRIVATE_8023_SUBTYPE_MACPHY, "MAC/PHY configuration/status"}, + { LLDP_PRIVATE_8023_SUBTYPE_MDIPOWER, "Power via MDI"}, + { LLDP_PRIVATE_8023_SUBTYPE_LINKAGGR, "Link aggregation"}, + { LLDP_PRIVATE_8023_SUBTYPE_MTU, "Max frame size"}, + { 0, NULL} +}; + +#define LLDP_PRIVATE_TIA_SUBTYPE_CAPABILITIES 1 +#define LLDP_PRIVATE_TIA_SUBTYPE_NETWORK_POLICY 2 +#define LLDP_PRIVATE_TIA_SUBTYPE_LOCAL_ID 3 +#define LLDP_PRIVATE_TIA_SUBTYPE_EXTENDED_POWER_MDI 4 +#define LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_HARDWARE_REV 5 +#define LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_FIRMWARE_REV 6 +#define LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_SOFTWARE_REV 7 +#define LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_SERIAL_NUMBER 8 +#define LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_MANUFACTURER_NAME 9 +#define LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_MODEL_NAME 10 +#define LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_ASSET_ID 11 + +static const struct tok lldp_tia_subtype_values[] = { + { LLDP_PRIVATE_TIA_SUBTYPE_CAPABILITIES, "LLDP-MED Capabilities" }, + { LLDP_PRIVATE_TIA_SUBTYPE_NETWORK_POLICY, "Network policy" }, + { LLDP_PRIVATE_TIA_SUBTYPE_LOCAL_ID, "Location identification" }, + { LLDP_PRIVATE_TIA_SUBTYPE_EXTENDED_POWER_MDI, "Extended power-via-MDI" }, + { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_HARDWARE_REV, "Inventory - hardware revision" }, + { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_FIRMWARE_REV, "Inventory - firmware revision" }, + { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_SOFTWARE_REV, "Inventory - software revision" }, + { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_SERIAL_NUMBER, "Inventory - serial number" }, + { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_MANUFACTURER_NAME, "Inventory - manufacturer name" }, + { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_MODEL_NAME, "Inventory - model name" }, + { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_ASSET_ID, "Inventory - asset ID" }, + { 0, NULL} +}; + +#define LLDP_PRIVATE_TIA_LOCATION_ALTITUDE_METERS 1 +#define LLDP_PRIVATE_TIA_LOCATION_ALTITUDE_FLOORS 2 + +static const struct tok lldp_tia_location_altitude_type_values[] = { + { LLDP_PRIVATE_TIA_LOCATION_ALTITUDE_METERS, "meters"}, + { LLDP_PRIVATE_TIA_LOCATION_ALTITUDE_FLOORS, "floors"}, + { 0, NULL} +}; + +/* ANSI/TIA-1057 - Annex B */ +#define LLDP_PRIVATE_TIA_LOCATION_LCI_CATYPE_A1 1 +#define LLDP_PRIVATE_TIA_LOCATION_LCI_CATYPE_A2 2 +#define LLDP_PRIVATE_TIA_LOCATION_LCI_CATYPE_A3 3 +#define LLDP_PRIVATE_TIA_LOCATION_LCI_CATYPE_A4 4 +#define LLDP_PRIVATE_TIA_LOCATION_LCI_CATYPE_A5 5 +#define LLDP_PRIVATE_TIA_LOCATION_LCI_CATYPE_A6 6 + +static const struct tok lldp_tia_location_lci_catype_values[] = { + { LLDP_PRIVATE_TIA_LOCATION_LCI_CATYPE_A1, "national subdivisions (state,canton,region,province,prefecture)"}, + { LLDP_PRIVATE_TIA_LOCATION_LCI_CATYPE_A2, "county, parish, gun, district"}, + { LLDP_PRIVATE_TIA_LOCATION_LCI_CATYPE_A3, "city, township, shi"}, + { LLDP_PRIVATE_TIA_LOCATION_LCI_CATYPE_A4, "city division, borough, city district, ward chou"}, + { LLDP_PRIVATE_TIA_LOCATION_LCI_CATYPE_A5, "neighborhood, block"}, + { LLDP_PRIVATE_TIA_LOCATION_LCI_CATYPE_A6, "street"}, + { 0, NULL} +}; + +static const struct tok lldp_tia_location_lci_what_values[] = { + { 0, "location of DHCP server"}, + { 1, "location of the network element believed to be closest to the client"}, + { 2, "location of the client"}, + { 0, NULL} +}; + +/* + * From RFC 3636 - dot3MauType + */ +#define LLDP_MAU_TYPE_UNKNOWN 0 +#define LLDP_MAU_TYPE_AUI 1 +#define LLDP_MAU_TYPE_10BASE_5 2 +#define LLDP_MAU_TYPE_FOIRL 3 +#define LLDP_MAU_TYPE_10BASE_2 4 +#define LLDP_MAU_TYPE_10BASE_T 5 +#define LLDP_MAU_TYPE_10BASE_FP 6 +#define LLDP_MAU_TYPE_10BASE_FB 7 +#define LLDP_MAU_TYPE_10BASE_FL 8 +#define LLDP_MAU_TYPE_10BROAD36 9 +#define LLDP_MAU_TYPE_10BASE_T_HD 10 +#define LLDP_MAU_TYPE_10BASE_T_FD 11 +#define LLDP_MAU_TYPE_10BASE_FL_HD 12 +#define LLDP_MAU_TYPE_10BASE_FL_FD 13 +#define LLDP_MAU_TYPE_100BASE_T4 14 +#define LLDP_MAU_TYPE_100BASE_TX_HD 15 +#define LLDP_MAU_TYPE_100BASE_TX_FD 16 +#define LLDP_MAU_TYPE_100BASE_FX_HD 17 +#define LLDP_MAU_TYPE_100BASE_FX_FD 18 +#define LLDP_MAU_TYPE_100BASE_T2_HD 19 +#define LLDP_MAU_TYPE_100BASE_T2_FD 20 +#define LLDP_MAU_TYPE_1000BASE_X_HD 21 +#define LLDP_MAU_TYPE_1000BASE_X_FD 22 +#define LLDP_MAU_TYPE_1000BASE_LX_HD 23 +#define LLDP_MAU_TYPE_1000BASE_LX_FD 24 +#define LLDP_MAU_TYPE_1000BASE_SX_HD 25 +#define LLDP_MAU_TYPE_1000BASE_SX_FD 26 +#define LLDP_MAU_TYPE_1000BASE_CX_HD 27 +#define LLDP_MAU_TYPE_1000BASE_CX_FD 28 +#define LLDP_MAU_TYPE_1000BASE_T_HD 29 +#define LLDP_MAU_TYPE_1000BASE_T_FD 30 +#define LLDP_MAU_TYPE_10GBASE_X 31 +#define LLDP_MAU_TYPE_10GBASE_LX4 32 +#define LLDP_MAU_TYPE_10GBASE_R 33 +#define LLDP_MAU_TYPE_10GBASE_ER 34 +#define LLDP_MAU_TYPE_10GBASE_LR 35 +#define LLDP_MAU_TYPE_10GBASE_SR 36 +#define LLDP_MAU_TYPE_10GBASE_W 37 +#define LLDP_MAU_TYPE_10GBASE_EW 38 +#define LLDP_MAU_TYPE_10GBASE_LW 39 +#define LLDP_MAU_TYPE_10GBASE_SW 40 + +static const struct tok lldp_mau_types_values[] = { + { LLDP_MAU_TYPE_UNKNOWN, "Unknown"}, + { LLDP_MAU_TYPE_AUI, "AUI"}, + { LLDP_MAU_TYPE_10BASE_5, "10BASE_5"}, + { LLDP_MAU_TYPE_FOIRL, "FOIRL"}, + { LLDP_MAU_TYPE_10BASE_2, "10BASE2"}, + { LLDP_MAU_TYPE_10BASE_T, "10BASET duplex mode unknown"}, + { LLDP_MAU_TYPE_10BASE_FP, "10BASEFP"}, + { LLDP_MAU_TYPE_10BASE_FB, "10BASEFB"}, + { LLDP_MAU_TYPE_10BASE_FL, "10BASEFL duplex mode unknown"}, + { LLDP_MAU_TYPE_10BROAD36, "10BROAD36"}, + { LLDP_MAU_TYPE_10BASE_T_HD, "10BASET hdx"}, + { LLDP_MAU_TYPE_10BASE_T_FD, "10BASET fdx"}, + { LLDP_MAU_TYPE_10BASE_FL_HD, "10BASEFL hdx"}, + { LLDP_MAU_TYPE_10BASE_FL_FD, "10BASEFL fdx"}, + { LLDP_MAU_TYPE_100BASE_T4, "100BASET4"}, + { LLDP_MAU_TYPE_100BASE_TX_HD, "100BASETX hdx"}, + { LLDP_MAU_TYPE_100BASE_TX_FD, "100BASETX fdx"}, + { LLDP_MAU_TYPE_100BASE_FX_HD, "100BASEFX hdx"}, + { LLDP_MAU_TYPE_100BASE_FX_FD, "100BASEFX fdx"}, + { LLDP_MAU_TYPE_100BASE_T2_HD, "100BASET2 hdx"}, + { LLDP_MAU_TYPE_100BASE_T2_FD, "100BASET2 fdx"}, + { LLDP_MAU_TYPE_1000BASE_X_HD, "1000BASEX hdx"}, + { LLDP_MAU_TYPE_1000BASE_X_FD, "1000BASEX fdx"}, + { LLDP_MAU_TYPE_1000BASE_LX_HD, "1000BASELX hdx"}, + { LLDP_MAU_TYPE_1000BASE_LX_FD, "1000BASELX fdx"}, + { LLDP_MAU_TYPE_1000BASE_SX_HD, "1000BASESX hdx"}, + { LLDP_MAU_TYPE_1000BASE_SX_FD, "1000BASESX fdx"}, + { LLDP_MAU_TYPE_1000BASE_CX_HD, "1000BASECX hdx"}, + { LLDP_MAU_TYPE_1000BASE_CX_FD, "1000BASECX fdx"}, + { LLDP_MAU_TYPE_1000BASE_T_HD, "1000BASET hdx"}, + { LLDP_MAU_TYPE_1000BASE_T_FD, "1000BASET fdx"}, + { LLDP_MAU_TYPE_10GBASE_X, "10GBASEX"}, + { LLDP_MAU_TYPE_10GBASE_LX4, "10GBASELX4"}, + { LLDP_MAU_TYPE_10GBASE_R, "10GBASER"}, + { LLDP_MAU_TYPE_10GBASE_ER, "10GBASEER"}, + { LLDP_MAU_TYPE_10GBASE_LR, "10GBASELR"}, + { LLDP_MAU_TYPE_10GBASE_SR, "10GBASESR"}, + { LLDP_MAU_TYPE_10GBASE_W, "10GBASEW"}, + { LLDP_MAU_TYPE_10GBASE_EW, "10GBASEEW"}, + { LLDP_MAU_TYPE_10GBASE_LW, "10GBASELW"}, + { LLDP_MAU_TYPE_10GBASE_SW, "10GBASESW"}, + { 0, NULL} +}; + +#define LLDP_8023_AUTONEGOTIATION_SUPPORT (1 << 0) +#define LLDP_8023_AUTONEGOTIATION_STATUS (1 << 1) + +static const struct tok lldp_8023_autonegotiation_values[] = { + { LLDP_8023_AUTONEGOTIATION_SUPPORT, "supported"}, + { LLDP_8023_AUTONEGOTIATION_STATUS, "enabled"}, + { 0, NULL} +}; + +#define LLDP_TIA_CAPABILITY_MED (1 << 0) +#define LLDP_TIA_CAPABILITY_NETWORK_POLICY (1 << 1) +#define LLDP_TIA_CAPABILITY_LOCATION_IDENTIFICATION (1 << 2) +#define LLDP_TIA_CAPABILITY_EXTENDED_POWER_MDI_PSE (1 << 3) +#define LLDP_TIA_CAPABILITY_EXTENDED_POWER_MDI_PD (1 << 4) +#define LLDP_TIA_CAPABILITY_INVENTORY (1 << 5) + +static const struct tok lldp_tia_capabilities_values[] = { + { LLDP_TIA_CAPABILITY_MED, "LLDP-MED capabilities"}, + { LLDP_TIA_CAPABILITY_NETWORK_POLICY, "network policy"}, + { LLDP_TIA_CAPABILITY_LOCATION_IDENTIFICATION, "location identification"}, + { LLDP_TIA_CAPABILITY_EXTENDED_POWER_MDI_PSE, "extended power via MDI-PSE"}, + { LLDP_TIA_CAPABILITY_EXTENDED_POWER_MDI_PD, "extended power via MDI-PD"}, + { LLDP_TIA_CAPABILITY_INVENTORY, "Inventory"}, + { 0, NULL} +}; + +#define LLDP_TIA_DEVICE_TYPE_ENDPOINT_CLASS_1 1 +#define LLDP_TIA_DEVICE_TYPE_ENDPOINT_CLASS_2 2 +#define LLDP_TIA_DEVICE_TYPE_ENDPOINT_CLASS_3 3 +#define LLDP_TIA_DEVICE_TYPE_NETWORK_CONNECTIVITY 4 + +static const struct tok lldp_tia_device_type_values[] = { + { LLDP_TIA_DEVICE_TYPE_ENDPOINT_CLASS_1, "endpoint class 1"}, + { LLDP_TIA_DEVICE_TYPE_ENDPOINT_CLASS_2, "endpoint class 2"}, + { LLDP_TIA_DEVICE_TYPE_ENDPOINT_CLASS_3, "endpoint class 3"}, + { LLDP_TIA_DEVICE_TYPE_NETWORK_CONNECTIVITY, "network connectivity"}, + { 0, NULL} +}; + +#define LLDP_TIA_APPLICATION_TYPE_VOICE 1 +#define LLDP_TIA_APPLICATION_TYPE_VOICE_SIGNALING 2 +#define LLDP_TIA_APPLICATION_TYPE_GUEST_VOICE 3 +#define LLDP_TIA_APPLICATION_TYPE_GUEST_VOICE_SIGNALING 4 +#define LLDP_TIA_APPLICATION_TYPE_SOFTPHONE_VOICE 5 +#define LLDP_TIA_APPLICATION_TYPE_VIDEO_CONFERENCING 6 +#define LLDP_TIA_APPLICATION_TYPE_STREAMING_VIDEO 7 +#define LLDP_TIA_APPLICATION_TYPE_VIDEO_SIGNALING 8 + +static const struct tok lldp_tia_application_type_values[] = { + { LLDP_TIA_APPLICATION_TYPE_VOICE, "voice"}, + { LLDP_TIA_APPLICATION_TYPE_VOICE_SIGNALING, "voice signaling"}, + { LLDP_TIA_APPLICATION_TYPE_GUEST_VOICE, "guest voice"}, + { LLDP_TIA_APPLICATION_TYPE_GUEST_VOICE_SIGNALING, "guest voice signaling"}, + { LLDP_TIA_APPLICATION_TYPE_SOFTPHONE_VOICE, "softphone voice"}, + { LLDP_TIA_APPLICATION_TYPE_VIDEO_CONFERENCING, "video conferencing"}, + { LLDP_TIA_APPLICATION_TYPE_STREAMING_VIDEO, "streaming video"}, + { LLDP_TIA_APPLICATION_TYPE_VIDEO_SIGNALING, "video signaling"}, + { 0, NULL} +}; + +#define LLDP_TIA_NETWORK_POLICY_X_BIT (1 << 5) +#define LLDP_TIA_NETWORK_POLICY_T_BIT (1 << 6) +#define LLDP_TIA_NETWORK_POLICY_U_BIT (1 << 7) + +static const struct tok lldp_tia_network_policy_bits_values[] = { + { LLDP_TIA_NETWORK_POLICY_U_BIT, "Unknown"}, + { LLDP_TIA_NETWORK_POLICY_T_BIT, "Tagged"}, + { LLDP_TIA_NETWORK_POLICY_X_BIT, "reserved"}, + { 0, NULL} +}; + +#define LLDP_EXTRACT_NETWORK_POLICY_VLAN(x) (((x)&0x1ffe)>>1) +#define LLDP_EXTRACT_NETWORK_POLICY_L2_PRIORITY(x) (((x)&0x01ff)>>6) +#define LLDP_EXTRACT_NETWORK_POLICY_DSCP(x) ((x)&0x003f) + +#define LLDP_TIA_LOCATION_DATA_FORMAT_COORDINATE_BASED 1 +#define LLDP_TIA_LOCATION_DATA_FORMAT_CIVIC_ADDRESS 2 +#define LLDP_TIA_LOCATION_DATA_FORMAT_ECS_ELIN 3 + +static const struct tok lldp_tia_location_data_format_values[] = { + { LLDP_TIA_LOCATION_DATA_FORMAT_COORDINATE_BASED, "coordinate-based LCI"}, + { LLDP_TIA_LOCATION_DATA_FORMAT_CIVIC_ADDRESS, "civic address LCI"}, + { LLDP_TIA_LOCATION_DATA_FORMAT_ECS_ELIN, "ECS ELIN"}, + { 0, NULL} +}; + +#define LLDP_TIA_LOCATION_DATUM_WGS_84 1 +#define LLDP_TIA_LOCATION_DATUM_NAD_83_NAVD_88 2 +#define LLDP_TIA_LOCATION_DATUM_NAD_83_MLLW 3 + +static const struct tok lldp_tia_location_datum_type_values[] = { + { LLDP_TIA_LOCATION_DATUM_WGS_84, "World Geodesic System 1984"}, + { LLDP_TIA_LOCATION_DATUM_NAD_83_NAVD_88, "North American Datum 1983 (NAVD88)"}, + { LLDP_TIA_LOCATION_DATUM_NAD_83_MLLW, "North American Datum 1983 (MLLW)"}, + { 0, NULL} +}; + +#define LLDP_TIA_POWER_SOURCE_PSE 1 +#define LLDP_TIA_POWER_SOURCE_LOCAL 2 +#define LLDP_TIA_POWER_SOURCE_PSE_AND_LOCAL 3 + +static const struct tok lldp_tia_power_source_values[] = { + { LLDP_TIA_POWER_SOURCE_PSE, "PSE - primary power source"}, + { LLDP_TIA_POWER_SOURCE_LOCAL, "local - backup power source"}, + { LLDP_TIA_POWER_SOURCE_PSE_AND_LOCAL, "PSE+local - reserved"}, + { 0, NULL} +}; + +#define LLDP_TIA_POWER_PRIORITY_CRITICAL 1 +#define LLDP_TIA_POWER_PRIORITY_HIGH 2 +#define LLDP_TIA_POWER_PRIORITY_LOW 3 + +static const struct tok lldp_tia_power_priority_values[] = { + { LLDP_TIA_POWER_PRIORITY_CRITICAL, "critical"}, + { LLDP_TIA_POWER_PRIORITY_HIGH, "high"}, + { LLDP_TIA_POWER_PRIORITY_LOW, "low"}, + { 0, NULL} +}; + +#define LLDP_TIA_POWER_VAL_MAX 1024 + +static const struct tok lldp_tia_inventory_values[] = { + { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_HARDWARE_REV, "Hardware revision" }, + { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_FIRMWARE_REV, "Firmware revision" }, + { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_SOFTWARE_REV, "Software revision" }, + { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_SERIAL_NUMBER, "Serial number" }, + { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_MANUFACTURER_NAME, "Manufacturer name" }, + { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_MODEL_NAME, "Model name" }, + { LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_ASSET_ID, "Asset ID" }, + { 0, NULL} +}; + +/* + * From RFC 3636 - ifMauAutoNegCapAdvertisedBits + */ +#define LLDP_MAU_PMD_OTHER (1 << 15) +#define LLDP_MAU_PMD_10BASE_T (1 << 14) +#define LLDP_MAU_PMD_10BASE_T_FD (1 << 13) +#define LLDP_MAU_PMD_100BASE_T4 (1 << 12) +#define LLDP_MAU_PMD_100BASE_TX (1 << 11) +#define LLDP_MAU_PMD_100BASE_TX_FD (1 << 10) +#define LLDP_MAU_PMD_100BASE_T2 (1 << 9) +#define LLDP_MAU_PMD_100BASE_T2_FD (1 << 8) +#define LLDP_MAU_PMD_FDXPAUSE (1 << 7) +#define LLDP_MAU_PMD_FDXAPAUSE (1 << 6) +#define LLDP_MAU_PMD_FDXSPAUSE (1 << 5) +#define LLDP_MAU_PMD_FDXBPAUSE (1 << 4) +#define LLDP_MAU_PMD_1000BASE_X (1 << 3) +#define LLDP_MAU_PMD_1000BASE_X_FD (1 << 2) +#define LLDP_MAU_PMD_1000BASE_T (1 << 1) +#define LLDP_MAU_PMD_1000BASE_T_FD (1 << 0) + +static const struct tok lldp_pmd_capability_values[] = { + { LLDP_MAU_PMD_10BASE_T, "10BASE-T hdx"}, + { LLDP_MAU_PMD_10BASE_T_FD, "10BASE-T fdx"}, + { LLDP_MAU_PMD_100BASE_T4, "100BASE-T4"}, + { LLDP_MAU_PMD_100BASE_TX, "100BASE-TX hdx"}, + { LLDP_MAU_PMD_100BASE_TX_FD, "100BASE-TX fdx"}, + { LLDP_MAU_PMD_100BASE_T2, "100BASE-T2 hdx"}, + { LLDP_MAU_PMD_100BASE_T2_FD, "100BASE-T2 fdx"}, + { LLDP_MAU_PMD_FDXPAUSE, "Pause for fdx links"}, + { LLDP_MAU_PMD_FDXAPAUSE, "Asym PAUSE for fdx"}, + { LLDP_MAU_PMD_FDXSPAUSE, "Sym PAUSE for fdx"}, + { LLDP_MAU_PMD_FDXBPAUSE, "Asym and Sym PAUSE for fdx"}, + { LLDP_MAU_PMD_1000BASE_X, "1000BASE-{X LX SX CX} hdx"}, + { LLDP_MAU_PMD_1000BASE_X_FD, "1000BASE-{X LX SX CX} fdx"}, + { LLDP_MAU_PMD_1000BASE_T, "1000BASE-T hdx"}, + { LLDP_MAU_PMD_1000BASE_T_FD, "1000BASE-T fdx"}, + { 0, NULL} +}; + +#define LLDP_MDI_PORT_CLASS (1 << 0) +#define LLDP_MDI_POWER_SUPPORT (1 << 1) +#define LLDP_MDI_POWER_STATE (1 << 2) +#define LLDP_MDI_PAIR_CONTROL_ABILITY (1 << 3) + +static const struct tok lldp_mdi_values[] = { + { LLDP_MDI_PORT_CLASS, "PSE"}, + { LLDP_MDI_POWER_SUPPORT, "supported"}, + { LLDP_MDI_POWER_STATE, "enabled"}, + { LLDP_MDI_PAIR_CONTROL_ABILITY, "can be controlled"}, + { 0, NULL} +}; + +#define LLDP_MDI_PSE_PORT_POWER_PAIRS_SIGNAL 1 +#define LLDP_MDI_PSE_PORT_POWER_PAIRS_SPARE 2 + +static const struct tok lldp_mdi_power_pairs_values[] = { + { LLDP_MDI_PSE_PORT_POWER_PAIRS_SIGNAL, "signal"}, + { LLDP_MDI_PSE_PORT_POWER_PAIRS_SPARE, "spare"}, + { 0, NULL} +}; + +#define LLDP_MDI_POWER_CLASS0 1 +#define LLDP_MDI_POWER_CLASS1 2 +#define LLDP_MDI_POWER_CLASS2 3 +#define LLDP_MDI_POWER_CLASS3 4 +#define LLDP_MDI_POWER_CLASS4 5 + +static const struct tok lldp_mdi_power_class_values[] = { + { LLDP_MDI_POWER_CLASS0, "class0"}, + { LLDP_MDI_POWER_CLASS1, "class1"}, + { LLDP_MDI_POWER_CLASS2, "class2"}, + { LLDP_MDI_POWER_CLASS3, "class3"}, + { LLDP_MDI_POWER_CLASS4, "class4"}, + { 0, NULL} +}; + +#define LLDP_AGGREGATION_CAPABILTIY (1 << 0) +#define LLDP_AGGREGATION_STATUS (1 << 1) + +static const struct tok lldp_aggregation_values[] = { + { LLDP_AGGREGATION_CAPABILTIY, "supported"}, + { LLDP_AGGREGATION_STATUS, "enabled"}, + { 0, NULL} +}; + +/* + * DCBX protocol subtypes. + */ +#define LLDP_DCBX_SUBTYPE_1 1 +#define LLDP_DCBX_SUBTYPE_2 2 + +static const struct tok lldp_dcbx_subtype_values[] = { + { LLDP_DCBX_SUBTYPE_1, "DCB Capability Exchange Protocol Rev 1" }, + { LLDP_DCBX_SUBTYPE_2, "DCB Capability Exchange Protocol Rev 1.01" }, + { 0, NULL} +}; + +#define LLDP_DCBX_CONTROL_TLV 1 +#define LLDP_DCBX_PRIORITY_GROUPS_TLV 2 +#define LLDP_DCBX_PRIORITY_FLOW_CONTROL_TLV 3 +#define LLDP_DCBX_APPLICATION_TLV 4 + +/* + * Interface numbering subtypes. + */ +#define LLDP_INTF_NUMB_IFX_SUBTYPE 2 +#define LLDP_INTF_NUMB_SYSPORT_SUBTYPE 3 + +static const struct tok lldp_intf_numb_subtype_values[] = { + { LLDP_INTF_NUMB_IFX_SUBTYPE, "Interface Index" }, + { LLDP_INTF_NUMB_SYSPORT_SUBTYPE, "System Port Number" }, + { 0, NULL} +}; + +#define LLDP_INTF_NUM_LEN 5 + +/* + * Print IEEE 802.1 private extensions. (802.1AB annex E) + */ +static int +lldp_private_8021_print(const u_char *tptr, u_int tlv_len) +{ + int subtype, hexdump = FALSE; + u_int sublen; + + if (tlv_len < 4) { + return hexdump; + } + subtype = *(tptr+3); + + printf("\n\t %s Subtype (%u)", + tok2str(lldp_8021_subtype_values, "unknown", subtype), + subtype); + + switch (subtype) { + case LLDP_PRIVATE_8021_SUBTYPE_PORT_VLAN_ID: + if (tlv_len < 6) { + return hexdump; + } + printf("\n\t port vlan id (PVID): %u", + EXTRACT_16BITS(tptr+4)); + break; + case LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_VLAN_ID: + if (tlv_len < 7) { + return hexdump; + } + printf("\n\t port and protocol vlan id (PPVID): %u, flags [%s] (0x%02x)", + EXTRACT_16BITS(tptr+5), + bittok2str(lldp_8021_port_protocol_id_values, "none", *(tptr+4)), + *(tptr+4)); + break; + case LLDP_PRIVATE_8021_SUBTYPE_VLAN_NAME: + if (tlv_len < 6) { + return hexdump; + } + printf("\n\t vlan id (VID): %u", + EXTRACT_16BITS(tptr+4)); + if (tlv_len < 7) { + return hexdump; + } + sublen = *(tptr+6); + if (tlv_len < 7+sublen) { + return hexdump; + } + printf("\n\t vlan name: "); + safeputs((const char *)tptr+7, sublen); + break; + case LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_IDENTITY: + if (tlv_len < 5) { + return hexdump; + } + sublen = *(tptr+4); + if (tlv_len < 5+sublen) { + return hexdump; + } + printf("\n\t protocol identity: "); + safeputs((const char *)tptr+5, sublen); + break; + + default: + hexdump = TRUE; + break; + } + + return hexdump; +} + +/* + * Print IEEE 802.3 private extensions. (802.3bc) + */ +static int +lldp_private_8023_print(const u_char *tptr, u_int tlv_len) +{ + int subtype, hexdump = FALSE; + + if (tlv_len < 4) { + return hexdump; + } + subtype = *(tptr+3); + + printf("\n\t %s Subtype (%u)", + tok2str(lldp_8023_subtype_values, "unknown", subtype), + subtype); + + switch (subtype) { + case LLDP_PRIVATE_8023_SUBTYPE_MACPHY: + if (tlv_len < 9) { + return hexdump; + } + printf("\n\t autonegotiation [%s] (0x%02x)", + bittok2str(lldp_8023_autonegotiation_values, "none", *(tptr+4)), + *(tptr+4)); + printf("\n\t PMD autoneg capability [%s] (0x%04x)", + bittok2str(lldp_pmd_capability_values,"unknown", EXTRACT_16BITS(tptr+5)), + EXTRACT_16BITS(tptr+5)); + printf("\n\t MAU type %s (0x%04x)", + tok2str(lldp_mau_types_values, "unknown", EXTRACT_16BITS(tptr+7)), + EXTRACT_16BITS(tptr+7)); + break; + + case LLDP_PRIVATE_8023_SUBTYPE_MDIPOWER: + if (tlv_len < 7) { + return hexdump; + } + printf("\n\t MDI power support [%s], power pair %s, power class %s", + bittok2str(lldp_mdi_values, "none", *(tptr+4)), + tok2str(lldp_mdi_power_pairs_values, "unknown", *(tptr+5)), + tok2str(lldp_mdi_power_class_values, "unknown", *(tptr+6))); + break; + + case LLDP_PRIVATE_8023_SUBTYPE_LINKAGGR: + if (tlv_len < 9) { + return hexdump; + } + printf("\n\t aggregation status [%s], aggregation port ID %u", + bittok2str(lldp_aggregation_values, "none", *(tptr+4)), + EXTRACT_32BITS(tptr+5)); + break; + + case LLDP_PRIVATE_8023_SUBTYPE_MTU: + printf("\n\t MTU size %u", EXTRACT_16BITS(tptr+4)); + break; + + default: + hexdump = TRUE; + break; + } + + return hexdump; +} + +/* + * Extract 34bits of latitude/longitude coordinates. + */ +static u_int64_t +lldp_extract_latlon(const u_char *tptr) +{ + u_int64_t latlon; + + latlon = *tptr & 0x3; + latlon = (latlon << 32) | EXTRACT_32BITS(tptr+1); + + return latlon; +} + +/* + * Print private TIA extensions. + */ +static int +lldp_private_tia_print(const u_char *tptr, u_int tlv_len) +{ + int subtype, hexdump = FALSE; + u_int8_t location_format; + u_int16_t power_val; + u_int lci_len; + u_int8_t ca_type, ca_len; + + if (tlv_len < 4) { + return hexdump; + } + subtype = *(tptr+3); + + printf("\n\t %s Subtype (%u)", + tok2str(lldp_tia_subtype_values, "unknown", subtype), + subtype); + + switch (subtype) { + case LLDP_PRIVATE_TIA_SUBTYPE_CAPABILITIES: + if (tlv_len < 7) { + return hexdump; + } + printf("\n\t Media capabilities [%s] (0x%04x)", + bittok2str(lldp_tia_capabilities_values, "none", + EXTRACT_16BITS(tptr+4)), EXTRACT_16BITS(tptr+4)); + printf("\n\t Device type [%s] (0x%02x)", + tok2str(lldp_tia_device_type_values, "unknown", *(tptr+6)), + *(tptr+6)); + break; + + case LLDP_PRIVATE_TIA_SUBTYPE_NETWORK_POLICY: + if (tlv_len < 8) { + return hexdump; + } + printf("\n\t Application type [%s] (0x%02x)", + tok2str(lldp_tia_application_type_values, "none", *(tptr+4)), + *(tptr+4)); + printf(", Flags [%s]", bittok2str( + lldp_tia_network_policy_bits_values, "none", *(tptr+5))); + printf("\n\t Vlan id %u", + LLDP_EXTRACT_NETWORK_POLICY_VLAN(EXTRACT_16BITS(tptr+5))); + printf(", L2 priority %u", + LLDP_EXTRACT_NETWORK_POLICY_L2_PRIORITY(EXTRACT_16BITS(tptr+6))); + printf(", DSCP value %u", + LLDP_EXTRACT_NETWORK_POLICY_DSCP(EXTRACT_16BITS(tptr+6))); + break; + + case LLDP_PRIVATE_TIA_SUBTYPE_LOCAL_ID: + if (tlv_len < 5) { + return hexdump; + } + location_format = *(tptr+4); + printf("\n\t Location data format %s (0x%02x)", + tok2str(lldp_tia_location_data_format_values, "unknown", location_format), + location_format); + + switch (location_format) { + case LLDP_TIA_LOCATION_DATA_FORMAT_COORDINATE_BASED: + if (tlv_len < 21) { + return hexdump; + } + printf("\n\t Latitude resolution %u, latitude value %" PRIu64, + (*(tptr+5)>>2), lldp_extract_latlon(tptr+5)); + printf("\n\t Longitude resolution %u, longitude value %" PRIu64, + (*(tptr+10)>>2), lldp_extract_latlon(tptr+10)); + printf("\n\t Altitude type %s (%u)", + tok2str(lldp_tia_location_altitude_type_values, "unknown",(*(tptr+15)>>4)), + (*(tptr+15)>>4)); + printf("\n\t Altitude resolution %u, altitude value 0x%x", + (EXTRACT_16BITS(tptr+15)>>6)&0x3f, + ((EXTRACT_32BITS(tptr+16)&0x3fffffff))); + printf("\n\t Datum %s (0x%02x)", + tok2str(lldp_tia_location_datum_type_values, "unknown", *(tptr+20)), + *(tptr+20)); + break; + + case LLDP_TIA_LOCATION_DATA_FORMAT_CIVIC_ADDRESS: + if (tlv_len < 6) { + return hexdump; + } + lci_len = *(tptr+5); + if (lci_len < 3) { + return hexdump; + } + if (tlv_len < 7+lci_len) { + return hexdump; + } + printf("\n\t LCI length %u, LCI what %s (0x%02x), Country-code ", + lci_len, + tok2str(lldp_tia_location_lci_what_values, "unknown", *(tptr+6)), + *(tptr+6)); + + /* Country code */ + safeputs((const char *)(tptr+7), 2); + + lci_len = lci_len-3; + tptr = tptr + 9; + + /* Decode each civic address element */ + while (lci_len > 0) { + if (lci_len < 2) { + return hexdump; + } + ca_type = *(tptr); + ca_len = *(tptr+1); + + tptr += 2; + lci_len -= 2; + + printf("\n\t CA type \'%s\' (%u), length %u: ", + tok2str(lldp_tia_location_lci_catype_values, "unknown", ca_type), + ca_type, ca_len); + + /* basic sanity check */ + if ( ca_type == 0 || ca_len == 0) { + return hexdump; + } + if (lci_len < ca_len) { + return hexdump; + } + + safeputs((const char *)tptr, ca_len); + tptr += ca_len; + lci_len -= ca_len; + } + break; + + case LLDP_TIA_LOCATION_DATA_FORMAT_ECS_ELIN: + printf("\n\t ECS ELIN id "); + safeputs((const char *)tptr+5, tlv_len-5); + break; + + default: + printf("\n\t Location ID "); + print_unknown_data(tptr+5, "\n\t ", tlv_len-5); + } + break; + + case LLDP_PRIVATE_TIA_SUBTYPE_EXTENDED_POWER_MDI: + if (tlv_len < 7) { + return hexdump; + } + printf("\n\t Power type [%s]", + (*(tptr+4)&0xC0>>6) ? "PD device" : "PSE device"); + printf(", Power source [%s]", + tok2str(lldp_tia_power_source_values, "none", (*(tptr+4)&0x30)>>4)); + printf("\n\t Power priority [%s] (0x%02x)", + tok2str(lldp_tia_power_priority_values, "none", *(tptr+4)&0x0f), + *(tptr+4)&0x0f); + power_val = EXTRACT_16BITS(tptr+5); + if (power_val < LLDP_TIA_POWER_VAL_MAX) { + printf(", Power %.1f Watts", ((float)power_val)/10); + } else { + printf(", Power %u (Reserved)", power_val); + } + break; + + case LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_HARDWARE_REV: + case LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_FIRMWARE_REV: + case LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_SOFTWARE_REV: + case LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_SERIAL_NUMBER: + case LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_MANUFACTURER_NAME: + case LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_MODEL_NAME: + case LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_ASSET_ID: + printf("\n\t %s ", + tok2str(lldp_tia_inventory_values, "unknown", subtype)); + safeputs((const char *)tptr+4, tlv_len-4); + break; + + default: + hexdump = TRUE; + break; + } + + return hexdump; +} + +/* + * Print DCBX Protocol fields (V 1.01). + */ +static int +lldp_private_dcbx_print(const u_char *pptr, u_int len) +{ + int subtype, hexdump = FALSE; + u_int8_t tval; + u_int16_t tlv; + u_int32_t i, pgval, uval; + u_int tlen, tlv_type, tlv_len; + const u_char *tptr, *mptr; + + if (len < 4) { + return hexdump; + } + subtype = *(pptr+3); + + printf("\n\t %s Subtype (%u)", + tok2str(lldp_dcbx_subtype_values, "unknown", subtype), + subtype); + + /* by passing old version */ + if (subtype == LLDP_DCBX_SUBTYPE_1) + return TRUE; + + tptr = pptr + 4; + tlen = len - 4; + + while (tlen >= sizeof(tlv)) { + + TCHECK2(*tptr, sizeof(tlv)); + + tlv = EXTRACT_16BITS(tptr); + + tlv_type = LLDP_EXTRACT_TYPE(tlv); + tlv_len = LLDP_EXTRACT_LEN(tlv); + hexdump = FALSE; + + tlen -= sizeof(tlv); + tptr += sizeof(tlv); + + /* loop check */ + if (!tlv_type || !tlv_len) { + break; + } + + TCHECK2(*tptr, tlv_len); + if (tlen < tlv_len) { + goto trunc; + } + + /* decode every tlv */ + switch (tlv_type) { + case LLDP_DCBX_CONTROL_TLV: + if (tlv_len < 10) { + goto trunc; + } + printf("\n\t Control - Protocol Control (type 0x%x, length %d)", + LLDP_DCBX_CONTROL_TLV, tlv_len); + printf("\n\t Oper_Version: %d", *tptr); + printf("\n\t Max_Version: %d", *(tptr+1)); + printf("\n\t Sequence Number: %d", EXTRACT_32BITS(tptr+2)); + printf("\n\t Acknowledgement Number: %d", + EXTRACT_32BITS(tptr+6)); + break; + case LLDP_DCBX_PRIORITY_GROUPS_TLV: + if (tlv_len < 17) { + goto trunc; + } + printf("\n\t Feature - Priority Group (type 0x%x, length %d)", + LLDP_DCBX_PRIORITY_GROUPS_TLV, tlv_len); + printf("\n\t Oper_Version: %d", *tptr); + printf("\n\t Max_Version: %d", *(tptr+1)); + printf("\n\t Info block(0x%02X): ", *(tptr+2)); + tval = *(tptr+2); + printf("Enable bit: %d, Willing bit: %d, Error Bit: %d", + (tval & 0x80) ? 1 : 0, (tval & 0x40) ? 1 : 0, + (tval & 0x20) ? 1 : 0); + printf("\n\t SubType: %d", *(tptr+3)); + printf("\n\t Priority Allocation"); + + pgval = EXTRACT_32BITS(tptr+4); + for (i = 0; i <= 7; i++) { + tval = *(tptr+4+(i/2)); + printf("\n\t PgId_%d: %d", + i, (pgval >> (28-4*i)) & 0xF); + } + printf("\n\t Priority Group Allocation"); + for (i = 0; i <= 7; i++) + printf("\n\t Pg percentage[%d]: %d", i, *(tptr+8+i)); + printf("\n\t NumTCsSupported: %d", *(tptr+8+8)); + break; + case LLDP_DCBX_PRIORITY_FLOW_CONTROL_TLV: + if (tlv_len < 6) { + goto trunc; + } + printf("\n\t Feature - Priority Flow Control"); + printf(" (type 0x%x, length %d)", + LLDP_DCBX_PRIORITY_FLOW_CONTROL_TLV, tlv_len); + printf("\n\t Oper_Version: %d", *tptr); + printf("\n\t Max_Version: %d", *(tptr+1)); + printf("\n\t Info block(0x%02X): ", *(tptr+2)); + tval = *(tptr+2); + printf("Enable bit: %d, Willing bit: %d, Error Bit: %d", + (tval & 0x80) ? 1 : 0, (tval & 0x40) ? 1 : 0, + (tval & 0x20) ? 1 : 0); + printf("\n\t SubType: %d", *(tptr+3)); + tval = *(tptr+4); + printf("\n\t PFC Config (0x%02X)", *(tptr+4)); + for (i = 0; i <= 7; i++) + printf("\n\t Priority Bit %d: %s", + i, (tval & (1 << i)) ? "Enabled" : "Disabled"); + printf("\n\t NumTCPFCSupported: %d", *(tptr+5)); + break; + case LLDP_DCBX_APPLICATION_TLV: + if (tlv_len < 4) { + goto trunc; + } + printf("\n\t Feature - Application (type 0x%x, length %d)", + LLDP_DCBX_APPLICATION_TLV, tlv_len); + printf("\n\t Oper_Version: %d", *tptr); + printf("\n\t Max_Version: %d", *(tptr+1)); + printf("\n\t Info block(0x%02X): ", *(tptr+2)); + tval = *(tptr+2); + printf("Enable bit: %d, Willing bit: %d, Error Bit: %d", + (tval & 0x80) ? 1 : 0, (tval & 0x40) ? 1 : 0, + (tval & 0x20) ? 1 : 0); + printf("\n\t SubType: %d", *(tptr+3)); + tval = tlv_len - 4; + mptr = tptr + 4; + while (tval >= 6) { + printf("\n\t Application Value"); + printf("\n\t Application Protocol ID: 0x%04x", + EXTRACT_16BITS(mptr)); + uval = EXTRACT_24BITS(mptr+2); + printf("\n\t SF (0x%x) Application Protocol ID is %s", + (uval >> 22), + (uval >> 22) ? "Socket Number" : "L2 EtherType"); + printf("\n\t OUI: 0x%06x", uval & 0x3fffff); + printf("\n\t User Priority Map: 0x%02x", *(mptr+5)); + tval = tval - 6; + mptr = mptr + 6; + } + break; + default: + hexdump = TRUE; + break; + } + + /* do we also want to see a hex dump ? */ + if (vflag > 1 || (vflag && hexdump)) { + print_unknown_data(tptr,"\n\t ", tlv_len); + } + + tlen -= tlv_len; + tptr += tlv_len; + } + + trunc: + return hexdump; +} + +static char * +lldp_network_addr_print(const u_char *tptr, u_int len) { + + u_int8_t af; + static char buf[BUFSIZE]; + const char * (*pfunc)(const u_char *); + + if (len < 1) + return NULL; + len--; + af = *tptr; + switch (af) { + case AFNUM_INET: + if (len < 4) + return NULL; + pfunc = getname; + break; +#ifdef INET6 + case AFNUM_INET6: + if (len < 16) + return NULL; + pfunc = getname6; + break; +#endif + case AFNUM_802: + if (len < 6) + return NULL; + pfunc = etheraddr_string; + break; + default: + pfunc = NULL; + break; + } + + if (!pfunc) { + snprintf(buf, sizeof(buf), "AFI %s (%u), no AF printer !", + tok2str(af_values, "Unknown", af), af); + } else { + snprintf(buf, sizeof(buf), "AFI %s (%u): %s", + tok2str(af_values, "Unknown", af), af, (*pfunc)(tptr+1)); + } + + return buf; +} + +static int +lldp_mgmt_addr_tlv_print(const u_char *pptr, u_int len) { + + u_int8_t mgmt_addr_len, intf_num_subtype, oid_len; + const u_char *tptr; + u_int tlen; + char *mgmt_addr; + + tlen = len; + tptr = pptr; + + if (tlen < 1) { + return 0; + } + mgmt_addr_len = *tptr++; + tlen--; + + if (tlen < mgmt_addr_len) { + return 0; + } + + mgmt_addr = lldp_network_addr_print(tptr, mgmt_addr_len); + if (mgmt_addr == NULL) { + return 0; + } + printf("\n\t Management Address length %u, %s", + mgmt_addr_len, mgmt_addr); + tptr += mgmt_addr_len; + tlen -= mgmt_addr_len; + + if (tlen < LLDP_INTF_NUM_LEN) { + return 0; + } + + intf_num_subtype = *tptr; + printf("\n\t %s Interface Numbering (%u): %u", + tok2str(lldp_intf_numb_subtype_values, "Unknown", intf_num_subtype), + intf_num_subtype, + EXTRACT_32BITS(tptr+1)); + + tptr += LLDP_INTF_NUM_LEN; + tlen -= LLDP_INTF_NUM_LEN; + + /* + * The OID is optional. + */ + if (tlen) { + oid_len = *tptr; + + if (tlen < oid_len) { + return 0; + } + if (oid_len) { + printf("\n\t OID length %u", oid_len); + safeputs((const char *)tptr+1, oid_len); + } + } + + return 1; +} + +void +lldp_print(register const u_char *pptr, register u_int len) { + + u_int8_t subtype; + u_int16_t tlv, cap, ena_cap; + u_int oui, tlen, hexdump, tlv_type, tlv_len; + const u_char *tptr; + char *network_addr; + + tptr = pptr; + tlen = len; + + if (vflag) { + printf("LLDP, length %u", len); + } + + while (tlen >= sizeof(tlv)) { + + TCHECK2(*tptr, sizeof(tlv)); + + tlv = EXTRACT_16BITS(tptr); + + tlv_type = LLDP_EXTRACT_TYPE(tlv); + tlv_len = LLDP_EXTRACT_LEN(tlv); + hexdump = FALSE; + + tlen -= sizeof(tlv); + tptr += sizeof(tlv); + + if (vflag) { + printf("\n\t%s TLV (%u), length %u", + tok2str(lldp_tlv_values, "Unknown", tlv_type), + tlv_type, tlv_len); + } + + /* infinite loop check */ + if (!tlv_type || !tlv_len) { + break; + } + + TCHECK2(*tptr, tlv_len); + if (tlen < tlv_len) { + goto trunc; + } + + switch (tlv_type) { + + case LLDP_CHASSIS_ID_TLV: + if (vflag) { + if (tlv_len < 2) { + goto trunc; + } + subtype = *tptr; + printf("\n\t Subtype %s (%u): ", + tok2str(lldp_chassis_subtype_values, "Unknown", subtype), + subtype); + + switch (subtype) { + case LLDP_CHASSIS_MAC_ADDR_SUBTYPE: + if (tlv_len < 1+6) { + goto trunc; + } + printf("%s", etheraddr_string(tptr+1)); + break; + + case LLDP_CHASSIS_INTF_NAME_SUBTYPE: /* fall through */ + case LLDP_CHASSIS_LOCAL_SUBTYPE: + case LLDP_CHASSIS_CHASSIS_COMP_SUBTYPE: + case LLDP_CHASSIS_INTF_ALIAS_SUBTYPE: + case LLDP_CHASSIS_PORT_COMP_SUBTYPE: + safeputs((const char *)tptr+1, tlv_len-1); + break; + + case LLDP_CHASSIS_NETWORK_ADDR_SUBTYPE: + network_addr = lldp_network_addr_print(tptr+1, tlv_len-1); + if (network_addr == NULL) { + goto trunc; + } + printf("%s", network_addr); + break; + + default: + hexdump = TRUE; + break; + } + } + break; + + case LLDP_PORT_ID_TLV: + if (vflag) { + if (tlv_len < 2) { + goto trunc; + } + subtype = *tptr; + printf("\n\t Subtype %s (%u): ", + tok2str(lldp_port_subtype_values, "Unknown", subtype), + subtype); + + switch (subtype) { + case LLDP_PORT_MAC_ADDR_SUBTYPE: + if (tlv_len < 1+6) { + goto trunc; + } + printf("%s", etheraddr_string(tptr+1)); + break; + + case LLDP_PORT_INTF_NAME_SUBTYPE: /* fall through */ + case LLDP_PORT_LOCAL_SUBTYPE: + case LLDP_PORT_AGENT_CIRC_ID_SUBTYPE: + case LLDP_PORT_INTF_ALIAS_SUBTYPE: + case LLDP_PORT_PORT_COMP_SUBTYPE: + safeputs((const char *)tptr+1, tlv_len-1); + break; + + case LLDP_PORT_NETWORK_ADDR_SUBTYPE: + network_addr = lldp_network_addr_print(tptr+1, tlv_len-1); + if (network_addr == NULL) { + goto trunc; + } + printf("%s", network_addr); + break; + + default: + hexdump = TRUE; + break; + } + } + break; + + case LLDP_TTL_TLV: + if (vflag) { + if (tlv_len < 2) { + goto trunc; + } + printf(": TTL %us", EXTRACT_16BITS(tptr)); + } + break; + + case LLDP_PORT_DESCR_TLV: + if (vflag) { + printf(": "); + safeputs((const char *)tptr, tlv_len); + } + break; + + case LLDP_SYSTEM_NAME_TLV: + /* + * The system name is also print in non-verbose mode + * similar to the CDP printer. + */ + if (vflag) { + printf(": "); + safeputs((const char *)tptr, tlv_len); + } else { + printf("LLDP, name "); + safeputs((const char *)tptr, tlv_len); + printf(", length %u", len); + } + break; + + case LLDP_SYSTEM_DESCR_TLV: + if (vflag) { + printf("\n\t "); + safeputs((const char *)tptr, tlv_len); + } + break; + + case LLDP_SYSTEM_CAP_TLV: + if (vflag) { + /* + * XXX - IEEE Std 802.1AB-2009 says the first octet + * if a chassis ID subtype, with the system + * capabilities and enabled capabilities following + * it. + */ + if (tlv_len < 4) { + goto trunc; + } + cap = EXTRACT_16BITS(tptr); + ena_cap = EXTRACT_16BITS(tptr+2); + printf("\n\t System Capabilities [%s] (0x%04x)", + bittok2str(lldp_cap_values, "none", cap), cap); + printf("\n\t Enabled Capabilities [%s] (0x%04x)", + bittok2str(lldp_cap_values, "none", ena_cap), ena_cap); + } + break; + + case LLDP_MGMT_ADDR_TLV: + if (vflag) { + if (!lldp_mgmt_addr_tlv_print(tptr, tlv_len)) { + goto trunc; + } + } + break; + + case LLDP_PRIVATE_TLV: + if (vflag) { + if (tlv_len < 3) { + goto trunc; + } + oui = EXTRACT_24BITS(tptr); + printf(": OUI %s (0x%06x)", tok2str(oui_values, "Unknown", oui), oui); + + switch (oui) { + case OUI_IEEE_8021_PRIVATE: + hexdump = lldp_private_8021_print(tptr, tlv_len); + break; + case OUI_IEEE_8023_PRIVATE: + hexdump = lldp_private_8023_print(tptr, tlv_len); + break; + case OUI_TIA: + hexdump = lldp_private_tia_print(tptr, tlv_len); + break; + case OUI_DCBX: + hexdump = lldp_private_dcbx_print(tptr, tlv_len); + break; + default: + hexdump = TRUE; + break; + } + } + break; + + default: + hexdump = TRUE; + break; + } + + /* do we also want to see a hex dump ? */ + if (vflag > 1 || (vflag && hexdump)) { + print_unknown_data(tptr,"\n\t ", tlv_len); + } + + tlen -= tlv_len; + tptr += tlv_len; + } + return; + trunc: + printf("\n\t[|LLDP]"); +} + +/* + * Local Variables: + * c-style: whitesmith + * c-basic-offset: 4 + * End: + */
diff --git a/tcpdump-4.3.0/print-lmp.c b/tcpdump-4.3.0/print-lmp.c new file mode 100644 index 0000000..e09b89f --- /dev/null +++ b/tcpdump-4.3.0/print-lmp.c
@@ -0,0 +1,883 @@ +/* + * 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. + * + * Support for the Link Management Protocol as per rfc 4204. + * + * Original code by Hannes Gredler (hannes@juniper.net) + * Support for LMP service discovery extensions (defined by UNI 1.0) added + * by Manu Pathak (mapathak@cisco.com), May 2005 + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-lmp.c,v 1.11 2007-08-02 17:32:49 hannes 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 "gmpls.h" + +/* + * LMP 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 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Vers | (Reserved) | Flags | Msg Type | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | LMP Length | (Reserved) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ + +struct lmp_common_header { + u_int8_t version_res[2]; + u_int8_t flags; + u_int8_t msg_type; + u_int8_t length[2]; + u_int8_t reserved[2]; +}; + +#define LMP_VERSION 1 +#define LMP_EXTRACT_VERSION(x) (((x)&0xf0)>>4) + +static const struct tok lmp_header_flag_values[] = { + { 0x01, "Control Channel Down"}, + { 0x02, "LMP restart"}, + { 0, NULL} +}; + +static const struct tok lmp_obj_te_link_flag_values[] = { + { 0x01, "Fault Management Supported"}, + { 0x02, "Link Verification Supported"}, + { 0, NULL} +}; + +static const struct tok lmp_obj_data_link_flag_values[] = { + { 0x01, "Data Link Port"}, + { 0x02, "Allocated for user traffic"}, + { 0x04, "Failed link"}, + { 0, NULL} +}; + +static const struct tok lmp_obj_channel_status_values[] = { + { 1, "Signal Okay"}, + { 2, "Signal Degraded"}, + { 3, "Signal Fail"}, + { 0, NULL} +}; + +static const struct tok lmp_obj_begin_verify_flag_values[] = { + { 0x0001, "Verify all links"}, + { 0x0002, "Data link type"}, + { 0, NULL} +}; + +static const struct tok lmp_obj_begin_verify_error_values[] = { + { 0x01, "Link Verification Procedure Not supported"}, + { 0x02, "Unwilling to verify"}, + { 0x04, "Unsupported verification transport mechanism"}, + { 0x08, "Link-Id configuration error"}, + { 0x10, "Unknown object c-type"}, + { 0, NULL} +}; + +static const struct tok lmp_obj_link_summary_error_values[] = { + { 0x01, "Unacceptable non-negotiable LINK-SUMMARY parameters"}, + { 0x02, "Renegotiate LINK-SUMMARY parameters"}, + { 0x04, "Invalid TE-LINK Object"}, + { 0x08, "Invalid DATA-LINK Object"}, + { 0x10, "Unknown TE-LINK Object c-type"}, + { 0x20, "Unknown DATA-LINK Object c-type"}, + { 0, NULL} +}; + +/* Service Config Supported Protocols Flags */ +static const struct tok lmp_obj_service_config_sp_flag_values[] = { + { 0x01, "RSVP Supported"}, + { 0x02, "LDP Supported"}, + { 0, NULL} +}; + +/* Service Config Client Port Service Attribute Transparency Flags */ +static const struct tok lmp_obj_service_config_cpsa_tp_flag_values[] = { + { 0x01, "Path/VC Overhead Transparency Supported"}, + { 0x02, "Line/MS Overhead Transparency Supported"}, + { 0x04, "Section/RS Overhead Transparency Supported"}, + { 0, NULL} +}; + +/* Service Config Client Port Service Attribute Contiguous Concatenation Types Flags */ +static const struct tok lmp_obj_service_config_cpsa_cct_flag_values[] = { + { 0x01, "Contiguous Concatenation Types Supported"}, + { 0, NULL} +}; + +/* Service Config Network Service Attributes Transparency Flags */ +static const struct tok lmp_obj_service_config_nsa_transparency_flag_values[] = { + { 0x01, "Standard SOH/RSOH Transparency Supported"}, + { 0x02, "Standard LOH/MSOH Transparency Supported"}, + { 0, NULL} +}; + +/* Service Config Network Service Attributes TCM Monitoring Flags */ +static const struct tok lmp_obj_service_config_nsa_tcm_flag_values[] = { + { 0x01, "Transparent Tandem Connection Monitoring Supported"}, + { 0, NULL} +}; + +/* Network Service Attributes Network Diversity Flags */ +static const struct tok lmp_obj_service_config_nsa_network_diversity_flag_values[] = { + { 0x01, "Node Diversity Supported"}, + { 0x02, "Link Diversity Supported"}, + { 0x04, "SRLG Diversity Supported"}, + { 0, NULL} +}; + +#define LMP_MSGTYPE_CONFIG 1 +#define LMP_MSGTYPE_CONFIG_ACK 2 +#define LMP_MSGTYPE_CONFIG_NACK 3 +#define LMP_MSGTYPE_HELLO 4 +#define LMP_MSGTYPE_VERIFY_BEGIN 5 +#define LMP_MSGTYPE_VERIFY_BEGIN_ACK 6 +#define LMP_MSGTYPE_VERIFY_BEGIN_NACK 7 +#define LMP_MSGTYPE_VERIFY_END 8 +#define LMP_MSGTYPE_VERIFY_END_ACK 9 +#define LMP_MSGTYPE_TEST 10 +#define LMP_MSGTYPE_TEST_STATUS_SUCCESS 11 +#define LMP_MSGTYPE_TEST_STATUS_FAILURE 12 +#define LMP_MSGTYPE_TEST_STATUS_ACK 13 +#define LMP_MSGTYPE_LINK_SUMMARY 14 +#define LMP_MSGTYPE_LINK_SUMMARY_ACK 15 +#define LMP_MSGTYPE_LINK_SUMMARY_NACK 16 +#define LMP_MSGTYPE_CHANNEL_STATUS 17 +#define LMP_MSGTYPE_CHANNEL_STATUS_ACK 18 +#define LMP_MSGTYPE_CHANNEL_STATUS_REQ 19 +#define LMP_MSGTYPE_CHANNEL_STATUS_RESP 20 +/* LMP Service Discovery message types defined by UNI 1.0 */ +#define LMP_MSGTYPE_SERVICE_CONFIG 50 +#define LMP_MSGTYPE_SERVICE_CONFIG_ACK 51 +#define LMP_MSGTYPE_SERVICE_CONFIG_NACK 52 + +static const struct tok lmp_msg_type_values[] = { + { LMP_MSGTYPE_CONFIG, "Config"}, + { LMP_MSGTYPE_CONFIG_ACK, "Config ACK"}, + { LMP_MSGTYPE_CONFIG_NACK, "Config NACK"}, + { LMP_MSGTYPE_HELLO, "Hello"}, + { LMP_MSGTYPE_VERIFY_BEGIN, "Begin Verify"}, + { LMP_MSGTYPE_VERIFY_BEGIN_ACK, "Begin Verify ACK"}, + { LMP_MSGTYPE_VERIFY_BEGIN_NACK, "Begin Verify NACK"}, + { LMP_MSGTYPE_VERIFY_END, "End Verify"}, + { LMP_MSGTYPE_VERIFY_END_ACK, "End Verify ACK"}, + { LMP_MSGTYPE_TEST, "Test"}, + { LMP_MSGTYPE_TEST_STATUS_SUCCESS, "Test Status Success"}, + { LMP_MSGTYPE_TEST_STATUS_FAILURE, "Test Status Failure"}, + { LMP_MSGTYPE_TEST_STATUS_ACK, "Test Status ACK"}, + { LMP_MSGTYPE_LINK_SUMMARY, "Link Summary"}, + { LMP_MSGTYPE_LINK_SUMMARY_ACK, "Link Summary ACK"}, + { LMP_MSGTYPE_LINK_SUMMARY_NACK, "Link Summary NACK"}, + { LMP_MSGTYPE_CHANNEL_STATUS, "Channel Status"}, + { LMP_MSGTYPE_CHANNEL_STATUS_ACK, "Channel Status ACK"}, + { LMP_MSGTYPE_CHANNEL_STATUS_REQ, "Channel Status Request"}, + { LMP_MSGTYPE_CHANNEL_STATUS_RESP, "Channel Status Response"}, + { LMP_MSGTYPE_SERVICE_CONFIG, "Service Config"}, + { LMP_MSGTYPE_SERVICE_CONFIG_ACK, "Service Config ACK"}, + { LMP_MSGTYPE_SERVICE_CONFIG_NACK, "Service Config NACK"}, + { 0, NULL} +}; + +/* + * LMP object 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 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * |N| C-Type | Class | Length | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | | + * // (object contents) // + * | | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ + +struct lmp_object_header { + u_int8_t ctype; + u_int8_t class_num; + u_int8_t length[2]; +}; + +#define LMP_OBJ_CC_ID 1 +#define LMP_OBJ_NODE_ID 2 +#define LMP_OBJ_LINK_ID 3 +#define LMP_OBJ_INTERFACE_ID 4 +#define LMP_OBJ_MESSAGE_ID 5 +#define LMP_OBJ_CONFIG 6 +#define LMP_OBJ_HELLO 7 +#define LMP_OBJ_VERIFY_BEGIN 8 +#define LMP_OBJ_VERIFY_BEGIN_ACK 9 +#define LMP_OBJ_VERIFY_ID 10 +#define LMP_OBJ_TE_LINK 11 +#define LMP_OBJ_DATA_LINK 12 +#define LMP_OBJ_CHANNEL_STATUS 13 +#define LMP_OBJ_CHANNEL_STATUS_REQ 14 +#define LMP_OBJ_ERROR_CODE 20 + +#define LMP_OBJ_SERVICE_CONFIG 51 /* defined in UNI 1.0 */ + +static const struct tok lmp_obj_values[] = { + { LMP_OBJ_CC_ID, "Control Channel ID" }, + { LMP_OBJ_NODE_ID, "Node ID" }, + { LMP_OBJ_LINK_ID, "Link ID" }, + { LMP_OBJ_INTERFACE_ID, "Interface ID" }, + { LMP_OBJ_MESSAGE_ID, "Message ID" }, + { LMP_OBJ_CONFIG, "Configuration" }, + { LMP_OBJ_HELLO, "Hello" }, + { LMP_OBJ_VERIFY_BEGIN, "Verify Begin" }, + { LMP_OBJ_VERIFY_BEGIN_ACK, "Verify Begin ACK" }, + { LMP_OBJ_VERIFY_ID, "Verify ID" }, + { LMP_OBJ_TE_LINK, "TE Link" }, + { LMP_OBJ_DATA_LINK, "Data Link" }, + { LMP_OBJ_CHANNEL_STATUS, "Channel Status" }, + { LMP_OBJ_CHANNEL_STATUS_REQ, "Channel Status Request" }, + { LMP_OBJ_ERROR_CODE, "Error Code" }, + { LMP_OBJ_SERVICE_CONFIG, "Service Config" }, + + { 0, NULL} +}; + +#define INT_SWITCHING_TYPE_SUBOBJ 1 +#define WAVELENGTH_SUBOBJ 2 + +static const struct tok lmp_data_link_subobj[] = { + { INT_SWITCHING_TYPE_SUBOBJ, "Interface Switching Type" }, + { WAVELENGTH_SUBOBJ , "Wavelength" }, + { 0, NULL} +}; + +#define LMP_CTYPE_IPV4 1 +#define LMP_CTYPE_IPV6 2 + +#define LMP_CTYPE_LOC 1 +#define LMP_CTYPE_RMT 2 +#define LMP_CTYPE_UNMD 3 + +#define LMP_CTYPE_IPV4_LOC 1 +#define LMP_CTYPE_IPV4_RMT 2 +#define LMP_CTYPE_IPV6_LOC 3 +#define LMP_CTYPE_IPV6_RMT 4 +#define LMP_CTYPE_UNMD_LOC 5 +#define LMP_CTYPE_UNMD_RMT 6 + +#define LMP_CTYPE_1 1 +#define LMP_CTYPE_2 2 + +#define LMP_CTYPE_HELLO_CONFIG 1 +#define LMP_CTYPE_HELLO 1 + +#define LMP_CTYPE_BEGIN_VERIFY_ERROR 1 +#define LMP_CTYPE_LINK_SUMMARY_ERROR 2 + +/* C-Types for Service Config Object */ +#define LMP_CTYPE_SERVICE_CONFIG_SP 1 +#define LMP_CTYPE_SERVICE_CONFIG_CPSA 2 +#define LMP_CTYPE_SERVICE_CONFIG_TRANSPARENCY_TCM 3 +#define LMP_CTYPE_SERVICE_CONFIG_NETWORK_DIVERSITY 4 + +/* + * Different link types allowed in the Client Port Service Attributes + * subobject defined for LMP Service Discovery in the UNI 1.0 spec + */ +#define LMP_SD_SERVICE_CONFIG_CPSA_LINK_TYPE_SDH 5 /* UNI 1.0 Sec 9.4.2 */ +#define LMP_SD_SERVICE_CONFIG_CPSA_LINK_TYPE_SONET 6 /* UNI 1.0 Sec 9.4.2 */ + +/* + * 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 lmp_ctype_values[] = { + { 256*LMP_OBJ_CC_ID+LMP_CTYPE_LOC, "Local" }, + { 256*LMP_OBJ_CC_ID+LMP_CTYPE_RMT, "Remote" }, + { 256*LMP_OBJ_NODE_ID+LMP_CTYPE_LOC, "Local" }, + { 256*LMP_OBJ_NODE_ID+LMP_CTYPE_RMT, "Remote" }, + { 256*LMP_OBJ_LINK_ID+LMP_CTYPE_IPV4_LOC, "IPv4 Local" }, + { 256*LMP_OBJ_LINK_ID+LMP_CTYPE_IPV4_RMT, "IPv4 Remote" }, + { 256*LMP_OBJ_LINK_ID+LMP_CTYPE_IPV6_LOC, "IPv6 Local" }, + { 256*LMP_OBJ_LINK_ID+LMP_CTYPE_IPV6_RMT, "IPv6 Remote" }, + { 256*LMP_OBJ_LINK_ID+LMP_CTYPE_UNMD_LOC, "Unnumbered Local" }, + { 256*LMP_OBJ_LINK_ID+LMP_CTYPE_UNMD_RMT, "Unnumbered Remote" }, + { 256*LMP_OBJ_INTERFACE_ID+LMP_CTYPE_IPV4_LOC, "IPv4 Local" }, + { 256*LMP_OBJ_INTERFACE_ID+LMP_CTYPE_IPV4_RMT, "IPv4 Remote" }, + { 256*LMP_OBJ_INTERFACE_ID+LMP_CTYPE_IPV6_LOC, "IPv6 Local" }, + { 256*LMP_OBJ_INTERFACE_ID+LMP_CTYPE_IPV6_RMT, "IPv6 Remote" }, + { 256*LMP_OBJ_INTERFACE_ID+LMP_CTYPE_UNMD_LOC, "Unnumbered Local" }, + { 256*LMP_OBJ_INTERFACE_ID+LMP_CTYPE_UNMD_RMT, "Unnumbered Remote" }, + { 256*LMP_OBJ_MESSAGE_ID+LMP_CTYPE_1, "1" }, + { 256*LMP_OBJ_MESSAGE_ID+LMP_CTYPE_2, "2" }, + { 256*LMP_OBJ_CONFIG+LMP_CTYPE_1, "1" }, + { 256*LMP_OBJ_HELLO+LMP_CTYPE_1, "1" }, + { 256*LMP_OBJ_VERIFY_BEGIN+LMP_CTYPE_1, "1" }, + { 256*LMP_OBJ_VERIFY_BEGIN_ACK+LMP_CTYPE_1, "1" }, + { 256*LMP_OBJ_VERIFY_ID+LMP_CTYPE_1, "1" }, + { 256*LMP_OBJ_TE_LINK+LMP_CTYPE_IPV4, "IPv4" }, + { 256*LMP_OBJ_TE_LINK+LMP_CTYPE_IPV6, "IPv6" }, + { 256*LMP_OBJ_TE_LINK+LMP_CTYPE_UNMD, "Unnumbered" }, + { 256*LMP_OBJ_DATA_LINK+LMP_CTYPE_IPV4, "IPv4" }, + { 256*LMP_OBJ_DATA_LINK+LMP_CTYPE_IPV6, "IPv6" }, + { 256*LMP_OBJ_DATA_LINK+LMP_CTYPE_UNMD, "Unnumbered" }, + { 256*LMP_OBJ_CHANNEL_STATUS+LMP_CTYPE_IPV4, "IPv4" }, + { 256*LMP_OBJ_CHANNEL_STATUS+LMP_CTYPE_IPV6, "IPv6" }, + { 256*LMP_OBJ_CHANNEL_STATUS+LMP_CTYPE_UNMD, "Unnumbered" }, + { 256*LMP_OBJ_CHANNEL_STATUS_REQ+LMP_CTYPE_IPV4, "IPv4" }, + { 256*LMP_OBJ_CHANNEL_STATUS_REQ+LMP_CTYPE_IPV6, "IPv6" }, + { 256*LMP_OBJ_CHANNEL_STATUS_REQ+LMP_CTYPE_UNMD, "Unnumbered" }, + { 256*LMP_OBJ_ERROR_CODE+LMP_CTYPE_1, "1" }, + { 256*LMP_OBJ_ERROR_CODE+LMP_CTYPE_2, "2" }, + { 256*LMP_OBJ_SERVICE_CONFIG+LMP_CTYPE_SERVICE_CONFIG_SP, "1" }, + { 256*LMP_OBJ_SERVICE_CONFIG+LMP_CTYPE_SERVICE_CONFIG_CPSA, "2" }, + { 256*LMP_OBJ_SERVICE_CONFIG+LMP_CTYPE_SERVICE_CONFIG_TRANSPARENCY_TCM, "3" }, + { 256*LMP_OBJ_SERVICE_CONFIG+LMP_CTYPE_SERVICE_CONFIG_NETWORK_DIVERSITY, "4" }, + { 0, NULL} +}; + +void +lmp_print(register const u_char *pptr, register u_int len) { + + const struct lmp_common_header *lmp_com_header; + const struct lmp_object_header *lmp_obj_header; + const u_char *tptr,*obj_tptr; + int tlen,lmp_obj_len,lmp_obj_ctype,obj_tlen; + int hexdump; + int offset,subobj_type,subobj_len,total_subobj_len; + int link_type; + + union { /* int to float conversion buffer */ + float f; + u_int32_t i; + } bw; + + tptr=pptr; + lmp_com_header = (const struct lmp_common_header *)pptr; + TCHECK(*lmp_com_header); + + /* + * Sanity checking of the header. + */ + if (LMP_EXTRACT_VERSION(lmp_com_header->version_res[0]) != LMP_VERSION) { + printf("LMP version %u packet not supported", + LMP_EXTRACT_VERSION(lmp_com_header->version_res[0])); + return; + } + + /* in non-verbose mode just lets print the basic Message Type*/ + if (vflag < 1) { + printf("LMPv%u %s Message, length: %u", + LMP_EXTRACT_VERSION(lmp_com_header->version_res[0]), + tok2str(lmp_msg_type_values, "unknown (%u)",lmp_com_header->msg_type), + len); + return; + } + + /* ok they seem to want to know everything - lets fully decode it */ + + tlen=EXTRACT_16BITS(lmp_com_header->length); + + printf("\n\tLMPv%u, msg-type: %s, Flags: [%s], length: %u", + LMP_EXTRACT_VERSION(lmp_com_header->version_res[0]), + tok2str(lmp_msg_type_values, "unknown, type: %u",lmp_com_header->msg_type), + bittok2str(lmp_header_flag_values,"none",lmp_com_header->flags), + tlen); + + tptr+=sizeof(const struct lmp_common_header); + tlen-=sizeof(const struct lmp_common_header); + + while(tlen>0) { + /* did we capture enough for fully decoding the object header ? */ + if (!TTEST2(*tptr, sizeof(struct lmp_object_header))) + goto trunc; + + lmp_obj_header = (const struct lmp_object_header *)tptr; + lmp_obj_len=EXTRACT_16BITS(lmp_obj_header->length); + lmp_obj_ctype=(lmp_obj_header->ctype)&0x7f; + + if(lmp_obj_len % 4 || lmp_obj_len < 4) + return; + + printf("\n\t %s Object (%u), Class-Type: %s (%u) Flags: [%snegotiable], length: %u", + tok2str(lmp_obj_values, + "Unknown", + lmp_obj_header->class_num), + lmp_obj_header->class_num, + tok2str(lmp_ctype_values, + "Unknown", + ((lmp_obj_header->class_num)<<8)+lmp_obj_ctype), + lmp_obj_ctype, + (lmp_obj_header->ctype)&0x80 ? "" : "non-", + lmp_obj_len); + + obj_tptr=tptr+sizeof(struct lmp_object_header); + obj_tlen=lmp_obj_len-sizeof(struct lmp_object_header); + + /* did we capture enough for fully decoding the object ? */ + if (!TTEST2(*tptr, lmp_obj_len)) + goto trunc; + hexdump=FALSE; + + switch(lmp_obj_header->class_num) { + + case LMP_OBJ_CC_ID: + switch(lmp_obj_ctype) { + case LMP_CTYPE_LOC: + case LMP_CTYPE_RMT: + printf("\n\t Control Channel ID: %u (0x%08x)", + EXTRACT_32BITS(obj_tptr), + EXTRACT_32BITS(obj_tptr)); + break; + + default: + hexdump=TRUE; + } + break; + + case LMP_OBJ_LINK_ID: + case LMP_OBJ_INTERFACE_ID: + switch(lmp_obj_ctype) { + case LMP_CTYPE_IPV4_LOC: + case LMP_CTYPE_IPV4_RMT: + printf("\n\t IPv4 Link ID: %s (0x%08x)", + ipaddr_string(obj_tptr), + EXTRACT_32BITS(obj_tptr)); + break; +#ifdef INET6 + case LMP_CTYPE_IPV6_LOC: + case LMP_CTYPE_IPV6_RMT: + printf("\n\t IPv6 Link ID: %s (0x%08x)", + ip6addr_string(obj_tptr), + EXTRACT_32BITS(obj_tptr)); + break; +#endif + case LMP_CTYPE_UNMD_LOC: + case LMP_CTYPE_UNMD_RMT: + printf("\n\t Link ID: %u (0x%08x)", + EXTRACT_32BITS(obj_tptr), + EXTRACT_32BITS(obj_tptr)); + break; + default: + hexdump=TRUE; + } + break; + + case LMP_OBJ_MESSAGE_ID: + switch(lmp_obj_ctype) { + case LMP_CTYPE_1: + printf("\n\t Message ID: %u (0x%08x)", + EXTRACT_32BITS(obj_tptr), + EXTRACT_32BITS(obj_tptr)); + break; + case LMP_CTYPE_2: + printf("\n\t Message ID Ack: %u (0x%08x)", + EXTRACT_32BITS(obj_tptr), + EXTRACT_32BITS(obj_tptr)); + break; + default: + hexdump=TRUE; + } + break; + + case LMP_OBJ_NODE_ID: + switch(lmp_obj_ctype) { + case LMP_CTYPE_LOC: + case LMP_CTYPE_RMT: + printf("\n\t Node ID: %s (0x%08x)", + ipaddr_string(obj_tptr), + EXTRACT_32BITS(obj_tptr)); + break; + + default: + hexdump=TRUE; + } + break; + + case LMP_OBJ_CONFIG: + switch(lmp_obj_ctype) { + case LMP_CTYPE_HELLO_CONFIG: + printf("\n\t Hello Interval: %u\n\t Hello Dead Interval: %u", + EXTRACT_16BITS(obj_tptr), + EXTRACT_16BITS(obj_tptr+2)); + break; + + default: + hexdump=TRUE; + } + break; + + case LMP_OBJ_HELLO: + switch(lmp_obj_ctype) { + case LMP_CTYPE_HELLO: + printf("\n\t Tx Seq: %u, Rx Seq: %u", + EXTRACT_32BITS(obj_tptr), + EXTRACT_32BITS(obj_tptr+4)); + break; + + default: + hexdump=TRUE; + } + break; + + case LMP_OBJ_TE_LINK: + printf("\n\t Flags: [%s]", + bittok2str(lmp_obj_te_link_flag_values, + "none", + EXTRACT_16BITS(obj_tptr)>>8)); + + switch(lmp_obj_ctype) { + case LMP_CTYPE_IPV4: + printf("\n\t Local Link-ID: %s (0x%08x) \ + \n\t Remote Link-ID: %s (0x%08x)", + ipaddr_string(obj_tptr+4), + EXTRACT_32BITS(obj_tptr+4), + ipaddr_string(obj_tptr+8), + EXTRACT_32BITS(obj_tptr+8)); + break; + +#ifdef INET6 + case LMP_CTYPE_IPV6: +#endif + case LMP_CTYPE_UNMD: + default: + hexdump=TRUE; + } + break; + + case LMP_OBJ_DATA_LINK: + printf("\n\t Flags: [%s]", + bittok2str(lmp_obj_data_link_flag_values, + "none", + EXTRACT_16BITS(obj_tptr)>>8)); + + switch(lmp_obj_ctype) { + case LMP_CTYPE_IPV4: + case LMP_CTYPE_UNMD: + printf("\n\t Local Interface ID: %s (0x%08x) \ + \n\t Remote Interface ID: %s (0x%08x)", + ipaddr_string(obj_tptr+4), + EXTRACT_32BITS(obj_tptr+4), + ipaddr_string(obj_tptr+8), + EXTRACT_32BITS(obj_tptr+8)); + + total_subobj_len = lmp_obj_len - 16; + offset = 12; + while (total_subobj_len > 0 && hexdump == FALSE ) { + subobj_type = EXTRACT_16BITS(obj_tptr+offset)>>8; + subobj_len = EXTRACT_16BITS(obj_tptr+offset)&0x00FF; + printf("\n\t Subobject, Type: %s (%u), Length: %u", + tok2str(lmp_data_link_subobj, + "Unknown", + subobj_type), + subobj_type, + subobj_len); + switch(subobj_type) { + case INT_SWITCHING_TYPE_SUBOBJ: + printf("\n\t Switching Type: %s (%u)", + tok2str(gmpls_switch_cap_values, + "Unknown", + EXTRACT_16BITS(obj_tptr+offset+2)>>8), + EXTRACT_16BITS(obj_tptr+offset+2)>>8); + printf("\n\t Encoding Type: %s (%u)", + tok2str(gmpls_encoding_values, + "Unknown", + EXTRACT_16BITS(obj_tptr+offset+2)&0x00FF), + EXTRACT_16BITS(obj_tptr+offset+2)&0x00FF); + bw.i = EXTRACT_32BITS(obj_tptr+offset+4); + printf("\n\t Min Reservable Bandwidth: %.3f Mbps", + bw.f*8/1000000); + bw.i = EXTRACT_32BITS(obj_tptr+offset+8); + printf("\n\t Max Reservable Bandwidth: %.3f Mbps", + bw.f*8/1000000); + break; + case WAVELENGTH_SUBOBJ: + printf("\n\t Wavelength: %u", + EXTRACT_32BITS(obj_tptr+offset+4)); + break; + default: + /* Any Unknown Subobject ==> Exit loop */ + hexdump=TRUE; + break; + } + total_subobj_len-=subobj_len; + offset+=subobj_len; + } + + break; +#ifdef INET6 + case LMP_CTYPE_IPV6: +#endif + default: + hexdump=TRUE; + } + break; + + case LMP_OBJ_VERIFY_BEGIN: + switch(lmp_obj_ctype) { + case LMP_CTYPE_1: + printf("\n\t Flags: %s", + bittok2str(lmp_obj_begin_verify_flag_values, + "none", + EXTRACT_16BITS(obj_tptr))); + printf("\n\t Verify Interval: %u", + EXTRACT_16BITS(obj_tptr+2)); + printf("\n\t Data links: %u", + EXTRACT_32BITS(obj_tptr+4)); + printf("\n\t Encoding type: %s", + tok2str(gmpls_encoding_values, "Unknown", *(obj_tptr+8))); + printf("\n\t Verify Tranport Mechanism: %u (0x%x) %s", + EXTRACT_16BITS(obj_tptr+10), + EXTRACT_16BITS(obj_tptr+10), + EXTRACT_16BITS(obj_tptr+10)&8000 ? "(Payload test messages capable)" : ""); + bw.i = EXTRACT_32BITS(obj_tptr+12); + printf("\n\t Transmission Rate: %.3f Mbps",bw.f*8/1000000); + printf("\n\t Wavelength: %u", + EXTRACT_32BITS(obj_tptr+16)); + break; + + default: + hexdump=TRUE; + } + break; + + case LMP_OBJ_VERIFY_BEGIN_ACK: + switch(lmp_obj_ctype) { + case LMP_CTYPE_1: + printf("\n\t Verify Dead Interval: %u \ + \n\t Verify Transport Response: %u", + EXTRACT_16BITS(obj_tptr), + EXTRACT_16BITS(obj_tptr+2)); + break; + + default: + hexdump=TRUE; + } + break; + + case LMP_OBJ_VERIFY_ID: + switch(lmp_obj_ctype) { + case LMP_CTYPE_1: + printf("\n\t Verify ID: %u", + EXTRACT_32BITS(obj_tptr)); + break; + + default: + hexdump=TRUE; + } + break; + + case LMP_OBJ_CHANNEL_STATUS: + switch(lmp_obj_ctype) { + case LMP_CTYPE_IPV4: + case LMP_CTYPE_UNMD: + offset = 0; + /* Decode pairs: <Interface_ID (4 bytes), Channel_status (4 bytes)> */ + while (offset < (lmp_obj_len-(int)sizeof(struct lmp_object_header)) ) { + printf("\n\t Interface ID: %s (0x%08x)", + ipaddr_string(obj_tptr+offset), + EXTRACT_32BITS(obj_tptr+offset)); + + printf("\n\t\t Active: %s (%u)", (EXTRACT_32BITS(obj_tptr+offset+4)>>31) ? + "Allocated" : "Non-allocated", + (EXTRACT_32BITS(obj_tptr+offset+4)>>31)); + + printf("\n\t\t Direction: %s (%u)", (EXTRACT_32BITS(obj_tptr+offset+4)>>30)&0x1 ? + "Transmit" : "Receive", + (EXTRACT_32BITS(obj_tptr+offset+4)>>30)&0x1); + + printf("\n\t\t Channel Status: %s (%u)", + tok2str(lmp_obj_channel_status_values, + "Unknown", + EXTRACT_32BITS(obj_tptr+offset+4)&0x3FFFFFF), + EXTRACT_32BITS(obj_tptr+offset+4)&0x3FFFFFF); + offset+=8; + } + break; +#ifdef INET6 + case LMP_CTYPE_IPV6: +#endif + default: + hexdump=TRUE; + } + break; + + case LMP_OBJ_CHANNEL_STATUS_REQ: + switch(lmp_obj_ctype) { + case LMP_CTYPE_IPV4: + case LMP_CTYPE_UNMD: + offset = 0; + while (offset < (lmp_obj_len-(int)sizeof(struct lmp_object_header)) ) { + printf("\n\t Interface ID: %s (0x%08x)", + ipaddr_string(obj_tptr+offset), + EXTRACT_32BITS(obj_tptr+offset)); + offset+=4; + } + break; +#ifdef INET6 + case LMP_CTYPE_IPV6: +#endif + default: + hexdump=TRUE; + } + break; + + case LMP_OBJ_ERROR_CODE: + switch(lmp_obj_ctype) { + case LMP_CTYPE_BEGIN_VERIFY_ERROR: + printf("\n\t Error Code: %s", + bittok2str(lmp_obj_begin_verify_error_values, + "none", + EXTRACT_32BITS(obj_tptr))); + break; + + case LMP_CTYPE_LINK_SUMMARY_ERROR: + printf("\n\t Error Code: %s", + bittok2str(lmp_obj_link_summary_error_values, + "none", + EXTRACT_32BITS(obj_tptr))); + break; + default: + hexdump=TRUE; + } + break; + + case LMP_OBJ_SERVICE_CONFIG: + switch (lmp_obj_ctype) { + case LMP_CTYPE_SERVICE_CONFIG_SP: + + printf("\n\t Flags: %s", + bittok2str(lmp_obj_service_config_sp_flag_values, + "none", + EXTRACT_16BITS(obj_tptr)>>8)); + + printf("\n\t UNI Version: %u", + EXTRACT_16BITS(obj_tptr) & 0x00FF); + + break; + + case LMP_CTYPE_SERVICE_CONFIG_CPSA: + + link_type = EXTRACT_16BITS(obj_tptr)>>8; + + printf("\n\t Link Type: %s (%u)", + tok2str(lmp_sd_service_config_cpsa_link_type_values, + "Unknown", link_type), + link_type); + + if (link_type == LMP_SD_SERVICE_CONFIG_CPSA_LINK_TYPE_SDH) { + printf("\n\t Signal Type: %s (%u)", + tok2str(lmp_sd_service_config_cpsa_signal_type_sdh_values, + "Unknown", + EXTRACT_16BITS(obj_tptr) & 0x00FF), + EXTRACT_16BITS(obj_tptr) & 0x00FF); + } + + if (link_type == LMP_SD_SERVICE_CONFIG_CPSA_LINK_TYPE_SONET) { + printf("\n\t Signal Type: %s (%u)", + tok2str(lmp_sd_service_config_cpsa_signal_type_sonet_values, + "Unknown", + EXTRACT_16BITS(obj_tptr) & 0x00FF), + EXTRACT_16BITS(obj_tptr) & 0x00FF); + } + + printf("\n\t Transparency: %s", + bittok2str(lmp_obj_service_config_cpsa_tp_flag_values, + "none", + EXTRACT_16BITS(obj_tptr+2)>>8)); + + printf("\n\t Contiguous Concatenation Types: %s", + bittok2str(lmp_obj_service_config_cpsa_cct_flag_values, + "none", + EXTRACT_16BITS(obj_tptr+2)>>8 & 0x00FF)); + + printf("\n\t Minimum NCC: %u", + EXTRACT_16BITS(obj_tptr+4)); + + printf("\n\t Maximum NCC: %u", + EXTRACT_16BITS(obj_tptr+6)); + + printf("\n\t Minimum NVC:%u", + EXTRACT_16BITS(obj_tptr+8)); + + printf("\n\t Maximum NVC:%u", + EXTRACT_16BITS(obj_tptr+10)); + + printf("\n\t Local Interface ID: %s (0x%08x)", + ipaddr_string(obj_tptr+12), + EXTRACT_32BITS(obj_tptr+12)); + + break; + + case LMP_CTYPE_SERVICE_CONFIG_TRANSPARENCY_TCM: + + printf("\n\t Transparency Flags: %s", + bittok2str( + lmp_obj_service_config_nsa_transparency_flag_values, + "none", + EXTRACT_32BITS(obj_tptr))); + + printf("\n\t TCM Monitoring Flags: %s", + bittok2str( + lmp_obj_service_config_nsa_tcm_flag_values, + "none", + EXTRACT_16BITS(obj_tptr+6) & 0x00FF)); + + break; + + case LMP_CTYPE_SERVICE_CONFIG_NETWORK_DIVERSITY: + + printf("\n\t Diversity: Flags: %s", + bittok2str( + lmp_obj_service_config_nsa_network_diversity_flag_values, + "none", + EXTRACT_16BITS(obj_tptr+2) & 0x00FF)); + break; + + default: + hexdump = TRUE; + }; + + break; + + 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(struct lmp_object_header),"\n\t ", + lmp_obj_len-sizeof(struct lmp_object_header)); + + tptr+=lmp_obj_len; + tlen-=lmp_obj_len; + } + return; +trunc: + printf("\n\t\t packet exceeded snapshot"); +}
diff --git a/tcpdump-4.3.0/print-lspping.c b/tcpdump-4.3.0/print-lspping.c new file mode 100644 index 0000000..2ca57fb --- /dev/null +++ b/tcpdump-4.3.0/print-lspping.c
@@ -0,0 +1,896 @@ +/* + * 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-lspping.c,v 1.20 2008-01-28 14:20:43 hannes 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 "bgp.h" +#include "l2vpn.h" +#include "oui.h" + +/* + * LSPPING 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 Number | Must Be Zero | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Message Type | Reply mode | Return Code | Return Subcode| + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Sender's Handle | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Sequence Number | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | TimeStamp Sent (seconds) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | TimeStamp Sent (microseconds) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | TimeStamp Received (seconds) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | TimeStamp Received (microseconds) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | TLVs ... | + * . . + * . . + * . . + */ + +struct lspping_common_header { + u_int8_t version[2]; + u_int8_t reserved[2]; + u_int8_t msg_type; + u_int8_t reply_mode; + u_int8_t return_code; + u_int8_t return_subcode; + u_int8_t sender_handle[4]; + u_int8_t seq_number[4]; + u_int8_t ts_sent_sec[4]; + u_int8_t ts_sent_usec[4]; + u_int8_t ts_rcvd_sec[4]; + u_int8_t ts_rcvd_usec[4]; +}; + +#define LSPPING_VERSION 1 + +static const struct tok lspping_msg_type_values[] = { + { 1, "MPLS Echo Request"}, + { 2, "MPLS Echo Reply"}, + { 0, NULL} +}; + +static const struct tok lspping_reply_mode_values[] = { + { 1, "Do not reply"}, + { 2, "Reply via an IPv4/IPv6 UDP packet"}, + { 3, "Reply via an IPv4/IPv6 UDP packet with Router Alert"}, + { 4, "Reply via application level control channel"}, + { 0, NULL} +}; + +static const struct tok lspping_return_code_values[] = { + { 0, "No return code or return code contained in the Error Code TLV"}, + { 1, "Malformed echo request received"}, + { 2, "One or more of the TLVs was not understood"}, + { 3, "Replying router is an egress for the FEC at stack depth"}, + { 4, "Replying router has no mapping for the FEC at stack depth"}, + { 5, "Reserved"}, + { 6, "Reserved"}, + { 7, "Reserved"}, + { 8, "Label switched at stack-depth"}, + { 9, "Label switched but no MPLS forwarding at stack-depth"}, + { 10, "Mapping for this FEC is not the given label at stack depth"}, + { 11, "No label entry at stack-depth"}, + { 12, "Protocol not associated with interface at FEC stack depth"}, +}; + + +/* + * LSPPING 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 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Type | Length | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Value | + * . . + * . . + * . . + * | | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ + +struct lspping_tlv_header { + u_int8_t type[2]; + u_int8_t length[2]; +}; + +#define LSPPING_TLV_TARGET_FEC_STACK 1 +#define LSPPING_TLV_DOWNSTREAM_MAPPING 2 +#define LSPPING_TLV_PAD 3 +#define LSPPING_TLV_VENDOR_ENTERPRISE 5 +#define LSPPING_TLV_VENDOR_ENTERPRISE_LEN 4 +#define LSPPING_TLV_INTERFACE_LABEL_STACK 7 +#define LSPPING_TLV_ERROR_CODE 9 +#define LSPPING_TLV_REPLY_TOS_BYTE 10 +#define LSPPING_TLV_BFD_DISCRIMINATOR 15 /* draft-ietf-bfd-mpls-02 */ +#define LSPPING_TLV_BFD_DISCRIMINATOR_LEN 4 +#define LSPPING_TLV_VENDOR_PRIVATE 0xfc00 + +static const struct tok lspping_tlv_values[] = { + { LSPPING_TLV_TARGET_FEC_STACK, "Target FEC Stack" }, + { LSPPING_TLV_DOWNSTREAM_MAPPING, "Downstream Mapping" }, + { LSPPING_TLV_PAD, "Pad" }, + { LSPPING_TLV_ERROR_CODE, "Error Code" }, + { LSPPING_TLV_VENDOR_ENTERPRISE, "Vendor Enterprise Code" }, + { LSPPING_TLV_INTERFACE_LABEL_STACK, "Interface Label Stack" }, + { LSPPING_TLV_REPLY_TOS_BYTE, "Reply TOS Byte" }, + { LSPPING_TLV_BFD_DISCRIMINATOR, "BFD Discriminator" }, + { LSPPING_TLV_VENDOR_PRIVATE, "Vendor Private Code" }, + { 0, NULL} +}; + +#define LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4 1 +#define LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6 2 +#define LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4 3 +#define LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6 4 +#define LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4 6 +#define LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6 7 +#define LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT 8 +#define LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID_OLD 9 +#define LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID 10 +#define LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4 11 +#define LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6 12 + +static const struct tok lspping_tlvtargetfec_subtlv_values[] = { + { LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4, "LDP IPv4 prefix"}, + { LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6, "LDP IPv6 prefix"}, + { LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4, "RSVP IPv4 Session Query"}, + { LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6, "RSVP IPv6 Session Query"}, + { 5, "Reserved"}, + { LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4, "VPN IPv4 prefix"}, + { LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6, "VPN IPv6 prefix"}, + { LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT, "L2 VPN endpoint"}, + { LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID_OLD, "L2 circuit ID (old)"}, + { LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID, "L2 circuit ID"}, + { LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4, "BGP labeled IPv4 prefix"}, + { LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6, "BGP labeled IPv6 prefix"}, + { 0, NULL} +}; + +/* + * 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 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | IPv4 prefix | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Prefix Length | Must Be Zero | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ +struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t { + u_int8_t prefix [4]; + u_int8_t prefix_len; +}; + +/* + * 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 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | IPv6 prefix | + * | (16 octets) | + * | | + * | | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Prefix Length | Must Be Zero | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ +struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t { + u_int8_t prefix [16]; + u_int8_t prefix_len; +}; + +/* + * 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 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Sender identifier | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | IPv4 prefix | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Prefix Length | Must Be Zero | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ +struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t { + u_int8_t sender_id [4]; + u_int8_t prefix [4]; + u_int8_t prefix_len; +}; + +/* + * 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 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Sender identifier | + * | (16 octets) | + * | | + * | | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | IPv6 prefix | + * | (16 octets) | + * | | + * | | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Prefix Length | Must Be Zero | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ +struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t { + u_int8_t sender_id [16]; + u_int8_t prefix [16]; + u_int8_t prefix_len; +}; + +/* + * 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 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | IPv4 tunnel end point address | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Must Be Zero | Tunnel ID | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Extended Tunnel ID | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | IPv4 tunnel sender address | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Must Be Zero | LSP ID | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ +struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t { + u_int8_t tunnel_endpoint [4]; + u_int8_t res[2]; + u_int8_t tunnel_id[2]; + u_int8_t extended_tunnel_id[4]; + u_int8_t tunnel_sender [4]; + u_int8_t res2[2]; + u_int8_t lsp_id [2]; +}; + +/* + * 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 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | IPv6 tunnel end point address | + * | | + * | | + * | | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Must Be Zero | Tunnel ID | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Extended Tunnel ID | + * | | + * | | + * | | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | IPv6 tunnel sender address | + * | | + * | | + * | | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Must Be Zero | LSP ID | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ +struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t { + u_int8_t tunnel_endpoint [16]; + u_int8_t res[2]; + u_int8_t tunnel_id[2]; + u_int8_t extended_tunnel_id[16]; + u_int8_t tunnel_sender [16]; + u_int8_t res2[2]; + u_int8_t lsp_id [2]; +}; + +/* + * 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 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Route Distinguisher | + * | (8 octets) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | IPv4 prefix | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Prefix Length | Must Be Zero | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ +struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t { + u_int8_t rd [8]; + u_int8_t prefix [4]; + u_int8_t prefix_len; +}; + +/* + * 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 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Route Distinguisher | + * | (8 octets) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | IPv6 prefix | + * | (16 octets) | + * | | + * | | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Prefix Length | Must Be Zero | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ +struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t { + u_int8_t rd [8]; + u_int8_t prefix [16]; + u_int8_t prefix_len; +}; + +/* + * 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 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Route Distinguisher | + * | (8 octets) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Sender's CE ID | Receiver's CE ID | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Encapsulation Type | Must Be Zero | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * 0 1 2 3 + */ +struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t { + u_int8_t rd [8]; + u_int8_t sender_ce_id [2]; + u_int8_t receiver_ce_id [2]; + u_int8_t encapsulation[2]; +}; + +/* + * 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 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Remote PE Address | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | VC ID | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Encapsulation Type | Must Be Zero | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ +struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_old_t { + u_int8_t remote_pe_address [4]; + u_int8_t vc_id [4]; + u_int8_t encapsulation[2]; +}; + +/* + * 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 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Sender's PE Address | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Remote PE Address | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | VC ID | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Encapsulation Type | Must Be Zero | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ +struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_t { + u_int8_t sender_pe_address [4]; + u_int8_t remote_pe_address [4]; + u_int8_t vc_id [4]; + u_int8_t encapsulation[2]; +}; + +/* + * 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 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | MTU | Address Type | Resvd (SBZ) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Downstream IP Address (4 or 16 octets) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Downstream Interface Address (4 or 16 octets) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Hash Key Type | Depth Limit | Multipath Length | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * . . + * . (Multipath Information) . + * . . + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Downstream Label | Protocol | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * . . + * . . + * . . + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Downstream Label | Protocol | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ +struct lspping_tlv_downstream_map_ipv4_t { + u_int8_t mtu [2]; + u_int8_t address_type; + u_int8_t res; + u_int8_t downstream_ip[4]; + u_int8_t downstream_interface[4]; +}; + +struct lspping_tlv_downstream_map_ipv6_t { + u_int8_t mtu [2]; + u_int8_t address_type; + u_int8_t res; + u_int8_t downstream_ip[16]; + u_int8_t downstream_interface[16]; +}; + +struct lspping_tlv_downstream_map_info_t { + u_int8_t hash_key_type; + u_int8_t depth_limit; + u_int8_t multipath_length [2]; +}; + +#define LSPPING_AFI_IPV4 1 +#define LSPPING_AFI_UNMB 2 +#define LSPPING_AFI_IPV6 3 + +static const struct tok lspping_tlv_downstream_addr_values[] = { + { LSPPING_AFI_IPV4, "IPv4"}, + { LSPPING_AFI_IPV6, "IPv6"}, + { LSPPING_AFI_UNMB, "Unnumbered"}, + { 0, NULL} +}; + +void +lspping_print(register const u_char *pptr, register u_int len) { + + const struct lspping_common_header *lspping_com_header; + const struct lspping_tlv_header *lspping_tlv_header; + const struct lspping_tlv_header *lspping_subtlv_header; + const u_char *tptr,*tlv_tptr,*subtlv_tptr; + int tlen,lspping_tlv_len,lspping_tlv_type,tlv_tlen; + int tlv_hexdump,subtlv_hexdump; + int lspping_subtlv_len,lspping_subtlv_type; + struct timeval timestamp; + + union { + const struct lspping_tlv_downstream_map_ipv4_t *lspping_tlv_downstream_map_ipv4; + const struct lspping_tlv_downstream_map_ipv6_t *lspping_tlv_downstream_map_ipv6; + const struct lspping_tlv_downstream_map_info_t *lspping_tlv_downstream_map_info; + } tlv_ptr; + + union { + const struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t *lspping_tlv_targetfec_subtlv_ldp_ipv4; + const struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t *lspping_tlv_targetfec_subtlv_ldp_ipv6; + const struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t *lspping_tlv_targetfec_subtlv_rsvp_ipv4; + const struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t *lspping_tlv_targetfec_subtlv_rsvp_ipv6; + const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t *lspping_tlv_targetfec_subtlv_l3vpn_ipv4; + const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t *lspping_tlv_targetfec_subtlv_l3vpn_ipv6; + const struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t *lspping_tlv_targetfec_subtlv_l2vpn_endpt; + const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_old_t *lspping_tlv_targetfec_subtlv_l2vpn_vcid_old; + const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_t *lspping_tlv_targetfec_subtlv_l2vpn_vcid; + const struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t *lspping_tlv_targetfec_subtlv_bgp_ipv4; + const struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t *lspping_tlv_targetfec_subtlv_bgp_ipv6; + } subtlv_ptr; + + tptr=pptr; + lspping_com_header = (const struct lspping_common_header *)pptr; + TCHECK(*lspping_com_header); + + /* + * Sanity checking of the header. + */ + if (EXTRACT_16BITS(&lspping_com_header->version[0]) != LSPPING_VERSION) { + printf("LSP-PING version %u packet not supported", + EXTRACT_16BITS(&lspping_com_header->version[0])); + return; + } + + /* in non-verbose mode just lets print the basic Message Type*/ + if (vflag < 1) { + printf("LSP-PINGv%u, %s, seq %u, length: %u", + EXTRACT_16BITS(&lspping_com_header->version[0]), + tok2str(lspping_msg_type_values, "unknown (%u)",lspping_com_header->msg_type), + EXTRACT_32BITS(lspping_com_header->seq_number), + len); + return; + } + + /* ok they seem to want to know everything - lets fully decode it */ + + tlen=len; + + printf("\n\tLSP-PINGv%u, msg-type: %s (%u), length: %u\n\t reply-mode: %s (%u)", + EXTRACT_16BITS(&lspping_com_header->version[0]), + tok2str(lspping_msg_type_values, "unknown",lspping_com_header->msg_type), + lspping_com_header->msg_type, + len, + tok2str(lspping_reply_mode_values, "unknown",lspping_com_header->reply_mode), + lspping_com_header->reply_mode); + + /* + * the following return codes require that the subcode is attached + * at the end of the translated token output + */ + if (lspping_com_header->return_code == 3 || + lspping_com_header->return_code == 4 || + lspping_com_header->return_code == 8 || + lspping_com_header->return_code == 10 || + lspping_com_header->return_code == 11 || + lspping_com_header->return_code == 12 ) + printf("\n\t Return Code: %s %u (%u)\n\t Return Subcode: (%u)", + tok2str(lspping_return_code_values, "unknown",lspping_com_header->return_code), + lspping_com_header->return_subcode, + lspping_com_header->return_code, + lspping_com_header->return_subcode); + else + printf("\n\t Return Code: %s (%u)\n\t Return Subcode: (%u)", + tok2str(lspping_return_code_values, "unknown",lspping_com_header->return_code), + lspping_com_header->return_code, + lspping_com_header->return_subcode); + + printf("\n\t Sender Handle: 0x%08x, Sequence: %u", + EXTRACT_32BITS(lspping_com_header->sender_handle), + EXTRACT_32BITS(lspping_com_header->seq_number)); + + timestamp.tv_sec=EXTRACT_32BITS(lspping_com_header->ts_sent_sec); + timestamp.tv_usec=EXTRACT_32BITS(lspping_com_header->ts_sent_usec); + printf("\n\t Sender Timestamp: "); + ts_print(×tamp); + + timestamp.tv_sec=EXTRACT_32BITS(lspping_com_header->ts_rcvd_sec); + timestamp.tv_usec=EXTRACT_32BITS(lspping_com_header->ts_rcvd_usec); + printf("Receiver Timestamp: "); + if ((timestamp.tv_sec != 0) && (timestamp.tv_usec != 0)) + ts_print(×tamp); + else + printf("no timestamp"); + + tptr+=sizeof(const struct lspping_common_header); + tlen-=sizeof(const struct lspping_common_header); + + while(tlen>(int)sizeof(struct lspping_tlv_header)) { + + /* did we capture enough for fully decoding the tlv header ? */ + if (!TTEST2(*tptr, sizeof(struct lspping_tlv_header))) + goto trunc; + + lspping_tlv_header = (const struct lspping_tlv_header *)tptr; + lspping_tlv_type=EXTRACT_16BITS(lspping_tlv_header->type); + lspping_tlv_len=EXTRACT_16BITS(lspping_tlv_header->length); + + /* some little sanity checking */ + if (lspping_tlv_type == 0 || lspping_tlv_len == 0) + return; + + if(lspping_tlv_len < 4) { + printf("\n\t ERROR: TLV %u bogus size %u",lspping_tlv_type,lspping_tlv_len); + return; + } + + printf("\n\t %s TLV (%u), length: %u", + tok2str(lspping_tlv_values, + "Unknown", + lspping_tlv_type), + lspping_tlv_type, + lspping_tlv_len); + + tlv_tptr=tptr+sizeof(struct lspping_tlv_header); + tlv_tlen=lspping_tlv_len; /* header not included -> no adjustment */ + + /* did we capture enough for fully decoding the tlv ? */ + if (!TTEST2(*tptr, lspping_tlv_len)) + goto trunc; + tlv_hexdump=FALSE; + + switch(lspping_tlv_type) { + case LSPPING_TLV_TARGET_FEC_STACK: + while(tlv_tlen>(int)sizeof(struct lspping_tlv_header)) { + + /* did we capture enough for fully decoding the subtlv header ? */ + if (!TTEST2(*tptr, sizeof(struct lspping_tlv_header))) + goto trunc; + subtlv_hexdump=FALSE; + + lspping_subtlv_header = (const struct lspping_tlv_header *)tlv_tptr; + lspping_subtlv_type=EXTRACT_16BITS(lspping_subtlv_header->type); + lspping_subtlv_len=EXTRACT_16BITS(lspping_subtlv_header->length); + subtlv_tptr=tlv_tptr+sizeof(struct lspping_tlv_header); + + if (lspping_subtlv_len == 0) + break; + + printf("\n\t %s subTLV (%u), length: %u", + tok2str(lspping_tlvtargetfec_subtlv_values, + "Unknown", + lspping_subtlv_type), + lspping_subtlv_type, + lspping_subtlv_len); + + switch(lspping_subtlv_type) { + + case LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4: + subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4 = \ + (const struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t *)subtlv_tptr; + printf("\n\t %s/%u", + ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4->prefix), + subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4->prefix_len); + break; + +#ifdef INET6 + case LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6: + subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6 = \ + (const struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t *)subtlv_tptr; + printf("\n\t %s/%u", + ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6->prefix), + subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6->prefix_len); + break; +#endif + + case LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4: + subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4 = \ + (const struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t *)subtlv_tptr; + printf("\n\t %s/%u, sender-id %s", + ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->prefix), + subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->prefix_len, + ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->sender_id)); + break; + +#ifdef INET6 + case LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6: + subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6 = \ + (const struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t *)subtlv_tptr; + printf("\n\t %s/%u, sender-id %s", + ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->prefix), + subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->prefix_len, + ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->sender_id)); + break; +#endif + + case LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4: + subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4 = \ + (const struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t *)subtlv_tptr; + printf("\n\t tunnel end-point %s, tunnel sender %s, lsp-id 0x%04x" \ + "\n\t tunnel-id 0x%04x, extended tunnel-id %s", + ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_endpoint), + ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_sender), + EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->lsp_id), + EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_id), + ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->extended_tunnel_id)); + break; + +#ifdef INET6 + case LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6: + subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6 = \ + (const struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t *)subtlv_tptr; + printf("\n\t tunnel end-point %s, tunnel sender %s, lsp-id 0x%04x" \ + "\n\t tunnel-id 0x%04x, extended tunnel-id %s", + ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_endpoint), + ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_sender), + EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->lsp_id), + EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_id), + ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->extended_tunnel_id)); + break; +#endif + + case LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4: + subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4 = \ + (const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t *)subtlv_tptr; + printf("\n\t RD: %s, %s/%u", + bgp_vpn_rd_print(subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->rd), + ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->prefix), + subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->prefix_len); + break; + +#ifdef INET6 + case LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6: + subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6 = \ + (const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t *)subtlv_tptr; + printf("\n\t RD: %s, %s/%u", + bgp_vpn_rd_print(subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->rd), + ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->prefix), + subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->prefix_len); + break; +#endif + + case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT: + subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt = \ + (const struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t *)subtlv_tptr; + printf("\n\t RD: %s, Sender CE-ID: %u, Receiver CE-ID: %u" \ + "\n\t Encapsulation Type: %s (%u)", + bgp_vpn_rd_print(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->rd), + EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->sender_ce_id), + EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->receiver_ce_id), + tok2str(l2vpn_encaps_values, + "unknown", + EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->encapsulation)), + EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->encapsulation)); + + break; + + /* the old L2VPN VCID subTLV does not have support for the sender field */ + case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID_OLD: + subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old = \ + (const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_old_t *)subtlv_tptr; + printf("\n\t Remote PE: %s" \ + "\n\t VC-ID: 0x%08x, Encapsulation Type: %s (%u)", + ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->remote_pe_address), + EXTRACT_32BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->vc_id), + tok2str(l2vpn_encaps_values, + "unknown", + EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->encapsulation)), + EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->encapsulation)); + + break; + + case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID: + subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid = \ + (const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_t *)subtlv_tptr; + printf("\n\t Sender PE: %s, Remote PE: %s" \ + "\n\t VC-ID: 0x%08x, Encapsulation Type: %s (%u)", + ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->sender_pe_address), + ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->remote_pe_address), + EXTRACT_32BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->vc_id), + tok2str(l2vpn_encaps_values, + "unknown", + EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->encapsulation)), + EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->encapsulation)); + + break; + + default: + subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */ + break; + } + /* do we want to see an additionally subtlv hexdump ? */ + if (vflag > 1 || subtlv_hexdump==TRUE) + print_unknown_data(tlv_tptr+sizeof(struct lspping_tlv_header), \ + "\n\t ", + lspping_subtlv_len); + + tlv_tptr+=lspping_subtlv_len; + tlv_tlen-=lspping_subtlv_len+sizeof(struct lspping_tlv_header); + } + break; + + case LSPPING_TLV_DOWNSTREAM_MAPPING: + /* that strange thing with the downstream map TLV is that until now + * we do not know if its IPv4 or IPv6 , after we found the adress-type + * lets recast the tlv_tptr and move on */ + + tlv_ptr.lspping_tlv_downstream_map_ipv4= \ + (const struct lspping_tlv_downstream_map_ipv4_t *)tlv_tptr; + tlv_ptr.lspping_tlv_downstream_map_ipv6= \ + (const struct lspping_tlv_downstream_map_ipv6_t *)tlv_tptr; + printf("\n\t MTU: %u, Address-Type: %s (%u)", + EXTRACT_16BITS(tlv_ptr.lspping_tlv_downstream_map_ipv4->mtu), + tok2str(lspping_tlv_downstream_addr_values, + "unknown", + tlv_ptr.lspping_tlv_downstream_map_ipv4->address_type), + tlv_ptr.lspping_tlv_downstream_map_ipv4->address_type); + + switch(tlv_ptr.lspping_tlv_downstream_map_ipv4->address_type) { + + case LSPPING_AFI_IPV4: + printf("\n\t Downstream IP: %s" \ + "\n\t Downstream Interface IP: %s", + ipaddr_string(tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_ip), + ipaddr_string(tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_interface)); + tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_ipv4_t); + tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_ipv4_t); + break; +#ifdef INET6 + case LSPPING_AFI_IPV6: + printf("\n\t Downstream IP: %s" \ + "\n\t Downstream Interface IP: %s", + ip6addr_string(tlv_ptr.lspping_tlv_downstream_map_ipv6->downstream_ip), + ip6addr_string(tlv_ptr.lspping_tlv_downstream_map_ipv6->downstream_interface)); + tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_ipv6_t); + tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_ipv6_t); + break; +#endif + case LSPPING_AFI_UNMB: + printf("\n\t Downstream IP: %s" \ + "\n\t Downstream Interface Index: 0x%08x", + ipaddr_string(tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_ip), + EXTRACT_32BITS(tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_interface)); + tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_ipv4_t); + tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_ipv4_t); + break; + + default: + /* should not happen ! - no error message - tok2str() has barked already */ + break; + } + + tlv_ptr.lspping_tlv_downstream_map_info= \ + (const struct lspping_tlv_downstream_map_info_t *)tlv_tptr; + + /* FIXME add hash-key type, depth limit, multipath processing */ + + + tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_info_t); + tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_info_t); + + /* FIXME print downstream labels */ + + + tlv_hexdump=TRUE; /* dump the TLV until code complete */ + + break; + + case LSPPING_TLV_BFD_DISCRIMINATOR: + tptr += sizeof(struct lspping_tlv_header); + if (!TTEST2(*tptr, LSPPING_TLV_BFD_DISCRIMINATOR_LEN)) + goto trunc; + printf("\n\t BFD Discriminator 0x%08x", EXTRACT_32BITS(tptr)); + break; + + case LSPPING_TLV_VENDOR_ENTERPRISE: + { + u_int32_t vendor_id; + + if (!TTEST2(*tptr, LSPPING_TLV_VENDOR_ENTERPRISE_LEN)) + goto trunc; + vendor_id = EXTRACT_32BITS(tlv_tptr); + printf("\n\t Vendor: %s (0x%04x)", + tok2str(smi_values, "Unknown", vendor_id), + vendor_id); + } + break; + + /* + * FIXME those are the defined TLVs that lack a decoder + * you are welcome to contribute code ;-) + */ + case LSPPING_TLV_PAD: + case LSPPING_TLV_ERROR_CODE: + case LSPPING_TLV_VENDOR_PRIVATE: + + default: + if (vflag <= 1) + print_unknown_data(tlv_tptr,"\n\t ",tlv_tlen); + break; + } + /* do we want to see an additionally tlv hexdump ? */ + if (vflag > 1 || tlv_hexdump==TRUE) + print_unknown_data(tptr+sizeof(struct lspping_tlv_header),"\n\t ", + lspping_tlv_len); + + + /* All TLVs are aligned to four octet boundary */ + if (lspping_tlv_len % 4) { + lspping_tlv_len += (4 - lspping_tlv_len % 4); + } + + tptr+=lspping_tlv_len+sizeof(struct lspping_tlv_header); + tlen-=lspping_tlv_len+sizeof(struct lspping_tlv_header); + } + return; +trunc: + printf("\n\t\t packet exceeded snapshot"); +}
diff --git a/tcpdump-4.3.0/print-lwapp.c b/tcpdump-4.3.0/print-lwapp.c new file mode 100644 index 0000000..154876f --- /dev/null +++ b/tcpdump-4.3.0/print-lwapp.c
@@ -0,0 +1,359 @@ +/* + * Copyright (c) 1998-2007 The TCPDUMP project + * + * 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. + * + * Support for the Light Weight Access Point Protocol as per draft-ohara-capwap-lwapp-04 + * + * Original code by Carles Kishimoto <carles.kishimoto@gmail.com> + */ + +#ifndef lint +static const char rcsid[] _U_ = +"@(#) $Header: /tcpdump/master/tcpdump/print-lwapp.c,v 1.1 2007-07-24 16:07:30 hannes 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" + +/* + * LWAPP transport (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 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * |VER| RID |C|F|L| Frag ID | Length | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Status/WLANs | Payload... | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * + */ + +struct lwapp_transport_header { + u_int8_t version; + u_int8_t frag_id; + u_int8_t length[2]; + u_int16_t status; +}; + +/* + * LWAPP control 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 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Message Type | Seq Num | Msg Element Length | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Session ID | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Msg Element [0..N] | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ + +struct lwapp_control_header { + u_int8_t msg_type; + u_int8_t seq_num; + u_int8_t len[2]; + u_int8_t session_id[4]; +}; + +#define LWAPP_VERSION 0 +#define LWAPP_EXTRACT_VERSION(x) (((x)&0xC0)>>6) +#define LWAPP_EXTRACT_RID(x) (((x)&0x38)>>3) +#define LWAPP_EXTRACT_CONTROL_BIT(x) (((x)&0x04)>>2) + +static const struct tok lwapp_header_bits_values[] = { + { 0x01, "Last Fragment Bit"}, + { 0x02, "Fragment Bit"}, + { 0x04, "Control Bit"}, + { 0, NULL} +}; + +#define LWAPP_MSGTYPE_DISCOVERY_REQUEST 1 +#define LWAPP_MSGTYPE_DISCOVERY_RESPONSE 2 +#define LWAPP_MSGTYPE_JOIN_REQUEST 3 +#define LWAPP_MSGTYPE_JOIN_RESPONSE 4 +#define LWAPP_MSGTYPE_JOIN_ACK 5 +#define LWAPP_MSGTYPE_JOIN_CONFIRM 6 +#define LWAPP_MSGTYPE_CONFIGURE_REQUEST 10 +#define LWAPP_MSGTYPE_CONFIGURE_RESPONSE 11 +#define LWAPP_MSGTYPE_CONF_UPDATE_REQUEST 12 +#define LWAPP_MSGTYPE_CONF_UPDATE_RESPONSE 13 +#define LWAPP_MSGTYPE_WTP_EVENT_REQUEST 14 +#define LWAPP_MSGTYPE_WTP_EVENT_RESPONSE 15 +#define LWAPP_MSGTYPE_CHANGE_STATE_EVENT_REQUEST 16 +#define LWAPP_MSGTYPE_CHANGE_STATE_EVENT_RESPONSE 17 +#define LWAPP_MSGTYPE_ECHO_REQUEST 22 +#define LWAPP_MSGTYPE_ECHO_RESPONSE 23 +#define LWAPP_MSGTYPE_IMAGE_DATA_REQUEST 24 +#define LWAPP_MSGTYPE_IMAGE_DATA_RESPONSE 25 +#define LWAPP_MSGTYPE_RESET_REQUEST 26 +#define LWAPP_MSGTYPE_RESET_RESPONSE 27 +#define LWAPP_MSGTYPE_KEY_UPDATE_REQUEST 30 +#define LWAPP_MSGTYPE_KEY_UPDATE_RESPONSE 31 +#define LWAPP_MSGTYPE_PRIMARY_DISCOVERY_REQUEST 32 +#define LWAPP_MSGTYPE_PRIMARY_DISCOVERY_RESPONSE 33 +#define LWAPP_MSGTYPE_DATA_TRANSFER_REQUEST 34 +#define LWAPP_MSGTYPE_DATA_TRANSFER_RESPONSE 35 +#define LWAPP_MSGTYPE_CLEAR_CONFIG_INDICATION 36 +#define LWAPP_MSGTYPE_WLAN_CONFIG_REQUEST 37 +#define LWAPP_MSGTYPE_WLAN_CONFIG_RESPONSE 38 +#define LWAPP_MSGTYPE_MOBILE_CONFIG_REQUEST 39 +#define LWAPP_MSGTYPE_MOBILE_CONFIG_RESPONSE 40 + +static const struct tok lwapp_msg_type_values[] = { + { LWAPP_MSGTYPE_DISCOVERY_REQUEST, "Discovery req"}, + { LWAPP_MSGTYPE_DISCOVERY_RESPONSE, "Discovery resp"}, + { LWAPP_MSGTYPE_JOIN_REQUEST, "Join req"}, + { LWAPP_MSGTYPE_JOIN_RESPONSE, "Join resp"}, + { LWAPP_MSGTYPE_JOIN_ACK, "Join ack"}, + { LWAPP_MSGTYPE_JOIN_CONFIRM, "Join confirm"}, + { LWAPP_MSGTYPE_CONFIGURE_REQUEST, "Configure req"}, + { LWAPP_MSGTYPE_CONFIGURE_RESPONSE, "Configure resp"}, + { LWAPP_MSGTYPE_CONF_UPDATE_REQUEST, "Update req"}, + { LWAPP_MSGTYPE_CONF_UPDATE_RESPONSE, "Update resp"}, + { LWAPP_MSGTYPE_WTP_EVENT_REQUEST, "WTP event req"}, + { LWAPP_MSGTYPE_WTP_EVENT_RESPONSE, "WTP event resp"}, + { LWAPP_MSGTYPE_CHANGE_STATE_EVENT_REQUEST, "Change state event req"}, + { LWAPP_MSGTYPE_CHANGE_STATE_EVENT_RESPONSE, "Change state event resp"}, + { LWAPP_MSGTYPE_ECHO_REQUEST, "Echo req"}, + { LWAPP_MSGTYPE_ECHO_RESPONSE, "Echo resp"}, + { LWAPP_MSGTYPE_IMAGE_DATA_REQUEST, "Image data req"}, + { LWAPP_MSGTYPE_IMAGE_DATA_RESPONSE, "Image data resp"}, + { LWAPP_MSGTYPE_RESET_REQUEST, "Channel status req"}, + { LWAPP_MSGTYPE_RESET_RESPONSE, "Channel status resp"}, + { LWAPP_MSGTYPE_KEY_UPDATE_REQUEST, "Key update req"}, + { LWAPP_MSGTYPE_KEY_UPDATE_RESPONSE, "Key update resp"}, + { LWAPP_MSGTYPE_PRIMARY_DISCOVERY_REQUEST, "Primary discovery req"}, + { LWAPP_MSGTYPE_PRIMARY_DISCOVERY_RESPONSE, "Primary discovery resp"}, + { LWAPP_MSGTYPE_DATA_TRANSFER_REQUEST, "Data transfer req"}, + { LWAPP_MSGTYPE_DATA_TRANSFER_RESPONSE, "Data transfer resp"}, + { LWAPP_MSGTYPE_CLEAR_CONFIG_INDICATION, "Clear config ind"}, + { LWAPP_MSGTYPE_WLAN_CONFIG_REQUEST, "Wlan config req"}, + { LWAPP_MSGTYPE_WLAN_CONFIG_RESPONSE, "Wlan config resp"}, + { LWAPP_MSGTYPE_MOBILE_CONFIG_REQUEST, "Mobile config req"}, + { LWAPP_MSGTYPE_MOBILE_CONFIG_RESPONSE, "Mobile config resp"}, + { 0, NULL} +}; + +/* + * LWAPP message elements + * + * 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 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Type | Length | Value ... | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ +struct lwapp_message_header { + u_int8_t type; + u_int8_t length[2]; +}; + +void +lwapp_control_print(const u_char *pptr, u_int len, int has_ap_ident) { + + const struct lwapp_transport_header *lwapp_trans_header; + const struct lwapp_control_header *lwapp_control_header; + const u_char *tptr; + int tlen; + int msg_tlen; + + tptr=pptr; + + if (has_ap_ident) { + /* check if enough bytes for AP identity */ + if (!TTEST2(*tptr, 6)) + goto trunc; + lwapp_trans_header = (const struct lwapp_transport_header *)(pptr+6); + } else { + lwapp_trans_header = (const struct lwapp_transport_header *)pptr; + } + TCHECK(*lwapp_trans_header); + + /* + * Sanity checking of the header. + */ + if (LWAPP_EXTRACT_VERSION(lwapp_trans_header->version) != LWAPP_VERSION) { + printf("LWAPP version %u packet not supported", + LWAPP_EXTRACT_VERSION(lwapp_trans_header->version)); + return; + } + + /* non-verbose */ + if (vflag < 1) { + printf("LWAPPv%u, %s frame, Flags [%s], length %u", + LWAPP_EXTRACT_VERSION(lwapp_trans_header->version), + LWAPP_EXTRACT_CONTROL_BIT(lwapp_trans_header->version) ? "Control" : "Data", + bittok2str(lwapp_header_bits_values,"none",(lwapp_trans_header->version)&0x07), + len); + return; + } + + /* ok they seem to want to know everything - lets fully decode it */ + tlen=EXTRACT_16BITS(lwapp_trans_header->length); + + printf("LWAPPv%u, %s frame, Radio-id %u, Flags [%s], Frag-id %u, length %u", + LWAPP_EXTRACT_VERSION(lwapp_trans_header->version), + LWAPP_EXTRACT_CONTROL_BIT(lwapp_trans_header->version) ? "Control" : "Data", + LWAPP_EXTRACT_RID(lwapp_trans_header->version), + bittok2str(lwapp_header_bits_values,"none",(lwapp_trans_header->version)&0x07), + lwapp_trans_header->frag_id, + tlen); + + if (has_ap_ident) { + printf("\n\tAP identity: %s", + etheraddr_string(tptr)); + tptr+=sizeof(const struct lwapp_transport_header)+6; + } else { + tptr+=sizeof(const struct lwapp_transport_header); + } + + while(tlen>0) { + + /* did we capture enough for fully decoding the object header ? */ + if (!TTEST2(*tptr, sizeof(struct lwapp_control_header))) + goto trunc; + + lwapp_control_header = (const struct lwapp_control_header *)tptr; + msg_tlen = EXTRACT_16BITS(lwapp_control_header->len); + + /* print message header */ + printf("\n\t Msg type: %s (%u), Seqnum: %u, Msg len: %d, Session: 0x%08x", + tok2str(lwapp_msg_type_values,"Unknown",lwapp_control_header->msg_type), + lwapp_control_header->msg_type, + lwapp_control_header->seq_num, + msg_tlen, + EXTRACT_32BITS(lwapp_control_header->session_id)); + + /* did we capture enough for fully decoding the message */ + if (!TTEST2(*tptr, msg_tlen)) + goto trunc; + + /* XXX - Decode sub messages for each message */ + switch(lwapp_control_header->msg_type) { + case LWAPP_MSGTYPE_DISCOVERY_REQUEST: + case LWAPP_MSGTYPE_DISCOVERY_RESPONSE: + case LWAPP_MSGTYPE_JOIN_REQUEST: + case LWAPP_MSGTYPE_JOIN_RESPONSE: + case LWAPP_MSGTYPE_JOIN_ACK: + case LWAPP_MSGTYPE_JOIN_CONFIRM: + case LWAPP_MSGTYPE_CONFIGURE_REQUEST: + case LWAPP_MSGTYPE_CONFIGURE_RESPONSE: + case LWAPP_MSGTYPE_CONF_UPDATE_REQUEST: + case LWAPP_MSGTYPE_CONF_UPDATE_RESPONSE: + case LWAPP_MSGTYPE_WTP_EVENT_REQUEST: + case LWAPP_MSGTYPE_WTP_EVENT_RESPONSE: + case LWAPP_MSGTYPE_CHANGE_STATE_EVENT_REQUEST: + case LWAPP_MSGTYPE_CHANGE_STATE_EVENT_RESPONSE: + case LWAPP_MSGTYPE_ECHO_REQUEST: + case LWAPP_MSGTYPE_ECHO_RESPONSE: + case LWAPP_MSGTYPE_IMAGE_DATA_REQUEST: + case LWAPP_MSGTYPE_IMAGE_DATA_RESPONSE: + case LWAPP_MSGTYPE_RESET_REQUEST: + case LWAPP_MSGTYPE_RESET_RESPONSE: + case LWAPP_MSGTYPE_KEY_UPDATE_REQUEST: + case LWAPP_MSGTYPE_KEY_UPDATE_RESPONSE: + case LWAPP_MSGTYPE_PRIMARY_DISCOVERY_REQUEST: + case LWAPP_MSGTYPE_PRIMARY_DISCOVERY_RESPONSE: + case LWAPP_MSGTYPE_DATA_TRANSFER_REQUEST: + case LWAPP_MSGTYPE_DATA_TRANSFER_RESPONSE: + case LWAPP_MSGTYPE_CLEAR_CONFIG_INDICATION: + case LWAPP_MSGTYPE_WLAN_CONFIG_REQUEST: + case LWAPP_MSGTYPE_WLAN_CONFIG_RESPONSE: + case LWAPP_MSGTYPE_MOBILE_CONFIG_REQUEST: + case LWAPP_MSGTYPE_MOBILE_CONFIG_RESPONSE: + default: + break; + } + + tptr += sizeof(struct lwapp_control_header) + msg_tlen; + tlen -= sizeof(struct lwapp_control_header) + msg_tlen; + } + return; + + trunc: + printf("\n\t\t packet exceeded snapshot"); +} + +void +lwapp_data_print(const u_char *pptr, u_int len) { + + const struct lwapp_transport_header *lwapp_trans_header; + const u_char *tptr; + int tlen; + + tptr=pptr; + + /* check if enough bytes for AP identity */ + if (!TTEST2(*tptr, 6)) + goto trunc; + lwapp_trans_header = (const struct lwapp_transport_header *)pptr; + TCHECK(*lwapp_trans_header); + + /* + * Sanity checking of the header. + */ + if (LWAPP_EXTRACT_VERSION(lwapp_trans_header->version) != LWAPP_VERSION) { + printf("LWAPP version %u packet not supported", + LWAPP_EXTRACT_VERSION(lwapp_trans_header->version)); + return; + } + + /* non-verbose */ + if (vflag < 1) { + printf("LWAPPv%u, %s frame, Flags [%s], length %u", + LWAPP_EXTRACT_VERSION(lwapp_trans_header->version), + LWAPP_EXTRACT_CONTROL_BIT(lwapp_trans_header->version) ? "Control" : "Data", + bittok2str(lwapp_header_bits_values,"none",(lwapp_trans_header->version)&0x07), + len); + return; + } + + /* ok they seem to want to know everything - lets fully decode it */ + tlen=EXTRACT_16BITS(lwapp_trans_header->length); + + printf("LWAPPv%u, %s frame, Radio-id %u, Flags [%s], Frag-id %u, length %u", + LWAPP_EXTRACT_VERSION(lwapp_trans_header->version), + LWAPP_EXTRACT_CONTROL_BIT(lwapp_trans_header->version) ? "Control" : "Data", + LWAPP_EXTRACT_RID(lwapp_trans_header->version), + bittok2str(lwapp_header_bits_values,"none",(lwapp_trans_header->version)&0x07), + lwapp_trans_header->frag_id, + tlen); + + tptr+=sizeof(const struct lwapp_transport_header); + tlen-=sizeof(const struct lwapp_transport_header); + + /* FIX - An IEEE 802.11 frame follows - hexdump for now */ + print_unknown_data(tptr, "\n\t", tlen); + + return; + + trunc: + printf("\n\t\t packet exceeded snapshot"); +} + +/* + * Local Variables: + * c-style: whitesmith + * c-basic-offset: 8 + * End: + */
diff --git a/tcpdump-4.3.0/print-lwres.c b/tcpdump-4.3.0/print-lwres.c new file mode 100644 index 0000000..aad4eee --- /dev/null +++ b/tcpdump-4.3.0/print-lwres.c
@@ -0,0 +1,601 @@ +/* + * Copyright (C) 2001 WIDE Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-lwres.c,v 1.13 2004-03-24 01:54:29 guy Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include "nameser.h" + +#include <stdio.h> +#include <string.h> + +#include "interface.h" +#include "addrtoname.h" +#include "extract.h" /* must come after interface.h */ + +/* BIND9 lib/lwres/include/lwres */ +typedef u_int32_t lwres_uint32_t; +typedef u_int16_t lwres_uint16_t; +typedef u_int8_t lwres_uint8_t; + +struct lwres_lwpacket { + lwres_uint32_t length; + lwres_uint16_t version; + lwres_uint16_t pktflags; + lwres_uint32_t serial; + lwres_uint32_t opcode; + lwres_uint32_t result; + lwres_uint32_t recvlength; + lwres_uint16_t authtype; + lwres_uint16_t authlength; +}; + +#define LWRES_LWPACKETFLAG_RESPONSE 0x0001U /* if set, pkt is a response */ + +#define LWRES_LWPACKETVERSION_0 0 + +#define LWRES_FLAG_TRUSTNOTREQUIRED 0x00000001U +#define LWRES_FLAG_SECUREDATA 0x00000002U + +/* + * no-op + */ +#define LWRES_OPCODE_NOOP 0x00000000U + +typedef struct { + /* public */ + lwres_uint16_t datalength; + /* data follows */ +} lwres_nooprequest_t; + +typedef struct { + /* public */ + lwres_uint16_t datalength; + /* data follows */ +} lwres_noopresponse_t; + +/* + * get addresses by name + */ +#define LWRES_OPCODE_GETADDRSBYNAME 0x00010001U + +typedef struct lwres_addr lwres_addr_t; + +struct lwres_addr { + lwres_uint32_t family; + lwres_uint16_t length; + /* address folows */ +}; + +typedef struct { + /* public */ + lwres_uint32_t flags; + lwres_uint32_t addrtypes; + lwres_uint16_t namelen; + /* name follows */ +} lwres_gabnrequest_t; + +typedef struct { + /* public */ + lwres_uint32_t flags; + lwres_uint16_t naliases; + lwres_uint16_t naddrs; + lwres_uint16_t realnamelen; + /* aliases follows */ + /* addrs follows */ + /* realname follows */ +} lwres_gabnresponse_t; + +/* + * get name by address + */ +#define LWRES_OPCODE_GETNAMEBYADDR 0x00010002U +typedef struct { + /* public */ + lwres_uint32_t flags; + lwres_addr_t addr; + /* addr body follows */ +} lwres_gnbarequest_t; + +typedef struct { + /* public */ + lwres_uint32_t flags; + lwres_uint16_t naliases; + lwres_uint16_t realnamelen; + /* aliases follows */ + /* realname follows */ +} lwres_gnbaresponse_t; + +/* + * get rdata by name + */ +#define LWRES_OPCODE_GETRDATABYNAME 0x00010003U + +typedef struct { + /* public */ + lwres_uint32_t flags; + lwres_uint16_t rdclass; + lwres_uint16_t rdtype; + lwres_uint16_t namelen; + /* name follows */ +} lwres_grbnrequest_t; + +typedef struct { + /* public */ + lwres_uint32_t flags; + lwres_uint16_t rdclass; + lwres_uint16_t rdtype; + lwres_uint32_t ttl; + lwres_uint16_t nrdatas; + lwres_uint16_t nsigs; + /* realname here (len + name) */ + /* rdata here (len + name) */ + /* signatures here (len + name) */ +} lwres_grbnresponse_t; + +#define LWRDATA_VALIDATED 0x00000001 + +#define LWRES_ADDRTYPE_V4 0x00000001U /* ipv4 */ +#define LWRES_ADDRTYPE_V6 0x00000002U /* ipv6 */ + +#define LWRES_MAX_ALIASES 16 /* max # of aliases */ +#define LWRES_MAX_ADDRS 64 /* max # of addrs */ + +struct tok opcode[] = { + { LWRES_OPCODE_NOOP, "noop", }, + { LWRES_OPCODE_GETADDRSBYNAME, "getaddrsbyname", }, + { LWRES_OPCODE_GETNAMEBYADDR, "getnamebyaddr", }, + { LWRES_OPCODE_GETRDATABYNAME, "getrdatabyname", }, + { 0, NULL, }, +}; + +/* print-domain.c */ +extern struct tok ns_type2str[]; +extern struct tok ns_class2str[]; + +static int lwres_printname(size_t, const char *); +static int lwres_printnamelen(const char *); +static int lwres_printbinlen(const char *); +static int lwres_printaddr(lwres_addr_t *); + +static int +lwres_printname(size_t l, const char *p0) +{ + const char *p; + size_t i; + + p = p0; + /* + 1 for terminating \0 */ + if (p + l + 1 > (const char *)snapend) + goto trunc; + + printf(" "); + for (i = 0; i < l; i++) + safeputchar(*p++); + p++; /* skip terminating \0 */ + + return p - p0; + + trunc: + return -1; +} + +static int +lwres_printnamelen(const char *p) +{ + u_int16_t l; + int advance; + + if (p + 2 > (const char *)snapend) + goto trunc; + l = EXTRACT_16BITS(p); + advance = lwres_printname(l, p + 2); + if (advance < 0) + goto trunc; + return 2 + advance; + + trunc: + return -1; +} + +static int +lwres_printbinlen(const char *p0) +{ + const char *p; + u_int16_t l; + int i; + + p = p0; + if (p + 2 > (const char *)snapend) + goto trunc; + l = EXTRACT_16BITS(p); + if (p + 2 + l > (const char *)snapend) + goto trunc; + p += 2; + for (i = 0; i < l; i++) + printf("%02x", *p++); + return p - p0; + + trunc: + return -1; +} + +static int +lwres_printaddr(lwres_addr_t *ap) +{ + u_int16_t l; + const char *p; + int i; + + TCHECK(ap->length); + l = EXTRACT_16BITS(&ap->length); + /* XXX ap points to packed struct */ + p = (const char *)&ap->length + sizeof(ap->length); + TCHECK2(*p, l); + + 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(" %u/", EXTRACT_32BITS(&ap->family)); + for (i = 0; i < l; i++) + printf("%02x", *p++); + } + + return p - (const char *)ap; + + trunc: + return -1; +} + +void +lwres_print(register const u_char *bp, u_int length) +{ + const struct lwres_lwpacket *np; + u_int32_t v; + const char *s; + int response; + int advance; + int unsupported = 0; + + np = (const struct lwres_lwpacket *)bp; + TCHECK(np->authlength); + + printf(" lwres"); + v = EXTRACT_16BITS(&np->version); + if (vflag || v != LWRES_LWPACKETVERSION_0) + printf(" v%u", v); + if (v != LWRES_LWPACKETVERSION_0) { + s = (const char *)np + EXTRACT_32BITS(&np->length); + goto tail; + } + + response = EXTRACT_16BITS(&np->pktflags) & LWRES_LWPACKETFLAG_RESPONSE; + + /* opcode and pktflags */ + v = EXTRACT_32BITS(&np->opcode); + s = tok2str(opcode, "#0x%x", v); + printf(" %s%s", s, response ? "" : "?"); + + /* pktflags */ + v = EXTRACT_16BITS(&np->pktflags); + if (v & ~LWRES_LWPACKETFLAG_RESPONSE) + printf("[0x%x]", v); + + if (vflag > 1) { + printf(" ("); /*)*/ + 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", EXTRACT_16BITS(&np->authtype)); + printf(" authlen:%u", EXTRACT_16BITS(&np->authlength)); + } + /*(*/ + printf(")"); + } + + /* per-opcode content */ + if (!response) { + /* + * queries + */ + lwres_gabnrequest_t *gabn; + lwres_gnbarequest_t *gnba; + lwres_grbnrequest_t *grbn; + u_int32_t l; + + gabn = NULL; + gnba = NULL; + grbn = NULL; + + switch (EXTRACT_32BITS(&np->opcode)) { + case LWRES_OPCODE_NOOP: + break; + case LWRES_OPCODE_GETADDRSBYNAME: + gabn = (lwres_gabnrequest_t *)(np + 1); + TCHECK(gabn->namelen); + /* XXX gabn points to packed struct */ + s = (const char *)&gabn->namelen + + sizeof(gabn->namelen); + l = EXTRACT_16BITS(&gabn->namelen); + + /* BIND910: not used */ + if (vflag > 2) { + printf(" flags:0x%x", + EXTRACT_32BITS(&gabn->flags)); + } + + v = EXTRACT_32BITS(&gabn->addrtypes); + switch (v & (LWRES_ADDRTYPE_V4 | LWRES_ADDRTYPE_V6)) { + case LWRES_ADDRTYPE_V4: + printf(" IPv4"); + break; + case LWRES_ADDRTYPE_V6: + printf(" IPv6"); + break; + case LWRES_ADDRTYPE_V4 | LWRES_ADDRTYPE_V6: + printf(" IPv4/6"); + break; + } + if (v & ~(LWRES_ADDRTYPE_V4 | LWRES_ADDRTYPE_V6)) + printf("[0x%x]", v); + + advance = lwres_printname(l, s); + if (advance < 0) + goto trunc; + s += advance; + break; + case LWRES_OPCODE_GETNAMEBYADDR: + gnba = (lwres_gnbarequest_t *)(np + 1); + TCHECK(gnba->addr); + + /* BIND910: not used */ + if (vflag > 2) { + printf(" flags:0x%x", + EXTRACT_32BITS(&gnba->flags)); + } + + s = (const char *)&gnba->addr; + + advance = lwres_printaddr(&gnba->addr); + if (advance < 0) + goto trunc; + s += advance; + break; + case LWRES_OPCODE_GETRDATABYNAME: + /* XXX no trace, not tested */ + grbn = (lwres_grbnrequest_t *)(np + 1); + TCHECK(grbn->namelen); + + /* BIND910: not used */ + if (vflag > 2) { + printf(" flags:0x%x", + EXTRACT_32BITS(&grbn->flags)); + } + + printf(" %s", tok2str(ns_type2str, "Type%d", + EXTRACT_16BITS(&grbn->rdtype))); + if (EXTRACT_16BITS(&grbn->rdclass) != C_IN) { + printf(" %s", tok2str(ns_class2str, "Class%d", + EXTRACT_16BITS(&grbn->rdclass))); + } + + /* XXX grbn points to packed struct */ + s = (const char *)&grbn->namelen + + sizeof(grbn->namelen); + l = EXTRACT_16BITS(&grbn->namelen); + + advance = lwres_printname(l, s); + if (advance < 0) + goto trunc; + s += advance; + break; + default: + unsupported++; + break; + } + } else { + /* + * responses + */ + lwres_gabnresponse_t *gabn; + lwres_gnbaresponse_t *gnba; + lwres_grbnresponse_t *grbn; + u_int32_t l, na; + u_int32_t i; + + gabn = NULL; + gnba = NULL; + grbn = NULL; + + switch (EXTRACT_32BITS(&np->opcode)) { + case LWRES_OPCODE_NOOP: + break; + case LWRES_OPCODE_GETADDRSBYNAME: + gabn = (lwres_gabnresponse_t *)(np + 1); + TCHECK(gabn->realnamelen); + /* XXX gabn points to packed struct */ + s = (const char *)&gabn->realnamelen + + sizeof(gabn->realnamelen); + l = EXTRACT_16BITS(&gabn->realnamelen); + + /* BIND910: not used */ + if (vflag > 2) { + printf(" flags:0x%x", + EXTRACT_32BITS(&gabn->flags)); + } + + printf(" %u/%u", EXTRACT_16BITS(&gabn->naliases), + EXTRACT_16BITS(&gabn->naddrs)); + + advance = lwres_printname(l, s); + if (advance < 0) + goto trunc; + s += advance; + + /* aliases */ + na = EXTRACT_16BITS(&gabn->naliases); + for (i = 0; i < na; i++) { + advance = lwres_printnamelen(s); + if (advance < 0) + goto trunc; + s += advance; + } + + /* addrs */ + na = EXTRACT_16BITS(&gabn->naddrs); + for (i = 0; i < na; i++) { + advance = lwres_printaddr((lwres_addr_t *)s); + if (advance < 0) + goto trunc; + s += advance; + } + break; + case LWRES_OPCODE_GETNAMEBYADDR: + gnba = (lwres_gnbaresponse_t *)(np + 1); + TCHECK(gnba->realnamelen); + /* XXX gnba points to packed struct */ + s = (const char *)&gnba->realnamelen + + sizeof(gnba->realnamelen); + l = EXTRACT_16BITS(&gnba->realnamelen); + + /* BIND910: not used */ + if (vflag > 2) { + printf(" flags:0x%x", + EXTRACT_32BITS(&gnba->flags)); + } + + printf(" %u", EXTRACT_16BITS(&gnba->naliases)); + + advance = lwres_printname(l, s); + if (advance < 0) + goto trunc; + s += advance; + + /* aliases */ + na = EXTRACT_16BITS(&gnba->naliases); + for (i = 0; i < na; i++) { + advance = lwres_printnamelen(s); + if (advance < 0) + goto trunc; + s += advance; + } + break; + case LWRES_OPCODE_GETRDATABYNAME: + /* XXX no trace, not tested */ + grbn = (lwres_grbnresponse_t *)(np + 1); + TCHECK(grbn->nsigs); + + /* BIND910: not used */ + if (vflag > 2) { + printf(" flags:0x%x", + EXTRACT_32BITS(&grbn->flags)); + } + + printf(" %s", tok2str(ns_type2str, "Type%d", + EXTRACT_16BITS(&grbn->rdtype))); + if (EXTRACT_16BITS(&grbn->rdclass) != C_IN) { + printf(" %s", tok2str(ns_class2str, "Class%d", + EXTRACT_16BITS(&grbn->rdclass))); + } + printf(" TTL "); + 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); + + advance = lwres_printnamelen(s); + if (advance < 0) + goto trunc; + s += advance; + + /* rdatas */ + na = EXTRACT_16BITS(&grbn->nrdatas); + for (i = 0; i < na; i++) { + /* XXX should decode resource data */ + advance = lwres_printbinlen(s); + if (advance < 0) + goto trunc; + s += advance; + } + + /* sigs */ + na = EXTRACT_16BITS(&grbn->nsigs); + for (i = 0; i < na; i++) { + /* XXX how should we print it? */ + advance = lwres_printbinlen(s); + if (advance < 0) + goto trunc; + s += advance; + } + break; + default: + unsupported++; + break; + } + } + + tail: + /* length mismatch */ + if (EXTRACT_32BITS(&np->length) != length) { + printf(" [len: %u != %u]", EXTRACT_32BITS(&np->length), + length); + } + if (!unsupported && s < (const char *)np + EXTRACT_32BITS(&np->length)) + printf("[extra]"); + return; + + trunc: + printf("[|lwres]"); + return; +}
diff --git a/tcpdump-4.3.0/print-mobile.c b/tcpdump-4.3.0/print-mobile.c new file mode 100644 index 0000000..de4eab1 --- /dev/null +++ b/tcpdump-4.3.0/print-mobile.c
@@ -0,0 +1,112 @@ +/* $NetBSD: print-mobile.c,v 1.2 1998/09/30 08:57:01 hwr Exp $ */ + +/* + * (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Heiko W.Rupp <hwr@pilhuhn.de> + * + * 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 NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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-mobile.c,v 1.15 2004-03-24 01:58:14 guy Exp $"; +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> + +#include "interface.h" +#include "addrtoname.h" +#include "extract.h" /* must come after interface.h */ + +#define MOBILE_SIZE (8) + +struct mobile_ip { + u_int16_t proto; + u_int16_t hcheck; + u_int32_t odst; + u_int32_t osrc; +}; + +#define OSRC_PRES 0x0080 /* old source is present */ + +/* + * Deencapsulate and print a mobile-tunneled IP datagram + */ +void +mobile_print(const u_char *bp, u_int length) +{ + const u_char *cp = bp +8 ; + const struct mobile_ip *mob; + struct cksum_vec vec[1]; + u_short proto,crc; + u_char osp =0; /* old source address present */ + + mob = (const struct mobile_ip *)bp; + + if (length < MOBILE_SIZE || !TTEST(*mob)) { + fputs("[|mobile]", stdout); + return; + } + fputs("mobile: ", stdout); + + proto = EXTRACT_16BITS(&mob->proto); + crc = EXTRACT_16BITS(&mob->hcheck); + if (proto & OSRC_PRES) { + osp=1; + cp +=4 ; + } + + if (osp) { + fputs("[S] ",stdout); + if (vflag) + (void)printf("%s ",ipaddr_string(&mob->osrc)); + } else { + fputs("[] ",stdout); + } + if (vflag) { + (void)printf("> %s ",ipaddr_string(&mob->odst)); + (void)printf("(oproto=%d)",proto>>8); + } + vec[0].ptr = (const u_int8_t *)(void *)mob; + vec[0].len = osp ? 12 : 8; + if (in_cksum(vec, 1)!=0) { + (void)printf(" (bad checksum %d)",crc); + } + + return; +}
diff --git a/tcpdump-4.3.0/print-mobility.c b/tcpdump-4.3.0/print-mobility.c new file mode 100644 index 0000000..1490b72 --- /dev/null +++ b/tcpdump-4.3.0/print-mobility.c
@@ -0,0 +1,312 @@ +/* + * 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.12 2005-04-20 22:21:00 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 _U_) +{ + const struct ip6_mobility *mh; + const u_char *ep; + int mhlen, hlen, type; + + mh = (struct ip6_mobility *)bp; + + /* '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/tcpdump-4.3.0/print-mpcp.c b/tcpdump-4.3.0/print-mpcp.c new file mode 100644 index 0000000..244f280 --- /dev/null +++ b/tcpdump-4.3.0/print-mpcp.c
@@ -0,0 +1,274 @@ +/* + * Copyright (c) 1998-2006 The TCPDUMP project + * + * 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. + * + * support for the IEEE MPCP protocol as per 802.3ah + * + * Original code by Hannes Gredler (hannes@juniper.net) + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-mpcp.c,v 1.2 2006-02-10 17:24:55 hannes 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 "ether.h" + +#define MPCP_TIMESTAMP_LEN 4 +#define MPCP_TIMESTAMP_DURATION_LEN 2 + +struct mpcp_common_header_t { + u_int8_t opcode[2]; + u_int8_t timestamp[MPCP_TIMESTAMP_LEN]; +}; + +#define MPCP_OPCODE_PAUSE 0x0001 +#define MPCP_OPCODE_GATE 0x0002 +#define MPCP_OPCODE_REPORT 0x0003 +#define MPCP_OPCODE_REG_REQ 0x0004 +#define MPCP_OPCODE_REG 0x0005 +#define MPCP_OPCODE_REG_ACK 0x0006 + +static const struct tok mpcp_opcode_values[] = { + { MPCP_OPCODE_PAUSE, "Pause" }, + { MPCP_OPCODE_GATE, "Gate" }, + { MPCP_OPCODE_REPORT, "Report" }, + { MPCP_OPCODE_REG_REQ, "Register Request" }, + { MPCP_OPCODE_REG, "Register" }, + { MPCP_OPCODE_REG_ACK, "Register ACK" }, + { 0, NULL} +}; + +#define MPCP_GRANT_NUMBER_LEN 1 +#define MPCP_GRANT_NUMBER_MASK 0x7 +static const struct tok mpcp_grant_flag_values[] = { + { 0x08, "Discovery" }, + { 0x10, "Force Grant #1" }, + { 0x20, "Force Grant #2" }, + { 0x40, "Force Grant #3" }, + { 0x80, "Force Grant #4" }, + { 0, NULL} +}; + +struct mpcp_grant_t { + u_int8_t starttime[MPCP_TIMESTAMP_LEN]; + u_int8_t duration[MPCP_TIMESTAMP_DURATION_LEN]; +}; + +struct mpcp_reg_req_t { + u_int8_t flags; + u_int8_t pending_grants; +}; + + +static const struct tok mpcp_reg_req_flag_values[] = { + { 1, "Register" }, + { 3, "De-Register" }, + { 0, NULL} +}; + +struct mpcp_reg_t { + u_int8_t assigned_port[2]; + u_int8_t flags; + u_int8_t sync_time[MPCP_TIMESTAMP_DURATION_LEN]; + u_int8_t echoed_pending_grants; +}; + +static const struct tok mpcp_reg_flag_values[] = { + { 1, "Re-Register" }, + { 2, "De-Register" }, + { 3, "ACK" }, + { 4, "NACK" }, + { 0, NULL} +}; + +#define MPCP_REPORT_QUEUESETS_LEN 1 +#define MPCP_REPORT_REPORTBITMAP_LEN 1 +static const struct tok mpcp_report_bitmap_values[] = { + { 0x01, "Q0" }, + { 0x02, "Q1" }, + { 0x04, "Q2" }, + { 0x08, "Q3" }, + { 0x10, "Q4" }, + { 0x20, "Q5" }, + { 0x40, "Q6" }, + { 0x80, "Q7" }, + { 0, NULL} +}; + +struct mpcp_reg_ack_t { + u_int8_t flags; + u_int8_t echoed_assigned_port[2]; + u_int8_t echoed_sync_time[MPCP_TIMESTAMP_DURATION_LEN]; +}; + +static const struct tok mpcp_reg_ack_flag_values[] = { + { 0, "NACK" }, + { 1, "ACK" }, + { 0, NULL} +}; + +void +mpcp_print(register const u_char *pptr, register u_int length) { + + union { + const struct mpcp_common_header_t *common_header; + const struct mpcp_grant_t *grant; + const struct mpcp_reg_req_t *reg_req; + const struct mpcp_reg_t *reg; + const struct mpcp_reg_ack_t *reg_ack; + } mpcp; + + + const u_char *tptr; + u_int16_t opcode; + u_int8_t grant_numbers, grant; + u_int8_t queue_sets, queue_set, report_bitmap, report; + + tptr=pptr; + mpcp.common_header = (const struct mpcp_common_header_t *)pptr; + + if (!TTEST2(*tptr, sizeof(const struct mpcp_common_header_t))) + goto trunc; + opcode = EXTRACT_16BITS(mpcp.common_header->opcode); + printf("MPCP, Opcode %s", tok2str(mpcp_opcode_values, "Unknown (%u)", opcode)); + if (opcode != MPCP_OPCODE_PAUSE) { + printf(", Timestamp %u ticks", EXTRACT_32BITS(mpcp.common_header->timestamp)); + } + printf(", length %u", length); + + if (!vflag) + return; + + tptr += sizeof(const struct mpcp_common_header_t); + + switch (opcode) { + case MPCP_OPCODE_PAUSE: + break; + + case MPCP_OPCODE_GATE: + if (!TTEST2(*tptr, MPCP_GRANT_NUMBER_LEN)) + goto trunc; + grant_numbers = *tptr & MPCP_GRANT_NUMBER_MASK; + printf("\n\tGrant Numbers %u, Flags [ %s ]", + grant_numbers, + bittok2str(mpcp_grant_flag_values, + "?", + *tptr &~ MPCP_GRANT_NUMBER_MASK)); + tptr++; + + for (grant = 1; grant <= grant_numbers; grant++) { + if (!TTEST2(*tptr, sizeof(const struct mpcp_grant_t))) + goto trunc; + mpcp.grant = (const struct mpcp_grant_t *)tptr; + printf("\n\tGrant #%u, Start-Time %u ticks, duration %u ticks", + grant, + EXTRACT_32BITS(mpcp.grant->starttime), + EXTRACT_16BITS(mpcp.grant->duration)); + tptr += sizeof(const struct mpcp_grant_t); + } + + if (!TTEST2(*tptr, MPCP_TIMESTAMP_DURATION_LEN)) + goto trunc; + printf("\n\tSync-Time %u ticks", EXTRACT_16BITS(tptr)); + break; + + + case MPCP_OPCODE_REPORT: + if (!TTEST2(*tptr, MPCP_REPORT_QUEUESETS_LEN)) + goto trunc; + queue_sets = *tptr; + tptr+=MPCP_REPORT_QUEUESETS_LEN; + printf("\n\tTotal Queue-Sets %u", queue_sets); + + for (queue_set = 1; queue_set < queue_sets; queue_set++) { + if (!TTEST2(*tptr, MPCP_REPORT_REPORTBITMAP_LEN)) + goto trunc; + report_bitmap = *(tptr); + printf("\n\t Queue-Set #%u, Report-Bitmap [ %s ]", + queue_sets, + bittok2str(mpcp_report_bitmap_values, "Unknown", report_bitmap)); + tptr++; + + report=1; + while (report_bitmap != 0) { + if (report_bitmap & 1) { + if (!TTEST2(*tptr, MPCP_TIMESTAMP_DURATION_LEN)) + goto trunc; + printf("\n\t Q%u Report, Duration %u ticks", + report, + EXTRACT_16BITS(tptr)); + tptr+=MPCP_TIMESTAMP_DURATION_LEN; + } + report++; + report_bitmap = report_bitmap >> 1; + } + } + break; + + case MPCP_OPCODE_REG_REQ: + if (!TTEST2(*tptr, sizeof(const struct mpcp_reg_req_t))) + goto trunc; + mpcp.reg_req = (const struct mpcp_reg_req_t *)tptr; + printf("\n\tFlags [ %s ], Pending-Grants %u", + bittok2str(mpcp_reg_req_flag_values, "Reserved", mpcp.reg_req->flags), + mpcp.reg_req->pending_grants); + break; + + case MPCP_OPCODE_REG: + if (!TTEST2(*tptr, sizeof(const struct mpcp_reg_t))) + goto trunc; + mpcp.reg = (const struct mpcp_reg_t *)tptr; + printf("\n\tAssigned-Port %u, Flags [ %s ]" \ + "\n\tSync-Time %u ticks, Echoed-Pending-Grants %u", + EXTRACT_16BITS(mpcp.reg->assigned_port), + bittok2str(mpcp_reg_flag_values, "Reserved", mpcp.reg->flags), + EXTRACT_16BITS(mpcp.reg->sync_time), + mpcp.reg->echoed_pending_grants); + break; + + case MPCP_OPCODE_REG_ACK: + if (!TTEST2(*tptr, sizeof(const struct mpcp_reg_ack_t))) + goto trunc; + mpcp.reg_ack = (const struct mpcp_reg_ack_t *)tptr; + printf("\n\tEchoed-Assigned-Port %u, Flags [ %s ]" \ + "\n\tEchoed-Sync-Time %u ticks", + EXTRACT_16BITS(mpcp.reg_ack->echoed_assigned_port), + bittok2str(mpcp_reg_ack_flag_values, "Reserved", mpcp.reg_ack->flags), + EXTRACT_16BITS(mpcp.reg_ack->echoed_sync_time)); + break; + + default: + /* unknown opcode - hexdump for now */ + print_unknown_data(pptr, "\n\t", length); + break; + } + + return; + +trunc: + printf("\n\t[|MPCP]"); +}
diff --git a/tcpdump-4.3.0/print-mpls.c b/tcpdump-4.3.0/print-mpls.c new file mode 100644 index 0000000..d97cce5 --- /dev/null +++ b/tcpdump-4.3.0/print-mpls.c
@@ -0,0 +1,227 @@ +/* + * Copyright (C) 2001 WIDE Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-mpls.c,v 1.14 2005-07-05 09:38:19 hannes Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "addrtoname.h" +#include "interface.h" +#include "extract.h" /* must come after interface.h */ +#include "mpls.h" + +static const char *mpls_labelname[] = { +/*0*/ "IPv4 explicit NULL", "router alert", "IPv6 explicit NULL", + "implicit NULL", "rsvd", +/*5*/ "rsvd", "rsvd", "rsvd", "rsvd", "rsvd", +/*10*/ "rsvd", "rsvd", "rsvd", "rsvd", "rsvd", +/*15*/ "rsvd", +}; + +enum mpls_packet_type { + PT_UNKNOWN, + PT_IPV4, + PT_IPV6, + PT_OSI +}; + +/* + * RFC3032: MPLS label stack encoding + */ +void +mpls_print(const u_char *bp, u_int length) +{ + const u_char *p; + u_int32_t label_entry; + u_int16_t label_stack_depth = 0; + enum mpls_packet_type pt = PT_UNKNOWN; + + p = bp; + printf("MPLS"); + do { + TCHECK2(*p, sizeof(label_entry)); + label_entry = EXTRACT_32BITS(p); + printf("%s(label %u", + (label_stack_depth && vflag) ? "\n\t" : " ", + MPLS_LABEL(label_entry)); + label_stack_depth++; + if (vflag && + MPLS_LABEL(label_entry) < sizeof(mpls_labelname) / sizeof(mpls_labelname[0])) + printf(" (%s)", mpls_labelname[MPLS_LABEL(label_entry)]); + printf(", exp %u", MPLS_EXP(label_entry)); + if (MPLS_STACK(label_entry)) + printf(", [S]"); + printf(", ttl %u)", MPLS_TTL(label_entry)); + + p += sizeof(label_entry); + } while (!MPLS_STACK(label_entry)); + + /* + * Try to figure out the packet type. + */ + switch (MPLS_LABEL(label_entry)) { + + case 0: /* IPv4 explicit NULL label */ + case 3: /* IPv4 implicit NULL label */ + pt = PT_IPV4; + break; + + case 2: /* IPv6 explicit NULL label */ + pt = PT_IPV6; + break; + + default: + /* + * Generally there's no indication of protocol in MPLS label + * encoding. + * + * However, draft-hsmit-isis-aal5mux-00.txt describes a + * technique for encapsulating IS-IS and IP traffic on the + * same ATM virtual circuit; you look at the first payload + * byte to determine the network layer protocol, based on + * the fact that + * + * 1) the first byte of an IP header is 0x45-0x4f + * for IPv4 and 0x60-0x6f for IPv6; + * + * 2) the first byte of an OSI CLNP packet is 0x81, + * the first byte of an OSI ES-IS packet is 0x82, + * and the first byte of an OSI IS-IS packet is + * 0x83; + * + * so the network layer protocol can be inferred from the + * first byte of the packet, if the protocol is one of the + * ones listed above. + * + * Cisco sends control-plane traffic MPLS-encapsulated in + * this fashion. + */ + switch(*p) { + + case 0x45: + case 0x46: + case 0x47: + case 0x48: + case 0x49: + case 0x4a: + case 0x4b: + case 0x4c: + case 0x4d: + case 0x4e: + case 0x4f: + pt = PT_IPV4; + break; + + 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: + pt = PT_IPV6; + break; + + case 0x81: + case 0x82: + case 0x83: + pt = PT_OSI; + break; + + default: + /* ok bail out - we did not figure out what it is*/ + break; + } + } + + /* + * Print the payload. + */ + if (pt == PT_UNKNOWN) { + if (!suppress_default_print) + default_print(p, length - (p - bp)); + return; + } + if (vflag) + printf("\n\t"); + else + printf(" "); + switch (pt) { + + case PT_IPV4: + ip_print(gndo, p, length - (p - bp)); + break; + + case PT_IPV6: +#ifdef INET6 + ip6_print(gndo, p, length - (p - bp)); +#else + printf("IPv6, length: %u", length); +#endif + break; + + case PT_OSI: + isoclns_print(p, length - (p - bp), length - (p - bp)); + break; + + default: + break; + } + return; + +trunc: + printf("[|MPLS]"); +} + + +/* + * Local Variables: + * c-style: whitesmith + * c-basic-offset: 8 + * End: + */
diff --git a/tcpdump-4.3.0/print-msdp.c b/tcpdump-4.3.0/print-msdp.c new file mode 100644 index 0000000..a228ab7 --- /dev/null +++ b/tcpdump-4.3.0/print-msdp.c
@@ -0,0 +1,108 @@ +/* + * Copyright (c) 2001 William C. Fenner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code + * distributions retain the above copyright notice and this paragraph + * in its entirety, and (2) distributions including binary code include + * the above copyright notice and this paragraph in its entirety in + * the documentation or other materials provided with the distribution. + * The name of William C. Fenner may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. THIS SOFTWARE IS PROVIDED ``AS IS'' AND + * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT + * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + */ +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-msdp.c,v 1.7 2005-04-06 21:32:41 mcr Exp $"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> +#include <stdlib.h> + +#include "interface.h" +#include "addrtoname.h" +#include "extract.h" + +#define MSDP_TYPE_MAX 7 + +void +msdp_print(const unsigned char *sp, u_int length) +{ + unsigned int type, len; + + TCHECK2(*sp, 3); + /* See if we think we're at the beginning of a compound packet */ + type = *sp; + len = EXTRACT_16BITS(sp + 1); + if (len > 1500 || len < 3 || type == 0 || type > MSDP_TYPE_MAX) + goto trunc; /* not really truncated, but still not decodable */ + (void)printf(" msdp:"); + while (length > 0) { + TCHECK2(*sp, 3); + type = *sp; + len = EXTRACT_16BITS(sp + 1); + if (len > 1400 || vflag) + printf(" [len %u]", len); + if (len < 3) + goto trunc; + sp += 3; + length -= 3; + switch (type) { + case 1: /* IPv4 Source-Active */ + case 3: /* IPv4 Source-Active Response */ + if (type == 1) + (void)printf(" SA"); + else + (void)printf(" SA-Response"); + TCHECK(*sp); + (void)printf(" %u entries", *sp); + if ((u_int)((*sp * 12) + 8) < len) { + (void)printf(" [w/data]"); + if (vflag > 1) { + (void)printf(" "); + ip_print(gndo, sp + *sp * 12 + 8 - 3, + len - (*sp * 12 + 8)); + } + } + break; + case 2: + (void)printf(" SA-Request"); + TCHECK2(*sp, 5); + (void)printf(" for %s", ipaddr_string(sp + 1)); + break; + case 4: + (void)printf(" Keepalive"); + if (len != 3) + (void)printf("[len=%d] ", len); + break; + case 5: + (void)printf(" Notification"); + break; + default: + (void)printf(" [type=%d len=%d]", type, len); + break; + } + sp += (len - 3); + length -= (len - 3); + } + return; +trunc: + (void)printf(" [|msdp]"); +} + +/* + * Local Variables: + * c-style: whitesmith + * c-basic-offset: 8 + * End: + */
diff --git a/tcpdump-4.3.0/print-netbios.c b/tcpdump-4.3.0/print-netbios.c new file mode 100644 index 0000000..c92eb9e --- /dev/null +++ b/tcpdump-4.3.0/print-netbios.c
@@ -0,0 +1,91 @@ +/* + * Copyright (c) 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. + * + * Format and print NETBIOS packets. + * Contributed by Brad Parker (brad@fcr.com). + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-netbios.c,v 1.20 2003-11-16 09:36:29 guy Exp $"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +#include "interface.h" +#include "addrtoname.h" +#include "netbios.h" +#include "extract.h" + +/* + * Print NETBIOS packets. + */ +void +netbios_print(struct p8022Hdr *nb, u_int length) +{ + if (length < p8022Size) { + (void)printf(" truncated-netbios %d", length); + return; + } + + if (nb->flags == UI) { + (void)printf("802.1 UI "); + } else { + (void)printf("802.1 CONN "); + } + + if ((u_char *)(nb + 1) > snapend) { + printf(" [|netbios]"); + return; + } + +/* + netbios_decode(nb, (u_char *)nb + p8022Size, length - p8022Size); +*/ +} + +#ifdef never + (void)printf("%s.%d > ", + ipxaddr_string(EXTRACT_32BITS(ipx->srcNet), ipx->srcNode), + EXTRACT_16BITS(ipx->srcSkt)); + + (void)printf("%s.%d:", + ipxaddr_string(EXTRACT_32BITS(ipx->dstNet), ipx->dstNode), + EXTRACT_16BITS(ipx->dstSkt)); + + if ((u_char *)(ipx + 1) > snapend) { + printf(" [|ipx]"); + return; + } + + /* take length from ipx header */ + length = EXTRACT_16BITS(&ipx->length); + + ipx_decode(ipx, (u_char *)ipx + ipxSize, length - ipxSize); +#endif +
diff --git a/tcpdump-4.3.0/print-nfs.c b/tcpdump-4.3.0/print-nfs.c new file mode 100644 index 0000000..4d17757 --- /dev/null +++ b/tcpdump-4.3.0/print-nfs.c
@@ -0,0 +1,1851 @@ +/* + * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-nfs.c,v 1.111 2007-12-22 03:08:04 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 "extract.h" + +#include "nfs.h" +#include "nfsfh.h" + +#include "ip.h" +#ifdef INET6 +#include "ip6.h" +#endif +#include "rpc_auth.h" +#include "rpc_msg.h" + +static void nfs_printfh(const u_int32_t *, const u_int); +static int xid_map_enter(const struct sunrpc_msg *, const u_char *); +static int32_t xid_map_find(const struct sunrpc_msg *, const u_char *, + u_int32_t *, u_int32_t *); +static void interp_reply(const struct sunrpc_msg *, u_int32_t, u_int32_t, int); +static const u_int32_t *parse_post_op_attr(const u_int32_t *, int); +static void print_sattr3(const struct nfsv3_sattr *sa3, int verbose); +static void print_nfsaddr(const u_char *, const char *, const char *); + +/* + * Mapping of old NFS Version 2 RPC numbers to generic numbers. + */ +u_int32_t nfsv3_procid[NFS_NPROCS] = { + NFSPROC_NULL, + NFSPROC_GETATTR, + NFSPROC_SETATTR, + NFSPROC_NOOP, + NFSPROC_LOOKUP, + NFSPROC_READLINK, + NFSPROC_READ, + NFSPROC_NOOP, + NFSPROC_WRITE, + NFSPROC_CREATE, + NFSPROC_REMOVE, + NFSPROC_RENAME, + NFSPROC_LINK, + NFSPROC_SYMLINK, + NFSPROC_MKDIR, + NFSPROC_RMDIR, + NFSPROC_READDIR, + NFSPROC_FSSTAT, + NFSPROC_NOOP, + NFSPROC_NOOP, + NFSPROC_NOOP, + NFSPROC_NOOP, + NFSPROC_NOOP, + NFSPROC_NOOP, + NFSPROC_NOOP, + NFSPROC_NOOP +}; + +/* + * NFS V2 and V3 status values. + * + * Some of these come from the RFCs for NFS V2 and V3, with the message + * strings taken from the FreeBSD C library "errlst.c". + * + * Others are errors that are not in the RFC but that I suspect some + * NFS servers could return; the values are FreeBSD errno values, as + * the first NFS server was the SunOS 2.0 one, and until 5.0 SunOS + * was primarily BSD-derived. + */ +static struct tok status2str[] = { + { 1, "Operation not permitted" }, /* EPERM */ + { 2, "No such file or directory" }, /* ENOENT */ + { 5, "Input/output error" }, /* EIO */ + { 6, "Device not configured" }, /* ENXIO */ + { 11, "Resource deadlock avoided" }, /* EDEADLK */ + { 12, "Cannot allocate memory" }, /* ENOMEM */ + { 13, "Permission denied" }, /* EACCES */ + { 17, "File exists" }, /* EEXIST */ + { 18, "Cross-device link" }, /* EXDEV */ + { 19, "Operation not supported by device" }, /* ENODEV */ + { 20, "Not a directory" }, /* ENOTDIR */ + { 21, "Is a directory" }, /* EISDIR */ + { 22, "Invalid argument" }, /* EINVAL */ + { 26, "Text file busy" }, /* ETXTBSY */ + { 27, "File too large" }, /* EFBIG */ + { 28, "No space left on device" }, /* ENOSPC */ + { 30, "Read-only file system" }, /* EROFS */ + { 31, "Too many links" }, /* EMLINK */ + { 45, "Operation not supported" }, /* EOPNOTSUPP */ + { 62, "Too many levels of symbolic links" }, /* ELOOP */ + { 63, "File name too long" }, /* ENAMETOOLONG */ + { 66, "Directory not empty" }, /* ENOTEMPTY */ + { 69, "Disc quota exceeded" }, /* EDQUOT */ + { 70, "Stale NFS file handle" }, /* ESTALE */ + { 71, "Too many levels of remote in path" }, /* EREMOTE */ + { 99, "Write cache flushed to disk" }, /* NFSERR_WFLUSH (not used) */ + { 10001, "Illegal NFS file handle" }, /* NFS3ERR_BADHANDLE */ + { 10002, "Update synchronization mismatch" }, /* NFS3ERR_NOT_SYNC */ + { 10003, "READDIR/READDIRPLUS cookie is stale" }, /* NFS3ERR_BAD_COOKIE */ + { 10004, "Operation not supported" }, /* NFS3ERR_NOTSUPP */ + { 10005, "Buffer or request is too small" }, /* NFS3ERR_TOOSMALL */ + { 10006, "Unspecified error on server" }, /* NFS3ERR_SERVERFAULT */ + { 10007, "Object of that type not supported" }, /* NFS3ERR_BADTYPE */ + { 10008, "Request couldn't be completed in time" }, /* NFS3ERR_JUKEBOX */ + { 0, NULL } +}; + +static struct tok nfsv3_writemodes[] = { + { 0, "unstable" }, + { 1, "datasync" }, + { 2, "filesync" }, + { 0, NULL } +}; + +static struct tok type2str[] = { + { NFNON, "NON" }, + { NFREG, "REG" }, + { NFDIR, "DIR" }, + { NFBLK, "BLK" }, + { NFCHR, "CHR" }, + { NFLNK, "LNK" }, + { NFFIFO, "FIFO" }, + { 0, NULL } +}; + +static void +print_nfsaddr(const u_char *bp, const char *s, const char *d) +{ + struct ip *ip; +#ifdef INET6 + struct ip6_hdr *ip6; + char srcaddr[INET6_ADDRSTRLEN], dstaddr[INET6_ADDRSTRLEN]; +#else +#ifndef INET_ADDRSTRLEN +#define INET_ADDRSTRLEN 16 +#endif + char srcaddr[INET_ADDRSTRLEN], dstaddr[INET_ADDRSTRLEN]; +#endif + + srcaddr[0] = dstaddr[0] = '\0'; + switch (IP_V((struct ip *)bp)) { + case 4: + ip = (struct ip *)bp; + strlcpy(srcaddr, ipaddr_string(&ip->ip_src), sizeof(srcaddr)); + strlcpy(dstaddr, ipaddr_string(&ip->ip_dst), sizeof(dstaddr)); + break; +#ifdef INET6 + case 6: + ip6 = (struct ip6_hdr *)bp; + strlcpy(srcaddr, ip6addr_string(&ip6->ip6_src), + sizeof(srcaddr)); + strlcpy(dstaddr, ip6addr_string(&ip6->ip6_dst), + sizeof(dstaddr)); + break; +#endif + default: + strlcpy(srcaddr, "?", sizeof(srcaddr)); + strlcpy(dstaddr, "?", sizeof(dstaddr)); + break; + } + + (void)printf("%s.%s > %s.%s: ", srcaddr, s, dstaddr, d); +} + +static const u_int32_t * +parse_sattr3(const u_int32_t *dp, struct nfsv3_sattr *sa3) +{ + TCHECK(dp[0]); + sa3->sa_modeset = EXTRACT_32BITS(dp); + dp++; + if (sa3->sa_modeset) { + TCHECK(dp[0]); + sa3->sa_mode = EXTRACT_32BITS(dp); + dp++; + } + + TCHECK(dp[0]); + sa3->sa_uidset = EXTRACT_32BITS(dp); + dp++; + if (sa3->sa_uidset) { + TCHECK(dp[0]); + sa3->sa_uid = EXTRACT_32BITS(dp); + dp++; + } + + TCHECK(dp[0]); + sa3->sa_gidset = EXTRACT_32BITS(dp); + dp++; + if (sa3->sa_gidset) { + TCHECK(dp[0]); + sa3->sa_gid = EXTRACT_32BITS(dp); + dp++; + } + + TCHECK(dp[0]); + sa3->sa_sizeset = EXTRACT_32BITS(dp); + dp++; + if (sa3->sa_sizeset) { + TCHECK(dp[0]); + sa3->sa_size = EXTRACT_32BITS(dp); + dp++; + } + + TCHECK(dp[0]); + sa3->sa_atimetype = EXTRACT_32BITS(dp); + dp++; + if (sa3->sa_atimetype == NFSV3SATTRTIME_TOCLIENT) { + TCHECK(dp[1]); + sa3->sa_atime.nfsv3_sec = EXTRACT_32BITS(dp); + dp++; + sa3->sa_atime.nfsv3_nsec = EXTRACT_32BITS(dp); + dp++; + } + + TCHECK(dp[0]); + sa3->sa_mtimetype = EXTRACT_32BITS(dp); + dp++; + if (sa3->sa_mtimetype == NFSV3SATTRTIME_TOCLIENT) { + TCHECK(dp[1]); + sa3->sa_mtime.nfsv3_sec = EXTRACT_32BITS(dp); + dp++; + sa3->sa_mtime.nfsv3_nsec = EXTRACT_32BITS(dp); + dp++; + } + + return dp; +trunc: + return NULL; +} + +static int nfserr; /* true if we error rather than trunc */ + +static void +print_sattr3(const struct nfsv3_sattr *sa3, int verbose) +{ + if (sa3->sa_modeset) + printf(" mode %o", sa3->sa_mode); + if (sa3->sa_uidset) + printf(" uid %u", sa3->sa_uid); + if (sa3->sa_gidset) + printf(" gid %u", sa3->sa_gid); + if (verbose > 1) { + if (sa3->sa_atimetype == NFSV3SATTRTIME_TOCLIENT) + printf(" atime %u.%06u", sa3->sa_atime.nfsv3_sec, + sa3->sa_atime.nfsv3_nsec); + if (sa3->sa_mtimetype == NFSV3SATTRTIME_TOCLIENT) + printf(" mtime %u.%06u", sa3->sa_mtime.nfsv3_sec, + sa3->sa_mtime.nfsv3_nsec); + } +} + +void +nfsreply_print(register const u_char *bp, u_int length, + register const u_char *bp2) +{ + register const struct sunrpc_msg *rp; + u_int32_t proc, vers, reply_stat; + char srcid[20], dstid[20]; /*fits 32bit*/ + enum sunrpc_reject_stat rstat; + u_int32_t rlow; + u_int32_t rhigh; + enum sunrpc_auth_stat rwhy; + + nfserr = 0; /* assume no error */ + rp = (const struct sunrpc_msg *)bp; + + TCHECK(rp->rm_xid); + if (!nflag) { + strlcpy(srcid, "nfs", sizeof(srcid)); + snprintf(dstid, sizeof(dstid), "%u", + EXTRACT_32BITS(&rp->rm_xid)); + } else { + snprintf(srcid, sizeof(srcid), "%u", NFS_PORT); + snprintf(dstid, sizeof(dstid), "%u", + EXTRACT_32BITS(&rp->rm_xid)); + } + print_nfsaddr(bp2, srcid, dstid); + TCHECK(rp->rm_reply.rp_stat); + reply_stat = EXTRACT_32BITS(&rp->rm_reply.rp_stat); + switch (reply_stat) { + + case SUNRPC_MSG_ACCEPTED: + (void)printf("reply ok %u", length); + if (xid_map_find(rp, bp2, &proc, &vers) >= 0) + interp_reply(rp, proc, vers, length); + break; + + case SUNRPC_MSG_DENIED: + (void)printf("reply ERR %u: ", length); + TCHECK(rp->rm_reply.rp_reject.rj_stat); + rstat = EXTRACT_32BITS(&rp->rm_reply.rp_reject.rj_stat); + switch (rstat) { + + case SUNRPC_RPC_MISMATCH: + TCHECK(rp->rm_reply.rp_reject.rj_vers.high); + rlow = EXTRACT_32BITS(&rp->rm_reply.rp_reject.rj_vers.low); + rhigh = EXTRACT_32BITS(&rp->rm_reply.rp_reject.rj_vers.high); + (void)printf("RPC Version mismatch (%u-%u)", + rlow, rhigh); + break; + + case SUNRPC_AUTH_ERROR: + TCHECK(rp->rm_reply.rp_reject.rj_why); + rwhy = EXTRACT_32BITS(&rp->rm_reply.rp_reject.rj_why); + (void)printf("Auth "); + switch (rwhy) { + + case SUNRPC_AUTH_OK: + (void)printf("OK"); + break; + + case SUNRPC_AUTH_BADCRED: + (void)printf("Bogus Credentials (seal broken)"); + break; + + case SUNRPC_AUTH_REJECTEDCRED: + (void)printf("Rejected Credentials (client should begin new session)"); + break; + + case SUNRPC_AUTH_BADVERF: + (void)printf("Bogus Verifier (seal broken)"); + break; + + case SUNRPC_AUTH_REJECTEDVERF: + (void)printf("Verifier expired or was replayed"); + break; + + case SUNRPC_AUTH_TOOWEAK: + (void)printf("Credentials are too weak"); + break; + + case SUNRPC_AUTH_INVALIDRESP: + (void)printf("Bogus response verifier"); + break; + + case SUNRPC_AUTH_FAILED: + (void)printf("Unknown failure"); + break; + + default: + (void)printf("Invalid failure code %u", + (unsigned int)rwhy); + break; + } + break; + + default: + (void)printf("Unknown reason for rejecting rpc message %u", + (unsigned int)rstat); + break; + } + break; + + default: + (void)printf("reply Unknown rpc response code=%u %u", + reply_stat, length); + break; + } + return; + +trunc: + if (!nfserr) + fputs(" [|nfs]", stdout); +} + +/* + * Return a pointer to the first file handle in the packet. + * If the packet was truncated, return 0. + */ +static const u_int32_t * +parsereq(register const struct sunrpc_msg *rp, register u_int length) +{ + register const u_int32_t *dp; + register u_int len; + + /* + * find the start of the req data (if we captured it) + */ + dp = (u_int32_t *)&rp->rm_call.cb_cred; + TCHECK(dp[1]); + len = EXTRACT_32BITS(&dp[1]); + if (len < length) { + dp += (len + (2 * sizeof(*dp) + 3)) / sizeof(*dp); + TCHECK(dp[1]); + len = EXTRACT_32BITS(&dp[1]); + if (len < length) { + dp += (len + (2 * sizeof(*dp) + 3)) / sizeof(*dp); + TCHECK2(dp[0], 0); + return (dp); + } + } +trunc: + return (NULL); +} + +/* + * Print out an NFS file handle and return a pointer to following word. + * If packet was truncated, return 0. + */ +static const u_int32_t * +parsefh(register const u_int32_t *dp, int v3) +{ + u_int len; + + if (v3) { + TCHECK(dp[0]); + len = EXTRACT_32BITS(dp) / 4; + dp++; + } else + len = NFSX_V2FH / 4; + + if (TTEST2(*dp, len * sizeof(*dp))) { + nfs_printfh(dp, len); + return (dp + len); + } +trunc: + return (NULL); +} + +/* + * Print out a file name and return pointer to 32-bit word past it. + * If packet was truncated, return 0. + */ +static const u_int32_t * +parsefn(register const u_int32_t *dp) +{ + register u_int32_t len; + register const u_char *cp; + + /* Bail if we don't have the string length */ + TCHECK(*dp); + + /* Fetch string length; convert to host order */ + len = *dp++; + NTOHL(len); + + TCHECK2(*dp, ((len + 3) & ~3)); + + cp = (u_char *)dp; + /* Update 32-bit pointer (NFS filenames padded to 32-bit boundaries) */ + dp += ((len + 3) & ~3) / sizeof(*dp); + putchar('"'); + if (fn_printn(cp, len, snapend)) { + putchar('"'); + goto trunc; + } + putchar('"'); + + return (dp); +trunc: + return NULL; +} + +/* + * Print out file handle and file name. + * Return pointer to 32-bit word past file name. + * If packet was truncated (or there was some other error), return 0. + */ +static const u_int32_t * +parsefhn(register const u_int32_t *dp, int v3) +{ + dp = parsefh(dp, v3); + if (dp == NULL) + return (NULL); + putchar(' '); + return (parsefn(dp)); +} + +void +nfsreq_print(register const u_char *bp, u_int length, + register const u_char *bp2) +{ + register const struct sunrpc_msg *rp; + register const u_int32_t *dp; + nfs_type type; + int v3; + u_int32_t proc; + u_int32_t access_flags; + struct nfsv3_sattr sa3; + char srcid[20], dstid[20]; /*fits 32bit*/ + + nfserr = 0; /* assume no error */ + rp = (const struct sunrpc_msg *)bp; + + TCHECK(rp->rm_xid); + if (!nflag) { + snprintf(srcid, sizeof(srcid), "%u", + EXTRACT_32BITS(&rp->rm_xid)); + strlcpy(dstid, "nfs", sizeof(dstid)); + } else { + snprintf(srcid, sizeof(srcid), "%u", + EXTRACT_32BITS(&rp->rm_xid)); + snprintf(dstid, sizeof(dstid), "%u", NFS_PORT); + } + print_nfsaddr(bp2, srcid, dstid); + (void)printf("%d", length); + + if (!xid_map_enter(rp, bp2)) /* record proc number for later on */ + goto trunc; + + v3 = (EXTRACT_32BITS(&rp->rm_call.cb_vers) == NFS_VER3); + proc = EXTRACT_32BITS(&rp->rm_call.cb_proc); + + if (!v3 && proc < NFS_NPROCS) + proc = nfsv3_procid[proc]; + + switch (proc) { + case NFSPROC_NOOP: + printf(" nop"); + return; + case NFSPROC_NULL: + printf(" null"); + return; + + case NFSPROC_GETATTR: + printf(" getattr"); + if ((dp = parsereq(rp, length)) != NULL && + parsefh(dp, v3) != NULL) + return; + break; + + case NFSPROC_SETATTR: + printf(" setattr"); + if ((dp = parsereq(rp, length)) != NULL && + parsefh(dp, v3) != NULL) + return; + break; + + case NFSPROC_LOOKUP: + printf(" lookup"); + if ((dp = parsereq(rp, length)) != NULL && + parsefhn(dp, v3) != NULL) + return; + break; + + case NFSPROC_ACCESS: + printf(" access"); + if ((dp = parsereq(rp, length)) != NULL && + (dp = parsefh(dp, v3)) != NULL) { + TCHECK(dp[0]); + access_flags = EXTRACT_32BITS(&dp[0]); + if (access_flags & ~NFSV3ACCESS_FULL) { + /* NFSV3ACCESS definitions aren't up to date */ + printf(" %04x", access_flags); + } else if ((access_flags & NFSV3ACCESS_FULL) == NFSV3ACCESS_FULL) { + printf(" NFS_ACCESS_FULL"); + } else { + char separator = ' '; + if (access_flags & NFSV3ACCESS_READ) { + printf(" NFS_ACCESS_READ"); + separator = '|'; + } + if (access_flags & NFSV3ACCESS_LOOKUP) { + printf("%cNFS_ACCESS_LOOKUP", separator); + separator = '|'; + } + if (access_flags & NFSV3ACCESS_MODIFY) { + printf("%cNFS_ACCESS_MODIFY", separator); + separator = '|'; + } + if (access_flags & NFSV3ACCESS_EXTEND) { + printf("%cNFS_ACCESS_EXTEND", separator); + separator = '|'; + } + if (access_flags & NFSV3ACCESS_DELETE) { + printf("%cNFS_ACCESS_DELETE", separator); + separator = '|'; + } + if (access_flags & NFSV3ACCESS_EXECUTE) + printf("%cNFS_ACCESS_EXECUTE", separator); + } + return; + } + break; + + case NFSPROC_READLINK: + printf(" readlink"); + if ((dp = parsereq(rp, length)) != NULL && + parsefh(dp, v3) != NULL) + return; + break; + + case NFSPROC_READ: + printf(" read"); + if ((dp = parsereq(rp, length)) != NULL && + (dp = parsefh(dp, v3)) != NULL) { + if (v3) { + TCHECK(dp[2]); + printf(" %u bytes @ %" PRIu64, + EXTRACT_32BITS(&dp[2]), + EXTRACT_64BITS(&dp[0])); + } else { + TCHECK(dp[1]); + printf(" %u bytes @ %u", + EXTRACT_32BITS(&dp[1]), + EXTRACT_32BITS(&dp[0])); + } + return; + } + break; + + case NFSPROC_WRITE: + printf(" write"); + if ((dp = parsereq(rp, length)) != NULL && + (dp = parsefh(dp, v3)) != NULL) { + if (v3) { + TCHECK(dp[2]); + printf(" %u (%u) bytes @ %" PRIu64, + EXTRACT_32BITS(&dp[4]), + EXTRACT_32BITS(&dp[2]), + EXTRACT_64BITS(&dp[0])); + if (vflag) { + dp += 3; + TCHECK(dp[0]); + printf(" <%s>", + tok2str(nfsv3_writemodes, + NULL, EXTRACT_32BITS(dp))); + } + } else { + TCHECK(dp[3]); + printf(" %u (%u) bytes @ %u (%u)", + EXTRACT_32BITS(&dp[3]), + EXTRACT_32BITS(&dp[2]), + EXTRACT_32BITS(&dp[1]), + EXTRACT_32BITS(&dp[0])); + } + return; + } + break; + + case NFSPROC_CREATE: + printf(" create"); + if ((dp = parsereq(rp, length)) != NULL && + parsefhn(dp, v3) != NULL) + return; + break; + + case NFSPROC_MKDIR: + printf(" mkdir"); + if ((dp = parsereq(rp, length)) != 0 && parsefhn(dp, v3) != 0) + return; + break; + + case NFSPROC_SYMLINK: + printf(" symlink"); + if ((dp = parsereq(rp, length)) != 0 && + (dp = parsefhn(dp, v3)) != 0) { + fputs(" ->", stdout); + if (v3 && (dp = parse_sattr3(dp, &sa3)) == 0) + break; + if (parsefn(dp) == 0) + break; + if (v3 && vflag) + print_sattr3(&sa3, vflag); + return; + } + break; + + case NFSPROC_MKNOD: + printf(" mknod"); + if ((dp = parsereq(rp, length)) != 0 && + (dp = parsefhn(dp, v3)) != 0) { + TCHECK(*dp); + type = (nfs_type)EXTRACT_32BITS(dp); + dp++; + if ((dp = parse_sattr3(dp, &sa3)) == 0) + break; + printf(" %s", tok2str(type2str, "unk-ft %d", type)); + if (vflag && (type == NFCHR || type == NFBLK)) { + TCHECK(dp[1]); + printf(" %u/%u", + EXTRACT_32BITS(&dp[0]), + EXTRACT_32BITS(&dp[1])); + dp += 2; + } + if (vflag) + print_sattr3(&sa3, vflag); + return; + } + break; + + case NFSPROC_REMOVE: + printf(" remove"); + if ((dp = parsereq(rp, length)) != NULL && + parsefhn(dp, v3) != NULL) + return; + break; + + case NFSPROC_RMDIR: + printf(" rmdir"); + if ((dp = parsereq(rp, length)) != NULL && + parsefhn(dp, v3) != NULL) + return; + break; + + case NFSPROC_RENAME: + printf(" rename"); + if ((dp = parsereq(rp, length)) != NULL && + (dp = parsefhn(dp, v3)) != NULL) { + fputs(" ->", stdout); + if (parsefhn(dp, v3) != NULL) + return; + } + break; + + case NFSPROC_LINK: + printf(" link"); + if ((dp = parsereq(rp, length)) != NULL && + (dp = parsefh(dp, v3)) != NULL) { + fputs(" ->", stdout); + if (parsefhn(dp, v3) != NULL) + return; + } + break; + + case NFSPROC_READDIR: + printf(" readdir"); + if ((dp = parsereq(rp, length)) != NULL && + (dp = parsefh(dp, v3)) != NULL) { + if (v3) { + TCHECK(dp[4]); + /* + * We shouldn't really try to interpret the + * offset cookie here. + */ + printf(" %u bytes @ %" PRId64, + EXTRACT_32BITS(&dp[4]), + EXTRACT_64BITS(&dp[0])); + if (vflag) + printf(" verf %08x%08x", dp[2], + dp[3]); + } else { + TCHECK(dp[1]); + /* + * Print the offset as signed, since -1 is + * common, but offsets > 2^31 aren't. + */ + printf(" %u bytes @ %d", + EXTRACT_32BITS(&dp[1]), + EXTRACT_32BITS(&dp[0])); + } + return; + } + break; + + case NFSPROC_READDIRPLUS: + printf(" readdirplus"); + if ((dp = parsereq(rp, length)) != NULL && + (dp = parsefh(dp, v3)) != NULL) { + TCHECK(dp[4]); + /* + * We don't try to interpret the offset + * cookie here. + */ + printf(" %u bytes @ %" PRId64, + EXTRACT_32BITS(&dp[4]), + EXTRACT_64BITS(&dp[0])); + if (vflag) { + TCHECK(dp[5]); + printf(" max %u verf %08x%08x", + EXTRACT_32BITS(&dp[5]), dp[2], dp[3]); + } + return; + } + break; + + case NFSPROC_FSSTAT: + printf(" fsstat"); + if ((dp = parsereq(rp, length)) != NULL && + parsefh(dp, v3) != NULL) + return; + break; + + case NFSPROC_FSINFO: + printf(" fsinfo"); + if ((dp = parsereq(rp, length)) != NULL && + parsefh(dp, v3) != NULL) + return; + break; + + case NFSPROC_PATHCONF: + printf(" pathconf"); + if ((dp = parsereq(rp, length)) != NULL && + parsefh(dp, v3) != NULL) + return; + break; + + case NFSPROC_COMMIT: + printf(" commit"); + if ((dp = parsereq(rp, length)) != NULL && + (dp = parsefh(dp, v3)) != NULL) { + TCHECK(dp[2]); + printf(" %u bytes @ %" PRIu64, + EXTRACT_32BITS(&dp[2]), + EXTRACT_64BITS(&dp[0])); + return; + } + break; + + default: + printf(" proc-%u", EXTRACT_32BITS(&rp->rm_call.cb_proc)); + return; + } + +trunc: + if (!nfserr) + fputs(" [|nfs]", stdout); +} + +/* + * Print out an NFS file handle. + * We assume packet was not truncated before the end of the + * file handle pointed to by dp. + * + * Note: new version (using portable file-handle parser) doesn't produce + * generation number. It probably could be made to do that, with some + * additional hacking on the parser code. + */ +static void +nfs_printfh(register const u_int32_t *dp, const u_int len) +{ + my_fsid fsid; + ino_t ino; + const char *sfsname = NULL; + char *spacep; + + if (uflag) { + u_int i; + char const *sep = ""; + + printf(" fh["); + for (i=0; i<len; i++) { + (void)printf("%s%x", sep, dp[i]); + sep = ":"; + } + printf("]"); + return; + } + + Parse_fh((const u_char *)dp, len, &fsid, &ino, NULL, &sfsname, 0); + + if (sfsname) { + /* file system ID is ASCII, not numeric, for this server OS */ + static char temp[NFSX_V3FHMAX+1]; + + /* Make sure string is null-terminated */ + strncpy(temp, sfsname, NFSX_V3FHMAX); + temp[sizeof(temp) - 1] = '\0'; + /* Remove trailing spaces */ + spacep = strchr(temp, ' '); + if (spacep) + *spacep = '\0'; + + (void)printf(" fh %s/", temp); + } else { + (void)printf(" fh %d,%d/", + fsid.Fsid_dev.Major, fsid.Fsid_dev.Minor); + } + + if(fsid.Fsid_dev.Minor == 257) + /* Print the undecoded handle */ + (void)printf("%s", fsid.Opaque_Handle); + else + (void)printf("%ld", (long) ino); +} + +/* + * Maintain a small cache of recent client.XID.server/proc pairs, to allow + * us to match up replies with requests and thus to know how to parse + * the reply. + */ + +struct xid_map_entry { + u_int32_t xid; /* transaction ID (net order) */ + int ipver; /* IP version (4 or 6) */ +#ifdef INET6 + struct in6_addr client; /* client IP address (net order) */ + struct in6_addr server; /* server IP address (net order) */ +#else + struct in_addr client; /* client IP address (net order) */ + struct in_addr server; /* server IP address (net order) */ +#endif + u_int32_t proc; /* call proc number (host order) */ + u_int32_t vers; /* program version (host order) */ +}; + +/* + * Map entries are kept in an array that we manage as a ring; + * new entries are always added at the tail of the ring. Initially, + * all the entries are zero and hence don't match anything. + */ + +#define XIDMAPSIZE 64 + +struct xid_map_entry xid_map[XIDMAPSIZE]; + +int xid_map_next = 0; +int xid_map_hint = 0; + +static int +xid_map_enter(const struct sunrpc_msg *rp, const u_char *bp) +{ + struct ip *ip = NULL; +#ifdef INET6 + struct ip6_hdr *ip6 = NULL; +#endif + struct xid_map_entry *xmep; + + if (!TTEST(rp->rm_call.cb_vers)) + return (0); + switch (IP_V((struct ip *)bp)) { + case 4: + ip = (struct ip *)bp; + break; +#ifdef INET6 + case 6: + ip6 = (struct ip6_hdr *)bp; + break; +#endif + default: + return (1); + } + + xmep = &xid_map[xid_map_next]; + + if (++xid_map_next >= XIDMAPSIZE) + xid_map_next = 0; + + xmep->xid = rp->rm_xid; + if (ip) { + xmep->ipver = 4; + memcpy(&xmep->client, &ip->ip_src, sizeof(ip->ip_src)); + memcpy(&xmep->server, &ip->ip_dst, sizeof(ip->ip_dst)); + } +#ifdef INET6 + else if (ip6) { + xmep->ipver = 6; + memcpy(&xmep->client, &ip6->ip6_src, sizeof(ip6->ip6_src)); + memcpy(&xmep->server, &ip6->ip6_dst, sizeof(ip6->ip6_dst)); + } +#endif + xmep->proc = EXTRACT_32BITS(&rp->rm_call.cb_proc); + xmep->vers = EXTRACT_32BITS(&rp->rm_call.cb_vers); + return (1); +} + +/* + * Returns 0 and puts NFSPROC_xxx in proc return and + * version in vers return, or returns -1 on failure + */ +static int +xid_map_find(const struct sunrpc_msg *rp, const u_char *bp, u_int32_t *proc, + u_int32_t *vers) +{ + int i; + struct xid_map_entry *xmep; + u_int32_t xid = rp->rm_xid; + struct ip *ip = (struct ip *)bp; +#ifdef INET6 + struct ip6_hdr *ip6 = (struct ip6_hdr *)bp; +#endif + int cmp; + + /* Start searching from where we last left off */ + i = xid_map_hint; + do { + xmep = &xid_map[i]; + cmp = 1; + if (xmep->ipver != IP_V(ip) || xmep->xid != xid) + goto nextitem; + switch (xmep->ipver) { + case 4: + if (memcmp(&ip->ip_src, &xmep->server, + sizeof(ip->ip_src)) != 0 || + memcmp(&ip->ip_dst, &xmep->client, + sizeof(ip->ip_dst)) != 0) { + cmp = 0; + } + break; +#ifdef INET6 + case 6: + if (memcmp(&ip6->ip6_src, &xmep->server, + sizeof(ip6->ip6_src)) != 0 || + memcmp(&ip6->ip6_dst, &xmep->client, + sizeof(ip6->ip6_dst)) != 0) { + cmp = 0; + } + break; +#endif + default: + cmp = 0; + break; + } + if (cmp) { + /* match */ + xid_map_hint = i; + *proc = xmep->proc; + *vers = xmep->vers; + return 0; + } + nextitem: + if (++i >= XIDMAPSIZE) + i = 0; + } while (i != xid_map_hint); + + /* search failed */ + return (-1); +} + +/* + * Routines for parsing reply packets + */ + +/* + * Return a pointer to the beginning of the actual results. + * If the packet was truncated, return 0. + */ +static const u_int32_t * +parserep(register const struct sunrpc_msg *rp, register u_int length) +{ + register const u_int32_t *dp; + u_int len; + enum sunrpc_accept_stat astat; + + /* + * Portability note: + * Here we find the address of the ar_verf credentials. + * Originally, this calculation was + * dp = (u_int32_t *)&rp->rm_reply.rp_acpt.ar_verf + * On the wire, the rp_acpt field starts immediately after + * the (32 bit) rp_stat field. However, rp_acpt (which is a + * "struct accepted_reply") contains a "struct opaque_auth", + * whose internal representation contains a pointer, so on a + * 64-bit machine the compiler inserts 32 bits of padding + * before rp->rm_reply.rp_acpt.ar_verf. So, we cannot use + * the internal representation to parse the on-the-wire + * representation. Instead, we skip past the rp_stat field, + * which is an "enum" and so occupies one 32-bit word. + */ + dp = ((const u_int32_t *)&rp->rm_reply) + 1; + TCHECK(dp[1]); + len = EXTRACT_32BITS(&dp[1]); + if (len >= length) + return (NULL); + /* + * skip past the ar_verf credentials. + */ + dp += (len + (2*sizeof(u_int32_t) + 3)) / sizeof(u_int32_t); + TCHECK2(dp[0], 0); + + /* + * now we can check the ar_stat field + */ + astat = (enum sunrpc_accept_stat) EXTRACT_32BITS(dp); + switch (astat) { + + case SUNRPC_SUCCESS: + break; + + case SUNRPC_PROG_UNAVAIL: + printf(" PROG_UNAVAIL"); + nfserr = 1; /* suppress trunc string */ + return (NULL); + + case SUNRPC_PROG_MISMATCH: + printf(" PROG_MISMATCH"); + nfserr = 1; /* suppress trunc string */ + return (NULL); + + case SUNRPC_PROC_UNAVAIL: + printf(" PROC_UNAVAIL"); + nfserr = 1; /* suppress trunc string */ + return (NULL); + + case SUNRPC_GARBAGE_ARGS: + printf(" GARBAGE_ARGS"); + nfserr = 1; /* suppress trunc string */ + return (NULL); + + case SUNRPC_SYSTEM_ERR: + printf(" SYSTEM_ERR"); + nfserr = 1; /* suppress trunc string */ + return (NULL); + + default: + printf(" ar_stat %d", astat); + nfserr = 1; /* suppress trunc string */ + return (NULL); + } + /* successful return */ + TCHECK2(*dp, sizeof(astat)); + return ((u_int32_t *) (sizeof(astat) + ((char *)dp))); +trunc: + return (0); +} + +static const u_int32_t * +parsestatus(const u_int32_t *dp, int *er) +{ + int errnum; + + TCHECK(dp[0]); + + errnum = EXTRACT_32BITS(&dp[0]); + if (er) + *er = errnum; + if (errnum != 0) { + if (!qflag) + printf(" ERROR: %s", + tok2str(status2str, "unk %d", errnum)); + nfserr = 1; + } + return (dp + 1); +trunc: + return NULL; +} + +static const u_int32_t * +parsefattr(const u_int32_t *dp, int verbose, int v3) +{ + const struct nfs_fattr *fap; + + fap = (const struct nfs_fattr *)dp; + TCHECK(fap->fa_gid); + if (verbose) { + printf(" %s %o ids %d/%d", + tok2str(type2str, "unk-ft %d ", + EXTRACT_32BITS(&fap->fa_type)), + EXTRACT_32BITS(&fap->fa_mode), + EXTRACT_32BITS(&fap->fa_uid), + EXTRACT_32BITS(&fap->fa_gid)); + if (v3) { + TCHECK(fap->fa3_size); + printf(" sz %" PRIu64, + EXTRACT_64BITS((u_int32_t *)&fap->fa3_size)); + } else { + TCHECK(fap->fa2_size); + printf(" sz %d", EXTRACT_32BITS(&fap->fa2_size)); + } + } + /* print lots more stuff */ + if (verbose > 1) { + if (v3) { + TCHECK(fap->fa3_ctime); + printf(" nlink %d rdev %d/%d", + EXTRACT_32BITS(&fap->fa_nlink), + EXTRACT_32BITS(&fap->fa3_rdev.specdata1), + EXTRACT_32BITS(&fap->fa3_rdev.specdata2)); + printf(" fsid %" PRIx64, + EXTRACT_64BITS((u_int32_t *)&fap->fa3_fsid)); + printf(" fileid %" PRIx64, + EXTRACT_64BITS((u_int32_t *)&fap->fa3_fileid)); + printf(" a/m/ctime %u.%06u", + EXTRACT_32BITS(&fap->fa3_atime.nfsv3_sec), + EXTRACT_32BITS(&fap->fa3_atime.nfsv3_nsec)); + printf(" %u.%06u", + EXTRACT_32BITS(&fap->fa3_mtime.nfsv3_sec), + EXTRACT_32BITS(&fap->fa3_mtime.nfsv3_nsec)); + printf(" %u.%06u", + EXTRACT_32BITS(&fap->fa3_ctime.nfsv3_sec), + EXTRACT_32BITS(&fap->fa3_ctime.nfsv3_nsec)); + } else { + TCHECK(fap->fa2_ctime); + printf(" nlink %d rdev %x fsid %x nodeid %x a/m/ctime", + EXTRACT_32BITS(&fap->fa_nlink), + EXTRACT_32BITS(&fap->fa2_rdev), + EXTRACT_32BITS(&fap->fa2_fsid), + EXTRACT_32BITS(&fap->fa2_fileid)); + printf(" %u.%06u", + EXTRACT_32BITS(&fap->fa2_atime.nfsv2_sec), + EXTRACT_32BITS(&fap->fa2_atime.nfsv2_usec)); + printf(" %u.%06u", + EXTRACT_32BITS(&fap->fa2_mtime.nfsv2_sec), + EXTRACT_32BITS(&fap->fa2_mtime.nfsv2_usec)); + printf(" %u.%06u", + EXTRACT_32BITS(&fap->fa2_ctime.nfsv2_sec), + EXTRACT_32BITS(&fap->fa2_ctime.nfsv2_usec)); + } + } + return ((const u_int32_t *)((unsigned char *)dp + + (v3 ? NFSX_V3FATTR : NFSX_V2FATTR))); +trunc: + return (NULL); +} + +static int +parseattrstat(const u_int32_t *dp, int verbose, int v3) +{ + int er; + + dp = parsestatus(dp, &er); + if (dp == NULL) + return (0); + if (er) + return (1); + + return (parsefattr(dp, verbose, v3) != NULL); +} + +static int +parsediropres(const u_int32_t *dp) +{ + int er; + + if (!(dp = parsestatus(dp, &er))) + return (0); + if (er) + return (1); + + dp = parsefh(dp, 0); + if (dp == NULL) + return (0); + + return (parsefattr(dp, vflag, 0) != NULL); +} + +static int +parselinkres(const u_int32_t *dp, int v3) +{ + int er; + + dp = parsestatus(dp, &er); + if (dp == NULL) + return(0); + if (er) + return(1); + if (v3 && !(dp = parse_post_op_attr(dp, vflag))) + return (0); + putchar(' '); + return (parsefn(dp) != NULL); +} + +static int +parsestatfs(const u_int32_t *dp, int v3) +{ + const struct nfs_statfs *sfsp; + int er; + + dp = parsestatus(dp, &er); + if (dp == NULL) + return (0); + if (!v3 && er) + return (1); + + if (qflag) + return(1); + + if (v3) { + if (vflag) + printf(" POST:"); + if (!(dp = parse_post_op_attr(dp, vflag))) + return (0); + } + + TCHECK2(*dp, (v3 ? NFSX_V3STATFS : NFSX_V2STATFS)); + + sfsp = (const struct nfs_statfs *)dp; + + if (v3) { + printf(" tbytes %" PRIu64 " fbytes %" PRIu64 " abytes %" PRIu64, + EXTRACT_64BITS((u_int32_t *)&sfsp->sf_tbytes), + EXTRACT_64BITS((u_int32_t *)&sfsp->sf_fbytes), + EXTRACT_64BITS((u_int32_t *)&sfsp->sf_abytes)); + if (vflag) { + printf(" tfiles %" PRIu64 " ffiles %" PRIu64 " afiles %" PRIu64 " invar %u", + EXTRACT_64BITS((u_int32_t *)&sfsp->sf_tfiles), + EXTRACT_64BITS((u_int32_t *)&sfsp->sf_ffiles), + EXTRACT_64BITS((u_int32_t *)&sfsp->sf_afiles), + EXTRACT_32BITS(&sfsp->sf_invarsec)); + } + } else { + printf(" tsize %d bsize %d blocks %d bfree %d bavail %d", + EXTRACT_32BITS(&sfsp->sf_tsize), + EXTRACT_32BITS(&sfsp->sf_bsize), + EXTRACT_32BITS(&sfsp->sf_blocks), + EXTRACT_32BITS(&sfsp->sf_bfree), + EXTRACT_32BITS(&sfsp->sf_bavail)); + } + + return (1); +trunc: + return (0); +} + +static int +parserddires(const u_int32_t *dp) +{ + int er; + + dp = parsestatus(dp, &er); + if (dp == NULL) + return (0); + if (er) + return (1); + if (qflag) + return (1); + + TCHECK(dp[2]); + printf(" offset %x size %d ", + EXTRACT_32BITS(&dp[0]), EXTRACT_32BITS(&dp[1])); + if (dp[2] != 0) + printf(" eof"); + + return (1); +trunc: + return (0); +} + +static const u_int32_t * +parse_wcc_attr(const u_int32_t *dp) +{ + printf(" sz %" PRIu64, EXTRACT_64BITS(&dp[0])); + printf(" mtime %u.%06u ctime %u.%06u", + EXTRACT_32BITS(&dp[2]), EXTRACT_32BITS(&dp[3]), + EXTRACT_32BITS(&dp[4]), EXTRACT_32BITS(&dp[5])); + return (dp + 6); +} + +/* + * Pre operation attributes. Print only if vflag > 1. + */ +static const u_int32_t * +parse_pre_op_attr(const u_int32_t *dp, int verbose) +{ + TCHECK(dp[0]); + if (!EXTRACT_32BITS(&dp[0])) + return (dp + 1); + dp++; + TCHECK2(*dp, 24); + if (verbose > 1) { + return parse_wcc_attr(dp); + } else { + /* If not verbose enough, just skip over wcc_attr */ + return (dp + 6); + } +trunc: + return (NULL); +} + +/* + * Post operation attributes are printed if vflag >= 1 + */ +static const u_int32_t * +parse_post_op_attr(const u_int32_t *dp, int verbose) +{ + TCHECK(dp[0]); + if (!EXTRACT_32BITS(&dp[0])) + return (dp + 1); + dp++; + if (verbose) { + return parsefattr(dp, verbose, 1); + } else + return (dp + (NFSX_V3FATTR / sizeof (u_int32_t))); +trunc: + return (NULL); +} + +static const u_int32_t * +parse_wcc_data(const u_int32_t *dp, int verbose) +{ + if (verbose > 1) + printf(" PRE:"); + if (!(dp = parse_pre_op_attr(dp, verbose))) + return (0); + + if (verbose) + printf(" POST:"); + return parse_post_op_attr(dp, verbose); +} + +static const u_int32_t * +parsecreateopres(const u_int32_t *dp, int verbose) +{ + int er; + + if (!(dp = parsestatus(dp, &er))) + return (0); + if (er) + dp = parse_wcc_data(dp, verbose); + else { + TCHECK(dp[0]); + if (!EXTRACT_32BITS(&dp[0])) + return (dp + 1); + dp++; + if (!(dp = parsefh(dp, 1))) + return (0); + if (verbose) { + if (!(dp = parse_post_op_attr(dp, verbose))) + return (0); + if (vflag > 1) { + printf(" dir attr:"); + dp = parse_wcc_data(dp, verbose); + } + } + } + return (dp); +trunc: + return (NULL); +} + +static int +parsewccres(const u_int32_t *dp, int verbose) +{ + int er; + + if (!(dp = parsestatus(dp, &er))) + return (0); + return parse_wcc_data(dp, verbose) != 0; +} + +static const u_int32_t * +parsev3rddirres(const u_int32_t *dp, int verbose) +{ + int er; + + if (!(dp = parsestatus(dp, &er))) + return (0); + if (vflag) + printf(" POST:"); + if (!(dp = parse_post_op_attr(dp, verbose))) + return (0); + if (er) + return dp; + if (vflag) { + TCHECK(dp[1]); + printf(" verf %08x%08x", dp[0], dp[1]); + dp += 2; + } + return dp; +trunc: + return (NULL); +} + +static int +parsefsinfo(const u_int32_t *dp) +{ + struct nfsv3_fsinfo *sfp; + int er; + + if (!(dp = parsestatus(dp, &er))) + return (0); + if (vflag) + printf(" POST:"); + if (!(dp = parse_post_op_attr(dp, vflag))) + return (0); + if (er) + return (1); + + sfp = (struct nfsv3_fsinfo *)dp; + TCHECK(*sfp); + printf(" rtmax %u rtpref %u wtmax %u wtpref %u dtpref %u", + EXTRACT_32BITS(&sfp->fs_rtmax), + EXTRACT_32BITS(&sfp->fs_rtpref), + EXTRACT_32BITS(&sfp->fs_wtmax), + EXTRACT_32BITS(&sfp->fs_wtpref), + EXTRACT_32BITS(&sfp->fs_dtpref)); + if (vflag) { + printf(" rtmult %u wtmult %u maxfsz %" PRIu64, + EXTRACT_32BITS(&sfp->fs_rtmult), + EXTRACT_32BITS(&sfp->fs_wtmult), + EXTRACT_64BITS((u_int32_t *)&sfp->fs_maxfilesize)); + printf(" delta %u.%06u ", + EXTRACT_32BITS(&sfp->fs_timedelta.nfsv3_sec), + EXTRACT_32BITS(&sfp->fs_timedelta.nfsv3_nsec)); + } + return (1); +trunc: + return (0); +} + +static int +parsepathconf(const u_int32_t *dp) +{ + int er; + struct nfsv3_pathconf *spp; + + if (!(dp = parsestatus(dp, &er))) + return (0); + if (vflag) + printf(" POST:"); + if (!(dp = parse_post_op_attr(dp, vflag))) + return (0); + if (er) + return (1); + + spp = (struct nfsv3_pathconf *)dp; + TCHECK(*spp); + + printf(" linkmax %u namemax %u %s %s %s %s", + EXTRACT_32BITS(&spp->pc_linkmax), + EXTRACT_32BITS(&spp->pc_namemax), + EXTRACT_32BITS(&spp->pc_notrunc) ? "notrunc" : "", + EXTRACT_32BITS(&spp->pc_chownrestricted) ? "chownres" : "", + EXTRACT_32BITS(&spp->pc_caseinsensitive) ? "igncase" : "", + EXTRACT_32BITS(&spp->pc_casepreserving) ? "keepcase" : ""); + return (1); +trunc: + return (0); +} + +static void +interp_reply(const struct sunrpc_msg *rp, u_int32_t proc, u_int32_t vers, int length) +{ + register const u_int32_t *dp; + register int v3; + int er; + + v3 = (vers == NFS_VER3); + + if (!v3 && proc < NFS_NPROCS) + proc = nfsv3_procid[proc]; + + switch (proc) { + + case NFSPROC_NOOP: + printf(" nop"); + return; + + case NFSPROC_NULL: + printf(" null"); + return; + + case NFSPROC_GETATTR: + printf(" getattr"); + dp = parserep(rp, length); + if (dp != NULL && parseattrstat(dp, !qflag, v3) != 0) + return; + break; + + case NFSPROC_SETATTR: + printf(" setattr"); + if (!(dp = parserep(rp, length))) + return; + if (v3) { + if (parsewccres(dp, vflag)) + return; + } else { + if (parseattrstat(dp, !qflag, 0) != 0) + return; + } + break; + + case NFSPROC_LOOKUP: + printf(" lookup"); + if (!(dp = parserep(rp, length))) + break; + if (v3) { + if (!(dp = parsestatus(dp, &er))) + break; + if (er) { + if (vflag > 1) { + printf(" post dattr:"); + dp = parse_post_op_attr(dp, vflag); + } + } else { + if (!(dp = parsefh(dp, v3))) + break; + if ((dp = parse_post_op_attr(dp, vflag)) && + vflag > 1) { + printf(" post dattr:"); + dp = parse_post_op_attr(dp, vflag); + } + } + if (dp) + return; + } else { + if (parsediropres(dp) != 0) + return; + } + break; + + case NFSPROC_ACCESS: + printf(" access"); + if (!(dp = parserep(rp, length))) + break; + if (!(dp = parsestatus(dp, &er))) + break; + if (vflag) + printf(" attr:"); + if (!(dp = parse_post_op_attr(dp, vflag))) + break; + if (!er) + printf(" c %04x", EXTRACT_32BITS(&dp[0])); + return; + + case NFSPROC_READLINK: + printf(" readlink"); + dp = parserep(rp, length); + if (dp != NULL && parselinkres(dp, v3) != 0) + return; + break; + + case NFSPROC_READ: + printf(" read"); + if (!(dp = parserep(rp, length))) + break; + if (v3) { + if (!(dp = parsestatus(dp, &er))) + break; + if (!(dp = parse_post_op_attr(dp, vflag))) + break; + if (er) + return; + if (vflag) { + TCHECK(dp[1]); + printf(" %u bytes", EXTRACT_32BITS(&dp[0])); + if (EXTRACT_32BITS(&dp[1])) + printf(" EOF"); + } + return; + } else { + if (parseattrstat(dp, vflag, 0) != 0) + return; + } + break; + + case NFSPROC_WRITE: + printf(" write"); + if (!(dp = parserep(rp, length))) + break; + if (v3) { + if (!(dp = parsestatus(dp, &er))) + break; + if (!(dp = parse_wcc_data(dp, vflag))) + break; + if (er) + return; + if (vflag) { + TCHECK(dp[0]); + printf(" %u bytes", EXTRACT_32BITS(&dp[0])); + if (vflag > 1) { + TCHECK(dp[1]); + printf(" <%s>", + tok2str(nfsv3_writemodes, + NULL, EXTRACT_32BITS(&dp[1]))); + } + return; + } + } else { + if (parseattrstat(dp, vflag, v3) != 0) + return; + } + break; + + case NFSPROC_CREATE: + printf(" create"); + if (!(dp = parserep(rp, length))) + break; + if (v3) { + if (parsecreateopres(dp, vflag) != 0) + return; + } else { + if (parsediropres(dp) != 0) + return; + } + break; + + case NFSPROC_MKDIR: + printf(" mkdir"); + if (!(dp = parserep(rp, length))) + break; + if (v3) { + if (parsecreateopres(dp, vflag) != 0) + return; + } else { + if (parsediropres(dp) != 0) + return; + } + break; + + case NFSPROC_SYMLINK: + printf(" symlink"); + if (!(dp = parserep(rp, length))) + break; + if (v3) { + if (parsecreateopres(dp, vflag) != 0) + return; + } else { + if (parsestatus(dp, &er) != 0) + return; + } + break; + + case NFSPROC_MKNOD: + printf(" mknod"); + if (!(dp = parserep(rp, length))) + break; + if (parsecreateopres(dp, vflag) != 0) + return; + break; + + case NFSPROC_REMOVE: + printf(" remove"); + if (!(dp = parserep(rp, length))) + break; + if (v3) { + if (parsewccres(dp, vflag)) + return; + } else { + if (parsestatus(dp, &er) != 0) + return; + } + break; + + case NFSPROC_RMDIR: + printf(" rmdir"); + if (!(dp = parserep(rp, length))) + break; + if (v3) { + if (parsewccres(dp, vflag)) + return; + } else { + if (parsestatus(dp, &er) != 0) + return; + } + break; + + case NFSPROC_RENAME: + printf(" rename"); + if (!(dp = parserep(rp, length))) + break; + if (v3) { + if (!(dp = parsestatus(dp, &er))) + break; + if (vflag) { + printf(" from:"); + if (!(dp = parse_wcc_data(dp, vflag))) + break; + printf(" to:"); + if (!(dp = parse_wcc_data(dp, vflag))) + break; + } + return; + } else { + if (parsestatus(dp, &er) != 0) + return; + } + break; + + case NFSPROC_LINK: + printf(" link"); + if (!(dp = parserep(rp, length))) + break; + if (v3) { + if (!(dp = parsestatus(dp, &er))) + break; + if (vflag) { + printf(" file POST:"); + if (!(dp = parse_post_op_attr(dp, vflag))) + break; + printf(" dir:"); + if (!(dp = parse_wcc_data(dp, vflag))) + break; + return; + } + } else { + if (parsestatus(dp, &er) != 0) + return; + } + break; + + case NFSPROC_READDIR: + printf(" readdir"); + if (!(dp = parserep(rp, length))) + break; + if (v3) { + if (parsev3rddirres(dp, vflag)) + return; + } else { + if (parserddires(dp) != 0) + return; + } + break; + + case NFSPROC_READDIRPLUS: + printf(" readdirplus"); + if (!(dp = parserep(rp, length))) + break; + if (parsev3rddirres(dp, vflag)) + return; + break; + + case NFSPROC_FSSTAT: + printf(" fsstat"); + dp = parserep(rp, length); + if (dp != NULL && parsestatfs(dp, v3) != 0) + return; + break; + + case NFSPROC_FSINFO: + printf(" fsinfo"); + dp = parserep(rp, length); + if (dp != NULL && parsefsinfo(dp) != 0) + return; + break; + + case NFSPROC_PATHCONF: + printf(" pathconf"); + dp = parserep(rp, length); + if (dp != NULL && parsepathconf(dp) != 0) + return; + break; + + case NFSPROC_COMMIT: + printf(" commit"); + dp = parserep(rp, length); + if (dp != NULL && parsewccres(dp, vflag) != 0) + return; + break; + + default: + printf(" proc-%u", proc); + return; + } +trunc: + if (!nfserr) + fputs(" [|nfs]", stdout); +}
diff --git a/tcpdump-4.3.0/print-ntp.c b/tcpdump-4.3.0/print-ntp.c new file mode 100644 index 0000000..d56f02a --- /dev/null +++ b/tcpdump-4.3.0/print-ntp.c
@@ -0,0 +1,308 @@ +/* + * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * Format and print ntp packets. + * By Jeffrey Mogul/DECWRL + * loosely based on print-bootp.c + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-ntp.c,v 1.43 2007-11-30 13:45:10 hannes Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> +#include <string.h> +#ifdef HAVE_STRFTIME +#include <time.h> +#endif + +#include "interface.h" +#include "addrtoname.h" +#include "extract.h" +#ifdef MODEMASK +#undef MODEMASK /* Solaris sucks */ +#endif +#include "ntp.h" + +static void p_sfix(const struct s_fixedpt *); +static void p_ntp_time(const struct l_fixedpt *); +static void p_ntp_delta(const struct l_fixedpt *, const struct l_fixedpt *); + +static struct tok ntp_mode_values[] = { + { MODE_UNSPEC, "unspecified" }, + { MODE_SYM_ACT, "symmetric active" }, + { MODE_SYM_PAS, "symmetric passive" }, + { MODE_CLIENT, "Client" }, + { MODE_SERVER, "Server" }, + { MODE_BROADCAST, "Broadcast" }, + { MODE_RES1, "Reserved" }, + { MODE_RES2, "Reserved" }, + { 0, NULL } +}; + +static struct tok ntp_leapind_values[] = { + { NO_WARNING, "" }, + { PLUS_SEC, "+1s" }, + { MINUS_SEC, "-1s" }, + { ALARM, "clock unsynchronized" }, + { 0, NULL } +}; + +static struct tok ntp_stratum_values[] = { + { UNSPECIFIED, "unspecified" }, + { PRIM_REF, "primary reference" }, + { 0, NULL } +}; + +/* + * Print ntp requests + */ +void +ntp_print(register const u_char *cp, u_int length) +{ + register const struct ntpdata *bp; + int mode, version, leapind; + + bp = (struct ntpdata *)cp; + + TCHECK(bp->status); + + version = (int)(bp->status & VERSIONMASK) >> 3; + printf("NTPv%d", version); + + mode = bp->status & MODEMASK; + if (!vflag) { + printf (", %s, length %u", + tok2str(ntp_mode_values, "Unknown mode", mode), + length); + return; + } + + printf (", length %u\n\t%s", + length, + tok2str(ntp_mode_values, "Unknown mode", mode)); + + leapind = bp->status & LEAPMASK; + printf (", Leap indicator: %s (%u)", + tok2str(ntp_leapind_values, "Unknown", leapind), + leapind); + + TCHECK(bp->stratum); + printf(", Stratum %u (%s)", + bp->stratum, + tok2str(ntp_stratum_values, (bp->stratum >=2 && bp->stratum<=15) ? "secondary reference" : "reserved", bp->stratum)); + + TCHECK(bp->ppoll); + printf(", poll %us", bp->ppoll); + + /* Can't TCHECK bp->precision bitfield so bp->distance + 0 instead */ + TCHECK2(bp->root_delay, 0); + printf(", precision %d", bp->precision); + + TCHECK(bp->root_delay); + fputs("\n\tRoot Delay: ", stdout); + p_sfix(&bp->root_delay); + + TCHECK(bp->root_dispersion); + fputs(", Root dispersion: ", stdout); + p_sfix(&bp->root_dispersion); + + TCHECK(bp->refid); + fputs(", Reference-ID: ", stdout); + /* Interpretation depends on stratum */ + switch (bp->stratum) { + + case UNSPECIFIED: + printf("(unspec)"); + break; + + case PRIM_REF: + if (fn_printn((u_char *)&(bp->refid), 4, snapend)) + goto trunc; + break; + + case INFO_QUERY: + printf("%s INFO_QUERY", ipaddr_string(&(bp->refid))); + /* this doesn't have more content */ + return; + + case INFO_REPLY: + printf("%s INFO_REPLY", ipaddr_string(&(bp->refid))); + /* this is too complex to be worth printing */ + return; + + default: + printf("%s", ipaddr_string(&(bp->refid))); + break; + } + + TCHECK(bp->ref_timestamp); + fputs("\n\t Reference Timestamp: ", stdout); + p_ntp_time(&(bp->ref_timestamp)); + + TCHECK(bp->org_timestamp); + fputs("\n\t Originator Timestamp: ", stdout); + p_ntp_time(&(bp->org_timestamp)); + + TCHECK(bp->rec_timestamp); + fputs("\n\t Receive Timestamp: ", stdout); + p_ntp_time(&(bp->rec_timestamp)); + + TCHECK(bp->xmt_timestamp); + fputs("\n\t Transmit Timestamp: ", stdout); + p_ntp_time(&(bp->xmt_timestamp)); + + fputs("\n\t Originator - Receive Timestamp: ", stdout); + p_ntp_delta(&(bp->org_timestamp), &(bp->rec_timestamp)); + + fputs("\n\t Originator - Transmit Timestamp: ", stdout); + p_ntp_delta(&(bp->org_timestamp), &(bp->xmt_timestamp)); + + if ( (sizeof(struct ntpdata) - length) == 16) { /* Optional: key-id */ + TCHECK(bp->key_id); + printf("\n\tKey id: %u", bp->key_id); + } else if ( (sizeof(struct ntpdata) - length) == 0) { /* Optional: key-id + authentication */ + TCHECK(bp->key_id); + printf("\n\tKey id: %u", bp->key_id); + TCHECK2(bp->message_digest, sizeof (bp->message_digest)); + printf("\n\tAuthentication: %08x%08x%08x%08x", + EXTRACT_32BITS(bp->message_digest), + EXTRACT_32BITS(bp->message_digest + 4), + EXTRACT_32BITS(bp->message_digest + 8), + EXTRACT_32BITS(bp->message_digest + 12)); + } + return; + +trunc: + fputs(" [|ntp]", stdout); +} + +static void +p_sfix(register const struct s_fixedpt *sfp) +{ + register int i; + register int f; + register float ff; + + i = EXTRACT_16BITS(&sfp->int_part); + f = EXTRACT_16BITS(&sfp->fraction); + ff = f / 65536.0; /* shift radix point by 16 bits */ + f = ff * 1000000.0; /* Treat fraction as parts per million */ + printf("%d.%06d", i, f); +} + +#define FMAXINT (4294967296.0) /* floating point rep. of MAXINT */ + +static void +p_ntp_time(register const struct l_fixedpt *lfp) +{ + register int32_t i; + register u_int32_t uf; + register u_int32_t f; + register float ff; + + i = EXTRACT_32BITS(&lfp->int_part); + uf = EXTRACT_32BITS(&lfp->fraction); + ff = uf; + if (ff < 0.0) /* some compilers are buggy */ + ff += FMAXINT; + ff = ff / FMAXINT; /* shift radix point by 32 bits */ + f = ff * 1000000000.0; /* treat fraction as parts per billion */ + printf("%u.%09d", i, f); + +#ifdef HAVE_STRFTIME + /* + * print the time in human-readable format. + */ + if (i) { + time_t seconds = i - JAN_1970; + struct tm *tm; + char time_buf[128]; + + tm = localtime(&seconds); + strftime(time_buf, sizeof (time_buf), "%Y/%m/%d %H:%M:%S", tm); + printf (" (%s)", time_buf); + } +#endif +} + +/* Prints time difference between *lfp and *olfp */ +static void +p_ntp_delta(register const struct l_fixedpt *olfp, + register const struct l_fixedpt *lfp) +{ + register int32_t i; + register u_int32_t u, uf; + register u_int32_t ou, ouf; + register u_int32_t f; + register float ff; + int signbit; + + u = EXTRACT_32BITS(&lfp->int_part); + ou = EXTRACT_32BITS(&olfp->int_part); + uf = EXTRACT_32BITS(&lfp->fraction); + ouf = EXTRACT_32BITS(&olfp->fraction); + if (ou == 0 && ouf == 0) { + p_ntp_time(lfp); + return; + } + + i = u - ou; + + if (i > 0) { /* new is definitely greater than old */ + signbit = 0; + f = uf - ouf; + if (ouf > uf) /* must borrow from high-order bits */ + i -= 1; + } else if (i < 0) { /* new is definitely less than old */ + signbit = 1; + f = ouf - uf; + if (uf > ouf) /* must carry into the high-order bits */ + i += 1; + i = -i; + } else { /* int_part is zero */ + if (uf > ouf) { + signbit = 0; + f = uf - ouf; + } else { + signbit = 1; + f = ouf - uf; + } + } + + ff = f; + if (ff < 0.0) /* some compilers are buggy */ + ff += FMAXINT; + ff = ff / FMAXINT; /* shift radix point by 32 bits */ + f = ff * 1000000000.0; /* treat fraction as parts per billion */ + if (signbit) + putchar('-'); + else + putchar('+'); + printf("%d.%09d", i, f); +} +
diff --git a/tcpdump-4.3.0/print-null.c b/tcpdump-4.3.0/print-null.c new file mode 100644 index 0000000..8eabe5d --- /dev/null +++ b/tcpdump-4.3.0/print-null.c
@@ -0,0 +1,160 @@ +/* + * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.57 2006-03-23 14:58:44 hannes 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 "ip.h" +#ifdef INET6 +#include "ip6.h" +#endif +#include "af.h" + +/* + * The DLT_NULL packet header is 4 bytes long. It contains a host-byte-order + * 32-bit integer that specifies the family, e.g. AF_INET. + * + * Note here that "host" refers to the host on which the packets were + * captured; that isn't necessarily *this* host. + * + * The OpenBSD DLT_LOOP packet header is the same, except that the integer + * is in network byte order. + */ +#define NULL_HDRLEN 4 + +/* + * Byte-swap a 32-bit number. + * ("htonl()" or "ntohl()" won't work - we want to byte-swap even on + * big-endian platforms.) + */ +#define SWAPLONG(y) \ +((((y)&0xff)<<24) | (((y)&0xff00)<<8) | (((y)&0xff0000)>>8) | (((y)>>24)&0xff)) + +static inline void +null_hdr_print(u_int family, u_int length) +{ + if (!qflag) { + (void)printf("AF %s (%u)", + tok2str(bsd_af_values,"Unknown",family),family); + } else { + (void)printf("%s", + tok2str(bsd_af_values,"Unknown AF %u",family)); + } + + (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->len' is the length of the packet off the wire, and 'h->caplen' + * is the number of bytes actually captured. + */ +u_int +null_if_print(const struct pcap_pkthdr *h, const u_char *p) +{ + u_int length = h->len; + u_int caplen = h->caplen; + u_int family; + + if (caplen < NULL_HDRLEN) { + printf("[|null]"); + return (NULL_HDRLEN); + } + + memcpy((char *)&family, (char *)p, sizeof(family)); + + /* + * This isn't necessarily in our host byte order; if this is + * a DLT_LOOP capture, it's in network byte order, and if + * this is a DLT_NULL capture from a machine with the opposite + * byte-order, it's in the opposite byte order from ours. + * + * If the upper 16 bits aren't all zero, assume it's byte-swapped. + */ + if ((family & 0xFFFF0000) != 0) + family = SWAPLONG(family); + + if (eflag) + null_hdr_print(family, length); + + length -= NULL_HDRLEN; + caplen -= NULL_HDRLEN; + p += NULL_HDRLEN; + + switch (family) { + + case BSD_AFNUM_INET: + ip_print(gndo, p, length); + break; + +#ifdef INET6 + case BSD_AFNUM_INET6_BSD: + case BSD_AFNUM_INET6_FREEBSD: + case BSD_AFNUM_INET6_DARWIN: + ip6_print(gndo, p, length); + break; +#endif + + case BSD_AFNUM_ISO: + isoclns_print(p, length, caplen); + break; + + case BSD_AFNUM_APPLETALK: + atalk_print(p, length); + break; + + case BSD_AFNUM_IPX: + ipx_print(p, length); + break; + + default: + /* unknown AF_ value */ + if (!eflag) + null_hdr_print(family, length + NULL_HDRLEN); + if (!suppress_default_print) + default_print(p, caplen); + } + + return (NULL_HDRLEN); +} + +/* + * Local Variables: + * c-style: whitesmith + * c-basic-offset: 8 + * End: + */
diff --git a/tcpdump-4.3.0/print-olsr.c b/tcpdump-4.3.0/print-olsr.c new file mode 100644 index 0000000..ba0ed2b --- /dev/null +++ b/tcpdump-4.3.0/print-olsr.c
@@ -0,0 +1,626 @@ +/* + * Copyright (c) 1998-2007 The TCPDUMP project + * Copyright (c) 2009 Florian Forster + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code + * 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. + * + * Optimized Link State Protocl (OLSR) as per rfc3626 + * + * Original code by Hannes Gredler <hannes@juniper.net> + * IPv6 additions by Florian Forster <octo at verplant.org> + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> +#include <string.h> + +#include "interface.h" +#include "addrtoname.h" +#include "extract.h" +#include "ip.h" + +/* + * RFC 3626 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 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Packet Length | Packet Sequence Number | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Message Type | Vtime | Message Size | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Originator Address | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Time To Live | Hop Count | Message Sequence Number | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | | + * : MESSAGE : + * | | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Message Type | Vtime | Message Size | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Originator Address | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Time To Live | Hop Count | Message Sequence Number | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | | + * : MESSAGE : + * | | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * : : + */ + +struct olsr_common { + u_int8_t packet_len[2]; + u_int8_t packet_seq[2]; +}; + +#define OLSR_HELLO_MSG 1 /* rfc3626 */ +#define OLSR_TC_MSG 2 /* rfc3626 */ +#define OLSR_MID_MSG 3 /* rfc3626 */ +#define OLSR_HNA_MSG 4 /* rfc3626 */ +#define OLSR_POWERINFO_MSG 128 +#define OLSR_NAMESERVICE_MSG 130 +#define OLSR_HELLO_LQ_MSG 201 /* LQ extensions olsr.org */ +#define OLSR_TC_LQ_MSG 202 /* LQ extensions olsr.org */ + +static struct tok olsr_msg_values[] = { + { OLSR_HELLO_MSG, "Hello" }, + { OLSR_TC_MSG, "TC" }, + { OLSR_MID_MSG, "MID" }, + { OLSR_HNA_MSG, "HNA" }, + { OLSR_POWERINFO_MSG, "Powerinfo" }, + { OLSR_NAMESERVICE_MSG, "Nameservice" }, + { OLSR_HELLO_LQ_MSG, "Hello-LQ" }, + { OLSR_TC_LQ_MSG, "TC-LQ" }, + { 0, NULL} +}; + +struct olsr_msg4 { + u_int8_t msg_type; + u_int8_t vtime; + u_int8_t msg_len[2]; + u_int8_t originator[4]; + u_int8_t ttl; + u_int8_t hopcount; + u_int8_t msg_seq[2]; +}; + +struct olsr_msg6 { + u_int8_t msg_type; + u_int8_t vtime; + u_int8_t msg_len[2]; + u_int8_t originator[16]; + u_int8_t ttl; + u_int8_t hopcount; + u_int8_t msg_seq[2]; +}; + +struct olsr_hello { + u_int8_t res[2]; + u_int8_t htime; + u_int8_t will; +}; + +struct olsr_hello_link { + u_int8_t link_code; + u_int8_t res; + u_int8_t len[2]; +}; + +struct olsr_tc { + u_int8_t ans_seq[2]; + u_int8_t res[2]; +}; + +struct olsr_hna4 { + u_int8_t network[4]; + u_int8_t mask[4]; +}; + +struct olsr_hna6 { + u_int8_t network[16]; + u_int8_t mask[16]; +}; + + +#define OLSR_EXTRACT_LINK_TYPE(link_code) (link_code & 0x3) +#define OLSR_EXTRACT_NEIGHBOR_TYPE(link_code) (link_code >> 2) + +static struct tok olsr_link_type_values[] = { + { 0, "Unspecified" }, + { 1, "Asymmetric" }, + { 2, "Symmetric" }, + { 3, "Lost" }, + { 0, NULL} +}; + +static struct tok olsr_neighbor_type_values[] = { + { 0, "Not-Neighbor" }, + { 1, "Symmetric" }, + { 2, "Symmetric-MPR" }, + { 0, NULL} +}; + +struct olsr_lq_neighbor4 { + u_int8_t neighbor[4]; + u_int8_t link_quality; + u_int8_t neighbor_link_quality; + u_int8_t res[2]; +}; + +struct olsr_lq_neighbor6 { + u_int8_t neighbor[16]; + u_int8_t link_quality; + u_int8_t neighbor_link_quality; + u_int8_t res[2]; +}; + +/* + * macro to convert the 8-bit mantissa/exponent to a double float + * taken from olsr.org. + */ +#define VTIME_SCALE_FACTOR 0.0625 +#define ME_TO_DOUBLE(me) \ + (double)(VTIME_SCALE_FACTOR*(1+(double)(me>>4)/16)*(double)(1<<(me&0x0F))) + +/* + * print a neighbor list with LQ extensions. + */ +static void +olsr_print_lq_neighbor4 (const u_char *msg_data, u_int hello_len) +{ + struct olsr_lq_neighbor4 *lq_neighbor; + + while (hello_len >= sizeof(struct olsr_lq_neighbor4)) { + + lq_neighbor = (struct olsr_lq_neighbor4 *)msg_data; + + printf("\n\t neighbor %s, link-quality %.2lf%%" + ", neighbor-link-quality %.2lf%%", + ipaddr_string(lq_neighbor->neighbor), + ((double)lq_neighbor->link_quality/2.55), + ((double)lq_neighbor->neighbor_link_quality/2.55)); + + msg_data += sizeof(struct olsr_lq_neighbor4); + hello_len -= sizeof(struct olsr_lq_neighbor4); + } +} + +#if INET6 +static void +olsr_print_lq_neighbor6 (const u_char *msg_data, u_int hello_len) +{ + struct olsr_lq_neighbor6 *lq_neighbor; + + while (hello_len >= sizeof(struct olsr_lq_neighbor6)) { + + lq_neighbor = (struct olsr_lq_neighbor6 *)msg_data; + + printf("\n\t neighbor %s, link-quality %.2lf%%" + ", neighbor-link-quality %.2lf%%", + ip6addr_string(lq_neighbor->neighbor), + ((double)lq_neighbor->link_quality/2.55), + ((double)lq_neighbor->neighbor_link_quality/2.55)); + + msg_data += sizeof(struct olsr_lq_neighbor6); + hello_len -= sizeof(struct olsr_lq_neighbor6); + } +} +#endif /* INET6 */ + +/* + * print a neighbor list. + */ +static void +olsr_print_neighbor (const u_char *msg_data, u_int hello_len) +{ + int neighbor; + + printf("\n\t neighbor\n\t\t"); + neighbor = 1; + + while (hello_len >= sizeof(struct in_addr)) { + + /* print 4 neighbors per line */ + + printf("%s%s", ipaddr_string(msg_data), + neighbor % 4 == 0 ? "\n\t\t" : " "); + + msg_data += sizeof(struct in_addr); + hello_len -= sizeof(struct in_addr); + } +} + + +void +olsr_print (const u_char *pptr, u_int length, int is_ipv6) +{ + union { + const struct olsr_common *common; + const struct olsr_msg4 *msg4; + const struct olsr_msg6 *msg6; + const struct olsr_hello *hello; + const struct olsr_hello_link *hello_link; + const struct olsr_tc *tc; + const struct olsr_hna4 *hna; + } ptr; + + u_int msg_type, msg_len, msg_tlen, hello_len; + u_int16_t name_entry_type, name_entry_len; + u_int name_entry_padding; + u_int8_t link_type, neighbor_type; + const u_char *tptr, *msg_data; + + tptr = pptr; + + if (length < sizeof(struct olsr_common)) { + goto trunc; + } + + if (!TTEST2(*tptr, sizeof(struct olsr_common))) { + goto trunc; + } + + ptr.common = (struct olsr_common *)tptr; + length = MIN(length, EXTRACT_16BITS(ptr.common->packet_len)); + + printf("OLSRv%i, seq 0x%04x, length %u", + (is_ipv6 == 0) ? 4 : 6, + EXTRACT_16BITS(ptr.common->packet_seq), + length); + + tptr += sizeof(struct olsr_common); + + /* + * In non-verbose mode, just print version. + */ + if (vflag < 1) { + return; + } + + while (tptr < (pptr+length)) { + union + { + struct olsr_msg4 *v4; + struct olsr_msg6 *v6; + } msgptr; + int msg_len_valid = 0; + + if (!TTEST2(*tptr, sizeof(struct olsr_msg4))) + goto trunc; + +#if INET6 + if (is_ipv6) + { + msgptr.v6 = (struct olsr_msg6 *) tptr; + msg_type = msgptr.v6->msg_type; + msg_len = EXTRACT_16BITS(msgptr.v6->msg_len); + if ((msg_len >= sizeof (struct olsr_msg6)) + && (msg_len <= length)) + msg_len_valid = 1; + + /* infinite loop check */ + if (msg_type == 0 || msg_len == 0) { + return; + } + + printf("\n\t%s Message (%#04x), originator %s, ttl %u, hop %u" + "\n\t vtime %.3lfs, msg-seq 0x%04x, length %u%s", + tok2str(olsr_msg_values, "Unknown", msg_type), + msg_type, ip6addr_string(msgptr.v6->originator), + msgptr.v6->ttl, + msgptr.v6->hopcount, + ME_TO_DOUBLE(msgptr.v6->vtime), + EXTRACT_16BITS(msgptr.v6->msg_seq), + msg_len, (msg_len_valid == 0) ? " (invalid)" : ""); + + msg_tlen = msg_len - sizeof(struct olsr_msg6); + msg_data = tptr + sizeof(struct olsr_msg6); + } + else