From ea7b4bf5be3f8ae279c2eae3a85c1fb67d4e0edb Mon Sep 17 00:00:00 2001 From: Peter Avalos Date: Sun, 5 Jul 2009 21:44:17 -1000 Subject: [PATCH] Upgrade to tcpdump-4.0.0. --- contrib/tcpdump/CHANGES | 44 +- contrib/tcpdump/INSTALL.txt | 254 ++++ contrib/tcpdump/README | 14 +- contrib/tcpdump/README.DELETED | 15 +- contrib/tcpdump/VERSION | 2 +- contrib/tcpdump/addrtoname.c | 14 +- contrib/tcpdump/addrtoname.h | 13 +- contrib/tcpdump/af.c | 2 +- contrib/tcpdump/af.h | 2 +- contrib/tcpdump/aodv.h | 2 +- contrib/tcpdump/appletalk.h | 2 +- contrib/tcpdump/arcnet.h | 2 +- contrib/tcpdump/atm.h | 3 +- contrib/tcpdump/atmuni31.h | 14 +- contrib/tcpdump/bgp.h | 2 +- contrib/tcpdump/bootp.h | 2 +- contrib/tcpdump/bpf_dump.c | 4 +- contrib/tcpdump/chdlc.h | 2 +- contrib/tcpdump/checksum.c | 137 +++ contrib/tcpdump/dccp.h | 6 +- contrib/tcpdump/decnet.h | 2 +- contrib/tcpdump/enc.h | 2 +- contrib/tcpdump/ether.h | 2 +- contrib/tcpdump/ethertype.h | 17 +- contrib/tcpdump/extract.h | 6 +- contrib/tcpdump/fddi.h | 2 +- contrib/tcpdump/gmpls.c | 26 +- contrib/tcpdump/gmpls.h | 12 +- contrib/tcpdump/gmt2local.c | 2 +- contrib/tcpdump/gmt2local.h | 2 +- contrib/tcpdump/icmp6.h | 4 +- contrib/tcpdump/ieee802_11.h | 2 +- contrib/tcpdump/ieee802_11_radio.h | 4 +- contrib/tcpdump/igrp.h | 2 +- contrib/tcpdump/interface.h | 32 +- contrib/tcpdump/ip.h | 2 +- contrib/tcpdump/ip6.h | 4 +- contrib/tcpdump/ipfc.h | 2 +- contrib/tcpdump/ipproto.c | 2 +- contrib/tcpdump/ipproto.h | 2 +- contrib/tcpdump/ipsec_doi.h | 2 +- contrib/tcpdump/ipx.h | 2 +- contrib/tcpdump/isakmp.h | 149 ++- contrib/tcpdump/l2tp.h | 2 +- contrib/tcpdump/l2vpn.c | 2 +- contrib/tcpdump/l2vpn.h | 2 +- contrib/tcpdump/lane.h | 2 +- contrib/tcpdump/llc.h | 4 +- contrib/tcpdump/machdep.c | 2 +- contrib/tcpdump/machdep.h | 2 +- contrib/tcpdump/makemib | 2 +- contrib/tcpdump/mpls.h | 2 +- contrib/tcpdump/nameser.h | 2 +- contrib/tcpdump/netbios.h | 2 +- contrib/tcpdump/netdissect.h | 12 +- contrib/tcpdump/nfs.h | 19 +- contrib/tcpdump/nfsfh.h | 2 +- contrib/tcpdump/nlpid.c | 2 +- contrib/tcpdump/nlpid.h | 2 +- contrib/tcpdump/ntp.h | 2 +- contrib/tcpdump/oakley.h | 2 +- contrib/tcpdump/ospf.h | 68 +- contrib/tcpdump/ospf6.h | 77 +- contrib/tcpdump/oui.c | 5 +- contrib/tcpdump/oui.h | 5 +- contrib/tcpdump/parsenfsfh.c | 2 +- contrib/tcpdump/pcap-missing.h | 2 +- contrib/tcpdump/pcap_dump_ftell.c | 2 +- contrib/tcpdump/pf.h | 77 -- contrib/tcpdump/pmap_prot.h | 2 +- contrib/tcpdump/ppp.h | 2 +- contrib/tcpdump/print-802_11.c | 51 +- contrib/tcpdump/print-ah.c | 2 +- contrib/tcpdump/print-aodv.c | 2 +- contrib/tcpdump/print-ap1394.c | 6 +- contrib/tcpdump/print-arcnet.c | 2 +- contrib/tcpdump/print-arp.c | 285 +++-- contrib/tcpdump/print-ascii.c | 2 +- contrib/tcpdump/print-atalk.c | 2 +- contrib/tcpdump/print-atm.c | 163 ++- contrib/tcpdump/print-beep.c | 2 +- contrib/tcpdump/print-bfd.c | 2 +- contrib/tcpdump/print-bgp.c | 457 +++++++- contrib/tcpdump/print-bootp.c | 16 +- contrib/tcpdump/print-cdp.c | 2 +- contrib/tcpdump/print-cfm.c | 641 ++++++++++ contrib/tcpdump/print-chdlc.c | 2 +- contrib/tcpdump/print-cip.c | 2 +- contrib/tcpdump/print-cnfp.c | 2 +- contrib/tcpdump/print-dccp.c | 71 +- contrib/tcpdump/print-decnet.c | 2 +- contrib/tcpdump/print-dhcp6.c | 133 ++- contrib/tcpdump/print-domain.c | 39 +- contrib/tcpdump/print-dtp.c | 123 ++ contrib/tcpdump/print-dvmrp.c | 2 +- contrib/tcpdump/print-eap.c | 274 ++++- contrib/tcpdump/print-egp.c | 16 +- contrib/tcpdump/print-eigrp.c | 2 +- contrib/tcpdump/print-enc.c | 15 +- contrib/tcpdump/print-esp.c | 2 +- contrib/tcpdump/print-ether.c | 24 +- contrib/tcpdump/print-fddi.c | 2 +- contrib/tcpdump/print-fr.c | 115 +- contrib/tcpdump/print-frag6.c | 2 +- contrib/tcpdump/print-gre.c | 2 +- contrib/tcpdump/print-hsrp.c | 2 +- contrib/tcpdump/print-icmp.c | 4 +- contrib/tcpdump/print-icmp6.c | 6 +- contrib/tcpdump/print-igmp.c | 2 +- contrib/tcpdump/print-igrp.c | 2 +- contrib/tcpdump/print-ip.c | 4 +- contrib/tcpdump/print-ip6.c | 2 +- contrib/tcpdump/print-ip6opts.c | 2 +- contrib/tcpdump/print-ipcomp.c | 2 +- contrib/tcpdump/print-ipfc.c | 2 +- contrib/tcpdump/print-ipx.c | 2 +- contrib/tcpdump/print-isakmp.c | 1740 +++++++++++++++++++++------- contrib/tcpdump/print-isoclns.c | 156 +-- contrib/tcpdump/print-juniper.c | 467 +++++++- contrib/tcpdump/print-krb.c | 2 +- contrib/tcpdump/print-l2tp.c | 2 +- contrib/tcpdump/print-lane.c | 2 +- contrib/tcpdump/print-ldp.c | 35 +- contrib/tcpdump/print-llc.c | 28 +- contrib/tcpdump/print-lldp.c | 1107 ++++++++++++++++++ contrib/tcpdump/print-lmp.c | 28 +- contrib/tcpdump/print-lspping.c | 13 +- contrib/tcpdump/print-lwapp.c | 360 ++++++ contrib/tcpdump/print-lwres.c | 2 +- contrib/tcpdump/print-mobile.c | 2 +- contrib/tcpdump/print-mobility.c | 2 +- contrib/tcpdump/print-mpcp.c | 274 +++++ contrib/tcpdump/print-mpls.c | 2 +- contrib/tcpdump/print-msdp.c | 2 +- contrib/tcpdump/print-netbios.c | 2 +- contrib/tcpdump/print-nfs.c | 26 +- contrib/tcpdump/print-ntp.c | 2 +- contrib/tcpdump/print-null.c | 5 +- contrib/tcpdump/print-ospf.c | 778 ++++++++----- contrib/tcpdump/print-ospf6.c | 596 ++++------ contrib/tcpdump/print-pflog.c | 7 +- contrib/tcpdump/print-pgm.c | 2 +- contrib/tcpdump/print-pim.c | 2 +- contrib/tcpdump/print-ppp.c | 2 +- contrib/tcpdump/print-pppoe.c | 2 +- contrib/tcpdump/print-pptp.c | 2 +- contrib/tcpdump/print-radius.c | 2 +- contrib/tcpdump/print-raw.c | 2 +- contrib/tcpdump/print-rip.c | 19 +- contrib/tcpdump/print-ripng.c | 2 +- contrib/tcpdump/print-rrcp.c | 137 +++ contrib/tcpdump/print-rsvp.c | 2 +- contrib/tcpdump/print-rt6.c | 2 +- contrib/tcpdump/print-rx.c | 332 +++++- contrib/tcpdump/print-sctp.c | 2 +- contrib/tcpdump/print-sflow.c | 577 +++++++++ contrib/tcpdump/print-sip.c | 2 +- contrib/tcpdump/print-sl.c | 2 +- contrib/tcpdump/print-sll.c | 2 +- contrib/tcpdump/print-slow.c | 465 +++++++- contrib/tcpdump/print-smb.c | 45 +- contrib/tcpdump/print-snmp.c | 2 +- contrib/tcpdump/print-stp.c | 2 +- contrib/tcpdump/print-sunatm.c | 2 +- contrib/tcpdump/print-sunrpc.c | 2 +- contrib/tcpdump/print-symantec.c | 2 +- contrib/tcpdump/print-syslog.c | 2 +- contrib/tcpdump/print-tcp.c | 1285 ++++++++++---------- contrib/tcpdump/print-telnet.c | 2 +- contrib/tcpdump/print-tftp.c | 6 +- contrib/tcpdump/print-timed.c | 2 +- contrib/tcpdump/print-token.c | 2 +- contrib/tcpdump/print-udld.c | 173 +++ contrib/tcpdump/print-udp.c | 12 +- contrib/tcpdump/print-vjc.c | 2 +- contrib/tcpdump/print-vqp.c | 209 ++++ contrib/tcpdump/print-vrrp.c | 2 +- contrib/tcpdump/print-vtp.c | 378 ++++++ contrib/tcpdump/print-wb.c | 2 +- contrib/tcpdump/print-zephyr.c | 11 +- contrib/tcpdump/route6d.h | 2 +- contrib/tcpdump/rpc_auth.h | 2 +- contrib/tcpdump/rpc_msg.h | 2 +- contrib/tcpdump/rx.h | 2 +- contrib/tcpdump/sctpConstants.h | 2 +- contrib/tcpdump/sctpHeader.h | 2 +- contrib/tcpdump/setsignal.c | 2 +- contrib/tcpdump/setsignal.h | 2 +- contrib/tcpdump/slcompress.h | 2 +- contrib/tcpdump/slip.h | 2 +- contrib/tcpdump/sll.h | 6 +- contrib/tcpdump/smb.h | 2 +- contrib/tcpdump/smbutil.c | 2 +- contrib/tcpdump/strcasecmp.c | 2 +- contrib/tcpdump/tcp.h | 44 +- contrib/tcpdump/tcpdump-stdinc.h | 2 +- contrib/tcpdump/tcpdump.1 | 855 ++------------ contrib/tcpdump/tcpdump.c | 386 +++++- contrib/tcpdump/telnet.h | 4 +- contrib/tcpdump/tftp.h | 4 +- contrib/tcpdump/timed.h | 9 +- contrib/tcpdump/token.h | 2 +- contrib/tcpdump/udp.h | 6 +- contrib/tcpdump/util.c | 109 +- contrib/tcpdump/vfprintf.c | 2 +- 205 files changed, 10969 insertions(+), 3447 deletions(-) create mode 100644 contrib/tcpdump/INSTALL.txt create mode 100644 contrib/tcpdump/checksum.c delete mode 100644 contrib/tcpdump/pf.h create mode 100644 contrib/tcpdump/print-cfm.c create mode 100644 contrib/tcpdump/print-dtp.c create mode 100644 contrib/tcpdump/print-lldp.c create mode 100644 contrib/tcpdump/print-lwapp.c create mode 100644 contrib/tcpdump/print-mpcp.c create mode 100644 contrib/tcpdump/print-rrcp.c create mode 100644 contrib/tcpdump/print-sflow.c create mode 100644 contrib/tcpdump/print-udld.c create mode 100644 contrib/tcpdump/print-vqp.c create mode 100644 contrib/tcpdump/print-vtp.c diff --git a/contrib/tcpdump/CHANGES b/contrib/tcpdump/CHANGES index aa29e305cf..3f3b6759ce 100644 --- a/contrib/tcpdump/CHANGES +++ b/contrib/tcpdump/CHANGES @@ -1,20 +1,36 @@ -$Header: /tcpdump/master/tcpdump/CHANGES,v 1.87.2.17 2007/09/13 13:39:44 ken Exp $ - -Mon. September 10, 2007. ken@xelerance.com. Summary for 0.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 +$Header: /tcpdump/master/tcpdump/CHANGES,v 1.98.2.2 2008-10-15 23:26:30 ken Exp $ + +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 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 0.9.7 tcpdump release + +Wed. July 23, 2007. mcr@xelerance.com. Summary for 3.9.7 libpcap release NFS: Print unsigned values as such. RX: parse safely. diff --git a/contrib/tcpdump/INSTALL.txt b/contrib/tcpdump/INSTALL.txt new file mode 100644 index 0000000000..e263f5368f --- /dev/null +++ b/contrib/tcpdump/INSTALL.txt @@ -0,0 +1,254 @@ +@(#) $Header: /tcpdump/master/tcpdump/INSTALL.txt,v 1.1.2.1 2008-02-06 10:49:22 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-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/contrib/tcpdump/README b/contrib/tcpdump/README index cb51d3092d..c2b6760aba 100644 --- a/contrib/tcpdump/README +++ b/contrib/tcpdump/README @@ -1,10 +1,11 @@ -@(#) $Header: /tcpdump/master/tcpdump/README,v 1.65.2.1 2007/09/14 01:03:12 guy Exp $ (LBL) +@(#) $Header: /tcpdump/master/tcpdump/README,v 1.66.2.1 2008-05-30 01:38:20 guy Exp $ (LBL) TCPDUMP 3.9 Now maintained by "The Tcpdump Group" See www.tcpdump.org -Please send inquiries/comments/reports to tcpdump-workers@tcpdump.org +Please send inquiries/comments/reports to: + tcpdump-workers@lists.tcpdump.org Anonymous CVS is available via: cvs -d :pserver:cvs.tcpdump.org:/tcpdump/master login @@ -68,15 +69,14 @@ 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@tcpdump.org". Bugs, support requests, -and feature requests may also be submitted on the SourceForge site for -tcpdump at +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 -"patches@tcpdump.org", or submitted as patches on the SourceForge site -for tcpdump. +submitted as patches on the SourceForge site for tcpdump. Current versions can be found at www.tcpdump.org, or the SourceForge site for tcpdump. diff --git a/contrib/tcpdump/README.DELETED b/contrib/tcpdump/README.DELETED index b2af9f546b..faea7ee91e 100644 --- a/contrib/tcpdump/README.DELETED +++ b/contrib/tcpdump/README.DELETED @@ -1,21 +1,9 @@ -.#CHANGES.1.87 -.#tcpdump.c.1.253.2.5 -.cvsignore -CHANGES.~1~ -CHANGES~ CREDITS -CVS/ -FILES -INSTALL -Makefile-devel-adds Makefile.in -PLATFORMS Readme.Win32 -TODO acconfig.h aclocal.m4 atime.awk -autom4te.cache/ config.guess config.h.in config.sub @@ -26,8 +14,7 @@ lbl/ missing/ mkdep packetdat.awk +print-bt.c send-ack.awk stime.awk -tcpdump-3.9 -tests/ win32/ diff --git a/contrib/tcpdump/VERSION b/contrib/tcpdump/VERSION index 26cb48590e..fcdb2e109f 100644 --- a/contrib/tcpdump/VERSION +++ b/contrib/tcpdump/VERSION @@ -1 +1 @@ -3.9.8 +4.0.0 diff --git a/contrib/tcpdump/addrtoname.c b/contrib/tcpdump/addrtoname.c index 53d615f2c0..e67d1148c9 100644 --- a/contrib/tcpdump/addrtoname.c +++ b/contrib/tcpdump/addrtoname.c @@ -23,7 +23,7 @@ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.108.2.9 2007/09/14 00:26:18 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.119 2007-08-08 14:06:34 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -79,7 +79,6 @@ extern int ether_ntohost(char *, const struct ether_addr *); */ #define HASHNAMESIZE 4096 -#define BUFSIZE 128 struct hnamemem { u_int32_t addr; @@ -509,14 +508,19 @@ etheraddr_string(register const u_char *ep) } const char * -linkaddr_string(const u_char *ep, const unsigned int len) +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 == ETHER_ADDR_LEN) /* XXX not totally correct... */ - return etheraddr_string(ep); + if (type == LINKADDR_ETHER && len == ETHER_ADDR_LEN) { + return etheraddr_string(ep); + } + + if (type == LINKADDR_FRELAY) { + return q922_string(ep); + } tp = lookup_bytestring(ep, len); if (tp->e_name) diff --git a/contrib/tcpdump/addrtoname.h b/contrib/tcpdump/addrtoname.h index 67ded6e694..1df204a941 100644 --- a/contrib/tcpdump/addrtoname.h +++ b/contrib/tcpdump/addrtoname.h @@ -18,12 +18,21 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * @(#) $Header: /tcpdump/master/tcpdump/addrtoname.h,v 1.18 2001/09/17 21:57:51 fenner Exp $ (LBL) + * @(#) $Header: /tcpdump/master/tcpdump/addrtoname.h,v 1.20 2007-08-08 14:06:34 hannes Exp $ (LBL) */ /* Name to address translation routines. */ -extern const char *linkaddr_string(const u_char *, const unsigned int); +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 *etherproto_string(u_short); extern const char *tcpport_string(u_short); diff --git a/contrib/tcpdump/af.c b/contrib/tcpdump/af.c index 76d61787d4..e3c77bf3c4 100644 --- a/contrib/tcpdump/af.c +++ b/contrib/tcpdump/af.c @@ -17,7 +17,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/af.c,v 1.3.2.1 2007/02/26 13:33:17 hannes Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/af.c,v 1.3 2006-03-23 14:58:44 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/af.h b/contrib/tcpdump/af.h index 1ba766212a..c036cef963 100644 --- a/contrib/tcpdump/af.h +++ b/contrib/tcpdump/af.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/af.h,v 1.3.2.1 2007/02/26 13:33:17 hannes Exp $ (LBL) */ +/* @(#) $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 diff --git a/contrib/tcpdump/aodv.h b/contrib/tcpdump/aodv.h index 335c175c12..456ec8b309 100644 --- a/contrib/tcpdump/aodv.h +++ b/contrib/tcpdump/aodv.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/aodv.h,v 1.3 2003/09/13 01:34:42 guy Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/aodv.h,v 1.3 2003-09-13 01:34:42 guy Exp $ (LBL) */ /* * Copyright (c) 2003 Bruce M. Simpson * All rights reserved. diff --git a/contrib/tcpdump/appletalk.h b/contrib/tcpdump/appletalk.h index 67e62ef870..ff972f65bf 100644 --- a/contrib/tcpdump/appletalk.h +++ b/contrib/tcpdump/appletalk.h @@ -20,7 +20,7 @@ * * AppleTalk protocol formats (courtesy Bill Croft of Stanford/SUMEX). * - * @(#) $Header: /tcpdump/master/tcpdump/appletalk.h,v 1.16 2004/05/01 09:41:50 hannes Exp $ (LBL) + * @(#) $Header: /tcpdump/master/tcpdump/appletalk.h,v 1.16 2004-05-01 09:41:50 hannes Exp $ (LBL) */ struct LAP { diff --git a/contrib/tcpdump/arcnet.h b/contrib/tcpdump/arcnet.h index 6e649f61e0..3b609566ff 100644 --- a/contrib/tcpdump/arcnet.h +++ b/contrib/tcpdump/arcnet.h @@ -30,7 +30,7 @@ * 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) + * @(#) $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 */ diff --git a/contrib/tcpdump/atm.h b/contrib/tcpdump/atm.h index c6ac53ea07..65ac5c17e5 100644 --- a/contrib/tcpdump/atm.h +++ b/contrib/tcpdump/atm.h @@ -14,7 +14,7 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * @(#) $Header: /tcpdump/master/tcpdump/atm.h,v 1.1.4.1 2005/06/20 07:45:05 hannes Exp $ + * @(#) $Header: /tcpdump/master/tcpdump/atm.h,v 1.3 2006-02-08 01:43:00 hannes Exp $ */ /* @@ -30,3 +30,4 @@ */ #define ATM_OAM_NOHEC 0 #define ATM_OAM_HEC 1 +#define ATM_HDR_LEN_NOHEC 4 diff --git a/contrib/tcpdump/atmuni31.h b/contrib/tcpdump/atmuni31.h index 304859a9f1..32acfb1ee5 100644 --- a/contrib/tcpdump/atmuni31.h +++ b/contrib/tcpdump/atmuni31.h @@ -29,18 +29,18 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * @(#) $Header: /tcpdump/master/tcpdump/atmuni31.h,v 1.2 2002/08/05 07:47:23 guy Exp $ (LBL) + * @(#) $Header: /tcpdump/master/tcpdump/atmuni31.h,v 1.2.6.1 2007-10-22 19:39:12 guy Exp $ (LBL) */ /* Based on UNI3.1 standard by ATM Forum */ /* ATM traffic types based on VPI=0 and (the following VCI */ -#define PPC 0x05 /* Point-to-point signal msg */ -#define BCC 0x02 /* Broadcast signal msg */ -#define OAMF4SC 0x03 /* Segment OAM F4 flow cell */ -#define OAMF4EC 0x04 /* End-to-end OAM F4 flow cell */ -#define METAC 0x01 /* Meta signal msg */ -#define ILMIC 0x10 /* ILMI msg */ +#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 */ diff --git a/contrib/tcpdump/bgp.h b/contrib/tcpdump/bgp.h index 06be3ea7c0..5081596014 100755 --- a/contrib/tcpdump/bgp.h +++ b/contrib/tcpdump/bgp.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/bgp.h,v 1.3 2004/06/16 08:45:15 hannes Exp $ (LBL) */ +/* @(#) $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 diff --git a/contrib/tcpdump/bootp.h b/contrib/tcpdump/bootp.h index 7c63d0c4a3..8f61b13a86 100644 --- a/contrib/tcpdump/bootp.h +++ b/contrib/tcpdump/bootp.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/bootp.h,v 1.15.4.3 2007/08/21 22:02:08 guy Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/bootp.h,v 1.18 2007-08-21 21:59:11 guy Exp $ (LBL) */ /* * Bootstrap Protocol (BOOTP). RFC951 and RFC1048. * diff --git a/contrib/tcpdump/bpf_dump.c b/contrib/tcpdump/bpf_dump.c index 0cad4d9554..f509b7edbf 100644 --- a/contrib/tcpdump/bpf_dump.c +++ b/contrib/tcpdump/bpf_dump.c @@ -20,7 +20,7 @@ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/bpf_dump.c,v 1.16 2003/11/16 09:36:08 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/bpf_dump.c,v 1.16.4.1 2008-02-14 20:54:53 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -35,7 +35,7 @@ static const char rcsid[] _U_ = #include "interface.h" void -bpf_dump(struct bpf_program *p, int option) +bpf_dump(const struct bpf_program *p, int option) { struct bpf_insn *insn; int i; diff --git a/contrib/tcpdump/chdlc.h b/contrib/tcpdump/chdlc.h index 4fb6e1d4e4..d11726336e 100644 --- a/contrib/tcpdump/chdlc.h +++ b/contrib/tcpdump/chdlc.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/chdlc.h,v 1.1 2000/09/18 05:11:43 guy Exp $ (LBL) */ +/* @(#) $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. diff --git a/contrib/tcpdump/checksum.c b/contrib/tcpdump/checksum.c new file mode 100644 index 0000000000..f441be3d4d --- /dev/null +++ b/contrib/tcpdump/checksum.c @@ -0,0 +1,137 @@ +/* + * 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 + +#include +#include +#include + +#include "interface.h" + +#define CRC10_POLYNOMIAL 0x633 +static u_int16_t crc10_table[256]; + +static void +init_crc10_table(void) +{ + register int i, j; + register u_int16_t accum; + + for ( i = 0; i < 256; i++ ) + { + accum = ((unsigned short) i << 2); + for ( j = 0; j < 8; j++ ) + { + if ((accum <<= 1) & 0x400) accum ^= CRC10_POLYNOMIAL; + } + crc10_table[i] = accum; + } + return; +} + +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/contrib/tcpdump/dccp.h b/contrib/tcpdump/dccp.h index 1afa8c0f57..5c66e23cd8 100644 --- a/contrib/tcpdump/dccp.h +++ b/contrib/tcpdump/dccp.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/dccp.h,v 1.1.2.4 2006/05/12 01:46:17 guy Exp $ (LBL) */ +/* @(#) $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 @@ -36,8 +36,8 @@ struct dccp_hdr { } dccph_xtrs; }; -#define DCCPH_CCVAL(dh) (((dh)->dccph_ccval_cscov) & 0x0F) -#define DCCPH_CSCOV(dh) (((dh)->dccph_ccval_cscov >> 4) & 0x0F) +#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) diff --git a/contrib/tcpdump/decnet.h b/contrib/tcpdump/decnet.h index 9a5c147703..d25d157d42 100644 --- a/contrib/tcpdump/decnet.h +++ b/contrib/tcpdump/decnet.h @@ -18,7 +18,7 @@ * 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) + * @(#) $Header: /tcpdump/master/tcpdump/decnet.h,v 1.11 2002-12-11 07:13:50 guy Exp $ (LBL) */ #ifndef WIN32 diff --git a/contrib/tcpdump/enc.h b/contrib/tcpdump/enc.h index f54b4eb695..2d57e2b8df 100644 --- a/contrib/tcpdump/enc.h +++ b/contrib/tcpdump/enc.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/enc.h,v 1.1 2003/03/08 08:55:33 guy Exp $ (LBL) */ +/* @(#) $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), diff --git a/contrib/tcpdump/ether.h b/contrib/tcpdump/ether.h index 3d3f3be501..e8b3a7138d 100644 --- a/contrib/tcpdump/ether.h +++ b/contrib/tcpdump/ether.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/ether.h,v 1.8 2002/12/11 07:13:51 guy Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/ether.h,v 1.8 2002-12-11 07:13:51 guy Exp $ (LBL) */ /* * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. diff --git a/contrib/tcpdump/ethertype.h b/contrib/tcpdump/ethertype.h index 36dc8e24d3..97550c7fdc 100644 --- a/contrib/tcpdump/ethertype.h +++ b/contrib/tcpdump/ethertype.h @@ -18,7 +18,7 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * @(#) $Header: /tcpdump/master/tcpdump/ethertype.h,v 1.24.2.1 2005/07/10 14:51:10 hannes Exp $ (LBL) + * @(#) $Header: /tcpdump/master/tcpdump/ethertype.h,v 1.29.2.1 2008-02-06 10:49:22 guy Exp $ (LBL) */ /* @@ -109,6 +109,9 @@ #ifndef ETHERTYPE_PPP #define ETHERTYPE_PPP 0x880b #endif +#ifndef ETHERTYPE_MPCP +#define ETHERTYPE_MPCP 0x8808 +#endif #ifndef ETHERTYPE_SLOW #define ETHERTYPE_SLOW 0x8809 #endif @@ -127,15 +130,27 @@ #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 diff --git a/contrib/tcpdump/extract.h b/contrib/tcpdump/extract.h index f3db2505dd..bab63f205d 100644 --- a/contrib/tcpdump/extract.h +++ b/contrib/tcpdump/extract.h @@ -18,7 +18,7 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * @(#) $Header: /tcpdump/master/tcpdump/extract.h,v 1.24 2005/01/15 02:06:50 guy Exp $ (LBL) + * @(#) $Header: /tcpdump/master/tcpdump/extract.h,v 1.25 2006-01-30 16:20:07 hannes Exp $ (LBL) */ /* @@ -115,6 +115,10 @@ typedef struct { (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 | \ diff --git a/contrib/tcpdump/fddi.h b/contrib/tcpdump/fddi.h index 690af48d87..df38c8e9a8 100644 --- a/contrib/tcpdump/fddi.h +++ b/contrib/tcpdump/fddi.h @@ -18,7 +18,7 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * @(#) $Header: /tcpdump/master/tcpdump/fddi.h,v 1.11 2002/12/11 07:13:51 guy Exp $ (LBL) + * @(#) $Header: /tcpdump/master/tcpdump/fddi.h,v 1.11 2002-12-11 07:13:51 guy Exp $ (LBL) */ /* diff --git a/contrib/tcpdump/gmpls.c b/contrib/tcpdump/gmpls.c index 4d4b9aeb39..ff9adb5950 100644 --- a/contrib/tcpdump/gmpls.c +++ b/contrib/tcpdump/gmpls.c @@ -15,7 +15,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/gmpls.c,v 1.5.2.1 2005/05/19 06:44:02 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/gmpls.c,v 1.7 2006-04-14 07:11:59 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -25,6 +25,7 @@ static const char rcsid[] _U_ = #include #include "interface.h" +#include "gmpls.h" /* rfc3471 */ struct tok gmpls_link_prot_values[] = { @@ -41,14 +42,21 @@ struct tok gmpls_link_prot_values[] = { /* rfc3471 */ struct tok gmpls_switch_cap_values[] = { - { 1, "Packet-Switch Capable-1"}, - { 2, "Packet-Switch Capable-2"}, - { 3, "Packet-Switch Capable-3"}, - { 4, "Packet-Switch Capable-4"}, - { 51, "Layer-2 Switch Capable"}, - { 100, "Time-Division-Multiplex"}, - { 150, "Lambda-Switch Capable"}, - { 200, "Fiber-Switch Capable"}, + { 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 */ +struct tok gmpls_switch_cap_tsc_indication_values[] = { + { 0, "Standard SONET/SDH" }, + { 1, "Arbitrary SONET/SDH" }, { 0, NULL } }; diff --git a/contrib/tcpdump/gmpls.h b/contrib/tcpdump/gmpls.h index 8c3f051ecc..6b2db230a1 100644 --- a/contrib/tcpdump/gmpls.h +++ b/contrib/tcpdump/gmpls.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/gmpls.h,v 1.3.2.1 2005/05/19 06:44:03 guy Exp $ (LBL) */ +/* @(#) $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 @@ -14,8 +14,18 @@ * 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 struct tok gmpls_link_prot_values[]; extern struct tok gmpls_switch_cap_values[]; +extern struct tok gmpls_switch_cap_tsc_indication_values[]; extern struct tok gmpls_encoding_values[]; extern struct tok gmpls_payload_values[]; extern struct tok diffserv_te_bc_values[]; diff --git a/contrib/tcpdump/gmt2local.c b/contrib/tcpdump/gmt2local.c index 926e86cfb7..1fe0e8a955 100644 --- a/contrib/tcpdump/gmt2local.c +++ b/contrib/tcpdump/gmt2local.c @@ -21,7 +21,7 @@ #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)"; + "@(#) $Header: /tcpdump/master/tcpdump/gmt2local.c,v 1.9 2003-11-16 09:36:09 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/gmt2local.h b/contrib/tcpdump/gmt2local.h index 81b0e96072..17120c5b78 100644 --- a/contrib/tcpdump/gmt2local.h +++ b/contrib/tcpdump/gmt2local.h @@ -18,7 +18,7 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * @(#) $Header: /tcpdump/master/tcpdump/gmt2local.h,v 1.2.1.1 1999/10/07 23:47:10 mcr Exp $ (LBL) + * @(#) $Header: /tcpdump/master/tcpdump/gmt2local.h,v 1.2.1.1 1999-10-07 23:47:10 mcr Exp $ (LBL) */ #ifndef gmt2local_h #define gmt2local_h diff --git a/contrib/tcpdump/icmp6.h b/contrib/tcpdump/icmp6.h index 20a51e3a61..5d272703fa 100644 --- a/contrib/tcpdump/icmp6.h +++ b/contrib/tcpdump/icmp6.h @@ -1,5 +1,5 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/icmp6.h,v 1.16.2.1 2005/09/05 09:29:28 guy Exp $ (LBL) */ -/* $NetBSD: icmp6.h,v 1.13 2000/08/03 16:30:37 itojun Exp $ */ +/* @(#) $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 $ */ /* diff --git a/contrib/tcpdump/ieee802_11.h b/contrib/tcpdump/ieee802_11.h index f578a43f1a..3bcda7d22b 100644 --- a/contrib/tcpdump/ieee802_11.h +++ b/contrib/tcpdump/ieee802_11.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/ieee802_11.h,v 1.9.4.3 2007/07/22 20:01:16 guy Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/ieee802_11.h,v 1.12 2007-07-22 19:59:06 guy Exp $ (LBL) */ /* * Copyright (c) 2001 * Fortress Technologies diff --git a/contrib/tcpdump/ieee802_11_radio.h b/contrib/tcpdump/ieee802_11_radio.h index 142a35e426..3f2b836f3b 100644 --- a/contrib/tcpdump/ieee802_11_radio.h +++ b/contrib/tcpdump/ieee802_11_radio.h @@ -1,6 +1,6 @@ /* $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.1.2.1 2006/06/13 22:24:45 guy 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. diff --git a/contrib/tcpdump/igrp.h b/contrib/tcpdump/igrp.h index 78876d3d84..b5f133bcb3 100644 --- a/contrib/tcpdump/igrp.h +++ b/contrib/tcpdump/igrp.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/igrp.h,v 1.6 2002/12/11 07:13:52 guy Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/igrp.h,v 1.6 2002-12-11 07:13:52 guy Exp $ (LBL) */ /* Cisco IGRP definitions */ /* IGRP Header */ diff --git a/contrib/tcpdump/interface.h b/contrib/tcpdump/interface.h index 49ba87d257..1f031231d4 100644 --- a/contrib/tcpdump/interface.h +++ b/contrib/tcpdump/interface.h @@ -18,7 +18,7 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.244.2.21 2007/03/28 07:45:46 hannes Exp $ (LBL) + * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.280.2.4 2008-04-04 19:42:52 guy Exp $ (LBL) */ #ifndef tcpdump_interface_h @@ -164,6 +164,11 @@ 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 @@ -209,10 +214,13 @@ 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); @@ -236,8 +244,11 @@ 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 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); @@ -250,6 +261,7 @@ 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 *); @@ -281,7 +293,9 @@ 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 *); @@ -291,14 +305,19 @@ 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 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); @@ -312,6 +331,7 @@ 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 *); #ifdef INET6 extern void ip6_print(const u_char *, u_int); @@ -332,7 +352,7 @@ extern u_int16_t in_cksum_shouldbe(u_int16_t, u_int16_t); #ifndef HAVE_BPF_DUMP struct bpf_program; -extern void bpf_dump(struct bpf_program *, int); +extern void bpf_dump(const struct bpf_program *, int); #endif @@ -340,10 +360,12 @@ extern void bpf_dump(struct bpf_program *, int); /* forward compatibility */ +#ifndef NETDISSECT_REWORKED extern netdissect_options *gndo; #define eflag gndo->ndo_eflag #define fflag gndo->ndo_fflag +#define Kflag gndo->ndo_Kflag #define nflag gndo->ndo_nflag #define Nflag gndo->ndo_Nflag #define Oflag gndo->ndo_Oflag @@ -359,13 +381,19 @@ extern netdissect_options *gndo; #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 tcpmd5secret gndo->ndo_tcpmd5secret #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 snaplen gndo->ndo_snaplen #define snapend gndo->ndo_snapend +#endif diff --git a/contrib/tcpdump/ip.h b/contrib/tcpdump/ip.h index e232ae0d18..a01d0f07d4 100644 --- a/contrib/tcpdump/ip.h +++ b/contrib/tcpdump/ip.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/ip.h,v 1.11.2.1 2007/09/14 01:30:02 guy Exp $ (LBL) */ +/* @(#) $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. diff --git a/contrib/tcpdump/ip6.h b/contrib/tcpdump/ip6.h index acf465c6b0..e4f9fe1c9e 100644 --- a/contrib/tcpdump/ip6.h +++ b/contrib/tcpdump/ip6.h @@ -1,5 +1,5 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/ip6.h,v 1.6.4.1 2005/04/20 10:04:37 guy Exp $ (LBL) */ -/* $NetBSD: ip6.h,v 1.9 2000/07/13 05:34:21 itojun Exp $ */ +/* @(#) $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 $ */ /* diff --git a/contrib/tcpdump/ipfc.h b/contrib/tcpdump/ipfc.h index f822d4af2e..438d115644 100644 --- a/contrib/tcpdump/ipfc.h +++ b/contrib/tcpdump/ipfc.h @@ -18,7 +18,7 @@ * 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) + * @(#) $Header: /tcpdump/master/tcpdump/ipfc.h,v 1.4 2002-12-11 07:13:53 guy Exp $ (LBL) */ struct ipfc_header { diff --git a/contrib/tcpdump/ipproto.c b/contrib/tcpdump/ipproto.c index 66ea3563ce..7b89afb9c8 100755 --- a/contrib/tcpdump/ipproto.c +++ b/contrib/tcpdump/ipproto.c @@ -15,7 +15,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/ipproto.c,v 1.3.2.3 2005/09/20 06:05:37 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/ipproto.c,v 1.6 2005-09-20 06:01:22 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/ipproto.h b/contrib/tcpdump/ipproto.h index 7e0f785b75..f5257863ce 100644 --- a/contrib/tcpdump/ipproto.h +++ b/contrib/tcpdump/ipproto.h @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#) $Header: /tcpdump/master/tcpdump/ipproto.h,v 1.4.2.2 2005/09/20 06:05:37 guy Exp $ (LBL) + * @(#) $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 diff --git a/contrib/tcpdump/ipsec_doi.h b/contrib/tcpdump/ipsec_doi.h index 83d05ea54b..554a2586a0 100644 --- a/contrib/tcpdump/ipsec_doi.h +++ b/contrib/tcpdump/ipsec_doi.h @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -/* YIPS @(#)$Id: ipsec_doi.h,v 1.7 2002/12/11 07:13:53 guy Exp $ */ +/* YIPS @(#)$Id: ipsec_doi.h,v 1.7 2002-12-11 07:13:53 guy Exp $ */ /* refer to RFC 2407 */ diff --git a/contrib/tcpdump/ipx.h b/contrib/tcpdump/ipx.h index a8c1cd5115..bfc301980d 100644 --- a/contrib/tcpdump/ipx.h +++ b/contrib/tcpdump/ipx.h @@ -1,7 +1,7 @@ /* * IPX protocol formats * - * @(#) $Header: /tcpdump/master/tcpdump/ipx.h,v 1.8 2002/12/11 07:13:54 guy Exp $ + * @(#) $Header: /tcpdump/master/tcpdump/ipx.h,v 1.8 2002-12-11 07:13:54 guy Exp $ */ /* well-known sockets */ diff --git a/contrib/tcpdump/isakmp.h b/contrib/tcpdump/isakmp.h index 94fac401d4..85d383d1b3 100644 --- a/contrib/tcpdump/isakmp.h +++ b/contrib/tcpdump/isakmp.h @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -/* YIPS @(#)$Id: isakmp.h,v 1.10 2002/12/11 07:13:54 guy Exp $ */ +/* YIPS @(#)$Id: isakmp.h,v 1.11 2007-08-29 02:38:14 mcr Exp $ */ /* refer to RFC 2408 */ @@ -81,7 +81,7 @@ typedef struct { /* i_cookie + r_cookie */ #define ISAKMP_TIMER_DEFAULT 10 /* seconds */ #define ISAKMP_TRY_DEFAULT 3 /* times */ -/* 3.1 ISAKMP Header Format +/* 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 ! @@ -128,8 +128,11 @@ struct isakmp { #define ISAKMP_NPTYPE_D 12 /* Delete */ #define ISAKMP_NPTYPE_VID 13 /* Vendor ID */ -#define ISAKMP_MAJOR_VERSION 1 -#define ISAKMP_MINOR_VERSION 0 +#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 */ @@ -142,6 +145,13 @@ struct isakmp { /* 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 @@ -151,7 +161,7 @@ struct isakmp { */ struct isakmp_gen { u_int8_t np; /* Next Payload */ - u_int8_t reserved; /* RESERVED, unused, must set to 0 */ + u_int8_t critical; /* bit 7 - critical, rest is RESERVED */ u_int16_t len; /* Payload Length */ }; @@ -188,7 +198,7 @@ struct isakmp_data { 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 isakmp_pl_sa { +struct ikev1_pl_sa { struct isakmp_gen h; u_int32_t doi; /* Domain of Interpretation */ u_int32_t sit; /* Situation */ @@ -202,7 +212,7 @@ struct isakmp_pl_sa { last within the security association proposal, then this field will be 0. */ -struct isakmp_pl_p { +struct ikev1_pl_p { struct isakmp_gen h; u_int8_t p_no; /* Proposal # */ u_int8_t prot_id; /* Protocol */ @@ -218,7 +228,7 @@ struct isakmp_pl_p { then this field will be 3. If the current Transform payload is the last within the proposal, then this field will be 0. */ -struct isakmp_pl_t { +struct ikev1_pl_t { struct isakmp_gen h; u_int8_t t_no; /* Transform # */ u_int8_t t_id; /* Transform-Id */ @@ -227,14 +237,14 @@ struct isakmp_pl_t { }; /* 3.7 Key Exchange Payload */ -struct isakmp_pl_ke { +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 isakmp_pl_id { +struct ikev1_pl_id { struct isakmp_gen h; union { u_int8_t id_type; /* ID Type */ @@ -244,7 +254,7 @@ struct isakmp_pl_id { }; /* 3.9 Certificate Payload */ -struct isakmp_pl_cert { +struct ikev1_pl_cert { struct isakmp_gen h; u_int8_t encode; /* Cert Encoding */ char cert; /* Certificate Data */ @@ -268,7 +278,7 @@ struct isakmp_pl_cert { #define ISAKMP_CERT_SPKI 9 /* 3.10 Certificate Request Payload */ -struct isakmp_pl_cr { +struct ikev1_pl_cr { struct isakmp_gen h; u_int8_t num_cert; /* # Cert. Types */ /* @@ -283,27 +293,27 @@ struct isakmp_pl_cr { /* 3.11 Hash Payload */ /* may not be used, because of having only data. */ -struct isakmp_pl_hash { +struct ikev1_pl_hash { struct isakmp_gen h; /* Hash Data */ }; /* 3.12 Signature Payload */ /* may not be used, because of having only data. */ -struct isakmp_pl_sig { +struct ikev1_pl_sig { struct isakmp_gen h; /* Signature Data */ }; /* 3.13 Nonce Payload */ /* may not be used, because of having only data. */ -struct isakmp_pl_nonce { +struct ikev1_pl_nonce { struct isakmp_gen h; /* Nonce Data */ }; /* 3.14 Notification Payload */ -struct isakmp_pl_n { +struct ikev1_pl_n { struct isakmp_gen h; u_int32_t doi; /* Domain of Interpretation */ u_int8_t prot_id; /* Protocol-ID */ @@ -347,7 +357,7 @@ struct isakmp_pl_n { #define ISAKMP_LOG_RETRY_LIMIT_REACHED 65530 /* 3.15 Delete Payload */ -struct isakmp_pl_d { +struct ikev1_pl_d { struct isakmp_gen h; u_int32_t doi; /* Domain of Interpretation */ u_int8_t prot_id; /* Protocol-Id */ @@ -357,15 +367,15 @@ struct isakmp_pl_d { }; -struct isakmp_ph1tab { - struct isakmp_ph1 *head; - struct isakmp_ph1 *tail; +struct ikev1_ph1tab { + struct ikev1_ph1 *head; + struct ikev1_ph1 *tail; int len; }; struct isakmp_ph2tab { - struct isakmp_ph2 *head; - struct isakmp_ph2 *tail; + struct ikev1_ph2 *head; + struct ikev1_ph2 *tail; int len; }; @@ -375,4 +385,99 @@ struct isakmp_ph2tab { #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.10 Notification Payload */ +struct ikev2_n { + struct isakmp_gen h; + u_int8_t prot_id; /* Protocol-ID */ + u_int8_t spi_size; /* SPI Size */ + u_int16_t type; /* Notify Message Type */ + /* SPI */ + /* Notification Data */ +}; + +enum ikev2_n_type { + 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/contrib/tcpdump/l2tp.h b/contrib/tcpdump/l2tp.h index 156888347f..5be24b9fc5 100644 --- a/contrib/tcpdump/l2tp.h +++ b/contrib/tcpdump/l2tp.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/l2tp.h,v 1.5 2001/11/05 10:03:27 guy Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/l2tp.h,v 1.5 2001-11-05 10:03:27 guy Exp $ (LBL) */ /* * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. diff --git a/contrib/tcpdump/l2vpn.c b/contrib/tcpdump/l2vpn.c index d98e69adfd..a822191782 100755 --- a/contrib/tcpdump/l2vpn.c +++ b/contrib/tcpdump/l2vpn.c @@ -15,7 +15,7 @@ #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)"; + "@(#) $Header: /tcpdump/master/tcpdump/l2vpn.c,v 1.1 2004-06-15 09:42:40 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/l2vpn.h b/contrib/tcpdump/l2vpn.h index 64eb0247b7..766cda546a 100755 --- a/contrib/tcpdump/l2vpn.h +++ b/contrib/tcpdump/l2vpn.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/l2vpn.h,v 1.1 2004/06/15 09:42:41 hannes Exp $ (LBL) */ +/* @(#) $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 diff --git a/contrib/tcpdump/lane.h b/contrib/tcpdump/lane.h index 51b6e19c93..76cc020ea7 100644 --- a/contrib/tcpdump/lane.h +++ b/contrib/tcpdump/lane.h @@ -20,7 +20,7 @@ * */ -/* $Id: lane.h,v 1.7 2002/12/11 07:13:54 guy Exp $ */ +/* $Id: lane.h,v 1.7 2002-12-11 07:13:54 guy Exp $ */ #ifndef ETHER_ADDR_LEN #define ETHER_ADDR_LEN 6 diff --git a/contrib/tcpdump/llc.h b/contrib/tcpdump/llc.h index fc04c671f0..faa72561c9 100644 --- a/contrib/tcpdump/llc.h +++ b/contrib/tcpdump/llc.h @@ -18,7 +18,7 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * @(#) $Header: /tcpdump/master/tcpdump/llc.h,v 1.17.2.4 2007/02/08 07:07:51 guy Exp $ (LBL) + * @(#) $Header: /tcpdump/master/tcpdump/llc.h,v 1.23 2007-04-13 09:43:11 hannes Exp $ (LBL) */ /* @@ -104,6 +104,8 @@ #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. diff --git a/contrib/tcpdump/machdep.c b/contrib/tcpdump/machdep.c index 5b04503a72..2bcf317470 100644 --- a/contrib/tcpdump/machdep.c +++ b/contrib/tcpdump/machdep.c @@ -21,7 +21,7 @@ #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)"; + "@(#) $Header: /tcpdump/master/tcpdump/machdep.c,v 1.13 2003-12-15 03:53:21 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/machdep.h b/contrib/tcpdump/machdep.h index 8d49a7af71..6328c82659 100644 --- a/contrib/tcpdump/machdep.h +++ b/contrib/tcpdump/machdep.h @@ -18,7 +18,7 @@ * 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) + * @(#) $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 diff --git a/contrib/tcpdump/makemib b/contrib/tcpdump/makemib index 2c80bef058..b59e2f105a 100755 --- a/contrib/tcpdump/makemib +++ b/contrib/tcpdump/makemib @@ -27,7 +27,7 @@ # (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) +# @(#) $Id: makemib,v 1.3 2001-09-17 22:16:52 fenner Exp $ (jlv) # # This script will read either ASN.1-style MIB files or the ".defs" files diff --git a/contrib/tcpdump/mpls.h b/contrib/tcpdump/mpls.h index 69fc9c9176..ae1c97e67e 100644 --- a/contrib/tcpdump/mpls.h +++ b/contrib/tcpdump/mpls.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/mpls.h,v 1.1 2004/06/14 14:47:58 hannes Exp $ (LBL) +/* @(#) $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 diff --git a/contrib/tcpdump/nameser.h b/contrib/tcpdump/nameser.h index e6391f43b9..f441f3ea6f 100644 --- a/contrib/tcpdump/nameser.h +++ b/contrib/tcpdump/nameser.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/nameser.h,v 1.14.4.2 2006/11/10 03:15:35 guy Exp $ (LBL) */ +/* @(#) $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. diff --git a/contrib/tcpdump/netbios.h b/contrib/tcpdump/netbios.h index 34abebae8e..d3e2725fc6 100644 --- a/contrib/tcpdump/netbios.h +++ b/contrib/tcpdump/netbios.h @@ -1,7 +1,7 @@ /* * NETBIOS protocol formats * - * @(#) $Header: /tcpdump/master/tcpdump/netbios.h,v 1.3 2002/12/11 07:13:55 guy Exp $ + * @(#) $Header: /tcpdump/master/tcpdump/netbios.h,v 1.3 2002-12-11 07:13:55 guy Exp $ */ struct p8022Hdr { diff --git a/contrib/tcpdump/netdissect.h b/contrib/tcpdump/netdissect.h index 3609455e67..cd6f2f1372 100644 --- a/contrib/tcpdump/netdissect.h +++ b/contrib/tcpdump/netdissect.h @@ -21,7 +21,7 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * @(#) $Header: /tcpdump/master/tcpdump/netdissect.h,v 1.16.2.4 2006/02/08 01:40:09 hannes Exp $ (LBL) + * @(#) $Header: /tcpdump/master/tcpdump/netdissect.h,v 1.23.2.2 2008-04-04 19:42:52 guy Exp $ (LBL) */ #ifndef netdissect_h @@ -77,6 +77,7 @@ extern const char *tok2strbuf(const struct tok *, const char *, int, /* 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; @@ -85,6 +86,7 @@ struct netdissect_options { int ndo_aflag; /* translate network and broadcast addresses */ 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 */ @@ -100,12 +102,17 @@ struct netdissect_options { 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_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_suppress_default_print; /* don't use default_print() for unknown packet types */ @@ -245,7 +252,7 @@ extern const char *dnnum_string(netdissect_options *, u_short); #include -extern void eap_print(netdissect_options *,const u_char *, u_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); @@ -258,6 +265,7 @@ 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); /* stuff that has not yet been rototiled */ #if 0 diff --git a/contrib/tcpdump/nfs.h b/contrib/tcpdump/nfs.h index 3d47c7d3d9..bf6c9838c8 100644 --- a/contrib/tcpdump/nfs.h +++ b/contrib/tcpdump/nfs.h @@ -1,5 +1,5 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/nfs.h,v 1.7 2002/12/11 07:13:55 guy Exp $ (LBL) */ -/* $NetBSD: nfs.h,v 1.1 1996/05/23 22:49:53 fvdl Exp $ */ +/* @(#) $Header: /tcpdump/master/tcpdump/nfs.h,v 1.8.2.1 2007-11-18 03:24:55 guy Exp $ (LBL) */ +/* NetBSD: nfs.h,v 1.1 1996/05/23 22:49:53 fvdl Exp */ /* * Copyright (c) 1989, 1993 @@ -286,21 +286,6 @@ struct nfs_uquad { }; typedef struct nfs_uquad nfsuint64; -#if 0 /* XXX - this doesn't seemed to be used and it doesn't work - * with non-gcc, so comment it out for now. - */ - -/* - * Used to convert between two u_longs and a u_quad_t. - */ -union nfs_quadconvert { - u_int32_t lval[2]; - u_int64_t qval; -}; -typedef union nfs_quadconvert nfsquad_t; - -#endif - /* * NFS Version 3 special file number. */ diff --git a/contrib/tcpdump/nfsfh.h b/contrib/tcpdump/nfsfh.h index b8a82e4bd9..0bca424a2d 100644 --- a/contrib/tcpdump/nfsfh.h +++ b/contrib/tcpdump/nfsfh.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/nfsfh.h,v 1.13 2002/04/24 06:27:05 guy Exp $ (LBL) */ +/* @(#) $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, diff --git a/contrib/tcpdump/nlpid.c b/contrib/tcpdump/nlpid.c index 7dfd6a6f88..47ebb53504 100755 --- a/contrib/tcpdump/nlpid.c +++ b/contrib/tcpdump/nlpid.c @@ -15,7 +15,7 @@ #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)"; + "@(#) $Header: /tcpdump/master/tcpdump/nlpid.c,v 1.4 2004-10-19 15:27:55 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/nlpid.h b/contrib/tcpdump/nlpid.h index fdca446552..31f6b66da6 100644 --- a/contrib/tcpdump/nlpid.h +++ b/contrib/tcpdump/nlpid.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/nlpid.h,v 1.4 2004/10/19 15:27:55 hannes Exp $ (LBL) */ +/* @(#) $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 diff --git a/contrib/tcpdump/ntp.h b/contrib/tcpdump/ntp.h index df856699ae..0614f73ba8 100644 --- a/contrib/tcpdump/ntp.h +++ b/contrib/tcpdump/ntp.h @@ -1,4 +1,4 @@ -/* $Header: /tcpdump/master/tcpdump/ntp.h,v 1.8 2004/01/28 14:34:50 hannes Exp $ */ +/* $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 diff --git a/contrib/tcpdump/oakley.h b/contrib/tcpdump/oakley.h index f40d6073eb..ad328171b3 100644 --- a/contrib/tcpdump/oakley.h +++ b/contrib/tcpdump/oakley.h @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -/* YIPS @(#)$Id: oakley.h,v 1.4 2002/12/11 07:13:56 guy Exp $ */ +/* YIPS @(#)$Id: oakley.h,v 1.4 2002-12-11 07:13:56 guy Exp $ */ /* refer to RFC 2409 */ diff --git a/contrib/tcpdump/ospf.h b/contrib/tcpdump/ospf.h index 91a904fed1..2b1c6ee4c6 100644 --- a/contrib/tcpdump/ospf.h +++ b/contrib/tcpdump/ospf.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/ospf.h,v 1.16.2.2 2006/12/13 08:24:27 hannes Exp $ (LBL) */ +/* @(#) $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. @@ -31,7 +31,7 @@ /* Options field * * +------------------------------------+ - * | * | O | DC | EA | N/P | MC | E | T | + * | DN | O | DC | L | N/P | MC | E | T | * +------------------------------------+ * */ @@ -41,6 +41,7 @@ #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 */ @@ -53,9 +54,10 @@ #define OSPF_AUTH_MD5_LEN 16 /* length of MD5 authentication */ /* db_flags */ -#define OSPF_DB_INIT 0x04 /* */ +#define OSPF_DB_INIT 0x04 #define OSPF_DB_MORE 0x02 -#define OSPF_DB_MASTER 0x01 +#define OSPF_DB_MASTER 0x01 +#define OSPF_DB_RESYNC 0x08 /* RFC4811 */ /* ls_type */ #define LS_TYPE_ROUTER 1 /* router link */ @@ -86,10 +88,10 @@ #define LS_OPAQUE_TE_LINK_SUBTLV_MAX_RES_BW 7 /* rfc3630 */ #define LS_OPAQUE_TE_LINK_SUBTLV_UNRES_BW 8 /* rfc3630 */ #define LS_OPAQUE_TE_LINK_SUBTLV_ADMIN_GROUP 9 /* rfc3630 */ -#define LS_OPAQUE_TE_LINK_SUBTLV_LINK_LOCAL_REMOTE_ID 11 /* draft-ietf-ccamp-ospf-gmpls-extensions */ -#define LS_OPAQUE_TE_LINK_SUBTLV_LINK_PROTECTION_TYPE 14 /* draft-ietf-ccamp-ospf-gmpls-extensions */ -#define LS_OPAQUE_TE_LINK_SUBTLV_INTF_SW_CAP_DESCR 15 /* draft-ietf-ccamp-ospf-gmpls-extensions */ -#define LS_OPAQUE_TE_LINK_SUBTLV_SHARED_RISK_GROUP 16 /* draft-ietf-ccamp-ospf-gmpls-extensions */ +#define LS_OPAQUE_TE_LINK_SUBTLV_LINK_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 */ @@ -106,12 +108,6 @@ #define LS_OPAQUE_RI_TLV_CAP 1 /* draft-ietf-ospf-cap-03 */ -/************************************************* - * - * is the above a bug in the documentation? - * - *************************************************/ - /* rla_link.link_type */ #define RLA_TYPE_ROUTER 1 /* point-to-point to another router */ @@ -140,6 +136,31 @@ #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; @@ -172,9 +193,7 @@ struct lsa { struct rlalink { struct in_addr link_id; struct in_addr link_data; - u_int8_t link_type; - u_int8_t link_toscount; - u_int16_t link_tos0metric; + union un_tos un_tos; } rla_link[1]; /* may repeat */ } un_rla; @@ -235,16 +254,6 @@ struct lsa { } lsa_un; }; - -/* - * TOS metric struct (will be 0 or more in router links update) - */ -struct tos_metric { - u_int8_t tos_type; - u_int8_t tos_zero; - u_int16_t tos_metric; -}; - #define OSPF_AUTH_SIZE 8 /* @@ -275,7 +284,7 @@ struct ospfhdr { /* Database Description packet */ struct { - u_int8_t db_zero[2]; + u_int16_t db_ifmtu; u_int8_t db_options; u_int8_t db_flags; u_int32_t db_seq; @@ -314,3 +323,6 @@ struct ospfhdr { #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(u_int8_t *, u_int); +extern int ospf_print_grace_lsa(u_int8_t *, u_int); diff --git a/contrib/tcpdump/ospf6.h b/contrib/tcpdump/ospf6.h index b8298ead91..e2eabee181 100644 --- a/contrib/tcpdump/ospf6.h +++ b/contrib/tcpdump/ospf6.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/ospf6.h,v 1.6 2002/12/11 07:13:56 guy Exp $ (LBL) */ +/* @(#) $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. @@ -21,13 +21,11 @@ * * OSPF support contributed by Jeffrey Honig (jch@mitchell.cit.cornell.edu) */ -#define OSPF_TYPE_UMD 0 /* UMd's special monitoring packets */ -#define OSPF_TYPE_HELLO 1 /* Hello */ -#define OSPF_TYPE_DB 2 /* Database Description */ -#define OSPF_TYPE_LSR 3 /* Link State Request */ -#define OSPF_TYPE_LSU 4 /* Link State Update */ -#define OSPF_TYPE_LSA 5 /* Link State Ack */ -#define OSPF_TYPE_MAX 6 +#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 */ @@ -50,23 +48,18 @@ #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_TYPE7 7 /* Type 7 LSA */ +#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_MAX 10 +#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 - -/************************************************* - * - * is the above a bug in the documentation? - * - *************************************************/ - +#define LS_SCOPE_U 0x8000 /* rla_link.link_type */ #define RLA_TYPE_ROUTER 1 /* point-to-point to another router */ @@ -78,6 +71,14 @@ #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 @@ -85,19 +86,14 @@ #define SLA_SHIFT_TOS 24 /* asla_metric */ -#define ASLA_FLAG_EXTERNAL 0x04000000 #define ASLA_FLAG_FWDADDR 0x02000000 #define ASLA_FLAG_ROUTETAG 0x01000000 #define ASLA_MASK_METRIC 0x00ffffff -/* multicast vertex type */ -#define MCLA_VERTEX_ROUTER 1 -#define MCLA_VERTEX_NETWORK 2 - typedef u_int32_t rtrid_t; /* link state advertisement header */ -struct lsa_hdr { +struct lsa6_hdr { u_int16_t ls_age; u_int16_t ls_type; rtrid_t ls_stateid; @@ -107,16 +103,16 @@ struct lsa_hdr { u_int16_t ls_length; }; -struct lsa_prefix { +struct lsa6_prefix { u_int8_t lsa_p_len; u_int8_t lsa_p_opt; - u_int16_t lsa_p_mbz; + u_int16_t lsa_p_metric; u_int8_t lsa_p_prefix[4]; }; /* link state advertisement */ -struct lsa { - struct lsa_hdr ls_hdr; +struct lsa6 { + struct lsa6_hdr ls_hdr; /* Link state types */ union { @@ -128,7 +124,7 @@ struct lsa { } rla_flgandopt; #define rla_flags rla_flgandopt.flg #define rla_options rla_flgandopt.opt - struct rlalink { + struct rlalink6 { u_int8_t link_type; u_int8_t link_zero[1]; u_int16_t link_metric; @@ -147,13 +143,13 @@ struct lsa { /* Inter Area Prefix LSA */ struct { u_int32_t inter_ap_metric; - struct lsa_prefix inter_ap_prefix[1]; + struct lsa6_prefix inter_ap_prefix[1]; } un_inter_ap; /* AS external links advertisements */ struct { u_int32_t asla_metric; - struct lsa_prefix asla_prefix[1]; + struct lsa6_prefix asla_prefix[1]; /* some optional fields follow */ } un_asla; @@ -183,7 +179,7 @@ struct lsa { #define llsa_options llsa_priandopt.opt struct in6_addr llsa_lladdr; u_int32_t llsa_nprefix; - struct lsa_prefix llsa_prefix[1]; + struct lsa6_prefix llsa_prefix[1]; } un_llsa; /* Intra-Area-Prefix */ @@ -192,21 +188,12 @@ struct lsa { u_int16_t intra_ap_lstype; rtrid_t intra_ap_lsid; rtrid_t intra_ap_rtid; - struct lsa_prefix intra_ap_prefix[1]; + struct lsa6_prefix intra_ap_prefix[1]; } un_intra_ap; } lsa_un; }; -/* - * TOS metric struct (will be 0 or more in router links update) - */ -struct tos_metric { - u_int8_t tos_type; - u_int8_t tos_zero; - u_int16_t tos_metric; -}; - #define OSPF_AUTH_SIZE 8 /* @@ -246,11 +233,11 @@ struct ospf6hdr { u_int8_t db_mbz; u_int8_t db_flags; u_int32_t db_seq; - struct lsa_hdr db_lshdr[1]; /* may repeat */ + struct lsa6_hdr db_lshdr[1]; /* may repeat */ } un_db; /* Link State Request */ - struct lsr { + struct lsr6 { u_int16_t ls_mbz; u_int16_t ls_type; rtrid_t ls_stateid; @@ -260,12 +247,12 @@ struct ospf6hdr { /* Link State Update */ struct { u_int32_t lsu_count; - struct lsa lsu_lsa[1]; /* may repeat */ + struct lsa6 lsu_lsa[1]; /* may repeat */ } un_lsu; /* Link State Acknowledgement */ struct { - struct lsa_hdr lsa_lshdr[1]; /* may repeat */ + struct lsa6_hdr lsa_lshdr[1]; /* may repeat */ } un_lsa ; } ospf6_un ; }; diff --git a/contrib/tcpdump/oui.c b/contrib/tcpdump/oui.c index 7cdcd40181..e6569d4654 100644 --- a/contrib/tcpdump/oui.c +++ b/contrib/tcpdump/oui.c @@ -15,7 +15,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/oui.c,v 1.4.2.1 2005/04/17 01:20:56 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/oui.c,v 1.8.2.1 2008-01-09 09:44:39 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -39,6 +39,9 @@ struct tok oui_values[] = { { 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"}, { 0, NULL } }; diff --git a/contrib/tcpdump/oui.h b/contrib/tcpdump/oui.h index 4d79e197d4..e70f82ab62 100644 --- a/contrib/tcpdump/oui.h +++ b/contrib/tcpdump/oui.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/oui.h,v 1.3.2.1 2005/04/17 01:20:56 guy Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/oui.h,v 1.7.2.1 2008-01-09 09:44:39 hannes Exp $ (LBL) */ /* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code @@ -27,6 +27,9 @@ extern struct tok smi_values[]; #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 */ /* * These are SMI Network Management Private Enterprise Codes for diff --git a/contrib/tcpdump/parsenfsfh.c b/contrib/tcpdump/parsenfsfh.c index ef1e0ba38b..d5f877d822 100644 --- a/contrib/tcpdump/parsenfsfh.c +++ b/contrib/tcpdump/parsenfsfh.c @@ -42,7 +42,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/parsenfsfh.c,v 1.28.2.1 2007/06/15 19:15:04 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/parsenfsfh.c,v 1.29 2006-06-13 22:21:38 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/pcap-missing.h b/contrib/tcpdump/pcap-missing.h index 1f2fcb422b..5c0ece25b3 100644 --- a/contrib/tcpdump/pcap-missing.h +++ b/contrib/tcpdump/pcap-missing.h @@ -18,7 +18,7 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * @(#) $Header: /tcpdump/master/tcpdump/pcap-missing.h,v 1.2.2.1 2005/06/03 22:10:16 guy Exp $ (LBL) + * @(#) $Header: /tcpdump/master/tcpdump/pcap-missing.h,v 1.3 2005-06-03 22:08:52 guy Exp $ (LBL) */ #ifndef tcpdump_pcap_missing_h diff --git a/contrib/tcpdump/pcap_dump_ftell.c b/contrib/tcpdump/pcap_dump_ftell.c index 438cd29dbe..6eb3a4ab75 100644 --- a/contrib/tcpdump/pcap_dump_ftell.c +++ b/contrib/tcpdump/pcap_dump_ftell.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/pcap_dump_ftell.c,v 1.1.2.1 2005/06/03 22:10:17 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/pcap_dump_ftell.c,v 1.1 2005-06-03 22:08:52 guy Exp $ (LBL)"; #endif #include diff --git a/contrib/tcpdump/pf.h b/contrib/tcpdump/pf.h deleted file mode 100644 index c2d332abb3..0000000000 --- a/contrib/tcpdump/pf.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2001 Daniel Hartmeier - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * @(#) $Header: /tcpdump/master/tcpdump/pf.h,v 1.2 2004/04/02 06:36:25 guy Exp $ (LBL) - */ - -/* from $OpenBSD: pfvar.h,v 1.170 2003/08/22 21:50:34 david Exp $ */ - -enum { PF_INOUT=0, PF_IN=1, PF_OUT=2 }; -enum { PF_PASS=0, PF_DROP=1, PF_SCRUB=2, PF_NAT=3, PF_NONAT=4, - PF_BINAT=5, PF_NOBINAT=6, PF_RDR=7, PF_NORDR=8, PF_SYNPROXY_DROP=9 }; - -/* Reasons code for passing/dropping a packet */ -#define PFRES_MATCH 0 /* Explicit match of a rule */ -#define PFRES_BADOFF 1 /* Bad offset for pull_hdr */ -#define PFRES_FRAG 2 /* Dropping following fragment */ -#define PFRES_SHORT 3 /* Dropping short packet */ -#define PFRES_NORM 4 /* Dropping by normalizer */ -#define PFRES_MEMORY 5 /* Dropped due to lacking mem */ -#define PFRES_MAX 6 /* total+1 */ - -#define PFRES_NAMES { \ - "match", \ - "bad-offset", \ - "fragment", \ - "short", \ - "normalize", \ - "memory", \ - NULL \ -} - -#define PF_RULESET_NAME_SIZE 16 - -/* from $OpenBSD: if_pflog.h,v 1.9 2003/07/15 20:27:27 dhartmei Exp $ */ - -#ifndef IFNAMSIZ -#define IFNAMSIZ 16 -#endif - -struct pfloghdr { - u_int8_t length; - u_int8_t af; - u_int8_t action; - u_int8_t reason; - char ifname[IFNAMSIZ]; - char ruleset[PF_RULESET_NAME_SIZE]; - u_int32_t rulenr; - u_int32_t subrulenr; - u_int8_t dir; - u_int8_t pad[3]; -}; -#define PFLOG_HDRLEN sizeof(struct pfloghdr) diff --git a/contrib/tcpdump/pmap_prot.h b/contrib/tcpdump/pmap_prot.h index f93e841624..67ad62626f 100644 --- a/contrib/tcpdump/pmap_prot.h +++ b/contrib/tcpdump/pmap_prot.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/pmap_prot.h,v 1.1.2.2 2005/04/27 21:44:06 guy Exp $ (LBL) */ +/* @(#) $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 diff --git a/contrib/tcpdump/ppp.h b/contrib/tcpdump/ppp.h index 71621caa9c..f1a2c48b98 100644 --- a/contrib/tcpdump/ppp.h +++ b/contrib/tcpdump/ppp.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/ppp.h,v 1.16 2004/10/20 16:14:16 hannes Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/ppp.h,v 1.16 2004-10-20 16:14:16 hannes Exp $ (LBL) */ /* * Point to Point Protocol (PPP) RFC1331 * diff --git a/contrib/tcpdump/print-802_11.c b/contrib/tcpdump/print-802_11.c index 21e316defc..835d21bd37 100644 --- a/contrib/tcpdump/print-802_11.c +++ b/contrib/tcpdump/print-802_11.c @@ -22,7 +22,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-802_11.c,v 1.31.2.15 2007/07/22 23:14:14 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-802_11.c,v 1.47.2.2 2007-12-29 23:25:28 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -264,7 +264,7 @@ parse_elements(struct mgmt_body_t *pbody, const u_char *p, int offset) if (pbody->tim.length <= 3) break; - if (pbody->tim.length - 3 > sizeof pbody->tim.bitmap) + if (pbody->tim.length - 3 > (int)sizeof pbody->tim.bitmap) return; if (!TTEST2(*(p + offset), pbody->tim.length - 3)) return; @@ -1209,6 +1209,11 @@ 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) { /* @@ -1231,32 +1236,38 @@ ieee802_11_avs_radio_print(const u_char *p, u_int length, u_int caplen) #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, it's - * really DLT_IEEE802_11_RADIO (currently, on Linux, there's no - * ARPHRD_ type for DLT_IEEE802_11_RADIO, as there is a - * ARPHRD_IEEE80211_PRISM for DLT_PRISM_HEADER, so - * ARPHRD_IEEE80211_PRISM is used for DLT_IEEE802_11_RADIO, and - * the first 4 bytes of the header are used to indicate which it is). + * 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; } - if (EXTRACT_32BITS(p) == WLANCAP_MAGIC_COOKIE_V1) + 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) { @@ -1270,19 +1281,21 @@ prism_if_print(const struct pcap_pkthdr *h, const u_char *p) /* * For DLT_IEEE802_11_RADIO; like DLT_IEEE802_11, but with an extra - * header, containing information such as radio information, which we - * currently ignore. + * header, containing information such as radio information. */ u_int ieee802_11_radio_if_print(const struct pcap_pkthdr *h, const u_char *p) { - u_int caplen = h->caplen; - u_int length = h->len; - - if (caplen < 8) { - printf("[|802.11]"); - return caplen; - } + return ieee802_11_radio_print(p, h->len, h->caplen); +} - return ieee802_11_radio_print(p, length, 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/contrib/tcpdump/print-ah.c b/contrib/tcpdump/print-ah.c index 92ed9094d7..ecd106b738 100644 --- a/contrib/tcpdump/print-ah.c +++ b/contrib/tcpdump/print-ah.c @@ -23,7 +23,7 @@ #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)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-ah.c,v 1.22 2003-11-19 00:36:06 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-aodv.c b/contrib/tcpdump/print-aodv.c index 80a547dd30..c5f6622374 100644 --- a/contrib/tcpdump/print-aodv.c +++ b/contrib/tcpdump/print-aodv.c @@ -32,7 +32,7 @@ #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)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-aodv.c,v 1.11 2004-03-24 00:30:19 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-ap1394.c b/contrib/tcpdump/print-ap1394.c index a01ce34cef..dd9bc5a6c2 100644 --- a/contrib/tcpdump/print-ap1394.c +++ b/contrib/tcpdump/print-ap1394.c @@ -20,7 +20,7 @@ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-ap1394.c,v 1.3.2.1 2005/07/07 01:24:33 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-ap1394.c,v 1.5 2006-02-11 22:12:06 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -60,8 +60,8 @@ ap1394_hdr_print(register const u_char *bp, u_int length) fp = (const struct firewire_header *)bp; (void)printf("%s > %s", - linkaddr_string(fp->firewire_dhost, FIREWIRE_EUI64_LEN), - linkaddr_string(fp->firewire_shost, FIREWIRE_EUI64_LEN)); + linkaddr_string(fp->firewire_dhost, LINKADDR_IEEE1394, FIREWIRE_EUI64_LEN), + linkaddr_string(fp->firewire_shost, LINKADDR_IEEE1394, FIREWIRE_EUI64_LEN)); if (!qflag) { (void)printf(", ethertype %s (0x%04x)", diff --git a/contrib/tcpdump/print-arcnet.c b/contrib/tcpdump/print-arcnet.c index 63f9c215d7..48a43030b4 100644 --- a/contrib/tcpdump/print-arcnet.c +++ b/contrib/tcpdump/print-arcnet.c @@ -22,7 +22,7 @@ */ #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)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-arcnet.c,v 1.20 2005-04-06 21:32:38 mcr Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-arp.c b/contrib/tcpdump/print-arp.c index 68e9dc6894..0ca86cfca0 100644 --- a/contrib/tcpdump/print-arp.c +++ b/contrib/tcpdump/print-arp.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-arp.c,v 1.64 2004/04/30 16:42:14 mcr Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-arp.c,v 1.66 2006-03-03 22:53:21 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -49,24 +49,27 @@ static const char rcsid[] _U_ = * 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_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 */ +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. @@ -86,8 +89,8 @@ struct arp_pkthdr { #define ARP_HDRLEN 8 #define HRD(ap) EXTRACT_16BITS(&(ap)->ar_hrd) -#define HLN(ap) ((ap)->ar_hln) -#define PLN(ap) ((ap)->ar_pln) +#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)) @@ -95,6 +98,29 @@ struct arp_pkthdr { #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. * @@ -104,20 +130,18 @@ struct arp_pkthdr { * 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 */ -#define ARPHRD_ATM2225 19 /* ATM (RFC 2225) */ - 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 */ -#define ATMARPOP_NAK 10 /* NAK */ - 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 */ +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. @@ -132,19 +156,19 @@ struct atmarp_pkthdr { #endif #define ATMHRD(ap) EXTRACT_16BITS(&(ap)->aar_hrd) -#define ATMSHLN(ap) ((ap)->aar_shtl & ATMARP_LEN_MASK) +#define ATMSHRD_LEN(ap) ((ap)->aar_shtl & ATMARP_LEN_MASK) #define ATMSSLN(ap) ((ap)->aar_sstl & ATMARP_LEN_MASK) -#define ATMSPLN(ap) ((ap)->aar_spln) +#define ATMSPROTO_LEN(ap) ((ap)->aar_spln) #define ATMOP(ap) EXTRACT_16BITS(&(ap)->aar_op) #define ATMPRO(ap) EXTRACT_16BITS(&(ap)->aar_pro) -#define ATMTHLN(ap) ((ap)->aar_thtl & ATMARP_LEN_MASK) +#define ATMTHRD_LEN(ap) ((ap)->aar_thtl & ATMARP_LEN_MASK) #define ATMTSLN(ap) ((ap)->aar_tstl & ATMARP_LEN_MASK) -#define ATMTPLN(ap) ((ap)->aar_tpln) +#define ATMTPROTO_LEN(ap) ((ap)->aar_tpln) #define aar_sha(ap) ((const u_char *)((ap)+1)) -#define aar_ssa(ap) (aar_sha(ap) + ATMSHLN(ap)) +#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) + ATMSPLN(ap)) -#define aar_tsa(ap) (aar_tha(ap) + ATMTHLN(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)) }; @@ -165,10 +189,10 @@ atmarp_addr_print(netdissect_options *ndo, if (ha_len == 0) ND_PRINT((ndo, "")); else { - ND_PRINT((ndo, "%s", linkaddr_string(ha, ha_len))); + ND_PRINT((ndo, "%s", linkaddr_string(ha, LINKADDR_ATM, ha_len))); if (srca_len != 0) ND_PRINT((ndo, ",%s", - linkaddr_string(srca, srca_len))); + linkaddr_string(srca, LINKADDR_ATM, srca_len))); } } @@ -186,69 +210,86 @@ atmarp_print(netdissect_options *ndo, pro = ATMPRO(ap); op = ATMOP(ap); - if (!ND_TTEST2(*aar_tpa(ap), ATMTPLN(ap))) { - ND_PRINT((ndo, "truncated-atmarp")); + 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) || - ATMSPLN(ap) != 4 || ATMTPLN(ap) != 4) { - ND_PRINT((ndo, "atmarp-#%d for proto #%d (%d/%d) hardware #%d", - op, pro, ATMSPLN(ap), ATMTPLN(ap), hrd)); - return; + 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; + } } - if (pro == ETHERTYPE_TRAIL) - ND_PRINT((ndo, "trailer-")); + + /* print operation */ + printf("%s%s ", + ndo->ndo_vflag ? ", " : "", + tok2str(arpop_values, "Unknown (%u)", op)); + switch (op) { case ARPOP_REQUEST: - ND_PRINT((ndo, "arp who-has %s", ipaddr_string(ATMTPA(ap)))); - if (ATMTHLN(ap) != 0) { + ND_PRINT((ndo, "who-has %s", ipaddr_string(ATMTPA(ap)))); + if (ATMTHRD_LEN(ap) != 0) { ND_PRINT((ndo, " (")); - atmarp_addr_print(ndo, ATMTHA(ap), ATMTHLN(ap), + 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)))); + ND_PRINT((ndo, "tell %s", ipaddr_string(ATMSPA(ap)))); break; case ARPOP_REPLY: - ND_PRINT((ndo, "arp reply %s", ipaddr_string(ATMSPA(ap)))); - ND_PRINT((ndo, " is-at ")); - atmarp_addr_print(ndo, ATMSHA(ap), ATMSHLN(ap), ATMSSA(ap), - ATMSSLN(ap)); + 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, "invarp who-is ")); - atmarp_addr_print(ndo, ATMTHA(ap), ATMTHLN(ap), ATMTSA(ap), + 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), ATMSHLN(ap), ATMSSA(ap), + atmarp_addr_print(ndo, ATMSHA(ap), ATMSHRD_LEN(ap), ATMSSA(ap), ATMSSLN(ap)); break; case ARPOP_INVREPLY: - ND_PRINT((ndo, "invarp reply ")); - atmarp_addr_print(ndo, ATMSHA(ap), ATMSHLN(ap), ATMSSA(ap), + atmarp_addr_print(ndo, ATMSHA(ap), ATMSHRD_LEN(ap), ATMSSA(ap), ATMSSLN(ap)); - ND_PRINT((ndo, " at %s", ipaddr_string(ATMSPA(ap)))); + ND_PRINT((ndo, "at %s", ipaddr_string(ATMSPA(ap)))); break; - case ATMARPOP_NAK: - ND_PRINT((ndo, "nak reply for %s", - ipaddr_string(ATMSPA(ap)))); + case ARPOP_NAK: + ND_PRINT((ndo, "for %s", ipaddr_string(ATMSPA(ap)))); break; default: - ND_PRINT((ndo, "atmarp-#%d", op)); ND_DEFAULTPRINT((const u_char *)ap, caplen); return; } - return; + + out: + ND_PRINT((ndo, ", length %u", length)); + return; + trunc: - ND_PRINT((ndo, "[|atmarp]")); + ND_PRINT((ndo, "[|ARP]")); } void @@ -256,81 +297,115 @@ 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; + u_short pro, hrd, op, linkaddr; ap = (const struct arp_pkthdr *)bp; ND_TCHECK(*ap); + hrd = HRD(ap); - if (hrd == ARPHRD_ATM2225) { - atmarp_print(ndo, bp, length, caplen); - return; - } pro = PRO(ap); op = OP(ap); - if (!ND_TTEST2(*ar_tpa(ap), PLN(ap))) { - ND_PRINT((ndo, "truncated-arp")); + + /* 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; + 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 ((pro != ETHERTYPE_IP && pro != ETHERTYPE_TRAIL) || - PLN(ap) != 4 || HLN(ap) == 0) { - ND_PRINT((ndo, "arp-#%d for proto #%d (%d) hardware #%d (%d)", - op, pro, PLN(ap), hrd, HLN(ap))); - 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; + } } - if (pro == ETHERTYPE_TRAIL) - ND_PRINT((ndo, "trailer-")); + + /* print operation */ + printf("%s%s ", + ndo->ndo_vflag ? ", " : "", + tok2str(arpop_values, "Unknown (%u)", op)); + switch (op) { case ARPOP_REQUEST: - ND_PRINT((ndo, "arp who-has %s", ipaddr_string(TPA(ap)))); - if (memcmp((const char *)ezero, (const char *)THA(ap), HLN(ap)) != 0) + 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), HLN(ap)))); + linkaddr_string(THA(ap), linkaddr, HRD_LEN(ap)))); ND_PRINT((ndo, " tell %s", ipaddr_string(SPA(ap)))); break; case ARPOP_REPLY: - ND_PRINT((ndo, "arp reply %s", ipaddr_string(SPA(ap)))); - ND_PRINT((ndo, " is-at %s", linkaddr_string(SHA(ap), HLN(ap)))); + 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, "rarp who-is %s tell %s", - linkaddr_string(THA(ap), HLN(ap)), - linkaddr_string(SHA(ap), HLN(ap)))); + 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, "rarp reply %s at %s", - linkaddr_string(THA(ap), HLN(ap)), + 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, "invarp who-is %s tell %s", - linkaddr_string(THA(ap), HLN(ap)), - linkaddr_string(SHA(ap), HLN(ap)))); + 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,"invarp reply %s at %s", - linkaddr_string(THA(ap), HLN(ap)), + ND_PRINT((ndo,"%s at %s", + linkaddr_string(THA(ap), linkaddr, HRD_LEN(ap)), ipaddr_string(TPA(ap)))); break; default: - ND_PRINT((ndo, "arp-#%d", op)); ND_DEFAULTPRINT((const u_char *)ap, caplen); return; } - if (hrd != ARPHRD_ETHER) - ND_PRINT((ndo, " hardware #%d", hrd)); + + out: + ND_PRINT((ndo, ", length %u", length)); + return; trunc: - ND_PRINT((ndo, "[|arp]")); + ND_PRINT((ndo, "[|ARP]")); } /* diff --git a/contrib/tcpdump/print-ascii.c b/contrib/tcpdump/print-ascii.c index cd48edd98d..fa8793cb06 100644 --- a/contrib/tcpdump/print-ascii.c +++ b/contrib/tcpdump/print-ascii.c @@ -42,7 +42,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-ascii.c,v 1.16.2.1 2005/07/06 20:54:49 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-ascii.c,v 1.17 2005-07-06 20:53:32 guy Exp $"; #endif #include #include diff --git a/contrib/tcpdump/print-atalk.c b/contrib/tcpdump/print-atalk.c index f1f45a3cb7..6ea1361167 100644 --- a/contrib/tcpdump/print-atalk.c +++ b/contrib/tcpdump/print-atalk.c @@ -23,7 +23,7 @@ #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)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-atalk.c,v 1.81 2004-05-01 09:41:50 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-atm.c b/contrib/tcpdump/print-atm.c index d664d6e5c3..f50918bfb2 100644 --- a/contrib/tcpdump/print-atm.c +++ b/contrib/tcpdump/print-atm.c @@ -20,7 +20,7 @@ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.38.2.6 2006/01/25 13:27:24 hannes Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.48.2.1 2007-10-22 19:39:12 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -43,25 +43,51 @@ static const char rcsid[] _U_ = #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[] = { - { OAMF4SC, "OAM F4 (segment)" }, - { OAMF4EC, "OAM F4 (end)" }, + { 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[] = { - { 0x1, "Fault Management" }, - { 0x2, "Performance Management" }, - { 0x8, "activate/deactivate" }, - { 0xf, "System Management" }, + { 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[] = { - { 0x0, "AIS" }, - { 0x1, "RDI" }, - { 0x4, "Continuity Check" }, - { 0x8, "Loopback" }, + { OAM_FM_FUNCTYPE_AIS, "AIS" }, + { OAM_FM_FUNCTYPE_RDI, "RDI" }, + { OAM_FM_FUNCTYPE_CONTCHECK, "Continuity Check" }, + { OAM_FM_FUNCTYPE_LOOPBACK, "Loopback" }, { 0, NULL } }; @@ -78,6 +104,14 @@ struct tok oam_ad_functype_values[] = { { 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 */ @@ -261,24 +295,24 @@ atm_print(u_int vpi, u_int vci, u_int traftype, const u_char *p, u_int length, if (vpi == 0) { switch (vci) { - case PPC: + case VCI_PPC: sig_print(p, caplen); return; - case BCC: + case VCI_BCC: printf("broadcast sig: "); return; - case OAMF4SC: /* fall through */ - case OAMF4EC: + case VCI_OAMF4SC: /* fall through */ + case VCI_OAMF4EC: oam_print(p, length, ATM_OAM_HEC); return; - case METAC: + case VCI_METAC: printf("meta: "); return; - case ILMIC: + case VCI_ILMIC: printf("ilmi: "); snmp_print(p, length); return; @@ -301,26 +335,53 @@ atm_print(u_int vpi, u_int vci, u_int traftype, const u_char *p, u_int length, } } +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 cell_type, func_type,vpi,vci,payload,clp; + 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+4+hec))>>4) & 0x0f; - func_type = *(p+4+hec) & 0x0f; + 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 %u, clp %u, ", + printf("%s, vpi %u, vci %u, payload [ %s ], clp %u, length %u", tok2str(oam_f_values, "OAM F5", vci), - vpi, vci, payload, clp); + vpi, vci, + tok2str(atm_pty_values, "Unknown", payload), + clp, length); + + if (!vflag) { + return 1; + } - printf("cell-type %s (%u)", + printf("\n\tcell-type %s (%u)", tok2str(oam_celltype_values, "unknown", cell_type), cell_type); @@ -328,9 +389,61 @@ oam_print (const u_char *p, u_int length, u_int hec) { printf(", func-type unknown (%u)", func_type); else printf(", func-type %s (%u)", - bittok2str(oam_functype_values[cell_type],"none",func_type), + tok2str(oam_functype_values[cell_type],"none",func_type), func_type); - printf(", length %u",length); + 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/contrib/tcpdump/print-beep.c b/contrib/tcpdump/print-beep.c index db40d61124..b476dbf96b 100644 --- a/contrib/tcpdump/print-beep.c +++ b/contrib/tcpdump/print-beep.c @@ -11,7 +11,7 @@ #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 $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-beep.c,v 1.6 2003-11-16 09:36:13 guy Exp $"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-bfd.c b/contrib/tcpdump/print-bfd.c index 03e59dc495..6406168b1b 100644 --- a/contrib/tcpdump/print-bfd.c +++ b/contrib/tcpdump/print-bfd.c @@ -15,7 +15,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-bfd.c,v 1.5.2.5 2006/02/02 06:36:37 hannes Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-bfd.c,v 1.10 2006-02-02 06:35:52 hannes Exp $"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-bgp.c b/contrib/tcpdump/print-bgp.c index 34aa7985ec..2dfdf52e07 100644 --- a/contrib/tcpdump/print-bgp.c +++ b/contrib/tcpdump/print-bgp.c @@ -36,7 +36,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.91.2.12 2007/07/14 22:26:35 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.117.2.1 2007-12-08 10:08:07 hannes Exp $"; #endif #include @@ -49,8 +49,8 @@ static const char rcsid[] _U_ = #include "addrtoname.h" #include "extract.h" #include "bgp.h" -#include "l2vpn.h" #include "af.h" +#include "l2vpn.h" struct bgp { u_int8_t bgp_marker[16]; @@ -145,6 +145,9 @@ struct bgp_attr { #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 */ @@ -152,11 +155,13 @@ struct bgp_attr { 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"}, @@ -166,6 +171,7 @@ static struct tok bgp_attr_values[] = { { 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} @@ -176,6 +182,9 @@ static struct tok bgp_attr_values[] = { #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, "{ "}, @@ -267,6 +276,7 @@ static struct tok bgp_notify_minor_open_values[] = { { 4, "Unsupported Optional Parameter"}, { 5, "Authentication Failure"}, { 6, "Unacceptable Hold Time"}, + { 7, "Capability Message Error"}, { 0, NULL} }; @@ -300,6 +310,31 @@ static struct tok bgp_origin_values[] = { { 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 @@ -307,6 +342,8 @@ static struct tok bgp_origin_values[] = { #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 */ #define SAFNUM_MDT 66 /* XXX */ @@ -331,7 +368,8 @@ static struct tok bgp_safi_values[] = { { SAFNUM_VPNUNICAST, "labeled VPN Unicast"}, { SAFNUM_VPNMULTICAST, "labeled VPN Multicast"}, { SAFNUM_VPNUNIMULTICAST, "labeled VPN Unicast+Multicast"}, - { SAFNUM_RT_ROUTING_INFO, "Route Target Routing Information"}, /* draft-marques-ppvpn-rt-constrain-01.txt */ + { SAFNUM_RT_ROUTING_INFO, "Route Target Routing Information"}, + { SAFNUM_MULTICAST_VPN, "Multicast VPN"}, { 0, NULL } }; @@ -349,8 +387,6 @@ static struct tok bgp_safi_values[] = { #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_CISCO_MCAST 0x0009 /* cisco proprietary */ - #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 */ @@ -364,6 +400,9 @@ static struct tok bgp_safi_values[] = { #define BGP_EXT_COM_L2INFO 0x800a /* draft-kompella-ppvpn-l2vpn */ +#define BGP_EXT_COM_SOURCE_AS 0x0009 /* draft-ietf-l3vpn-2547bis-mcast-bgp-02.txt */ +#define BGP_EXT_COM_VRF_RT_IMP 0x010a /* draft-ietf-l3vpn-2547bis-mcast-bgp-02.txt */ + /* 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 @@ -386,7 +425,6 @@ static struct tok bgp_extd_comm_subtype_values[] = { { BGP_EXT_COM_RO_1, "origin"}, { BGP_EXT_COM_RO_2, "origin"}, { BGP_EXT_COM_LINKBAND, "link-BW"}, - { BGP_EXT_COM_CISCO_MCAST, "mdt-group"}, { BGP_EXT_COM_VPN_ORIGIN, "ospf-domain"}, { BGP_EXT_COM_VPN_ORIGIN2, "ospf-domain"}, { BGP_EXT_COM_VPN_ORIGIN3, "ospf-domain"}, @@ -402,6 +440,8 @@ static struct tok bgp_extd_comm_subtype_values[] = { { 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"}, { 0, NULL}, }; @@ -494,6 +534,99 @@ trunc: return -2; } +/* + * 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 */ @@ -507,10 +640,12 @@ bgp_vpn_rd_print (const u_char *pptr) { /* ok lets load the RD format */ switch (EXTRACT_16BITS(pptr)) { - /* AS:IP-address fmt*/ + /* 2-byte-AS:number fmt*/ case 0: - snprintf(pos, sizeof(rd) - (pos - rd), "%u:%u.%u.%u.%u", - EXTRACT_16BITS(pptr+2), *(pptr+4), *(pptr+5), *(pptr+6), *(pptr+7)); + 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*/ @@ -609,6 +744,108 @@ 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 %u", + bgp_vpn_rd_print(pptr), + 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 %u", + bgp_vpn_rd_print(pptr), + 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 @@ -863,6 +1100,63 @@ 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(const struct bgp_attr *attr, const u_char *pptr, int len) { @@ -878,6 +1172,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len) const u_char *tptr; char buf[MAXHOSTNAMELEN + 100]; char tokbuf[TOKBUFSIZE]; + int as_size; tptr = pptr; tlen=len; @@ -895,6 +1190,11 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len) } 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"); @@ -905,21 +1205,33 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len) 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(attr->bgpa_type, 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] * 2; i += 2) { - TCHECK2(tptr[2 + i], 2); - printf("%u ", EXTRACT_16BITS(&tptr[2 + i])); + for (i = 0; i < tptr[1] * as_size; i += as_size) { + TCHECK2(tptr[2 + i], as_size); + printf("%u ", + as_size == 2 ? EXTRACT_16BITS(&tptr[2 + i]) : + EXTRACT_32BITS(&tptr[2 + i])); } TCHECK(tptr[0]); printf("%s", tok2strbuf(bgp_as_path_segment_close_values, "?", tptr[0], tokbuf, sizeof(tokbuf))); TCHECK(tptr[1]); - tptr += 2 + tptr[1] * 2; + tptr += 2 + tptr[1] * as_size; } break; case BGPTYPE_NEXT_HOP: @@ -952,6 +1264,15 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len) printf(" AS #%u, origin %s", EXTRACT_16BITS(tptr), getname(tptr + 2)); break; + case BGPTYPE_AGGREGATOR4: + if (len != 8) { + printf("invalid len"); + break; + } + TCHECK2(tptr[0], 8); + printf(" AS #%u, origin %s", EXTRACT_32BITS(tptr), + getname(tptr + 4)); + break; case BGPTYPE_COMMUNITIES: if (len % 4) { printf("invalid len"); @@ -1027,12 +1348,12 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len) 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): #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_RT_ROUTING_INFO): case (AFNUM_INET6<<8 | SAFNUM_VPNUNICAST): case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST): case (AFNUM_INET6<<8 | SAFNUM_VPNUNIMULTICAST): @@ -1073,6 +1394,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len) 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): if (tlen < (int)sizeof(struct in_addr)) { printf("invalid len"); tlen = 0; @@ -1103,7 +1425,6 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len) case (AFNUM_INET6<<8 | SAFNUM_MULTICAST): case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST): case (AFNUM_INET6<<8 | SAFNUM_LABUNICAST): - case (AFNUM_INET6<<8 | SAFNUM_RT_ROUTING_INFO): if (tlen < (int)sizeof(struct in6_addr)) { printf("invalid len"); tlen = 0; @@ -1248,6 +1569,16 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len) else printf("\n\t %s", buf); break; + case (AFNUM_INET<<8 | SAFNUM_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; #ifdef INET6 case (AFNUM_INET6<<8 | SAFNUM_UNICAST): case (AFNUM_INET6<<8 | SAFNUM_MULTICAST): @@ -1280,15 +1611,6 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len) else printf("\n\t %s", buf); break; - case (AFNUM_INET6<<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; #endif case (AFNUM_VPLS<<8 | SAFNUM_VPLS): case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST): @@ -1459,6 +1781,16 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len) else printf("\n\t %s", buf); break; + case (AFNUM_INET<<8 | SAFNUM_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); @@ -1495,12 +1827,14 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len) switch(extd_comm) { case BGP_EXT_COM_RT_0: case BGP_EXT_COM_RO_0: - printf(": %u:%s", + 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_VRF_RT_IMP: printf(": %s:%u", getname(tptr+2), EXTRACT_16BITS(tptr+6)); @@ -1516,11 +1850,6 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len) printf(": bandwidth: %.3f Mbps", bw.f*8/1000000); break; - case BGP_EXT_COM_CISCO_MCAST: - printf(": AS %u, group %s", - EXTRACT_16BITS(tptr+2), - getname(tptr+4)); - break; case BGP_EXT_COM_VPN_ORIGIN: case BGP_EXT_COM_VPN_ORIGIN2: case BGP_EXT_COM_VPN_ORIGIN3: @@ -1549,6 +1878,9 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len) *(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); @@ -1559,6 +1891,64 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len) } 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); printf("\n\t Origin AS: %u", EXTRACT_32BITS(tptr)); @@ -2077,3 +2467,10 @@ bgp_print(const u_char *dat, int length) trunc: printf(" [|BGP]"); } + +/* + * Local Variables: + * c-style: whitesmith + * c-basic-offset: 4 + * End: + */ diff --git a/contrib/tcpdump/print-bootp.c b/contrib/tcpdump/print-bootp.c index e2086e44ea..b442c18388 100644 --- a/contrib/tcpdump/print-bootp.c +++ b/contrib/tcpdump/print-bootp.c @@ -22,7 +22,7 @@ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.78.2.9 2007/08/21 22:02:08 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.88 2007-09-20 15:04:45 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -352,9 +352,13 @@ static struct tok dhcp_msg_values[] = { { 0, NULL } }; -#define AGENT_SUBOPTION_CIRCUIT_ID 1 +#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 } }; @@ -686,9 +690,11 @@ rfc1048_print(register const u_char *bp) suboptlen); switch (subopt) { - case AGENT_SUBOPTION_CIRCUIT_ID: - fn_printn(bp, suboptlen, NULL); - break; + 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); diff --git a/contrib/tcpdump/print-cdp.c b/contrib/tcpdump/print-cdp.c index 4398fbefda..f8f4427c04 100644 --- a/contrib/tcpdump/print-cdp.c +++ b/contrib/tcpdump/print-cdp.c @@ -26,7 +26,7 @@ #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 $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-cdp.c,v 1.25 2004-10-07 14:53:11 hannes Exp $"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-cfm.c b/contrib/tcpdump/print-cfm.c new file mode 100644 index 0000000000..bd98dd26d2 --- /dev/null +++ b/contrib/tcpdump/print-cfm.c @@ -0,0 +1,641 @@ +/* + * 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 + +#include +#include +#include + +#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: + 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: + 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/contrib/tcpdump/print-chdlc.c b/contrib/tcpdump/print-chdlc.c index b7654f5c65..238e91a98c 100644 --- a/contrib/tcpdump/print-chdlc.c +++ b/contrib/tcpdump/print-chdlc.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.32.2.11 2005/11/29 08:57:10 hannes Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.43 2005-11-29 08:56:19 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-cip.c b/contrib/tcpdump/print-cip.c index 774b700237..e9d672fe76 100644 --- a/contrib/tcpdump/print-cip.c +++ b/contrib/tcpdump/print-cip.c @@ -22,7 +22,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-cip.c,v 1.25.2.1 2005/07/07 01:24:34 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-cip.c,v 1.26 2005-07-07 01:22:17 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-cnfp.c b/contrib/tcpdump/print-cnfp.c index 9fdfbd4d06..86d7128296 100644 --- a/contrib/tcpdump/print-cnfp.c +++ b/contrib/tcpdump/print-cnfp.c @@ -34,7 +34,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-cnfp.c,v 1.16.2.1 2005/04/20 20:53:39 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-cnfp.c,v 1.17 2005-04-20 20:53:18 guy Exp $"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-dccp.c b/contrib/tcpdump/print-dccp.c index e6bfca61af..b7377cf915 100644 --- a/contrib/tcpdump/print-dccp.c +++ b/contrib/tcpdump/print-dccp.c @@ -9,7 +9,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-dccp.c,v 1.1.2.6 2006/02/19 05:08:44 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-dccp.c,v 1.7.2.1 2007-11-09 00:45:16 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -60,9 +60,20 @@ static const char *dccp_feature_nums[] = { "check data checksum", }; +static inline 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) { + int cov = dccp_csum_coverage(dh, len); union phu { struct phdr { u_int32_t src; @@ -86,15 +97,15 @@ static int dccp_cksum(const struct ip *ip, phu.ph.dst = ip_finddst(ip); sp = &phu.pa[0]; - return in_cksum((u_short *)dh, len, sp[0]+sp[1]+sp[2]+sp[3]+sp[4]+sp[5]); + return in_cksum((u_short *)dh, cov, sp[0]+sp[1]+sp[2]+sp[3]+sp[4]+sp[5]); } #ifdef INET6 static int dccp6_cksum(const struct ip6_hdr *ip6, const struct dccp_hdr *dh, u_int len) { size_t i; - const u_int16_t *sp; - u_int32_t sum; + u_int32_t sum = 0; + int cov = dccp_csum_coverage(dh, len); union { struct { struct in6_addr ph_src; @@ -113,23 +124,10 @@ static int dccp6_cksum(const struct ip6_hdr *ip6, const struct dccp_hdr *dh, u_i phu.ph.ph_len = htonl(len); phu.ph.ph_nxt = IPPROTO_DCCP; - sum = 0; for (i = 0; i < sizeof(phu.pa) / sizeof(phu.pa[0]); i++) sum += phu.pa[i]; - sp = (const u_int16_t *)dh; - - for (i = 0; i < (len & ~1); i += 2) - sum += *sp++; - - if (len & 1) - sum += htons((*(const u_int8_t *)sp) << 8); - - while (sum > 0xffff) - sum = (sum & 0xffff) + (sum >> 16); - sum = ~sum & 0xffff; - - return (sum); + return in_cksum((u_short *)dh, cov, sum); } #endif @@ -279,32 +277,21 @@ void dccp_print(const u_char *bp, const u_char *data2, u_int len) } /* checksum calculation */ -#ifdef INET6 - if (ip6) { - if (ip6->ip6_plen && vflag) { - u_int16_t sum, dccp_sum; + 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); - dccp_sum = EXTRACT_16BITS(&dh->dccph_checksum); - printf("cksum 0x%04x", dccp_sum); - if (sum != 0) { - (void)printf(" (incorrect (-> 0x%04x), ",in_cksum_shouldbe(dccp_sum, sum)); - } else - (void)printf(" (correct), "); - } - } else -#endif /* INET6 */ - if (vflag) - { - u_int16_t sum, dccp_sum; - - sum = dccp_cksum(ip, dh, len); - dccp_sum = EXTRACT_16BITS(&dh->dccph_checksum); - printf("cksum 0x%04x", dccp_sum); - if (sum != 0) { - (void)printf(" (incorrect (-> 0x%04x), ",in_cksum_shouldbe(dccp_sum, sum)); - } else - (void)printf(" (correct), "); +#endif + if (sum != 0) + (void)printf("(incorrect -> 0x%04x), ",in_cksum_shouldbe(dccp_sum, sum)); + else + (void)printf("(correct), "); } switch (DCCPH_TYPE(dh)) { diff --git a/contrib/tcpdump/print-decnet.c b/contrib/tcpdump/print-decnet.c index ae7ba5c4ea..7fea582e8a 100644 --- a/contrib/tcpdump/print-decnet.c +++ b/contrib/tcpdump/print-decnet.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-decnet.c,v 1.38.2.1 2005/05/06 02:16:53 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-decnet.c,v 1.39 2005-05-06 02:16:26 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-dhcp6.c b/contrib/tcpdump/print-dhcp6.c index 9f4999d70f..ec0df763c0 100644 --- a/contrib/tcpdump/print-dhcp6.c +++ b/contrib/tcpdump/print-dhcp6.c @@ -40,7 +40,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-dhcp6.c,v 1.35.2.1 2006/10/25 22:04:36 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-dhcp6.c,v 1.36.2.1 2008-02-06 10:26:27 guy Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -80,6 +80,8 @@ static const char rcsid[] _U_ = #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 { @@ -130,6 +132,10 @@ struct dhcp6_relay { # 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 @@ -155,6 +161,15 @@ struct dhcp6_relay { #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; @@ -280,6 +295,24 @@ dhcp6opt_name(int type) 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); @@ -309,6 +342,14 @@ dhcp6stcode(int code) 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); @@ -420,6 +461,7 @@ dhcp6opt_print(const u_char *cp, const u_char *ep) printf(")"); break; case DH6OPT_ORO: + case DH6OPT_ERO: if (optlen % 2) { printf(" ?)"); break; @@ -549,12 +591,15 @@ dhcp6opt_print(const u_char *cp, const u_char *ep) printf(")"); break; case DH6OPT_INTERFACE_ID: + case DH6OPT_SUBSCRIBER_ID: /* * Since we cannot predict the encoding, print hex dump * at most 10 characters. */ + printf(" "); for (i = 0; i < optlen && i < 10; i++) printf("%02x", ((u_char *)(dh6o + 1))[i]); + printf("...)"); break; case DH6OPT_RECONF_MSG: tp = (u_char *)(dh6o + 1); @@ -579,6 +624,8 @@ dhcp6opt_print(const u_char *cp, const u_char *ep) 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; @@ -618,6 +665,21 @@ dhcp6opt_print(const u_char *cp, const u_char *ep) } printf(")"); break; + case DH6OPT_IA_TA: + if (optlen < 4) { + printf(" ?)"); + break; + } + memcpy(&val32, dh6o + 1, sizeof(val32)); + val32 = ntohl(val32); + printf(" IAID:%lu", (unsigned long)val32); + if (optlen > 4) { + /* there are sub-options */ + dhcp6opt_print((u_char *)(dh6o + 1) + 4, + (u_char *)(dh6o + 1) + optlen); + } + printf(")"); + break; case DH6OPT_IA_PD_PREFIX: if (optlen < sizeof(ia_prefix) - 4) { printf(" ?)"); @@ -643,6 +705,7 @@ dhcp6opt_print(const u_char *cp, const u_char *ep) printf(")"); break; case DH6OPT_LIFETIME: + case DH6OPT_CLT_TIME: if (optlen != 4) { printf(" ?)"); break; @@ -651,6 +714,68 @@ dhcp6opt_print(const u_char *cp, const u_char *ep) val32 = ntohl(val32); printf(" %d)", (int)val32); break; + case DH6OPT_REMOTE_ID: + if (optlen < 4) { + printf(" ?)"); + break; + } + tp = (u_char *)(dh6o + 1); + memcpy(&val32, &tp[0], sizeof(val32)); + val32 = ntohl(val32); + printf(" %d ", (int)val32); + /* + * 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: + if (optlen > 0) { + /* there are encapsulated options */ + dhcp6opt_print((u_char *)(dh6o + 1), + (u_char *)(dh6o + 1) + 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; @@ -725,6 +850,12 @@ dhcp6_print(const u_char *cp, u_int length) 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; diff --git a/contrib/tcpdump/print-domain.c b/contrib/tcpdump/print-domain.c index d4a35d8c84..80b4b33d3d 100644 --- a/contrib/tcpdump/print-domain.c +++ b/contrib/tcpdump/print-domain.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.89.2.8 2007/02/13 19:19:27 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.97.2.1 2007-12-09 01:51:12 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -387,13 +387,22 @@ ns_rprint(register const u_char *cp, register const u_char *bp, int is_mdns) printf(" (Cache flush)"); } - /* ignore ttl */ - cp += 2; - /* if T_OPT, save opt_flags */ - if (typ == T_OPT) + if (typ == T_OPT) { + /* get opt flags */ + cp += 2; opt_flags = EXTRACT_16BITS(cp); - /* ignore rest of ttl */ - cp += 2; + /* 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; @@ -408,7 +417,7 @@ ns_rprint(register const u_char *cp, register const u_char *bp, int is_mdns) case T_A: if (!TTEST2(*cp, sizeof(struct in_addr))) return(NULL); - printf(" %s", ipaddr_string(cp)); + printf(" %s", intoa(htonl(EXTRACT_32BITS(cp)))); break; case T_NS: @@ -475,15 +484,24 @@ ns_rprint(register const u_char *cp, register const u_char *bp, int is_mdns) #ifdef INET6 case T_AAAA: + { + struct in6_addr addr; + char ntop_buf[INET6_ADDRSTRLEN]; + if (!TTEST2(*cp, sizeof(struct in6_addr))) return(NULL); - printf(" %s", ip6addr_string(cp)); + 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); @@ -497,7 +515,8 @@ ns_rprint(register const u_char *cp, register const u_char *bp, int is_mdns) return(NULL); memset(&a, 0, sizeof(a)); memcpy(&a.s6_addr[pbyte], cp + 1, sizeof(a) - pbyte); - printf(" %u %s", pbit, ip6addr_string(&a)); + printf(" %u %s", pbit, + inet_ntop(AF_INET6, &a, ntop_buf, sizeof(ntop_buf))); } if (pbit > 0) { putchar(' '); diff --git a/contrib/tcpdump/print-dtp.c b/contrib/tcpdump/print-dtp.c new file mode 100644 index 0000000000..c358a89307 --- /dev/null +++ b/contrib/tcpdump/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 + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include +#include + +#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/contrib/tcpdump/print-dvmrp.c b/contrib/tcpdump/print-dvmrp.c index 2c159bf945..437e7160c7 100644 --- a/contrib/tcpdump/print-dvmrp.c +++ b/contrib/tcpdump/print-dvmrp.c @@ -21,7 +21,7 @@ #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)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-dvmrp.c,v 1.27 2003-11-19 09:42:04 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-eap.c b/contrib/tcpdump/print-eap.c index fb39e76f89..9fb333ad86 100644 --- a/contrib/tcpdump/print-eap.c +++ b/contrib/tcpdump/print-eap.c @@ -17,12 +17,13 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * Format and print bootp packets. + * Format and print EAP packets. + * */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-eap.c,v 1.3 2004/04/23 19:03:39 mcr Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-eap.c,v 1.5 2007-10-04 16:41:33 hannes Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -35,37 +36,272 @@ static const char rcsid[] _U_ = #include #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]; - unsigned char data[1]; + 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 bootp requests + * Print EAP requests / responses */ void -eap_print(netdissect_options *ndo, - register const u_char *cp, - u_int length _U_) +eap_print(netdissect_options *ndo _U_, + register const u_char *cp, + u_int length _U_) { - const struct eap_packet_t *eap; + 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; - eap = (const struct eap_packet_t *)cp; - ND_TCHECK(eap->data); + /* + * 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; - ND_PRINT((ndo, "EAP code=%u id=%u length=%u ", - eap->code, eap->id, (eap->length[0]<<8) + eap->length[1])); + 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 (!ndo->ndo_vflag) - return; + if (EAP_TLS_EXTRACT_BIT_L(*(tptr+5))) { + printf(" len %u", EXTRACT_32BITS(tptr+6)); + } + break; -trunc: - ; + 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/contrib/tcpdump/print-egp.c b/contrib/tcpdump/print-egp.c index e5a811d7dc..4a1d046531 100644 --- a/contrib/tcpdump/print-egp.c +++ b/contrib/tcpdump/print-egp.c @@ -20,7 +20,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-egp.c,v 1.37 2005/01/12 11:19:09 hannes Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-egp.c,v 1.38 2006-02-11 22:13:24 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -226,13 +226,23 @@ egp_print(register const u_int8_t *bp, register u_int length) printf("[|egp]"); return; } - (void)printf("egp: "); + + 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; } - printf("as:%d seq:%d", EXTRACT_16BITS(&egp->egp_as), EXTRACT_16BITS(&egp->egp_sequence)); type = egp->egp_type; code = egp->egp_code; diff --git a/contrib/tcpdump/print-eigrp.c b/contrib/tcpdump/print-eigrp.c index 3168b3ca78..2787bafb9d 100644 --- a/contrib/tcpdump/print-eigrp.c +++ b/contrib/tcpdump/print-eigrp.c @@ -16,7 +16,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-eigrp.c,v 1.5.2.2 2005/05/06 02:53:41 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-eigrp.c,v 1.7 2005-05-06 02:53:26 guy Exp $"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-enc.c b/contrib/tcpdump/print-enc.c index f9b871b351..9569534cbd 100644 --- a/contrib/tcpdump/print-enc.c +++ b/contrib/tcpdump/print-enc.c @@ -23,7 +23,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-enc.c,v 1.4 2005/04/06 21:32:39 mcr Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-enc.c,v 1.4.4.1 2008-02-06 10:34:15 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -70,8 +70,17 @@ enc_if_print(const struct pcap_pkthdr *h, register const u_char *p) printf("SPI 0x%08x: ", (u_int32_t)ntohl(hdr->spi)); length -= ENC_HDRLEN; - /* XXX - use the address family */ - ip_print(gndo, p + ENC_HDRLEN, length); + caplen -= ENC_HDRLEN; + p += ENC_HDRLEN; + + switch (hdr->af) { + case AF_INET: + ip_print(gndo, p, length); + break; + case AF_INET6: + ip6_print(p, length); + break; + } out: return (ENC_HDRLEN); diff --git a/contrib/tcpdump/print-esp.c b/contrib/tcpdump/print-esp.c index 3ccc899e9c..260fe8710e 100644 --- a/contrib/tcpdump/print-esp.c +++ b/contrib/tcpdump/print-esp.c @@ -23,7 +23,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-esp.c,v 1.55.2.1 2005/04/21 06:44:57 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-esp.c,v 1.56 2005-04-21 06:44:40 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-ether.c b/contrib/tcpdump/print-ether.c index f71a7ccdca..b66e885c6b 100644 --- a/contrib/tcpdump/print-ether.c +++ b/contrib/tcpdump/print-ether.c @@ -20,7 +20,7 @@ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.95.2.6 2006/02/20 18:15:03 hannes Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.105.2.1 2008-02-06 10:49:22 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -65,14 +65,19 @@ const struct tok ethertype_values[] = { { 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" }, { 0, NULL} }; @@ -291,6 +296,10 @@ ether_encap_print(u_short ether_type, const u_char *p, eap_print(gndo, p, length); return (1); + case ETHERTYPE_RRCP: + rrcp_print(gndo, p - 14 , length + 14); + return (1); + case ETHERTYPE_PPP: if (length) { printf(": "); @@ -298,10 +307,23 @@ ether_encap_print(u_short ether_type, const u_char *p, } return (1); + case ETHERTYPE_MPCP: + mpcp_print(p, length); + return (1); + case ETHERTYPE_SLOW: slow_print(p, length); return (1); + case ETHERTYPE_CFM: + case ETHERTYPE_CFM_OLD: + cfm_print(p, length); + return (1); + + case ETHERTYPE_LLDP: + lldp_print(p, length); + return (1); + case ETHERTYPE_LOOPBACK: return (1); diff --git a/contrib/tcpdump/print-fddi.c b/contrib/tcpdump/print-fddi.c index eeb7191b3f..1e7d554ad7 100644 --- a/contrib/tcpdump/print-fddi.c +++ b/contrib/tcpdump/print-fddi.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.64.2.2 2005/11/13 12:12:59 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.66 2005-11-13 12:12:41 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-fr.c b/contrib/tcpdump/print-fr.c index b53a88bdc8..f71aee6652 100644 --- a/contrib/tcpdump/print-fr.c +++ b/contrib/tcpdump/print-fr.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#)$Header: /tcpdump/master/tcpdump/print-fr.c,v 1.32.2.15 2006/02/01 14:39:56 hannes Exp $ (LBL)"; + "@(#)$Header: /tcpdump/master/tcpdump/print-fr.c,v 1.51 2006-06-23 22:20:32 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -100,7 +100,7 @@ struct tok frf_flag_values[] = { /* 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 *sdlcore, +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)) @@ -130,14 +130,26 @@ static int parse_q922_addr(const u_char *p, u_int *dlci, u_int *sdlcore, flags[3] = p[0] & 0x02; - if (p[0] & 0x02) - *sdlcore = p[0] >> 2; - else - *dlci = (*dlci << 6) | (p[0] >> 2); + *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 +---------------------------+ @@ -222,13 +234,12 @@ fr_print(register const u_char *p, u_int length) { u_int16_t extracted_ethertype; u_int dlci; - u_int sdlcore; u_int addr_len; u_int16_t nlpid; u_int hdr_len; u_int8_t flags[4]; - if (parse_q922_addr(p, &dlci, &sdlcore, &addr_len, flags)) { + if (parse_q922_addr(p, &dlci, &addr_len, flags)) { printf("Q.922, invalid address"); return 0; } @@ -730,25 +741,29 @@ q933_print(const u_char *p, u_int length) codeset = p[2]&0x0f; /* extract the codeset */ - if (p[2] == MSG_ANSI_LOCKING_SHIFT) - is_ansi = 1; + 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])); + 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 */ @@ -756,49 +771,57 @@ q933_print(const u_char *p, u_int length) printf("[|q.933]"); return; } - length -= 2 - is_ansi; + length -= 2 + is_ansi; ptemp += 2 + is_ansi; /* Loop through the rest of IE */ - while (length > sizeof(struct ie_tlv_header_t )) { + 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 */ + 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 + } 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 intereststing in non-verbose mode */ - if (vflag) + * 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), + 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) + if (ie_p->ie_type == 0 || ie_p->ie_len == 0) { return; + } - if (fr_q933_print_ie_codeset[codeset] != NULL) + 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) + } + + 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) + 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) + if (!vflag) { printf(", length %u",olen); + } } static int @@ -810,24 +833,27 @@ fr_q933_print_ie_codeset5(const struct ie_tlv_header_t *ie_p, const u_char *p) case FR_LMI_ANSI_REPORT_TYPE_IE: /* fall through */ case FR_LMI_CCITT_REPORT_TYPE_IE: - if (vflag) + 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) + 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) + if (!vflag) { printf(", "); + } /* now parse the DLCI information element. */ if ((ie_p->ie_len < 3) || (p[2] & 0x80) || @@ -836,14 +862,17 @@ fr_q933_print_ie_codeset5(const struct ie_tlv_header_t *ie_p, const u_char *p) ((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)) + !(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) + if (ie_p->ie_len == 4) { dlci = (dlci << 6) | ((p[4] & 0x7E) >> 1); - else if (ie_p->ie_len == 5) + } + 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, " : "", diff --git a/contrib/tcpdump/print-frag6.c b/contrib/tcpdump/print-frag6.c index 2c7788ba26..e125bd3ef9 100644 --- a/contrib/tcpdump/print-frag6.c +++ b/contrib/tcpdump/print-frag6.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-frag6.c,v 1.19.2.1 2005/04/20 22:33:21 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-frag6.c,v 1.20 2005-04-20 22:33:06 guy Exp $"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-gre.c b/contrib/tcpdump/print-gre.c index d739356ac8..55f0e9d16b 100644 --- a/contrib/tcpdump/print-gre.c +++ b/contrib/tcpdump/print-gre.c @@ -38,7 +38,7 @@ #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)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-gre.c,v 1.28 2005-04-06 21:32:39 mcr Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-hsrp.c b/contrib/tcpdump/print-hsrp.c index 1d22247e8e..06304fd567 100644 --- a/contrib/tcpdump/print-hsrp.c +++ b/contrib/tcpdump/print-hsrp.c @@ -31,7 +31,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-hsrp.c,v 1.9.2.1 2005/05/06 07:57:17 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-hsrp.c,v 1.10 2005-05-06 07:56:52 guy Exp $"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-icmp.c b/contrib/tcpdump/print-icmp.c index e9e8459f41..36bff6a412 100644 --- a/contrib/tcpdump/print-icmp.c +++ b/contrib/tcpdump/print-icmp.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.81.2.6 2007/09/13 17:40:18 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.87 2007-09-13 17:42:31 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -412,7 +412,7 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented) case ICMP_UNREACH_NEEDFRAG: { register const struct mtu_discovery *mp; - mp = (struct mtu_discovery *)&dp->icmp_void; + mp = (struct mtu_discovery *)(u_char *)&dp->icmp_void; mtu = EXTRACT_16BITS(&mp->nexthopmtu); if (mtu) { (void)snprintf(buf, sizeof(buf), diff --git a/contrib/tcpdump/print-icmp6.c b/contrib/tcpdump/print-icmp6.c index c5039247af..41d56b68da 100644 --- a/contrib/tcpdump/print-icmp6.c +++ b/contrib/tcpdump/print-icmp6.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-icmp6.c,v 1.79.2.6 2005/09/05 09:29:28 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-icmp6.c,v 1.85.2.1 2008-02-05 19:36:58 guy Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -1192,9 +1192,9 @@ icmp6_rrenum_print(const u_char *bp, const u_char *ep) F(ICMP6_RR_FLAGS_PREVDONE, "P")); } printf("seg=%u,", rr6->rr_segnum); - printf("maxdelay=%u", rr6->rr_maxdelay); + printf("maxdelay=%u", EXTRACT_16BITS(&rr6->rr_maxdelay)); if (rr6->rr_reserved) - printf("rsvd=0x%x", EXTRACT_16BITS(&rr6->rr_reserved)); + printf("rsvd=0x%x", EXTRACT_32BITS(&rr6->rr_reserved)); /*[*/ printf("]"); #undef F diff --git a/contrib/tcpdump/print-igmp.c b/contrib/tcpdump/print-igmp.c index c310d55b9d..a848562985 100644 --- a/contrib/tcpdump/print-igmp.c +++ b/contrib/tcpdump/print-igmp.c @@ -21,7 +21,7 @@ #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)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-igmp.c,v 1.15 2004-03-24 00:59:16 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-igrp.c b/contrib/tcpdump/print-igrp.c index 898471d08f..3cede7ec89 100644 --- a/contrib/tcpdump/print-igrp.c +++ b/contrib/tcpdump/print-igrp.c @@ -23,7 +23,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-igrp.c,v 1.20.2.1 2005/04/20 21:02:15 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-igrp.c,v 1.21 2005-04-20 21:01:56 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-ip.c b/contrib/tcpdump/print-ip.c index 07238f51d5..8bdf5ebce3 100644 --- a/contrib/tcpdump/print-ip.c +++ b/contrib/tcpdump/print-ip.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.149.2.9 2007/09/14 01:30:02 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.159 2007-09-14 01:29:28 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -666,7 +666,7 @@ ip_print(netdissect_options *ndo, } } - printf(") "); + printf(")\n "); } /* diff --git a/contrib/tcpdump/print-ip6.c b/contrib/tcpdump/print-ip6.c index 29e5988b19..0758bb952e 100644 --- a/contrib/tcpdump/print-ip6.c +++ b/contrib/tcpdump/print-ip6.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.47.2.5 2007/09/21 07:07:52 hannes Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.52 2007-09-21 07:05:33 hannes Exp $"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-ip6opts.c b/contrib/tcpdump/print-ip6opts.c index 82163a261e..7a4bf5593a 100644 --- a/contrib/tcpdump/print-ip6opts.c +++ b/contrib/tcpdump/print-ip6opts.c @@ -33,7 +33,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-ip6opts.c,v 1.17.2.1 2005/04/20 22:19:06 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-ip6opts.c,v 1.18 2005-04-20 22:18:50 guy Exp $"; #endif #ifdef INET6 diff --git a/contrib/tcpdump/print-ipcomp.c b/contrib/tcpdump/print-ipcomp.c index 099e5ad9b6..89130a373c 100644 --- a/contrib/tcpdump/print-ipcomp.c +++ b/contrib/tcpdump/print-ipcomp.c @@ -21,7 +21,7 @@ #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 $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-ipcomp.c,v 1.20 2003-11-19 00:36:08 guy Exp $"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-ipfc.c b/contrib/tcpdump/print-ipfc.c index 6712e5f92a..c980765196 100644 --- a/contrib/tcpdump/print-ipfc.c +++ b/contrib/tcpdump/print-ipfc.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-ipfc.c,v 1.7.2.2 2005/11/13 12:12:59 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-ipfc.c,v 1.9 2005-11-13 12:12:42 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-ipx.c b/contrib/tcpdump/print-ipx.c index 5309aa47d1..604561c608 100644 --- a/contrib/tcpdump/print-ipx.c +++ b/contrib/tcpdump/print-ipx.c @@ -24,7 +24,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-ipx.c,v 1.40.2.2 2005/05/06 08:27:00 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-ipx.c,v 1.42 2005-05-06 08:26:44 guy Exp $"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-isakmp.c b/contrib/tcpdump/print-isakmp.c index 09972f0292..763f58aa5e 100644 --- a/contrib/tcpdump/print-isakmp.c +++ b/contrib/tcpdump/print-isakmp.c @@ -30,9 +30,10 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-isakmp.c,v 1.51 2005/04/07 00:28:17 mcr Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-isakmp.c,v 1.56 2007-08-29 12:31:00 mcr Exp $ (LBL)"; #endif +#define NETDISSECT_REWORKED #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -59,39 +60,64 @@ static const char rcsid[] _U_ = #define sockaddr_storage sockaddr #endif -static const u_char *isakmp_sa_print(const struct isakmp_gen *, - u_int, const u_char *, u_int32_t, u_int32_t, u_int32_t, int); -static const u_char *isakmp_p_print(const struct isakmp_gen *, - u_int, const u_char *, u_int32_t, u_int32_t, u_int32_t, int); -static const u_char *isakmp_t_print(const struct isakmp_gen *, - u_int, const u_char *, u_int32_t, u_int32_t, u_int32_t, int); -static const u_char *isakmp_ke_print(const struct isakmp_gen *, - u_int, const u_char *, u_int32_t, u_int32_t, u_int32_t, int); -static const u_char *isakmp_id_print(const struct isakmp_gen *, - u_int, const u_char *, u_int32_t, u_int32_t, u_int32_t, int); -static const u_char *isakmp_cert_print(const struct isakmp_gen *, - u_int, const u_char *, u_int32_t, u_int32_t, u_int32_t, int); -static const u_char *isakmp_cr_print(const struct isakmp_gen *, - u_int, const u_char *, u_int32_t, u_int32_t, u_int32_t, int); -static const u_char *isakmp_sig_print(const struct isakmp_gen *, - u_int, const u_char *, u_int32_t, u_int32_t, u_int32_t, int); -static const u_char *isakmp_hash_print(const struct isakmp_gen *, - u_int, const u_char *, u_int32_t, u_int32_t, u_int32_t, int); -static const u_char *isakmp_nonce_print(const struct isakmp_gen *, - u_int, const u_char *, u_int32_t, u_int32_t, u_int32_t, int); -static const u_char *isakmp_n_print(const struct isakmp_gen *, - u_int, const u_char *, u_int32_t, u_int32_t, u_int32_t, int); -static const u_char *isakmp_d_print(const struct isakmp_gen *, - u_int, const u_char *, u_int32_t, u_int32_t, u_int32_t, int); -static const u_char *isakmp_vid_print(const struct isakmp_gen *, - u_int, const u_char *, u_int32_t, u_int32_t, u_int32_t, int); -static const u_char *isakmp_sub0_print(u_char, const struct isakmp_gen *, +#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_e); +DECLARE_PRINTER(v2_cp); +DECLARE_PRINTER(v2_eap); + +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 *isakmp_sub_print(u_char, const struct isakmp_gen *, +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, + 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 { @@ -107,36 +133,73 @@ static const char *protoidstr[] = { /* isakmp->np */ static const char *npstr[] = { - "none", "sa", "p", "t", "ke", "id", "cert", "cr", "hash", - "sig", "nonce", "n", "d", "vid" + "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[])(const struct isakmp_gen *, u_int, - const u_char *, u_int32_t, u_int32_t, u_int32_t, int) = { +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, - isakmp_sa_print, - isakmp_p_print, - isakmp_t_print, - isakmp_ke_print, - isakmp_id_print, - isakmp_cert_print, - isakmp_cr_print, - isakmp_hash_print, - isakmp_sig_print, - isakmp_nonce_print, - isakmp_n_print, - isakmp_d_print, - isakmp_vid_print, + 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 */ + ikev2_e_print, /* 46 */ + ikev2_cp_print, /* 47 */ + ikev2_eap_print, /* 48 */ }; /* isakmp->etype */ static const char *etypestr[] = { - "none", "base", "ident", "auth", "agg", "inf", NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - "oakley-quick", "oakley-newgroup", +/* 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) \ @@ -145,6 +208,13 @@ static const char *etypestr[] = { #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) @@ -322,21 +392,54 @@ cookie_sidecheck(int i, const u_char *bp2, int initiator) } static int -rawprint(caddr_t loc, size_t len) +rawprint(netdissect_options *ndo, caddr_t loc, size_t len) { static u_char *p; size_t i; - TCHECK2(*loc, len); + ND_TCHECK2(*loc, len); p = (u_char *)loc; for (i = 0; i < len; i++) - printf("%02x", p[i] & 0xff); + ND_PRINT((ndo,"%02x", p[i] & 0xff)); 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; @@ -344,8 +447,9 @@ struct attrmap { }; static const u_char * -isakmp_attrmap_print(const u_char *p, const u_char *ep, - const struct attrmap *map, size_t nmap) +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; @@ -357,33 +461,33 @@ isakmp_attrmap_print(const u_char *p, const u_char *ep, else totlen = 4 + EXTRACT_16BITS(&q[1]); if (ep < p + totlen) { - printf("[|attr]"); + ND_PRINT((ndo,"[|attr]")); return ep + 1; } - printf("("); + ND_PRINT((ndo,"(")); t = EXTRACT_16BITS(&q[0]) & 0x7fff; if (map && t < nmap && map[t].type) - printf("type=%s ", map[t].type); + ND_PRINT((ndo,"type=%s ", map[t].type)); else - printf("type=#%d ", t); + ND_PRINT((ndo,"type=#%d ", t)); if (p[0] & 0x80) { - printf("value="); + ND_PRINT((ndo,"value=")); v = EXTRACT_16BITS(&q[1]); if (map && t < nmap && v < map[t].nvalue && map[t].value[v]) - printf("%s", map[t].value[v]); + ND_PRINT((ndo,"%s", map[t].value[v])); else - rawprint((caddr_t)&q[1], 2); + rawprint(ndo, (caddr_t)&q[1], 2); } else { - printf("len=%d value=", EXTRACT_16BITS(&q[1])); - rawprint((caddr_t)&p[4], EXTRACT_16BITS(&q[1])); + ND_PRINT((ndo,"len=%d value=", EXTRACT_16BITS(&q[1]))); + rawprint(ndo, (caddr_t)&p[4], EXTRACT_16BITS(&q[1])); } - printf(")"); + ND_PRINT((ndo,")")); return p + totlen; } static const u_char * -isakmp_attr_print(const u_char *p, const u_char *ep) +ikev1_attr_print(netdissect_options *ndo, const u_char *p, const u_char *ep) { u_int16_t *q; int totlen; @@ -395,129 +499,166 @@ isakmp_attr_print(const u_char *p, const u_char *ep) else totlen = 4 + EXTRACT_16BITS(&q[1]); if (ep < p + totlen) { - printf("[|attr]"); + ND_PRINT((ndo,"[|attr]")); return ep + 1; } - printf("("); + ND_PRINT((ndo,"(")); t = EXTRACT_16BITS(&q[0]) & 0x7fff; - printf("type=#%d ", t); + ND_PRINT((ndo,"type=#%d ", t)); if (p[0] & 0x80) { - printf("value="); + ND_PRINT((ndo,"value=")); t = q[1]; - rawprint((caddr_t)&q[1], 2); + rawprint(ndo, (caddr_t)&q[1], 2); } else { - printf("len=%d value=", EXTRACT_16BITS(&q[1])); - rawprint((caddr_t)&p[2], EXTRACT_16BITS(&q[1])); + ND_PRINT((ndo,"len=%d value=", EXTRACT_16BITS(&q[1]))); + rawprint(ndo, (caddr_t)&p[2], EXTRACT_16BITS(&q[1])); } - printf(")"); + ND_PRINT((ndo,")")); return p + totlen; } static const u_char * -isakmp_sa_print(const struct isakmp_gen *ext, +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 isakmp_pl_sa *p; - struct isakmp_pl_sa sa; + 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; - printf("%s:", NPSTR(ISAKMP_NPTYPE_SA)); + ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_SA))); - p = (struct isakmp_pl_sa *)ext; - TCHECK(*p); + 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) { - printf(" doi=%d", doi); - printf(" situation=%u", (u_int32_t)ntohl(sa.sit)); + ND_PRINT((ndo," doi=%d", doi)); + ND_PRINT((ndo," situation=%u", (u_int32_t)ntohl(sa.sit))); return (u_char *)(p + 1); } - printf(" doi=ipsec"); + ND_PRINT((ndo," doi=ipsec")); q = (u_int32_t *)&sa.sit; - printf(" situation="); + ND_PRINT((ndo," situation=")); t = 0; if (sit & 0x01) { - printf("identity"); + ND_PRINT((ndo,"identity")); t++; } if (sit & 0x02) { - printf("%ssecrecy", t ? "+" : ""); + ND_PRINT((ndo,"%ssecrecy", t ? "+" : "")); t++; } if (sit & 0x04) - printf("%sintegrity", t ? "+" : ""); + ND_PRINT((ndo,"%sintegrity", t ? "+" : "")); np = (u_char *)ext + sizeof(sa); if (sit != 0x01) { - TCHECK2(*(ext + 1), sizeof(ident)); + ND_TCHECK2(*(ext + 1), sizeof(ident)); safememcpy(&ident, ext + 1, sizeof(ident)); - printf(" ident=%u", (u_int32_t)ntohl(ident)); + ND_PRINT((ndo," ident=%u", (u_int32_t)ntohl(ident))); np += sizeof(ident); } ext = (struct isakmp_gen *)np; - TCHECK(*ext); + ND_TCHECK(*ext); - cp = isakmp_sub_print(ISAKMP_NPTYPE_P, ext, ep, phase, doi, proto0, + cp = ikev1_sub_print(ndo, ISAKMP_NPTYPE_P, ext, ep, phase, doi, proto0, depth); return cp; trunc: - printf(" [|%s]", NPSTR(ISAKMP_NPTYPE_SA)); + ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_SA))); return NULL; } static const u_char * -isakmp_p_print(const struct isakmp_gen *ext, u_int item_len _U_, +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 isakmp_pl_p *p; - struct isakmp_pl_p prop; + const struct ikev1_pl_p *p; + struct ikev1_pl_p prop; const u_char *cp; - printf("%s:", NPSTR(ISAKMP_NPTYPE_P)); + ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_P))); - p = (struct isakmp_pl_p *)ext; - TCHECK(*p); + p = (struct ikev1_pl_p *)ext; + ND_TCHECK(*p); safememcpy(&prop, ext, sizeof(prop)); - printf(" #%d protoid=%s transform=%d", - prop.p_no, PROTOIDSTR(prop.prot_id), prop.num_t); + ND_PRINT((ndo," #%d protoid=%s transform=%d", + prop.p_no, PROTOIDSTR(prop.prot_id), prop.num_t)); if (prop.spi_size) { - printf(" spi="); - if (!rawprint((caddr_t)(p + 1), 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); - TCHECK(*ext); - - cp = isakmp_sub_print(ISAKMP_NPTYPE_T, ext, ep, phase, doi0, - prop.prot_id, depth); - + ND_TCHECK(*ext); + + cp = ikev1_sub_print(ndo, ISAKMP_NPTYPE_T, ext, ep, phase, doi0, + prop.prot_id, depth); + return cp; trunc: - printf(" [|%s]", NPSTR(ISAKMP_NPTYPE_P)); + ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_P))); return NULL; } -static const char *isakmp_p_map[] = { +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" @@ -531,8 +672,21 @@ const struct attrmap ipsec_t_map[] = { { NULL, 0, { NULL } }, { "lifetype", 3, { NULL, "sec", "kb", }, }, { "life", 0, { NULL } }, - { "group desc", 5, { NULL, "modp768", "modp1024", "EC2N 2^155", - "EC2N 2^185", }, }, + { "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 } }, @@ -541,6 +695,17 @@ const struct attrmap ipsec_t_map[] = { { "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", @@ -549,8 +714,21 @@ const struct attrmap oakley_t_map[] = { "sha2-256", "sha2-384", "sha2-512", }, }, { "auth", 6, { NULL, "preshared", "dss", "rsa sig", "rsa enc", "rsa enc revised", }, }, - { "group desc", 5, { NULL, "modp768", "modp1024", "EC2N 2^155", - "EC2N 2^185", }, }, + { "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 } }, @@ -566,27 +744,28 @@ const struct attrmap oakley_t_map[] = { }; static const u_char * -isakmp_t_print(const struct isakmp_gen *ext, u_int item_len, - const u_char *ep, u_int32_t phase _U_, u_int32_t doi _U_, - u_int32_t proto, int depth _U_) +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 isakmp_pl_t *p; - struct isakmp_pl_t t; + 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; - printf("%s:", NPSTR(ISAKMP_NPTYPE_T)); + ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_T))); - p = (struct isakmp_pl_t *)ext; - TCHECK(*p); + 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, isakmp_p_map); + 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; @@ -613,57 +792,59 @@ isakmp_t_print(const struct isakmp_gen *ext, u_int item_len, } if (idstr) - printf(" #%d id=%s ", t.t_no, idstr); + ND_PRINT((ndo," #%d id=%s ", t.t_no, idstr)); else - printf(" #%d id=%d ", t.t_no, t.t_id); + 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 = isakmp_attrmap_print(cp, (ep < ep2) ? ep : ep2, + cp = ikev1_attrmap_print(ndo, cp, (ep < ep2) ? ep : ep2, map, nmap); } else - cp = isakmp_attr_print(cp, (ep < ep2) ? ep : ep2); + cp = ikev1_attr_print(ndo, cp, (ep < ep2) ? ep : ep2); } if (ep < ep2) - printf("..."); + ND_PRINT((ndo,"...")); return cp; trunc: - printf(" [|%s]", NPSTR(ISAKMP_NPTYPE_T)); + ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_T))); return NULL; } static const u_char * -isakmp_ke_print(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_) +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; - printf("%s:", NPSTR(ISAKMP_NPTYPE_KE)); + ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_KE))); - TCHECK(*ext); + ND_TCHECK(*ext); safememcpy(&e, ext, sizeof(e)); - printf(" key len=%d", ntohs(e.len) - 4); - if (2 < vflag && 4 < ntohs(e.len)) { - printf(" "); - if (!rawprint((caddr_t)(ext + 1), ntohs(e.len) - 4)) + 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: - printf(" [|%s]", NPSTR(ISAKMP_NPTYPE_KE)); + ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_KE))); return NULL; } static const u_char * -isakmp_id_print(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_) +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 isakmp_pl_id *p; - struct isakmp_pl_id id; + const struct ikev1_pl_id *p; + struct ikev1_pl_id id; static const char *idtypestr[] = { "IPv4", "IPv4net", "IPv6", "IPv6net", }; @@ -675,10 +856,10 @@ isakmp_id_print(const struct isakmp_gen *ext, u_int item_len _U_, int len; const u_char *data; - printf("%s:", NPSTR(ISAKMP_NPTYPE_ID)); + ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_ID))); - p = (struct isakmp_pl_id *)ext; - TCHECK(*p); + p = (struct ikev1_pl_id *)ext; + ND_TCHECK(*p); safememcpy(&id, ext, sizeof(id)); if (sizeof(*p) < item_len) { data = (u_char *)(p + 1); @@ -689,16 +870,16 @@ isakmp_id_print(const struct isakmp_gen *ext, u_int item_len _U_, } #if 0 /*debug*/ - printf(" [phase=%d doi=%d proto=%d]", phase, doi, proto); + ND_PRINT((ndo," [phase=%d doi=%d proto=%d]", phase, doi, proto)); #endif switch (phase) { #ifndef USE_IPSECDOI_IN_PHASE1 case 1: #endif default: - printf(" idtype=%s", STR_OR_ID(id.d.id_type, idtypestr)); - printf(" doi_data=%u", - (u_int32_t)(ntohl(id.d.doi_data) & 0xffffff)); + 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 @@ -711,42 +892,42 @@ isakmp_id_print(const struct isakmp_gen *ext, u_int item_len _U_, struct protoent *pe; p = (struct ipsecdoi_id *)ext; - TCHECK(*p); + ND_TCHECK(*p); safememcpy(&id, ext, sizeof(id)); - printf(" idtype=%s", STR_OR_ID(id.type, ipsecidtypestr)); + 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) - printf(" protoid=%s", pe->p_name); + ND_PRINT((ndo," protoid=%s", pe->p_name)); #ifndef WIN32 endprotoent(); #endif /* WIN32 */ } else { /* it DOES NOT mean IPPROTO_IP! */ - printf(" protoid=%s", "0"); + ND_PRINT((ndo," protoid=%s", "0")); } - printf(" port=%d", ntohs(id.port)); + ND_PRINT((ndo," port=%d", ntohs(id.port))); if (!len) break; if (data == NULL) goto trunc; - TCHECK2(*data, len); + ND_TCHECK2(*data, len); switch (id.type) { case IPSECDOI_ID_IPV4_ADDR: if (len < 4) - printf(" len=%d [bad: < 4]", len); + ND_PRINT((ndo," len=%d [bad: < 4]", len)); else - printf(" len=%d %s", len, ipaddr_string(data)); + ND_PRINT((ndo," len=%d %s", len, ipaddr_string(data))); len = 0; break; case IPSECDOI_ID_FQDN: case IPSECDOI_ID_USER_FQDN: { int i; - printf(" len=%d ", len); + ND_PRINT((ndo," len=%d ", len)); for (i = 0; i < len; i++) safeputchar(data[i]); len = 0; @@ -756,12 +937,12 @@ isakmp_id_print(const struct isakmp_gen *ext, u_int item_len _U_, { const u_char *mask; if (len < 8) - printf(" len=%d [bad: < 8]", len); + ND_PRINT((ndo," len=%d [bad: < 8]", len)); else { mask = data + sizeof(struct in_addr); - printf(" len=%d %s/%u.%u.%u.%u", len, - ipaddr_string(data), - mask[0], mask[1], mask[2], mask[3]); + 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; @@ -769,22 +950,22 @@ isakmp_id_print(const struct isakmp_gen *ext, u_int item_len _U_, #ifdef INET6 case IPSECDOI_ID_IPV6_ADDR: if (len < 16) - printf(" len=%d [bad: < 16]", len); + ND_PRINT((ndo," len=%d [bad: < 16]", len)); else - printf(" len=%d %s", len, ip6addr_string(data)); + 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) - printf(" len=%d [bad: < 20]", len); + ND_PRINT((ndo," len=%d [bad: < 20]", len)); else { mask = (u_int32_t *)(data + sizeof(struct in6_addr)); /*XXX*/ - printf(" len=%d %s/0x%08x%08x%08x%08x", len, - ip6addr_string(data), - mask[0], mask[1], mask[2], mask[3]); + 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; @@ -792,22 +973,22 @@ isakmp_id_print(const struct isakmp_gen *ext, u_int item_len _U_, #endif /*INET6*/ case IPSECDOI_ID_IPV4_ADDR_RANGE: if (len < 8) - printf(" len=%d [bad: < 8]", len); + ND_PRINT((ndo," len=%d [bad: < 8]", len)); else { - printf(" len=%d %s-%s", len, - ipaddr_string(data), - ipaddr_string(data + sizeof(struct in_addr))); + 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) - printf(" len=%d [bad: < 32]", len); + ND_PRINT((ndo," len=%d [bad: < 32]", len)); else { - printf(" len=%d %s-%s", len, - ip6addr_string(data), - ip6addr_string(data + sizeof(struct in6_addr))); + ND_PRINT((ndo," len=%d %s-%s", len, + ip6addr_string(data), + ip6addr_string(data + sizeof(struct in6_addr)))); } len = 0; break; @@ -821,159 +1002,169 @@ isakmp_id_print(const struct isakmp_gen *ext, u_int item_len _U_, } } if (data && len) { - printf(" len=%d", len); - if (2 < vflag) { - printf(" "); - if (!rawprint((caddr_t)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: - printf(" [|%s]", NPSTR(ISAKMP_NPTYPE_ID)); + ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_ID))); return NULL; } static const u_char * -isakmp_cert_print(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_) +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 isakmp_pl_cert *p; - struct isakmp_pl_cert cert; + 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", }; - printf("%s:", NPSTR(ISAKMP_NPTYPE_CERT)); + ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_CERT))); - p = (struct isakmp_pl_cert *)ext; - TCHECK(*p); + p = (struct ikev1_pl_cert *)ext; + ND_TCHECK(*p); safememcpy(&cert, ext, sizeof(cert)); - printf(" len=%d", item_len - 4); - printf(" type=%s", STR_OR_ID((cert.encode), certstr)); - if (2 < vflag && 4 < item_len) { - printf(" "); - if (!rawprint((caddr_t)(ext + 1), item_len - 4)) + 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: - printf(" [|%s]", NPSTR(ISAKMP_NPTYPE_CERT)); + ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_CERT))); return NULL; } static const u_char * -isakmp_cr_print(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_) +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 isakmp_pl_cert *p; - struct isakmp_pl_cert cert; + 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", }; - printf("%s:", NPSTR(ISAKMP_NPTYPE_CR)); + ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_CR))); - p = (struct isakmp_pl_cert *)ext; - TCHECK(*p); + p = (struct ikev1_pl_cert *)ext; + ND_TCHECK(*p); safememcpy(&cert, ext, sizeof(cert)); - printf(" len=%d", item_len - 4); - printf(" type=%s", STR_OR_ID((cert.encode), certstr)); - if (2 < vflag && 4 < item_len) { - printf(" "); - if (!rawprint((caddr_t)(ext + 1), item_len - 4)) + 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: - printf(" [|%s]", NPSTR(ISAKMP_NPTYPE_CR)); + ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_CR))); return NULL; } static const u_char * -isakmp_hash_print(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_) +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; - printf("%s:", NPSTR(ISAKMP_NPTYPE_HASH)); + ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_HASH))); - TCHECK(*ext); + ND_TCHECK(*ext); safememcpy(&e, ext, sizeof(e)); - printf(" len=%d", ntohs(e.len) - 4); - if (2 < vflag && 4 < ntohs(e.len)) { - printf(" "); - if (!rawprint((caddr_t)(ext + 1), ntohs(e.len) - 4)) + 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: - printf(" [|%s]", NPSTR(ISAKMP_NPTYPE_HASH)); + ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_HASH))); return NULL; } static const u_char * -isakmp_sig_print(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_) +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; - printf("%s:", NPSTR(ISAKMP_NPTYPE_SIG)); + ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_SIG))); - TCHECK(*ext); + ND_TCHECK(*ext); safememcpy(&e, ext, sizeof(e)); - printf(" len=%d", ntohs(e.len) - 4); - if (2 < vflag && 4 < ntohs(e.len)) { - printf(" "); - if (!rawprint((caddr_t)(ext + 1), ntohs(e.len) - 4)) + 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: - printf(" [|%s]", NPSTR(ISAKMP_NPTYPE_SIG)); + ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_SIG))); return NULL; } static const u_char * -isakmp_nonce_print(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_) +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; - printf("%s:", NPSTR(ISAKMP_NPTYPE_NONCE)); + ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_NONCE))); - TCHECK(*ext); + ND_TCHECK(*ext); safememcpy(&e, ext, sizeof(e)); - printf(" n len=%d", ntohs(e.len) - 4); - if (2 < vflag && 4 < ntohs(e.len)) { - printf(" "); - if (!rawprint((caddr_t)(ext + 1), ntohs(e.len) - 4)) + 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: - printf(" [|%s]", NPSTR(ISAKMP_NPTYPE_NONCE)); + ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_NONCE))); return NULL; } static const u_char * -isakmp_n_print(const struct isakmp_gen *ext, u_int item_len, - const u_char *ep, u_int32_t phase, u_int32_t doi0 _U_, - u_int32_t proto0 _U_, int depth) +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 isakmp_pl_n *p, n; + struct ikev1_pl_n *p, n; const u_char *cp; u_char *ep2; u_int32_t doi; @@ -1024,47 +1215,47 @@ isakmp_n_print(const struct isakmp_gen *ext, u_int item_len, #define IPSEC_NOTIFY_STATUS_STR(x) \ STR_OR_ID((u_int)((x) - 24576), ipsec_notify_status_str) - printf("%s:", NPSTR(ISAKMP_NPTYPE_N)); + ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_N))); - p = (struct isakmp_pl_n *)ext; - TCHECK(*p); + 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) { - printf(" doi=%d", doi); - printf(" proto=%d", proto); + ND_PRINT((ndo," doi=%d", doi)); + ND_PRINT((ndo," proto=%d", proto)); if (ntohs(n.type) < 8192) - printf(" type=%s", NOTIFY_ERROR_STR(ntohs(n.type))); + ND_PRINT((ndo," type=%s", NOTIFY_ERROR_STR(ntohs(n.type)))); else if (ntohs(n.type) < 16384) - printf(" type=%s", numstr(ntohs(n.type))); + ND_PRINT((ndo," type=%s", numstr(ntohs(n.type)))); else if (ntohs(n.type) < 24576) - printf(" type=%s", NOTIFY_STATUS_STR(ntohs(n.type))); + ND_PRINT((ndo," type=%s", NOTIFY_STATUS_STR(ntohs(n.type)))); else - printf(" type=%s", numstr(ntohs(n.type))); + ND_PRINT((ndo," type=%s", numstr(ntohs(n.type)))); if (n.spi_size) { - printf(" spi="); - if (!rawprint((caddr_t)(p + 1), 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; } - printf(" doi=ipsec"); - printf(" proto=%s", PROTOIDSTR(proto)); + ND_PRINT((ndo," doi=ipsec")); + ND_PRINT((ndo," proto=%s", PROTOIDSTR(proto))); if (ntohs(n.type) < 8192) - printf(" type=%s", NOTIFY_ERROR_STR(ntohs(n.type))); + ND_PRINT((ndo," type=%s", NOTIFY_ERROR_STR(ntohs(n.type)))); else if (ntohs(n.type) < 16384) - printf(" type=%s", IPSEC_NOTIFY_ERROR_STR(ntohs(n.type))); + ND_PRINT((ndo," type=%s", IPSEC_NOTIFY_ERROR_STR(ntohs(n.type)))); else if (ntohs(n.type) < 24576) - printf(" type=%s", NOTIFY_STATUS_STR(ntohs(n.type))); + ND_PRINT((ndo," type=%s", NOTIFY_STATUS_STR(ntohs(n.type)))); else if (ntohs(n.type) < 32768) - printf(" type=%s", IPSEC_NOTIFY_STATUS_STR(ntohs(n.type))); + ND_PRINT((ndo," type=%s", IPSEC_NOTIFY_STATUS_STR(ntohs(n.type)))); else - printf(" type=%s", numstr(ntohs(n.type))); + ND_PRINT((ndo," type=%s", numstr(ntohs(n.type)))); if (n.spi_size) { - printf(" spi="); - if (!rawprint((caddr_t)(p + 1), n.spi_size)) + ND_PRINT((ndo," spi=")); + if (!rawprint(ndo, (caddr_t)(p + 1), n.spi_size)) goto trunc; } @@ -1072,119 +1263,712 @@ isakmp_n_print(const struct isakmp_gen *ext, u_int item_len, ep2 = (u_char *)p + item_len; if (cp < ep) { - printf(" orig=("); + 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 = isakmp_attrmap_print(cp, + cp = ikev1_attrmap_print(ndo, cp, (ep < ep2) ? ep : ep2, map, nmap); } break; } case IPSECDOI_NTYPE_REPLAY_STATUS: - printf("replay detection %sabled", - (*(u_int32_t *)cp) ? "en" : "dis"); + ND_PRINT((ndo,"replay detection %sabled", + (*(u_int32_t *)cp) ? "en" : "dis")); break; case ISAKMP_NTYPE_NO_PROPOSAL_CHOSEN: - if (isakmp_sub_print(ISAKMP_NPTYPE_SA, - (struct isakmp_gen *)cp, ep, phase, doi, proto, - depth) == NULL) + 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(gndo, cp, + isakmp_print(ndo, cp, item_len - sizeof(*p) - n.spi_size, NULL); } - printf(")"); + ND_PRINT((ndo,")")); } return (u_char *)ext + item_len; trunc: - printf(" [|%s]", NPSTR(ISAKMP_NPTYPE_N)); + ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_N))); return NULL; } static const u_char * -isakmp_d_print(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_) +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 isakmp_pl_d *p; - struct isakmp_pl_d d; + 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; - printf("%s:", NPSTR(ISAKMP_NPTYPE_D)); + ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_D))); - p = (struct isakmp_pl_d *)ext; - TCHECK(*p); + 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) { - printf(" doi=%u", doi); - printf(" proto=%u", proto); + ND_PRINT((ndo," doi=%u", doi)); + ND_PRINT((ndo," proto=%u", proto)); } else { - printf(" doi=ipsec"); - printf(" proto=%s", PROTOIDSTR(proto)); + ND_PRINT((ndo," doi=ipsec")); + ND_PRINT((ndo," proto=%s", PROTOIDSTR(proto))); } - printf(" spilen=%u", d.spi_size); - printf(" nspi=%u", ntohs(d.num_spi)); - printf(" spi="); + 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) - printf(","); - if (!rawprint((caddr_t)q, d.spi_size)) + ND_PRINT((ndo,",")); + if (!rawprint(ndo, (caddr_t)q, d.spi_size)) goto trunc; q += d.spi_size; } return q; trunc: - printf(" [|%s]", NPSTR(ISAKMP_NPTYPE_D)); + ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_D))); return NULL; } static const u_char * -isakmp_vid_print(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_) +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; - printf("%s:", NPSTR(ISAKMP_NPTYPE_VID)); + ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_VID))); - TCHECK(*ext); + ND_TCHECK(*ext); safememcpy(&e, ext, sizeof(e)); - printf(" len=%d", ntohs(e.len) - 4); - if (2 < vflag && 4 < ntohs(e.len)) { - printf(" "); - if (!rawprint((caddr_t)(ext + 1), ntohs(e.len) - 4)) + 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: - printf(" [|%s]", NPSTR(ISAKMP_NPTYPE_VID)); + 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 * -isakmp_sub0_print(u_char np, const struct isakmp_gen *ext, const u_char *ep, - u_int32_t phase, u_int32_t doi, u_int32_t proto, int depth) +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", + 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 = ikev2_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 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_len, sa_len; + + ND_TCHECK(*ext1); + safememcpy(&e, ext1, sizeof(e)); + ikev2_pay_print(ndo, "sa", e.critical); + + osa_len= ntohs(e.len); + sa_len = osa_len - 4; + ND_PRINT((ndo," len=%d", sa_len)); + + ikev2_sub_print(ndo, ISAKMP_NPTYPE_P, + ext1+1, ep, + 0, 0, 0, depth); + + return (u_char *)ext1 + osa_len; +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_) +{ + return ikev2_gen_print(ndo, tpay, ext); +} + +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 e; + const char *v2_auth[]={ "invalid", "rsasig", + "shared-secret", "dsssig" }; + + ND_TCHECK(*ext); + safememcpy(&e, ext, sizeof(e)); + ikev2_pay_print(ndo, NPSTR(tpay), e.h.critical); + + ND_PRINT((ndo," len=%d method=%s", ntohs(e.h.len) - 4, + STR_OR_ID(e.auth_method, v2_auth))); + + if (1 < ndo->ndo_vflag && 4 < ntohs(e.h.len)) { + ND_PRINT((ndo," authdata=(")); + if (!rawprint(ndo, (caddr_t)(ext + 1), ntohs(e.h.len) - 4)) + goto trunc; + ND_PRINT((ndo,") ")); + } else if(ndo->ndo_vflag && 4 < ntohs(e.h.len)) { + if(!ike_show_somedata(ndo, (const u_char *)(ext+1), ep)) goto trunc; + } + + return (u_char *)ext + ntohs(e.h.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; indo_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, 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_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; - TCHECK(*ext); + ND_TCHECK(*ext); safememcpy(&e, ext, sizeof(e)); /* @@ -1202,21 +1986,22 @@ isakmp_sub0_print(u_char np, const struct isakmp_gen *ext, const u_char *ep, * XXX - what if item_len is too short, or too long, * for this payload type? */ - cp = (*npfunc[np])(ext, item_len, ep, phase, doi, proto, depth); + cp = (*npfunc[np])(ndo, np, ext, item_len, ep, phase, doi, proto, depth); } else { - printf("%s", NPSTR(np)); + ND_PRINT((ndo,"%s", NPSTR(np))); cp += item_len; } return cp; trunc: - printf(" [|isakmp]"); + ND_PRINT((ndo," [|isakmp]")); return NULL; } static const u_char * -isakmp_sub_print(u_char np, const struct isakmp_gen *ext, const u_char *ep, - u_int32_t phase, u_int32_t doi, u_int32_t proto, int depth) +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; @@ -1225,19 +2010,19 @@ isakmp_sub_print(u_char np, const struct isakmp_gen *ext, const u_char *ep, cp = (const u_char *)ext; while (np) { - TCHECK(*ext); + ND_TCHECK(*ext); safememcpy(&e, ext, sizeof(e)); - TCHECK2(*ext, ntohs(e.len)); + ND_TCHECK2(*ext, ntohs(e.len)); depth++; - printf("\n"); + ND_PRINT((ndo,"\n")); for (i = 0; i < depth; i++) - printf(" "); - printf("("); - cp = isakmp_sub0_print(np, ext, ep, phase, doi, proto, depth); - printf(")"); + 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) { @@ -1250,7 +2035,7 @@ isakmp_sub_print(u_char np, const struct isakmp_gen *ext, const u_char *ep, } return cp; trunc: - printf(" [|%s]", NPSTR(np)); + ND_PRINT((ndo," [|%s]", NPSTR(np))); return NULL; } @@ -1274,119 +2059,286 @@ safememcpy(void *p, const void *q, size_t l) } void -isakmp_print(netdissect_options *ndo, - const u_char *bp, u_int length, - const u_char *bp2) +ikev1_print(netdissect_options *ndo, + const u_char *bp, u_int length, + const u_char *bp2, struct isakmp *base) { const struct isakmp *p; - struct isakmp base; const u_char *ep; u_char np; int i; int phase; - int major, minor; - + p = (const struct isakmp *)bp; ep = ndo->ndo_snapend; - - if ((struct isakmp *)ep < p + 1) { - printf("[|isakmp]"); - return; - } - - safememcpy(&base, p, sizeof(base)); - - printf("isakmp"); - if (vflag) { - major = (base.vers & ISAKMP_VERS_MAJOR) - >> ISAKMP_VERS_MAJOR_SHIFT; - minor = (base.vers & ISAKMP_VERS_MINOR) - >> ISAKMP_VERS_MINOR_SHIFT; - printf(" %d.%d", major, minor); - } - - if (vflag) { - printf(" msgid "); - rawprint((caddr_t)&base.msgid, sizeof(base.msgid)); - } - - if (1 < vflag) { - printf(" cookie "); - rawprint((caddr_t)&base.i_ck, sizeof(base.i_ck)); - printf("->"); - rawprint((caddr_t)&base.r_ck, sizeof(base.r_ck)); - } - printf(":"); - - phase = (*(u_int32_t *)base.msgid == 0) ? 1 : 2; + + phase = (*(u_int32_t *)base->msgid == 0) ? 1 : 2; if (phase == 1) - printf(" phase %d", phase); + ND_PRINT((ndo," phase %d", phase)); else - printf(" phase %d/others", phase); - - i = cookie_find(&base.i_ck); + 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))) { + if (iszero((u_char *)&base->r_ck, sizeof(base->r_ck))) { /* the first packet */ - printf(" I"); + ND_PRINT((ndo," I")); if (bp2) - cookie_record(&base.i_ck, bp2); + cookie_record(&base->i_ck, bp2); } else - printf(" ?"); + ND_PRINT((ndo," ?")); } else { if (bp2 && cookie_isinitiator(i, bp2)) - printf(" I"); + ND_PRINT((ndo," I")); else if (bp2 && cookie_isresponder(i, bp2)) - printf(" R"); + ND_PRINT((ndo," R")); else - printf(" ?"); + ND_PRINT((ndo," ?")); } - - printf(" %s", ETYPESTR(base.etype)); - if (base.flags) { - printf("[%s%s]", base.flags & ISAKMP_FLAG_E ? "E" : "", - base.flags & ISAKMP_FLAG_C ? "C" : ""); + + 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 (vflag) { + + 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)); + } + } +} -#define CHECKLEN(p, np) \ - if (ep < (u_char *)(p)) { \ - printf(" [|%s]", NPSTR(np)); \ - goto done; \ +static const u_char * +ikev2_sub0_print(netdissect_options *ndo, 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 (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, + 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, np, pcount, + ext, ep, phase, doi, proto, depth); + ND_PRINT((ndo,")")); + depth--; + + if (cp == NULL) { + /* Zero-length subitem */ + return NULL; } - printf(":"); + 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]", + 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) { + if (base->flags & ISAKMP_FLAG_E) { /* * encrypted, nothing we can do right now. * we hope to decrypt the packet in the future... */ - printf(" [encrypted %s]", NPSTR(base.np)); + ND_PRINT((ndo, " [encrypted %s]", NPSTR(base->np))); goto done; } nparen = 0; - CHECKLEN(p + 1, base.np) + CHECKLEN(p + 1, base->np) - np = base.np; + np = base->np; ext = (struct isakmp_gen *)(p + 1); - isakmp_sub_print(np, ext, ep, phase, 0, 0, 0); + ikev2_sub_print(ndo, np, ext, ep, phase, 0, 0, 0); } done: - if (vflag) { - if (ntohl(base.len) != length) { - printf(" (len mismatch: isakmp %u/ip %u)", - (u_int32_t)ntohl(base.len), length); + 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; + + 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 ")); + rawprint(ndo, (caddr_t)&base.msgid, sizeof(base.msgid)); + } + + if (1 < ndo->ndo_vflag) { + ND_PRINT((ndo," cookie ")); + rawprint(ndo, (caddr_t)&base.i_ck, sizeof(base.i_ck)); + ND_PRINT((ndo,"->")); + rawprint(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, @@ -1403,7 +2355,7 @@ isakmp_rfc3948_print(netdissect_options *ndo, if(length < 4) { goto trunc; } - + /* * see if this is an IKE packet */ @@ -1433,7 +2385,7 @@ isakmp_rfc3948_print(netdissect_options *ndo, } trunc: - printf("[|isakmp]"); + ND_PRINT((ndo,"[|isakmp]")); return; } diff --git a/contrib/tcpdump/print-isoclns.c b/contrib/tcpdump/print-isoclns.c index d3935fc411..4f8c347b81 100644 --- a/contrib/tcpdump/print-isoclns.c +++ b/contrib/tcpdump/print-isoclns.c @@ -26,7 +26,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.133.2.25 2007/03/02 09:20:27 hannes Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.163 2007-03-02 09:16:19 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -47,9 +47,6 @@ static const char rcsid[] _U_ = #include "gmpls.h" #include "oui.h" -#define IPV4 1 /* AFI value */ -#define IPV6 2 /* AFI value */ - /* * IS-IS is defined in ISO 10589. Look there for protocol definitions. */ @@ -338,7 +335,7 @@ static struct tok clnp_option_qos_global_values[] = { }; #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 /* draft-ietf-isis-gmpls-extensions */ +#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 */ @@ -347,8 +344,9 @@ static struct tok clnp_option_qos_global_values[] = { #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_PROTECTION_TYPE 20 /* draft-ietf-isis-gmpls-extensions */ -#define ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR 21 /* draft-ietf-isis-gmpls-extensions */ +#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[] = { @@ -361,6 +359,7 @@ static struct tok isis_ext_is_reach_subtlv_values[] = { { 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)" }, @@ -385,6 +384,13 @@ static struct tok isis_ext_ip_reach_subtlv_values[] = { { 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_MD5 54 #define ISIS_SUBTLV_AUTH_MD5_LEN 16 @@ -502,7 +508,8 @@ struct isis_tlv_ptp_adj { u_int8_t neighbor_extd_local_circuit_id[4]; }; -static int osi_cksum(const u_int8_t *, u_int); +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); @@ -765,7 +772,7 @@ static int clnp_print (const u_int8_t *pptr, u_int length) } printf("%slength %u",eflag ? "" : ", ",length); - printf("\n\t%s PDU, hlen: %u, v: %u, lifetime: %u.%us, Segment PDU length: %u, checksum: 0x%04x ", + 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, @@ -774,10 +781,8 @@ static int clnp_print (const u_int8_t *pptr, u_int length) EXTRACT_16BITS(clnp_header->segment_length), EXTRACT_16BITS(clnp_header->cksum)); - /* do not attempt to verify the checksum if it is zero */ - if (EXTRACT_16BITS(clnp_header->cksum) == 0) - printf("(unverified)"); - else printf("(%s)", osi_cksum(optr, clnp_header->length_indicator) ? "incorrect" : "correct"); + 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)); @@ -1031,12 +1036,9 @@ esis_print(const u_int8_t *pptr, u_int length) 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)); - /* do not attempt to verify the checksum if it is zero */ - if (EXTRACT_16BITS(esis_header->cksum) == 0) - printf("(unverified)"); - else - printf("(%s)", osi_cksum(pptr, li) ? "incorrect" : "correct"); + 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); @@ -1411,7 +1413,7 @@ trunctlv: 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; + u_int te_class,priority_level,gmpls_switch_cap; union { /* int to float conversion buffer for several subTLVs */ float f; u_int32_t i; @@ -1435,7 +1437,7 @@ isis_print_is_reach_subtlv (const u_int8_t *tptr,u_int subt,u_int subl,const cha case ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID: if (subl >= 4) { printf(", 0x%08x", EXTRACT_32BITS(tptr)); - if (subl == 8) /* draft-ietf-isis-gmpls-extensions */ + if (subl == 8) /* rfc4205 */ printf(", 0x%08x", EXTRACT_32BITS(tptr+4)); } break; @@ -1484,6 +1486,15 @@ isis_print_is_reach_subtlv (const u_int8_t *tptr,u_int subt,u_int subl,const cha 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", @@ -1493,9 +1504,10 @@ isis_print_is_reach_subtlv (const u_int8_t *tptr,u_int subt,u_int subl,const cha 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", *(tptr))); + tok2str(gmpls_switch_cap_values, "Unknown", gmpls_switch_cap)); printf(", LSP Encoding: %s", tok2str(gmpls_encoding_values, "Unknown", *(tptr+1))); tptr+=4; @@ -1509,12 +1521,29 @@ isis_print_is_reach_subtlv (const u_int8_t *tptr,u_int subt,u_int subl,const cha tptr+=4; } subl-=36; - /* 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)) + 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; @@ -1629,7 +1658,7 @@ isis_print_extd_ip_reach (const u_int8_t *tptr, const char *ident, u_int16_t afi processed=4; tptr+=4; - if (afi == IPV4) { + if (afi == AF_INET) { if (!TTEST2(*tptr, 1)) /* fetch status byte */ return (0); status_byte=*(tptr++); @@ -1642,7 +1671,7 @@ isis_print_extd_ip_reach (const u_int8_t *tptr, const char *ident, u_int16_t afi } processed++; #ifdef INET6 - } else if (afi == IPV6) { + } else if (afi == AF_INET6) { if (!TTEST2(*tptr, 1)) /* fetch status & prefix_len byte */ return (0); status_byte=*(tptr++); @@ -1667,13 +1696,13 @@ isis_print_extd_ip_reach (const u_int8_t *tptr, const char *ident, u_int16_t afi tptr+=byte_length; processed+=byte_length; - if (afi == IPV4) + if (afi == AF_INET) printf("%sIPv4 prefix: %15s/%u", ident, ipaddr_string(prefix), bit_length); #ifdef INET6 - if (afi == IPV6) + if (afi == AF_INET6) printf("%sIPv6 prefix: %s/%u", ident, ip6addr_string(prefix), @@ -1684,17 +1713,20 @@ isis_print_extd_ip_reach (const u_int8_t *tptr, const char *ident, u_int16_t afi ISIS_MASK_TLV_EXTD_IP_UPDOWN(status_byte) ? "down" : "up", metric); - if (afi == IPV4 && ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte)) + if (afi == AF_INET && ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte)) printf(", sub-TLVs present"); #ifdef INET6 - if (afi == IPV6) + 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 ((ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte) && afi == IPV4) || - (ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte) && afi == IPV6)) { + 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 @@ -1977,15 +2009,9 @@ static int isis_print (const u_int8_t *p, u_int length) EXTRACT_16BITS(header_lsp->remaining_lifetime), EXTRACT_16BITS(header_lsp->checksum)); - /* if this is a purge do not attempt to verify the checksum */ - if ( EXTRACT_16BITS(header_lsp->remaining_lifetime) == 0 && - EXTRACT_16BITS(header_lsp->checksum) == 0) - printf(" (purged)"); - else - /* verify the checksum - - * checking starts at the lsp-id field at byte position [12] - * hence the length needs to be reduced by 12 bytes */ - printf(" (%s)", (osi_cksum((u_int8_t *)header_lsp->lsp_id, length-12)) ? "incorrect" : "correct"); + + osi_print_cksum((u_int8_t *)header_lsp->lsp_id, + EXTRACT_16BITS(header_lsp->checksum), 12, length-12); printf(", PDU length: %u, Flags: [ %s", pdu_len, @@ -2238,7 +2264,7 @@ static int isis_print (const u_int8_t *p, u_int length) case ISIS_TLV_EXTD_IP_REACH: while (tmp>0) { - ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", IPV4); + 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; @@ -2255,7 +2281,7 @@ static int isis_print (const u_int8_t *p, u_int length) tmp-=mt_len; while (tmp>0) { - ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", IPV4); + 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; @@ -2266,7 +2292,7 @@ static int isis_print (const u_int8_t *p, u_int length) #ifdef INET6 case ISIS_TLV_IP6_REACH: while (tmp>0) { - ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", IPV6); + 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; @@ -2283,7 +2309,7 @@ static int isis_print (const u_int8_t *p, u_int length) tmp-=mt_len; while (tmp>0) { - ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", IPV6); + 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; @@ -2488,9 +2514,7 @@ static int isis_print (const u_int8_t *p, u_int length) * to avoid conflicts the checksum TLV is zeroed. * see rfc3358 for details */ - if (EXTRACT_16BITS(tptr) == 0) - printf("(unverified)"); - else printf("(%s)", osi_cksum(optr, length) ? "incorrect" : "correct"); + osi_print_cksum(optr, EXTRACT_16BITS(tptr), tptr-optr, length); break; case ISIS_TLV_MT_SUPPORTED: @@ -2682,25 +2706,25 @@ static int isis_print (const u_int8_t *p, u_int length) return(1); } -/* - * Verify the checksum. See 8473-1, Appendix C, section C.4. - */ - -static int -osi_cksum(const u_int8_t *tptr, u_int len) +static void +osi_print_cksum (const u_int8_t *pptr, u_int16_t checksum, + u_int checksum_offset, u_int length) { - int32_t c0 = 0, c1 = 0; + u_int16_t calculated_checksum; - while ((int)--len >= 0) { - c0 += *tptr++; - c0 %= 255; - c1 += c0; - c1 %= 255; - } - return (c0 | c1); + /* 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 diff --git a/contrib/tcpdump/print-juniper.c b/contrib/tcpdump/print-juniper.c index b5837e3785..08a929f1e2 100644 --- a/contrib/tcpdump/print-juniper.c +++ b/contrib/tcpdump/print-juniper.c @@ -1,3 +1,5 @@ +/* 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 @@ -15,7 +17,9 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-juniper.c,v 1.8.2.22 2006/05/10 22:42:46 guy Exp $ (LBL)"; + "@(#) $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 @@ -40,6 +44,8 @@ static const char rcsid[] _U_ = #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" */ @@ -74,6 +80,291 @@ static struct tok juniper_direction_values[] = { { 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 */ @@ -128,6 +419,7 @@ struct juniper_l2info_t { u_int8_t cookie[8]; u_int8_t bundle; u_int16_t proto; + u_int8_t flags; }; #define LS_COOKIE_ID 0x54 @@ -156,6 +448,7 @@ static struct tok juniper_protocol_values[] = { 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 @@ -178,13 +471,14 @@ juniper_ggsn_print(const struct pcap_pkthdr *h, register const u_char *p) return l2info.header_len; p+=l2info.header_len; - gh = (struct juniper_ggsn_header *)p; + gh = (struct juniper_ggsn_header *)&l2info.cookie; - if (eflag) + 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: @@ -256,8 +550,8 @@ juniper_es_print(const struct pcap_pkthdr *h, register const u_char *p) tok2str(juniper_ipsec_type_values,"Unknown",ih->type), ih->type, EXTRACT_32BITS(&ih->spi), - ipaddr_string(EXTRACT_32BITS(&ih->src_ip)), - ipaddr_string(EXTRACT_32BITS(&ih->dst_ip)), + 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", @@ -790,14 +1084,63 @@ ip_heuristic_guess(register const u_char *p, u_int length) { 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, offset; -#ifdef DLT_JUNIPER_ATM2 + u_int idx, jnx_ext_len, jnx_header_len = 0; + u_int8_t tlv_type,tlv_len; u_int32_t control_word; -#endif + int tlv_value; + const u_char *tptr; + l2info->header_len = 0; l2info->cookie_len = 0; @@ -806,9 +1149,10 @@ juniper_parse_header (const u_char *p, const struct pcap_pkthdr *h, struct junip l2info->length = h->len; l2info->caplen = h->caplen; + TCHECK2(p[0],4); + l2info->flags = p[3]; l2info->direction = p[3]&JUNIPER_BPF_PKT_IN; - TCHECK2(p[0],4); if (EXTRACT_24BITS(p) != JUNIPER_MGC_NUMBER) { /* magic number found ? */ printf("no magic-number found!"); return 0; @@ -817,15 +1161,92 @@ juniper_parse_header (const u_char *p, const struct pcap_pkthdr *h, struct junip 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 ((p[3] & JUNIPER_BPF_EXT ) == JUNIPER_BPF_EXT ) { - offset = 6 + EXTRACT_16BITS(p+4); - if (eflag>1) - printf("ext-len %u, ",EXTRACT_16BITS(p+4)); - } else - offset = 4; - - if ((p[3] & JUNIPER_BPF_NO_L2 ) == JUNIPER_BPF_NO_L2 ) { + 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, "); @@ -833,15 +1254,15 @@ juniper_parse_header (const u_char *p, const struct pcap_pkthdr *h, struct junip * perform the v4/v6 heuristics * to figure out what it is */ - TCHECK2(p[offset+4],1); - if(ip_heuristic_guess(p+offset+4,l2info->length-(offset+4)) == 0) + 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=offset+4; + l2info->header_len=jnx_header_len+4; return 0; /* stop parsing the output further */ } - l2info->header_len = offset; + l2info->header_len = jnx_header_len; p+=l2info->header_len; l2info->length -= l2info->header_len; l2info->caplen -= l2info->header_len; @@ -988,6 +1409,10 @@ juniper_parse_header (const u_char *p, const struct pcap_pkthdr *h, struct junip } break; #endif +#ifdef DLT_JUNIPER_GGSN + case DLT_JUNIPER_GGSN: + break; +#endif #ifdef DLT_JUNIPER_ATM1 case DLT_JUNIPER_ATM1: break; diff --git a/contrib/tcpdump/print-krb.c b/contrib/tcpdump/print-krb.c index d6c8e14f4f..213db642db 100644 --- a/contrib/tcpdump/print-krb.c +++ b/contrib/tcpdump/print-krb.c @@ -23,7 +23,7 @@ #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 $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-krb.c,v 1.23 2003-11-16 09:36:26 guy Exp $"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-l2tp.c b/contrib/tcpdump/print-l2tp.c index 6ceab43e75..55c2125174 100644 --- a/contrib/tcpdump/print-l2tp.c +++ b/contrib/tcpdump/print-l2tp.c @@ -23,7 +23,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-l2tp.c,v 1.17.2.3 2006/06/23 02:07:27 hannes Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-l2tp.c,v 1.20 2006-06-23 02:03:09 hannes Exp $"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-lane.c b/contrib/tcpdump/print-lane.c index 1c3c2c2163..33723aaa47 100644 --- a/contrib/tcpdump/print-lane.c +++ b/contrib/tcpdump/print-lane.c @@ -22,7 +22,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.23.2.2 2005/11/13 12:12:59 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.25 2005-11-13 12:12:42 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-ldp.c b/contrib/tcpdump/print-ldp.c index 3280d8ca2a..de3b34e5b5 100644 --- a/contrib/tcpdump/print-ldp.c +++ b/contrib/tcpdump/print-ldp.c @@ -16,7 +16,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-ldp.c,v 1.8.2.10 2007/02/26 13:31:33 hannes Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-ldp.c,v 1.20 2006-06-23 02:03:09 hannes Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -33,9 +33,9 @@ static const char rcsid[] _U_ = #include "decode_prefix.h" #include "extract.h" #include "addrtoname.h" -#include "af.h" #include "l2vpn.h" +#include "af.h" /* * ldp common header @@ -131,6 +131,7 @@ static const struct tok ldp_msg_values[] = { #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 @@ -149,6 +150,7 @@ static const struct tok ldp_msg_values[] = { #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" }, @@ -171,6 +173,7 @@ static const struct tok ldp_tlv_values[] = { { 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} }; @@ -215,8 +218,6 @@ static const struct tok ldp_fec_martini_ifparm_vccv_cv_values[] = { { 0, NULL} }; -#define AFNUM_LEN 2 - int ldp_msg_print(register const u_char *); int ldp_tlv_print(register const u_char *); @@ -292,27 +293,31 @@ ldp_tlv_print(register const u_char *tptr) { case LDP_TLV_ADDRESS_LIST: af = EXTRACT_16BITS(tptr); - tptr+=AFNUM_LEN; - tlv_tlen -= AFNUM_LEN; - printf("\n\t Address Family: "); - if (af == AFNUM_INET) { - printf("IPv4, addresses:"); + 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)) { printf(" %s",ipaddr_string(tptr)); tlv_tlen-=sizeof(struct in_addr); tptr+=sizeof(struct in_addr); } - } + break; #ifdef INET6 - else if (af == AFNUM_INET6) { - printf("IPv6, addresses:"); + case AFNUM_INET6: while(tlv_tlen >= 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: @@ -450,6 +455,10 @@ ldp_tlv_print(register const u_char *tptr) { printf(", Recovery Time: %ums", ui); break; + case LDP_TLV_MTU: + printf("\n\t MTU: %u", EXTRACT_16BITS(tptr)); + break; + /* * FIXME those are the defined TLVs that lack a decoder diff --git a/contrib/tcpdump/print-llc.c b/contrib/tcpdump/print-llc.c index bc4198501a..0c8259fbb6 100644 --- a/contrib/tcpdump/print-llc.c +++ b/contrib/tcpdump/print-llc.c @@ -24,7 +24,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.61.2.10 2007/02/08 07:07:51 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.75 2007-04-13 09:43:11 hannes Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -105,6 +105,8 @@ 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 } }; @@ -441,11 +443,25 @@ snap_print(const u_char *p, u_int length, u_int caplen, break; case OUI_CISCO: - if (et == PID_CISCO_CDP) { - cdp_print(p, length, caplen); - return (1); - } - break; + 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) { diff --git a/contrib/tcpdump/print-lldp.c b/contrib/tcpdump/print-lldp.c new file mode 100644 index 0000000000..36b99343ec --- /dev/null +++ b/contrib/tcpdump/print-lldp.c @@ -0,0 +1,1107 @@ +/* + * 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 + */ + +#ifndef lint +static const char rcsid[] _U_ = +"@(#) $Header: /tcpdump/master/tcpdump/print-lldp.c,v 1.7.2.3 2008-03-20 09:33:52 hannes Exp $"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include +#include +#include + +#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_U_BIT (1 << 5) +#define LLDP_TIA_NETWORK_POLICY_T_BIT (1 << 6) +#define LLDP_TIA_NETWORK_POLICY_X_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} +}; + +/* + * 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 private extensions. (802.1 annex F) + */ +static int +lldp_private_8021_print(const u_char *tptr) +{ + int subtype, hexdump = FALSE; + + 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: + printf("\n\t port vlan id (PVID): %u", + EXTRACT_16BITS(tptr+4)); + break; + case LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_VLAN_ID: + 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: + printf("\n\t vlan id (VID): %u", + EXTRACT_16BITS(tptr+4)); + printf("\n\t vlan name: "); + safeputs((const char *)tptr+7, *(tptr+6)); + break; + case LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_IDENTITY: + printf("\n\t protocol identity: "); + safeputs((const char *)tptr+5, *(tptr+4)); + break; + + default: + hexdump = TRUE; + break; + } + + return hexdump; +} + +/* + * Print IEEE private extensions. (802.3) + */ +static int +lldp_private_8023_print(const u_char *tptr) +{ + int subtype, hexdump = FALSE; + + 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: + 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: + 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: + 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_int8_t lci_len, ca_type, ca_len; + + 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: + 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: + 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: + 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: + 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: + lci_len = *(tptr+5); + 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) { + 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; + } + + 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: + 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; +} + +static char * +lldp_network_addr_print(const u_char *tptr) { + + u_int8_t af; + static char buf[BUFSIZE]; + const char * (*pfunc)(const u_char *); + + af = *tptr; + switch (af) { + case AFNUM_INET: + pfunc = getname; + break; +#ifdef INET6 + case AFNUM_INET6: + pfunc = getname6; + break; +#endif + case AFNUM_802: + 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; + + tlen = len; + tptr = pptr; + + mgmt_addr_len = *tptr++; + tlen--; + + if (tlen < mgmt_addr_len) { + return 0; + } + + printf("\n\t Management Address length %u, %s", + mgmt_addr_len, + lldp_network_addr_print(tptr)); + 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 (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; + + 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); + + switch (tlv_type) { + case LLDP_TTL_TLV: + if (vflag) { + printf(": TTL %us", EXTRACT_16BITS(tptr)); + } + 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_PORT_DESCR_TLV: + if (vflag) { + printf(": "); + safeputs((const char *)tptr, tlv_len); + } + break; + + case LLDP_SYSTEM_DESCR_TLV: + if (vflag) { + printf("\n\t "); + safeputs((const char *)tptr, tlv_len); + } + break; + + + case LLDP_CHASSIS_ID_TLV: + if (vflag) { + subtype = *tptr; + printf("\n\t Subtype %s (%u): ", + tok2str(lldp_chassis_subtype_values, "Unknown", subtype), + subtype); + + switch (subtype) { + case LLDP_CHASSIS_MAC_ADDR_SUBTYPE: + 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: + printf("%s", lldp_network_addr_print(tptr+1)); + break; + + default: + hexdump = TRUE; + break; + } + } + break; + + case LLDP_PORT_ID_TLV: + if (vflag) { + subtype = *tptr; + printf("\n\t Subtype %s (%u): ", + tok2str(lldp_port_subtype_values, "Unknown", subtype), + subtype); + + switch (subtype) { + case LLDP_PORT_MAC_ADDR_SUBTYPE: + 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: + printf("%s", lldp_network_addr_print(tptr+1)); + break; + + default: + hexdump = TRUE; + break; + } + } + break; + + case LLDP_PRIVATE_TLV: + if (vflag) { + 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); + break; + case OUI_IEEE_8023_PRIVATE: + hexdump = lldp_private_8023_print(tptr); + break; + case OUI_TIA: + hexdump = lldp_private_tia_print(tptr, tlv_len); + break; + default: + hexdump = TRUE; + break; + } + } + break; + + case LLDP_SYSTEM_CAP_TLV: + if (vflag) { + 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, tlen)) { + goto trunc; + } + } + 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/contrib/tcpdump/print-lmp.c b/contrib/tcpdump/print-lmp.c index 84d166f5c1..556db173e4 100644 --- a/contrib/tcpdump/print-lmp.c +++ b/contrib/tcpdump/print-lmp.c @@ -10,6 +10,8 @@ * 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 @@ -17,7 +19,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-lmp.c,v 1.5.2.4 2006/06/23 02:07:27 hannes Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-lmp.c,v 1.11 2007-08-02 17:32:49 hannes Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -91,21 +93,21 @@ static const struct tok lmp_obj_begin_verify_flag_values[] = { }; static const struct tok lmp_obj_begin_verify_error_values[] = { - { 0x01, "\n\t\tLink Verification Procedure Not supported"}, - { 0x02, "\n\t\tUnwilling to verify"}, - { 0x04, "\n\t\tUnsupported verification transport mechanism"}, - { 0x08, "\n\t\tLink_Id configuration error"}, - { 0x10, "\n\t\tUnknown object c-type"}, + { 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, "\n\t\tUnacceptable non-negotiable LINK_SUMMARY parameters"}, - { 0x02, "\n\t\tRenegotiate LINK_SUMMARY parameters"}, - { 0x04, "\n\t\tInvalid TE-LINK Object"}, - { 0x08, "\n\t\tInvalid DATA-LINK Object"}, - { 0x10, "\n\t\tUnknown TE-LINK Object c-type"}, - { 0x20, "\n\t\tUnknown DATA-LINK Object c-type"}, + { 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} }; @@ -532,7 +534,7 @@ lmp_print(register const u_char *pptr, register u_int len) { case LMP_OBJ_HELLO: switch(lmp_obj_ctype) { case LMP_CTYPE_HELLO: - printf("\n\t TxSeqNum: %u\n\t RcvSeqNum: %u", + printf("\n\t Tx Seq: %u, Rx Seq: %u", EXTRACT_32BITS(obj_tptr), EXTRACT_32BITS(obj_tptr+4)); break; diff --git a/contrib/tcpdump/print-lspping.c b/contrib/tcpdump/print-lspping.c index a80cdc6d0c..f47a900485 100644 --- a/contrib/tcpdump/print-lspping.c +++ b/contrib/tcpdump/print-lspping.c @@ -15,7 +15,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-lspping.c,v 1.12.2.6 2006/06/23 02:07:27 hannes Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-lspping.c,v 1.18.2.1 2008-01-28 13:48:16 hannes Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -574,10 +574,11 @@ lspping_print(register const u_char *pptr, register u_int len) { lspping_tlv_type=EXTRACT_16BITS(lspping_tlv_header->type); lspping_tlv_len=EXTRACT_16BITS(lspping_tlv_header->length); - if (lspping_tlv_len == 0) + /* some little sanity checking */ + if (lspping_tlv_type == 0 || lspping_tlv_len == 0) return; - if(lspping_tlv_len % 4 || lspping_tlv_len < 4) { /* aligned to four octet boundary */ + if(lspping_tlv_len < 4) { printf("\n\t ERROR: TLV %u bogus size %u",lspping_tlv_type,lspping_tlv_len); return; } @@ -858,6 +859,12 @@ lspping_print(register const u_char *pptr, register u_int len) { print_unknown_data(tptr+sizeof(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); } diff --git a/contrib/tcpdump/print-lwapp.c b/contrib/tcpdump/print-lwapp.c new file mode 100644 index 0000000000..984ebaa304 --- /dev/null +++ b/contrib/tcpdump/print-lwapp.c @@ -0,0 +1,360 @@ +/* + * 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 + */ + +#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 + +#include +#include +#include + +#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 hexdump,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; + hexdump=FALSE; + + /* 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/contrib/tcpdump/print-lwres.c b/contrib/tcpdump/print-lwres.c index d0d6fe1cdd..aad4eee384 100644 --- a/contrib/tcpdump/print-lwres.c +++ b/contrib/tcpdump/print-lwres.c @@ -29,7 +29,7 @@ #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)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-lwres.c,v 1.13 2004-03-24 01:54:29 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-mobile.c b/contrib/tcpdump/print-mobile.c index fe6f013fa6..816ffd6e65 100644 --- a/contrib/tcpdump/print-mobile.c +++ b/contrib/tcpdump/print-mobile.c @@ -42,7 +42,7 @@ #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 $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-mobile.c,v 1.15 2004-03-24 01:58:14 guy Exp $"; #endif #include diff --git a/contrib/tcpdump/print-mobility.c b/contrib/tcpdump/print-mobility.c index 8f9cbee708..1490b72e72 100644 --- a/contrib/tcpdump/print-mobility.c +++ b/contrib/tcpdump/print-mobility.c @@ -33,7 +33,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-mobility.c,v 1.11.2.1 2005/04/20 22:21:16 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-mobility.c,v 1.12 2005-04-20 22:21:00 guy Exp $"; #endif #ifdef INET6 diff --git a/contrib/tcpdump/print-mpcp.c b/contrib/tcpdump/print-mpcp.c new file mode 100644 index 0000000000..244f2802bb --- /dev/null +++ b/contrib/tcpdump/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 + +#include +#include +#include + +#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/contrib/tcpdump/print-mpls.c b/contrib/tcpdump/print-mpls.c index 9d545677cc..c6b0814ffe 100644 --- a/contrib/tcpdump/print-mpls.c +++ b/contrib/tcpdump/print-mpls.c @@ -28,7 +28,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-mpls.c,v 1.13.2.1 2005/07/05 09:39:29 hannes Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-mpls.c,v 1.14 2005-07-05 09:38:19 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-msdp.c b/contrib/tcpdump/print-msdp.c index 3f79b68b1a..a228ab7cec 100644 --- a/contrib/tcpdump/print-msdp.c +++ b/contrib/tcpdump/print-msdp.c @@ -17,7 +17,7 @@ */ #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 $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-msdp.c,v 1.7 2005-04-06 21:32:41 mcr Exp $"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-netbios.c b/contrib/tcpdump/print-netbios.c index 419953cb5c..c92eb9e6b1 100644 --- a/contrib/tcpdump/print-netbios.c +++ b/contrib/tcpdump/print-netbios.c @@ -24,7 +24,7 @@ #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 $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-netbios.c,v 1.20 2003-11-16 09:36:29 guy Exp $"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-nfs.c b/contrib/tcpdump/print-nfs.c index 45e886978b..fb09e30843 100644 --- a/contrib/tcpdump/print-nfs.c +++ b/contrib/tcpdump/print-nfs.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-nfs.c,v 1.106.2.4 2007/06/15 23:17:40 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-nfs.c,v 1.110.2.1 2007-12-22 03:08:45 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -49,7 +49,7 @@ static const char rcsid[] _U_ = #include "rpc_msg.h" static void nfs_printfh(const u_int32_t *, const u_int); -static void xid_map_enter(const struct sunrpc_msg *, const u_char *); +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); @@ -297,6 +297,7 @@ nfsreply_print(register const u_char *bp, u_int length, 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", @@ -307,6 +308,7 @@ nfsreply_print(register const u_char *bp, u_int length, 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) { @@ -318,10 +320,12 @@ nfsreply_print(register const u_char *bp, u_int length, 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)", @@ -329,6 +333,7 @@ nfsreply_print(register const u_char *bp, u_int length, 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) { @@ -384,6 +389,11 @@ nfsreply_print(register const u_char *bp, u_int length, reply_stat, length); break; } + return; + +trunc: + if (!nfserr) + fputs(" [|nfs]", stdout); } /* @@ -503,6 +513,8 @@ nfsreq_print(register const u_char *bp, u_int length, 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)); @@ -515,7 +527,8 @@ nfsreq_print(register const u_char *bp, u_int length, print_nfsaddr(bp2, srcid, dstid); (void)printf("%d", length); - xid_map_enter(rp, bp2); /* record proc number for later on */ + 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); @@ -886,7 +899,7 @@ struct xid_map_entry xid_map[XIDMAPSIZE]; int xid_map_next = 0; int xid_map_hint = 0; -static void +static int xid_map_enter(const struct sunrpc_msg *rp, const u_char *bp) { struct ip *ip = NULL; @@ -895,6 +908,8 @@ xid_map_enter(const struct sunrpc_msg *rp, const u_char *bp) #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; @@ -905,7 +920,7 @@ xid_map_enter(const struct sunrpc_msg *rp, const u_char *bp) break; #endif default: - return; + return (1); } xmep = &xid_map[xid_map_next]; @@ -928,6 +943,7 @@ xid_map_enter(const struct sunrpc_msg *rp, const u_char *bp) #endif xmep->proc = EXTRACT_32BITS(&rp->rm_call.cb_proc); xmep->vers = EXTRACT_32BITS(&rp->rm_call.cb_vers); + return (1); } /* diff --git a/contrib/tcpdump/print-ntp.c b/contrib/tcpdump/print-ntp.c index 606a654de1..4960dc829c 100644 --- a/contrib/tcpdump/print-ntp.c +++ b/contrib/tcpdump/print-ntp.c @@ -25,7 +25,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-ntp.c,v 1.41.2.1 2005/05/06 07:57:18 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-ntp.c,v 1.42 2005-05-06 07:56:53 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-null.c b/contrib/tcpdump/print-null.c index 3d203da4f2..a69997da12 100644 --- a/contrib/tcpdump/print-null.c +++ b/contrib/tcpdump/print-null.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.53.2.4 2007/02/26 13:31:33 hannes Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.57 2006-03-23 14:58:44 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -36,12 +36,12 @@ static const char rcsid[] _U_ = #include "interface.h" #include "addrtoname.h" -#include "af.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 @@ -55,7 +55,6 @@ static const char rcsid[] _U_ = */ #define NULL_HDRLEN 4 - /* * Byte-swap a 32-bit number. * ("htonl()" or "ntohl()" won't work - we want to byte-swap even on diff --git a/contrib/tcpdump/print-ospf.c b/contrib/tcpdump/print-ospf.c index fd8f111a3c..4490496468 100644 --- a/contrib/tcpdump/print-ospf.c +++ b/contrib/tcpdump/print-ospf.c @@ -23,7 +23,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-ospf.c,v 1.56.2.4 2006/12/13 08:24:27 hannes Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-ospf.c,v 1.66 2007-10-08 07:53:21 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -44,11 +44,11 @@ static const char rcsid[] _U_ = #include "ip.h" static struct tok ospf_option_values[] = { - { OSPF_OPTION_T, "TOS" }, + { OSPF_OPTION_T, "MultiTopology" }, /* draft-ietf-ospf-mt-09 */ { OSPF_OPTION_E, "External" }, { OSPF_OPTION_MC, "Multicast" }, { OSPF_OPTION_NP, "NSSA" }, - { OSPF_OPTION_EA, "Advertise External" }, + { OSPF_OPTION_L, "LLS" }, { OSPF_OPTION_DC, "Demand Circuit" }, { OSPF_OPTION_O, "Opaque" }, { OSPF_OPTION_DN, "Up/Down" }, @@ -98,6 +98,7 @@ static struct tok ospf_dd_flag_values[] = { { OSPF_DB_INIT, "Init" }, { OSPF_DB_MORE, "More" }, { OSPF_DB_MASTER, "Master" }, + { OSPF_DB_RESYNC, "OOBResync" }, { 0, NULL } }; @@ -172,7 +173,19 @@ static struct tok lsa_opaque_ri_tlv_cap_values[] = { { 0, NULL } }; -static char tstr[] = " [|ospf]"; +static struct tok ospf_lls_tlv_values[] = { + { OSPF_LLS_EO, "Extended Options" }, + { OSPF_LLS_MD5, "MD5 Authentication" }, + { 0, NULL } +}; + +static struct tok ospf_lls_eo_options[] = { + { OSPF_LLS_EO_LR, "LSDB resync" }, + { OSPF_LLS_EO_RS, "Restart" }, + { 0, NULL } +}; + +static char tstr[] = " [|ospf2]"; #ifdef WIN32 #define inline __inline @@ -181,6 +194,274 @@ static char tstr[] = " [|ospf]"; static int ospf_print_lshdr(const struct lsa_hdr *); static const u_char *ospf_print_lsa(const struct lsa *); static int ospf_decode_v2(const struct ospfhdr *, const u_char *); +static int ospf_decode_lls(const struct ospfhdr *, register u_int); + +int +ospf_print_grace_lsa (u_int8_t *tptr, u_int ls_length) { + + u_int tlv_type, tlv_length; + + + while (ls_length > 0) { + TCHECK2(*tptr, 4); + if (ls_length < 4) { + printf("\n\t Remaining LS length %u < 4", ls_length); + return -1; + } + tlv_type = EXTRACT_16BITS(tptr); + tlv_length = EXTRACT_16BITS(tptr+2); + tptr+=4; + ls_length-=4; + + printf("\n\t %s TLV (%u), length %u, value: ", + tok2str(lsa_opaque_grace_tlv_values,"unknown",tlv_type), + tlv_type, + tlv_length); + + if (tlv_length > ls_length) { + printf("\n\t Bogus length %u > %u", tlv_length, + ls_length); + return -1; + } + + /* Infinite loop protection. */ + if (tlv_type == 0 || tlv_length ==0) { + return -1; + } + + TCHECK2(*tptr, tlv_length); + switch(tlv_type) { + + case LS_OPAQUE_GRACE_TLV_PERIOD: + if (tlv_length != 4) { + printf("\n\t Bogus length %u != 4", tlv_length); + return -1; + } + printf("%us",EXTRACT_32BITS(tptr)); + break; + + case LS_OPAQUE_GRACE_TLV_REASON: + if (tlv_length != 1) { + printf("\n\t Bogus length %u != 1", tlv_length); + return -1; + } + printf("%s (%u)", + tok2str(lsa_opaque_grace_tlv_reason_values, "Unknown", *tptr), + *tptr); + break; + + case LS_OPAQUE_GRACE_TLV_INT_ADDRESS: + if (tlv_length != 4) { + printf("\n\t Bogus length %u != 4", tlv_length); + return -1; + } + printf("%s", ipaddr_string(tptr)); + break; + + default: + if (vflag <= 1) { + if(!print_unknown_data(tptr,"\n\t ",tlv_length)) + return -1; + } + break; + + } + /* in OSPF everything has to be 32-bit aligned, including TLVs */ + if (tlv_length%4 != 0) + tlv_length+=4-(tlv_length%4); + ls_length-=tlv_length; + tptr+=tlv_length; + } + + return 0; +trunc: + return -1; +} + +int +ospf_print_te_lsa (u_int8_t *tptr, u_int ls_length) { + + u_int tlv_type, tlv_length, subtlv_type, subtlv_length; + u_int priority_level, te_class, count_srlg; + union { /* int to float conversion buffer for several subTLVs */ + float f; + u_int32_t i; + } bw; + + while (ls_length != 0) { + TCHECK2(*tptr, 4); + if (ls_length < 4) { + printf("\n\t Remaining LS length %u < 4", ls_length); + return -1; + } + tlv_type = EXTRACT_16BITS(tptr); + tlv_length = EXTRACT_16BITS(tptr+2); + tptr+=4; + ls_length-=4; + + printf("\n\t %s TLV (%u), length: %u", + tok2str(lsa_opaque_te_tlv_values,"unknown",tlv_type), + tlv_type, + tlv_length); + + if (tlv_length > ls_length) { + printf("\n\t Bogus length %u > %u", tlv_length, + ls_length); + return -1; + } + + /* Infinite loop protection. */ + if (tlv_type == 0 || tlv_length ==0) { + return -1; + } + + switch(tlv_type) { + case LS_OPAQUE_TE_TLV_LINK: + while (tlv_length >= sizeof(subtlv_type) + sizeof(subtlv_length)) { + if (tlv_length < 4) { + printf("\n\t Remaining TLV length %u < 4", + tlv_length); + return -1; + } + TCHECK2(*tptr, 4); + subtlv_type = EXTRACT_16BITS(tptr); + subtlv_length = EXTRACT_16BITS(tptr+2); + tptr+=4; + tlv_length-=4; + + printf("\n\t %s subTLV (%u), length: %u", + tok2str(lsa_opaque_te_link_tlv_subtlv_values,"unknown",subtlv_type), + subtlv_type, + subtlv_length); + + TCHECK2(*tptr, subtlv_length); + switch(subtlv_type) { + case LS_OPAQUE_TE_LINK_SUBTLV_ADMIN_GROUP: + printf(", 0x%08x", EXTRACT_32BITS(tptr)); + break; + case LS_OPAQUE_TE_LINK_SUBTLV_LINK_ID: + case LS_OPAQUE_TE_LINK_SUBTLV_LINK_LOCAL_REMOTE_ID: + printf(", %s (0x%08x)", + ipaddr_string(tptr), + EXTRACT_32BITS(tptr)); + if (subtlv_length == 8) /* rfc4203 */ + printf(", %s (0x%08x)", + ipaddr_string(tptr+4), + EXTRACT_32BITS(tptr+4)); + break; + case LS_OPAQUE_TE_LINK_SUBTLV_LOCAL_IP: + case LS_OPAQUE_TE_LINK_SUBTLV_REMOTE_IP: + printf(", %s", ipaddr_string(tptr)); + break; + case LS_OPAQUE_TE_LINK_SUBTLV_MAX_BW: + case LS_OPAQUE_TE_LINK_SUBTLV_MAX_RES_BW: + bw.i = EXTRACT_32BITS(tptr); + printf(", %.3f Mbps", bw.f*8/1000000 ); + break; + case LS_OPAQUE_TE_LINK_SUBTLV_UNRES_BW: + for (te_class = 0; te_class < 8; te_class++) { + bw.i = EXTRACT_32BITS(tptr+te_class*4); + printf("\n\t\tTE-Class %u: %.3f Mbps", + te_class, + bw.f*8/1000000 ); + } + break; + case LS_OPAQUE_TE_LINK_SUBTLV_BW_CONSTRAINTS: + printf("\n\t\tBandwidth Constraints Model ID: %s (%u)", + tok2str(diffserv_te_bc_values, "unknown", *tptr), + *tptr); + /* decode BCs until the subTLV ends */ + for (te_class = 0; te_class < (subtlv_length-4)/4; te_class++) { + bw.i = EXTRACT_32BITS(tptr+4+te_class*4); + printf("\n\t\t Bandwidth constraint CT%u: %.3f Mbps", + te_class, + bw.f*8/1000000 ); + } + break; + case LS_OPAQUE_TE_LINK_SUBTLV_TE_METRIC: + printf(", Metric %u", EXTRACT_32BITS(tptr)); + break; + case LS_OPAQUE_TE_LINK_SUBTLV_LINK_PROTECTION_TYPE: + printf(", %s, Priority %u", + bittok2str(gmpls_link_prot_values, "none", *tptr), + *(tptr+1)); + break; + case LS_OPAQUE_TE_LINK_SUBTLV_INTF_SW_CAP_DESCR: + printf("\n\t\tInterface Switching Capability: %s", + tok2str(gmpls_switch_cap_values, "Unknown", *(tptr))); + printf("\n\t\tLSP Encoding: %s\n\t\tMax LSP Bandwidth:", + tok2str(gmpls_encoding_values, "Unknown", *(tptr+1))); + for (priority_level = 0; priority_level < 8; priority_level++) { + bw.i = EXTRACT_32BITS(tptr+4+(priority_level*4)); + printf("\n\t\t priority level %d: %.3f Mbps", + priority_level, + bw.f*8/1000000 ); + } + break; + case LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE: + printf(", %s (%u)", + tok2str(lsa_opaque_te_tlv_link_type_sub_tlv_values,"unknown",*tptr), + *tptr); + break; + + case LS_OPAQUE_TE_LINK_SUBTLV_SHARED_RISK_GROUP: + count_srlg = subtlv_length / 4; + if (count_srlg != 0) + printf("\n\t\t Shared risk group: "); + while (count_srlg > 0) { + bw.i = EXTRACT_32BITS(tptr); + printf("%d",bw.i); + tptr+=4; + count_srlg--; + if (count_srlg > 0) + printf(", "); + } + break; + + default: + if (vflag <= 1) { + if(!print_unknown_data(tptr,"\n\t\t",subtlv_length)) + return -1; + } + break; + } + /* in OSPF everything has to be 32-bit aligned, including subTLVs */ + if (subtlv_length%4 != 0) + subtlv_length+=4-(subtlv_length%4); + + tlv_length-=subtlv_length; + tptr+=subtlv_length; + + } + break; + + case LS_OPAQUE_TE_TLV_ROUTER: + if (tlv_length < 4) { + printf("\n\t TLV length %u < 4", tlv_length); + return -1; + } + TCHECK2(*tptr, 4); + printf(", %s", ipaddr_string(tptr)); + break; + + default: + if (vflag <= 1) { + if(!print_unknown_data(tptr,"\n\t ",tlv_length)) + return -1; + } + break; + } + /* in OSPF everything has to be 32-bit aligned, including TLVs */ + if (tlv_length%4 != 0) + tlv_length+=4-(tlv_length%4); + ls_length-=tlv_length; + tptr+=tlv_length; + } + return 0; +trunc: + return -1; +} + static int ospf_print_lshdr(register const struct lsa_hdr *lshp) @@ -190,13 +471,13 @@ ospf_print_lshdr(register const struct lsa_hdr *lshp) TCHECK(lshp->ls_length); ls_length = EXTRACT_16BITS(&lshp->ls_length); if (ls_length < sizeof(struct lsa_hdr)) { - printf("\n\t Bogus length %u < %lu", ls_length, + printf("\n\t Bogus length %u < header (%lu)", ls_length, (unsigned long)sizeof(struct lsa_hdr)); return(-1); } TCHECK(lshp->ls_seq); /* XXX - ls_length check checked this */ - printf("\n\t Advertising Router: %s, seq 0x%08x, age %us, length: %u", + printf("\n\t Advertising Router %s, seq 0x%08x, age %us, length %u", ipaddr_string(&lshp->ls_router), EXTRACT_32BITS(&lshp->ls_seq), EXTRACT_16BITS(&lshp->ls_age), @@ -208,7 +489,7 @@ ospf_print_lshdr(register const struct lsa_hdr *lshp) case LS_TYPE_OPAQUE_LL: case LS_TYPE_OPAQUE_AL: case LS_TYPE_OPAQUE_DW: - printf("\n\t %s LSA (%d), Opaque-Type: %s LSA (%u), Opaque-ID: %u", + printf("\n\t %s LSA (%d), Opaque-Type %s LSA (%u), Opaque-ID %u", tok2str(lsa_values,"unknown",lshp->ls_type), lshp->ls_type, @@ -238,6 +519,41 @@ trunc: return (-1); } +/* draft-ietf-ospf-mt-09 */ +static struct tok ospf_topology_values[] = { + { 0, "default " }, + { 1, "multicast " }, + { 2, "management " }, + { 0, NULL } +}; + +/* + * Print all the per-topology metrics. + */ +static void +ospf_print_tos_metrics(const union un_tos *tos) +{ + int metric_count; + int toscount; + + toscount = tos->link.link_tos_count+1; + metric_count = 0; + + /* + * All but the first metric contain a valid topology id. + */ + while (toscount) { + printf("\n\t\ttopology %s(%u), metric %u", + tok2str(ospf_topology_values, "", + metric_count ? tos->metrics.tos_type : 0), + metric_count ? tos->metrics.tos_type : 0, + EXTRACT_16BITS(&tos->metrics.tos_metric)); + metric_count++; + tos++; + toscount--; + } +} + /* * Print a single link state advertisement. If truncated or if LSA length * field is less than the length of the LSA header, return NULl, else @@ -248,19 +564,13 @@ ospf_print_lsa(register const struct lsa *lsap) { register const u_int8_t *ls_end; register const struct rlalink *rlp; - register const struct tos_metric *tosp; register const struct in_addr *ap; register const struct aslametric *almp; register const struct mcla *mcp; register const u_int32_t *lp; - register int j, k, tlv_type, tlv_length, subtlv_type, subtlv_length, priority_level, te_class; + register int j, tlv_type, tlv_length, topology; register int ls_length; const u_int8_t *tptr; - int count_srlg; - union { /* int to float conversion buffer for several subTLVs */ - float f; - u_int32_t i; - } bw; tptr = (u_int8_t *)lsap->lsa_un.un_unknown; /* squelch compiler warnings */ ls_length = ospf_print_lshdr(&lsap->ls_hdr); @@ -281,7 +591,7 @@ ospf_print_lsa(register const struct lsa *lsap) rlp = lsap->lsa_un.un_rla.rla_link; while (j--) { TCHECK(*rlp); - switch (rlp->link_type) { + switch (rlp->un_tos.link.link_type) { case RLA_TYPE_VIRTUAL: printf("\n\t Virtual Link: Neighbor Router-ID: %s, Interface Address: %s", @@ -309,20 +619,14 @@ ospf_print_lsa(register const struct lsa *lsap) default: printf("\n\t Unknown Router Link Type (%u)", - rlp->link_type); + rlp->un_tos.link.link_type); return (ls_end); } - printf(", tos 0, metric: %d", EXTRACT_16BITS(&rlp->link_tos0metric)); - tosp = (struct tos_metric *) - ((sizeof rlp->link_tos0metric) + (u_char *) rlp); - for (k = 0; k < (int) rlp->link_toscount; ++k, ++tosp) { - TCHECK(*tosp); - printf(", tos %d, metric: %d", - tosp->tos_type, - EXTRACT_16BITS(&tosp->tos_metric)); - } + + ospf_print_tos_metrics(&rlp->un_tos); + rlp = (struct rlalink *)((u_char *)(rlp + 1) + - ((rlp->link_toscount) * sizeof(*tosp))); + ((rlp->un_tos.link.link_tos_count) * sizeof(union un_tos))); } break; @@ -344,19 +648,16 @@ ospf_print_lsa(register const struct lsa *lsap) ipaddr_string(&lsap->lsa_un.un_sla.sla_mask)); TCHECK(lsap->lsa_un.un_sla.sla_tosmetric); lp = lsap->lsa_un.un_sla.sla_tosmetric; - /* suppress tos if its not supported */ - if(!((lsap->ls_hdr.ls_options)&OSPF_OPTION_T)) { - printf(", metric: %u", EXTRACT_32BITS(lp)&SLA_MASK_METRIC); - break; - } while ((u_char *)lp < ls_end) { register u_int32_t ul; TCHECK(*lp); ul = EXTRACT_32BITS(lp); - printf(", tos %d metric %d", - (ul & SLA_MASK_TOS) >> SLA_SHIFT_TOS, - ul & SLA_MASK_METRIC); + topology = (ul & SLA_MASK_TOS) >> SLA_SHIFT_TOS; + printf("\n\t\ttopology %s(%u) metric %d", + tok2str(ospf_topology_values, "", topology), + topology, + ul & SLA_MASK_METRIC); ++lp; } break; @@ -364,19 +665,16 @@ ospf_print_lsa(register const struct lsa *lsap) case LS_TYPE_SUM_ABR: TCHECK(lsap->lsa_un.un_sla.sla_tosmetric); lp = lsap->lsa_un.un_sla.sla_tosmetric; - /* suppress tos if its not supported */ - if(!((lsap->ls_hdr.ls_options)&OSPF_OPTION_T)) { - printf(", metric: %u", EXTRACT_32BITS(lp)&SLA_MASK_METRIC); - break; - } while ((u_char *)lp < ls_end) { register u_int32_t ul; TCHECK(*lp); ul = EXTRACT_32BITS(lp); - printf(", tos %d metric %d", - (ul & SLA_MASK_TOS) >> SLA_SHIFT_TOS, - ul & SLA_MASK_METRIC); + topology = (ul & SLA_MASK_TOS) >> SLA_SHIFT_TOS; + printf("\n\t\ttopology %s(%u) metric %d", + tok2str(ospf_topology_values, "", topology), + topology, + ul & SLA_MASK_METRIC); ++lp; } break; @@ -394,9 +692,11 @@ ospf_print_lsa(register const struct lsa *lsap) TCHECK(almp->asla_tosmetric); ul = EXTRACT_32BITS(&almp->asla_tosmetric); - printf(", type %d, tos %d metric:", - (ul & ASLA_FLAG_EXTERNAL) ? 2 : 1, - (ul & ASLA_MASK_TOS) >> ASLA_SHIFT_TOS); + topology = ((ul & ASLA_MASK_TOS) >> ASLA_SHIFT_TOS); + printf("\n\t\ttopology %s(%u), type %d, metric", + tok2str(ospf_topology_values, "", topology), + topology, + (ul & ASLA_FLAG_EXTERNAL) ? 2 : 1); if ((ul & ASLA_MASK_METRIC)==0xffffff) printf(" infinite"); else @@ -471,7 +771,6 @@ ospf_print_lsa(register const struct lsa *lsap) ls_length); return(ls_end); } - ls_length-=tlv_length; TCHECK2(*tptr, tlv_length); switch(tlv_type) { @@ -492,245 +791,32 @@ ospf_print_lsa(register const struct lsa *lsap) } tptr+=tlv_length; + ls_length-=tlv_length; } - break; - case LS_OPAQUE_TYPE_GRACE: - tptr = (u_int8_t *)(&lsap->lsa_un.un_grace_tlv.type); - - while (ls_length != 0) { - TCHECK2(*tptr, 4); - if (ls_length < 4) { - printf("\n\t Remaining LS length %u < 4", ls_length); - return(ls_end); - } - tlv_type = EXTRACT_16BITS(tptr); - tlv_length = EXTRACT_16BITS(tptr+2); - tptr+=4; - ls_length-=4; - - printf("\n\t %s TLV (%u), length: %u, value: ", - tok2str(lsa_opaque_grace_tlv_values,"unknown",tlv_type), - tlv_type, - tlv_length); - - if (tlv_length > ls_length) { - printf("\n\t Bogus length %u > %u", tlv_length, - ls_length); - return(ls_end); - } - ls_length-=tlv_length; - TCHECK2(*tptr, tlv_length); - switch(tlv_type) { - - case LS_OPAQUE_GRACE_TLV_PERIOD: - if (tlv_length != 4) { - printf("\n\t Bogus length %u != 4", tlv_length); - return(ls_end); - } - printf("%us",EXTRACT_32BITS(tptr)); - break; - case LS_OPAQUE_GRACE_TLV_REASON: - if (tlv_length != 1) { - printf("\n\t Bogus length %u != 1", tlv_length); - return(ls_end); - } - printf("%s (%u)", - tok2str(lsa_opaque_grace_tlv_reason_values, "Unknown", *tptr), - *tptr); - break; - case LS_OPAQUE_GRACE_TLV_INT_ADDRESS: - if (tlv_length != 4) { - printf("\n\t Bogus length %u != 4", tlv_length); - return(ls_end); - } - printf("%s", ipaddr_string(tptr)); - break; - default: - if (vflag <= 1) { - if(!print_unknown_data(tptr,"\n\t ",tlv_length)) - return(ls_end); - } - break; - } - tptr+=tlv_length; + case LS_OPAQUE_TYPE_GRACE: + if (ospf_print_grace_lsa((u_int8_t *)(&lsap->lsa_un.un_grace_tlv.type), + ls_length) == -1) { + return(ls_end); } - break; - case LS_OPAQUE_TYPE_TE: - tptr = (u_int8_t *)(&lsap->lsa_un.un_te_lsa_tlv.type); - while (ls_length != 0) { - TCHECK2(*tptr, 4); - if (ls_length < 4) { - printf("\n\t Remaining LS length %u < 4", ls_length); - return(ls_end); - } - tlv_type = EXTRACT_16BITS(tptr); - tlv_length = EXTRACT_16BITS(tptr+2); - tptr+=4; - ls_length-=4; - - printf("\n\t %s TLV (%u), length: %u", - tok2str(lsa_opaque_te_tlv_values,"unknown",tlv_type), - tlv_type, - tlv_length); + case LS_OPAQUE_TYPE_TE: + if (ospf_print_te_lsa((u_int8_t *)(&lsap->lsa_un.un_te_lsa_tlv.type), + ls_length) == -1) { + return(ls_end); + } + break; - if (tlv_length > ls_length) { - printf("\n\t Bogus length %u > %u", tlv_length, - ls_length); + default: + if (vflag <= 1) { + if(!print_unknown_data((u_int8_t *)lsap->lsa_un.un_unknown, + "\n\t ", ls_length)) return(ls_end); - } - ls_length-=tlv_length; - switch(tlv_type) { - case LS_OPAQUE_TE_TLV_LINK: - while (tlv_length != 0) { - if (tlv_length < 4) { - printf("\n\t Remaining TLV length %u < 4", - tlv_length); - return(ls_end); - } - TCHECK2(*tptr, 4); - subtlv_type = EXTRACT_16BITS(tptr); - subtlv_length = EXTRACT_16BITS(tptr+2); - tptr+=4; - tlv_length-=4; - - printf("\n\t %s subTLV (%u), length: %u", - tok2str(lsa_opaque_te_link_tlv_subtlv_values,"unknown",subtlv_type), - subtlv_type, - subtlv_length); - - TCHECK2(*tptr, subtlv_length); - switch(subtlv_type) { - case LS_OPAQUE_TE_LINK_SUBTLV_ADMIN_GROUP: - printf(", 0x%08x", EXTRACT_32BITS(tptr)); - break; - case LS_OPAQUE_TE_LINK_SUBTLV_LINK_ID: - case LS_OPAQUE_TE_LINK_SUBTLV_LINK_LOCAL_REMOTE_ID: - printf(", %s (0x%08x)", - ipaddr_string(tptr), - EXTRACT_32BITS(tptr)); - if (subtlv_length == 8) /* draft-ietf-ccamp-ospf-gmpls-extensions */ - printf(", %s (0x%08x)", - ipaddr_string(tptr+4), - EXTRACT_32BITS(tptr+4)); - break; - case LS_OPAQUE_TE_LINK_SUBTLV_LOCAL_IP: - case LS_OPAQUE_TE_LINK_SUBTLV_REMOTE_IP: - printf(", %s", ipaddr_string(tptr)); - break; - case LS_OPAQUE_TE_LINK_SUBTLV_MAX_BW: - case LS_OPAQUE_TE_LINK_SUBTLV_MAX_RES_BW: - bw.i = EXTRACT_32BITS(tptr); - printf(", %.3f Mbps", bw.f*8/1000000 ); - break; - case LS_OPAQUE_TE_LINK_SUBTLV_UNRES_BW: - for (te_class = 0; te_class < 8; te_class++) { - bw.i = EXTRACT_32BITS(tptr+te_class*4); - printf("\n\t\tTE-Class %u: %.3f Mbps", - te_class, - bw.f*8/1000000 ); - } - break; - case LS_OPAQUE_TE_LINK_SUBTLV_BW_CONSTRAINTS: - printf("\n\t\tBandwidth Constraints Model ID: %s (%u)", - tok2str(diffserv_te_bc_values, "unknown", *tptr), - *tptr); - /* decode BCs until the subTLV ends */ - for (te_class = 0; te_class < (subtlv_length-4)/4; te_class++) { - bw.i = EXTRACT_32BITS(tptr+4+te_class*4); - printf("\n\t\t Bandwidth constraint CT%u: %.3f Mbps", - te_class, - bw.f*8/1000000 ); - } - break; - case LS_OPAQUE_TE_LINK_SUBTLV_TE_METRIC: - printf(", Metric %u", EXTRACT_32BITS(tptr)); - break; - case LS_OPAQUE_TE_LINK_SUBTLV_LINK_PROTECTION_TYPE: - printf(", %s, Priority %u", - bittok2str(gmpls_link_prot_values, "none", *tptr), - *(tptr+1)); - break; - case LS_OPAQUE_TE_LINK_SUBTLV_INTF_SW_CAP_DESCR: - printf("\n\t\tInterface Switching Capability: %s", - tok2str(gmpls_switch_cap_values, "Unknown", *(tptr))); - printf("\n\t\tLSP Encoding: %s\n\t\tMax LSP Bandwidth:", - tok2str(gmpls_encoding_values, "Unknown", *(tptr+1))); - for (priority_level = 0; priority_level < 8; priority_level++) { - bw.i = EXTRACT_32BITS(tptr+4+(priority_level*4)); - printf("\n\t\t priority level %d: %.3f Mbps", - priority_level, - bw.f*8/1000000 ); - } - break; - case LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE: - printf(", %s (%u)", - tok2str(lsa_opaque_te_tlv_link_type_sub_tlv_values,"unknown",*tptr), - *tptr); - break; - - case LS_OPAQUE_TE_LINK_SUBTLV_SHARED_RISK_GROUP: - count_srlg = subtlv_length / 4; - if (count_srlg != 0) - printf("\n\t\t Shared risk group: "); - while (count_srlg > 0) { - bw.i = EXTRACT_32BITS(tptr); - printf("%d",bw.i); - tptr+=4; - count_srlg--; - if (count_srlg > 0) - printf(", "); - } - break; - - default: - if (vflag <= 1) { - if(!print_unknown_data(tptr,"\n\t\t",subtlv_length)) - return(ls_end); - } - break; - } - /* in OSPF everything has to be 32-bit aligned, including TLVs */ - if (subtlv_length%4 != 0) - subtlv_length+=4-(subtlv_length%4); - - tlv_length-=subtlv_length; - tptr+=subtlv_length; - - } - break; - - case LS_OPAQUE_TE_TLV_ROUTER: - if (tlv_length < 4) { - printf("\n\t TLV length %u < 4", tlv_length); - return(ls_end); - } - TCHECK2(*tptr, 4); - printf(", %s", ipaddr_string(tptr)); - break; - - default: - if (vflag <= 1) { - if(!print_unknown_data(tptr,"\n\t ",tlv_length)) - return(ls_end); - } - break; - } - tptr+=tlv_length; - } + } break; - } - break; - default: - if (vflag <= 1) { - if(!print_unknown_data((u_int8_t *)lsap->lsa_un.un_unknown, - "\n\t ", ls_length)) - return(ls_end); - } - break; + } } /* do we want to see an additionally hexdump ? */ @@ -745,6 +831,98 @@ trunc: return (NULL); } +static int +ospf_decode_lls(register const struct ospfhdr *op, + register u_int length) +{ + register const u_char *dptr; + register const u_char *dataend; + register u_int length2; + register u_int16_t lls_type, lls_len; + register u_int32_t lls_flags; + + switch (op->ospf_type) { + + case OSPF_TYPE_HELLO: + if (!(op->ospf_hello.hello_options & OSPF_OPTION_L)) + return (0); + break; + + case OSPF_TYPE_DD: + if (!(op->ospf_db.db_options & OSPF_OPTION_L)) + return (0); + break; + + default: + return (0); + } + + /* dig deeper if LLS data is available; see RFC4813 */ + length2 = EXTRACT_16BITS(&op->ospf_len); + dptr = (u_char *)op + length2; + dataend = (u_char *)op + length; + + if (EXTRACT_16BITS(&op->ospf_authtype) == OSPF_AUTH_MD5) { + dptr = dptr + op->ospf_authdata[3]; + length2 += op->ospf_authdata[3]; + } + if (length2 >= length) { + printf("\n\t[LLS truncated]"); + return (1); + } + TCHECK2(*dptr, 2); + printf("\n\t LLS: checksum: 0x%04x", (u_int)EXTRACT_16BITS(dptr)); + + dptr += 2; + TCHECK2(*dptr, 2); + length2 = EXTRACT_16BITS(dptr); + printf(", length: %u", length2); + + dptr += 2; + TCHECK(*dptr); + while (dptr < dataend) { + TCHECK2(*dptr, 2); + lls_type = EXTRACT_16BITS(dptr); + printf("\n\t %s (%u)", + tok2str(ospf_lls_tlv_values,"Unknown TLV",lls_type), + lls_type); + dptr += 2; + TCHECK2(*dptr, 2); + lls_len = EXTRACT_16BITS(dptr); + printf(", length: %u", lls_len); + dptr += 2; + switch (lls_type) { + + case OSPF_LLS_EO: + if (lls_len != 4) { + printf(" [should be 4]"); + lls_len = 4; + } + TCHECK2(*dptr, 4); + lls_flags = EXTRACT_32BITS(dptr); + printf("\n\t Options: 0x%08x [%s]", lls_flags, + bittok2str(ospf_lls_eo_options,"?",lls_flags)); + + break; + + case OSPF_LLS_MD5: + if (lls_len != 20) { + printf(" [should be 20]"); + lls_len = 20; + } + TCHECK2(*dptr, 4); + printf("\n\t Sequence number: 0x%08x", EXTRACT_32BITS(dptr)); + break; + } + + dptr += lls_len; + } + + return (0); +trunc: + return (1); +} + static int ospf_decode_v2(register const struct ospfhdr *op, register const u_char *dataend) @@ -765,11 +943,11 @@ ospf_decode_v2(register const struct ospfhdr *op, break; case OSPF_TYPE_HELLO: - printf("\n\tOptions: [%s]", + printf("\n\tOptions [%s]", bittok2str(ospf_option_values,"none",op->ospf_hello.hello_options)); TCHECK(op->ospf_hello.hello_deadint); - printf("\n\t Hello Timer: %us, Dead Timer %us, Mask: %s, Priority: %u", + printf("\n\t Hello Timer %us, Dead Timer %us, Mask %s, Priority %u", EXTRACT_16BITS(&op->ospf_hello.hello_helloint), EXTRACT_32BITS(&op->ospf_hello.hello_deadint), ipaddr_string(&op->ospf_hello.hello_mask), @@ -797,19 +975,23 @@ ospf_decode_v2(register const struct ospfhdr *op, case OSPF_TYPE_DD: TCHECK(op->ospf_db.db_options); - printf("\n\tOptions: [%s]", + printf("\n\tOptions [%s]", bittok2str(ospf_option_values,"none",op->ospf_db.db_options)); TCHECK(op->ospf_db.db_flags); - printf(", DD Flags: [%s]", + printf(", DD Flags [%s]", bittok2str(ospf_dd_flag_values,"none",op->ospf_db.db_flags)); + TCHECK(op->ospf_db.db_ifmtu); + if (op->ospf_db.db_ifmtu) { + printf(", MTU: %u", ntohs(op->ospf_db.db_ifmtu)); + } + TCHECK(op->ospf_db.db_seq); + printf(", Sequence: 0x%08x", EXTRACT_32BITS(&op->ospf_db.db_seq)); - if (vflag) { - /* Print all the LS adv's */ - lshp = op->ospf_db.db_lshdr; - while (ospf_print_lshdr(lshp) != -1) { - ++lshp; - } - } + /* Print all the LS adv's */ + lshp = op->ospf_db.db_lshdr; + while (((u_char *)lshp < dataend) && ospf_print_lshdr(lshp) != -1) { + ++lshp; + } break; case OSPF_TYPE_LS_REQ: @@ -863,7 +1045,6 @@ ospf_decode_v2(register const struct ospfhdr *op, break; default: - printf("v2 type (%d)", op->ospf_type); break; } return (0); @@ -892,25 +1073,30 @@ ospf_print(register const u_char *bp, register u_int length, /* value. If it's not valid, say so and return */ TCHECK(op->ospf_type); cp = tok2str(type2str, "unknown LS-type", op->ospf_type); - printf("OSPFv%u, %s, length: %u", + printf("OSPFv%u, %s, length %u", op->ospf_version, cp, length); if (*cp == 'u') return; - if(!vflag) /* non verbose - so lets bail out here */ + if(!vflag) { /* non verbose - so lets bail out here */ return; + } TCHECK(op->ospf_len); if (length != EXTRACT_16BITS(&op->ospf_len)) { printf(" [len %d]", EXTRACT_16BITS(&op->ospf_len)); - return; } - dataend = bp + length; + + if (length > EXTRACT_16BITS(&op->ospf_len)) { + dataend = bp + EXTRACT_16BITS(&op->ospf_len); + } else { + dataend = bp + length; + } TCHECK(op->ospf_routerid); - printf("\n\tRouter-ID: %s", ipaddr_string(&op->ospf_routerid)); + printf("\n\tRouter-ID %s", ipaddr_string(&op->ospf_routerid)); TCHECK(op->ospf_areaid); if (op->ospf_areaid.s_addr != 0) @@ -933,7 +1119,7 @@ ospf_print(register const u_char *bp, register u_int length, case OSPF_AUTH_SIMPLE: printf("\n\tSimple text password: "); - safeputs(op->ospf_authdata, OSPF_AUTH_SIMPLE_LEN); + safeputs((const char *)op->ospf_authdata, OSPF_AUTH_SIMPLE_LEN); break; case OSPF_AUTH_MD5: @@ -954,6 +1140,10 @@ ospf_print(register const u_char *bp, register u_int length, /* ospf version 2 */ if (ospf_decode_v2(op, dataend)) goto trunc; + if (length > EXTRACT_16BITS(&op->ospf_len)) { + if (ospf_decode_lls(op, length)) + goto trunc; + } break; default: diff --git a/contrib/tcpdump/print-ospf6.c b/contrib/tcpdump/print-ospf6.c index 6325a21920..1100485670 100644 --- a/contrib/tcpdump/print-ospf6.c +++ b/contrib/tcpdump/print-ospf6.c @@ -23,7 +23,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-ospf6.c,v 1.13 2003/11/16 09:36:31 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-ospf6.c,v 1.15 2006-09-13 06:31:11 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -39,188 +39,120 @@ static const char rcsid[] _U_ = #include "addrtoname.h" #include "extract.h" +#include "ospf.h" #include "ospf6.h" -struct bits { - u_int32_t bit; - const char *str; +static const struct tok ospf6_option_values[] = { + { OSPF6_OPTION_V6, "V6" }, + { OSPF6_OPTION_E, "External" }, + { OSPF6_OPTION_MC, "Multicast" }, + { OSPF6_OPTION_N, "NSSA" }, + { OSPF6_OPTION_R, "Router" }, + { OSPF6_OPTION_DC, "Demand Circuit" }, + { 0, NULL } }; -static const struct bits ospf6_option_bits[] = { - { OSPF6_OPTION_V6, "V6" }, - { OSPF6_OPTION_E, "E" }, - { OSPF6_OPTION_MC, "MC" }, - { OSPF6_OPTION_N, "N" }, - { OSPF6_OPTION_R, "R" }, - { OSPF6_OPTION_DC, "DC" }, +static const struct tok ospf6_rla_flag_values[] = { + { RLA_FLAG_B, "ABR" }, + { RLA_FLAG_E, "External" }, + { RLA_FLAG_V, "Virtual-Link Endpoint" }, + { RLA_FLAG_W, "Wildcard Receiver" }, + { RLA_FLAG_N, "NSSA Translator" }, { 0, NULL } }; -static const struct bits ospf6_rla_flag_bits[] = { - { RLA_FLAG_B, "B" }, - { RLA_FLAG_E, "E" }, - { RLA_FLAG_V, "V" }, - { RLA_FLAG_W, "W" }, +static const struct tok ospf6_asla_flag_values[] = { + { ASLA_FLAG_EXTERNAL, "External Type 2" }, + { ASLA_FLAG_FWDADDR, "Fforwarding" }, + { ASLA_FLAG_ROUTETAG, "Tag" }, { 0, NULL } }; -static const struct bits ospf6_asla_flag_bits[] = { - { ASLA_FLAG_EXTERNAL, "E" }, - { ASLA_FLAG_FWDADDR, "F" }, - { ASLA_FLAG_ROUTETAG, "T" }, +static struct tok ospf6_type_values[] = { + { OSPF_TYPE_HELLO, "Hello" }, + { OSPF_TYPE_DD, "Database Description" }, + { OSPF_TYPE_LS_REQ, "LS-Request" }, + { OSPF_TYPE_LS_UPDATE, "LS-Update" }, + { OSPF_TYPE_LS_ACK, "LS-Ack" }, { 0, NULL } }; -static struct tok type2str[] = { - { OSPF_TYPE_UMD, "umd" }, - { OSPF_TYPE_HELLO, "hello" }, - { OSPF_TYPE_DB, "dd" }, - { OSPF_TYPE_LSR, "ls_req" }, - { OSPF_TYPE_LSU, "ls_upd" }, - { OSPF_TYPE_LSA, "ls_ack" }, +static struct tok ospf6_lsa_values[] = { + { LS_TYPE_ROUTER, "Router" }, + { LS_TYPE_NETWORK, "Network" }, + { LS_TYPE_INTER_AP, "Inter-Area Prefix" }, + { LS_TYPE_INTER_AR, "Inter-Area Router" }, + { LS_TYPE_ASE, "External" }, + { LS_TYPE_GROUP, "Multicast Group" }, + { LS_TYPE_NSSA, "NSSA" }, + { LS_TYPE_LINK, "Link" }, + { LS_TYPE_INTRA_AP, "Intra-Area Prefix" }, + { LS_TYPE_INTRA_ATE, "Intra-Area TE" }, + { LS_TYPE_GRACE, "Grace" }, { 0, NULL } }; -static char tstr[] = " [|ospf]"; +static struct tok ospf6_ls_scope_values[] = { + { LS_SCOPE_LINKLOCAL, "Link Local" }, + { LS_SCOPE_AREA, "Area Local" }, + { LS_SCOPE_AS, "Domain Wide" }, + { 0, NULL } +}; + +static struct tok ospf6_dd_flag_values[] = { + { OSPF6_DB_INIT, "Init" }, + { OSPF6_DB_MORE, "More" }, + { OSPF6_DB_MASTER, "Master" }, + { 0, NULL } +}; + +static struct tok ospf6_lsa_prefix_option_values[] = { + { LSA_PREFIX_OPT_NU, "No Unicast" }, + { LSA_PREFIX_OPT_LA, "Local address" }, + { LSA_PREFIX_OPT_MC, "Multicast" }, + { LSA_PREFIX_OPT_P, "Propagate" }, + { LSA_PREFIX_OPT_DN, "Down" }, + { 0, NULL } +}; + +static char tstr[] = " [|ospf3]"; #ifdef WIN32 #define inline __inline #endif /* WIN32 */ /* Forwards */ -static inline void ospf6_print_seqage(u_int32_t, time_t); -static inline void ospf6_print_bits(const struct bits *, u_char); -static void ospf6_print_ls_type(u_int, const rtrid_t *, - const rtrid_t *, const char *); -static int ospf6_print_lshdr(const struct lsa_hdr *); -static int ospf6_print_lsa(const struct lsa *); +static void ospf6_print_ls_type(u_int, const rtrid_t *); +static int ospf6_print_lshdr(const struct lsa6_hdr *); +static int ospf6_print_lsa(const struct lsa6 *); static int ospf6_decode_v3(const struct ospf6hdr *, const u_char *); -static inline void -ospf6_print_seqage(register u_int32_t seq, register time_t us) -{ - register time_t sec = us % 60; - register time_t mins = (us / 60) % 60; - register time_t hour = us / 3600; - - printf(" S %X age ", seq); - if (hour) - printf("%u:%02u:%02u", - (u_int32_t) hour, (u_int32_t) mins, (u_int32_t) sec); - else if (mins) - printf("%u:%02u", (u_int32_t) mins, (u_int32_t) sec); - else - printf("%u", (u_int32_t) sec); -} - - -static inline void -ospf6_print_bits(register const struct bits *bp, register u_char options) -{ - register char sep = ' '; - - do { - if (options & bp->bit) { - printf("%c%s", sep, bp->str); - sep = '/'; - } - } while ((++bp)->bit); -} static void -ospf6_print_ls_type(register u_int ls_type, - register const rtrid_t *ls_stateid, - register const rtrid_t *ls_router, register const char *fmt) +ospf6_print_ls_type(register u_int ls_type, register const rtrid_t *ls_stateid) { - const char *scope; - - switch (ls_type & LS_SCOPE_MASK) { - case LS_SCOPE_LINKLOCAL: - scope = "linklocal-"; - break; - case LS_SCOPE_AREA: - scope = "area-"; - break; - case LS_SCOPE_AS: - scope = "AS-"; - break; - default: - scope = ""; - break; - } - - switch (ls_type & LS_TYPE_MASK) { - case LS_TYPE_ROUTER: - printf(" %srtr %s", scope, ipaddr_string(ls_router)); - break; - - case LS_TYPE_NETWORK: - printf(" %snet dr %s if %s", scope, - ipaddr_string(ls_router), - ipaddr_string(ls_stateid)); - break; - - case LS_TYPE_INTER_AP: - printf(" %sinter-area-prefix %s abr %s", scope, - ipaddr_string(ls_stateid), - ipaddr_string(ls_router)); - break; - - case LS_TYPE_INTER_AR: - printf(" %sinter-area-router %s rtr %s", scope, - ipaddr_string(ls_router), - ipaddr_string(ls_stateid)); - break; - - case LS_TYPE_ASE: - printf(" %sase %s asbr %s", scope, - ipaddr_string(ls_stateid), - ipaddr_string(ls_router)); - break; - - case LS_TYPE_GROUP: - printf(" %sgroup %s rtr %s", scope, - ipaddr_string(ls_stateid), - ipaddr_string(ls_router)); - break; - - case LS_TYPE_TYPE7: - printf(" %stype7 %s rtr %s", scope, - ipaddr_string(ls_stateid), - ipaddr_string(ls_router)); - break; - - case LS_TYPE_LINK: - printf(" %slink %s rtr %s", scope, - ipaddr_string(ls_stateid), - ipaddr_string(ls_router)); - break; - - case LS_TYPE_INTRA_AP: - printf(" %sintra-area-prefix %s rtr %s", scope, - ipaddr_string(ls_stateid), - ipaddr_string(ls_router)); - break; - - default: - printf(" %s", scope); - printf(fmt, ls_type); - break; - } - + printf("\n\t %s LSA (%d), %s Scope%s, LSA-ID %s", + tok2str(ospf6_lsa_values, "Unknown", ls_type & LS_TYPE_MASK), + ls_type & LS_TYPE_MASK, + tok2str(ospf6_ls_scope_values, "Unknown", ls_type & LS_SCOPE_MASK), + ls_type &0x8000 ? ", transitive" : "", /* U-bit */ + ipaddr_string(ls_stateid)); } static int -ospf6_print_lshdr(register const struct lsa_hdr *lshp) +ospf6_print_lshdr(register const struct lsa6_hdr *lshp) { TCHECK(lshp->ls_type); - printf(" {"); /* } (ctags) */ - TCHECK(lshp->ls_seq); - ospf6_print_seqage(EXTRACT_32BITS(&lshp->ls_seq), EXTRACT_16BITS(&lshp->ls_age)); - ospf6_print_ls_type(EXTRACT_16BITS(&lshp->ls_type), &lshp->ls_stateid, - &lshp->ls_router, "ls_type %d"); + + printf("\n\t Advertising Router %s, seq 0x%08x, age %us, length %u", + ipaddr_string(&lshp->ls_router), + EXTRACT_32BITS(&lshp->ls_seq), + EXTRACT_16BITS(&lshp->ls_age), + EXTRACT_16BITS(&lshp->ls_length)-(u_int)sizeof(struct lsa6_hdr)); + + ospf6_print_ls_type(EXTRACT_16BITS(&lshp->ls_type), &lshp->ls_stateid); return (0); trunc: @@ -228,26 +160,28 @@ trunc: } static int -ospf6_print_lsaprefix(register const struct lsa_prefix *lsapp) +ospf6_print_lsaprefix(register const struct lsa6_prefix *lsapp) { - u_int k; + u_int wordlen; struct in6_addr prefix; TCHECK(*lsapp); - k = (lsapp->lsa_p_len + 31) / 32; - if (k * 4 > sizeof(struct in6_addr)) { - printf("??prefixlen %d??", lsapp->lsa_p_len); + wordlen = (lsapp->lsa_p_len + 31) / 32; + if (wordlen * 4 > sizeof(struct in6_addr)) { + printf(" bogus prefixlen /%d", lsapp->lsa_p_len); goto trunc; } memset(&prefix, 0, sizeof(prefix)); - memcpy(&prefix, lsapp->lsa_p_prefix, k * 4); - printf(" %s/%d", ip6addr_string(&prefix), + memcpy(&prefix, lsapp->lsa_p_prefix, wordlen * 4); + printf("\n\t\t%s/%d", ip6addr_string(&prefix), lsapp->lsa_p_len); - if (lsapp->lsa_p_opt) - printf("(opt=%x)", lsapp->lsa_p_opt); - if (lsapp->lsa_p_mbz) - printf("(mbz=%x)", EXTRACT_16BITS(&lsapp->lsa_p_mbz)); /* XXX */ - return sizeof(*lsapp) - 4 + k * 4; + if (lsapp->lsa_p_opt) { + printf(", Options [%s]", + bittok2str(ospf6_lsa_prefix_option_values, + "none", lsapp->lsa_p_opt)); + } + printf(", metric %u", EXTRACT_16BITS(&lsapp->lsa_p_metric)); + return sizeof(*lsapp) - 4 + wordlen * 4; trunc: return -1; @@ -258,10 +192,10 @@ trunc: * Print a single link state advertisement. If truncated return 1, else 0. */ static int -ospf6_print_lsa(register const struct lsa *lsap) +ospf6_print_lsa(register const struct lsa6 *lsap) { register const u_char *ls_end, *ls_opt; - register const struct rlalink *rlp; + register const struct rlalink6 *rlp; #if 0 register const struct tos_metric *tosp; #endif @@ -271,102 +205,115 @@ ospf6_print_lsa(register const struct lsa *lsap) register const struct mcla *mcp; #endif register const struct llsa *llsap; - register const struct lsa_prefix *lsapp; + register const struct lsa6_prefix *lsapp; #if 0 register const u_int32_t *lp; #endif - register u_int j; - register int k; + register u_int prefixes; + register int bytelen, length, lsa_length; u_int32_t flags32; + u_int8_t *tptr; if (ospf6_print_lshdr(&lsap->ls_hdr)) return (1); TCHECK(lsap->ls_hdr.ls_length); - ls_end = (u_char *)lsap + EXTRACT_16BITS(&lsap->ls_hdr.ls_length); + length = EXTRACT_16BITS(&lsap->ls_hdr.ls_length); + lsa_length = length - sizeof(struct lsa6_hdr); + ls_end = (u_char *)lsap + length; + tptr = (u_int8_t *)lsap+sizeof(struct lsa6_hdr); + switch (EXTRACT_16BITS(&lsap->ls_hdr.ls_type)) { case LS_TYPE_ROUTER | LS_SCOPE_AREA: - TCHECK(lsap->lsa_un.un_rla.rla_flags); - ospf6_print_bits(ospf6_rla_flag_bits, - lsap->lsa_un.un_rla.rla_flags); TCHECK(lsap->lsa_un.un_rla.rla_options); - ospf6_print_bits(ospf6_option_bits, - EXTRACT_32BITS(&lsap->lsa_un.un_rla.rla_options)); + printf("\n\t Options [%s]", + bittok2str(ospf6_option_values, "none", + EXTRACT_32BITS(&lsap->lsa_un.un_rla.rla_options))); + + TCHECK(lsap->lsa_un.un_rla.rla_flags); + printf(", RLA-Flags [%s]", + bittok2str(ospf6_rla_flag_values, "none", + lsap->lsa_un.un_rla.rla_flags)); + TCHECK(lsap->lsa_un.un_rla.rla_link); rlp = lsap->lsa_un.un_rla.rla_link; - while (rlp + sizeof(*rlp) <= (struct rlalink *)ls_end) { + while (rlp + 1 <= (struct rlalink6 *)ls_end) { TCHECK(*rlp); - printf(" {"); /* } (ctags) */ switch (rlp->link_type) { case RLA_TYPE_VIRTUAL: - printf(" virt"); - /* Fall through */ + printf("\n\t Virtual Link: Neighbor Router-ID %s" + "\n\t Neighbor Interface-ID %s, Interface %s", + ipaddr_string(&rlp->link_nrtid), + ipaddr_string(&rlp->link_nifid), + ipaddr_string(&rlp->link_ifid)); + break; case RLA_TYPE_ROUTER: - printf(" nbrid %s nbrif %s if %s", - ipaddr_string(&rlp->link_nrtid), - ipaddr_string(&rlp->link_nifid), - ipaddr_string(&rlp->link_ifid)); + printf("\n\t Neighbor Router-ID %s" + "\n\t Neighbor Interface-ID %s, Interface %s", + ipaddr_string(&rlp->link_nrtid), + ipaddr_string(&rlp->link_nifid), + ipaddr_string(&rlp->link_ifid)); break; case RLA_TYPE_TRANSIT: - printf(" dr %s drif %s if %s", + printf("\n\t Neighbor Network-ID %s" + "\n\t Neighbor Interface-ID %s, Interface %s", ipaddr_string(&rlp->link_nrtid), ipaddr_string(&rlp->link_nifid), ipaddr_string(&rlp->link_ifid)); break; default: - /* { (ctags) */ - printf(" ??RouterLinksType 0x%02x?? }", + printf("\n\t Unknown Router Links Type 0x%02x", rlp->link_type); return (0); } - printf(" metric %d", EXTRACT_16BITS(&rlp->link_metric)); - /* { (ctags) */ - printf(" }"); + printf(", metric %d", EXTRACT_16BITS(&rlp->link_metric)); rlp++; } break; case LS_TYPE_NETWORK | LS_SCOPE_AREA: TCHECK(lsap->lsa_un.un_nla.nla_options); - ospf6_print_bits(ospf6_option_bits, - EXTRACT_32BITS(&lsap->lsa_un.un_nla.nla_options)); - printf(" rtrs"); + printf("\n\t Options [%s]", + bittok2str(ospf6_option_values, "none", + EXTRACT_32BITS(&lsap->lsa_un.un_nla.nla_options))); + printf("\n\t Connected Routers:"); ap = lsap->lsa_un.un_nla.nla_router; while ((u_char *)ap < ls_end) { TCHECK(*ap); - printf(" %s", ipaddr_string(ap)); + printf("\n\t\t%s", ipaddr_string(ap)); ++ap; } break; case LS_TYPE_INTER_AP | LS_SCOPE_AREA: TCHECK(lsap->lsa_un.un_inter_ap.inter_ap_metric); - printf(" metric %u", + printf(", metric %u", EXTRACT_32BITS(&lsap->lsa_un.un_inter_ap.inter_ap_metric) & SLA_MASK_METRIC); lsapp = lsap->lsa_un.un_inter_ap.inter_ap_prefix; - while (lsapp + sizeof(lsapp) <= (struct lsa_prefix *)ls_end) { - k = ospf6_print_lsaprefix(lsapp); - if (k) + while (lsapp + sizeof(lsapp) <= (struct lsa6_prefix *)ls_end) { + bytelen = ospf6_print_lsaprefix(lsapp); + if (bytelen) goto trunc; - lsapp = (struct lsa_prefix *)(((u_char *)lsapp) + k); + lsapp = (struct lsa6_prefix *)(((u_char *)lsapp) + bytelen); } break; case LS_SCOPE_AS | LS_TYPE_ASE: TCHECK(lsap->lsa_un.un_asla.asla_metric); flags32 = EXTRACT_32BITS(&lsap->lsa_un.un_asla.asla_metric); - ospf6_print_bits(ospf6_asla_flag_bits, flags32); + printf("\n\t Flags [%s]", + bittok2str(ospf6_asla_flag_values, "none", flags32)); printf(" metric %u", EXTRACT_32BITS(&lsap->lsa_un.un_asla.asla_metric) & ASLA_MASK_METRIC); lsapp = lsap->lsa_un.un_asla.asla_prefix; - k = ospf6_print_lsaprefix(lsapp); - if (k < 0) + bytelen = ospf6_print_lsaprefix(lsapp); + if (bytelen < 0) goto trunc; - if ((ls_opt = (u_char *)(((u_char *)lsapp) + k)) < ls_end) { + if ((ls_opt = (u_char *)(((u_char *)lsapp) + bytelen)) < ls_end) { struct in6_addr *fwdaddr6; if ((flags32 & ASLA_FLAG_FWDADDR) != 0) { @@ -386,7 +333,7 @@ ospf6_print_lsa(register const struct lsa *lsap) ls_opt += sizeof(u_int32_t); } - if (lsapp->lsa_p_mbz) { + if (lsapp->lsa_p_metric) { TCHECK(*(u_int32_t *)ls_opt); printf(" RefLSID: %s", ipaddr_string((u_int32_t *)ls_opt)); @@ -395,64 +342,30 @@ ospf6_print_lsa(register const struct lsa *lsap) } } break; -#if 0 - case LS_TYPE_SUM_ABR: - TCHECK(lsap->lsa_un.un_sla.sla_tosmetric); - lp = lsap->lsa_un.un_sla.sla_tosmetric; - while ((u_char *)lp < ls_end) { - register u_int32_t ul; - - TCHECK(*lp); - ul = EXTRACT_32BITS(lp); - printf(" tos %d metric %d", - (ul & SLA_MASK_TOS) >> SLA_SHIFT_TOS, - ul & SLA_MASK_METRIC); - ++lp; - } - break; - - case LS_TYPE_GROUP: - /* Multicast extensions as of 23 July 1991 */ - mcp = lsap->lsa_un.un_mcla; - while ((u_char *)mcp < ls_end) { - TCHECK(mcp->mcla_vid); - switch (EXTRACT_32BITS(&mcp->mcla_vtype)) { - - case MCLA_VERTEX_ROUTER: - printf(" rtr rtrid %s", - ipaddr_string(&mcp->mcla_vid)); - break; - - case MCLA_VERTEX_NETWORK: - printf(" net dr %s", - ipaddr_string(&mcp->mcla_vid)); - break; - - default: - printf(" ??VertexType %u??", - EXTRACT_32BITS(&mcp->mcla_vtype)); - break; - } - ++mcp; - } -#endif case LS_TYPE_LINK: /* Link LSA */ llsap = &lsap->lsa_un.un_llsa; TCHECK(llsap->llsa_options); - ospf6_print_bits(ospf6_option_bits, EXTRACT_32BITS(&llsap->llsa_options)); + printf("\n\t Options [%s]", + bittok2str(ospf6_option_values, "none", + EXTRACT_32BITS(&llsap->llsa_options))); TCHECK(llsap->llsa_nprefix); - printf(" pri %d lladdr %s npref %d", llsap->llsa_priority, - ip6addr_string(&llsap->llsa_lladdr), - EXTRACT_32BITS(&llsap->llsa_nprefix)); - lsapp = llsap->llsa_prefix; - for (j = 0; j < EXTRACT_32BITS(&llsap->llsa_nprefix); j++) { - k = ospf6_print_lsaprefix(lsapp); - if (k) - goto trunc; - lsapp = (struct lsa_prefix *)(((u_char *)lsapp) + k); - } + prefixes = EXTRACT_32BITS(&llsap->llsa_nprefix); + printf("\n\t Priority %d, Link-local address %s, Prefixes %d:", + llsap->llsa_priority, + ip6addr_string(&llsap->llsa_lladdr), + prefixes); + + tptr = (u_int8_t *)llsap->llsa_prefix; + while (prefixes > 0) { + lsapp = (struct lsa6_prefix *)tptr; + if ((bytelen = ospf6_print_lsaprefix(lsapp)) == -1) { + goto trunc; + } + prefixes--; + tptr += bytelen; + } break; case LS_TYPE_INTRA_AP | LS_SCOPE_AREA: @@ -460,34 +373,46 @@ ospf6_print_lsa(register const struct lsa *lsap) TCHECK(lsap->lsa_un.un_intra_ap.intra_ap_rtid); ospf6_print_ls_type( EXTRACT_16BITS(&lsap->lsa_un.un_intra_ap.intra_ap_lstype), - &lsap->lsa_un.un_intra_ap.intra_ap_lsid, - &lsap->lsa_un.un_intra_ap.intra_ap_rtid, - "LinkStateType %d"); + &lsap->lsa_un.un_intra_ap.intra_ap_lsid); TCHECK(lsap->lsa_un.un_intra_ap.intra_ap_nprefix); - printf(" npref %d", - EXTRACT_16BITS(&lsap->lsa_un.un_intra_ap.intra_ap_nprefix)); - - lsapp = lsap->lsa_un.un_intra_ap.intra_ap_prefix; - for (j = 0; - j < EXTRACT_16BITS(&lsap->lsa_un.un_intra_ap.intra_ap_nprefix); - j++) { - k = ospf6_print_lsaprefix(lsapp); - if (k) - goto trunc; - lsapp = (struct lsa_prefix *)(((u_char *)lsapp) + k); - } + prefixes = EXTRACT_16BITS(&lsap->lsa_un.un_intra_ap.intra_ap_nprefix); + printf("\n\t Prefixes %d:", prefixes); + + tptr = (u_int8_t *)lsap->lsa_un.un_intra_ap.intra_ap_prefix; + + while (prefixes > 0) { + lsapp = (struct lsa6_prefix *)tptr; + if ((bytelen = ospf6_print_lsaprefix(lsapp)) == -1) { + goto trunc; + } + prefixes--; + tptr += bytelen; + } break; + case LS_TYPE_GRACE | LS_SCOPE_LINKLOCAL: + if (ospf_print_grace_lsa(tptr, lsa_length) == -1) { + return 1; + } + + break; + + case LS_TYPE_INTRA_ATE | LS_SCOPE_LINKLOCAL: + if (ospf_print_te_lsa(tptr, lsa_length) == -1) { + return 1; + } + break; + default: - printf(" ??LinkStateType 0x%04x??", - EXTRACT_16BITS(&lsap->ls_hdr.ls_type)); + if(!print_unknown_data(tptr, + "\n\t ", + lsa_length)) { + return (1); + } } - /* { (ctags) */ - fputs(" }", stdout); return (0); trunc: - fputs(" }", stdout); return (1); } @@ -496,103 +421,80 @@ ospf6_decode_v3(register const struct ospf6hdr *op, register const u_char *dataend) { register const rtrid_t *ap; - register const struct lsr *lsrp; - register const struct lsa_hdr *lshp; - register const struct lsa *lsap; - register char sep; + register const struct lsr6 *lsrp; + register const struct lsa6_hdr *lshp; + register const struct lsa6 *lsap; register int i; switch (op->ospf6_type) { - case OSPF_TYPE_UMD: - /* - * Rob Coltun's special monitoring packets; - * do nothing - */ - break; - case OSPF_TYPE_HELLO: - if (vflag) { - TCHECK(op->ospf6_hello.hello_deadint); - ospf6_print_bits(ospf6_option_bits, - EXTRACT_32BITS(&op->ospf6_hello.hello_options)); - printf(" ifid %s pri %d int %d dead %u", - ipaddr_string(&op->ospf6_hello.hello_ifid), - op->ospf6_hello.hello_priority, - EXTRACT_16BITS(&op->ospf6_hello.hello_helloint), - EXTRACT_16BITS(&op->ospf6_hello.hello_deadint)); - } + printf("\n\tOptions [%s]", + bittok2str(ospf6_option_values, "none", + EXTRACT_32BITS(&op->ospf6_hello.hello_options))); + + TCHECK(op->ospf6_hello.hello_deadint); + printf("\n\t Hello Timer %us, Dead Timer %us, Interface-ID %s, Priority %u", + EXTRACT_16BITS(&op->ospf6_hello.hello_helloint), + EXTRACT_16BITS(&op->ospf6_hello.hello_deadint), + ipaddr_string(&op->ospf6_hello.hello_ifid), + op->ospf6_hello.hello_priority); + TCHECK(op->ospf6_hello.hello_dr); if (op->ospf6_hello.hello_dr != 0) - printf(" dr %s", + printf("\n\t Designated Router %s", ipaddr_string(&op->ospf6_hello.hello_dr)); TCHECK(op->ospf6_hello.hello_bdr); if (op->ospf6_hello.hello_bdr != 0) - printf(" bdr %s", + printf(", Backup Designated Router %s", ipaddr_string(&op->ospf6_hello.hello_bdr)); if (vflag) { - printf(" nbrs"); + printf("\n\t Neighbor List:"); ap = op->ospf6_hello.hello_neighbor; while ((u_char *)ap < dataend) { TCHECK(*ap); - printf(" %s", ipaddr_string(ap)); + printf("\n\t %s", ipaddr_string(ap)); ++ap; } } break; /* HELLO */ - case OSPF_TYPE_DB: + case OSPF_TYPE_DD: TCHECK(op->ospf6_db.db_options); - ospf6_print_bits(ospf6_option_bits, - EXTRACT_32BITS(&op->ospf6_db.db_options)); - sep = ' '; + printf("\n\tOptions [%s]", + bittok2str(ospf6_option_values, "none", + EXTRACT_32BITS(&op->ospf6_db.db_options))); TCHECK(op->ospf6_db.db_flags); - if (op->ospf6_db.db_flags & OSPF6_DB_INIT) { - printf("%cI", sep); - sep = '/'; - } - if (op->ospf6_db.db_flags & OSPF6_DB_MORE) { - printf("%cM", sep); - sep = '/'; - } - if (op->ospf6_db.db_flags & OSPF6_DB_MASTER) { - printf("%cMS", sep); - sep = '/'; - } - TCHECK(op->ospf6_db.db_seq); - printf(" mtu %u S %X", EXTRACT_16BITS(&op->ospf6_db.db_mtu), - EXTRACT_32BITS(&op->ospf6_db.db_seq)); - - if (vflag) { - /* Print all the LS adv's */ - lshp = op->ospf6_db.db_lshdr; + printf(", DD Flags [%s]", + bittok2str(ospf6_dd_flag_values,"none",op->ospf6_db.db_flags)); - while (!ospf6_print_lshdr(lshp)) { - /* { (ctags) */ - printf(" }"); - ++lshp; - } - } + TCHECK(op->ospf6_db.db_seq); + printf(", MTU %u, DD-Sequence 0x%08x", + EXTRACT_16BITS(&op->ospf6_db.db_mtu), + EXTRACT_32BITS(&op->ospf6_db.db_seq)); + + /* Print all the LS adv's */ + lshp = op->ospf6_db.db_lshdr; + while (!ospf6_print_lshdr(lshp)) { + ++lshp; + } break; - case OSPF_TYPE_LSR: + case OSPF_TYPE_LS_REQ: if (vflag) { lsrp = op->ospf6_lsr; while ((u_char *)lsrp < dataend) { TCHECK(*lsrp); - printf(" {"); /* } (ctags) */ + printf("\n\t Advertising Router %s", + ipaddr_string(&lsrp->ls_router)); ospf6_print_ls_type(EXTRACT_16BITS(&lsrp->ls_type), - &lsrp->ls_stateid, - &lsrp->ls_router, - "LinkStateType %d"); - /* { (ctags) */ - printf(" }"); + &lsrp->ls_stateid); ++lsrp; } } break; - case OSPF_TYPE_LSU: + case OSPF_TYPE_LS_UPDATE: if (vflag) { lsap = op->ospf6_lsu.lsu_lsa; TCHECK(op->ospf6_lsu.lsu_count); @@ -600,27 +502,24 @@ ospf6_decode_v3(register const struct ospf6hdr *op, while (i--) { if (ospf6_print_lsa(lsap)) goto trunc; - lsap = (struct lsa *)((u_char *)lsap + + lsap = (struct lsa6 *)((u_char *)lsap + EXTRACT_16BITS(&lsap->ls_hdr.ls_length)); } } break; - case OSPF_TYPE_LSA: + case OSPF_TYPE_LS_ACK: if (vflag) { lshp = op->ospf6_lsa.lsa_lshdr; while (!ospf6_print_lshdr(lshp)) { - /* { (ctags) */ - printf(" }"); ++lshp; } } break; default: - printf("v3 type %d", op->ospf6_type); break; } return (0); @@ -640,10 +539,15 @@ ospf6_print(register const u_char *bp, register u_int length) /* If the type is valid translate it, or just print the type */ /* value. If it's not valid, say so and return */ TCHECK(op->ospf6_type); - cp = tok2str(type2str, "type%d", op->ospf6_type); - printf("OSPFv%d-%s %d:", op->ospf6_version, cp, length); - if (*cp == 't') + cp = tok2str(ospf6_type_values, "unknown LS-type", op->ospf6_type); + printf("OSPFv%u, %s, length %d", op->ospf6_version, cp, length); + if (*cp == 'u') { return; + } + + if(!vflag) { /* non verbose - so lets bail out here */ + return; + } TCHECK(op->ospf6_len); if (length != EXTRACT_16BITS(&op->ospf6_len)) { @@ -654,16 +558,16 @@ ospf6_print(register const u_char *bp, register u_int length) /* Print the routerid if it is not the same as the source */ TCHECK(op->ospf6_routerid); - printf(" rtrid %s", ipaddr_string(&op->ospf6_routerid)); + printf("\n\tRouter-ID %s", ipaddr_string(&op->ospf6_routerid)); TCHECK(op->ospf6_areaid); if (op->ospf6_areaid != 0) - printf(" area %s", ipaddr_string(&op->ospf6_areaid)); + printf(", Area %s", ipaddr_string(&op->ospf6_areaid)); else - printf(" backbone"); + printf(", Backbone Area"); TCHECK(op->ospf6_instanceid); if (op->ospf6_instanceid) - printf(" instance %u", op->ospf6_instanceid); + printf(", Instance %u", op->ospf6_instanceid); /* Do rest according to version. */ switch (op->ospf6_version) { diff --git a/contrib/tcpdump/print-pflog.c b/contrib/tcpdump/print-pflog.c index dd9ba495e9..972cb4b132 100644 --- a/contrib/tcpdump/print-pflog.c +++ b/contrib/tcpdump/print-pflog.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-pflog.c,v 1.13.2.4 2007/09/13 17:18:10 gianluca Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-pflog.c,v 1.16 2007-09-12 19:36:18 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -31,17 +31,12 @@ static const char rcsid[] _U_ = #ifndef HAVE_NET_PFVAR_H #error "No pf headers available" #endif - #include -#ifndef WIN32 #include -#endif #include #include #include - - #include #include diff --git a/contrib/tcpdump/print-pgm.c b/contrib/tcpdump/print-pgm.c index edaf93333e..73a42914c7 100644 --- a/contrib/tcpdump/print-pgm.c +++ b/contrib/tcpdump/print-pgm.c @@ -15,7 +15,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-pgm.c,v 1.1.2.5 2005/06/07 22:06:16 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-pgm.c,v 1.5 2005-06-07 22:05:58 guy Exp $"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-pim.c b/contrib/tcpdump/print-pim.c index 39c4e4d738..774096e2f9 100644 --- a/contrib/tcpdump/print-pim.c +++ b/contrib/tcpdump/print-pim.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.45.2.4 2006/02/13 01:32:34 hannes Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.49 2006-02-13 01:31:35 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-ppp.c b/contrib/tcpdump/print-ppp.c index 1e99c15f18..708e934fd8 100644 --- a/contrib/tcpdump/print-ppp.c +++ b/contrib/tcpdump/print-ppp.c @@ -31,7 +31,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.108.2.6 2005/12/05 11:40:36 hannes Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.114 2005-12-05 11:35:58 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-pppoe.c b/contrib/tcpdump/print-pppoe.c index 229b5eef60..7abc787832 100644 --- a/contrib/tcpdump/print-pppoe.c +++ b/contrib/tcpdump/print-pppoe.c @@ -23,7 +23,7 @@ #ifndef lint static const char rcsid[] _U_ = -"@(#) $Header: /tcpdump/master/tcpdump/print-pppoe.c,v 1.30.2.1 2005/04/26 19:48:56 guy Exp $ (LBL)"; +"@(#) $Header: /tcpdump/master/tcpdump/print-pppoe.c,v 1.31 2005-04-26 19:48:38 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-pptp.c b/contrib/tcpdump/print-pptp.c index d400589300..2fbba6211e 100644 --- a/contrib/tcpdump/print-pptp.c +++ b/contrib/tcpdump/print-pptp.c @@ -24,7 +24,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-pptp.c,v 1.11.2.1 2006/06/23 02:07:27 hannes Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-pptp.c,v 1.12 2006-06-23 02:03:09 hannes Exp $"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-radius.c b/contrib/tcpdump/print-radius.c index 203c50bd06..44f0c7fce9 100644 --- a/contrib/tcpdump/print-radius.c +++ b/contrib/tcpdump/print-radius.c @@ -44,7 +44,7 @@ #ifndef lint static const char rcsid[] _U_ = - "$Id: print-radius.c,v 1.27.2.1 2005/09/26 01:02:40 guy Exp $"; + "$Id: print-radius.c,v 1.28 2005-09-26 01:01:55 guy Exp $"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-raw.c b/contrib/tcpdump/print-raw.c index 0fe6dd1947..8e376ce52c 100644 --- a/contrib/tcpdump/print-raw.c +++ b/contrib/tcpdump/print-raw.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-raw.c,v 1.41 2003/11/16 09:36:34 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-raw.c,v 1.41 2003-11-16 09:36:34 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-rip.c b/contrib/tcpdump/print-rip.c index 772a2e056c..27446a6823 100644 --- a/contrib/tcpdump/print-rip.c +++ b/contrib/tcpdump/print-rip.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-rip.c,v 1.57 2003/11/16 09:36:34 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-rip.c,v 1.59 2006-03-23 14:58:44 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -37,6 +37,8 @@ static const char rcsid[] _U_ = #include "addrtoname.h" #include "extract.h" /* must come after interface.h */ +#include "af.h" + struct rip { u_int8_t rip_cmd; /* request/response */ u_int8_t rip_vers; /* protocol version # */ @@ -100,8 +102,8 @@ rip_entry_print_v1(register const struct rip_netinfo *ni) /* RFC 1058 */ family = EXTRACT_16BITS(&ni->rip_family); - if (family != AF_INET) { - printf("\n\t AFI: %u:", family); + if (family != BSD_AFNUM_INET) { + printf("\n\t AFI %s, ", tok2str(bsd_af_values, "Unknown (%u)", family)); print_unknown_data((u_int8_t *)&ni->rip_family,"\n\t ",RIP_ROUTELEN); return; } @@ -111,7 +113,7 @@ rip_entry_print_v1(register const struct rip_netinfo *ni) /* MBZ fields not zero */ print_unknown_data((u_int8_t *)&ni->rip_family,"\n\t ",RIP_ROUTELEN); return; - } /* AF_INET */ + } /* BSD_AFNUM_INET */ printf("\n\t %s, metric: %u", ipaddr_string(&ni->rip_dest), EXTRACT_32BITS(&ni->rip_metric)); @@ -139,12 +141,13 @@ rip_entry_print_v2(register const struct rip_netinfo *ni) EXTRACT_16BITS(&ni->rip_tag)); print_unknown_data((u_int8_t *)&ni->rip_dest,"\n\t ",RIP_AUTHLEN); } - } else if (family != AF_INET) { - printf("\n\t AFI: %u", family); + } else if (family != BSD_AFNUM_INET) { + printf("\n\t AFI %s", tok2str(bsd_af_values, "Unknown (%u)", family)); print_unknown_data((u_int8_t *)&ni->rip_tag,"\n\t ",RIP_ROUTELEN-2); return; - } else { /* AF_INET */ - printf("\n\t AFI: IPv4: %15s/%-2d, tag 0x%04x, metric: %u, next-hop: ", + } else { /* BSD_AFNUM_INET */ + printf("\n\t AFI %s, %15s/%-2d, tag 0x%04x, metric: %u, next-hop: ", + tok2str(bsd_af_values, "Unknown (%u)", family), ipaddr_string(&ni->rip_dest), mask2plen(EXTRACT_32BITS(&ni->rip_dest_mask)), EXTRACT_16BITS(&ni->rip_tag), diff --git a/contrib/tcpdump/print-ripng.c b/contrib/tcpdump/print-ripng.c index 5e7a02ecc4..cef39daf1e 100644 --- a/contrib/tcpdump/print-ripng.c +++ b/contrib/tcpdump/print-ripng.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-ripng.c,v 1.18 2005/01/04 00:15:54 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-ripng.c,v 1.18 2005-01-04 00:15:54 guy Exp $"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-rrcp.c b/contrib/tcpdump/print-rrcp.c new file mode 100644 index 0000000000..dc3045793b --- /dev/null +++ b/contrib/tcpdump/print-rrcp.c @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2007 - Andrey "nording" Chernyak + * + * 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 Realtek Remote Control Protocol (RRCP) + * and Realtek Echo Protocol (RRCP-REP) packets. + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-rrcp.c,v 1.1.2.2 2008-04-11 17:00:00 gianluca Exp $"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include +#include + +#include "netdissect.h" +#include "addrtoname.h" +#include "extract.h" +#include "ether.h" + +#ifndef ETH_ALEN +#define ETH_ALEN 6 +#endif + +struct rrcp_packet_t +{ + u_int16_t rrcp_ethertype; /* 0x8899 */ + u_int8_t rrcp_proto; /* must be 0x01 */ + u_int8_t rrcp_opcode:7; /* 0x00 = hello, 0x01 = get, 0x02 = set */ + u_int8_t rrcp_isreply:1; /* 0 = request to switch, 1 = reply from switch */ + u_int16_t rrcp_authkey; /* 0x2379 by default */ + u_int16_t rrcp_reg_addr; /* register address */ + u_int32_t rrcp_reg_data; /* register data */ + u_int32_t cookie1; + u_int32_t cookie2; +}; + +struct rrcp_helloreply_packet_t +{ + u_int16_t rrcp_ethertype; /* 0x8899 */ + u_int8_t rrcp_proto; /* must be 0x01 */ + u_int8_t rrcp_opcode:7; /* 0x00 = hello, 0x01 = get, 0x02 = set */ + u_int8_t rrcp_isreply:1; /* 0 = request to switch, 1 = reply from switch */ + u_int16_t rrcp_authkey; /* 0x2379 by default */ + u_int8_t rrcp_downlink_port; /* */ + u_int8_t rrcp_uplink_port; /* */ + u_int8_t rrcp_uplink_mac[ETH_ALEN]; /* */ + u_int16_t rrcp_chip_id; /* */ + u_int32_t rrcp_vendor_id; /* */ +}; + + +/* + * Print RRCP requests + */ +void +rrcp_print(netdissect_options *ndo, + register const u_char *cp, + u_int length _U_) +{ + const struct rrcp_packet_t *rrcp; + const struct rrcp_helloreply_packet_t *rrcp_hello; + register const struct ether_header *ep; + char proto_str[16]; + char opcode_str[32]; + + ep = (const struct ether_header *)cp; + rrcp = (const struct rrcp_packet_t *)(cp+12); + rrcp_hello = (const struct rrcp_helloreply_packet_t *)(cp+12); + + if (rrcp->rrcp_proto==1){ + strcpy(proto_str,"RRCP"); + }else if ( rrcp->rrcp_proto==2 ){ + strcpy(proto_str,"RRCP-REP"); + }else{ + sprintf(proto_str,"RRCP-0x%02d",rrcp->rrcp_proto); + } + if (rrcp->rrcp_opcode==0){ + strcpy(opcode_str,"hello"); + }else if ( rrcp->rrcp_opcode==1 ){ + strcpy(opcode_str,"get"); + }else if ( rrcp->rrcp_opcode==2 ){ + strcpy(opcode_str,"set"); + }else{ + sprintf(opcode_str,"unknown opcode (0x%02d)",rrcp->rrcp_opcode); + } + ND_PRINT((ndo, "%s > %s, %s %s", + etheraddr_string(ESRC(ep)), + etheraddr_string(EDST(ep)), + proto_str, rrcp->rrcp_isreply ? "reply" : "query")); + if (rrcp->rrcp_proto==1){ + ND_PRINT((ndo, ": %s", opcode_str)); + } + if (rrcp->rrcp_opcode==1 || rrcp->rrcp_opcode==2){ + ND_PRINT((ndo, " addr=0x%04x, data=0x%04x", + rrcp->rrcp_reg_addr, rrcp->rrcp_reg_data, rrcp->rrcp_authkey)); + } + if (rrcp->rrcp_proto==1){ + ND_PRINT((ndo, ", auth=0x%04x", + ntohs(rrcp->rrcp_authkey))); + } + if (rrcp->rrcp_proto==1 && rrcp->rrcp_opcode==0 && rrcp->rrcp_isreply){ + ND_PRINT((ndo, " downlink_port=%d, uplink_port=%d, uplink_mac=%s, vendor_id=%08x ,chip_id=%04x ", + rrcp_hello->rrcp_downlink_port, + rrcp_hello->rrcp_uplink_port, + etheraddr_string(rrcp_hello->rrcp_uplink_mac), + rrcp_hello->rrcp_vendor_id, + rrcp_hello->rrcp_chip_id)); + }else if (rrcp->rrcp_opcode==1 || rrcp->rrcp_opcode==2 || rrcp->rrcp_proto==2){ + ND_PRINT((ndo, ", cookie=0x%08x%08x ", + rrcp->cookie2, rrcp->cookie1)); + } + if (!ndo->ndo_vflag) + return; +} diff --git a/contrib/tcpdump/print-rsvp.c b/contrib/tcpdump/print-rsvp.c index ad519305fa..5ed731c3de 100644 --- a/contrib/tcpdump/print-rsvp.c +++ b/contrib/tcpdump/print-rsvp.c @@ -17,7 +17,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-rsvp.c,v 1.33.2.15 2007/09/13 17:33:54 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-rsvp.c,v 1.48 2007-09-13 17:29:50 guy Exp $"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-rt6.c b/contrib/tcpdump/print-rt6.c index 39e22aeaa2..dc196b4e76 100644 --- a/contrib/tcpdump/print-rt6.c +++ b/contrib/tcpdump/print-rt6.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-rt6.c,v 1.26.2.1 2005/04/20 22:35:11 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-rt6.c,v 1.27 2005-04-20 22:34:57 guy Exp $"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-rx.c b/contrib/tcpdump/print-rx.c index d99106660e..3812a120fc 100644 --- a/contrib/tcpdump/print-rx.c +++ b/contrib/tcpdump/print-rx.c @@ -34,7 +34,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-rx.c,v 1.37.2.2 2007/06/15 19:43:15 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-rx.c,v 1.39.2.3 2008-07-01 07:45:09 guy Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -118,6 +118,12 @@ static struct tok fs_req[] = { { 162, "dfs-flushcps" }, { 163, "dfs-symlink" }, { 220, "residency" }, + { 65536, "inline-bulk-status" }, + { 65537, "fetch-data-64" }, + { 65538, "store-data-64" }, + { 65539, "give-up-all-cbs" }, + { 65540, "get-caps" }, + { 65541, "cb-rx-conn-addr" }, { 0, NULL }, }; @@ -137,6 +143,9 @@ static struct tok cb_req[] = { { 216, "getcellservdb" }, { 217, "getlocalcell" }, { 218, "getcacheconf" }, + { 65536, "getce64" }, + { 65537, "getcellbynum" }, + { 65538, "tellmeaboutyourself" }, { 0, NULL }, }; @@ -163,6 +172,7 @@ static struct tok pt_req[] = { { 519, "get-host-cps" }, { 520, "update-entry" }, { 521, "list-entries" }, + { 530, "list-super-groups" }, { 0, NULL }, }; @@ -256,6 +266,9 @@ static struct tok vol_req[] = { { 126, "set-info" }, { 127, "x-list-partitions" }, { 128, "forward-multiple" }, + { 65536, "convert-ro" }, + { 65537, "get-size" }, + { 65538, "dump-v2" }, { 0, NULL }, }; @@ -307,6 +320,8 @@ static struct tok ubik_req[] = { { 10003, "vote-getsyncsite" }, { 10004, "vote-debug" }, { 10005, "vote-sdebug" }, + { 10006, "vote-xdebug" }, + { 10007, "vote-xsdebug" }, { 20000, "disk-begin" }, { 20001, "disk-commit" }, { 20002, "disk-lock" }, @@ -325,7 +340,7 @@ static struct tok ubik_req[] = { }; #define VOTE_LOW 10000 -#define VOTE_HIGH 10005 +#define VOTE_HIGH 10007 #define DISK_LOW 20000 #define DISK_HIGH 20013 @@ -688,6 +703,13 @@ rx_cache_find(const struct rx_header *rxh, const struct ip *ip, int sport, printf(" %lu", i); \ } +#define UINT64OUT() { u_int64_t i; \ + TCHECK2(bp[0], sizeof(u_int64_t)); \ + i = EXTRACT_64BITS(bp); \ + bp += sizeof(u_int64_t); \ + printf(" %" PRIu64, i); \ + } + #define DATEOUT() { time_t t; struct tm *tm; char str[256]; \ TCHECK2(bp[0], sizeof(int32_t)); \ t = (time_t) EXTRACT_32BITS(bp); \ @@ -763,6 +785,17 @@ rx_cache_find(const struct rx_header *rxh, const struct ip *ip, int sport, printf("\""); \ } +#define DESTSERVEROUT() { unsigned long n1, n2, n3; \ + TCHECK2(bp[0], sizeof(int32_t) * 3); \ + n1 = EXTRACT_32BITS(bp); \ + bp += sizeof(int32_t); \ + n2 = EXTRACT_32BITS(bp); \ + bp += sizeof(int32_t); \ + n3 = EXTRACT_32BITS(bp); \ + bp += sizeof(int32_t); \ + printf(" server %d:%d:%d", (int) n1, (int) n2, (int) n3); \ + } + /* * Handle calls to the AFS file service (fs) */ @@ -890,6 +923,7 @@ fs_print(register const u_char *bp, int length) STROUT(AFSNAMEMAX); break; case 155: /* Bulk stat */ + case 65536: /* Inline bulk stat */ { unsigned long j; TCHECK2(bp[0], 4); @@ -904,6 +938,26 @@ fs_print(register const u_char *bp, int length) if (j == 0) printf(" "); } + case 65537: /* Fetch data 64 */ + FIDOUT(); + printf(" offset"); + UINT64OUT(); + printf(" length"); + UINT64OUT(); + break; + case 65538: /* Store data 64 */ + FIDOUT(); + STOREATTROUT(); + printf(" offset"); + UINT64OUT(); + printf(" length"); + UINT64OUT(); + printf(" flen"); + UINT64OUT(); + break; + case 65541: /* CallBack rx conn address */ + printf(" addr"); + UINTOUT(); default: ; } @@ -1267,6 +1321,7 @@ prot_print(register const u_char *bp, int length) case 517: /* List owned */ case 518: /* Get CPS2 */ case 519: /* Get host CPS */ + case 530: /* List super groups */ printf(" id"); INTOUT(); break; @@ -1915,13 +1970,176 @@ vol_print(register const u_char *bp, int length) printf(" vol call %s", tok2str(vol_req, "op#%d", vol_op)); - /* - * Normally there would be a switch statement here to decode the - * arguments to the AFS call, but since I don't have access to - * an AFS server (yet) and I'm not an AFS admin, I can't - * test any of these calls. Leave this blank for now. - */ + bp += sizeof(struct rx_header) + 4; + switch (vol_op) { + case 100: /* Create volume */ + printf(" partition"); + UINTOUT(); + printf(" name"); + STROUT(AFSNAMEMAX); + printf(" type"); + UINTOUT(); + printf(" parent"); + UINTOUT(); + break; + case 101: /* Delete volume */ + case 107: /* Get flags */ + printf(" trans"); + UINTOUT(); + break; + case 102: /* Restore */ + printf(" totrans"); + UINTOUT(); + printf(" flags"); + UINTOUT(); + break; + case 103: /* Forward */ + printf(" fromtrans"); + UINTOUT(); + printf(" fromdate"); + DATEOUT(); + DESTSERVEROUT(); + printf(" desttrans"); + INTOUT(); + break; + case 104: /* End trans */ + printf(" trans"); + UINTOUT(); + break; + case 105: /* Clone */ + printf(" trans"); + UINTOUT(); + printf(" purgevol"); + UINTOUT(); + printf(" newtype"); + UINTOUT(); + printf(" newname"); + STROUT(AFSNAMEMAX); + break; + case 106: /* Set flags */ + printf(" trans"); + UINTOUT(); + printf(" flags"); + UINTOUT(); + break; + case 108: /* Trans create */ + printf(" vol"); + UINTOUT(); + printf(" partition"); + UINTOUT(); + printf(" flags"); + UINTOUT(); + break; + case 109: /* Dump */ + case 655537: /* Get size */ + printf(" fromtrans"); + UINTOUT(); + printf(" fromdate"); + DATEOUT(); + break; + case 110: /* Get n-th volume */ + printf(" index"); + UINTOUT(); + break; + case 111: /* Set forwarding */ + printf(" tid"); + UINTOUT(); + printf(" newsite"); + UINTOUT(); + break; + case 112: /* Get name */ + case 113: /* Get status */ + printf(" tid"); + break; + case 114: /* Signal restore */ + printf(" name"); + STROUT(AFSNAMEMAX); + printf(" type"); + UINTOUT(); + printf(" pid"); + UINTOUT(); + printf(" cloneid"); + UINTOUT(); + break; + case 116: /* List volumes */ + printf(" partition"); + UINTOUT(); + printf(" flags"); + UINTOUT(); + break; + case 117: /* Set id types */ + printf(" tid"); + UINTOUT(); + printf(" name"); + STROUT(AFSNAMEMAX); + printf(" type"); + UINTOUT(); + printf(" pid"); + UINTOUT(); + printf(" clone"); + UINTOUT(); + printf(" backup"); + UINTOUT(); + break; + case 119: /* Partition info */ + printf(" name"); + STROUT(AFSNAMEMAX); + break; + case 120: /* Reclone */ + printf(" tid"); + UINTOUT(); + break; + case 121: /* List one volume */ + case 122: /* Nuke volume */ + case 124: /* Extended List volumes */ + case 125: /* Extended List one volume */ + case 65536: /* Convert RO to RW volume */ + printf(" partid"); + UINTOUT(); + printf(" volid"); + UINTOUT(); + break; + case 123: /* Set date */ + printf(" tid"); + UINTOUT(); + printf(" date"); + DATEOUT(); + break; + case 126: /* Set info */ + printf(" tid"); + UINTOUT(); + break; + case 128: /* Forward multiple */ + printf(" fromtrans"); + UINTOUT(); + printf(" fromdate"); + DATEOUT(); + { + unsigned long i, j; + TCHECK2(bp[0], 4); + j = EXTRACT_32BITS(bp); + bp += sizeof(int32_t); + for (i = 0; i < j; i++) { + DESTSERVEROUT(); + if (i != j - 1) + printf(","); + } + if (j == 0) + printf(" "); + } + break; + case 65538: /* Dump version 2 */ + printf(" fromtrans"); + UINTOUT(); + printf(" fromdate"); + DATEOUT(); + printf(" flags"); + UINTOUT(); + break; + default: + ; + } return; trunc: @@ -1955,10 +2173,100 @@ vol_reply_print(register const u_char *bp, int length, int32_t opcode) * If it was a data packet, interpret the response. */ - if (rxh->type == RX_PACKET_TYPE_DATA) - /* Well, no, not really. Leave this for later */ - ; - else { + if (rxh->type == RX_PACKET_TYPE_DATA) { + switch (opcode) { + case 100: /* Create volume */ + printf(" volid"); + UINTOUT(); + printf(" trans"); + UINTOUT(); + break; + case 104: /* End transaction */ + UINTOUT(); + break; + case 105: /* Clone */ + printf(" newvol"); + UINTOUT(); + break; + case 107: /* Get flags */ + UINTOUT(); + break; + case 108: /* Transaction create */ + printf(" trans"); + UINTOUT(); + break; + case 110: /* Get n-th volume */ + printf(" volume"); + UINTOUT(); + printf(" partition"); + UINTOUT(); + break; + case 112: /* Get name */ + STROUT(AFSNAMEMAX); + break; + case 113: /* Get status */ + printf(" volid"); + UINTOUT(); + printf(" nextuniq"); + UINTOUT(); + printf(" type"); + UINTOUT(); + printf(" parentid"); + UINTOUT(); + printf(" clone"); + UINTOUT(); + printf(" backup"); + UINTOUT(); + printf(" restore"); + UINTOUT(); + printf(" maxquota"); + UINTOUT(); + printf(" minquota"); + UINTOUT(); + printf(" owner"); + UINTOUT(); + printf(" create"); + DATEOUT(); + printf(" access"); + DATEOUT(); + printf(" update"); + DATEOUT(); + printf(" expire"); + DATEOUT(); + printf(" backup"); + DATEOUT(); + printf(" copy"); + DATEOUT(); + break; + case 115: /* Old list partitions */ + break; + case 116: /* List volumes */ + case 121: /* List one volume */ + { + unsigned long i, j; + TCHECK2(bp[0], 4); + j = EXTRACT_32BITS(bp); + bp += sizeof(int32_t); + for (i = 0; i < j; i++) { + printf(" name"); + VECOUT(32); + printf(" volid"); + UINTOUT(); + printf(" type"); + bp += sizeof(int32_t) * 21; + if (i != j - 1) + printf(","); + } + if (j == 0) + printf(" "); + } + break; + + + default: + ; + } + } else { /* * Otherwise, just print out the return code */ diff --git a/contrib/tcpdump/print-sctp.c b/contrib/tcpdump/print-sctp.c index 7a1897812b..05c753a52e 100644 --- a/contrib/tcpdump/print-sctp.c +++ b/contrib/tcpdump/print-sctp.c @@ -35,7 +35,7 @@ #ifndef lint static const char rcsid[] _U_ = -"@(#) $Header: /tcpdump/master/tcpdump/print-sctp.c,v 1.16.2.5 2007/09/13 18:04:58 guy Exp $ (NETLAB/PEL)"; +"@(#) $Header: /tcpdump/master/tcpdump/print-sctp.c,v 1.21 2007-09-13 18:03:49 guy Exp $ (NETLAB/PEL)"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-sflow.c b/contrib/tcpdump/print-sflow.c new file mode 100644 index 0000000000..baa55300b6 --- /dev/null +++ b/contrib/tcpdump/print-sflow.c @@ -0,0 +1,577 @@ +/* + * 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. + * + * The SFLOW protocol as per http://www.sflow.org/developers/specifications.php + * + * Original code by Carles Kishimoto + */ + +#ifndef lint +static const char rcsid[] _U_ = +"@(#) $Header: /tcpdump/master/tcpdump/print-sflow.c,v 1.1 2007-08-08 17:20:58 hannes Exp $"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include +#include +#include + +#include "interface.h" +#include "extract.h" +#include "addrtoname.h" + +/* + * sFlow datagram + * + * 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 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Sflow version (2,4,5) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | IP version (1 for IPv4 | 2 for IPv6) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | IP Address AGENT (4 or 16 bytes) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Sub agent ID | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Datagram sequence number | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Switch uptime in ms | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | num samples in datagram | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * + */ + +struct sflow_datagram_t { + u_int8_t version[4]; + u_int8_t ip_version[4]; + u_int8_t agent[4]; + u_int8_t agent_id[4]; + u_int8_t seqnum[4]; + u_int8_t uptime[4]; + u_int8_t samples[4]; +}; + +struct sflow_sample_header { + u_int8_t format[4]; + u_int8_t len[4]; +}; + +#define SFLOW_FLOW_SAMPLE 1 +#define SFLOW_COUNTER_SAMPLE 2 +#define SFLOW_EXPANDED_FLOW_SAMPLE 3 +#define SFLOW_EXPANDED_COUNTER_SAMPLE 4 + +static const struct tok sflow_format_values[] = { + { SFLOW_FLOW_SAMPLE, "flow sample" }, + { SFLOW_COUNTER_SAMPLE, "counter sample" }, + { SFLOW_EXPANDED_FLOW_SAMPLE, "expanded flow sample" }, + { SFLOW_EXPANDED_COUNTER_SAMPLE, "expanded counter sample" }, + { 0, NULL} +}; + +struct sflow_expanded_flow_sample_t { + u_int8_t seqnum[4]; + u_int8_t type[4]; + u_int8_t index[4]; + u_int8_t rate[4]; + u_int8_t pool[4]; + u_int8_t drops[4]; + u_int8_t in_interface_format[4]; + u_int8_t in_interface_value[4]; + u_int8_t out_interface_format[4]; + u_int8_t out_interface_value[4]; + u_int8_t records[4]; +}; + +#define SFLOW_FLOW_RAW_PACKET 1 +#define SFLOW_FLOW_ETHERNET_FRAME 2 +#define SFLOW_FLOW_IPV4_DATA 3 +#define SFLOW_FLOW_IPV6_DATA 4 +#define SFLOW_FLOW_EXTENDED_SWITCH_DATA 1001 +#define SFLOW_FLOW_EXTENDED_ROUTER_DATA 1002 +#define SFLOW_FLOW_EXTENDED_GATEWAY_DATA 1003 +#define SFLOW_FLOW_EXTENDED_USER_DATA 1004 +#define SFLOW_FLOW_EXTENDED_URL_DATA 1005 +#define SFLOW_FLOW_EXTENDED_MPLS_DATA 1006 +#define SFLOW_FLOW_EXTENDED_NAT_DATA 1007 +#define SFLOW_FLOW_EXTENDED_MPLS_TUNNEL 1008 +#define SFLOW_FLOW_EXTENDED_MPLS_VC 1009 +#define SFLOW_FLOW_EXTENDED_MPLS_FEC 1010 +#define SFLOW_FLOW_EXTENDED_MPLS_LVP_FEC 1011 +#define SFLOW_FLOW_EXTENDED_VLAN_TUNNEL 1012 + +static const struct tok sflow_flow_type_values[] = { + { SFLOW_FLOW_RAW_PACKET, "Raw packet"}, + { SFLOW_FLOW_ETHERNET_FRAME, "Ethernet frame"}, + { SFLOW_FLOW_IPV4_DATA, "IPv4 Data"}, + { SFLOW_FLOW_IPV6_DATA, "IPv6 Data"}, + { SFLOW_FLOW_EXTENDED_SWITCH_DATA, "Extended Switch data"}, + { SFLOW_FLOW_EXTENDED_ROUTER_DATA, "Extended Router data"}, + { SFLOW_FLOW_EXTENDED_GATEWAY_DATA, "Extended Gateway data"}, + { SFLOW_FLOW_EXTENDED_USER_DATA, "Extended User data"}, + { SFLOW_FLOW_EXTENDED_URL_DATA, "Extended URL data"}, + { SFLOW_FLOW_EXTENDED_MPLS_DATA, "Extended MPLS data"}, + { SFLOW_FLOW_EXTENDED_NAT_DATA, "Extended NAT data"}, + { SFLOW_FLOW_EXTENDED_MPLS_TUNNEL, "Extended MPLS tunnel"}, + { SFLOW_FLOW_EXTENDED_MPLS_VC, "Extended MPLS VC"}, + { SFLOW_FLOW_EXTENDED_MPLS_FEC, "Extended MPLS FEC"}, + { SFLOW_FLOW_EXTENDED_MPLS_LVP_FEC, "Extended MPLS LVP FEC"}, + { SFLOW_FLOW_EXTENDED_VLAN_TUNNEL, "Extended VLAN Tunnel"}, + { 0, NULL} +}; + +#define SFLOW_HEADER_PROTOCOL_ETHERNET 1 +#define SFLOW_HEADER_PROTOCOL_IPV4 11 +#define SFLOW_HEADER_PROTOCOL_IPV6 12 + +static const struct tok sflow_flow_raw_protocol_values[] = { + { SFLOW_HEADER_PROTOCOL_ETHERNET, "Ethernet"}, + { SFLOW_HEADER_PROTOCOL_IPV4, "IPv4"}, + { SFLOW_HEADER_PROTOCOL_IPV6, "IPv6"}, + { 0, NULL} +}; + +struct sflow_expanded_flow_raw_t { + u_int8_t protocol[4]; + u_int8_t length[4]; + u_int8_t stripped_bytes[4]; + u_int8_t header_size[4]; +}; + +struct sflow_expanded_counter_sample_t { + u_int8_t seqnum[4]; + u_int8_t type[4]; + u_int8_t index[4]; + u_int8_t records[4]; +}; + +#define SFLOW_COUNTER_GENERIC 1 +#define SFLOW_COUNTER_ETHERNET 2 +#define SFLOW_COUNTER_TOKEN_RING 3 +#define SFLOW_COUNTER_BASEVG 4 +#define SFLOW_COUNTER_VLAN 5 +#define SFLOW_COUNTER_PROCESSOR 1001 + +static const struct tok sflow_counter_type_values[] = { + { SFLOW_COUNTER_GENERIC, "Generic counter"}, + { SFLOW_COUNTER_ETHERNET, "Ethernet counter"}, + { SFLOW_COUNTER_TOKEN_RING, "Token ring counter"}, + { SFLOW_COUNTER_BASEVG, "100 BaseVG counter"}, + { SFLOW_COUNTER_VLAN, "Vlan counter"}, + { SFLOW_COUNTER_PROCESSOR, "Processor counter"}, + { 0, NULL} +}; + +#define SFLOW_IFACE_DIRECTION_UNKNOWN 0 +#define SFLOW_IFACE_DIRECTION_FULLDUPLEX 1 +#define SFLOW_IFACE_DIRECTION_HALFDUPLEX 2 +#define SFLOW_IFACE_DIRECTION_IN 3 +#define SFLOW_IFACE_DIRECTION_OUT 4 + +static const struct tok sflow_iface_direction_values[] = { + { SFLOW_IFACE_DIRECTION_UNKNOWN, "unknown"}, + { SFLOW_IFACE_DIRECTION_FULLDUPLEX, "full-duplex"}, + { SFLOW_IFACE_DIRECTION_HALFDUPLEX, "half-duplex"}, + { SFLOW_IFACE_DIRECTION_IN, "in"}, + { SFLOW_IFACE_DIRECTION_OUT, "out"}, + { 0, NULL} +}; + +struct sflow_generic_counter_t { + u_int8_t ifindex[4]; + u_int8_t iftype[4]; + u_int8_t ifspeed[8]; + u_int8_t ifdirection[4]; + u_int8_t ifstatus[4]; + u_int8_t ifinoctets[8]; + u_int8_t ifinunicastpkts[4]; + u_int8_t ifinmulticastpkts[4]; + u_int8_t ifinbroadcastpkts[4]; + u_int8_t ifindiscards[4]; + u_int8_t ifinerrors[4]; + u_int8_t ifinunkownprotos[4]; + u_int8_t ifoutoctets[8]; + u_int8_t ifoutunicastpkts[4]; + u_int8_t ifoutmulticastpkts[4]; + u_int8_t ifoutbroadcastpkts[4]; + u_int8_t ifoutdiscards[4]; + u_int8_t ifouterrors[4]; + u_int8_t ifpromiscmode[4]; +}; + +struct sflow_ethernet_counter_t { + u_int8_t alignerrors[4]; + u_int8_t fcserrors[4]; + u_int8_t single_collision_frames[4]; + u_int8_t multiple_collision_frames[4]; + u_int8_t test_errors[4]; + u_int8_t deferred_transmissions[4]; + u_int8_t late_collisions[4]; + u_int8_t excessive_collisions[4]; + u_int8_t mac_transmit_errors[4]; + u_int8_t carrier_sense_errors[4]; + u_int8_t frame_too_longs[4]; + u_int8_t mac_receive_errors[4]; + u_int8_t symbol_errors[4]; +}; + +struct sflow_100basevg_counter_t { + u_int8_t in_highpriority_frames[4]; + u_int8_t in_highpriority_octets[8]; + u_int8_t in_normpriority_frames[4]; + u_int8_t in_normpriority_octets[8]; + u_int8_t in_ipmerrors[4]; + u_int8_t in_oversized[4]; + u_int8_t in_data_errors[4]; + u_int8_t in_null_addressed_frames[4]; + u_int8_t out_highpriority_frames[4]; + u_int8_t out_highpriority_octets[8]; + u_int8_t transitioninto_frames[4]; + u_int8_t hc_in_highpriority_octets[8]; + u_int8_t hc_in_normpriority_octets[8]; + u_int8_t hc_out_highpriority_octets[8]; +}; + +struct sflow_vlan_counter_t { + u_int8_t vlan_id[4]; + u_int8_t octets[8]; + u_int8_t unicast_pkt[4]; + u_int8_t multicast_pkt[4]; + u_int8_t broadcast_pkt[4]; + u_int8_t discards[4]; +}; + +void +sflow_print(const u_char *pptr, u_int len) { + + const struct sflow_datagram_t *sflow_datagram; + const struct sflow_sample_header *sflow_sample; + const struct sflow_expanded_flow_sample_t *sflow_expanded_flow_sample; + const struct sflow_expanded_flow_raw_t *sflow_flow_raw; + const struct sflow_expanded_counter_sample_t *sflow_expanded_counter_sample; + const struct sflow_generic_counter_t *sflow_gen_counter; + const struct sflow_ethernet_counter_t *sflow_eth_counter; + const struct sflow_100basevg_counter_t *sflow_100basevg_counter; + const struct sflow_vlan_counter_t *sflow_vlan_counter; + const u_char *tptr; + int tlen; + u_int32_t sflow_sample_type, sflow_sample_len; + int nsamples, nrecords, counter_len, counter_type, flow_len, flow_type; + + tptr=pptr; + tlen = len; + sflow_datagram = (const struct sflow_datagram_t *)pptr; + TCHECK(*sflow_datagram); + + /* + * Sanity checking of the header. + */ + if (EXTRACT_32BITS(sflow_datagram->version) != 5) { + printf("sFlow version %u packet not supported", + EXTRACT_32BITS(sflow_datagram->version)); + return; + } + + if (vflag < 1) { + printf("sFlowv%u, %s agent %s, agent-id %u, length %u", + EXTRACT_32BITS(sflow_datagram->version), + EXTRACT_32BITS(sflow_datagram->ip_version) == 1 ? "IPv4" : "IPv6", + ipaddr_string(sflow_datagram->agent), + EXTRACT_32BITS(sflow_datagram->samples), + len); + return; + } + + /* ok they seem to want to know everything - lets fully decode it */ + nsamples=EXTRACT_32BITS(sflow_datagram->samples); + printf("sFlowv%u, %s agent %s, agent-id %u, seqnum %u, uptime %u, samples %u, length %u", + EXTRACT_32BITS(sflow_datagram->version), + EXTRACT_32BITS(sflow_datagram->ip_version) == 1 ? "IPv4" : "IPv6", + ipaddr_string(sflow_datagram->agent), + EXTRACT_32BITS(sflow_datagram->agent_id), + EXTRACT_32BITS(sflow_datagram->seqnum), + EXTRACT_32BITS(sflow_datagram->uptime), + nsamples, + len); + + /* skip Common header */ + tptr+=sizeof(const struct sflow_datagram_t); + tlen-=sizeof(const struct sflow_datagram_t); + + while (nsamples > 0 && tlen > 0) { + sflow_sample = (const struct sflow_sample_header *)tptr; + sflow_sample_type = (EXTRACT_32BITS(sflow_sample->format)&0x0FFF); + sflow_sample_len = EXTRACT_32BITS(sflow_sample->len); + + tptr+=sizeof(struct sflow_sample_header); + tlen-=sizeof(struct sflow_sample_header); + + printf("\n\t%s (%u), length %u,", + tok2str(sflow_format_values, "Unknown", sflow_sample_type), + sflow_sample_type, + sflow_sample_len); + + /* basic sanity check */ + if (sflow_sample_type == 0 || sflow_sample_len ==0) { + return; + } + + /* did we capture enough for fully decoding the sample ? */ + if (!TTEST2(*tptr, sflow_sample_len)) + goto trunc; + + switch(sflow_sample_type) { + case SFLOW_FLOW_SAMPLE: /* XXX */ + break; + + case SFLOW_COUNTER_SAMPLE: /* XXX */ + break; + + case SFLOW_EXPANDED_FLOW_SAMPLE: + sflow_expanded_flow_sample = (const struct sflow_expanded_flow_sample_t *)tptr; + nrecords = EXTRACT_32BITS(sflow_expanded_flow_sample->records); + + printf(" seqnum %u, type %u, idx %u, rate %u, pool %u, drops %u, records %u", + EXTRACT_32BITS(sflow_expanded_flow_sample->seqnum), + EXTRACT_32BITS(sflow_expanded_flow_sample->type), + EXTRACT_32BITS(sflow_expanded_flow_sample->index), + EXTRACT_32BITS(sflow_expanded_flow_sample->rate), + EXTRACT_32BITS(sflow_expanded_flow_sample->pool), + EXTRACT_32BITS(sflow_expanded_flow_sample->drops), + EXTRACT_32BITS(sflow_expanded_flow_sample->records)); + + tptr+= sizeof(struct sflow_expanded_flow_sample_t); + tlen-= sizeof(struct sflow_expanded_flow_sample_t); + + while ( nrecords > 0 && tlen > 0) { + + /* decode Flow record - 2 bytes */ + flow_type = EXTRACT_32BITS(tptr)&0x0FFF; + flow_len = EXTRACT_32BITS(tptr+4); + printf("\n\t %s (%u) length %u", + tok2str(sflow_flow_type_values,"Unknown",flow_type), + flow_type, + flow_len); + + tptr += 8; + tlen -= 8; + + /* did we capture enough for fully decoding the flow ? */ + if (!TTEST2(*tptr, flow_len)) + goto trunc; + + switch(flow_type) { + case SFLOW_FLOW_RAW_PACKET: + sflow_flow_raw = (const struct sflow_expanded_flow_raw_t *)tptr; + printf("\n\t protocol %s (%u), length %u, stripped bytes %u, header_size %u", + tok2str(sflow_flow_raw_protocol_values,"Unknown",EXTRACT_32BITS(sflow_flow_raw->protocol)), + EXTRACT_32BITS(sflow_flow_raw->protocol), + EXTRACT_32BITS(sflow_flow_raw->length), + EXTRACT_32BITS(sflow_flow_raw->stripped_bytes), + EXTRACT_32BITS(sflow_flow_raw->header_size)); + break; + + /* + * FIXME those are the defined flow types that lack a decoder + */ + case SFLOW_FLOW_ETHERNET_FRAME: + case SFLOW_FLOW_IPV4_DATA: + case SFLOW_FLOW_IPV6_DATA: + case SFLOW_FLOW_EXTENDED_SWITCH_DATA: + case SFLOW_FLOW_EXTENDED_ROUTER_DATA: + case SFLOW_FLOW_EXTENDED_GATEWAY_DATA: + case SFLOW_FLOW_EXTENDED_USER_DATA: + case SFLOW_FLOW_EXTENDED_URL_DATA: + case SFLOW_FLOW_EXTENDED_MPLS_DATA: + case SFLOW_FLOW_EXTENDED_NAT_DATA: + case SFLOW_FLOW_EXTENDED_MPLS_TUNNEL: + case SFLOW_FLOW_EXTENDED_MPLS_VC: + case SFLOW_FLOW_EXTENDED_MPLS_FEC: + case SFLOW_FLOW_EXTENDED_MPLS_LVP_FEC: + case SFLOW_FLOW_EXTENDED_VLAN_TUNNEL: + break; + default: + if (vflag <= 1) + print_unknown_data(tptr, "\n\t ", flow_len); + break; + + } + tptr += flow_len; + tlen -= flow_len; + nrecords--; + } + break; + + case SFLOW_EXPANDED_COUNTER_SAMPLE: + sflow_expanded_counter_sample = (const struct sflow_expanded_counter_sample_t *)tptr; + nrecords = EXTRACT_32BITS(sflow_expanded_counter_sample->records); + + printf(" seqnum %u, type %u, idx %u, records %u", + EXTRACT_32BITS(sflow_expanded_counter_sample->seqnum), + EXTRACT_32BITS(sflow_expanded_counter_sample->type), + EXTRACT_32BITS(sflow_expanded_counter_sample->index), + nrecords); + + tptr+= sizeof(struct sflow_expanded_counter_sample_t); + tlen-= sizeof(struct sflow_expanded_counter_sample_t); + + while ( nrecords > 0 && tlen > 0) { + + /* decode counter record - 2 bytes */ + counter_type = EXTRACT_32BITS(tptr)&0x0FFF; + counter_len = EXTRACT_32BITS(tptr+4); + printf("\n\t %s (%u) length %u", + tok2str(sflow_counter_type_values,"Unknown",counter_type), + counter_type, + counter_len); + + tptr += 8; + tlen -= 8; + + /* did we capture enough for fully decoding the counter ? */ + if (!TTEST2(*tptr, counter_len)) + goto trunc; + + switch(counter_type) { + case SFLOW_COUNTER_GENERIC: + sflow_gen_counter = (const struct sflow_generic_counter_t *)tptr; + printf("\n\t ifindex %u, iftype %u, ifspeed %u, ifdirection %u (%s)", + EXTRACT_32BITS(sflow_gen_counter->ifindex), + EXTRACT_32BITS(sflow_gen_counter->iftype), + EXTRACT_32BITS(sflow_gen_counter->ifspeed), + EXTRACT_32BITS(sflow_gen_counter->ifdirection), + tok2str(sflow_iface_direction_values, "Unknown", + EXTRACT_32BITS(sflow_gen_counter->ifdirection))); + printf("\n\t ifstatus %u, adminstatus: %s, operstatus: %s", + EXTRACT_32BITS(sflow_gen_counter->ifstatus), + EXTRACT_32BITS(sflow_gen_counter->ifstatus)&1 ? "up" : "down", + (EXTRACT_32BITS(sflow_gen_counter->ifstatus)>>1)&1 ? "up" : "down"); + printf("\n\t In octets %" PRIu64 + ", unicast pkts %u, multicast pkts %u, broadcast pkts %u, discards %u", + EXTRACT_64BITS(sflow_gen_counter->ifinoctets), + EXTRACT_32BITS(sflow_gen_counter->ifinunicastpkts), + EXTRACT_32BITS(sflow_gen_counter->ifinmulticastpkts), + EXTRACT_32BITS(sflow_gen_counter->ifinbroadcastpkts), + EXTRACT_32BITS(sflow_gen_counter->ifindiscards)); + printf("\n\t In errors %u, unknown protos %u", + EXTRACT_32BITS(sflow_gen_counter->ifinerrors), + EXTRACT_32BITS(sflow_gen_counter->ifinunkownprotos)); + printf("\n\t Out octets %" PRIu64 + ", unicast pkts %u, multicast pkts %u, broadcast pkts %u, discards %u", + EXTRACT_64BITS(sflow_gen_counter->ifoutoctets), + EXTRACT_32BITS(sflow_gen_counter->ifoutunicastpkts), + EXTRACT_32BITS(sflow_gen_counter->ifoutmulticastpkts), + EXTRACT_32BITS(sflow_gen_counter->ifoutbroadcastpkts), + EXTRACT_32BITS(sflow_gen_counter->ifoutdiscards)); + printf("\n\t Out errors %u, promisc mode %u", + EXTRACT_32BITS(sflow_gen_counter->ifouterrors), + EXTRACT_32BITS(sflow_gen_counter->ifpromiscmode)); + break; + case SFLOW_COUNTER_ETHERNET: + sflow_eth_counter = (const struct sflow_ethernet_counter_t *)tptr; + printf("\n\t align errors %u, fcs errors %u, single collision %u, multiple collision %u, test error %u", + EXTRACT_32BITS(sflow_eth_counter->alignerrors), + EXTRACT_32BITS(sflow_eth_counter->fcserrors), + EXTRACT_32BITS(sflow_eth_counter->single_collision_frames), + EXTRACT_32BITS(sflow_eth_counter->multiple_collision_frames), + EXTRACT_32BITS(sflow_eth_counter->test_errors)); + printf("\n\t deferred %u, late collision %u, excessive collision %u, mac trans error %u", + EXTRACT_32BITS(sflow_eth_counter->deferred_transmissions), + EXTRACT_32BITS(sflow_eth_counter->late_collisions), + EXTRACT_32BITS(sflow_eth_counter->excessive_collisions), + EXTRACT_32BITS(sflow_eth_counter->mac_transmit_errors)); + printf("\n\t carrier error %u, frames too long %u, mac receive errors %u, symbol errors %u", + EXTRACT_32BITS(sflow_eth_counter->carrier_sense_errors), + EXTRACT_32BITS(sflow_eth_counter->frame_too_longs), + EXTRACT_32BITS(sflow_eth_counter->mac_receive_errors), + EXTRACT_32BITS(sflow_eth_counter->symbol_errors)); + break; + case SFLOW_COUNTER_TOKEN_RING: /* XXX */ + break; + case SFLOW_COUNTER_BASEVG: + sflow_100basevg_counter = (const struct sflow_100basevg_counter_t *)tptr; + printf("\n\t in high prio frames %u, in high prio octets %" PRIu64, + EXTRACT_32BITS(sflow_100basevg_counter->in_highpriority_frames), + EXTRACT_64BITS(sflow_100basevg_counter->in_highpriority_octets)); + printf("\n\t in norm prio frames %u, in norm prio octets %" PRIu64, + EXTRACT_32BITS(sflow_100basevg_counter->in_normpriority_frames), + EXTRACT_64BITS(sflow_100basevg_counter->in_normpriority_octets)); + printf("\n\t in ipm errors %u, oversized %u, in data errors %u, null addressed frames %u", + EXTRACT_32BITS(sflow_100basevg_counter->in_ipmerrors), + EXTRACT_32BITS(sflow_100basevg_counter->in_oversized), + EXTRACT_32BITS(sflow_100basevg_counter->in_data_errors), + EXTRACT_32BITS(sflow_100basevg_counter->in_null_addressed_frames)); + printf("\n\t out high prio frames %u, out high prio octets %" PRIu64 + ", trans into frames %u", + EXTRACT_32BITS(sflow_100basevg_counter->out_highpriority_frames), + EXTRACT_64BITS(sflow_100basevg_counter->out_highpriority_octets), + EXTRACT_32BITS(sflow_100basevg_counter->transitioninto_frames)); + printf("\n\t in hc high prio octets %" PRIu64 + ", in hc norm prio octets %" PRIu64 + ", out hc high prio octets %" PRIu64, + EXTRACT_64BITS(sflow_100basevg_counter->hc_in_highpriority_octets), + EXTRACT_64BITS(sflow_100basevg_counter->hc_in_normpriority_octets), + EXTRACT_64BITS(sflow_100basevg_counter->hc_out_highpriority_octets)); + break; + case SFLOW_COUNTER_VLAN: + sflow_vlan_counter = (const struct sflow_vlan_counter_t *)tptr; + printf("\n\t vlan_id %u, octets %" PRIu64 + ", unicast_pkt %u, multicast_pkt %u, broadcast_pkt %u, discards %u", + EXTRACT_32BITS(sflow_vlan_counter->vlan_id), + EXTRACT_64BITS(sflow_vlan_counter->octets), + EXTRACT_32BITS(sflow_vlan_counter->unicast_pkt), + EXTRACT_32BITS(sflow_vlan_counter->multicast_pkt), + EXTRACT_32BITS(sflow_vlan_counter->broadcast_pkt), + EXTRACT_32BITS(sflow_vlan_counter->discards)); + break; + case SFLOW_COUNTER_PROCESSOR: /* XXX */ + break; + default: + if (vflag <= 1) + print_unknown_data(tptr, "\n\t\t", counter_len); + break; + } + tptr += counter_len; + tlen -= counter_len; + nrecords--; + } + break; + default: + if (vflag <= 1) + print_unknown_data(tptr, "\n\t ", sflow_sample_len); + break; + } + tptr += sflow_sample_len; + tlen -= sflow_sample_len; + nsamples--; + } + return; + + trunc: + printf("[|SFLOW]"); +} + +/* + * Local Variables: + * c-style: whitesmith + * c-basic-offset: 4 + * End: + */ diff --git a/contrib/tcpdump/print-sip.c b/contrib/tcpdump/print-sip.c index b4d13b132f..48562f8c38 100644 --- a/contrib/tcpdump/print-sip.c +++ b/contrib/tcpdump/print-sip.c @@ -15,7 +15,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-sip.c,v 1.1 2004/07/27 17:04:20 hannes Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-sip.c,v 1.1 2004-07-27 17:04:20 hannes Exp $"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-sl.c b/contrib/tcpdump/print-sl.c index f28a21a407..f00d3943d3 100644 --- a/contrib/tcpdump/print-sl.c +++ b/contrib/tcpdump/print-sl.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-sl.c,v 1.65 2005/04/06 21:32:42 mcr Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-sl.c,v 1.65 2005-04-06 21:32:42 mcr Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-sll.c b/contrib/tcpdump/print-sll.c index 1735f65095..d96b3de29e 100644 --- a/contrib/tcpdump/print-sll.c +++ b/contrib/tcpdump/print-sll.c @@ -20,7 +20,7 @@ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.16.2.3 2005/11/13 12:13:00 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.19 2005-11-13 12:12:43 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-slow.c b/contrib/tcpdump/print-slow.c index 96099221b9..eaf94ed9bb 100644 --- a/contrib/tcpdump/print-slow.c +++ b/contrib/tcpdump/print-slow.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998-2005 The TCPDUMP project + * 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 @@ -13,13 +13,14 @@ * FOR A PARTICULAR PURPOSE. * * support for the IEEE "slow protocols" LACP, MARKER as per 802.3ad + * OAM as per 802.3ah * * Original code by Hannes Gredler (hannes@juniper.net) */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-slow.c,v 1.1.2.1 2005/07/10 14:47:56 hannes Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-slow.c,v 1.8 2006-10-12 05:44:33 hannes Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -36,14 +37,16 @@ static const char rcsid[] _U_ = #include "extract.h" #include "addrtoname.h" #include "ether.h" +#include "oui.h" -struct slow_common_header { +struct slow_common_header_t { u_int8_t proto_subtype; u_int8_t version; }; #define SLOW_PROTO_LACP 1 #define SLOW_PROTO_MARKER 2 +#define SLOW_PROTO_OAM 3 #define LACP_VERSION 1 #define MARKER_VERSION 1 @@ -51,6 +54,137 @@ struct slow_common_header { static const struct tok slow_proto_values[] = { { SLOW_PROTO_LACP, "LACP" }, { SLOW_PROTO_MARKER, "MARKER" }, + { SLOW_PROTO_OAM, "OAM" }, + { 0, NULL} +}; + +static const struct tok slow_oam_flag_values[] = { + { 0x0001, "Link Fault" }, + { 0x0002, "Dying Gasp" }, + { 0x0004, "Critical Event" }, + { 0x0008, "Local Evaluating" }, + { 0x0010, "Local Stable" }, + { 0x0020, "Remote Evaluating" }, + { 0x0040, "Remote Stable" }, + { 0, NULL} +}; + +#define SLOW_OAM_CODE_INFO 0x00 +#define SLOW_OAM_CODE_EVENT_NOTIF 0x01 +#define SLOW_OAM_CODE_VAR_REQUEST 0x02 +#define SLOW_OAM_CODE_VAR_RESPONSE 0x03 +#define SLOW_OAM_CODE_LOOPBACK_CTRL 0x04 +#define SLOW_OAM_CODE_PRIVATE 0xfe + +static const struct tok slow_oam_code_values[] = { + { SLOW_OAM_CODE_INFO, "Information" }, + { SLOW_OAM_CODE_EVENT_NOTIF, "Event Notification" }, + { SLOW_OAM_CODE_VAR_REQUEST, "Variable Request" }, + { SLOW_OAM_CODE_VAR_RESPONSE, "Variable Response" }, + { SLOW_OAM_CODE_LOOPBACK_CTRL, "Loopback Control" }, + { SLOW_OAM_CODE_PRIVATE, "Vendor Private" }, + { 0, NULL} +}; + +struct slow_oam_info_t { + u_int8_t info_type; + u_int8_t info_length; + u_int8_t oam_version; + u_int8_t revision[2]; + u_int8_t state; + u_int8_t oam_config; + u_int8_t oam_pdu_config[2]; + u_int8_t oui[3]; + u_int8_t vendor_private[4]; +}; + +#define SLOW_OAM_INFO_TYPE_END_OF_TLV 0x00 +#define SLOW_OAM_INFO_TYPE_LOCAL 0x01 +#define SLOW_OAM_INFO_TYPE_REMOTE 0x02 +#define SLOW_OAM_INFO_TYPE_ORG_SPECIFIC 0xfe + +static const struct tok slow_oam_info_type_values[] = { + { SLOW_OAM_INFO_TYPE_END_OF_TLV, "End of TLV marker" }, + { SLOW_OAM_INFO_TYPE_LOCAL, "Local" }, + { SLOW_OAM_INFO_TYPE_REMOTE, "Remote" }, + { SLOW_OAM_INFO_TYPE_ORG_SPECIFIC, "Organization specific" }, + { 0, NULL} +}; + +#define OAM_INFO_TYPE_PARSER_MASK 0x3 +static const struct tok slow_oam_info_type_state_parser_values[] = { + { 0x00, "forwarding" }, + { 0x01, "looping back" }, + { 0x02, "discarding" }, + { 0x03, "reserved" }, + { 0, NULL} +}; + +#define OAM_INFO_TYPE_MUX_MASK 0x4 +static const struct tok slow_oam_info_type_state_mux_values[] = { + { 0x00, "forwarding" }, + { 0x04, "discarding" }, + { 0, NULL} +}; + +static const struct tok slow_oam_info_type_oam_config_values[] = { + { 0x01, "Active" }, + { 0x02, "Unidirectional" }, + { 0x04, "Remote-Loopback" }, + { 0x08, "Link-Events" }, + { 0x10, "Variable-Retrieval" }, + { 0, NULL} +}; + +/* 11 Bits */ +#define OAM_INFO_TYPE_PDU_SIZE_MASK 0x7ff + +#define SLOW_OAM_LINK_EVENT_END_OF_TLV 0x00 +#define SLOW_OAM_LINK_EVENT_ERR_SYM_PER 0x01 +#define SLOW_OAM_LINK_EVENT_ERR_FRM 0x02 +#define SLOW_OAM_LINK_EVENT_ERR_FRM_PER 0x03 +#define SLOW_OAM_LINK_EVENT_ERR_FRM_SUMM 0x04 +#define SLOW_OAM_LINK_EVENT_ORG_SPECIFIC 0xfe + +static const struct tok slow_oam_link_event_values[] = { + { SLOW_OAM_LINK_EVENT_END_OF_TLV, "End of TLV marker" }, + { SLOW_OAM_LINK_EVENT_ERR_SYM_PER, "Errored Symbol Period Event" }, + { SLOW_OAM_LINK_EVENT_ERR_FRM, "Errored Frame Event" }, + { SLOW_OAM_LINK_EVENT_ERR_FRM_PER, "Errored Frame Period Event" }, + { SLOW_OAM_LINK_EVENT_ERR_FRM_SUMM, "Errored Frame Seconds Summary Event" }, + { SLOW_OAM_LINK_EVENT_ORG_SPECIFIC, "Organization specific" }, + { 0, NULL} +}; + +struct slow_oam_link_event_t { + u_int8_t event_type; + u_int8_t event_length; + u_int8_t time_stamp[2]; + u_int8_t window[8]; + u_int8_t threshold[8]; + u_int8_t errors[8]; + u_int8_t errors_running_total[8]; + u_int8_t event_running_total[4]; +}; + +struct slow_oam_variablerequest_t { + u_int8_t branch; + u_int8_t leaf[2]; +}; + +struct slow_oam_variableresponse_t { + u_int8_t branch; + u_int8_t leaf[2]; + u_int8_t length; +}; + +struct slow_oam_loopbackctrl_t { + u_int8_t command; +}; + +static const struct tok slow_oam_loopbackctrl_cmd_values[] = { + { 0x01, "Enable OAM Remote Loopback" }, + { 0x02, "Disable OAM Remote Loopback" }, { 0, NULL} }; @@ -116,58 +250,113 @@ struct lacp_marker_tlv_terminator_t { u_int8_t pad[50]; }; +void slow_marker_lacp_print(register const u_char *, register u_int); +void slow_oam_print(register const u_char *, register u_int); + +const struct slow_common_header_t *slow_com_header; + void slow_print(register const u_char *pptr, register u_int len) { - const struct slow_common_header *slow_com_header; - const struct tlv_header_t *tlv_header; - const u_char *tptr,*tlv_tptr; - u_int tlv_len,tlen,tlv_tlen; - - union { - const struct lacp_marker_tlv_terminator_t *lacp_marker_tlv_terminator; - const struct lacp_tlv_actor_partner_info_t *lacp_tlv_actor_partner_info; - const struct lacp_tlv_collector_info_t *lacp_tlv_collector_info; - const struct marker_tlv_marker_info_t *marker_tlv_marker_info; - } tlv_ptr; + int print_version; - tptr=pptr; - slow_com_header = (const struct slow_common_header *)pptr; + slow_com_header = (const struct slow_common_header_t *)pptr; TCHECK(*slow_com_header); /* * Sanity checking of the header. */ - if (slow_com_header->proto_subtype == SLOW_PROTO_LACP && - slow_com_header->version != LACP_VERSION) { - printf("LACP version %u packet not supported",slow_com_header->version); - return; + switch (slow_com_header->proto_subtype) { + case SLOW_PROTO_LACP: + if (slow_com_header->version != LACP_VERSION) { + printf("LACP version %u packet not supported",slow_com_header->version); + return; + } + print_version = 1; + break; + + case SLOW_PROTO_MARKER: + if (slow_com_header->version != MARKER_VERSION) { + printf("MARKER version %u packet not supported",slow_com_header->version); + return; + } + print_version = 1; + break; + + case SLOW_PROTO_OAM: /* fall through */ + print_version = 0; + break; + + default: + /* print basic information and exit */ + print_version = -1; + break; } - if (slow_com_header->proto_subtype == SLOW_PROTO_MARKER && - slow_com_header->version != MARKER_VERSION) { - printf("MARKER version %u packet not supported",slow_com_header->version); - return; + + if (print_version) { + printf("%sv%u, length %u", + tok2str(slow_proto_values, "unknown (%u)",slow_com_header->proto_subtype), + slow_com_header->version, + len); + } else { + /* some slow protos don't have a version number in the header */ + printf("%s, length %u", + tok2str(slow_proto_values, "unknown (%u)",slow_com_header->proto_subtype), + len); } - printf("%sv%u, length: %u", - tok2str(slow_proto_values, "unknown (%u)",slow_com_header->proto_subtype), - slow_com_header->version, - len); + /* unrecognized subtype */ + if (print_version == -1) { + print_unknown_data(pptr, "\n\t", len); + return; + } if (!vflag) return; - /* ok they seem to want to know everything - lets fully decode it */ - tlen=len-sizeof(struct slow_common_header); - tptr+=sizeof(const struct slow_common_header); + switch (slow_com_header->proto_subtype) { + default: /* should not happen */ + break; + + case SLOW_PROTO_OAM: + /* skip proto_subtype */ + slow_oam_print(pptr+1, len-1); + break; + + case SLOW_PROTO_LACP: /* LACP and MARKER share the same semantics */ + case SLOW_PROTO_MARKER: + /* skip slow_common_header */ + len -= sizeof(const struct slow_common_header_t); + pptr += sizeof(const struct slow_common_header_t); + slow_marker_lacp_print(pptr, len); + break; + } + return; + +trunc: + printf("\n\t\t packet exceeded snapshot"); +} +void slow_marker_lacp_print(register const u_char *tptr, register u_int tlen) { + + const struct tlv_header_t *tlv_header; + const u_char *tlv_tptr; + u_int tlv_len, tlv_tlen; + + union { + const struct lacp_marker_tlv_terminator_t *lacp_marker_tlv_terminator; + const struct lacp_tlv_actor_partner_info_t *lacp_tlv_actor_partner_info; + const struct lacp_tlv_collector_info_t *lacp_tlv_collector_info; + const struct marker_tlv_marker_info_t *marker_tlv_marker_info; + } tlv_ptr; + while(tlen>0) { /* did we capture enough for fully decoding the tlv header ? */ TCHECK2(*tptr, sizeof(struct tlv_header_t)); tlv_header = (const struct tlv_header_t *)tptr; tlv_len = tlv_header->length; - printf("\n\t%s TLV (0x%02x), length: %u", + printf("\n\t%s TLV (0x%02x), length %u", tok2str(slow_tlv_values, "Unknown", (slow_com_header->proto_subtype << 8) + tlv_header->type), @@ -250,10 +439,11 @@ slow_print(register const u_char *pptr, register u_int len) { print_unknown_data(tlv_tptr,"\n\t ",tlv_tlen); break; } - /* do we want to see an additionally hexdump ? */ - if (vflag > 1) + /* do we want to see an additional hexdump ? */ + if (vflag > 1) { print_unknown_data(tptr+sizeof(sizeof(struct tlv_header_t)),"\n\t ", tlv_len-sizeof(struct tlv_header_t)); + } tptr+=tlv_len; tlen-=tlv_len; @@ -262,3 +452,210 @@ slow_print(register const u_char *pptr, register u_int len) { trunc: printf("\n\t\t packet exceeded snapshot"); } + +void slow_oam_print(register const u_char *tptr, register u_int tlen) { + + u_int hexdump; + + struct slow_oam_common_header_t { + u_int8_t flags[2]; + u_int8_t code; + }; + + struct slow_oam_tlv_header_t { + u_int8_t type; + u_int8_t length; + }; + + union { + const struct slow_oam_common_header_t *slow_oam_common_header; + const struct slow_oam_tlv_header_t *slow_oam_tlv_header; + } ptr; + + union { + const struct slow_oam_info_t *slow_oam_info; + const struct slow_oam_link_event_t *slow_oam_link_event; + const struct slow_oam_variablerequest_t *slow_oam_variablerequest; + const struct slow_oam_variableresponse_t *slow_oam_variableresponse; + const struct slow_oam_loopbackctrl_t *slow_oam_loopbackctrl; + } tlv; + + ptr.slow_oam_common_header = (struct slow_oam_common_header_t *)tptr; + tptr += sizeof(struct slow_oam_common_header_t); + tlen -= sizeof(struct slow_oam_common_header_t); + + printf("\n\tCode %s OAM PDU, Flags [%s]", + tok2str(slow_oam_code_values, "Unknown (%u)", ptr.slow_oam_common_header->code), + bittok2str(slow_oam_flag_values, + "none", + EXTRACT_16BITS(&ptr.slow_oam_common_header->flags))); + + switch (ptr.slow_oam_common_header->code) { + case SLOW_OAM_CODE_INFO: + while (tlen > 0) { + ptr.slow_oam_tlv_header = (const struct slow_oam_tlv_header_t *)tptr; + printf("\n\t %s Information Type (%u), length %u", + tok2str(slow_oam_info_type_values, "Reserved", + ptr.slow_oam_tlv_header->type), + ptr.slow_oam_tlv_header->type, + ptr.slow_oam_tlv_header->length); + + hexdump = FALSE; + switch (ptr.slow_oam_tlv_header->type) { + case SLOW_OAM_INFO_TYPE_END_OF_TLV: + if (ptr.slow_oam_tlv_header->length != 0) { + printf("\n\t ERROR: illegal length - should be 0"); + } + return; + + case SLOW_OAM_INFO_TYPE_LOCAL: /* identical format - fall through */ + case SLOW_OAM_INFO_TYPE_REMOTE: + tlv.slow_oam_info = (const struct slow_oam_info_t *)tptr; + + if (tlv.slow_oam_info->info_length != + sizeof(struct slow_oam_info_t)) { + printf("\n\t ERROR: illegal length - should be %lu", + (unsigned long) sizeof(struct slow_oam_info_t)); + return; + } + + printf("\n\t OAM-Version %u, Revision %u", + tlv.slow_oam_info->oam_version, + EXTRACT_16BITS(&tlv.slow_oam_info->revision)); + + printf("\n\t State-Parser-Action %s, State-MUX-Action %s", + tok2str(slow_oam_info_type_state_parser_values, "Reserved", + tlv.slow_oam_info->state & OAM_INFO_TYPE_PARSER_MASK), + tok2str(slow_oam_info_type_state_mux_values, "Reserved", + tlv.slow_oam_info->state & OAM_INFO_TYPE_MUX_MASK)); + printf("\n\t OAM-Config Flags [%s], OAM-PDU-Config max-PDU size %u", + bittok2str(slow_oam_info_type_oam_config_values, "none", + tlv.slow_oam_info->oam_config), + EXTRACT_16BITS(&tlv.slow_oam_info->oam_pdu_config) & + OAM_INFO_TYPE_PDU_SIZE_MASK); + printf("\n\t OUI %s (0x%06x), Vendor-Private 0x%08x", + tok2str(oui_values, "Unknown", + EXTRACT_24BITS(&tlv.slow_oam_info->oui)), + EXTRACT_24BITS(&tlv.slow_oam_info->oui), + EXTRACT_32BITS(&tlv.slow_oam_info->vendor_private)); + break; + + case SLOW_OAM_INFO_TYPE_ORG_SPECIFIC: + hexdump = TRUE; + break; + + default: + hexdump = TRUE; + break; + } + + /* infinite loop check */ + if (!ptr.slow_oam_tlv_header->length) { + return; + } + + /* do we also want to see a hex dump ? */ + if (vflag > 1 || hexdump==TRUE) { + print_unknown_data(tptr,"\n\t ", + ptr.slow_oam_tlv_header->length); + } + + tlen -= ptr.slow_oam_tlv_header->length; + tptr += ptr.slow_oam_tlv_header->length; + } + break; + + case SLOW_OAM_CODE_EVENT_NOTIF: + while (tlen > 0) { + ptr.slow_oam_tlv_header = (const struct slow_oam_tlv_header_t *)tptr; + printf("\n\t %s Link Event Type (%u), length %u", + tok2str(slow_oam_link_event_values, "Reserved", + ptr.slow_oam_tlv_header->type), + ptr.slow_oam_tlv_header->type, + ptr.slow_oam_tlv_header->length); + + hexdump = FALSE; + switch (ptr.slow_oam_tlv_header->type) { + case SLOW_OAM_LINK_EVENT_END_OF_TLV: + if (ptr.slow_oam_tlv_header->length != 0) { + printf("\n\t ERROR: illegal length - should be 0"); + } + return; + + case SLOW_OAM_LINK_EVENT_ERR_SYM_PER: /* identical format - fall through */ + case SLOW_OAM_LINK_EVENT_ERR_FRM: + case SLOW_OAM_LINK_EVENT_ERR_FRM_PER: + case SLOW_OAM_LINK_EVENT_ERR_FRM_SUMM: + tlv.slow_oam_link_event = (const struct slow_oam_link_event_t *)tptr; + + if (tlv.slow_oam_link_event->event_length != + sizeof(struct slow_oam_link_event_t)) { + printf("\n\t ERROR: illegal length - should be %lu", + (unsigned long) sizeof(struct slow_oam_link_event_t)); + return; + } + + printf("\n\t Timestamp %u ms, Errored Window %" PRIu64 + "\n\t Errored Threshold %" PRIu64 + "\n\t Errors %" PRIu64 + "\n\t Error Running Total %" PRIu64 + "\n\t Event Running Total %u", + EXTRACT_16BITS(&tlv.slow_oam_link_event->time_stamp)*100, + EXTRACT_64BITS(&tlv.slow_oam_link_event->window), + EXTRACT_64BITS(&tlv.slow_oam_link_event->threshold), + EXTRACT_64BITS(&tlv.slow_oam_link_event->errors), + EXTRACT_64BITS(&tlv.slow_oam_link_event->errors_running_total), + EXTRACT_32BITS(&tlv.slow_oam_link_event->event_running_total)); + break; + + case SLOW_OAM_LINK_EVENT_ORG_SPECIFIC: + hexdump = TRUE; + break; + + default: + hexdump = TRUE; + break; + } + + /* infinite loop check */ + if (!ptr.slow_oam_tlv_header->length) { + return; + } + + /* do we also want to see a hex dump ? */ + if (vflag > 1 || hexdump==TRUE) { + print_unknown_data(tptr,"\n\t ", + ptr.slow_oam_tlv_header->length); + } + + tlen -= ptr.slow_oam_tlv_header->length; + tptr += ptr.slow_oam_tlv_header->length; + } + break; + + case SLOW_OAM_CODE_LOOPBACK_CTRL: + tlv.slow_oam_loopbackctrl = (const struct slow_oam_loopbackctrl_t *)tptr; + printf("\n\t Command %s (%u)", + tok2str(slow_oam_loopbackctrl_cmd_values, + "Unknown", + tlv.slow_oam_loopbackctrl->command), + tlv.slow_oam_loopbackctrl->command); + tptr ++; + tlen --; + break; + + /* + * FIXME those are the defined codes that lack a decoder + * you are welcome to contribute code ;-) + */ + case SLOW_OAM_CODE_VAR_REQUEST: + case SLOW_OAM_CODE_VAR_RESPONSE: + case SLOW_OAM_CODE_PRIVATE: + default: + if (vflag <= 1) { + print_unknown_data(tptr,"\n\t ", tlen); + } + break; + } + return; +} diff --git a/contrib/tcpdump/print-smb.c b/contrib/tcpdump/print-smb.c index 5b963de94b..391f1860c6 100644 --- a/contrib/tcpdump/print-smb.c +++ b/contrib/tcpdump/print-smb.c @@ -12,7 +12,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-smb.c,v 1.41.2.4 2007/07/14 22:29:05 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-smb.c,v 1.46.2.1 2007-12-09 00:31:35 guy Exp $"; #endif #include @@ -1244,7 +1244,47 @@ trunc: return; } +/* + * Print an SMB-over-TCP packet received across tcp on port 445 + */ +void +smb_tcp_print (const u_char * data, int length) +{ + int caplen; + u_int smb_len; + const u_char *maxbuf; + + if (length < 4) + goto trunc; + if (snapend < data) + goto trunc; + caplen = snapend - data; + if (caplen < 4) + goto trunc; + maxbuf = data + caplen; + smb_len = EXTRACT_24BITS(data + 1); + length -= 4; + caplen -= 4; + startbuf = data; + data += 4; + + if (smb_len >= 4 && caplen >= 4 && memcmp(data,"\377SMB",4) == 0) { + if ((int)smb_len > caplen) { + if ((int)smb_len > length) + printf("WARNING: Packet is continued in later TCP segments\n"); + else + printf("WARNING: Short packet. Try increasing the snap length by %d\n", + smb_len - caplen); + } + print_smb(data, maxbuf > data + smb_len ? data + smb_len : maxbuf); + } else + printf("SMB-over-TCP packet:(raw data or continuation?)\n"); + return; +trunc: + printf("[|SMB]"); + return; +} /* * print a NBT packet received across udp on port 138 @@ -1459,8 +1499,7 @@ ipx_netbios_print(const u_char *data, u_int length) break; if (memcmp(&data[i], "\377SMB", 4) == 0) { smb_fdata(data, "\n>>> IPX transport ", &data[i], 0); - if (data != NULL) - print_smb(&data[i], maxbuf); + print_smb(&data[i], maxbuf); printf("\n"); fflush(stdout); break; diff --git a/contrib/tcpdump/print-snmp.c b/contrib/tcpdump/print-snmp.c index 0686b62230..728da6beb7 100644 --- a/contrib/tcpdump/print-snmp.c +++ b/contrib/tcpdump/print-snmp.c @@ -58,7 +58,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-snmp.c,v 1.62.2.2 2005/05/06 07:57:19 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-snmp.c,v 1.64 2005-05-06 07:56:53 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-stp.c b/contrib/tcpdump/print-stp.c index 4308ae01b9..8822c3046d 100644 --- a/contrib/tcpdump/print-stp.c +++ b/contrib/tcpdump/print-stp.c @@ -11,7 +11,7 @@ #ifndef lint static const char rcsid[] _U_ = -"@(#) $Header: /tcpdump/master/tcpdump/print-stp.c,v 1.13.2.7 2007/03/18 17:12:36 hannes Exp $"; +"@(#) $Header: /tcpdump/master/tcpdump/print-stp.c,v 1.20 2007-03-18 17:11:46 hannes Exp $"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-sunatm.c b/contrib/tcpdump/print-sunatm.c index acd38bf7ee..e6f19e8586 100644 --- a/contrib/tcpdump/print-sunatm.c +++ b/contrib/tcpdump/print-sunatm.c @@ -31,7 +31,7 @@ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-sunatm.c,v 1.8 2004/03/17 23:24:38 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-sunatm.c,v 1.8 2004-03-17 23:24:38 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-sunrpc.c b/contrib/tcpdump/print-sunrpc.c index 03e28a489b..bfb2fe9a79 100644 --- a/contrib/tcpdump/print-sunrpc.c +++ b/contrib/tcpdump/print-sunrpc.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-sunrpc.c,v 1.46.2.1 2005/04/27 21:44:06 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-sunrpc.c,v 1.47 2005-04-27 21:43:48 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-symantec.c b/contrib/tcpdump/print-symantec.c index eb72180850..ebb62cd4d1 100644 --- a/contrib/tcpdump/print-symantec.c +++ b/contrib/tcpdump/print-symantec.c @@ -20,7 +20,7 @@ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-symantec.c,v 1.4.2.1 2005/07/07 01:24:39 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-symantec.c,v 1.5 2005-07-07 01:22:21 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-syslog.c b/contrib/tcpdump/print-syslog.c index 099d027b25..3685d62042 100755 --- a/contrib/tcpdump/print-syslog.c +++ b/contrib/tcpdump/print-syslog.c @@ -16,7 +16,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-syslog.c,v 1.1 2004/10/29 11:42:53 hannes Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-syslog.c,v 1.1 2004-10-29 11:42:53 hannes Exp $"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-tcp.c b/contrib/tcpdump/print-tcp.c index 11bd6b7ab4..5b0a7969a5 100644 --- a/contrib/tcpdump/print-tcp.c +++ b/contrib/tcpdump/print-tcp.c @@ -1,3 +1,5 @@ +/* $NetBSD: print-tcp.c,v 1.9 2007/07/26 18:15:12 plunky Exp $ */ + /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. @@ -23,7 +25,9 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-tcp.c,v 1.120.2.3 2005/10/16 06:05:46 guy Exp $ (LBL)"; +"@(#) $Header: /tcpdump/master/tcpdump/print-tcp.c,v 1.130.2.3 2007-12-22 03:08:45 guy Exp $ (LBL)"; + #else +__RCSID("$NetBSD: print-tcp.c,v 1.8 2007/07/24 11:53:48 drochner Exp $"); #endif #ifdef HAVE_CONFIG_H @@ -60,7 +64,7 @@ static const char rcsid[] _U_ = #define CANT_CHECK_SIGNATURE 2 static int tcp_verify_signature(const struct ip *ip, const struct tcphdr *tp, - const u_char *data, int length, const u_char *rcvsig); + const u_char *data, int length, const u_char *rcvsig); #endif static void print_tcp_rst_data(register const u_char *sp, u_int length); @@ -70,20 +74,20 @@ static void print_tcp_rst_data(register const u_char *sp, u_int length); struct tha { #ifndef INET6 - struct in_addr src; - struct in_addr dst; + struct in_addr src; + struct in_addr dst; #else - struct in6_addr src; - struct in6_addr dst; + struct in6_addr src; + struct in6_addr dst; #endif /*INET6*/ - u_int port; + u_int port; }; struct tcp_seq_hash { - struct tcp_seq_hash *nxt; - struct tha addr; - tcp_seq seq; - tcp_seq ack; + struct tcp_seq_hash *nxt; + struct tha addr; + tcp_seq seq; + tcp_seq ack; }; #define TSEQ_HASHSIZE 919 @@ -93,97 +97,95 @@ struct tcp_seq_hash { static struct tcp_seq_hash tcp_seq_hash[TSEQ_HASHSIZE]; +struct tok tcp_flag_values[] = { + { TH_FIN, "F" }, + { TH_SYN, "S" }, + { TH_RST, "R" }, + { TH_PUSH, "P" }, + { TH_ACK, "." }, + { TH_URG, "U" }, + { TH_ECNECHO, "E" }, + { TH_CWR, "W" }, + { 0, NULL } +}; -#ifndef TELNET_PORT -#define TELNET_PORT 23 -#endif -#ifndef BGP_PORT -#define BGP_PORT 179 -#endif -#define NETBIOS_SSN_PORT 139 -#ifndef PPTP_PORT -#define PPTP_PORT 1723 -#endif -#define BEEP_PORT 10288 -#ifndef NFS_PORT -#define NFS_PORT 2049 -#endif -#define MSDP_PORT 639 -#define LDP_PORT 646 +struct tok tcp_option_values[] = { + { TCPOPT_EOL, "eol" }, + { TCPOPT_NOP, "nop" }, + { TCPOPT_MAXSEG, "mss" }, + { TCPOPT_WSCALE, "wscale" }, + { TCPOPT_SACKOK, "sackOK" }, + { TCPOPT_SACK, "sack" }, + { TCPOPT_ECHO, "echo" }, + { TCPOPT_ECHOREPLY, "echoreply" }, + { TCPOPT_TIMESTAMP, "TS" }, + { TCPOPT_CC, "cc" }, + { TCPOPT_CCNEW, "ccnew" }, + { TCPOPT_CCECHO, "" }, + { TCPOPT_SIGNATURE, "md5" }, + { TCPOPT_AUTH, "enhanced auth" }, + { 0, NULL } +}; static int tcp_cksum(register const struct ip *ip, register const struct tcphdr *tp, register u_int len) { - union phu { - struct phdr { - u_int32_t src; - u_int32_t dst; - u_char mbz; - u_char proto; - u_int16_t len; - } ph; - u_int16_t pa[6]; - } phu; - const u_int16_t *sp; - - /* pseudo-header.. */ - phu.ph.len = htons((u_int16_t)len); - phu.ph.mbz = 0; - phu.ph.proto = IPPROTO_TCP; - memcpy(&phu.ph.src, &ip->ip_src.s_addr, sizeof(u_int32_t)); - if (IP_HL(ip) == 5) - memcpy(&phu.ph.dst, &ip->ip_dst.s_addr, sizeof(u_int32_t)); - else - phu.ph.dst = ip_finddst(ip); - - sp = &phu.pa[0]; - return in_cksum((u_short *)tp, len, - sp[0]+sp[1]+sp[2]+sp[3]+sp[4]+sp[5]); + union phu { + struct phdr { + u_int32_t src; + u_int32_t dst; + u_char mbz; + u_char proto; + u_int16_t len; + } ph; + u_int16_t pa[6]; + } phu; + const u_int16_t *sp; + + /* pseudo-header.. */ + phu.ph.len = htons((u_int16_t)len); + phu.ph.mbz = 0; + phu.ph.proto = IPPROTO_TCP; + memcpy(&phu.ph.src, &ip->ip_src.s_addr, sizeof(u_int32_t)); + if (IP_HL(ip) == 5) + memcpy(&phu.ph.dst, &ip->ip_dst.s_addr, sizeof(u_int32_t)); + else + phu.ph.dst = ip_finddst(ip); + + sp = &phu.pa[0]; + return in_cksum((u_short *)tp, len, + sp[0]+sp[1]+sp[2]+sp[3]+sp[4]+sp[5]); } #ifdef INET6 static int tcp6_cksum(const struct ip6_hdr *ip6, const struct tcphdr *tp, - u_int len) + u_int len) { - size_t i; - register const u_int16_t *sp; - u_int32_t sum; - union { - struct { - struct in6_addr ph_src; - struct in6_addr ph_dst; - u_int32_t ph_len; - u_int8_t ph_zero[3]; - u_int8_t ph_nxt; - } ph; - u_int16_t pa[20]; - } phu; - - /* pseudo-header */ - memset(&phu, 0, sizeof(phu)); - phu.ph.ph_src = ip6->ip6_src; - phu.ph.ph_dst = ip6->ip6_dst; - phu.ph.ph_len = htonl(len); - phu.ph.ph_nxt = IPPROTO_TCP; - - sum = 0; - for (i = 0; i < sizeof(phu.pa) / sizeof(phu.pa[0]); i++) - sum += phu.pa[i]; - - sp = (const u_int16_t *)tp; - - for (i = 0; i < (len & ~1); i += 2) - sum += *sp++; - - if (len & 1) - sum += htons((*(const u_int8_t *)sp) << 8); - - while (sum > 0xffff) - sum = (sum & 0xffff) + (sum >> 16); - sum = ~sum & 0xffff; - - return (sum); + size_t i; + u_int32_t sum = 0; + union { + struct { + struct in6_addr ph_src; + struct in6_addr ph_dst; + u_int32_t ph_len; + u_int8_t ph_zero[3]; + u_int8_t ph_nxt; + } ph; + u_int16_t pa[20]; + } phu; + + /* pseudo-header */ + memset(&phu, 0, sizeof(phu)); + phu.ph.ph_src = ip6->ip6_src; + phu.ph.ph_dst = ip6->ip6_dst; + phu.ph.ph_len = htonl(len); + phu.ph.ph_nxt = IPPROTO_TCP; + + for (i = 0; i < sizeof(phu.pa) / sizeof(phu.pa[0]); i++) + sum += phu.pa[i]; + + return in_cksum((u_short *)tp, len, sum); } #endif @@ -191,507 +193,509 @@ void tcp_print(register const u_char *bp, register u_int length, register const u_char *bp2, int fragmented) { - register const struct tcphdr *tp; - register const struct ip *ip; - register u_char flags; - register u_int hlen; - register char ch; - u_int16_t sport, dport, win, urp; - u_int32_t seq, ack, thseq, thack; - int threv; + register const struct tcphdr *tp; + register const struct ip *ip; + register u_char flags; + register u_int hlen; + register char ch; + u_int16_t sport, dport, win, urp; + u_int32_t seq, ack, thseq, thack; + int threv; #ifdef INET6 - register const struct ip6_hdr *ip6; + register const struct ip6_hdr *ip6; #endif - tp = (struct tcphdr *)bp; - ip = (struct ip *)bp2; + tp = (struct tcphdr *)bp; + ip = (struct ip *)bp2; #ifdef INET6 - if (IP_V(ip) == 6) - ip6 = (struct ip6_hdr *)bp2; - else - ip6 = NULL; + if (IP_V(ip) == 6) + ip6 = (struct ip6_hdr *)bp2; + else + ip6 = NULL; #endif /*INET6*/ - ch = '\0'; - if (!TTEST(tp->th_dport)) { - (void)printf("%s > %s: [|tcp]", - ipaddr_string(&ip->ip_src), - ipaddr_string(&ip->ip_dst)); - return; - } + ch = '\0'; + if (!TTEST(tp->th_dport)) { + (void)printf("%s > %s: [|tcp]", + ipaddr_string(&ip->ip_src), + ipaddr_string(&ip->ip_dst)); + return; + } - sport = EXTRACT_16BITS(&tp->th_sport); - dport = EXTRACT_16BITS(&tp->th_dport); + sport = EXTRACT_16BITS(&tp->th_sport); + dport = EXTRACT_16BITS(&tp->th_dport); - hlen = TH_OFF(tp) * 4; + hlen = TH_OFF(tp) * 4; - /* + /* * If data present, header length valid, and NFS port used, * assume NFS. * Pass offset of data plus 4 bytes for RPC TCP msg length * to NFS print routines. */ - if (!qflag && hlen >= sizeof(*tp) && hlen <= length) { - if ((u_char *)tp + 4 + sizeof(struct sunrpc_msg) <= snapend && - dport == NFS_PORT) { - nfsreq_print((u_char *)tp + hlen + 4, length - hlen, - (u_char *)ip); - return; - } else if ((u_char *)tp + 4 + sizeof(struct sunrpc_msg) - <= snapend && - sport == NFS_PORT) { - nfsreply_print((u_char *)tp + hlen + 4, length - hlen, - (u_char *)ip); - return; - } - } + if (!qflag && hlen >= sizeof(*tp) && hlen <= length && + (length - hlen) >= 4) { + u_char *fraglenp; + u_int32_t fraglen; + register struct sunrpc_msg *rp; + enum sunrpc_msg_type direction; + + fraglenp = (u_char *)tp + hlen; + if (TTEST2(*fraglenp, 4)) { + fraglen = EXTRACT_32BITS(fraglenp) & 0x7FFFFFFF; + if (fraglen > (length - hlen) - 4) + fraglen = (length - hlen) - 4; + rp = (struct sunrpc_msg *)(fraglenp + 4); + if (TTEST(rp->rm_direction)) { + direction = (enum sunrpc_msg_type)EXTRACT_32BITS(&rp->rm_direction); + if (dport == NFS_PORT && + direction == SUNRPC_CALL) { + nfsreq_print((u_char *)rp, fraglen, + (u_char *)ip); + return; + } + if (sport == NFS_PORT && + direction == SUNRPC_REPLY) { + nfsreply_print((u_char *)rp, fraglen, + (u_char *)ip); + return; + } + } + } + } #ifdef INET6 - if (ip6) { - if (ip6->ip6_nxt == IPPROTO_TCP) { - (void)printf("%s.%s > %s.%s: ", - ip6addr_string(&ip6->ip6_src), - tcpport_string(sport), - ip6addr_string(&ip6->ip6_dst), - tcpport_string(dport)); - } else { - (void)printf("%s > %s: ", - tcpport_string(sport), tcpport_string(dport)); - } - } else + if (ip6) { + if (ip6->ip6_nxt == IPPROTO_TCP) { + (void)printf("%s.%s > %s.%s: ", + ip6addr_string(&ip6->ip6_src), + tcpport_string(sport), + ip6addr_string(&ip6->ip6_dst), + tcpport_string(dport)); + } else { + (void)printf("%s > %s: ", + tcpport_string(sport), tcpport_string(dport)); + } + } else #endif /*INET6*/ - { - if (ip->ip_p == IPPROTO_TCP) { - (void)printf("%s.%s > %s.%s: ", - ipaddr_string(&ip->ip_src), - tcpport_string(sport), - ipaddr_string(&ip->ip_dst), - tcpport_string(dport)); - } else { - (void)printf("%s > %s: ", - tcpport_string(sport), tcpport_string(dport)); - } - } - - if (hlen < sizeof(*tp)) { - (void)printf(" tcp %d [bad hdr length %u - too short, < %lu]", - length - hlen, hlen, (unsigned long)sizeof(*tp)); - return; - } - - TCHECK(*tp); - - seq = EXTRACT_32BITS(&tp->th_seq); - ack = EXTRACT_32BITS(&tp->th_ack); - win = EXTRACT_16BITS(&tp->th_win); - urp = EXTRACT_16BITS(&tp->th_urp); - - if (qflag) { - (void)printf("tcp %d", length - hlen); - if (hlen > length) { - (void)printf(" [bad hdr length %u - too long, > %u]", - hlen, length); - } - return; - } - if ((flags = tp->th_flags) & (TH_SYN|TH_FIN|TH_RST|TH_PUSH| - TH_ECNECHO|TH_CWR)) { - if (flags & TH_SYN) - putchar('S'); - if (flags & TH_FIN) - putchar('F'); - if (flags & TH_RST) - putchar('R'); - if (flags & TH_PUSH) - putchar('P'); - if (flags & TH_CWR) - putchar('W'); /* congestion _W_indow reduced (ECN) */ - if (flags & TH_ECNECHO) - putchar('E'); /* ecn _E_cho sent (ECN) */ - } else - putchar('.'); - - if (!Sflag && (flags & TH_ACK)) { - register struct tcp_seq_hash *th; - const void *src, *dst; - register int rev; - struct tha tha; - /* - * Find (or record) the initial sequence numbers for - * this conversation. (we pick an arbitrary - * collating order so there's only one entry for - * both directions). - */ + { + if (ip->ip_p == IPPROTO_TCP) { + (void)printf("%s.%s > %s.%s: ", + ipaddr_string(&ip->ip_src), + tcpport_string(sport), + ipaddr_string(&ip->ip_dst), + tcpport_string(dport)); + } else { + (void)printf("%s > %s: ", + tcpport_string(sport), tcpport_string(dport)); + } + } + + if (hlen < sizeof(*tp)) { + (void)printf(" tcp %d [bad hdr length %u - too short, < %lu]", + length - hlen, hlen, (unsigned long)sizeof(*tp)); + return; + } + + TCHECK(*tp); + + seq = EXTRACT_32BITS(&tp->th_seq); + ack = EXTRACT_32BITS(&tp->th_ack); + win = EXTRACT_16BITS(&tp->th_win); + urp = EXTRACT_16BITS(&tp->th_urp); + + if (qflag) { + (void)printf("tcp %d", length - hlen); + if (hlen > length) { + (void)printf(" [bad hdr length %u - too long, > %u]", + hlen, length); + } + return; + } + + flags = tp->th_flags; + printf("Flags [%s]", bittok2str_nosep(tcp_flag_values, "none", flags)); + + if (!Sflag && (flags & TH_ACK)) { + register struct tcp_seq_hash *th; + const void *src, *dst; + register int rev; + struct tha tha; + /* + * Find (or record) the initial sequence numbers for + * this conversation. (we pick an arbitrary + * collating order so there's only one entry for + * both directions). + */ #ifdef INET6 - memset(&tha, 0, sizeof(tha)); - rev = 0; - if (ip6) { - src = &ip6->ip6_src; - dst = &ip6->ip6_dst; - if (sport > dport) - rev = 1; - else if (sport == dport) { - if (memcmp(src, dst, sizeof ip6->ip6_dst) > 0) - rev = 1; - } - if (rev) { - memcpy(&tha.src, dst, sizeof ip6->ip6_dst); - memcpy(&tha.dst, src, sizeof ip6->ip6_src); - tha.port = dport << 16 | sport; - } else { - memcpy(&tha.dst, dst, sizeof ip6->ip6_dst); - memcpy(&tha.src, src, sizeof ip6->ip6_src); - tha.port = sport << 16 | dport; - } - } else { - src = &ip->ip_src; - dst = &ip->ip_dst; - if (sport > dport) - rev = 1; - else if (sport == dport) { - if (memcmp(src, dst, sizeof ip->ip_dst) > 0) - rev = 1; - } - if (rev) { - memcpy(&tha.src, dst, sizeof ip->ip_dst); - memcpy(&tha.dst, src, sizeof ip->ip_src); - tha.port = dport << 16 | sport; - } else { - memcpy(&tha.dst, dst, sizeof ip->ip_dst); - memcpy(&tha.src, src, sizeof ip->ip_src); - tha.port = sport << 16 | dport; - } - } + memset(&tha, 0, sizeof(tha)); + rev = 0; + if (ip6) { + src = &ip6->ip6_src; + dst = &ip6->ip6_dst; + if (sport > dport) + rev = 1; + else if (sport == dport) { + if (memcmp(src, dst, sizeof ip6->ip6_dst) > 0) + rev = 1; + } + if (rev) { + memcpy(&tha.src, dst, sizeof ip6->ip6_dst); + memcpy(&tha.dst, src, sizeof ip6->ip6_src); + tha.port = dport << 16 | sport; + } else { + memcpy(&tha.dst, dst, sizeof ip6->ip6_dst); + memcpy(&tha.src, src, sizeof ip6->ip6_src); + tha.port = sport << 16 | dport; + } + } else { + src = &ip->ip_src; + dst = &ip->ip_dst; + if (sport > dport) + rev = 1; + else if (sport == dport) { + if (memcmp(src, dst, sizeof ip->ip_dst) > 0) + rev = 1; + } + if (rev) { + memcpy(&tha.src, dst, sizeof ip->ip_dst); + memcpy(&tha.dst, src, sizeof ip->ip_src); + tha.port = dport << 16 | sport; + } else { + memcpy(&tha.dst, dst, sizeof ip->ip_dst); + memcpy(&tha.src, src, sizeof ip->ip_src); + tha.port = sport << 16 | dport; + } + } #else - rev = 0; - src = &ip->ip_src; - dst = &ip->ip_dst; - if (sport > dport) - rev = 1; - else if (sport == dport) { - if (memcmp(src, dst, sizeof ip->ip_dst) > 0) - rev = 1; - } - if (rev) { - memcpy(&tha.src, dst, sizeof ip->ip_dst); - memcpy(&tha.dst, src, sizeof ip->ip_src); - tha.port = dport << 16 | sport; - } else { - memcpy(&tha.dst, dst, sizeof ip->ip_dst); - memcpy(&tha.src, src, sizeof ip->ip_src); - tha.port = sport << 16 | dport; - } + rev = 0; + src = &ip->ip_src; + dst = &ip->ip_dst; + if (sport > dport) + rev = 1; + else if (sport == dport) { + if (memcmp(src, dst, sizeof ip->ip_dst) > 0) + rev = 1; + } + if (rev) { + memcpy(&tha.src, dst, sizeof ip->ip_dst); + memcpy(&tha.dst, src, sizeof ip->ip_src); + tha.port = dport << 16 | sport; + } else { + memcpy(&tha.dst, dst, sizeof ip->ip_dst); + memcpy(&tha.src, src, sizeof ip->ip_src); + tha.port = sport << 16 | dport; + } #endif - threv = rev; - for (th = &tcp_seq_hash[tha.port % TSEQ_HASHSIZE]; - th->nxt; th = th->nxt) - if (memcmp((char *)&tha, (char *)&th->addr, - sizeof(th->addr)) == 0) - break; - - if (!th->nxt || (flags & TH_SYN)) { - /* didn't find it or new conversation */ - if (th->nxt == NULL) { - th->nxt = (struct tcp_seq_hash *) - calloc(1, sizeof(*th)); - if (th->nxt == NULL) - error("tcp_print: calloc"); - } - th->addr = tha; - if (rev) - th->ack = seq, th->seq = ack - 1; - else - th->seq = seq, th->ack = ack - 1; - } else { - if (rev) - seq -= th->ack, ack -= th->seq; - else - seq -= th->seq, ack -= th->ack; - } - - thseq = th->seq; - thack = th->ack; - } else { - /*fool gcc*/ - thseq = thack = threv = 0; - } - if (hlen > length) { - (void)printf(" [bad hdr length %u - too long, > %u]", - hlen, length); - return; - } - - if (IP_V(ip) == 4 && vflag && !fragmented) { - u_int16_t sum, tcp_sum; - if (TTEST2(tp->th_sport, length)) { - sum = tcp_cksum(ip, tp, length); + threv = rev; + for (th = &tcp_seq_hash[tha.port % TSEQ_HASHSIZE]; + th->nxt; th = th->nxt) + if (memcmp((char *)&tha, (char *)&th->addr, + sizeof(th->addr)) == 0) + break; + + if (!th->nxt || (flags & TH_SYN)) { + /* didn't find it or new conversation */ + if (th->nxt == NULL) { + th->nxt = (struct tcp_seq_hash *) + calloc(1, sizeof(*th)); + if (th->nxt == NULL) + error("tcp_print: calloc"); + } + th->addr = tha; + if (rev) + th->ack = seq, th->seq = ack - 1; + else + th->seq = seq, th->ack = ack - 1; + } else { + if (rev) + seq -= th->ack, ack -= th->seq; + else + seq -= th->seq, ack -= th->ack; + } + + thseq = th->seq; + thack = th->ack; + } else { + /*fool gcc*/ + thseq = thack = threv = 0; + } + if (hlen > length) { + (void)printf(" [bad hdr length %u - too long, > %u]", + hlen, length); + return; + } + + if (IP_V(ip) == 4 && vflag && !Kflag && !fragmented) { + u_int16_t sum, tcp_sum; + if (TTEST2(tp->th_sport, length)) { + sum = tcp_cksum(ip, tp, length); (void)printf(", cksum 0x%04x",EXTRACT_16BITS(&tp->th_sum)); - if (sum != 0) { - tcp_sum = EXTRACT_16BITS(&tp->th_sum); - (void)printf(" (incorrect (-> 0x%04x),",in_cksum_shouldbe(tcp_sum, sum)); - } else - (void)printf(" (correct),"); - } - } + if (sum != 0) { + tcp_sum = EXTRACT_16BITS(&tp->th_sum); + (void)printf(" (incorrect -> 0x%04x)",in_cksum_shouldbe(tcp_sum, sum)); + } else + (void)printf(" (correct)"); + } + } #ifdef INET6 - if (IP_V(ip) == 6 && ip6->ip6_plen && vflag && !fragmented) { - u_int16_t sum,tcp_sum; - if (TTEST2(tp->th_sport, length)) { - sum = tcp6_cksum(ip6, tp, length); + if (IP_V(ip) == 6 && ip6->ip6_plen && vflag && !Kflag && !fragmented) { + u_int16_t sum,tcp_sum; + if (TTEST2(tp->th_sport, length)) { + sum = tcp6_cksum(ip6, tp, length); (void)printf(", cksum 0x%04x",EXTRACT_16BITS(&tp->th_sum)); - if (sum != 0) { - tcp_sum = EXTRACT_16BITS(&tp->th_sum); - (void)printf(" (incorrect (-> 0x%04x),",in_cksum_shouldbe(tcp_sum, sum)); - } else - (void)printf(" (correct),"); - - } - } + if (sum != 0) { + tcp_sum = EXTRACT_16BITS(&tp->th_sum); + (void)printf(" (incorrect -> 0x%04x)",in_cksum_shouldbe(tcp_sum, sum)); + } else + (void)printf(" (correct)"); + + } + } #endif - length -= hlen; - if (vflag > 1 || length > 0 || flags & (TH_SYN | TH_FIN | TH_RST)) - (void)printf(" %u:%u(%u)", seq, seq + length, length); - if (flags & TH_ACK) - (void)printf(" ack %u", ack); - - (void)printf(" win %d", win); - - if (flags & TH_URG) - (void)printf(" urg %d", urp); - /* - * Handle any options. - */ - if (hlen > sizeof(*tp)) { - register const u_char *cp; - register u_int i, opt, datalen; - register u_int len; - - hlen -= sizeof(*tp); - cp = (const u_char *)tp + sizeof(*tp); - putchar(' '); - ch = '<'; - while (hlen > 0) { - putchar(ch); - TCHECK(*cp); - opt = *cp++; - if (ZEROLENOPT(opt)) - len = 1; - else { - TCHECK(*cp); - len = *cp++; /* total including type, len */ - if (len < 2 || len > hlen) - goto bad; - --hlen; /* account for length byte */ - } - --hlen; /* account for type byte */ - datalen = 0; + length -= hlen; + if (vflag > 1 || flags & (TH_SYN | TH_FIN | TH_RST)) { + (void)printf(", seq %u", seq); + + if (length > 0) { + (void)printf(":%u", seq + length); + } + } + + if (flags & TH_ACK) { + (void)printf(", ack %u", ack); + } + + (void)printf(", win %d", win); + + if (flags & TH_URG) + (void)printf(", urg %d", urp); + /* + * Handle any options. + */ + if (hlen > sizeof(*tp)) { + register const u_char *cp; + register u_int i, opt, datalen; + register u_int len; + + hlen -= sizeof(*tp); + cp = (const u_char *)tp + sizeof(*tp); + printf(", options ["); + while (hlen > 0) { + if (ch != '\0') + putchar(ch); + TCHECK(*cp); + opt = *cp++; + if (ZEROLENOPT(opt)) + len = 1; + else { + TCHECK(*cp); + len = *cp++; /* total including type, len */ + if (len < 2 || len > hlen) + goto bad; + --hlen; /* account for length byte */ + } + --hlen; /* account for type byte */ + datalen = 0; /* Bail if "l" bytes of data are not left or were not captured */ #define LENCHECK(l) { if ((l) > hlen) goto bad; TCHECK2(*cp, l); } - switch (opt) { - - case TCPOPT_MAXSEG: - (void)printf("mss"); - datalen = 2; - LENCHECK(datalen); - (void)printf(" %u", EXTRACT_16BITS(cp)); - - break; - - case TCPOPT_EOL: - (void)printf("eol"); - break; - - case TCPOPT_NOP: - (void)printf("nop"); - break; - - case TCPOPT_WSCALE: - (void)printf("wscale"); - datalen = 1; - LENCHECK(datalen); - (void)printf(" %u", *cp); - break; - - case TCPOPT_SACKOK: - (void)printf("sackOK"); - break; - - case TCPOPT_SACK: - datalen = len - 2; - if (datalen % 8 != 0) { - (void)printf("malformed sack"); - } else { - u_int32_t s, e; - - (void)printf("sack %d ", datalen / 8); - for (i = 0; i < datalen; i += 8) { - LENCHECK(i + 4); - s = EXTRACT_32BITS(cp + i); - LENCHECK(i + 8); - e = EXTRACT_32BITS(cp + i + 4); - if (threv) { - s -= thseq; - e -= thseq; - } else { - s -= thack; - e -= thack; - } - (void)printf("{%u:%u}", s, e); - } - } - break; - - case TCPOPT_ECHO: - (void)printf("echo"); - datalen = 4; - LENCHECK(datalen); - (void)printf(" %u", EXTRACT_32BITS(cp)); - break; - - case TCPOPT_ECHOREPLY: - (void)printf("echoreply"); - datalen = 4; - LENCHECK(datalen); - (void)printf(" %u", EXTRACT_32BITS(cp)); - break; - - case TCPOPT_TIMESTAMP: - (void)printf("timestamp"); - datalen = 8; - LENCHECK(4); - (void)printf(" %u", EXTRACT_32BITS(cp)); - LENCHECK(datalen); - (void)printf(" %u", EXTRACT_32BITS(cp + 4)); - break; - - case TCPOPT_CC: - (void)printf("cc"); - datalen = 4; - LENCHECK(datalen); - (void)printf(" %u", EXTRACT_32BITS(cp)); - break; - - case TCPOPT_CCNEW: - (void)printf("ccnew"); - datalen = 4; - LENCHECK(datalen); - (void)printf(" %u", EXTRACT_32BITS(cp)); - break; - - case TCPOPT_CCECHO: - (void)printf("ccecho"); - datalen = 4; - LENCHECK(datalen); - (void)printf(" %u", EXTRACT_32BITS(cp)); - break; - - case TCPOPT_SIGNATURE: - (void)printf("md5:"); - datalen = TCP_SIGLEN; - LENCHECK(datalen); + + printf("%s", tok2str(tcp_option_values, "Unknown Option %u", opt)); + + switch (opt) { + + case TCPOPT_MAXSEG: + datalen = 2; + LENCHECK(datalen); + (void)printf(" %u", EXTRACT_16BITS(cp)); + break; + + case TCPOPT_WSCALE: + datalen = 1; + LENCHECK(datalen); + (void)printf(" %u", *cp); + break; + + case TCPOPT_SACK: + datalen = len - 2; + if (datalen % 8 != 0) { + (void)printf("malformed sack"); + } else { + u_int32_t s, e; + + (void)printf(" %d ", datalen / 8); + for (i = 0; i < datalen; i += 8) { + LENCHECK(i + 4); + s = EXTRACT_32BITS(cp + i); + LENCHECK(i + 8); + e = EXTRACT_32BITS(cp + i + 4); + if (threv) { + s -= thseq; + e -= thseq; + } else { + s -= thack; + e -= thack; + } + (void)printf("{%u:%u}", s, e); + } + } + break; + + case TCPOPT_CC: + case TCPOPT_CCNEW: + case TCPOPT_CCECHO: + case TCPOPT_ECHO: + case TCPOPT_ECHOREPLY: + + /* + * those options share their semantics. + * fall through + */ + datalen = 4; + LENCHECK(datalen); + (void)printf(" %u", EXTRACT_32BITS(cp)); + break; + + case TCPOPT_TIMESTAMP: + datalen = 8; + LENCHECK(datalen); + (void)printf(" val %u ecr %u", + EXTRACT_32BITS(cp), + EXTRACT_32BITS(cp + 4)); + break; + + case TCPOPT_SIGNATURE: + datalen = TCP_SIGLEN; + LENCHECK(datalen); #ifdef HAVE_LIBCRYPTO - switch (tcp_verify_signature(ip, tp, - bp + TH_OFF(tp) * 4, length, cp)) { - - case SIGNATURE_VALID: - (void)printf("valid"); - break; - - case SIGNATURE_INVALID: - (void)printf("invalid"); - break; - - case CANT_CHECK_SIGNATURE: - (void)printf("can't check - "); - for (i = 0; i < TCP_SIGLEN; ++i) - (void)printf("%02x", cp[i]); - break; - } + switch (tcp_verify_signature(ip, tp, + bp + TH_OFF(tp) * 4, length, cp)) { + + case SIGNATURE_VALID: + (void)printf("valid"); + break; + + case SIGNATURE_INVALID: + (void)printf("invalid"); + break; + + case CANT_CHECK_SIGNATURE: + (void)printf("can't check - "); + for (i = 0; i < TCP_SIGLEN; ++i) + (void)printf("%02x", cp[i]); + break; + } #else - for (i = 0; i < TCP_SIGLEN; ++i) - (void)printf("%02x", cp[i]); + for (i = 0; i < TCP_SIGLEN; ++i) + (void)printf("%02x", cp[i]); #endif - break; - - default: - (void)printf("opt-%u:", opt); - datalen = len - 2; - for (i = 0; i < datalen; ++i) { - LENCHECK(i); - (void)printf("%02x", cp[i]); - } - break; - } - - /* Account for data printed */ - cp += datalen; - hlen -= datalen; - - /* Check specification against observed length */ - ++datalen; /* option octet */ - if (!ZEROLENOPT(opt)) - ++datalen; /* size octet */ - if (datalen != len) - (void)printf("[len %d]", len); - ch = ','; - if (opt == TCPOPT_EOL) - break; - } - putchar('>'); - } - - if (length <= 0) - return; - - /* - * Decode payload if necessary. - */ - bp += TH_OFF(tp) * 4; - if (flags & TH_RST) { - if (vflag) - print_tcp_rst_data(bp, length); - } else { - if (sport == TELNET_PORT || dport == TELNET_PORT) { - if (!qflag && vflag) - telnet_print(bp, length); - } else if (sport == BGP_PORT || dport == BGP_PORT) - bgp_print(bp, length); - else if (sport == PPTP_PORT || dport == PPTP_PORT) - pptp_print(bp); + break; + + case TCPOPT_AUTH: + (void)printf("keyid %d", *cp++); + datalen = len - 3; + for (i = 0; i < datalen; ++i) { + LENCHECK(i); + (void)printf("%02x", cp[i]); + } + break; + + + case TCPOPT_EOL: + case TCPOPT_NOP: + case TCPOPT_SACKOK: + /* + * Nothing interesting. + * fall through + */ + break; + + default: + datalen = len - 2; + for (i = 0; i < datalen; ++i) { + LENCHECK(i); + (void)printf("%02x", cp[i]); + } + break; + } + + /* Account for data printed */ + cp += datalen; + hlen -= datalen; + + /* Check specification against observed length */ + ++datalen; /* option octet */ + if (!ZEROLENOPT(opt)) + ++datalen; /* size octet */ + if (datalen != len) + (void)printf("[len %d]", len); + ch = ','; + if (opt == TCPOPT_EOL) + break; + } + putchar(']'); + } + + /* + * Print length field before crawling down the stack. + */ + printf(", length %u", length); + + if (length <= 0) + return; + + /* + * Decode payload if necessary. + */ + bp += TH_OFF(tp) * 4; + if ((flags & TH_RST) && vflag) { + print_tcp_rst_data(bp, length); + return; + } + + if (sport == TELNET_PORT || dport == TELNET_PORT) { + if (!qflag && vflag) + telnet_print(bp, length); + } else if (sport == BGP_PORT || dport == BGP_PORT) + bgp_print(bp, length); + else if (sport == PPTP_PORT || dport == PPTP_PORT) + pptp_print(bp); #ifdef TCPDUMP_DO_SMB - else if (sport == NETBIOS_SSN_PORT || dport == NETBIOS_SSN_PORT) - nbt_tcp_print(bp, length); + else if (sport == NETBIOS_SSN_PORT || dport == NETBIOS_SSN_PORT) + nbt_tcp_print(bp, length); + else if (sport == SMB_PORT || dport == SMB_PORT) + smb_tcp_print(bp, length); #endif - else if (sport == BEEP_PORT || dport == BEEP_PORT) - beep_print(bp, length); - else if (length > 2 && - (sport == NAMESERVER_PORT || dport == NAMESERVER_PORT || - sport == MULTICASTDNS_PORT || dport == MULTICASTDNS_PORT)) { - /* - * TCP DNS query has 2byte length at the head. - * XXX packet could be unaligned, it can go strange - */ - ns_print(bp + 2, length - 2, 0); - } else if (sport == MSDP_PORT || dport == MSDP_PORT) { - msdp_print(bp, length); - } - else if (length > 0 && (sport == LDP_PORT || dport == LDP_PORT)) { - ldp_print(bp, length); - } - } - return; -bad: - fputs("[bad opt]", stdout); - if (ch != '\0') - putchar('>'); - return; -trunc: - fputs("[|tcp]", stdout); - if (ch != '\0') - putchar('>'); + else if (sport == BEEP_PORT || dport == BEEP_PORT) + beep_print(bp, length); + else if (length > 2 && + (sport == NAMESERVER_PORT || dport == NAMESERVER_PORT || + sport == MULTICASTDNS_PORT || dport == MULTICASTDNS_PORT)) { + /* + * TCP DNS query has 2byte length at the head. + * XXX packet could be unaligned, it can go strange + */ + ns_print(bp + 2, length - 2, 0); + } else if (sport == MSDP_PORT || dport == MSDP_PORT) { + msdp_print(bp, length); + } + else if (length > 0 && (sport == LDP_PORT || dport == LDP_PORT)) { + ldp_print(bp, length); + } + + return; + bad: + fputs("[bad opt]", stdout); + if (ch != '\0') + putchar('>'); + return; + trunc: + fputs("[|tcp]", stdout); + if (ch != '\0') + putchar('>'); } /* @@ -712,96 +716,103 @@ trunc: static void print_tcp_rst_data(register const u_char *sp, u_int length) { - int c; - - if (TTEST2(*sp, length)) - printf(" [RST"); - else - printf(" [!RST"); - if (length > MAX_RST_DATA_LEN) { - length = MAX_RST_DATA_LEN; /* can use -X for longer */ - putchar('+'); /* indicate we truncate */ - } - putchar(' '); - while (length-- && sp <= snapend) { - c = *sp++; - safeputchar(c); - } - putchar(']'); + int c; + + if (TTEST2(*sp, length)) + printf(" [RST"); + else + printf(" [!RST"); + if (length > MAX_RST_DATA_LEN) { + length = MAX_RST_DATA_LEN; /* can use -X for longer */ + putchar('+'); /* indicate we truncate */ + } + putchar(' '); + while (length-- && sp <= snapend) { + c = *sp++; + safeputchar(c); + } + putchar(']'); } #ifdef HAVE_LIBCRYPTO static int tcp_verify_signature(const struct ip *ip, const struct tcphdr *tp, - const u_char *data, int length, const u_char *rcvsig) + const u_char *data, int length, const u_char *rcvsig) { struct tcphdr tp1; - u_char sig[TCP_SIGLEN]; - char zero_proto = 0; - MD5_CTX ctx; - u_int16_t savecsum, tlen; + u_char sig[TCP_SIGLEN]; + char zero_proto = 0; + MD5_CTX ctx; + u_int16_t savecsum, tlen; #ifdef INET6 - struct ip6_hdr *ip6; + struct ip6_hdr *ip6; + u_int32_t len32; + u_int8_t nxt; #endif - u_int32_t len32; - u_int8_t nxt; - - tp1 = *tp; - - if (tcpmd5secret == NULL) - return (CANT_CHECK_SIGNATURE); - MD5_Init(&ctx); - /* - * Step 1: Update MD5 hash with IP pseudo-header. - */ - if (IP_V(ip) == 4) { - MD5_Update(&ctx, (char *)&ip->ip_src, sizeof(ip->ip_src)); - MD5_Update(&ctx, (char *)&ip->ip_dst, sizeof(ip->ip_dst)); - MD5_Update(&ctx, (char *)&zero_proto, sizeof(zero_proto)); - MD5_Update(&ctx, (char *)&ip->ip_p, sizeof(ip->ip_p)); - tlen = EXTRACT_16BITS(&ip->ip_len) - IP_HL(ip) * 4; - tlen = htons(tlen); - MD5_Update(&ctx, (char *)&tlen, sizeof(tlen)); + tp1 = *tp; + + if (tcpmd5secret == NULL) + return (CANT_CHECK_SIGNATURE); + + MD5_Init(&ctx); + /* + * Step 1: Update MD5 hash with IP pseudo-header. + */ + if (IP_V(ip) == 4) { + MD5_Update(&ctx, (char *)&ip->ip_src, sizeof(ip->ip_src)); + MD5_Update(&ctx, (char *)&ip->ip_dst, sizeof(ip->ip_dst)); + MD5_Update(&ctx, (char *)&zero_proto, sizeof(zero_proto)); + MD5_Update(&ctx, (char *)&ip->ip_p, sizeof(ip->ip_p)); + tlen = EXTRACT_16BITS(&ip->ip_len) - IP_HL(ip) * 4; + tlen = htons(tlen); + MD5_Update(&ctx, (char *)&tlen, sizeof(tlen)); #ifdef INET6 - } else if (IP_V(ip) == 6) { - ip6 = (struct ip6_hdr *)ip; - MD5_Update(&ctx, (char *)&ip6->ip6_src, sizeof(ip6->ip6_src)); - MD5_Update(&ctx, (char *)&ip6->ip6_dst, sizeof(ip6->ip6_dst)); - len32 = htonl(ntohs(ip6->ip6_plen)); - MD5_Update(&ctx, (char *)&len32, sizeof(len32)); - nxt = 0; - MD5_Update(&ctx, (char *)&nxt, sizeof(nxt)); - MD5_Update(&ctx, (char *)&nxt, sizeof(nxt)); - MD5_Update(&ctx, (char *)&nxt, sizeof(nxt)); - nxt = IPPROTO_TCP; - MD5_Update(&ctx, (char *)&nxt, sizeof(nxt)); + } else if (IP_V(ip) == 6) { + ip6 = (struct ip6_hdr *)ip; + MD5_Update(&ctx, (char *)&ip6->ip6_src, sizeof(ip6->ip6_src)); + MD5_Update(&ctx, (char *)&ip6->ip6_dst, sizeof(ip6->ip6_dst)); + len32 = htonl(ntohs(ip6->ip6_plen)); + MD5_Update(&ctx, (char *)&len32, sizeof(len32)); + nxt = 0; + MD5_Update(&ctx, (char *)&nxt, sizeof(nxt)); + MD5_Update(&ctx, (char *)&nxt, sizeof(nxt)); + MD5_Update(&ctx, (char *)&nxt, sizeof(nxt)); + nxt = IPPROTO_TCP; + MD5_Update(&ctx, (char *)&nxt, sizeof(nxt)); #endif - } else - return (CANT_CHECK_SIGNATURE); - - /* - * Step 2: Update MD5 hash with TCP header, excluding options. - * The TCP checksum must be set to zero. - */ - savecsum = tp1.th_sum; - tp1.th_sum = 0; - MD5_Update(&ctx, (char *)&tp1, sizeof(struct tcphdr)); - tp1.th_sum = savecsum; - /* - * Step 3: Update MD5 hash with TCP segment data, if present. - */ - if (length > 0) - MD5_Update(&ctx, data, length); - /* - * Step 4: Update MD5 hash with shared secret. - */ - MD5_Update(&ctx, tcpmd5secret, strlen(tcpmd5secret)); - MD5_Final(sig, &ctx); - - if (memcmp(rcvsig, sig, TCP_SIGLEN) == 0) - return (SIGNATURE_VALID); - else - return (SIGNATURE_INVALID); + } else + return (CANT_CHECK_SIGNATURE); + + /* + * Step 2: Update MD5 hash with TCP header, excluding options. + * The TCP checksum must be set to zero. + */ + savecsum = tp1.th_sum; + tp1.th_sum = 0; + MD5_Update(&ctx, (char *)&tp1, sizeof(struct tcphdr)); + tp1.th_sum = savecsum; + /* + * Step 3: Update MD5 hash with TCP segment data, if present. + */ + if (length > 0) + MD5_Update(&ctx, data, length); + /* + * Step 4: Update MD5 hash with shared secret. + */ + MD5_Update(&ctx, tcpmd5secret, strlen(tcpmd5secret)); + MD5_Final(sig, &ctx); + + if (memcmp(rcvsig, sig, TCP_SIGLEN) == 0) + return (SIGNATURE_VALID); + else + return (SIGNATURE_INVALID); } #endif /* HAVE_LIBCRYPTO */ + +/* + * Local Variables: + * c-style: whitesmith + * c-basic-offset: 8 + * End: + */ diff --git a/contrib/tcpdump/print-telnet.c b/contrib/tcpdump/print-telnet.c index 78887278bf..4911e5caf2 100644 --- a/contrib/tcpdump/print-telnet.c +++ b/contrib/tcpdump/print-telnet.c @@ -51,7 +51,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-telnet.c,v 1.24 2003/12/29 11:05:10 hannes Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-telnet.c,v 1.24 2003-12-29 11:05:10 hannes Exp $"; #endif #include diff --git a/contrib/tcpdump/print-tftp.c b/contrib/tcpdump/print-tftp.c index b517898b13..c4fc7ea2af 100644 --- a/contrib/tcpdump/print-tftp.c +++ b/contrib/tcpdump/print-tftp.c @@ -23,7 +23,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-tftp.c,v 1.37.2.1 2007/09/14 01:03:12 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-tftp.c,v 1.38.2.1 2008-04-11 16:44:17 gianluca Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -50,7 +50,7 @@ static struct tok op2str[] = { { WRQ, "WRQ" }, /* write request */ { DATA, "DATA" }, /* data packet */ { ACK, "ACK" }, /* acknowledgement */ - { ERROR, "ERROR" }, /* error code */ + { TFTP_ERROR, "ERROR" }, /* error code */ { OACK, "OACK" }, /* option acknowledgement */ { 0, NULL } }; @@ -137,7 +137,7 @@ tftp_print(register const u_char *bp, u_int length) printf(" block %d", EXTRACT_16BITS(&tp->th_block)); break; - case ERROR: + case TFTP_ERROR: /* Print error code string */ TCHECK(tp->th_code); printf(" %s \"", tok2str(err2str, "tftp-err-#%d \"", diff --git a/contrib/tcpdump/print-timed.c b/contrib/tcpdump/print-timed.c index 3df224129f..55fbb39eae 100644 --- a/contrib/tcpdump/print-timed.c +++ b/contrib/tcpdump/print-timed.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-timed.c,v 1.9 2003/11/16 09:36:40 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-timed.c,v 1.9 2003-11-16 09:36:40 guy Exp $"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-token.c b/contrib/tcpdump/print-token.c index 47fcca63ab..04defa9921 100644 --- a/contrib/tcpdump/print-token.c +++ b/contrib/tcpdump/print-token.c @@ -25,7 +25,7 @@ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.25.2.2 2005/11/13 12:13:01 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.27 2005-11-13 12:12:43 guy Exp $"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-udld.c b/contrib/tcpdump/print-udld.c new file mode 100644 index 0000000000..a5488dda45 --- /dev/null +++ b/contrib/tcpdump/print-udld.c @@ -0,0 +1,173 @@ +/* + * 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. + * + * UNIDIRECTIONAL LINK DETECTION (UDLD) as per + * http://www.ietf.org/internet-drafts/draft-foschiano-udld-02.txt + * + * Original code by Carles Kishimoto + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include +#include + +#include "interface.h" +#include "addrtoname.h" +#include "extract.h" +#include "nlpid.h" + +#define UDLD_HEADER_LEN 4 +#define UDLD_DEVICE_ID_TLV 0x0001 +#define UDLD_PORT_ID_TLV 0x0002 +#define UDLD_ECHO_TLV 0x0003 +#define UDLD_MESSAGE_INTERVAL_TLV 0x0004 +#define UDLD_TIMEOUT_INTERVAL_TLV 0x0005 +#define UDLD_DEVICE_NAME_TLV 0x0006 +#define UDLD_SEQ_NUMBER_TLV 0x0007 + +static struct tok udld_tlv_values[] = { + { UDLD_DEVICE_ID_TLV, "Device-ID TLV"}, + { UDLD_PORT_ID_TLV, "Port-ID TLV"}, + { UDLD_ECHO_TLV, "Echo TLV"}, + { UDLD_MESSAGE_INTERVAL_TLV, "Message Interval TLV"}, + { UDLD_TIMEOUT_INTERVAL_TLV, "Timeout Interval TLV"}, + { UDLD_DEVICE_NAME_TLV, "Device Name TLV"}, + { UDLD_SEQ_NUMBER_TLV,"Sequence Number TLV"}, + { 0, NULL} +}; + +static struct tok udld_code_values[] = { + { 0x00, "Reserved"}, + { 0x01, "Probe message"}, + { 0x02, "Echo message"}, + { 0x03, "Flush message"}, + { 0, NULL} +}; + +static struct tok udld_flags_values[] = { + { 0x00, "RT"}, + { 0x01, "RSY"}, + { 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 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Ver | Opcode | Flags | Checksum | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | List of TLVs (variable length list) | + * | ... | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * + */ + +#define UDLD_EXTRACT_VERSION(x) (((x)&0xe0)>>5) +#define UDLD_EXTRACT_OPCODE(x) ((x)&0x1f) + +void +udld_print (const u_char *pptr, u_int length) +{ + int code, type, len; + const u_char *tptr; + + if (length < UDLD_HEADER_LEN) + goto trunc; + + tptr = pptr; + + if (!TTEST2(*tptr, UDLD_HEADER_LEN)) + goto trunc; + + code = UDLD_EXTRACT_OPCODE(*tptr); + + printf("UDLDv%u, Code %s (%x), Flags [%s] (0x%02x), length %u", + UDLD_EXTRACT_VERSION(*tptr), + tok2str(udld_code_values, "Reserved", code), + code, + bittok2str(udld_flags_values, "none", *(tptr+1)), + *(tptr+1), + length); + + /* + * In non-verbose mode, just print version and opcode type + */ + if (vflag < 1) { + return; + } + + printf("\n\tChecksum 0x%04x (unverified)", EXTRACT_16BITS(tptr+2)); + + tptr += UDLD_HEADER_LEN; + + while (tptr < (pptr+length)) { + + if (!TTEST2(*tptr, 4)) + goto trunc; + + type = EXTRACT_16BITS(tptr); + len = EXTRACT_16BITS(tptr+2); + len -= 4; + tptr += 4; + + /* infinite loop check */ + if (type == 0 || len == 0) { + return; + } + + printf("\n\t%s (0x%04x) TLV, length %u", + tok2str(udld_tlv_values, "Unknown", type), + type, len); + + switch (type) { + case UDLD_DEVICE_ID_TLV: + case UDLD_PORT_ID_TLV: + case UDLD_ECHO_TLV: + case UDLD_DEVICE_NAME_TLV: + printf(", %s", tptr); + break; + + case UDLD_MESSAGE_INTERVAL_TLV: + case UDLD_TIMEOUT_INTERVAL_TLV: + printf(", %us", (*tptr)); + break; + + case UDLD_SEQ_NUMBER_TLV: + printf(", %u", EXTRACT_32BITS(tptr)); + break; + + default: + break; + } + tptr += len; + } + + return; + + trunc: + printf("[|udld]"); +} + +/* + * Local Variables: + * c-style: whitesmith + * c-basic-offset: 4 + * End: + */ diff --git a/contrib/tcpdump/print-udp.c b/contrib/tcpdump/print-udp.c index 3f08a1c20b..f534c1bb45 100644 --- a/contrib/tcpdump/print-udp.c +++ b/contrib/tcpdump/print-udp.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.138.2.1 2007/03/28 07:45:46 hannes Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.142 2007-08-08 17:20:58 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -683,6 +683,16 @@ udp_print(register const u_char *bp, u_int length, bfd_print((const u_char *)(up+1), length, dport); else if (ISPORT(LMP_PORT)) lmp_print((const u_char *)(up + 1), length); + else if (ISPORT(VQP_PORT)) + vqp_print((const u_char *)(up + 1), length); + else if (ISPORT(SFLOW_PORT)) + sflow_print((const u_char *)(up + 1), length); + else if (dport == LWAPP_CONTROL_PORT) + lwapp_control_print((const u_char *)(up + 1), length, 1); + else if (sport == LWAPP_CONTROL_PORT) + lwapp_control_print((const u_char *)(up + 1), length, 0); + else if (ISPORT(LWAPP_DATA_PORT)) + lwapp_data_print((const u_char *)(up + 1), length); else if (ISPORT(SIP_PORT)) sip_print((const u_char *)(up + 1), length); else if (ISPORT(SYSLOG_PORT)) diff --git a/contrib/tcpdump/print-vjc.c b/contrib/tcpdump/print-vjc.c index 55b7d08b26..2dc89aa5f9 100644 --- a/contrib/tcpdump/print-vjc.c +++ b/contrib/tcpdump/print-vjc.c @@ -25,7 +25,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-vjc.c,v 1.15 2004/03/25 03:31:17 mcr Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-vjc.c,v 1.15 2004-03-25 03:31:17 mcr Exp $ (LBL)"; #endif #include diff --git a/contrib/tcpdump/print-vqp.c b/contrib/tcpdump/print-vqp.c new file mode 100644 index 0000000000..2d9e8e1f96 --- /dev/null +++ b/contrib/tcpdump/print-vqp.c @@ -0,0 +1,209 @@ +/* + * 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 Cisco prop. VQP Protocol + * + * Original code by Carles Kishimoto + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-vqp.c,v 1.3 2006-08-19 06:51:13 guy Exp $"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include +#include +#include + +#include "interface.h" +#include "extract.h" +#include "addrtoname.h" + +#define VQP_VERSION 1 +#define VQP_EXTRACT_VERSION(x) ((x)&0xFF) + +/* + * VQP 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 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Constant | Packet type | Error Code | nitems | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Packet Sequence Number (4 bytes) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ + +struct vqp_common_header_t { + u_int8_t version; + u_int8_t msg_type; + u_int8_t error_code; + u_int8_t nitems; + u_int8_t sequence[4]; +}; + +struct vqp_obj_tlv_t { + u_int8_t obj_type[4]; + u_int8_t obj_length[2]; +}; + +#define VQP_OBJ_REQ_JOIN_PORT 0x01 +#define VQP_OBJ_RESP_VLAN 0x02 +#define VQP_OBJ_REQ_RECONFIRM 0x03 +#define VQP_OBJ_RESP_RECONFIRM 0x04 + +static const struct tok vqp_msg_type_values[] = { + { VQP_OBJ_REQ_JOIN_PORT, "Request, Join Port"}, + { VQP_OBJ_RESP_VLAN, "Response, VLAN"}, + { VQP_OBJ_REQ_RECONFIRM, "Request, Reconfirm"}, + { VQP_OBJ_RESP_RECONFIRM, "Response, Reconfirm"}, + { 0, NULL} +}; + +static const struct tok vqp_error_code_values[] = { + { 0x00, "No error"}, + { 0x03, "Access denied"}, + { 0x04, "Shutdown port"}, + { 0x05, "Wrong VTP domain"}, + { 0, NULL} +}; + +/* FIXME the heading 0x0c looks ugly - those must be flags etc. */ +#define VQP_OBJ_IP_ADDRESS 0x0c01 +#define VQP_OBJ_PORT_NAME 0x0c02 +#define VQP_OBJ_VLAN_NAME 0x0c03 +#define VQP_OBJ_VTP_DOMAIN 0x0c04 +#define VQP_OBJ_ETHERNET_PKT 0x0c05 +#define VQP_OBJ_MAC_NULL 0x0c06 +#define VQP_OBJ_MAC_ADDRESS 0x0c08 + +static const struct tok vqp_obj_values[] = { + { VQP_OBJ_IP_ADDRESS, "Client IP Address" }, + { VQP_OBJ_PORT_NAME, "Port Name" }, + { VQP_OBJ_VLAN_NAME, "VLAN Name" }, + { VQP_OBJ_VTP_DOMAIN, "VTP Domain" }, + { VQP_OBJ_ETHERNET_PKT, "Ethernet Packet" }, + { VQP_OBJ_MAC_NULL, "MAC Null" }, + { VQP_OBJ_MAC_ADDRESS, "MAC Address" }, + { 0, NULL} +}; + +void +vqp_print(register const u_char *pptr, register u_int len) +{ + const struct vqp_common_header_t *vqp_common_header; + const struct vqp_obj_tlv_t *vqp_obj_tlv; + + const u_char *tptr; + u_int16_t vqp_obj_len; + u_int32_t vqp_obj_type; + int tlen; + u_int8_t nitems; + + tptr=pptr; + tlen = len; + vqp_common_header = (const struct vqp_common_header_t *)pptr; + TCHECK(*vqp_common_header); + + /* + * Sanity checking of the header. + */ + if (VQP_EXTRACT_VERSION(vqp_common_header->version) != VQP_VERSION) { + printf("VQP version %u packet not supported", + VQP_EXTRACT_VERSION(vqp_common_header->version)); + return; + } + + /* in non-verbose mode just lets print the basic Message Type */ + if (vflag < 1) { + printf("VQPv%u %s Message, error-code %s (%u), length %u", + VQP_EXTRACT_VERSION(vqp_common_header->version), + tok2str(vqp_msg_type_values, "unknown (%u)",vqp_common_header->msg_type), + tok2str(vqp_error_code_values, "unknown (%u)",vqp_common_header->error_code), + vqp_common_header->error_code, + len); + return; + } + + /* ok they seem to want to know everything - lets fully decode it */ + nitems = vqp_common_header->nitems; + printf("\n\tVQPv%u, %s Message, error-code %s (%u), seq 0x%08x, items %u, length %u", + VQP_EXTRACT_VERSION(vqp_common_header->version), + tok2str(vqp_msg_type_values, "unknown (%u)",vqp_common_header->msg_type), + tok2str(vqp_error_code_values, "unknown (%u)",vqp_common_header->error_code), + vqp_common_header->error_code, + EXTRACT_32BITS(&vqp_common_header->sequence), + nitems, + len); + + /* skip VQP Common header */ + tptr+=sizeof(const struct vqp_common_header_t); + tlen-=sizeof(const struct vqp_common_header_t); + + while (nitems > 0 && tlen > 0) { + + vqp_obj_tlv = (const struct vqp_obj_tlv_t *)tptr; + vqp_obj_type = EXTRACT_32BITS(vqp_obj_tlv->obj_type); + vqp_obj_len = EXTRACT_16BITS(vqp_obj_tlv->obj_length); + tptr+=sizeof(struct vqp_obj_tlv_t); + tlen-=sizeof(struct vqp_obj_tlv_t); + + printf("\n\t %s Object (0x%08x), length %u, value: ", + tok2str(vqp_obj_values, "Unknown", vqp_obj_type), + vqp_obj_type, vqp_obj_len); + + /* basic sanity check */ + if (vqp_obj_type == 0 || vqp_obj_len ==0) { + return; + } + + /* did we capture enough for fully decoding the object ? */ + if (!TTEST2(*tptr, vqp_obj_len)) + goto trunc; + + switch(vqp_obj_type) { + case VQP_OBJ_IP_ADDRESS: + printf("%s (0x%08x)", ipaddr_string(tptr), EXTRACT_32BITS(tptr)); + break; + /* those objects have similar semantics - fall through */ + case VQP_OBJ_PORT_NAME: + case VQP_OBJ_VLAN_NAME: + case VQP_OBJ_VTP_DOMAIN: + case VQP_OBJ_ETHERNET_PKT: + safeputs((const char *)tptr, vqp_obj_len); + break; + /* those objects have similar semantics - fall through */ + case VQP_OBJ_MAC_ADDRESS: + case VQP_OBJ_MAC_NULL: + printf("%s", etheraddr_string(tptr)); + break; + default: + if (vflag <= 1) + print_unknown_data(tptr, "\n\t ", vqp_obj_len); + break; + } + tptr += vqp_obj_len; + tlen -= vqp_obj_len; + nitems--; + } + return; +trunc: + printf("\n\t[|VQP]"); +} diff --git a/contrib/tcpdump/print-vrrp.c b/contrib/tcpdump/print-vrrp.c index 1e87a5003a..899542dac4 100644 --- a/contrib/tcpdump/print-vrrp.c +++ b/contrib/tcpdump/print-vrrp.c @@ -25,7 +25,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-vrrp.c,v 1.9.2.1 2005/05/06 07:57:20 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-vrrp.c,v 1.10 2005-05-06 07:56:54 guy Exp $"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-vtp.c b/contrib/tcpdump/print-vtp.c new file mode 100644 index 0000000000..7631c6f618 --- /dev/null +++ b/contrib/tcpdump/print-vtp.c @@ -0,0 +1,378 @@ +/* + * 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. + * + * VLAN TRUNKING PROTOCOL (VTP) + * + * Reference documentation: + * http://www.cisco.com/en/US/tech/tk389/tk689/technologies_tech_note09186a0080094c52.shtml + * http://www.cisco.com/warp/public/473/21.html + * http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/frames.htm + * + * Original code ode by Carles Kishimoto + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include +#include + +#include "interface.h" +#include "addrtoname.h" +#include "extract.h" +#include "nlpid.h" + +#define VTP_HEADER_LEN 36 +#define VTP_DOMAIN_NAME_LEN 32 +#define VTP_MD5_DIGEST_LEN 16 +#define VTP_UPDATE_TIMESTAMP_LEN 12 +#define VTP_VLAN_INFO_OFFSET 12 + +#define VTP_SUMMARY_ADV 0x01 +#define VTP_SUBSET_ADV 0x02 +#define VTP_ADV_REQUEST 0x03 +#define VTP_JOIN_MESSAGE 0x04 + +struct vtp_vlan_ { + u_int8_t len; + u_int8_t status; + u_int8_t type; + u_int8_t name_len; + u_int16_t vlanid; + u_int16_t mtu; + u_int32_t index; +}; + +static struct tok vtp_message_type_values[] = { + { VTP_SUMMARY_ADV, "Summary advertisement"}, + { VTP_SUBSET_ADV, "Subset advertisement"}, + { VTP_ADV_REQUEST, "Advertisement request"}, + { VTP_JOIN_MESSAGE, "Join message"}, + { 0, NULL } +}; + +static struct tok vtp_header_values[] = { + { 0x01, "Followers"}, /* On Summary advertisement, 3rd byte is Followers */ + { 0x02, "Seq number"}, /* On Subset advertisement, 3rd byte is Sequence number */ + { 0x03, "Rsvd"}, /* On Adver. requests 3rd byte is Rsvd */ + { 0x04, "Rsvd"}, /* On Adver. requests 3rd byte is Rsvd */ + { 0, NULL } +}; + +static struct tok vtp_vlan_type_values[] = { + { 0x01, "Ethernet"}, + { 0x02, "FDDI"}, + { 0x03, "TrCRF"}, + { 0x04, "FDDI-net"}, + { 0x05, "TrBRF"}, + { 0, NULL } +}; + +static struct tok vtp_vlan_status[] = { + { 0x00, "Operational"}, + { 0x01, "Suspended"}, + { 0, NULL } +}; + +#define VTP_VLAN_SOURCE_ROUTING_RING_NUMBER 0x01 +#define VTP_VLAN_SOURCE_ROUTING_BRIDGE_NUMBER 0x02 +#define VTP_VLAN_STP_TYPE 0x03 +#define VTP_VLAN_PARENT_VLAN 0x04 +#define VTP_VLAN_TRANS_BRIDGED_VLAN 0x05 +#define VTP_VLAN_PRUNING 0x06 +#define VTP_VLAN_BRIDGE_TYPE 0x07 +#define VTP_VLAN_ARP_HOP_COUNT 0x08 +#define VTP_VLAN_STE_HOP_COUNT 0x09 +#define VTP_VLAN_BACKUP_CRF_MODE 0x0A + +static struct tok vtp_vlan_tlv_values[] = { + { VTP_VLAN_SOURCE_ROUTING_RING_NUMBER, "Source-Routing Ring Number TLV"}, + { VTP_VLAN_SOURCE_ROUTING_BRIDGE_NUMBER, "Source-Routing Bridge Number TLV"}, + { VTP_VLAN_STP_TYPE, "STP type TLV"}, + { VTP_VLAN_PARENT_VLAN, "Parent VLAN TLV"}, + { VTP_VLAN_TRANS_BRIDGED_VLAN, "Translationally bridged VLANs TLV"}, + { VTP_VLAN_PRUNING, "Pruning TLV"}, + { VTP_VLAN_BRIDGE_TYPE, "Bridge Type TLV"}, + { VTP_VLAN_ARP_HOP_COUNT, "Max ARP Hop Count TLV"}, + { VTP_VLAN_STE_HOP_COUNT, "Max STE Hop Count TLV"}, + { VTP_VLAN_BACKUP_CRF_MODE, "Backup CRF Mode TLV"}, + { 0, NULL } +}; + +static struct tok vtp_stp_type_values[] = { + { 1, "SRT"}, + { 2, "SRB"}, + { 3, "Auto"}, + { 0, NULL } +}; + +void +vtp_print (const u_char *pptr, u_int length) +{ + int type, len, tlv_len, tlv_value; + const u_char *tptr; + const struct vtp_vlan_ *vtp_vlan; + + if (length < VTP_HEADER_LEN) + goto trunc; + + tptr = pptr; + + if (!TTEST2(*tptr, VTP_HEADER_LEN)) + goto trunc; + + type = *(tptr+1); + printf("VTPv%u, Message %s (0x%02x), length %u", + *tptr, + tok2str(vtp_message_type_values,"Unknown message type", type), + *(tptr+1), + length); + + /* In non-verbose mode, just print version and message type */ + if (vflag < 1) { + return; + } + + /* verbose mode print all fields */ + printf("\n\tDomain name: %s, %s: %u", + (tptr+4), + tok2str(vtp_header_values,"Unknown",*(tptr+1)), + *(tptr+2)); + + tptr += VTP_HEADER_LEN; + + switch (type) { + + case VTP_SUMMARY_ADV: + + /* + * SUMMARY ADVERTISEMENT + * + * 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 | Code | Followers | MmgtD Len | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Management Domain Name | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Configuration revision number | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Updater Identity IP address | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Update Timestamp (12 bytes) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | MD5 digest (16 bytes) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * + */ + + printf("\n\t Config Rev %x, Updater %s", + EXTRACT_32BITS(tptr), + ipaddr_string(tptr+4)); + tptr += 8; + printf(", Timestamp 0x%08x 0x%08x 0x%08x", + EXTRACT_32BITS(tptr), + EXTRACT_32BITS(tptr + 4), + EXTRACT_32BITS(tptr + 8)); + tptr += VTP_UPDATE_TIMESTAMP_LEN; + printf(", MD5 digest: %08x%08x%08x%08x", + EXTRACT_32BITS(tptr), + EXTRACT_32BITS(tptr + 4), + EXTRACT_32BITS(tptr + 8), + EXTRACT_32BITS(tptr + 12)); + tptr += VTP_MD5_DIGEST_LEN; + break; + + case VTP_SUBSET_ADV: + + /* + * SUBSET ADVERTISEMENT + * + * 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 | Code | Seq number | MmgtD Len | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Management Domain Name | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Configuration revision number | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | VLAN info field 1 | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | ................ | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | VLAN info field N | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * + */ + + printf(", Config Rev %x", EXTRACT_32BITS(tptr)); + + /* + * VLAN INFORMATION + * 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 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | V info len | Status | VLAN type | VLAN name len | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | ISL vlan id | MTU size | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | 802.10 index (SAID) | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | VLAN name | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * + */ + + tptr += 4; + while (tptr < (pptr+length)) { + + len = *tptr; + if (len == 0) + break; + + if (!TTEST2(*tptr, len)) + goto trunc; + + vtp_vlan = (struct vtp_vlan_*)tptr; + printf("\n\tVLAN info status %s, type %s, VLAN-id %u, MTU %u, SAID 0x%08x, Name %s", + tok2str(vtp_vlan_status,"Unknown",vtp_vlan->status), + tok2str(vtp_vlan_type_values,"Unknown",vtp_vlan->type), + EXTRACT_16BITS(&vtp_vlan->vlanid), + EXTRACT_16BITS(&vtp_vlan->mtu), + EXTRACT_32BITS(&vtp_vlan->index), + (tptr + VTP_VLAN_INFO_OFFSET)); + + /* + * Vlan names are aligned to 32-bit boundaries. + */ + len -= VTP_VLAN_INFO_OFFSET + 4*((vtp_vlan->name_len + 3)/4); + tptr += VTP_VLAN_INFO_OFFSET + 4*((vtp_vlan->name_len + 3)/4); + + /* TLV information follows */ + + while (len > 0) { + + /* + * Cisco specs says 2 bytes for type + 2 bytes for length, take only 1 + * See: http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/frames.htm + */ + type = *tptr; + tlv_len = *(tptr+1); + + printf("\n\t\t%s (0x%04x) TLV", + tok2str(vtp_vlan_tlv_values, "Unknown", type), + type); + + /* + * infinite loop check + */ + if (type == 0 || tlv_len == 0) { + return; + } + + if (!TTEST2(*tptr, tlv_len*2 +2)) + goto trunc; + + tlv_value = EXTRACT_16BITS(tptr+2); + + switch (type) { + case VTP_VLAN_STE_HOP_COUNT: + printf(", %u", tlv_value); + break; + + case VTP_VLAN_PRUNING: + printf(", %s (%u)", + tlv_value == 1 ? "Enabled" : "Disabled", + tlv_value); + break; + + case VTP_VLAN_STP_TYPE: + printf(", %s (%u)", + tok2str(vtp_stp_type_values, "Unknown", tlv_value), + tlv_value); + break; + + case VTP_VLAN_BRIDGE_TYPE: + printf(", %s (%u)", + tlv_value == 1 ? "SRB" : "SRT", + tlv_value); + break; + + case VTP_VLAN_BACKUP_CRF_MODE: + printf(", %s (%u)", + tlv_value == 1 ? "Backup" : "Not backup", + tlv_value); + break; + + /* + * FIXME those are the defined TLVs that lack a decoder + * you are welcome to contribute code ;-) + */ + + case VTP_VLAN_SOURCE_ROUTING_RING_NUMBER: + case VTP_VLAN_SOURCE_ROUTING_BRIDGE_NUMBER: + case VTP_VLAN_PARENT_VLAN: + case VTP_VLAN_TRANS_BRIDGED_VLAN: + case VTP_VLAN_ARP_HOP_COUNT: + default: + print_unknown_data(tptr, "\n\t\t ", 2 + tlv_len*2); + break; + } + len -= 2 + tlv_len*2; + tptr += 2 + tlv_len*2; + } + } + break; + + case VTP_ADV_REQUEST: + + /* + * ADVERTISEMENT REQUEST + * + * 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 | Code | Reserved | MmgtD Len | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Management Domain Name | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Start value | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * + */ + + printf("\n\tStart value: %u", EXTRACT_32BITS(tptr)); + break; + + case VTP_JOIN_MESSAGE: + + /* FIXME - Could not find message format */ + break; + + default: + break; + } + + return; + + trunc: + printf("[|vtp]"); +} + +/* + * Local Variables: + * c-style: whitesmith + * c-basic-offset: 4 + * End: + */ diff --git a/contrib/tcpdump/print-wb.c b/contrib/tcpdump/print-wb.c index e28697a6bb..3ae604ffed 100644 --- a/contrib/tcpdump/print-wb.c +++ b/contrib/tcpdump/print-wb.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-wb.c,v 1.33 2004/03/24 04:06:28 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-wb.c,v 1.33 2004-03-24 04:06:28 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/print-zephyr.c b/contrib/tcpdump/print-zephyr.c index 698faa2f5b..7c52e65406 100644 --- a/contrib/tcpdump/print-zephyr.c +++ b/contrib/tcpdump/print-zephyr.c @@ -22,7 +22,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-zephyr.c,v 1.8.2.1 2005/04/21 06:51:24 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-zephyr.c,v 1.10 2007-08-09 18:47:27 hannes Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -140,6 +140,15 @@ zephyr_print(const u_char *cp, int length) char *s; int lose = 0; + /* squelch compiler warnings */ + + z.kind = 0; + z.class = 0; + z.inst = 0; + z.opcode = 0; + z.sender = 0; + z.recipient = 0; + #define PARSE_STRING \ s = parse_field(&parse, &parselen); \ if (!s) lose = 1; diff --git a/contrib/tcpdump/route6d.h b/contrib/tcpdump/route6d.h index ee0033148c..53953fdb6d 100644 --- a/contrib/tcpdump/route6d.h +++ b/contrib/tcpdump/route6d.h @@ -27,7 +27,7 @@ * SUCH DAMAGE. */ /* - * $Header: /tcpdump/master/tcpdump/route6d.h,v 1.5 2002/12/11 07:14:10 guy Exp $ + * $Header: /tcpdump/master/tcpdump/route6d.h,v 1.5 2002-12-11 07:14:10 guy Exp $ */ #define RIP6_VERSION 1 diff --git a/contrib/tcpdump/rpc_auth.h b/contrib/tcpdump/rpc_auth.h index aed427ec16..fe9a40b262 100644 --- a/contrib/tcpdump/rpc_auth.h +++ b/contrib/tcpdump/rpc_auth.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/rpc_auth.h,v 1.1.2.1 2005/04/27 21:44:07 guy Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/rpc_auth.h,v 1.2 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 diff --git a/contrib/tcpdump/rpc_msg.h b/contrib/tcpdump/rpc_msg.h index 1ff3c42b70..3e79ac716b 100644 --- a/contrib/tcpdump/rpc_msg.h +++ b/contrib/tcpdump/rpc_msg.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/rpc_msg.h,v 1.1.2.1 2005/04/27 21:44:07 guy Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/rpc_msg.h,v 1.2 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 diff --git a/contrib/tcpdump/rx.h b/contrib/tcpdump/rx.h index 1912e51ae3..b79dd30cde 100644 --- a/contrib/tcpdump/rx.h +++ b/contrib/tcpdump/rx.h @@ -23,7 +23,7 @@ /* * Rx protocol format * - * $Id: rx.h,v 1.8 2002/12/11 07:14:11 guy Exp $ + * $Id: rx.h,v 1.8 2002-12-11 07:14:11 guy Exp $ */ #define FS_RX_PORT 7000 diff --git a/contrib/tcpdump/sctpConstants.h b/contrib/tcpdump/sctpConstants.h index f70226b624..ac28a151d0 100644 --- a/contrib/tcpdump/sctpConstants.h +++ b/contrib/tcpdump/sctpConstants.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/sctpConstants.h,v 1.4 2003/06/03 23:49:23 guy Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/sctpConstants.h,v 1.4 2003-06-03 23:49:23 guy Exp $ (LBL) */ /* SCTP reference Implementation Copyright (C) 1999 Cisco And Motorola * diff --git a/contrib/tcpdump/sctpHeader.h b/contrib/tcpdump/sctpHeader.h index 3b26094c1b..63f30b5d83 100644 --- a/contrib/tcpdump/sctpHeader.h +++ b/contrib/tcpdump/sctpHeader.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/sctpHeader.h,v 1.6 2002/12/11 07:14:11 guy Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/sctpHeader.h,v 1.6 2002-12-11 07:14:11 guy Exp $ (LBL) */ /* SCTP reference Implementation Copyright (C) 1999 Cisco And Motorola * diff --git a/contrib/tcpdump/setsignal.c b/contrib/tcpdump/setsignal.c index dbb8678182..a4b59cefe1 100644 --- a/contrib/tcpdump/setsignal.c +++ b/contrib/tcpdump/setsignal.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/setsignal.c,v 1.11 2003/11/16 09:36:42 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/setsignal.c,v 1.11 2003-11-16 09:36:42 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/setsignal.h b/contrib/tcpdump/setsignal.h index a7fb2a7481..cc8e86c242 100644 --- a/contrib/tcpdump/setsignal.h +++ b/contrib/tcpdump/setsignal.h @@ -18,7 +18,7 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * @(#) $Header: /tcpdump/master/tcpdump/setsignal.h,v 1.2.1.1 1999/10/07 23:47:13 mcr Exp $ (LBL) + * @(#) $Header: /tcpdump/master/tcpdump/setsignal.h,v 1.2.1.1 1999-10-07 23:47:13 mcr Exp $ (LBL) */ #ifndef setsignal_h #define setsignal_h diff --git a/contrib/tcpdump/slcompress.h b/contrib/tcpdump/slcompress.h index d8a596cf52..d10243a9fd 100644 --- a/contrib/tcpdump/slcompress.h +++ b/contrib/tcpdump/slcompress.h @@ -1,7 +1,7 @@ /* * Definitions for tcp compression routines. * - * @(#) $Header: /tcpdump/master/tcpdump/slcompress.h,v 1.2 2000/10/09 02:03:44 guy Exp $ (LBL) + * @(#) $Header: /tcpdump/master/tcpdump/slcompress.h,v 1.2 2000-10-09 02:03:44 guy Exp $ (LBL) * * Copyright (c) 1989, 1990, 1992, 1993 Regents of the University of * California. All rights reserved. diff --git a/contrib/tcpdump/slip.h b/contrib/tcpdump/slip.h index e64f3015ac..aa6402c3b1 100644 --- a/contrib/tcpdump/slip.h +++ b/contrib/tcpdump/slip.h @@ -2,7 +2,7 @@ * Definitions that user level programs might need to know to interact * with serial line IP (slip) lines. * - * @(#) $Header: /tcpdump/master/tcpdump/slip.h,v 1.1 2000/10/09 01:53:21 guy Exp $ + * @(#) $Header: /tcpdump/master/tcpdump/slip.h,v 1.1 2000-10-09 01:53:21 guy Exp $ * * Copyright (c) 1990 Regents of the University of California. * All rights reserved. diff --git a/contrib/tcpdump/sll.h b/contrib/tcpdump/sll.h index 693f05efa4..bad31e27a4 100644 --- a/contrib/tcpdump/sll.h +++ b/contrib/tcpdump/sll.h @@ -35,7 +35,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#) $Header: /tcpdump/master/tcpdump/sll.h,v 1.7 2002/12/11 07:14:11 guy Exp $ (LBL) + * @(#) $Header: /tcpdump/master/tcpdump/sll.h,v 1.7.6.1 2008-05-30 01:38:21 guy Exp $ (LBL) */ /* @@ -64,8 +64,8 @@ * DO NOT change the layout of this structure, or change any of the * LINUX_SLL_ values below. If you must change the link-layer header * for a "cooked" Linux capture, introduce a new DLT_ type (ask - * "tcpdump-workers@tcpdump.org" for one, so that you don't give it a - * value that collides with a value already being used), and use the + * "tcpdump-workers@lists.tcpdump.org" for one, so that you don't give it + * a value that collides with a value already being used), and use the * new header in captures of that type, so that programs that can * handle DLT_LINUX_SLL captures will continue to handle them correctly * without any change, and so that capture files with different headers diff --git a/contrib/tcpdump/smb.h b/contrib/tcpdump/smb.h index bb05227f1d..8eeb303f91 100644 --- a/contrib/tcpdump/smb.h +++ b/contrib/tcpdump/smb.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/smb.h,v 1.9 2004/12/28 22:29:44 guy Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/smb.h,v 1.9 2004-12-28 22:29:44 guy Exp $ (LBL) */ /* * Copyright (C) Andrew Tridgell 1995-1999 * diff --git a/contrib/tcpdump/smbutil.c b/contrib/tcpdump/smbutil.c index 86bcb4c93c..ba7ec31a98 100644 --- a/contrib/tcpdump/smbutil.c +++ b/contrib/tcpdump/smbutil.c @@ -12,7 +12,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/smbutil.c,v 1.36.2.3 2007/07/15 19:08:25 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/smbutil.c,v 1.39 2007-07-15 19:07:39 guy Exp $"; #endif #include diff --git a/contrib/tcpdump/strcasecmp.c b/contrib/tcpdump/strcasecmp.c index aa6d007421..f19ccf547d 100644 --- a/contrib/tcpdump/strcasecmp.c +++ b/contrib/tcpdump/strcasecmp.c @@ -16,7 +16,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/strcasecmp.c,v 1.6 2003/11/16 09:36:43 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/strcasecmp.c,v 1.6 2003-11-16 09:36:43 guy Exp $"; #endif #include diff --git a/contrib/tcpdump/tcp.h b/contrib/tcpdump/tcp.h index 5934cd632e..db7dd44775 100644 --- a/contrib/tcpdump/tcp.h +++ b/contrib/tcpdump/tcp.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/tcp.h,v 1.11.2.1 2005/11/29 09:09:26 hannes Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/tcp.h,v 1.13.2.1 2007-12-09 00:31:35 guy Exp $ (LBL) */ /* * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. @@ -45,21 +45,25 @@ struct tcphdr { tcp_seq th_seq; /* sequence number */ tcp_seq th_ack; /* acknowledgement number */ u_int8_t th_offx2; /* data offset, rsvd */ -#define TH_OFF(th) (((th)->th_offx2 & 0xf0) >> 4) u_int8_t th_flags; -#define TH_FIN 0x01 -#define TH_SYN 0x02 -#define TH_RST 0x04 -#define TH_PUSH 0x08 -#define TH_ACK 0x10 -#define TH_URG 0x20 -#define TH_ECNECHO 0x40 /* ECN Echo */ -#define TH_CWR 0x80 /* ECN Cwnd Reduced */ u_int16_t th_win; /* window */ u_int16_t th_sum; /* checksum */ u_int16_t th_urp; /* urgent pointer */ }; +#define TH_OFF(th) (((th)->th_offx2 & 0xf0) >> 4) + +/* TCP flags */ +#define TH_FIN 0x01 +#define TH_SYN 0x02 +#define TH_RST 0x04 +#define TH_PUSH 0x08 +#define TH_ACK 0x10 +#define TH_URG 0x20 +#define TH_ECNECHO 0x40 /* ECN Echo */ +#define TH_CWR 0x80 /* ECN Cwnd Reduced */ + + #define TCPOPT_EOL 0 #define TCPOPT_NOP 1 #define TCPOPT_MAXSEG 2 @@ -82,3 +86,23 @@ struct tcphdr { #define TCPOPT_TSTAMP_HDR \ (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP) + +#ifndef TELNET_PORT +#define TELNET_PORT 23 +#endif +#ifndef BGP_PORT +#define BGP_PORT 179 +#endif +#define NETBIOS_SSN_PORT 139 +#ifndef PPTP_PORT +#define PPTP_PORT 1723 +#endif +#define BEEP_PORT 10288 +#ifndef NFS_PORT +#define NFS_PORT 2049 +#endif +#define MSDP_PORT 639 +#define LDP_PORT 646 +#ifndef SMB_PORT +#define SMB_PORT 445 +#endif diff --git a/contrib/tcpdump/tcpdump-stdinc.h b/contrib/tcpdump/tcpdump-stdinc.h index cd04d09df9..30d42fcd50 100644 --- a/contrib/tcpdump/tcpdump-stdinc.h +++ b/contrib/tcpdump/tcpdump-stdinc.h @@ -29,7 +29,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * - * @(#) $Header: /tcpdump/master/tcpdump/tcpdump-stdinc.h,v 1.12.2.5 2006/06/23 02:07:27 hannes Exp $ (LBL) + * @(#) $Header: /tcpdump/master/tcpdump/tcpdump-stdinc.h,v 1.17 2006-05-19 17:55:34 hannes Exp $ (LBL) */ /* diff --git a/contrib/tcpdump/tcpdump.1 b/contrib/tcpdump/tcpdump.1 index d13b4de6f9..50efc31c56 100644 --- a/contrib/tcpdump/tcpdump.1 +++ b/contrib/tcpdump/tcpdump.1 @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/tcpdump/tcpdump.1,v 1.167.2.11 2007/06/15 20:13:49 guy Exp $ (LBL) +.\" @(#) $Header: /tcpdump/master/tcpdump/tcpdump.1,v 1.185.2.6 2008-05-30 01:38:21 guy Exp $ (LBL) .\" .\" $NetBSD: tcpdump.8,v 1.9 2003/03/31 00:18:17 perry Exp $ .\" @@ -22,14 +22,17 @@ .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" -.TH TCPDUMP 1 "18 April 2005" +.TH TCPDUMP 1 "07 January 2008" .SH NAME tcpdump \- dump traffic on a network .SH SYNOPSIS .na .B tcpdump [ -.B \-AdDeflLnNOpqRStuUvxX +.B \-AdDefIKlLnNOpqRStuUvxX +] [ +.B \-B +.I buffer_size ] [ .B \-c .I count @@ -40,6 +43,9 @@ tcpdump \- dump traffic on a network .B \-C .I file_size ] [ +.B \-G +.I rotate_seconds +] [ .B \-F .I file ] @@ -94,6 +100,10 @@ tcpdump \- dump traffic on a network .I datalinktype ] [ +.B \-z +.I postrotate-command +] +[ .B \-Z .I user ] @@ -171,87 +181,19 @@ default, so you must set it with in order to use it) and will continue capturing packets. .LP Reading packets from a network interface may require that you have -special privileges: -.TP -.B Under SunOS 3.x or 4.x with NIT or BPF: -You must have read access to -.I /dev/nit -or -.IR /dev/bpf* . -.TP -.B Under Solaris with DLPI: -You must have read/write access to the network pseudo device, e.g. -.IR /dev/le . -On at least some versions of Solaris, however, this is not sufficient to -allow -.I tcpdump -to capture in promiscuous mode; on those versions of Solaris, you must -be root, or -.I tcpdump -must be installed setuid to root, in order to capture in promiscuous -mode. Note that, on many (perhaps all) interfaces, if you don't capture -in promiscuous mode, you will not see any outgoing packets, so a capture -not done in promiscuous mode may not be very useful. -.TP -.B Under HP-UX with DLPI: -You must be root or -.I tcpdump -must be installed setuid to root. -.TP -.B Under IRIX with snoop: -You must be root or -.I tcpdump -must be installed setuid to root. -.TP -.B Under Linux: -You must be root or -.I tcpdump -must be installed setuid to root (unless your distribution has a kernel -that supports capability bits such as CAP_NET_RAW and code to allow -those capability bits to be given to particular accounts and to cause -those bits to be set on a user's initial processes when they log in, in -which case you must have CAP_NET_RAW in order to capture and -CAP_NET_ADMIN to enumerate network devices with, for example, the -.B \-D -flag). -.TP -.B Under ULTRIX and Digital UNIX/Tru64 UNIX: -Any user may capture network traffic with -.IR tcpdump . -However, no user (not even the super-user) can capture in promiscuous -mode on an interface unless the super-user has enabled promiscuous-mode -operation on that interface using -.IR pfconfig (8), -and no user (not even the super-user) can capture unicast traffic -received by or sent by the machine on an interface unless the super-user -has enabled copy-all-mode operation on that interface using -.IR pfconfig , -so -.I useful -packet capture on an interface probably requires that either -promiscuous-mode or copy-all-mode operation, or both modes of -operation, be enabled on that interface. -.TP -.B Under BSD (this includes Mac OS X): -You must have read access to -.I /dev/bpf* -on systems that don't have a cloning BPF device, or to -.I /dev/bpf -on systems that do. -On BSDs with a devfs (this includes Mac OS X), this might involve more -than just having somebody with super-user access setting the ownership -or permissions on the BPF devices - it might involve configuring devfs -to set the ownership or permissions every time the system is booted, -if the system even supports that; if it doesn't support that, you might -have to find some other way to make that happen at boot time. -.LP -Reading a saved packet file doesn't require special privileges. +special privileges; see the +.B pcap (3PCAP) +man page for details. Reading a saved packet file doesn't require +special privileges. .SH OPTIONS .TP .B \-A Print each packet (minus its link level header) in ASCII. Handy for capturing web pages. .TP +.B \-B +Set the operating system capture buffer size to \fIbuffer_size\fP. +.TP .B \-c Exit after receiving \fIcount\fP packets. .TP @@ -359,6 +301,20 @@ correctly. Use \fIfile\fP as input for the filter expression. An additional expression given on the command line is ignored. .TP +.B \-G +If specified, rotates the dump file specified with the +.B \-w +option every \fIrotate_seconds\fP seconds. +Savefiles will have the name specified by +.B \-w +which should include a time format as defined by +.BR strftime (3). +If no time format is specified, each new file will overwrite the previous. +.IP +If used in conjunction with the +.B \-C +option, filenames will take the form of `\fIfile\fP'. +.TP .B \-i Listen on \fIinterface\fP. If unspecified, \fItcpdump\fP searches the system interface list for the @@ -378,6 +334,22 @@ used as the .I interface argument. .TP +.B \-I +Put the interface in "monitor mode"; this is supported only on IEEE +802.11 Wi-Fi interfaces, and supported only on some operating systems. +.IP +Note that in monitor mode the adapter might disassociate from the +network with which it's associated, so that you will not be able to use +any wireless networks with that adapter. This could prevent accessing +files on a network server, or resolving host names or network addresses, +if you are capturing in monitor mode and are not connected to another +network with another adapter. +.TP +.B \-K +Don't attempt to verify TCP checksums. This is useful for interfaces +that perform the TCP checksum calculation in hardware; otherwise, +all outgoing TCP checksums will be flagged as bad. +.TP .B \-l Make stdout line buffered. Useful if you want to see the data @@ -481,12 +453,16 @@ and Print an unformatted timestamp on each dump line. .TP .B \-ttt -Print a delta (in micro-seconds) between current and previous line +Print a delta (micro-second resolution) between current and previous line on each dump line. .TP .B \-tttt Print a timestamp in default format proceeded by date on each dump line. .TP +.B \-ttttt +Print a delta (micro-second resolution) between current and first line +on each dump line. +.TP .B \-u Print undecoded NFS handles. .TP @@ -547,6 +523,13 @@ from the beginning, thus creating a 'rotating' buffer. In addition, it will name the files with enough leading 0s to support the maximum number of files, allowing them to sort correctly. +.IP +Used in conjunction with the +.B \-G +option, this will limit the number of rotated dump files that get +created, exiting with status 0 when reaching the limit. If used with +.B \-C +as well, the behavior will result in cyclical files per timeslice. .TP .B \-x When parsing and printing, @@ -582,6 +565,31 @@ its link level header, in hex and ASCII. .B \-y Set the data link type to use while capturing packets to \fIdatalinktype\fP. .TP +.B \-z +Used in conjunction with the +.B -C +or +.B -G +options, this will make +.I tcpdump +run " +.I command file +" where +.I file +is the savefile being closed after each rotation. For example, specifying +.B \-z gzip +or +.B \-z bzip2 +will compress each savefile using gzip or bzip2. +.IP +Note that tcpdump will run the command in parallel to the capture, using +the lowest priority so that this doesn't disturb the capture process. +.IP +And in case you would like to use a command that itself takes flags or +different arguments, you can always write a shell script that will take the +savefile name as the only argument, make the flags & arguments arrangements +and execute the command that you want. +.TP .B \-Z Drops privileges (if root) and changes user ID to .I user @@ -597,678 +605,8 @@ is given, all packets on the net will be dumped. Otherwise, only packets for which \fIexpression\fP is `true' will be dumped. .LP -The \fIexpression\fP consists of one or more -.I primitives. -Primitives usually consist of an -.I id -(name or number) preceded by one or more qualifiers. -There are three -different kinds of qualifier: -.IP \fItype\fP -qualifiers say what kind of thing the id name or number refers to. -Possible types are -.BR host , -.B net , -.B port -and -.BR portrange . -E.g., `host foo', `net 128.3', `port 20', `portrange 6000-6008'. -If there is no type -qualifier, -.B host -is assumed. -.IP \fIdir\fP -qualifiers specify a particular transfer direction to and/or from -.IR id . -Possible directions are -.BR src , -.BR dst , -.B "src or dst" -and -.B "src and" -.BR dst . -E.g., `src foo', `dst net 128.3', `src or dst port ftp-data'. -If -there is no dir qualifier, -.B "src or dst" -is assumed. -For some link layers, such as SLIP and the ``cooked'' Linux capture mode -used for the ``any'' device and for some other device types, the -.B inbound -and -.B outbound -qualifiers can be used to specify a desired direction. -.IP \fIproto\fP -qualifiers restrict the match to a particular protocol. -Possible -protos are: -.BR ether , -.BR fddi , -.BR tr , -.BR wlan , -.BR ip , -.BR ip6 , -.BR arp , -.BR rarp , -.BR decnet , -.B tcp -and -.BR udp . -E.g., `ether src foo', `arp net 128.3', `tcp port 21', `udp portrange -7000-7009'. -If there is -no proto qualifier, all protocols consistent with the type are -assumed. -E.g., `src foo' means `(ip or arp or rarp) src foo' -(except the latter is not legal syntax), `net bar' means `(ip or -arp or rarp) net bar' and `port 53' means `(tcp or udp) port 53'. -.LP -[`fddi' is actually an alias for `ether'; the parser treats them -identically as meaning ``the data link level used on the specified -network interface.'' FDDI headers contain Ethernet-like source -and destination addresses, and often contain Ethernet-like packet -types, so you can filter on these FDDI fields just as with the -analogous Ethernet fields. -FDDI headers also contain other fields, -but you cannot name them explicitly in a filter expression. -.LP -Similarly, `tr' and `wlan' are aliases for `ether'; the previous -paragraph's statements about FDDI headers also apply to Token Ring -and 802.11 wireless LAN headers. For 802.11 headers, the destination -address is the DA field and the source address is the SA field; the -BSSID, RA, and TA fields aren't tested.] -.LP -In addition to the above, there are some special `primitive' keywords -that don't follow the pattern: -.BR gateway , -.BR broadcast , -.BR less , -.B greater -and arithmetic expressions. -All of these are described below. -.LP -More complex filter expressions are built up by using the words -.BR and , -.B or -and -.B not -to combine primitives. -E.g., `host foo and not port ftp and not port ftp-data'. -To save typing, identical qualifier lists can be omitted. -E.g., -`tcp dst port ftp or ftp-data or domain' is exactly the same as -`tcp dst port ftp or tcp dst port ftp-data or tcp dst port domain'. -.LP -Allowable primitives are: -.IP "\fBdst host \fIhost\fR" -True if the IPv4/v6 destination field of the packet is \fIhost\fP, -which may be either an address or a name. -.IP "\fBsrc host \fIhost\fR" -True if the IPv4/v6 source field of the packet is \fIhost\fP. -.IP "\fBhost \fIhost\fP -True if either the IPv4/v6 source or destination of the packet is \fIhost\fP. -.IP -Any of the above host expressions can be prepended with the keywords, -\fBip\fP, \fBarp\fP, \fBrarp\fP, or \fBip6\fP as in: -.in +.5i -.nf -\fBip host \fIhost\fR -.fi -.in -.5i -which is equivalent to: -.in +.5i -.nf -\fBether proto \fI\\ip\fB and host \fIhost\fR -.fi -.in -.5i -If \fIhost\fR is a name with multiple IP addresses, each address will -be checked for a match. -.IP "\fBether dst \fIehost\fP -True if the Ethernet destination address is \fIehost\fP. -\fIEhost\fP -may be either a name from /etc/ethers or a number (see -.IR ethers (3N) -for numeric format). -.IP "\fBether src \fIehost\fP -True if the Ethernet source address is \fIehost\fP. -.IP "\fBether host \fIehost\fP -True if either the Ethernet source or destination address is \fIehost\fP. -.IP "\fBgateway\fP \fIhost\fP -True if the packet used \fIhost\fP as a gateway. -I.e., the Ethernet -source or destination address was \fIhost\fP but neither the IP source -nor the IP destination was \fIhost\fP. -\fIHost\fP must be a name and -must be found both by the machine's host-name-to-IP-address resolution -mechanisms (host name file, DNS, NIS, etc.) and by the machine's -host-name-to-Ethernet-address resolution mechanism (/etc/ethers, etc.). -(An equivalent expression is -.in +.5i -.nf -\fBether host \fIehost \fBand not host \fIhost\fR -.fi -.in -.5i -which can be used with either names or numbers for \fIhost / ehost\fP.) -This syntax does not work in IPv6-enabled configuration at this moment. -.IP "\fBdst net \fInet\fR" -True if the IPv4/v6 destination address of the packet has a network -number of \fInet\fP. -\fINet\fP may be either a name from the networks database -(/etc/networks, etc.) or a network number. -An IPv4 network number can be written as a dotted quad (e.g., 192.168.1.0), -dotted triple (e.g., 192.168.1), dotted pair (e.g, 172.16), or single -number (e.g., 10); the netmask is 255.255.255.255 for a dotted quad -(which means that it's really a host match), 255.255.255.0 for a dotted -triple, 255.255.0.0 for a dotted pair, or 255.0.0.0 for a single number. -An IPv6 network number must be written out fully; the netmask is -ff:ff:ff:ff:ff:ff:ff:ff, so IPv6 "network" matches are really always -host matches, and a network match requires a netmask length. -.IP "\fBsrc net \fInet\fR" -True if the IPv4/v6 source address of the packet has a network -number of \fInet\fP. -.IP "\fBnet \fInet\fR" -True if either the IPv4/v6 source or destination address of the packet has a network -number of \fInet\fP. -.IP "\fBnet \fInet\fR \fBmask \fInetmask\fR" -True if the IPv4 address matches \fInet\fR with the specific \fInetmask\fR. -May be qualified with \fBsrc\fR or \fBdst\fR. -Note that this syntax is not valid for IPv6 \fInet\fR. -.IP "\fBnet \fInet\fR/\fIlen\fR" -True if the IPv4/v6 address matches \fInet\fR with a netmask \fIlen\fR -bits wide. -May be qualified with \fBsrc\fR or \fBdst\fR. -.IP "\fBdst port \fIport\fR" -True if the packet is ip/tcp, ip/udp, ip6/tcp or ip6/udp and has a -destination port value of \fIport\fP. -The \fIport\fP can be a number or a name used in /etc/services (see -.IR tcp (4P) -and -.IR udp (4P)). -If a name is used, both the port -number and protocol are checked. -If a number or ambiguous name is used, -only the port number is checked (e.g., \fBdst port 513\fR will print both -tcp/login traffic and udp/who traffic, and \fBport domain\fR will print -both tcp/domain and udp/domain traffic). -.IP "\fBsrc port \fIport\fR" -True if the packet has a source port value of \fIport\fP. -.IP "\fBport \fIport\fR" -True if either the source or destination port of the packet is \fIport\fP. -.IP "\fBdst portrange \fIport1\fB-\fIport2\fR" -True if the packet is ip/tcp, ip/udp, ip6/tcp or ip6/udp and has a -destination port value between \fIport1\fP and \fIport2\fP. -.I port1 -and -.I port2 -are interpreted in the same fashion as the -.I port -parameter for -.BR port . -.IP "\fBsrc portrange \fIport1\fB-\fIport2\fR" -True if the packet has a source port value between \fIport1\fP and -\fIport2\fP. -.IP "\fBportrange \fIport1\fB-\fIport2\fR" -True if either the source or destination port of the packet is between -\fIport1\fP and \fIport2\fP. -.IP -Any of the above port or port range expressions can be prepended with -the keywords, \fBtcp\fP or \fBudp\fP, as in: -.in +.5i -.nf -\fBtcp src port \fIport\fR -.fi -.in -.5i -which matches only tcp packets whose source port is \fIport\fP. -.IP "\fBless \fIlength\fR" -True if the packet has a length less than or equal to \fIlength\fP. -This is equivalent to: -.in +.5i -.nf -\fBlen <= \fIlength\fP. -.fi -.in -.5i -.IP "\fBgreater \fIlength\fR" -True if the packet has a length greater than or equal to \fIlength\fP. -This is equivalent to: -.in +.5i -.nf -\fBlen >= \fIlength\fP. -.fi -.in -.5i -.IP "\fBip proto \fIprotocol\fR" -True if the packet is an IPv4 packet (see -.IR ip (4P)) -of protocol type \fIprotocol\fP. -\fIProtocol\fP can be a number or one of the names -\fBicmp\fP, \fBicmp6\fP, \fBigmp\fP, \fBigrp\fP, \fBpim\fP, \fBah\fP, -\fBesp\fP, \fBvrrp\fP, \fBudp\fP, or \fBtcp\fP. -Note that the identifiers \fBtcp\fP, \fBudp\fP, and \fBicmp\fP are also -keywords and must be escaped via backslash (\\), which is \\\\ in the C-shell. -Note that this primitive does not chase the protocol header chain. -.IP "\fBip6 proto \fIprotocol\fR" -True if the packet is an IPv6 packet of protocol type \fIprotocol\fP. -Note that this primitive does not chase the protocol header chain. -.IP "\fBip6 protochain \fIprotocol\fR" -True if the packet is IPv6 packet, -and contains protocol header with type \fIprotocol\fR -in its protocol header chain. -For example, -.in +.5i -.nf -\fBip6 protochain 6\fR -.fi -.in -.5i -matches any IPv6 packet with TCP protocol header in the protocol header chain. -The packet may contain, for example, -authentication header, routing header, or hop-by-hop option header, -between IPv6 header and TCP header. -The BPF code emitted by this primitive is complex and -cannot be optimized by BPF optimizer code in \fItcpdump\fP, -so this can be somewhat slow. -.IP "\fBip protochain \fIprotocol\fR" -Equivalent to \fBip6 protochain \fIprotocol\fR, but this is for IPv4. -.IP "\fBether broadcast\fR" -True if the packet is an Ethernet broadcast packet. -The \fIether\fP -keyword is optional. -.IP "\fBip broadcast\fR" -True if the packet is an IPv4 broadcast packet. -It checks for both the all-zeroes and all-ones broadcast conventions, -and looks up the subnet mask on the interface on which the capture is -being done. -.IP -If the subnet mask of the interface on which the capture is being done -is not available, either because the interface on which capture is being -done has no netmask or because the capture is being done on the Linux -"any" interface, which can capture on more than one interface, this -check will not work correctly. -.IP "\fBether multicast\fR" -True if the packet is an Ethernet multicast packet. -The \fBether\fP -keyword is optional. -This is shorthand for `\fBether[0] & 1 != 0\fP'. -.IP "\fBip multicast\fR" -True if the packet is an IPv4 multicast packet. -.IP "\fBip6 multicast\fR" -True if the packet is an IPv6 multicast packet. -.IP "\fBether proto \fIprotocol\fR" -True if the packet is of ether type \fIprotocol\fR. -\fIProtocol\fP can be a number or one of the names -\fBip\fP, \fBip6\fP, \fBarp\fP, \fBrarp\fP, \fBatalk\fP, \fBaarp\fP, -\fBdecnet\fP, \fBsca\fP, \fBlat\fP, \fBmopdl\fP, \fBmoprc\fP, -\fBiso\fP, \fBstp\fP, \fBipx\fP, or \fBnetbeui\fP. -Note these identifiers are also keywords -and must be escaped via backslash (\\). -.IP -[In the case of FDDI (e.g., `\fBfddi protocol arp\fR'), Token Ring -(e.g., `\fBtr protocol arp\fR'), and IEEE 802.11 wireless LANS (e.g., -`\fBwlan protocol arp\fR'), for most of those protocols, the -protocol identification comes from the 802.2 Logical Link Control (LLC) -header, which is usually layered on top of the FDDI, Token Ring, or -802.11 header. -.IP -When filtering for most protocol identifiers on FDDI, Token Ring, or -802.11, \fItcpdump\fR checks only the protocol ID field of an LLC header -in so-called SNAP format with an Organizational Unit Identifier (OUI) of -0x000000, for encapsulated Ethernet; it doesn't check whether the packet -is in SNAP format with an OUI of 0x000000. -The exceptions are: -.RS -.TP -\fBiso\fP -\fItcpdump\fR checks the DSAP (Destination Service Access Point) and -SSAP (Source Service Access Point) fields of the LLC header; -.TP -\fBstp\fP and \fBnetbeui\fP -\fItcpdump\fR checks the DSAP of the LLC header; -.TP -\fBatalk\fP -\fItcpdump\fR checks for a SNAP-format packet with an OUI of 0x080007 -and the AppleTalk etype. -.RE -.IP -In the case of Ethernet, \fItcpdump\fR checks the Ethernet type field -for most of those protocols. The exceptions are: -.RS -.TP -\fBiso\fP, \fBstp\fP, and \fBnetbeui\fP -\fItcpdump\fR checks for an 802.3 frame and then checks the LLC header as -it does for FDDI, Token Ring, and 802.11; -.TP -\fBatalk\fP -\fItcpdump\fR checks both for the AppleTalk etype in an Ethernet frame and -for a SNAP-format packet as it does for FDDI, Token Ring, and 802.11; -.TP -\fBaarp\fP -\fItcpdump\fR checks for the AppleTalk ARP etype in either an Ethernet -frame or an 802.2 SNAP frame with an OUI of 0x000000; -.TP -\fBipx\fP -\fItcpdump\fR checks for the IPX etype in an Ethernet frame, the IPX -DSAP in the LLC header, the 802.3-with-no-LLC-header encapsulation of -IPX, and the IPX etype in a SNAP frame. -.RE -.IP "\fBdecnet src \fIhost\fR" -True if the DECNET source address is -.IR host , -which may be an address of the form ``10.123'', or a DECNET host -name. -[DECNET host name support is only available on ULTRIX systems -that are configured to run DECNET.] -.IP "\fBdecnet dst \fIhost\fR" -True if the DECNET destination address is -.IR host . -.IP "\fBdecnet host \fIhost\fR" -True if either the DECNET source or destination address is -.IR host . -.IP "\fBifname \fIinterface\fR" -True if the packet was logged as coming from the specified interface (applies -only to packets logged by OpenBSD's -.BR pf (4)). -.IP "\fBon \fIinterface\fR" -Synonymous with the -.B ifname -modifier. -.IP "\fBrnr \fInum\fR" -True if the packet was logged as matching the specified PF rule number -(applies only to packets logged by OpenBSD's -.BR pf (4)). -.IP "\fBrulenum \fInum\fR" -Synonomous with the -.B rnr -modifier. -.IP "\fBreason \fIcode\fR" -True if the packet was logged with the specified PF reason code. The known -codes are: -.BR match , -.BR bad-offset , -.BR fragment , -.BR short , -.BR normalize , -and -.B memory -(applies only to packets logged by OpenBSD's -.BR pf (4)). -.IP "\fBrset \fIname\fR" -True if the packet was logged as matching the specified PF ruleset -name of an anchored ruleset (applies only to packets logged by -.BR pf (4)). -.IP "\fBruleset \fIname\fR" -Synonomous with the -.B rset -modifier. -.IP "\fBsrnr \fInum\fR" -True if the packet was logged as matching the specified PF rule number -of an anchored ruleset (applies only to packets logged by -.BR pf (4)). -.IP "\fBsubrulenum \fInum\fR" -Synonomous with the -.B srnr -modifier. -.IP "\fBaction \fIact\fR" -True if PF took the specified action when the packet was logged. Known actions -are: -.B pass -and -.B block -(applies only to packets logged by OpenBSD's -.BR pf (4)). -.IP "\fBip\fR, \fBip6\fR, \fBarp\fR, \fBrarp\fR, \fBatalk\fR, \fBaarp\fR, \fBdecnet\fR, \fBiso\fR, \fBstp\fR, \fBipx\fR, \fInetbeui\fP" -Abbreviations for: -.in +.5i -.nf -\fBether proto \fIp\fR -.fi -.in -.5i -where \fIp\fR is one of the above protocols. -.IP "\fBlat\fR, \fBmoprc\fR, \fBmopdl\fR" -Abbreviations for: -.in +.5i -.nf -\fBether proto \fIp\fR -.fi -.in -.5i -where \fIp\fR is one of the above protocols. -Note that -\fItcpdump\fP does not currently know how to parse these protocols. -.IP "\fBvlan \fI[vlan_id]\fR" -True if the packet is an IEEE 802.1Q VLAN packet. -If \fI[vlan_id]\fR is specified, only true if the packet has the specified -\fIvlan_id\fR. -Note that the first \fBvlan\fR keyword encountered in \fIexpression\fR -changes the decoding offsets for the remainder of \fIexpression\fR on -the assumption that the packet is a VLAN packet. The \fBvlan -\fI[vlan_id]\fR expression may be used more than once, to filter on VLAN -hierarchies. Each use of that expression increments the filter offsets -by 4. -.IP -For example: -.in +.5i -.nf -\fBvlan 100 && vlan 200\fR -.fi -.in -.5i -filters on VLAN 200 encapsulated within VLAN 100, and -.in +.5i -.nf -\fBvlan && vlan 300 && ip\fR -.fi -.in -.5i -filters IPv4 protocols encapsulated in VLAN 300 encapsulated within any -higher order VLAN. -.IP "\fBmpls \fI[label_num]\fR" -True if the packet is an MPLS packet. -If \fI[label_num]\fR is specified, only true is the packet has the specified -\fIlabel_num\fR. -Note that the first \fBmpls\fR keyword encountered in \fIexpression\fR -changes the decoding offsets for the remainder of \fIexpression\fR on -the assumption that the packet is a MPLS-encapsulated IP packet. The -\fBmpls \fI[label_num]\fR expression may be used more than once, to -filter on MPLS hierarchies. Each use of that expression increments the -filter offsets by 4. -.IP -For example: -.in +.5i -.nf -\fBmpls 100000 && mpls 1024\fR -.fi -.in -.5i -filters packets with an outer label of 100000 and an inner label of -1024, and -.in +.5i -.nf -\fBmpls && mpls 1024 && host 192.9.200.1\fR -.fi -.in -.5i -filters packets to or from 192.9.200.1 with an inner label of 1024 and -any outer label. -.IP \fBpppoed\fP -True if the packet is a PPP-over-Ethernet Discovery packet (Ethernet -type 0x8863). -.IP \fBpppoes\fP -True if the packet is a PPP-over-Ethernet Session packet (Ethernet -type 0x8864). -Note that the first \fBpppoes\fR keyword encountered in \fIexpression\fR -changes the decoding offsets for the remainder of \fIexpression\fR on -the assumption that the packet is a PPPoE session packet. -.IP -For example: -.in +.5i -.nf -\fBpppoes && ip\fR -.fi -.in -.5i -filters IPv4 protocols encapsulated in PPPoE. -.IP "\fBtcp\fR, \fBudp\fR, \fBicmp\fR" -Abbreviations for: -.in +.5i -.nf -\fBip proto \fIp\fR\fB or ip6 proto \fIp\fR -.fi -.in -.5i -where \fIp\fR is one of the above protocols. -.IP "\fBiso proto \fIprotocol\fR" -True if the packet is an OSI packet of protocol type \fIprotocol\fP. -\fIProtocol\fP can be a number or one of the names -\fBclnp\fP, \fBesis\fP, or \fBisis\fP. -.IP "\fBclnp\fR, \fBesis\fR, \fBisis\fR" -Abbreviations for: -.in +.5i -.nf -\fBiso proto \fIp\fR -.fi -.in -.5i -where \fIp\fR is one of the above protocols. -.IP "\fBl1\fR, \fBl2\fR, \fBiih\fR, \fBlsp\fR, \fBsnp\fR, \fBcsnp\fR, \fBpsnp\fR" -Abbreviations for IS-IS PDU types. -.IP "\fBvpi\fP \fIn\fR -True if the packet is an ATM packet, for SunATM on Solaris, with a -virtual path identifier of -.IR n . -.IP "\fBvci\fP \fIn\fR -True if the packet is an ATM packet, for SunATM on Solaris, with a -virtual channel identifier of -.IR n . -.IP \fBlane\fP -True if the packet is an ATM packet, for SunATM on Solaris, and is -an ATM LANE packet. -Note that the first \fBlane\fR keyword encountered in \fIexpression\fR -changes the tests done in the remainder of \fIexpression\fR -on the assumption that the packet is either a LANE emulated Ethernet -packet or a LANE LE Control packet. If \fBlane\fR isn't specified, the -tests are done under the assumption that the packet is an -LLC-encapsulated packet. -.IP \fBllc\fP -True if the packet is an ATM packet, for SunATM on Solaris, and is -an LLC-encapsulated packet. -.IP \fBoamf4s\fP -True if the packet is an ATM packet, for SunATM on Solaris, and is -a segment OAM F4 flow cell (VPI=0 & VCI=3). -.IP \fBoamf4e\fP -True if the packet is an ATM packet, for SunATM on Solaris, and is -an end-to-end OAM F4 flow cell (VPI=0 & VCI=4). -.IP \fBoamf4\fP -True if the packet is an ATM packet, for SunATM on Solaris, and is -a segment or end-to-end OAM F4 flow cell (VPI=0 & (VCI=3 | VCI=4)). -.IP \fBoam\fP -True if the packet is an ATM packet, for SunATM on Solaris, and is -a segment or end-to-end OAM F4 flow cell (VPI=0 & (VCI=3 | VCI=4)). -.IP \fBmetac\fP -True if the packet is an ATM packet, for SunATM on Solaris, and is -on a meta signaling circuit (VPI=0 & VCI=1). -.IP \fBbcc\fP -True if the packet is an ATM packet, for SunATM on Solaris, and is -on a broadcast signaling circuit (VPI=0 & VCI=2). -.IP \fBsc\fP -True if the packet is an ATM packet, for SunATM on Solaris, and is -on a signaling circuit (VPI=0 & VCI=5). -.IP \fBilmic\fP -True if the packet is an ATM packet, for SunATM on Solaris, and is -on an ILMI circuit (VPI=0 & VCI=16). -.IP \fBconnectmsg\fP -True if the packet is an ATM packet, for SunATM on Solaris, and is -on a signaling circuit and is a Q.2931 Setup, Call Proceeding, Connect, -Connect Ack, Release, or Release Done message. -.IP \fBmetaconnect\fP -True if the packet is an ATM packet, for SunATM on Solaris, and is -on a meta signaling circuit and is a Q.2931 Setup, Call Proceeding, Connect, -Release, or Release Done message. -.IP "\fIexpr relop expr\fR" -True if the relation holds, where \fIrelop\fR is one of >, <, >=, <=, =, -!=, and \fIexpr\fR is an arithmetic expression composed of integer -constants (expressed in standard C syntax), the normal binary operators -[+, -, *, /, &, |, <<, >>], a length operator, and special packet data -accessors. Note that all comparisons are unsigned, so that, for example, -0x80000000 and 0xffffffff are > 0. -To access -data inside the packet, use the following syntax: -.in +.5i -.nf -\fIproto\fB [ \fIexpr\fB : \fIsize\fB ]\fR -.fi -.in -.5i -\fIProto\fR is one of \fBether, fddi, tr, wlan, ppp, slip, link, -ip, arp, rarp, tcp, udp, icmp, ip6\fR or \fBradio\fR, and -indicates the protocol layer for the index operation. -(\fBether, fddi, wlan, tr, ppp, slip\fR and \fBlink\fR all refer to the -link layer. \fBradio\fR refers to the "radio header" added to some -802.11 captures.) -Note that \fItcp, udp\fR and other upper-layer protocol types only -apply to IPv4, not IPv6 (this will be fixed in the future). -The byte offset, relative to the indicated protocol layer, is -given by \fIexpr\fR. -\fISize\fR is optional and indicates the number of bytes in the -field of interest; it can be either one, two, or four, and defaults to one. -The length operator, indicated by the keyword \fBlen\fP, gives the -length of the packet. - -For example, `\fBether[0] & 1 != 0\fP' catches all multicast traffic. -The expression `\fBip[0] & 0xf != 5\fP' -catches all IPv4 packets with options. -The expression -`\fBip[6:2] & 0x1fff = 0\fP' -catches only unfragmented IPv4 datagrams and frag zero of fragmented -IPv4 datagrams. -This check is implicitly applied to the \fBtcp\fP and \fBudp\fP -index operations. -For instance, \fBtcp[0]\fP always means the first -byte of the TCP \fIheader\fP, and never means the first byte of an -intervening fragment. - -Some offsets and field values may be expressed as names rather than -as numeric values. -The following protocol header field offsets are -available: \fBicmptype\fP (ICMP type field), \fBicmpcode\fP (ICMP -code field), and \fBtcpflags\fP (TCP flags field). - -The following ICMP type field values are available: \fBicmp-echoreply\fP, -\fBicmp-unreach\fP, \fBicmp-sourcequench\fP, \fBicmp-redirect\fP, -\fBicmp-echo\fP, \fBicmp-routeradvert\fP, \fBicmp-routersolicit\fP, -\fBicmp-timxceed\fP, \fBicmp-paramprob\fP, \fBicmp-tstamp\fP, -\fBicmp-tstampreply\fP, \fBicmp-ireq\fP, \fBicmp-ireqreply\fP, -\fBicmp-maskreq\fP, \fBicmp-maskreply\fP. - -The following TCP flags field values are available: \fBtcp-fin\fP, -\fBtcp-syn\fP, \fBtcp-rst\fP, \fBtcp-push\fP, -\fBtcp-ack\fP, \fBtcp-urg\fP. -.LP -Primitives may be combined using: -.IP -A parenthesized group of primitives and operators -(parentheses are special to the Shell and must be escaped). -.IP -Negation (`\fB!\fP' or `\fBnot\fP'). -.IP -Concatenation (`\fB&&\fP' or `\fBand\fP'). -.IP -Alternation (`\fB||\fP' or `\fBor\fP'). -.LP -Negation has highest precedence. -Alternation and concatenation have equal precedence and associate -left to right. -Note that explicit \fBand\fR tokens, not juxtaposition, -are now required for concatenation. -.LP -If an identifier is given without a keyword, the most recent keyword -is assumed. -For example, -.in +.5i -.nf -\fBnot host vs and ace\fR -.fi -.in -.5i -is short for -.in +.5i -.nf -\fBnot host vs and host ace\fR -.fi -.in -.5i -which should not be confused with -.in +.5i -.nf -\fBnot ( host vs or ace )\fR -.fi -.in -.5i +For the \fIexpression\fP syntax, see +.BR pcap-filter (4). .LP Expression arguments can be passed to \fItcpdump\fP as either a single argument or as multiple arguments, whichever is more convenient. @@ -2272,7 +1610,7 @@ is made to account for the time lag between when the Ethernet interface removed the packet from the wire and when the kernel serviced the `new packet' interrupt. .SH "SEE ALSO" -stty(1), pcap(3), bpf(4), nit(4P), pfconfig(8) +stty(1), pcap(3PCAP), pcap-filter(4), bpf(4), nit(4P) .SH AUTHORS The original authors are: .LP @@ -2296,18 +1634,13 @@ The original distribution is available via anonymous ftp: .RE .LP IPv6/IPsec support is added by WIDE/KAME project. -This program uses Eric Young's SSLeay library, under specific configuration. +This program uses Eric Young's SSLeay library, under specific configurations. .SH BUGS -Please send problems, bugs, questions, desirable enhancements, etc. to: -.LP -.RS -tcpdump-workers@tcpdump.org -.RE -.LP -Please send source code contributions, etc. to: +Please send problems, bugs, questions, desirable enhancements, patches +etc. to: .LP .RS -patches@tcpdump.org +tcpdump-workers@lists.tcpdump.org .RE .LP NIT doesn't let you watch your own outbound traffic, BPF will. diff --git a/contrib/tcpdump/tcpdump.c b/contrib/tcpdump/tcpdump.c index caf419ea8a..4328b30490 100644 --- a/contrib/tcpdump/tcpdump.c +++ b/contrib/tcpdump/tcpdump.c @@ -30,7 +30,7 @@ static const char copyright[] _U_ = "@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000\n\ The Regents of the University of California. All rights reserved.\n"; static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.253.2.13 2007/09/12 19:48:51 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.271.2.11 2008-09-25 21:50:04 guy Exp $ (LBL)"; #endif /* @@ -65,12 +65,16 @@ extern int SIZE_BUF; #include #include #include +#include #ifndef WIN32 +#include +#include #include #include #include #endif /* WIN32 */ + #include "netdissect.h" #include "interface.h" #include "addrtoname.h" @@ -79,19 +83,16 @@ extern int SIZE_BUF; #include "gmt2local.h" #include "pcap-missing.h" +#ifndef NAME_MAX +#define NAME_MAX 255 +#endif + netdissect_options Gndo; netdissect_options *gndo = &Gndo; -/* - * Define the maximum number of files for the -C flag, and how many - * characters can be added to a filename for the -C flag (which - * should be enough to handle MAX_CFLAG - 1). - */ -#define MAX_CFLAG 1000000 -#define MAX_CFLAG_CHARS 6 - int dflag; /* print filter code */ int Lflag; /* list available data link types and exit */ +char *zflag = NULL; /* compress each savefile using a specified command (like gzip or bzip2) */ static int infodelay; static int infoprint; @@ -102,6 +103,7 @@ int32_t thiszone; /* seconds offset from gmt to local time */ /* Forwards */ static RETSIGTYPE cleanup(int); +static RETSIGTYPE child_cleanup(int); static void usage(void) __attribute__((noreturn)); static void show_dlts_and_exit(pcap_t *pd) __attribute__((noreturn)); @@ -220,6 +222,9 @@ static struct printer printers[] = { #ifdef DLT_APPLE_IP_OVER_IEEE1394 { ap1394_if_print, DLT_APPLE_IP_OVER_IEEE1394 }, #endif +#ifdef DLT_IEEE802_11_RADIO_AVS + { ieee802_11_radio_avs_if_print, DLT_IEEE802_11_RADIO_AVS }, +#endif #ifdef DLT_JUNIPER_ATM1 { juniper_atm1_print, DLT_JUNIPER_ATM1 }, #endif @@ -267,6 +272,9 @@ static struct printer printers[] = { #endif #ifdef DLT_MFR { mfr_if_print, DLT_MFR }, +#endif +#if defined(DLT_BLUETOOTH_HCI_H4_WITH_PHDR) && defined(HAVE_PCAP_BLUETOOTH_H) + { bt_if_print, DLT_BLUETOOTH_HCI_H4_WITH_PHDR}, #endif { NULL, 0 }, }; @@ -296,6 +304,7 @@ struct print_info { struct dump_info { char *WFileName; + char *CurrentFileName; pcap_t *pd; pcap_dumper_t *p; }; @@ -325,10 +334,10 @@ show_dlts_and_exit(pcap_t *pd) * OK, does tcpdump handle that type? */ if (lookup_printer(dlts[n_dlts]) == NULL) - (void) fprintf(stderr, " (not supported)"); + (void) fprintf(stderr, " (printing not supported)"); putchar('\n'); } else { - (void) fprintf(stderr, " DLT %d (not supported)\n", + (void) fprintf(stderr, " DLT %d (printing not supported)\n", dlts[n_dlts]); } } @@ -340,13 +349,19 @@ show_dlts_and_exit(pcap_t *pd) * Set up flags that might or might not be supported depending on the * version of libpcap we're using. */ -#ifdef WIN32 +#if defined(HAVE_PCAP_CREATE) || defined(WIN32) #define B_FLAG "B:" #define B_FLAG_USAGE " [ -B size ]" -#else /* WIN32 */ +#else /* defined(HAVE_PCAP_CREATE) || defined(WIN32) */ #define B_FLAG #define B_FLAG_USAGE -#endif /* WIN32 */ +#endif /* defined(HAVE_PCAP_CREATE) || defined(WIN32) */ + +#ifdef HAVE_PCAP_CREATE +#define I_FLAG "I" +#else /* HAVE_PCAP_CREATE */ +#define I_FLAG +#endif /* HAVE_PCAP_CREATE */ #ifdef HAVE_PCAP_FINDALLDEVS #ifndef HAVE_PCAP_IF_T @@ -423,10 +438,32 @@ getWflagChars(int x) static void MakeFilename(char *buffer, char *orig_name, int cnt, int max_chars) { + char *filename = malloc(NAME_MAX + 1); + + /* Process with strftime if Gflag is set. */ + if (Gflag != 0) { + struct tm *local_tm; + + /* Convert Gflag_time to a usable format */ + if ((local_tm = localtime(&Gflag_time)) == NULL) { + error("MakeTimedFilename: localtime"); + } + + /* There's no good way to detect an error in strftime since a return + * value of 0 isn't necessarily failure. + */ + strftime(filename, NAME_MAX, orig_name, local_tm); + } else { + strncpy(filename, orig_name, NAME_MAX); + } + if (cnt == 0 && max_chars == 0) - strcpy(buffer, orig_name); + strncpy(buffer, filename, NAME_MAX + 1); else - sprintf(buffer, "%s%0*d", orig_name, max_chars, cnt); + if (snprintf(buffer, NAME_MAX + 1, "%s%0*d", filename, max_chars, cnt) > NAME_MAX) + /* Report an error if the filename is too large */ + error("too many output files or filename is too long (> %d)", NAME_MAX); + free(filename); } static int tcpdump_printf(netdissect_options *ndo _U_, @@ -448,7 +485,7 @@ main(int argc, char **argv) { register int cnt, op, i; bpf_u_int32 localnet, netmask; - register char *cp, *infile, *cmdbuf, *device, *RFileName, *WFileName, *WFileNameAlt; + register char *cp, *infile, *cmdbuf, *device, *RFileName, *WFileName; pcap_handler callback; int type; struct bpf_program fcode; @@ -467,7 +504,6 @@ main(int argc, char **argv) #endif int status; #ifdef WIN32 - u_int UserBufferSize = 1000000; if(wsockinit() != 0) return 1; #endif /* WIN32 */ @@ -499,7 +535,7 @@ main(int argc, char **argv) opterr = 0; while ( - (op = getopt(argc, argv, "aA" B_FLAG "c:C:d" D_FLAG "eE:fF:i:lLm:M:nNOpqr:Rs:StT:u" U_FLAG "vw:W:xXy:YZ:")) != -1) + (op = getopt(argc, argv, "aA" B_FLAG "c:C:d" D_FLAG "eE:fF:G:i:" I_FLAG "KlLm:M:nNOpqr:Rs:StT:u" U_FLAG "vw:W:xXy:Yz:Z:")) != -1) switch (op) { case 'a': @@ -510,13 +546,13 @@ main(int argc, char **argv) ++Aflag; break; -#ifdef WIN32 +#if defined(HAVE_PCAP_CREATE) || defined(WIN32) case 'B': - UserBufferSize = atoi(optarg)*1024; - if (UserBufferSize < 0) + Bflag = atoi(optarg)*1024; + if (Bflag <= 0) error("invalid packet buffer size %s", optarg); break; -#endif /* WIN32 */ +#endif /* defined(HAVE_PCAP_CREATE) || defined(WIN32) */ case 'c': cnt = atoi(optarg); @@ -573,6 +609,21 @@ main(int argc, char **argv) infile = optarg; break; + case 'G': + Gflag = atoi(optarg); + if (Gflag < 0) + error("invalid number of seconds %s", optarg); + + /* We will create one file initially. */ + Gflag_count = 0; + + /* Grab the current time for rotation use. */ + if ((Gflag_time = time(NULL)) == (time_t)-1) { + error("main: can't get current time: %s", + pcap_strerror(errno)); + } + break; + case 'i': if (optarg[0] == '0' && optarg[1] == 0) error("Invalid adapter index"); @@ -608,6 +659,12 @@ main(int argc, char **argv) device = optarg; break; +#ifdef HAVE_PCAP_CREATE + case 'I': + ++Iflag; + break; +#endif /* HAVE_PCAP_CREATE */ + case 'l': #ifdef WIN32 /* @@ -629,19 +686,15 @@ main(int argc, char **argv) #endif /* WIN32 */ break; - case 'n': - ++nflag; - break; - - case 'N': - ++Nflag; + case 'K': + ++Kflag; break; case 'm': #ifdef LIBSMI - if (smiLoadModule(optarg) == 0) { + if (smiLoadModule(optarg) == 0) { error("could not load MIB module %s", optarg); - } + } sflag = 1; #else (void)fprintf(stderr, "%s: ignoring option `-m %s' ", @@ -658,6 +711,14 @@ main(int argc, char **argv) tcpmd5secret = optarg; break; + case 'n': + ++nflag; + break; + + case 'N': + ++Nflag; + break; + case 'O': Oflag = 0; break; @@ -779,6 +840,15 @@ main(int argc, char **argv) } break; #endif + case 'z': + if (optarg) { + zflag = strdup(optarg); + } else { + usage(); + /* NOTREACHED */ + } + break; + case 'Z': if (optarg) { username = strdup(optarg); @@ -804,10 +874,11 @@ main(int argc, char **argv) case 1: /* No time stamp */ case 2: /* Unix timeval style */ case 3: /* Microseconds since previous packet */ + case 5: /* Microseconds since first packet */ break; default: /* Not supported */ - error("only -t, -tt, -ttt, and -tttt are supported"); + error("only -t, -tt, -ttt, -tttt and -ttttt are supported"); break; } @@ -882,12 +953,74 @@ main(int argc, char **argv) fflush(stderr); #endif /* WIN32 */ +#ifdef HAVE_PCAP_CREATE + pd = pcap_create(device, ebuf); + if (pd == NULL) + error("%s", ebuf); + status = pcap_set_snaplen(pd, snaplen); + if (status != 0) + error("%s: pcap_set_snaplen failed: %s", + device, pcap_statustostr(status)); + status = pcap_set_promisc(pd, !pflag); + if (status != 0) + error("%s: pcap_set_promisc failed: %s", + device, pcap_statustostr(status)); + if (Iflag) { + status = pcap_set_rfmon(pd, 1); + if (status != 0) + error("%s: pcap_set_rfmon failed: %s", + device, pcap_statustostr(status)); + } + status = pcap_set_timeout(pd, 1000); + if (status != 0) + error("%s: pcap_set_timeout failed: %s", + device, pcap_statustostr(status)); + if (Bflag != 0) { + status = pcap_set_buffer_size(pd, Bflag); + if (status != 0) + error("%s: pcap_set_buffer_size failed: %s", + device, pcap_statustostr(status)); + } + status = pcap_activate(pd); + if (status < 0) { + /* + * pcap_activate() failed. + */ + cp = pcap_geterr(pd); + if (status == PCAP_ERROR) + error("%s", cp); + else if ((status == PCAP_ERROR_NO_SUCH_DEVICE || + status == PCAP_ERROR_PERM_DENIED) && + *cp != '\0') + error("%s: %s\n(%s)", device, + pcap_statustostr(status), cp); + else + error("%s: %s", device, + pcap_statustostr(status)); + } else if (status > 0) { + /* + * pcap_activate() succeeded, but it's warning us + * of a problem it had. + */ + cp = pcap_geterr(pd); + if (status == PCAP_WARNING) + warning("%s", cp); + else if (status == PCAP_WARNING_PROMISC_NOTSUP && + *cp != '\0') + warning("%s: %s\n(%s)", device, + pcap_statustostr(status), cp); + else + warning("%s: %s", device, + pcap_statustostr(status)); + } +#else *ebuf = '\0'; pd = pcap_open_live(device, snaplen, !pflag, 1000, ebuf); if (pd == NULL) error("%s", ebuf); else if (*ebuf) warning("%s", ebuf); +#endif /* HAVE_PCAP_CREATE */ /* * Let user own process after socket has been opened. */ @@ -895,12 +1028,12 @@ main(int argc, char **argv) if (setgid(getgid()) != 0 || setuid(getuid()) != 0) fprintf(stderr, "Warning: setgid/setuid failed !\n"); #endif /* WIN32 */ -#ifdef WIN32 - if(UserBufferSize != 1000000) - if(pcap_setbuff(pd, UserBufferSize)==-1){ +#if !defined(HAVE_PCAP_CREATE) && defined(WIN32) + if(Bflag != 0) + if(pcap_setbuff(pd, Bflag)==-1){ error("%s", pcap_geterr(pd)); } -#endif /* WIN32 */ +#endif /* !defined(HAVE_PCAP_CREATE) && defined(WIN32) */ if (Lflag) show_dlts_and_exit(pd); if (gndo->ndo_dlt >= 0) { @@ -919,7 +1052,7 @@ main(int argc, char **argv) } #endif (void)fprintf(stderr, "%s: data link type %s\n", - program_name, gndo->ndo_dltname); + program_name, gndo->ndo_dltname); (void)fflush(stderr); } i = pcap_snapshot(pd); @@ -946,12 +1079,14 @@ main(int argc, char **argv) exit(0); } init_addrtoname(localnet, netmask); + init_checksum(); #ifndef WIN32 (void)setsignal(SIGPIPE, cleanup); -#endif /* WIN32 */ (void)setsignal(SIGTERM, cleanup); (void)setsignal(SIGINT, cleanup); + (void)setsignal(SIGCHLD, child_cleanup); +#endif /* WIN32 */ /* Cooperate with nohup(1) */ #ifndef WIN32 if ((oldhandler = setsignal(SIGHUP, cleanup)) != SIG_DFL) @@ -962,15 +1097,22 @@ main(int argc, char **argv) error("%s", pcap_geterr(pd)); if (WFileName) { pcap_dumper_t *p; + /* Do not exceed the default NAME_MAX for files. */ + dumpinfo.CurrentFileName = (char *)malloc(NAME_MAX + 1); + + if (dumpinfo.CurrentFileName == NULL) + error("malloc of dumpinfo.CurrentFileName"); + + /* We do not need numbering for dumpfiles if Cflag isn't set. */ + if (Cflag != 0) + MakeFilename(dumpinfo.CurrentFileName, WFileName, 0, WflagChars); + else + MakeFilename(dumpinfo.CurrentFileName, WFileName, 0, 0); - WFileNameAlt = (char *)malloc(strlen(WFileName) + MAX_CFLAG_CHARS + 1); - if (WFileNameAlt == NULL) - error("malloc of WFileNameAlt"); - MakeFilename(WFileNameAlt, WFileName, 0, WflagChars); - p = pcap_dump_open(pd, WFileNameAlt); + p = pcap_dump_open(pd, dumpinfo.CurrentFileName); if (p == NULL) error("%s", pcap_geterr(pd)); - if (Cflag != 0) { + if (Cflag != 0 || Gflag != 0) { callback = dump_packet_and_trunc; dumpinfo.WFileName = WFileName; dumpinfo.pd = pd; @@ -1005,7 +1147,12 @@ main(int argc, char **argv) } #endif /* WIN32 */ #ifdef SIGINFO - (void)setsignal(SIGINFO, requestinfo); + /* + * We can't get statistics when reading from a file rather + * than capturing from a device. + */ + if (RFileName == NULL) + (void)setsignal(SIGINFO, requestinfo); #endif if (vflag > 0 && WFileName) { @@ -1123,6 +1270,18 @@ cleanup(int signo _U_) #endif } +/* + On windows, we do not use a fork, so we do not care less about + waiting a child processes to die + */ +#ifndef WIN32 +static RETSIGTYPE +child_cleanup(int signo _U_) +{ + wait(NULL); +} +#endif /* WIN32 */ + static void info(register int verbose) { @@ -1130,6 +1289,7 @@ info(register int verbose) if (pcap_stats(pd, &stat) < 0) { (void)fprintf(stderr, "pcap_stats: %s\n", pcap_geterr(pd)); + infoprint = 0; return; } @@ -1150,11 +1310,40 @@ info(register int verbose) infoprint = 0; } +#ifndef WIN32 +static void +compress_savefile(const char *filename) +{ + if (fork()) + return; + /* + * Set to lowest priority so that this doesn't disturb the capture + */ +#ifdef NZERO + setpriority(PRIO_PROCESS, 0, NZERO - 1); +#else + setpriority(PRIO_PROCESS, 0, 19); +#endif + if (execlp(zflag, zflag, filename, NULL) == -1) + fprintf(stderr, + "compress_savefile:execlp(%s, %s): %s\n", + zflag, + filename, + strerror(errno)); +} +#else /* WIN32 */ +static void +compress_savefile(const char *filename) +{ + fprintf(stderr, + "compress_savefile failed. Functionality not implemented under windows\n"); +} +#endif /* WIN32 */ + static void dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *sp) { struct dump_info *dump_info; - char *name; ++packets_captured; @@ -1162,30 +1351,104 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s dump_info = (struct dump_info *)user; + /* + * XXX - this won't force the file to rotate on the specified time + * boundary, but it will rotate on the first packet received after the + * specified Gflag number of seconds. Note: if a Gflag time boundary + * and a Cflag size boundary coincide, the time rotation will occur + * first thereby cancelling the Cflag boundary (since the file should + * be 0). + */ + if (Gflag != 0) { + /* Check if it is time to rotate */ + time_t t; + + /* Get the current time */ + if ((t = time(NULL)) == (time_t)-1) { + error("dump_and_trunc_packet: can't get current_time: %s", + pcap_strerror(errno)); + } + + + /* If the time is greater than the specified window, rotate */ + if (t - Gflag_time >= Gflag) { + /* Update the Gflag_time */ + Gflag_time = t; + /* Update Gflag_count */ + Gflag_count++; + /* + * Close the current file and open a new one. + */ + pcap_dump_close(dump_info->p); + + /* + * Compress the file we just closed, if the user asked for it + */ + if (zflag != NULL) + compress_savefile(dump_info->CurrentFileName); + + /* + * Check to see if we've exceeded the Wflag (when + * not using Cflag). + */ + if (Cflag == 0 && Wflag > 0 && Gflag_count >= Wflag) { + (void)fprintf(stderr, "Maximum file limit reached: %d\n", + Wflag); + exit(0); + /* NOTREACHED */ + } + if (dump_info->CurrentFileName != NULL) + free(dump_info->CurrentFileName); + /* Allocate space for max filename + \0. */ + dump_info->CurrentFileName = (char *)malloc(NAME_MAX + 1); + if (dump_info->CurrentFileName == NULL) + error("dump_packet_and_trunc: malloc"); + /* + * This is always the first file in the Cflag + * rotation: e.g. 0 + * We also don't need numbering if Cflag is not set. + */ + if (Cflag != 0) + MakeFilename(dump_info->CurrentFileName, dump_info->WFileName, 0, + WflagChars); + else + MakeFilename(dump_info->CurrentFileName, dump_info->WFileName, 0, 0); + + dump_info->p = pcap_dump_open(dump_info->pd, dump_info->CurrentFileName); + if (dump_info->p == NULL) + error("%s", pcap_geterr(pd)); + } + } + /* * XXX - this won't prevent capture files from getting * larger than Cflag - the last packet written to the * file could put it over Cflag. */ - if (pcap_dump_ftell(dump_info->p) > Cflag) { + if (Cflag != 0 && pcap_dump_ftell(dump_info->p) > Cflag) { /* * Close the current file and open a new one. */ pcap_dump_close(dump_info->p); + + /* + * Compress the file we just closed, if the user asked for it + */ + if (zflag != NULL) + compress_savefile(dump_info->CurrentFileName); + Cflag_count++; if (Wflag > 0) { if (Cflag_count >= Wflag) Cflag_count = 0; - } else { - if (Cflag_count >= MAX_CFLAG) - error("too many output files"); } - name = (char *)malloc(strlen(dump_info->WFileName) + MAX_CFLAG_CHARS + 1); - if (name == NULL) + if (dump_info->CurrentFileName != NULL) + free(dump_info->CurrentFileName); + dump_info->CurrentFileName = (char *)malloc(NAME_MAX + 1); + if (dump_info->CurrentFileName == NULL) error("dump_packet_and_trunc: malloc"); - MakeFilename(name, dump_info->WFileName, Cflag_count, WflagChars); - dump_info->p = pcap_dump_open(dump_info->pd, name); - free(name); + MakeFilename(dump_info->CurrentFileName, dump_info->WFileName, Cflag_count, WflagChars); + dump_info->p = pcap_dump_open(dump_info->pd, dump_info->CurrentFileName); if (dump_info->p == NULL) error("%s", pcap_geterr(pd)); } @@ -1362,7 +1625,7 @@ RETSIGTYPE requestinfo(int signo _U_) */ #ifdef USE_WIN32_MM_TIMER void CALLBACK verbose_stats_dump (UINT timer_id _U_, UINT msg _U_, DWORD_PTR arg _U_, - DWORD_PTR dw1 _U_, DWORD_PTR dw2 _U_) + DWORD_PTR dw1 _U_, DWORD_PTR dw2 _U_) { struct pcap_stat stat; @@ -1409,13 +1672,15 @@ usage(void) #endif /* WIN32 */ #endif /* HAVE_PCAP_LIB_VERSION */ (void)fprintf(stderr, -"Usage: %s [-aAd" D_FLAG "eflLnNOpqRStu" U_FLAG "vxX]" B_FLAG_USAGE " [-c count] [ -C file_size ]\n", program_name); +"Usage: %s [-aAd" D_FLAG "ef" I_FLAG "KlLnNOpqRStu" U_FLAG "vxX]" B_FLAG_USAGE " [ -c count ]\n", program_name); + (void)fprintf(stderr, +"\t\t[ -C file_size ] [ -E algo:secret ] [ -F file ] [ -G seconds ]\n"); (void)fprintf(stderr, -"\t\t[ -E algo:secret ] [ -F file ] [ -i interface ] [ -M secret ]\n"); +"\t\t[ -i interface ] [ -M secret ] [ -r file ]\n"); (void)fprintf(stderr, -"\t\t[ -r file ] [ -s snaplen ] [ -T type ] [ -w file ]\n"); +"\t\t[ -s snaplen ] [ -T type ] [ -w file ] [ -W filecount ]\n"); (void)fprintf(stderr, -"\t\t[ -W filecount ] [ -y datalinktype ] [ -Z user ]\n"); +"\t\t[ -y datalinktype ] [ -z command ] [ -Z user ]\n"); (void)fprintf(stderr, "\t\t[ expression ]\n"); exit(1); @@ -1458,4 +1723,3 @@ ndo_warning(netdissect_options *ndo _U_, const char *fmt, ...) (void)fputc('\n', stderr); } } - diff --git a/contrib/tcpdump/telnet.h b/contrib/tcpdump/telnet.h index da11043019..33a07be948 100644 --- a/contrib/tcpdump/telnet.h +++ b/contrib/tcpdump/telnet.h @@ -1,6 +1,6 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/telnet.h,v 1.4 2002/06/11 17:09:01 itojun Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/telnet.h,v 1.5 2007-08-29 02:31:44 mcr Exp $ (LBL) */ -/* $NetBSD: telnet.h,v 1.9 2001/06/11 01:50:50 wiz Exp $ */ +/* NetBSD: telnet.h,v 1.9 2001/06/11 01:50:50 wiz Exp */ /* * Copyright (c) 1983, 1993 diff --git a/contrib/tcpdump/tftp.h b/contrib/tcpdump/tftp.h index 44083042d5..6285404fc7 100644 --- a/contrib/tcpdump/tftp.h +++ b/contrib/tcpdump/tftp.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/tftp.h,v 1.1.2.1 2007/09/14 01:03:12 guy Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/tftp.h,v 1.1.4.1 2008-04-11 16:44:17 gianluca Exp $ (LBL) */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -49,7 +49,7 @@ #define WRQ 02 /* write request */ #define DATA 03 /* data packet */ #define ACK 04 /* acknowledgement */ -#define ERROR 05 /* error code */ +#define TFTP_ERROR 05 /* error code */ #define OACK 06 /* option acknowledgement */ struct tftphdr { diff --git a/contrib/tcpdump/timed.h b/contrib/tcpdump/timed.h index 0a5c5fe57a..15135e7372 100644 --- a/contrib/tcpdump/timed.h +++ b/contrib/tcpdump/timed.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/timed.h,v 1.5 2002/12/11 07:14:12 guy Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/timed.h,v 1.5.6.1 2008-02-05 19:46:58 guy Exp $ (LBL) */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -44,12 +44,17 @@ #define TSPVERSION 1 #define ANYADDR NULL +struct tsp_timeval { + u_int32_t tv_sec; + u_int32_t tv_usec; +}; + struct tsp { u_int8_t tsp_type; u_int8_t tsp_vers; u_int16_t tsp_seq; union { - struct timeval tspu_time; + struct tsp_timeval tspu_time; int8_t tspu_hopcnt; } tsp_u; int8_t tsp_name[256]; diff --git a/contrib/tcpdump/token.h b/contrib/tcpdump/token.h index 8e7fd6d4e2..b1d92a3f1a 100644 --- a/contrib/tcpdump/token.h +++ b/contrib/tcpdump/token.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/token.h,v 1.6 2002/12/11 07:14:12 guy Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/token.h,v 1.6 2002-12-11 07:14:12 guy Exp $ (LBL) */ /* * Copyright (c) 1998, Larry Lile * All rights reserved. diff --git a/contrib/tcpdump/udp.h b/contrib/tcpdump/udp.h index dedc9c1846..fb45d68f7b 100644 --- a/contrib/tcpdump/udp.h +++ b/contrib/tcpdump/udp.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/udp.h,v 1.8.2.2 2007/03/28 07:45:46 hannes Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/udp.h,v 1.13 2007-08-08 17:20:58 hannes Exp $ (LBL) */ /* * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. @@ -76,11 +76,15 @@ struct udphdr { #define HSRP_PORT 1985 /*XXX*/ #define LMP_PORT 701 /* rfc4204 */ #define LWRES_PORT 921 +#define VQP_PORT 1589 #define ZEPHYR_SRV_PORT 2103 #define ZEPHYR_CLT_PORT 2104 #define MPLS_LSP_PING_PORT 3503 /* draft-ietf-mpls-lsp-ping-02.txt */ #define BFD_CONTROL_PORT 3784 /* draft-katz-ward-bfd-v4v6-1hop-00.txt */ #define BFD_ECHO_PORT 3785 /* draft-katz-ward-bfd-v4v6-1hop-00.txt */ +#define SFLOW_PORT 6343 /* http://www.sflow.org/developers/specifications.php */ +#define LWAPP_DATA_PORT 12222 /* draft-ohara-capwap-lwapp-04.txt */ +#define LWAPP_CONTROL_PORT 12223 /* draft-ohara-capwap-lwapp-04.txt */ #ifdef INET6 #define RIPNG_PORT 521 /*XXX*/ diff --git a/contrib/tcpdump/util.c b/contrib/tcpdump/util.c index 912f6f3c76..6b723e543c 100644 --- a/contrib/tcpdump/util.c +++ b/contrib/tcpdump/util.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/util.c,v 1.95.2.6 2006/02/08 01:40:09 hannes Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/util.c,v 1.109 2007-01-29 09:59:42 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -44,6 +44,8 @@ static const char rcsid[] _U_ = #include "interface.h" +char * ts_format(register int, register int); + /* * Print out a null-terminated filename (or other ascii string). * If ep is NULL, assume no truncation check is needed. @@ -138,6 +140,19 @@ fn_printzp(register const u_char *s, register u_int n, return (n == 0) ? 0 : ret; } +/* + * Format the timestamp + */ +char * +ts_format(register int sec, register int usec) +{ + static char buf[sizeof("00:00:00.000000")]; + (void)snprintf(buf, sizeof(buf), "%02d:%02d:%02d.%06u", + sec / 3600, (sec % 3600) / 60, sec % 60, usec); + + return buf; +} + /* * Print the timestamp */ @@ -149,14 +164,14 @@ ts_print(register const struct timeval *tvp) time_t Time; static unsigned b_sec; static unsigned b_usec; + int d_usec; + int d_sec; switch (tflag) { case 0: /* Default */ s = (tvp->tv_sec + thiszone) % 86400; - (void)printf("%02d:%02d:%02d.%06u ", - s / 3600, (s % 3600) / 60, s % 60, - (unsigned)tvp->tv_usec); + (void)printf("%s ", ts_format(s, tvp->tv_usec)); break; case 1: /* No time stamp */ @@ -169,22 +184,27 @@ ts_print(register const struct timeval *tvp) break; case 3: /* Microseconds since previous packet */ + case 5: /* Microseconds since first packet */ if (b_sec == 0) { - printf("000000 "); - } else { - int d_usec = tvp->tv_usec - b_usec; - int d_sec = tvp->tv_sec - b_sec; - - while (d_usec < 0) { - d_usec += 1000000; - d_sec--; - } - if (d_sec) - printf("%d. ", d_sec); - printf("%06d ", d_usec); - } - b_sec = tvp->tv_sec; - b_usec = tvp->tv_usec; + /* init timestamp for first packet */ + b_usec = tvp->tv_usec; + b_sec = tvp->tv_sec; + } + + d_usec = tvp->tv_usec - b_usec; + d_sec = tvp->tv_sec - b_sec; + + while (d_usec < 0) { + d_usec += 1000000; + d_sec--; + } + + (void)printf("%s ", ts_format(d_sec, d_usec)); + + if (tflag == 3) { /* set timestamp for last packet */ + b_sec = tvp->tv_sec; + b_usec = tvp->tv_usec; + } break; case 4: /* Default + Date*/ @@ -194,10 +214,9 @@ ts_print(register const struct timeval *tvp) if (!tm) printf("Date fail "); else - printf("%04d-%02d-%02d ", - tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday); - printf("%02d:%02d:%02d.%06u ", - s / 3600, (s % 3600) / 60, s % 60, (unsigned)tvp->tv_usec); + printf("%04d-%02d-%02d %s ", + tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday, + ts_format(s, tvp->tv_usec)); break; } } @@ -297,11 +316,12 @@ tok2str(register const struct tok *lp, register const char *fmt, /* * Convert a bit token value to a string; use "fmt" if not found. - * this is useful for parsing bitfields, the output strings are comma seperated + * this is useful for parsing bitfields, the output strings are seperated + * if the s field is positive. */ -char * -bittok2str(register const struct tok *lp, register const char *fmt, - register int v) +static char * +bittok2str_internal(register const struct tok *lp, register const char *fmt, + register int v, register int sep) { static char buf[256]; /* our stringbuffer */ int buflen=0; @@ -318,7 +338,8 @@ bittok2str(register const struct tok *lp, register const char *fmt, */ if (tokval == (v&rotbit)) { /* ok we have found something */ - buflen+=snprintf(buf+buflen, sizeof(buf)-buflen, "%s, ",lp->s); + buflen+=snprintf(buf+buflen, sizeof(buf)-buflen, "%s%s", + lp->s, sep ? ", " : ""); break; } rotbit=rotbit<<1; /* no match - lets shift and try again */ @@ -326,6 +347,11 @@ bittok2str(register const struct tok *lp, register const char *fmt, lp++; } + /* user didn't want string seperation - no need to cut off trailing seperators */ + if (!sep) { + return (buf); + } + if (buflen != 0) { /* did we find anything */ /* yep, set the the trailing zero 2 bytes before to eliminate the last comma & whitespace */ buf[buflen-2] = '\0'; @@ -340,6 +366,28 @@ bittok2str(register const struct tok *lp, register const char *fmt, } } +/* + * Convert a bit token value to a string; use "fmt" if not found. + * this is useful for parsing bitfields, the output strings are not seperated. + */ +char * +bittok2str_nosep(register const struct tok *lp, register const char *fmt, + register int v) +{ + return (bittok2str_internal(lp, fmt, v, 0)); +} + +/* + * Convert a bit token value to a string; use "fmt" if not found. + * this is useful for parsing bitfields, the output strings are comma seperated. + */ +char * +bittok2str(register const struct tok *lp, register const char *fmt, + register int v) +{ + return (bittok2str_internal(lp, fmt, v, 1)); +} + /* * Convert a value to a string using an array; the macro * tok2strary() in is the public interface to @@ -509,7 +557,8 @@ read_infile(char *fname) void safeputs(const char *s, int maxlen) { - int idx = 0; + int idx = 0; + while (*s && idx < maxlen) { safeputchar(*s); idx++; @@ -526,5 +575,5 @@ safeputchar(int c) if (ch < 0x80 && isprint(ch)) printf("%c", ch); else - printf("\\%03o", ch); + printf("\\0x%02x", ch); } diff --git a/contrib/tcpdump/vfprintf.c b/contrib/tcpdump/vfprintf.c index 354406ce2c..6f8407af69 100644 --- a/contrib/tcpdump/vfprintf.c +++ b/contrib/tcpdump/vfprintf.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/vfprintf.c,v 1.6 2003/11/16 09:36:45 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/vfprintf.c,v 1.6 2003-11-16 09:36:45 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H -- 2.41.0