aboutsummaryrefslogtreecommitdiff
path: root/contrib/tcpdump
diff options
context:
space:
mode:
authorXin LI <delphij@FreeBSD.org>2015-01-07 19:55:18 +0000
committerXin LI <delphij@FreeBSD.org>2015-01-07 19:55:18 +0000
commit3c602fabf9b894ff79f08a80cbb7ad3b1eb84e62 (patch)
treee268839e08c106e178b33bd461d8d0a9c6fb5ad9 /contrib/tcpdump
parent61b3223976cc010f61cd50773dd8b9e06d123d9a (diff)
parente91eac244982a8728f370000c353b16e18174ec9 (diff)
downloadsrc-3c602fabf9b894ff79f08a80cbb7ad3b1eb84e62.tar.gz
src-3c602fabf9b894ff79f08a80cbb7ad3b1eb84e62.zip
MFV r276761: tcpdump 4.6.2.
MFC after: 1 month
Notes
Notes: svn path=/head/; revision=276788
Diffstat (limited to 'contrib/tcpdump')
-rw-r--r--contrib/tcpdump/CHANGES81
-rw-r--r--contrib/tcpdump/CREDITS70
-rw-r--r--contrib/tcpdump/INSTALL.txt43
-rw-r--r--contrib/tcpdump/Makefile-devel-adds4
-rw-r--r--contrib/tcpdump/Makefile.in250
-rw-r--r--contrib/tcpdump/README.md (renamed from contrib/tcpdump/README)50
-rw-r--r--contrib/tcpdump/VERSION2
-rw-r--r--contrib/tcpdump/acconfig.h75
-rw-r--r--contrib/tcpdump/addrtoname.c93
-rw-r--r--contrib/tcpdump/addrtoname.h22
-rw-r--r--contrib/tcpdump/af.c6
-rw-r--r--contrib/tcpdump/af.h2
-rw-r--r--contrib/tcpdump/ah.h18
-rw-r--r--contrib/tcpdump/aodv.h190
-rw-r--r--contrib/tcpdump/appletalk.h62
-rw-r--r--contrib/tcpdump/arcnet.h101
-rw-r--r--contrib/tcpdump/atm.h2
-rw-r--r--contrib/tcpdump/atmuni31.h2
-rw-r--r--contrib/tcpdump/bgp.h17
-rw-r--r--contrib/tcpdump/bootp.h257
-rw-r--r--contrib/tcpdump/bpf_dump.c6
-rw-r--r--contrib/tcpdump/chdlc.h1
-rw-r--r--contrib/tcpdump/checksum.c38
-rwxr-xr-xcontrib/tcpdump/config.guess258
-rw-r--r--contrib/tcpdump/config.h.in246
-rwxr-xr-xcontrib/tcpdump/config.sub211
-rwxr-xr-xcontrib/tcpdump/configure2247
-rw-r--r--contrib/tcpdump/configure.in309
-rw-r--r--contrib/tcpdump/cpack.c44
-rw-r--r--contrib/tcpdump/cpack.h28
-rw-r--r--contrib/tcpdump/dccp.h139
-rw-r--r--contrib/tcpdump/decnet.h461
-rw-r--r--contrib/tcpdump/decode_prefix.h41
-rw-r--r--contrib/tcpdump/enc.h47
-rw-r--r--contrib/tcpdump/esp.h68
-rw-r--r--contrib/tcpdump/ether.h7
-rw-r--r--contrib/tcpdump/ethertype.h19
-rw-r--r--contrib/tcpdump/extract.h194
-rw-r--r--contrib/tcpdump/fddi.h76
-rw-r--r--contrib/tcpdump/forces.h679
-rw-r--r--contrib/tcpdump/getopt_long.h66
-rw-r--r--contrib/tcpdump/gmpls.c26
-rw-r--r--contrib/tcpdump/gmpls.h3
-rw-r--r--contrib/tcpdump/gmt2local.c6
-rw-r--r--contrib/tcpdump/gmt2local.h2
-rw-r--r--contrib/tcpdump/icmp6.h473
-rw-r--r--contrib/tcpdump/ieee802_11.h347
-rw-r--r--contrib/tcpdump/ieee802_11_radio.h291
-rw-r--r--contrib/tcpdump/igrp.h33
-rw-r--r--contrib/tcpdump/in_cksum.c33
-rwxr-xr-xcontrib/tcpdump/install-sh14
-rw-r--r--contrib/tcpdump/interface.h294
-rw-r--r--contrib/tcpdump/ip.h36
-rw-r--r--contrib/tcpdump/ip6.h73
-rw-r--r--contrib/tcpdump/ipfc.h29
-rw-r--r--contrib/tcpdump/ipnet.h13
-rw-r--r--contrib/tcpdump/ipproto.c8
-rw-r--r--contrib/tcpdump/ipproto.h2
-rw-r--r--contrib/tcpdump/ipsec_doi.h151
-rw-r--r--contrib/tcpdump/ipx.h31
-rw-r--r--contrib/tcpdump/isakmp.h501
-rw-r--r--contrib/tcpdump/l2tp.h62
-rw-r--r--contrib/tcpdump/l2vpn.c30
-rw-r--r--contrib/tcpdump/l2vpn.h3
-rw-r--r--contrib/tcpdump/lane.h41
-rw-r--r--contrib/tcpdump/lbl/os-osf4.h2
-rw-r--r--contrib/tcpdump/lbl/os-solaris2.h2
-rw-r--r--contrib/tcpdump/lbl/os-sunos4.h2
-rw-r--r--contrib/tcpdump/lbl/os-ultrix4.h2
-rw-r--r--contrib/tcpdump/llc.h3
-rw-r--r--contrib/tcpdump/machdep.c10
-rw-r--r--contrib/tcpdump/machdep.h2
-rwxr-xr-xcontrib/tcpdump/makemib8
-rw-r--r--contrib/tcpdump/missing/addrinfo.h2
-rw-r--r--contrib/tcpdump/missing/datalinks.c5
-rw-r--r--contrib/tcpdump/missing/dlnames.c5
-rw-r--r--contrib/tcpdump/missing/getnameinfo.c9
-rw-r--r--contrib/tcpdump/missing/getopt_long.c612
-rw-r--r--contrib/tcpdump/missing/inet_aton.c7
-rw-r--r--contrib/tcpdump/missing/inet_ntop.c13
-rw-r--r--contrib/tcpdump/missing/inet_pton.c13
-rw-r--r--contrib/tcpdump/missing/snprintf.c7
-rw-r--r--contrib/tcpdump/missing/sockstorage.h38
-rw-r--r--contrib/tcpdump/missing/strdup.c5
-rw-r--r--contrib/tcpdump/missing/strlcat.c7
-rw-r--r--contrib/tcpdump/missing/strlcpy.c7
-rw-r--r--contrib/tcpdump/missing/strsep.c5
-rwxr-xr-xcontrib/tcpdump/mkdep10
-rw-r--r--contrib/tcpdump/mpls.h2
-rw-r--r--contrib/tcpdump/nameser.h35
-rw-r--r--contrib/tcpdump/netbios.h16
-rw-r--r--contrib/tcpdump/netdissect.h480
-rw-r--r--contrib/tcpdump/nfs.h111
-rw-r--r--contrib/tcpdump/nfsfh.h10
-rw-r--r--contrib/tcpdump/nlpid.c8
-rw-r--r--contrib/tcpdump/nlpid.h3
-rw-r--r--contrib/tcpdump/ntp.h127
-rw-r--r--contrib/tcpdump/oakley.h126
-rw-r--r--contrib/tcpdump/openflow.h40
-rw-r--r--contrib/tcpdump/ospf.h105
-rw-r--r--contrib/tcpdump/ospf6.h265
-rw-r--r--contrib/tcpdump/oui.c8
-rw-r--r--contrib/tcpdump/oui.h3
-rw-r--r--contrib/tcpdump/parsenfsfh.c57
-rw-r--r--contrib/tcpdump/pcap-missing.h2
-rw-r--r--contrib/tcpdump/pcap_dump_ftell.c5
-rw-r--r--contrib/tcpdump/pmap_prot.h90
-rw-r--r--contrib/tcpdump/ppi.h9
-rw-r--r--contrib/tcpdump/ppp.h3
-rw-r--r--contrib/tcpdump/print-802_11.c1552
-rw-r--r--contrib/tcpdump/print-802_15_4.c27
-rw-r--r--contrib/tcpdump/print-ah.c31
-rw-r--r--contrib/tcpdump/print-ahcp.c413
-rw-r--r--contrib/tcpdump/print-aodv.c423
-rw-r--r--contrib/tcpdump/print-aoe.c432
-rw-r--r--contrib/tcpdump/print-ap1394.c48
-rw-r--r--contrib/tcpdump/print-arcnet.c157
-rw-r--r--contrib/tcpdump/print-arp.c81
-rw-r--r--contrib/tcpdump/print-ascii.c75
-rw-r--r--contrib/tcpdump/print-atalk.c305
-rw-r--r--contrib/tcpdump/print-atm.c175
-rw-r--r--contrib/tcpdump/print-babel.c354
-rw-r--r--contrib/tcpdump/print-beep.c32
-rw-r--r--contrib/tcpdump/print-bfd.c123
-rw-r--r--contrib/tcpdump/print-bgp.c1131
-rw-r--r--contrib/tcpdump/print-bootp.c348
-rw-r--r--contrib/tcpdump/print-bt.c27
-rw-r--r--contrib/tcpdump/print-calm-fast.c60
-rw-r--r--contrib/tcpdump/print-carp.c40
-rw-r--r--contrib/tcpdump/print-cdp.c172
-rw-r--r--contrib/tcpdump/print-cfm.c231
-rw-r--r--contrib/tcpdump/print-chdlc.c95
-rw-r--r--contrib/tcpdump/print-cip.c41
-rw-r--r--contrib/tcpdump/print-cnfp.c97
-rw-r--r--contrib/tcpdump/print-dccp.c646
-rw-r--r--contrib/tcpdump/print-decnet.c845
-rw-r--r--contrib/tcpdump/print-dhcp6.c653
-rw-r--r--contrib/tcpdump/print-domain.c377
-rw-r--r--contrib/tcpdump/print-dtp.c43
-rw-r--r--contrib/tcpdump/print-dvmrp.c199
-rw-r--r--contrib/tcpdump/print-eap.c89
-rw-r--r--contrib/tcpdump/print-egp.c174
-rw-r--r--contrib/tcpdump/print-eigrp.c290
-rw-r--r--contrib/tcpdump/print-enc.c75
-rw-r--r--contrib/tcpdump/print-esp.c196
-rw-r--r--contrib/tcpdump/print-ether.c103
-rw-r--r--contrib/tcpdump/print-fddi.c154
-rw-r--r--contrib/tcpdump/print-forces.c1390
-rw-r--r--contrib/tcpdump/print-fr.c317
-rw-r--r--contrib/tcpdump/print-frag6.c31
-rw-r--r--contrib/tcpdump/print-geonet.c247
-rw-r--r--contrib/tcpdump/print-gre.c199
-rw-r--r--contrib/tcpdump/print-hsrp.c82
-rw-r--r--contrib/tcpdump/print-icmp.c213
-rw-r--r--contrib/tcpdump/print-icmp6.c1522
-rw-r--r--contrib/tcpdump/print-igmp.c228
-rw-r--r--contrib/tcpdump/print-igrp.c92
-rw-r--r--contrib/tcpdump/print-ip.c291
-rw-r--r--contrib/tcpdump/print-ip6.c90
-rw-r--r--contrib/tcpdump/print-ip6opts.c202
-rw-r--r--contrib/tcpdump/print-ipcomp.c28
-rw-r--r--contrib/tcpdump/print-ipfc.c52
-rw-r--r--contrib/tcpdump/print-ipnet.c31
-rw-r--r--contrib/tcpdump/print-ipx.c153
-rw-r--r--contrib/tcpdump/print-isakmp.c1140
-rw-r--r--contrib/tcpdump/print-isoclns.c1562
-rw-r--r--contrib/tcpdump/print-juniper.c482
-rw-r--r--contrib/tcpdump/print-krb.c118
-rw-r--r--contrib/tcpdump/print-l2tp.c345
-rw-r--r--contrib/tcpdump/print-lane.c41
-rw-r--r--contrib/tcpdump/print-ldp.c224
-rw-r--r--contrib/tcpdump/print-llc.c166
-rw-r--r--contrib/tcpdump/print-lldp.c646
-rw-r--r--contrib/tcpdump/print-lmp.c431
-rw-r--r--contrib/tcpdump/print-loopback.c136
-rw-r--r--contrib/tcpdump/print-lspping.c365
-rw-r--r--contrib/tcpdump/print-lwapp.c107
-rw-r--r--contrib/tcpdump/print-lwres.c227
-rw-r--r--contrib/tcpdump/print-m3ua.c339
-rw-r--r--contrib/tcpdump/print-mobile.c46
-rw-r--r--contrib/tcpdump/print-mobility.c180
-rw-r--r--contrib/tcpdump/print-mpcp.c138
-rw-r--r--contrib/tcpdump/print-mpls.c58
-rw-r--r--contrib/tcpdump/print-mptcp.c429
-rw-r--r--contrib/tcpdump/print-msdp.c52
-rw-r--r--contrib/tcpdump/print-msnlb.c22
-rw-r--r--contrib/tcpdump/print-netbios.c91
-rw-r--r--contrib/tcpdump/print-nflog.c167
-rw-r--r--contrib/tcpdump/print-nfs.c1227
-rw-r--r--contrib/tcpdump/print-ntp.c305
-rw-r--r--contrib/tcpdump/print-null.c54
-rw-r--r--contrib/tcpdump/print-olsr.c252
-rw-r--r--contrib/tcpdump/print-openflow-1.0.c2078
-rw-r--r--contrib/tcpdump/print-openflow.c119
-rw-r--r--contrib/tcpdump/print-ospf.c684
-rw-r--r--contrib/tcpdump/print-ospf6.c815
-rw-r--r--contrib/tcpdump/print-otv.c38
-rw-r--r--contrib/tcpdump/print-pflog.c71
-rw-r--r--contrib/tcpdump/print-pfsync.c1
-rw-r--r--contrib/tcpdump/print-pgm.c469
-rw-r--r--contrib/tcpdump/print-pim.c656
-rw-r--r--contrib/tcpdump/print-pktap.c169
-rw-r--r--contrib/tcpdump/print-ppi.c35
-rw-r--r--contrib/tcpdump/print-ppp.c974
-rw-r--r--contrib/tcpdump/print-pppoe.c71
-rw-r--r--contrib/tcpdump/print-pptp.c1097
-rw-r--r--contrib/tcpdump/print-radius.c277
-rw-r--r--contrib/tcpdump/print-raw.c19
-rw-r--r--contrib/tcpdump/print-rip.c142
-rw-r--r--contrib/tcpdump/print-ripng.c108
-rw-r--r--contrib/tcpdump/print-rpki-rtr.c68
-rw-r--r--contrib/tcpdump/print-rrcp.c27
-rw-r--r--contrib/tcpdump/print-rsvp.c629
-rw-r--r--contrib/tcpdump/print-rt6.c44
-rw-r--r--contrib/tcpdump/print-rx.c1094
-rw-r--r--contrib/tcpdump/print-sctp.c687
-rw-r--r--contrib/tcpdump/print-sflow.c480
-rw-r--r--contrib/tcpdump/print-sip.c30
-rw-r--r--contrib/tcpdump/print-sl.c117
-rw-r--r--contrib/tcpdump/print-sll.c174
-rw-r--r--contrib/tcpdump/print-slow.c275
-rw-r--r--contrib/tcpdump/print-smb.c566
-rw-r--r--contrib/tcpdump/print-snmp.c669
-rw-r--r--contrib/tcpdump/print-stp.c244
-rw-r--r--contrib/tcpdump/print-sunatm.c26
-rw-r--r--contrib/tcpdump/print-sunrpc.c141
-rw-r--r--contrib/tcpdump/print-symantec.c65
-rw-r--r--contrib/tcpdump/print-syslog.c78
-rw-r--r--contrib/tcpdump/print-tcp.c583
-rw-r--r--contrib/tcpdump/print-telnet.c348
-rw-r--r--contrib/tcpdump/print-tftp.c102
-rw-r--r--contrib/tcpdump/print-timed.c140
-rw-r--r--contrib/tcpdump/print-tipc.c95
-rw-r--r--contrib/tcpdump/print-token.c139
-rw-r--r--contrib/tcpdump/print-udld.c74
-rw-r--r--contrib/tcpdump/print-udp.c416
-rw-r--r--contrib/tcpdump/print-usb.c47
-rw-r--r--contrib/tcpdump/print-vjc.c41
-rw-r--r--contrib/tcpdump/print-vqp.c71
-rw-r--r--contrib/tcpdump/print-vrrp.c109
-rw-r--r--contrib/tcpdump/print-vtp.c121
-rw-r--r--contrib/tcpdump/print-vxlan.c36
-rw-r--r--contrib/tcpdump/print-wb.c216
-rw-r--r--contrib/tcpdump/print-zephyr.c85
-rw-r--r--contrib/tcpdump/print-zeromq.c127
-rw-r--r--contrib/tcpdump/route6d.h77
-rw-r--r--contrib/tcpdump/rpc_auth.h5
-rw-r--r--contrib/tcpdump/rpc_msg.h25
-rw-r--r--contrib/tcpdump/rpl.h174
-rw-r--r--contrib/tcpdump/rx.h113
-rw-r--r--contrib/tcpdump/sctpConstants.h571
-rw-r--r--contrib/tcpdump/sctpHeader.h323
-rw-r--r--contrib/tcpdump/setsignal.c7
-rw-r--r--contrib/tcpdump/setsignal.h2
-rw-r--r--contrib/tcpdump/signature.c31
-rw-r--r--contrib/tcpdump/signature.h7
-rw-r--r--contrib/tcpdump/slcompress.h2
-rw-r--r--contrib/tcpdump/slip.h34
-rw-r--r--contrib/tcpdump/sll.h127
-rw-r--r--contrib/tcpdump/smb.h6
-rw-r--r--contrib/tcpdump/smbutil.c277
-rw-r--r--contrib/tcpdump/strcasecmp.c5
-rw-r--r--contrib/tcpdump/tcp.h28
-rw-r--r--contrib/tcpdump/tcpdump-stdinc.h184
-rw-r--r--contrib/tcpdump/tcpdump.1.in228
-rw-r--r--contrib/tcpdump/tcpdump.c718
-rw-r--r--contrib/tcpdump/telnet.h348
-rw-r--r--contrib/tcpdump/tftp.h82
-rw-r--r--contrib/tcpdump/timed.h97
-rw-r--r--contrib/tcpdump/token.h53
-rw-r--r--contrib/tcpdump/udp.h13
-rw-r--r--contrib/tcpdump/util.c209
-rw-r--r--contrib/tcpdump/vfprintf.c5
273 files changed, 30584 insertions, 25301 deletions
diff --git a/contrib/tcpdump/CHANGES b/contrib/tcpdump/CHANGES
index fbf11db667bf..62e57ebab7ca 100644
--- a/contrib/tcpdump/CHANGES
+++ b/contrib/tcpdump/CHANGES
@@ -1,4 +1,61 @@
-Thursday February 19, 2013 guy@alum.mit.edu.
+Tuesday Sep. 2, 2014 mcr@sandelman.ca
+ fix out-of-source-tree builds: find libpcap that is out of source
+ better configure check for libsmi
+
+Saturday Jul. 19, 2014 mcr@sandelman.ca
+ Summary for 4.6.1 tcpdump release
+ added FreeBSD capsicum
+ add a short option '#', same as long option '--number'
+
+Wednesday Jul. 2, 2014 mcr@sandelman.ca
+ Summary for 4.6.0 tcpdump release
+ all of tcpdump is now using the new "NDO" code base (Thanks Denis!)
+ nflog, mobile, forces, pptp, AODV, AHCP, IPv6, OSPFv4, RPL, DHCPv6 enhancements/fixes
+ M3UA decode added.
+ many new test cases: 82 in 4.5.1 to 133 in 4.6.0
+ many improvements to travis continuous integration system: OSX, and Coverity options
+ cleaned up some unnecessary header files
+ Added bittok2str().
+ a number of unaligned access faults fixed
+ -A flag does not consider CR to be printable anymore
+ fx.lebail took over coverity baby sitting
+ default snapshot size increased to 256K for accomodate USB captures
+ WARNING: this release contains a lot of very worthwhile code churn.
+
+Wednesday Jan. 15, 2014 guy@alum.mit.edu
+ Summary for 4.5.2 tcpdump release
+ Man page fix
+ Fix crashes on SPARC
+
+Monday Nov. 11, 2013 mcr@sandelman.ca
+ Summary for 4.5.1 tcpdump release
+ CREDITS file fixes
+
+Thursday Nov. 7, 2013 mcr@sandelman.ca and guy@alum.mit.edu.
+ Summary for 4.5.0 tcpdump release
+ some NFSv4 fixes for printing
+ fix printing of unknown TCP options, and tcp fast-open
+ fixes for syslog parser
+ some gcc-version-specific flag tuning
+ adopt MacOS deprecation workarounds for openssl
+ improvements to babel printing
+ add OpenFlow 1.0 (no SSL) and test cases
+ GeoNet printer.
+ added STBC Rx support
+ improvements to DHCPv6 decoder
+ clarify which autoconf is needed
+ Point users to the the-tcpdump-group repository on GitHub rather
+ than the mcr repository
+ Add MSDP printer.
+ Fixed IPv6 check on Solaris and other OSes requiring extra
+ networking libraries.
+ Add support for VXLAN (draft-mahalingam-dutt-dcops-vxlan-03),
+ and add "vxlan" as an option for -T.
+ Add support for OTV (draft-hasmit-otv-04).
+ fixes for DLT_IEEE802_11_RADIO datalink types
+ added MPTCP decoder
+
+Saturday April 6, 2013 guy@alum.mit.edu.
Summary for 4.4.0 tcpdump release
RPKI-RTR (RFC6810) is now official (TCP Port 323)
Fix detection of OpenSSL libcrypto.
@@ -16,6 +73,8 @@ Thursday February 19, 2013 guy@alum.mit.edu.
On Linux systems with cap-ng.h, drop root privileges
using Linux Capabilities.
Add support for reading multiple files.
+ Add MS NLB heartbeat printer.
+ Separate multiple nexthops in BGP.
Wednesday November 28, 2012 guy@alum.mit.edu.
Summary for 4.3.1 tcpdump release
@@ -32,7 +91,7 @@ Wednesday November 28, 2012 guy@alum.mit.edu.
Use the right maximum path length
Don't treat 192_1_2, when passed to -i, as an interface number
-Friday April 3, 2011. mcr@sandelman.ca.
+Friday April 3, 2012. mcr@sandelman.ca.
Summary for 4.3.0 tcpdump release
fixes for forces: SPARSE data (per RFC 5810)
some more test cases added
@@ -113,7 +172,7 @@ Thu. April 1, 2010. guy@alum.mit.edu.
Summary for 4.1.1 tcpdump release
Fix build on systems with PF, such as FreeBSD and OpenBSD.
Don't blow up if a zero-length link-layer address is passed to
- linkaddr_string().
+ linkaddr_string().
Thu. March 11, 2010. ken@netfunctional.ca/guy@alum.mit.edu.
Summary for 4.1.0 tcpdump release
@@ -142,7 +201,7 @@ Thu. March 11, 2010. ken@netfunctional.ca/guy@alum.mit.edu.
Add printer for ForCES
Handle frames with an FCS
Handle 802.11n Control Wrapper, Block Acq Req and Block Ack frames
- Fix TCP sequence number printing
+ Fix TCP sequence number printing
Report 802.2 packets as 802.2 instead of 802.3
Don't include -L/usr/lib in LDFLAGS
On x86_64 Linux, look in lib64 directory too
@@ -178,13 +237,13 @@ Mon. September 10, 2007. ken@xelerance.com. Summary for 3.9.8 tcpdump relea
Converted print-isakmp.c to NETDISSECT
Moved AF specific stuff into af.h
Test subsystem now table driven, and saves outputs and diffs to one place
- Require <net/pfvar.h> for pf definitions - allows reading of pflog formatted
+ Require <net/pfvar.h> for pf definitions - allows reading of pflog formatted
libpcap files on an OS other than where the file was generated
Wed. July 23, 2007. mcr@xelerance.com. Summary for 3.9.7 libpcap release
- NFS: Print unsigned values as such.
+ NFS: Print unsigned values as such.
RX: parse safely.
BGP: fixes for IPv6-less builds.
801.1ag: use standard codepoint.
@@ -194,7 +253,7 @@ Wed. July 23, 2007. mcr@xelerance.com. Summary for 3.9.7 libpcap release
smb: squelch an uninitialized complaint from coverity.
NFS: from NetBSD; don't interpret the reply as a possible NFS reply
if it got MSG_DENIED.
- BGP: don't print TLV values that didn't fit, from www.digit-labs.org.
+ BGP: don't print TLV values that didn't fit, from www.digit-labs.org.
revised INSTALL.txt about libpcap dependancy.
Wed. April 25, 2007. ken@xelerance.com. Summary for 3.9.6 tcpdump release
@@ -212,11 +271,11 @@ Wed. April 25, 2007. ken@xelerance.com. Summary for 3.9.6 tcpdump release
Add support for 802.3ah loopback ctrl msg
Add support for Multiple-STP as per 802.1s
Add support for rapid-SPT as per 802.1w
- Add support for CFM Link-trace msg, Link-trace-Reply msg,
+ Add support for CFM Link-trace msg, Link-trace-Reply msg,
Sender-ID tlv, private tlv, port, interface status
Add support for unidirectional link detection as per
http://www.ietf.org/internet-drafts/draft-foschiano-udld-02.txt
- Add support for the olsr protocol as per RFC 3626 plus the LQ
+ Add support for the olsr protocol as per RFC 3626 plus the LQ
extensions from olsr.org
Add support for variable-length checksum in DCCP, as per section 9 of
RFC 4340.
@@ -228,7 +287,7 @@ Wed. April 25, 2007. ken@xelerance.com. Summary for 3.9.6 tcpdump release
Tue. September 19, 2006. ken@xelerance.com. Summary for 3.9.5 tcpdump release
-
+
Fix compiling on AIX (, at end of ENUM)
Updated list of DNS RR typecodes
Use local Ethernet defs on WIN32
@@ -243,7 +302,7 @@ Tue. September 19, 2006. ken@xelerance.com. Summary for 3.9.5 tcpdump release
Add support for BGP signaled VPLS
Cleanup the bootp printer
Add support for PPP over Frame-Relay
- Add some bounds checking to the IP options code, and clean up
+ Add some bounds checking to the IP options code, and clean up
the options output a bit.
Add additional modp groups to ISAKMP printer
Add support for Address-Withdraw and Label-Withdraw Msgs
diff --git a/contrib/tcpdump/CREDITS b/contrib/tcpdump/CREDITS
index bdbfd36e80e4..b8ef1e07a93c 100644
--- a/contrib/tcpdump/CREDITS
+++ b/contrib/tcpdump/CREDITS
@@ -2,18 +2,20 @@ This file lists people who have contributed to tcpdump:
The current maintainers:
Bill Fenner <fenner at research dot att dot com>
- David Young <dyoung at pobox dot com>
+ Denis Ovsienko <infrastation at yandex dot ru>
Fulvio Risso <risso at polito dot it>
Guy Harris <guy at alum dot mit dot edu>
Hannes Gredler <hannes at juniper dot net>
Michael Richardson <mcr at sandelman dot ottawa dot on dot ca>
+ Francois-Xavier Le Bail <fx dot lebail at yahoo dot com>
Additional people who have contributed patches:
- A Costa <agcosta at gis dot net>
Aaron Campbell <aaron at arbor dot net>
- Alfredo Andres <aandres at s21sec dot com>
+ A Costa <agcosta at gis dot net>
Albert Chin <china at thewrittenword dot com>
+ Alexandra Kossovsky <alexandra1975 at sourceforge dot net>
+ Alfredo Andres <aandres at s21sec dot com>
Ananth Suryanarayana <anantha at juniper dot net>
Andrea Bittau <a dot bittau at cs dot ucl dot ac dot uk>
Andrew Brown <atatat at atatdot dot net>
@@ -26,17 +28,19 @@ Additional people who have contributed patches:
Arkadiusz Miskiewicz <misiek at pld dot org dot pl>
Armando L. Caro Jr. <acaro at mail dot eecis dot udel dot edu>
Arnaldo Carvalho de Melo <acme at ghostprotocols dot net>
- Ben Byer <bushing at sourceforge dot net>
Atsushi Onoe <onoe at netbsd dot org>
+ Baptiste Jonglez <baptiste dot jonglez at ens-lyon dot org>
+ Ben Byer <bushing at sourceforge dot net>
Ben Smithurst <ben at scientia dot demon dot co dot uk>
Bert Vermeulen <bert at biot dot com>
Bjoern A. Zeeb <bzeeb at Zabbadoz dot NeT>
+ Bram <tcpdump at mail dot wizbit dot be>
Brent L. Bates <blbates at vigyan dot com>
Brian Ginsbach <ginsbach at cray dot com>
Bruce M. Simpson <bms at spc dot org>
Carles Kishimoto Bisbe <ckishimo at ac dot upc dot es>
- Charlie Lenahan <clenahan at fortresstech dot com>
Charles M. Hannum <mycroft at netbsd dot org>
+ Charlie Lenahan <clenahan at fortresstech dot com>
Chris Cogdon <chris at cogdon dot org>
Chris G. Demetriou <cgd at netbsd dot org>
Chris Jepeway <jepeway at blasted-heath dot com>
@@ -52,7 +56,7 @@ Additional people who have contributed patches:
David Horn <dhorn2000 at gmail dot com>
David Smith <dsmith at redhat dot com>
David Young <dyoung at ojctech dot com>
- Denis Ovsienko <infrastation at yandex dot ru>
+ Dmitrij Tejblum <tejblum at yandex-team dot ru>
Dmitry Eremin-Solenikov <dbaryshkov at gmail dot com>
Don Ebright <Don dot Ebright at compuware dot com>
Eddie Kohler <xexd at sourceforge dot net>
@@ -60,22 +64,24 @@ Additional people who have contributed patches:
Fang Wang <fangwang at sourceforge dot net>
Florent Drouin <Florent dot Drouin at alcatel-lucent dot fr>
Florian Forster <octo at verplant dot org>
- Francis Dupont <Francis dot Dupont at enst-bretagne dot fr>
+ fra <foo at bar dot baz>
+ Francesco Fondelli <francesco dot fondelli at gmail dot com>
Francisco Matias Cuenca-Acuna <mcuenca at george dot rutgers dot edu>
- Francois-Xavier Le Bail <fx dot lebail at yahoo dot com>
+ Francis Dupont <Francis dot Dupont at enst-bretagne dot fr>
Frank Volf <volf at oasis dot IAEhv dot nl>
Fulvio Risso <risso at polito dot it>
George Bakos <gbakos at ists dot dartmouth dot edu>
Gerald Combs <gerald at ethereal dot com>
Gerrit Renker <gerrit at erg dot abdn dot ac dot uk>
Gert Doering <gert at greenie dot muc dot de>
+ Gilbert Ramirez Jr. <gram at xiexie dot org>
+ Gisle Vanem <gvanem at yahoo dot no>
Greg Minshall <minshall at acm dot org>
+ Grégoire Henry <henry at pps dot jussieu dot fr>
+ Gregory Detal <gregory dot detal at uclouvain dot be>
Greg Stark <gsstark at mit dot edu>
- Grégoire Henry <henry@pps.jussieu.fr>
- Gilbert Ramirez Jr. <gram at xiexie dot org>
- Gisle Vanem <gvanem at broadpark dot no>
- Hannes Viertel <hviertel at juniper dot net>
Hank Leininger <tcpdump-workers at progressive-comp dot com>
+ Hannes Viertel <hviertel at juniper dot net>
Harry Raaymakers <harryr at connect dot com dot au>
Heinz-Ado Arnolds <Ado dot Arnolds at dhm-systems dot de>
Hendrik Scholz <hendrik at scholz dot net>
@@ -90,34 +96,37 @@ Additional people who have contributed patches:
Jeffrey Hutzelman <jhutz at cmu dot edu>
Jesper Peterson <jesper at endace dot com>
Jim Hutchins <jim at ca dot sandia dot gov>
- Jonathan Heusser <jonny at drugphish dot ch>
- Tatuya Jinmei <jinmei at kame dot net>
João Medeiros <ignotus21 at sourceforge dot net>
- Joerg Mayer <jmayer@loplof.de>
- Jørgen Thomsen <jth at jth dot net>
+ Joerg Mayer <jmayer at loplof dot de>
+ Jonathan Heusser <jonny at drugphish dot ch>
+ Jorge Boncompte [DTI2] <jorge at dti2 dot net>
+ Jørgen Thomsen <jth at jth dot net>
Julian Cowley <julian at lava dot net>
- Juliusz Chroboczek <jch@pps.jussieu.fr>
+ Juliusz Chroboczek <jch at pps dot jussieu dot fr>
Kaarthik Sivakumar <kaarthik at torrentnet dot com>
Kaladhar Musunuru <kaladharm at sourceforge dot net>
Karl Norby <karl-norby at sourceforge dot net>
Kazushi Sugyo <sugyo at pb dot jp dot nec dot com>
Kelly Carmichael <kcarmich at ipapp dot com>
Ken Hornstein <kenh at cmf dot nrl dot navy dot mil>
- Kevin Steves <stevesk at pobox dot com>
Kenichi Maehashi <webmaster at kenichimaehashi dot com>
+ Kevin Steves <stevesk at pobox dot com>
Klaus Klein <kleink at reziprozitaet dot de>
Kris Kennaway <kris at freebsd dot org>
Krzysztof Halasa <khc at pm dot waw dot pl>
Larry Lile <lile at stdio dot com>
Lennert Buytenhek <buytenh at gnu dot org>
+ Loganaden Velvindron <logan at elandsys dot com>
+ Longinus00 <Longinus00 at gmail dot com>
Loris Degioanni <loris at netgroup-serv dot polito dot it>
Love Hörnquist-Åstrand <lha at stacken dot kth dot se>
Lucas C. Villa Real <lucasvr at us dot ibm dot com>
Luis MartinGarcia <luis dot mgarc at gmail dot com>
Maciej W. Rozycki <macro at ds2 dot pg dot gda dot pl>
Manu Pathak <mapathak at cisco dot com>
- Marc Binderberger <mbind at sourceforge dot net>
+ Marc Abramowitz <marc at marc-abramowitz dot com>
Marc A. Lehmann <pcg at goof dot com>
+ Marc Binderberger <mbind at sourceforge dot net>
Mark Ellzey Thomas <mark at ackers dot net>
Marko Kiiskila <carnil at cs dot tut dot fi>
Markus Schöpflin <schoepflin at sourceforge dot net>
@@ -136,14 +145,16 @@ Additional people who have contributed patches:
Minto Jeyananth <minto at juniper dot net>
Monroe Williams <monroe at pobox dot com>
Motonori Shindo <mshindo at mshindo dot net>
- Nathan J. Williams <nathanw at MIT dot EDU>
Nathaniel Couper-Noles <Nathaniel at isi1 dot tccisi dot com>
+ Nathan J. Williams <nathanw at MIT dot EDU>
Neil T. Spring <bluehal at users dot sourceforge dot net>
- Niels Provos <provos at openbsd dot org>
Nickolai Zeldovich <kolya at MIT dot EDU>
Nicolas Ferrero <toorop at babylo dot net>
+ Niels Provos <provos at openbsd dot org>
Noritoshi Demizu <demizu at users dot sourceforge dot net>
Olaf Kirch <okir at caldera dot de>
+ Ola Martin Lykkja <ola dot lykkja at q-free dot com>
+ Oleksij Rempel <linux at rempel-privat dot de>
Onno van der Linden <onno at simplex dot nl>
Paolo Abeni <paolo dot abeni at email dot it>
Pascal Hennequin <pascal dot hennequin at int-evry dot fr>
@@ -153,11 +164,12 @@ Additional people who have contributed patches:
Paul S. Traina <pst at freebsd dot org>
Pavlin Radoslavov <pavlin at icir dot org>
Pawel Worach <pawel dot worach at gmail dot com>
- Pekka Savola <pekkas at netcore dot fi>
+ Pekka Savola <pekkas at netcore dot fi>
+ Petar Alilovic <petar dot alilovic at gmail dot com>
Peter Fales <peter at fales-lorenz dot net>
Peter Jeremy <peter dot jeremy at alcatel dot com dot au>
- <pfhunt at users dot sourceforge dot net>
Peter Volkov <pva at gentoo dot org>
+ <pfhunt at users dot sourceforge dot net>
Phil Wood <cpw at lanl dot gov>
Rafal Maszkowski <rzm at icm dot edu dot pl>
Randy Sofia <rsofia at users dot sourceforge dot net>
@@ -169,9 +181,10 @@ Additional people who have contributed patches:
Robert Edmonds <stu-42 at sourceforge dot net>
Roderick Schertler <roderick at argon dot org>
Romain Francoise <rfrancoise at debian dot org>
+ Ruben Kerkhof <ruben at rubenkerkhof dot com>
Sagun Shakya <sagun dot shakya at sun dot com>
Sami Farin <safari at iki dot fi>
- Scott Mcmillan <scott.a.mcmillan at intel dot com>
+ Scott Mcmillan <scott dot a dot mcmillan at intel dot com>
Scott Rose <syberpunk at users dot sourceforge dot net>
Sebastian Krahmer <krahmer at cs dot uni-potsdam dot de>
Sebastien Raveau <sebastien dot raveau at epita dot fr>
@@ -181,20 +194,27 @@ Additional people who have contributed patches:
Shinsuke Suzuki <suz at kame dot net>
Simon Ruderich <simon at ruderich dot org>
Steinar Haug <sthaug at nethelp dot no>
+ Stephane Bortzmeyer <stephane+github at bortzmeyer dot org>
Swaminathan Chandrasekaran <chander at juniper dot net>
+ Swaathi Vetrivel <swaathiv at juniper dot net>
Takashi Yamamoto <yamt at mwd dot biglobe dot ne dot jp>
+ Tatuya Jinmei <jinmei at kame dot net>
Terry Kennedy <terry at tmk dot com>
+ Thomas Jacob <jacob at internet24 dot de>
Timo Koskiahde
Tony Li <tli at procket dot com>
Toshihiro Kanda <candy at fct dot kgc dot co dot jp>
+ Udayakumar <udaya011 at gmail dot com>
Uns Lider <unslider at miranda dot org>
Victor Oppleman <oppleman at users dot sourceforge dot net>
+ Vyacheslav Trushkin <dogonthesun at gmail dot com>
Weesan Lee <weesan at juniper dot net>
Wesley Griffin <wgriffin at users dot sourceforge dot net>
Wesley Shields <wxs at FreeBSD dot org>
Wilbert de Graaf <wilbertdg at hetnet dot nl>
Will Drewry <will at alum dot bu dot edu>
William J. Hulley <bill dot hulley at gmail dot com>
+ Wim Torfs <wtorfs at gmail dot com>
Yen Yen Lim
Yoshifumi Nishida
@@ -204,4 +224,4 @@ The original LBL crew:
Van Jacobson
Past maintainers:
- Jun-ichiro itojun Hagino <itojun at iijlab dot net>
+ Jun-ichiro itojun Hagino <itojun at iijlab dot net> Also see: http://www.wide.ad.jp/itojun-award/
diff --git a/contrib/tcpdump/INSTALL.txt b/contrib/tcpdump/INSTALL.txt
index a03e2c0001b3..6a0e6b8e1437 100644
--- a/contrib/tcpdump/INSTALL.txt
+++ b/contrib/tcpdump/INSTALL.txt
@@ -1,5 +1,3 @@
-@(#) $Header: /tcpdump/master/tcpdump/INSTALL.txt,v 1.2 2008-02-06 10:47:53 guy Exp $ (LBL)
-
If you have not built libpcap, and your system does not have libpcap
installed, install libpcap first. Your system might provide a version
of libpcap that can be installed; if so, to compile tcpdump you might
@@ -9,9 +7,7 @@ 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/
+the generally available GNU C compiler (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
@@ -42,25 +38,20 @@ 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
@@ -72,37 +63,21 @@ 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
@@ -113,23 +88,18 @@ 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
@@ -184,7 +154,6 @@ 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
@@ -226,18 +195,12 @@ 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
@@ -245,10 +208,6 @@ 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
diff --git a/contrib/tcpdump/Makefile-devel-adds b/contrib/tcpdump/Makefile-devel-adds
index 512a1199795c..7bf6420c1c82 100644
--- a/contrib/tcpdump/Makefile-devel-adds
+++ b/contrib/tcpdump/Makefile-devel-adds
@@ -2,12 +2,12 @@
# Auto-regenerate configure script or Makefile when things change.
# From autoconf.info . Works best with GNU Make.
#
-${srcdir}/configure: configure.in
+${srcdir}/configure: configure.in aclocal.m4
cd ${srcdir} && autoconf
# autoheader might not change config.h.in, so touch a stamp file.
${srcdir}/config.h.in: ${srcdir}/stamp-h.in
-${srcdir}/stamp-h.in: configure.in acconfig.h
+${srcdir}/stamp-h.in: configure.in aclocal.m4
cd ${srcdir} && autoheader
echo timestamp > ${srcdir}/stamp-h.in
diff --git a/contrib/tcpdump/Makefile.in b/contrib/tcpdump/Makefile.in
index fc3c990257b1..a6f1cf77c800 100644
--- a/contrib/tcpdump/Makefile.in
+++ b/contrib/tcpdump/Makefile.in
@@ -16,8 +16,6 @@
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-#
-# @(#) $Header: /tcpdump/master/tcpdump/Makefile.in,v 1.325 2008-11-21 23:17:26 guy Exp $ (LBL)
#
# Various configurable paths (remember to edit Makefile.in, not Makefile)
@@ -41,6 +39,8 @@ VPATH = @srcdir@
#
CC = @CC@
+AR = @AR@
+MKDEP = @MKDEP@
PROG = tcpdump
CCOPT = @V_CCOPT@
INCLS = -I. @V_INCLS@
@@ -61,6 +61,8 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
RANLIB = @RANLIB@
+DEPENDENCY_CFLAG = @DEPENDENCY_CFLAG@
+
# Explicitly define compilation rule since SunOS 4's make doesn't like gcc.
# Also, gcc does not remove the .o before forking 'as', which can be a
# problem if you don't own the file but can write to the directory.
@@ -68,126 +70,205 @@ RANLIB = @RANLIB@
@rm -f $@
$(CC) $(FULL_CFLAGS) -c $(srcdir)/$*.c
-CSRC = addrtoname.c af.c checksum.c cpack.c gmpls.c oui.c gmt2local.c ipproto.c \
- nlpid.c l2vpn.c machdep.c parsenfsfh.c in_cksum.c \
- print-802_11.c print-802_15_4.c print-ap1394.c print-ah.c \
- print-arcnet.c print-aodv.c print-arp.c print-ascii.c print-atalk.c \
- print-atm.c print-beep.c print-bfd.c print-bgp.c \
- print-bootp.c print-bt.c print-carp.c print-cdp.c print-cfm.c \
- print-chdlc.c print-cip.c print-cnfp.c print-dccp.c print-decnet.c \
- print-domain.c print-dtp.c print-dvmrp.c print-enc.c print-egp.c \
- print-eap.c print-eigrp.c\
- print-esp.c print-ether.c print-fddi.c print-forces.c print-fr.c \
- print-gre.c print-hsrp.c print-icmp.c print-igmp.c \
- print-igrp.c print-ip.c print-ipcomp.c print-ipfc.c print-ipnet.c \
- print-ipx.c print-isoclns.c print-juniper.c print-krb.c \
- print-l2tp.c print-lane.c print-ldp.c print-lldp.c print-llc.c \
- print-lmp.c print-lspping.c print-lwapp.c \
- print-lwres.c print-mobile.c print-mpcp.c print-mpls.c print-msdp.c \
- print-msnlb.c print-nfs.c print-ntp.c print-null.c print-olsr.c print-ospf.c \
- print-pgm.c print-pim.c \
- print-ppi.c print-ppp.c print-pppoe.c print-pptp.c \
- print-radius.c print-raw.c print-rip.c print-rpki-rtr.c print-rrcp.c print-rsvp.c \
- print-rx.c print-sctp.c print-sflow.c print-sip.c print-sl.c print-sll.c \
- print-slow.c print-snmp.c print-stp.c print-sunatm.c print-sunrpc.c \
- print-symantec.c print-syslog.c print-tcp.c print-telnet.c print-tftp.c \
- print-timed.c print-tipc.c print-token.c print-udld.c print-udp.c \
- print-usb.c print-vjc.c print-vqp.c print-vrrp.c print-vtp.c \
- print-wb.c print-zephyr.c print-zeromq.c print-vxlan.c print-otv.c signature.c setsignal.c tcpdump.c util.c
-
-LIBNETDISSECT_SRC=print-isakmp.c
-LIBNETDISSECT_OBJ=$(LIBNETDISSECT_SRC:.c=.o)
-LIBNETDISSECT=libnetdissect.a
+CSRC = setsignal.c tcpdump.c
+
+LIBNETDISSECT_SRC=\
+ addrtoname.c \
+ af.c \
+ checksum.c \
+ cpack.c \
+ gmpls.c \
+ gmt2local.c \
+ in_cksum.c \
+ ipproto.c \
+ l2vpn.c \
+ machdep.c \
+ nlpid.c \
+ oui.c \
+ parsenfsfh.c \
+ print-802_11.c \
+ print-802_15_4.c \
+ print-ah.c \
+ print-ahcp.c \
+ print-aodv.c \
+ print-aoe.c \
+ print-ap1394.c \
+ print-arcnet.c \
+ print-arp.c \
+ print-ascii.c \
+ print-atalk.c \
+ print-atm.c \
+ print-beep.c \
+ print-bfd.c \
+ print-bgp.c \
+ print-bootp.c \
+ print-bt.c \
+ print-calm-fast.c \
+ print-carp.c \
+ print-cdp.c \
+ print-cfm.c \
+ print-chdlc.c \
+ print-cip.c \
+ print-cnfp.c \
+ print-dccp.c \
+ print-decnet.c \
+ print-domain.c \
+ print-dtp.c \
+ print-dvmrp.c \
+ print-eap.c \
+ print-egp.c \
+ print-eigrp.c \
+ print-enc.c \
+ print-esp.c \
+ print-ether.c \
+ print-fddi.c \
+ print-forces.c \
+ print-fr.c \
+ print-geonet.c \
+ print-gre.c \
+ print-hsrp.c \
+ print-icmp.c \
+ print-igmp.c \
+ print-igrp.c \
+ print-ip.c \
+ print-ipcomp.c \
+ print-ipfc.c \
+ print-ipnet.c \
+ print-ipx.c \
+ print-isakmp.c \
+ print-isoclns.c \
+ print-juniper.c \
+ print-krb.c \
+ print-l2tp.c \
+ print-lane.c \
+ print-ldp.c \
+ print-llc.c \
+ print-lldp.c \
+ print-lmp.c \
+ print-loopback.c \
+ print-lspping.c \
+ print-lwapp.c \
+ print-lwres.c \
+ print-m3ua.c \
+ print-mobile.c \
+ print-mpcp.c \
+ print-mpls.c \
+ print-mptcp.c \
+ print-msdp.c \
+ print-msnlb.c \
+ print-nflog.c \
+ print-nfs.c \
+ print-ntp.c \
+ print-null.c \
+ print-olsr.c \
+ print-openflow-1.0.c \
+ print-openflow.c \
+ print-ospf.c \
+ print-otv.c \
+ print-pgm.c \
+ print-pim.c \
+ print-pktap.c \
+ print-ppi.c \
+ print-ppp.c \
+ print-pppoe.c \
+ print-pptp.c \
+ print-radius.c \
+ print-raw.c \
+ print-rip.c \
+ print-rpki-rtr.c \
+ print-rrcp.c \
+ print-rsvp.c \
+ print-rx.c \
+ print-sctp.c \
+ print-sflow.c \
+ print-sip.c \
+ print-sl.c \
+ print-sll.c \
+ print-slow.c \
+ print-snmp.c \
+ print-stp.c \
+ print-sunatm.c \
+ print-sunrpc.c \
+ print-symantec.c \
+ print-syslog.c \
+ print-tcp.c \
+ print-telnet.c \
+ print-tftp.c \
+ print-timed.c \
+ print-tipc.c \
+ print-token.c \
+ print-udld.c \
+ print-udp.c \
+ print-usb.c \
+ print-vjc.c \
+ print-vqp.c \
+ print-vrrp.c \
+ print-vtp.c \
+ print-vxlan.c \
+ print-wb.c \
+ print-zephyr.c \
+ print-zeromq.c \
+ signature.c \
+ util.c
LOCALSRC = @LOCALSRC@
GENSRC = version.c
LIBOBJS = @LIBOBJS@
+LIBNETDISSECT_OBJ=$(LIBNETDISSECT_SRC:.c=.o) ${LOCALSRC:.c=.o} ${LIBOBJS}
+LIBNETDISSECT=libnetdissect.a
+
+
SRC = $(CSRC) $(GENSRC) $(LOCALSRC) $(LIBNETDISSECT_SRC)
# We would like to say "OBJ = $(SRC:.c=.o)" but Ultrix's make cannot
# hack the extra indirection
-OBJ = $(CSRC:.c=.o) $(GENSRC:.c=.o) $(LOCALSRC:.c=.o) $(LIBOBJS) $(LIBNETDISSECT_OBJ)
+OBJ = $(CSRC:.c=.o) $(GENSRC:.c=.o) $(LIBNETDISSECT_OBJ)
HDR = \
- acconfig.h \
addrtoname.h \
af.h \
ah.h \
- aodv.h \
appletalk.h \
- arcnet.h \
atm.h \
atmuni31.h \
bootp.h \
- bgp.h \
chdlc.h \
cpack.h \
- dccp.h \
- decnet.h \
- decode_prefix.h \
- enc.h \
- esp.h \
ether.h \
ethertype.h \
extract.h \
- fddi.h \
- forces.h \
+ getopt_long.h \
gmpls.h \
gmt2local.h \
- icmp6.h \
- ieee802_11.h \
- ieee802_11_radio.h \
- igrp.h \
interface.h \
interface.h \
ip.h \
ip6.h \
- ipfc.h \
- ipnet.h \
ipproto.h \
- ipsec_doi.h \
- ipx.h \
- isakmp.h \
- l2tp.h \
l2vpn.h \
- lane.h \
llc.h \
machdep.h \
mib.h \
mpls.h \
nameser.h \
- netbios.h \
netdissect.h \
nfs.h \
nfsfh.h \
nlpid.h \
- ntp.h \
- oakley.h \
+ openflow.h \
ospf.h \
- ospf6.h \
oui.h \
pcap-missing.h \
- pmap_prot.h \
- ppi.h \
ppp.h \
- route6d.h \
rpc_auth.h \
rpc_msg.h \
- rx.h \
- sctpConstants.h \
- sctpHeader.h \
+ rpl.h \
setsignal.h \
signature.h \
slcompress.h \
- slip.h \
- sll.h \
smb.h \
tcp.h \
tcpdump-stdinc.h \
- telnet.h \
- tftp.h \
- timed.h \
- token.h \
udp.h
TAGHDR = \
@@ -212,7 +293,7 @@ EXTRA_DIST = \
LICENSE \
Makefile.in \
Makefile-devel-adds \
- README \
+ README.md \
Readme.Win32 \
VERSION \
aclocal.m4 \
@@ -233,11 +314,11 @@ EXTRA_DIST = \
missing/dlnames.c \
missing/datalinks.c \
missing/getnameinfo.c \
+ missing/getopt_long.c \
missing/inet_aton.c \
missing/inet_ntop.c \
missing/inet_pton.c \
missing/snprintf.c \
- missing/sockstorage.h \
missing/strdup.c \
missing/strlcat.c \
missing/strlcpy.c \
@@ -252,7 +333,6 @@ EXTRA_DIST = \
print-ip6.c \
print-ip6opts.c \
print-mobility.c \
- print-netbios.c \
print-ospf6.c \
print-pflog.c \
print-ripng.c \
@@ -264,18 +344,14 @@ EXTRA_DIST = \
strcasecmp.c \
tcpdump.1.in \
vfprintf.c \
- win32/Include/bittypes.h \
- win32/Include/errno.h \
- win32/Include/getopt.h \
win32/Include/w32_fzs.h \
- win32/Src/getopt.c \
win32/prj/GNUmakefile \
win32/prj/WinDump.dsp \
win32/prj/WinDump.dsw
TEST_DIST= `find tests \( -name 'DIFF' -prune \) -o \( -name NEW -prune \) -o -type f \! -name '.*' \! -name '*~' -print`
-all: $(PROG)
+all: $(PROG) $(LIBNETDISSECT)
$(PROG): $(OBJ) @V_PCAPDEP@
@rm -f $@
@@ -283,7 +359,7 @@ $(PROG): $(OBJ) @V_PCAPDEP@
$(LIBNETDISSECT): $(LIBNETDISSECT_OBJ)
@rm -f $@
- $(AR) $(ARFLAGS) $@ $(LIBNETDISSECT_OBJ)
+ $(AR) $(ARFLAGS) $@ $(LIBNETDISSECT_OBJ)
$(RANLIB) $@
datalinks.o: $(srcdir)/missing/datalinks.c
@@ -292,8 +368,8 @@ dlnames.o: $(srcdir)/missing/dlnames.c
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/dlnames.c
getnameinfo.o: $(srcdir)/missing/getnameinfo.c
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/getnameinfo.c
-getaddrinfo.o: $(srcdir)/missing/getaddrinfo.c
- $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/getaddrinfo.c
+getopt_long.o: $(srcdir)/missing/getopt_long.c
+ $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/getopt_long.c
inet_pton.o: $(srcdir)/missing/inet_pton.c
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/inet_pton.c
inet_ntop.o: $(srcdir)/missing/inet_ntop.c
@@ -302,6 +378,8 @@ inet_aton.o: $(srcdir)/missing/inet_aton.c
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/inet_aton.c
snprintf.o: $(srcdir)/missing/snprintf.c
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c
+strdup.o: $(srcdir)/missing/strdup.c
+ $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strdup.c
strlcat.o: $(srcdir)/missing/strlcat.c
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strlcat.c
strlcpy.o: $(srcdir)/missing/strlcpy.c
@@ -345,8 +423,10 @@ clean:
distclean:
rm -f $(CLEANFILES) Makefile config.cache config.log config.status \
- config.h gnuc.h os-proto.h stamp-h stamp-h.in $(PROG).1
- rm -rf autom4te.cache
+ config.h gnuc.h os-proto.h stamp-h stamp-h.in $(PROG).1 \
+ libnetdissect.a tests/.failed tests/.passed \
+ tests/failure-outputs.txt
+ rm -rf autom4te.cache tests/DIFF tests/NEW
check: tcpdump
(cd tests && ./TESTrun.sh)
@@ -368,4 +448,4 @@ testlist:
echo $(TEST_DIST)
depend: $(GENSRC)
- ${srcdir}/mkdep -c $(CC) $(DEFS) $(INCLS) $(SRC)
+ $(MKDEP) -c $(CC) -m $(DEPENDENCY_CFLAG) $(DEFS) $(INCLS) $(SRC)
diff --git a/contrib/tcpdump/README b/contrib/tcpdump/README.md
index e7b5d65c69a0..c83ffab9f7b4 100644
--- a/contrib/tcpdump/README
+++ b/contrib/tcpdump/README.md
@@ -1,33 +1,35 @@
-@(#) $Header: /tcpdump/master/tcpdump/README,v 1.68 2008-12-15 00:05:27 guy Exp $ (LBL)
+# tcpdump
-TCPDUMP 4.x.y
-Now maintained by "The Tcpdump Group"
-See www.tcpdump.org
+[![Build
+Status](https://travis-ci.org/the-tcpdump-group/tcpdump.png)](https://travis-ci.org/the-tcpdump-group/tcpdump)
+
+TCPDUMP 4.x.y
+Now maintained by "The Tcpdump Group"
+See www.tcpdump.org
Please send inquiries/comments/reports to:
- tcpdump-workers@lists.tcpdump.org
+
+* tcpdump-workers@lists.tcpdump.org
Anonymous Git is available via:
- git clone git://bpf.tcpdump.org/tcpdump
-Version 4.x.y of TCPDUMP can be retrieved with the CVS tag "tcpdump_4_xrely":
- cvs -d :pserver:cvs.tcpdump.org:/tcpdump/master checkout -r tcpdump_4_xrely tcpdump
+ git clone git://bpf.tcpdump.org/tcpdump
-Please submit patches by forking the branch on GitHub at
+Please submit patches by forking the branch on GitHub at:
- http://github.com/mcr/tcpdump/tree/master
+* http://github.com/the-tcpdump-group/tcpdump/tree/master
and issuing a pull request.
-formerly from Lawrence Berkeley National Laboratory
- Network Research Group <tcpdump@ee.lbl.gov>
- ftp://ftp.ee.lbl.gov/tcpdump.tar.Z (3.4)
+formerly from Lawrence Berkeley National Laboratory
+ Network Research Group <tcpdump@ee.lbl.gov>
+ ftp://ftp.ee.lbl.gov/old/tcpdump.tar.Z (3.4)
This directory contains source code for tcpdump, a tool for network
monitoring and data acquisition. This software was originally
developed by the Network Research Group at the Lawrence Berkeley
National Laboratory. The original distribution is available via
-anonymous ftp to ftp.ee.lbl.gov, in tcpdump.tar.Z. More recent
+anonymous ftp to `ftp.ee.lbl.gov`, in `tcpdump.tar.Z`. More recent
development is performed at tcpdump.org, http://www.tcpdump.org/
Tcpdump uses libpcap, a system-independent interface for user-level
@@ -36,7 +38,7 @@ build libpcap, also originally from LBL and now being maintained by
tcpdump.org; see http://www.tcpdump.org/ .
Once libpcap is built (either install it or make sure it's in
-../libpcap), you can build tcpdump using the procedure in the INSTALL
+`../libpcap`), you can build tcpdump using the procedure in the `INSTALL.txt`
file.
The program is loosely based on SMI's "etherfind" although none of the
@@ -50,20 +52,20 @@ manual entry, with no access to the source of tcpdump or etherfind.
Over the past few years, tcpdump has been steadily improved by the
excellent contributions from the Internet community (just browse
-through the CHANGES file). We are grateful for all the input.
+through the `CHANGES` file). We are grateful for all the input.
Richard Stevens gives an excellent treatment of the Internet protocols
-in his book ``TCP/IP Illustrated, Volume 1''. If you want to learn more
+in his book *"TCP/IP Illustrated, Volume 1"*. If you want to learn more
about tcpdump and how to interpret its output, pick up this book.
Some tools for viewing and analyzing tcpdump trace files are available
from the Internet Traffic Archive:
- http://www.acm.org/sigcomm/ITA/
+* http://www.sigcomm.org/ITA/
Another tool that tcpdump users might find useful is tcpslice:
- ftp://ftp.ee.lbl.gov/tcpslice.tar.Z
+* https://github.com/the-tcpdump-group/tcpslice
It is a program that can be used to extract portions of tcpdump binary
trace files. See the above distribution for further details and
@@ -72,14 +74,14 @@ documentation.
Problems, bugs, questions, desirable enhancements, etc. should be sent
to the address "tcpdump-workers@lists.tcpdump.org". Bugs, support
requests, and feature requests may also be submitted on the GitHub issue
-tracker for tcpdump at
+tracker for tcpdump at:
- https://github.com/mcr/tcpdump/issues
+* https://github.com/the-tcpdump-group/tcpdump/issues
Source code contributions, etc. should be sent to the email address
-above or submitted by forking the branch on GitHub at
+above or submitted by forking the branch on GitHub at:
- http://github.com/mcr/tcpdump/tree/master
+* http://github.com/the-tcpdump-group/tcpdump/tree/master
and issuing a pull request.
@@ -90,6 +92,7 @@ Current versions can be found at www.tcpdump.org.
original text by: Steve McCanne, Craig Leres, Van Jacobson
-------------------------------------
+```
This directory also contains some short awk programs intended as
examples of ways to reduce tcpdump data when you're tracking
particular network problems:
@@ -237,3 +240,4 @@ The method was:
- Once a week, tell your funding agent that you're discovering
wonderful things and you'll write up that research report
"real soon now".
+```
diff --git a/contrib/tcpdump/VERSION b/contrib/tcpdump/VERSION
index fdc6698807a9..c78c4964cac9 100644
--- a/contrib/tcpdump/VERSION
+++ b/contrib/tcpdump/VERSION
@@ -1 +1 @@
-4.4.0
+4.6.2
diff --git a/contrib/tcpdump/acconfig.h b/contrib/tcpdump/acconfig.h
deleted file mode 100644
index 9eb54f8b3dfa..000000000000
--- a/contrib/tcpdump/acconfig.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/* "generated automatically" means DO NOT MAKE CHANGES TO config.h.in --
- * make them to acconfig.h and rerun autoheader */
-@TOP@
-
-/* Define if you enable IPv6 support */
-#undef INET6
-
-/* Define if you enable support for the libsmi. */
-#undef LIBSMI
-
-/* define if you have the addrinfo function. */
-#undef HAVE_ADDRINFO
-
-/* define if you need to include missing/addrinfoh.h. */
-#undef NEED_ADDRINFO_H
-
-/* define ifyou have the h_errno variable. */
-#undef HAVE_H_ERRNO
-
-/* define if you have struct sockaddr_storage */
-#undef HAVE_SOCKADDR_STORAGE
-
-/* define if you have both getipnodebyname() and getipnodebyaddr() */
-#undef USE_GETIPNODEBY
-
-/* define if you have ether_ntohost() and it works */
-#undef USE_ETHER_NTOHOST
-
-/* define if libpcap has pcap_version */
-#undef HAVE_PCAP_VERSION
-
-/* define if libpcap has pcap_debug */
-#undef HAVE_PCAP_DEBUG
-
-/* define if libpcap has yydebug */
-#undef HAVE_YYDEBUG
-
-/* define if libpcap has pcap_list_datalinks() */
-#undef HAVE_PCAP_LIST_DATALINKS
-
-/* define if libpcap has pcap_set_datalink() */
-#undef HAVE_PCAP_SET_DATALINK
-
-/* define if libpcap has pcap_datalink_name_to_val() */
-#undef HAVE_PCAP_DATALINK_NAME_TO_VAL
-
-/* define if libpcap has pcap_datalink_val_to_description() */
-#undef HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION
-
-/* define if libpcap has pcap_dump_ftell() */
-#undef HAVE_PCAP_DUMP_FTELL
-
-/* define if you have getrpcbynumber() */
-#undef HAVE_GETRPCBYNUMBER
-
-/* Workaround for missing 64-bit formats */
-#undef PRId64
-#undef PRIo64
-#undef PRIx64
-#undef PRIu64
-
-/* Whether or not to include the possibly-buggy SMB printer */
-#undef TCPDUMP_DO_SMB
-
-/* Define if you have the dnet_htoa function. */
-#undef HAVE_DNET_HTOA
-
-/* Define if you have a dnet_htoa declaration in <netdnet/dnetdb.h>. */
-#undef HAVE_NETDNET_DNETDB_H_DNET_HTOA
-
-/* define if should drop privileges by default */
-#undef WITH_USER
-
-/* define if should chroot when dropping privileges */
-#undef WITH_CHROOT
diff --git a/contrib/tcpdump/addrtoname.c b/contrib/tcpdump/addrtoname.c
index 34b54f6b459d..e208f54bd9ab 100644
--- a/contrib/tcpdump/addrtoname.c
+++ b/contrib/tcpdump/addrtoname.c
@@ -23,21 +23,16 @@
*
* $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.119 2007-08-08 14:06:34 hannes Exp $ (LBL)";
-#endif
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifdef __FreeBSD__
-#ifdef HAVE_LIBCAPSICUM
+#ifdef HAVE_CAPSICUM
#include <libcapsicum.h>
#include <libcapsicum_dns.h>
-#endif /* HAVE_LIBCAPSICUM */
-#endif
+#endif /* HAVE_CAPSICUM */
#include <tcpdump-stdinc.h>
#ifdef USE_ETHER_NTOHOST
@@ -89,7 +84,7 @@ extern int ether_ntohost(char *, const struct ether_addr *);
#define HASHNAMESIZE 4096
struct hnamemem {
- u_int32_t addr;
+ uint32_t addr;
const char *name;
struct hnamemem *nxt;
};
@@ -166,7 +161,7 @@ static struct enamemem nsaptable[HASHNAMESIZE];
static struct enamemem bytestringtable[HASHNAMESIZE];
struct protoidmem {
- u_int32_t p_oui;
+ uint32_t p_oui;
u_short p_proto;
const char *p_name;
struct protoidmem *p_nxt;
@@ -178,7 +173,7 @@ static struct protoidmem protoidtable[HASHNAMESIZE];
* A faster replacement for inet_ntoa().
*/
const char *
-intoa(u_int32_t addr)
+intoa(uint32_t addr)
{
register char *cp;
register u_int byte;
@@ -207,9 +202,9 @@ intoa(u_int32_t addr)
return cp + 1;
}
-static u_int32_t f_netmask;
-static u_int32_t f_localnet;
-#ifdef HAVE_LIBCAPSICUM
+static uint32_t f_netmask;
+static uint32_t f_localnet;
+#ifdef HAVE_CAPSICUM
extern cap_channel_t *capdns;
#endif
@@ -233,10 +228,10 @@ extern cap_channel_t *capdns;
* also needs to check whether they're present in the packet buffer.
*/
const char *
-getname(const u_char *ap)
+getname(netdissect_options *ndo, const u_char *ap)
{
register struct hostent *hp;
- u_int32_t addr;
+ uint32_t addr;
static struct hnamemem *p; /* static for longjmp() */
memcpy(&addr, ap, sizeof(addr));
@@ -255,9 +250,9 @@ getname(const u_char *ap)
* given, f_netmask and f_localnet are 0 and the test
* evaluates to true)
*/
- if (!nflag &&
+ if (!ndo->ndo_nflag &&
(addr & f_netmask) == f_localnet) {
-#ifdef HAVE_LIBCAPSICUM
+#ifdef HAVE_CAPSICUM
if (capdns != NULL) {
hp = cap_gethostbyaddr(capdns, (char *)&addr, 4,
AF_INET);
@@ -268,7 +263,7 @@ getname(const u_char *ap)
char *dotp;
p->name = strdup(hp->h_name);
- if (Nflag) {
+ if (ndo->ndo_Nflag) {
/* Remove domain qualifications */
dotp = strchr(p->name, '.');
if (dotp)
@@ -287,28 +282,34 @@ getname(const u_char *ap)
* is assumed to be in network byte order.
*/
const char *
-getname6(const u_char *ap)
+getname6(netdissect_options *ndo, const u_char *ap)
{
register struct hostent *hp;
- struct in6_addr addr;
+ union {
+ struct in6_addr addr;
+ struct for_hash_addr {
+ char fill[14];
+ uint16_t d;
+ } addra;
+ } addr;
static struct h6namemem *p; /* static for longjmp() */
register const char *cp;
char ntop_buf[INET6_ADDRSTRLEN];
memcpy(&addr, ap, sizeof(addr));
- p = &h6nametable[*(u_int16_t *)&addr.s6_addr[14] & (HASHNAMESIZE-1)];
+ p = &h6nametable[addr.addra.d & (HASHNAMESIZE-1)];
for (; p->nxt; p = p->nxt) {
if (memcmp(&p->addr, &addr, sizeof(addr)) == 0)
return (p->name);
}
- p->addr = addr;
+ p->addr = addr.addr;
p->nxt = newh6namemem();
/*
* Do not print names if -n was given.
*/
- if (!nflag) {
-#ifdef HAVE_LIBCAPSICUM
+ if (!ndo->ndo_nflag) {
+#ifdef HAVE_CAPSICUM
if (capdns != NULL) {
hp = cap_gethostbyaddr(capdns, (char *)&addr,
sizeof(addr), AF_INET6);
@@ -319,7 +320,7 @@ getname6(const u_char *ap)
char *dotp;
p->name = strdup(hp->h_name);
- if (Nflag) {
+ if (ndo->ndo_Nflag) {
/* Remove domain qualifications */
dotp = strchr(p->name, '.');
if (dotp)
@@ -487,7 +488,7 @@ lookup_protoid(const u_char *pi)
}
const char *
-etheraddr_string(register const u_char *ep)
+etheraddr_string(netdissect_options *ndo, register const u_char *ep)
{
register int i;
register char *cp;
@@ -499,7 +500,7 @@ etheraddr_string(register const u_char *ep)
if (tp->e_name)
return (tp->e_name);
#ifdef USE_ETHER_NTOHOST
- if (!nflag) {
+ if (!ndo->ndo_nflag) {
char buf2[BUFSIZE];
/*
@@ -524,7 +525,7 @@ etheraddr_string(register const u_char *ep)
*cp++ = hex[*ep++ & 0xf];
}
- if (!nflag) {
+ if (!ndo->ndo_nflag) {
snprintf(cp, BUFSIZE - (2 + 5*3), " (oui %s)",
tok2str(oui_values, "Unknown", oui));
} else
@@ -562,7 +563,7 @@ le64addr_string(const u_char *ep)
}
const char *
-linkaddr_string(const u_char *ep, const unsigned int type, const unsigned int len)
+linkaddr_string(netdissect_options *ndo, const u_char *ep, const unsigned int type, const unsigned int len)
{
register u_int i;
register char *cp;
@@ -572,7 +573,7 @@ linkaddr_string(const u_char *ep, const unsigned int type, const unsigned int le
return ("<empty>");
if (type == LINKADDR_ETHER && len == ETHER_ADDR_LEN)
- return (etheraddr_string(ep));
+ return (etheraddr_string(ndo, ep));
if (type == LINKADDR_FRELAY)
return (q922_string(ep));
@@ -600,7 +601,7 @@ etherproto_string(u_short port)
{
register char *cp;
register struct hnamemem *tp;
- register u_int32_t i = port;
+ register uint32_t i = port;
char buf[sizeof("0000")];
for (tp = &eprototable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt)
@@ -683,7 +684,7 @@ const char *
tcpport_string(u_short port)
{
register struct hnamemem *tp;
- register u_int32_t i = port;
+ register uint32_t i = port;
char buf[sizeof("00000")];
for (tp = &tporttable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt)
@@ -702,7 +703,7 @@ const char *
udpport_string(register u_short port)
{
register struct hnamemem *tp;
- register u_int32_t i = port;
+ register uint32_t i = port;
char buf[sizeof("00000")];
for (tp = &uporttable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt)
@@ -722,7 +723,7 @@ ipxsap_string(u_short port)
{
register char *cp;
register struct hnamemem *tp;
- register u_int32_t i = port;
+ register uint32_t i = port;
char buf[sizeof("0000")];
for (tp = &ipxsaptable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt)
@@ -744,7 +745,7 @@ ipxsap_string(u_short port)
}
static void
-init_servarray(void)
+init_servarray(netdissect_options *ndo)
{
struct servent *sv;
register struct hnamemem *table;
@@ -763,7 +764,7 @@ init_servarray(void)
while (table->name)
table = table->nxt;
- if (nflag) {
+ if (ndo->ndo_nflag) {
(void)snprintf(buf, sizeof(buf), "%d", port);
table->name = strdup(buf);
} else
@@ -776,7 +777,7 @@ init_servarray(void)
/* in libpcap.a (nametoaddr.c) */
#if defined(WIN32) && !defined(USE_STATIC_LIBPCAP)
-__declspec(dllimport)
+extern __declspec(dllimport)
#else
extern
#endif
@@ -1152,32 +1153,32 @@ init_ipxsaparray(void)
/*
* Initialize the address to name translation machinery. We map all
- * non-local IP addresses to numeric addresses if fflag is true (i.e.,
- * to prevent blocking on the nameserver). localnet is the IP address
+ * non-local IP addresses to numeric addresses if ndo->ndo_fflag is true
+ * (i.e., to prevent blocking on the nameserver). localnet is the IP address
* of the local network. mask is its subnet mask.
*/
void
-init_addrtoname(u_int32_t localnet, u_int32_t mask)
+init_addrtoname(netdissect_options *ndo, uint32_t localnet, uint32_t mask)
{
- if (fflag) {
+ if (ndo->ndo_fflag) {
f_localnet = localnet;
f_netmask = mask;
}
- if (nflag)
+ if (ndo->ndo_nflag)
/*
* Simplest way to suppress names.
*/
return;
init_etherarray();
- init_servarray();
+ init_servarray(ndo);
init_eprotoarray();
init_protoidarray();
init_ipxsaparray();
}
const char *
-dnaddr_string(u_short dnaddr)
+dnaddr_string(netdissect_options *ndo, u_short dnaddr)
{
register struct hnamemem *tp;
@@ -1188,7 +1189,7 @@ dnaddr_string(u_short dnaddr)
tp->addr = dnaddr;
tp->nxt = newhnamemem();
- if (nflag)
+ if (ndo->ndo_nflag)
tp->name = dnnum_string(dnaddr);
else
tp->name = dnname_string(dnaddr);
diff --git a/contrib/tcpdump/addrtoname.h b/contrib/tcpdump/addrtoname.h
index cd5c41f4a5ff..252c570e401d 100644
--- a/contrib/tcpdump/addrtoname.h
+++ b/contrib/tcpdump/addrtoname.h
@@ -17,8 +17,6 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/addrtoname.h,v 1.20 2007-08-08 14:06:34 hannes Exp $ (LBL)
*/
/* Name to address translation routines. */
@@ -32,25 +30,29 @@ enum {
#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 *linkaddr_string(netdissect_options *, const u_char *, const unsigned int, const unsigned int);
+extern const char *etheraddr_string(netdissect_options *, const u_char *);
extern const char *le64addr_string(const u_char *);
extern const char *etherproto_string(u_short);
extern const char *tcpport_string(u_short);
extern const char *udpport_string(u_short);
-extern const char *getname(const u_char *);
+extern const char *isonsap_string(const u_char *, register u_int);
+extern const char *dnaddr_string(netdissect_options *, u_short);
+extern const char *protoid_string(const u_char *);
+extern const char *ipxsap_string(u_short);
+extern const char *getname(netdissect_options *, const u_char *);
#ifdef INET6
-extern const char *getname6(const u_char *);
+extern const char *getname6(netdissect_options *, const u_char *);
#endif
-extern const char *intoa(u_int32_t);
+extern const char *intoa(uint32_t);
-extern void init_addrtoname(u_int32_t, u_int32_t);
+extern void init_addrtoname(netdissect_options *, uint32_t, uint32_t);
extern struct hnamemem *newhnamemem(void);
#ifdef INET6
extern struct h6namemem *newh6namemem(void);
#endif
-#define ipaddr_string(p) getname((const u_char *)(p))
+#define ipaddr_string(ndo, p) getname(ndo, (const u_char *)(p))
#ifdef INET6
-#define ip6addr_string(p) getname6((const u_char *)(p))
+#define ip6addr_string(ndo, p) getname6(ndo, (const u_char *)(p))
#endif
diff --git a/contrib/tcpdump/af.c b/contrib/tcpdump/af.c
index 2c8a928e02ad..bea6d977763f 100644
--- a/contrib/tcpdump/af.c
+++ b/contrib/tcpdump/af.c
@@ -15,11 +15,7 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/af.c,v 1.3 2006-03-23 14:58:44 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
diff --git a/contrib/tcpdump/af.h b/contrib/tcpdump/af.h
index 679cc8e5fa18..bbe1a16f4f94 100644
--- a/contrib/tcpdump/af.h
+++ b/contrib/tcpdump/af.h
@@ -1,5 +1,3 @@
-/* @(#) $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/ah.h b/contrib/tcpdump/ah.h
index c22806afe850..d87a087e1a89 100644
--- a/contrib/tcpdump/ah.h
+++ b/contrib/tcpdump/ah.h
@@ -38,19 +38,19 @@
#define _NETINET6_AH_H_
struct ah {
- u_int8_t ah_nxt; /* Next Header */
- u_int8_t ah_len; /* Length of data, in 32bit */
- u_int16_t ah_reserve; /* Reserved for future use */
- u_int32_t ah_spi; /* Security parameter index */
+ uint8_t ah_nxt; /* Next Header */
+ uint8_t ah_len; /* Length of data, in 32bit */
+ uint16_t ah_reserve; /* Reserved for future use */
+ uint32_t ah_spi; /* Security parameter index */
/* variable size, 32bit bound*/ /* Authentication data */
};
struct newah {
- u_int8_t ah_nxt; /* Next Header */
- u_int8_t ah_len; /* Length of data + 1, in 32bit */
- u_int16_t ah_reserve; /* Reserved for future use */
- u_int32_t ah_spi; /* Security parameter index */
- u_int32_t ah_seq; /* Sequence number field */
+ uint8_t ah_nxt; /* Next Header */
+ uint8_t ah_len; /* Length of data + 1, in 32bit */
+ uint16_t ah_reserve; /* Reserved for future use */
+ uint32_t ah_spi; /* Security parameter index */
+ uint32_t ah_seq; /* Sequence number field */
/* variable size, 32bit bound*/ /* Authentication data */
};
diff --git a/contrib/tcpdump/aodv.h b/contrib/tcpdump/aodv.h
deleted file mode 100644
index 456ec8b309ed..000000000000
--- a/contrib/tcpdump/aodv.h
+++ /dev/null
@@ -1,190 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/aodv.h,v 1.3 2003-09-13 01:34:42 guy Exp $ (LBL) */
-/*
- * Copyright (c) 2003 Bruce M. Simpson <bms@spc.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Bruce M. Simpson.
- * 4. Neither the name of Bruce M. Simpson nor the names of co-
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY Bruce M. Simpson AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Bruce M. Simpson OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef _AODV_H_
-#define _AODV_H_
-
-struct aodv_rreq {
- u_int8_t rreq_type; /* AODV message type (1) */
- u_int8_t rreq_flags; /* various flags */
- u_int8_t rreq_zero0; /* reserved, set to zero */
- u_int8_t rreq_hops; /* number of hops from originator */
- u_int32_t rreq_id; /* request ID */
- u_int32_t rreq_da; /* destination IPv4 address */
- u_int32_t rreq_ds; /* destination sequence number */
- u_int32_t rreq_oa; /* originator IPv4 address */
- u_int32_t rreq_os; /* originator sequence number */
-};
-#ifdef INET6
-struct aodv_rreq6 {
- u_int8_t rreq_type; /* AODV message type (1) */
- u_int8_t rreq_flags; /* various flags */
- u_int8_t rreq_zero0; /* reserved, set to zero */
- u_int8_t rreq_hops; /* number of hops from originator */
- u_int32_t rreq_id; /* request ID */
- struct in6_addr rreq_da; /* destination IPv6 address */
- u_int32_t rreq_ds; /* destination sequence number */
- struct in6_addr rreq_oa; /* originator IPv6 address */
- u_int32_t rreq_os; /* originator sequence number */
-};
-struct aodv_rreq6_draft_01 {
- u_int8_t rreq_type; /* AODV message type (16) */
- u_int8_t rreq_flags; /* various flags */
- u_int8_t rreq_zero0; /* reserved, set to zero */
- u_int8_t rreq_hops; /* number of hops from originator */
- u_int32_t rreq_id; /* request ID */
- u_int32_t rreq_ds; /* destination sequence number */
- u_int32_t rreq_os; /* originator sequence number */
- struct in6_addr rreq_da; /* destination IPv6 address */
- struct in6_addr rreq_oa; /* originator IPv6 address */
-};
-#endif
-
-#define RREQ_JOIN 0x80 /* join (reserved for multicast */
-#define RREQ_REPAIR 0x40 /* repair (reserved for multicast */
-#define RREQ_GRAT 0x20 /* gratuitous RREP */
-#define RREQ_DEST 0x10 /* destination only */
-#define RREQ_UNKNOWN 0x08 /* unknown destination sequence num */
-#define RREQ_FLAGS_MASK 0xF8 /* mask for rreq_flags */
-
-struct aodv_rrep {
- u_int8_t rrep_type; /* AODV message type (2) */
- u_int8_t rrep_flags; /* various flags */
- u_int8_t rrep_ps; /* prefix size */
- u_int8_t rrep_hops; /* number of hops from o to d */
- u_int32_t rrep_da; /* destination IPv4 address */
- u_int32_t rrep_ds; /* destination sequence number */
- u_int32_t rrep_oa; /* originator IPv4 address */
- u_int32_t rrep_life; /* lifetime of this route */
-};
-#ifdef INET6
-struct aodv_rrep6 {
- u_int8_t rrep_type; /* AODV message type (2) */
- u_int8_t rrep_flags; /* various flags */
- u_int8_t rrep_ps; /* prefix size */
- u_int8_t rrep_hops; /* number of hops from o to d */
- struct in6_addr rrep_da; /* destination IPv6 address */
- u_int32_t rrep_ds; /* destination sequence number */
- struct in6_addr rrep_oa; /* originator IPv6 address */
- u_int32_t rrep_life; /* lifetime of this route */
-};
-struct aodv_rrep6_draft_01 {
- u_int8_t rrep_type; /* AODV message type (17) */
- u_int8_t rrep_flags; /* various flags */
- u_int8_t rrep_ps; /* prefix size */
- u_int8_t rrep_hops; /* number of hops from o to d */
- u_int32_t rrep_ds; /* destination sequence number */
- struct in6_addr rrep_da; /* destination IPv6 address */
- struct in6_addr rrep_oa; /* originator IPv6 address */
- u_int32_t rrep_life; /* lifetime of this route */
-};
-#endif
-
-#define RREP_REPAIR 0x80 /* repair (reserved for multicast */
-#define RREP_ACK 0x40 /* acknowledgement required */
-#define RREP_FLAGS_MASK 0xC0 /* mask for rrep_flags */
-#define RREP_PREFIX_MASK 0x1F /* mask for prefix size */
-
-struct rerr_unreach {
- u_int32_t u_da; /* IPv4 address */
- u_int32_t u_ds; /* sequence number */
-};
-#ifdef INET6
-struct rerr_unreach6 {
- struct in6_addr u_da; /* IPv6 address */
- u_int32_t u_ds; /* sequence number */
-};
-struct rerr_unreach6_draft_01 {
- struct in6_addr u_da; /* IPv6 address */
- u_int32_t u_ds; /* sequence number */
-};
-#endif
-
-struct aodv_rerr {
- u_int8_t rerr_type; /* AODV message type (3 or 18) */
- u_int8_t rerr_flags; /* various flags */
- u_int8_t rerr_zero0; /* reserved, set to zero */
- u_int8_t rerr_dc; /* destination count */
- union {
- struct rerr_unreach dest[1];
-#ifdef INET6
- struct rerr_unreach6 dest6[1];
- struct rerr_unreach6_draft_01 dest6_draft_01[1];
-#endif
- } r;
-};
-
-#define RERR_NODELETE 0x80 /* don't delete the link */
-#define RERR_FLAGS_MASK 0x80 /* mask for rerr_flags */
-
-struct aodv_rrep_ack {
- u_int8_t ra_type;
- u_int8_t ra_zero0;
-};
-
-union aodv {
- struct aodv_rreq rreq;
- struct aodv_rrep rrep;
- struct aodv_rerr rerr;
- struct aodv_rrep_ack rrep_ack;
-#ifdef INET6
- struct aodv_rreq6 rreq6;
- struct aodv_rreq6_draft_01 rreq6_draft_01;
- struct aodv_rrep6 rrep6;
- struct aodv_rrep6_draft_01 rrep6_draft_01;
-#endif
-};
-
-#define AODV_RREQ 1 /* route request */
-#define AODV_RREP 2 /* route response */
-#define AODV_RERR 3 /* error report */
-#define AODV_RREP_ACK 4 /* route response acknowledgement */
-
-#define AODV_V6_DRAFT_01_RREQ 16 /* IPv6 route request */
-#define AODV_V6_DRAFT_01_RREP 17 /* IPv6 route response */
-#define AODV_V6_DRAFT_01_RERR 18 /* IPv6 error report */
-#define AODV_V6_DRAFT_01_RREP_ACK 19 /* IPV6 route response acknowledgment */
-
-struct aodv_ext {
- u_int8_t type; /* extension type */
- u_int8_t length; /* extension length */
-};
-
-struct aodv_hello {
- struct aodv_ext eh; /* extension header */
- u_int32_t interval; /* expect my next hello in
- * (n) ms */
-};
-
-#define AODV_EXT_HELLO 1
-
-#endif /* _AODV_H_ */
diff --git a/contrib/tcpdump/appletalk.h b/contrib/tcpdump/appletalk.h
index ff972f65bfa9..3fbcbce00e13 100644
--- a/contrib/tcpdump/appletalk.h
+++ b/contrib/tcpdump/appletalk.h
@@ -19,14 +19,12 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* AppleTalk protocol formats (courtesy Bill Croft of Stanford/SUMEX).
- *
- * @(#) $Header: /tcpdump/master/tcpdump/appletalk.h,v 1.16 2004-05-01 09:41:50 hannes Exp $ (LBL)
*/
struct LAP {
- u_int8_t dst;
- u_int8_t src;
- u_int8_t type;
+ uint8_t dst;
+ uint8_t src;
+ uint8_t type;
};
#define lapShortDDP 1 /* short DDP type */
#define lapDDP 2 /* DDP type */
@@ -35,22 +33,22 @@ struct LAP {
/* Datagram Delivery Protocol */
struct atDDP {
- u_int16_t length;
- u_int16_t checksum;
- u_int16_t dstNet;
- u_int16_t srcNet;
- u_int8_t dstNode;
- u_int8_t srcNode;
- u_int8_t dstSkt;
- u_int8_t srcSkt;
- u_int8_t type;
+ uint16_t length;
+ uint16_t checksum;
+ uint16_t dstNet;
+ uint16_t srcNet;
+ uint8_t dstNode;
+ uint8_t srcNode;
+ uint8_t dstSkt;
+ uint8_t srcSkt;
+ uint8_t type;
};
struct atShortDDP {
- u_int16_t length;
- u_int8_t dstSkt;
- u_int8_t srcSkt;
- u_int8_t type;
+ uint16_t length;
+ uint8_t dstSkt;
+ uint8_t srcSkt;
+ uint8_t type;
};
#define ddpMaxWKS 0x7F
@@ -74,10 +72,10 @@ struct atShortDDP {
/* AppleTalk Transaction Protocol */
struct atATP {
- u_int8_t control;
- u_int8_t bitmap;
- u_int16_t transID;
- int32_t userData;
+ uint8_t control;
+ uint8_t bitmap;
+ uint16_t transID;
+ int32_t userData;
};
#define atpReqCode 0x40
@@ -95,8 +93,8 @@ struct atATP {
/* AppleTalk Echo Protocol */
struct atEcho {
- u_int8_t echoFunction;
- u_int8_t *echoData;
+ uint8_t echoFunction;
+ uint8_t *echoData;
};
#define echoSkt 4 /* the echoer socket */
@@ -108,15 +106,15 @@ struct atEcho {
/* Name Binding Protocol */
struct atNBP {
- u_int8_t control;
- u_int8_t id;
+ uint8_t control;
+ uint8_t id;
};
struct atNBPtuple {
- u_int16_t net;
- u_int8_t node;
- u_int8_t skt;
- u_int8_t enumerator;
+ uint16_t net;
+ uint8_t node;
+ uint8_t skt;
+ uint8_t enumerator;
};
#define nbpBrRq 0x10
@@ -142,8 +140,8 @@ struct atNBPtuple {
/* Zone Information Protocol */
struct zipHeader {
- u_int8_t command;
- u_int8_t netcount;
+ uint8_t command;
+ uint8_t netcount;
};
#define zipHeaderSize 2
diff --git a/contrib/tcpdump/arcnet.h b/contrib/tcpdump/arcnet.h
deleted file mode 100644
index 3b609566ff81..000000000000
--- a/contrib/tcpdump/arcnet.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (c) 1982, 1986, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#) $Id: arcnet.h,v 1.3 2003-01-23 09:05:37 guy Exp $ (LBL)
- *
- * from: NetBSD: if_arc.h,v 1.13 1999/11/19 20:41:19 thorpej Exp
- */
-
-/*
- * Structure of a 2.5MB/s Arcnet header on the BSDs,
- * as given to interface code.
- */
-struct arc_header {
- u_int8_t arc_shost;
- u_int8_t arc_dhost;
- u_int8_t arc_type;
- /*
- * only present for newstyle encoding with LL fragmentation.
- * Don't use sizeof(anything), use ARC_HDR{,NEW}LEN instead.
- */
- u_int8_t arc_flag;
- u_int16_t arc_seqid;
-
- /*
- * only present in exception packets (arc_flag == 0xff)
- */
- u_int8_t arc_type2; /* same as arc_type */
- u_int8_t arc_flag2; /* real flag value */
- u_int16_t arc_seqid2; /* real seqid value */
-};
-
-#define ARC_HDRLEN 3
-#define ARC_HDRNEWLEN 6
-#define ARC_HDRNEWLEN_EXC 10
-
-/* RFC 1051 */
-#define ARCTYPE_IP_OLD 240 /* IP protocol */
-#define ARCTYPE_ARP_OLD 241 /* address resolution protocol */
-
-/* RFC 1201 */
-#define ARCTYPE_IP 212 /* IP protocol */
-#define ARCTYPE_ARP 213 /* address resolution protocol */
-#define ARCTYPE_REVARP 214 /* reverse addr resolution protocol */
-
-#define ARCTYPE_ATALK 221 /* Appletalk */
-#define ARCTYPE_BANIAN 247 /* Banyan Vines */
-#define ARCTYPE_IPX 250 /* Novell IPX */
-
-#define ARCTYPE_INET6 0xc4 /* IPng */
-#define ARCTYPE_DIAGNOSE 0x80 /* as per ANSI/ATA 878.1 */
-
-/*
- * Structure of a 2.5MB/s Arcnet header on Linux. Linux has
- * an extra "offset" field when given to interface code, and
- * never presents packets that look like exception frames.
- */
-struct arc_linux_header {
- u_int8_t arc_shost;
- u_int8_t arc_dhost;
- u_int16_t arc_offset;
- u_int8_t arc_type;
- /*
- * only present for newstyle encoding with LL fragmentation.
- * Don't use sizeof(anything), use ARC_LINUX_HDR{,NEW}LEN
- * instead.
- */
- u_int8_t arc_flag;
- u_int16_t arc_seqid;
-};
-
-#define ARC_LINUX_HDRLEN 5
-#define ARC_LINUX_HDRNEWLEN 8
diff --git a/contrib/tcpdump/atm.h b/contrib/tcpdump/atm.h
index 65ac5c17e514..8d1737ed31cf 100644
--- a/contrib/tcpdump/atm.h
+++ b/contrib/tcpdump/atm.h
@@ -13,8 +13,6 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/atm.h,v 1.3 2006-02-08 01:43:00 hannes Exp $
*/
/*
diff --git a/contrib/tcpdump/atmuni31.h b/contrib/tcpdump/atmuni31.h
index ab7a03ddf54c..0f85430098ce 100644
--- a/contrib/tcpdump/atmuni31.h
+++ b/contrib/tcpdump/atmuni31.h
@@ -28,8 +28,6 @@
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/atmuni31.h,v 1.3 2007-10-22 19:37:51 guy Exp $ (LBL)
*/
/* Based on UNI3.1 standard by ATM Forum */
diff --git a/contrib/tcpdump/bgp.h b/contrib/tcpdump/bgp.h
deleted file mode 100644
index 508159601437..000000000000
--- a/contrib/tcpdump/bgp.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/bgp.h,v 1.3 2004-06-16 08:45:15 hannes Exp $ (LBL) */
-/*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that: (1) source code
- * distributions retain the above copyright notice and this paragraph
- * in its entirety, and (2) distributions including binary code include
- * the above copyright notice and this paragraph in its entirety in
- * the documentation or other materials provided with the distribution.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
- * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
- * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE.
- *
- * Original code by Hannes Gredler (hannes@juniper.net)
- */
-
-extern char *bgp_vpn_rd_print (const u_char *);
diff --git a/contrib/tcpdump/bootp.h b/contrib/tcpdump/bootp.h
index b1b81dce9084..b6aac4c3c439 100644
--- a/contrib/tcpdump/bootp.h
+++ b/contrib/tcpdump/bootp.h
@@ -1,4 +1,3 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/bootp.h,v 1.19 2008-04-22 09:46:03 hannes Exp $ (LBL) */
/*
* Bootstrap Protocol (BOOTP). RFC951 and RFC1048.
*
@@ -21,22 +20,22 @@
struct bootp {
- u_int8_t bp_op; /* packet opcode type */
- u_int8_t bp_htype; /* hardware addr type */
- u_int8_t bp_hlen; /* hardware addr length */
- u_int8_t bp_hops; /* gateway hops */
- u_int32_t bp_xid; /* transaction ID */
- u_int16_t bp_secs; /* seconds since boot began */
- u_int16_t bp_flags; /* flags - see bootp_flag_values[]
+ uint8_t bp_op; /* packet opcode type */
+ uint8_t bp_htype; /* hardware addr type */
+ uint8_t bp_hlen; /* hardware addr length */
+ uint8_t bp_hops; /* gateway hops */
+ uint32_t bp_xid; /* transaction ID */
+ uint16_t bp_secs; /* seconds since boot began */
+ uint16_t bp_flags; /* flags - see bootp_flag_values[]
in print-bootp.c */
struct in_addr bp_ciaddr; /* client IP address */
struct in_addr bp_yiaddr; /* 'your' IP address */
struct in_addr bp_siaddr; /* server IP address */
struct in_addr bp_giaddr; /* gateway IP address */
- u_int8_t bp_chaddr[16]; /* client hardware address */
- u_int8_t bp_sname[64]; /* server host name */
- u_int8_t bp_file[128]; /* boot file name */
- u_int8_t bp_vend[64]; /* vendor-specific area */
+ uint8_t bp_chaddr[16]; /* client hardware address */
+ uint8_t bp_sname[64]; /* server host name */
+ uint8_t bp_file[128]; /* boot file name */
+ uint8_t bp_vend[64]; /* vendor-specific area */
} UNALIGNED;
/*
@@ -65,132 +64,132 @@ struct bootp {
* the vendor field of the packet.
*/
-#define TAG_PAD ((u_int8_t) 0)
-#define TAG_SUBNET_MASK ((u_int8_t) 1)
-#define TAG_TIME_OFFSET ((u_int8_t) 2)
-#define TAG_GATEWAY ((u_int8_t) 3)
-#define TAG_TIME_SERVER ((u_int8_t) 4)
-#define TAG_NAME_SERVER ((u_int8_t) 5)
-#define TAG_DOMAIN_SERVER ((u_int8_t) 6)
-#define TAG_LOG_SERVER ((u_int8_t) 7)
-#define TAG_COOKIE_SERVER ((u_int8_t) 8)
-#define TAG_LPR_SERVER ((u_int8_t) 9)
-#define TAG_IMPRESS_SERVER ((u_int8_t) 10)
-#define TAG_RLP_SERVER ((u_int8_t) 11)
-#define TAG_HOSTNAME ((u_int8_t) 12)
-#define TAG_BOOTSIZE ((u_int8_t) 13)
-#define TAG_END ((u_int8_t) 255)
+#define TAG_PAD ((uint8_t) 0)
+#define TAG_SUBNET_MASK ((uint8_t) 1)
+#define TAG_TIME_OFFSET ((uint8_t) 2)
+#define TAG_GATEWAY ((uint8_t) 3)
+#define TAG_TIME_SERVER ((uint8_t) 4)
+#define TAG_NAME_SERVER ((uint8_t) 5)
+#define TAG_DOMAIN_SERVER ((uint8_t) 6)
+#define TAG_LOG_SERVER ((uint8_t) 7)
+#define TAG_COOKIE_SERVER ((uint8_t) 8)
+#define TAG_LPR_SERVER ((uint8_t) 9)
+#define TAG_IMPRESS_SERVER ((uint8_t) 10)
+#define TAG_RLP_SERVER ((uint8_t) 11)
+#define TAG_HOSTNAME ((uint8_t) 12)
+#define TAG_BOOTSIZE ((uint8_t) 13)
+#define TAG_END ((uint8_t) 255)
/* RFC1497 tags */
-#define TAG_DUMPPATH ((u_int8_t) 14)
-#define TAG_DOMAINNAME ((u_int8_t) 15)
-#define TAG_SWAP_SERVER ((u_int8_t) 16)
-#define TAG_ROOTPATH ((u_int8_t) 17)
-#define TAG_EXTPATH ((u_int8_t) 18)
+#define TAG_DUMPPATH ((uint8_t) 14)
+#define TAG_DOMAINNAME ((uint8_t) 15)
+#define TAG_SWAP_SERVER ((uint8_t) 16)
+#define TAG_ROOTPATH ((uint8_t) 17)
+#define TAG_EXTPATH ((uint8_t) 18)
/* RFC2132 */
-#define TAG_IP_FORWARD ((u_int8_t) 19)
-#define TAG_NL_SRCRT ((u_int8_t) 20)
-#define TAG_PFILTERS ((u_int8_t) 21)
-#define TAG_REASS_SIZE ((u_int8_t) 22)
-#define TAG_DEF_TTL ((u_int8_t) 23)
-#define TAG_MTU_TIMEOUT ((u_int8_t) 24)
-#define TAG_MTU_TABLE ((u_int8_t) 25)
-#define TAG_INT_MTU ((u_int8_t) 26)
-#define TAG_LOCAL_SUBNETS ((u_int8_t) 27)
-#define TAG_BROAD_ADDR ((u_int8_t) 28)
-#define TAG_DO_MASK_DISC ((u_int8_t) 29)
-#define TAG_SUPPLY_MASK ((u_int8_t) 30)
-#define TAG_DO_RDISC ((u_int8_t) 31)
-#define TAG_RTR_SOL_ADDR ((u_int8_t) 32)
-#define TAG_STATIC_ROUTE ((u_int8_t) 33)
-#define TAG_USE_TRAILERS ((u_int8_t) 34)
-#define TAG_ARP_TIMEOUT ((u_int8_t) 35)
-#define TAG_ETH_ENCAP ((u_int8_t) 36)
-#define TAG_TCP_TTL ((u_int8_t) 37)
-#define TAG_TCP_KEEPALIVE ((u_int8_t) 38)
-#define TAG_KEEPALIVE_GO ((u_int8_t) 39)
-#define TAG_NIS_DOMAIN ((u_int8_t) 40)
-#define TAG_NIS_SERVERS ((u_int8_t) 41)
-#define TAG_NTP_SERVERS ((u_int8_t) 42)
-#define TAG_VENDOR_OPTS ((u_int8_t) 43)
-#define TAG_NETBIOS_NS ((u_int8_t) 44)
-#define TAG_NETBIOS_DDS ((u_int8_t) 45)
-#define TAG_NETBIOS_NODE ((u_int8_t) 46)
-#define TAG_NETBIOS_SCOPE ((u_int8_t) 47)
-#define TAG_XWIN_FS ((u_int8_t) 48)
-#define TAG_XWIN_DM ((u_int8_t) 49)
-#define TAG_NIS_P_DOMAIN ((u_int8_t) 64)
-#define TAG_NIS_P_SERVERS ((u_int8_t) 65)
-#define TAG_MOBILE_HOME ((u_int8_t) 68)
-#define TAG_SMPT_SERVER ((u_int8_t) 69)
-#define TAG_POP3_SERVER ((u_int8_t) 70)
-#define TAG_NNTP_SERVER ((u_int8_t) 71)
-#define TAG_WWW_SERVER ((u_int8_t) 72)
-#define TAG_FINGER_SERVER ((u_int8_t) 73)
-#define TAG_IRC_SERVER ((u_int8_t) 74)
-#define TAG_STREETTALK_SRVR ((u_int8_t) 75)
-#define TAG_STREETTALK_STDA ((u_int8_t) 76)
+#define TAG_IP_FORWARD ((uint8_t) 19)
+#define TAG_NL_SRCRT ((uint8_t) 20)
+#define TAG_PFILTERS ((uint8_t) 21)
+#define TAG_REASS_SIZE ((uint8_t) 22)
+#define TAG_DEF_TTL ((uint8_t) 23)
+#define TAG_MTU_TIMEOUT ((uint8_t) 24)
+#define TAG_MTU_TABLE ((uint8_t) 25)
+#define TAG_INT_MTU ((uint8_t) 26)
+#define TAG_LOCAL_SUBNETS ((uint8_t) 27)
+#define TAG_BROAD_ADDR ((uint8_t) 28)
+#define TAG_DO_MASK_DISC ((uint8_t) 29)
+#define TAG_SUPPLY_MASK ((uint8_t) 30)
+#define TAG_DO_RDISC ((uint8_t) 31)
+#define TAG_RTR_SOL_ADDR ((uint8_t) 32)
+#define TAG_STATIC_ROUTE ((uint8_t) 33)
+#define TAG_USE_TRAILERS ((uint8_t) 34)
+#define TAG_ARP_TIMEOUT ((uint8_t) 35)
+#define TAG_ETH_ENCAP ((uint8_t) 36)
+#define TAG_TCP_TTL ((uint8_t) 37)
+#define TAG_TCP_KEEPALIVE ((uint8_t) 38)
+#define TAG_KEEPALIVE_GO ((uint8_t) 39)
+#define TAG_NIS_DOMAIN ((uint8_t) 40)
+#define TAG_NIS_SERVERS ((uint8_t) 41)
+#define TAG_NTP_SERVERS ((uint8_t) 42)
+#define TAG_VENDOR_OPTS ((uint8_t) 43)
+#define TAG_NETBIOS_NS ((uint8_t) 44)
+#define TAG_NETBIOS_DDS ((uint8_t) 45)
+#define TAG_NETBIOS_NODE ((uint8_t) 46)
+#define TAG_NETBIOS_SCOPE ((uint8_t) 47)
+#define TAG_XWIN_FS ((uint8_t) 48)
+#define TAG_XWIN_DM ((uint8_t) 49)
+#define TAG_NIS_P_DOMAIN ((uint8_t) 64)
+#define TAG_NIS_P_SERVERS ((uint8_t) 65)
+#define TAG_MOBILE_HOME ((uint8_t) 68)
+#define TAG_SMPT_SERVER ((uint8_t) 69)
+#define TAG_POP3_SERVER ((uint8_t) 70)
+#define TAG_NNTP_SERVER ((uint8_t) 71)
+#define TAG_WWW_SERVER ((uint8_t) 72)
+#define TAG_FINGER_SERVER ((uint8_t) 73)
+#define TAG_IRC_SERVER ((uint8_t) 74)
+#define TAG_STREETTALK_SRVR ((uint8_t) 75)
+#define TAG_STREETTALK_STDA ((uint8_t) 76)
/* DHCP options */
-#define TAG_REQUESTED_IP ((u_int8_t) 50)
-#define TAG_IP_LEASE ((u_int8_t) 51)
-#define TAG_OPT_OVERLOAD ((u_int8_t) 52)
-#define TAG_TFTP_SERVER ((u_int8_t) 66)
-#define TAG_BOOTFILENAME ((u_int8_t) 67)
-#define TAG_DHCP_MESSAGE ((u_int8_t) 53)
-#define TAG_SERVER_ID ((u_int8_t) 54)
-#define TAG_PARM_REQUEST ((u_int8_t) 55)
-#define TAG_MESSAGE ((u_int8_t) 56)
-#define TAG_MAX_MSG_SIZE ((u_int8_t) 57)
-#define TAG_RENEWAL_TIME ((u_int8_t) 58)
-#define TAG_REBIND_TIME ((u_int8_t) 59)
-#define TAG_VENDOR_CLASS ((u_int8_t) 60)
-#define TAG_CLIENT_ID ((u_int8_t) 61)
+#define TAG_REQUESTED_IP ((uint8_t) 50)
+#define TAG_IP_LEASE ((uint8_t) 51)
+#define TAG_OPT_OVERLOAD ((uint8_t) 52)
+#define TAG_TFTP_SERVER ((uint8_t) 66)
+#define TAG_BOOTFILENAME ((uint8_t) 67)
+#define TAG_DHCP_MESSAGE ((uint8_t) 53)
+#define TAG_SERVER_ID ((uint8_t) 54)
+#define TAG_PARM_REQUEST ((uint8_t) 55)
+#define TAG_MESSAGE ((uint8_t) 56)
+#define TAG_MAX_MSG_SIZE ((uint8_t) 57)
+#define TAG_RENEWAL_TIME ((uint8_t) 58)
+#define TAG_REBIND_TIME ((uint8_t) 59)
+#define TAG_VENDOR_CLASS ((uint8_t) 60)
+#define TAG_CLIENT_ID ((uint8_t) 61)
/* RFC 2241 */
-#define TAG_NDS_SERVERS ((u_int8_t) 85)
-#define TAG_NDS_TREE_NAME ((u_int8_t) 86)
-#define TAG_NDS_CONTEXT ((u_int8_t) 87)
+#define TAG_NDS_SERVERS ((uint8_t) 85)
+#define TAG_NDS_TREE_NAME ((uint8_t) 86)
+#define TAG_NDS_CONTEXT ((uint8_t) 87)
/* RFC 2242 */
-#define TAG_NDS_IPDOMAIN ((u_int8_t) 62)
-#define TAG_NDS_IPINFO ((u_int8_t) 63)
+#define TAG_NDS_IPDOMAIN ((uint8_t) 62)
+#define TAG_NDS_IPINFO ((uint8_t) 63)
/* RFC 2485 */
-#define TAG_OPEN_GROUP_UAP ((u_int8_t) 98)
+#define TAG_OPEN_GROUP_UAP ((uint8_t) 98)
/* RFC 2563 */
-#define TAG_DISABLE_AUTOCONF ((u_int8_t) 116)
+#define TAG_DISABLE_AUTOCONF ((uint8_t) 116)
/* RFC 2610 */
-#define TAG_SLP_DA ((u_int8_t) 78)
-#define TAG_SLP_SCOPE ((u_int8_t) 79)
+#define TAG_SLP_DA ((uint8_t) 78)
+#define TAG_SLP_SCOPE ((uint8_t) 79)
/* RFC 2937 */
-#define TAG_NS_SEARCH ((u_int8_t) 117)
+#define TAG_NS_SEARCH ((uint8_t) 117)
/* RFC 3011 */
-#define TAG_IP4_SUBNET_SELECT ((u_int8_t) 118)
+#define TAG_IP4_SUBNET_SELECT ((uint8_t) 118)
/* RFC 3442 */
-#define TAG_CLASSLESS_STATIC_RT ((u_int8_t) 121)
-#define TAG_CLASSLESS_STA_RT_MS ((u_int8_t) 249)
+#define TAG_CLASSLESS_STATIC_RT ((uint8_t) 121)
+#define TAG_CLASSLESS_STA_RT_MS ((uint8_t) 249)
/* ftp://ftp.isi.edu/.../assignments/bootp-dhcp-extensions */
-#define TAG_USER_CLASS ((u_int8_t) 77)
-#define TAG_SLP_NAMING_AUTH ((u_int8_t) 80)
-#define TAG_CLIENT_FQDN ((u_int8_t) 81)
-#define TAG_AGENT_CIRCUIT ((u_int8_t) 82)
-#define TAG_AGENT_REMOTE ((u_int8_t) 83)
-#define TAG_AGENT_MASK ((u_int8_t) 84)
-#define TAG_TZ_STRING ((u_int8_t) 88)
-#define TAG_FQDN_OPTION ((u_int8_t) 89)
-#define TAG_AUTH ((u_int8_t) 90)
-#define TAG_VINES_SERVERS ((u_int8_t) 91)
-#define TAG_SERVER_RANK ((u_int8_t) 92)
-#define TAG_CLIENT_ARCH ((u_int8_t) 93)
-#define TAG_CLIENT_NDI ((u_int8_t) 94)
-#define TAG_CLIENT_GUID ((u_int8_t) 97)
-#define TAG_LDAP_URL ((u_int8_t) 95)
-#define TAG_6OVER4 ((u_int8_t) 96)
-#define TAG_PRINTER_NAME ((u_int8_t) 100)
-#define TAG_MDHCP_SERVER ((u_int8_t) 101)
-#define TAG_IPX_COMPAT ((u_int8_t) 110)
-#define TAG_NETINFO_PARENT ((u_int8_t) 112)
-#define TAG_NETINFO_PARENT_TAG ((u_int8_t) 113)
-#define TAG_URL ((u_int8_t) 114)
-#define TAG_FAILOVER ((u_int8_t) 115)
-#define TAG_EXTENDED_REQUEST ((u_int8_t) 126)
-#define TAG_EXTENDED_OPTION ((u_int8_t) 127)
+#define TAG_USER_CLASS ((uint8_t) 77)
+#define TAG_SLP_NAMING_AUTH ((uint8_t) 80)
+#define TAG_CLIENT_FQDN ((uint8_t) 81)
+#define TAG_AGENT_CIRCUIT ((uint8_t) 82)
+#define TAG_AGENT_REMOTE ((uint8_t) 83)
+#define TAG_AGENT_MASK ((uint8_t) 84)
+#define TAG_TZ_STRING ((uint8_t) 88)
+#define TAG_FQDN_OPTION ((uint8_t) 89)
+#define TAG_AUTH ((uint8_t) 90)
+#define TAG_VINES_SERVERS ((uint8_t) 91)
+#define TAG_SERVER_RANK ((uint8_t) 92)
+#define TAG_CLIENT_ARCH ((uint8_t) 93)
+#define TAG_CLIENT_NDI ((uint8_t) 94)
+#define TAG_CLIENT_GUID ((uint8_t) 97)
+#define TAG_LDAP_URL ((uint8_t) 95)
+#define TAG_6OVER4 ((uint8_t) 96)
+#define TAG_PRINTER_NAME ((uint8_t) 100)
+#define TAG_MDHCP_SERVER ((uint8_t) 101)
+#define TAG_IPX_COMPAT ((uint8_t) 110)
+#define TAG_NETINFO_PARENT ((uint8_t) 112)
+#define TAG_NETINFO_PARENT_TAG ((uint8_t) 113)
+#define TAG_URL ((uint8_t) 114)
+#define TAG_FAILOVER ((uint8_t) 115)
+#define TAG_EXTENDED_REQUEST ((uint8_t) 126)
+#define TAG_EXTENDED_OPTION ((uint8_t) 127)
/* DHCP Message types (values for TAG_DHCP_MESSAGE option) */
@@ -209,14 +208,14 @@ struct bootp {
*/
struct cmu_vend {
- u_int8_t v_magic[4]; /* magic number */
- u_int32_t v_flags; /* flags/opcodes, etc. */
+ uint8_t v_magic[4]; /* magic number */
+ uint32_t v_flags; /* flags/opcodes, etc. */
struct in_addr v_smask; /* Subnet mask */
struct in_addr v_dgate; /* Default gateway */
struct in_addr v_dns1, v_dns2; /* Domain name servers */
struct in_addr v_ins1, v_ins2; /* IEN-116 name servers */
struct in_addr v_ts1, v_ts2; /* Time servers */
- u_int8_t v_unused[24]; /* currently unused */
+ uint8_t v_unused[24]; /* currently unused */
} UNALIGNED;
diff --git a/contrib/tcpdump/bpf_dump.c b/contrib/tcpdump/bpf_dump.c
index b50d7e7b6639..2ef852834085 100644
--- a/contrib/tcpdump/bpf_dump.c
+++ b/contrib/tcpdump/bpf_dump.c
@@ -18,18 +18,14 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/bpf_dump.c,v 1.17 2008-02-14 20:53:49 guy Exp $ (LBL)";
-#endif
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <pcap.h>
#include <stdio.h>
#include "interface.h"
diff --git a/contrib/tcpdump/chdlc.h b/contrib/tcpdump/chdlc.h
index d11726336ee0..d5a2d915eada 100644
--- a/contrib/tcpdump/chdlc.h
+++ b/contrib/tcpdump/chdlc.h
@@ -1,4 +1,3 @@
-/* @(#) $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
index 57c02bd1e057..d8263c7a244a 100644
--- a/contrib/tcpdump/checksum.c
+++ b/contrib/tcpdump/checksum.c
@@ -17,11 +17,7 @@
* 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
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -55,7 +51,7 @@ for i in range(len(crc_table)/8):
sys.stdout.write("\n")
*/
-static const u_int16_t crc10_table[256] =
+static const uint16_t crc10_table[256] =
{
0x0000, 0x0233, 0x0255, 0x0066, 0x0299, 0x00aa, 0x00cc, 0x02ff,
0x0301, 0x0132, 0x0154, 0x0367, 0x0198, 0x03ab, 0x03cd, 0x01fe,
@@ -93,12 +89,12 @@ static const u_int16_t crc10_table[256] =
static void
init_crc10_table(void)
-{
+{
#define CRC10_POLYNOMIAL 0x633
register int i, j;
- register u_int16_t accum;
- u_int16_t verify_crc10_table[256];
-
+ register uint16_t accum;
+ uint16_t verify_crc10_table[256];
+
for ( i = 0; i < 256; i++ )
{
accum = ((unsigned short) i << 2);
@@ -114,8 +110,8 @@ init_crc10_table(void)
#undef CRC10_POLYNOMIAL
}
-u_int16_t
-verify_crc10_cksum(u_int16_t accum, const u_char *p, int length)
+uint16_t
+verify_crc10_cksum(uint16_t accum, const u_char *p, int length)
{
register int i;
@@ -140,16 +136,16 @@ init_checksum(void) {
* 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)
+uint16_t
+create_osi_cksum (const uint8_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;
+ uint32_t mul;
+ uint32_t c0;
+ uint32_t c1;
+ uint16_t checksum;
int index;
c0 = 0;
@@ -166,14 +162,14 @@ create_osi_cksum (const u_int8_t *pptr, int checksum_offset, int length)
} 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;
@@ -189,6 +185,6 @@ create_osi_cksum (const u_int8_t *pptr, int checksum_offset, int length)
y &= 0x00FF;
checksum = ((x << 8) | y);
-
+
return checksum;
}
diff --git a/contrib/tcpdump/config.guess b/contrib/tcpdump/config.guess
index c2246a4f7f4c..d622a44e551f 100755
--- a/contrib/tcpdump/config.guess
+++ b/contrib/tcpdump/config.guess
@@ -1,10 +1,10 @@
#! /bin/sh
# Attempt to guess a canonical system name.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
-# Free Software Foundation, Inc.
+# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
+# 2011, 2012 Free Software Foundation, Inc.
-timestamp='2009-12-30'
+timestamp='2012-02-10'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@@ -17,9 +17,7 @@ timestamp='2009-12-30'
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
-# 02110-1301, USA.
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
@@ -57,8 +55,8 @@ GNU config.guess ($timestamp)
Originally written by Per Bothner.
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free
-Software Foundation, Inc.
+2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
+Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -145,7 +143,7 @@ UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
*:NetBSD:*:*)
# NetBSD (nbsd) targets should (where applicable) match one or
- # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+ # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
# *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
# switched to ELF, *-*-netbsd* would select the old
# object file format. This provides both forward
@@ -181,7 +179,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
fi
;;
*)
- os=netbsd
+ os=netbsd
;;
esac
# The OS release
@@ -224,7 +222,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
;;
*5.*)
- UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
;;
esac
# According to Compaq, /usr/sbin/psrinfo has been available on
@@ -270,7 +268,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
# A Xn.n version is an unreleased experimental baselevel.
# 1.2 uses "1.2" for uname -r.
echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
- exit ;;
+ # Reset EXIT trap before exiting to avoid spurious non-zero exit code.
+ exitcode=$?
+ trap '' 0
+ exit $exitcode ;;
Alpha\ *:Windows_NT*:*)
# How do we know it's Interix rather than the generic POSIX subsystem?
# Should we change UNAME_MACHINE based on the output of uname instead
@@ -296,7 +297,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
echo s390-ibm-zvmoe
exit ;;
*:OS400:*:*)
- echo powerpc-ibm-os400
+ echo powerpc-ibm-os400
exit ;;
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
echo arm-acorn-riscix${UNAME_RELEASE}
@@ -395,23 +396,23 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
# MiNT. But MiNT is downward compatible to TOS, so this should
# be no problem.
atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
- echo m68k-atari-mint${UNAME_RELEASE}
+ echo m68k-atari-mint${UNAME_RELEASE}
exit ;;
atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
echo m68k-atari-mint${UNAME_RELEASE}
- exit ;;
+ exit ;;
*falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
- echo m68k-atari-mint${UNAME_RELEASE}
+ echo m68k-atari-mint${UNAME_RELEASE}
exit ;;
milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
- echo m68k-milan-mint${UNAME_RELEASE}
- exit ;;
+ echo m68k-milan-mint${UNAME_RELEASE}
+ exit ;;
hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
- echo m68k-hades-mint${UNAME_RELEASE}
- exit ;;
+ echo m68k-hades-mint${UNAME_RELEASE}
+ exit ;;
*:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
- echo m68k-unknown-mint${UNAME_RELEASE}
- exit ;;
+ echo m68k-unknown-mint${UNAME_RELEASE}
+ exit ;;
m68k:machten:*:*)
echo m68k-apple-machten${UNAME_RELEASE}
exit ;;
@@ -481,8 +482,8 @@ EOF
echo m88k-motorola-sysv3
exit ;;
AViiON:dgux:*:*)
- # DG/UX returns AViiON for all architectures
- UNAME_PROCESSOR=`/usr/bin/uname -p`
+ # DG/UX returns AViiON for all architectures
+ UNAME_PROCESSOR=`/usr/bin/uname -p`
if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
then
if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
@@ -495,7 +496,7 @@ EOF
else
echo i586-dg-dgux${UNAME_RELEASE}
fi
- exit ;;
+ exit ;;
M88*:DolphinOS:*:*) # DolphinOS (SVR3)
echo m88k-dolphin-sysv3
exit ;;
@@ -552,7 +553,7 @@ EOF
echo rs6000-ibm-aix3.2
fi
exit ;;
- *:AIX:*:[456])
+ *:AIX:*:[4567])
IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
IBM_ARCH=rs6000
@@ -595,52 +596,52 @@ EOF
9000/[678][0-9][0-9])
if [ -x /usr/bin/getconf ]; then
sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
- sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
- case "${sc_cpu_version}" in
- 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
- 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
- 532) # CPU_PA_RISC2_0
- case "${sc_kernel_bits}" in
- 32) HP_ARCH="hppa2.0n" ;;
- 64) HP_ARCH="hppa2.0w" ;;
+ sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+ case "${sc_cpu_version}" in
+ 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+ 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+ 532) # CPU_PA_RISC2_0
+ case "${sc_kernel_bits}" in
+ 32) HP_ARCH="hppa2.0n" ;;
+ 64) HP_ARCH="hppa2.0w" ;;
'') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
- esac ;;
- esac
+ esac ;;
+ esac
fi
if [ "${HP_ARCH}" = "" ]; then
eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
+ sed 's/^ //' << EOF >$dummy.c
- #define _HPUX_SOURCE
- #include <stdlib.h>
- #include <unistd.h>
+ #define _HPUX_SOURCE
+ #include <stdlib.h>
+ #include <unistd.h>
- int main ()
- {
- #if defined(_SC_KERNEL_BITS)
- long bits = sysconf(_SC_KERNEL_BITS);
- #endif
- long cpu = sysconf (_SC_CPU_VERSION);
+ int main ()
+ {
+ #if defined(_SC_KERNEL_BITS)
+ long bits = sysconf(_SC_KERNEL_BITS);
+ #endif
+ long cpu = sysconf (_SC_CPU_VERSION);
- switch (cpu)
- {
- case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
- case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
- case CPU_PA_RISC2_0:
- #if defined(_SC_KERNEL_BITS)
- switch (bits)
- {
- case 64: puts ("hppa2.0w"); break;
- case 32: puts ("hppa2.0n"); break;
- default: puts ("hppa2.0"); break;
- } break;
- #else /* !defined(_SC_KERNEL_BITS) */
- puts ("hppa2.0"); break;
- #endif
- default: puts ("hppa1.0"); break;
- }
- exit (0);
- }
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+ case CPU_PA_RISC2_0:
+ #if defined(_SC_KERNEL_BITS)
+ switch (bits)
+ {
+ case 64: puts ("hppa2.0w"); break;
+ case 32: puts ("hppa2.0n"); break;
+ default: puts ("hppa2.0"); break;
+ } break;
+ #else /* !defined(_SC_KERNEL_BITS) */
+ puts ("hppa2.0"); break;
+ #endif
+ default: puts ("hppa1.0"); break;
+ }
+ exit (0);
+ }
EOF
(CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
test -z "$HP_ARCH" && HP_ARCH=hppa
@@ -731,22 +732,22 @@ EOF
exit ;;
C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
echo c1-convex-bsd
- exit ;;
+ exit ;;
C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
if getsysinfo -f scalar_acc
then echo c32-convex-bsd
else echo c2-convex-bsd
fi
- exit ;;
+ exit ;;
C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
echo c34-convex-bsd
- exit ;;
+ exit ;;
C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
echo c38-convex-bsd
- exit ;;
+ exit ;;
C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
echo c4-convex-bsd
- exit ;;
+ exit ;;
CRAY*Y-MP:*:*:*)
echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit ;;
@@ -770,14 +771,14 @@ EOF
exit ;;
F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
- FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
- FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
- echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
- exit ;;
+ FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+ FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+ echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+ exit ;;
5000:UNIX_System_V:4.*:*)
- FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
- FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
- echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+ FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+ FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
+ echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit ;;
i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
@@ -789,13 +790,12 @@ EOF
echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
exit ;;
*:FreeBSD:*:*)
- case ${UNAME_MACHINE} in
- pc98)
- echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ UNAME_PROCESSOR=`/usr/bin/uname -p`
+ case ${UNAME_PROCESSOR} in
amd64)
echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
*)
- echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
esac
exit ;;
i*:CYGWIN*:*)
@@ -804,15 +804,18 @@ EOF
*:MINGW*:*)
echo ${UNAME_MACHINE}-pc-mingw32
exit ;;
+ i*:MSYS*:*)
+ echo ${UNAME_MACHINE}-pc-msys
+ exit ;;
i*:windows32*:*)
- # uname -m includes "-pc" on this system.
- echo ${UNAME_MACHINE}-mingw32
+ # uname -m includes "-pc" on this system.
+ echo ${UNAME_MACHINE}-mingw32
exit ;;
i*:PW*:*)
echo ${UNAME_MACHINE}-pc-pw32
exit ;;
*:Interix*:*)
- case ${UNAME_MACHINE} in
+ case ${UNAME_MACHINE} in
x86)
echo i586-pc-interix${UNAME_RELEASE}
exit ;;
@@ -858,6 +861,13 @@ EOF
i*86:Minix:*:*)
echo ${UNAME_MACHINE}-pc-minix
exit ;;
+ aarch64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ aarch64_be:Linux:*:*)
+ UNAME_MACHINE=aarch64_be
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
alpha:Linux:*:*)
case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
EV5) UNAME_MACHINE=alphaev5 ;;
@@ -867,7 +877,7 @@ EOF
EV6) UNAME_MACHINE=alphaev6 ;;
EV67) UNAME_MACHINE=alphaev67 ;;
EV68*) UNAME_MACHINE=alphaev68 ;;
- esac
+ esac
objdump --private-headers /bin/sh | grep -q ld.so.1
if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
@@ -879,20 +889,29 @@ EOF
then
echo ${UNAME_MACHINE}-unknown-linux-gnu
else
- echo ${UNAME_MACHINE}-unknown-linux-gnueabi
+ if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep -q __ARM_PCS_VFP
+ then
+ echo ${UNAME_MACHINE}-unknown-linux-gnueabi
+ else
+ echo ${UNAME_MACHINE}-unknown-linux-gnueabihf
+ fi
fi
exit ;;
avr32*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
cris:Linux:*:*)
- echo cris-axis-linux-gnu
+ echo ${UNAME_MACHINE}-axis-linux-gnu
exit ;;
crisv32:Linux:*:*)
- echo crisv32-axis-linux-gnu
+ echo ${UNAME_MACHINE}-axis-linux-gnu
exit ;;
frv:Linux:*:*)
- echo frv-unknown-linux-gnu
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ hexagon:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
i*86:Linux:*:*)
LIBC=gnu
@@ -934,7 +953,7 @@ EOF
test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
;;
or32:Linux:*:*)
- echo or32-unknown-linux-gnu
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
padre:Linux:*:*)
echo sparc-unknown-linux-gnu
@@ -960,7 +979,7 @@ EOF
echo ${UNAME_MACHINE}-ibm-linux
exit ;;
sh64*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
sh*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
@@ -968,14 +987,17 @@ EOF
sparc:Linux:*:* | sparc64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
+ tile*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
vax:Linux:*:*)
echo ${UNAME_MACHINE}-dec-linux-gnu
exit ;;
x86_64:Linux:*:*)
- echo x86_64-unknown-linux-gnu
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
xtensa*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
i*86:DYNIX/ptx:4*:*)
# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
@@ -984,11 +1006,11 @@ EOF
echo i386-sequent-sysv4
exit ;;
i*86:UNIX_SV:4.2MP:2.*)
- # Unixware is an offshoot of SVR4, but it has its own version
- # number series starting with 2...
- # I am not positive that other SVR4 systems won't match this,
+ # Unixware is an offshoot of SVR4, but it has its own version
+ # number series starting with 2...
+ # I am not positive that other SVR4 systems won't match this,
# I just have to hope. -- rms.
- # Use sysv4.2uw... so that sysv4* matches it.
+ # Use sysv4.2uw... so that sysv4* matches it.
echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
exit ;;
i*86:OS/2:*:*)
@@ -1020,7 +1042,7 @@ EOF
fi
exit ;;
i*86:*:5:[678]*)
- # UnixWare 7.x, OpenUNIX and OpenServer 6.
+ # UnixWare 7.x, OpenUNIX and OpenServer 6.
case `/bin/uname -X | grep "^Machine"` in
*486*) UNAME_MACHINE=i486 ;;
*Pentium) UNAME_MACHINE=i586 ;;
@@ -1048,13 +1070,13 @@ EOF
exit ;;
pc:*:*:*)
# Left here for compatibility:
- # uname -m prints for DJGPP always 'pc', but it prints nothing about
- # the processor, so we play safe by assuming i586.
+ # uname -m prints for DJGPP always 'pc', but it prints nothing about
+ # the processor, so we play safe by assuming i586.
# Note: whatever this is, it MUST be the same as what config.sub
# prints for the "djgpp" host, or else GDB configury will decide that
# this is a cross-build.
echo i586-pc-msdosdjgpp
- exit ;;
+ exit ;;
Intel:Mach:3*:*)
echo i386-pc-mach3
exit ;;
@@ -1089,8 +1111,8 @@ EOF
/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
&& { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
- /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
- && { echo i486-ncr-sysv4; exit; } ;;
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && { echo i486-ncr-sysv4; exit; } ;;
NCR*:*:4.2:* | MPRAS*:*:4.2:*)
OS_REL='.3'
test -r /etc/.relid \
@@ -1133,10 +1155,10 @@ EOF
echo ns32k-sni-sysv
fi
exit ;;
- PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
- # says <Richard.M.Bartel@ccMail.Census.GOV>
- echo i586-unisys-sysv4
- exit ;;
+ PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+ # says <Richard.M.Bartel@ccMail.Census.GOV>
+ echo i586-unisys-sysv4
+ exit ;;
*:UNIX_System_V:4*:FTX*)
# From Gerald Hewes <hewes@openmarket.com>.
# How about differentiating between stratus architectures? -djm
@@ -1162,11 +1184,11 @@ EOF
exit ;;
R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
if [ -d /usr/nec ]; then
- echo mips-nec-sysv${UNAME_RELEASE}
+ echo mips-nec-sysv${UNAME_RELEASE}
else
- echo mips-unknown-sysv${UNAME_RELEASE}
+ echo mips-unknown-sysv${UNAME_RELEASE}
fi
- exit ;;
+ exit ;;
BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
echo powerpc-be-beos
exit ;;
@@ -1231,6 +1253,9 @@ EOF
*:QNX:*:4*)
echo i386-pc-qnx
exit ;;
+ NEO-?:NONSTOP_KERNEL:*:*)
+ echo neo-tandem-nsk${UNAME_RELEASE}
+ exit ;;
NSE-?:NONSTOP_KERNEL:*:*)
echo nse-tandem-nsk${UNAME_RELEASE}
exit ;;
@@ -1276,13 +1301,13 @@ EOF
echo pdp10-unknown-its
exit ;;
SEI:*:*:SEIUX)
- echo mips-sei-seiux${UNAME_RELEASE}
+ echo mips-sei-seiux${UNAME_RELEASE}
exit ;;
*:DragonFly:*:*)
echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
exit ;;
*:*VMS:*:*)
- UNAME_MACHINE=`(uname -p) 2>/dev/null`
+ UNAME_MACHINE=`(uname -p) 2>/dev/null`
case "${UNAME_MACHINE}" in
A*) echo alpha-dec-vms ; exit ;;
I*) echo ia64-dec-vms ; exit ;;
@@ -1300,6 +1325,9 @@ EOF
i*86:AROS:*:*)
echo ${UNAME_MACHINE}-pc-aros
exit ;;
+ x86_64:VMkernel:*:*)
+ echo ${UNAME_MACHINE}-unknown-esx
+ exit ;;
esac
#echo '(No uname command or uname output not recognized.)' 1>&2
@@ -1322,11 +1350,11 @@ main ()
#include <sys/param.h>
printf ("m68k-sony-newsos%s\n",
#ifdef NEWSOS4
- "4"
+ "4"
#else
- ""
+ ""
#endif
- ); exit (0);
+ ); exit (0);
#endif
#endif
diff --git a/contrib/tcpdump/config.h.in b/contrib/tcpdump/config.h.in
index 9ee068be14fe..0342e6101a4d 100644
--- a/contrib/tcpdump/config.h.in
+++ b/contrib/tcpdump/config.h.in
@@ -1,89 +1,36 @@
/* config.h.in. Generated from configure.in by autoheader. */
-/* "generated automatically" means DO NOT MAKE CHANGES TO config.h.in --
- * make them to acconfig.h and rerun autoheader */
-/* Define if you enable IPv6 support */
-#undef INET6
-
-/* Define if you enable support for the libsmi. */
-#undef LIBSMI
-
-/* define if you have the addrinfo function. */
+/* define if you have the addrinfo function */
#undef HAVE_ADDRINFO
-/* define if you need to include missing/addrinfoh.h. */
-#undef NEED_ADDRINFO_H
-
-/* define ifyou have the h_errno variable. */
-#undef HAVE_H_ERRNO
-
-/* define if you have struct sockaddr_storage */
-#undef HAVE_SOCKADDR_STORAGE
-
-/* define if you have both getipnodebyname() and getipnodebyaddr() */
-#undef USE_GETIPNODEBY
-
-/* define if you have ether_ntohost() and it works */
-#undef USE_ETHER_NTOHOST
-
-/* define if libpcap has pcap_version */
-#undef HAVE_PCAP_VERSION
-
-/* define if libpcap has pcap_debug */
-#undef HAVE_PCAP_DEBUG
-
-/* define if libpcap has yydebug */
-#undef HAVE_YYDEBUG
-
-/* define if libpcap has pcap_list_datalinks() */
-#undef HAVE_PCAP_LIST_DATALINKS
-
-/* define if libpcap has pcap_set_datalink() */
-#undef HAVE_PCAP_SET_DATALINK
-
-/* define if libpcap has pcap_datalink_name_to_val() */
-#undef HAVE_PCAP_DATALINK_NAME_TO_VAL
-
-/* define if libpcap has pcap_datalink_val_to_description() */
-#undef HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION
-
-/* define if libpcap has pcap_dump_ftell() */
-#undef HAVE_PCAP_DUMP_FTELL
-
-/* define if you have getrpcbynumber() */
-#undef HAVE_GETRPCBYNUMBER
-
-/* Workaround for missing 64-bit formats */
-#undef PRId64
-#undef PRIo64
-#undef PRIx64
-#undef PRIu64
-
-/* Whether or not to include the possibly-buggy SMB printer */
-#undef TCPDUMP_DO_SMB
+/* Define to 1 if you have the `alarm' function. */
+#undef HAVE_ALARM
-/* Define if you have the dnet_htoa function. */
-#undef HAVE_DNET_HTOA
+/* Define to 1 if you have the `bpf_dump' function. */
+#undef HAVE_BPF_DUMP
-/* Define if you have a dnet_htoa declaration in <netdnet/dnetdb.h>. */
-#undef HAVE_NETDNET_DNETDB_H_DNET_HTOA
+/* capsicum support available */
+#undef HAVE_CAPSICUM
-/* define if should drop privileges by default */
-#undef WITH_USER
+/* Define to 1 if you have the `cap_enter' function. */
+#undef HAVE_CAP_ENTER
-/* define if should chroot when dropping privileges */
-#undef WITH_CHROOT
+/* Define to 1 if you have the `cap_ioctls_limit' function. */
+#undef HAVE_CAP_IOCTLS_LIMIT
-/* Define to 1 if you have the `alarm' function. */
-#undef HAVE_ALARM
+/* Define to 1 if you have the `cap_rights_init' function. */
+#undef HAVE_CAP_RIGHTS_INIT
-/* Define to 1 if you have the `bpf_dump' function. */
-#undef HAVE_BPF_DUMP
+/* Define to 1 if you have the `cap_rights_limit' function. */
+#undef HAVE_CAP_RIGHTS_LIMIT
/* Define to 1 if you have the declaration of `ether_ntohost', and to 0 if you
don't. */
#undef HAVE_DECL_ETHER_NTOHOST
+/* define if you have the dnet_htoa function */
+#undef HAVE_DNET_HTOA
+
/* Define to 1 if you have the `ether_ntohost' function. */
#undef HAVE_ETHER_NTOHOST
@@ -96,6 +43,15 @@
/* Define to 1 if you have the `getnameinfo' function. */
#undef HAVE_GETNAMEINFO
+/* Define to 1 if you have the `getopt_long' function. */
+#undef HAVE_GETOPT_LONG
+
+/* define if you have getrpcbynumber() */
+#undef HAVE_GETRPCBYNUMBER
+
+/* define if you have the h_errno variable */
+#undef HAVE_H_ERRNO
+
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
@@ -105,15 +61,15 @@
/* Define to 1 if you have the `rpc' library (-lrpc). */
#undef HAVE_LIBRPC
-/* Define to 1 if you have the `smi' library (-lsmi). */
-#undef HAVE_LIBSMI
-
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the <netdnet/dnetdb.h> header file. */
#undef HAVE_NETDNET_DNETDB_H
+/* define if you have a dnet_htoa declaration in <netdnet/dnetdb.h> */
+#undef HAVE_NETDNET_DNETDB_H_DNET_HTOA
+
/* Define to 1 if you have the <netinet/ether.h> header file. */
#undef HAVE_NETINET_ETHER_H
@@ -123,6 +79,9 @@
/* Define to 1 if you have the <net/pfvar.h> header file. */
#undef HAVE_NET_PFVAR_H
+/* Define to 1 if you have the `openat' function. */
+#undef HAVE_OPENAT
+
/* Define to 1 if you have the <openssl/evp.h> header file. */
#undef HAVE_OPENSSL_EVP_H
@@ -138,24 +97,57 @@
/* Define to 1 if you have the `pcap_create' function. */
#undef HAVE_PCAP_CREATE
+/* define if libpcap has pcap_datalink_name_to_val() */
+#undef HAVE_PCAP_DATALINK_NAME_TO_VAL
+
+/* define if libpcap has pcap_datalink_val_to_description() */
+#undef HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION
+
+/* define if libpcap has pcap_debug */
+#undef HAVE_PCAP_DEBUG
+
/* Define to 1 if you have the `pcap_dump_flush' function. */
#undef HAVE_PCAP_DUMP_FLUSH
+/* define if libpcap has pcap_dump_ftell() */
+#undef HAVE_PCAP_DUMP_FTELL
+
/* Define to 1 if you have the `pcap_findalldevs' function. */
#undef HAVE_PCAP_FINDALLDEVS
+/* Define to 1 if you have the `pcap_free_datalinks' function. */
+#undef HAVE_PCAP_FREE_DATALINKS
+
/* Define to 1 if the system has the type `pcap_if_t'. */
#undef HAVE_PCAP_IF_T
/* Define to 1 if you have the `pcap_lib_version' function. */
#undef HAVE_PCAP_LIB_VERSION
+/* define if libpcap has pcap_list_datalinks() */
+#undef HAVE_PCAP_LIST_DATALINKS
+
+/* Define to 1 if you have the <pcap/nflog.h> header file. */
+#undef HAVE_PCAP_NFLOG_H
+
+/* Define to 1 if you have the `pcap_setdirection' function. */
+#undef HAVE_PCAP_SETDIRECTION
+
+/* Define to 1 if you have the `pcap_set_datalink' function. */
+#undef HAVE_PCAP_SET_DATALINK
+
+/* Define to 1 if you have the `pcap_set_tstamp_precision' function. */
+#undef HAVE_PCAP_SET_TSTAMP_PRECISION
+
/* Define to 1 if you have the `pcap_set_tstamp_type' function. */
#undef HAVE_PCAP_SET_TSTAMP_TYPE
/* Define to 1 if you have the <pcap/usb.h> header file. */
#undef HAVE_PCAP_USB_H
+/* define if libpcap has pcap_version */
+#undef HAVE_PCAP_VERSION
+
/* Define to 1 if you have the `pfopen' function. */
#undef HAVE_PFOPEN
@@ -174,9 +166,6 @@
/* Define to 1 if you have the `sigset' function. */
#undef HAVE_SIGSET
-/* Define to 1 if you have the <smi.h> header file. */
-#undef HAVE_SMI_H
-
/* Define to 1 if you have the `snprintf' function. */
#undef HAVE_SNPRINTF
@@ -216,9 +205,6 @@
/* Define to 1 if the system has the type `struct ether_addr'. */
#undef HAVE_STRUCT_ETHER_ADDR
-/* Define to 1 if you have the <sys/bitypes.h> header file. */
-#undef HAVE_SYS_BITYPES_H
-
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
@@ -237,12 +223,21 @@
/* Define to 1 if you have the `vsnprintf' function. */
#undef HAVE_VSNPRINTF
+/* define if libpcap has yydebug */
+#undef HAVE_YYDEBUG
+
/* define if your compiler has __attribute__ */
#undef HAVE___ATTRIBUTE__
+/* Define if you enable IPv6 support */
+#undef INET6
+
/* if unaligned access fails */
#undef LBL_ALIGN
+/* define if you need to include missing/addrinfo.h */
+#undef NEED_ADDRINFO_H
+
/* Define to 1 if netinet/ether.h declares `ether_ntohost' */
#undef NETINET_ETHER_H_DECLARES_ETHER_NTOHOST
@@ -261,9 +256,24 @@
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
/* Define to the version of this package. */
#undef PACKAGE_VERSION
+/* define if the platform doesn't define PRId64 */
+#undef PRId64
+
+/* define if the platform doesn't define PRIo64 */
+#undef PRIo64
+
+/* define if the platform doesn't define PRIx64 */
+#undef PRIu64
+
+/* define if the platform doesn't define PRIu64 */
+#undef PRIx64
+
/* Define as the return type of signal handlers (`int' or `void'). */
#undef RETSIGTYPE
@@ -273,48 +283,102 @@
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
+/* define if you want to build the possibly-buggy SMB printer */
+#undef TCPDUMP_DO_SMB
+
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#undef TIME_WITH_SYS_TIME
+/* define if you have ether_ntohost() and it works */
+#undef USE_ETHER_NTOHOST
+
+/* Define if you enable support for libsmi */
+#undef USE_LIBSMI
+
+/* define if should chroot when dropping privileges */
+#undef WITH_CHROOT
+
+/* define if should drop privileges by default */
+#undef WITH_USER
+
/* get BSD semantics on Irix */
#undef _BSD_SIGNALS
-/* needed on HP-UX */
-#undef _HPUX_SOURCE
-
/* define on AIX to get certain functions */
#undef _SUN
+/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
+ <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+ #define below would cause a syntax error. */
+#undef _UINT32_T
+
+/* Define for Solaris 2.5.1 so the uint64_t typedef from <sys/synch.h>,
+ <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+ #define below would cause a syntax error. */
+#undef _UINT64_T
+
+/* Define for Solaris 2.5.1 so the uint8_t typedef from <sys/synch.h>,
+ <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+ #define below would cause a syntax error. */
+#undef _UINT8_T
+
+/* define if your compiler allows __attribute__((format)) without a warning */
+#undef __ATTRIBUTE___FORMAT_OK
+
/* define if your compiler allows __attribute__((format)) to be applied to
function pointers */
#undef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS
+/* define if your compiler allows __attribute__((noreturn)) to be applied to
+ function pointers */
+#undef __ATTRIBUTE___NORETURN_OK_FOR_FUNCTION_POINTERS
+
/* to handle Ultrix compilers that don't support const in prototypes */
#undef const
/* Define as token for inline if inlining supported */
#undef inline
-/* Define to `short' if int16_t not defined. */
+/* Define to the type of a signed integer type of width exactly 16 bits if
+ such a type exists and the standard includes do not define it. */
#undef int16_t
-/* Define to `int' if int32_t not defined. */
+/* Define to the type of a signed integer type of width exactly 32 bits if
+ such a type exists and the standard includes do not define it. */
#undef int32_t
-/* Define to `long long' if int64_t not defined. */
+/* Define to the type of a signed integer type of width exactly 64 bits if
+ such a type exists and the standard includes do not define it. */
#undef int64_t
-/* Define to `signed char' if int8_t not defined. */
+/* Define to the type of a signed integer type of width exactly 8 bits if such
+ a type exists and the standard includes do not define it. */
#undef int8_t
-/* Define to `unsigned short' if u_int16_t not defined. */
+/* Define to `uint16_t' if u_int16_t not defined. */
#undef u_int16_t
-/* Define to `unsigned int' if u_int32_t not defined. */
+/* Define to `uint32_t' if u_int32_t not defined. */
#undef u_int32_t
-/* Define to `unsigned long long' if u_int64_t not defined. */
+/* Define to `uint64_t' if u_int64_t not defined. */
#undef u_int64_t
-/* Define to `unsigned char' if u_int8_t not defined. */
+/* Define to `uint8_t' if u_int8_t not defined. */
#undef u_int8_t
+
+/* Define to the type of an unsigned integer type of width exactly 16 bits if
+ such a type exists and the standard includes do not define it. */
+#undef uint16_t
+
+/* Define to the type of an unsigned integer type of width exactly 32 bits if
+ such a type exists and the standard includes do not define it. */
+#undef uint32_t
+
+/* Define to the type of an unsigned integer type of width exactly 64 bits if
+ such a type exists and the standard includes do not define it. */
+#undef uint64_t
+
+/* Define to the type of an unsigned integer type of width exactly 8 bits if
+ such a type exists and the standard includes do not define it. */
+#undef uint8_t
diff --git a/contrib/tcpdump/config.sub b/contrib/tcpdump/config.sub
index 85186096a9e1..59bb593f109c 100755
--- a/contrib/tcpdump/config.sub
+++ b/contrib/tcpdump/config.sub
@@ -1,10 +1,10 @@
#! /bin/sh
# Configuration validation subroutine script.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
-# Free Software Foundation, Inc.
+# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
+# 2011, 2012 Free Software Foundation, Inc.
-timestamp='2009-12-31'
+timestamp='2012-04-18'
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
@@ -21,9 +21,7 @@ timestamp='2009-12-31'
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
-# 02110-1301, USA.
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
@@ -76,8 +74,8 @@ version="\
GNU config.sub ($timestamp)
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free
-Software Foundation, Inc.
+2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
+Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -124,13 +122,18 @@ esac
# Here we must recognize all the valid KERNEL-OS combinations.
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in
- nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
- uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
+ nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
+ linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
+ knetbsd*-gnu* | netbsd*-gnu* | \
kopensolaris*-gnu* | \
storm-chaos* | os2-emx* | rtmk-nova*)
os=-$maybe_os
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
;;
+ android-linux)
+ os=-linux-android
+ basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
+ ;;
*)
basic_machine=`echo $1 | sed 's/-[^-]*$//'`
if [ $basic_machine != $1 ]
@@ -157,8 +160,8 @@ case $os in
os=
basic_machine=$1
;;
- -bluegene*)
- os=-cnk
+ -bluegene*)
+ os=-cnk
;;
-sim | -cisco | -oki | -wec | -winbond)
os=
@@ -174,10 +177,10 @@ case $os in
os=-chorusos
basic_machine=$1
;;
- -chorusrdb)
- os=-chorusrdb
+ -chorusrdb)
+ os=-chorusrdb
basic_machine=$1
- ;;
+ ;;
-hiux*)
os=-hiuxwe2
;;
@@ -222,6 +225,12 @@ case $os in
-isc*)
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
+ -lynx*178)
+ os=-lynxos178
+ ;;
+ -lynx*5)
+ os=-lynxos5
+ ;;
-lynx*)
os=-lynxos
;;
@@ -246,17 +255,22 @@ case $basic_machine in
# Some are omitted here because they have special meanings below.
1750a | 580 \
| a29k \
+ | aarch64 | aarch64_be \
| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
| am33_2.0 \
| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
+ | be32 | be64 \
| bfin \
| c4x | clipper \
| d10v | d30v | dlx | dsp16xx \
+ | epiphany \
| fido | fr30 | frv \
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+ | hexagon \
| i370 | i860 | i960 | ia64 \
| ip2k | iq2000 \
+ | le32 | le64 \
| lm32 \
| m32c | m32r | m32rle | m68000 | m68k | m88k \
| maxq | mb | microblaze | mcore | mep | metag \
@@ -282,29 +296,39 @@ case $basic_machine in
| moxie \
| mt \
| msp430 \
+ | nds32 | nds32le | nds32be \
| nios | nios2 \
| ns16k | ns32k \
+ | open8 \
| or32 \
| pdp10 | pdp11 | pj | pjl \
- | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
+ | powerpc | powerpc64 | powerpc64le | powerpcle \
| pyramid \
- | rx \
+ | rl78 | rx \
| score \
| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
| sh64 | sh64le \
| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
| sparcv8 | sparcv9 | sparcv9b | sparcv9v \
- | spu | strongarm \
- | tahoe | thumb | tic4x | tic80 | tron \
+ | spu \
+ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
| ubicom32 \
- | v850 | v850e \
+ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
| we32k \
- | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
+ | x86 | xc16x | xstormy16 | xtensa \
| z8k | z80)
basic_machine=$basic_machine-unknown
;;
- m6811 | m68hc11 | m6812 | m68hc12 | picochip)
- # Motorola 68HC11/12.
+ c54x)
+ basic_machine=tic54x-unknown
+ ;;
+ c55x)
+ basic_machine=tic55x-unknown
+ ;;
+ c6x)
+ basic_machine=tic6x-unknown
+ ;;
+ m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip)
basic_machine=$basic_machine-unknown
os=-none
;;
@@ -314,6 +338,21 @@ case $basic_machine in
basic_machine=mt-unknown
;;
+ strongarm | thumb | xscale)
+ basic_machine=arm-unknown
+ ;;
+ xgate)
+ basic_machine=$basic_machine-unknown
+ os=-none
+ ;;
+ xscaleeb)
+ basic_machine=armeb-unknown
+ ;;
+
+ xscaleel)
+ basic_machine=armel-unknown
+ ;;
+
# We use `pc' rather than `unknown'
# because (1) that's what they normally are, and
# (2) the word "unknown" tends to confuse beginning users.
@@ -328,21 +367,25 @@ case $basic_machine in
# Recognize the basic CPU types with company name.
580-* \
| a29k-* \
+ | aarch64-* | aarch64_be-* \
| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
| arm-* | armbe-* | armle-* | armeb-* | armv*-* \
| avr-* | avr32-* \
+ | be32-* | be64-* \
| bfin-* | bs2000-* \
- | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
+ | c[123]* | c30-* | [cjt]90-* | c4x-* \
| clipper-* | craynv-* | cydra-* \
| d10v-* | d30v-* | dlx-* \
| elxsi-* \
| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
| h8300-* | h8500-* \
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+ | hexagon-* \
| i*86-* | i860-* | i960-* | ia64-* \
| ip2k-* | iq2000-* \
+ | le32-* | le64-* \
| lm32-* \
| m32c-* | m32r-* | m32rle-* \
| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
@@ -368,25 +411,29 @@ case $basic_machine in
| mmix-* \
| mt-* \
| msp430-* \
+ | nds32-* | nds32le-* | nds32be-* \
| nios-* | nios2-* \
| none-* | np1-* | ns16k-* | ns32k-* \
+ | open8-* \
| orion-* \
| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
- | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
+ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
| pyramid-* \
- | romp-* | rs6000-* | rx-* \
+ | rl78-* | romp-* | rs6000-* | rx-* \
| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
| sparclite-* \
- | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
- | tahoe-* | thumb-* \
- | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \
+ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \
+ | tahoe-* \
+ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
+ | tile*-* \
| tron-* \
| ubicom32-* \
- | v850-* | v850e-* | vax-* \
+ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
+ | vax-* \
| we32k-* \
- | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
+ | x86-* | x86_64-* | xc16x-* | xps100-* \
| xstormy16-* | xtensa*-* \
| ymp-* \
| z8k-* | z80-*)
@@ -411,7 +458,7 @@ case $basic_machine in
basic_machine=a29k-amd
os=-udi
;;
- abacus)
+ abacus)
basic_machine=abacus-unknown
;;
adobe68k)
@@ -481,11 +528,20 @@ case $basic_machine in
basic_machine=powerpc-ibm
os=-cnk
;;
+ c54x-*)
+ basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ c55x-*)
+ basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ c6x-*)
+ basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
c90)
basic_machine=c90-cray
os=-unicos
;;
- cegcc)
+ cegcc)
basic_machine=arm-unknown
os=-cegcc
;;
@@ -517,7 +573,7 @@ case $basic_machine in
basic_machine=craynv-cray
os=-unicosmp
;;
- cr16)
+ cr16 | cr16-*)
basic_machine=cr16-unknown
os=-elf
;;
@@ -675,7 +731,6 @@ case $basic_machine in
i370-ibm* | ibm*)
basic_machine=i370-ibm
;;
-# I'm not sure what "Sysv32" means. Should this be sysv3.2?
i*86v32)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv32
@@ -733,7 +788,7 @@ case $basic_machine in
basic_machine=ns32k-utek
os=-sysv
;;
- microblaze)
+ microblaze)
basic_machine=microblaze-xilinx
;;
mingw32)
@@ -772,10 +827,18 @@ case $basic_machine in
ms1-*)
basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
;;
+ msys)
+ basic_machine=i386-pc
+ os=-msys
+ ;;
mvs)
basic_machine=i370-ibm
os=-mvs
;;
+ nacl)
+ basic_machine=le32-unknown
+ os=-nacl
+ ;;
ncr3000)
basic_machine=i486-ncr
os=-sysv4
@@ -840,6 +903,12 @@ case $basic_machine in
np1)
basic_machine=np1-gould
;;
+ neo-tandem)
+ basic_machine=neo-tandem
+ ;;
+ nse-tandem)
+ basic_machine=nse-tandem
+ ;;
nsr-tandem)
basic_machine=nsr-tandem
;;
@@ -922,9 +991,10 @@ case $basic_machine in
;;
power) basic_machine=power-ibm
;;
- ppc) basic_machine=powerpc-unknown
+ ppc | ppcbe) basic_machine=powerpc-unknown
;;
- ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ppc-* | ppcbe-*)
+ basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppcle | powerpclittle | ppc-le | powerpc-little)
basic_machine=powerpcle-unknown
@@ -1018,6 +1088,9 @@ case $basic_machine in
basic_machine=i860-stratus
os=-sysv4
;;
+ strongarm-* | thumb-*)
+ basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
sun2)
basic_machine=m68000-sun
;;
@@ -1074,20 +1147,8 @@ case $basic_machine in
basic_machine=t90-cray
os=-unicos
;;
- tic54x | c54x*)
- basic_machine=tic54x-unknown
- os=-coff
- ;;
- tic55x | c55x*)
- basic_machine=tic55x-unknown
- os=-coff
- ;;
- tic6x | c6x*)
- basic_machine=tic6x-unknown
- os=-coff
- ;;
tile*)
- basic_machine=tile-unknown
+ basic_machine=$basic_machine-unknown
os=-linux-gnu
;;
tx39)
@@ -1157,6 +1218,9 @@ case $basic_machine in
xps | xps100)
basic_machine=xps100-honeywell
;;
+ xscale-* | xscalee[bl]-*)
+ basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'`
+ ;;
ymp)
basic_machine=ymp-cray
os=-unicos
@@ -1254,11 +1318,11 @@ esac
if [ x"$os" != x"" ]
then
case $os in
- # First match some system type aliases
- # that might get confused with valid system types.
+ # First match some system type aliases
+ # that might get confused with valid system types.
# -solaris* is a basic system type, with this one exception.
- -auroraux)
- os=-auroraux
+ -auroraux)
+ os=-auroraux
;;
-solaris1 | -solaris1.*)
os=`echo $os | sed -e 's|solaris1|sunos4|'`
@@ -1294,8 +1358,9 @@ case $os in
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
| -chorusos* | -chorusrdb* | -cegcc* \
- | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
- | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
+ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+ | -mingw32* | -linux-gnu* | -linux-android* \
+ | -linux-newlib* | -linux-uclibc* \
| -uxpv* | -beos* | -mpeix* | -udk* \
| -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
@@ -1342,7 +1407,7 @@ case $os in
-opened*)
os=-openedition
;;
- -os400*)
+ -os400*)
os=-os400
;;
-wince*)
@@ -1391,7 +1456,7 @@ case $os in
-sinix*)
os=-sysv4
;;
- -tpf*)
+ -tpf*)
os=-tpf
;;
-triton*)
@@ -1436,8 +1501,8 @@ case $os in
-dicos*)
os=-dicos
;;
- -nacl*)
- ;;
+ -nacl*)
+ ;;
-none)
;;
*)
@@ -1460,10 +1525,10 @@ else
# system, and we'll never get to this point.
case $basic_machine in
- score-*)
+ score-*)
os=-elf
;;
- spu-*)
+ spu-*)
os=-elf
;;
*-acorn)
@@ -1475,8 +1540,17 @@ case $basic_machine in
arm*-semi)
os=-aout
;;
- c4x-* | tic4x-*)
- os=-coff
+ c4x-* | tic4x-*)
+ os=-coff
+ ;;
+ tic54x-*)
+ os=-coff
+ ;;
+ tic55x-*)
+ os=-coff
+ ;;
+ tic6x-*)
+ os=-coff
;;
# This must come before the *-dec entry.
pdp10-*)
@@ -1496,14 +1570,11 @@ case $basic_machine in
;;
m68000-sun)
os=-sunos3
- # This also exists in the configure program, but was not the
- # default.
- # os=-sunos4
;;
m68*-cisco)
os=-aout
;;
- mep-*)
+ mep-*)
os=-elf
;;
mips*-cisco)
@@ -1530,7 +1601,7 @@ case $basic_machine in
*-ibm)
os=-aix
;;
- *-knuth)
+ *-knuth)
os=-mmixware
;;
*-wec)
diff --git a/contrib/tcpdump/configure b/contrib/tcpdump/configure
index c217f1398e26..83a07eff6c5f 100755
--- a/contrib/tcpdump/configure
+++ b/contrib/tcpdump/configure
@@ -1,12 +1,9 @@
#! /bin/sh
-# From configure.in Revision: 1.204 .
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.68.
+# Generated by GNU Autoconf 2.69.
#
#
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
-# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
-# Foundation, Inc.
+# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
#
#
# This configure script is free software; the Free Software Foundation
@@ -135,6 +132,31 @@ export LANGUAGE
# CDPATH.
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+# Use a proper internal environment variable to ensure we don't fall
+ # into an infinite loop, continuously re-executing ourselves.
+ if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
+ _as_can_reexec=no; export _as_can_reexec;
+ # We cannot yet assume a decent shell, so we have to provide a
+# neutralization value for shells without unset; and this also
+# works around shells that cannot unset nonexistent variables.
+# Preserve -v and -x to the replacement shell.
+BASH_ENV=/dev/null
+ENV=/dev/null
+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+case $- in # ((((
+ *v*x* | *x*v* ) as_opts=-vx ;;
+ *v* ) as_opts=-v ;;
+ *x* ) as_opts=-x ;;
+ * ) as_opts= ;;
+esac
+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
+# Admittedly, this is quite paranoid, since all the known shells bail
+# out after a failed `exec'.
+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
+as_fn_exit 255
+ fi
+ # We don't want this to propagate to other subprocesses.
+ { _as_can_reexec=; unset _as_can_reexec;}
if test "x$CONFIG_SHELL" = x; then
as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
emulate sh
@@ -168,7 +190,8 @@ if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
else
exitcode=1; echo positional parameters were not saved.
fi
-test x\$exitcode = x0 || exit 1"
+test x\$exitcode = x0 || exit 1
+test -x / || exit 1"
as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
@@ -213,21 +236,25 @@ IFS=$as_save_IFS
if test "x$CONFIG_SHELL" != x; then :
- # We cannot yet assume a decent shell, so we have to provide a
- # neutralization value for shells without unset; and this also
- # works around shells that cannot unset nonexistent variables.
- # Preserve -v and -x to the replacement shell.
- BASH_ENV=/dev/null
- ENV=/dev/null
- (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
- export CONFIG_SHELL
- case $- in # ((((
- *v*x* | *x*v* ) as_opts=-vx ;;
- *v* ) as_opts=-v ;;
- *x* ) as_opts=-x ;;
- * ) as_opts= ;;
- esac
- exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"}
+ export CONFIG_SHELL
+ # We cannot yet assume a decent shell, so we have to provide a
+# neutralization value for shells without unset; and this also
+# works around shells that cannot unset nonexistent variables.
+# Preserve -v and -x to the replacement shell.
+BASH_ENV=/dev/null
+ENV=/dev/null
+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+case $- in # ((((
+ *v*x* | *x*v* ) as_opts=-vx ;;
+ *v* ) as_opts=-v ;;
+ *x* ) as_opts=-x ;;
+ * ) as_opts= ;;
+esac
+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
+# Admittedly, this is quite paranoid, since all the known shells bail
+# out after a failed `exec'.
+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
+exit 255
fi
if test x$as_have_required = xno; then :
@@ -329,6 +356,14 @@ $as_echo X"$as_dir" |
} # as_fn_mkdir_p
+
+# as_fn_executable_p FILE
+# -----------------------
+# Test if FILE is an executable regular file.
+as_fn_executable_p ()
+{
+ test -f "$1" && test -x "$1"
+} # as_fn_executable_p
# as_fn_append VAR VALUE
# ----------------------
# Append the text in VALUE to the end of the definition contained in VAR. Take
@@ -450,6 +485,10 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits
chmod +x "$as_me.lineno" ||
{ $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
+ # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
+ # already done that, so ensure we don't try to do so again and fall
+ # in an infinite loop. This has already happened in practice.
+ _as_can_reexec=no; export _as_can_reexec
# Don't try to exec as it changes $[0], causing all sort of problems
# (the dirname of $[0] is not the place where we might find the
# original and so on. Autoconf is especially sensitive to this).
@@ -484,16 +523,16 @@ if (echo >conf$$.file) 2>/dev/null; then
# ... but there are two gotchas:
# 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
# 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
- # In both cases, we have to default to `cp -p'.
+ # In both cases, we have to default to `cp -pR'.
ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
- as_ln_s='cp -p'
+ as_ln_s='cp -pR'
elif ln conf$$.file conf$$ 2>/dev/null; then
as_ln_s=ln
else
- as_ln_s='cp -p'
+ as_ln_s='cp -pR'
fi
else
- as_ln_s='cp -p'
+ as_ln_s='cp -pR'
fi
rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
rmdir conf$$.dir 2>/dev/null
@@ -505,28 +544,8 @@ else
as_mkdir_p=false
fi
-if test -x / >/dev/null 2>&1; then
- as_test_x='test -x'
-else
- if ls -dL / >/dev/null 2>&1; then
- as_ls_L_option=L
- else
- as_ls_L_option=
- fi
- as_test_x='
- eval sh -c '\''
- if test -d "$1"; then
- test -d "$1/.";
- else
- case $1 in #(
- -*)set "./$1";;
- esac;
- case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
- ???[sx]*):;;*)false;;esac;fi
- '\'' sh
- '
-fi
-as_executable_p=$as_test_x
+as_test_x='test -x'
+as_executable_p=as_fn_executable_p
# Sed expression to map a string onto a valid CPP name.
as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
@@ -612,6 +631,9 @@ V_INCLS
V_GROUP
V_DEFS
V_CCOPT
+MKDEP
+DEPENDENCY_CFLAG
+AR
RANLIB
PCAP_CONFIG
LIBOBJS
@@ -681,6 +703,7 @@ with_smi
enable_smb
with_user
with_chroot
+with_sandbox_capsicum
enable_ipv6
with_crypto
'
@@ -1148,8 +1171,6 @@ target=$target_alias
if test "x$host_alias" != x; then
if test "x$build_alias" = x; then
cross_compiling=maybe
- $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host.
- If a cross compiler is detected then cross compile mode will be used" >&2
elif test "x$build_alias" != "x$host_alias"; then
cross_compiling=yes
fi
@@ -1320,6 +1341,7 @@ Optional Packages:
--without-smi don't link with libsmi
--with-user=USERNAME drop privileges by default to USERNAME
--with-chroot=DIRECTORY when dropping privileges, chroot to DIRECTORY
+ --with-sandbox-capsicum
--with-crypto use OpenSSL libcrypto [default=yes, if available]
Some influential environment variables:
@@ -1399,9 +1421,9 @@ test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
configure
-generated by GNU Autoconf 2.68
+generated by GNU Autoconf 2.69
-Copyright (C) 2010 Free Software Foundation, Inc.
+Copyright (C) 2012 Free Software Foundation, Inc.
This configure script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it.
_ACEOF
@@ -1674,7 +1696,7 @@ $as_echo "$ac_try_echo"; } >&5
test ! -s conftest.err
} && test -s conftest$ac_exeext && {
test "$cross_compiling" = yes ||
- $as_test_x conftest$ac_exeext
+ test -x conftest$ac_exeext
}; then :
ac_retval=0
else
@@ -1859,12 +1881,142 @@ $as_echo "$ac_res" >&6; }
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_check_type
+
+# ac_fn_c_find_intX_t LINENO BITS VAR
+# -----------------------------------
+# Finds a signed integer type with width BITS, setting cache variable VAR
+# accordingly.
+ac_fn_c_find_intX_t ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for int$2_t" >&5
+$as_echo_n "checking for int$2_t... " >&6; }
+if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ eval "$3=no"
+ # Order is important - never check a type that is potentially smaller
+ # than half of the expected target width.
+ for ac_type in int$2_t 'int' 'long int' \
+ 'long long int' 'short int' 'signed char'; do
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$ac_includes_default
+ enum { N = $2 / 2 - 1 };
+int
+main ()
+{
+static int test_array [1 - 2 * !(0 < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1))];
+test_array [0] = 0;
+return test_array [0];
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$ac_includes_default
+ enum { N = $2 / 2 - 1 };
+int
+main ()
+{
+static int test_array [1 - 2 * !(($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1)
+ < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 2))];
+test_array [0] = 0;
+return test_array [0];
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+ case $ac_type in #(
+ int$2_t) :
+ eval "$3=yes" ;; #(
+ *) :
+ eval "$3=\$ac_type" ;;
+esac
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ if eval test \"x\$"$3"\" = x"no"; then :
+
+else
+ break
+fi
+ done
+fi
+eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_find_intX_t
+
+# ac_fn_c_find_uintX_t LINENO BITS VAR
+# ------------------------------------
+# Finds an unsigned integer type with width BITS, setting cache variable VAR
+# accordingly.
+ac_fn_c_find_uintX_t ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uint$2_t" >&5
+$as_echo_n "checking for uint$2_t... " >&6; }
+if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ eval "$3=no"
+ # Order is important - never check a type that is potentially smaller
+ # than half of the expected target width.
+ for ac_type in uint$2_t 'unsigned int' 'unsigned long int' \
+ 'unsigned long long int' 'unsigned short int' 'unsigned char'; do
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !((($ac_type) -1 >> ($2 / 2 - 1)) >> ($2 / 2 - 1) == 3)];
+test_array [0] = 0;
+return test_array [0];
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ case $ac_type in #(
+ uint$2_t) :
+ eval "$3=yes" ;; #(
+ *) :
+ eval "$3=\$ac_type" ;;
+esac
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ if eval test \"x\$"$3"\" = x"no"; then :
+
+else
+ break
+fi
+ done
+fi
+eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_find_uintX_t
cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by $as_me, which was
-generated by GNU Autoconf 2.68. Invocation command line was
+generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -2324,7 +2476,6 @@ if test "${with_gcc+set}" = set; then :
withval=$with_gcc;
fi
- V_CCOPT="-O"
V_INCLS=""
if test "${srcdir}" != "." ; then
V_INCLS="-I$srcdir"
@@ -2352,7 +2503,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_SHLICC2="yes"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@@ -2408,7 +2559,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_CC="${ac_tool_prefix}gcc"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@@ -2448,7 +2599,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_ac_ct_CC="gcc"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@@ -2501,7 +2652,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_CC="${ac_tool_prefix}cc"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@@ -2542,7 +2693,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
ac_prog_rejected=yes
continue
@@ -2600,7 +2751,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@@ -2644,7 +2795,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_ac_ct_CC="$ac_prog"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@@ -3090,8 +3241,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <stdarg.h>
#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
+struct stat;
/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
struct buf { int x; };
FILE * (*rcsopen) (struct buf *, struct stat *, int);
@@ -3180,147 +3330,107 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
if test "$GCC" = yes ; then
- if test "$SHLICC2" = yes ; then
- ac_cv_lbl_gcc_vers=2
- V_CCOPT="-O2"
- else
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking gcc version" >&5
-$as_echo_n "checking gcc version... " >&6; }
- if ${ac_cv_lbl_gcc_vers+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_cv_lbl_gcc_vers=`$CC -v 2>&1 | \
- sed -e '/^gcc version /!d' \
- -e 's/^gcc version //' \
- -e 's/ .*//' -e 's/^[^0-9]*//' \
- -e 's/\..*//'`
-fi
+ #
+ # -Werror forces warnings to be errors.
+ #
+ ac_lbl_cc_force_warning_errors=-Werror
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_gcc_vers" >&5
-$as_echo "$ac_cv_lbl_gcc_vers" >&6; }
- if test $ac_cv_lbl_gcc_vers -gt 1 ; then
- V_CCOPT="-O2"
- fi
- fi
- else
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking that $CC handles ansi prototypes" >&5
-$as_echo_n "checking that $CC handles ansi prototypes... " >&6; }
- if ${ac_cv_lbl_cc_ansi_prototypes+:} false; then :
- $as_echo_n "(cached) " >&6
-else
+ #
+ # Use -ffloat-store so that, on 32-bit x86, we don't
+ # do 80-bit arithmetic with the FPU; that way we should
+ # get the same results for floating-point calculations
+ # on x86-32 and x86-64.
+ #
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -ffloat-store option" >&5
+$as_echo_n "checking whether the compiler supports the -ffloat-store option... " >&6; }
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors -ffloat-store"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-#include <sys/types.h>
-int
-main ()
-{
-int frob(int, char *)
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_lbl_cc_ansi_prototypes=yes
-else
- ac_cv_lbl_cc_ansi_prototypes=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_cc_ansi_prototypes" >&5
-$as_echo "$ac_cv_lbl_cc_ansi_prototypes" >&6; }
- if test $ac_cv_lbl_cc_ansi_prototypes = no ; then
- case "$host_os" in
- hpux*)
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE)" >&5
-$as_echo_n "checking for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE)... " >&6; }
- savedcflags="$CFLAGS"
- CFLAGS="-Aa -D_HPUX_SOURCE $CFLAGS"
- if ${ac_cv_lbl_cc_hpux_cc_aa+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <sys/types.h>
int
main ()
{
-int frob(int, char *)
+return 0
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_lbl_cc_hpux_cc_aa=yes
-else
- ac_cv_lbl_cc_hpux_cc_aa=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_cc_hpux_cc_aa" >&5
-$as_echo "$ac_cv_lbl_cc_hpux_cc_aa" >&6; }
- if test $ac_cv_lbl_cc_hpux_cc_aa = no ; then
- as_fn_error $? "see the INSTALL doc for more info" "$LINENO" 5
- fi
- CFLAGS="$savedcflags"
- V_CCOPT="-Aa $V_CCOPT"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ CFLAGS="$save_CFLAGS"
+ V_CCOPT="$V_CCOPT -ffloat-store"
-$as_echo "#define _HPUX_SOURCE 1" >>confdefs.h
+else
- ;;
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ CFLAGS="$save_CFLAGS"
- osf*)
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ansi mode in DEC compiler ($CC -std1)" >&5
-$as_echo_n "checking for ansi mode in DEC compiler ($CC -std1)... " >&6; }
- savedcflags="$CFLAGS"
- CFLAGS="-std1"
- if ${ac_cv_lbl_cc_osf1_cc_std1+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <sys/types.h>
-int
-main ()
-{
-int frob(int, char *)
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_lbl_cc_osf1_cc_std1=yes
-else
- ac_cv_lbl_cc_osf1_cc_std1=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_cc_osf1_cc_std1" >&5
-$as_echo "$ac_cv_lbl_cc_osf1_cc_std1" >&6; }
- if test $ac_cv_lbl_cc_osf1_cc_std1 = no ; then
- as_fn_error $? "see the INSTALL doc for more info" "$LINENO" 5
- fi
- CFLAGS="$savedcflags"
- V_CCOPT="-std1 $V_CCOPT"
- ;;
-
- *)
- as_fn_error $? "see the INSTALL doc for more info" "$LINENO" 5
- ;;
- esac
- fi
+ else
V_INCLS="$V_INCLS -I/usr/local/include"
LDFLAGS="$LDFLAGS -L/usr/local/lib"
case "$host_os" in
+ darwin*)
+ #
+ # This is assumed either to be GCC or clang, both
+ # of which use -Werror to force warnings to be errors.
+ #
+ ac_lbl_cc_force_warning_errors=-Werror
+ ;;
+
+ hpux*)
+ #
+ # HP C, which is what we presume we're using, doesn't
+ # exit with a non-zero exit status if we hand it an
+ # invalid -W flag, can't be forced to do so even with
+ # +We, and doesn't handle GCC-style -W flags, so we
+ # don't want to try using GCC-style -W flags.
+ #
+ ac_lbl_cc_dont_try_gcc_dashW=yes
+ ;;
+
irix*)
- V_CCOPT="$V_CCOPT -xansi -signed -O"
+ #
+ # MIPS C, which is what we presume we're using, doesn't
+ # necessarily exit with a non-zero exit status if we
+ # hand it an invalid -W flag, can't be forced to do
+ # so, and doesn't handle GCC-style -W flags, so we
+ # don't want to try using GCC-style -W flags.
+ #
+ ac_lbl_cc_dont_try_gcc_dashW=yes
+ #
+ # It also, apparently, defaults to "char" being
+ # unsigned, unlike most other C implementations;
+ # I suppose we could say "signed char" whenever
+ # we want to guarantee a signed "char", but let's
+ # just force signed chars.
+ #
+ # -xansi is normally the default, but the
+ # configure script was setting it; perhaps -cckr
+ # was the default in the Old Days. (Then again,
+ # that would probably be for backwards compatibility
+ # in the days when ANSI C was Shiny and New, i.e.
+ # 1989 and the early '90's, so maybe we can just
+ # drop support for those compilers.)
+ #
+ # -g is equivalent to -g2, which turns off
+ # optimization; we choose -g3, which generates
+ # debugging information but doesn't turn off
+ # optimization (even if the optimization would
+ # cause inaccuracies in debugging).
+ #
+ V_CCOPT="$V_CCOPT -xansi -signed -g3"
;;
osf*)
@@ -3328,7 +3438,29 @@ $as_echo "$ac_cv_lbl_cc_osf1_cc_std1" >&6; }
# Presumed to be DEC OSF/1, Digital UNIX, or
# Tru64 UNIX.
#
- V_CCOPT="$V_CCOPT -O"
+ # The DEC C compiler, which is what we presume we're
+ # using, doesn't exit with a non-zero exit status if we
+ # hand it an invalid -W flag, can't be forced to do
+ # so, and doesn't handle GCC-style -W flags, so we
+ # don't want to try using GCC-style -W flags.
+ #
+ ac_lbl_cc_dont_try_gcc_dashW=yes
+ #
+ # -g is equivalent to -g2, which turns off
+ # optimization; we choose -g3, which generates
+ # debugging information but doesn't turn off
+ # optimization (even if the optimization would
+ # cause inaccuracies in debugging).
+ #
+ V_CCOPT="$V_CCOPT -g3"
+ ;;
+
+ solaris*)
+ #
+ # Assumed to be Sun C, which requires -errwarn to force
+ # warnings to be treated as errors.
+ #
+ ac_lbl_cc_force_warning_errors=-errwarn
;;
ultrix*)
@@ -3366,6 +3498,7 @@ $as_echo "#define const /**/" >>confdefs.h
fi
;;
esac
+ V_CCOPT="$V_CCOPT -O"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5
@@ -3470,8 +3603,11 @@ if test "$ac_cv___attribute__" = "yes"; then
$as_echo "#define HAVE___ATTRIBUTE__ 1" >>confdefs.h
- V_DEFS="$V_DEFS -D_U_=\"__attribute__((unused))\""
else
+ #
+ # We can't use __attribute__, so we can't use __attribute__((unused)),
+ # so we define _U_ to an empty string.
+ #
V_DEFS="$V_DEFS -D_U_=\"\""
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv___attribute__" >&5
@@ -3479,6 +3615,132 @@ $as_echo "$ac_cv___attribute__" >&6; }
if test "$ac_cv___attribute__" = "yes"; then
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether __attribute__((unused)) can be used without warnings" >&5
+$as_echo_n "checking whether __attribute__((unused)) can be used without warnings... " >&6; }
+if ${ac_cv___attribute___unused+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+save_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+
+int
+main(int argc __attribute((unused)), char **argv __attribute((unused)))
+{
+ printf("Hello, world!\n");
+ return 0;
+}
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv___attribute___unused=yes
+else
+ ac_cv___attribute___unused=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+CFLAGS="$save_CFLAGS"
+if test "$ac_cv___attribute___unused" = "yes"; then
+ V_DEFS="$V_DEFS -D_U_=\"__attribute__((unused))\""
+else
+ V_DEFS="$V_DEFS -D_U_=\"\""
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv___attribute___unused" >&5
+$as_echo "$ac_cv___attribute___unused" >&6; }
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether __attribute__((noreturn)) can be applied to function pointers without warnings" >&5
+$as_echo_n "checking whether __attribute__((noreturn)) can be applied to function pointers without warnings... " >&6; }
+if ${ac_cv___attribute___noreturn_function_pointer+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+save_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+
+#include <stdlib.h>
+
+extern int (*foo)(int i)
+ __attribute__ ((noreturn));
+
+int
+main(int argc, char **argv)
+{
+ (*foo)(1);
+}
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv___attribute___noreturn_function_pointer=yes
+else
+ ac_cv___attribute___noreturn_function_pointer=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+CFLAGS="$save_CFLAGS"
+if test "$ac_cv___attribute___noreturn_function_pointer" = "yes"; then
+
+$as_echo "#define __ATTRIBUTE___NORETURN_OK_FOR_FUNCTION_POINTERS 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv___attribute___noreturn_function_pointer" >&5
+$as_echo "$ac_cv___attribute___noreturn_function_pointer" >&6; }
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether __attribute__((format)) can be used without warnings" >&5
+$as_echo_n "checking whether __attribute__((format)) can be used without warnings... " >&6; }
+if ${ac_cv___attribute___format+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+save_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+
+#include <stdlib.h>
+
+extern int foo(const char *fmt, ...)
+ __attribute__ ((format (printf, 1, 2)));
+
+int
+main(int argc, char **argv)
+{
+ foo("%s", "test");
+}
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv___attribute___format=yes
+else
+ ac_cv___attribute___format=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+CFLAGS="$save_CFLAGS"
+if test "$ac_cv___attribute___format" = "yes"; then
+
+$as_echo "#define __ATTRIBUTE___FORMAT_OK 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv___attribute___format" >&5
+$as_echo "$ac_cv___attribute___format" >&6; }
+
+ if test "$ac_cv___attribute___format" = "yes"; then
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether __attribute__((format)) can be applied to function pointers" >&5
$as_echo_n "checking whether __attribute__((format)) can be applied to function pointers... " >&6; }
if ${ac_cv___attribute___format_function_pointer+:} false; then :
@@ -3517,7 +3779,9 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv___attribute___format_function_pointer" >&5
$as_echo "$ac_cv___attribute___format_function_pointer" >&6; }
+ fi
fi
+
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -3672,7 +3936,7 @@ do
for ac_prog in grep ggrep; do
for ac_exec_ext in '' $ac_executable_extensions; do
ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
- { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
+ as_fn_executable_p "$ac_path_GREP" || continue
# Check for GNU ac_path_GREP and select it if it is found.
# Check for GNU $ac_path_GREP
case `"$ac_path_GREP" --version 2>&1` in
@@ -3738,7 +4002,7 @@ do
for ac_prog in egrep; do
for ac_exec_ext in '' $ac_executable_extensions; do
ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
- { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
+ as_fn_executable_p "$ac_path_EGREP" || continue
# Check for GNU ac_path_EGREP and select it if it is found.
# Check for GNU $ac_path_EGREP
case `"$ac_path_EGREP" --version 2>&1` in
@@ -4058,38 +4322,6 @@ fi
esac
fi
;;
-
-linux*)
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking Linux kernel version" >&5
-$as_echo_n "checking Linux kernel version... " >&6; }
- if test "$cross_compiling" = yes; then
- if ${ac_cv_linux_vers+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_cv_linux_vers=unknown
-fi
-
- else
- if ${ac_cv_linux_vers+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_cv_linux_vers=`uname -r 2>&1 | \
- sed -n -e '$s/.* //' -e '$s/\..*//p'`
-fi
-
- fi
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_linux_vers" >&5
-$as_echo "$ac_cv_linux_vers" >&6; }
- if test $ac_cv_linux_vers = unknown ; then
- as_fn_error $? "cannot determine linux version when cross-compiling" "$LINENO" 5
- fi
- if test $ac_cv_linux_vers -lt 2 ; then
- as_fn_error $? "version 2 or higher required; see the INSTALL doc for more info" "$LINENO" 5
- fi
- ;;
-
-*)
- ;;
esac
@@ -4103,19 +4335,13 @@ fi
if test "x$with_smi" != "xno" ; then
-for ac_header in smi.h
-do :
- ac_fn_c_check_header_mongrel "$LINENO" "smi.h" "ac_cv_header_smi_h" "$ac_includes_default"
+ ac_fn_c_check_header_mongrel "$LINENO" "smi.h" "ac_cv_header_smi_h" "$ac_includes_default"
if test "x$ac_cv_header_smi_h" = xyes; then :
- cat >>confdefs.h <<_ACEOF
-#define HAVE_SMI_H 1
-_ACEOF
-
-fi
-done
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for smiInit in -lsmi" >&5
+ #
+ # OK, we found smi.h. Do we have libsmi with smiInit?
+ #
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for smiInit in -lsmi" >&5
$as_echo_n "checking for smiInit in -lsmi... " >&6; }
if ${ac_cv_lib_smi_smiInit+:} false; then :
$as_echo_n "(cached) " >&6
@@ -4152,27 +4378,26 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_smi_smiInit" >&5
$as_echo "$ac_cv_lib_smi_smiInit" >&6; }
if test "x$ac_cv_lib_smi_smiInit" = xyes; then :
- cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBSMI 1
-_ACEOF
-
- LIBS="-lsmi $LIBS"
-fi
-
-if test "$ac_cv_header_smi_h" = yes -a "$ac_cv_lib_smi_smiInit" = yes
-then
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable libsmi" >&5
+ #
+ # OK, we have libsmi with smiInit. Can we use it?
+ #
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable libsmi" >&5
$as_echo_n "checking whether to enable libsmi... " >&6; }
- if test "$cross_compiling" = yes; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: not when cross-compiling" >&5
+ savedlibs="$LIBS"
+ LIBS="-lsmi $LIBS"
+ if test "$cross_compiling" = yes; then :
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: not when cross-compiling" >&5
$as_echo "not when cross-compiling" >&6; }
- libsmi=no
+ LIBS="$savedlibs"
+
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
- /* libsmi available check */
+
+/* libsmi available check */
#include <smi.h>
main()
{
@@ -4192,31 +4417,41 @@ main()
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
- $as_echo "#define LIBSMI 1" >>confdefs.h
- libsmi=yes
+$as_echo "#define USE_LIBSMI 1" >>confdefs.h
+
+
else
- case $? in
- 1) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no - smiInit failed" >&5
+
+ case $? in
+ 1) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no - smiInit failed" >&5
$as_echo "no - smiInit failed" >&6; } ;;
- 2) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no - header/library version mismatch" >&5
+ 2) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no - header/library version mismatch" >&5
$as_echo "no - header/library version mismatch" >&6; } ;;
- 3) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no - can't determine library version" >&5
+ 3) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no - can't determine library version" >&5
$as_echo "no - can't determine library version" >&6; } ;;
- 4) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no - too old" >&5
+ 4) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no - too old" >&5
$as_echo "no - too old" >&6; } ;;
- *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+ *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; } ;;
- esac
- libsmi=no
+ esac
+ LIBS="$savedlibs"
+
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
+
fi
+
+
+fi
+
+
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable the possibly-buggy SMB printer" >&5
@@ -4233,7 +4468,8 @@ yes) { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: The SMB printer may have exploitable buffer overflows!!!" >&5
$as_echo "$as_me: WARNING: The SMB printer may have exploitable buffer overflows!!!" >&2;}
- $as_echo "#define TCPDUMP_DO_SMB 1" >>confdefs.h
+
+$as_echo "#define TCPDUMP_DO_SMB 1" >>confdefs.h
LOCALSRC="print-smb.c smbutil.c $LOCALSRC"
;;
@@ -4251,7 +4487,8 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to drop root privileges by default" >&5
$as_echo_n "checking whether to drop root privileges by default... " >&6; }
if test ! -z "$with_user" ; then
- cat >>confdefs.h <<_ACEOF
+
+cat >>confdefs.h <<_ACEOF
#define WITH_USER "$withval"
_ACEOF
@@ -4271,7 +4508,8 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to chroot" >&5
$as_echo_n "checking whether to chroot... " >&6; }
if test ! -z "$with_chroot" && test "$with_chroot" != "no" ; then
- cat >>confdefs.h <<_ACEOF
+
+cat >>confdefs.h <<_ACEOF
#define WITH_CHROOT "$withval"
_ACEOF
@@ -4282,6 +4520,315 @@ else
$as_echo "no" >&6; }
fi
+
+# Check whether --with-sandbox-capsicum was given.
+if test "${with_sandbox_capsicum+set}" = set; then :
+ withval=$with_sandbox_capsicum;
+fi
+
+#
+# Check whether various functions are available. If any are, set
+# ac_lbl_capsicum_function_seen to yes; if any are not, set
+# ac_lbl_capsicum_function_not_seen to yes.
+#
+# All of them must be available in order to enable capsicum sandboxing.
+#
+if test ! -z "$with_sandbox-capsicum" && test "$with_sandbox-capsicum" != "no" ; then
+ for ac_func in cap_enter cap_rights_init cap_rights_limit cap_ioctls_limit openat
+do :
+ as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+ ac_lbl_capsicum_function_seen=yes
+else
+ ac_lbl_capsicum_function_not_seen=yes
+fi
+done
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to sandbox using capsicum" >&5
+$as_echo_n "checking whether to sandbox using capsicum... " >&6; }
+if test "x$ac_lbl_capsicum_function_seen" = "xyes" -a "x$ac_lbl_capsicum_function_not_seen" != "xyes"; then
+
+$as_echo "#define HAVE_CAPSICUM 1" >>confdefs.h
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+#
+# We must check this before checking whether to enable IPv6, because,
+# on some platforms (such as SunOS 5.x), the test program requires
+# the extra networking libraries.
+#
+
+ # Most operating systems have gethostbyname() in the default searched
+ # libraries (i.e. libc):
+ # Some OSes (eg. Solaris) place it in libnsl
+ # Some strange OSes (SINIX) have it in libsocket:
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gethostbyname" >&5
+$as_echo_n "checking for library containing gethostbyname... " >&6; }
+if ${ac_cv_search_gethostbyname+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char gethostbyname ();
+int
+main ()
+{
+return gethostbyname ();
+ ;
+ return 0;
+}
+_ACEOF
+for ac_lib in '' nsl socket resolv; do
+ if test -z "$ac_lib"; then
+ ac_res="none required"
+ else
+ ac_res=-l$ac_lib
+ LIBS="-l$ac_lib $ac_func_search_save_LIBS"
+ fi
+ if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_search_gethostbyname=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext
+ if ${ac_cv_search_gethostbyname+:} false; then :
+ break
+fi
+done
+if ${ac_cv_search_gethostbyname+:} false; then :
+
+else
+ ac_cv_search_gethostbyname=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_gethostbyname" >&5
+$as_echo "$ac_cv_search_gethostbyname" >&6; }
+ac_res=$ac_cv_search_gethostbyname
+if test "$ac_res" != no; then :
+ test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+ # Unfortunately libsocket sometimes depends on libnsl and
+ # AC_SEARCH_LIBS isn't up to the task of handling dependencies like this.
+ if test "$ac_cv_search_gethostbyname" = "no"
+ then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lsocket" >&5
+$as_echo_n "checking for gethostbyname in -lsocket... " >&6; }
+if ${ac_cv_lib_socket_gethostbyname+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lsocket -lnsl $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char gethostbyname ();
+int
+main ()
+{
+return gethostbyname ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_socket_gethostbyname=yes
+else
+ ac_cv_lib_socket_gethostbyname=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_gethostbyname" >&5
+$as_echo "$ac_cv_lib_socket_gethostbyname" >&6; }
+if test "x$ac_cv_lib_socket_gethostbyname" = xyes; then :
+ LIBS="-lsocket -lnsl $LIBS"
+fi
+
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing socket" >&5
+$as_echo_n "checking for library containing socket... " >&6; }
+if ${ac_cv_search_socket+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char socket ();
+int
+main ()
+{
+return socket ();
+ ;
+ return 0;
+}
+_ACEOF
+for ac_lib in '' socket; do
+ if test -z "$ac_lib"; then
+ ac_res="none required"
+ else
+ ac_res=-l$ac_lib
+ LIBS="-l$ac_lib $ac_func_search_save_LIBS"
+ fi
+ if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_search_socket=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext
+ if ${ac_cv_search_socket+:} false; then :
+ break
+fi
+done
+if ${ac_cv_search_socket+:} false; then :
+
+else
+ ac_cv_search_socket=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_socket" >&5
+$as_echo "$ac_cv_search_socket" >&6; }
+ac_res=$ac_cv_search_socket
+if test "$ac_res" != no; then :
+ test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for socket in -lsocket" >&5
+$as_echo_n "checking for socket in -lsocket... " >&6; }
+if ${ac_cv_lib_socket_socket+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lsocket -lnsl $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char socket ();
+int
+main ()
+{
+return socket ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_socket_socket=yes
+else
+ ac_cv_lib_socket_socket=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_socket" >&5
+$as_echo "$ac_cv_lib_socket_socket" >&6; }
+if test "x$ac_cv_lib_socket_socket" = xyes; then :
+ LIBS="-lsocket -lnsl $LIBS"
+fi
+
+fi
+
+ # DLPI needs putmsg under HPUX so test for -lstr while we're at it
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing putmsg" >&5
+$as_echo_n "checking for library containing putmsg... " >&6; }
+if ${ac_cv_search_putmsg+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char putmsg ();
+int
+main ()
+{
+return putmsg ();
+ ;
+ return 0;
+}
+_ACEOF
+for ac_lib in '' str; do
+ if test -z "$ac_lib"; then
+ ac_res="none required"
+ else
+ ac_res=-l$ac_lib
+ LIBS="-l$ac_lib $ac_func_search_save_LIBS"
+ fi
+ if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_search_putmsg=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext
+ if ${ac_cv_search_putmsg+:} false; then :
+ break
+fi
+done
+if ${ac_cv_search_putmsg+:} false; then :
+
+else
+ ac_cv_search_putmsg=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_putmsg" >&5
+$as_echo "$ac_cv_search_putmsg" >&6; }
+ac_res=$ac_cv_search_putmsg
+if test "$ac_res" != no; then :
+ test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable ipv6" >&5
$as_echo_n "checking whether to enable ipv6... " >&6; }
# Check whether --enable-ipv6 was given.
@@ -4290,7 +4837,8 @@ if test "${enable_ipv6+set}" = set; then :
yes) { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
LOCALSRC="print-ip6.c print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c print-babel.c $LOCALSRC"
- $as_echo "#define INET6 1" >>confdefs.h
+
+$as_echo "#define INET6 1" >>confdefs.h
ipv6=yes
;;
@@ -4301,31 +4849,31 @@ $as_echo "no" >&6; }
;;
esac
else
- if test "$cross_compiling" = yes; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
- ipv6=no
-
-else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
- /* AF_INET6 available check */
+
+ /* AF_INET6 available check */
#include <sys/types.h>
#include <sys/socket.h>
-main()
+#include <netinet/in.h>
+#ifdef AF_INET6
+void
+foo(struct in6_addr *addr)
{
- if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
- exit(1);
- else
- exit(0);
+ memset(addr, 0, sizeof (struct in6_addr));
}
+#else
+#error "AF_INET6 not defined"
+#endif
+
_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
+if ac_fn_c_try_compile "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
LOCALSRC="print-ip6.c print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c print-babel.c $LOCALSRC"
- $as_echo "#define INET6 1" >>confdefs.h
+
+$as_echo "#define INET6 1" >>confdefs.h
ipv6=yes
else
@@ -4333,10 +4881,7 @@ else
$as_echo "no" >&6; }
ipv6=no
fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
- conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
@@ -4740,7 +5285,8 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $td_cv_decl_netdnet_dnetdb_h_dnet_htoa" >&5
$as_echo "$td_cv_decl_netdnet_dnetdb_h_dnet_htoa" >&6; }
if test "$td_cv_decl_netdnet_dnetdb_h_dnet_htoa" = yes; then
- $as_echo "#define HAVE_NETDNET_DNETDB_H_DNET_HTOA 1" >>confdefs.h
+
+$as_echo "#define HAVE_NETDNET_DNETDB_H_DNET_HTOA 1" >>confdefs.h
fi
@@ -4773,10 +5319,12 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_addrinfo" >&5
$as_echo "$ac_cv_addrinfo" >&6; }
if test $ac_cv_addrinfo = yes; then
- $as_echo "#define HAVE_ADDRINFO 1" >>confdefs.h
+
+$as_echo "#define HAVE_ADDRINFO 1" >>confdefs.h
else
- $as_echo "#define NEED_ADDRINFO_H 1" >>confdefs.h
+
+$as_echo "#define NEED_ADDRINFO_H 1" >>confdefs.h
fi
@@ -4852,44 +5400,6 @@ if test "$ac_cv_namereqd" = no; then
missing_includes=yes
fi
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sockaddr_storage" >&5
-$as_echo_n "checking for sockaddr_storage... " >&6; }
- if ${ac_cv_sa_storage+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-# include <sys/types.h>
-# include <sys/socket.h>
-int
-main ()
-{
-struct sockaddr_storage s
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_sa_storage=yes
-else
- ac_cv_sa_storage=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sa_storage" >&5
-$as_echo "$ac_cv_sa_storage" >&6; }
- if test $ac_cv_sa_storage = yes; then
- $as_echo "#define HAVE_SOCKADDR_STORAGE 1" >>confdefs.h
-
- fi
-
-if test "$ac_cv_sa_storage" = no; then
- missing_includes=yes
-fi
-
ac_fn_c_check_func "$LINENO" "vfprintf" "ac_cv_func_vfprintf"
if test "x$ac_cv_func_vfprintf" = xyes; then :
$as_echo "#define HAVE_VFPRINTF 1" >>confdefs.h
@@ -4968,6 +5478,19 @@ esac
fi
+ac_fn_c_check_func "$LINENO" "getopt_long" "ac_cv_func_getopt_long"
+if test "x$ac_cv_func_getopt_long" = xyes; then :
+ $as_echo "#define HAVE_GETOPT_LONG 1" >>confdefs.h
+
+else
+ case " $LIBOBJS " in
+ *" getopt_long.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS getopt_long.$ac_objext"
+ ;;
+esac
+
+fi
+
for ac_func in fork vfork strftime
do :
@@ -5150,7 +5673,8 @@ $as_echo "$ac_cv_search_dnet_htoa" >&6; }
ac_res=$ac_cv_search_dnet_htoa
if test "$ac_res" != no; then :
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
- $as_echo "#define HAVE_DNET_HTOA 1" >>confdefs.h
+
+$as_echo "#define HAVE_DNET_HTOA 1" >>confdefs.h
fi
@@ -5247,271 +5771,11 @@ $as_echo "$ac_cv_search_getrpcbynumber" >&6; }
ac_res=$ac_cv_search_getrpcbynumber
if test "$ac_res" != no; then :
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
- $as_echo "#define HAVE_GETRPCBYNUMBER 1" >>confdefs.h
-
-fi
-
-
-
-
- # Most operating systems have gethostbyname() in the default searched
- # libraries (i.e. libc):
- # Some OSes (eg. Solaris) place it in libnsl
- # Some strange OSes (SINIX) have it in libsocket:
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gethostbyname" >&5
-$as_echo_n "checking for library containing gethostbyname... " >&6; }
-if ${ac_cv_search_gethostbyname+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_func_search_save_LIBS=$LIBS
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char gethostbyname ();
-int
-main ()
-{
-return gethostbyname ();
- ;
- return 0;
-}
-_ACEOF
-for ac_lib in '' nsl socket resolv; do
- if test -z "$ac_lib"; then
- ac_res="none required"
- else
- ac_res=-l$ac_lib
- LIBS="-l$ac_lib $ac_func_search_save_LIBS"
- fi
- if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_search_gethostbyname=$ac_res
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext
- if ${ac_cv_search_gethostbyname+:} false; then :
- break
-fi
-done
-if ${ac_cv_search_gethostbyname+:} false; then :
-
-else
- ac_cv_search_gethostbyname=no
-fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_gethostbyname" >&5
-$as_echo "$ac_cv_search_gethostbyname" >&6; }
-ac_res=$ac_cv_search_gethostbyname
-if test "$ac_res" != no; then :
- test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
-
-fi
-
- # Unfortunately libsocket sometimes depends on libnsl and
- # AC_SEARCH_LIBS isn't up to the task of handling dependencies like this.
- if test "$ac_cv_search_gethostbyname" = "no"
- then
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lsocket" >&5
-$as_echo_n "checking for gethostbyname in -lsocket... " >&6; }
-if ${ac_cv_lib_socket_gethostbyname+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lsocket -lnsl $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char gethostbyname ();
-int
-main ()
-{
-return gethostbyname ();
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_lib_socket_gethostbyname=yes
-else
- ac_cv_lib_socket_gethostbyname=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_gethostbyname" >&5
-$as_echo "$ac_cv_lib_socket_gethostbyname" >&6; }
-if test "x$ac_cv_lib_socket_gethostbyname" = xyes; then :
- LIBS="-lsocket -lnsl $LIBS"
-fi
-
- fi
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing socket" >&5
-$as_echo_n "checking for library containing socket... " >&6; }
-if ${ac_cv_search_socket+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_func_search_save_LIBS=$LIBS
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char socket ();
-int
-main ()
-{
-return socket ();
- ;
- return 0;
-}
-_ACEOF
-for ac_lib in '' socket; do
- if test -z "$ac_lib"; then
- ac_res="none required"
- else
- ac_res=-l$ac_lib
- LIBS="-l$ac_lib $ac_func_search_save_LIBS"
- fi
- if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_search_socket=$ac_res
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext
- if ${ac_cv_search_socket+:} false; then :
- break
-fi
-done
-if ${ac_cv_search_socket+:} false; then :
-
-else
- ac_cv_search_socket=no
-fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_socket" >&5
-$as_echo "$ac_cv_search_socket" >&6; }
-ac_res=$ac_cv_search_socket
-if test "$ac_res" != no; then :
- test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
-
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for socket in -lsocket" >&5
-$as_echo_n "checking for socket in -lsocket... " >&6; }
-if ${ac_cv_lib_socket_socket+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lsocket -lnsl $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char socket ();
-int
-main ()
-{
-return socket ();
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_lib_socket_socket=yes
-else
- ac_cv_lib_socket_socket=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_socket" >&5
-$as_echo "$ac_cv_lib_socket_socket" >&6; }
-if test "x$ac_cv_lib_socket_socket" = xyes; then :
- LIBS="-lsocket -lnsl $LIBS"
-fi
+$as_echo "#define HAVE_GETRPCBYNUMBER 1" >>confdefs.h
fi
- # DLPI needs putmsg under HPUX so test for -lstr while we're at it
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing putmsg" >&5
-$as_echo_n "checking for library containing putmsg... " >&6; }
-if ${ac_cv_search_putmsg+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_func_search_save_LIBS=$LIBS
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char putmsg ();
-int
-main ()
-{
-return putmsg ();
- ;
- return 0;
-}
-_ACEOF
-for ac_lib in '' str; do
- if test -z "$ac_lib"; then
- ac_res="none required"
- else
- ac_res=-l$ac_lib
- LIBS="-l$ac_lib $ac_func_search_save_LIBS"
- fi
- if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_search_putmsg=$ac_res
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext
- if ${ac_cv_search_putmsg+:} false; then :
- break
-fi
-done
-if ${ac_cv_search_putmsg+:} false; then :
-
-else
- ac_cv_search_putmsg=no
-fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_putmsg" >&5
-$as_echo "$ac_cv_search_putmsg" >&6; }
-ac_res=$ac_cv_search_putmsg
-if test "$ac_res" != no; then :
- test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
-
-fi
@@ -5541,7 +5805,9 @@ $as_echo_n "checking for local pcap library... " >&6; }
lastdir=FAIL
places=`ls $srcdir/.. | sed -e 's,/$,,' -e "s,^,$srcdir/../," | \
egrep '/libpcap-[0-9]+\.[0-9]+(\.[0-9]*)?([ab][0-9]*|-PRE-GIT)?$'`
- for dir in $places $srcdir/../libpcap $srcdir/libpcap ; do
+ places2=`ls .. | sed -e 's,/$,,' -e "s,^,../," | \
+ egrep '/libpcap-[0-9]+\.[0-9]+(\.[0-9]*)?([ab][0-9]*|-PRE-GIT)?$'`
+ for dir in $places $srcdir/../libpcap ../libpcap $srcdir/libpcap $places2 ; do
basedir=`echo $dir | sed -e 's/[ab][0-9]*$//' | \
sed -e 's/-PRE-GIT$//' `
if test $lastdir = $basedir ; then
@@ -5579,7 +5845,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_path_PCAP_CONFIG="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@@ -5622,7 +5888,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_path_ac_pt_PCAP_CONFIG="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@@ -5737,13 +6003,23 @@ $as_echo "found -- -I$d added" >&6; }
V_PCAPDEP=$libpcap
places=`ls $srcdir/.. | sed -e 's,/$,,' -e "s,^,$srcdir/../," | \
egrep '/libpcap-[0-9]*.[0-9]*(.[0-9]*)?([ab][0-9]*)?$'`
+ places2=`ls .. | sed -e 's,/$,,' -e "s,^,../," | \
+ egrep '/libpcap-[0-9]*.[0-9]*(.[0-9]*)?([ab][0-9]*)?$'`
+ pcapH=FAIL
if test -r $d/pcap.h; then
- V_INCLS="-I$d $V_INCLS"
- elif test -r $places/pcap.h; then
- V_INCLS="-I$places $V_INCLS"
+ pcapH=$d
else
- as_fn_error see INSTALL "cannot find pcap.h" "$LINENO" 5
+ for dir in $places $srcdir/../libpcap ../libpcap $srcdir/libpcap $places2 ; do
+ if test -r $dir/pcap.h ; then
+ pcapH=$dir
+ fi
+ done
+ fi
+
+ if test $pcapH = FAIL ; then
+ as_fn_error $? "cannot find pcap.h: see INSTALL" "$LINENO" 5
fi
+ V_INCLS="-I$pcapH $V_INCLS"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libpcap" >&5
$as_echo "$libpcap" >&6; }
# Extract the first word of "pcap-config", so it can be a program name with args.
@@ -5764,7 +6040,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_path_PCAP_CONFIG="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@@ -5860,7 +6136,21 @@ fi
ac_fn_c_check_func "$LINENO" "pcap_list_datalinks" "ac_cv_func_pcap_list_datalinks"
if test "x$ac_cv_func_pcap_list_datalinks" = xyes; then :
- $as_echo "#define HAVE_PCAP_LIST_DATALINKS 1" >>confdefs.h
+
+
+$as_echo "#define HAVE_PCAP_LIST_DATALINKS 1" >>confdefs.h
+
+ for ac_func in pcap_free_datalinks
+do :
+ ac_fn_c_check_func "$LINENO" "pcap_free_datalinks" "ac_cv_func_pcap_free_datalinks"
+if test "x$ac_cv_func_pcap_free_datalinks" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_PCAP_FREE_DATALINKS 1
+_ACEOF
+
+fi
+done
+
else
@@ -5873,20 +6163,27 @@ esac
fi
- ac_fn_c_check_func "$LINENO" "pcap_set_datalink" "ac_cv_func_pcap_set_datalink"
+ for ac_func in pcap_set_datalink
+do :
+ ac_fn_c_check_func "$LINENO" "pcap_set_datalink" "ac_cv_func_pcap_set_datalink"
if test "x$ac_cv_func_pcap_set_datalink" = xyes; then :
- $as_echo "#define HAVE_PCAP_SET_DATALINK 1" >>confdefs.h
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_PCAP_SET_DATALINK 1
+_ACEOF
fi
+done
ac_fn_c_check_func "$LINENO" "pcap_datalink_name_to_val" "ac_cv_func_pcap_datalink_name_to_val"
if test "x$ac_cv_func_pcap_datalink_name_to_val" = xyes; then :
- $as_echo "#define HAVE_PCAP_DATALINK_NAME_TO_VAL 1" >>confdefs.h
+
+$as_echo "#define HAVE_PCAP_DATALINK_NAME_TO_VAL 1" >>confdefs.h
ac_fn_c_check_func "$LINENO" "pcap_datalink_val_to_description" "ac_cv_func_pcap_datalink_val_to_description"
if test "x$ac_cv_func_pcap_datalink_val_to_description" = xyes; then :
- $as_echo "#define HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION 1" >>confdefs.h
+
+$as_echo "#define HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION 1" >>confdefs.h
else
@@ -5924,9 +6221,10 @@ fi
done
- ac_fn_c_check_func "$LINENO" "pcap_dump_ftell" "ac_cv_func_pcap_dump_ftell"
+ ac_fn_c_check_func "$LINENO" "pcap_dump_ftell" "ac_cv_func_pcap_dump_ftell"
if test "x$ac_cv_func_pcap_dump_ftell" = xyes; then :
- $as_echo "#define HAVE_PCAP_DUMP_FTELL 1" >>confdefs.h
+
+$as_echo "#define HAVE_PCAP_DUMP_FTELL 1" >>confdefs.h
else
@@ -6112,7 +6410,8 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_buggy_ether_ntohost" >&5
$as_echo "$ac_cv_buggy_ether_ntohost" >&6; }
if test "$ac_cv_buggy_ether_ntohost" = "no"; then
- $as_echo "#define USE_ETHER_NTOHOST 1" >>confdefs.h
+
+$as_echo "#define USE_ETHER_NTOHOST 1" >>confdefs.h
fi
@@ -6339,9 +6638,24 @@ _ACEOF
fi
done
+ #
+ # And do we have pcap_set_tstamp_precision? If so, we assume
+ # we also have pcap_open_offline_with_tstamp_precision.
+ #
+ for ac_func in pcap_set_tstamp_precision
+do :
+ ac_fn_c_check_func "$LINENO" "pcap_set_tstamp_precision" "ac_cv_func_pcap_set_tstamp_precision"
+if test "x$ac_cv_func_pcap_set_tstamp_precision" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_PCAP_SET_TSTAMP_PRECISION 1
+_ACEOF
+
+fi
+done
+
fi
-for ac_func in pcap_findalldevs pcap_dump_flush pcap_lib_version
+for ac_func in pcap_findalldevs pcap_dump_flush pcap_lib_version pcap_setdirection
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
@@ -6398,7 +6712,8 @@ rm -f core conftest.err conftest.$ac_objext \
if test "$ac_lbl_cv_pcap_version_defined" = yes ; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
- $as_echo "#define HAVE_PCAP_VERSION 1" >>confdefs.h
+
+$as_echo "#define HAVE_PCAP_VERSION 1" >>confdefs.h
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
@@ -6432,7 +6747,8 @@ rm -f core conftest.err conftest.$ac_objext \
if test "$ac_lbl_cv_pcap_debug_defined" = yes ; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
- $as_echo "#define HAVE_PCAP_DEBUG 1" >>confdefs.h
+
+$as_echo "#define HAVE_PCAP_DEBUG 1" >>confdefs.h
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
@@ -6467,7 +6783,8 @@ rm -f core conftest.err conftest.$ac_objext \
if test "$ac_lbl_cv_yydebug_defined" = yes ; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
- $as_echo "#define HAVE_YYDEBUG 1" >>confdefs.h
+
+$as_echo "#define HAVE_YYDEBUG 1" >>confdefs.h
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
@@ -6549,127 +6866,164 @@ if test -f /dev/bpf0 ; then
V_GROUP=bpf
fi
-for ac_header in sys/bitypes.h
-do :
- ac_fn_c_check_header_mongrel "$LINENO" "sys/bitypes.h" "ac_cv_header_sys_bitypes_h" "$ac_includes_default"
-if test "x$ac_cv_header_sys_bitypes_h" = xyes; then :
- cat >>confdefs.h <<_ACEOF
-#define HAVE_SYS_BITYPES_H 1
+#
+# Make sure we have definitions for all the C99 specified-width types
+# (regardless of whether the environment is a C99 environment or not).
+#
+ac_fn_c_find_intX_t "$LINENO" "8" "ac_cv_c_int8_t"
+case $ac_cv_c_int8_t in #(
+ no|yes) ;; #(
+ *)
+
+cat >>confdefs.h <<_ACEOF
+#define int8_t $ac_cv_c_int8_t
_ACEOF
+;;
+esac
-fi
+ac_fn_c_find_intX_t "$LINENO" "16" "ac_cv_c_int16_t"
+case $ac_cv_c_int16_t in #(
+ no|yes) ;; #(
+ *)
-done
+cat >>confdefs.h <<_ACEOF
+#define int16_t $ac_cv_c_int16_t
+_ACEOF
+;;
+esac
+ac_fn_c_find_intX_t "$LINENO" "32" "ac_cv_c_int32_t"
+case $ac_cv_c_int32_t in #(
+ no|yes) ;; #(
+ *)
-ac_fn_c_check_type "$LINENO" "int8_t" "ac_cv_type_int8_t" "$ac_includes_default
-#ifdef HAVE_SYS_BITYPES_H
-#include <sys/bitypes.h>
-#endif
-"
-if test "x$ac_cv_type_int8_t" = xyes; then :
+cat >>confdefs.h <<_ACEOF
+#define int32_t $ac_cv_c_int32_t
+_ACEOF
+;;
+esac
-else
+ac_fn_c_find_intX_t "$LINENO" "64" "ac_cv_c_int64_t"
+case $ac_cv_c_int64_t in #(
+ no|yes) ;; #(
+ *)
-$as_echo "#define int8_t signed char" >>confdefs.h
+cat >>confdefs.h <<_ACEOF
+#define int64_t $ac_cv_c_int64_t
+_ACEOF
+;;
+esac
-fi
+ac_fn_c_find_uintX_t "$LINENO" "8" "ac_cv_c_uint8_t"
+case $ac_cv_c_uint8_t in #(
+ no|yes) ;; #(
+ *)
-ac_fn_c_check_type "$LINENO" "u_int8_t" "ac_cv_type_u_int8_t" "$ac_includes_default
-#ifdef HAVE_SYS_BITYPES_H
-#include <sys/bitypes.h>
-#endif
-"
-if test "x$ac_cv_type_u_int8_t" = xyes; then :
+$as_echo "#define _UINT8_T 1" >>confdefs.h
-else
-$as_echo "#define u_int8_t unsigned char" >>confdefs.h
+cat >>confdefs.h <<_ACEOF
+#define uint8_t $ac_cv_c_uint8_t
+_ACEOF
+;;
+ esac
-fi
+ac_fn_c_find_uintX_t "$LINENO" "16" "ac_cv_c_uint16_t"
+case $ac_cv_c_uint16_t in #(
+ no|yes) ;; #(
+ *)
-ac_fn_c_check_type "$LINENO" "int16_t" "ac_cv_type_int16_t" "$ac_includes_default"
-if test "x$ac_cv_type_int16_t" = xyes; then :
-else
+cat >>confdefs.h <<_ACEOF
+#define uint16_t $ac_cv_c_uint16_t
+_ACEOF
+;;
+ esac
+
+ac_fn_c_find_uintX_t "$LINENO" "32" "ac_cv_c_uint32_t"
+case $ac_cv_c_uint32_t in #(
+ no|yes) ;; #(
+ *)
-$as_echo "#define int16_t short" >>confdefs.h
+$as_echo "#define _UINT32_T 1" >>confdefs.h
- $ac_includes_default
-#ifdef HAVE_SYS_BITYPES_H
-#include <sys/bitypes.h>
-#endif
-fi
-ac_fn_c_check_type "$LINENO" "u_int16_t" "ac_cv_type_u_int16_t" "$ac_includes_default
-#ifdef HAVE_SYS_BITYPES_H
-#include <sys/bitypes.h>
-#endif
-"
-if test "x$ac_cv_type_u_int16_t" = xyes; then :
+cat >>confdefs.h <<_ACEOF
+#define uint32_t $ac_cv_c_uint32_t
+_ACEOF
+;;
+ esac
-else
+ac_fn_c_find_uintX_t "$LINENO" "64" "ac_cv_c_uint64_t"
+case $ac_cv_c_uint64_t in #(
+ no|yes) ;; #(
+ *)
-$as_echo "#define u_int16_t unsigned short" >>confdefs.h
+$as_echo "#define _UINT64_T 1" >>confdefs.h
-fi
-ac_fn_c_check_type "$LINENO" "int32_t" "ac_cv_type_int32_t" "$ac_includes_default
-#ifdef HAVE_SYS_BITYPES_H
-#include <sys/bitypes.h>
-#endif
+cat >>confdefs.h <<_ACEOF
+#define uint64_t $ac_cv_c_uint64_t
+_ACEOF
+;;
+ esac
+
+
+#
+# Define the old BSD specified-width types in terms of the C99 types;
+# we may need them with libpcap include files.
+#
+ac_fn_c_check_type "$LINENO" "u_int8_t" "ac_cv_type_u_int8_t" "$ac_includes_default
+#include <sys/types.h>
+
"
-if test "x$ac_cv_type_int32_t" = xyes; then :
+if test "x$ac_cv_type_u_int8_t" = xyes; then :
else
-$as_echo "#define int32_t int" >>confdefs.h
+$as_echo "#define u_int8_t uint8_t" >>confdefs.h
fi
-ac_fn_c_check_type "$LINENO" "u_int32_t" "ac_cv_type_u_int32_t" "$ac_includes_default
-#ifdef HAVE_SYS_BITYPES_H
-#include <sys/bitypes.h>
-#endif
+ac_fn_c_check_type "$LINENO" "u_int16_t" "ac_cv_type_u_int16_t" "$ac_includes_default
+#include <sys/types.h>
+
"
-if test "x$ac_cv_type_u_int32_t" = xyes; then :
+if test "x$ac_cv_type_u_int16_t" = xyes; then :
else
-$as_echo "#define u_int32_t unsigned int" >>confdefs.h
+$as_echo "#define u_int16_t uint16_t" >>confdefs.h
fi
-ac_fn_c_check_type "$LINENO" "int64_t" "ac_cv_type_int64_t" "$ac_includes_default
-#ifdef HAVE_SYS_BITYPES_H
-#include <sys/bitypes.h>
-#endif
+ac_fn_c_check_type "$LINENO" "u_int32_t" "ac_cv_type_u_int32_t" "$ac_includes_default
+#include <sys/types.h>
+
"
-if test "x$ac_cv_type_int64_t" = xyes; then :
+if test "x$ac_cv_type_u_int32_t" = xyes; then :
else
-$as_echo "#define int64_t long long" >>confdefs.h
+$as_echo "#define u_int32_t uint32_t" >>confdefs.h
fi
ac_fn_c_check_type "$LINENO" "u_int64_t" "ac_cv_type_u_int64_t" "$ac_includes_default
-#ifdef HAVE_SYS_BITYPES_H
-#include <sys/bitypes.h>
-#endif
+#include <sys/types.h>
+
"
if test "x$ac_cv_type_u_int64_t" = xyes; then :
else
-$as_echo "#define u_int64_t unsigned long long" >>confdefs.h
+$as_echo "#define u_int64_t uint64_t" >>confdefs.h
fi
#
-# We can't just check for <inttypes.h> - some systems have one that
-# doesn't define all the PRI[doxu]64 macros.
+# Check for <inttypes.h>
#
for ac_header in inttypes.h
do :
@@ -6680,7 +7034,8 @@ if test "x$ac_cv_header_inttypes_h" = xyes; then :
_ACEOF
#
- # OK, we have inttypes.h, but does it define those macros?
+ # OK, we have inttypes.h, but does it define all the PRI[doxu]64 macros?
+ # Some systems have an inttypes.h that doesn't define all of them.
#
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether inttypes.h defines the PRI[doxu]64 macros" >&5
$as_echo_n "checking whether inttypes.h defines the PRI[doxu]64 macros... " >&6; }
@@ -6691,16 +7046,13 @@ $as_echo_n "checking whether inttypes.h defines the PRI[doxu]64 macros... " >&6;
#include <inttypes.h>
#include <stdio.h>
#include <sys/types.h>
- #ifdef HAVE_SYS_BITYPES_H
- #include <sys/bitypes.h>
- #endif
main()
{
- printf("%" PRId64 "\n", (u_int64_t)1);
- printf("%" PRIo64 "\n", (u_int64_t)1);
- printf("%" PRIx64 "\n", (u_int64_t)1);
- printf("%" PRIu64 "\n", (u_int64_t)1);
+ printf("%" PRId64 "\n", (uint64_t)1);
+ printf("%" PRIo64 "\n", (uint64_t)1);
+ printf("%" PRIx64 "\n", (uint64_t)1);
+ printf("%" PRIu64 "\n", (uint64_t)1);
}
@@ -6749,15 +7101,12 @@ else
# ifdef HAVE_INTTYPES_H
#include <inttypes.h>
# endif
-# ifdef HAVE_SYS_BITYPES_H
- #include <sys/bitypes.h>
-# endif
#include <stdio.h>
#include <sys/types.h>
main()
{
- u_int64_t t = 1;
+ uint64_t t = 1;
char strbuf[16+1];
sprintf(strbuf, "%016lx", t << 32);
if (strcmp(strbuf, "0000000100000000") == 0)
@@ -6770,13 +7119,17 @@ else
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
- $as_echo "#define PRId64 \"ld\"" >>confdefs.h
- $as_echo "#define PRIo64 \"lo\"" >>confdefs.h
+$as_echo "#define PRId64 \"ld\"" >>confdefs.h
+
- $as_echo "#define PRIx64 \"lx\"" >>confdefs.h
+$as_echo "#define PRIo64 \"lo\"" >>confdefs.h
- $as_echo "#define PRIu64 \"lu\"" >>confdefs.h
+
+$as_echo "#define PRIx64 \"lx\"" >>confdefs.h
+
+
+$as_echo "#define PRIu64 \"lu\"" >>confdefs.h
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
@@ -6802,15 +7155,12 @@ else
# ifdef HAVE_INTTYPES_H
#include <inttypes.h>
# endif
-# ifdef HAVE_SYS_BITYPES_H
- #include <sys/bitypes.h>
-# endif
#include <stdio.h>
#include <sys/types.h>
main()
{
- u_int64_t t = 1;
+ uint64_t t = 1;
char strbuf[16+1];
sprintf(strbuf, "%016llx", t << 32);
if (strcmp(strbuf, "0000000100000000") == 0)
@@ -6823,13 +7173,17 @@ else
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
- $as_echo "#define PRId64 \"lld\"" >>confdefs.h
- $as_echo "#define PRIo64 \"llo\"" >>confdefs.h
+$as_echo "#define PRId64 \"lld\"" >>confdefs.h
+
+
+$as_echo "#define PRIo64 \"llo\"" >>confdefs.h
- $as_echo "#define PRIx64 \"llx\"" >>confdefs.h
- $as_echo "#define PRIu64 \"llu\"" >>confdefs.h
+$as_echo "#define PRIx64 \"llx\"" >>confdefs.h
+
+
+$as_echo "#define PRIu64 \"llu\"" >>confdefs.h
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
@@ -6855,15 +7209,12 @@ else
# ifdef HAVE_INTTYPES_H
#include <inttypes.h>
# endif
-# ifdef HAVE_SYS_BITYPES_H
- #include <sys/bitypes.h>
-# endif
#include <stdio.h>
#include <sys/types.h>
main()
{
- u_int64_t t = 1;
+ uint64_t t = 1;
char strbuf[16+1];
sprintf(strbuf, "%016Lx", t << 32);
if (strcmp(strbuf, "0000000100000000") == 0)
@@ -6876,13 +7227,17 @@ else
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
- $as_echo "#define PRId64 \"Ld\"" >>confdefs.h
- $as_echo "#define PRIo64 \"Lo\"" >>confdefs.h
+$as_echo "#define PRId64 \"Ld\"" >>confdefs.h
+
+
+$as_echo "#define PRIo64 \"Lo\"" >>confdefs.h
- $as_echo "#define PRIx64 \"Lx\"" >>confdefs.h
- $as_echo "#define PRIu64 \"Lu\"" >>confdefs.h
+$as_echo "#define PRIx64 \"Lx\"" >>confdefs.h
+
+
+$as_echo "#define PRIu64 \"Lu\"" >>confdefs.h
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
@@ -6908,15 +7263,12 @@ else
# ifdef HAVE_INTTYPES_H
#include <inttypes.h>
# endif
-# ifdef HAVE_SYS_BITYPES_H
- #include <sys/bitypes.h>
-# endif
#include <stdio.h>
#include <sys/types.h>
main()
{
- u_int64_t t = 1;
+ uint64_t t = 1;
char strbuf[16+1];
sprintf(strbuf, "%016qx", t << 32);
if (strcmp(strbuf, "0000000100000000") == 0)
@@ -6929,13 +7281,17 @@ else
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
- $as_echo "#define PRId64 \"qd\"" >>confdefs.h
- $as_echo "#define PRIo64 \"qo\"" >>confdefs.h
+$as_echo "#define PRId64 \"qd\"" >>confdefs.h
+
+
+$as_echo "#define PRIo64 \"qo\"" >>confdefs.h
- $as_echo "#define PRIx64 \"qx\"" >>confdefs.h
- $as_echo "#define PRIu64 \"qu\"" >>confdefs.h
+$as_echo "#define PRIx64 \"qx\"" >>confdefs.h
+
+
+$as_echo "#define PRIu64 \"qu\"" >>confdefs.h
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
@@ -6991,7 +7347,7 @@ savedcppflags="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $V_INCLS"
for ac_header in pcap/bluetooth.h
do :
- ac_fn_c_check_header_compile "$LINENO" "pcap/bluetooth.h" "ac_cv_header_pcap_bluetooth_h" "#include <tcpdump-stdinc.h>
+ ac_fn_c_check_header_compile "$LINENO" "pcap/bluetooth.h" "ac_cv_header_pcap_bluetooth_h" "#include \"tcpdump-stdinc.h\"
"
if test "x$ac_cv_header_pcap_bluetooth_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
@@ -7002,9 +7358,22 @@ fi
done
+for ac_header in pcap/nflog.h
+do :
+ ac_fn_c_check_header_compile "$LINENO" "pcap/nflog.h" "ac_cv_header_pcap_nflog_h" "#include \"tcpdump-stdinc.h\"
+"
+if test "x$ac_cv_header_pcap_nflog_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_PCAP_NFLOG_H 1
+_ACEOF
+
+fi
+
+done
+
for ac_header in pcap/usb.h
do :
- ac_fn_c_check_header_compile "$LINENO" "pcap/usb.h" "ac_cv_header_pcap_usb_h" "#include <tcpdump-stdinc.h>
+ ac_fn_c_check_header_compile "$LINENO" "pcap/usb.h" "ac_cv_header_pcap_usb_h" "#include \"tcpdump-stdinc.h\"
"
if test "x$ac_cv_header_pcap_usb_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
@@ -7034,7 +7403,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@@ -7074,7 +7443,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_ac_ct_RANLIB="ranlib"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@@ -7109,33 +7478,408 @@ else
RANLIB="$ac_cv_prog_RANLIB"
fi
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ar; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_AR+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$AR"; then
+ ac_cv_prog_AR="$AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_AR="${ac_tool_prefix}ar"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+AR=$ac_cv_prog_AR
+if test -n "$AR"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
+$as_echo "$AR" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_AR"; then
+ ac_ct_AR=$AR
+ # Extract the first word of "ar", so it can be a program name with args.
+set dummy ar; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_AR+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_AR"; then
+ ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_AR="ar"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_AR=$ac_cv_prog_ac_ct_AR
+if test -n "$ac_ct_AR"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
+$as_echo "$ac_ct_AR" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_AR" = x; then
+ AR=""
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ AR=$ac_ct_AR
+ fi
+else
+ AR="$ac_cv_prog_AR"
+fi
+
rm -f os-proto.h
if test "${LBL_CFLAGS+set}" = set; then
V_CCOPT="$V_CCOPT ${LBL_CFLAGS}"
fi
if test -f .devel ; then
- if test "$GCC" = yes ; then
- if test "${LBL_CFLAGS+set}" != set; then
- if test "$ac_cv_prog_cc_g" = yes ; then
- V_CCOPT="-g $V_CCOPT"
- fi
- V_CCOPT="$V_CCOPT -Wall"
- if test $ac_cv_lbl_gcc_vers -gt 1 ; then
- V_CCOPT="$V_CCOPT -Wmissing-prototypes -Wstrict-prototypes -Wwrite-strings -Wpointer-arith -W"
- fi
- fi
- else
- case "$host_os" in
+ #
+ # Skip all the warning option stuff on some compilers.
+ #
+ if test "$ac_lbl_cc_dont_try_gcc_dashW" != yes; then
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wall option" >&5
+$as_echo_n "checking whether the compiler supports the -Wall option... " >&6; }
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors -Wall"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+return 0
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ CFLAGS="$save_CFLAGS"
+ V_CCOPT="$V_CCOPT -Wall"
+
+else
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ CFLAGS="$save_CFLAGS"
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wmissing-prototypes option" >&5
+$as_echo_n "checking whether the compiler supports the -Wmissing-prototypes option... " >&6; }
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors -Wmissing-prototypes"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+return 0
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ CFLAGS="$save_CFLAGS"
+ V_CCOPT="$V_CCOPT -Wmissing-prototypes"
+
+else
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ CFLAGS="$save_CFLAGS"
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wstrict-prototypes option" >&5
+$as_echo_n "checking whether the compiler supports the -Wstrict-prototypes option... " >&6; }
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors -Wstrict-prototypes"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+return 0
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ CFLAGS="$save_CFLAGS"
+ V_CCOPT="$V_CCOPT -Wstrict-prototypes"
+
+else
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ CFLAGS="$save_CFLAGS"
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
- irix6*)
- V_CCOPT="$V_CCOPT -n32"
- ;;
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wwrite-strings option" >&5
+$as_echo_n "checking whether the compiler supports the -Wwrite-strings option... " >&6; }
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors -Wwrite-strings"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+return 0
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ CFLAGS="$save_CFLAGS"
+ V_CCOPT="$V_CCOPT -Wwrite-strings"
+
+else
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ CFLAGS="$save_CFLAGS"
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wpointer-arith option" >&5
+$as_echo_n "checking whether the compiler supports the -Wpointer-arith option... " >&6; }
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors -Wpointer-arith"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+return 0
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ CFLAGS="$save_CFLAGS"
+ V_CCOPT="$V_CCOPT -Wpointer-arith"
+
+else
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ CFLAGS="$save_CFLAGS"
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -W option" >&5
+$as_echo_n "checking whether the compiler supports the -W option... " >&6; }
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors -W"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+return 0
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ CFLAGS="$save_CFLAGS"
+ V_CCOPT="$V_CCOPT -W"
+
+else
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ CFLAGS="$save_CFLAGS"
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
- *)
- ;;
- esac
fi
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports generating dependencies" >&5
+$as_echo_n "checking whether the compiler supports generating dependencies... " >&6; }
+ if test "$GCC" = yes ; then
+ #
+ # GCC, or a compiler deemed to be GCC by AC_PROG_CC (even
+ # though it's not); we assume that, in this case, the flag
+ # would be -M.
+ #
+ ac_lbl_dependency_flag="-M"
+ else
+ #
+ # Not GCC or a compiler deemed to be GCC; what platform is
+ # this? (We're assuming that if the compiler isn't GCC
+ # it's the compiler from the vendor of the OS; that won't
+ # necessarily be true for x86 platforms, where it might be
+ # the Intel C compiler.)
+ #
+ case "$host_os" in
+
+ irix*|osf*|darwin*)
+ #
+ # MIPS C for IRIX, DEC C, and clang all use -M.
+ #
+ ac_lbl_dependency_flag="-M"
+ ;;
+
+ solaris*)
+ #
+ # Sun C uses -xM.
+ #
+ ac_lbl_dependency_flag="-xM"
+ ;;
+
+ hpux*)
+ #
+ # HP's older C compilers don't support this.
+ # HP's newer C compilers support this with
+ # either +M or +Make; the older compilers
+ # interpret +M as something completely
+ # different, so we use +Make so we don't
+ # think it works with the older compilers.
+ #
+ ac_lbl_dependency_flag="+Make"
+ ;;
+
+ *)
+ #
+ # Not one of the above; assume no support for
+ # generating dependencies.
+ #
+ ac_lbl_dependency_flag=""
+ ;;
+ esac
+ fi
+
+ #
+ # Is ac_lbl_dependency_flag defined and, if so, does the compiler
+ # complain about it?
+ #
+ # Note: clang doesn't seem to exit with an error status when handed
+ # an unknown non-warning error, even if you pass it
+ # -Werror=unknown-warning-option. However, it always supports
+ # -M, so the fact that this test always succeeds with clang
+ # isn't an issue.
+ #
+ if test ! -z "$ac_lbl_dependency_flag"; then
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+int main(void) { return 0; }
+_ACEOF
+ echo "$CC" $ac_lbl_dependency_flag conftest.c >&5
+ if "$CC" $ac_lbl_dependency_flag conftest.c >/dev/null 2>&1; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, with $ac_lbl_dependency_flag" >&5
+$as_echo "yes, with $ac_lbl_dependency_flag" >&6; }
+ DEPENDENCY_CFLAG="$ac_lbl_dependency_flag"
+ MKDEP='${srcdir}/mkdep'
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ #
+ # We can't run mkdep, so have "make depend" do
+ # nothing.
+ #
+ MKDEP=:
+ fi
+ rm -rf conftest*
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ #
+ # We can't run mkdep, so have "make depend" do
+ # nothing.
+ #
+ MKDEP=:
+ fi
+
+
+
+ #
+ # We used to set -n32 for IRIX 6 when not using GCC (presumed
+ # to mean that we're using MIPS C or MIPSpro C); it specified
+ # the "new" faster 32-bit ABI, introduced in IRIX 6.2. I'm
+ # not sure why that would be something to do *only* with a
+ # .devel file; why should the ABI for which we produce code
+ # depend on .devel?
+ #
os=`echo $host_os | sed -e 's/\([0-9][0-9]*\)[^0-9].*$/\1/'`
name="lbl/os-$os.h"
if test -f $name ; then
@@ -7308,7 +8052,8 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_h_errno" >&5
$as_echo "$ac_cv_var_h_errno" >&6; }
if test "$ac_cv_var_h_errno" = "yes"; then
- $as_echo "#define HAVE_H_ERRNO 1" >>confdefs.h
+
+$as_echo "#define HAVE_H_ERRNO 1" >>confdefs.h
fi
@@ -7456,7 +8201,7 @@ case $as_dir/ in #((
# by default.
for ac_prog in ginstall scoinst install; do
for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then
+ if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
if test $ac_prog = install &&
grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
# AIX install. It has an incompatible calling convention.
@@ -7927,16 +8672,16 @@ if (echo >conf$$.file) 2>/dev/null; then
# ... but there are two gotchas:
# 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
# 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
- # In both cases, we have to default to `cp -p'.
+ # In both cases, we have to default to `cp -pR'.
ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
- as_ln_s='cp -p'
+ as_ln_s='cp -pR'
elif ln conf$$.file conf$$ 2>/dev/null; then
as_ln_s=ln
else
- as_ln_s='cp -p'
+ as_ln_s='cp -pR'
fi
else
- as_ln_s='cp -p'
+ as_ln_s='cp -pR'
fi
rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
rmdir conf$$.dir 2>/dev/null
@@ -7996,28 +8741,16 @@ else
as_mkdir_p=false
fi
-if test -x / >/dev/null 2>&1; then
- as_test_x='test -x'
-else
- if ls -dL / >/dev/null 2>&1; then
- as_ls_L_option=L
- else
- as_ls_L_option=
- fi
- as_test_x='
- eval sh -c '\''
- if test -d "$1"; then
- test -d "$1/.";
- else
- case $1 in #(
- -*)set "./$1";;
- esac;
- case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
- ???[sx]*):;;*)false;;esac;fi
- '\'' sh
- '
-fi
-as_executable_p=$as_test_x
+
+# as_fn_executable_p FILE
+# -----------------------
+# Test if FILE is an executable regular file.
+as_fn_executable_p ()
+{
+ test -f "$1" && test -x "$1"
+} # as_fn_executable_p
+as_test_x='test -x'
+as_executable_p=as_fn_executable_p
# Sed expression to map a string onto a valid CPP name.
as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
@@ -8039,7 +8772,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# values after options handling.
ac_log="
This file was extended by $as_me, which was
-generated by GNU Autoconf 2.68. Invocation command line was
+generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
CONFIG_HEADERS = $CONFIG_HEADERS
@@ -8105,10 +8838,10 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
config.status
-configured by $0, generated by GNU Autoconf 2.68,
+configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
-Copyright (C) 2010 Free Software Foundation, Inc.
+Copyright (C) 2012 Free Software Foundation, Inc.
This config.status script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it."
@@ -8197,7 +8930,7 @@ fi
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
if \$ac_cs_recheck; then
- set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+ set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
shift
\$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
CONFIG_SHELL='$SHELL'
diff --git a/contrib/tcpdump/configure.in b/contrib/tcpdump/configure.in
index 14a60e185e31..5d0f771b3753 100644
--- a/contrib/tcpdump/configure.in
+++ b/contrib/tcpdump/configure.in
@@ -1,5 +1,3 @@
-dnl @(#) $Header: /tcpdump/master/tcpdump/configure.in,v 1.204 2008-11-18 07:39:20 guy Exp $ (LBL)
-dnl
dnl Copyright (c) 1994, 1995, 1996, 1997
dnl The Regents of the University of California. All rights reserved.
dnl
@@ -15,20 +13,25 @@ dnl
# config.sub.
#
-AC_REVISION($Revision: 1.204 $)
-AC_PREREQ(2.50)
+AC_PREREQ(2.61)
AC_INIT(tcpdump.c)
AC_CANONICAL_HOST
-AC_LBL_C_INIT_BEFORE_CC(V_CCOPT, V_INCLS)
+AC_LBL_C_INIT_BEFORE_CC(V_INCLS)
AC_PROG_CC
AC_LBL_C_INIT(V_CCOPT, V_INCLS)
AC_LBL_C_INLINE
AC_C___ATTRIBUTE__
if test "$ac_cv___attribute__" = "yes"; then
- AC_C___ATTRIBUTE___FORMAT_FUNCTION_POINTER
+ AC_C___ATTRIBUTE___UNUSED
+ AC_C___ATTRIBUTE___NORETURN_FUNCTION_POINTER
+ AC_C___ATTRIBUTE___FORMAT
+ if test "$ac_cv___attribute___format" = "yes"; then
+ AC_C___ATTRIBUTE___FORMAT_FUNCTION_POINTER
+ fi
fi
+
AC_CHECK_HEADERS(fcntl.h rpc/rpc.h rpc/rpcent.h netdnet/dnetdb.h)
AC_CHECK_HEADERS(net/pfvar.h, , , [#include <sys/types.h>
#include <sys/socket.h>
@@ -86,28 +89,6 @@ darwin*)
esac
fi
;;
-
-linux*)
- AC_MSG_CHECKING(Linux kernel version)
- if test "$cross_compiling" = yes; then
- AC_CACHE_VAL(ac_cv_linux_vers,
- ac_cv_linux_vers=unknown)
- else
- AC_CACHE_VAL(ac_cv_linux_vers,
- ac_cv_linux_vers=`uname -r 2>&1 | \
- sed -n -e '$s/.* //' -e '$s/\..*//p'`)
- fi
- AC_MSG_RESULT($ac_cv_linux_vers)
- if test $ac_cv_linux_vers = unknown ; then
- AC_MSG_ERROR(cannot determine linux version when cross-compiling)
- fi
- if test $ac_cv_linux_vers -lt 2 ; then
- AC_MSG_ERROR(version 2 or higher required; see the INSTALL doc for more info)
- fi
- ;;
-
-*)
- ;;
esac
@@ -117,18 +98,28 @@ AC_ARG_WITH(smi,
with_smi=yes)
if test "x$with_smi" != "xno" ; then
-AC_CHECK_HEADERS(smi.h)
-AC_CHECK_LIB(smi, smiInit)
-if test "$ac_cv_header_smi_h" = yes -a "$ac_cv_lib_smi_smiInit" = yes
-then
-AC_MSG_CHECKING([whether to enable libsmi])
- AC_TRY_RUN([ /* libsmi available check */
+ AC_CHECK_HEADER(smi.h,
+ [
+ #
+ # OK, we found smi.h. Do we have libsmi with smiInit?
+ #
+ AC_CHECK_LIB(smi, smiInit,
+ [
+ #
+ # OK, we have libsmi with smiInit. Can we use it?
+ #
+ AC_MSG_CHECKING([whether to enable libsmi])
+ savedlibs="$LIBS"
+ LIBS="-lsmi $LIBS"
+ AC_TRY_RUN(
+ [
+/* libsmi available check */
#include <smi.h>
main()
{
int current, revision, age, n;
const int required = 2;
- if (smiInit(""))
+ if (smiInit(""))
exit(1);
if (strcmp(SMI_LIBRARY_VERSION, smi_library_version))
exit(2);
@@ -139,25 +130,35 @@ main()
exit(4);
exit(0);
}
-],
-[ AC_MSG_RESULT(yes)
- AC_DEFINE(LIBSMI)
- libsmi=yes],
-dnl autoconf documentation says that $? contains the exit value.
-dnl reality is that it does not. We leave this in just in case
-dnl autoconf ever comes back to match the documentation.
-[ case $? in
- 1) AC_MSG_RESULT(no - smiInit failed) ;;
- 2) AC_MSG_RESULT(no - header/library version mismatch) ;;
- 3) AC_MSG_RESULT(no - can't determine library version) ;;
- 4) AC_MSG_RESULT(no - too old) ;;
- *) AC_MSG_RESULT(no) ;;
- esac
- libsmi=no],
-[ AC_MSG_RESULT(not when cross-compiling)
- libsmi=no]
-)
-fi
+ ],
+ [
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(USE_LIBSMI, 1,
+ [Define if you enable support for libsmi])
+ ],
+ [
+ dnl autoconf documentation says that
+ dnl $? contains the exit value.
+ dnl reality is that it does not.
+ dnl We leave this in just in case
+ dnl autoconf ever comes back to
+ dnl match the documentation.
+ case $? in
+ 1) AC_MSG_RESULT(no - smiInit failed) ;;
+ 2) AC_MSG_RESULT(no - header/library version mismatch) ;;
+ 3) AC_MSG_RESULT(no - can't determine library version) ;;
+ 4) AC_MSG_RESULT(no - too old) ;;
+ *) AC_MSG_RESULT(no) ;;
+ esac
+ LIBS="$savedlibs"
+ ],
+ [
+ AC_MSG_RESULT(not when cross-compiling)
+ LIBS="$savedlibs"
+ ]
+ )
+ ])
+ ])
fi
AC_MSG_CHECKING([whether to enable the possibly-buggy SMB printer])
@@ -168,7 +169,8 @@ AC_ARG_ENABLE(smb,
case "$enableval" in
yes) AC_MSG_RESULT(yes)
AC_WARN([The SMB printer may have exploitable buffer overflows!!!])
- AC_DEFINE(TCPDUMP_DO_SMB)
+ AC_DEFINE(TCPDUMP_DO_SMB, 1,
+ [define if you want to build the possibly-buggy SMB printer])
LOCALSRC="print-smb.c smbutil.c $LOCALSRC"
;;
*) AC_MSG_RESULT(no)
@@ -178,7 +180,8 @@ esac
AC_ARG_WITH(user, [ --with-user=USERNAME drop privileges by default to USERNAME])
AC_MSG_CHECKING([whether to drop root privileges by default])
if test ! -z "$with_user" ; then
- AC_DEFINE_UNQUOTED(WITH_USER, "$withval")
+ AC_DEFINE_UNQUOTED(WITH_USER, "$withval",
+ [define if should drop privileges by default])
AC_MSG_RESULT(to \"$withval\")
else
AC_MSG_RESULT(no)
@@ -187,12 +190,41 @@ fi
AC_ARG_WITH(chroot, [ --with-chroot=DIRECTORY when dropping privileges, chroot to DIRECTORY])
AC_MSG_CHECKING([whether to chroot])
if test ! -z "$with_chroot" && test "$with_chroot" != "no" ; then
- AC_DEFINE_UNQUOTED(WITH_CHROOT, "$withval")
+ AC_DEFINE_UNQUOTED(WITH_CHROOT, "$withval",
+ [define if should chroot when dropping privileges])
AC_MSG_RESULT(to \"$withval\")
else
AC_MSG_RESULT(no)
fi
+AC_ARG_WITH(sandbox-capsicum, [ --with-sandbox-capsicum ])
+#
+# Check whether various functions are available. If any are, set
+# ac_lbl_capsicum_function_seen to yes; if any are not, set
+# ac_lbl_capsicum_function_not_seen to yes.
+#
+# All of them must be available in order to enable capsicum sandboxing.
+#
+if test ! -z "$with_sandbox-capsicum" && test "$with_sandbox-capsicum" != "no" ; then
+ AC_CHECK_FUNCS(cap_enter cap_rights_init cap_rights_limit cap_ioctls_limit openat,
+ ac_lbl_capsicum_function_seen=yes,
+ ac_lbl_capsicum_function_not_seen=yes)
+fi
+AC_MSG_CHECKING([whether to sandbox using capsicum])
+if test "x$ac_lbl_capsicum_function_seen" = "xyes" -a "x$ac_lbl_capsicum_function_not_seen" != "xyes"; then
+ AC_DEFINE(HAVE_CAPSICUM, 1, [capsicum support available])
+ AC_MSG_RESULT(yes)
+else
+ AC_MSG_RESULT(no)
+fi
+
+#
+# We must check this before checking whether to enable IPv6, because,
+# on some platforms (such as SunOS 5.x), the test program requires
+# the extra networking libraries.
+#
+AC_LBL_LIBRARY_NET
+
AC_MSG_CHECKING([whether to enable ipv6])
AC_ARG_ENABLE(ipv6,
[ --enable-ipv6 enable ipv6 (with ipv4) support
@@ -200,7 +232,7 @@ AC_ARG_ENABLE(ipv6,
[ case "$enableval" in
yes) AC_MSG_RESULT(yes)
LOCALSRC="print-ip6.c print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c print-babel.c $LOCALSRC"
- AC_DEFINE(INET6)
+ AC_DEFINE(INET6, 1, [Define if you enable IPv6 support])
ipv6=yes
;;
*)
@@ -209,20 +241,27 @@ yes) AC_MSG_RESULT(yes)
;;
esac ],
- AC_TRY_RUN([ /* AF_INET6 available check */
+ AC_COMPILE_IFELSE(
+ [
+ AC_LANG_SOURCE(
+ [[/* AF_INET6 available check */
#include <sys/types.h>
#include <sys/socket.h>
-main()
+#include <netinet/in.h>
+#ifdef AF_INET6
+void
+foo(struct in6_addr *addr)
{
- if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
- exit(1);
- else
- exit(0);
+ memset(addr, 0, sizeof (struct in6_addr));
}
-],
+#else
+#error "AF_INET6 not defined"
+#endif
+ ]])
+ ],
[ AC_MSG_RESULT(yes)
LOCALSRC="print-ip6.c print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c print-babel.c $LOCALSRC"
- AC_DEFINE(INET6)
+ AC_DEFINE(INET6, 1, [Define if you enable IPv6 support])
ipv6=yes],
[ AC_MSG_RESULT(no)
ipv6=no],
@@ -491,7 +530,8 @@ AC_CACHE_CHECK([for dnet_htoa declaration in netdnet/dnetdb.h],
td_cv_decl_netdnet_dnetdb_h_dnet_htoa=yes,
td_cv_decl_netdnet_dnetdb_h_dnet_htoa=no)])
if test "$td_cv_decl_netdnet_dnetdb_h_dnet_htoa" = yes; then
- AC_DEFINE(HAVE_NETDNET_DNETDB_H_DNET_HTOA)
+ AC_DEFINE(HAVE_NETDNET_DNETDB_H_DNET_HTOA, 1,
+ [define if you have a dnet_htoa declaration in <netdnet/dnetdb.h>])
fi
dnl
@@ -515,14 +555,7 @@ if test "$ac_cv_namereqd" = no; then
missing_includes=yes
fi
-dnl
-dnl Checks for sockaddr_storage structure
-AC_STRUCT_SA_STORAGE(ac_cv_sa_storage)
-if test "$ac_cv_sa_storage" = no; then
- missing_includes=yes
-fi
-
-AC_REPLACE_FUNCS(vfprintf strcasecmp strlcat strlcpy strdup strsep)
+AC_REPLACE_FUNCS(vfprintf strcasecmp strlcat strlcpy strdup strsep getopt_long)
AC_CHECK_FUNCS(fork vfork strftime)
AC_CHECK_FUNCS(setlinebuf alarm)
@@ -535,12 +568,14 @@ fi
AC_LBL_TYPE_SIGNAL
-AC_SEARCH_LIBS(dnet_htoa, dnet, AC_DEFINE(HAVE_DNET_HTOA))
+AC_SEARCH_LIBS(dnet_htoa, dnet,
+ AC_DEFINE(HAVE_DNET_HTOA, 1, [define if you have the dnet_htoa function]))
AC_CHECK_LIB(rpc, main) dnl It's unclear why we might need -lrpc
dnl Some platforms may need -lnsl for getrpcbynumber.
-AC_SEARCH_LIBS(getrpcbynumber, nsl, AC_DEFINE(HAVE_GETRPCBYNUMBER))
+AC_SEARCH_LIBS(getrpcbynumber, nsl,
+ AC_DEFINE(HAVE_GETRPCBYNUMBER, 1, [define if you have getrpcbynumber()]))
dnl AC_CHECK_LIB(z, uncompress)
dnl AC_CHECK_HEADERS(zlib.h)
@@ -619,7 +654,8 @@ AC_CHECK_FUNCS(ether_ntohost, [
[ac_cv_buggy_ether_ntohost=yes],
[ac_cv_buggy_ether_ntohost="not while cross-compiling"])])
if test "$ac_cv_buggy_ether_ntohost" = "no"; then
- AC_DEFINE(USE_ETHER_NTOHOST)
+ AC_DEFINE(USE_ETHER_NTOHOST, 1,
+ [define if you have ether_ntohost() and it works])
fi
])
if test "$ac_cv_func_ether_ntohost" = yes -a \
@@ -725,9 +761,14 @@ if test $ac_cv_func_pcap_create = "yes" ; then
# pcap_list_tstamp_types and pcap_free_tstamp_types as well.
#
AC_CHECK_FUNCS(pcap_set_tstamp_type)
+ #
+ # And do we have pcap_set_tstamp_precision? If so, we assume
+ # we also have pcap_open_offline_with_tstamp_precision.
+ #
+ AC_CHECK_FUNCS(pcap_set_tstamp_precision)
fi
-AC_CHECK_FUNCS(pcap_findalldevs pcap_dump_flush pcap_lib_version)
+AC_CHECK_FUNCS(pcap_findalldevs pcap_dump_flush pcap_lib_version pcap_setdirection)
if test $ac_cv_func_pcap_findalldevs = "yes" ; then
dnl Check for Mac OS X, which may ship pcap.h from 0.6 but libpcap may
dnl be 0.8; this means that lib has pcap_findalldevs but header doesn't
@@ -750,7 +791,7 @@ if test $ac_cv_func_pcap_lib_version = "no" ; then
ac_lbl_cv_pcap_version_defined=no)
if test "$ac_lbl_cv_pcap_version_defined" = yes ; then
AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_PCAP_VERSION)
+ AC_DEFINE(HAVE_PCAP_VERSION, 1, [define if libpcap has pcap_version])
else
AC_MSG_RESULT(no)
fi
@@ -766,7 +807,7 @@ AC_TRY_LINK([],
ac_lbl_cv_pcap_debug_defined=no)
if test "$ac_lbl_cv_pcap_debug_defined" = yes ; then
AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_PCAP_DEBUG)
+ AC_DEFINE(HAVE_PCAP_DEBUG, 1, [define if libpcap has pcap_debug])
else
AC_MSG_RESULT(no)
#
@@ -783,7 +824,7 @@ else
ac_lbl_cv_yydebug_defined=no)
if test "$ac_lbl_cv_yydebug_defined" = yes ; then
AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_YYDEBUG)
+ AC_DEFINE(HAVE_YYDEBUG, 1, [define if libpcap has yydebug])
else
AC_MSG_RESULT(no)
fi
@@ -850,73 +891,56 @@ if test -f /dev/bpf0 ; then
V_GROUP=bpf
fi
-AC_CHECK_HEADERS(sys/bitypes.h)
+#
+# Make sure we have definitions for all the C99 specified-width types
+# (regardless of whether the environment is a C99 environment or not).
+#
+AC_TYPE_INT8_T
+AC_TYPE_INT16_T
+AC_TYPE_INT32_T
+AC_TYPE_INT64_T
+AC_TYPE_UINT8_T
+AC_TYPE_UINT16_T
+AC_TYPE_UINT32_T
+AC_TYPE_UINT64_T
-AC_CHECK_TYPE([int8_t], ,
- [AC_DEFINE([int8_t], [signed char],
- [Define to `signed char' if int8_t not defined.])],
- [AC_INCLUDES_DEFAULT
-#ifdef HAVE_SYS_BITYPES_H
-#include <sys/bitypes.h>
-#endif])
+#
+# Define the old BSD specified-width types in terms of the C99 types;
+# we may need them with libpcap include files.
+#
AC_CHECK_TYPE([u_int8_t], ,
- [AC_DEFINE([u_int8_t], [unsigned char],
- [Define to `unsigned char' if u_int8_t not defined.])],
- [AC_INCLUDES_DEFAULT
-#ifdef HAVE_SYS_BITYPES_H
-#include <sys/bitypes.h>
-#endif])
-AC_CHECK_TYPE([int16_t], ,
- [AC_DEFINE([int16_t], [short],
- [Define to `short' if int16_t not defined.])]
+ [AC_DEFINE([u_int8_t], [uint8_t],
+ [Define to `uint8_t' if u_int8_t not defined.])],
[AC_INCLUDES_DEFAULT
-#ifdef HAVE_SYS_BITYPES_H
-#include <sys/bitypes.h>
-#endif])
+#include <sys/types.h>
+])
AC_CHECK_TYPE([u_int16_t], ,
- [AC_DEFINE([u_int16_t], [unsigned short],
- [Define to `unsigned short' if u_int16_t not defined.])],
- [AC_INCLUDES_DEFAULT
-#ifdef HAVE_SYS_BITYPES_H
-#include <sys/bitypes.h>
-#endif])
-AC_CHECK_TYPE([int32_t], ,
- [AC_DEFINE([int32_t], [int],
- [Define to `int' if int32_t not defined.])],
+ [AC_DEFINE([u_int16_t], [uint16_t],
+ [Define to `uint16_t' if u_int16_t not defined.])],
[AC_INCLUDES_DEFAULT
-#ifdef HAVE_SYS_BITYPES_H
-#include <sys/bitypes.h>
-#endif])
+#include <sys/types.h>
+])
AC_CHECK_TYPE([u_int32_t], ,
- [AC_DEFINE([u_int32_t], [unsigned int],
- [Define to `unsigned int' if u_int32_t not defined.])],
+ [AC_DEFINE([u_int32_t], [uint32_t],
+ [Define to `uint32_t' if u_int32_t not defined.])],
[AC_INCLUDES_DEFAULT
-#ifdef HAVE_SYS_BITYPES_H
-#include <sys/bitypes.h>
-#endif])
-AC_CHECK_TYPE([int64_t], ,
- [AC_DEFINE([int64_t], [long long],
- [Define to `long long' if int64_t not defined.])],
- [AC_INCLUDES_DEFAULT
-#ifdef HAVE_SYS_BITYPES_H
-#include <sys/bitypes.h>
-#endif])
+#include <sys/types.h>
+])
AC_CHECK_TYPE([u_int64_t], ,
- [AC_DEFINE([u_int64_t], [unsigned long long],
- [Define to `unsigned long long' if u_int64_t not defined.])],
+ [AC_DEFINE([u_int64_t], [uint64_t],
+ [Define to `uint64_t' if u_int64_t not defined.])],
[AC_INCLUDES_DEFAULT
-#ifdef HAVE_SYS_BITYPES_H
-#include <sys/bitypes.h>
-#endif])
+#include <sys/types.h>
+])
#
-# We can't just check for <inttypes.h> - some systems have one that
-# doesn't define all the PRI[doxu]64 macros.
+# Check for <inttypes.h>
#
AC_CHECK_HEADERS(inttypes.h,
[
#
- # OK, we have inttypes.h, but does it define those macros?
+ # OK, we have inttypes.h, but does it define all the PRI[doxu]64 macros?
+ # Some systems have an inttypes.h that doesn't define all of them.
#
AC_MSG_CHECKING([[whether inttypes.h defines the PRI[doxu]64 macros]])
AC_COMPILE_IFELSE(
@@ -926,16 +950,13 @@ AC_CHECK_HEADERS(inttypes.h,
#include <inttypes.h>
#include <stdio.h>
#include <sys/types.h>
- #ifdef HAVE_SYS_BITYPES_H
- #include <sys/bitypes.h>
- #endif
main()
{
- printf("%" PRId64 "\n", (u_int64_t)1);
- printf("%" PRIo64 "\n", (u_int64_t)1);
- printf("%" PRIx64 "\n", (u_int64_t)1);
- printf("%" PRIu64 "\n", (u_int64_t)1);
+ printf("%" PRId64 "\n", (uint64_t)1);
+ printf("%" PRIo64 "\n", (uint64_t)1);
+ printf("%" PRIx64 "\n", (uint64_t)1);
+ printf("%" PRIu64 "\n", (uint64_t)1);
}
]])
],
@@ -980,11 +1001,13 @@ fi
#
savedcppflags="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $V_INCLS"
-AC_CHECK_HEADERS(pcap/bluetooth.h,,,[#include <tcpdump-stdinc.h>])
-AC_CHECK_HEADERS(pcap/usb.h,,,[#include <tcpdump-stdinc.h>])
+AC_CHECK_HEADERS(pcap/bluetooth.h,,,[#include "tcpdump-stdinc.h"])
+AC_CHECK_HEADERS(pcap/nflog.h,,,[#include "tcpdump-stdinc.h"])
+AC_CHECK_HEADERS(pcap/usb.h,,,[#include "tcpdump-stdinc.h"])
CPPFLAGS="$savedcppflags"
AC_PROG_RANLIB
+AC_CHECK_TOOL([AR], [ar])
AC_LBL_DEVEL(V_CCOPT)
diff --git a/contrib/tcpdump/cpack.c b/contrib/tcpdump/cpack.c
index c921b3905918..16bfd151698e 100644
--- a/contrib/tcpdump/cpack.c
+++ b/contrib/tcpdump/cpack.c
@@ -27,6 +27,7 @@
* OF SUCH DAMAGE.
*/
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -38,8 +39,8 @@
#include "cpack.h"
#include "extract.h"
-u_int8_t *
-cpack_next_boundary(u_int8_t *buf, u_int8_t *p, size_t alignment)
+uint8_t *
+cpack_next_boundary(uint8_t *buf, uint8_t *p, size_t alignment)
{
size_t misalignment = (size_t)(p - buf) % alignment;
@@ -53,10 +54,10 @@ cpack_next_boundary(u_int8_t *buf, u_int8_t *p, size_t alignment)
* wordsize bytes remain in the buffer after the boundary. Otherwise,
* return a pointer to the boundary.
*/
-u_int8_t *
+uint8_t *
cpack_align_and_reserve(struct cpack_state *cs, size_t wordsize)
{
- u_int8_t *next;
+ uint8_t *next;
/* Ensure alignment. */
next = cpack_next_boundary(cs->c_buf, cs->c_next, wordsize);
@@ -68,8 +69,19 @@ cpack_align_and_reserve(struct cpack_state *cs, size_t wordsize)
return next;
}
+/* Advance by N bytes without returning them. */
int
-cpack_init(struct cpack_state *cs, u_int8_t *buf, size_t buflen)
+cpack_advance(struct cpack_state *cs, const size_t toskip)
+{
+ /* No space left? */
+ if (cs->c_next - cs->c_buf + toskip > cs->c_len)
+ return -1;
+ cs->c_next += toskip;
+ return 0;
+}
+
+int
+cpack_init(struct cpack_state *cs, uint8_t *buf, size_t buflen)
{
memset(cs, 0, sizeof(*cs));
@@ -82,55 +94,55 @@ cpack_init(struct cpack_state *cs, u_int8_t *buf, size_t buflen)
/* Unpack a 64-bit unsigned integer. */
int
-cpack_uint64(struct cpack_state *cs, u_int64_t *u)
+cpack_uint64(struct cpack_state *cs, uint64_t *u)
{
- u_int8_t *next;
+ uint8_t *next;
if ((next = cpack_align_and_reserve(cs, sizeof(*u))) == NULL)
return -1;
*u = EXTRACT_LE_64BITS(next);
- /* Move pointer past the u_int64_t. */
+ /* Move pointer past the uint64_t. */
cs->c_next = next + sizeof(*u);
return 0;
}
/* Unpack a 32-bit unsigned integer. */
int
-cpack_uint32(struct cpack_state *cs, u_int32_t *u)
+cpack_uint32(struct cpack_state *cs, uint32_t *u)
{
- u_int8_t *next;
+ uint8_t *next;
if ((next = cpack_align_and_reserve(cs, sizeof(*u))) == NULL)
return -1;
*u = EXTRACT_LE_32BITS(next);
- /* Move pointer past the u_int32_t. */
+ /* Move pointer past the uint32_t. */
cs->c_next = next + sizeof(*u);
return 0;
}
/* Unpack a 16-bit unsigned integer. */
int
-cpack_uint16(struct cpack_state *cs, u_int16_t *u)
+cpack_uint16(struct cpack_state *cs, uint16_t *u)
{
- u_int8_t *next;
+ uint8_t *next;
if ((next = cpack_align_and_reserve(cs, sizeof(*u))) == NULL)
return -1;
*u = EXTRACT_LE_16BITS(next);
- /* Move pointer past the u_int16_t. */
+ /* Move pointer past the uint16_t. */
cs->c_next = next + sizeof(*u);
return 0;
}
/* Unpack an 8-bit unsigned integer. */
int
-cpack_uint8(struct cpack_state *cs, u_int8_t *u)
+cpack_uint8(struct cpack_state *cs, uint8_t *u)
{
/* No space left? */
if ((size_t)(cs->c_next - cs->c_buf) >= cs->c_len)
@@ -138,7 +150,7 @@ cpack_uint8(struct cpack_state *cs, u_int8_t *u)
*u = *cs->c_next;
- /* Move pointer past the u_int8_t. */
+ /* Move pointer past the uint8_t. */
cs->c_next++;
return 0;
}
diff --git a/contrib/tcpdump/cpack.h b/contrib/tcpdump/cpack.h
index 74f97960adb8..a7eb6d611d6b 100644
--- a/contrib/tcpdump/cpack.h
+++ b/contrib/tcpdump/cpack.h
@@ -31,24 +31,26 @@
#define _CPACK_H
struct cpack_state {
- u_int8_t *c_buf;
- u_int8_t *c_next;
+ uint8_t *c_buf;
+ uint8_t *c_next;
size_t c_len;
};
-int cpack_init(struct cpack_state *, u_int8_t *, size_t);
+int cpack_init(struct cpack_state *, uint8_t *, size_t);
-int cpack_uint8(struct cpack_state *, u_int8_t *);
-int cpack_uint16(struct cpack_state *, u_int16_t *);
-int cpack_uint32(struct cpack_state *, u_int32_t *);
-int cpack_uint64(struct cpack_state *, u_int64_t *);
+int cpack_uint8(struct cpack_state *, uint8_t *);
+int cpack_uint16(struct cpack_state *, uint16_t *);
+int cpack_uint32(struct cpack_state *, uint32_t *);
+int cpack_uint64(struct cpack_state *, uint64_t *);
-u_int8_t *cpack_next_boundary(u_int8_t *buf, u_int8_t *p, size_t alignment);
-u_int8_t *cpack_align_and_reserve(struct cpack_state *cs, size_t wordsize);
+uint8_t *cpack_next_boundary(uint8_t *buf, uint8_t *p, size_t alignment);
+uint8_t *cpack_align_and_reserve(struct cpack_state *cs, size_t wordsize);
-#define cpack_int8(__s, __p) cpack_uint8((__s), (u_int8_t*)(__p))
-#define cpack_int16(__s, __p) cpack_uint16((__s), (u_int16_t*)(__p))
-#define cpack_int32(__s, __p) cpack_uint32((__s), (u_int32_t*)(__p))
-#define cpack_int64(__s, __p) cpack_uint64((__s), (u_int64_t*)(__p))
+#define cpack_int8(__s, __p) cpack_uint8((__s), (uint8_t*)(__p))
+#define cpack_int16(__s, __p) cpack_uint16((__s), (uint16_t*)(__p))
+#define cpack_int32(__s, __p) cpack_uint32((__s), (uint32_t*)(__p))
+#define cpack_int64(__s, __p) cpack_uint64((__s), (uint64_t*)(__p))
+
+extern int cpack_advance(struct cpack_state *, const size_t);
#endif /* _CPACK_H */
diff --git a/contrib/tcpdump/dccp.h b/contrib/tcpdump/dccp.h
deleted file mode 100644
index 5c66e23cd860..000000000000
--- a/contrib/tcpdump/dccp.h
+++ /dev/null
@@ -1,139 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/dccp.h,v 1.5 2006-11-02 09:05:23 hannes Exp $ (LBL) */
-/*
- * Copyright (C) Arnaldo Carvalho de Melo 2004
- * Copyright (C) Ian McDonald 2005 <iam4@cs.waikato.ac.nz>
- * Copyright (C) Yoshifumi Nishida 2005
- *
- * This software may be distributed either under the terms of the
- * BSD-style license that accompanies tcpdump or the GNU GPL version 2
- */
-
-#ifndef __DCCP_HDR__
-#define __DCCP_HDR__
-
-/**
- * struct dccp_hdr - generic part of DCCP packet header
- *
- * @dccph_sport - Relevant port on the endpoint that sent this packet
- * @dccph_dport - Relevant port on the other endpoint
- * @dccph_doff - Data Offset from the start of the DCCP header, in 32-bit words
- * @dccph_ccval - Used by the HC-Sender CCID
- * @dccph_cscov - Parts of the packet that are covered by the Checksum field
- * @dccph_checksum - Internet checksum, depends on dccph_cscov
- * @dccph_x - 0 = 24 bit sequence number, 1 = 48
- * @dccph_type - packet type, see DCCP_PKT_ prefixed macros
- * @dccph_seq - sequence number high or low order 24 bits, depends on dccph_x
- */
-struct dccp_hdr {
- u_int16_t dccph_sport,
- dccph_dport;
- u_int8_t dccph_doff;
- u_int8_t dccph_ccval_cscov;
- u_int16_t dccph_checksum;
- union {
- u_int8_t dccph_xtr;
- u_int32_t dccph_seq;
- } dccph_xtrs;
-};
-
-#define DCCPH_CCVAL(dh) (((dh)->dccph_ccval_cscov >> 4) & 0xF)
-#define DCCPH_CSCOV(dh) (((dh)->dccph_ccval_cscov) & 0xF)
-
-#define DCCPH_X(dh) ((dh)->dccph_xtrs.dccph_xtr & 1)
-#define DCCPH_TYPE(dh) (((dh)->dccph_xtrs.dccph_xtr >> 1) & 0xF)
-#define DCCPH_SEQ(dh) (((dh)->dccph_xtrs.dccph_seq) >> 8)
-
-/**
- * struct dccp_hdr_ext - the low bits of a 48 bit seq packet
- *
- * @dccph_seq_low - low 24 bits of a 48 bit seq packet
- */
-struct dccp_hdr_ext {
- u_int32_t dccph_seq_low;
-};
-
-/**
- * struct dccp_hdr_request - Conection initiation request header
- *
- * @dccph_req_service - Service to which the client app wants to connect
- */
-struct dccp_hdr_request {
- u_int32_t dccph_req_service;
-};
-
-/**
- * struct dccp_hdr_ack_bits - acknowledgment bits common to most packets
- *
- * @dccph_resp_ack_nr_high - 48 bit ack number high order bits, contains GSR
- * @dccph_resp_ack_nr_low - 48 bit ack number low order bits, contains GSR
- */
-struct dccp_hdr_ack_bits {
- u_int32_t dccph_ra;
- u_int32_t dccph_ack_nr_low;
-};
-
-#define DCCPH_ACK(dh_ack) ((dh_ack)->dccph_ra >> 8)
-
-/**
- * struct dccp_hdr_response - Conection initiation response header
- *
- * @dccph_resp_ack_nr_high - 48 bit ack number high order bits, contains GSR
- * @dccph_resp_ack_nr_low - 48 bit ack number low order bits, contains GSR
- * @dccph_resp_service - Echoes the Service Code on a received DCCP-Request
- */
-struct dccp_hdr_response {
- struct dccp_hdr_ack_bits dccph_resp_ack;
- u_int32_t dccph_resp_service;
-};
-
-#if 0
-static inline struct dccp_hdr_data *dccp_hdr_data(struct dccp_hdr *hdrg)
-{
- const int ext = DCCPH_X(hdrg) ? sizeof(struct dccp_hdr_ext) : 0;
-
- return (struct dccp_hdr_data *)(((u_char *)hdrg) + sizeof(hdrg) + ext);
-}
-#endif
-
-/**
- * struct dccp_hdr_reset - Unconditionally shut down a connection
- *
- * @dccph_reset_service - Echoes the Service Code on a received DCCP-Request
- */
-struct dccp_hdr_reset {
- struct dccp_hdr_ack_bits dccph_reset_ack;
- u_int8_t dccph_reset_code,
- dccph_reset_data[3];
-};
-
-enum dccp_pkt_type {
- DCCP_PKT_REQUEST = 0,
- DCCP_PKT_RESPONSE,
- DCCP_PKT_DATA,
- DCCP_PKT_ACK,
- DCCP_PKT_DATAACK,
- DCCP_PKT_CLOSEREQ,
- DCCP_PKT_CLOSE,
- DCCP_PKT_RESET,
- DCCP_PKT_SYNC,
- DCCP_PKT_SYNCACK,
- DCCP_PKT_INVALID
-};
-
-enum dccp_reset_codes {
- DCCP_RESET_CODE_UNSPECIFIED = 0,
- DCCP_RESET_CODE_CLOSED,
- DCCP_RESET_CODE_ABORTED,
- DCCP_RESET_CODE_NO_CONNECTION,
- DCCP_RESET_CODE_PACKET_ERROR,
- DCCP_RESET_CODE_OPTION_ERROR,
- DCCP_RESET_CODE_MANDATORY_ERROR,
- DCCP_RESET_CODE_CONNECTION_REFUSED,
- DCCP_RESET_CODE_BAD_SERVICE_CODE,
- DCCP_RESET_CODE_TOO_BUSY,
- DCCP_RESET_CODE_BAD_INIT_COOKIE,
- DCCP_RESET_CODE_AGGRESSION_PENALTY,
- __DCCP_RESET_CODE_LAST
-};
-
-#endif /* __DCCP_HDR__ */
diff --git a/contrib/tcpdump/decnet.h b/contrib/tcpdump/decnet.h
deleted file mode 100644
index d25d157d4270..000000000000
--- a/contrib/tcpdump/decnet.h
+++ /dev/null
@@ -1,461 +0,0 @@
-/*
- * Copyright (c) 1992, 1994, 1996
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that: (1) source code distributions
- * retain the above copyright notice and this paragraph in its entirety, (2)
- * distributions including binary code include the above copyright notice and
- * this paragraph in its entirety in the documentation or other materials
- * provided with the distribution, and (3) all advertising materials mentioning
- * features or use of this software display the following acknowledgement:
- * ``This product includes software developed by the University of California,
- * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
- * the University nor the names of its contributors may be used to endorse
- * or promote products derived from this software without specific prior
- * written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/decnet.h,v 1.11 2002-12-11 07:13:50 guy Exp $ (LBL)
- */
-
-#ifndef WIN32
-typedef u_int8_t byte[1]; /* single byte field */
-#else
-/*
- * the keyword 'byte' generates conflicts in Windows
- */
-typedef unsigned char Byte[1]; /* single byte field */
-#define byte Byte
-#endif /* WIN32 */
-typedef u_int8_t word[2]; /* 2 byte field */
-typedef u_int8_t longword[4]; /* 4 bytes field */
-
-/*
- * Definitions for DECNET Phase IV protocol headers
- */
-union etheraddress {
- u_int8_t dne_addr[6]; /* full ethernet address */
- struct {
- u_int8_t dne_hiord[4]; /* DECnet HIORD prefix */
- u_int8_t dne_nodeaddr[2]; /* DECnet node address */
- } dne_remote;
-};
-
-typedef union etheraddress etheraddr; /* Ethernet address */
-
-#define HIORD 0x000400aa /* high 32-bits of address (swapped) */
-
-#define AREAMASK 0176000 /* mask for area field */
-#define AREASHIFT 10 /* bit-offset for area field */
-#define NODEMASK 01777 /* mask for node address field */
-
-#define DN_MAXADDL 20 /* max size of DECnet address */
-struct dn_naddr {
- u_int16_t a_len; /* length of address */
- u_int8_t a_addr[DN_MAXADDL]; /* address as bytes */
-};
-
-/*
- * Define long and short header formats.
- */
-struct shorthdr
- {
- byte sh_flags; /* route flags */
- word sh_dst; /* destination node address */
- word sh_src; /* source node address */
- byte sh_visits; /* visit count */
- };
-
-struct longhdr
- {
- byte lg_flags; /* route flags */
- byte lg_darea; /* destination area (reserved) */
- byte lg_dsarea; /* destination subarea (reserved) */
- etheraddr lg_dst; /* destination id */
- byte lg_sarea; /* source area (reserved) */
- byte lg_ssarea; /* source subarea (reserved) */
- etheraddr lg_src; /* source id */
- byte lg_nextl2; /* next level 2 router (reserved) */
- byte lg_visits; /* visit count */
- byte lg_service; /* service class (reserved) */
- byte lg_pt; /* protocol type (reserved) */
- };
-
-union routehdr
- {
- struct shorthdr rh_short; /* short route header */
- struct longhdr rh_long; /* long route header */
- };
-
-/*
- * Define the values of various fields in the protocol messages.
- *
- * 1. Data packet formats.
- */
-#define RMF_MASK 7 /* mask for message type */
-#define RMF_SHORT 2 /* short message format */
-#define RMF_LONG 6 /* long message format */
-#ifndef RMF_RQR
-#define RMF_RQR 010 /* request return to sender */
-#define RMF_RTS 020 /* returning to sender */
-#define RMF_IE 040 /* intra-ethernet packet */
-#endif /* RMR_RQR */
-#define RMF_FVER 0100 /* future version flag */
-#define RMF_PAD 0200 /* pad field */
-#define RMF_PADMASK 0177 /* pad field mask */
-
-#define VIS_MASK 077 /* visit field mask */
-
-/*
- * 2. Control packet formats.
- */
-#define RMF_CTLMASK 017 /* mask for message type */
-#define RMF_CTLMSG 01 /* control message indicator */
-#define RMF_INIT 01 /* initialization message */
-#define RMF_VER 03 /* verification message */
-#define RMF_TEST 05 /* hello and test message */
-#define RMF_L1ROUT 07 /* level 1 routing message */
-#define RMF_L2ROUT 011 /* level 2 routing message */
-#define RMF_RHELLO 013 /* router hello message */
-#define RMF_EHELLO 015 /* endnode hello message */
-
-#define TI_L2ROUT 01 /* level 2 router */
-#define TI_L1ROUT 02 /* level 1 router */
-#define TI_ENDNODE 03 /* endnode */
-#define TI_VERIF 04 /* verification required */
-#define TI_BLOCK 010 /* blocking requested */
-
-#define VE_VERS 2 /* version number (2) */
-#define VE_ECO 0 /* ECO number */
-#define VE_UECO 0 /* user ECO number (0) */
-
-#define P3_VERS 1 /* phase III version number (1) */
-#define P3_ECO 3 /* ECO number (3) */
-#define P3_UECO 0 /* user ECO number (0) */
-
-#define II_L2ROUT 01 /* level 2 router */
-#define II_L1ROUT 02 /* level 1 router */
-#define II_ENDNODE 03 /* endnode */
-#define II_VERIF 04 /* verification required */
-#define II_NOMCAST 040 /* no multicast traffic accepted */
-#define II_BLOCK 0100 /* blocking requested */
-#define II_TYPEMASK 03 /* mask for node type */
-
-#define TESTDATA 0252 /* test data bytes */
-#define TESTLEN 1 /* length of transmitted test data */
-
-/*
- * Define control message formats.
- */
-struct initmsgIII /* phase III initialization message */
- {
- byte inIII_flags; /* route flags */
- word inIII_src; /* source node address */
- byte inIII_info; /* routing layer information */
- word inIII_blksize; /* maximum data link block size */
- byte inIII_vers; /* version number */
- byte inIII_eco; /* ECO number */
- byte inIII_ueco; /* user ECO number */
- byte inIII_rsvd; /* reserved image field */
- };
-
-struct initmsg /* initialization message */
- {
- byte in_flags; /* route flags */
- word in_src; /* source node address */
- byte in_info; /* routing layer information */
- word in_blksize; /* maximum data link block size */
- byte in_vers; /* version number */
- byte in_eco; /* ECO number */
- byte in_ueco; /* user ECO number */
- word in_hello; /* hello timer */
- byte in_rsvd; /* reserved image field */
- };
-
-struct verifmsg /* verification message */
- {
- byte ve_flags; /* route flags */
- word ve_src; /* source node address */
- byte ve_fcnval; /* function value image field */
- };
-
-struct testmsg /* hello and test message */
- {
- byte te_flags; /* route flags */
- word te_src; /* source node address */
- byte te_data; /* test data image field */
- };
-
-struct l1rout /* level 1 routing message */
- {
- byte r1_flags; /* route flags */
- word r1_src; /* source node address */
- byte r1_rsvd; /* reserved field */
- };
-
-struct l2rout /* level 2 routing message */
- {
- byte r2_flags; /* route flags */
- word r2_src; /* source node address */
- byte r2_rsvd; /* reserved field */
- };
-
-struct rhellomsg /* router hello message */
- {
- byte rh_flags; /* route flags */
- byte rh_vers; /* version number */
- byte rh_eco; /* ECO number */
- byte rh_ueco; /* user ECO number */
- etheraddr rh_src; /* source id */
- byte rh_info; /* routing layer information */
- word rh_blksize; /* maximum data link block size */
- byte rh_priority; /* router's priority */
- byte rh_area; /* reserved */
- word rh_hello; /* hello timer */
- byte rh_mpd; /* reserved */
- };
-
-struct ehellomsg /* endnode hello message */
- {
- byte eh_flags; /* route flags */
- byte eh_vers; /* version number */
- byte eh_eco; /* ECO number */
- byte eh_ueco; /* user ECO number */
- etheraddr eh_src; /* source id */
- byte eh_info; /* routing layer information */
- word eh_blksize; /* maximum data link block size */
- byte eh_area; /* area (reserved) */
- byte eh_seed[8]; /* verification seed */
- etheraddr eh_router; /* designated router */
- word eh_hello; /* hello timer */
- byte eh_mpd; /* (reserved) */
- byte eh_data; /* test data image field */
- };
-
-union controlmsg
- {
- struct initmsg cm_init; /* initialization message */
- struct verifmsg cm_ver; /* verification message */
- struct testmsg cm_test; /* hello and test message */
- struct l1rout cm_l1rou; /* level 1 routing message */
- struct l2rout cm_l2rout; /* level 2 routing message */
- struct rhellomsg cm_rhello; /* router hello message */
- struct ehellomsg cm_ehello; /* endnode hello message */
- };
-
-/* Macros for decoding routing-info fields */
-#define RI_COST(x) ((x)&0777)
-#define RI_HOPS(x) (((x)>>10)&037)
-
-/*
- * NSP protocol fields and values.
- */
-
-#define NSP_TYPEMASK 014 /* mask to isolate type code */
-#define NSP_SUBMASK 0160 /* mask to isolate subtype code */
-#define NSP_SUBSHFT 4 /* shift to move subtype code */
-
-#define MFT_DATA 0 /* data message */
-#define MFT_ACK 04 /* acknowledgement message */
-#define MFT_CTL 010 /* control message */
-
-#define MFS_ILS 020 /* data or I/LS indicator */
-#define MFS_BOM 040 /* beginning of message (data) */
-#define MFS_MOM 0 /* middle of message (data) */
-#define MFS_EOM 0100 /* end of message (data) */
-#define MFS_INT 040 /* interrupt message */
-
-#define MFS_DACK 0 /* data acknowledgement */
-#define MFS_IACK 020 /* I/LS acknowledgement */
-#define MFS_CACK 040 /* connect acknowledgement */
-
-#define MFS_NOP 0 /* no operation */
-#define MFS_CI 020 /* connect initiate */
-#define MFS_CC 040 /* connect confirm */
-#define MFS_DI 060 /* disconnect initiate */
-#define MFS_DC 0100 /* disconnect confirm */
-#define MFS_RCI 0140 /* retransmitted connect initiate */
-
-#define SGQ_ACK 0100000 /* ack */
-#define SGQ_NAK 0110000 /* negative ack */
-#define SGQ_OACK 0120000 /* other channel ack */
-#define SGQ_ONAK 0130000 /* other channel negative ack */
-#define SGQ_MASK 07777 /* mask to isolate seq # */
-#define SGQ_OTHER 020000 /* other channel qualifier */
-#define SGQ_DELAY 010000 /* ack delay flag */
-
-#define SGQ_EOM 0100000 /* pseudo flag for end-of-message */
-
-#define LSM_MASK 03 /* mask for modifier field */
-#define LSM_NOCHANGE 0 /* no change */
-#define LSM_DONOTSEND 1 /* do not send data */
-#define LSM_SEND 2 /* send data */
-
-#define LSI_MASK 014 /* mask for interpretation field */
-#define LSI_DATA 0 /* data segment or message count */
-#define LSI_INTR 4 /* interrupt request count */
-#define LSI_INTM 0377 /* funny marker for int. message */
-
-#define COS_MASK 014 /* mask for flow control field */
-#define COS_NONE 0 /* no flow control */
-#define COS_SEGMENT 04 /* segment flow control */
-#define COS_MESSAGE 010 /* message flow control */
-#define COS_CRYPTSER 020 /* cryptographic services requested */
-#define COS_DEFAULT 1 /* default value for field */
-
-#define COI_MASK 3 /* mask for version field */
-#define COI_32 0 /* version 3.2 */
-#define COI_31 1 /* version 3.1 */
-#define COI_40 2 /* version 4.0 */
-#define COI_41 3 /* version 4.1 */
-
-#define MNU_MASK 140 /* mask for session control version */
-#define MNU_10 000 /* session V1.0 */
-#define MNU_20 040 /* session V2.0 */
-#define MNU_ACCESS 1 /* access control present */
-#define MNU_USRDATA 2 /* user data field present */
-#define MNU_INVKPROXY 4 /* invoke proxy field present */
-#define MNU_UICPROXY 8 /* use uic-based proxy */
-
-#define DC_NORESOURCES 1 /* no resource reason code */
-#define DC_NOLINK 41 /* no link terminate reason code */
-#define DC_COMPLETE 42 /* disconnect complete reason code */
-
-#define DI_NOERROR 0 /* user disconnect */
-#define DI_SHUT 3 /* node is shutting down */
-#define DI_NOUSER 4 /* destination end user does not exist */
-#define DI_INVDEST 5 /* invalid end user destination */
-#define DI_REMRESRC 6 /* insufficient remote resources */
-#define DI_TPA 8 /* third party abort */
-#define DI_PROTOCOL 7 /* protocol error discovered */
-#define DI_ABORT 9 /* user abort */
-#define DI_LOCALRESRC 32 /* insufficient local resources */
-#define DI_REMUSERRESRC 33 /* insufficient remote user resources */
-#define DI_BADACCESS 34 /* bad access control information */
-#define DI_BADACCNT 36 /* bad ACCOUNT information */
-#define DI_CONNECTABORT 38 /* connect request cancelled */
-#define DI_TIMEDOUT 38 /* remote node or user crashed */
-#define DI_UNREACHABLE 39 /* local timers expired due to ... */
-#define DI_BADIMAGE 43 /* bad image data in connect */
-#define DI_SERVMISMATCH 54 /* cryptographic service mismatch */
-
-#define UC_OBJREJECT 0 /* object rejected connect */
-#define UC_USERDISCONNECT 0 /* user disconnect */
-#define UC_RESOURCES 1 /* insufficient resources (local or remote) */
-#define UC_NOSUCHNODE 2 /* unrecognized node name */
-#define UC_REMOTESHUT 3 /* remote node shutting down */
-#define UC_NOSUCHOBJ 4 /* unrecognized object */
-#define UC_INVOBJFORMAT 5 /* invalid object name format */
-#define UC_OBJTOOBUSY 6 /* object too busy */
-#define UC_NETWORKABORT 8 /* network abort */
-#define UC_USERABORT 9 /* user abort */
-#define UC_INVNODEFORMAT 10 /* invalid node name format */
-#define UC_LOCALSHUT 11 /* local node shutting down */
-#define UC_ACCESSREJECT 34 /* invalid access control information */
-#define UC_NORESPONSE 38 /* no response from object */
-#define UC_UNREACHABLE 39 /* node unreachable */
-
-/*
- * NSP message formats.
- */
-struct nsphdr /* general nsp header */
- {
- byte nh_flags; /* message flags */
- word nh_dst; /* destination link address */
- word nh_src; /* source link address */
- };
-
-struct seghdr /* data segment header */
- {
- byte sh_flags; /* message flags */
- word sh_dst; /* destination link address */
- word sh_src; /* source link address */
- word sh_seq[3]; /* sequence numbers */
- };
-
-struct minseghdr /* minimum data segment header */
- {
- byte ms_flags; /* message flags */
- word ms_dst; /* destination link address */
- word ms_src; /* source link address */
- word ms_seq; /* sequence number */
- };
-
-struct lsmsg /* link service message (after hdr) */
- {
- byte ls_lsflags; /* link service flags */
- byte ls_fcval; /* flow control value */
- };
-
-struct ackmsg /* acknowledgement message */
- {
- byte ak_flags; /* message flags */
- word ak_dst; /* destination link address */
- word ak_src; /* source link address */
- word ak_acknum[2]; /* acknowledgement numbers */
- };
-
-struct minackmsg /* minimum acknowledgement message */
- {
- byte mk_flags; /* message flags */
- word mk_dst; /* destination link address */
- word mk_src; /* source link address */
- word mk_acknum; /* acknowledgement number */
- };
-
-struct ciackmsg /* connect acknowledgement message */
- {
- byte ck_flags; /* message flags */
- word ck_dst; /* destination link address */
- };
-
-struct cimsg /* connect initiate message */
- {
- byte ci_flags; /* message flags */
- word ci_dst; /* destination link address (0) */
- word ci_src; /* source link address */
- byte ci_services; /* requested services */
- byte ci_info; /* information */
- word ci_segsize; /* maximum segment size */
- };
-
-struct ccmsg /* connect confirm message */
- {
- byte cc_flags; /* message flags */
- word cc_dst; /* destination link address */
- word cc_src; /* source link address */
- byte cc_services; /* requested services */
- byte cc_info; /* information */
- word cc_segsize; /* maximum segment size */
- byte cc_optlen; /* optional data length */
- };
-
-struct cnmsg /* generic connect message */
- {
- byte cn_flags; /* message flags */
- word cn_dst; /* destination link address */
- word cn_src; /* source link address */
- byte cn_services; /* requested services */
- byte cn_info; /* information */
- word cn_segsize; /* maximum segment size */
- };
-
-struct dimsg /* disconnect initiate message */
- {
- byte di_flags; /* message flags */
- word di_dst; /* destination link address */
- word di_src; /* source link address */
- word di_reason; /* reason code */
- byte di_optlen; /* optional data length */
- };
-
-struct dcmsg /* disconnect confirm message */
- {
- byte dc_flags; /* message flags */
- word dc_dst; /* destination link address */
- word dc_src; /* source link address */
- word dc_reason; /* reason code */
- };
diff --git a/contrib/tcpdump/decode_prefix.h b/contrib/tcpdump/decode_prefix.h
deleted file mode 100644
index 8bb4a76750a5..000000000000
--- a/contrib/tcpdump/decode_prefix.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 1999 WIDE Project.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * Extensively modified by Hannes Gredler (hannes@juniper.net) for more
- * complete BGP support.
- */
-
-#ifndef tcpdump_decode_prefix_h
-#define tcpdump_decode_prefix_h
-
-extern int decode_prefix4(const u_char *pptr, u_int itemlen, char *buf, u_int buflen);
-#ifdef INET6
-extern int decode_prefix6(const u_char *pd, u_int itemlen, char *buf, u_int buflen);
-#endif
-
-#endif
diff --git a/contrib/tcpdump/enc.h b/contrib/tcpdump/enc.h
deleted file mode 100644
index 2d57e2b8df16..000000000000
--- a/contrib/tcpdump/enc.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/enc.h,v 1.1 2003-03-08 08:55:33 guy Exp $ (LBL) */
-/* From $OpenBSD: if_enc.h,v 1.8 2001/06/25 05:14:00 angelos Exp $ */
-/*
- * The authors of this code are John Ioannidis (ji@tla.org),
- * Angelos D. Keromytis (kermit@csd.uch.gr) and
- * Niels Provos (provos@physnet.uni-hamburg.de).
- *
- * This code was written by John Ioannidis for BSD/OS in Athens, Greece,
- * in November 1995.
- *
- * Ported to OpenBSD and NetBSD, with additional transforms, in December 1996,
- * by Angelos D. Keromytis.
- *
- * Additional transforms and features in 1997 and 1998 by Angelos D. Keromytis
- * and Niels Provos.
- *
- * Copyright (C) 1995, 1996, 1997, 1998 by John Ioannidis, Angelos D. Keromytis
- * and Niels Provos.
- * Copyright (c) 2001, Angelos D. Keromytis.
- *
- * Permission to use, copy, and modify this software with or without fee
- * is hereby granted, provided that this entire notice is included in
- * all copies of any software which is or includes a copy or
- * modification of this software.
- * You may use this code under the GNU public license if you so wish. Please
- * contribute changes back to the authors under this freer than GPL license
- * so that we may further the use of strong encryption without limitations to
- * all.
- *
- * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY
- * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
- * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
- * PURPOSE.
- */
-
-#define ENC_HDRLEN 12
-
-/* From $OpenBSD: mbuf.h,v 1.56 2002/01/25 15:50:23 art Exp $ */
-#define M_CONF 0x0400 /* packet was encrypted (ESP-transport) */
-#define M_AUTH 0x0800 /* packet was authenticated (AH) */
-
-struct enchdr {
- u_int32_t af;
- u_int32_t spi;
- u_int32_t flags;
-};
diff --git a/contrib/tcpdump/esp.h b/contrib/tcpdump/esp.h
deleted file mode 100644
index 56cdada01e2d..000000000000
--- a/contrib/tcpdump/esp.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* $NetBSD: esp.h,v 1.13 2000/09/26 08:37:38 itojun Exp $ */
-/* $KAME: esp.h,v 1.15 2000/09/20 18:15:22 itojun Exp $ */
-
-/*
- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * RFC1827/2406 Encapsulated Security Payload.
- */
-
-#ifndef _NETINET6_ESP_H_
-#define _NETINET6_ESP_H_
-
-struct esp {
- u_int32_t esp_spi; /* ESP */
- /*variable size, 32bit bound*/ /* Initialization Vector */
- /*variable size*/ /* Payload data */
- /*variable size*/ /* padding */
- /*8bit*/ /* pad size */
- /*8bit*/ /* next header */
- /*8bit*/ /* next header */
- /*variable size, 32bit bound*/ /* Authentication data (new IPsec) */
-};
-
-struct newesp {
- u_int32_t esp_spi; /* ESP */
- u_int32_t esp_seq; /* Sequence number */
- /*variable size*/ /* (IV and) Payload data */
- /*variable size*/ /* padding */
- /*8bit*/ /* pad size */
- /*8bit*/ /* next header */
- /*8bit*/ /* next header */
- /*variable size, 32bit bound*/ /* Authentication data */
-};
-
-struct esptail {
- u_int8_t esp_padlen; /* pad length */
- u_int8_t esp_nxt; /* Next header */
- /*variable size, 32bit bound*/ /* Authentication data (new IPsec)*/
-};
-
-#endif /*_NETINET6_ESP_H_*/
diff --git a/contrib/tcpdump/ether.h b/contrib/tcpdump/ether.h
index e8b3a7138dd5..58b92de52a03 100644
--- a/contrib/tcpdump/ether.h
+++ b/contrib/tcpdump/ether.h
@@ -1,4 +1,3 @@
-/* @(#) $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.
@@ -45,9 +44,9 @@
* Structure of a DEC/Intel/Xerox or 802.3 Ethernet header.
*/
struct ether_header {
- u_int8_t ether_dhost[ETHER_ADDR_LEN];
- u_int8_t ether_shost[ETHER_ADDR_LEN];
- u_int16_t ether_type;
+ uint8_t ether_dhost[ETHER_ADDR_LEN];
+ uint8_t ether_shost[ETHER_ADDR_LEN];
+ uint16_t ether_type;
};
/*
diff --git a/contrib/tcpdump/ethertype.h b/contrib/tcpdump/ethertype.h
index 2c79ba286c88..e855221ea095 100644
--- a/contrib/tcpdump/ethertype.h
+++ b/contrib/tcpdump/ethertype.h
@@ -17,8 +17,6 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/ethertype.h,v 1.30 2008-02-06 10:47:53 guy Exp $ (LBL)
* $FreeBSD$
*/
@@ -169,11 +167,14 @@
#ifndef ETHERTYPE_RRCP
#define ETHERTYPE_RRCP 0x8899
#endif
+#ifndef ETHERTYPE_AOE
+#define ETHERTYPE_AOE 0x88a2
+#endif
#ifndef ETHERTYPE_LOOPBACK
#define ETHERTYPE_LOOPBACK 0x9000
#endif
#ifndef ETHERTYPE_VMAN
-#define ETHERTYPE_VMAN 0x9100 /* Extreme VMAN Protocol */
+#define ETHERTYPE_VMAN 0x9100 /* Extreme VMAN Protocol */
#endif
#ifndef ETHERTYPE_CFM_OLD
#define ETHERTYPE_CFM_OLD 0xabcd /* 802.1ag depreciated */
@@ -181,8 +182,20 @@
#ifndef ETHERTYPE_CFM
#define ETHERTYPE_CFM 0x8902 /* 802.1ag */
#endif
+#ifndef ETHERTYPE_IEEE1905_1
+#define ETHERTYPE_IEEE1905_1 0x893a /* IEEE 1905.1 */
+#endif
#ifndef ETHERTYPE_ISO
#define ETHERTYPE_ISO 0xfefe /* nonstandard - used in Cisco HDLC encapsulation */
#endif
+#ifndef ETHERTYPE_CALM_FAST
+#define ETHERTYPE_CALM_FAST 0x1111 /* ISO CALM FAST */
+#endif
+#ifndef ETHERTYPE_GEONET_OLD
+#define ETHERTYPE_GEONET_OLD 0x0707 /* ETSI GeoNetworking (before Jan 2013) */
+#endif
+#ifndef ETHERTYPE_GEONET
+#define ETHERTYPE_GEONET 0x8947 /* ETSI GeoNetworking (Official IEEE registration from Jan 2013) */
+#endif
extern const struct tok ethertype_values[];
diff --git a/contrib/tcpdump/extract.h b/contrib/tcpdump/extract.h
index 60ecd680363a..d2174ba2c542 100644
--- a/contrib/tcpdump/extract.h
+++ b/contrib/tcpdump/extract.h
@@ -17,8 +17,6 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/extract.h,v 1.25 2006-01-30 16:20:07 hannes Exp $ (LBL)
*/
/*
@@ -28,104 +26,168 @@
/*
* The processor doesn't natively handle unaligned loads.
*/
-#ifdef HAVE___ATTRIBUTE__
+#if defined(__GNUC__) && defined(HAVE___ATTRIBUTE__) && \
+ (defined(__alpha) || defined(__alpha__) || \
+ defined(__mips) || defined(__mips__))
+
/*
- * We have __attribute__; we assume that means we have __attribute__((packed)).
- * Declare packed structures containing a u_int16_t and a u_int32_t,
+ * This is a GCC-compatible compiler and we have __attribute__, which
+ * we assume that mean we have __attribute__((packed)), and this is
+ * MIPS or Alpha, which has instructions that can help when doing
+ * unaligned loads.
+ *
+ * Declare packed structures containing a uint16_t and a uint32_t,
* cast the pointer to point to one of those, and fetch through it;
* the GCC manual doesn't appear to explicitly say that
* __attribute__((packed)) causes the compiler to generate unaligned-safe
* code, but it apppears to do so.
*
- * We do this in case the compiler can generate, for this instruction set,
- * better code to do an unaligned load and pass stuff to "ntohs()" or
- * "ntohl()" than the code to fetch the bytes one at a time and
- * assemble them. (That might not be the case on a little-endian platform,
- * where "ntohs()" and "ntohl()" might not be done inline.)
+ * We do this in case the compiler can generate code using those
+ * instructions to do an unaligned load and pass stuff to "ntohs()" or
+ * "ntohl()", which might be better than than the code to fetch the
+ * bytes one at a time and assemble them. (That might not be the
+ * case on a little-endian platform, such as DEC's MIPS machines and
+ * Alpha machines, where "ntohs()" and "ntohl()" might not be done
+ * inline.)
+ *
+ * We do this only for specific architectures because, for example,
+ * at least some versions of GCC, when compiling for 64-bit SPARC,
+ * generate code that assumes alignment if we do this.
+ *
+ * XXX - add other architectures and compilers as possible and
+ * appropriate.
+ *
+ * HP's C compiler, indicated by __HP_cc being defined, supports
+ * "#pragma unaligned N" in version A.05.50 and later, where "N"
+ * specifies a number of bytes at which the typedef on the next
+ * line is aligned, e.g.
+ *
+ * #pragma unalign 1
+ * typedef uint16_t unaligned_uint16_t;
+ *
+ * to define unaligned_uint16_t as a 16-bit unaligned data type.
+ * This could be presumably used, in sufficiently recent versions of
+ * the compiler, with macros similar to those below. This would be
+ * useful only if that compiler could generate better code for PA-RISC
+ * or Itanium than would be generated by a bunch of shifts-and-ORs.
+ *
+ * DEC C, indicated by __DECC being defined, has, at least on Alpha,
+ * an __unaligned qualifier that can be applied to pointers to get the
+ * compiler to generate code that does unaligned loads and stores when
+ * dereferencing the pointer in question.
+ *
+ * XXX - what if the native C compiler doesn't support
+ * __attribute__((packed))? How can we get it to generate unaligned
+ * accesses for *specific* items?
*/
typedef struct {
- u_int16_t val;
-} __attribute__((packed)) unaligned_u_int16_t;
+ uint16_t val;
+} __attribute__((packed)) unaligned_uint16_t;
typedef struct {
- u_int32_t val;
-} __attribute__((packed)) unaligned_u_int32_t;
+ uint32_t val;
+} __attribute__((packed)) unaligned_uint32_t;
-static inline u_int16_t
+static inline uint16_t
EXTRACT_16BITS(const void *p)
{
- return ((u_int16_t)ntohs(((const unaligned_u_int16_t *)(p))->val));
+ return ((uint16_t)ntohs(((const unaligned_uint16_t *)(p))->val));
}
-static inline u_int32_t
+static inline uint32_t
EXTRACT_32BITS(const void *p)
{
- return ((u_int32_t)ntohl(((const unaligned_u_int32_t *)(p))->val));
+ return ((uint32_t)ntohl(((const unaligned_uint32_t *)(p))->val));
}
-static inline u_int64_t
+static inline uint64_t
EXTRACT_64BITS(const void *p)
{
- return ((u_int64_t)(((u_int64_t)ntohl(((const unaligned_u_int32_t *)(p) + 0)->val)) << 32 | \
- ((u_int64_t)ntohl(((const unaligned_u_int32_t *)(p) + 1)->val)) << 0));
-
+ return ((uint64_t)(((uint64_t)ntohl(((const unaligned_uint32_t *)(p) + 0)->val)) << 32 | \
+ ((uint64_t)ntohl(((const unaligned_uint32_t *)(p) + 1)->val)) << 0));
}
-#else /* HAVE___ATTRIBUTE__ */
+#else /* have to do it a byte at a time */
/*
- * We don't have __attribute__, so do unaligned loads of big-endian
+ * This isn't a GCC-compatible compiler, we don't have __attribute__,
+ * or we do but we don't know of any better way with this instruction
+ * set to do unaligned loads, so do unaligned loads of big-endian
* quantities the hard way - fetch the bytes one at a time and
* assemble them.
*/
#define EXTRACT_16BITS(p) \
- ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \
- (u_int16_t)*((const u_int8_t *)(p) + 1)))
+ ((uint16_t)((uint16_t)*((const uint8_t *)(p) + 0) << 8 | \
+ (uint16_t)*((const uint8_t *)(p) + 1)))
#define EXTRACT_32BITS(p) \
- ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \
- (u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \
- (u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \
- (u_int32_t)*((const u_int8_t *)(p) + 3)))
+ ((uint32_t)((uint32_t)*((const uint8_t *)(p) + 0) << 24 | \
+ (uint32_t)*((const uint8_t *)(p) + 1) << 16 | \
+ (uint32_t)*((const uint8_t *)(p) + 2) << 8 | \
+ (uint32_t)*((const uint8_t *)(p) + 3)))
#define EXTRACT_64BITS(p) \
- ((u_int64_t)((u_int64_t)*((const u_int8_t *)(p) + 0) << 56 | \
- (u_int64_t)*((const u_int8_t *)(p) + 1) << 48 | \
- (u_int64_t)*((const u_int8_t *)(p) + 2) << 40 | \
- (u_int64_t)*((const u_int8_t *)(p) + 3) << 32 | \
- (u_int64_t)*((const u_int8_t *)(p) + 4) << 24 | \
- (u_int64_t)*((const u_int8_t *)(p) + 5) << 16 | \
- (u_int64_t)*((const u_int8_t *)(p) + 6) << 8 | \
- (u_int64_t)*((const u_int8_t *)(p) + 7)))
-#endif /* HAVE___ATTRIBUTE__ */
+ ((uint64_t)((uint64_t)*((const uint8_t *)(p) + 0) << 56 | \
+ (uint64_t)*((const uint8_t *)(p) + 1) << 48 | \
+ (uint64_t)*((const uint8_t *)(p) + 2) << 40 | \
+ (uint64_t)*((const uint8_t *)(p) + 3) << 32 | \
+ (uint64_t)*((const uint8_t *)(p) + 4) << 24 | \
+ (uint64_t)*((const uint8_t *)(p) + 5) << 16 | \
+ (uint64_t)*((const uint8_t *)(p) + 6) << 8 | \
+ (uint64_t)*((const uint8_t *)(p) + 7)))
+#endif /* must special-case unaligned accesses */
#else /* LBL_ALIGN */
/*
* The processor natively handles unaligned loads, so we can just
* cast the pointer and fetch through it.
*/
-static inline u_int16_t
+static inline uint16_t
EXTRACT_16BITS(const void *p)
{
- return ((u_int16_t)ntohs(*(const u_int16_t *)(p)));
+ return ((uint16_t)ntohs(*(const uint16_t *)(p)));
}
-static inline u_int32_t
+static inline uint32_t
EXTRACT_32BITS(const void *p)
{
- return ((u_int32_t)ntohl(*(const u_int32_t *)(p)));
+ return ((uint32_t)ntohl(*(const uint32_t *)(p)));
}
-static inline u_int64_t
+static inline uint64_t
EXTRACT_64BITS(const void *p)
{
- return ((u_int64_t)(((u_int64_t)ntohl(*((const u_int32_t *)(p) + 0))) << 32 | \
- ((u_int64_t)ntohl(*((const u_int32_t *)(p) + 1))) << 0));
+ return ((uint64_t)(((uint64_t)ntohl(*((const uint32_t *)(p) + 0))) << 32 | \
+ ((uint64_t)ntohl(*((const uint32_t *)(p) + 1))) << 0));
}
#endif /* LBL_ALIGN */
#define EXTRACT_24BITS(p) \
- ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \
- (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \
- (u_int32_t)*((const u_int8_t *)(p) + 2)))
+ ((uint32_t)((uint32_t)*((const uint8_t *)(p) + 0) << 16 | \
+ (uint32_t)*((const uint8_t *)(p) + 1) << 8 | \
+ (uint32_t)*((const uint8_t *)(p) + 2)))
+
+#define EXTRACT_40BITS(p) \
+ ((uint64_t)((uint64_t)*((const uint8_t *)(p) + 0) << 32 | \
+ (uint64_t)*((const uint8_t *)(p) + 1) << 24 | \
+ (uint64_t)*((const uint8_t *)(p) + 2) << 16 | \
+ (uint64_t)*((const uint8_t *)(p) + 3) << 8 | \
+ (uint64_t)*((const uint8_t *)(p) + 4)))
+
+#define EXTRACT_48BITS(p) \
+ ((uint64_t)((uint64_t)*((const uint8_t *)(p) + 0) << 40 | \
+ (uint64_t)*((const uint8_t *)(p) + 1) << 32 | \
+ (uint64_t)*((const uint8_t *)(p) + 2) << 24 | \
+ (uint64_t)*((const uint8_t *)(p) + 3) << 16 | \
+ (uint64_t)*((const uint8_t *)(p) + 4) << 8 | \
+ (uint64_t)*((const uint8_t *)(p) + 5)))
+
+#define EXTRACT_56BITS(p) \
+ ((uint64_t)((uint64_t)*((const uint8_t *)(p) + 0) << 48 | \
+ (uint64_t)*((const uint8_t *)(p) + 1) << 40 | \
+ (uint64_t)*((const uint8_t *)(p) + 2) << 32 | \
+ (uint64_t)*((const uint8_t *)(p) + 3) << 24 | \
+ (uint64_t)*((const uint8_t *)(p) + 4) << 16 | \
+ (uint64_t)*((const uint8_t *)(p) + 5) << 8 | \
+ (uint64_t)*((const uint8_t *)(p) + 6)))
/*
* Macros to extract possibly-unaligned little-endian integral values.
@@ -133,23 +195,23 @@ EXTRACT_64BITS(const void *p)
*/
#define EXTRACT_LE_8BITS(p) (*(p))
#define EXTRACT_LE_16BITS(p) \
- ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 1) << 8 | \
- (u_int16_t)*((const u_int8_t *)(p) + 0)))
+ ((uint16_t)((uint16_t)*((const uint8_t *)(p) + 1) << 8 | \
+ (uint16_t)*((const uint8_t *)(p) + 0)))
#define EXTRACT_LE_32BITS(p) \
- ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 3) << 24 | \
- (u_int32_t)*((const u_int8_t *)(p) + 2) << 16 | \
- (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \
- (u_int32_t)*((const u_int8_t *)(p) + 0)))
+ ((uint32_t)((uint32_t)*((const uint8_t *)(p) + 3) << 24 | \
+ (uint32_t)*((const uint8_t *)(p) + 2) << 16 | \
+ (uint32_t)*((const uint8_t *)(p) + 1) << 8 | \
+ (uint32_t)*((const uint8_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)))
+ ((uint32_t)((uint32_t)*((const uint8_t *)(p) + 2) << 16 | \
+ (uint32_t)*((const uint8_t *)(p) + 1) << 8 | \
+ (uint32_t)*((const uint8_t *)(p) + 0)))
#define EXTRACT_LE_64BITS(p) \
- ((u_int64_t)((u_int64_t)*((const u_int8_t *)(p) + 7) << 56 | \
- (u_int64_t)*((const u_int8_t *)(p) + 6) << 48 | \
- (u_int64_t)*((const u_int8_t *)(p) + 5) << 40 | \
- (u_int64_t)*((const u_int8_t *)(p) + 4) << 32 | \
- (u_int64_t)*((const u_int8_t *)(p) + 3) << 24 | \
- (u_int64_t)*((const u_int8_t *)(p) + 2) << 16 | \
- (u_int64_t)*((const u_int8_t *)(p) + 1) << 8 | \
- (u_int64_t)*((const u_int8_t *)(p) + 0)))
+ ((uint64_t)((uint64_t)*((const uint8_t *)(p) + 7) << 56 | \
+ (uint64_t)*((const uint8_t *)(p) + 6) << 48 | \
+ (uint64_t)*((const uint8_t *)(p) + 5) << 40 | \
+ (uint64_t)*((const uint8_t *)(p) + 4) << 32 | \
+ (uint64_t)*((const uint8_t *)(p) + 3) << 24 | \
+ (uint64_t)*((const uint8_t *)(p) + 2) << 16 | \
+ (uint64_t)*((const uint8_t *)(p) + 1) << 8 | \
+ (uint64_t)*((const uint8_t *)(p) + 0)))
diff --git a/contrib/tcpdump/fddi.h b/contrib/tcpdump/fddi.h
deleted file mode 100644
index df38c8e9a870..000000000000
--- a/contrib/tcpdump/fddi.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 1992, 1993, 1994, 1995, 1996
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that: (1) source code distributions
- * retain the above copyright notice and this paragraph in its entirety, (2)
- * distributions including binary code include the above copyright notice and
- * this paragraph in its entirety in the documentation or other materials
- * provided with the distribution, and (3) all advertising materials mentioning
- * features or use of this software display the following acknowledgement:
- * ``This product includes software developed by the University of California,
- * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
- * the University nor the names of its contributors may be used to endorse
- * or promote products derived from this software without specific prior
- * written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/fddi.h,v 1.11 2002-12-11 07:13:51 guy Exp $ (LBL)
- */
-
-/*
- * Based on Ultrix if_fddi.h
- */
-
-/*
- * This stuff should come from a system header file, but there's no
- * obviously portable way to do that and it's not really going
- * to change from system to system (except for the padding business).
- */
-
-struct fddi_header {
- u_char fddi_fc; /* frame control */
- u_char fddi_dhost[6];
- u_char fddi_shost[6];
-};
-
-/*
- * Length of an FDDI header; note that some compilers may pad
- * "struct fddi_header" to a multiple of 4 bytes, for example, so
- * "sizeof (struct fddi_header)" may not give the right
- * answer.
- */
-#define FDDI_HDRLEN 13
-
-/* Useful values for fddi_fc (frame control) field */
-
-/*
- * FDDI Frame Control bits
- */
-#define FDDIFC_C 0x80 /* Class bit */
-#define FDDIFC_L 0x40 /* Address length bit */
-#define FDDIFC_F 0x30 /* Frame format bits */
-#define FDDIFC_Z 0x0f /* Control bits */
-
-/*
- * FDDI Frame Control values. (48-bit addressing only).
- */
-#define FDDIFC_VOID 0x40 /* Void frame */
-#define FDDIFC_NRT 0x80 /* Nonrestricted token */
-#define FDDIFC_RT 0xc0 /* Restricted token */
-#define FDDIFC_SMT_INFO 0x41 /* SMT Info */
-#define FDDIFC_SMT_NSA 0x4F /* SMT Next station adrs */
-#define FDDIFC_MAC_BEACON 0xc2 /* MAC Beacon frame */
-#define FDDIFC_MAC_CLAIM 0xc3 /* MAC Claim frame */
-#define FDDIFC_LLC_ASYNC 0x50 /* Async. LLC frame */
-#define FDDIFC_LLC_SYNC 0xd0 /* Sync. LLC frame */
-#define FDDIFC_IMP_ASYNC 0x60 /* Implementor Async. */
-#define FDDIFC_IMP_SYNC 0xe0 /* Implementor Synch. */
-#define FDDIFC_SMT 0x40 /* SMT frame */
-#define FDDIFC_MAC 0xc0 /* MAC frame */
-
-#define FDDIFC_CLFF 0xF0 /* Class/Length/Format bits */
-#define FDDIFC_ZZZZ 0x0F /* Control bits */
diff --git a/contrib/tcpdump/forces.h b/contrib/tcpdump/forces.h
deleted file mode 100644
index d41475f908ae..000000000000
--- a/contrib/tcpdump/forces.h
+++ /dev/null
@@ -1,679 +0,0 @@
-/*
- * Copyright (c) 1982, 1986, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * Copyright (c) 2009 Mojatatu Networks, Inc
- *
- */
-
-/*
- * Per draft-ietf-forces-protocol-22
-*/
-#define ForCES_VERS 1
-#define ForCES_HDRL 24
-#define ForCES_ALNL 4U
-#define TLV_HDRL 4
-#define ILV_HDRL 8
-
-#define TOM_RSVD 0x0
-#define TOM_ASSNSETUP 0x1
-#define TOM_ASSNTEARD 0x2
-#define TOM_CONFIG 0x3
-#define TOM_QUERY 0x4
-#define TOM_EVENTNOT 0x5
-#define TOM_PKTREDIR 0x6
-#define TOM_HEARTBT 0x0F
-#define TOM_ASSNSETREP 0x11
-#define TOM_CONFIGREP 0x13
-#define TOM_QUERYREP 0x14
-
-/*
- * tom_h Flags: resv1(8b):maxtlvs(4b):resv2(2b):mintlv(2b)
-*/
-#define ZERO_TTLV 0x01
-#define ZERO_MORE_TTLV 0x02
-#define ONE_MORE_TTLV 0x04
-#define ZERO_TLV 0x00
-#define ONE_TLV 0x10
-#define TWO_TLV 0x20
-#define MAX_TLV 0xF0
-
-#define TTLV_T1 (ONE_MORE_TTLV|ONE_TLV)
-#define TTLV_T2 (ONE_MORE_TTLV|MAX_TLV)
-
-struct tom_h {
- u_int32_t v;
- u_int16_t flags;
- u_int16_t op_msk;
- const char *s;
- int (*print) (register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-};
-
-enum {
- TOM_RSV_I,
- TOM_ASS_I,
- TOM_AST_I,
- TOM_CFG_I,
- TOM_QRY_I,
- TOM_EVN_I,
- TOM_RED_I,
- TOM_HBT_I,
- TOM_ASR_I,
- TOM_CNR_I,
- TOM_QRR_I,
- _TOM_RSV_MAX
-};
-#define TOM_MAX_IND (_TOM_RSV_MAX - 1)
-
-int lfbselect_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-int redirect_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-int asrtlv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-int asttlv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-int gentltlv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-int print_metailv(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-int print_metatlv(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-int print_reddata(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-
-static inline int tom_valid(u_int8_t tom)
-{
- if (tom > 0) {
- if (tom >= 0x7 && tom <= 0xe)
- return 0;
- if (tom == 0x10)
- return 0;
- if (tom > 0x14)
- return 0;
- return 1;
- } else
- return 0;
-}
-
-static inline const char *ForCES_node(u_int32_t node)
-{
- if (node <= 0x3FFFFFFF)
- return "FE";
- if (node >= 0x40000000 && node <= 0x7FFFFFFF)
- return "CE";
- if (node >= 0xC0000000 && node <= 0xFFFFFFEF)
- return "AllMulticast";
- if (node == 0xFFFFFFFD)
- return "AllCEsBroadcast";
- if (node == 0xFFFFFFFE)
- return "AllFEsBroadcast";
- if (node == 0xFFFFFFFF)
- return "AllBroadcast";
-
- return "ForCESreserved";
-
-}
-
-static inline const char *ForCES_ACKp(u_int32_t flg)
-{
- if (flg == 0x0)
- return "NoACK";
- if (flg == 0x1)
- return "SuccessACK";
- if (flg == 0x2)
- return "FailureACK";
- if (flg == 0x3)
- return "AlwaysACK";
- return "ACKUnknown";
-}
-
-static inline const char *ForCES_EMp(u_int32_t flg)
-{
- if (flg == 0x0)
- return "EMReserved";
- if (flg == 0x1)
- return "execute-all-or-none";
- if (flg == 0x2)
- return "execute-until-failure";
- if (flg == 0x3)
- return "continue-execute-on-failure";
- return "EMUnknown";
-}
-
-static inline const char *ForCES_ATp(u_int32_t flg)
-{
- if (flg == 0x0)
- return "Standalone";
- if (flg == 0x1)
- return "2PCtransaction";
- return "ATUnknown";
-}
-
-static inline const char *ForCES_TPp(u_int32_t flg)
-{
- if (flg == 0x0)
- return "StartofTransaction";
- if (flg == 0x1)
- return "MiddleofTransaction";
- if (flg == 0x2)
- return "EndofTransaction";
- if (flg == 0x3)
- return "abort";
- return "TPUnknown";
-}
-
-/*
- * Structure of forces header, naked of TLVs.
- */
-struct forcesh {
- u_int8_t fm_vrsvd; /* version and reserved */
-#define ForCES_V(forcesh) ((forcesh)->fm_vrsvd >> 4)
- u_int8_t fm_tom; /* type of message */
- u_int16_t fm_len; /* total length * 4 bytes */
-#define ForCES_BLN(forcesh) ((u_int32_t)(EXTRACT_16BITS(&(forcesh)->fm_len) << 2))
- u_int32_t fm_sid; /* Source ID */
-#define ForCES_SID(forcesh) EXTRACT_32BITS(&(forcesh)->fm_sid)
- u_int32_t fm_did; /* Destination ID */
-#define ForCES_DID(forcesh) EXTRACT_32BITS(&(forcesh)->fm_did)
- u_int8_t fm_cor[8]; /* correlator */
- u_int32_t fm_flags; /* flags */
-#define ForCES_ACK(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0xC0000000) >> 30)
-#define ForCES_PRI(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x38000000) >> 27)
-#define ForCES_RS1(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x07000000) >> 24)
-#define ForCES_EM(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x00C00000) >> 22)
-#define ForCES_AT(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x00200000) >> 21)
-#define ForCES_TP(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x00180000) >> 19)
-#define ForCES_RS2(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x0007FFFF) >> 0)
-};
-
-#define ForCES_HLN_VALID(fhl,tlen) ((tlen) >= ForCES_HDRL && \
- (fhl) >= ForCES_HDRL && \
- (fhl) == (tlen))
-
-#define F_LFB_RSVD 0x0
-#define F_LFB_FEO 0x1
-#define F_LFB_FEPO 0x2
-const struct tok ForCES_LFBs[] = {
- {F_LFB_RSVD, "Invalid TLV"},
- {F_LFB_FEO, "FEObj LFB"},
- {F_LFB_FEPO, "FEProtoObj LFB"},
- {0, NULL}
-};
-
-int forces_type_print(register const u_char * pptr, const struct forcesh *fhdr,
- register u_int mlen, const struct tom_h *tops);
-
-enum {
- F_OP_RSV,
- F_OP_SET,
- F_OP_SETPROP,
- F_OP_SETRESP,
- F_OP_SETPRESP,
- F_OP_DEL,
- F_OP_DELRESP,
- F_OP_GET,
- F_OP_GETPROP,
- F_OP_GETRESP,
- F_OP_GETPRESP,
- F_OP_REPORT,
- F_OP_COMMIT,
- F_OP_RCOMMIT,
- F_OP_RTRCOMP,
- _F_OP_MAX
-};
-
-#define F_OP_MAX (_F_OP_MAX - 1)
-enum {
- B_OP_SET = 1 << (F_OP_SET - 1),
- B_OP_SETPROP = 1 << (F_OP_SETPROP - 1),
- B_OP_SETRESP = 1 << (F_OP_SETRESP - 1),
- B_OP_SETPRESP = 1 << (F_OP_SETPRESP - 1),
- B_OP_DEL = 1 << (F_OP_DEL - 1),
- B_OP_DELRESP = 1 << (F_OP_DELRESP - 1),
- B_OP_GET = 1 << (F_OP_GET - 1),
- B_OP_GETPROP = 1 << (F_OP_GETPROP - 1),
- B_OP_GETRESP = 1 << (F_OP_GETRESP - 1),
- B_OP_GETPRESP = 1 << (F_OP_GETPRESP - 1),
- B_OP_REPORT = 1 << (F_OP_REPORT - 1),
- B_OP_COMMIT = 1 << (F_OP_COMMIT - 1),
- B_OP_RCOMMIT = 1 << (F_OP_RCOMMIT - 1),
- B_OP_RTRCOMP = 1 << (F_OP_RTRCOMP - 1),
-};
-
-struct optlv_h {
- u_int16_t flags;
- u_int16_t op_msk;
- const char *s;
- int (*print) (register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-};
-
-int genoptlv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-int recpdoptlv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-int invoptlv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-
-#define OP_MIN_SIZ 8
-struct pathdata_h {
- u_int16_t pflags;
- u_int16_t pIDcnt;
-};
-
-#define B_FULLD 0x1
-#define B_SPARD 0x2
-#define B_RESTV 0x4
-#define B_KEYIN 0x8
-
-static const struct optlv_h OPTLV_msg[F_OP_MAX + 1] = {
- /* F_OP_RSV */ {ZERO_TTLV, 0, "Invalid OPTLV", invoptlv_print},
- /* F_OP_SET */ {TTLV_T2, B_FULLD | B_SPARD, " Set", recpdoptlv_print},
- /* F_OP_SETPROP */
- {TTLV_T2, B_FULLD | B_SPARD, " SetProp", recpdoptlv_print},
- /* F_OP_SETRESP */ {TTLV_T2, B_RESTV, " SetResp", recpdoptlv_print},
- /* F_OP_SETPRESP */ {TTLV_T2, B_RESTV, " SetPropResp", recpdoptlv_print},
- /* F_OP_DEL */ {ZERO_TTLV, 0, " Del", recpdoptlv_print},
- /* F_OP_DELRESP */ {TTLV_T2, B_RESTV, " DelResp", recpdoptlv_print},
- /* F_OP_GET */ {ZERO_TTLV, 0, " Get", recpdoptlv_print},
- /* F_OP_GETPROP */ {ZERO_TTLV, 0, " GetProp", recpdoptlv_print},
- /* F_OP_GETRESP */
- {TTLV_T2, B_FULLD | B_SPARD | B_RESTV, " GetResp", recpdoptlv_print},
- /* F_OP_GETPRESP */
- {TTLV_T2, B_FULLD | B_RESTV, " GetPropResp", recpdoptlv_print},
- /* F_OP_REPORT */
- {TTLV_T2, B_FULLD | B_SPARD, " Report", recpdoptlv_print},
- /* F_OP_COMMIT */ {ZERO_TTLV, 0, " Commit", NULL},
- /* F_OP_RCOMMIT */ {TTLV_T1, B_RESTV, " RCommit", genoptlv_print},
- /* F_OP_RTRCOMP */ {ZERO_TTLV, 0, " RTRCOMP", NULL},
-};
-
-static inline const struct optlv_h *get_forces_optlv_h(u_int16_t opt)
-{
- if (opt > F_OP_MAX || opt <= F_OP_RSV)
- return &OPTLV_msg[F_OP_RSV];
-
- return &OPTLV_msg[opt];
-}
-
-#define IND_SIZE 256
-#define IND_CHR ' '
-#define IND_PREF '\n'
-#define IND_SUF 0x0
-char ind_buf[IND_SIZE];
-
-static inline char *indent_pr(int indent, int nlpref)
-{
- int i = 0;
- char *r = ind_buf;
-
- if (indent > (IND_SIZE - 1))
- indent = IND_SIZE - 1;
-
- if (nlpref) {
- r[i] = IND_PREF;
- i++;
- indent--;
- }
-
- while (--indent >= 0)
- r[i++] = IND_CHR;
-
- r[i] = IND_SUF;
- return r;
-}
-
-static inline int op_valid(u_int16_t op, u_int16_t mask)
-{
- int opb = 1 << (op - 1);
-
- if (op == 0)
- return 0;
- if (opb & mask)
- return 1;
- /* I guess we should allow vendor operations? */
- if (op >= 0x8000)
- return 1;
- return 0;
-}
-
-#define F_TLV_RSVD 0x0000
-#define F_TLV_REDR 0x0001
-#define F_TLV_ASRS 0x0010
-#define F_TLV_ASRT 0x0011
-#define F_TLV_LFBS 0x1000
-#define F_TLV_PDAT 0x0110
-#define F_TLV_KEYI 0x0111
-#define F_TLV_FULD 0x0112
-#define F_TLV_SPAD 0x0113
-#define F_TLV_REST 0x0114
-#define F_TLV_METD 0x0115
-#define F_TLV_REDD 0x0116
-#define F_TLV_VNST 0x8000
-
-static const struct tok ForCES_TLV[] = {
- {F_TLV_RSVD, "Invalid TLV"},
- {F_TLV_REDR, "REDIRECT TLV"},
- {F_TLV_ASRS, "ASResult TLV"},
- {F_TLV_ASRT, "ASTreason TLV"},
- {F_TLV_LFBS, "LFBselect TLV"},
- {F_TLV_PDAT, "PATH-DATA TLV"},
- {F_TLV_KEYI, "KEYINFO TLV"},
- {F_TLV_FULD, "FULLDATA TLV"},
- {F_TLV_SPAD, "SPARSEDATA TLV"},
- {F_TLV_REST, "RESULT TLV"},
- {F_TLV_METD, "METADATA TLV"},
- {F_TLV_REDD, "REDIRECTDATA TLV"},
- {0, NULL}
-};
-
-#define TLV_HLN 4
-static inline int ttlv_valid(u_int16_t ttlv)
-{
- if (ttlv > 0) {
- if (ttlv == 1 || ttlv == 0x1000)
- return 1;
- if (ttlv >= 0x10 && ttlv <= 0x11)
- return 1;
- if (ttlv >= 0x110 && ttlv <= 0x116)
- return 1;
- if (ttlv >= 0x8000)
- return 0; /* XXX: */
- }
-
- return 0;
-}
-
-struct forces_ilv {
- u_int32_t type;
- u_int32_t length;
-};
-
-struct forces_tlv {
- u_int16_t type;
- u_int16_t length;
-};
-
-int otlv_print(const struct forces_tlv *otlv, u_int16_t op_msk, int indent);
-
-#define F_ALN_LEN(len) ( ((len)+ForCES_ALNL-1) & ~(ForCES_ALNL-1) )
-#define GET_TOP_TLV(fhdr) ((struct forces_tlv *)((fhdr) + sizeof (struct forcesh)))
-#define TLV_SET_LEN(len) (F_ALN_LEN(TLV_HDRL) + (len))
-#define TLV_ALN_LEN(len) F_ALN_LEN(TLV_SET_LEN(len))
-#define TLV_RDAT_LEN(tlv) ((int)(EXTRACT_16BITS(&(tlv)->length) - TLV_SET_LEN(0))
-#define TLV_DATA(tlvp) ((void*)(((char*)(tlvp)) + TLV_SET_LEN(0)))
-#define GO_NXT_TLV(tlv,rlen) ((rlen) -= F_ALN_LEN(EXTRACT_16BITS(&(tlv)->length)), \
- (struct forces_tlv*)(((char*)(tlv)) \
- + F_ALN_LEN(EXTRACT_16BITS(&(tlv)->length))))
-#define ILV_SET_LEN(len) (F_ALN_LEN(ILV_HDRL) + (len))
-#define ILV_ALN_LEN(len) F_ALN_LEN(ILV_SET_LEN(len))
-#define ILV_RDAT_LEN(ilv) ((int)(EXTRACT_32BITS(&(ilv)->length)) - ILV_SET_LEN(0))
-#define ILV_DATA(ilvp) ((void*)(((char*)(ilvp)) + ILV_SET_LEN(0)))
-#define GO_NXT_ILV(ilv,rlen) ((rlen) -= F_ALN_LEN(EXTRACT_32BITS(&(ilv)->length)), \
- (struct forces_ilv *)(((char*)(ilv)) \
- + F_ALN_LEN(EXTRACT_32BITS(&(ilv)->length))))
-#define INVALID_RLEN -1
-#define INVALID_STLN -2
-#define INVALID_LTLN -3
-#define INVALID_ALEN -4
-
-static const struct tok ForCES_TLV_err[] = {
- {INVALID_RLEN, "Invalid total length"},
- {INVALID_STLN, "xLV too short"},
- {INVALID_LTLN, "xLV too long"},
- {INVALID_ALEN, "data padding missing"},
- {0, NULL}
-};
-
-static inline int tlv_valid(const struct forces_tlv *tlv, u_int rlen)
-{
- if (rlen < TLV_HDRL)
- return INVALID_RLEN;
- if (EXTRACT_16BITS(&tlv->length) < TLV_HDRL)
- return INVALID_STLN;
- if (EXTRACT_16BITS(&tlv->length) > rlen)
- return INVALID_LTLN;
- if (rlen < F_ALN_LEN(EXTRACT_16BITS(&tlv->length)))
- return INVALID_ALEN;
-
- return 0;
-}
-
-static inline int ilv_valid(const struct forces_ilv *ilv, u_int rlen)
-{
- if (rlen < ILV_HDRL)
- return INVALID_RLEN;
- if (EXTRACT_32BITS(&ilv->length) < ILV_HDRL)
- return INVALID_STLN;
- if (EXTRACT_32BITS(&ilv->length) > rlen)
- return INVALID_LTLN;
- if (rlen < F_ALN_LEN(EXTRACT_32BITS(&ilv->length)))
- return INVALID_ALEN;
-
- return 0;
-}
-
-struct forces_lfbsh {
- u_int32_t class;
- u_int32_t instance;
-};
-
-#define ASSNS_OPS (B_OP_REPORT)
-#define CFG_OPS (B_OP_SET|B_OP_SETPROP|B_OP_DEL|B_OP_COMMIT|B_OP_RTRCOMP)
-#define CFG_ROPS (B_OP_SETRESP|B_OP_SETPRESP|B_OP_DELRESP|B_OP_RCOMMIT)
-#define CFG_QY (B_OP_GET|B_OP_GETPROP)
-#define CFG_QYR (B_OP_GETRESP|B_OP_GETPRESP)
-#define CFG_EVN (B_OP_REPORT)
-
-static const struct tom_h ForCES_msg[TOM_MAX_IND + 1] = {
- /* TOM_RSV_I */ {TOM_RSVD, ZERO_TTLV, 0, "Invalid message", NULL},
- /* TOM_ASS_I */ {TOM_ASSNSETUP, ZERO_MORE_TTLV | TWO_TLV, ASSNS_OPS,
- "Association Setup", lfbselect_print},
- /* TOM_AST_I */
- {TOM_ASSNTEARD, TTLV_T1, 0, "Association TearDown", asttlv_print},
- /* TOM_CFG_I */ {TOM_CONFIG, TTLV_T2, CFG_OPS, "Config", lfbselect_print},
- /* TOM_QRY_I */ {TOM_QUERY, TTLV_T2, CFG_QY, "Query", lfbselect_print},
- /* TOM_EVN_I */ {TOM_EVENTNOT, TTLV_T1, CFG_EVN, "Event Notification",
- lfbselect_print},
- /* TOM_RED_I */
- {TOM_PKTREDIR, TTLV_T2, 0, "Packet Redirect", redirect_print},
- /* TOM_HBT_I */ {TOM_HEARTBT, ZERO_TTLV, 0, "HeartBeat", NULL},
- /* TOM_ASR_I */
- {TOM_ASSNSETREP, TTLV_T1, 0, "Association Response", asrtlv_print},
- /* TOM_CNR_I */ {TOM_CONFIGREP, TTLV_T2, CFG_ROPS, "Config Response",
- lfbselect_print},
- /* TOM_QRR_I */
- {TOM_QUERYREP, TTLV_T2, CFG_QYR, "Query Response", lfbselect_print},
-};
-
-static inline const struct tom_h *get_forces_tom(u_int8_t tom)
-{
- int i;
- for (i = TOM_RSV_I; i <= TOM_MAX_IND; i++) {
- const struct tom_h *th = &ForCES_msg[i];
- if (th->v == tom)
- return th;
- }
- return &ForCES_msg[TOM_RSV_I];
-}
-
-struct pdata_ops {
- u_int32_t v;
- u_int16_t flags;
- u_int16_t op_msk;
- const char *s;
- int (*print) (register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-};
-
-enum {
- PD_RSV_I,
- PD_SEL_I,
- PD_FDT_I,
- PD_SDT_I,
- PD_RES_I,
- PD_PDT_I,
- _PD_RSV_MAX
-};
-#define PD_MAX_IND (_TOM_RSV_MAX - 1)
-
-static inline int pd_valid(u_int16_t pd)
-{
- if (pd >= F_TLV_PDAT && pd <= F_TLV_REST)
- return 1;
- return 0;
-}
-
-static inline void chk_op_type(u_int16_t type, u_int16_t msk, u_int16_t omsk)
-{
- if (type != F_TLV_PDAT) {
- if (msk & B_KEYIN) {
- if (type != F_TLV_KEYI) {
- printf
- ("Based on flags expected KEYINFO TLV!\n");
- }
- } else {
- if (!(msk & omsk)) {
- printf
- ("Illegal DATA encoding for type 0x%x programmed %x got %x \n",
- type, omsk, msk);
- }
- }
- }
-
-}
-
-int fdatatlv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-int sdatailv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-int sdatatlv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-int pdatatlv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-int pkeyitlv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-
-int pdatacnt_print(register const u_char * pptr, register u_int len,
- u_int16_t IDcnt, u_int16_t op_msk, int indent);
-int pdata_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-
-int prestlv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-#define F_SELKEY 1
-
-struct res_val {
- u_int8_t result;
- u_int8_t resv1;
- u_int16_t resv2;
-};
-
-static const struct pdata_ops ForCES_pdata[PD_MAX_IND + 1] = {
- /* PD_RSV_I */ {0, 0, 0, "Invalid message", NULL},
- /* PD_SEL_I */ {F_TLV_KEYI, 0, 0, "KEYINFO TLV", pkeyitlv_print},
- /* PD_FDT_I */ {F_TLV_FULD, 0, B_FULLD, "FULLDATA TLV", fdatatlv_print},
- /* PD_SDT_I */ {F_TLV_SPAD, 0, B_SPARD, "SPARSEDATA TLV", sdatatlv_print},
- /* PD_RES_I */ {F_TLV_REST, 0, B_RESTV, "RESULT TLV", prestlv_print},
- /* PD_PDT_I */
- {F_TLV_PDAT, 0, 0, "Inner PATH-DATA TLV", recpdoptlv_print},
-};
-
-static inline const struct pdata_ops *get_forces_pd(u_int16_t pd)
-{
- int i;
- for (i = PD_RSV_I + 1; i <= PD_MAX_IND; i++) {
- const struct pdata_ops *pdo = &ForCES_pdata[i];
- if (pdo->v == pd)
- return pdo;
- }
- return &ForCES_pdata[TOM_RSV_I];
-}
-
-enum {
- E_SUCCESS,
- E_INVALID_HEADER,
- E_LENGTH_MISMATCH,
- E_VERSION_MISMATCH,
- E_INVALID_DESTINATION_PID,
- E_LFB_UNKNOWN,
- E_LFB_NOT_FOUND,
- E_LFB_INSTANCE_ID_NOT_FOUND,
- E_INVALID_PATH,
- E_COMPONENT_DOES_NOT_EXIST,
- E_EXISTS,
- E_NOT_FOUND,
- E_READ_ONLY,
- E_INVALID_ARRAY_CREATION,
- E_VALUE_OUT_OF_RANGE,
- E_CONTENTS_TOO_LONG,
- E_INVALID_PARAMETERS,
- E_INVALID_MESSAGE_TYPE,
- E_INVALID_FLAGS,
- E_INVALID_TLV,
- E_EVENT_ERROR,
- E_NOT_SUPPORTED,
- E_MEMORY_ERROR,
- E_INTERNAL_ERROR,
- /* 0x18-0xFE are reserved .. */
- E_UNSPECIFIED_ERROR = 0XFF
-};
-
-const struct tok ForCES_errs[] = {
- {E_SUCCESS, "SUCCESS"},
- {E_INVALID_HEADER, "INVALID HEADER"},
- {E_LENGTH_MISMATCH, "LENGTH MISMATCH"},
- {E_VERSION_MISMATCH, "VERSION MISMATCH"},
- {E_INVALID_DESTINATION_PID, "INVALID DESTINATION PID"},
- {E_LFB_UNKNOWN, "LFB UNKNOWN"},
- {E_LFB_NOT_FOUND, "LFB NOT FOUND"},
- {E_LFB_INSTANCE_ID_NOT_FOUND, "LFB INSTANCE ID NOT FOUND"},
- {E_INVALID_PATH, "INVALID PATH"},
- {E_COMPONENT_DOES_NOT_EXIST, "COMPONENT DOES NOT EXIST"},
- {E_EXISTS, "EXISTS ALREADY"},
- {E_NOT_FOUND, "NOT FOUND"},
- {E_READ_ONLY, "READ ONLY"},
- {E_INVALID_ARRAY_CREATION, "INVALID ARRAY CREATION"},
- {E_VALUE_OUT_OF_RANGE, "VALUE OUT OF RANGE"},
- {E_CONTENTS_TOO_LONG, "CONTENTS TOO LONG"},
- {E_INVALID_PARAMETERS, "INVALID PARAMETERS"},
- {E_INVALID_MESSAGE_TYPE, "INVALID MESSAGE TYPE"},
- {E_INVALID_FLAGS, "INVALID FLAGS"},
- {E_INVALID_TLV, "INVALID TLV"},
- {E_EVENT_ERROR, "EVENT ERROR"},
- {E_NOT_SUPPORTED, "NOT SUPPORTED"},
- {E_MEMORY_ERROR, "MEMORY ERROR"},
- {E_INTERNAL_ERROR, "INTERNAL ERROR"},
- {E_UNSPECIFIED_ERROR, "UNSPECIFIED ERROR"},
- {0, NULL}
-};
diff --git a/contrib/tcpdump/getopt_long.h b/contrib/tcpdump/getopt_long.h
new file mode 100644
index 000000000000..fbb94e6bff77
--- /dev/null
+++ b/contrib/tcpdump/getopt_long.h
@@ -0,0 +1,66 @@
+/* $NetBSD: getopt.h,v 1.4 2000/07/07 10:43:54 ad Exp $ */
+/* $FreeBSD$ */
+
+/*-
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Dieter Baron and Thomas Klausner.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _GETOPT_LONG_H_
+#define _GETOPT_LONG_H_
+
+/*
+ * GNU-like getopt_long()/getopt_long_only() with 4.4BSD optreset extension.
+ * getopt() is declared here too for GNU programs.
+ */
+#define no_argument 0
+#define required_argument 1
+#define optional_argument 2
+
+struct option {
+ /* name of long option */
+ const char *name;
+ /*
+ * one of no_argument, required_argument, and optional_argument:
+ * whether option takes an argument
+ */
+ int has_arg;
+ /* if not NULL, set *flag to val when option found */
+ int *flag;
+ /* if flag not NULL, value to set *flag to; else return value */
+ int val;
+};
+
+int getopt_long(int, char * const *, const char *,
+ const struct option *, int *);
+int getopt_long_only(int, char * const *, const char *,
+ const struct option *, int *);
+
+extern char *optarg; /* getopt(3) external variables */
+extern int optind, opterr, optopt;
+
+#endif /* !_GETOPT_LONG_H_ */
diff --git a/contrib/tcpdump/gmpls.c b/contrib/tcpdump/gmpls.c
index 739176798cde..c9fd9bb8ac6c 100644
--- a/contrib/tcpdump/gmpls.c
+++ b/contrib/tcpdump/gmpls.c
@@ -1,4 +1,4 @@
-/*
+/*
* 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
@@ -13,11 +13,7 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/gmpls.c,v 1.7 2006-04-14 07:11:59 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -141,8 +137,8 @@ const struct tok gmpls_payload_values[] = {
{ 0, NULL }
};
-/*
- * Link Type values used by LMP Service Discovery (specifically, the Client
+/*
+ * Link Type values used by LMP Service Discovery (specifically, the Client
* Port Service Attributes Object). See UNI 1.0 section 9.4.2 for details.
*/
const struct tok lmp_sd_service_config_cpsa_link_type_values[] = {
@@ -151,9 +147,9 @@ const struct tok lmp_sd_service_config_cpsa_link_type_values[] = {
{ 0, NULL}
};
-/*
- * Signal Type values for SDH links used by LMP Service Discovery (specifically,
- * the Client Port Service Attributes Object). See UNI 1.0 section 9.4.2 for
+/*
+ * Signal Type values for SDH links used by LMP Service Discovery (specifically,
+ * the Client Port Service Attributes Object). See UNI 1.0 section 9.4.2 for
* details.
*/
const struct tok lmp_sd_service_config_cpsa_signal_type_sdh_values[] = {
@@ -168,9 +164,9 @@ const struct tok lmp_sd_service_config_cpsa_signal_type_sdh_values[] = {
{ 0, NULL}
};
-/*
- * Signal Type values for SONET links used by LMP Service Discovery (specifically,
- * the Client Port Service Attributes Object). See UNI 1.0 section 9.4.2 for
+/*
+ * Signal Type values for SONET links used by LMP Service Discovery (specifically,
+ * the Client Port Service Attributes Object). See UNI 1.0 section 9.4.2 for
* details.
*/
const struct tok lmp_sd_service_config_cpsa_signal_type_sonet_values[] = {
@@ -186,7 +182,7 @@ const struct tok lmp_sd_service_config_cpsa_signal_type_sonet_values[] = {
};
#define DIFFSERV_BC_MODEL_RDM 0 /* draft-ietf-tewg-diff-te-proto-07 */
-#define DIFFSERV_BC_MODEL_MAM 1 /* draft-ietf-tewg-diff-te-proto-07 */
+#define DIFFSERV_BC_MODEL_MAM 1 /* draft-ietf-tewg-diff-te-proto-07 */
#define DIFFSERV_BC_MODEL_EXTD_MAM 254 /* experimental */
const struct tok diffserv_te_bc_values[] = {
diff --git a/contrib/tcpdump/gmpls.h b/contrib/tcpdump/gmpls.h
index 8db99deac8c6..8b44f9491e9f 100644
--- a/contrib/tcpdump/gmpls.h
+++ b/contrib/tcpdump/gmpls.h
@@ -1,5 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/gmpls.h,v 1.5 2006-04-14 07:11:59 hannes Exp $ (LBL) */
-/*
+/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code
* distributions retain the above copyright notice and this paragraph
diff --git a/contrib/tcpdump/gmt2local.c b/contrib/tcpdump/gmt2local.c
index 1fe0e8a955f3..6958f66a4640 100644
--- a/contrib/tcpdump/gmt2local.c
+++ b/contrib/tcpdump/gmt2local.c
@@ -19,11 +19,7 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/gmt2local.c,v 1.9 2003-11-16 09:36:09 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
diff --git a/contrib/tcpdump/gmt2local.h b/contrib/tcpdump/gmt2local.h
index f7b3841e6aef..89254df9fe48 100644
--- a/contrib/tcpdump/gmt2local.h
+++ b/contrib/tcpdump/gmt2local.h
@@ -17,8 +17,6 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/gmt2local.h,v 1.2 1999-10-07 23:47:10 mcr Exp $ (LBL)
*/
#ifndef gmt2local_h
#define gmt2local_h
diff --git a/contrib/tcpdump/icmp6.h b/contrib/tcpdump/icmp6.h
deleted file mode 100644
index c4d292e5966a..000000000000
--- a/contrib/tcpdump/icmp6.h
+++ /dev/null
@@ -1,473 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/icmp6.h,v 1.18 2007-08-29 02:31:44 mcr Exp $ (LBL) */
-/* NetBSD: icmp6.h,v 1.13 2000/08/03 16:30:37 itojun Exp */
-/* $KAME: icmp6.h,v 1.22 2000/08/03 15:25:16 jinmei Exp $ */
-
-/*
- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * Copyright (c) 1982, 1986, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93
- */
-
-#ifndef _NETINET_ICMP6_H_
-#define _NETINET_ICMP6_H_
-
-struct icmp6_hdr {
- u_int8_t icmp6_type; /* type field */
- u_int8_t icmp6_code; /* code field */
- u_int16_t icmp6_cksum; /* checksum field */
- union {
- u_int32_t icmp6_un_data32[1]; /* type-specific field */
- u_int16_t icmp6_un_data16[2]; /* type-specific field */
- u_int8_t icmp6_un_data8[4]; /* type-specific field */
- } icmp6_dataun;
-};
-
-#define icmp6_data32 icmp6_dataun.icmp6_un_data32
-#define icmp6_data16 icmp6_dataun.icmp6_un_data16
-#define icmp6_data8 icmp6_dataun.icmp6_un_data8
-#define icmp6_pptr icmp6_data32[0] /* parameter prob */
-#define icmp6_mtu icmp6_data32[0] /* packet too big */
-#define icmp6_id icmp6_data16[0] /* echo request/reply */
-#define icmp6_seq icmp6_data16[1] /* echo request/reply */
-#define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */
-
-#define ICMP6_DST_UNREACH 1 /* dest unreachable, codes: */
-#define ICMP6_PACKET_TOO_BIG 2 /* packet too big */
-#define ICMP6_TIME_EXCEEDED 3 /* time exceeded, code: */
-#define ICMP6_PARAM_PROB 4 /* ip6 header bad */
-
-#define ICMP6_ECHO_REQUEST 128 /* echo service */
-#define ICMP6_ECHO_REPLY 129 /* echo reply */
-#define ICMP6_MEMBERSHIP_QUERY 130 /* group membership query */
-#define MLD6_LISTENER_QUERY 130 /* multicast listener query */
-#define ICMP6_MEMBERSHIP_REPORT 131 /* group membership report */
-#define MLD6_LISTENER_REPORT 131 /* multicast listener report */
-#define ICMP6_MEMBERSHIP_REDUCTION 132 /* group membership termination */
-#define MLD6_LISTENER_DONE 132 /* multicast listener done */
-
-#define ND_ROUTER_SOLICIT 133 /* router solicitation */
-#define ND_ROUTER_ADVERT 134 /* router advertisement */
-#define ND_NEIGHBOR_SOLICIT 135 /* neighbor solicitation */
-#define ND_NEIGHBOR_ADVERT 136 /* neighbor advertisement */
-#define ND_REDIRECT 137 /* redirect */
-
-#define ICMP6_ROUTER_RENUMBERING 138 /* router renumbering */
-
-#define ICMP6_WRUREQUEST 139 /* who are you request */
-#define ICMP6_WRUREPLY 140 /* who are you reply */
-#define ICMP6_FQDN_QUERY 139 /* FQDN query */
-#define ICMP6_FQDN_REPLY 140 /* FQDN reply */
-#define ICMP6_NI_QUERY 139 /* node information request */
-#define ICMP6_NI_REPLY 140 /* node information reply */
-#define IND_SOLICIT 141 /* inverse neighbor solicitation */
-#define IND_ADVERT 142 /* inverse neighbor advertisement */
-
-#define ICMP6_V2_MEMBERSHIP_REPORT 143 /* v2 membership report */
-#define MLDV2_LISTENER_REPORT 143 /* v2 multicast listener report */
-#define ICMP6_HADISCOV_REQUEST 144
-#define ICMP6_HADISCOV_REPLY 145
-#define ICMP6_MOBILEPREFIX_SOLICIT 146
-#define ICMP6_MOBILEPREFIX_ADVERT 147
-
-#define MLD6_MTRACE_RESP 200 /* mtrace response(to sender) */
-#define MLD6_MTRACE 201 /* mtrace messages */
-
-#define ICMP6_MAXTYPE 201
-
-#define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */
-#define ICMP6_DST_UNREACH_ADMIN 1 /* administratively prohibited */
-#define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor(obsolete) */
-#define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */
-#define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */
-#define ICMP6_DST_UNREACH_NOPORT 4 /* port unreachable */
-
-#define ICMP6_TIME_EXCEED_TRANSIT 0 /* ttl==0 in transit */
-#define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* ttl==0 in reass */
-
-#define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */
-#define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized next header */
-#define ICMP6_PARAMPROB_OPTION 2 /* unrecognized option */
-
-#define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */
-
-#define ICMP6_NI_SUBJ_IPV6 0 /* Query Subject is an IPv6 address */
-#define ICMP6_NI_SUBJ_FQDN 1 /* Query Subject is a Domain name */
-#define ICMP6_NI_SUBJ_IPV4 2 /* Query Subject is an IPv4 address */
-
-#define ICMP6_NI_SUCCESS 0 /* node information successful reply */
-#define ICMP6_NI_REFUSED 1 /* node information request is refused */
-#define ICMP6_NI_UNKNOWN 2 /* unknown Qtype */
-
-#define ICMP6_ROUTER_RENUMBERING_COMMAND 0 /* rr command */
-#define ICMP6_ROUTER_RENUMBERING_RESULT 1 /* rr result */
-#define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 /* rr seq num reset */
-
-/* Used in kernel only */
-#define ND_REDIRECT_ONLINK 0 /* redirect to an on-link node */
-#define ND_REDIRECT_ROUTER 1 /* redirect to a better router */
-
-/*
- * Multicast Listener Discovery
- */
-struct mld6_hdr {
- struct icmp6_hdr mld6_hdr;
- struct in6_addr mld6_addr; /* multicast address */
-};
-
-#define mld6_type mld6_hdr.icmp6_type
-#define mld6_code mld6_hdr.icmp6_code
-#define mld6_cksum mld6_hdr.icmp6_cksum
-#define mld6_maxdelay mld6_hdr.icmp6_data16[0]
-#define mld6_reserved mld6_hdr.icmp6_data16[1]
-
-#define MLD_MINLEN 24
-#define MLDV2_MINLEN 28
-
-/*
- * Neighbor Discovery
- */
-
-struct nd_router_solicit { /* router solicitation */
- struct icmp6_hdr nd_rs_hdr;
- /* could be followed by options */
-};
-
-#define nd_rs_type nd_rs_hdr.icmp6_type
-#define nd_rs_code nd_rs_hdr.icmp6_code
-#define nd_rs_cksum nd_rs_hdr.icmp6_cksum
-#define nd_rs_reserved nd_rs_hdr.icmp6_data32[0]
-
-struct nd_router_advert { /* router advertisement */
- struct icmp6_hdr nd_ra_hdr;
- u_int32_t nd_ra_reachable; /* reachable time */
- u_int32_t nd_ra_retransmit; /* retransmit timer */
- /* could be followed by options */
-};
-
-#define nd_ra_type nd_ra_hdr.icmp6_type
-#define nd_ra_code nd_ra_hdr.icmp6_code
-#define nd_ra_cksum nd_ra_hdr.icmp6_cksum
-#define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0]
-#define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1]
-#define ND_RA_FLAG_MANAGED 0x80
-#define ND_RA_FLAG_OTHER 0x40
-#define ND_RA_FLAG_HOME_AGENT 0x20
-
-/*
- * Router preference values based on draft-draves-ipngwg-router-selection-01.
- * These are non-standard definitions.
- */
-#define ND_RA_FLAG_RTPREF_MASK 0x18 /* 00011000 */
-
-#define ND_RA_FLAG_RTPREF_HIGH 0x08 /* 00001000 */
-#define ND_RA_FLAG_RTPREF_MEDIUM 0x00 /* 00000000 */
-#define ND_RA_FLAG_RTPREF_LOW 0x18 /* 00011000 */
-#define ND_RA_FLAG_RTPREF_RSV 0x10 /* 00010000 */
-
-#define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
-
-struct nd_neighbor_solicit { /* neighbor solicitation */
- struct icmp6_hdr nd_ns_hdr;
- struct in6_addr nd_ns_target; /*target address */
- /* could be followed by options */
-};
-
-#define nd_ns_type nd_ns_hdr.icmp6_type
-#define nd_ns_code nd_ns_hdr.icmp6_code
-#define nd_ns_cksum nd_ns_hdr.icmp6_cksum
-#define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
-
-struct nd_neighbor_advert { /* neighbor advertisement */
- struct icmp6_hdr nd_na_hdr;
- struct in6_addr nd_na_target; /* target address */
- /* could be followed by options */
-};
-
-#define nd_na_type nd_na_hdr.icmp6_type
-#define nd_na_code nd_na_hdr.icmp6_code
-#define nd_na_cksum nd_na_hdr.icmp6_cksum
-#define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0]
-
-#define ND_NA_FLAG_ROUTER 0x80000000
-#define ND_NA_FLAG_SOLICITED 0x40000000
-#define ND_NA_FLAG_OVERRIDE 0x20000000
-
-struct nd_redirect { /* redirect */
- struct icmp6_hdr nd_rd_hdr;
- struct in6_addr nd_rd_target; /* target address */
- struct in6_addr nd_rd_dst; /* destination address */
- /* could be followed by options */
-};
-
-#define nd_rd_type nd_rd_hdr.icmp6_type
-#define nd_rd_code nd_rd_hdr.icmp6_code
-#define nd_rd_cksum nd_rd_hdr.icmp6_cksum
-#define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
-
-struct nd_opt_hdr { /* Neighbor discovery option header */
- u_int8_t nd_opt_type;
- u_int8_t nd_opt_len;
- /* followed by option specific data*/
-};
-
-#define ND_OPT_SOURCE_LINKADDR 1
-#define ND_OPT_TARGET_LINKADDR 2
-#define ND_OPT_PREFIX_INFORMATION 3
-#define ND_OPT_REDIRECTED_HEADER 4
-#define ND_OPT_MTU 5
-#define ND_OPT_ADVINTERVAL 7
-#define ND_OPT_HOMEAGENT_INFO 8
-#define ND_OPT_ROUTE_INFO 9 /* draft-ietf-ipngwg-router-preference, not officially assigned yet */
-#define ND_OPT_RDNSS 25
-#define ND_OPT_DNSSL 31
-
-struct nd_opt_prefix_info { /* prefix information */
- u_int8_t nd_opt_pi_type;
- u_int8_t nd_opt_pi_len;
- u_int8_t nd_opt_pi_prefix_len;
- u_int8_t nd_opt_pi_flags_reserved;
- u_int8_t nd_opt_pi_valid_time[4];
- u_int8_t nd_opt_pi_preferred_time[4];
- u_int8_t nd_opt_pi_reserved2[4];
- struct in6_addr nd_opt_pi_prefix;
-};
-
-#define ND_OPT_PI_FLAG_ONLINK 0x80
-#define ND_OPT_PI_FLAG_AUTO 0x40
-#define ND_OPT_PI_FLAG_ROUTER 0x20 /*2292bis*/
-
-struct nd_opt_rd_hdr { /* redirected header */
- u_int8_t nd_opt_rh_type;
- u_int8_t nd_opt_rh_len;
- u_int16_t nd_opt_rh_reserved1;
- u_int32_t nd_opt_rh_reserved2;
- /* followed by IP header and data */
-};
-
-struct nd_opt_mtu { /* MTU option */
- u_int8_t nd_opt_mtu_type;
- u_int8_t nd_opt_mtu_len;
- u_int16_t nd_opt_mtu_reserved;
- u_int32_t nd_opt_mtu_mtu;
-};
-
-struct nd_opt_rdnss { /* RDNSS RFC 6106 5.1 */
- u_int8_t nd_opt_rdnss_type;
- u_int8_t nd_opt_rdnss_len;
- u_int16_t nd_opt_rdnss_reserved;
- u_int32_t nd_opt_rdnss_lifetime;
- struct in6_addr nd_opt_rdnss_addr[1]; /* variable-length */
-};
-
-struct nd_opt_dnssl { /* DNSSL RFC 6106 5.2 */
- u_int8_t nd_opt_dnssl_type;
- u_int8_t nd_opt_dnssl_len;
- u_int16_t nd_opt_dnssl_reserved;
- u_int32_t nd_opt_dnssl_lifetime;
- /* followed by list of DNS search domains, variable-length */
-};
-
-struct nd_opt_advinterval { /* Advertisement interval option */
- u_int8_t nd_opt_adv_type;
- u_int8_t nd_opt_adv_len;
- u_int16_t nd_opt_adv_reserved;
- u_int32_t nd_opt_adv_interval;
-};
-
-struct nd_opt_homeagent_info { /* Home Agent info */
- u_int8_t nd_opt_hai_type;
- u_int8_t nd_opt_hai_len;
- u_int16_t nd_opt_hai_reserved;
- int16_t nd_opt_hai_preference;
- u_int16_t nd_opt_hai_lifetime;
-};
-
-struct nd_opt_route_info { /* route info */
- u_int8_t nd_opt_rti_type;
- u_int8_t nd_opt_rti_len;
- u_int8_t nd_opt_rti_prefixlen;
- u_int8_t nd_opt_rti_flags;
- u_int32_t nd_opt_rti_lifetime;
- /* prefix follows */
-};
-
-/*
- * icmp6 namelookup
- */
-
-struct icmp6_namelookup {
- struct icmp6_hdr icmp6_nl_hdr;
- u_int8_t icmp6_nl_nonce[8];
- int32_t icmp6_nl_ttl;
-#if 0
- u_int8_t icmp6_nl_len;
- u_int8_t icmp6_nl_name[3];
-#endif
- /* could be followed by options */
-};
-
-/*
- * icmp6 node information
- */
-struct icmp6_nodeinfo {
- struct icmp6_hdr icmp6_ni_hdr;
- u_int8_t icmp6_ni_nonce[8];
- /* could be followed by reply data */
-};
-
-#define ni_type icmp6_ni_hdr.icmp6_type
-#define ni_code icmp6_ni_hdr.icmp6_code
-#define ni_cksum icmp6_ni_hdr.icmp6_cksum
-#define ni_qtype icmp6_ni_hdr.icmp6_data16[0]
-#define ni_flags icmp6_ni_hdr.icmp6_data16[1]
-
-#define NI_QTYPE_NOOP 0 /* NOOP */
-#define NI_QTYPE_SUPTYPES 1 /* Supported Qtypes */
-#define NI_QTYPE_FQDN 2 /* FQDN (draft 04) */
-#define NI_QTYPE_DNSNAME 2 /* DNS Name */
-#define NI_QTYPE_NODEADDR 3 /* Node Addresses */
-#define NI_QTYPE_IPV4ADDR 4 /* IPv4 Addresses */
-
-/* network endian */
-#define NI_SUPTYPE_FLAG_COMPRESS ((u_int16_t)htons(0x1))
-#define NI_FQDN_FLAG_VALIDTTL ((u_int16_t)htons(0x1))
-
-/* network endian */
-#define NI_NODEADDR_FLAG_TRUNCATE ((u_int16_t)htons(0x1))
-#define NI_NODEADDR_FLAG_ALL ((u_int16_t)htons(0x2))
-#define NI_NODEADDR_FLAG_COMPAT ((u_int16_t)htons(0x4))
-#define NI_NODEADDR_FLAG_LINKLOCAL ((u_int16_t)htons(0x8))
-#define NI_NODEADDR_FLAG_SITELOCAL ((u_int16_t)htons(0x10))
-#define NI_NODEADDR_FLAG_GLOBAL ((u_int16_t)htons(0x20))
-#define NI_NODEADDR_FLAG_ANYCAST ((u_int16_t)htons(0x40)) /* just experimental. not in spec */
-
-struct ni_reply_fqdn {
- u_int32_t ni_fqdn_ttl; /* TTL */
- u_int8_t ni_fqdn_namelen; /* length in octets of the FQDN */
- u_int8_t ni_fqdn_name[3]; /* XXX: alignment */
-};
-
-/*
- * Router Renumbering. as router-renum-08.txt
- */
-struct icmp6_router_renum { /* router renumbering header */
- struct icmp6_hdr rr_hdr;
- u_int8_t rr_segnum;
- u_int8_t rr_flags;
- u_int16_t rr_maxdelay;
- u_int32_t rr_reserved;
-};
-#define ICMP6_RR_FLAGS_TEST 0x80
-#define ICMP6_RR_FLAGS_REQRESULT 0x40
-#define ICMP6_RR_FLAGS_FORCEAPPLY 0x20
-#define ICMP6_RR_FLAGS_SPECSITE 0x10
-#define ICMP6_RR_FLAGS_PREVDONE 0x08
-
-#define rr_type rr_hdr.icmp6_type
-#define rr_code rr_hdr.icmp6_code
-#define rr_cksum rr_hdr.icmp6_cksum
-#define rr_seqnum rr_hdr.icmp6_data32[0]
-
-struct rr_pco_match { /* match prefix part */
- u_int8_t rpm_code;
- u_int8_t rpm_len;
- u_int8_t rpm_ordinal;
- u_int8_t rpm_matchlen;
- u_int8_t rpm_minlen;
- u_int8_t rpm_maxlen;
- u_int16_t rpm_reserved;
- struct in6_addr rpm_prefix;
-};
-
-#define RPM_PCO_ADD 1
-#define RPM_PCO_CHANGE 2
-#define RPM_PCO_SETGLOBAL 3
-#define RPM_PCO_MAX 4
-
-struct rr_pco_use { /* use prefix part */
- u_int8_t rpu_uselen;
- u_int8_t rpu_keeplen;
- u_int8_t rpu_ramask;
- u_int8_t rpu_raflags;
- u_int32_t rpu_vltime;
- u_int32_t rpu_pltime;
- u_int32_t rpu_flags;
- struct in6_addr rpu_prefix;
-};
-#define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x80
-#define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x40
-
-/* network endian */
-#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME ((u_int32_t)htonl(0x80000000))
-#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME ((u_int32_t)htonl(0x40000000))
-
-struct rr_result { /* router renumbering result message */
- u_int16_t rrr_flags;
- u_int8_t rrr_ordinal;
- u_int8_t rrr_matchedlen;
- u_int32_t rrr_ifid;
- struct in6_addr rrr_prefix;
-};
-/* network endian */
-#define ICMP6_RR_RESULT_FLAGS_OOB ((u_int16_t)htons(0x0002))
-#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN ((u_int16_t)htons(0x0001))
-
-#endif /* not _NETINET_ICMP6_H_ */
diff --git a/contrib/tcpdump/ieee802_11.h b/contrib/tcpdump/ieee802_11.h
deleted file mode 100644
index 2aa1345038a2..000000000000
--- a/contrib/tcpdump/ieee802_11.h
+++ /dev/null
@@ -1,347 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/ieee802_11.h,v 1.12 2007-07-22 19:59:06 guy Exp $ (LBL) */
-/*
- * Copyright (c) 2001
- * Fortress Technologies
- * Charlie Lenahan ( clenahan@fortresstech.com )
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that: (1) source code distributions
- * retain the above copyright notice and this paragraph in its entirety, (2)
- * distributions including binary code include the above copyright notice and
- * this paragraph in its entirety in the documentation or other materials
- * provided with the distribution, and (3) all advertising materials mentioning
- * features or use of this software display the following acknowledgement:
- * ``This product includes software developed by the University of California,
- * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
- * the University nor the names of its contributors may be used to endorse
- * or promote products derived from this software without specific prior
- * written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-/* Lengths of 802.11 header components. */
-#define IEEE802_11_FC_LEN 2
-#define IEEE802_11_DUR_LEN 2
-#define IEEE802_11_DA_LEN 6
-#define IEEE802_11_SA_LEN 6
-#define IEEE802_11_BSSID_LEN 6
-#define IEEE802_11_RA_LEN 6
-#define IEEE802_11_TA_LEN 6
-#define IEEE802_11_SEQ_LEN 2
-#define IEEE802_11_CTL_LEN 2
-#define IEEE802_11_IV_LEN 3
-#define IEEE802_11_KID_LEN 1
-
-/* Frame check sequence length. */
-#define IEEE802_11_FCS_LEN 4
-
-/* Lengths of beacon components. */
-#define IEEE802_11_TSTAMP_LEN 8
-#define IEEE802_11_BCNINT_LEN 2
-#define IEEE802_11_CAPINFO_LEN 2
-#define IEEE802_11_LISTENINT_LEN 2
-
-#define IEEE802_11_AID_LEN 2
-#define IEEE802_11_STATUS_LEN 2
-#define IEEE802_11_REASON_LEN 2
-
-/* Length of previous AP in reassocation frame */
-#define IEEE802_11_AP_LEN 6
-
-#define T_MGMT 0x0 /* management */
-#define T_CTRL 0x1 /* control */
-#define T_DATA 0x2 /* data */
-#define T_RESV 0x3 /* reserved */
-
-#define ST_ASSOC_REQUEST 0x0
-#define ST_ASSOC_RESPONSE 0x1
-#define ST_REASSOC_REQUEST 0x2
-#define ST_REASSOC_RESPONSE 0x3
-#define ST_PROBE_REQUEST 0x4
-#define ST_PROBE_RESPONSE 0x5
-/* RESERVED 0x6 */
-/* RESERVED 0x7 */
-#define ST_BEACON 0x8
-#define ST_ATIM 0x9
-#define ST_DISASSOC 0xA
-#define ST_AUTH 0xB
-#define ST_DEAUTH 0xC
-#define ST_ACTION 0xD
-/* RESERVED 0xE */
-/* RESERVED 0xF */
-
-
-#define CTRL_CONTROL_WRAPPER 0x7
-#define CTRL_BAR 0x8
-#define CTRL_BA 0x9
-#define CTRL_PS_POLL 0xA
-#define CTRL_RTS 0xB
-#define CTRL_CTS 0xC
-#define CTRL_ACK 0xD
-#define CTRL_CF_END 0xE
-#define CTRL_END_ACK 0xF
-
-#define DATA_DATA 0x0
-#define DATA_DATA_CF_ACK 0x1
-#define DATA_DATA_CF_POLL 0x2
-#define DATA_DATA_CF_ACK_POLL 0x3
-#define DATA_NODATA 0x4
-#define DATA_NODATA_CF_ACK 0x5
-#define DATA_NODATA_CF_POLL 0x6
-#define DATA_NODATA_CF_ACK_POLL 0x7
-
-#define DATA_QOS_DATA 0x8
-#define DATA_QOS_DATA_CF_ACK 0x9
-#define DATA_QOS_DATA_CF_POLL 0xA
-#define DATA_QOS_DATA_CF_ACK_POLL 0xB
-#define DATA_QOS_NODATA 0xC
-#define DATA_QOS_CF_POLL_NODATA 0xE
-#define DATA_QOS_CF_ACK_POLL_NODATA 0xF
-
-/*
- * The subtype field of a data frame is, in effect, composed of 4 flag
- * bits - CF-Ack, CF-Poll, Null (means the frame doesn't actually have
- * any data), and QoS.
- */
-#define DATA_FRAME_IS_CF_ACK(x) ((x) & 0x01)
-#define DATA_FRAME_IS_CF_POLL(x) ((x) & 0x02)
-#define DATA_FRAME_IS_NULL(x) ((x) & 0x04)
-#define DATA_FRAME_IS_QOS(x) ((x) & 0x08)
-
-/*
- * Bits in the frame control field.
- */
-#define FC_VERSION(fc) ((fc) & 0x3)
-#define FC_TYPE(fc) (((fc) >> 2) & 0x3)
-#define FC_SUBTYPE(fc) (((fc) >> 4) & 0xF)
-#define FC_TO_DS(fc) ((fc) & 0x0100)
-#define FC_FROM_DS(fc) ((fc) & 0x0200)
-#define FC_MORE_FLAG(fc) ((fc) & 0x0400)
-#define FC_RETRY(fc) ((fc) & 0x0800)
-#define FC_POWER_MGMT(fc) ((fc) & 0x1000)
-#define FC_MORE_DATA(fc) ((fc) & 0x2000)
-#define FC_WEP(fc) ((fc) & 0x4000)
-#define FC_ORDER(fc) ((fc) & 0x8000)
-
-struct mgmt_header_t {
- u_int16_t fc;
- u_int16_t duration;
- u_int8_t da[6];
- u_int8_t sa[6];
- u_int8_t bssid[6];
- u_int16_t seq_ctrl;
-};
-
-#define MGMT_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
- IEEE802_11_DA_LEN+IEEE802_11_SA_LEN+\
- IEEE802_11_BSSID_LEN+IEEE802_11_SEQ_LEN)
-
-#define CAPABILITY_ESS(cap) ((cap) & 0x0001)
-#define CAPABILITY_IBSS(cap) ((cap) & 0x0002)
-#define CAPABILITY_CFP(cap) ((cap) & 0x0004)
-#define CAPABILITY_CFP_REQ(cap) ((cap) & 0x0008)
-#define CAPABILITY_PRIVACY(cap) ((cap) & 0x0010)
-
-struct ssid_t {
- u_int8_t element_id;
- u_int8_t length;
- u_char ssid[33]; /* 32 + 1 for null */
-};
-
-struct rates_t {
- u_int8_t element_id;
- u_int8_t length;
- u_int8_t rate[16];
-};
-
-struct challenge_t {
- u_int8_t element_id;
- u_int8_t length;
- u_int8_t text[254]; /* 1-253 + 1 for null */
-};
-
-struct fh_t {
- u_int8_t element_id;
- u_int8_t length;
- u_int16_t dwell_time;
- u_int8_t hop_set;
- u_int8_t hop_pattern;
- u_int8_t hop_index;
-};
-
-struct ds_t {
- u_int8_t element_id;
- u_int8_t length;
- u_int8_t channel;
-};
-
-struct cf_t {
- u_int8_t element_id;
- u_int8_t length;
- u_int8_t count;
- u_int8_t period;
- u_int16_t max_duration;
- u_int16_t dur_remaing;
-};
-
-struct tim_t {
- u_int8_t element_id;
- u_int8_t length;
- u_int8_t count;
- u_int8_t period;
- u_int8_t bitmap_control;
- u_int8_t bitmap[251];
-};
-
-#define E_SSID 0
-#define E_RATES 1
-#define E_FH 2
-#define E_DS 3
-#define E_CF 4
-#define E_TIM 5
-#define E_IBSS 6
-/* reserved 7 */
-/* reserved 8 */
-/* reserved 9 */
-/* reserved 10 */
-/* reserved 11 */
-/* reserved 12 */
-/* reserved 13 */
-/* reserved 14 */
-/* reserved 15 */
-/* reserved 16 */
-
-#define E_CHALLENGE 16
-/* reserved 17 */
-/* reserved 18 */
-/* reserved 19 */
-/* reserved 16 */
-/* reserved 16 */
-
-
-struct mgmt_body_t {
- u_int8_t timestamp[IEEE802_11_TSTAMP_LEN];
- u_int16_t beacon_interval;
- u_int16_t listen_interval;
- u_int16_t status_code;
- u_int16_t aid;
- u_char ap[IEEE802_11_AP_LEN];
- u_int16_t reason_code;
- u_int16_t auth_alg;
- u_int16_t auth_trans_seq_num;
- int challenge_present;
- struct challenge_t challenge;
- u_int16_t capability_info;
- int ssid_present;
- struct ssid_t ssid;
- int rates_present;
- struct rates_t rates;
- int ds_present;
- struct ds_t ds;
- int cf_present;
- struct cf_t cf;
- int fh_present;
- struct fh_t fh;
- int tim_present;
- struct tim_t tim;
-};
-
-struct ctrl_rts_t {
- u_int16_t fc;
- u_int16_t duration;
- u_int8_t ra[6];
- u_int8_t ta[6];
- u_int8_t fcs[4];
-};
-
-#define CTRL_RTS_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
- IEEE802_11_RA_LEN+IEEE802_11_TA_LEN)
-
-struct ctrl_cts_t {
- u_int16_t fc;
- u_int16_t duration;
- u_int8_t ra[6];
- u_int8_t fcs[4];
-};
-
-#define CTRL_CTS_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
-
-struct ctrl_ack_t {
- u_int16_t fc;
- u_int16_t duration;
- u_int8_t ra[6];
- u_int8_t fcs[4];
-};
-
-#define CTRL_ACK_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
-
-struct ctrl_ps_poll_t {
- u_int16_t fc;
- u_int16_t aid;
- u_int8_t bssid[6];
- u_int8_t ta[6];
- u_int8_t fcs[4];
-};
-
-#define CTRL_PS_POLL_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_AID_LEN+\
- IEEE802_11_BSSID_LEN+IEEE802_11_TA_LEN)
-
-struct ctrl_end_t {
- u_int16_t fc;
- u_int16_t duration;
- u_int8_t ra[6];
- u_int8_t bssid[6];
- u_int8_t fcs[4];
-};
-
-#define CTRL_END_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
- IEEE802_11_RA_LEN+IEEE802_11_BSSID_LEN)
-
-struct ctrl_end_ack_t {
- u_int16_t fc;
- u_int16_t duration;
- u_int8_t ra[6];
- u_int8_t bssid[6];
- u_int8_t fcs[4];
-};
-
-#define CTRL_END_ACK_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
- IEEE802_11_RA_LEN+IEEE802_11_BSSID_LEN)
-
-struct ctrl_ba_t {
- u_int16_t fc;
- u_int16_t duration;
- u_int8_t ra[6];
- u_int8_t fcs[4];
-};
-
-#define CTRL_BA_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
-
-struct ctrl_bar_t {
- u_int16_t fc;
- u_int16_t dur;
- u_int8_t ra[6];
- u_int8_t ta[6];
- u_int16_t ctl;
- u_int16_t seq;
- u_int8_t fcs[4];
-};
-
-#define CTRL_BAR_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
- IEEE802_11_RA_LEN+IEEE802_11_TA_LEN+\
- IEEE802_11_CTL_LEN+IEEE802_11_SEQ_LEN)
-
-struct meshcntl_t {
- u_int8_t flags;
- u_int8_t ttl;
- u_int8_t seq[4];
- u_int8_t addr4[6];
- u_int8_t addr5[6];
- u_int8_t addr6[6];
-};
-
-#define IV_IV(iv) ((iv) & 0xFFFFFF)
-#define IV_PAD(iv) (((iv) >> 24) & 0x3F)
-#define IV_KEYID(iv) (((iv) >> 30) & 0x03)
diff --git a/contrib/tcpdump/ieee802_11_radio.h b/contrib/tcpdump/ieee802_11_radio.h
deleted file mode 100644
index 812b5ac31e99..000000000000
--- a/contrib/tcpdump/ieee802_11_radio.h
+++ /dev/null
@@ -1,291 +0,0 @@
-/* $FreeBSD$ */
-/* NetBSD: ieee802_11_radio.h,v 1.2 2006/02/26 03:04:03 dyoung Exp */
-/* $Header: /tcpdump/master/tcpdump/ieee802_11_radio.h,v 1.3 2007-08-29 02:31:44 mcr Exp $ */
-
-/*-
- * Copyright (c) 2003, 2004 David Young. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of David Young may not be used to endorse or promote
- * products derived from this software without specific prior
- * written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID
- * YOUNG BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
- * OF SUCH DAMAGE.
- */
-#ifndef _NET_IF_IEEE80211RADIOTAP_H_
-#define _NET_IF_IEEE80211RADIOTAP_H_
-
-/* A generic radio capture format is desirable. It must be
- * rigidly defined (e.g., units for fields should be given),
- * and easily extensible.
- *
- * The following is an extensible radio capture format. It is
- * based on a bitmap indicating which fields are present.
- *
- * I am trying to describe precisely what the application programmer
- * should expect in the following, and for that reason I tell the
- * units and origin of each measurement (where it applies), or else I
- * use sufficiently weaselly language ("is a monotonically nondecreasing
- * function of...") that I cannot set false expectations for lawyerly
- * readers.
- */
-
-/*
- * The radio capture header precedes the 802.11 header.
- *
- * Note well: all radiotap fields are little-endian.
- */
-struct ieee80211_radiotap_header {
- u_int8_t it_version; /* Version 0. Only increases
- * for drastic changes,
- * introduction of compatible
- * new fields does not count.
- */
- u_int8_t it_pad;
- u_int16_t it_len; /* length of the whole
- * header in bytes, including
- * it_version, it_pad,
- * it_len, and data fields.
- */
- u_int32_t it_present; /* A bitmap telling which
- * fields are present. Set bit 31
- * (0x80000000) to extend the
- * bitmap by another 32 bits.
- * Additional extensions are made
- * by setting bit 31.
- */
-};
-
-/* Name Data type Units
- * ---- --------- -----
- *
- * IEEE80211_RADIOTAP_TSFT u_int64_t microseconds
- *
- * Value in microseconds of the MAC's 64-bit 802.11 Time
- * Synchronization Function timer when the first bit of the
- * MPDU arrived at the MAC. For received frames, only.
- *
- * IEEE80211_RADIOTAP_CHANNEL 2 x u_int16_t MHz, bitmap
- *
- * Tx/Rx frequency in MHz, followed by flags (see below).
- * Note that IEEE80211_RADIOTAP_XCHANNEL must be used to
- * represent an HT channel as there is not enough room in
- * the flags word.
- *
- * IEEE80211_RADIOTAP_FHSS u_int16_t see below
- *
- * For frequency-hopping radios, the hop set (first byte)
- * and pattern (second byte).
- *
- * IEEE80211_RADIOTAP_RATE u_int8_t 500kb/s or index
- *
- * Tx/Rx data rate. If bit 0x80 is set then it represents an
- * an MCS index and not an IEEE rate.
- *
- * IEEE80211_RADIOTAP_DBM_ANTSIGNAL int8_t decibels from
- * one milliwatt (dBm)
- *
- * RF signal power at the antenna, decibel difference from
- * one milliwatt.
- *
- * IEEE80211_RADIOTAP_DBM_ANTNOISE int8_t decibels from
- * one milliwatt (dBm)
- *
- * RF noise power at the antenna, decibel difference from one
- * milliwatt.
- *
- * IEEE80211_RADIOTAP_DB_ANTSIGNAL u_int8_t decibel (dB)
- *
- * RF signal power at the antenna, decibel difference from an
- * arbitrary, fixed reference.
- *
- * IEEE80211_RADIOTAP_DB_ANTNOISE u_int8_t decibel (dB)
- *
- * RF noise power at the antenna, decibel difference from an
- * arbitrary, fixed reference point.
- *
- * IEEE80211_RADIOTAP_LOCK_QUALITY u_int16_t unitless
- *
- * Quality of Barker code lock. Unitless. Monotonically
- * nondecreasing with "better" lock strength. Called "Signal
- * Quality" in datasheets. (Is there a standard way to measure
- * this?)
- *
- * IEEE80211_RADIOTAP_TX_ATTENUATION u_int16_t unitless
- *
- * Transmit power expressed as unitless distance from max
- * power set at factory calibration. 0 is max power.
- * Monotonically nondecreasing with lower power levels.
- *
- * IEEE80211_RADIOTAP_DB_TX_ATTENUATION u_int16_t decibels (dB)
- *
- * Transmit power expressed as decibel distance from max power
- * set at factory calibration. 0 is max power. Monotonically
- * nondecreasing with lower power levels.
- *
- * IEEE80211_RADIOTAP_DBM_TX_POWER int8_t decibels from
- * one milliwatt (dBm)
- *
- * Transmit power expressed as dBm (decibels from a 1 milliwatt
- * reference). This is the absolute power level measured at
- * the antenna port.
- *
- * IEEE80211_RADIOTAP_FLAGS u_int8_t bitmap
- *
- * Properties of transmitted and received frames. See flags
- * defined below.
- *
- * IEEE80211_RADIOTAP_ANTENNA u_int8_t antenna index
- *
- * Unitless indication of the Rx/Tx antenna for this packet.
- * The first antenna is antenna 0.
- *
- * IEEE80211_RADIOTAP_RX_FLAGS u_int16_t bitmap
- *
- * Properties of received frames. See flags defined below.
- *
- * IEEE80211_RADIOTAP_XCHANNEL u_int32_t bitmap
- * u_int16_t MHz
- * u_int8_t channel number
- * u_int8_t .5 dBm
- *
- * Extended channel specification: flags (see below) followed by
- * frequency in MHz, the corresponding IEEE channel number, and
- * finally the maximum regulatory transmit power cap in .5 dBm
- * units. This property supersedes IEEE80211_RADIOTAP_CHANNEL
- * and only one of the two should be present.
- *
- * IEEE80211_RADIOTAP_MCS u_int8_t known
- * u_int8_t flags
- * u_int8_t mcs
- *
- * Bitset indicating which fields have known values, followed
- * by bitset of flag values, followed by the MCS rate index as
- * in IEEE 802.11n.
- *
- * IEEE80211_RADIOTAP_VENDOR_NAMESPACE
- * u_int8_t OUI[3]
- * u_int8_t subspace
- * u_int16_t length
- *
- * The Vendor Namespace Field contains three sub-fields. The first
- * sub-field is 3 bytes long. It contains the vendor's IEEE 802
- * Organizationally Unique Identifier (OUI). The fourth byte is a
- * vendor-specific "namespace selector."
- *
- */
-enum ieee80211_radiotap_type {
- IEEE80211_RADIOTAP_TSFT = 0,
- IEEE80211_RADIOTAP_FLAGS = 1,
- IEEE80211_RADIOTAP_RATE = 2,
- IEEE80211_RADIOTAP_CHANNEL = 3,
- IEEE80211_RADIOTAP_FHSS = 4,
- IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5,
- IEEE80211_RADIOTAP_DBM_ANTNOISE = 6,
- IEEE80211_RADIOTAP_LOCK_QUALITY = 7,
- IEEE80211_RADIOTAP_TX_ATTENUATION = 8,
- IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9,
- IEEE80211_RADIOTAP_DBM_TX_POWER = 10,
- IEEE80211_RADIOTAP_ANTENNA = 11,
- IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12,
- IEEE80211_RADIOTAP_DB_ANTNOISE = 13,
- IEEE80211_RADIOTAP_RX_FLAGS = 14,
- /* NB: gap for netbsd definitions */
- IEEE80211_RADIOTAP_XCHANNEL = 18,
- IEEE80211_RADIOTAP_MCS = 19,
- IEEE80211_RADIOTAP_NAMESPACE = 29,
- IEEE80211_RADIOTAP_VENDOR_NAMESPACE = 30,
- IEEE80211_RADIOTAP_EXT = 31
-};
-
-/* channel attributes */
-#define IEEE80211_CHAN_TURBO 0x00010 /* Turbo channel */
-#define IEEE80211_CHAN_CCK 0x00020 /* CCK channel */
-#define IEEE80211_CHAN_OFDM 0x00040 /* OFDM channel */
-#define IEEE80211_CHAN_2GHZ 0x00080 /* 2 GHz spectrum channel. */
-#define IEEE80211_CHAN_5GHZ 0x00100 /* 5 GHz spectrum channel */
-#define IEEE80211_CHAN_PASSIVE 0x00200 /* Only passive scan allowed */
-#define IEEE80211_CHAN_DYN 0x00400 /* Dynamic CCK-OFDM channel */
-#define IEEE80211_CHAN_GFSK 0x00800 /* GFSK channel (FHSS PHY) */
-#define IEEE80211_CHAN_GSM 0x01000 /* 900 MHz spectrum channel */
-#define IEEE80211_CHAN_STURBO 0x02000 /* 11a static turbo channel only */
-#define IEEE80211_CHAN_HALF 0x04000 /* Half rate channel */
-#define IEEE80211_CHAN_QUARTER 0x08000 /* Quarter rate channel */
-#define IEEE80211_CHAN_HT20 0x10000 /* HT 20 channel */
-#define IEEE80211_CHAN_HT40U 0x20000 /* HT 40 channel w/ ext above */
-#define IEEE80211_CHAN_HT40D 0x40000 /* HT 40 channel w/ ext below */
-
-/* Useful combinations of channel characteristics, borrowed from Ethereal */
-#define IEEE80211_CHAN_A \
- (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM)
-#define IEEE80211_CHAN_B \
- (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_CCK)
-#define IEEE80211_CHAN_G \
- (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN)
-#define IEEE80211_CHAN_TA \
- (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_TURBO)
-#define IEEE80211_CHAN_TG \
- (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN | IEEE80211_CHAN_TURBO)
-
-
-/* For IEEE80211_RADIOTAP_FLAGS */
-#define IEEE80211_RADIOTAP_F_CFP 0x01 /* sent/received
- * during CFP
- */
-#define IEEE80211_RADIOTAP_F_SHORTPRE 0x02 /* sent/received
- * with short
- * preamble
- */
-#define IEEE80211_RADIOTAP_F_WEP 0x04 /* sent/received
- * with WEP encryption
- */
-#define IEEE80211_RADIOTAP_F_FRAG 0x08 /* sent/received
- * with fragmentation
- */
-#define IEEE80211_RADIOTAP_F_FCS 0x10 /* frame includes FCS */
-#define IEEE80211_RADIOTAP_F_DATAPAD 0x20 /* frame has padding between
- * 802.11 header and payload
- * (to 32-bit boundary)
- */
-#define IEEE80211_RADIOTAP_F_BADFCS 0x40 /* does not pass FCS check */
-
-/* For IEEE80211_RADIOTAP_RX_FLAGS */
-#define IEEE80211_RADIOTAP_F_RX_BADFCS 0x0001 /* frame failed crc check */
-#define IEEE80211_RADIOTAP_F_RX_PLCP_CRC 0x0002 /* frame failed PLCP CRC check */
-
-/* For IEEE80211_RADIOTAP_MCS known */
-#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_KNOWN 0x01
-#define IEEE80211_RADIOTAP_MCS_MCS_INDEX_KNOWN 0x02 /* MCS index field */
-#define IEEE80211_RADIOTAP_MCS_GUARD_INTERVAL_KNOWN 0x04
-#define IEEE80211_RADIOTAP_MCS_HT_FORMAT_KNOWN 0x08
-#define IEEE80211_RADIOTAP_MCS_FEC_TYPE_KNOWN 0x10
-
-/* For IEEE80211_RADIOTAP_MCS flags */
-#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK 0x03
-#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20 0
-#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_40 1
-#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20L 2
-#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20U 3
-#define IEEE80211_RADIOTAP_MCS_SHORT_GI 0x04 /* short guard interval */
-#define IEEE80211_RADIOTAP_MCS_HT_GREENFIELD 0x08
-#define IEEE80211_RADIOTAP_MCS_FEC_LDPC 0x10
-
-#endif /* _NET_IF_IEEE80211RADIOTAP_H_ */
diff --git a/contrib/tcpdump/igrp.h b/contrib/tcpdump/igrp.h
deleted file mode 100644
index b5f133bcb3cd..000000000000
--- a/contrib/tcpdump/igrp.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/igrp.h,v 1.6 2002-12-11 07:13:52 guy Exp $ (LBL) */
-/* Cisco IGRP definitions */
-
-/* IGRP Header */
-
-struct igrphdr {
- u_int8_t ig_vop; /* protocol version number / opcode */
-#define IGRP_V(x) (((x) & 0xf0) >> 4)
-#define IGRP_OP(x) ((x) & 0x0f)
- u_int8_t ig_ed; /* edition number */
- u_int16_t ig_as; /* autonomous system number */
- u_int16_t ig_ni; /* number of subnet in local net */
- u_int16_t ig_ns; /* number of networks in AS */
- u_int16_t ig_nx; /* number of networks ouside AS */
- u_int16_t ig_sum; /* checksum of IGRP header & data */
-};
-
-#define IGRP_UPDATE 1
-#define IGRP_REQUEST 2
-
-/* IGRP routing entry */
-
-struct igrprte {
- u_int8_t igr_net[3]; /* 3 significant octets of IP address */
- u_int8_t igr_dly[3]; /* delay in tens of microseconds */
- u_int8_t igr_bw[3]; /* bandwidth in units of 1 kb/s */
- u_int8_t igr_mtu[2]; /* MTU in octets */
- u_int8_t igr_rel; /* percent packets successfully tx/rx */
- u_int8_t igr_ld; /* percent of channel occupied */
- u_int8_t igr_hct; /* hop count */
-};
-
-#define IGRP_RTE_SIZE 14 /* don't believe sizeof ! */
diff --git a/contrib/tcpdump/in_cksum.c b/contrib/tcpdump/in_cksum.c
index 93cdfc9aad98..171728a88ceb 100644
--- a/contrib/tcpdump/in_cksum.c
+++ b/contrib/tcpdump/in_cksum.c
@@ -35,6 +35,7 @@
* @(#)in_cksum.c 8.1 (Berkeley) 6/10/93
*/
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
@@ -53,27 +54,27 @@
#define ADDCARRY(x) {if ((x) > 65535) (x) -= 65535;}
#define REDUCE {l_util.l = sum; sum = l_util.s[0] + l_util.s[1]; ADDCARRY(sum);}
-u_int16_t
+uint16_t
in_cksum(const struct cksum_vec *vec, int veclen)
{
- register const u_int16_t *w;
+ register const uint16_t *w;
register int sum = 0;
register int mlen = 0;
int byte_swapped = 0;
union {
- u_int8_t c[2];
- u_int16_t s;
+ uint8_t c[2];
+ uint16_t s;
} s_util;
union {
- u_int16_t s[2];
- u_int32_t l;
+ uint16_t s[2];
+ uint32_t l;
} l_util;
for (; veclen != 0; vec++, veclen--) {
if (vec->len == 0)
continue;
- w = (const u_int16_t *)(void *)vec->ptr;
+ w = (const uint16_t *)(void *)vec->ptr;
if (mlen == -1) {
/*
* The first byte of this chunk is the continuation
@@ -83,9 +84,9 @@ in_cksum(const struct cksum_vec *vec, int veclen)
* s_util.c[0] is already saved when scanning previous
* chunk.
*/
- s_util.c[1] = *(const u_int8_t *)w;
+ s_util.c[1] = *(const uint8_t *)w;
sum += s_util.s;
- w = (const u_int16_t *)(void *)((const u_int8_t *)w + 1);
+ w = (const uint16_t *)(void *)((const uint8_t *)w + 1);
mlen = vec->len - 1;
} else
mlen = vec->len;
@@ -95,8 +96,8 @@ in_cksum(const struct cksum_vec *vec, int veclen)
if ((1 & (unsigned long) w) && (mlen > 0)) {
REDUCE;
sum <<= 8;
- s_util.c[0] = *(const u_int8_t *)w;
- w = (const u_int16_t *)(void *)((const u_int8_t *)w + 1);
+ s_util.c[0] = *(const uint8_t *)w;
+ w = (const uint16_t *)(void *)((const uint8_t *)w + 1);
mlen--;
byte_swapped = 1;
}
@@ -128,13 +129,13 @@ in_cksum(const struct cksum_vec *vec, int veclen)
sum <<= 8;
byte_swapped = 0;
if (mlen == -1) {
- s_util.c[1] = *(const u_int8_t *)w;
+ s_util.c[1] = *(const uint8_t *)w;
sum += s_util.s;
mlen = 0;
} else
mlen = -1;
} else if (mlen == -1)
- s_util.c[0] = *(const u_int8_t *)w;
+ s_util.c[0] = *(const uint8_t *)w;
}
if (mlen == -1) {
/* The last mbuf has odd # of bytes. Follow the
@@ -153,10 +154,10 @@ in_cksum(const struct cksum_vec *vec, int veclen)
* that the checksum covers (including the checksum itself), compute
* what the checksum field *should* have been.
*/
-u_int16_t
-in_cksum_shouldbe(u_int16_t sum, u_int16_t computed_sum)
+uint16_t
+in_cksum_shouldbe(uint16_t sum, uint16_t computed_sum)
{
- u_int32_t shouldbe;
+ uint32_t shouldbe;
/*
* The value that should have gone into the checksum field
diff --git a/contrib/tcpdump/install-sh b/contrib/tcpdump/install-sh
index ebc66913e940..b44de0989d2f 100755
--- a/contrib/tcpdump/install-sh
+++ b/contrib/tcpdump/install-sh
@@ -115,7 +115,7 @@ fi
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
-
+
if [ -d $dst ]; then
instcmd=:
else
@@ -124,7 +124,7 @@ if [ x"$dir_arg" != x ]; then
else
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
-# might cause directories to be created, which would be especially bad
+# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if [ -f $src -o -d $src ]
@@ -134,7 +134,7 @@ else
echo "install: $src does not exist"
exit 1
fi
-
+
if [ x"$dst" = x ]
then
echo "install: no destination specified"
@@ -201,17 +201,17 @@ else
# If we're going to rename the final executable, determine the name now.
- if [ x"$transformarg" = x ]
+ if [ x"$transformarg" = x ]
then
dstfile=`basename $dst`
else
- dstfile=`basename $dst $transformbasename |
+ dstfile=`basename $dst $transformbasename |
sed $transformarg`$transformbasename
fi
# don't allow the sed command to completely eliminate the filename
- if [ x"$dstfile" = x ]
+ if [ x"$dstfile" = x ]
then
dstfile=`basename $dst`
else
@@ -242,7 +242,7 @@ else
# Now rename the file to the real destination.
$doit $rmcmd -f $dstdir/$dstfile &&
- $doit $mvcmd $dsttmp $dstdir/$dstfile
+ $doit $mvcmd $dsttmp $dstdir/$dstfile
fi &&
diff --git a/contrib/tcpdump/interface.h b/contrib/tcpdump/interface.h
index 175c33e29024..5efecb80c23e 100644
--- a/contrib/tcpdump/interface.h
+++ b/contrib/tcpdump/interface.h
@@ -17,8 +17,6 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.285 2008-08-16 11:36:20 hannes Exp $ (LBL)
*/
#ifndef tcpdump_interface_h
@@ -38,13 +36,19 @@
#if !defined(HAVE_SNPRINTF)
int snprintf(char *, size_t, const char *, ...)
- __attribute__((format(printf, 3, 4)));
-#endif
+#ifdef __ATTRIBUTE___FORMAT_OK
+ __attribute__((format(printf, 3, 4)))
+#endif /* __ATTRIBUTE___FORMAT_OK */
+ ;
+#endif /* !defined(HAVE_SNPRINTF) */
#if !defined(HAVE_VSNPRINTF)
int vsnprintf(char *, size_t, const char *, va_list)
- __attribute__((format(printf, 3, 0)));
-#endif
+#ifdef __ATTRIBUTE___FORMAT_OK
+ __attribute__((format(printf, 3, 0)))
+#endif /* __ATTRIBUTE___FORMAT_OK */
+ ;
+#endif /* !defined(HAVE_VSNPRINTF) */
#ifndef HAVE_STRLCAT
extern size_t strlcat(char *, const char *, size_t);
@@ -74,13 +78,9 @@ extern char *strsep(char **, const char *);
#define PT_RADIUS 11 /* RADIUS authentication Protocol */
#define PT_ZMTP1 12 /* ZeroMQ Message Transport Protocol 1.0 */
#define PT_VXLAN 13 /* Virtual eXtensible Local Area Network */
-
-#ifndef min
-#define min(a,b) ((a)>(b)?(b):(a))
-#endif
-#ifndef max
-#define max(a,b) ((b)>(a)?(b):(a))
-#endif
+#define PT_PGM 14 /* [UDP-encapsulated] Pragmatic General Multicast */
+#define PT_PGM_ZMTP1 15 /* ZMTP/1.0 inside PGM (native or UDP-encapsulated) */
+#define PT_LMP 16 /* Link Management Protocol */
#define ESRC(ep) ((ep)->ether_shost)
#define EDST(ep) ((ep)->ether_dhost)
@@ -93,10 +93,6 @@ extern char *strsep(char **, const char *);
#endif
#endif
-#ifndef MIN
-#define MIN(a,b) ((a)<(b)?(a):(b))
-#endif
-
extern char *program_name; /* used to generate self-identifying messages */
extern int32_t thiszone; /* seconds offset from gmt to local time */
@@ -121,231 +117,53 @@ extern int32_t thiszone; /* seconds offset from gmt to local time */
/* Bail if "var" was not captured */
#define TCHECK(var) TCHECK2(var, sizeof(var))
-extern void ts_print(const struct timeval *);
-extern void relts_print(int);
-
-extern int fn_print(const u_char *, const u_char *);
-extern int fn_printn(const u_char *, u_int, const u_char *);
-extern int fn_printzp(const u_char *, u_int, const u_char *);
-extern int mask2plen(u_int32_t);
+extern int mask2plen(uint32_t);
extern const char *tok2strary_internal(const char **, int, const char *, int);
#define tok2strary(a,f,i) tok2strary_internal(a, sizeof(a)/sizeof(a[0]),f,i)
-extern const char *dnaddr_string(u_short);
-
extern void error(const char *, ...)
- __attribute__((noreturn, format (printf, 1, 2)));
-extern void warning(const char *, ...) __attribute__ ((format (printf, 1, 2)));
+ __attribute__((noreturn))
+#ifdef __ATTRIBUTE___FORMAT_OK
+ __attribute__((format (printf, 1, 2)))
+#endif /* __ATTRIBUTE___FORMAT_OK */
+ ;
+extern void warning(const char *, ...)
+#ifdef __ATTRIBUTE___FORMAT_OK
+ __attribute__((format (printf, 1, 2)))
+#endif /* __ATTRIBUTE___FORMAT_OK */
+ ;
extern char *read_infile(char *);
extern char *copy_argv(char **);
-extern void safeputchar(int);
-extern void safeputs(const char *, int);
-
-extern const char *isonsap_string(const u_char *, register u_int);
-extern const char *protoid_string(const u_char *);
-extern const char *ipxsap_string(u_short);
extern const char *dnname_string(u_short);
extern const char *dnnum_string(u_short);
/* checksum routines */
extern void init_checksum(void);
-extern u_int16_t verify_crc10_cksum(u_int16_t, const u_char *, int);
-extern u_int16_t create_osi_cksum(const u_int8_t *, int, int);
+extern uint16_t verify_crc10_cksum(uint16_t, const u_char *, int);
+extern uint16_t create_osi_cksum(const uint8_t *, int, int);
/* The printer routines. */
#include <pcap.h>
-extern int print_unknown_data(const u_char *, const char *,int);
-extern void ascii_print(const u_char *, u_int);
-extern void hex_and_ascii_print_with_offset(const char *, const u_char *,
- u_int, u_int);
-extern void hex_and_ascii_print(const char *, const u_char *, u_int);
-extern void hex_print_with_offset(const char *, const u_char *, u_int, u_int);
-extern void hex_print(const char *, const u_char *, u_int);
-extern void telnet_print(const u_char *, u_int);
-extern int llc_print(const u_char *, u_int, u_int, const u_char *,
- const u_char *, u_short *);
-extern int snap_print(const u_char *, u_int, u_int, u_int);
-extern void aarp_print(const u_char *, u_int);
-extern void aodv_print(const u_char *, u_int, int);
-extern void atalk_print(const u_char *, u_int);
-extern void atm_print(u_int, u_int, u_int, const u_char *, u_int, u_int);
-extern u_int atm_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int sunatm_if_print(const struct pcap_pkthdr *, const u_char *);
-extern int oam_print(const u_char *, u_int, u_int);
-extern void bootp_print(const u_char *, u_int);
-extern void bgp_print(const u_char *, int);
-extern void beep_print(const u_char *, u_int);
-extern void cnfp_print(const u_char *, const u_char *);
-extern void decnet_print(const u_char *, u_int, u_int);
-extern void default_print(const u_char *, u_int);
-extern void dvmrp_print(const u_char *, u_int);
-extern void egp_print(const u_char *, u_int);
-extern u_int enc_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int pflog_if_print(const struct pcap_pkthdr *, const u_char *);
extern void pfsync_ip_print(const u_char *, u_int);
-extern u_int arcnet_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int arcnet_linux_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int token_print(const u_char *, u_int, u_int);
-extern u_int token_if_print(const struct pcap_pkthdr *, const u_char *);
-extern void fddi_print(const u_char *, u_int, u_int);
-extern u_int fddi_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int fr_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int mfr_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int fr_print(register const u_char *, u_int);
-extern u_int mfr_print(register const u_char *, u_int);
+
extern char *q922_string(const u_char *);
-extern u_int ieee802_11_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int ieee802_11_radio_if_print(const struct pcap_pkthdr *,
- const u_char *);
-extern u_int ap1394_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int ieee802_11_radio_avs_if_print(const struct pcap_pkthdr *,
- const u_char *);
-extern void gre_print(const u_char *, u_int);
-extern void icmp_print(const u_char *, u_int, const u_char *, int);
-extern void igmp_print(const u_char *, u_int);
-extern void igrp_print(const u_char *, u_int, const u_char *);
-extern void ipN_print(const u_char *, u_int);
-extern u_int ipfc_if_print(const struct pcap_pkthdr *, const u_char *);
-extern void ipx_print(const u_char *, u_int);
-extern void isoclns_print(const u_char *, u_int, u_int);
-extern void krb_print(const u_char *);
-extern u_int llap_print(const u_char *, u_int);
-extern u_int ltalk_if_print(const struct pcap_pkthdr *, const u_char *);
-extern void msdp_print(const unsigned char *, u_int);
-extern void nfsreply_print(const u_char *, u_int, const u_char *);
-extern void nfsreq_print(const u_char *, u_int, const u_char *);
-extern void ns_print(const u_char *, u_int, int);
-extern const u_char * ns_nprint (register const u_char *, register const u_char *);
-extern void ntp_print(const u_char *, u_int);
-extern u_int null_if_print(const struct pcap_pkthdr *, const u_char *);
-extern void ospf_print(const u_char *, u_int, const u_char *);
-extern void olsr_print (const u_char *, u_int, int);
-extern void pimv1_print(const u_char *, u_int);
-extern void cisco_autorp_print(const u_char *, u_int);
-extern void rsvp_print(const u_char *, u_int);
-extern void ldp_print(const u_char *, u_int);
-extern void lldp_print(const u_char *, u_int);
-extern void rpki_rtr_print(const u_char *, u_int);
-extern void lmp_print(const u_char *, u_int);
-extern void lspping_print(const u_char *, u_int);
-extern void lwapp_control_print(const u_char *, u_int, int);
-extern void lwapp_data_print(const u_char *, u_int);
-extern void eigrp_print(const u_char *, u_int);
-extern void mobile_print(const u_char *, u_int);
-extern void pim_print(const u_char *, u_int, u_int);
-extern u_int pppoe_print(const u_char *, u_int);
-extern u_int ppp_print(register const u_char *, u_int);
-extern u_int ppp_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int ppp_hdlc_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int ppp_bsdos_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int pppoe_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int prism_if_print(const struct pcap_pkthdr *, const u_char *);
-extern void q933_print(const u_char *, u_int);
-extern int vjc_print(register const char *, u_short);
-extern void vqp_print(register const u_char *, register u_int);
-extern u_int raw_if_print(const struct pcap_pkthdr *, const u_char *);
-extern void rip_print(const u_char *, u_int);
-extern u_int sl_if_print(const struct pcap_pkthdr *, const u_char *);
-extern void lane_print(const u_char *, u_int, u_int);
-extern u_int lane_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int cip_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int sl_bsdos_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int chdlc_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int chdlc_print(register const u_char *, u_int);
-extern u_int juniper_atm1_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_atm2_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_mfr_print(const struct pcap_pkthdr *, register const u_char *);
-extern u_int juniper_mlfr_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_mlppp_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_pppoe_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_pppoe_atm_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_ggsn_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_es_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_monitor_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_services_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_ether_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_ppp_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_frelay_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_chdlc_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int sll_if_print(const struct pcap_pkthdr *, const u_char *);
-extern void snmp_print(const u_char *, u_int);
-extern void sunrpcrequest_print(const u_char *, u_int, const u_char *);
-extern u_int symantec_if_print(const struct pcap_pkthdr *, const u_char *);
-extern void tcp_print(const u_char *, u_int, const u_char *, int);
-extern void tftp_print(const u_char *, u_int);
-extern void timed_print(const u_char *);
-extern void udld_print(const u_char *, u_int);
-extern void udp_print(const u_char *, u_int, const u_char *, int);
-extern void vtp_print(const u_char *, u_int);
-extern void wb_print(const void *, u_int);
-extern int ah_print(register const u_char *);
-extern int ipcomp_print(register const u_char *, int *);
-extern void rx_print(register const u_char *, int, int, int, u_char *);
-extern void netbeui_print(u_short, const u_char *, int);
-extern void ipx_netbios_print(const u_char *, u_int);
-extern void nbt_tcp_print(const u_char *, int);
-extern void nbt_udp137_print(const u_char *, int);
-extern void nbt_udp138_print(const u_char *, int);
-extern void smb_tcp_print(const u_char *, int);
extern char *smb_errstr(int, int);
-extern const char *nt_errstr(u_int32_t);
-extern void print_data(const unsigned char *, int);
-extern void l2tp_print(const u_char *, u_int);
-extern void vrrp_print(const u_char *, u_int, int);
-extern void carp_print(const u_char *, u_int, int);
-extern void slow_print(const u_char *, u_int);
-extern void sflow_print(const u_char *, u_int);
-extern void mpcp_print(const u_char *, u_int);
-extern void cfm_print(const u_char *, u_int);
-extern void pgm_print(const u_char *, u_int, const u_char *);
-extern void cdp_print(const u_char *, u_int, u_int);
-extern void dtp_print(const u_char *, u_int);
-extern void stp_print(const u_char *, u_int);
-extern void radius_print(const u_char *, u_int);
-extern void lwres_print(const u_char *, u_int);
-extern void pptp_print(const u_char *);
-extern void dccp_print(const u_char *, const u_char *, u_int);
-extern void sctp_print(const u_char *, const u_char *, u_int);
-extern void forces_print(const u_char *, u_int);
-extern void mpls_print(const u_char *, u_int);
-extern void mpls_lsp_ping_print(const u_char *, u_int);
-extern void zephyr_print(const u_char *, int);
-extern void zmtp1_print(const u_char *, u_int);
-extern void hsrp_print(const u_char *, u_int);
-extern void bfd_print(const u_char *, u_int, u_int);
-extern void sip_print(const u_char *, u_int);
-extern void syslog_print(const u_char *, u_int);
-extern u_int bt_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int usb_linux_48_byte_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int usb_linux_64_byte_print(const struct pcap_pkthdr *, const u_char *);
-extern void vxlan_print(const u_char *, u_int);
-extern void otv_print(const u_char *, u_int);
-
+extern const char *nt_errstr(uint32_t);
#ifdef INET6
-extern void ip6_opt_print(const u_char *, int);
-extern int hbhopt_print(const u_char *);
-extern int dstopt_print(const u_char *);
-extern int frag6_print(const u_char *, const u_char *);
-extern int mobility_print(const u_char *, const u_char *);
-extern void ripng_print(const u_char *, unsigned int);
-extern int rt6_print(const u_char *, const u_char *);
-extern void ospf6_print(const u_char *, u_int);
-extern void dhcp6_print(const u_char *, u_int);
-extern void babel_print(const u_char *, u_int);
extern int mask62plen(const u_char *);
#endif /*INET6*/
struct cksum_vec {
- const u_int8_t *ptr;
+ const uint8_t *ptr;
int len;
};
-extern u_int16_t in_cksum(const struct cksum_vec *, int);
-extern u_int16_t in_cksum_shouldbe(u_int16_t, u_int16_t);
+extern uint16_t in_cksum(const struct cksum_vec *, int);
+extern uint16_t in_cksum_shouldbe(uint16_t, uint16_t);
#ifndef HAVE_BPF_DUMP
struct bpf_program;
@@ -361,30 +179,30 @@ extern void bpf_dump(const struct bpf_program *, int);
#ifndef NETDISSECT_REWORKED
extern netdissect_options *gndo;
-#define bflag gndo->ndo_bflag
-#define eflag gndo->ndo_eflag
-#define fflag gndo->ndo_fflag
+#define bflag gndo->ndo_bflag
+#define eflag gndo->ndo_eflag
+#define fflag gndo->ndo_fflag
#define jflag gndo->ndo_jflag
-#define Kflag gndo->ndo_Kflag
-#define nflag gndo->ndo_nflag
-#define Nflag gndo->ndo_Nflag
-#define Oflag gndo->ndo_Oflag
-#define pflag gndo->ndo_pflag
-#define qflag gndo->ndo_qflag
-#define Rflag gndo->ndo_Rflag
-#define sflag gndo->ndo_sflag
-#define Sflag gndo->ndo_Sflag
-#define tflag gndo->ndo_tflag
-#define Uflag gndo->ndo_Uflag
-#define uflag gndo->ndo_uflag
-#define vflag gndo->ndo_vflag
-#define xflag gndo->ndo_xflag
-#define Xflag gndo->ndo_Xflag
-#define Cflag gndo->ndo_Cflag
-#define Gflag gndo->ndo_Gflag
-#define Aflag gndo->ndo_Aflag
-#define Bflag gndo->ndo_Bflag
-#define Iflag gndo->ndo_Iflag
+#define Kflag gndo->ndo_Kflag
+#define nflag gndo->ndo_nflag
+#define Nflag gndo->ndo_Nflag
+#define Oflag gndo->ndo_Oflag
+#define pflag gndo->ndo_pflag
+#define qflag gndo->ndo_qflag
+#define Rflag gndo->ndo_Rflag
+#define sflag gndo->ndo_sflag
+#define Sflag gndo->ndo_Sflag
+#define tflag gndo->ndo_tflag
+#define Uflag gndo->ndo_Uflag
+#define uflag gndo->ndo_uflag
+#define vflag gndo->ndo_vflag
+#define xflag gndo->ndo_xflag
+#define Xflag gndo->ndo_Xflag
+#define Cflag gndo->ndo_Cflag
+#define Gflag gndo->ndo_Gflag
+#define Aflag gndo->ndo_Aflag
+#define Bflag gndo->ndo_Bflag
+#define Iflag gndo->ndo_Iflag
#define suppress_default_print gndo->ndo_suppress_default_print
#define packettype gndo->ndo_packettype
#define sigsecret gndo->ndo_sigsecret
@@ -392,9 +210,11 @@ extern netdissect_options *gndo;
#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 Gflag_time gndo->ndo_Gflag_time
#define Hflag gndo->ndo_Hflag
#define snaplen gndo->ndo_snaplen
#define snapend gndo->ndo_snapend
+extern void default_print(const u_char *, u_int);
+
#endif
diff --git a/contrib/tcpdump/ip.h b/contrib/tcpdump/ip.h
index 8a97632e515f..891a89cd2d4d 100644
--- a/contrib/tcpdump/ip.h
+++ b/contrib/tcpdump/ip.h
@@ -1,4 +1,3 @@
-/* @(#) $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.
@@ -34,6 +33,9 @@
* @(#)ip.h 8.2 (Berkeley) 6/1/94
*/
+#ifndef TCPDUMP_IP_H
+#define TCPDUMP_IP_H
+
/*
* Definitions for internet protocol version 4.
* Per RFC 791, September 1981.
@@ -48,19 +50,19 @@
* against negative integers quite easily, and fail in subtle ways.
*/
struct ip {
- u_int8_t ip_vhl; /* header length, version */
+ uint8_t ip_vhl; /* header length, version */
#define IP_V(ip) (((ip)->ip_vhl & 0xf0) >> 4)
#define IP_HL(ip) ((ip)->ip_vhl & 0x0f)
- u_int8_t ip_tos; /* type of service */
- u_int16_t ip_len; /* total length */
- u_int16_t ip_id; /* identification */
- u_int16_t ip_off; /* fragment offset field */
+ uint8_t ip_tos; /* type of service */
+ uint16_t ip_len; /* total length */
+ uint16_t ip_id; /* identification */
+ uint16_t ip_off; /* fragment offset field */
#define IP_DF 0x4000 /* dont fragment flag */
#define IP_MF 0x2000 /* more fragments flag */
#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
- u_int8_t ip_ttl; /* time to live */
- u_int8_t ip_p; /* protocol */
- u_int16_t ip_sum; /* checksum */
+ uint8_t ip_ttl; /* time to live */
+ uint8_t ip_p; /* protocol */
+ uint16_t ip_sum; /* checksum */
struct in_addr ip_src,ip_dst; /* source and dest address */
} UNALIGNED;
@@ -121,17 +123,17 @@ struct ip {
* Time stamp option structure.
*/
struct ip_timestamp {
- u_int8_t ipt_code; /* IPOPT_TS */
- u_int8_t ipt_len; /* size of structure (variable) */
- u_int8_t ipt_ptr; /* index of current entry */
- u_int8_t ipt_oflwflg; /* flags, overflow counter */
+ uint8_t ipt_code; /* IPOPT_TS */
+ uint8_t ipt_len; /* size of structure (variable) */
+ uint8_t ipt_ptr; /* index of current entry */
+ uint8_t ipt_oflwflg; /* flags, overflow counter */
#define IPTS_OFLW(ip) (((ipt)->ipt_oflwflg & 0xf0) >> 4)
#define IPTS_FLG(ip) ((ipt)->ipt_oflwflg & 0x0f)
union ipt_timestamp {
- u_int32_t ipt_time[1];
+ uint32_t ipt_time[1];
struct ipt_ta {
struct in_addr ipt_addr;
- u_int32_t ipt_time;
+ uint32_t ipt_time;
} ipt_ta[1];
} ipt_timestamp;
} UNALIGNED;
@@ -159,6 +161,4 @@ struct ip_timestamp {
#define IPTTLDEC 1 /* subtracted when forwarding */
#define IP_MSS 576 /* default maximum segment size */
-
-/* in print-ip.c */
-extern int nextproto4_cksum(const struct ip *, const u_int8_t *, u_int, u_int);
+#endif /* TCPDUMP_IP_H */
diff --git a/contrib/tcpdump/ip6.h b/contrib/tcpdump/ip6.h
index 12c87ad29291..1ad914985b62 100644
--- a/contrib/tcpdump/ip6.h
+++ b/contrib/tcpdump/ip6.h
@@ -1,4 +1,3 @@
-/* @(#) $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 $ */
@@ -77,18 +76,19 @@
struct ip6_hdr {
union {
struct ip6_hdrctl {
- u_int32_t ip6_un1_flow; /* 20 bits of flow-ID */
- u_int16_t ip6_un1_plen; /* payload length */
- u_int8_t ip6_un1_nxt; /* next header */
- u_int8_t ip6_un1_hlim; /* hop limit */
+ uint32_t ip6_un1_flow; /* 20 bits of flow-ID */
+ uint16_t ip6_un1_plen; /* payload length */
+ uint8_t ip6_un1_nxt; /* next header */
+ uint8_t ip6_un1_hlim; /* hop limit */
} ip6_un1;
- u_int8_t ip6_un2_vfc; /* 4 bits version, top 4 bits class */
+ uint8_t ip6_un2_vfc; /* 4 bits version, top 4 bits class */
} ip6_ctlun;
struct in6_addr ip6_src; /* source address */
struct in6_addr ip6_dst; /* destination address */
} UNALIGNED;
#define ip6_vfc ip6_ctlun.ip6_un2_vfc
+#define IP6_VERSION(ip6_hdr) (((ip6_hdr)->ip6_vfc & 0xf0) >> 4)
#define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow
#define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen
#define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt
@@ -96,8 +96,8 @@ struct ip6_hdr {
#define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim
/* in network endian */
-#define IPV6_FLOWINFO_MASK ((u_int32_t)htonl(0x0fffffff)) /* flow info (28 bits) */
-#define IPV6_FLOWLABEL_MASK ((u_int32_t)htonl(0x000fffff)) /* flow label (20 bits) */
+#define IPV6_FLOWINFO_MASK ((uint32_t)htonl(0x0fffffff)) /* flow info (28 bits) */
+#define IPV6_FLOWLABEL_MASK ((uint32_t)htonl(0x000fffff)) /* flow label (20 bits) */
#if 1
/* ECN bits proposed by Sally Floyd */
#define IP6TOS_CE 0x01 /* congestion experienced */
@@ -109,29 +109,33 @@ struct ip6_hdr {
*/
struct ip6_ext {
- u_int8_t ip6e_nxt;
- u_int8_t ip6e_len;
+ uint8_t ip6e_nxt;
+ uint8_t ip6e_len;
} UNALIGNED;
/* Hop-by-Hop options header */
struct ip6_hbh {
- u_int8_t ip6h_nxt; /* next header */
- u_int8_t ip6h_len; /* length in units of 8 octets */
+ uint8_t ip6h_nxt; /* next header */
+ uint8_t ip6h_len; /* length in units of 8 octets */
/* followed by options */
} UNALIGNED;
/* Destination options header */
struct ip6_dest {
- u_int8_t ip6d_nxt; /* next header */
- u_int8_t ip6d_len; /* length in units of 8 octets */
+ uint8_t ip6d_nxt; /* next header */
+ uint8_t ip6d_len; /* length in units of 8 octets */
/* followed by options */
} UNALIGNED;
+/* http://www.iana.org/assignments/ipv6-parameters/ipv6-parameters.xhtml */
+
/* Option types and related macros */
#define IP6OPT_PAD1 0x00 /* 00 0 00000 */
#define IP6OPT_PADN 0x01 /* 00 0 00001 */
#define IP6OPT_JUMBO 0xC2 /* 11 0 00010 = 194 */
#define IP6OPT_JUMBO_LEN 6
+#define IP6OPT_RPL 0x63 /* 01 1 00011 */
+#define IP6OPT_TUN_ENC_LIMIT 0x04 /* 00 0 00100 */
#define IP6OPT_ROUTER_ALERT 0x05 /* 00 0 00101 */
#define IP6OPT_RTALERT_LEN 4
@@ -140,11 +144,16 @@ struct ip6_dest {
#define IP6OPT_RTALERT_ACTNET 2 /* contains an Active Networks msg */
#define IP6OPT_MINLEN 2
-#define IP6OPT_BINDING_UPDATE 0xc6 /* 11 0 00110 */
-#define IP6OPT_BINDING_ACK 0x07 /* 00 0 00111 */
-#define IP6OPT_BINDING_REQ 0x08 /* 00 0 01000 */
+#define IP6OPT_QUICK_START 0x26 /* 00 1 00110 */
+#define IP6OPT_CALIPSO 0x07 /* 00 0 00111 */
+#define IP6OPT_SMF_DPD 0x08 /* 00 0 01000 */
#define IP6OPT_HOME_ADDRESS 0xc9 /* 11 0 01001 */
+#define IP6OPT_HOMEADDR_MINLEN 18
#define IP6OPT_EID 0x8a /* 10 0 01010 */
+#define IP6OPT_ILNP_NOTICE 0x8b /* 10 0 01011 */
+#define IP6OPT_LINE_ID 0x8c /* 10 0 01100 */
+#define IP6OPT_MPL 0x6d /* 01 1 01101 */
+#define IP6OPT_IP_DFF 0xee /* 11 1 01110 */
#define IP6OPT_TYPE(o) ((o) & 0xC0)
#define IP6OPT_TYPE_SKIP 0x00
@@ -156,30 +165,30 @@ struct ip6_dest {
/* Routing header */
struct ip6_rthdr {
- u_int8_t ip6r_nxt; /* next header */
- u_int8_t ip6r_len; /* length in units of 8 octets */
- u_int8_t ip6r_type; /* routing type */
- u_int8_t ip6r_segleft; /* segments left */
+ uint8_t ip6r_nxt; /* next header */
+ uint8_t ip6r_len; /* length in units of 8 octets */
+ uint8_t ip6r_type; /* routing type */
+ uint8_t ip6r_segleft; /* segments left */
/* followed by routing type specific data */
} UNALIGNED;
/* Type 0 Routing header */
struct ip6_rthdr0 {
- u_int8_t ip6r0_nxt; /* next header */
- u_int8_t ip6r0_len; /* length in units of 8 octets */
- u_int8_t ip6r0_type; /* always zero */
- u_int8_t ip6r0_segleft; /* segments left */
- u_int8_t ip6r0_reserved; /* reserved field */
- u_int8_t ip6r0_slmap[3]; /* strict/loose bit map */
+ uint8_t ip6r0_nxt; /* next header */
+ uint8_t ip6r0_len; /* length in units of 8 octets */
+ uint8_t ip6r0_type; /* always zero */
+ uint8_t ip6r0_segleft; /* segments left */
+ uint8_t ip6r0_reserved; /* reserved field */
+ uint8_t ip6r0_slmap[3]; /* strict/loose bit map */
struct in6_addr ip6r0_addr[1]; /* up to 23 addresses */
} UNALIGNED;
/* Fragment header */
struct ip6_frag {
- u_int8_t ip6f_nxt; /* next header */
- u_int8_t ip6f_reserved; /* reserved field */
- u_int16_t ip6f_offlg; /* offset, reserved, and flag */
- u_int32_t ip6f_ident; /* identification */
+ uint8_t ip6f_nxt; /* next header */
+ uint8_t ip6f_reserved; /* reserved field */
+ uint16_t ip6f_offlg; /* offset, reserved, and flag */
+ uint32_t ip6f_ident; /* identification */
} UNALIGNED;
#define IP6F_OFF_MASK 0xfff8 /* mask out offset from ip6f_offlg */
@@ -187,6 +196,6 @@ struct ip6_frag {
#define IP6F_MORE_FRAG 0x0001 /* more-fragments flag */
/* in print-ip6.c */
-extern int nextproto6_cksum(const struct ip6_hdr *, const u_int8_t *, u_int, u_int);
+extern int nextproto6_cksum(const struct ip6_hdr *, const uint8_t *, u_int, u_int, u_int);
#endif /* not _NETINET_IP6_H_ */
diff --git a/contrib/tcpdump/ipfc.h b/contrib/tcpdump/ipfc.h
deleted file mode 100644
index 438d1156446a..000000000000
--- a/contrib/tcpdump/ipfc.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 1992, 1993, 1994, 1995, 1996
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that: (1) source code distributions
- * retain the above copyright notice and this paragraph in its entirety, (2)
- * distributions including binary code include the above copyright notice and
- * this paragraph in its entirety in the documentation or other materials
- * provided with the distribution, and (3) all advertising materials mentioning
- * features or use of this software display the following acknowledgement:
- * ``This product includes software developed by the University of California,
- * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
- * the University nor the names of its contributors may be used to endorse
- * or promote products derived from this software without specific prior
- * written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/ipfc.h,v 1.4 2002-12-11 07:13:53 guy Exp $ (LBL)
- */
-
-struct ipfc_header {
- u_char ipfc_dhost[8];
- u_char ipfc_shost[8];
-};
-
-#define IPFC_HDRLEN 16
diff --git a/contrib/tcpdump/ipnet.h b/contrib/tcpdump/ipnet.h
deleted file mode 100644
index ae692842e3b8..000000000000
--- a/contrib/tcpdump/ipnet.h
+++ /dev/null
@@ -1,13 +0,0 @@
-typedef struct ipnet_hdr {
- uint8_t iph_version;
- uint8_t iph_family;
- uint16_t iph_htype;
- uint32_t iph_pktlen;
- uint32_t iph_ifindex;
- uint32_t iph_grifindex;
- uint32_t iph_zsrc;
- uint32_t iph_zdst;
-} ipnet_hdr_t;
-
-#define IPH_AF_INET 2 /* Matches Solaris's AF_INET */
-#define IPH_AF_INET6 26 /* Matches Solaris's AF_INET6 */
diff --git a/contrib/tcpdump/ipproto.c b/contrib/tcpdump/ipproto.c
index e5d328c6edc3..8300d1a5b6c3 100644
--- a/contrib/tcpdump/ipproto.c
+++ b/contrib/tcpdump/ipproto.c
@@ -1,4 +1,4 @@
-/*
+/*
* 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
@@ -13,11 +13,7 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/ipproto.c,v 1.6 2005-09-20 06:01:22 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
diff --git a/contrib/tcpdump/ipproto.h b/contrib/tcpdump/ipproto.h
index 4b6bf51cfc15..87e2f1533b43 100644
--- a/contrib/tcpdump/ipproto.h
+++ b/contrib/tcpdump/ipproto.h
@@ -30,8 +30,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/ipproto.h,v 1.6 2005-09-20 06:01:22 guy Exp $ (LBL)
- *
* From:
* @(#)in.h 8.3 (Berkeley) 1/3/94
* $FreeBSD$
diff --git a/contrib/tcpdump/ipsec_doi.h b/contrib/tcpdump/ipsec_doi.h
deleted file mode 100644
index 554a2586a0a3..000000000000
--- a/contrib/tcpdump/ipsec_doi.h
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-/* YIPS @(#)$Id: ipsec_doi.h,v 1.7 2002-12-11 07:13:53 guy Exp $ */
-
-/* refer to RFC 2407 */
-
-#if !defined(_IPSEC_DOI_H_)
-#define _IPSEC_DOI_H_
-
-#define IPSEC_DOI 1
-
-/* 4.2 IPSEC Situation Definition */
-#define IPSECDOI_SIT_IDENTITY_ONLY 0x00000001
-#define IPSECDOI_SIT_SECRECY 0x00000002
-#define IPSECDOI_SIT_INTEGRITY 0x00000004
-
-/* 4.4.1 IPSEC Security Protocol Identifiers */
- /* 4.4.2 IPSEC ISAKMP Transform Values */
-#define IPSECDOI_PROTO_ISAKMP 1
-#define IPSECDOI_KEY_IKE 1
-
-/* 4.4.1 IPSEC Security Protocol Identifiers */
-#define IPSECDOI_PROTO_IPSEC_AH 2
- /* 4.4.3 IPSEC AH Transform Values */
-#define IPSECDOI_AH_MD5 2
-#define IPSECDOI_AH_SHA 3
-#define IPSECDOI_AH_DES 4
-#define IPSECDOI_AH_SHA2_256 5
-#define IPSECDOI_AH_SHA2_384 6
-#define IPSECDOI_AH_SHA2_512 7
-
-/* 4.4.1 IPSEC Security Protocol Identifiers */
-#define IPSECDOI_PROTO_IPSEC_ESP 3
- /* 4.4.4 IPSEC ESP Transform Identifiers */
-#define IPSECDOI_ESP_DES_IV64 1
-#define IPSECDOI_ESP_DES 2
-#define IPSECDOI_ESP_3DES 3
-#define IPSECDOI_ESP_RC5 4
-#define IPSECDOI_ESP_IDEA 5
-#define IPSECDOI_ESP_CAST 6
-#define IPSECDOI_ESP_BLOWFISH 7
-#define IPSECDOI_ESP_3IDEA 8
-#define IPSECDOI_ESP_DES_IV32 9
-#define IPSECDOI_ESP_RC4 10
-#define IPSECDOI_ESP_NULL 11
-#define IPSECDOI_ESP_RIJNDAEL 12
-#define IPSECDOI_ESP_AES 12
-
-/* 4.4.1 IPSEC Security Protocol Identifiers */
-#define IPSECDOI_PROTO_IPCOMP 4
- /* 4.4.5 IPSEC IPCOMP Transform Identifiers */
-#define IPSECDOI_IPCOMP_OUI 1
-#define IPSECDOI_IPCOMP_DEFLATE 2
-#define IPSECDOI_IPCOMP_LZS 3
-
-/* 4.5 IPSEC Security Association Attributes */
-#define IPSECDOI_ATTR_SA_LTYPE 1 /* B */
-#define IPSECDOI_ATTR_SA_LTYPE_DEFAULT 1
-#define IPSECDOI_ATTR_SA_LTYPE_SEC 1
-#define IPSECDOI_ATTR_SA_LTYPE_KB 2
-#define IPSECDOI_ATTR_SA_LDUR 2 /* V */
-#define IPSECDOI_ATTR_SA_LDUR_DEFAULT 28800 /* 8 hours */
-#define IPSECDOI_ATTR_GRP_DESC 3 /* B */
-#define IPSECDOI_ATTR_ENC_MODE 4 /* B */
- /* default value: host dependent */
-#define IPSECDOI_ATTR_ENC_MODE_TUNNEL 1
-#define IPSECDOI_ATTR_ENC_MODE_TRNS 2
-#define IPSECDOI_ATTR_AUTH 5 /* B */
- /* 0 means not to use authentication. */
-#define IPSECDOI_ATTR_AUTH_HMAC_MD5 1
-#define IPSECDOI_ATTR_AUTH_HMAC_SHA1 2
-#define IPSECDOI_ATTR_AUTH_DES_MAC 3
-#define IPSECDOI_ATTR_AUTH_KPDK 4 /*RFC-1826(Key/Pad/Data/Key)*/
- /*
- * When negotiating ESP without authentication, the Auth
- * Algorithm attribute MUST NOT be included in the proposal.
- * When negotiating ESP without confidentiality, the Auth
- * Algorithm attribute MUST be included in the proposal and
- * the ESP transform ID must be ESP_NULL.
- */
-#define IPSECDOI_ATTR_KEY_LENGTH 6 /* B */
-#define IPSECDOI_ATTR_KEY_ROUNDS 7 /* B */
-#define IPSECDOI_ATTR_COMP_DICT_SIZE 8 /* B */
-#define IPSECDOI_ATTR_COMP_PRIVALG 9 /* V */
-
-/* 4.6.1 Security Association Payload */
-struct ipsecdoi_sa {
- struct isakmp_gen h;
- u_int32_t doi; /* Domain of Interpretation */
- u_int32_t sit; /* Situation */
-};
-
-struct ipsecdoi_secrecy_h {
- u_int16_t len;
- u_int16_t reserved;
-};
-
-/* 4.6.2.1 Identification Type Values */
-struct ipsecdoi_id {
- struct isakmp_gen h;
- u_int8_t type; /* ID Type */
- u_int8_t proto_id; /* Protocol ID */
- u_int16_t port; /* Port */
- /* Identification Data */
-};
-
-#define IPSECDOI_ID_IPV4_ADDR 1
-#define IPSECDOI_ID_FQDN 2
-#define IPSECDOI_ID_USER_FQDN 3
-#define IPSECDOI_ID_IPV4_ADDR_SUBNET 4
-#define IPSECDOI_ID_IPV6_ADDR 5
-#define IPSECDOI_ID_IPV6_ADDR_SUBNET 6
-#define IPSECDOI_ID_IPV4_ADDR_RANGE 7
-#define IPSECDOI_ID_IPV6_ADDR_RANGE 8
-#define IPSECDOI_ID_DER_ASN1_DN 9
-#define IPSECDOI_ID_DER_ASN1_GN 10
-#define IPSECDOI_ID_KEY_ID 11
-
-/* 4.6.3 IPSEC DOI Notify Message Types */
-/* Notify Messages - Status Types */
-#define IPSECDOI_NTYPE_RESPONDER_LIFETIME 24576
-#define IPSECDOI_NTYPE_REPLAY_STATUS 24577
-#define IPSECDOI_NTYPE_INITIAL_CONTACT 24578
-
-#endif /* !defined(_IPSEC_DOI_H_) */
diff --git a/contrib/tcpdump/ipx.h b/contrib/tcpdump/ipx.h
deleted file mode 100644
index bfc301980d18..000000000000
--- a/contrib/tcpdump/ipx.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * IPX protocol formats
- *
- * @(#) $Header: /tcpdump/master/tcpdump/ipx.h,v 1.8 2002-12-11 07:13:54 guy Exp $
- */
-
-/* well-known sockets */
-#define IPX_SKT_NCP 0x0451
-#define IPX_SKT_SAP 0x0452
-#define IPX_SKT_RIP 0x0453
-#define IPX_SKT_NETBIOS 0x0455
-#define IPX_SKT_DIAGNOSTICS 0x0456
-#define IPX_SKT_NWLINK_DGM 0x0553 /* NWLink datagram, may contain SMB */
-#define IPX_SKT_EIGRP 0x85be /* Cisco EIGRP over IPX */
-
-/* IPX transport header */
-struct ipxHdr {
- u_int16_t cksum; /* Checksum */
- u_int16_t length; /* Length, in bytes, including header */
- u_int8_t tCtl; /* Transport Control (i.e. hop count) */
- u_int8_t pType; /* Packet Type (i.e. level 2 protocol) */
- u_int16_t dstNet[2]; /* destination net */
- u_int8_t dstNode[6]; /* destination node */
- u_int16_t dstSkt; /* destination socket */
- u_int16_t srcNet[2]; /* source net */
- u_int8_t srcNode[6]; /* source node */
- u_int16_t srcSkt; /* source socket */
-};
-
-#define ipxSize 30
-
diff --git a/contrib/tcpdump/isakmp.h b/contrib/tcpdump/isakmp.h
deleted file mode 100644
index d628f7ae32fc..000000000000
--- a/contrib/tcpdump/isakmp.h
+++ /dev/null
@@ -1,501 +0,0 @@
-/*
- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-/* YIPS @(#)$Id: isakmp.h,v 1.12 2007-11-24 18:13:33 mcr Exp $ */
-
-/* refer to RFC 2408 */
-
-/* must include <netinet/in.h> */
-
-#if !defined(_ISAKMP_H_)
-#define _ISAKMP_H_
-
-typedef u_char cookie_t[8];
-typedef u_char msgid_t[4];
-
-typedef struct { /* i_cookie + r_cookie */
- cookie_t i_ck;
- cookie_t r_ck;
-} isakmp_index;
-
-#define INITIATOR 1
-#define RESPONDER 2
-
-#define PORT_ISAKMP 500
-
-#define GENERATE 1
-#define VALIDATE 0
-
-/* Phase of oakley definition */
-/*
- 0000 0000 0000 0000
- | |||| ||||
- | |||| ++++--> negosiation number in phase
- | ++++-------> phase number
- +---------------> expire ?
- */
-#define ISAKMP_PH1 0x0010
-#define ISAKMP_PH2 0x0020
-#define ISAKMP_EXPIRED 0x0100
-
-#define ISAKMP_NGP_0 0x0000
-#define ISAKMP_NGP_1 0x0001
-#define ISAKMP_NGP_2 0x0002
-#define ISAKMP_NGP_3 0x0003
-#define ISAKMP_NGP_4 0x0004
-
-#define ISAKMP_PH1_N (ISAKMP_PH1 | ISAKMP_NGP_0) /* i.e. spawn */
-#define ISAKMP_PH1_1 (ISAKMP_PH1 | ISAKMP_NGP_1)
-#define ISAKMP_PH1_2 (ISAKMP_PH1 | ISAKMP_NGP_2)
-#define ISAKMP_PH1_3 (ISAKMP_PH1 | ISAKMP_NGP_3)
-#define ISAKMP_PH2_N (ISAKMP_PH2 | ISAKMP_NGP_0)
-#define ISAKMP_PH2_1 (ISAKMP_PH2 | ISAKMP_NGP_1)
-#define ISAKMP_PH2_2 (ISAKMP_PH2 | ISAKMP_NGP_2)
-#define ISAKMP_PH2_3 (ISAKMP_PH2 | ISAKMP_NGP_3)
-
-#define ISAKMP_TIMER_DEFAULT 10 /* seconds */
-#define ISAKMP_TRY_DEFAULT 3 /* times */
-
-/* 3.1 ISAKMP Header Format (IKEv1 and IKEv2)
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- ! Initiator !
- ! Cookie !
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- ! Responder !
- ! Cookie !
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- ! Next Payload ! MjVer ! MnVer ! Exchange Type ! Flags !
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- ! Message ID !
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- ! Length !
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-*/
-struct isakmp {
- cookie_t i_ck; /* Initiator Cookie */
- cookie_t r_ck; /* Responder Cookie */
- u_int8_t np; /* Next Payload Type */
- u_int8_t vers;
-#define ISAKMP_VERS_MAJOR 0xf0
-#define ISAKMP_VERS_MAJOR_SHIFT 4
-#define ISAKMP_VERS_MINOR 0x0f
-#define ISAKMP_VERS_MINOR_SHIFT 0
- u_int8_t etype; /* Exchange Type */
- u_int8_t flags; /* Flags */
- msgid_t msgid;
- u_int32_t len; /* Length */
-};
-
-/* Next Payload Type */
-#define ISAKMP_NPTYPE_NONE 0 /* NONE*/
-#define ISAKMP_NPTYPE_SA 1 /* Security Association */
-#define ISAKMP_NPTYPE_P 2 /* Proposal */
-#define ISAKMP_NPTYPE_T 3 /* Transform */
-#define ISAKMP_NPTYPE_KE 4 /* Key Exchange */
-#define ISAKMP_NPTYPE_ID 5 /* Identification */
-#define ISAKMP_NPTYPE_CERT 6 /* Certificate */
-#define ISAKMP_NPTYPE_CR 7 /* Certificate Request */
-#define ISAKMP_NPTYPE_HASH 8 /* Hash */
-#define ISAKMP_NPTYPE_SIG 9 /* Signature */
-#define ISAKMP_NPTYPE_NONCE 10 /* Nonce */
-#define ISAKMP_NPTYPE_N 11 /* Notification */
-#define ISAKMP_NPTYPE_D 12 /* Delete */
-#define ISAKMP_NPTYPE_VID 13 /* Vendor ID */
-#define ISAKMP_NPTYPE_v2E 46 /* v2 Encrypted payload */
-
-#define IKEv1_MAJOR_VERSION 1
-#define IKEv1_MINOR_VERSION 0
-
-#define IKEv2_MAJOR_VERSION 2
-#define IKEv2_MINOR_VERSION 0
-
-/* Exchange Type */
-#define ISAKMP_ETYPE_NONE 0 /* NONE */
-#define ISAKMP_ETYPE_BASE 1 /* Base */
-#define ISAKMP_ETYPE_IDENT 2 /* Identity Proteciton */
-#define ISAKMP_ETYPE_AUTH 3 /* Authentication Only */
-#define ISAKMP_ETYPE_AGG 4 /* Aggressive */
-#define ISAKMP_ETYPE_INF 5 /* Informational */
-
-/* Flags */
-#define ISAKMP_FLAG_E 0x01 /* Encryption Bit */
-#define ISAKMP_FLAG_C 0x02 /* Commit Bit */
-#define ISAKMP_FLAG_extra 0x04
-
-/* IKEv2 */
-#define ISAKMP_FLAG_I (1 << 3) /* (I)nitiator */
-#define ISAKMP_FLAG_V (1 << 4) /* (V)ersion */
-#define ISAKMP_FLAG_R (1 << 5) /* (R)esponse */
-
-
-/* 3.2 Payload Generic Header
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- ! Next Payload ! RESERVED ! Payload Length !
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-*/
-struct isakmp_gen {
- u_int8_t np; /* Next Payload */
- u_int8_t critical; /* bit 7 - critical, rest is RESERVED */
- u_int16_t len; /* Payload Length */
-};
-
-/* 3.3 Data Attributes
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- !A! Attribute Type ! AF=0 Attribute Length !
- !F! ! AF=1 Attribute Value !
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- . AF=0 Attribute Value .
- . AF=1 Not Transmitted .
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-*/
-struct isakmp_data {
- u_int16_t type; /* defined by DOI-spec, and Attribute Format */
- u_int16_t lorv; /* if f equal 1, Attribute Length */
- /* if f equal 0, Attribute Value */
- /* if f equal 1, Attribute Value */
-};
-#define ISAKMP_GEN_TLV 0x0000
-#define ISAKMP_GEN_TV 0x8000
- /* mask for type of attribute format */
-#define ISAKMP_GEN_MASK 0x8000
-
-/* 3.4 Security Association Payload */
- /* MAY NOT be used, because of being defined in ipsec-doi. */
- /*
- If the current payload is the last in the message,
- then the value of the next payload field will be 0.
- This field MUST NOT contain the
- values for the Proposal or Transform payloads as they are considered
- part of the security association negotiation. For example, this
- field would contain the value "10" (Nonce payload) in the first
- message of a Base Exchange (see Section 4.4) and the value "0" in the
- first message of an Identity Protect Exchange (see Section 4.5).
- */
-struct ikev1_pl_sa {
- struct isakmp_gen h;
- u_int32_t doi; /* Domain of Interpretation */
- u_int32_t sit; /* Situation */
-};
-
-/* 3.5 Proposal Payload */
- /*
- The value of the next payload field MUST only contain the value "2"
- or "0". If there are additional Proposal payloads in the message,
- then this field will be 2. If the current Proposal payload is the
- last within the security association proposal, then this field will
- be 0.
- */
-struct ikev1_pl_p {
- struct isakmp_gen h;
- u_int8_t p_no; /* Proposal # */
- u_int8_t prot_id; /* Protocol */
- u_int8_t spi_size; /* SPI Size */
- u_int8_t num_t; /* Number of Transforms */
- /* SPI */
-};
-
-/* 3.6 Transform Payload */
- /*
- The value of the next payload field MUST only contain the value "3"
- or "0". If there are additional Transform payloads in the proposal,
- then this field will be 3. If the current Transform payload is the
- last within the proposal, then this field will be 0.
- */
-struct ikev1_pl_t {
- struct isakmp_gen h;
- u_int8_t t_no; /* Transform # */
- u_int8_t t_id; /* Transform-Id */
- u_int16_t reserved; /* RESERVED2 */
- /* SA Attributes */
-};
-
-/* 3.7 Key Exchange Payload */
-struct ikev1_pl_ke {
- struct isakmp_gen h;
- /* Key Exchange Data */
-};
-
-/* 3.8 Identification Payload */
- /* MUST NOT to be used, because of being defined in ipsec-doi. */
-struct ikev1_pl_id {
- struct isakmp_gen h;
- union {
- u_int8_t id_type; /* ID Type */
- u_int32_t doi_data; /* DOI Specific ID Data */
- } d;
- /* Identification Data */
-};
-
-/* 3.9 Certificate Payload */
-struct ikev1_pl_cert {
- struct isakmp_gen h;
- u_int8_t encode; /* Cert Encoding */
- char cert; /* Certificate Data */
- /*
- This field indicates the type of
- certificate or certificate-related information contained in the
- Certificate Data field.
- */
-};
-
-/* Certificate Type */
-#define ISAKMP_CERT_NONE 0
-#define ISAKMP_CERT_PKCS 1
-#define ISAKMP_CERT_PGP 2
-#define ISAKMP_CERT_DNS 3
-#define ISAKMP_CERT_SIGN 4
-#define ISAKMP_CERT_KE 5
-#define ISAKMP_CERT_KT 6
-#define ISAKMP_CERT_CRL 7
-#define ISAKMP_CERT_ARL 8
-#define ISAKMP_CERT_SPKI 9
-
-/* 3.10 Certificate Request Payload */
-struct ikev1_pl_cr {
- struct isakmp_gen h;
- u_int8_t num_cert; /* # Cert. Types */
- /*
- Certificate Types (variable length)
- -- Contains a list of the types of certificates requested,
- sorted in order of preference. Each individual certificate
- type is 1 octet. This field is NOT requiredo
- */
- /* # Certificate Authorities (1 octet) */
- /* Certificate Authorities (variable length) */
-};
-
-/* 3.11 Hash Payload */
- /* may not be used, because of having only data. */
-struct ikev1_pl_hash {
- struct isakmp_gen h;
- /* Hash Data */
-};
-
-/* 3.12 Signature Payload */
- /* may not be used, because of having only data. */
-struct ikev1_pl_sig {
- struct isakmp_gen h;
- /* Signature Data */
-};
-
-/* 3.13 Nonce Payload */
- /* may not be used, because of having only data. */
-struct ikev1_pl_nonce {
- struct isakmp_gen h;
- /* Nonce Data */
-};
-
-/* 3.14 Notification Payload */
-struct ikev1_pl_n {
- struct isakmp_gen h;
- u_int32_t doi; /* Domain of Interpretation */
- u_int8_t prot_id; /* Protocol-ID */
- u_int8_t spi_size; /* SPI Size */
- u_int16_t type; /* Notify Message Type */
- /* SPI */
- /* Notification Data */
-};
-
-/* 3.14.1 Notify Message Types */
-/* NOTIFY MESSAGES - ERROR TYPES */
-#define ISAKMP_NTYPE_INVALID_PAYLOAD_TYPE 1
-#define ISAKMP_NTYPE_DOI_NOT_SUPPORTED 2
-#define ISAKMP_NTYPE_SITUATION_NOT_SUPPORTED 3
-#define ISAKMP_NTYPE_INVALID_COOKIE 4
-#define ISAKMP_NTYPE_INVALID_MAJOR_VERSION 5
-#define ISAKMP_NTYPE_INVALID_MINOR_VERSION 6
-#define ISAKMP_NTYPE_INVALID_EXCHANGE_TYPE 7
-#define ISAKMP_NTYPE_INVALID_FLAGS 8
-#define ISAKMP_NTYPE_INVALID_MESSAGE_ID 9
-#define ISAKMP_NTYPE_INVALID_PROTOCOL_ID 10
-#define ISAKMP_NTYPE_INVALID_SPI 11
-#define ISAKMP_NTYPE_INVALID_TRANSFORM_ID 12
-#define ISAKMP_NTYPE_ATTRIBUTES_NOT_SUPPORTED 13
-#define ISAKMP_NTYPE_NO_PROPOSAL_CHOSEN 14
-#define ISAKMP_NTYPE_BAD_PROPOSAL_SYNTAX 15
-#define ISAKMP_NTYPE_PAYLOAD_MALFORMED 16
-#define ISAKMP_NTYPE_INVALID_KEY_INFORMATION 17
-#define ISAKMP_NTYPE_INVALID_ID_INFORMATION 18
-#define ISAKMP_NTYPE_INVALID_CERT_ENCODING 19
-#define ISAKMP_NTYPE_INVALID_CERTIFICATE 20
-#define ISAKMP_NTYPE_BAD_CERT_REQUEST_SYNTAX 21
-#define ISAKMP_NTYPE_INVALID_CERT_AUTHORITY 22
-#define ISAKMP_NTYPE_INVALID_HASH_INFORMATION 23
-#define ISAKMP_NTYPE_AUTHENTICATION_FAILED 24
-#define ISAKMP_NTYPE_INVALID_SIGNATURE 25
-#define ISAKMP_NTYPE_ADDRESS_NOTIFICATION 26
-/* NOTIFY MESSAGES - STATUS TYPES */
-#define ISAKMP_NTYPE_CONNECTED 16384
-/* using only to log */
-#define ISAKMP_LOG_RETRY_LIMIT_REACHED 65530
-
-/* 3.15 Delete Payload */
-struct ikev1_pl_d {
- struct isakmp_gen h;
- u_int32_t doi; /* Domain of Interpretation */
- u_int8_t prot_id; /* Protocol-Id */
- u_int8_t spi_size; /* SPI Size */
- u_int16_t num_spi; /* # of SPIs */
- /* SPI(es) */
-};
-
-
-struct ikev1_ph1tab {
- struct ikev1_ph1 *head;
- struct ikev1_ph1 *tail;
- int len;
-};
-
-struct isakmp_ph2tab {
- struct ikev1_ph2 *head;
- struct ikev1_ph2 *tail;
- int len;
-};
-
-#define EXCHANGE_PROXY 1
-#define EXCHANGE_MYSELF 0
-
-#define PFS_NEED 1
-#define PFS_NONEED 0
-
-/* IKEv2 (RFC4306) */
-
-/* 3.3 Security Association Payload -- generic header */
-/* 3.3.1. Proposal Substructure */
-struct ikev2_p {
- struct isakmp_gen h;
- u_int8_t p_no; /* Proposal # */
- u_int8_t prot_id; /* Protocol */
- u_int8_t spi_size; /* SPI Size */
- u_int8_t num_t; /* Number of Transforms */
-};
-
-/* 3.3.2. Transform Substructure */
-struct ikev2_t {
- struct isakmp_gen h;
- u_int8_t t_type; /* Transform Type (ENCR,PRF,INTEG,etc.*/
- u_int8_t res2; /* reserved byte */
- u_int16_t t_id; /* Transform ID */
-};
-
-enum ikev2_t_type {
- IV2_T_ENCR = 1,
- IV2_T_PRF = 2,
- IV2_T_INTEG= 3,
- IV2_T_DH = 4,
- IV2_T_ESN = 5,
-};
-
-/* 3.4. Key Exchange Payload */
-struct ikev2_ke {
- struct isakmp_gen h;
- u_int16_t ke_group;
- u_int16_t ke_res1;
- /* KE data */
-};
-
-
-/* 3.5. Identification Payloads */
-enum ikev2_id_type {
- ID_IPV4_ADDR=1,
- ID_FQDN=2,
- ID_RFC822_ADDR=3,
- ID_IPV6_ADDR=5,
- ID_DER_ASN1_DN=9,
- ID_DER_ASN1_GN=10,
- ID_KEY_ID=11,
-};
-struct ikev2_id {
- struct isakmp_gen h;
- u_int8_t type; /* ID type */
- u_int8_t res1;
- u_int16_t res2;
- /* SPI */
- /* Notification Data */
-};
-
-/* 3.10 Notification Payload */
-struct ikev2_n {
- struct isakmp_gen h;
- u_int8_t prot_id; /* Protocol-ID */
- u_int8_t spi_size; /* SPI Size */
- u_int16_t type; /* Notify Message Type */
-};
-
-enum ikev2_n_type {
- IV2_NOTIFY_UNSUPPORTED_CRITICAL_PAYLOAD = 1,
- IV2_NOTIFY_INVALID_IKE_SPI = 4,
- IV2_NOTIFY_INVALID_MAJOR_VERSION = 5,
- IV2_NOTIFY_INVALID_SYNTAX = 7,
- IV2_NOTIFY_INVALID_MESSAGE_ID = 9,
- IV2_NOTIFY_INVALID_SPI =11,
- IV2_NOTIFY_NO_PROPOSAL_CHOSEN =14,
- IV2_NOTIFY_INVALID_KE_PAYLOAD =17,
- IV2_NOTIFY_AUTHENTICATION_FAILED =24,
- IV2_NOTIFY_SINGLE_PAIR_REQUIRED =34,
- IV2_NOTIFY_NO_ADDITIONAL_SAS =35,
- IV2_NOTIFY_INTERNAL_ADDRESS_FAILURE =36,
- IV2_NOTIFY_FAILED_CP_REQUIRED =37,
- IV2_NOTIFY_INVALID_SELECTORS =39,
- IV2_NOTIFY_INITIAL_CONTACT =16384,
- IV2_NOTIFY_SET_WINDOW_SIZE =16385,
- IV2_NOTIFY_ADDITIONAL_TS_POSSIBLE =16386,
- IV2_NOTIFY_IPCOMP_SUPPORTED =16387,
- IV2_NOTIFY_NAT_DETECTION_SOURCE_IP =16388,
- IV2_NOTIFY_NAT_DETECTION_DESTINATION_IP =16389,
- IV2_NOTIFY_COOKIE =16390,
- IV2_NOTIFY_USE_TRANSPORT_MODE =16391,
- IV2_NOTIFY_HTTP_CERT_LOOKUP_SUPPORTED =16392,
- IV2_NOTIFY_REKEY_SA =16393,
- IV2_NOTIFY_ESP_TFC_PADDING_NOT_SUPPORTED =16394,
- IV2_NOTIFY_NON_FIRST_FRAGMENTS_ALSO =16395
-};
-
-struct notify_messages {
- u_int16_t type;
- char *msg;
-};
-
-/* 3.8 Notification Payload */
-struct ikev2_auth {
- struct isakmp_gen h;
- u_int8_t auth_method; /* Protocol-ID */
- u_int8_t reserved[3];
- /* authentication data */
-};
-
-enum ikev2_auth_type {
- IV2_RSA_SIG = 1,
- IV2_SHARED = 2,
- IV2_DSS_SIG = 3,
-};
-
-#endif /* !defined(_ISAKMP_H_) */
diff --git a/contrib/tcpdump/l2tp.h b/contrib/tcpdump/l2tp.h
deleted file mode 100644
index 5be24b9fc5af..000000000000
--- a/contrib/tcpdump/l2tp.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/l2tp.h,v 1.5 2001-11-05 10:03:27 guy Exp $ (LBL) */
-/*
- * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that: (1) source code distributions
- * retain the above copyright notice and this paragraph in its entirety, (2)
- * distributions including binary code include the above copyright notice and
- * this paragraph in its entirety in the documentation or other materials
- * provided with the distribution, and (3) all advertising materials mentioning
- * features or use of this software display the following acknowledgement:
- * ``This product includes software developed by the University of California,
- * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
- * the University nor the names of its contributors may be used to endorse
- * or promote products derived from this software without specific prior
- * written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * L2TP support contributed by Motonori Shindo (mshindo@mshindo.net)
- */
-
-
-#define L2TP_FLAG_TYPE 0x8000 /* Type (0=Data, 1=Control) */
-#define L2TP_FLAG_LENGTH 0x4000 /* Length */
-#define L2TP_FLAG_SEQUENCE 0x0800 /* Sequence */
-#define L2TP_FLAG_OFFSET 0x0200 /* Offset */
-#define L2TP_FLAG_PRIORITY 0x0100 /* Priority */
-
-#define L2TP_VERSION_MASK 0x000f /* Version Mask */
-#define L2TP_VERSION_L2F 0x0001 /* L2F */
-#define L2TP_VERSION_L2TP 0x0002 /* L2TP */
-
-#define L2TP_AVP_HDR_FLAG_MANDATORY 0x8000 /* Mandatory Flag */
-#define L2TP_AVP_HDR_FLAG_HIDDEN 0x4000 /* Hidden Flag */
-#define L2TP_AVP_HDR_LEN_MASK 0x03ff /* Length Mask */
-
-#define L2TP_FRAMING_CAP_SYNC_MASK 0x00000001 /* Synchronous */
-#define L2TP_FRAMING_CAP_ASYNC_MASK 0x00000002 /* Asynchronous */
-
-#define L2TP_FRAMING_TYPE_SYNC_MASK 0x00000001 /* Synchronous */
-#define L2TP_FRAMING_TYPE_ASYNC_MASK 0x00000002 /* Asynchronous */
-
-#define L2TP_BEARER_CAP_DIGITAL_MASK 0x00000001 /* Digital */
-#define L2TP_BEARER_CAP_ANALOG_MASK 0x00000002 /* Analog */
-
-#define L2TP_BEARER_TYPE_DIGITAL_MASK 0x00000001 /* Digital */
-#define L2TP_BEARER_TYPE_ANALOG_MASK 0x00000002 /* Analog */
-
-/* Authen Type */
-#define L2TP_AUTHEN_TYPE_RESERVED 0x0000 /* Reserved */
-#define L2TP_AUTHEN_TYPE_TEXTUAL 0x0001 /* Textual username/password exchange */
-#define L2TP_AUTHEN_TYPE_CHAP 0x0002 /* PPP CHAP */
-#define L2TP_AUTHEN_TYPE_PAP 0x0003 /* PPP PAP */
-#define L2TP_AUTHEN_TYPE_NO_AUTH 0x0004 /* No Authentication */
-#define L2TP_AUTHEN_TYPE_MSCHAPv1 0x0005 /* MSCHAPv1 */
-
-#define L2TP_PROXY_AUTH_ID_MASK 0x00ff
-
-
diff --git a/contrib/tcpdump/l2vpn.c b/contrib/tcpdump/l2vpn.c
index 021e7f0ad2bb..54037aa19bc3 100644
--- a/contrib/tcpdump/l2vpn.c
+++ b/contrib/tcpdump/l2vpn.c
@@ -1,4 +1,4 @@
-/*
+/*
* 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
@@ -13,11 +13,7 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/l2vpn.c,v 1.1 2004-06-15 09:42:40 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -31,16 +27,16 @@ const struct tok l2vpn_encaps_values[] = {
{ 0x00, "Reserved"},
{ 0x01, "Frame Relay"},
{ 0x02, "ATM AAL5 VCC transport"},
- { 0x03, "ATM transparent cell transport"},
- { 0x04, "Ethernet VLAN"},
- { 0x05, "Ethernet"},
- { 0x06, "Cisco-HDLC"},
- { 0x07, "PPP"},
- { 0x08, "SONET/SDH Circuit Emulation Service over MPLS"},
- { 0x09, "ATM n-to-one VCC cell transport"},
- { 0x0a, "ATM n-to-one VPC cell transport"},
- { 0x0b, "IP Layer2 Transport"},
- { 0x0c, "ATM one-to-one VCC Cell Mode"},
+ { 0x03, "ATM transparent cell transport"},
+ { 0x04, "Ethernet VLAN"},
+ { 0x05, "Ethernet"},
+ { 0x06, "Cisco-HDLC"},
+ { 0x07, "PPP"},
+ { 0x08, "SONET/SDH Circuit Emulation Service over MPLS"},
+ { 0x09, "ATM n-to-one VCC cell transport"},
+ { 0x0a, "ATM n-to-one VPC cell transport"},
+ { 0x0b, "IP Layer2 Transport"},
+ { 0x0c, "ATM one-to-one VCC Cell Mode"},
{ 0x0d, "ATM one-to-one VPC Cell Mode"},
{ 0x0e, "ATM AAL5 PDU VCC transport"},
{ 0x0f, "Frame-Relay Port mode"},
@@ -53,6 +49,6 @@ const struct tok l2vpn_encaps_values[] = {
{ 0x16, "TDMoIP basic mode"},
{ 0x17, "CESoPSN TDM with CAS"},
{ 0x18, "TDMoIP TDM with CAS"},
- { 0x40, "IP-interworking"},
+ { 0x40, "IP-interworking"},
{ 0, NULL}
};
diff --git a/contrib/tcpdump/l2vpn.h b/contrib/tcpdump/l2vpn.h
index 871eca0e0d22..151228fc697b 100644
--- a/contrib/tcpdump/l2vpn.h
+++ b/contrib/tcpdump/l2vpn.h
@@ -1,5 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/l2vpn.h,v 1.1 2004-06-15 09:42:41 hannes Exp $ (LBL) */
-/*
+/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code
* distributions retain the above copyright notice and this paragraph
diff --git a/contrib/tcpdump/lane.h b/contrib/tcpdump/lane.h
deleted file mode 100644
index 76cc020ea791..000000000000
--- a/contrib/tcpdump/lane.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Marko Kiiskila carnil@cs.tut.fi
- *
- * Tampere University of Technology - Telecommunications Laboratory
- *
- * Permission to use, copy, modify and distribute this
- * software and its documentation is hereby granted,
- * provided that both the copyright notice and this
- * permission notice appear in all copies of the software,
- * derivative works or modified versions, and any portions
- * thereof, that both notices appear in supporting
- * documentation, and that the use of this software is
- * acknowledged in any publications resulting from using
- * the software.
- *
- * TUT ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION AND DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS
- * SOFTWARE.
- *
- */
-
-/* $Id: lane.h,v 1.7 2002-12-11 07:13:54 guy Exp $ */
-
-#ifndef ETHER_ADDR_LEN
-#define ETHER_ADDR_LEN 6
-#endif
-
-struct lecdatahdr_8023 {
- u_int16_t le_header;
- u_int8_t h_dest[ETHER_ADDR_LEN];
- u_int8_t h_source[ETHER_ADDR_LEN];
- u_int16_t h_type;
-};
-
-struct lane_controlhdr {
- u_int16_t lec_header;
- u_int8_t lec_proto;
- u_int8_t lec_vers;
- u_int16_t lec_opcode;
-};
diff --git a/contrib/tcpdump/lbl/os-osf4.h b/contrib/tcpdump/lbl/os-osf4.h
index 5682b7e6c1fa..359bf3656eb0 100644
--- a/contrib/tcpdump/lbl/os-osf4.h
+++ b/contrib/tcpdump/lbl/os-osf4.h
@@ -17,8 +17,6 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/lbl/os-osf4.h,v 1.1 2002-12-11 05:03:13 guy Exp $ (LBL)
*/
/* Prototypes missing in Digital UNIX 4.x */
diff --git a/contrib/tcpdump/lbl/os-solaris2.h b/contrib/tcpdump/lbl/os-solaris2.h
index 5c01b87212e6..9f94da97658f 100644
--- a/contrib/tcpdump/lbl/os-solaris2.h
+++ b/contrib/tcpdump/lbl/os-solaris2.h
@@ -17,8 +17,6 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/lbl/os-solaris2.h,v 1.19 2000-10-11 04:02:15 guy Exp $ (LBL)
*/
/* Prototypes missing in SunOS 5 */
diff --git a/contrib/tcpdump/lbl/os-sunos4.h b/contrib/tcpdump/lbl/os-sunos4.h
index ab0a12c54131..b73585706cd5 100644
--- a/contrib/tcpdump/lbl/os-sunos4.h
+++ b/contrib/tcpdump/lbl/os-sunos4.h
@@ -17,8 +17,6 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/lbl/os-sunos4.h,v 1.32 1999-10-07 23:47:13 mcr Exp $ (LBL)
*/
/* Prototypes missing in SunOS 4 */
diff --git a/contrib/tcpdump/lbl/os-ultrix4.h b/contrib/tcpdump/lbl/os-ultrix4.h
index 347485ec530e..fa1f770f8d44 100644
--- a/contrib/tcpdump/lbl/os-ultrix4.h
+++ b/contrib/tcpdump/lbl/os-ultrix4.h
@@ -17,8 +17,6 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/lbl/os-ultrix4.h,v 1.19 1999-10-07 23:47:13 mcr Exp $ (LBL)
*/
/* Prototypes missing in Ultrix 4 */
diff --git a/contrib/tcpdump/llc.h b/contrib/tcpdump/llc.h
index faa72561c9a9..ec8d069e77b9 100644
--- a/contrib/tcpdump/llc.h
+++ b/contrib/tcpdump/llc.h
@@ -17,8 +17,6 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/llc.h,v 1.23 2007-04-13 09:43:11 hannes Exp $ (LBL)
*/
/*
@@ -106,6 +104,7 @@
#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+ */
+#define PID_CISCO_VLANBRIDGE 0x010c /* "VLAN Bridge", according to Wireshark */
/*
* PIDs for use with OUI_RFC2684.
diff --git a/contrib/tcpdump/machdep.c b/contrib/tcpdump/machdep.c
index 2bcf31747062..3b8c9664f266 100644
--- a/contrib/tcpdump/machdep.c
+++ b/contrib/tcpdump/machdep.c
@@ -19,11 +19,6 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/machdep.c,v 1.13 2003-12-15 03:53:21 guy Exp $ (LBL)";
-#endif
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -46,7 +41,10 @@ static const char rcsid[] _U_ =
#if !defined(HAVE_SNPRINTF)
int snprintf(char *, size_t, const char *, ...)
- __attribute__((format(printf, 3, 4)));
+#ifdef __ATTRIBUTE___FORMAT_OK
+ __attribute__((format(printf, 3, 4)))
+#endif /* __ATTRIBUTE___FORMAT_OK */
+ ;
#endif /* !defined(HAVE_SNPRINTF) */
#endif /* __osf__ */
diff --git a/contrib/tcpdump/machdep.h b/contrib/tcpdump/machdep.h
index 6328c8265947..d1c7d4b5c55b 100644
--- a/contrib/tcpdump/machdep.h
+++ b/contrib/tcpdump/machdep.h
@@ -17,8 +17,6 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/machdep.h,v 1.2 2000-01-17 06:24:24 itojun Exp $ (LBL)
*/
#ifndef tcpdump_machdep_h
#define tcpdump_machdep_h
diff --git a/contrib/tcpdump/makemib b/contrib/tcpdump/makemib
index b59e2f105a75..97e78754ff7b 100755
--- a/contrib/tcpdump/makemib
+++ b/contrib/tcpdump/makemib
@@ -26,8 +26,6 @@
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-# @(#) $Id: makemib,v 1.3 2001-09-17 22:16:52 fenner Exp $ (jlv)
#
# This script will read either ASN.1-style MIB files or the ".defs" files
@@ -39,7 +37,7 @@
# This script needs to be run by "gawk" (GNU awk). "nawk" will work, but
# dump will get a recursion error if you process LARGE mibs. While it would
# by farily easy to rewrite this not to use recursion (and also easy to
-# eliminate use of gsub and functions to use classic "awk"), you have to
+# eliminate use of gsub and functions to use classic "awk"), you have to
# order the structure declarations in defined-first order for the compiler
# not to barf; too bad tsort doesn't take arguments.
#
@@ -49,7 +47,7 @@ cat << EOF
* This file was generated by tcpdump/makemib on `date`
* You probably don't want to edit this by hand!
*
- * struct mib somename = { desc, oid-octet, type, child-pointer, next-pointer
+ * struct mib somename = { desc, oid-octet, type, child-pointer, next-pointer
};
*/
@@ -159,7 +157,7 @@ $2$3 == "::={" {
}
-#
+#
# End of the road - output the data.
#
diff --git a/contrib/tcpdump/missing/addrinfo.h b/contrib/tcpdump/missing/addrinfo.h
index d3d63cd78bea..bf4bbf6ed6d0 100644
--- a/contrib/tcpdump/missing/addrinfo.h
+++ b/contrib/tcpdump/missing/addrinfo.h
@@ -27,8 +27,6 @@
* SUCH DAMAGE.
*/
-/* $Id: addrinfo.h,v 1.4 2002-06-11 17:13:36 itojun Exp $ */
-
#ifndef HAVE_ADDRINFO
/*
diff --git a/contrib/tcpdump/missing/datalinks.c b/contrib/tcpdump/missing/datalinks.c
index 1bd86448a8d0..e7d526bcedb1 100644
--- a/contrib/tcpdump/missing/datalinks.c
+++ b/contrib/tcpdump/missing/datalinks.c
@@ -31,11 +31,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/missing/datalinks.c,v 1.3 2003-11-16 09:36:47 guy Exp $ (LBL)";
-#endif
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
diff --git a/contrib/tcpdump/missing/dlnames.c b/contrib/tcpdump/missing/dlnames.c
index 32072b784f95..a10cd398d893 100644
--- a/contrib/tcpdump/missing/dlnames.c
+++ b/contrib/tcpdump/missing/dlnames.c
@@ -31,11 +31,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/missing/dlnames.c,v 1.5 2003-11-18 23:09:43 guy Exp $ (LBL)";
-#endif
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
diff --git a/contrib/tcpdump/missing/getnameinfo.c b/contrib/tcpdump/missing/getnameinfo.c
index c287221c402b..63aba7310487 100644
--- a/contrib/tcpdump/missing/getnameinfo.c
+++ b/contrib/tcpdump/missing/getnameinfo.c
@@ -41,11 +41,6 @@
#include <config.h>
#endif
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/missing/getnameinfo.c,v 1.11 2003-11-16 09:36:49 guy Exp $";
-#endif
-
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
@@ -112,7 +107,7 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
u_short port;
int family, i;
char *addr, *p;
- u_int32_t v4a;
+ uint32_t v4a;
int h_error;
char numserv[512];
char numaddr[512];
@@ -168,7 +163,7 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
switch (sa->sa_family) {
case AF_INET:
- v4a = (u_int32_t)
+ v4a = (uint32_t)
ntohl(((struct sockaddr_in *)sa)->sin_addr.s_addr);
if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a))
flags |= NI_NUMERICHOST;
diff --git a/contrib/tcpdump/missing/getopt_long.c b/contrib/tcpdump/missing/getopt_long.c
new file mode 100644
index 000000000000..80857369804d
--- /dev/null
+++ b/contrib/tcpdump/missing/getopt_long.c
@@ -0,0 +1,612 @@
+/* $OpenBSD: getopt_long.c,v 1.22 2006/10/04 21:29:04 jmc Exp $ */
+/* $NetBSD: getopt_long.c,v 1.15 2002/01/31 22:43:40 tv Exp $ */
+
+/*
+ * Copyright (c) 2002 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Sponsored in part by the Defense Advanced Research Projects
+ * Agency (DARPA) and Air Force Research Laboratory, Air Force
+ * Materiel Command, USAF, under agreement number F39502-99-1-0512.
+ */
+/*-
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Dieter Baron and Thomas Klausner.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include <errno.h>
+#include "getopt_long.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdarg.h>
+
+#define GNU_COMPATIBLE /* Be more compatible, configure's use us! */
+
+#define PRINT_ERROR ((opterr) && (*options != ':'))
+
+#define FLAG_PERMUTE 0x01 /* permute non-options to the end of argv */
+#define FLAG_ALLARGS 0x02 /* treat non-options as args to option "-1" */
+#define FLAG_LONGONLY 0x04 /* operate as getopt_long_only */
+
+/* return values */
+#define BADCH (int)'?'
+#define BADARG ((*options == ':') ? (int)':' : (int)'?')
+#define INORDER (int)1
+
+#define EMSG ""
+
+#ifdef GNU_COMPATIBLE
+#define NO_PREFIX (-1)
+#define D_PREFIX 0
+#define DD_PREFIX 1
+#define W_PREFIX 2
+#endif
+
+char *optarg;
+int optind, opterr = 1, optopt;
+
+static int getopt_internal(int, char * const *, const char *,
+ const struct option *, int *, int);
+static int parse_long_options(char * const *, const char *,
+ const struct option *, int *, int, int);
+static int gcd(int, int);
+static void permute_args(int, int, int, char * const *);
+
+static const char *place = EMSG; /* option letter processing */
+
+static int nonopt_start = -1; /* first non option argument (for permute) */
+static int nonopt_end = -1; /* first option after non options (for permute) */
+
+/* Error messages */
+static const char recargchar[] = "option requires an argument -- %c";
+static const char illoptchar[] = "illegal option -- %c"; /* From P1003.2 */
+#ifdef GNU_COMPATIBLE
+static int dash_prefix = NO_PREFIX;
+static const char gnuoptchar[] = "invalid option -- %c";
+
+static const char recargstring[] = "option `%s%s' requires an argument";
+static const char ambig[] = "option `%s%.*s' is ambiguous";
+static const char noarg[] = "option `%s%.*s' doesn't allow an argument";
+static const char illoptstring[] = "unrecognized option `%s%s'";
+#else
+static const char recargstring[] = "option requires an argument -- %s";
+static const char ambig[] = "ambiguous option -- %.*s";
+static const char noarg[] = "option doesn't take an argument -- %.*s";
+static const char illoptstring[] = "unknown option -- %s";
+#endif
+
+/*
+ * Compute the greatest common divisor of a and b.
+ */
+static int
+gcd(int a, int b)
+{
+ int c;
+
+ c = a % b;
+ while (c != 0) {
+ a = b;
+ b = c;
+ c = a % b;
+ }
+
+ return (b);
+}
+
+/*
+ * Exchange the block from nonopt_start to nonopt_end with the block
+ * from nonopt_end to opt_end (keeping the same order of arguments
+ * in each block).
+ */
+static void
+permute_args(int panonopt_start, int panonopt_end, int opt_end,
+ char * const *nargv)
+{
+ int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos;
+ char *swap;
+
+ /*
+ * compute lengths of blocks and number and size of cycles
+ */
+ nnonopts = panonopt_end - panonopt_start;
+ nopts = opt_end - panonopt_end;
+ ncycle = gcd(nnonopts, nopts);
+ cyclelen = (opt_end - panonopt_start) / ncycle;
+
+ for (i = 0; i < ncycle; i++) {
+ cstart = panonopt_end+i;
+ pos = cstart;
+ for (j = 0; j < cyclelen; j++) {
+ if (pos >= panonopt_end)
+ pos -= nnonopts;
+ else
+ pos += nopts;
+ swap = nargv[pos];
+ /* LINTED const cast */
+ ((char **) nargv)[pos] = nargv[cstart];
+ /* LINTED const cast */
+ ((char **)nargv)[cstart] = swap;
+ }
+ }
+}
+
+static void
+warnx(const char *fmt, ...)
+{
+ extern char *program_name;
+ va_list ap;
+
+ va_start(ap, fmt);
+ fprintf(stderr, "%s: ", program_name);
+ vfprintf(stderr, fmt, ap);
+ fprintf(stderr, "\n");
+ va_end(ap);
+}
+
+/*
+ * parse_long_options --
+ * Parse long options in argc/argv argument vector.
+ * Returns -1 if short_too is set and the option does not match long_options.
+ */
+static int
+parse_long_options(char * const *nargv, const char *options,
+ const struct option *long_options, int *idx, int short_too, int flags)
+{
+ const char *current_argv, *has_equal;
+#ifdef GNU_COMPATIBLE
+ const char *current_dash;
+#endif
+ size_t current_argv_len;
+ int i, match, exact_match, second_partial_match;
+
+ current_argv = place;
+#ifdef GNU_COMPATIBLE
+ switch (dash_prefix) {
+ case D_PREFIX:
+ current_dash = "-";
+ break;
+ case DD_PREFIX:
+ current_dash = "--";
+ break;
+ case W_PREFIX:
+ current_dash = "-W ";
+ break;
+ default:
+ current_dash = "";
+ break;
+ }
+#endif
+ match = -1;
+ exact_match = 0;
+ second_partial_match = 0;
+
+ optind++;
+
+ if ((has_equal = strchr(current_argv, '=')) != NULL) {
+ /* argument found (--option=arg) */
+ current_argv_len = has_equal - current_argv;
+ has_equal++;
+ } else
+ current_argv_len = strlen(current_argv);
+
+ for (i = 0; long_options[i].name; i++) {
+ /* find matching long option */
+ if (strncmp(current_argv, long_options[i].name,
+ current_argv_len))
+ continue;
+
+ if (strlen(long_options[i].name) == current_argv_len) {
+ /* exact match */
+ match = i;
+ exact_match = 1;
+ break;
+ }
+ /*
+ * If this is a known short option, don't allow
+ * a partial match of a single character.
+ */
+ if (short_too && current_argv_len == 1)
+ continue;
+
+ if (match == -1) /* first partial match */
+ match = i;
+ else if ((flags & FLAG_LONGONLY) ||
+ long_options[i].has_arg !=
+ long_options[match].has_arg ||
+ long_options[i].flag != long_options[match].flag ||
+ long_options[i].val != long_options[match].val)
+ second_partial_match = 1;
+ }
+ if (!exact_match && second_partial_match) {
+ /* ambiguous abbreviation */
+ if (PRINT_ERROR)
+ warnx(ambig,
+#ifdef GNU_COMPATIBLE
+ current_dash,
+#endif
+ (int)current_argv_len,
+ current_argv);
+ optopt = 0;
+ return (BADCH);
+ }
+ if (match != -1) { /* option found */
+ if (long_options[match].has_arg == no_argument
+ && has_equal) {
+ if (PRINT_ERROR)
+ warnx(noarg,
+#ifdef GNU_COMPATIBLE
+ current_dash,
+#endif
+ (int)current_argv_len,
+ current_argv);
+ /*
+ * XXX: GNU sets optopt to val regardless of flag
+ */
+ if (long_options[match].flag == NULL)
+ optopt = long_options[match].val;
+ else
+ optopt = 0;
+#ifdef GNU_COMPATIBLE
+ return (BADCH);
+#else
+ return (BADARG);
+#endif
+ }
+ if (long_options[match].has_arg == required_argument ||
+ long_options[match].has_arg == optional_argument) {
+ if (has_equal)
+ optarg = (char *)has_equal;
+ else if (long_options[match].has_arg ==
+ required_argument) {
+ /*
+ * optional argument doesn't use next nargv
+ */
+ optarg = nargv[optind++];
+ }
+ }
+ if ((long_options[match].has_arg == required_argument)
+ && (optarg == NULL)) {
+ /*
+ * Missing argument; leading ':' indicates no error
+ * should be generated.
+ */
+ if (PRINT_ERROR)
+ warnx(recargstring,
+#ifdef GNU_COMPATIBLE
+ current_dash,
+#endif
+ current_argv);
+ /*
+ * XXX: GNU sets optopt to val regardless of flag
+ */
+ if (long_options[match].flag == NULL)
+ optopt = long_options[match].val;
+ else
+ optopt = 0;
+ --optind;
+ return (BADARG);
+ }
+ } else { /* unknown option */
+ if (short_too) {
+ --optind;
+ return (-1);
+ }
+ if (PRINT_ERROR)
+ warnx(illoptstring,
+#ifdef GNU_COMPATIBLE
+ current_dash,
+#endif
+ current_argv);
+ optopt = 0;
+ return (BADCH);
+ }
+ if (idx)
+ *idx = match;
+ if (long_options[match].flag) {
+ *long_options[match].flag = long_options[match].val;
+ return (0);
+ } else
+ return (long_options[match].val);
+}
+
+/*
+ * getopt_internal --
+ * Parse argc/argv argument vector. Called by user level routines.
+ */
+static int
+getopt_internal(int nargc, char * const *nargv, const char *options,
+ const struct option *long_options, int *idx, int flags)
+{
+ char *oli; /* option letter list index */
+ int optchar, short_too;
+ int posixly_correct; /* no static, can be changed on the fly */
+
+ if (options == NULL)
+ return (-1);
+
+ /*
+ * Disable GNU extensions if POSIXLY_CORRECT is set or options
+ * string begins with a '+'.
+ */
+ posixly_correct = (getenv("POSIXLY_CORRECT") != NULL);
+#ifdef GNU_COMPATIBLE
+ if (*options == '-')
+ flags |= FLAG_ALLARGS;
+ else if (posixly_correct || *options == '+')
+ flags &= ~FLAG_PERMUTE;
+#else
+ if (posixly_correct || *options == '+')
+ flags &= ~FLAG_PERMUTE;
+ else if (*options == '-')
+ flags |= FLAG_ALLARGS;
+#endif
+ if (*options == '+' || *options == '-')
+ options++;
+
+ /*
+ * XXX Some GNU programs (like cvs) set optind to 0 instead of
+ * XXX using optreset. Work around this braindamage.
+ */
+ if (optind == 0)
+ optind = 1;
+
+ optarg = NULL;
+start:
+ if (!*place) { /* update scanning pointer */
+ if (optind >= nargc) { /* end of argument vector */
+ place = EMSG;
+ if (nonopt_end != -1) {
+ /* do permutation, if we have to */
+ permute_args(nonopt_start, nonopt_end,
+ optind, nargv);
+ optind -= nonopt_end - nonopt_start;
+ }
+ else if (nonopt_start != -1) {
+ /*
+ * If we skipped non-options, set optind
+ * to the first of them.
+ */
+ optind = nonopt_start;
+ }
+ nonopt_start = nonopt_end = -1;
+ return (-1);
+ }
+ if (*(place = nargv[optind]) != '-' ||
+#ifdef GNU_COMPATIBLE
+ place[1] == '\0') {
+#else
+ (place[1] == '\0' && strchr(options, '-') == NULL)) {
+#endif
+ place = EMSG; /* found non-option */
+ if (flags & FLAG_ALLARGS) {
+ /*
+ * GNU extension:
+ * return non-option as argument to option 1
+ */
+ optarg = nargv[optind++];
+ return (INORDER);
+ }
+ if (!(flags & FLAG_PERMUTE)) {
+ /*
+ * If no permutation wanted, stop parsing
+ * at first non-option.
+ */
+ return (-1);
+ }
+ /* do permutation */
+ if (nonopt_start == -1)
+ nonopt_start = optind;
+ else if (nonopt_end != -1) {
+ permute_args(nonopt_start, nonopt_end,
+ optind, nargv);
+ nonopt_start = optind -
+ (nonopt_end - nonopt_start);
+ nonopt_end = -1;
+ }
+ optind++;
+ /* process next argument */
+ goto start;
+ }
+ if (nonopt_start != -1 && nonopt_end == -1)
+ nonopt_end = optind;
+
+ /*
+ * If we have "-" do nothing, if "--" we are done.
+ */
+ if (place[1] != '\0' && *++place == '-' && place[1] == '\0') {
+ optind++;
+ place = EMSG;
+ /*
+ * We found an option (--), so if we skipped
+ * non-options, we have to permute.
+ */
+ if (nonopt_end != -1) {
+ permute_args(nonopt_start, nonopt_end,
+ optind, nargv);
+ optind -= nonopt_end - nonopt_start;
+ }
+ nonopt_start = nonopt_end = -1;
+ return (-1);
+ }
+ }
+
+ /*
+ * Check long options if:
+ * 1) we were passed some
+ * 2) the arg is not just "-"
+ * 3) either the arg starts with -- we are getopt_long_only()
+ */
+ if (long_options != NULL && place != nargv[optind] &&
+ (*place == '-' || (flags & FLAG_LONGONLY))) {
+ short_too = 0;
+#ifdef GNU_COMPATIBLE
+ dash_prefix = D_PREFIX;
+#endif
+ if (*place == '-') {
+ place++; /* --foo long option */
+#ifdef GNU_COMPATIBLE
+ dash_prefix = DD_PREFIX;
+#endif
+ } else if (*place != ':' && strchr(options, *place) != NULL)
+ short_too = 1; /* could be short option too */
+
+ optchar = parse_long_options(nargv, options, long_options,
+ idx, short_too, flags);
+ if (optchar != -1) {
+ place = EMSG;
+ return (optchar);
+ }
+ }
+
+ if ((optchar = (int)*place++) == (int)':' ||
+ (optchar == (int)'-' && *place != '\0') ||
+ (oli = strchr(options, optchar)) == NULL) {
+ /*
+ * If the user specified "-" and '-' isn't listed in
+ * options, return -1 (non-option) as per POSIX.
+ * Otherwise, it is an unknown option character (or ':').
+ */
+ if (optchar == (int)'-' && *place == '\0')
+ return (-1);
+ if (!*place)
+ ++optind;
+#ifdef GNU_COMPATIBLE
+ if (PRINT_ERROR)
+ warnx(posixly_correct ? illoptchar : gnuoptchar,
+ optchar);
+#else
+ if (PRINT_ERROR)
+ warnx(illoptchar, optchar);
+#endif
+ optopt = optchar;
+ return (BADCH);
+ }
+ if (long_options != NULL && optchar == 'W' && oli[1] == ';') {
+ /* -W long-option */
+ if (*place) /* no space */
+ /* NOTHING */;
+ else if (++optind >= nargc) { /* no arg */
+ place = EMSG;
+ if (PRINT_ERROR)
+ warnx(recargchar, optchar);
+ optopt = optchar;
+ return (BADARG);
+ } else /* white space */
+ place = nargv[optind];
+#ifdef GNU_COMPATIBLE
+ dash_prefix = W_PREFIX;
+#endif
+ optchar = parse_long_options(nargv, options, long_options,
+ idx, 0, flags);
+ place = EMSG;
+ return (optchar);
+ }
+ if (*++oli != ':') { /* doesn't take argument */
+ if (!*place)
+ ++optind;
+ } else { /* takes (optional) argument */
+ optarg = NULL;
+ if (*place) /* no white space */
+ optarg = (char *)place;
+ else if (oli[1] != ':') { /* arg not optional */
+ if (++optind >= nargc) { /* no arg */
+ place = EMSG;
+ if (PRINT_ERROR)
+ warnx(recargchar, optchar);
+ optopt = optchar;
+ return (BADARG);
+ } else
+ optarg = nargv[optind];
+ }
+ place = EMSG;
+ ++optind;
+ }
+ /* dump back option letter */
+ return (optchar);
+}
+
+#ifdef REPLACE_GETOPT
+/*
+ * getopt --
+ * Parse argc/argv argument vector.
+ *
+ * [eventually this will replace the BSD getopt]
+ */
+int
+getopt(int nargc, char * const *nargv, const char *options)
+{
+
+ /*
+ * We don't pass FLAG_PERMUTE to getopt_internal() since
+ * the BSD getopt(3) (unlike GNU) has never done this.
+ *
+ * Furthermore, since many privileged programs call getopt()
+ * before dropping privileges it makes sense to keep things
+ * as simple (and bug-free) as possible.
+ */
+ return (getopt_internal(nargc, nargv, options, NULL, NULL, 0));
+}
+#endif /* REPLACE_GETOPT */
+
+/*
+ * getopt_long --
+ * Parse argc/argv argument vector.
+ */
+int
+getopt_long(int nargc, char * const *nargv, const char *options,
+ const struct option *long_options, int *idx)
+{
+
+ return (getopt_internal(nargc, nargv, options, long_options, idx,
+ FLAG_PERMUTE));
+}
+
+/*
+ * getopt_long_only --
+ * Parse argc/argv argument vector.
+ */
+int
+getopt_long_only(int nargc, char * const *nargv, const char *options,
+ const struct option *long_options, int *idx)
+{
+
+ return (getopt_internal(nargc, nargv, options, long_options, idx,
+ FLAG_PERMUTE|FLAG_LONGONLY));
+}
diff --git a/contrib/tcpdump/missing/inet_aton.c b/contrib/tcpdump/missing/inet_aton.c
index bc1461aa7189..e85ad5f814dc 100644
--- a/contrib/tcpdump/missing/inet_aton.c
+++ b/contrib/tcpdump/missing/inet_aton.c
@@ -36,13 +36,6 @@
* SUCH DAMAGE.
*/
-/* $Id: inet_aton.c,v 1.6 2003-11-16 09:36:49 guy Exp $ */
-
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/missing/inet_aton.c,v 1.6 2003-11-16 09:36:49 guy Exp $";
-#endif
-
#include <tcpdump-stdinc.h>
/* Minimal implementation of inet_aton.
diff --git a/contrib/tcpdump/missing/inet_ntop.c b/contrib/tcpdump/missing/inet_ntop.c
index d17d5925737d..8c6f7eb8c7eb 100644
--- a/contrib/tcpdump/missing/inet_ntop.c
+++ b/contrib/tcpdump/missing/inet_ntop.c
@@ -36,17 +36,13 @@
* SUCH DAMAGE.
*/
-/* $Id: inet_ntop.c,v 1.8 2005-02-09 02:25:46 guy Exp $ */
-
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/missing/inet_ntop.c,v 1.8 2005-02-09 02:25:46 guy Exp $";
+#ifdef HAVE_CONFIG_H
+#include "config.h"
#endif
#include <tcpdump-stdinc.h>
#include <stdio.h>
-#include <errno.h>
/*
*
@@ -126,7 +122,9 @@ inet_ntop_v6 (const u_char *src, char *dst, size_t size)
for (i = 0; i < IN6ADDRSZ; i++)
words[i/2] |= (src[i] << ((1 - (i % 2)) << 3));
+ best.len = 0;
best.base = -1;
+ cur.len = 0;
cur.base = -1;
for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++)
{
@@ -180,7 +178,7 @@ inet_ntop_v6 (const u_char *src, char *dst, size_t size)
tp += strlen(tp);
break;
}
- tp += sprintf (tp, "%lX", words[i]);
+ tp += sprintf (tp, "%lx", words[i]);
}
/* Was it a trailing run of 0x00's?
@@ -197,7 +195,6 @@ inet_ntop_v6 (const u_char *src, char *dst, size_t size)
return (NULL);
}
return strcpy (dst, tmp);
- return (NULL);
}
#endif /* INET6 */
diff --git a/contrib/tcpdump/missing/inet_pton.c b/contrib/tcpdump/missing/inet_pton.c
index 83f67e1e515a..3466f42b7cb5 100644
--- a/contrib/tcpdump/missing/inet_pton.c
+++ b/contrib/tcpdump/missing/inet_pton.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999 Kungliga Tekniska Högskolan
+ * Copyright (c) 1999 Kungliga Tekniska H�gskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -17,7 +17,7 @@
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Kungliga Tekniska
- * Högskolan and its contributors.
+ * H�gskolan and its contributors.
*
* 4. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
@@ -36,17 +36,8 @@
* SUCH DAMAGE.
*/
-/* $Id: inet_pton.c,v 1.6 2003-11-16 09:36:51 guy Exp $ */
-
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/missing/inet_pton.c,v 1.6 2003-11-16 09:36:51 guy Exp $";
-#endif
-
#include <tcpdump-stdinc.h>
-#include <errno.h>
-
int
inet_pton(int af, const char *src, void *dst)
{
diff --git a/contrib/tcpdump/missing/snprintf.c b/contrib/tcpdump/missing/snprintf.c
index 79329977bf9b..21d235d217f2 100644
--- a/contrib/tcpdump/missing/snprintf.c
+++ b/contrib/tcpdump/missing/snprintf.c
@@ -31,17 +31,10 @@
* SUCH DAMAGE.
*/
-/* $Id: snprintf.c,v 1.8 2003-11-16 09:36:51 guy Exp $ */
-
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/missing/snprintf.c,v 1.8 2003-11-16 09:36:51 guy Exp $";
-#endif
-
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
diff --git a/contrib/tcpdump/missing/sockstorage.h b/contrib/tcpdump/missing/sockstorage.h
deleted file mode 100644
index e7333289f176..000000000000
--- a/contrib/tcpdump/missing/sockstorage.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 1999 WIDE Project.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-struct sockaddr_storage {
-#ifdef HAVE_SOCKADDR_SA_LEN
- u_int8_t ss_len;
- u_int8_t ss_family;
- u_int8_t fill[126];
-#else
- u_int8_t ss_family;
- u_int8_t fill[127];
-#endif /* HAVE_SOCKADDR_SA_LEN */
-};
diff --git a/contrib/tcpdump/missing/strdup.c b/contrib/tcpdump/missing/strdup.c
index 079a8ff82141..9fca7529e34d 100644
--- a/contrib/tcpdump/missing/strdup.c
+++ b/contrib/tcpdump/missing/strdup.c
@@ -31,11 +31,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/missing/strdup.c,v 1.1 2001-01-20 07:26:08 guy Exp $ (LBL)";
-#endif /* LIBC_SCCS and not lint */
-
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
diff --git a/contrib/tcpdump/missing/strlcat.c b/contrib/tcpdump/missing/strlcat.c
index a3d3face4a83..34f1af2d9628 100644
--- a/contrib/tcpdump/missing/strlcat.c
+++ b/contrib/tcpdump/missing/strlcat.c
@@ -28,11 +28,6 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/missing/strlcat.c,v 1.5 2003-11-16 09:36:51 guy Exp $ (LBL)";
-#endif
-
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -41,6 +36,8 @@ static const char rcsid[] _U_ =
#include <string.h>
+#include "interface.h"
+
/*
* Appends src to string dst of size siz (unlike strncat, siz is the
* full size of dst, not space left). At most siz-1 characters
diff --git a/contrib/tcpdump/missing/strlcpy.c b/contrib/tcpdump/missing/strlcpy.c
index a92e4d130bb9..b0671ebd311b 100644
--- a/contrib/tcpdump/missing/strlcpy.c
+++ b/contrib/tcpdump/missing/strlcpy.c
@@ -28,11 +28,6 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/missing/strlcpy.c,v 1.5 2003-11-16 09:36:52 guy Exp $ (LBL)";
-#endif
-
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -41,6 +36,8 @@ static const char rcsid[] _U_ =
#include <string.h>
+#include "interface.h"
+
/*
* Copy src to string dst of size siz. At most siz-1 characters
* will be copied. Always NUL terminates (unless siz == 0).
diff --git a/contrib/tcpdump/missing/strsep.c b/contrib/tcpdump/missing/strsep.c
index 0362d1f51b71..bcce4c46861a 100644
--- a/contrib/tcpdump/missing/strsep.c
+++ b/contrib/tcpdump/missing/strsep.c
@@ -31,11 +31,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/missing/strsep.c,v 1.3 2003-03-25 08:33:48 guy Exp $ (LBL)";
-#endif /* LIBC_SCCS and not lint */
-
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
diff --git a/contrib/tcpdump/mkdep b/contrib/tcpdump/mkdep
index 2a9c221b1f1d..3062e642eab8 100755
--- a/contrib/tcpdump/mkdep
+++ b/contrib/tcpdump/mkdep
@@ -18,6 +18,7 @@ export PATH
MAKE=Makefile # default makefile name is "Makefile"
CC=cc # default C compiler is "cc"
+DEPENDENCY_CFLAG=-M # default dependency-generation flag is -M
while :
do case "$1" in
@@ -31,6 +32,11 @@ while :
MAKE=$2
shift; shift ;;
+ # -m allows you to specify the dependency-generation flag
+ -m)
+ DEPENDENCY_CFLAG=$2
+ shift; shift ;;
+
# the -p flag produces "program: program.c" style dependencies
# so .o's don't get produced
-p)
@@ -42,7 +48,7 @@ while :
done
if [ $# = 0 ] ; then
- echo 'usage: mkdep [-p] [-c cc] [-f makefile] [flags] file ...'
+ echo 'usage: mkdep [-p] [-c cc] [-f makefile] [-m dependency-cflag] [flags] file ...'
exit 1
fi
@@ -74,7 +80,7 @@ _EOF_
# sed -e 's/:[^"]*"\([^"]*\)".*/: \1/' -e 's/\.c/.o/' |
# XXX this doesn't work with things like "-DDECLWAITSTATUS=union\ wait"
-$CC -M $* |
+$CC $DEPENDENCY_CFLAG $* |
sed "
s; \./; ;g
$SED" |
diff --git a/contrib/tcpdump/mpls.h b/contrib/tcpdump/mpls.h
index ae1c97e67ee0..03cb4bf57032 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)
+/*
* 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 f441f3ea6f56..11e71ef87d6a 100644
--- a/contrib/tcpdump/nameser.h
+++ b/contrib/tcpdump/nameser.h
@@ -1,4 +1,3 @@
-/* @(#) $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.
@@ -225,13 +224,13 @@
* Structure for query header.
*/
typedef struct {
- u_int16_t id; /* query identification number */
- u_int8_t flags1; /* first byte of flags */
- u_int8_t flags2; /* second byte of flags */
- u_int16_t qdcount; /* number of question entries */
- u_int16_t ancount; /* number of answer entries */
- u_int16_t nscount; /* number of authority entries */
- u_int16_t arcount; /* number of resource entries */
+ uint16_t id; /* query identification number */
+ uint8_t flags1; /* first byte of flags */
+ uint8_t flags2; /* second byte of flags */
+ uint16_t qdcount; /* number of question entries */
+ uint16_t ancount; /* number of answer entries */
+ uint16_t nscount; /* number of authority entries */
+ uint16_t arcount; /* number of resource entries */
} HEADER;
/*
@@ -262,36 +261,36 @@ struct rrec {
int16_t r_zone; /* zone number */
int16_t r_class; /* class number */
int16_t r_type; /* type number */
- u_int32_t r_ttl; /* time to live */
+ uint32_t r_ttl; /* time to live */
int r_size; /* size of data area */
char *r_data; /* pointer to data */
};
/*
* Inline versions of get/put short/long. Pointer is advanced.
- * We also assume that a "u_int16_t" holds 2 "chars"
- * and that a "u_int32_t" holds 4 "chars".
+ * We also assume that a "uint16_t" holds 2 "chars"
+ * and that a "uint32_t" holds 4 "chars".
*
* These macros demonstrate the property of C whereby it can be
* portable or it can be elegant but never both.
*/
#define GETSHORT(s, cp) { \
register u_char *t_cp = (u_char *)(cp); \
- (s) = ((u_int16_t)t_cp[0] << 8) | (u_int16_t)t_cp[1]; \
+ (s) = ((uint16_t)t_cp[0] << 8) | (uint16_t)t_cp[1]; \
(cp) += 2; \
}
#define GETLONG(l, cp) { \
register u_char *t_cp = (u_char *)(cp); \
- (l) = (((u_int32_t)t_cp[0]) << 24) \
- | (((u_int32_t)t_cp[1]) << 16) \
- | (((u_int32_t)t_cp[2]) << 8) \
- | (((u_int32_t)t_cp[3])); \
+ (l) = (((uint32_t)t_cp[0]) << 24) \
+ | (((uint32_t)t_cp[1]) << 16) \
+ | (((uint32_t)t_cp[2]) << 8) \
+ | (((uint32_t)t_cp[3])); \
(cp) += 4; \
}
#define PUTSHORT(s, cp) { \
- register u_int16_t t_s = (u_int16_t)(s); \
+ register uint16_t t_s = (uint16_t)(s); \
register u_char *t_cp = (u_char *)(cp); \
*t_cp++ = t_s >> 8; \
*t_cp = t_s; \
@@ -303,7 +302,7 @@ struct rrec {
* were depending on this "feature", you will lose.
*/
#define PUTLONG(l, cp) { \
- register u_int32_t t_l = (u_int32_t)(l); \
+ register uint32_t t_l = (uint32_t)(l); \
register u_char *t_cp = (u_char *)(cp); \
*t_cp++ = t_l >> 24; \
*t_cp++ = t_l >> 16; \
diff --git a/contrib/tcpdump/netbios.h b/contrib/tcpdump/netbios.h
deleted file mode 100644
index d3e2725fc6d1..000000000000
--- a/contrib/tcpdump/netbios.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * NETBIOS protocol formats
- *
- * @(#) $Header: /tcpdump/master/tcpdump/netbios.h,v 1.3 2002-12-11 07:13:55 guy Exp $
- */
-
-struct p8022Hdr {
- u_char dsap;
- u_char ssap;
- u_char flags;
-};
-
-#define p8022Size 3 /* min 802.2 header size */
-
-#define UI 0x03 /* 802.2 flags */
-
diff --git a/contrib/tcpdump/netdissect.h b/contrib/tcpdump/netdissect.h
index be6fb11908ba..55d45b2a9ea6 100644
--- a/contrib/tcpdump/netdissect.h
+++ b/contrib/tcpdump/netdissect.h
@@ -20,8 +20,6 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/netdissect.h,v 1.27 2008-08-16 11:36:20 hannes Exp $ (LBL)
*/
#ifndef netdissect_h
@@ -40,15 +38,23 @@
#include <stdarg.h>
+#include "ip.h" /* struct ip for nextproto4_cksum() */
+
#if !defined(HAVE_SNPRINTF)
int snprintf (char *str, size_t sz, const char *format, ...)
- __attribute__ ((format (printf, 3, 4)));
-#endif
+#ifdef __ATTRIBUTE___FORMAT_OK
+ __attribute__((format (printf, 3, 4)))
+#endif /* __ATTRIBUTE___FORMAT_OK */
+ ;
+#endif /* !defined(HAVE_SNPRINTF) */
#if !defined(HAVE_VSNPRINTF)
int vsnprintf (char *str, size_t sz, const char *format, va_list ap)
- __attribute__((format (printf, 3, 0)));
-#endif
+#ifdef __ATTRIBUTE___FORMAT_OK
+ __attribute__((format (printf, 3, 0)))
+#endif /* __ATTRIBUTE___FORMAT_OK */
+ ;
+#endif /* !defined(HAVE_SNPRINTF) */
#ifndef HAVE_STRLCAT
extern size_t strlcat (char *, const char *, size_t);
@@ -66,12 +72,12 @@ extern char *strsep(char **, const char *);
#endif
struct tok {
- int v; /* value */
+ u_int v; /* value */
const char *s; /* string */
};
#define TOKBUFSIZE 128
-extern const char *tok2strbuf(const struct tok *, const char *, int,
+extern const char *tok2strbuf(const struct tok *, const char *, u_int,
char *buf, size_t bufsize);
/* tok2str is deprecated */
@@ -118,7 +124,9 @@ struct netdissect_options {
int ndo_Wflag; /* recycle output files after this number of files */
int ndo_WflagChars;
int ndo_Hflag; /* dissect 802.11s draft mesh standard */
+ int ndo_packet_number; /* print a packet number in the beginning of line */
int ndo_suppress_default_print; /* don't use default_print() for unknown packet types */
+ int ndo_tstamp_precision; /* requested time stamp precision */
const char *ndo_dltname;
char *ndo_espsecret;
@@ -158,9 +166,12 @@ struct netdissect_options {
;
void (*ndo_error)(netdissect_options *,
const char *fmt, ...)
+#ifdef __ATTRIBUTE___NORETURN_OK_FOR_FUNCTION_POINTERS
+ __attribute__ ((noreturn))
+#endif /* __ATTRIBUTE___NORETURN_OK_FOR_FUNCTION_POINTERS */
#ifdef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS
- __attribute__ ((noreturn, format (printf, 2, 3)))
-#endif
+ __attribute__ ((format (printf, 2, 3)))
+#endif /* __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS */
;
void (*ndo_warning)(netdissect_options *,
const char *fmt, ...)
@@ -183,6 +194,9 @@ struct netdissect_options {
#define PT_RADIUS 11 /* RADIUS authentication Protocol */
#define PT_ZMTP1 12 /* ZeroMQ Message Transport Protocol 1.0 */
#define PT_VXLAN 13 /* Virtual eXtensible Local Area Network */
+#define PT_PGM 14 /* [UDP-encapsulated] Pragmatic General Multicast */
+#define PT_PGM_ZMTP1 15 /* ZMTP/1.0 inside PGM (native or UDP-encapsulated) */
+#define PT_LMP 16 /* Link Management Protocol */
#ifndef min
#define min(a,b) ((a)>(b)?(b):(a))
@@ -195,12 +209,26 @@ struct netdissect_options {
* Maximum snapshot length. This should be enough to capture the full
* packet on most network interfaces.
*
- * XXX - could it be larger? If so, should it? Some applications might
- * use the snapshot length in a savefile header to control the size of
- * the buffer they allocate, so a size of, say, 2^31-1 might not work
- * well.
+ *
+ * Somewhat arbitrary, but chosen to be:
+ *
+ * 1) big enough for maximum-size Linux loopback packets (65549)
+ * and some USB packets captured with USBPcap:
+ *
+ * http://desowin.org/usbpcap/
+ *
+ * (> 131072, < 262144)
+ *
+ * and
+ *
+ * 2) small enough not to cause attempts to allocate huge amounts of
+ * memory; some applications might use the snapshot length in a
+ * savefile header to control the size of the buffer they allocate,
+ * so a size of, say, 2^31-1 might not work well.
+ *
+ * XXX - does it need to be bigger still?
*/
-#define MAXIMUM_SNAPLEN 65535
+#define MAXIMUM_SNAPLEN 262144
/*
* The default snapshot length is the maximum.
@@ -240,32 +268,62 @@ struct netdissect_options {
#define ND_PRINT(STUFF) (*ndo->ndo_printf)STUFF
#define ND_DEFAULTPRINT(ap, length) (*ndo->ndo_default_print)(ndo, ap, length)
-#if 0
-extern void ts_print(netdissect_options *ipdo,
- const struct timeval *);
-extern void relts_print(int);
-#endif
+extern void ts_print(netdissect_options *, const struct timeval *);
+extern void relts_print(netdissect_options *, int);
-extern int fn_print(const u_char *, const u_char *);
-extern int fn_printn(const u_char *, u_int, const u_char *);
+extern int fn_print(netdissect_options *, const u_char *, const u_char *);
+extern int fn_printn(netdissect_options *, const u_char *, u_int, const u_char *);
+extern int fn_printzp(netdissect_options *, const u_char *, u_int, const u_char *);
extern const char *tok2str(const struct tok *, const char *, int);
-extern void wrapup(int);
-
#if 0
extern char *read_infile(netdissect_options *, char *);
extern char *copy_argv(netdissect_options *, char **);
#endif
-extern void safeputchar(int);
-extern void safeputs(const char *, int);
+/*
+ * Locale-independent macros for testing character properties and
+ * stripping the 8th bit from characters. Assumed to be handed
+ * a value between 0 and 255, i.e. don't hand them a char, as
+ * those might be in the range -128 to 127.
+ */
+#define ND_ISASCII(c) (!((c) & 0x80)) /* value is an ASCII code point */
+#define ND_ISPRINT(c) ((c) >= 0x20 && (c) <= 0x7E)
+#define ND_ISGRAPH(c) ((c) > 0x20 && (c) <= 0x7E)
+#define ND_TOASCII(c) ((c) & 0x7F)
+
+extern void safeputchar(netdissect_options *, const u_char);
+extern void safeputs(netdissect_options *, const u_char *, const u_int);
+
+#ifdef LBL_ALIGN
+/*
+ * The processor doesn't natively handle unaligned loads,
+ * and the compiler might "helpfully" optimize memcpy()
+ * and memcmp(), when handed pointers that would normally
+ * be properly aligned, into sequences that assume proper
+ * alignment.
+ *
+ * Do copies and compares of possibly-unaligned data by
+ * calling routines that wrap memcpy() and memcmp(), to
+ * prevent that optimization.
+ */
+extern void unaligned_memcpy(void *, const void *, size_t);
+extern int unaligned_memcmp(const void *, const void *, size_t);
+#define UNALIGNED_MEMCPY(p, q, l) unaligned_memcpy((p), (q), (l))
+#define UNALIGNED_MEMCMP(p, q, l) unaligned_memcmp((p), (q), (l))
+#else
+/*
+ * The procesor natively handles unaligned loads, so just use memcpy()
+ * and memcmp(), to enable those optimizations.
+ */
+#define UNALIGNED_MEMCPY(p, q, l) memcpy((p), (q), (l))
+#define UNALIGNED_MEMCMP(p, q, l) memcmp((p), (q), (l))
+#endif
#define PLURAL_SUFFIX(n) \
(((n) != 1) ? "s" : "")
#if 0
-extern const char *isonsap_string(netdissect_options *, const u_char *);
-extern const char *protoid_string(netdissect_options *, const u_char *);
extern const char *dnname_string(netdissect_options *, u_short);
extern const char *dnnum_string(netdissect_options *, u_short);
#endif
@@ -283,11 +341,11 @@ extern if_printer lookup_printer(int);
extern void eap_print(netdissect_options *,const u_char *, u_int);
extern int esp_print(netdissect_options *,
- register const u_char *bp, int len, register const u_char *bp2,
+ const u_char *bp, const int length, const u_char *bp2,
int *nhdr, int *padlen);
extern void arp_print(netdissect_options *,const u_char *, u_int, u_int);
extern void tipc_print(netdissect_options *, const u_char *, u_int, u_int);
-extern void msnlb_print(netdissect_options *, const u_char *, u_int);
+extern void msnlb_print(netdissect_options *, const u_char *);
extern void icmp6_print(netdissect_options *ndo, const u_char *,
u_int, const u_char *, int);
extern void isakmp_print(netdissect_options *,const u_char *,
@@ -299,6 +357,8 @@ extern void ip_print_inner(netdissect_options *ndo,
const u_char *bp, u_int length, u_int nh,
const u_char *bp2);
extern void rrcp_print(netdissect_options *,const u_char *, u_int);
+extern void loopback_print(netdissect_options *, const u_char *, const u_int);
+extern void carp_print(netdissect_options *, const u_char *, u_int, int);
extern void ether_print(netdissect_options *,
const u_char *, u_int, u_int,
@@ -316,193 +376,214 @@ extern u_int netanalyzer_transparent_if_print(netdissect_options *,
extern int ethertype_print(netdissect_options *,u_short, const u_char *,
u_int, u_int);
+extern int print_unknown_data(netdissect_options *,const u_char *, const char *,int);
+extern void ascii_print(netdissect_options *, const u_char *, u_int);
+extern void hex_print_with_offset(netdissect_options *, const char *ident, const u_char *cp,
+ u_int, u_int);
+extern void hex_print(netdissect_options *,const char *ident, const u_char *cp,u_int);
+extern void hex_and_ascii_print_with_offset(netdissect_options *, const char *, const u_char *, u_int, u_int);
+extern void hex_and_ascii_print(netdissect_options *, const char *, const u_char *, u_int);
+
+extern int ah_print(netdissect_options *, register const u_char *);
+extern void beep_print(netdissect_options *, const u_char *, u_int);
+extern void dtp_print(netdissect_options *, const u_char *, u_int);
+extern u_int cip_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern int ipcomp_print(netdissect_options *, register const u_char *, int *);
+extern u_int ipfc_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern void udld_print(netdissect_options *, const u_char *, u_int);
+extern void hsrp_print(netdissect_options *, const u_char *, u_int);
+extern void igrp_print(netdissect_options *, const u_char *, u_int);
+extern void msdp_print(netdissect_options *, const u_char *, u_int);
+extern u_int null_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern void mobile_print(netdissect_options *, const u_char *, u_int);
+extern u_int ap1394_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int bt_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern void lane_print(netdissect_options *, const u_char *, u_int, u_int);
+extern u_int lane_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern void otv_print(netdissect_options *, const u_char *, u_int);
+extern void ahcp_print(netdissect_options *, const u_char *, const u_int);
+extern void vxlan_print(netdissect_options *, const u_char *, u_int);
+extern u_int arcnet_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int arcnet_linux_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern void bfd_print(netdissect_options *, const u_char *, u_int, u_int);
+extern void gre_print(netdissect_options *, const u_char *, u_int);
+extern int vjc_print(netdissect_options *, register const char *, u_short);
+extern void ipN_print(netdissect_options *, const u_char *, u_int);
+extern u_int raw_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int usb_linux_48_byte_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int usb_linux_64_byte_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int symantec_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int chdlc_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int chdlc_print(netdissect_options *, register const u_char *, u_int);
+extern void zmtp1_print(netdissect_options *, const u_char *, u_int);
+extern void zmtp1_print_datagram(netdissect_options *, const u_char *, const u_int);
+extern void ipx_print(netdissect_options *, const u_char *, u_int);
+extern void mpls_print(netdissect_options *, const u_char *, u_int);
+extern u_int pppoe_print(netdissect_options *, const u_char *, u_int);
+extern u_int pppoe_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern void sunrpcrequest_print(netdissect_options *, const u_char *, u_int, const u_char *);
+extern u_int pflog_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int token_print(netdissect_options *, const u_char *, u_int, u_int);
+extern u_int token_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern void vqp_print(netdissect_options *, register const u_char *, register u_int);
+extern void zephyr_print(netdissect_options *, const u_char *, int);
+extern void fddi_print(netdissect_options *, const u_char *, u_int, u_int);
+extern u_int fddi_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern void mpcp_print(netdissect_options *, const u_char *, u_int);
+extern void rpki_rtr_print(netdissect_options *, const u_char *, u_int);
+extern u_int sll_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern void dccp_print(netdissect_options *, const u_char *, const u_char *, u_int);
+extern int llc_print(netdissect_options *, const u_char *, u_int, u_int, const u_char *, const u_char *, u_short *);
+extern int snap_print(netdissect_options *, const u_char *, u_int, u_int, u_int);
+extern void eigrp_print(netdissect_options *, const u_char *, u_int);
+extern void stp_print(netdissect_options *, const u_char *, u_int);
+extern void l2tp_print(netdissect_options *, const u_char *, u_int);
+extern void udp_print(netdissect_options *, const u_char *, u_int, const u_char *, int);
+extern void icmp_print(netdissect_options *, const u_char *, u_int, const u_char *, int);
+extern void openflow_print(netdissect_options *, const u_char *, const u_int);
+extern void telnet_print(netdissect_options *, const u_char *, u_int);
+extern void slow_print(netdissect_options *, const u_char *, u_int);
+extern void radius_print(netdissect_options *, const u_char *, u_int);
+extern void lmp_print(netdissect_options *, const u_char *, u_int);
+extern u_int fr_print(netdissect_options *, register const u_char *, u_int);
+extern u_int mfr_print(netdissect_options *, register const u_char *, u_int);
+extern u_int fr_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int mfr_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern void q933_print(netdissect_options *, const u_char *, u_int);
+extern void igmp_print(netdissect_options *, const u_char *, u_int);
+extern void rip_print(netdissect_options *, const u_char *, u_int);
+extern void lwapp_control_print(netdissect_options *, const u_char *, u_int, int);
+extern void lwapp_data_print(netdissect_options *, const u_char *, u_int);
+extern void pgm_print(netdissect_options *, const u_char *, u_int, const u_char *);
+extern void pptp_print(netdissect_options *, const u_char *);
+extern void ldp_print(netdissect_options *, const u_char *, u_int);
+extern void wb_print(netdissect_options *, const void *, u_int);
+extern int oam_print(netdissect_options *, const u_char *, u_int, u_int);
+extern void atm_print(netdissect_options *, u_int, u_int, u_int, const u_char *, u_int, u_int);
+extern u_int sunatm_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int atm_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern void vtp_print(netdissect_options *, const u_char *, u_int);
+extern int mptcp_print(netdissect_options *, const u_char *, u_int, u_char);
+extern void ntp_print(netdissect_options *, const u_char *, u_int);
+extern void cnfp_print(netdissect_options *, const u_char *, const u_char *);
+extern void dvmrp_print(netdissect_options *, const u_char *, u_int);
+extern void egp_print(netdissect_options *, const u_char *, u_int);
+extern u_int enc_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int sl_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int sl_bsdos_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern void tftp_print(netdissect_options *, const u_char *, u_int);
+extern void vrrp_print(netdissect_options *, const u_char *, u_int, const u_char *, int);
+extern void pimv1_print(netdissect_options *, const u_char *, u_int);
+extern void cisco_autorp_print(netdissect_options *, const u_char *, u_int);
+extern void pim_print(netdissect_options *, const u_char *, u_int, u_int);
+extern const u_char * ns_nprint (netdissect_options *, register const u_char *, register const u_char *);
+extern void ns_print(netdissect_options *, const u_char *, u_int, int);
+extern void bootp_print(netdissect_options *, const u_char *, u_int);
+extern void sflow_print(netdissect_options *, const u_char *, u_int);
+extern void aodv_print(netdissect_options *, const u_char *, u_int, int);
+extern void sctp_print(netdissect_options *, const u_char *, const u_char *, u_int);
+extern char *bgp_vpn_rd_print (netdissect_options *, const u_char *);
+extern void bgp_print(netdissect_options *, const u_char *, int);
+extern void olsr_print(netdissect_options *, const u_char *, u_int, int);
+extern void forces_print(netdissect_options *, const u_char *, u_int);
+extern void lspping_print(netdissect_options *, const u_char *, u_int);
+extern void isoclns_print(netdissect_options *, const u_char *, u_int, u_int);
+extern void krb_print(netdissect_options *, const u_char *);
+extern void cdp_print(netdissect_options *, const u_char *, u_int, u_int);
+extern void atalk_print(netdissect_options *, const u_char *, u_int);
+extern u_int ltalk_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int llap_print(netdissect_options *, const u_char *, u_int);
+extern void aarp_print(netdissect_options *, const u_char *, u_int);
+extern u_int juniper_atm1_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int juniper_atm2_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int juniper_mfr_print(netdissect_options *, const struct pcap_pkthdr *, register const u_char *);
+extern u_int juniper_mlfr_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int juniper_mlppp_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int juniper_pppoe_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int juniper_pppoe_atm_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int juniper_ggsn_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int juniper_es_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int juniper_monitor_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int juniper_services_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int juniper_ether_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int juniper_ppp_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int juniper_frelay_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int juniper_chdlc_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern void snmp_print(netdissect_options *, const u_char *, u_int);
+extern void rx_print(netdissect_options *, register const u_char *, int, int, int, u_char *);
+extern void nfsreply_print(netdissect_options *, const u_char *, u_int, const u_char *);
+extern void nfsreply_print_noaddr(netdissect_options *, const u_char *, u_int, const u_char *);
+extern void nfsreq_print_noaddr(netdissect_options *, const u_char *, u_int, const u_char *);
+extern void sip_print(netdissect_options *, const u_char *, u_int);
+extern void syslog_print(netdissect_options *, const u_char *, u_int);
+extern void lwres_print(netdissect_options *, const u_char *, u_int);
+extern void cfm_print(netdissect_options *, const u_char *, u_int);
+extern void nbt_tcp_print(netdissect_options *, const u_char *, int);
+extern void nbt_udp137_print(netdissect_options *, const u_char *, int);
+extern void nbt_udp138_print(netdissect_options *, const u_char *, int);
+extern void smb_tcp_print(netdissect_options *, const u_char *, int);
+extern void netbeui_print(netdissect_options *, u_short, const u_char *, int);
+extern void ipx_netbios_print(netdissect_options *, const u_char *, u_int);
+extern void print_data(netdissect_options *, const unsigned char *, int);
+extern void decnet_print(netdissect_options *, const u_char *, u_int, u_int);
+extern void tcp_print(netdissect_options *, const u_char *, u_int, const u_char *, int);
+extern void ospf_print(netdissect_options *, const u_char *, u_int, const u_char *);
+extern int ospf_print_te_lsa(netdissect_options *, const uint8_t *, u_int);
+extern int ospf_print_grace_lsa(netdissect_options *, const uint8_t *, u_int);
+extern u_int ppp_print(netdissect_options *, register const u_char *, u_int);
+extern u_int ppp_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int ppp_hdlc_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int ppp_bsdos_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern void lldp_print(netdissect_options *, const u_char *, u_int);
+extern void rsvp_print(netdissect_options *, const u_char *, u_int);
+extern void timed_print(netdissect_options *, const u_char *);
+extern void m3ua_print(netdissect_options *, const u_char *, const u_int);
+extern void aoe_print(netdissect_options *, const u_char *, const u_int);
+
/* stuff that has not yet been rototiled */
+
#if 0
extern void ascii_print(netdissect_options *,u_int);
-extern void hex_and_ascii_print_with_offset(netdissect_options *,const char *,
- u_int, u_int);
-extern void hex_and_ascii_print(netdissect_options *,const char *, u_int);
-extern void hex_print_with_offset(netdissect_options *,const char *,
- u_int, u_int);
-extern void hex_print(netdissect_options *,const char *, u_int);
-extern void telnet_print(netdissect_options *,const u_char *, u_int);
-extern int llc_print(netdissect_options *,
- const u_char *, u_int, u_int, const u_char *,
- const u_char *, u_short *);
-extern void aarp_print(netdissect_options *,const u_char *, u_int);
-extern void atalk_print(netdissect_options *,const u_char *, u_int);
-extern void atm_if_print(u_char *,const struct pcap_pkthdr *, const u_char *);
-extern void bootp_print(netdissect_options *,const u_char *,
- u_int, u_short, u_short);
-extern void bgp_print(netdissect_options *,const u_char *, int);
-extern void bxxp_print(netdissect_options *,const u_char *, u_int);
-extern void chdlc_if_print(u_char *user, const struct pcap_pkthdr *h,
- register const u_char *p);
-extern void chdlc_print(netdissect_options *ndo,
- register const u_char *p, u_int length, u_int caplen);
-extern void cisco_autorp_print(netdissect_options *,
- const u_char *, u_int);
-extern void cnfp_print(netdissect_options *,const u_char *cp,
- u_int len, const u_char *bp);
-extern void decnet_print(netdissect_options *,const u_char *,
- u_int, u_int);
extern void default_print(netdissect_options *,const u_char *, u_int);
-extern void dvmrp_print(netdissect_options *,const u_char *, u_int);
-extern void egp_print(netdissect_options *,const u_char *, u_int,
- const u_char *);
-
-extern void arcnet_if_print(u_char*,const struct pcap_pkthdr *,const u_char *);
-extern void token_if_print(u_char *,const struct pcap_pkthdr *,const u_char *);
-extern void fddi_if_print(u_char *,const struct pcap_pkthdr *, const u_char *);
-
-extern void gre_print(netdissect_options *,const u_char *, u_int);
-extern void icmp_print(netdissect_options *,const u_char *, u_int,
- const u_char *);
-extern void hsrp_print(netdissect_options *ndo,
- register const u_char *bp, register u_int len);
-extern void ieee802_11_if_print(u_char *,const struct pcap_pkthdr *, const u_char *);
-extern void igmp_print(netdissect_options *,
- register const u_char *, u_int);
-extern void igrp_print(netdissect_options *,const u_char *, u_int,
- const u_char *);
-extern int nextproto4_cksum(const struct ip *, const u_int8_t *, u_int, u_int);
-extern void ipN_print(netdissect_options *,const u_char *, u_int);
-extern void ipx_print(netdissect_options *,const u_char *, u_int);
-extern void isoclns_print(netdissect_options *,const u_char *,
- u_int, u_int, const u_char *, const u_char *);
-extern void krb_print(netdissect_options *,const u_char *, u_int);
-extern void llap_print(netdissect_options *,const u_char *, u_int);
-extern const char *linkaddr_string(netdissect_options *ndo,
- const u_char *ep, const unsigned int len);
-extern void ltalk_if_print(netdissect_options *ndo,
- u_char *user, const struct pcap_pkthdr *h,
- const u_char *p);
-extern void mpls_print(netdissect_options *ndo,
- const u_char *bp, u_int length);
-extern void msdp_print(netdissect_options *ndo,
- const unsigned char *sp, u_int length);
-extern void nfsreply_print(netdissect_options *,const u_char *,
- u_int, const u_char *);
-extern void nfsreq_print(netdissect_options *,const u_char *,
- u_int, const u_char *);
-extern void ns_print(netdissect_options *,const u_char *, u_int);
-extern void ntp_print(netdissect_options *,const u_char *, u_int);
-extern void null_if_print(u_char *,const struct pcap_pkthdr *, const u_char *);
-extern void ospf_print(netdissect_options *,const u_char *,
- u_int, const u_char *);
-extern void pimv1_print(netdissect_options *,const u_char *, u_int);
-extern void mobile_print(netdissect_options *,const u_char *, u_int);
-extern void pim_print(netdissect_options *,const u_char *, u_int, u_int);
-extern void pppoe_if_print(u_char *,const struct pcap_pkthdr *, const u_char *);
-extern void pppoe_print(netdissect_options *,const u_char *, u_int);
-extern void ppp_print(netdissect_options *,
- register const u_char *, u_int);
-
-extern void ppp_if_print(u_char *,const struct pcap_pkthdr *, const u_char *);
-extern void ppp_hdlc_if_print(u_char *,
- const struct pcap_pkthdr *, const u_char *);
-extern void ppp_bsdos_if_print(u_char *,
- const struct pcap_pkthdr *, const u_char *);
-
-extern int vjc_print(netdissect_options *,register const char *,
- register u_int, u_short);
-
-extern void raw_if_print(u_char *,
- const struct pcap_pkthdr *, const u_char *);
-
-extern void rip_print(netdissect_options *,const u_char *, u_int);
-extern void rpki_rtr_print(netdissect_options *,const u_char *, u_int);
-
-extern void sctp_print(netdissect_options *ndo,
- const u_char *bp, const u_char *bp2,
- u_int sctpPacketLength);
-
-extern void sl_if_print(u_char *,const struct pcap_pkthdr *, const u_char *);
-
-extern void lane_if_print(u_char *,const struct pcap_pkthdr *,const u_char *);
-extern void cip_if_print(u_char *,const struct pcap_pkthdr *,const u_char *);
-extern void sl_bsdos_if_print(u_char *,
- const struct pcap_pkthdr *, const u_char *);
-extern void sll_if_print(u_char *,
- const struct pcap_pkthdr *, const u_char *);
-
-extern void snmp_print(netdissect_options *,const u_char *, u_int);
-extern void sunrpcrequest_print(netdissect_options *,const u_char *,
- u_int, const u_char *);
-extern void tcp_print(netdissect_options *,const u_char *, u_int,
- const u_char *, int);
-extern void tftp_print(netdissect_options *,const u_char *, u_int);
-extern void timed_print(netdissect_options *,const u_char *, u_int);
-extern void udp_print(netdissect_options *,const u_char *, u_int,
- const u_char *, int);
-extern void wb_print(netdissect_options *,const void *, u_int);
-extern int ah_print(netdissect_options *,register const u_char *,
- register const u_char *);
-extern void esp_print_decodesecret(netdissect_options *ndo);
-extern int ipcomp_print(netdissect_options *,register const u_char *,
- register const u_char *, int *);
-extern void rx_print(netdissect_options *,register const u_char *,
- int, int, int, u_char *);
-extern void netbeui_print(netdissect_options *,u_short,
- const u_char *, int);
-extern void ipx_netbios_print(netdissect_options *,const u_char *, u_int);
-extern void nbt_tcp_print(netdissect_options *,const u_char *, int);
-extern void nbt_udp137_print(netdissect_options *,
- const u_char *data, int);
-extern void nbt_udp138_print(netdissect_options *,
- const u_char *data, int);
extern char *smb_errstr(netdissect_options *,int, int);
-extern const char *nt_errstr(netdissect_options *, u_int32_t);
-extern void print_data(netdissect_options *,const unsigned char *, int);
-extern void l2tp_print(netdissect_options *,const u_char *, u_int);
-extern void lcp_print(netdissect_options *,const u_char *, u_int);
-extern void vrrp_print(netdissect_options *,const u_char *bp,
- u_int len, int ttl);
-extern void carp_print(netdissect_options *,const u_char *bp,
- u_int len, int ttl);
-extern void cdp_print(netdissect_options *,const u_char *,
- u_int, u_int, const u_char *, const u_char *);
-extern void stp_print(netdissect_options *,const u_char *p, u_int length);
-extern void radius_print(netdissect_options *,const u_char *, u_int);
-extern void lwres_print(netdissect_options *,const u_char *, u_int);
-extern void pptp_print(netdissect_options *,const u_char *, u_int);
+extern const char *nt_errstr(netdissect_options *, uint32_t);
#endif
extern u_int ipnet_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *);
extern u_int ppi_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *);
-
+extern u_int nflog_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *);
extern u_int ieee802_15_4_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *);
+extern u_int pktap_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *);
+extern u_int ieee802_11_radio_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int ieee802_11_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int ieee802_11_radio_avs_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int prism_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
#ifdef INET6
extern void ip6_print(netdissect_options *,const u_char *, u_int);
-#if 0
-extern void ip6_opt_print(netdissect_options *,const u_char *, int);
-extern int nextproto6_cksum(const struct ip6_hdr *, const u_int8_t *, u_int, u_int);
-extern int hbhopt_print(netdissect_options *,const u_char *);
-extern int dstopt_print(netdissect_options *,const u_char *);
-extern int frag6_print(netdissect_options *,const u_char *,
- const u_char *);
-extern void icmp6_print(netdissect_options *,const u_char *,
- const u_char *);
-extern void ripng_print(netdissect_options *,const u_char *, int);
-extern int rt6_print(netdissect_options *,const u_char *, const u_char *);
-extern void ospf6_print(netdissect_options *,const u_char *, u_int);
-extern void dhcp6_print(netdissect_options *,const u_char *,
- u_int, u_int16_t, u_int16_t);
-
-extern void zephyr_print(netdissect_options * ndo,
- const u_char *cp, int length);
-#endif /* 0 */
-
+extern int frag6_print(netdissect_options *, const u_char *, const u_char *);
+extern int rt6_print(netdissect_options *, const u_char *, const u_char *);
+extern int hbhopt_print(netdissect_options *, const u_char *);
+extern int dstopt_print(netdissect_options *, const u_char *);
+extern void ripng_print(netdissect_options *, const u_char *, unsigned int);
+extern int mobility_print(netdissect_options *, const u_char *, const u_char *);
+extern void dhcp6_print(netdissect_options *, const u_char *, u_int);
+extern void ospf6_print(netdissect_options *, const u_char *, u_int);
+extern void babel_print(netdissect_options *, const u_char *, u_int);
#endif /*INET6*/
#if 0
struct cksum_vec {
- const u_int8_t *ptr;
+ const uint8_t *ptr;
int len;
};
-extern u_int16_t in_cksum(const struct cksum_vec *, int);
-extern u_int16_t in_cksum_shouldbe(u_int16_t, u_int16_t);
+extern uint16_t in_cksum(const struct cksum_vec *, int);
+extern uint16_t in_cksum_shouldbe(uint16_t, uint16_t);
+#endif
+extern int nextproto4_cksum(netdissect_options *ndo, const struct ip *, const uint8_t *, u_int, u_int, u_int);
+extern int decode_prefix4(netdissect_options *ndo, const u_char *, u_int, char *, u_int);
+#ifdef INET6
+extern int decode_prefix6(netdissect_options *ndo, const u_char *, u_int, char *, u_int);
#endif
extern void esp_print_decodesecret(netdissect_options *ndo);
@@ -512,4 +593,7 @@ extern int esp_print_decrypt_buffer_by_ikev2(netdissect_options *ndo,
u_char *buf, u_char *end);
+extern void geonet_print(netdissect_options *ndo,const u_char *eth_hdr,const u_char *geo_pck, u_int len);
+extern void calm_fast_print(netdissect_options *ndo,const u_char *eth_hdr,const u_char *calm_pck, u_int len);
+
#endif /* netdissect_h */
diff --git a/contrib/tcpdump/nfs.h b/contrib/tcpdump/nfs.h
index b35e2cd575eb..a47c005c89d6 100644
--- a/contrib/tcpdump/nfs.h
+++ b/contrib/tcpdump/nfs.h
@@ -1,4 +1,3 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/nfs.h,v 1.9 2007-11-18 03:24:38 guy Exp $ (LBL) */
/* NetBSD: nfs.h,v 1.1 1996/05/23 22:49:53 fvdl Exp */
/*
@@ -240,11 +239,11 @@
txdr_unsigned(((t) == VFIFO) ? MAKEIMODE(VCHR, (m)) : \
MAKEIMODE((t), (m)))
#define vtonfsv3_mode(m) txdr_unsigned((m) & 07777)
-#define nfstov_mode(a) (fxdr_unsigned(u_int16_t, (a))&07777)
+#define nfstov_mode(a) (fxdr_unsigned(uint16_t, (a))&07777)
#define vtonfsv2_type(a) txdr_unsigned(nfsv2_type[((int32_t)(a))])
#define vtonfsv3_type(a) txdr_unsigned(nfsv3_type[((int32_t)(a))])
-#define nfsv2tov_type(a) nv2tov_type[fxdr_unsigned(u_int32_t,(a))&0x7]
-#define nfsv3tov_type(a) nv3tov_type[fxdr_unsigned(u_int32_t,(a))&0x7]
+#define nfsv2tov_type(a) nv2tov_type[fxdr_unsigned(uint32_t,(a))&0x7]
+#define nfsv3tov_type(a) nv3tov_type[fxdr_unsigned(uint32_t,(a))&0x7]
/* File types */
typedef enum { NFNON=0, NFREG=1, NFDIR=2, NFBLK=3, NFCHR=4, NFLNK=5,
@@ -268,14 +267,14 @@ union nfsfh {
typedef union nfsfh nfsfh_t;
struct nfsv2_time {
- u_int32_t nfsv2_sec;
- u_int32_t nfsv2_usec;
+ uint32_t nfsv2_sec;
+ uint32_t nfsv2_usec;
};
typedef struct nfsv2_time nfstime2;
struct nfsv3_time {
- u_int32_t nfsv3_sec;
- u_int32_t nfsv3_nsec;
+ uint32_t nfsv3_sec;
+ uint32_t nfsv3_nsec;
};
typedef struct nfsv3_time nfstime3;
@@ -284,7 +283,7 @@ typedef struct nfsv3_time nfstime3;
* protocol and to facilitate xdr conversion.
*/
struct nfs_uquad {
- u_int32_t nfsuquad[2];
+ uint32_t nfsuquad[2];
};
typedef struct nfs_uquad nfsuint64;
@@ -292,8 +291,8 @@ typedef struct nfs_uquad nfsuint64;
* NFS Version 3 special file number.
*/
struct nfsv3_spec {
- u_int32_t specdata1;
- u_int32_t specdata2;
+ uint32_t specdata1;
+ uint32_t specdata2;
};
typedef struct nfsv3_spec nfsv3spec;
@@ -307,19 +306,19 @@ typedef struct nfsv3_spec nfsv3spec;
* NFSX_FATTR(v3) macro.
*/
struct nfs_fattr {
- u_int32_t fa_type;
- u_int32_t fa_mode;
- u_int32_t fa_nlink;
- u_int32_t fa_uid;
- u_int32_t fa_gid;
+ uint32_t fa_type;
+ uint32_t fa_mode;
+ uint32_t fa_nlink;
+ uint32_t fa_uid;
+ uint32_t fa_gid;
union {
struct {
- u_int32_t nfsv2fa_size;
- u_int32_t nfsv2fa_blocksize;
- u_int32_t nfsv2fa_rdev;
- u_int32_t nfsv2fa_blocks;
- u_int32_t nfsv2fa_fsid;
- u_int32_t nfsv2fa_fileid;
+ uint32_t nfsv2fa_size;
+ uint32_t nfsv2fa_blocksize;
+ uint32_t nfsv2fa_rdev;
+ uint32_t nfsv2fa_blocks;
+ uint32_t nfsv2fa_fsid;
+ uint32_t nfsv2fa_fileid;
nfstime2 nfsv2fa_atime;
nfstime2 nfsv2fa_mtime;
nfstime2 nfsv2fa_ctime;
@@ -357,10 +356,10 @@ struct nfs_fattr {
#define fa3_ctime fa_un.fa_nfsv3.nfsv3fa_ctime
struct nfsv2_sattr {
- u_int32_t sa_mode;
- u_int32_t sa_uid;
- u_int32_t sa_gid;
- u_int32_t sa_size;
+ uint32_t sa_mode;
+ uint32_t sa_uid;
+ uint32_t sa_gid;
+ uint32_t sa_size;
nfstime2 sa_atime;
nfstime2 sa_mtime;
};
@@ -369,28 +368,28 @@ struct nfsv2_sattr {
* NFS Version 3 sattr structure for the new node creation case.
*/
struct nfsv3_sattr {
- u_int32_t sa_modeset;
- u_int32_t sa_mode;
- u_int32_t sa_uidset;
- u_int32_t sa_uid;
- u_int32_t sa_gidset;
- u_int32_t sa_gid;
- u_int32_t sa_sizeset;
- u_int32_t sa_size;
- u_int32_t sa_atimetype;
+ uint32_t sa_modeset;
+ uint32_t sa_mode;
+ uint32_t sa_uidset;
+ uint32_t sa_uid;
+ uint32_t sa_gidset;
+ uint32_t sa_gid;
+ uint32_t sa_sizeset;
+ uint32_t sa_size;
+ uint32_t sa_atimetype;
nfstime3 sa_atime;
- u_int32_t sa_mtimetype;
+ uint32_t sa_mtimetype;
nfstime3 sa_mtime;
};
struct nfs_statfs {
union {
struct {
- u_int32_t nfsv2sf_tsize;
- u_int32_t nfsv2sf_bsize;
- u_int32_t nfsv2sf_blocks;
- u_int32_t nfsv2sf_bfree;
- u_int32_t nfsv2sf_bavail;
+ uint32_t nfsv2sf_tsize;
+ uint32_t nfsv2sf_bsize;
+ uint32_t nfsv2sf_blocks;
+ uint32_t nfsv2sf_bfree;
+ uint32_t nfsv2sf_bavail;
} sf_nfsv2;
struct {
nfsuint64 nfsv3sf_tbytes;
@@ -399,7 +398,7 @@ struct nfs_statfs {
nfsuint64 nfsv3sf_tfiles;
nfsuint64 nfsv3sf_ffiles;
nfsuint64 nfsv3sf_afiles;
- u_int32_t nfsv3sf_invarsec;
+ uint32_t nfsv3sf_invarsec;
} sf_nfsv3;
} sf_un;
};
@@ -418,23 +417,23 @@ struct nfs_statfs {
#define sf_invarsec sf_un.sf_nfsv3.nfsv3sf_invarsec
struct nfsv3_fsinfo {
- u_int32_t fs_rtmax;
- u_int32_t fs_rtpref;
- u_int32_t fs_rtmult;
- u_int32_t fs_wtmax;
- u_int32_t fs_wtpref;
- u_int32_t fs_wtmult;
- u_int32_t fs_dtpref;
+ uint32_t fs_rtmax;
+ uint32_t fs_rtpref;
+ uint32_t fs_rtmult;
+ uint32_t fs_wtmax;
+ uint32_t fs_wtpref;
+ uint32_t fs_wtmult;
+ uint32_t fs_dtpref;
nfsuint64 fs_maxfilesize;
nfstime3 fs_timedelta;
- u_int32_t fs_properties;
+ uint32_t fs_properties;
};
struct nfsv3_pathconf {
- u_int32_t pc_linkmax;
- u_int32_t pc_namemax;
- u_int32_t pc_notrunc;
- u_int32_t pc_chownrestricted;
- u_int32_t pc_caseinsensitive;
- u_int32_t pc_casepreserving;
+ uint32_t pc_linkmax;
+ uint32_t pc_namemax;
+ uint32_t pc_notrunc;
+ uint32_t pc_chownrestricted;
+ uint32_t pc_caseinsensitive;
+ uint32_t pc_casepreserving;
};
diff --git a/contrib/tcpdump/nfsfh.h b/contrib/tcpdump/nfsfh.h
index 823671321957..fbc2355de4cb 100644
--- a/contrib/tcpdump/nfsfh.h
+++ b/contrib/tcpdump/nfsfh.h
@@ -1,5 +1,3 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/nfsfh.h,v 1.13 2002-04-24 06:27:05 guy Exp $ (LBL) */
-
/*
* Copyright (c) 1993, 1994 Jeffrey C. Mogul, Digital Equipment Corporation,
* Western Research Laboratory. All rights reserved.
@@ -48,8 +46,8 @@
* that we might be spying upon use different external representations.
*/
typedef struct {
- u_int32_t Minor; /* upper case to avoid clashing with macro names */
- u_int32_t Major;
+ uint32_t Minor; /* upper case to avoid clashing with macro names */
+ uint32_t Major;
} my_devt;
#define dev_eq(a,b) ((a.Minor == b.Minor) && (a.Major == b.Major))
@@ -61,10 +59,10 @@ typedef struct {
typedef struct {
my_devt Fsid_dev; /* XXX avoid name conflict with AIX */
char Opaque_Handle[2 * 32 + 1];
- u_int32_t fsid_code;
+ uint32_t fsid_code;
} my_fsid;
#define fsid_eq(a,b) ((a.fsid_code == b.fsid_code) &&\
dev_eq(a.Fsid_dev, b.Fsid_dev))
-extern void Parse_fh(const unsigned char *, int, my_fsid *, ino_t *, const char **, const char **, int);
+extern void Parse_fh(const unsigned char *, int, my_fsid *, uint32_t *, const char **, const char **, int);
diff --git a/contrib/tcpdump/nlpid.c b/contrib/tcpdump/nlpid.c
index 9579ba3a1629..919e87dd4ae8 100644
--- a/contrib/tcpdump/nlpid.c
+++ b/contrib/tcpdump/nlpid.c
@@ -1,4 +1,4 @@
-/*
+/*
* 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
@@ -13,11 +13,7 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/nlpid.c,v 1.4 2004-10-19 15:27:55 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
diff --git a/contrib/tcpdump/nlpid.h b/contrib/tcpdump/nlpid.h
index 1546fc6ec76d..63a2e7095d42 100644
--- a/contrib/tcpdump/nlpid.h
+++ b/contrib/tcpdump/nlpid.h
@@ -1,5 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/nlpid.h,v 1.4 2004-10-19 15:27:55 hannes Exp $ (LBL) */
-/*
+/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code
* distributions retain the above copyright notice and this paragraph
diff --git a/contrib/tcpdump/ntp.h b/contrib/tcpdump/ntp.h
deleted file mode 100644
index 0614f73ba8bd..000000000000
--- a/contrib/tcpdump/ntp.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/* $Header: /tcpdump/master/tcpdump/ntp.h,v 1.8 2004-01-28 14:34:50 hannes Exp $ */
-
-/*
- * Based on ntp.h from the U of MD implementation
- * This file is based on Version 2 of the NTP spec (RFC1119).
- */
-
-/*
- * Definitions for the masses
- */
-#define JAN_1970 2208988800U /* 1970 - 1900 in seconds */
-
-/*
- * Structure definitions for NTP fixed point values
- *
- * 0 1 2 3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Integer Part |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Fraction Part |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *
- * 0 1 2 3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Integer Part | Fraction Part |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-*/
-struct l_fixedpt {
- u_int32_t int_part;
- u_int32_t fraction;
-};
-
-struct s_fixedpt {
- u_int16_t int_part;
- u_int16_t fraction;
-};
-
-/* rfc2030
- * 1 2 3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * |LI | VN |Mode | Stratum | Poll | Precision |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Root Delay |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Root Dispersion |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Reference Identifier |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | |
- * | Reference Timestamp (64) |
- * | |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | |
- * | Originate Timestamp (64) |
- * | |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | |
- * | Receive Timestamp (64) |
- * | |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | |
- * | Transmit Timestamp (64) |
- * | |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Key Identifier (optional) (32) |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | |
- * | |
- * | Message Digest (optional) (128) |
- * | |
- * | |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
-struct ntpdata {
- u_char status; /* status of local clock and leap info */
- u_char stratum; /* Stratum level */
- u_char ppoll; /* poll value */
- int precision:8;
- struct s_fixedpt root_delay;
- struct s_fixedpt root_dispersion;
- u_int32_t refid;
- struct l_fixedpt ref_timestamp;
- struct l_fixedpt org_timestamp;
- struct l_fixedpt rec_timestamp;
- struct l_fixedpt xmt_timestamp;
- u_int32_t key_id;
- u_int8_t message_digest[16];
-};
-/*
- * Leap Second Codes (high order two bits)
- */
-#define NO_WARNING 0x00 /* no warning */
-#define PLUS_SEC 0x40 /* add a second (61 seconds) */
-#define MINUS_SEC 0x80 /* minus a second (59 seconds) */
-#define ALARM 0xc0 /* alarm condition (clock unsynchronized) */
-
-/*
- * Clock Status Bits that Encode Version
- */
-#define NTPVERSION_1 0x08
-#define VERSIONMASK 0x38
-#define LEAPMASK 0xc0
-#define MODEMASK 0x07
-
-/*
- * Code values
- */
-#define MODE_UNSPEC 0 /* unspecified */
-#define MODE_SYM_ACT 1 /* symmetric active */
-#define MODE_SYM_PAS 2 /* symmetric passive */
-#define MODE_CLIENT 3 /* client */
-#define MODE_SERVER 4 /* server */
-#define MODE_BROADCAST 5 /* broadcast */
-#define MODE_RES1 6 /* reserved */
-#define MODE_RES2 7 /* reserved */
-
-/*
- * Stratum Definitions
- */
-#define UNSPECIFIED 0
-#define PRIM_REF 1 /* radio clock */
-#define INFO_QUERY 62 /* **** THIS implementation dependent **** */
-#define INFO_REPLY 63 /* **** THIS implementation dependent **** */
diff --git a/contrib/tcpdump/oakley.h b/contrib/tcpdump/oakley.h
deleted file mode 100644
index ad328171b336..000000000000
--- a/contrib/tcpdump/oakley.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-/* YIPS @(#)$Id: oakley.h,v 1.4 2002-12-11 07:13:56 guy Exp $ */
-
-/* refer to RFC 2409 */
-
-#if !defined(_ISAKMP_OAKLEY_H_)
-#define _ISAKMP_OAKLEY_H_
-
-/* Attribute Classes */
-#define OAKLEY_ATTR_ENC_ALG 1 /* B */
-#define OAKLEY_ATTR_ENC_ALG_DES 1
-#define OAKLEY_ATTR_ENC_ALG_IDEA 2
-#define OAKLEY_ATTR_ENC_ALG_BL 3
-#define OAKLEY_ATTR_ENC_ALG_RC5 4
-#define OAKLEY_ATTR_ENC_ALG_3DES 5
-#define OAKLEY_ATTR_ENC_ALG_CAST 6
-#define OAKLEY_ATTR_HASH_ALG 2 /* B */
-#define OAKLEY_ATTR_HASH_ALG_MD5 1
-#define OAKLEY_ATTR_HASH_ALG_SHA 2
-#define OAKLEY_ATTR_HASH_ALG_TIGER 3
-#define OAKLEY_ATTR_AUTH_METHOD 3 /* B */
-#define OAKLEY_ATTR_AUTH_METHOD_PSKEY 1
-#define OAKLEY_ATTR_AUTH_METHOD_DSS 2
-#define OAKLEY_ATTR_AUTH_METHOD_RSA 3
-#define OAKLEY_ATTR_AUTH_METHOD_RSAENC 4
-#define OAKLEY_ATTR_AUTH_METHOD_RSAREV 5
-#define OAKLEY_ATTR_GRP_DESC 4 /* B */
-#define OAKLEY_ATTR_GRP_DESC_MODP768 1
-#define OAKLEY_ATTR_GRP_DESC_MODP1024 2
-#define OAKLEY_ATTR_GRP_DESC_EC2N155 3
-#define OAKLEY_ATTR_GRP_DESC_EC2N185 4
-#define OAKLEY_ATTR_GRP_TYPE 5 /* B */
-#define OAKLEY_ATTR_GRP_TYPE_MODP 1
-#define OAKLEY_ATTR_GRP_TYPE_ECP 2
-#define OAKLEY_ATTR_GRP_TYPE_EC2N 3
-#define OAKLEY_ATTR_GRP_PI 6 /* V */
-#define OAKLEY_ATTR_GRP_GEN_ONE 7 /* V */
-#define OAKLEY_ATTR_GRP_GEN_TWO 8 /* V */
-#define OAKLEY_ATTR_GRP_CURVE_A 9 /* V */
-#define OAKLEY_ATTR_GRP_CURVE_B 10 /* V */
-#define OAKLEY_ATTR_SA_LTYPE 11 /* B */
-#define OAKLEY_ATTR_SA_LTYPE_DEFAULT 1
-#define OAKLEY_ATTR_SA_LTYPE_SEC 1
-#define OAKLEY_ATTR_SA_LTYPE_KB 2
-#define OAKLEY_ATTR_SA_LDUR 12 /* V */
-#define OAKLEY_ATTR_SA_LDUR_DEFAULT 28800 /* 8 hours */
-#define OAKLEY_ATTR_PRF 13 /* B */
-#define OAKLEY_ATTR_KEY_LEN 14 /* B */
-#define OAKLEY_ATTR_FIELD_SIZE 15 /* B */
-#define OAKLEY_ATTR_GRP_ORDER 16 /* V */
-
-#define OAKLEY_ID_IPV4_ADDR 0
-#define OAKLEY_ID_IPV4_ADDR_SUBNET 1
-#define OAKLEY_ID_IPV6_ADDR 2
-#define OAKLEY_ID_IPV6_ADDR_SUBNET 3
-
-/* Additional Exchange Type */
-#define ISAKMP_ETYPE_QUICK 32
-#define ISAKMP_ETYPE_NEWGRP 33
-
-/* The use for checking proposal payload. This is not exchange type. */
-#define OAKLEY_MAIN_MODE 0
-#define OAKLEY_QUICK_MODE 1
-
-#define OAKLEY_PRIME_MODP768 "\
- FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1 \
- 29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD \
- EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245 \
- E485B576 625E7EC6 F44C42E9 A63A3620 FFFFFFFF FFFFFFFF"
-
-#define OAKLEY_PRIME_MODP1024 "\
- FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1 \
- 29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD \
- EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245 \
- E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED \
- EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE65381 \
- FFFFFFFF FFFFFFFF"
-
-#define DEFAULTSECRETSIZE ( 128 / 8 ) /* 128 bits */
-#define DEFAULTNONCESIZE ( 128 / 8 ) /* 128 bits */
-
-#define MAXPADLWORD 20
-
-#if 0
-/* isakmp sa structure */
-struct oakley_sa {
- u_int8_t proto_id; /* OAKLEY */
- vchar_t *spi; /* spi */
- u_int8_t dhgrp; /* DH; group */
- u_int8_t auth_t; /* method of authentication */
- u_int8_t prf_t; /* type of prf */
- u_int8_t hash_t; /* type of hash */
- u_int8_t enc_t; /* type of cipher */
- u_int8_t life_t; /* type of duration of lifetime */
- u_int32_t ldur; /* life duration */
-};
-#endif
-
-#endif /* !defined(_ISAKMP_OAKLEY_H_) */
diff --git a/contrib/tcpdump/openflow.h b/contrib/tcpdump/openflow.h
new file mode 100644
index 000000000000..d330f1ecf0a9
--- /dev/null
+++ b/contrib/tcpdump/openflow.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2013 The TCPDUMP project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 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 HOLDER 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.
+ */
+
+/* OpenFlow: protocol between controller and datapath. */
+
+/* for netdissect_options */
+#include "netdissect.h"
+
+#define OF_HEADER_LEN 8
+
+/*
+ * Routines to print packets for various versions of OpenFlow.
+ */
+extern const u_char *of10_header_body_print(netdissect_options *ndo,
+ const u_char *, const u_char *,
+ const uint8_t, const uint16_t, const uint32_t);
diff --git a/contrib/tcpdump/ospf.h b/contrib/tcpdump/ospf.h
index b86458baa7ee..b47aaf69319d 100644
--- a/contrib/tcpdump/ospf.h
+++ b/contrib/tcpdump/ospf.h
@@ -1,4 +1,3 @@
-/* @(#) $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.
@@ -35,7 +34,7 @@
* +------------------------------------+
*
*/
-
+
#define OSPF_OPTION_T 0x01 /* T bit: TOS support */
#define OSPF_OPTION_E 0x02 /* E bit: External routes advertised */
#define OSPF_OPTION_MC 0x04 /* MC bit: Multicast capable */
@@ -137,6 +136,8 @@
#define MCLA_VERTEX_NETWORK 2
/* Link-Local-Signaling */
+#define OSPF_LLS_HDRLEN 4U /* RFC5613 Section 2.2 */
+
#define OSPF_LLS_EO 1 /* RFC4811, RFC4812 */
#define OSPF_LLS_MD5 2 /* RFC4813 */
@@ -147,14 +148,14 @@
* 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];
+ uint8_t tos_type;
+ uint8_t reserved;
+ uint8_t tos_metric[2];
};
struct tos_link {
- u_int8_t link_type;
- u_int8_t link_tos_count;
- u_int8_t tos_metric[2];
+ uint8_t link_type;
+ uint8_t link_tos_count;
+ uint8_t tos_metric[2];
};
union un_tos {
struct tos_link link;
@@ -163,20 +164,20 @@ union un_tos {
/* link state advertisement header */
struct lsa_hdr {
- u_int16_t ls_age;
- u_int8_t ls_options;
- u_int8_t ls_type;
+ uint16_t ls_age;
+ uint8_t ls_options;
+ uint8_t ls_type;
union {
struct in_addr lsa_id;
struct { /* opaque LSAs change the LSA-ID field */
- u_int8_t opaque_type;
- u_int8_t opaque_id[3];
+ uint8_t opaque_type;
+ uint8_t opaque_id[3];
} opaque_field;
} un_lsa_id;
struct in_addr ls_router;
- u_int32_t ls_seq;
- u_int16_t ls_chksum;
- u_int16_t ls_length;
+ uint32_t ls_seq;
+ uint16_t ls_chksum;
+ uint16_t ls_length;
};
/* link state advertisement */
@@ -187,9 +188,9 @@ struct lsa {
union {
/* Router links advertisements */
struct {
- u_int8_t rla_flags;
- u_int8_t rla_zero[1];
- u_int16_t rla_count;
+ uint8_t rla_flags;
+ uint8_t rla_zero[1];
+ uint16_t rla_count;
struct rlalink {
struct in_addr link_id;
struct in_addr link_data;
@@ -206,14 +207,14 @@ struct lsa {
/* Summary links advertisements */
struct {
struct in_addr sla_mask;
- u_int32_t sla_tosmetric[1]; /* may repeat */
+ uint32_t sla_tosmetric[1]; /* may repeat */
} un_sla;
/* AS external links advertisements */
struct {
struct in_addr asla_mask;
struct aslametric {
- u_int32_t asla_tosmetric;
+ uint32_t asla_tosmetric;
struct in_addr asla_forward;
struct in_addr asla_tag;
} asla_metric[1]; /* may repeat */
@@ -221,34 +222,34 @@ struct lsa {
/* Multicast group membership */
struct mcla {
- u_int32_t mcla_vtype;
+ uint32_t mcla_vtype;
struct in_addr mcla_vid;
} un_mcla[1];
/* Opaque TE LSA */
struct {
- u_int16_t type;
- u_int16_t length;
- u_int8_t data[1]; /* may repeat */
+ uint16_t type;
+ uint16_t length;
+ uint8_t data[1]; /* may repeat */
} un_te_lsa_tlv;
/* Opaque Grace LSA */
struct {
- u_int16_t type;
- u_int16_t length;
- u_int8_t data[1]; /* may repeat */
+ uint16_t type;
+ uint16_t length;
+ uint8_t data[1]; /* may repeat */
} un_grace_tlv;
/* Opaque Router information LSA */
struct {
- u_int16_t type;
- u_int16_t length;
- u_int8_t data[1]; /* may repeat */
+ uint16_t type;
+ uint16_t length;
+ uint8_t data[1]; /* may repeat */
} un_ri_tlv;
/* Unknown LSA */
struct unknown {
- u_int8_t data[1]; /* may repeat */
+ uint8_t data[1]; /* may repeat */
} un_unknown[1];
} lsa_un;
@@ -260,23 +261,23 @@ struct lsa {
* the main header
*/
struct ospfhdr {
- u_int8_t ospf_version;
- u_int8_t ospf_type;
- u_int16_t ospf_len;
+ uint8_t ospf_version;
+ uint8_t ospf_type;
+ uint16_t ospf_len;
struct in_addr ospf_routerid;
struct in_addr ospf_areaid;
- u_int16_t ospf_chksum;
- u_int16_t ospf_authtype;
- u_int8_t ospf_authdata[OSPF_AUTH_SIZE];
+ uint16_t ospf_chksum;
+ uint16_t ospf_authtype;
+ uint8_t ospf_authdata[OSPF_AUTH_SIZE];
union {
/* Hello packet */
struct {
struct in_addr hello_mask;
- u_int16_t hello_helloint;
- u_int8_t hello_options;
- u_int8_t hello_priority;
- u_int32_t hello_deadint;
+ uint16_t hello_helloint;
+ uint8_t hello_options;
+ uint8_t hello_priority;
+ uint32_t hello_deadint;
struct in_addr hello_dr;
struct in_addr hello_bdr;
struct in_addr hello_neighbor[1]; /* may repeat */
@@ -284,21 +285,21 @@ struct ospfhdr {
/* Database Description packet */
struct {
- u_int16_t db_ifmtu;
- u_int8_t db_options;
- u_int8_t db_flags;
- u_int32_t db_seq;
+ uint16_t db_ifmtu;
+ uint8_t db_options;
+ uint8_t db_flags;
+ uint32_t db_seq;
struct lsa_hdr db_lshdr[1]; /* may repeat */
} un_db;
/* Link State Request */
struct lsr {
- u_int8_t ls_type[4];
+ uint8_t ls_type[4];
union {
struct in_addr ls_stateid;
struct { /* opaque LSAs change the LSA-ID field */
- u_int8_t opaque_type;
- u_int8_t opaque_id[3];
+ uint8_t opaque_type;
+ uint8_t opaque_id[3];
} opaque_field;
} un_ls_stateid;
struct in_addr ls_router;
@@ -306,7 +307,7 @@ struct ospfhdr {
/* Link State Update */
struct {
- u_int32_t lsu_count;
+ uint32_t lsu_count;
struct lsa lsu_lsa[1]; /* may repeat */
} un_lsu;
@@ -322,7 +323,3 @@ struct ospfhdr {
#define ospf_lsr ospf_un.un_lsr
#define ospf_lsu ospf_un.un_lsu
#define ospf_lsa ospf_un.un_lsa
-
-/* Functions shared by ospf and ospf6 */
-extern int ospf_print_te_lsa(const u_int8_t *, u_int);
-extern int ospf_print_grace_lsa(const u_int8_t *, u_int);
diff --git a/contrib/tcpdump/ospf6.h b/contrib/tcpdump/ospf6.h
deleted file mode 100644
index e2eabee1815c..000000000000
--- a/contrib/tcpdump/ospf6.h
+++ /dev/null
@@ -1,265 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/ospf6.h,v 1.7 2006-09-05 15:50:26 hannes Exp $ (LBL) */
-/*
- * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that: (1) source code distributions
- * retain the above copyright notice and this paragraph in its entirety, (2)
- * distributions including binary code include the above copyright notice and
- * this paragraph in its entirety in the documentation or other materials
- * provided with the distribution, and (3) all advertising materials mentioning
- * features or use of this software display the following acknowledgement:
- * ``This product includes software developed by the University of California,
- * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
- * the University nor the names of its contributors may be used to endorse
- * or promote products derived from this software without specific prior
- * written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * OSPF support contributed by Jeffrey Honig (jch@mitchell.cit.cornell.edu)
- */
-#define OSPF_TYPE_HELLO 1 /* Hello */
-#define OSPF_TYPE_DD 2 /* Database Description */
-#define OSPF_TYPE_LS_REQ 3 /* Link State Request */
-#define OSPF_TYPE_LS_UPDATE 4 /* Link State Update */
-#define OSPF_TYPE_LS_ACK 5 /* Link State Ack */
-
-/* Options *_options */
-#define OSPF6_OPTION_V6 0x01 /* V6 bit: A bit for peeping tom */
-#define OSPF6_OPTION_E 0x02 /* E bit: External routes advertised */
-#define OSPF6_OPTION_MC 0x04 /* MC bit: Multicast capable */
-#define OSPF6_OPTION_N 0x08 /* N bit: For type-7 LSA */
-#define OSPF6_OPTION_R 0x10 /* R bit: Router bit */
-#define OSPF6_OPTION_DC 0x20 /* DC bit: Demand circuits */
-
-
-/* db_flags */
-#define OSPF6_DB_INIT 0x04 /* */
-#define OSPF6_DB_MORE 0x02
-#define OSPF6_DB_MASTER 0x01
-
-/* ls_type */
-#define LS_TYPE_ROUTER 1 /* router link */
-#define LS_TYPE_NETWORK 2 /* network link */
-#define LS_TYPE_INTER_AP 3 /* Inter-Area-Prefix */
-#define LS_TYPE_INTER_AR 4 /* Inter-Area-Router */
-#define LS_TYPE_ASE 5 /* ASE */
-#define LS_TYPE_GROUP 6 /* Group membership */
-#define LS_TYPE_NSSA 7 /* NSSA */
-#define LS_TYPE_LINK 8 /* Link LSA */
-#define LS_TYPE_INTRA_AP 9 /* Intra-Area-Prefix */
-#define LS_TYPE_INTRA_ATE 10 /* Intra-Area-TE */
-#define LS_TYPE_GRACE 11 /* Grace LSA */
-#define LS_TYPE_MASK 0x1fff
-
-#define LS_SCOPE_LINKLOCAL 0x0000
-#define LS_SCOPE_AREA 0x2000
-#define LS_SCOPE_AS 0x4000
-#define LS_SCOPE_MASK 0x6000
-#define LS_SCOPE_U 0x8000
-
-/* rla_link.link_type */
-#define RLA_TYPE_ROUTER 1 /* point-to-point to another router */
-#define RLA_TYPE_TRANSIT 2 /* connection to transit network */
-#define RLA_TYPE_VIRTUAL 4 /* virtual link */
-
-/* rla_flags */
-#define RLA_FLAG_B 0x01
-#define RLA_FLAG_E 0x02
-#define RLA_FLAG_V 0x04
-#define RLA_FLAG_W 0x08
-#define RLA_FLAG_N 0x10
-
-/* lsa_prefix options */
-#define LSA_PREFIX_OPT_NU 0x01
-#define LSA_PREFIX_OPT_LA 0x02
-#define LSA_PREFIX_OPT_MC 0x04
-#define LSA_PREFIX_OPT_P 0x08
-#define LSA_PREFIX_OPT_DN 0x10
-
-/* sla_tosmetric breakdown */
-#define SLA_MASK_TOS 0x7f000000
-#define SLA_MASK_METRIC 0x00ffffff
-#define SLA_SHIFT_TOS 24
-
-/* asla_metric */
-#define ASLA_FLAG_FWDADDR 0x02000000
-#define ASLA_FLAG_ROUTETAG 0x01000000
-#define ASLA_MASK_METRIC 0x00ffffff
-
-typedef u_int32_t rtrid_t;
-
-/* link state advertisement header */
-struct lsa6_hdr {
- u_int16_t ls_age;
- u_int16_t ls_type;
- rtrid_t ls_stateid;
- rtrid_t ls_router;
- u_int32_t ls_seq;
- u_int16_t ls_chksum;
- u_int16_t ls_length;
-};
-
-struct lsa6_prefix {
- u_int8_t lsa_p_len;
- u_int8_t lsa_p_opt;
- u_int16_t lsa_p_metric;
- u_int8_t lsa_p_prefix[4];
-};
-
-/* link state advertisement */
-struct lsa6 {
- struct lsa6_hdr ls_hdr;
-
- /* Link state types */
- union {
- /* Router links advertisements */
- struct {
- union {
- u_int8_t flg;
- u_int32_t opt;
- } rla_flgandopt;
-#define rla_flags rla_flgandopt.flg
-#define rla_options rla_flgandopt.opt
- struct rlalink6 {
- u_int8_t link_type;
- u_int8_t link_zero[1];
- u_int16_t link_metric;
- u_int32_t link_ifid;
- u_int32_t link_nifid;
- rtrid_t link_nrtid;
- } rla_link[1]; /* may repeat */
- } un_rla;
-
- /* Network links advertisements */
- struct {
- u_int32_t nla_options;
- rtrid_t nla_router[1]; /* may repeat */
- } un_nla;
-
- /* Inter Area Prefix LSA */
- struct {
- u_int32_t inter_ap_metric;
- struct lsa6_prefix inter_ap_prefix[1];
- } un_inter_ap;
-
- /* AS external links advertisements */
- struct {
- u_int32_t asla_metric;
- struct lsa6_prefix asla_prefix[1];
- /* some optional fields follow */
- } un_asla;
-
-#if 0
- /* Summary links advertisements */
- struct {
- struct in_addr sla_mask;
- u_int32_t sla_tosmetric[1]; /* may repeat */
- } un_sla;
-
- /* Multicast group membership */
- struct mcla {
- u_int32_t mcla_vtype;
- struct in_addr mcla_vid;
- } un_mcla[1];
-#endif
-
- /* Type 7 LSA */
-
- /* Link LSA */
- struct llsa {
- union {
- u_int8_t pri;
- u_int32_t opt;
- } llsa_priandopt;
-#define llsa_priority llsa_priandopt.pri
-#define llsa_options llsa_priandopt.opt
- struct in6_addr llsa_lladdr;
- u_int32_t llsa_nprefix;
- struct lsa6_prefix llsa_prefix[1];
- } un_llsa;
-
- /* Intra-Area-Prefix */
- struct {
- u_int16_t intra_ap_nprefix;
- u_int16_t intra_ap_lstype;
- rtrid_t intra_ap_lsid;
- rtrid_t intra_ap_rtid;
- struct lsa6_prefix intra_ap_prefix[1];
- } un_intra_ap;
- } lsa_un;
-};
-
-
-#define OSPF_AUTH_SIZE 8
-
-/*
- * the main header
- */
-struct ospf6hdr {
- u_int8_t ospf6_version;
- u_int8_t ospf6_type;
- u_int16_t ospf6_len;
- rtrid_t ospf6_routerid;
- rtrid_t ospf6_areaid;
- u_int16_t ospf6_chksum;
- u_int8_t ospf6_instanceid;
- u_int8_t ospf6_rsvd;
- union {
-
- /* Hello packet */
- struct {
- u_int32_t hello_ifid;
- union {
- u_int8_t pri;
- u_int32_t opt;
- } hello_priandopt;
-#define hello_priority hello_priandopt.pri
-#define hello_options hello_priandopt.opt
- u_int16_t hello_helloint;
- u_int16_t hello_deadint;
- rtrid_t hello_dr;
- rtrid_t hello_bdr;
- rtrid_t hello_neighbor[1]; /* may repeat */
- } un_hello;
-
- /* Database Description packet */
- struct {
- u_int32_t db_options;
- u_int16_t db_mtu;
- u_int8_t db_mbz;
- u_int8_t db_flags;
- u_int32_t db_seq;
- struct lsa6_hdr db_lshdr[1]; /* may repeat */
- } un_db;
-
- /* Link State Request */
- struct lsr6 {
- u_int16_t ls_mbz;
- u_int16_t ls_type;
- rtrid_t ls_stateid;
- rtrid_t ls_router;
- } un_lsr[1]; /* may repeat */
-
- /* Link State Update */
- struct {
- u_int32_t lsu_count;
- struct lsa6 lsu_lsa[1]; /* may repeat */
- } un_lsu;
-
- /* Link State Acknowledgement */
- struct {
- struct lsa6_hdr lsa_lshdr[1]; /* may repeat */
- } un_lsa ;
- } ospf6_un ;
-};
-
-#define ospf6_hello ospf6_un.un_hello
-#define ospf6_db ospf6_un.un_db
-#define ospf6_lsr ospf6_un.un_lsr
-#define ospf6_lsu ospf6_un.un_lsu
-#define ospf6_lsa ospf6_un.un_lsa
-
diff --git a/contrib/tcpdump/oui.c b/contrib/tcpdump/oui.c
index 1067aa1c5cec..a6d5787f79b9 100644
--- a/contrib/tcpdump/oui.c
+++ b/contrib/tcpdump/oui.c
@@ -1,4 +1,4 @@
-/*
+/*
* 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
@@ -13,11 +13,7 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/oui.c,v 1.9 2008-01-09 09:40:47 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
diff --git a/contrib/tcpdump/oui.h b/contrib/tcpdump/oui.h
index d39cb6cae37f..bf87099d26ce 100644
--- a/contrib/tcpdump/oui.h
+++ b/contrib/tcpdump/oui.h
@@ -1,5 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/oui.h,v 1.8 2008-01-09 09:40:47 hannes Exp $ (LBL) */
-/*
+/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code
* distributions retain the above copyright notice and this paragraph
diff --git a/contrib/tcpdump/parsenfsfh.c b/contrib/tcpdump/parsenfsfh.c
index bf575e0eef80..909a18047500 100644
--- a/contrib/tcpdump/parsenfsfh.c
+++ b/contrib/tcpdump/parsenfsfh.c
@@ -42,11 +42,7 @@
* $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/parsenfsfh.c,v 1.29 2006-06-13 22:21:38 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -85,7 +81,7 @@ static const char rcsid[] _U_ =
#ifdef ultrix
/* Nasty hack to keep the Ultrix C compiler from emitting bogus warnings */
-#define XFF(x) ((u_int32_t)(x))
+#define XFF(x) ((uint32_t)(x))
#else
#define XFF(x) (x)
#endif
@@ -112,17 +108,14 @@ static const char rcsid[] _U_ =
static int is_UCX(const unsigned char *);
void
-Parse_fh(fh, len, fsidp, inop, osnamep, fsnamep, ourself)
-register const unsigned char *fh;
-int len _U_;
-my_fsid *fsidp;
-ino_t *inop;
-const char **osnamep; /* if non-NULL, return OS name here */
-const char **fsnamep; /* if non-NULL, return server fs name here (for VMS) */
-int ourself; /* true if file handle was generated on this host */
+Parse_fh(register const unsigned char *fh, int len _U_, my_fsid *fsidp,
+ uint32_t *inop,
+ const char **osnamep, /* if non-NULL, return OS name here */
+ const char **fsnamep, /* if non-NULL, return server fs name here (for VMS) */
+ int ourself) /* true if file handle was generated on this host */
{
register const unsigned char *fhp = fh;
- u_int32_t temp;
+ uint32_t temp;
int fhtype = FHT_UNKNOWN;
int i;
@@ -266,8 +259,7 @@ int ourself; /* true if file handle was generated on this host */
fsidp->Fsid_dev.Major = fhp[6];
fsidp->fsid_code = 0;
- temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
- *inop = temp;
+ *inop = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
if (osnamep)
*osnamep = "Auspex";
@@ -278,8 +270,7 @@ int ourself; /* true if file handle was generated on this host */
fsidp->Fsid_dev.Major = fhp[1];
fsidp->fsid_code = 0;
- temp = make_uint32(fhp[15], fhp[14], fhp[13], fhp[12]);
- *inop = temp;
+ *inop = make_uint32(fhp[15], fhp[14], fhp[13], fhp[12]);
if (osnamep)
*osnamep = "BSD 4.4";
@@ -293,8 +284,7 @@ int ourself; /* true if file handle was generated on this host */
fsidp->Fsid_dev.Minor = temp & 0xFFFFF;
fsidp->Fsid_dev.Major = (temp>>20) & 0xFFF;
- temp = make_uint32(fhp[15], fhp[14], fhp[13], fhp[12]);
- *inop = temp;
+ *inop = make_uint32(fhp[15], fhp[14], fhp[13], fhp[12]);
if (osnamep)
*osnamep = "OSF";
break;
@@ -304,8 +294,7 @@ int ourself; /* true if file handle was generated on this host */
fsidp->Fsid_dev.Major = fhp[2];
fsidp->fsid_code = 0;
- temp = make_uint32(fhp[8], fhp[9], fhp[10], fhp[11]);
- *inop = temp;
+ *inop = make_uint32(fhp[8], fhp[9], fhp[10], fhp[11]);
if (osnamep)
*osnamep = "IRIX4";
@@ -316,8 +305,7 @@ int ourself; /* true if file handle was generated on this host */
fsidp->Fsid_dev.Major = make_uint16(fhp[0], fhp[1]);
fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]);
- temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
- *inop = temp;
+ *inop = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
if (osnamep)
*osnamep = "IRIX5";
@@ -339,8 +327,7 @@ int ourself; /* true if file handle was generated on this host */
fsidp->Fsid_dev.Major = fhp[2];
fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]);
- temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
- *inop = temp;
+ *inop = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
if (osnamep)
*osnamep = "SUNOS4";
@@ -353,8 +340,7 @@ int ourself; /* true if file handle was generated on this host */
fsidp->Fsid_dev.Minor = temp & 0x3FFFF;
fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]);
- temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
- *inop = temp;
+ *inop = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
if (osnamep)
*osnamep = "SUNOS5";
@@ -380,7 +366,7 @@ int ourself; /* true if file handle was generated on this host */
memcpy((char *)fsidp, (char *)fh, 14);
}
else {
- u_int32_t tempa[4]; /* at least 16 bytes, maybe more */
+ uint32_t tempa[4]; /* at least 16 bytes, maybe more */
memset((char *)tempa, 0, sizeof(tempa));
memcpy((char *)tempa, (char *)fh, 14); /* ensure alignment */
@@ -405,8 +391,7 @@ int ourself; /* true if file handle was generated on this host */
fsidp->Fsid_dev.Major = make_uint16(fhp[0], fhp[1]);
fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]);
- temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
- *inop = temp;
+ *inop = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
if (osnamep)
*osnamep = "AIX32";
@@ -418,8 +403,7 @@ int ourself; /* true if file handle was generated on this host */
fsidp->Fsid_dev.Minor = temp;
fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]);
- temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
- *inop = temp;
+ *inop = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
if (osnamep)
*osnamep = "HPUX9";
@@ -461,14 +445,13 @@ int ourself; /* true if file handle was generated on this host */
* (3) followed by string of nulls
*/
static int
-is_UCX(fhp)
-const unsigned char *fhp;
+is_UCX(const unsigned char *fhp)
{
register int i;
int seen_null = 0;
for (i = 1; i < 14; i++) {
- if (isprint(fhp[i])) {
+ if (ND_ISPRINT(fhp[i])) {
if (seen_null)
return(0);
else
diff --git a/contrib/tcpdump/pcap-missing.h b/contrib/tcpdump/pcap-missing.h
index 5c0ece25b313..d776810f9112 100644
--- a/contrib/tcpdump/pcap-missing.h
+++ b/contrib/tcpdump/pcap-missing.h
@@ -17,8 +17,6 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/pcap-missing.h,v 1.3 2005-06-03 22:08:52 guy Exp $ (LBL)
*/
#ifndef tcpdump_pcap_missing_h
diff --git a/contrib/tcpdump/pcap_dump_ftell.c b/contrib/tcpdump/pcap_dump_ftell.c
index 6eb3a4ab75c9..1b652b5427d0 100644
--- a/contrib/tcpdump/pcap_dump_ftell.c
+++ b/contrib/tcpdump/pcap_dump_ftell.c
@@ -19,11 +19,6 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/pcap_dump_ftell.c,v 1.1 2005-06-03 22:08:52 guy Exp $ (LBL)";
-#endif
-
#include <stdio.h>
#include <pcap.h>
diff --git a/contrib/tcpdump/pmap_prot.h b/contrib/tcpdump/pmap_prot.h
deleted file mode 100644
index 949c3994515f..000000000000
--- a/contrib/tcpdump/pmap_prot.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/pmap_prot.h,v 1.3 2005-04-27 21:43:48 guy Exp $ (LBL) */
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
- *
- * from: @(#)pmap_prot.h 1.14 88/02/08 SMI
- * from: @(#)pmap_prot.h 2.1 88/07/29 4.0 RPCSRC
- * $FreeBSD$
- * FreeBSD: src/include/rpc/pmap_prot.h,v 1.9.2.1 1999/08/29 14:39:05 peter Exp
- */
-
-/*
- * pmap_prot.h
- * Protocol for the local binder service, or pmap.
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- *
- * The following procedures are supported by the protocol:
- *
- * PMAPPROC_NULL() returns ()
- * takes nothing, returns nothing
- *
- * PMAPPROC_SET(struct pmap) returns (bool_t)
- * TRUE is success, FALSE is failure. Registers the tuple
- * [prog, vers, prot, port].
- *
- * PMAPPROC_UNSET(struct pmap) returns (bool_t)
- * TRUE is success, FALSE is failure. Un-registers pair
- * [prog, vers]. prot and port are ignored.
- *
- * PMAPPROC_GETPORT(struct pmap) returns (long unsigned).
- * 0 is failure. Otherwise returns the port number where the pair
- * [prog, vers] is registered. It may lie!
- *
- * PMAPPROC_DUMP() RETURNS (struct pmaplist *)
- *
- * PMAPPROC_CALLIT(unsigned, unsigned, unsigned, string<>)
- * RETURNS (port, string<>);
- * usage: encapsulatedresults = PMAPPROC_CALLIT(prog, vers, proc, encapsulatedargs);
- * Calls the procedure on the local machine. If it is not registered,
- * this procedure is quite; ie it does not return error information!!!
- * This procedure only is supported on rpc/udp and calls via
- * rpc/udp. This routine only passes null authentication parameters.
- * This file has no interface to xdr routines for PMAPPROC_CALLIT.
- *
- * The service supports remote procedure calls on udp/ip or tcp/ip socket 111.
- */
-
-#define SUNRPC_PMAPPORT ((u_int16_t)111)
-#define SUNRPC_PMAPPROG ((u_int32_t)100000)
-#define SUNRPC_PMAPVERS ((u_int32_t)2)
-#define SUNRPC_PMAPVERS_PROTO ((u_int32_t)2)
-#define SUNRPC_PMAPVERS_ORIG ((u_int32_t)1)
-#define SUNRPC_PMAPPROC_NULL ((u_int32_t)0)
-#define SUNRPC_PMAPPROC_SET ((u_int32_t)1)
-#define SUNRPC_PMAPPROC_UNSET ((u_int32_t)2)
-#define SUNRPC_PMAPPROC_GETPORT ((u_int32_t)3)
-#define SUNRPC_PMAPPROC_DUMP ((u_int32_t)4)
-#define SUNRPC_PMAPPROC_CALLIT ((u_int32_t)5)
-
-struct sunrpc_pmap {
- u_int32_t pm_prog;
- u_int32_t pm_vers;
- u_int32_t pm_prot;
- u_int32_t pm_port;
-};
diff --git a/contrib/tcpdump/ppi.h b/contrib/tcpdump/ppi.h
deleted file mode 100644
index 733eb950f0de..000000000000
--- a/contrib/tcpdump/ppi.h
+++ /dev/null
@@ -1,9 +0,0 @@
-typedef struct ppi_header {
- uint8_t ppi_ver;
- uint8_t ppi_flags;
- uint16_t ppi_len;
- uint32_t ppi_dlt;
-} ppi_header_t;
-
-#define PPI_HDRLEN 8
-
diff --git a/contrib/tcpdump/ppp.h b/contrib/tcpdump/ppp.h
index 3ae519b6eb1c..da4810ab7e71 100644
--- a/contrib/tcpdump/ppp.h
+++ b/contrib/tcpdump/ppp.h
@@ -1,4 +1,3 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/ppp.h,v 1.16 2004-10-20 16:14:16 hannes Exp $ (LBL) */
/*
* Point to Point Protocol (PPP) RFC1331
*
@@ -69,5 +68,3 @@
#define PPP_MPCP 0xc03d /* Multi-Link */
#define PPP_SPAP_OLD 0xc123
#define PPP_EAP 0xc227
-
-extern struct tok ppptype2str[];
diff --git a/contrib/tcpdump/print-802_11.c b/contrib/tcpdump/print-802_11.c
index 97badb9fc83e..88fbf40d4d4a 100644
--- a/contrib/tcpdump/print-802_11.c
+++ b/contrib/tcpdump/print-802_11.c
@@ -20,50 +20,689 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-802_11.c,v 1.49 2007-12-29 23:25:02 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <pcap.h>
#include <string.h>
#include "interface.h"
#include "addrtoname.h"
-#include "ethertype.h"
#include "extract.h"
#include "cpack.h"
-#include "ieee802_11.h"
-#include "ieee802_11_radio.h"
+
+/* Lengths of 802.11 header components. */
+#define IEEE802_11_FC_LEN 2
+#define IEEE802_11_DUR_LEN 2
+#define IEEE802_11_DA_LEN 6
+#define IEEE802_11_SA_LEN 6
+#define IEEE802_11_BSSID_LEN 6
+#define IEEE802_11_RA_LEN 6
+#define IEEE802_11_TA_LEN 6
+#define IEEE802_11_SEQ_LEN 2
+#define IEEE802_11_CTL_LEN 2
+#define IEEE802_11_IV_LEN 3
+#define IEEE802_11_KID_LEN 1
+
+/* Frame check sequence length. */
+#define IEEE802_11_FCS_LEN 4
+
+/* Lengths of beacon components. */
+#define IEEE802_11_TSTAMP_LEN 8
+#define IEEE802_11_BCNINT_LEN 2
+#define IEEE802_11_CAPINFO_LEN 2
+#define IEEE802_11_LISTENINT_LEN 2
+
+#define IEEE802_11_AID_LEN 2
+#define IEEE802_11_STATUS_LEN 2
+#define IEEE802_11_REASON_LEN 2
+
+/* Length of previous AP in reassocation frame */
+#define IEEE802_11_AP_LEN 6
+
+#define T_MGMT 0x0 /* management */
+#define T_CTRL 0x1 /* control */
+#define T_DATA 0x2 /* data */
+#define T_RESV 0x3 /* reserved */
+
+#define ST_ASSOC_REQUEST 0x0
+#define ST_ASSOC_RESPONSE 0x1
+#define ST_REASSOC_REQUEST 0x2
+#define ST_REASSOC_RESPONSE 0x3
+#define ST_PROBE_REQUEST 0x4
+#define ST_PROBE_RESPONSE 0x5
+/* RESERVED 0x6 */
+/* RESERVED 0x7 */
+#define ST_BEACON 0x8
+#define ST_ATIM 0x9
+#define ST_DISASSOC 0xA
+#define ST_AUTH 0xB
+#define ST_DEAUTH 0xC
+#define ST_ACTION 0xD
+/* RESERVED 0xE */
+/* RESERVED 0xF */
+
+static const struct tok st_str[] = {
+ { ST_ASSOC_REQUEST, "Assoc Request" },
+ { ST_ASSOC_RESPONSE, "Assoc Response" },
+ { ST_REASSOC_REQUEST, "ReAssoc Request" },
+ { ST_REASSOC_RESPONSE, "ReAssoc Response" },
+ { ST_PROBE_REQUEST, "Probe Request" },
+ { ST_PROBE_RESPONSE, "Probe Response" },
+ { ST_BEACON, "Beacon" },
+ { ST_ATIM, "ATIM" },
+ { ST_DISASSOC, "Disassociation" },
+ { ST_AUTH, "Authentication" },
+ { ST_DEAUTH, "DeAuthentication" },
+ { ST_ACTION, "Action" },
+ { 0, NULL }
+};
+
+#define CTRL_CONTROL_WRAPPER 0x7
+#define CTRL_BAR 0x8
+#define CTRL_BA 0x9
+#define CTRL_PS_POLL 0xA
+#define CTRL_RTS 0xB
+#define CTRL_CTS 0xC
+#define CTRL_ACK 0xD
+#define CTRL_CF_END 0xE
+#define CTRL_END_ACK 0xF
+
+static const struct tok ctrl_str[] = {
+ { CTRL_CONTROL_WRAPPER, "Control Wrapper" },
+ { CTRL_BAR, "BAR" },
+ { CTRL_BA, "BA" },
+ { CTRL_PS_POLL, "Power Save-Poll" },
+ { CTRL_RTS, "Request-To-Send" },
+ { CTRL_CTS, "Clear-To-Send" },
+ { CTRL_ACK, "Acknowledgment" },
+ { CTRL_CF_END, "CF-End" },
+ { CTRL_END_ACK, "CF-End+CF-Ack" },
+ { 0, NULL }
+};
+
+#define DATA_DATA 0x0
+#define DATA_DATA_CF_ACK 0x1
+#define DATA_DATA_CF_POLL 0x2
+#define DATA_DATA_CF_ACK_POLL 0x3
+#define DATA_NODATA 0x4
+#define DATA_NODATA_CF_ACK 0x5
+#define DATA_NODATA_CF_POLL 0x6
+#define DATA_NODATA_CF_ACK_POLL 0x7
+
+#define DATA_QOS_DATA 0x8
+#define DATA_QOS_DATA_CF_ACK 0x9
+#define DATA_QOS_DATA_CF_POLL 0xA
+#define DATA_QOS_DATA_CF_ACK_POLL 0xB
+#define DATA_QOS_NODATA 0xC
+#define DATA_QOS_CF_POLL_NODATA 0xE
+#define DATA_QOS_CF_ACK_POLL_NODATA 0xF
+
+/*
+ * The subtype field of a data frame is, in effect, composed of 4 flag
+ * bits - CF-Ack, CF-Poll, Null (means the frame doesn't actually have
+ * any data), and QoS.
+ */
+#define DATA_FRAME_IS_CF_ACK(x) ((x) & 0x01)
+#define DATA_FRAME_IS_CF_POLL(x) ((x) & 0x02)
+#define DATA_FRAME_IS_NULL(x) ((x) & 0x04)
+#define DATA_FRAME_IS_QOS(x) ((x) & 0x08)
+
+/*
+ * Bits in the frame control field.
+ */
+#define FC_VERSION(fc) ((fc) & 0x3)
+#define FC_TYPE(fc) (((fc) >> 2) & 0x3)
+#define FC_SUBTYPE(fc) (((fc) >> 4) & 0xF)
+#define FC_TO_DS(fc) ((fc) & 0x0100)
+#define FC_FROM_DS(fc) ((fc) & 0x0200)
+#define FC_MORE_FLAG(fc) ((fc) & 0x0400)
+#define FC_RETRY(fc) ((fc) & 0x0800)
+#define FC_POWER_MGMT(fc) ((fc) & 0x1000)
+#define FC_MORE_DATA(fc) ((fc) & 0x2000)
+#define FC_WEP(fc) ((fc) & 0x4000)
+#define FC_ORDER(fc) ((fc) & 0x8000)
+
+struct mgmt_header_t {
+ uint16_t fc;
+ uint16_t duration;
+ uint8_t da[6];
+ uint8_t sa[6];
+ uint8_t bssid[6];
+ uint16_t seq_ctrl;
+};
+
+#define MGMT_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
+ IEEE802_11_DA_LEN+IEEE802_11_SA_LEN+\
+ IEEE802_11_BSSID_LEN+IEEE802_11_SEQ_LEN)
+
+#define CAPABILITY_ESS(cap) ((cap) & 0x0001)
+#define CAPABILITY_IBSS(cap) ((cap) & 0x0002)
+#define CAPABILITY_CFP(cap) ((cap) & 0x0004)
+#define CAPABILITY_CFP_REQ(cap) ((cap) & 0x0008)
+#define CAPABILITY_PRIVACY(cap) ((cap) & 0x0010)
+
+struct ssid_t {
+ uint8_t element_id;
+ uint8_t length;
+ u_char ssid[33]; /* 32 + 1 for null */
+};
+
+struct rates_t {
+ uint8_t element_id;
+ uint8_t length;
+ uint8_t rate[16];
+};
+
+struct challenge_t {
+ uint8_t element_id;
+ uint8_t length;
+ uint8_t text[254]; /* 1-253 + 1 for null */
+};
+
+struct fh_t {
+ uint8_t element_id;
+ uint8_t length;
+ uint16_t dwell_time;
+ uint8_t hop_set;
+ uint8_t hop_pattern;
+ uint8_t hop_index;
+};
+
+struct ds_t {
+ uint8_t element_id;
+ uint8_t length;
+ uint8_t channel;
+};
+
+struct cf_t {
+ uint8_t element_id;
+ uint8_t length;
+ uint8_t count;
+ uint8_t period;
+ uint16_t max_duration;
+ uint16_t dur_remaing;
+};
+
+struct tim_t {
+ uint8_t element_id;
+ uint8_t length;
+ uint8_t count;
+ uint8_t period;
+ uint8_t bitmap_control;
+ uint8_t bitmap[251];
+};
+
+#define E_SSID 0
+#define E_RATES 1
+#define E_FH 2
+#define E_DS 3
+#define E_CF 4
+#define E_TIM 5
+#define E_IBSS 6
+/* reserved 7 */
+/* reserved 8 */
+/* reserved 9 */
+/* reserved 10 */
+/* reserved 11 */
+/* reserved 12 */
+/* reserved 13 */
+/* reserved 14 */
+/* reserved 15 */
+/* reserved 16 */
+
+#define E_CHALLENGE 16
+/* reserved 17 */
+/* reserved 18 */
+/* reserved 19 */
+/* reserved 16 */
+/* reserved 16 */
+
+
+struct mgmt_body_t {
+ uint8_t timestamp[IEEE802_11_TSTAMP_LEN];
+ uint16_t beacon_interval;
+ uint16_t listen_interval;
+ uint16_t status_code;
+ uint16_t aid;
+ u_char ap[IEEE802_11_AP_LEN];
+ uint16_t reason_code;
+ uint16_t auth_alg;
+ uint16_t auth_trans_seq_num;
+ int challenge_present;
+ struct challenge_t challenge;
+ uint16_t capability_info;
+ int ssid_present;
+ struct ssid_t ssid;
+ int rates_present;
+ struct rates_t rates;
+ int ds_present;
+ struct ds_t ds;
+ int cf_present;
+ struct cf_t cf;
+ int fh_present;
+ struct fh_t fh;
+ int tim_present;
+ struct tim_t tim;
+};
+
+struct ctrl_rts_t {
+ uint16_t fc;
+ uint16_t duration;
+ uint8_t ra[6];
+ uint8_t ta[6];
+ uint8_t fcs[4];
+};
+
+#define CTRL_RTS_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
+ IEEE802_11_RA_LEN+IEEE802_11_TA_LEN)
+
+struct ctrl_cts_t {
+ uint16_t fc;
+ uint16_t duration;
+ uint8_t ra[6];
+ uint8_t fcs[4];
+};
+
+#define CTRL_CTS_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
+
+struct ctrl_ack_t {
+ uint16_t fc;
+ uint16_t duration;
+ uint8_t ra[6];
+ uint8_t fcs[4];
+};
+
+#define CTRL_ACK_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
+
+struct ctrl_ps_poll_t {
+ uint16_t fc;
+ uint16_t aid;
+ uint8_t bssid[6];
+ uint8_t ta[6];
+ uint8_t fcs[4];
+};
+
+#define CTRL_PS_POLL_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_AID_LEN+\
+ IEEE802_11_BSSID_LEN+IEEE802_11_TA_LEN)
+
+struct ctrl_end_t {
+ uint16_t fc;
+ uint16_t duration;
+ uint8_t ra[6];
+ uint8_t bssid[6];
+ uint8_t fcs[4];
+};
+
+#define CTRL_END_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
+ IEEE802_11_RA_LEN+IEEE802_11_BSSID_LEN)
+
+struct ctrl_end_ack_t {
+ uint16_t fc;
+ uint16_t duration;
+ uint8_t ra[6];
+ uint8_t bssid[6];
+ uint8_t fcs[4];
+};
+
+#define CTRL_END_ACK_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
+ IEEE802_11_RA_LEN+IEEE802_11_BSSID_LEN)
+
+struct ctrl_ba_t {
+ uint16_t fc;
+ uint16_t duration;
+ uint8_t ra[6];
+ uint8_t fcs[4];
+};
+
+#define CTRL_BA_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
+
+struct ctrl_bar_t {
+ uint16_t fc;
+ uint16_t dur;
+ uint8_t ra[6];
+ uint8_t ta[6];
+ uint16_t ctl;
+ uint16_t seq;
+ uint8_t fcs[4];
+};
+
+#define CTRL_BAR_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
+ IEEE802_11_RA_LEN+IEEE802_11_TA_LEN+\
+ IEEE802_11_CTL_LEN+IEEE802_11_SEQ_LEN)
+
+struct meshcntl_t {
+ uint8_t flags;
+ uint8_t ttl;
+ uint8_t seq[4];
+ uint8_t addr4[6];
+ uint8_t addr5[6];
+ uint8_t addr6[6];
+};
+
+#define IV_IV(iv) ((iv) & 0xFFFFFF)
+#define IV_PAD(iv) (((iv) >> 24) & 0x3F)
+#define IV_KEYID(iv) (((iv) >> 30) & 0x03)
+
+/* $FreeBSD$ */
+/* NetBSD: ieee802_11_radio.h,v 1.2 2006/02/26 03:04:03 dyoung Exp */
+
+/*-
+ * Copyright (c) 2003, 2004 David Young. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of David Young may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID
+ * YOUNG BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ */
+
+/* A generic radio capture format is desirable. It must be
+ * rigidly defined (e.g., units for fields should be given),
+ * and easily extensible.
+ *
+ * The following is an extensible radio capture format. It is
+ * based on a bitmap indicating which fields are present.
+ *
+ * I am trying to describe precisely what the application programmer
+ * should expect in the following, and for that reason I tell the
+ * units and origin of each measurement (where it applies), or else I
+ * use sufficiently weaselly language ("is a monotonically nondecreasing
+ * function of...") that I cannot set false expectations for lawyerly
+ * readers.
+ */
+
+/*
+ * The radio capture header precedes the 802.11 header.
+ *
+ * Note well: all radiotap fields are little-endian.
+ */
+struct ieee80211_radiotap_header {
+ uint8_t it_version; /* Version 0. Only increases
+ * for drastic changes,
+ * introduction of compatible
+ * new fields does not count.
+ */
+ uint8_t it_pad;
+ uint16_t it_len; /* length of the whole
+ * header in bytes, including
+ * it_version, it_pad,
+ * it_len, and data fields.
+ */
+ uint32_t it_present; /* A bitmap telling which
+ * fields are present. Set bit 31
+ * (0x80000000) to extend the
+ * bitmap by another 32 bits.
+ * Additional extensions are made
+ * by setting bit 31.
+ */
+};
+
+/* Name Data type Units
+ * ---- --------- -----
+ *
+ * IEEE80211_RADIOTAP_TSFT uint64_t microseconds
+ *
+ * Value in microseconds of the MAC's 64-bit 802.11 Time
+ * Synchronization Function timer when the first bit of the
+ * MPDU arrived at the MAC. For received frames, only.
+ *
+ * IEEE80211_RADIOTAP_CHANNEL 2 x uint16_t MHz, bitmap
+ *
+ * Tx/Rx frequency in MHz, followed by flags (see below).
+ * Note that IEEE80211_RADIOTAP_XCHANNEL must be used to
+ * represent an HT channel as there is not enough room in
+ * the flags word.
+ *
+ * IEEE80211_RADIOTAP_FHSS uint16_t see below
+ *
+ * For frequency-hopping radios, the hop set (first byte)
+ * and pattern (second byte).
+ *
+ * IEEE80211_RADIOTAP_RATE uint8_t 500kb/s or index
+ *
+ * Tx/Rx data rate. If bit 0x80 is set then it represents an
+ * an MCS index and not an IEEE rate.
+ *
+ * IEEE80211_RADIOTAP_DBM_ANTSIGNAL int8_t decibels from
+ * one milliwatt (dBm)
+ *
+ * RF signal power at the antenna, decibel difference from
+ * one milliwatt.
+ *
+ * IEEE80211_RADIOTAP_DBM_ANTNOISE int8_t decibels from
+ * one milliwatt (dBm)
+ *
+ * RF noise power at the antenna, decibel difference from one
+ * milliwatt.
+ *
+ * IEEE80211_RADIOTAP_DB_ANTSIGNAL uint8_t decibel (dB)
+ *
+ * RF signal power at the antenna, decibel difference from an
+ * arbitrary, fixed reference.
+ *
+ * IEEE80211_RADIOTAP_DB_ANTNOISE uint8_t decibel (dB)
+ *
+ * RF noise power at the antenna, decibel difference from an
+ * arbitrary, fixed reference point.
+ *
+ * IEEE80211_RADIOTAP_LOCK_QUALITY uint16_t unitless
+ *
+ * Quality of Barker code lock. Unitless. Monotonically
+ * nondecreasing with "better" lock strength. Called "Signal
+ * Quality" in datasheets. (Is there a standard way to measure
+ * this?)
+ *
+ * IEEE80211_RADIOTAP_TX_ATTENUATION uint16_t unitless
+ *
+ * Transmit power expressed as unitless distance from max
+ * power set at factory calibration. 0 is max power.
+ * Monotonically nondecreasing with lower power levels.
+ *
+ * IEEE80211_RADIOTAP_DB_TX_ATTENUATION uint16_t decibels (dB)
+ *
+ * Transmit power expressed as decibel distance from max power
+ * set at factory calibration. 0 is max power. Monotonically
+ * nondecreasing with lower power levels.
+ *
+ * IEEE80211_RADIOTAP_DBM_TX_POWER int8_t decibels from
+ * one milliwatt (dBm)
+ *
+ * Transmit power expressed as dBm (decibels from a 1 milliwatt
+ * reference). This is the absolute power level measured at
+ * the antenna port.
+ *
+ * IEEE80211_RADIOTAP_FLAGS uint8_t bitmap
+ *
+ * Properties of transmitted and received frames. See flags
+ * defined below.
+ *
+ * IEEE80211_RADIOTAP_ANTENNA uint8_t antenna index
+ *
+ * Unitless indication of the Rx/Tx antenna for this packet.
+ * The first antenna is antenna 0.
+ *
+ * IEEE80211_RADIOTAP_RX_FLAGS uint16_t bitmap
+ *
+ * Properties of received frames. See flags defined below.
+ *
+ * IEEE80211_RADIOTAP_XCHANNEL uint32_t bitmap
+ * uint16_t MHz
+ * uint8_t channel number
+ * uint8_t .5 dBm
+ *
+ * Extended channel specification: flags (see below) followed by
+ * frequency in MHz, the corresponding IEEE channel number, and
+ * finally the maximum regulatory transmit power cap in .5 dBm
+ * units. This property supersedes IEEE80211_RADIOTAP_CHANNEL
+ * and only one of the two should be present.
+ *
+ * IEEE80211_RADIOTAP_MCS uint8_t known
+ * uint8_t flags
+ * uint8_t mcs
+ *
+ * Bitset indicating which fields have known values, followed
+ * by bitset of flag values, followed by the MCS rate index as
+ * in IEEE 802.11n.
+ *
+ * IEEE80211_RADIOTAP_VENDOR_NAMESPACE
+ * uint8_t OUI[3]
+ * uint8_t subspace
+ * uint16_t length
+ *
+ * The Vendor Namespace Field contains three sub-fields. The first
+ * sub-field is 3 bytes long. It contains the vendor's IEEE 802
+ * Organizationally Unique Identifier (OUI). The fourth byte is a
+ * vendor-specific "namespace selector."
+ *
+ */
+enum ieee80211_radiotap_type {
+ IEEE80211_RADIOTAP_TSFT = 0,
+ IEEE80211_RADIOTAP_FLAGS = 1,
+ IEEE80211_RADIOTAP_RATE = 2,
+ IEEE80211_RADIOTAP_CHANNEL = 3,
+ IEEE80211_RADIOTAP_FHSS = 4,
+ IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5,
+ IEEE80211_RADIOTAP_DBM_ANTNOISE = 6,
+ IEEE80211_RADIOTAP_LOCK_QUALITY = 7,
+ IEEE80211_RADIOTAP_TX_ATTENUATION = 8,
+ IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9,
+ IEEE80211_RADIOTAP_DBM_TX_POWER = 10,
+ IEEE80211_RADIOTAP_ANTENNA = 11,
+ IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12,
+ IEEE80211_RADIOTAP_DB_ANTNOISE = 13,
+ IEEE80211_RADIOTAP_RX_FLAGS = 14,
+ /* NB: gap for netbsd definitions */
+ IEEE80211_RADIOTAP_XCHANNEL = 18,
+ IEEE80211_RADIOTAP_MCS = 19,
+ IEEE80211_RADIOTAP_NAMESPACE = 29,
+ IEEE80211_RADIOTAP_VENDOR_NAMESPACE = 30,
+ IEEE80211_RADIOTAP_EXT = 31
+};
+
+/* channel attributes */
+#define IEEE80211_CHAN_TURBO 0x00010 /* Turbo channel */
+#define IEEE80211_CHAN_CCK 0x00020 /* CCK channel */
+#define IEEE80211_CHAN_OFDM 0x00040 /* OFDM channel */
+#define IEEE80211_CHAN_2GHZ 0x00080 /* 2 GHz spectrum channel. */
+#define IEEE80211_CHAN_5GHZ 0x00100 /* 5 GHz spectrum channel */
+#define IEEE80211_CHAN_PASSIVE 0x00200 /* Only passive scan allowed */
+#define IEEE80211_CHAN_DYN 0x00400 /* Dynamic CCK-OFDM channel */
+#define IEEE80211_CHAN_GFSK 0x00800 /* GFSK channel (FHSS PHY) */
+#define IEEE80211_CHAN_GSM 0x01000 /* 900 MHz spectrum channel */
+#define IEEE80211_CHAN_STURBO 0x02000 /* 11a static turbo channel only */
+#define IEEE80211_CHAN_HALF 0x04000 /* Half rate channel */
+#define IEEE80211_CHAN_QUARTER 0x08000 /* Quarter rate channel */
+#define IEEE80211_CHAN_HT20 0x10000 /* HT 20 channel */
+#define IEEE80211_CHAN_HT40U 0x20000 /* HT 40 channel w/ ext above */
+#define IEEE80211_CHAN_HT40D 0x40000 /* HT 40 channel w/ ext below */
+
+/* Useful combinations of channel characteristics, borrowed from Ethereal */
+#define IEEE80211_CHAN_A \
+ (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM)
+#define IEEE80211_CHAN_B \
+ (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_CCK)
+#define IEEE80211_CHAN_G \
+ (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN)
+#define IEEE80211_CHAN_TA \
+ (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_TURBO)
+#define IEEE80211_CHAN_TG \
+ (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN | IEEE80211_CHAN_TURBO)
+
+
+/* For IEEE80211_RADIOTAP_FLAGS */
+#define IEEE80211_RADIOTAP_F_CFP 0x01 /* sent/received
+ * during CFP
+ */
+#define IEEE80211_RADIOTAP_F_SHORTPRE 0x02 /* sent/received
+ * with short
+ * preamble
+ */
+#define IEEE80211_RADIOTAP_F_WEP 0x04 /* sent/received
+ * with WEP encryption
+ */
+#define IEEE80211_RADIOTAP_F_FRAG 0x08 /* sent/received
+ * with fragmentation
+ */
+#define IEEE80211_RADIOTAP_F_FCS 0x10 /* frame includes FCS */
+#define IEEE80211_RADIOTAP_F_DATAPAD 0x20 /* frame has padding between
+ * 802.11 header and payload
+ * (to 32-bit boundary)
+ */
+#define IEEE80211_RADIOTAP_F_BADFCS 0x40 /* does not pass FCS check */
+
+/* For IEEE80211_RADIOTAP_RX_FLAGS */
+#define IEEE80211_RADIOTAP_F_RX_BADFCS 0x0001 /* frame failed crc check */
+#define IEEE80211_RADIOTAP_F_RX_PLCP_CRC 0x0002 /* frame failed PLCP CRC check */
+
+/* For IEEE80211_RADIOTAP_MCS known */
+#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_KNOWN 0x01
+#define IEEE80211_RADIOTAP_MCS_MCS_INDEX_KNOWN 0x02 /* MCS index field */
+#define IEEE80211_RADIOTAP_MCS_GUARD_INTERVAL_KNOWN 0x04
+#define IEEE80211_RADIOTAP_MCS_HT_FORMAT_KNOWN 0x08
+#define IEEE80211_RADIOTAP_MCS_FEC_TYPE_KNOWN 0x10
+#define IEEE80211_RADIOTAP_MCS_STBC_KNOWN 0x20
+
+/* For IEEE80211_RADIOTAP_MCS flags */
+#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK 0x03
+#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20 0
+#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_40 1
+#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20L 2
+#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20U 3
+#define IEEE80211_RADIOTAP_MCS_SHORT_GI 0x04 /* short guard interval */
+#define IEEE80211_RADIOTAP_MCS_HT_GREENFIELD 0x08
+#define IEEE80211_RADIOTAP_MCS_FEC_LDPC 0x10
+#define IEEE80211_RADIOTAP_MCS_STBC_MASK 0x60
+#define IEEE80211_RADIOTAP_MCS_STBC_1 1
+#define IEEE80211_RADIOTAP_MCS_STBC_2 2
+#define IEEE80211_RADIOTAP_MCS_STBC_3 3
+#define IEEE80211_RADIOTAP_MCS_STBC_SHIFT 5
+
+static const char tstr[] = "[|802.11]";
/* Radiotap state */
/* This is used to save state when parsing/processing parameters */
struct radiotap_state
{
- u_int32_t present;
+ uint32_t present;
- u_int8_t rate;
+ uint8_t rate;
};
#define PRINT_SSID(p) \
if (p.ssid_present) { \
- printf(" ("); \
- fn_print(p.ssid.ssid, NULL); \
- printf(")"); \
+ ND_PRINT((ndo, " (")); \
+ fn_print(ndo, p.ssid.ssid, NULL); \
+ ND_PRINT((ndo, ")")); \
}
#define PRINT_RATE(_sep, _r, _suf) \
- printf("%s%2.1f%s", _sep, (.5 * ((_r) & 0x7f)), _suf)
+ ND_PRINT((ndo, "%s%2.1f%s", _sep, (.5 * ((_r) & 0x7f)), _suf))
#define PRINT_RATES(p) \
if (p.rates_present) { \
int z; \
@@ -74,14 +713,14 @@ struct radiotap_state
sep = " "; \
} \
if (p.rates.length != 0) \
- printf(" Mbit]"); \
+ ND_PRINT((ndo, " Mbit]")); \
}
#define PRINT_DS_CHANNEL(p) \
if (p.ds_present) \
- printf(" CH: %u", p.ds.channel); \
- printf("%s", \
- CAPABILITY_PRIVACY(p.capability_info) ? ", PRIVACY" : "" );
+ ND_PRINT((ndo, " CH: %u", p.ds.channel)); \
+ ND_PRINT((ndo, "%s", \
+ CAPABILITY_PRIVACY(p.capability_info) ? ", PRIVACY" : ""));
#define MAX_MCS_INDEX 76
@@ -548,9 +1187,7 @@ static const char *status_text[] = {
"The request has not been successful as one or more parameters "
"have invalid values", /* 38 */
"The TS has not been created because the request cannot be honored. "
- "However, a suggested TSPEC is provided so that the initiating QSTA"
- "may attempt to set another TS with the suggested changes to the "
- "TSPEC", /* 39 */
+ "Try again with the suggested changes to the TSPEC", /* 39 */
"Invalid Information Element", /* 40 */
"Group Cipher is not valid", /* 41 */
"Pairwise Cipher is not valid", /* 42 */
@@ -637,23 +1274,25 @@ static const char *reason_text[] = {
#define NUM_REASONS (sizeof reason_text / sizeof reason_text[0])
static int
-wep_print(const u_char *p)
+wep_print(netdissect_options *ndo,
+ const u_char *p)
{
- u_int32_t iv;
+ uint32_t iv;
- if (!TTEST2(*p, IEEE802_11_IV_LEN + IEEE802_11_KID_LEN))
+ if (!ND_TTEST2(*p, IEEE802_11_IV_LEN + IEEE802_11_KID_LEN))
return 0;
iv = EXTRACT_LE_32BITS(p);
- printf("Data IV:%3x Pad %x KeyID %x", IV_IV(iv), IV_PAD(iv),
- IV_KEYID(iv));
+ ND_PRINT((ndo, "Data IV:%3x Pad %x KeyID %x", IV_IV(iv), IV_PAD(iv),
+ IV_KEYID(iv)));
return 1;
}
static int
-parse_elements(struct mgmt_body_t *pbody, const u_char *p, int offset,
- u_int length)
+parse_elements(netdissect_options *ndo,
+ struct mgmt_body_t *pbody, const u_char *p, int offset,
+ u_int length)
{
u_int elementlen;
struct ssid_t ssid;
@@ -674,23 +1313,28 @@ parse_elements(struct mgmt_body_t *pbody, const u_char *p, int offset,
pbody->tim_present = 0;
while (length != 0) {
- if (!TTEST2(*(p + offset), 1))
+ /* Make sure we at least have the element ID and length. */
+ if (!ND_TTEST2(*(p + offset), 2))
+ return 0;
+ if (length < 2)
+ return 0;
+ elementlen = *(p + offset + 1);
+
+ /* Make sure we have the entire element. */
+ if (!ND_TTEST2(*(p + offset + 2), elementlen))
return 0;
- if (length < 1)
+ if (length < elementlen + 2)
return 0;
+
switch (*(p + offset)) {
case E_SSID:
- if (!TTEST2(*(p + offset), 2))
- return 0;
- if (length < 2)
- return 0;
memcpy(&ssid, p + offset, 2);
offset += 2;
length -= 2;
if (ssid.length != 0) {
if (ssid.length > sizeof(ssid.ssid) - 1)
return 0;
- if (!TTEST2(*(p + offset), ssid.length))
+ if (!ND_TTEST2(*(p + offset), ssid.length))
return 0;
if (length < ssid.length)
return 0;
@@ -712,10 +1356,6 @@ parse_elements(struct mgmt_body_t *pbody, const u_char *p, int offset,
}
break;
case E_CHALLENGE:
- if (!TTEST2(*(p + offset), 2))
- return 0;
- if (length < 2)
- return 0;
memcpy(&challenge, p + offset, 2);
offset += 2;
length -= 2;
@@ -723,7 +1363,7 @@ parse_elements(struct mgmt_body_t *pbody, const u_char *p, int offset,
if (challenge.length >
sizeof(challenge.text) - 1)
return 0;
- if (!TTEST2(*(p + offset), challenge.length))
+ if (!ND_TTEST2(*(p + offset), challenge.length))
return 0;
if (length < challenge.length)
return 0;
@@ -746,17 +1386,13 @@ parse_elements(struct mgmt_body_t *pbody, const u_char *p, int offset,
}
break;
case E_RATES:
- if (!TTEST2(*(p + offset), 2))
- return 0;
- if (length < 2)
- return 0;
memcpy(&rates, p + offset, 2);
offset += 2;
length -= 2;
if (rates.length != 0) {
if (rates.length > sizeof rates.rate)
return 0;
- if (!TTEST2(*(p + offset), rates.length))
+ if (!ND_TTEST2(*(p + offset), rates.length))
return 0;
if (length < rates.length)
return 0;
@@ -786,13 +1422,17 @@ parse_elements(struct mgmt_body_t *pbody, const u_char *p, int offset,
}
break;
case E_DS:
- if (!TTEST2(*(p + offset), 3))
- return 0;
- if (length < 3)
- return 0;
- memcpy(&ds, p + offset, 3);
- offset += 3;
- length -= 3;
+ memcpy(&ds, p + offset, 2);
+ offset += 2;
+ length -= 2;
+ if (ds.length != 1) {
+ offset += ds.length;
+ length -= ds.length;
+ break;
+ }
+ ds.channel = *(p + offset);
+ offset += 1;
+ length -= 1;
/*
* Present and not truncated.
*
@@ -806,13 +1446,17 @@ parse_elements(struct mgmt_body_t *pbody, const u_char *p, int offset,
}
break;
case E_CF:
- if (!TTEST2(*(p + offset), 8))
- return 0;
- if (length < 8)
- return 0;
- memcpy(&cf, p + offset, 8);
- offset += 8;
- length -= 8;
+ memcpy(&cf, p + offset, 2);
+ offset += 2;
+ length -= 2;
+ if (cf.length != 6) {
+ offset += cf.length;
+ length -= cf.length;
+ break;
+ }
+ memcpy(&cf.count, p + offset, 6);
+ offset += 6;
+ length -= 6;
/*
* Present and not truncated.
*
@@ -826,29 +1470,20 @@ parse_elements(struct mgmt_body_t *pbody, const u_char *p, int offset,
}
break;
case E_TIM:
- if (!TTEST2(*(p + offset), 2))
- return 0;
- if (length < 2)
- return 0;
memcpy(&tim, p + offset, 2);
offset += 2;
length -= 2;
- if (!TTEST2(*(p + offset), 3))
- return 0;
- if (length < 3)
+ if (tim.length <= 3) {
+ offset += tim.length;
+ length -= tim.length;
+ break;
+ }
+ if (tim.length - 3 > (int)sizeof tim.bitmap)
return 0;
memcpy(&tim.count, p + offset, 3);
offset += 3;
length -= 3;
- if (tim.length <= 3)
- break;
- if (tim.length - 3 > (int)sizeof tim.bitmap)
- return 0;
- if (!TTEST2(*(p + offset), tim.length - 3))
- return 0;
- if (length < (u_int)(tim.length - 3))
- return 0;
memcpy(tim.bitmap, p + (tim.length - 3),
(tim.length - 3));
offset += tim.length - 3;
@@ -867,20 +1502,11 @@ parse_elements(struct mgmt_body_t *pbody, const u_char *p, int offset,
break;
default:
#if 0
- printf("(1) unhandled element_id (%d) ",
- *(p + offset));
+ ND_PRINT((ndo, "(1) unhandled element_id (%d) ",
+ *(p + offset)));
#endif
- if (!TTEST2(*(p + offset), 2))
- return 0;
- if (length < 2)
- return 0;
- elementlen = *(p + offset + 1);
- if (!TTEST2(*(p + offset + 2), elementlen))
- return 0;
- if (length < elementlen + 2)
- return 0;
- offset += elementlen + 2;
- length -= elementlen + 2;
+ offset += 2 + elementlen;
+ length -= 2 + elementlen;
break;
}
}
@@ -894,7 +1520,8 @@ parse_elements(struct mgmt_body_t *pbody, const u_char *p, int offset,
*********************************************************************************/
static int
-handle_beacon(const u_char *p, u_int length)
+handle_beacon(netdissect_options *ndo,
+ const u_char *p, u_int length)
{
struct mgmt_body_t pbody;
int offset = 0;
@@ -902,7 +1529,7 @@ handle_beacon(const u_char *p, u_int length)
memset(&pbody, 0, sizeof(pbody));
- if (!TTEST2(*p, IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN +
+ if (!ND_TTEST2(*p, IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN +
IEEE802_11_CAPINFO_LEN))
return 0;
if (length < IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN +
@@ -918,19 +1545,20 @@ handle_beacon(const u_char *p, u_int length)
offset += IEEE802_11_CAPINFO_LEN;
length -= IEEE802_11_CAPINFO_LEN;
- ret = parse_elements(&pbody, p, offset, length);
+ ret = parse_elements(ndo, &pbody, p, offset, length);
PRINT_SSID(pbody);
PRINT_RATES(pbody);
- printf(" %s",
- CAPABILITY_ESS(pbody.capability_info) ? "ESS" : "IBSS");
+ ND_PRINT((ndo, " %s",
+ CAPABILITY_ESS(pbody.capability_info) ? "ESS" : "IBSS"));
PRINT_DS_CHANNEL(pbody);
return ret;
}
static int
-handle_assoc_request(const u_char *p, u_int length)
+handle_assoc_request(netdissect_options *ndo,
+ const u_char *p, u_int length)
{
struct mgmt_body_t pbody;
int offset = 0;
@@ -938,7 +1566,7 @@ handle_assoc_request(const u_char *p, u_int length)
memset(&pbody, 0, sizeof(pbody));
- if (!TTEST2(*p, IEEE802_11_CAPINFO_LEN + IEEE802_11_LISTENINT_LEN))
+ if (!ND_TTEST2(*p, IEEE802_11_CAPINFO_LEN + IEEE802_11_LISTENINT_LEN))
return 0;
if (length < IEEE802_11_CAPINFO_LEN + IEEE802_11_LISTENINT_LEN)
return 0;
@@ -949,7 +1577,7 @@ handle_assoc_request(const u_char *p, u_int length)
offset += IEEE802_11_LISTENINT_LEN;
length -= IEEE802_11_LISTENINT_LEN;
- ret = parse_elements(&pbody, p, offset, length);
+ ret = parse_elements(ndo, &pbody, p, offset, length);
PRINT_SSID(pbody);
PRINT_RATES(pbody);
@@ -957,7 +1585,8 @@ handle_assoc_request(const u_char *p, u_int length)
}
static int
-handle_assoc_response(const u_char *p, u_int length)
+handle_assoc_response(netdissect_options *ndo,
+ const u_char *p, u_int length)
{
struct mgmt_body_t pbody;
int offset = 0;
@@ -965,7 +1594,7 @@ handle_assoc_response(const u_char *p, u_int length)
memset(&pbody, 0, sizeof(pbody));
- if (!TTEST2(*p, IEEE802_11_CAPINFO_LEN + IEEE802_11_STATUS_LEN +
+ if (!ND_TTEST2(*p, IEEE802_11_CAPINFO_LEN + IEEE802_11_STATUS_LEN +
IEEE802_11_AID_LEN))
return 0;
if (length < IEEE802_11_CAPINFO_LEN + IEEE802_11_STATUS_LEN +
@@ -981,19 +1610,20 @@ handle_assoc_response(const u_char *p, u_int length)
offset += IEEE802_11_AID_LEN;
length -= IEEE802_11_AID_LEN;
- ret = parse_elements(&pbody, p, offset, length);
+ ret = parse_elements(ndo, &pbody, p, offset, length);
- printf(" AID(%x) :%s: %s", ((u_int16_t)(pbody.aid << 2 )) >> 2 ,
+ ND_PRINT((ndo, " AID(%x) :%s: %s", ((uint16_t)(pbody.aid << 2 )) >> 2 ,
CAPABILITY_PRIVACY(pbody.capability_info) ? " PRIVACY " : "",
(pbody.status_code < NUM_STATUSES
? status_text[pbody.status_code]
- : "n/a"));
+ : "n/a")));
return ret;
}
static int
-handle_reassoc_request(const u_char *p, u_int length)
+handle_reassoc_request(netdissect_options *ndo,
+ const u_char *p, u_int length)
{
struct mgmt_body_t pbody;
int offset = 0;
@@ -1001,7 +1631,7 @@ handle_reassoc_request(const u_char *p, u_int length)
memset(&pbody, 0, sizeof(pbody));
- if (!TTEST2(*p, IEEE802_11_CAPINFO_LEN + IEEE802_11_LISTENINT_LEN +
+ if (!ND_TTEST2(*p, IEEE802_11_CAPINFO_LEN + IEEE802_11_LISTENINT_LEN +
IEEE802_11_AP_LEN))
return 0;
if (length < IEEE802_11_CAPINFO_LEN + IEEE802_11_LISTENINT_LEN +
@@ -1017,23 +1647,25 @@ handle_reassoc_request(const u_char *p, u_int length)
offset += IEEE802_11_AP_LEN;
length -= IEEE802_11_AP_LEN;
- ret = parse_elements(&pbody, p, offset, length);
+ ret = parse_elements(ndo, &pbody, p, offset, length);
PRINT_SSID(pbody);
- printf(" AP : %s", etheraddr_string( pbody.ap ));
+ ND_PRINT((ndo, " AP : %s", etheraddr_string(ndo, pbody.ap )));
return ret;
}
static int
-handle_reassoc_response(const u_char *p, u_int length)
+handle_reassoc_response(netdissect_options *ndo,
+ const u_char *p, u_int length)
{
/* Same as a Association Reponse */
- return handle_assoc_response(p, length);
+ return handle_assoc_response(ndo, p, length);
}
static int
-handle_probe_request(const u_char *p, u_int length)
+handle_probe_request(netdissect_options *ndo,
+ const u_char *p, u_int length)
{
struct mgmt_body_t pbody;
int offset = 0;
@@ -1041,7 +1673,7 @@ handle_probe_request(const u_char *p, u_int length)
memset(&pbody, 0, sizeof(pbody));
- ret = parse_elements(&pbody, p, offset, length);
+ ret = parse_elements(ndo, &pbody, p, offset, length);
PRINT_SSID(pbody);
PRINT_RATES(pbody);
@@ -1050,7 +1682,8 @@ handle_probe_request(const u_char *p, u_int length)
}
static int
-handle_probe_response(const u_char *p, u_int length)
+handle_probe_response(netdissect_options *ndo,
+ const u_char *p, u_int length)
{
struct mgmt_body_t pbody;
int offset = 0;
@@ -1058,7 +1691,7 @@ handle_probe_response(const u_char *p, u_int length)
memset(&pbody, 0, sizeof(pbody));
- if (!TTEST2(*p, IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN +
+ if (!ND_TTEST2(*p, IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN +
IEEE802_11_CAPINFO_LEN))
return 0;
if (length < IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN +
@@ -1074,7 +1707,7 @@ handle_probe_response(const u_char *p, u_int length)
offset += IEEE802_11_CAPINFO_LEN;
length -= IEEE802_11_CAPINFO_LEN;
- ret = parse_elements(&pbody, p, offset, length);
+ ret = parse_elements(ndo, &pbody, p, offset, length);
PRINT_SSID(pbody);
PRINT_RATES(pbody);
@@ -1091,28 +1724,30 @@ handle_atim(void)
}
static int
-handle_disassoc(const u_char *p, u_int length)
+handle_disassoc(netdissect_options *ndo,
+ const u_char *p, u_int length)
{
struct mgmt_body_t pbody;
memset(&pbody, 0, sizeof(pbody));
- if (!TTEST2(*p, IEEE802_11_REASON_LEN))
+ if (!ND_TTEST2(*p, IEEE802_11_REASON_LEN))
return 0;
if (length < IEEE802_11_REASON_LEN)
return 0;
pbody.reason_code = EXTRACT_LE_16BITS(p);
- printf(": %s",
+ ND_PRINT((ndo, ": %s",
(pbody.reason_code < NUM_REASONS)
? reason_text[pbody.reason_code]
- : "Reserved" );
+ : "Reserved"));
return 1;
}
static int
-handle_auth(const u_char *p, u_int length)
+handle_auth(netdissect_options *ndo,
+ const u_char *p, u_int length)
{
struct mgmt_body_t pbody;
int offset = 0;
@@ -1120,7 +1755,7 @@ handle_auth(const u_char *p, u_int length)
memset(&pbody, 0, sizeof(pbody));
- if (!TTEST2(*p, 6))
+ if (!ND_TTEST2(*p, 6))
return 0;
if (length < 6)
return 0;
@@ -1134,12 +1769,12 @@ handle_auth(const u_char *p, u_int length)
offset += 2;
length -= 2;
- ret = parse_elements(&pbody, p, offset, length);
+ ret = parse_elements(ndo, &pbody, p, offset, length);
if ((pbody.auth_alg == 1) &&
((pbody.auth_trans_seq_num == 2) ||
(pbody.auth_trans_seq_num == 3))) {
- printf(" (%s)-%x [Challenge Text] %s",
+ ND_PRINT((ndo, " (%s)-%x [Challenge Text] %s",
(pbody.auth_alg < NUM_AUTH_ALGS)
? auth_alg_text[pbody.auth_alg]
: "Reserved",
@@ -1147,10 +1782,10 @@ handle_auth(const u_char *p, u_int length)
((pbody.auth_trans_seq_num % 2)
? ((pbody.status_code < NUM_STATUSES)
? status_text[pbody.status_code]
- : "n/a") : ""));
+ : "n/a") : "")));
return ret;
}
- printf(" (%s)-%x: %s",
+ ND_PRINT((ndo, " (%s)-%x: %s",
(pbody.auth_alg < NUM_AUTH_ALGS)
? auth_alg_text[pbody.auth_alg]
: "Reserved",
@@ -1159,126 +1794,125 @@ handle_auth(const u_char *p, u_int length)
? ((pbody.status_code < NUM_STATUSES)
? status_text[pbody.status_code]
: "n/a")
- : "");
+ : ""));
return ret;
}
static int
-handle_deauth(const struct mgmt_header_t *pmh, const u_char *p, u_int length)
+handle_deauth(netdissect_options *ndo,
+ const struct mgmt_header_t *pmh, const u_char *p, u_int length)
{
struct mgmt_body_t pbody;
- int offset = 0;
const char *reason = NULL;
memset(&pbody, 0, sizeof(pbody));
- if (!TTEST2(*p, IEEE802_11_REASON_LEN))
+ if (!ND_TTEST2(*p, IEEE802_11_REASON_LEN))
return 0;
if (length < IEEE802_11_REASON_LEN)
return 0;
pbody.reason_code = EXTRACT_LE_16BITS(p);
- offset += IEEE802_11_REASON_LEN;
- length -= IEEE802_11_REASON_LEN;
reason = (pbody.reason_code < NUM_REASONS)
? reason_text[pbody.reason_code]
: "Reserved";
- if (eflag) {
- printf(": %s", reason);
+ if (ndo->ndo_eflag) {
+ ND_PRINT((ndo, ": %s", reason));
} else {
- printf(" (%s): %s", etheraddr_string(pmh->sa), reason);
+ ND_PRINT((ndo, " (%s): %s", etheraddr_string(ndo, pmh->sa), reason));
}
return 1;
}
#define PRINT_HT_ACTION(v) (\
- (v) == 0 ? printf("TxChWidth") : \
- (v) == 1 ? printf("MIMOPwrSave") : \
- printf("Act#%d", (v)) \
+ (v) == 0 ? ND_PRINT((ndo, "TxChWidth")) : \
+ (v) == 1 ? ND_PRINT((ndo, "MIMOPwrSave")) : \
+ ND_PRINT((ndo, "Act#%d", (v))) \
)
#define PRINT_BA_ACTION(v) (\
- (v) == 0 ? printf("ADDBA Request") : \
- (v) == 1 ? printf("ADDBA Response") : \
- (v) == 2 ? printf("DELBA") : \
- printf("Act#%d", (v)) \
+ (v) == 0 ? ND_PRINT((ndo, "ADDBA Request")) : \
+ (v) == 1 ? ND_PRINT((ndo, "ADDBA Response")) : \
+ (v) == 2 ? ND_PRINT((ndo, "DELBA")) : \
+ ND_PRINT((ndo, "Act#%d", (v))) \
)
#define PRINT_MESHLINK_ACTION(v) (\
- (v) == 0 ? printf("Request") : \
- (v) == 1 ? printf("Report") : \
- printf("Act#%d", (v)) \
+ (v) == 0 ? ND_PRINT((ndo, "Request")) : \
+ (v) == 1 ? ND_PRINT((ndo, "Report")) : \
+ ND_PRINT((ndo, "Act#%d", (v))) \
)
#define PRINT_MESHPEERING_ACTION(v) (\
- (v) == 0 ? printf("Open") : \
- (v) == 1 ? printf("Confirm") : \
- (v) == 2 ? printf("Close") : \
- printf("Act#%d", (v)) \
+ (v) == 0 ? ND_PRINT((ndo, "Open")) : \
+ (v) == 1 ? ND_PRINT((ndo, "Confirm")) : \
+ (v) == 2 ? ND_PRINT((ndo, "Close")) : \
+ ND_PRINT((ndo, "Act#%d", (v))) \
)
#define PRINT_MESHPATH_ACTION(v) (\
- (v) == 0 ? printf("Request") : \
- (v) == 1 ? printf("Report") : \
- (v) == 2 ? printf("Error") : \
- (v) == 3 ? printf("RootAnnouncement") : \
- printf("Act#%d", (v)) \
+ (v) == 0 ? ND_PRINT((ndo, "Request")) : \
+ (v) == 1 ? ND_PRINT((ndo, "Report")) : \
+ (v) == 2 ? ND_PRINT((ndo, "Error")) : \
+ (v) == 3 ? ND_PRINT((ndo, "RootAnnouncement")) : \
+ ND_PRINT((ndo, "Act#%d", (v))) \
)
#define PRINT_MESH_ACTION(v) (\
- (v) == 0 ? printf("MeshLink") : \
- (v) == 1 ? printf("HWMP") : \
- (v) == 2 ? printf("Gate Announcement") : \
- (v) == 3 ? printf("Congestion Control") : \
- (v) == 4 ? printf("MCCA Setup Request") : \
- (v) == 5 ? printf("MCCA Setup Reply") : \
- (v) == 6 ? printf("MCCA Advertisement Request") : \
- (v) == 7 ? printf("MCCA Advertisement") : \
- (v) == 8 ? printf("MCCA Teardown") : \
- (v) == 9 ? printf("TBTT Adjustment Request") : \
- (v) == 10 ? printf("TBTT Adjustment Response") : \
- printf("Act#%d", (v)) \
+ (v) == 0 ? ND_PRINT((ndo, "MeshLink")) : \
+ (v) == 1 ? ND_PRINT((ndo, "HWMP")) : \
+ (v) == 2 ? ND_PRINT((ndo, "Gate Announcement")) : \
+ (v) == 3 ? ND_PRINT((ndo, "Congestion Control")) : \
+ (v) == 4 ? ND_PRINT((ndo, "MCCA Setup Request")) : \
+ (v) == 5 ? ND_PRINT((ndo, "MCCA Setup Reply")) : \
+ (v) == 6 ? ND_PRINT((ndo, "MCCA Advertisement Request")) : \
+ (v) == 7 ? ND_PRINT((ndo, "MCCA Advertisement")) : \
+ (v) == 8 ? ND_PRINT((ndo, "MCCA Teardown")) : \
+ (v) == 9 ? ND_PRINT((ndo, "TBTT Adjustment Request")) : \
+ (v) == 10 ? ND_PRINT((ndo, "TBTT Adjustment Response")) : \
+ ND_PRINT((ndo, "Act#%d", (v))) \
)
#define PRINT_MULTIHOP_ACTION(v) (\
- (v) == 0 ? printf("Proxy Update") : \
- (v) == 1 ? printf("Proxy Update Confirmation") : \
- printf("Act#%d", (v)) \
+ (v) == 0 ? ND_PRINT((ndo, "Proxy Update")) : \
+ (v) == 1 ? ND_PRINT((ndo, "Proxy Update Confirmation")) : \
+ ND_PRINT((ndo, "Act#%d", (v))) \
)
#define PRINT_SELFPROT_ACTION(v) (\
- (v) == 1 ? printf("Peering Open") : \
- (v) == 2 ? printf("Peering Confirm") : \
- (v) == 3 ? printf("Peering Close") : \
- (v) == 4 ? printf("Group Key Inform") : \
- (v) == 5 ? printf("Group Key Acknowledge") : \
- printf("Act#%d", (v)) \
+ (v) == 1 ? ND_PRINT((ndo, "Peering Open")) : \
+ (v) == 2 ? ND_PRINT((ndo, "Peering Confirm")) : \
+ (v) == 3 ? ND_PRINT((ndo, "Peering Close")) : \
+ (v) == 4 ? ND_PRINT((ndo, "Group Key Inform")) : \
+ (v) == 5 ? ND_PRINT((ndo, "Group Key Acknowledge")) : \
+ ND_PRINT((ndo, "Act#%d", (v))) \
)
static int
-handle_action(const struct mgmt_header_t *pmh, const u_char *p, u_int length)
+handle_action(netdissect_options *ndo,
+ const struct mgmt_header_t *pmh, const u_char *p, u_int length)
{
- if (!TTEST2(*p, 2))
+ if (!ND_TTEST2(*p, 2))
return 0;
if (length < 2)
return 0;
- if (eflag) {
- printf(": ");
+ if (ndo->ndo_eflag) {
+ ND_PRINT((ndo, ": "));
} else {
- printf(" (%s): ", etheraddr_string(pmh->sa));
+ ND_PRINT((ndo, " (%s): ", etheraddr_string(ndo, pmh->sa)));
}
switch (p[0]) {
- case 0: printf("Spectrum Management Act#%d", p[1]); break;
- case 1: printf("QoS Act#%d", p[1]); break;
- case 2: printf("DLS Act#%d", p[1]); break;
- case 3: printf("BA "); PRINT_BA_ACTION(p[1]); break;
- case 7: printf("HT "); PRINT_HT_ACTION(p[1]); break;
- case 13: printf("MeshAction "); PRINT_MESH_ACTION(p[1]); break;
+ case 0: ND_PRINT((ndo, "Spectrum Management Act#%d", p[1])); break;
+ case 1: ND_PRINT((ndo, "QoS Act#%d", p[1])); break;
+ case 2: ND_PRINT((ndo, "DLS Act#%d", p[1])); break;
+ case 3: ND_PRINT((ndo, "BA ")); PRINT_BA_ACTION(p[1]); break;
+ case 7: ND_PRINT((ndo, "HT ")); PRINT_HT_ACTION(p[1]); break;
+ case 13: ND_PRINT((ndo, "MeshAction ")); PRINT_MESH_ACTION(p[1]); break;
case 14:
- printf("MultiohopAction ");
+ ND_PRINT((ndo, "MultiohopAction "));
PRINT_MULTIHOP_ACTION(p[1]); break;
case 15:
- printf("SelfprotectAction ");
+ ND_PRINT((ndo, "SelfprotectAction "));
PRINT_SELFPROT_ACTION(p[1]); break;
- case 127: printf("Vendor Act#%d", p[1]); break;
+ case 127: ND_PRINT((ndo, "Vendor Act#%d", p[1])); break;
default:
- printf("Reserved(%d) Act#%d", p[0], p[1]);
+ ND_PRINT((ndo, "Reserved(%d) Act#%d", p[0], p[1]));
break;
}
return 1;
@@ -1291,57 +1925,43 @@ handle_action(const struct mgmt_header_t *pmh, const u_char *p, u_int length)
static int
-mgmt_body_print(u_int16_t fc, const struct mgmt_header_t *pmh,
- const u_char *p, u_int length)
+mgmt_body_print(netdissect_options *ndo,
+ uint16_t fc, const struct mgmt_header_t *pmh,
+ const u_char *p, u_int length)
{
+ ND_PRINT((ndo, "%s", tok2str(st_str, "Unhandled Management subtype(%x)", FC_SUBTYPE(fc))));
switch (FC_SUBTYPE(fc)) {
case ST_ASSOC_REQUEST:
- printf("Assoc Request");
- return handle_assoc_request(p, length);
+ return handle_assoc_request(ndo, p, length);
case ST_ASSOC_RESPONSE:
- printf("Assoc Response");
- return handle_assoc_response(p, length);
+ return handle_assoc_response(ndo, p, length);
case ST_REASSOC_REQUEST:
- printf("ReAssoc Request");
- return handle_reassoc_request(p, length);
+ return handle_reassoc_request(ndo, p, length);
case ST_REASSOC_RESPONSE:
- printf("ReAssoc Response");
- return handle_reassoc_response(p, length);
+ return handle_reassoc_response(ndo, p, length);
case ST_PROBE_REQUEST:
- printf("Probe Request");
- return handle_probe_request(p, length);
+ return handle_probe_request(ndo, p, length);
case ST_PROBE_RESPONSE:
- printf("Probe Response");
- return handle_probe_response(p, length);
+ return handle_probe_response(ndo, p, length);
case ST_BEACON:
- printf("Beacon");
- return handle_beacon(p, length);
+ return handle_beacon(ndo, p, length);
case ST_ATIM:
- printf("ATIM");
return handle_atim();
case ST_DISASSOC:
- printf("Disassociation");
- return handle_disassoc(p, length);
+ return handle_disassoc(ndo, p, length);
case ST_AUTH:
- printf("Authentication");
- if (!TTEST2(*p, 3))
+ if (!ND_TTEST2(*p, 3))
return 0;
if ((p[0] == 0 ) && (p[1] == 0) && (p[2] == 0)) {
- printf("Authentication (Shared-Key)-3 ");
- return wep_print(p);
+ ND_PRINT((ndo, "Authentication (Shared-Key)-3 "));
+ return wep_print(ndo, p);
}
- return handle_auth(p, length);
+ return handle_auth(ndo, p, length);
case ST_DEAUTH:
- printf("DeAuthentication");
- return handle_deauth(pmh, p, length);
- break;
+ return handle_deauth(ndo, pmh, p, length);
case ST_ACTION:
- printf("Action");
- return handle_action(pmh, p, length);
- break;
+ return handle_action(ndo, pmh, p, length);
default:
- printf("Unhandled Management subtype(%x)",
- FC_SUBTYPE(fc));
return 1;
}
}
@@ -1352,81 +1972,72 @@ mgmt_body_print(u_int16_t fc, const struct mgmt_header_t *pmh,
*********************************************************************************/
static int
-ctrl_body_print(u_int16_t fc, const u_char *p)
+ctrl_body_print(netdissect_options *ndo,
+ uint16_t fc, const u_char *p)
{
+ ND_PRINT((ndo, "%s", tok2str(ctrl_str, "Unknown Ctrl Subtype", FC_SUBTYPE(fc))));
switch (FC_SUBTYPE(fc)) {
case CTRL_CONTROL_WRAPPER:
- printf("Control Wrapper");
/* XXX - requires special handling */
break;
case CTRL_BAR:
- printf("BAR");
- if (!TTEST2(*p, CTRL_BAR_HDRLEN))
+ if (!ND_TTEST2(*p, CTRL_BAR_HDRLEN))
return 0;
- if (!eflag)
- printf(" RA:%s TA:%s CTL(%x) SEQ(%u) ",
- etheraddr_string(((const struct ctrl_bar_t *)p)->ra),
- etheraddr_string(((const struct ctrl_bar_t *)p)->ta),
+ if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, " RA:%s TA:%s CTL(%x) SEQ(%u) ",
+ etheraddr_string(ndo, ((const struct ctrl_bar_t *)p)->ra),
+ etheraddr_string(ndo, ((const struct ctrl_bar_t *)p)->ta),
EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t *)p)->ctl)),
- EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t *)p)->seq)));
+ EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t *)p)->seq))));
break;
case CTRL_BA:
- printf("BA");
- if (!TTEST2(*p, CTRL_BA_HDRLEN))
+ if (!ND_TTEST2(*p, CTRL_BA_HDRLEN))
return 0;
- if (!eflag)
- printf(" RA:%s ",
- etheraddr_string(((const struct ctrl_ba_t *)p)->ra));
+ if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, " RA:%s ",
+ etheraddr_string(ndo, ((const struct ctrl_ba_t *)p)->ra)));
break;
case CTRL_PS_POLL:
- printf("Power Save-Poll");
- if (!TTEST2(*p, CTRL_PS_POLL_HDRLEN))
+ if (!ND_TTEST2(*p, CTRL_PS_POLL_HDRLEN))
return 0;
- printf(" AID(%x)",
- EXTRACT_LE_16BITS(&(((const struct ctrl_ps_poll_t *)p)->aid)));
+ ND_PRINT((ndo, " AID(%x)",
+ EXTRACT_LE_16BITS(&(((const struct ctrl_ps_poll_t *)p)->aid))));
break;
case CTRL_RTS:
- printf("Request-To-Send");
- if (!TTEST2(*p, CTRL_RTS_HDRLEN))
+ if (!ND_TTEST2(*p, CTRL_RTS_HDRLEN))
return 0;
- if (!eflag)
- printf(" TA:%s ",
- etheraddr_string(((const struct ctrl_rts_t *)p)->ta));
+ if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, " TA:%s ",
+ etheraddr_string(ndo, ((const struct ctrl_rts_t *)p)->ta)));
break;
case CTRL_CTS:
- printf("Clear-To-Send");
- if (!TTEST2(*p, CTRL_CTS_HDRLEN))
+ if (!ND_TTEST2(*p, CTRL_CTS_HDRLEN))
return 0;
- if (!eflag)
- printf(" RA:%s ",
- etheraddr_string(((const struct ctrl_cts_t *)p)->ra));
+ if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, " RA:%s ",
+ etheraddr_string(ndo, ((const struct ctrl_cts_t *)p)->ra)));
break;
case CTRL_ACK:
- printf("Acknowledgment");
- if (!TTEST2(*p, CTRL_ACK_HDRLEN))
+ if (!ND_TTEST2(*p, CTRL_ACK_HDRLEN))
return 0;
- if (!eflag)
- printf(" RA:%s ",
- etheraddr_string(((const struct ctrl_ack_t *)p)->ra));
+ if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, " RA:%s ",
+ etheraddr_string(ndo, ((const struct ctrl_ack_t *)p)->ra)));
break;
case CTRL_CF_END:
- printf("CF-End");
- if (!TTEST2(*p, CTRL_END_HDRLEN))
+ if (!ND_TTEST2(*p, CTRL_END_HDRLEN))
return 0;
- if (!eflag)
- printf(" RA:%s ",
- etheraddr_string(((const struct ctrl_end_t *)p)->ra));
+ if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, " RA:%s ",
+ etheraddr_string(ndo, ((const struct ctrl_end_t *)p)->ra)));
break;
case CTRL_END_ACK:
- printf("CF-End+CF-Ack");
- if (!TTEST2(*p, CTRL_END_ACK_HDRLEN))
+ if (!ND_TTEST2(*p, CTRL_END_ACK_HDRLEN))
return 0;
- if (!eflag)
- printf(" RA:%s ",
- etheraddr_string(((const struct ctrl_end_ack_t *)p)->ra));
+ if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, " RA:%s ",
+ etheraddr_string(ndo, ((const struct ctrl_end_ack_t *)p)->ra)));
break;
- default:
- printf("Unknown Ctrl Subtype");
}
return 1;
}
@@ -1446,26 +2057,27 @@ ctrl_body_print(u_int16_t fc, const u_char *p)
*/
static void
-data_header_print(u_int16_t fc, const u_char *p, const u_int8_t **srcp,
- const u_int8_t **dstp)
+data_header_print(netdissect_options *ndo,
+ uint16_t fc, const u_char *p, const uint8_t **srcp,
+ const uint8_t **dstp)
{
u_int subtype = FC_SUBTYPE(fc);
if (DATA_FRAME_IS_CF_ACK(subtype) || DATA_FRAME_IS_CF_POLL(subtype) ||
DATA_FRAME_IS_QOS(subtype)) {
- printf("CF ");
+ ND_PRINT((ndo, "CF "));
if (DATA_FRAME_IS_CF_ACK(subtype)) {
if (DATA_FRAME_IS_CF_POLL(subtype))
- printf("Ack/Poll");
+ ND_PRINT((ndo, "Ack/Poll"));
else
- printf("Ack");
+ ND_PRINT((ndo, "Ack"));
} else {
if (DATA_FRAME_IS_CF_POLL(subtype))
- printf("Poll");
+ ND_PRINT((ndo, "Poll"));
}
if (DATA_FRAME_IS_QOS(subtype))
- printf("+QoS");
- printf(" ");
+ ND_PRINT((ndo, "+QoS"));
+ ND_PRINT((ndo, " "));
}
#define ADDR1 (p + 4)
@@ -1478,41 +2090,41 @@ data_header_print(u_int16_t fc, const u_char *p, const u_int8_t **srcp,
*srcp = ADDR2;
if (dstp != NULL)
*dstp = ADDR1;
- if (!eflag)
+ if (!ndo->ndo_eflag)
return;
- printf("DA:%s SA:%s BSSID:%s ",
- etheraddr_string(ADDR1), etheraddr_string(ADDR2),
- etheraddr_string(ADDR3));
+ ND_PRINT((ndo, "DA:%s SA:%s BSSID:%s ",
+ etheraddr_string(ndo, ADDR1), etheraddr_string(ndo, ADDR2),
+ etheraddr_string(ndo, ADDR3)));
} else if (!FC_TO_DS(fc) && FC_FROM_DS(fc)) {
if (srcp != NULL)
*srcp = ADDR3;
if (dstp != NULL)
*dstp = ADDR1;
- if (!eflag)
+ if (!ndo->ndo_eflag)
return;
- printf("DA:%s BSSID:%s SA:%s ",
- etheraddr_string(ADDR1), etheraddr_string(ADDR2),
- etheraddr_string(ADDR3));
+ ND_PRINT((ndo, "DA:%s BSSID:%s SA:%s ",
+ etheraddr_string(ndo, ADDR1), etheraddr_string(ndo, ADDR2),
+ etheraddr_string(ndo, ADDR3)));
} else if (FC_TO_DS(fc) && !FC_FROM_DS(fc)) {
if (srcp != NULL)
*srcp = ADDR2;
if (dstp != NULL)
*dstp = ADDR3;
- if (!eflag)
+ if (!ndo->ndo_eflag)
return;
- printf("BSSID:%s SA:%s DA:%s ",
- etheraddr_string(ADDR1), etheraddr_string(ADDR2),
- etheraddr_string(ADDR3));
+ ND_PRINT((ndo, "BSSID:%s SA:%s DA:%s ",
+ etheraddr_string(ndo, ADDR1), etheraddr_string(ndo, ADDR2),
+ etheraddr_string(ndo, ADDR3)));
} else if (FC_TO_DS(fc) && FC_FROM_DS(fc)) {
if (srcp != NULL)
*srcp = ADDR4;
if (dstp != NULL)
*dstp = ADDR3;
- if (!eflag)
+ if (!ndo->ndo_eflag)
return;
- printf("RA:%s TA:%s DA:%s SA:%s ",
- etheraddr_string(ADDR1), etheraddr_string(ADDR2),
- etheraddr_string(ADDR3), etheraddr_string(ADDR4));
+ ND_PRINT((ndo, "RA:%s TA:%s DA:%s SA:%s ",
+ etheraddr_string(ndo, ADDR1), etheraddr_string(ndo, ADDR2),
+ etheraddr_string(ndo, ADDR3), etheraddr_string(ndo, ADDR4)));
}
#undef ADDR1
@@ -1522,8 +2134,8 @@ data_header_print(u_int16_t fc, const u_char *p, const u_int8_t **srcp,
}
static void
-mgmt_header_print(const u_char *p, const u_int8_t **srcp,
- const u_int8_t **dstp)
+mgmt_header_print(netdissect_options *ndo,
+ const u_char *p, const uint8_t **srcp, const uint8_t **dstp)
{
const struct mgmt_header_t *hp = (const struct mgmt_header_t *) p;
@@ -1531,73 +2143,75 @@ mgmt_header_print(const u_char *p, const u_int8_t **srcp,
*srcp = hp->sa;
if (dstp != NULL)
*dstp = hp->da;
- if (!eflag)
+ if (!ndo->ndo_eflag)
return;
- printf("BSSID:%s DA:%s SA:%s ",
- etheraddr_string((hp)->bssid), etheraddr_string((hp)->da),
- etheraddr_string((hp)->sa));
+ ND_PRINT((ndo, "BSSID:%s DA:%s SA:%s ",
+ etheraddr_string(ndo, (hp)->bssid), etheraddr_string(ndo, (hp)->da),
+ etheraddr_string(ndo, (hp)->sa)));
}
static void
-ctrl_header_print(u_int16_t fc, const u_char *p, const u_int8_t **srcp,
- const u_int8_t **dstp)
+ctrl_header_print(netdissect_options *ndo,
+ uint16_t fc, const u_char *p, const uint8_t **srcp,
+ const uint8_t **dstp)
{
if (srcp != NULL)
*srcp = NULL;
if (dstp != NULL)
*dstp = NULL;
- if (!eflag)
+ if (!ndo->ndo_eflag)
return;
switch (FC_SUBTYPE(fc)) {
case CTRL_BAR:
- printf(" RA:%s TA:%s CTL(%x) SEQ(%u) ",
- etheraddr_string(((const struct ctrl_bar_t *)p)->ra),
- etheraddr_string(((const struct ctrl_bar_t *)p)->ta),
+ ND_PRINT((ndo, " RA:%s TA:%s CTL(%x) SEQ(%u) ",
+ etheraddr_string(ndo, ((const struct ctrl_bar_t *)p)->ra),
+ etheraddr_string(ndo, ((const struct ctrl_bar_t *)p)->ta),
EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t *)p)->ctl)),
- EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t *)p)->seq)));
+ EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t *)p)->seq))));
break;
case CTRL_BA:
- printf("RA:%s ",
- etheraddr_string(((const struct ctrl_ba_t *)p)->ra));
+ ND_PRINT((ndo, "RA:%s ",
+ etheraddr_string(ndo, ((const struct ctrl_ba_t *)p)->ra)));
break;
case CTRL_PS_POLL:
- printf("BSSID:%s TA:%s ",
- etheraddr_string(((const struct ctrl_ps_poll_t *)p)->bssid),
- etheraddr_string(((const struct ctrl_ps_poll_t *)p)->ta));
+ ND_PRINT((ndo, "BSSID:%s TA:%s ",
+ etheraddr_string(ndo, ((const struct ctrl_ps_poll_t *)p)->bssid),
+ etheraddr_string(ndo, ((const struct ctrl_ps_poll_t *)p)->ta)));
break;
case CTRL_RTS:
- printf("RA:%s TA:%s ",
- etheraddr_string(((const struct ctrl_rts_t *)p)->ra),
- etheraddr_string(((const struct ctrl_rts_t *)p)->ta));
+ ND_PRINT((ndo, "RA:%s TA:%s ",
+ etheraddr_string(ndo, ((const struct ctrl_rts_t *)p)->ra),
+ etheraddr_string(ndo, ((const struct ctrl_rts_t *)p)->ta)));
break;
case CTRL_CTS:
- printf("RA:%s ",
- etheraddr_string(((const struct ctrl_cts_t *)p)->ra));
+ ND_PRINT((ndo, "RA:%s ",
+ etheraddr_string(ndo, ((const struct ctrl_cts_t *)p)->ra)));
break;
case CTRL_ACK:
- printf("RA:%s ",
- etheraddr_string(((const struct ctrl_ack_t *)p)->ra));
+ ND_PRINT((ndo, "RA:%s ",
+ etheraddr_string(ndo, ((const struct ctrl_ack_t *)p)->ra)));
break;
case CTRL_CF_END:
- printf("RA:%s BSSID:%s ",
- etheraddr_string(((const struct ctrl_end_t *)p)->ra),
- etheraddr_string(((const struct ctrl_end_t *)p)->bssid));
+ ND_PRINT((ndo, "RA:%s BSSID:%s ",
+ etheraddr_string(ndo, ((const struct ctrl_end_t *)p)->ra),
+ etheraddr_string(ndo, ((const struct ctrl_end_t *)p)->bssid)));
break;
case CTRL_END_ACK:
- printf("RA:%s BSSID:%s ",
- etheraddr_string(((const struct ctrl_end_ack_t *)p)->ra),
- etheraddr_string(((const struct ctrl_end_ack_t *)p)->bssid));
+ ND_PRINT((ndo, "RA:%s BSSID:%s ",
+ etheraddr_string(ndo, ((const struct ctrl_end_ack_t *)p)->ra),
+ etheraddr_string(ndo, ((const struct ctrl_end_ack_t *)p)->bssid)));
break;
default:
- printf("(H) Unknown Ctrl Subtype");
+ ND_PRINT((ndo, "(H) Unknown Ctrl Subtype"));
break;
}
}
static int
-extract_header_length(u_int16_t fc)
+extract_header_length(netdissect_options *ndo,
+ uint16_t fc)
{
int len;
@@ -1629,7 +2243,7 @@ extract_header_length(u_int16_t fc)
len += 2;
return len;
default:
- printf("unknown IEEE802.11 frame type (%d)", FC_TYPE(fc));
+ ND_PRINT((ndo, "unknown IEEE802.11 frame type (%d)", FC_TYPE(fc)));
return 0;
}
}
@@ -1646,56 +2260,58 @@ extract_mesh_header_length(const u_char *p)
* "srcp" and "dstp" aren't null.
*/
static void
-ieee_802_11_hdr_print(u_int16_t fc, const u_char *p, u_int hdrlen,
- u_int meshdrlen, const u_int8_t **srcp, const u_int8_t **dstp)
+ieee_802_11_hdr_print(netdissect_options *ndo,
+ uint16_t fc, const u_char *p, u_int hdrlen,
+ u_int meshdrlen, const uint8_t **srcp,
+ const uint8_t **dstp)
{
- if (vflag) {
+ if (ndo->ndo_vflag) {
if (FC_MORE_DATA(fc))
- printf("More Data ");
+ ND_PRINT((ndo, "More Data "));
if (FC_MORE_FLAG(fc))
- printf("More Fragments ");
+ ND_PRINT((ndo, "More Fragments "));
if (FC_POWER_MGMT(fc))
- printf("Pwr Mgmt ");
+ ND_PRINT((ndo, "Pwr Mgmt "));
if (FC_RETRY(fc))
- printf("Retry ");
+ ND_PRINT((ndo, "Retry "));
if (FC_ORDER(fc))
- printf("Strictly Ordered ");
+ ND_PRINT((ndo, "Strictly Ordered "));
if (FC_WEP(fc))
- printf("WEP Encrypted ");
+ ND_PRINT((ndo, "WEP Encrypted "));
if (FC_TYPE(fc) != T_CTRL || FC_SUBTYPE(fc) != CTRL_PS_POLL)
- printf("%dus ",
+ ND_PRINT((ndo, "%dus ",
EXTRACT_LE_16BITS(
- &((const struct mgmt_header_t *)p)->duration));
+ &((const struct mgmt_header_t *)p)->duration)));
}
if (meshdrlen != 0) {
const struct meshcntl_t *mc =
(const struct meshcntl_t *)&p[hdrlen - meshdrlen];
int ae = mc->flags & 3;
- printf("MeshData (AE %d TTL %u seq %u", ae, mc->ttl,
- EXTRACT_LE_32BITS(mc->seq));
+ ND_PRINT((ndo, "MeshData (AE %d TTL %u seq %u", ae, mc->ttl,
+ EXTRACT_LE_32BITS(mc->seq)));
if (ae > 0)
- printf(" A4:%s", etheraddr_string(mc->addr4));
+ ND_PRINT((ndo, " A4:%s", etheraddr_string(ndo, mc->addr4)));
if (ae > 1)
- printf(" A5:%s", etheraddr_string(mc->addr5));
+ ND_PRINT((ndo, " A5:%s", etheraddr_string(ndo, mc->addr5)));
if (ae > 2)
- printf(" A6:%s", etheraddr_string(mc->addr6));
- printf(") ");
+ ND_PRINT((ndo, " A6:%s", etheraddr_string(ndo, mc->addr6)));
+ ND_PRINT((ndo, ") "));
}
switch (FC_TYPE(fc)) {
case T_MGMT:
- mgmt_header_print(p, srcp, dstp);
+ mgmt_header_print(ndo, p, srcp, dstp);
break;
case T_CTRL:
- ctrl_header_print(fc, p, srcp, dstp);
+ ctrl_header_print(ndo, fc, p, srcp, dstp);
break;
case T_DATA:
- data_header_print(fc, p, srcp, dstp);
+ data_header_print(ndo, fc, p, srcp, dstp);
break;
default:
- printf("(header) unknown IEEE802.11 frame type (%d)",
- FC_TYPE(fc));
+ ND_PRINT((ndo, "(header) unknown IEEE802.11 frame type (%d)",
+ FC_TYPE(fc)));
*srcp = NULL;
*dstp = NULL;
break;
@@ -1707,18 +2323,19 @@ ieee_802_11_hdr_print(u_int16_t fc, const u_char *p, u_int hdrlen,
#endif
static u_int
-ieee802_11_print(const u_char *p, u_int length, u_int orig_caplen, int pad,
- u_int fcslen)
+ieee802_11_print(netdissect_options *ndo,
+ const u_char *p, u_int length, u_int orig_caplen, int pad,
+ u_int fcslen)
{
- u_int16_t fc;
+ uint16_t fc;
u_int caplen, hdrlen, meshdrlen;
- const u_int8_t *src, *dst;
+ const uint8_t *src, *dst;
u_short extracted_ethertype;
caplen = orig_caplen;
/* Remove FCS, if present */
if (length < fcslen) {
- printf("[|802.11]");
+ ND_PRINT((ndo, "%s", tstr));
return caplen;
}
length -= fcslen;
@@ -1726,19 +2343,19 @@ ieee802_11_print(const u_char *p, u_int length, u_int orig_caplen, int pad,
/* Amount of FCS in actual packet data, if any */
fcslen = caplen - length;
caplen -= fcslen;
- snapend -= fcslen;
+ ndo->ndo_snapend -= fcslen;
}
if (caplen < IEEE802_11_FC_LEN) {
- printf("[|802.11]");
+ ND_PRINT((ndo, "%s", tstr));
return orig_caplen;
}
fc = EXTRACT_LE_16BITS(p);
- hdrlen = extract_header_length(fc);
+ hdrlen = extract_header_length(ndo, fc);
if (pad)
hdrlen = roundup2(hdrlen, 4);
- if (Hflag && FC_TYPE(fc) == T_DATA &&
+ if (ndo->ndo_Hflag && FC_TYPE(fc) == T_DATA &&
DATA_FRAME_IS_QOS(FC_SUBTYPE(fc))) {
meshdrlen = extract_mesh_header_length(p+hdrlen);
hdrlen += meshdrlen;
@@ -1747,11 +2364,11 @@ ieee802_11_print(const u_char *p, u_int length, u_int orig_caplen, int pad,
if (caplen < hdrlen) {
- printf("[|802.11]");
+ ND_PRINT((ndo, "%s", tstr));
return hdrlen;
}
- ieee_802_11_hdr_print(fc, p, hdrlen, meshdrlen, &src, &dst);
+ ieee_802_11_hdr_print(ndo, fc, p, hdrlen, meshdrlen, &src, &dst);
/*
* Go past the 802.11 header.
@@ -1762,15 +2379,15 @@ ieee802_11_print(const u_char *p, u_int length, u_int orig_caplen, int pad,
switch (FC_TYPE(fc)) {
case T_MGMT:
- if (!mgmt_body_print(fc,
+ if (!mgmt_body_print(ndo, fc,
(const struct mgmt_header_t *)(p - hdrlen), p, length)) {
- printf("[|802.11]");
+ ND_PRINT((ndo, "%s", tstr));
return hdrlen;
}
break;
case T_CTRL:
- if (!ctrl_body_print(fc, p - hdrlen)) {
- printf("[|802.11]");
+ if (!ctrl_body_print(ndo, fc, p - hdrlen)) {
+ ND_PRINT((ndo, "%s", tstr));
return hdrlen;
}
break;
@@ -1779,29 +2396,29 @@ ieee802_11_print(const u_char *p, u_int length, u_int orig_caplen, int pad,
return hdrlen; /* no-data frame */
/* There may be a problem w/ AP not having this bit set */
if (FC_WEP(fc)) {
- if (!wep_print(p)) {
- printf("[|802.11]");
+ if (!wep_print(ndo, p)) {
+ ND_PRINT((ndo, "%s", tstr));
return hdrlen;
}
- } else if (llc_print(p, length, caplen, dst, src,
+ } else if (llc_print(ndo, p, length, caplen, dst, src,
&extracted_ethertype) == 0) {
/*
* Some kinds of LLC packet we cannot
* handle intelligently
*/
- if (!eflag)
- ieee_802_11_hdr_print(fc, p - hdrlen, hdrlen,
+ if (!ndo->ndo_eflag)
+ ieee_802_11_hdr_print(ndo, fc, p - hdrlen, hdrlen,
meshdrlen, NULL, NULL);
if (extracted_ethertype)
- printf("(LLC %s) ",
+ ND_PRINT((ndo, "(LLC %s) ",
etherproto_string(
- htons(extracted_ethertype)));
- if (!suppress_default_print)
- default_print(p, caplen);
+ htons(extracted_ethertype))));
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
}
break;
default:
- printf("unknown 802.11 frame type (%d)", FC_TYPE(fc));
+ ND_PRINT((ndo, "unknown 802.11 frame type (%d)", FC_TYPE(fc)));
break;
}
@@ -1815,9 +2432,10 @@ ieee802_11_print(const u_char *p, u_int length, u_int orig_caplen, int pad,
* is the number of bytes actually captured.
*/
u_int
-ieee802_11_if_print(const struct pcap_pkthdr *h, const u_char *p)
+ieee802_11_if_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, const u_char *p)
{
- return ieee802_11_print(p, h->len, h->caplen, 0, 0);
+ return ieee802_11_print(ndo, p, h->len, h->caplen, 0, 0);
}
#define IEEE80211_CHAN_FHSS \
@@ -1845,50 +2463,52 @@ ieee802_11_if_print(const struct pcap_pkthdr *h, const u_char *p)
(IS_CHAN_PUREG(flags) || IS_CHAN_G(flags))
static void
-print_chaninfo(int freq, int flags)
+print_chaninfo(netdissect_options *ndo,
+ int freq, int flags)
{
- printf("%u MHz", freq);
+ ND_PRINT((ndo, "%u MHz", freq));
if (IS_CHAN_FHSS(flags))
- printf(" FHSS");
+ ND_PRINT((ndo, " FHSS"));
if (IS_CHAN_A(flags)) {
if (flags & IEEE80211_CHAN_HALF)
- printf(" 11a/10Mhz");
+ ND_PRINT((ndo, " 11a/10Mhz"));
else if (flags & IEEE80211_CHAN_QUARTER)
- printf(" 11a/5Mhz");
+ ND_PRINT((ndo, " 11a/5Mhz"));
else
- printf(" 11a");
+ ND_PRINT((ndo, " 11a"));
}
if (IS_CHAN_ANYG(flags)) {
if (flags & IEEE80211_CHAN_HALF)
- printf(" 11g/10Mhz");
+ ND_PRINT((ndo, " 11g/10Mhz"));
else if (flags & IEEE80211_CHAN_QUARTER)
- printf(" 11g/5Mhz");
+ ND_PRINT((ndo, " 11g/5Mhz"));
else
- printf(" 11g");
+ ND_PRINT((ndo, " 11g"));
} else if (IS_CHAN_B(flags))
- printf(" 11b");
+ ND_PRINT((ndo, " 11b"));
if (flags & IEEE80211_CHAN_TURBO)
- printf(" Turbo");
+ ND_PRINT((ndo, " Turbo"));
if (flags & IEEE80211_CHAN_HT20)
- printf(" ht/20");
+ ND_PRINT((ndo, " ht/20"));
else if (flags & IEEE80211_CHAN_HT40D)
- printf(" ht/40-");
+ ND_PRINT((ndo, " ht/40-"));
else if (flags & IEEE80211_CHAN_HT40U)
- printf(" ht/40+");
- printf(" ");
+ ND_PRINT((ndo, " ht/40+"));
+ ND_PRINT((ndo, " "));
}
static int
-print_radiotap_field(struct cpack_state *s, u_int32_t bit, u_int8_t *flags,
- struct radiotap_state *state, u_int32_t presentflags)
+print_radiotap_field(netdissect_options *ndo,
+ struct cpack_state *s, uint32_t bit, uint8_t *flags,
+ struct radiotap_state *state, uint32_t presentflags)
{
union {
int8_t i8;
- u_int8_t u8;
+ uint8_t u8;
int16_t i16;
- u_int16_t u16;
- u_int32_t u32;
- u_int64_t u64;
+ uint16_t u16;
+ uint32_t u32;
+ uint64_t u64;
} u, u2, u3, u4;
int rc;
@@ -1959,9 +2579,9 @@ print_radiotap_field(struct cpack_state *s, u_int32_t bit, u_int8_t *flags,
rc = cpack_uint8(s, &u3.u8);
break;
case IEEE80211_RADIOTAP_VENDOR_NAMESPACE: {
- u_int8_t vns[3];
- u_int16_t length;
- u_int8_t subspace;
+ uint8_t vns[3];
+ uint16_t length;
+ uint8_t subspace;
if ((cpack_align_and_reserve(s, 2)) == NULL) {
rc = -1;
@@ -1993,12 +2613,12 @@ print_radiotap_field(struct cpack_state *s, u_int32_t bit, u_int8_t *flags,
* size we do not know, so we cannot
* proceed. Just print the bit number.
*/
- printf("[bit %u] ", bit);
+ ND_PRINT((ndo, "[bit %u] ", bit));
return -1;
}
if (rc != 0) {
- printf("[|802.11]");
+ ND_PRINT((ndo, "%s", tstr));
return rc;
}
@@ -2013,10 +2633,10 @@ print_radiotap_field(struct cpack_state *s, u_int32_t bit, u_int8_t *flags,
*/
if (presentflags & (1 << IEEE80211_RADIOTAP_XCHANNEL))
break;
- print_chaninfo(u.u16, u2.u16);
+ print_chaninfo(ndo, u.u16, u2.u16);
break;
case IEEE80211_RADIOTAP_FHSS:
- printf("fhset %d fhpat %d ", u.u16 & 0xff, (u.u16 >> 8) & 0xff);
+ ND_PRINT((ndo, "fhset %d fhpat %d ", u.u16 & 0xff, (u.u16 >> 8) & 0xff));
break;
case IEEE80211_RADIOTAP_RATE:
/*
@@ -2057,57 +2677,57 @@ print_radiotap_field(struct cpack_state *s, u_int32_t bit, u_int8_t *flags,
* information from Flags, at least on
* FreeBSD?
*/
- printf("MCS %u ", u.u8 & 0x7f);
+ ND_PRINT((ndo, "MCS %u ", u.u8 & 0x7f));
} else
- printf("%2.1f Mb/s ", .5*u.u8);
+ ND_PRINT((ndo, "%2.1f Mb/s ", .5 * u.u8));
break;
case IEEE80211_RADIOTAP_DBM_ANTSIGNAL:
- printf("%ddB signal ", u.i8);
+ ND_PRINT((ndo, "%ddB signal ", u.i8));
break;
case IEEE80211_RADIOTAP_DBM_ANTNOISE:
- printf("%ddB noise ", u.i8);
+ ND_PRINT((ndo, "%ddB noise ", u.i8));
break;
case IEEE80211_RADIOTAP_DB_ANTSIGNAL:
- printf("%ddB signal ", u.u8);
+ ND_PRINT((ndo, "%ddB signal ", u.u8));
break;
case IEEE80211_RADIOTAP_DB_ANTNOISE:
- printf("%ddB noise ", u.u8);
+ ND_PRINT((ndo, "%ddB noise ", u.u8));
break;
case IEEE80211_RADIOTAP_LOCK_QUALITY:
- printf("%u sq ", u.u16);
+ ND_PRINT((ndo, "%u sq ", u.u16));
break;
case IEEE80211_RADIOTAP_TX_ATTENUATION:
- printf("%d tx power ", -(int)u.u16);
+ ND_PRINT((ndo, "%d tx power ", -(int)u.u16));
break;
case IEEE80211_RADIOTAP_DB_TX_ATTENUATION:
- printf("%ddB tx power ", -(int)u.u8);
+ ND_PRINT((ndo, "%ddB tx power ", -(int)u.u8));
break;
case IEEE80211_RADIOTAP_DBM_TX_POWER:
- printf("%ddBm tx power ", u.i8);
+ ND_PRINT((ndo, "%ddBm tx power ", u.i8));
break;
case IEEE80211_RADIOTAP_FLAGS:
if (u.u8 & IEEE80211_RADIOTAP_F_CFP)
- printf("cfp ");
+ ND_PRINT((ndo, "cfp "));
if (u.u8 & IEEE80211_RADIOTAP_F_SHORTPRE)
- printf("short preamble ");
+ ND_PRINT((ndo, "short preamble "));
if (u.u8 & IEEE80211_RADIOTAP_F_WEP)
- printf("wep ");
+ ND_PRINT((ndo, "wep "));
if (u.u8 & IEEE80211_RADIOTAP_F_FRAG)
- printf("fragmented ");
+ ND_PRINT((ndo, "fragmented "));
if (u.u8 & IEEE80211_RADIOTAP_F_BADFCS)
- printf("bad-fcs ");
+ ND_PRINT((ndo, "bad-fcs "));
break;
case IEEE80211_RADIOTAP_ANTENNA:
- printf("antenna %d ", u.u8);
+ ND_PRINT((ndo, "antenna %d ", u.u8));
break;
case IEEE80211_RADIOTAP_TSFT:
- printf("%" PRIu64 "us tsft ", u.u64);
+ ND_PRINT((ndo, "%" PRIu64 "us tsft ", u.u64));
break;
case IEEE80211_RADIOTAP_RX_FLAGS:
/* Do nothing for now */
break;
case IEEE80211_RADIOTAP_XCHANNEL:
- print_chaninfo(u2.u16, u.u32);
+ print_chaninfo(ndo, u2.u16, u.u32);
break;
case IEEE80211_RADIOTAP_MCS: {
static const char *bandwidth[4] = {
@@ -2132,7 +2752,7 @@ print_radiotap_field(struct cpack_state *s, u_int32_t bit, u_int8_t *flags,
* the guard interval, so we can look
* up the rate.
*/
- htrate =
+ htrate =
ieee80211_float_htrates \
[u3.u8] \
[((u2.u8 & IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK) == IEEE80211_RADIOTAP_MCS_BANDWIDTH_40 ? 1 : 0)] \
@@ -2156,34 +2776,39 @@ print_radiotap_field(struct cpack_state *s, u_int32_t bit, u_int8_t *flags,
* We have the rate.
* Print it.
*/
- printf("%.1f Mb/s MCS %u ", htrate, u3.u8);
+ ND_PRINT((ndo, "%.1f Mb/s MCS %u ", htrate, u3.u8));
} else {
/*
* We at least have the MCS index.
* Print it.
*/
- printf("MCS %u ", u3.u8);
+ ND_PRINT((ndo, "MCS %u ", u3.u8));
}
}
if (u.u8 & IEEE80211_RADIOTAP_MCS_BANDWIDTH_KNOWN) {
- printf("%s ",
- bandwidth[u2.u8 & IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK]);
+ ND_PRINT((ndo, "%s ",
+ bandwidth[u2.u8 & IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK]));
}
if (u.u8 & IEEE80211_RADIOTAP_MCS_GUARD_INTERVAL_KNOWN) {
- printf("%s GI ",
+ ND_PRINT((ndo, "%s GI ",
(u2.u8 & IEEE80211_RADIOTAP_MCS_SHORT_GI) ?
- "short" : "lon");
+ "short" : "lon"));
}
if (u.u8 & IEEE80211_RADIOTAP_MCS_HT_FORMAT_KNOWN) {
- printf("%s ",
+ ND_PRINT((ndo, "%s ",
(u2.u8 & IEEE80211_RADIOTAP_MCS_HT_GREENFIELD) ?
- "greenfield" : "mixed");
+ "greenfield" : "mixed"));
}
if (u.u8 & IEEE80211_RADIOTAP_MCS_FEC_TYPE_KNOWN) {
- printf("%s FEC ",
+ ND_PRINT((ndo, "%s FEC ",
(u2.u8 & IEEE80211_RADIOTAP_MCS_FEC_LDPC) ?
- "LDPC" : "BCC");
+ "LDPC" : "BCC"));
+ }
+ if (u.u8 & IEEE80211_RADIOTAP_MCS_STBC_KNOWN) {
+ ND_PRINT((ndo, "RX-STBC%u ",
+ (u2.u8 & IEEE80211_RADIOTAP_MCS_STBC_MASK) >> IEEE80211_RADIOTAP_MCS_STBC_SHIFT));
}
+
break;
}
}
@@ -2191,7 +2816,8 @@ print_radiotap_field(struct cpack_state *s, u_int32_t bit, u_int8_t *flags,
}
static u_int
-ieee802_11_radio_print(const u_char *p, u_int length, u_int caplen)
+ieee802_11_radio_print(netdissect_options *ndo,
+ const u_char *p, u_int length, u_int caplen)
{
#define BITNO_32(x) (((x) >> 16) ? 16 + BITNO_16((x) >> 16) : BITNO_16((x)))
#define BITNO_16(x) (((x) >> 8) ? 8 + BITNO_8((x) >> 8) : BITNO_8((x)))
@@ -2204,20 +2830,19 @@ ieee802_11_radio_print(const u_char *p, u_int length, u_int caplen)
struct cpack_state cpacker;
struct ieee80211_radiotap_header *hdr;
- u_int32_t present, next_present;
- u_int32_t presentflags = 0;
- u_int32_t *presentp, *last_presentp;
+ uint32_t present, next_present;
+ uint32_t presentflags = 0;
+ uint32_t *presentp, *last_presentp;
enum ieee80211_radiotap_type bit;
int bit0;
- const u_char *iter;
u_int len;
- u_int8_t flags;
+ uint8_t flags;
int pad;
u_int fcslen;
struct radiotap_state state;
if (caplen < sizeof(*hdr)) {
- printf("[|802.11]");
+ ND_PRINT((ndo, "%s", tstr));
return caplen;
}
@@ -2226,25 +2851,20 @@ ieee802_11_radio_print(const u_char *p, u_int length, u_int caplen)
len = EXTRACT_LE_16BITS(&hdr->it_len);
if (caplen < len) {
- printf("[|802.11]");
+ ND_PRINT((ndo, "%s", tstr));
return caplen;
}
+ cpack_init(&cpacker, (uint8_t *)hdr, len); /* align against header start */
+ cpack_advance(&cpacker, sizeof(*hdr)); /* includes the 1st bitmap */
for (last_presentp = &hdr->it_present;
IS_EXTENDED(last_presentp) &&
(u_char*)(last_presentp + 1) <= p + len;
- last_presentp++);
+ last_presentp++)
+ cpack_advance(&cpacker, sizeof(hdr->it_present)); /* more bitmaps */
/* are there more bitmap extensions than bytes in header? */
if (IS_EXTENDED(last_presentp)) {
- printf("[|802.11]");
- return caplen;
- }
-
- iter = (u_char*)(last_presentp + 1);
-
- if (cpack_init(&cpacker, (u_int8_t*)iter, len - (iter - p)) != 0) {
- /* XXX */
- printf("[|802.11]");
+ ND_PRINT((ndo, "%s", tstr));
return caplen;
}
@@ -2270,7 +2890,7 @@ ieee802_11_radio_print(const u_char *p, u_int length, u_int caplen)
bit = (enum ieee80211_radiotap_type)
(bit0 + BITNO_32(present ^ next_present));
- if (print_radiotap_field(&cpacker, bit, &flags, &state, presentflags) != 0)
+ if (print_radiotap_field(ndo, &cpacker, bit, &flags, &state, presentflags) != 0)
goto out;
}
}
@@ -2280,7 +2900,7 @@ out:
pad = 1; /* Atheros padding */
if (flags & IEEE80211_RADIOTAP_F_FCS)
fcslen = 4; /* FCS at end of packet */
- return len + ieee802_11_print(p + len, length - len, caplen - len, pad,
+ return len + ieee802_11_print(ndo, p + len, length - len, caplen - len, pad,
fcslen);
#undef BITNO_32
#undef BITNO_16
@@ -2291,12 +2911,13 @@ out:
}
static u_int
-ieee802_11_avs_radio_print(const u_char *p, u_int length, u_int caplen)
+ieee802_11_avs_radio_print(netdissect_options *ndo,
+ const u_char *p, u_int length, u_int caplen)
{
- u_int32_t caphdr_len;
+ uint32_t caphdr_len;
if (caplen < 8) {
- printf("[|802.11]");
+ ND_PRINT((ndo, "%s", tstr));
return caplen;
}
@@ -2307,16 +2928,16 @@ ieee802_11_avs_radio_print(const u_char *p, u_int length, u_int caplen)
* to be large enough to include even the version
* cookie or capture header length!
*/
- printf("[|802.11]");
+ ND_PRINT((ndo, "%s", tstr));
return caplen;
}
if (caplen < caphdr_len) {
- printf("[|802.11]");
+ ND_PRINT((ndo, "%s", tstr));
return caplen;
}
- return caphdr_len + ieee802_11_print(p + caphdr_len,
+ return caphdr_len + ieee802_11_print(ndo, p + caphdr_len,
length - caphdr_len, caplen - caphdr_len, 0, 0);
}
@@ -2340,28 +2961,29 @@ ieee802_11_avs_radio_print(const u_char *p, u_int length, u_int caplen)
* 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)
+prism_if_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, const u_char *p)
{
u_int caplen = h->caplen;
u_int length = h->len;
- u_int32_t msgcode;
+ uint32_t msgcode;
if (caplen < 4) {
- printf("[|802.11]");
+ ND_PRINT((ndo, "%s", tstr));
return caplen;
}
msgcode = EXTRACT_32BITS(p);
if (msgcode == WLANCAP_MAGIC_COOKIE_V1 ||
msgcode == WLANCAP_MAGIC_COOKIE_V2)
- return ieee802_11_avs_radio_print(p, length, caplen);
+ return ieee802_11_avs_radio_print(ndo, p, length, caplen);
if (caplen < PRISM_HDR_LEN) {
- printf("[|802.11]");
+ ND_PRINT((ndo, "%s", tstr));
return caplen;
}
- return PRISM_HDR_LEN + ieee802_11_print(p + PRISM_HDR_LEN,
+ return PRISM_HDR_LEN + ieee802_11_print(ndo, p + PRISM_HDR_LEN,
length - PRISM_HDR_LEN, caplen - PRISM_HDR_LEN, 0, 0);
}
@@ -2370,9 +2992,10 @@ prism_if_print(const struct pcap_pkthdr *h, const u_char *p)
* header, containing information such as radio information.
*/
u_int
-ieee802_11_radio_if_print(const struct pcap_pkthdr *h, const u_char *p)
+ieee802_11_radio_if_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, const u_char *p)
{
- return ieee802_11_radio_print(p, h->len, h->caplen);
+ return ieee802_11_radio_print(ndo, p, h->len, h->caplen);
}
/*
@@ -2381,7 +3004,8 @@ ieee802_11_radio_if_print(const struct pcap_pkthdr *h, const u_char *p)
* which we currently ignore.
*/
u_int
-ieee802_11_radio_avs_if_print(const struct pcap_pkthdr *h, const u_char *p)
+ieee802_11_radio_avs_if_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, const u_char *p)
{
- return ieee802_11_avs_radio_print(p, h->len, h->caplen);
+ return ieee802_11_avs_radio_print(ndo, p, h->len, h->caplen);
}
diff --git a/contrib/tcpdump/print-802_15_4.c b/contrib/tcpdump/print-802_15_4.c
index 2016552cea2c..26c28ee652aa 100644
--- a/contrib/tcpdump/print-802_15_4.c
+++ b/contrib/tcpdump/print-802_15_4.c
@@ -20,16 +20,13 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <pcap.h>
-#include <string.h>
-
#include "interface.h"
#include "addrtoname.h"
@@ -47,7 +44,7 @@ static const char *ftypes[] = {
};
static int
-extract_header_length(u_int16_t fc)
+extract_header_length(uint16_t fc)
{
int len = 0;
@@ -90,13 +87,13 @@ extract_header_length(u_int16_t fc)
u_int
-ieee802_15_4_if_print(struct netdissect_options *ndo,
+ieee802_15_4_if_print(netdissect_options *ndo,
const struct pcap_pkthdr *h, const u_char *p)
{
u_int caplen = h->caplen;
int hdrlen;
- u_int16_t fc;
- u_int8_t seq;
+ uint16_t fc;
+ uint8_t seq;
if (caplen < 3) {
ND_PRINT((ndo, "[|802.15.4] %x", caplen));
@@ -112,7 +109,7 @@ ieee802_15_4_if_print(struct netdissect_options *ndo,
caplen -= 3;
ND_PRINT((ndo,"IEEE 802.15.4 %s packet ", ftypes[fc & 0x7]));
- if (vflag)
+ if (ndo->ndo_vflag)
ND_PRINT((ndo,"seq %02x ", seq));
if (hdrlen == -1) {
ND_PRINT((ndo,"malformed! "));
@@ -120,11 +117,11 @@ ieee802_15_4_if_print(struct netdissect_options *ndo,
}
- if (!vflag) {
+ if (!ndo->ndo_vflag) {
p+= hdrlen;
caplen -= hdrlen;
} else {
- u_int16_t panid = 0;
+ uint16_t panid = 0;
switch ((fc >> 10) & 0x3) {
case 0x00:
@@ -146,7 +143,7 @@ ieee802_15_4_if_print(struct netdissect_options *ndo,
p += 8;
break;
}
- ND_PRINT((ndo,"< ");
+ ND_PRINT((ndo,"< "));
switch ((fc >> 14) & 0x3) {
case 0x00:
@@ -168,7 +165,7 @@ ieee802_15_4_if_print(struct netdissect_options *ndo,
panid = EXTRACT_LE_16BITS(p);
p += 2;
}
- ND_PRINT((ndo,"%04x:%s ", panid, le64addr_string(p))));
+ ND_PRINT((ndo,"%04x:%s ", panid, le64addr_string(p)));
p += 8;
break;
}
@@ -176,8 +173,8 @@ ieee802_15_4_if_print(struct netdissect_options *ndo,
caplen -= hdrlen;
}
- if (!suppress_default_print)
- (ndo->ndo_default_print)(ndo, p, caplen);
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
return 0;
}
diff --git a/contrib/tcpdump/print-ah.c b/contrib/tcpdump/print-ah.c
index ecd106b73806..0badf48233bf 100644
--- a/contrib/tcpdump/print-ah.c
+++ b/contrib/tcpdump/print-ah.c
@@ -21,51 +21,44 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ah.c,v 1.22 2003-11-19 00:36:06 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-
#include "ah.h"
#include "interface.h"
-#include "addrtoname.h"
#include "extract.h"
int
-ah_print(register const u_char *bp)
+ah_print(netdissect_options *ndo, register const u_char *bp)
{
register const struct ah *ah;
register const u_char *ep;
int sumlen;
- u_int32_t spi;
+ uint32_t spi;
ah = (const struct ah *)bp;
- ep = snapend; /* 'ep' points to the end of available data. */
+ ep = ndo->ndo_snapend; /* 'ep' points to the end of available data. */
- TCHECK(*ah);
+ ND_TCHECK(*ah);
sumlen = ah->ah_len << 2;
spi = EXTRACT_32BITS(&ah->ah_spi);
- printf("AH(spi=0x%08x", spi);
- if (vflag)
- printf(",sumlen=%d", sumlen);
- printf(",seq=0x%x", EXTRACT_32BITS(ah + 1));
+ ND_PRINT((ndo, "AH(spi=0x%08x", spi));
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, ",sumlen=%d", sumlen));
+ ND_PRINT((ndo, ",seq=0x%x", EXTRACT_32BITS(ah + 1)));
if (bp + sizeof(struct ah) + sumlen > ep)
- fputs("[truncated]", stdout);
- fputs("): ", stdout);
+ ND_PRINT((ndo, "[truncated]"));
+ ND_PRINT((ndo, "): "));
return sizeof(struct ah) + sumlen;
trunc:
- fputs("[|AH]", stdout);
+ ND_PRINT((ndo, "[|AH]"));
return -1;
}
diff --git a/contrib/tcpdump/print-ahcp.c b/contrib/tcpdump/print-ahcp.c
new file mode 100644
index 000000000000..280372dadbfb
--- /dev/null
+++ b/contrib/tcpdump/print-ahcp.c
@@ -0,0 +1,413 @@
+/*
+ * This module implements decoding of AHCP (Ad Hoc Configuration Protocol) based
+ * on draft-chroboczek-ahcp-00 and source code of ahcpd-0.53.
+ *
+ *
+ * Copyright (c) 2013 The TCPDUMP project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 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 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#define NETDISSECT_REWORKED
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tcpdump-stdinc.h>
+
+#include "interface.h"
+#include "extract.h"
+#include "addrtoname.h"
+
+static const char tstr[] = " [|ahcp]";
+static const char cstr[] = "(corrupt)";
+
+#define AHCP_MAGIC_NUMBER 43
+#define AHCP_VERSION_1 1
+#define AHCP1_HEADER_FIX_LEN 24
+#define AHCP1_BODY_MIN_LEN 4
+
+#define AHCP1_MSG_DISCOVER 0
+#define AHCP1_MSG_OFFER 1
+#define AHCP1_MSG_REQUEST 2
+#define AHCP1_MSG_ACK 3
+#define AHCP1_MSG_NACK 4
+#define AHCP1_MSG_RELEASE 5
+
+static const struct tok ahcp1_msg_str[] = {
+ { AHCP1_MSG_DISCOVER, "Discover" },
+ { AHCP1_MSG_OFFER, "Offer" },
+ { AHCP1_MSG_REQUEST, "Request" },
+ { AHCP1_MSG_ACK, "Ack" },
+ { AHCP1_MSG_NACK, "Nack" },
+ { AHCP1_MSG_RELEASE, "Release" },
+ { 0, NULL }
+};
+
+#define AHCP1_OPT_PAD 0
+#define AHCP1_OPT_MANDATORY 1
+#define AHCP1_OPT_ORIGIN_TIME 2
+#define AHCP1_OPT_EXPIRES 3
+#define AHCP1_OPT_MY_IPV6_ADDRESS 4
+#define AHCP1_OPT_MY_IPV4_ADDRESS 5
+#define AHCP1_OPT_IPV6_PREFIX 6
+#define AHCP1_OPT_IPV4_PREFIX 7
+#define AHCP1_OPT_IPV6_ADDRESS 8
+#define AHCP1_OPT_IPV4_ADDRESS 9
+#define AHCP1_OPT_IPV6_PREFIX_DELEGATION 10
+#define AHCP1_OPT_IPV4_PREFIX_DELEGATION 11
+#define AHCP1_OPT_NAME_SERVER 12
+#define AHCP1_OPT_NTP_SERVER 13
+#define AHCP1_OPT_MAX 13
+
+static const struct tok ahcp1_opt_str[] = {
+ { AHCP1_OPT_PAD, "Pad" },
+ { AHCP1_OPT_MANDATORY, "Mandatory" },
+ { AHCP1_OPT_ORIGIN_TIME, "Origin Time" },
+ { AHCP1_OPT_EXPIRES, "Expires" },
+ { AHCP1_OPT_MY_IPV6_ADDRESS, "My-IPv6-Address" },
+ { AHCP1_OPT_MY_IPV4_ADDRESS, "My-IPv4-Address" },
+ { AHCP1_OPT_IPV6_PREFIX, "IPv6 Prefix" },
+ { AHCP1_OPT_IPV4_PREFIX, "IPv4 Prefix" },
+ { AHCP1_OPT_IPV6_ADDRESS, "IPv6 Address" },
+ { AHCP1_OPT_IPV4_ADDRESS, "IPv4 Address" },
+ { AHCP1_OPT_IPV6_PREFIX_DELEGATION, "IPv6 Prefix Delegation" },
+ { AHCP1_OPT_IPV4_PREFIX_DELEGATION, "IPv4 Prefix Delegation" },
+ { AHCP1_OPT_NAME_SERVER, "Name Server" },
+ { AHCP1_OPT_NTP_SERVER, "NTP Server" },
+ { 0, NULL }
+};
+
+static int
+ahcp_time_print(netdissect_options *ndo, const u_char *cp, const u_char *ep) {
+ time_t t;
+ struct tm *tm;
+ char buf[BUFSIZE];
+
+ if (cp + 4 != ep)
+ goto corrupt;
+ ND_TCHECK2(*cp, 4);
+ t = EXTRACT_32BITS(cp);
+ if (NULL == (tm = gmtime(&t)))
+ ND_PRINT((ndo, ": gmtime() error"));
+ else if (0 == strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", tm))
+ ND_PRINT((ndo, ": strftime() error"));
+ else
+ ND_PRINT((ndo, ": %s UTC", buf));
+ return 0;
+
+corrupt:
+ ND_PRINT((ndo, ": %s", cstr));
+ ND_TCHECK2(*cp, ep - cp);
+ return 0;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return -1;
+}
+
+static int
+ahcp_seconds_print(netdissect_options *ndo, const u_char *cp, const u_char *ep) {
+ if (cp + 4 != ep)
+ goto corrupt;
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, ": %us", EXTRACT_32BITS(cp)));
+ return 0;
+
+corrupt:
+ ND_PRINT((ndo, ": %s", cstr));
+ ND_TCHECK2(*cp, ep - cp);
+ return 0;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return -1;
+}
+
+static int
+ahcp_ipv6_addresses_print(netdissect_options *ndo, const u_char *cp, const u_char *ep) {
+ const char *sep = ": ";
+
+ while (cp < ep) {
+ if (cp + 16 > ep)
+ goto corrupt;
+ ND_TCHECK2(*cp, 16);
+#ifdef INET6
+ ND_PRINT((ndo, "%s%s", sep, ip6addr_string(ndo, cp)));
+#else
+ ND_PRINT((ndo, "%s(compiled w/o IPv6)", sep));
+#endif /* INET6 */
+ cp += 16;
+ sep = ", ";
+ }
+ return 0;
+
+corrupt:
+ ND_PRINT((ndo, ": %s", cstr));
+ ND_TCHECK2(*cp, ep - cp);
+ return 0;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return -1;
+}
+
+static int
+ahcp_ipv4_addresses_print(netdissect_options *ndo, const u_char *cp, const u_char *ep) {
+ const char *sep = ": ";
+
+ while (cp < ep) {
+ if (cp + 4 > ep)
+ goto corrupt;
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, "%s%s", sep, ipaddr_string(ndo, cp)));
+ cp += 4;
+ sep = ", ";
+ }
+ return 0;
+
+corrupt:
+ ND_PRINT((ndo, ": %s", cstr));
+ ND_TCHECK2(*cp, ep - cp);
+ return 0;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return -1;
+}
+
+static int
+ahcp_ipv6_prefixes_print(netdissect_options *ndo, const u_char *cp, const u_char *ep) {
+ const char *sep = ": ";
+
+ while (cp < ep) {
+ if (cp + 17 > ep)
+ goto corrupt;
+ ND_TCHECK2(*cp, 17);
+#ifdef INET6
+ ND_PRINT((ndo, "%s%s/%u", sep, ip6addr_string(ndo, cp), *(cp + 16)));
+#else
+ ND_PRINT((ndo, "%s(compiled w/o IPv6)/%u", sep, *(cp + 16)));
+#endif /* INET6 */
+ cp += 17;
+ sep = ", ";
+ }
+ return 0;
+
+corrupt:
+ ND_PRINT((ndo, ": %s", cstr));
+ ND_TCHECK2(*cp, ep - cp);
+ return 0;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return -1;
+}
+
+static int
+ahcp_ipv4_prefixes_print(netdissect_options *ndo, const u_char *cp, const u_char *ep) {
+ const char *sep = ": ";
+
+ while (cp < ep) {
+ if (cp + 5 > ep)
+ goto corrupt;
+ ND_TCHECK2(*cp, 5);
+ ND_PRINT((ndo, "%s%s/%u", sep, ipaddr_string(ndo, cp), *(cp + 4)));
+ cp += 5;
+ sep = ", ";
+ }
+ return 0;
+
+corrupt:
+ ND_PRINT((ndo, ": %s", cstr));
+ ND_TCHECK2(*cp, ep - cp);
+ return 0;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return -1;
+}
+
+/* Data decoders signal truncated data with -1. */
+static int
+(* const data_decoders[AHCP1_OPT_MAX + 1])(netdissect_options *, const u_char *, const u_char *) = {
+ /* [AHCP1_OPT_PAD] = */ NULL,
+ /* [AHCP1_OPT_MANDATORY] = */ NULL,
+ /* [AHCP1_OPT_ORIGIN_TIME] = */ ahcp_time_print,
+ /* [AHCP1_OPT_EXPIRES] = */ ahcp_seconds_print,
+ /* [AHCP1_OPT_MY_IPV6_ADDRESS] = */ ahcp_ipv6_addresses_print,
+ /* [AHCP1_OPT_MY_IPV4_ADDRESS] = */ ahcp_ipv4_addresses_print,
+ /* [AHCP1_OPT_IPV6_PREFIX] = */ ahcp_ipv6_prefixes_print,
+ /* [AHCP1_OPT_IPV4_PREFIX] = */ NULL,
+ /* [AHCP1_OPT_IPV6_ADDRESS] = */ ahcp_ipv6_addresses_print,
+ /* [AHCP1_OPT_IPV4_ADDRESS] = */ ahcp_ipv4_addresses_print,
+ /* [AHCP1_OPT_IPV6_PREFIX_DELEGATION] = */ ahcp_ipv6_prefixes_print,
+ /* [AHCP1_OPT_IPV4_PREFIX_DELEGATION] = */ ahcp_ipv4_prefixes_print,
+ /* [AHCP1_OPT_NAME_SERVER] = */ ahcp_ipv6_addresses_print,
+ /* [AHCP1_OPT_NTP_SERVER] = */ ahcp_ipv6_addresses_print,
+};
+
+static void
+ahcp1_options_print(netdissect_options *ndo, const u_char *cp, const u_char *ep) {
+ uint8_t option_no, option_len;
+
+ while (cp < ep) {
+ /* Option no */
+ ND_TCHECK2(*cp, 1);
+ option_no = *cp;
+ cp += 1;
+ ND_PRINT((ndo, "\n\t %s", tok2str(ahcp1_opt_str, "Unknown-%u", option_no)));
+ if (option_no == AHCP1_OPT_PAD || option_no == AHCP1_OPT_MANDATORY)
+ continue;
+ /* Length */
+ if (cp + 1 > ep)
+ goto corrupt;
+ ND_TCHECK2(*cp, 1);
+ option_len = *cp;
+ cp += 1;
+ if (cp + option_len > ep)
+ goto corrupt;
+ /* Value */
+ if (option_no <= AHCP1_OPT_MAX && data_decoders[option_no] != NULL) {
+ if (data_decoders[option_no](ndo, cp, cp + option_len) < 0)
+ break; /* truncated and already marked up */
+ } else {
+ ND_PRINT((ndo, " (Length %u)", option_len));
+ ND_TCHECK2(*cp, option_len);
+ }
+ cp += option_len;
+ }
+ return;
+
+corrupt:
+ ND_PRINT((ndo, " %s", cstr));
+ ND_TCHECK2(*cp, ep - cp);
+ return;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+}
+
+static void
+ahcp1_body_print(netdissect_options *ndo, const u_char *cp, const u_char *ep) {
+ uint8_t type, mbz;
+ uint16_t body_len;
+
+ if (cp + AHCP1_BODY_MIN_LEN > ep)
+ goto corrupt;
+ /* Type */
+ ND_TCHECK2(*cp, 1);
+ type = *cp;
+ cp += 1;
+ /* MBZ */
+ ND_TCHECK2(*cp, 1);
+ mbz = *cp;
+ cp += 1;
+ /* Length */
+ ND_TCHECK2(*cp, 2);
+ body_len = EXTRACT_16BITS(cp);
+ cp += 2;
+
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "\n\t%s", tok2str(ahcp1_msg_str, "Unknown-%u", type)));
+ if (mbz != 0)
+ ND_PRINT((ndo, ", MBZ %u", mbz));
+ ND_PRINT((ndo, ", Length %u", body_len));
+ }
+ if (cp + body_len > ep)
+ goto corrupt;
+
+ /* Options */
+ if (ndo->ndo_vflag >= 2)
+ ahcp1_options_print(ndo, cp, cp + body_len); /* not ep (ignore extra data) */
+ else
+ ND_TCHECK2(*cp, body_len);
+ return;
+
+corrupt:
+ ND_PRINT((ndo, " %s", cstr));
+ ND_TCHECK2(*cp, ep - cp);
+ return;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+}
+
+void
+ahcp_print(netdissect_options *ndo, const u_char *cp, const u_int len) {
+ const u_char *ep = cp + len;
+ uint8_t version;
+
+ ND_PRINT((ndo, "AHCP"));
+ if (len < 2)
+ goto corrupt;
+ /* Magic */
+ ND_TCHECK2(*cp, 1);
+ if (*cp != AHCP_MAGIC_NUMBER)
+ goto corrupt;
+ cp += 1;
+ /* Version */
+ ND_TCHECK2(*cp, 1);
+ version = *cp;
+ cp += 1;
+ switch (version) {
+ case AHCP_VERSION_1: {
+ ND_PRINT((ndo, " Version 1"));
+ if (len < AHCP1_HEADER_FIX_LEN)
+ goto corrupt;
+ if (!ndo->ndo_vflag) {
+ ND_TCHECK2(*cp, AHCP1_HEADER_FIX_LEN - 2);
+ cp += AHCP1_HEADER_FIX_LEN - 2;
+ } else {
+ /* Hopcount */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, "\n\tHopcount %u", *cp));
+ cp += 1;
+ /* Original Hopcount */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", Original Hopcount %u", *cp));
+ cp += 1;
+ /* Nonce */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, ", Nonce 0x%08x", EXTRACT_32BITS(cp)));
+ cp += 4;
+ /* Source Id */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", Source Id %s", linkaddr_string(ndo, cp, 0, 8)));
+ cp += 8;
+ /* Destination Id */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", Destination Id %s", linkaddr_string(ndo, cp, 0, 8)));
+ cp += 8;
+ }
+ /* Body */
+ ahcp1_body_print(ndo, cp, ep);
+ break;
+ }
+ default:
+ ND_PRINT((ndo, " Version %u (unknown)", version));
+ break;
+ }
+ return;
+
+corrupt:
+ ND_PRINT((ndo, " %s", cstr));
+ ND_TCHECK2(*cp, ep - cp);
+ return;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+}
+
diff --git a/contrib/tcpdump/print-aodv.c b/contrib/tcpdump/print-aodv.c
index c5f662237448..093e17480cfa 100644
--- a/contrib/tcpdump/print-aodv.c
+++ b/contrib/tcpdump/print-aodv.c
@@ -30,73 +30,223 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-aodv.c,v 1.11 2004-03-24 00:30:19 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
+/* for offsetof */
#include <stddef.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
#include "interface.h"
#include "addrtoname.h"
#include "extract.h" /* must come after interface.h */
-#include "aodv.h"
+
+struct aodv_rreq {
+ uint8_t rreq_type; /* AODV message type (1) */
+ uint8_t rreq_flags; /* various flags */
+ uint8_t rreq_zero0; /* reserved, set to zero */
+ uint8_t rreq_hops; /* number of hops from originator */
+ uint32_t rreq_id; /* request ID */
+ uint32_t rreq_da; /* destination IPv4 address */
+ uint32_t rreq_ds; /* destination sequence number */
+ uint32_t rreq_oa; /* originator IPv4 address */
+ uint32_t rreq_os; /* originator sequence number */
+};
+#ifdef INET6
+struct aodv_rreq6 {
+ uint8_t rreq_type; /* AODV message type (1) */
+ uint8_t rreq_flags; /* various flags */
+ uint8_t rreq_zero0; /* reserved, set to zero */
+ uint8_t rreq_hops; /* number of hops from originator */
+ uint32_t rreq_id; /* request ID */
+ struct in6_addr rreq_da; /* destination IPv6 address */
+ uint32_t rreq_ds; /* destination sequence number */
+ struct in6_addr rreq_oa; /* originator IPv6 address */
+ uint32_t rreq_os; /* originator sequence number */
+};
+struct aodv_rreq6_draft_01 {
+ uint8_t rreq_type; /* AODV message type (16) */
+ uint8_t rreq_flags; /* various flags */
+ uint8_t rreq_zero0; /* reserved, set to zero */
+ uint8_t rreq_hops; /* number of hops from originator */
+ uint32_t rreq_id; /* request ID */
+ uint32_t rreq_ds; /* destination sequence number */
+ uint32_t rreq_os; /* originator sequence number */
+ struct in6_addr rreq_da; /* destination IPv6 address */
+ struct in6_addr rreq_oa; /* originator IPv6 address */
+};
+#endif
+
+#define RREQ_JOIN 0x80 /* join (reserved for multicast */
+#define RREQ_REPAIR 0x40 /* repair (reserved for multicast */
+#define RREQ_GRAT 0x20 /* gratuitous RREP */
+#define RREQ_DEST 0x10 /* destination only */
+#define RREQ_UNKNOWN 0x08 /* unknown destination sequence num */
+#define RREQ_FLAGS_MASK 0xF8 /* mask for rreq_flags */
+
+struct aodv_rrep {
+ uint8_t rrep_type; /* AODV message type (2) */
+ uint8_t rrep_flags; /* various flags */
+ uint8_t rrep_ps; /* prefix size */
+ uint8_t rrep_hops; /* number of hops from o to d */
+ uint32_t rrep_da; /* destination IPv4 address */
+ uint32_t rrep_ds; /* destination sequence number */
+ uint32_t rrep_oa; /* originator IPv4 address */
+ uint32_t rrep_life; /* lifetime of this route */
+};
+#ifdef INET6
+struct aodv_rrep6 {
+ uint8_t rrep_type; /* AODV message type (2) */
+ uint8_t rrep_flags; /* various flags */
+ uint8_t rrep_ps; /* prefix size */
+ uint8_t rrep_hops; /* number of hops from o to d */
+ struct in6_addr rrep_da; /* destination IPv6 address */
+ uint32_t rrep_ds; /* destination sequence number */
+ struct in6_addr rrep_oa; /* originator IPv6 address */
+ uint32_t rrep_life; /* lifetime of this route */
+};
+struct aodv_rrep6_draft_01 {
+ uint8_t rrep_type; /* AODV message type (17) */
+ uint8_t rrep_flags; /* various flags */
+ uint8_t rrep_ps; /* prefix size */
+ uint8_t rrep_hops; /* number of hops from o to d */
+ uint32_t rrep_ds; /* destination sequence number */
+ struct in6_addr rrep_da; /* destination IPv6 address */
+ struct in6_addr rrep_oa; /* originator IPv6 address */
+ uint32_t rrep_life; /* lifetime of this route */
+};
+#endif
+
+#define RREP_REPAIR 0x80 /* repair (reserved for multicast */
+#define RREP_ACK 0x40 /* acknowledgement required */
+#define RREP_FLAGS_MASK 0xC0 /* mask for rrep_flags */
+#define RREP_PREFIX_MASK 0x1F /* mask for prefix size */
+
+struct rerr_unreach {
+ uint32_t u_da; /* IPv4 address */
+ uint32_t u_ds; /* sequence number */
+};
+#ifdef INET6
+struct rerr_unreach6 {
+ struct in6_addr u_da; /* IPv6 address */
+ uint32_t u_ds; /* sequence number */
+};
+struct rerr_unreach6_draft_01 {
+ struct in6_addr u_da; /* IPv6 address */
+ uint32_t u_ds; /* sequence number */
+};
+#endif
+
+struct aodv_rerr {
+ uint8_t rerr_type; /* AODV message type (3 or 18) */
+ uint8_t rerr_flags; /* various flags */
+ uint8_t rerr_zero0; /* reserved, set to zero */
+ uint8_t rerr_dc; /* destination count */
+ union {
+ struct rerr_unreach dest[1];
+#ifdef INET6
+ struct rerr_unreach6 dest6[1];
+ struct rerr_unreach6_draft_01 dest6_draft_01[1];
+#endif
+ } r;
+};
+
+#define RERR_NODELETE 0x80 /* don't delete the link */
+#define RERR_FLAGS_MASK 0x80 /* mask for rerr_flags */
+
+struct aodv_rrep_ack {
+ uint8_t ra_type;
+ uint8_t ra_zero0;
+};
+
+union aodv {
+ struct aodv_rreq rreq;
+ struct aodv_rrep rrep;
+ struct aodv_rerr rerr;
+ struct aodv_rrep_ack rrep_ack;
+#ifdef INET6
+ struct aodv_rreq6 rreq6;
+ struct aodv_rreq6_draft_01 rreq6_draft_01;
+ struct aodv_rrep6 rrep6;
+ struct aodv_rrep6_draft_01 rrep6_draft_01;
+#endif
+};
+
+#define AODV_RREQ 1 /* route request */
+#define AODV_RREP 2 /* route response */
+#define AODV_RERR 3 /* error report */
+#define AODV_RREP_ACK 4 /* route response acknowledgement */
+
+#define AODV_V6_DRAFT_01_RREQ 16 /* IPv6 route request */
+#define AODV_V6_DRAFT_01_RREP 17 /* IPv6 route response */
+#define AODV_V6_DRAFT_01_RERR 18 /* IPv6 error report */
+#define AODV_V6_DRAFT_01_RREP_ACK 19 /* IPV6 route response acknowledgment */
+
+struct aodv_ext {
+ uint8_t type; /* extension type */
+ uint8_t length; /* extension length */
+};
+
+struct aodv_hello {
+ struct aodv_ext eh; /* extension header */
+ uint8_t interval[4]; /* expect my next hello in
+ * (n) ms
+ * NOTE: this is not aligned */
+};
+
+#define AODV_EXT_HELLO 1
static void
-aodv_extension(const struct aodv_ext *ep, u_int length)
+aodv_extension(netdissect_options *ndo,
+ const struct aodv_ext *ep, u_int length)
{
u_int i;
const struct aodv_hello *ah;
switch (ep->type) {
case AODV_EXT_HELLO:
- if (snapend < (u_char *) ep) {
- printf(" [|hello]");
+ if (ndo->ndo_snapend < (u_char *) ep) {
+ ND_PRINT((ndo, " [|hello]"));
return;
}
- i = min(length, (u_int)(snapend - (u_char *)ep));
+ i = min(length, (u_int)(ndo->ndo_snapend - (u_char *)ep));
if (i < sizeof(struct aodv_hello)) {
- printf(" [|hello]");
+ ND_PRINT((ndo, " [|hello]"));
return;
}
i -= sizeof(struct aodv_hello);
ah = (void *)ep;
- printf("\n\text HELLO %ld ms",
- (unsigned long)EXTRACT_32BITS(&ah->interval));
+ ND_PRINT((ndo, "\n\text HELLO %ld ms",
+ (unsigned long)EXTRACT_32BITS(&ah->interval)));
break;
default:
- printf("\n\text %u %u", ep->type, ep->length);
+ ND_PRINT((ndo, "\n\text %u %u", ep->type, ep->length));
break;
}
}
static void
-aodv_rreq(const union aodv *ap, const u_char *dat, u_int length)
+aodv_rreq(netdissect_options *ndo,
+ const union aodv *ap, const u_char *dat, u_int length)
{
u_int i;
- if (snapend < dat) {
- printf(" [|aodv]");
+ if (ndo->ndo_snapend < dat) {
+ ND_PRINT((ndo, " [|aodv]"));
return;
}
- i = min(length, (u_int)(snapend - dat));
+ i = min(length, (u_int)(ndo->ndo_snapend - dat));
if (i < sizeof(ap->rreq)) {
- printf(" [|rreq]");
+ ND_PRINT((ndo, " [|rreq]"));
return;
}
i -= sizeof(ap->rreq);
- printf(" rreq %u %s%s%s%s%shops %u id 0x%08lx\n"
+ ND_PRINT((ndo, " rreq %u %s%s%s%s%shops %u id 0x%08lx\n"
"\tdst %s seq %lu src %s seq %lu", length,
ap->rreq.rreq_type & RREQ_JOIN ? "[J]" : "",
ap->rreq.rreq_type & RREQ_REPAIR ? "[R]" : "",
@@ -105,96 +255,100 @@ aodv_rreq(const union aodv *ap, const u_char *dat, u_int length)
ap->rreq.rreq_type & RREQ_UNKNOWN ? "[U] " : " ",
ap->rreq.rreq_hops,
(unsigned long)EXTRACT_32BITS(&ap->rreq.rreq_id),
- ipaddr_string(&ap->rreq.rreq_da),
+ ipaddr_string(ndo, &ap->rreq.rreq_da),
(unsigned long)EXTRACT_32BITS(&ap->rreq.rreq_ds),
- ipaddr_string(&ap->rreq.rreq_oa),
- (unsigned long)EXTRACT_32BITS(&ap->rreq.rreq_os));
+ ipaddr_string(ndo, &ap->rreq.rreq_oa),
+ (unsigned long)EXTRACT_32BITS(&ap->rreq.rreq_os)));
if (i >= sizeof(struct aodv_ext))
- aodv_extension((void *)(&ap->rreq + 1), i);
+ aodv_extension(ndo, (void *)(&ap->rreq + 1), i);
}
static void
-aodv_rrep(const union aodv *ap, const u_char *dat, u_int length)
+aodv_rrep(netdissect_options *ndo,
+ const union aodv *ap, const u_char *dat, u_int length)
{
u_int i;
- if (snapend < dat) {
- printf(" [|aodv]");
+ if (ndo->ndo_snapend < dat) {
+ ND_PRINT((ndo, " [|aodv]"));
return;
}
- i = min(length, (u_int)(snapend - dat));
+ i = min(length, (u_int)(ndo->ndo_snapend - dat));
if (i < sizeof(ap->rrep)) {
- printf(" [|rrep]");
+ ND_PRINT((ndo, " [|rrep]"));
return;
}
i -= sizeof(ap->rrep);
- printf(" rrep %u %s%sprefix %u hops %u\n"
+ ND_PRINT((ndo, " rrep %u %s%sprefix %u hops %u\n"
"\tdst %s dseq %lu src %s %lu ms", length,
ap->rrep.rrep_type & RREP_REPAIR ? "[R]" : "",
ap->rrep.rrep_type & RREP_ACK ? "[A] " : " ",
ap->rrep.rrep_ps & RREP_PREFIX_MASK,
ap->rrep.rrep_hops,
- ipaddr_string(&ap->rrep.rrep_da),
+ ipaddr_string(ndo, &ap->rrep.rrep_da),
(unsigned long)EXTRACT_32BITS(&ap->rrep.rrep_ds),
- ipaddr_string(&ap->rrep.rrep_oa),
- (unsigned long)EXTRACT_32BITS(&ap->rrep.rrep_life));
+ ipaddr_string(ndo, &ap->rrep.rrep_oa),
+ (unsigned long)EXTRACT_32BITS(&ap->rrep.rrep_life)));
if (i >= sizeof(struct aodv_ext))
- aodv_extension((void *)(&ap->rrep + 1), i);
+ aodv_extension(ndo, (void *)(&ap->rrep + 1), i);
}
static void
-aodv_rerr(const union aodv *ap, const u_char *dat, u_int length)
+aodv_rerr(netdissect_options *ndo,
+ const union aodv *ap, const u_char *dat, u_int length)
{
u_int i;
const struct rerr_unreach *dp = NULL;
int n, trunc;
- if (snapend < dat) {
- printf(" [|aodv]");
+ if (ndo->ndo_snapend < dat) {
+ ND_PRINT((ndo, " [|aodv]"));
return;
}
- i = min(length, (u_int)(snapend - dat));
+ i = min(length, (u_int)(ndo->ndo_snapend - dat));
if (i < offsetof(struct aodv_rerr, r)) {
- printf(" [|rerr]");
+ ND_PRINT((ndo, " [|rerr]"));
return;
}
i -= offsetof(struct aodv_rerr, r);
dp = &ap->rerr.r.dest[0];
n = ap->rerr.rerr_dc * sizeof(ap->rerr.r.dest[0]);
- printf(" rerr %s [items %u] [%u]:",
+ ND_PRINT((ndo, " rerr %s [items %u] [%u]:",
ap->rerr.rerr_flags & RERR_NODELETE ? "[D]" : "",
- ap->rerr.rerr_dc, length);
+ ap->rerr.rerr_dc, length));
trunc = n - (i/sizeof(ap->rerr.r.dest[0]));
for (; i >= sizeof(ap->rerr.r.dest[0]);
++dp, i -= sizeof(ap->rerr.r.dest[0])) {
- printf(" {%s}(%ld)", ipaddr_string(&dp->u_da),
- (unsigned long)EXTRACT_32BITS(&dp->u_ds));
+ ND_PRINT((ndo, " {%s}(%ld)", ipaddr_string(ndo, &dp->u_da),
+ (unsigned long)EXTRACT_32BITS(&dp->u_ds)));
}
if (trunc)
- printf("[|rerr]");
+ ND_PRINT((ndo, "[|rerr]"));
}
static void
#ifdef INET6
-aodv_v6_rreq(const union aodv *ap, const u_char *dat, u_int length)
+aodv_v6_rreq(netdissect_options *ndo,
+ const union aodv *ap, const u_char *dat, u_int length)
#else
-aodv_v6_rreq(const union aodv *ap _U_, const u_char *dat _U_, u_int length)
+aodv_v6_rreq(netdissect_options *ndo,
+ const union aodv *ap _U_, const u_char *dat _U_, u_int length)
#endif
{
#ifdef INET6
u_int i;
- if (snapend < dat) {
- printf(" [|aodv]");
+ if (ndo->ndo_snapend < dat) {
+ ND_PRINT((ndo, " [|aodv]"));
return;
}
- i = min(length, (u_int)(snapend - dat));
+ i = min(length, (u_int)(ndo->ndo_snapend - dat));
if (i < sizeof(ap->rreq6)) {
- printf(" [|rreq6]");
+ ND_PRINT((ndo, " [|rreq6]"));
return;
}
i -= sizeof(ap->rreq6);
- printf(" v6 rreq %u %s%s%s%s%shops %u id 0x%08lx\n"
+ ND_PRINT((ndo, " v6 rreq %u %s%s%s%s%shops %u id 0x%08lx\n"
"\tdst %s seq %lu src %s seq %lu", length,
ap->rreq6.rreq_type & RREQ_JOIN ? "[J]" : "",
ap->rreq6.rreq_type & RREQ_REPAIR ? "[R]" : "",
@@ -203,59 +357,63 @@ aodv_v6_rreq(const union aodv *ap _U_, const u_char *dat _U_, u_int length)
ap->rreq6.rreq_type & RREQ_UNKNOWN ? "[U] " : " ",
ap->rreq6.rreq_hops,
(unsigned long)EXTRACT_32BITS(&ap->rreq6.rreq_id),
- ip6addr_string(&ap->rreq6.rreq_da),
+ ip6addr_string(ndo, &ap->rreq6.rreq_da),
(unsigned long)EXTRACT_32BITS(&ap->rreq6.rreq_ds),
- ip6addr_string(&ap->rreq6.rreq_oa),
- (unsigned long)EXTRACT_32BITS(&ap->rreq6.rreq_os));
+ ip6addr_string(ndo, &ap->rreq6.rreq_oa),
+ (unsigned long)EXTRACT_32BITS(&ap->rreq6.rreq_os)));
if (i >= sizeof(struct aodv_ext))
- aodv_extension((void *)(&ap->rreq6 + 1), i);
+ aodv_extension(ndo, (void *)(&ap->rreq6 + 1), i);
#else
- printf(" v6 rreq %u", length);
+ ND_PRINT((ndo, " v6 rreq %u", length));
#endif
}
static void
#ifdef INET6
-aodv_v6_rrep(const union aodv *ap, const u_char *dat, u_int length)
+aodv_v6_rrep(netdissect_options *ndo,
+ const union aodv *ap, const u_char *dat, u_int length)
#else
-aodv_v6_rrep(const union aodv *ap _U_, const u_char *dat _U_, u_int length)
+aodv_v6_rrep(netdissect_options *ndo,
+ const union aodv *ap _U_, const u_char *dat _U_, u_int length)
#endif
{
#ifdef INET6
u_int i;
- if (snapend < dat) {
- printf(" [|aodv]");
+ if (ndo->ndo_snapend < dat) {
+ ND_PRINT((ndo, " [|aodv]"));
return;
}
- i = min(length, (u_int)(snapend - dat));
+ i = min(length, (u_int)(ndo->ndo_snapend - dat));
if (i < sizeof(ap->rrep6)) {
- printf(" [|rrep6]");
+ ND_PRINT((ndo, " [|rrep6]"));
return;
}
i -= sizeof(ap->rrep6);
- printf(" rrep %u %s%sprefix %u hops %u\n"
+ ND_PRINT((ndo, " rrep %u %s%sprefix %u hops %u\n"
"\tdst %s dseq %lu src %s %lu ms", length,
ap->rrep6.rrep_type & RREP_REPAIR ? "[R]" : "",
ap->rrep6.rrep_type & RREP_ACK ? "[A] " : " ",
ap->rrep6.rrep_ps & RREP_PREFIX_MASK,
ap->rrep6.rrep_hops,
- ip6addr_string(&ap->rrep6.rrep_da),
+ ip6addr_string(ndo, &ap->rrep6.rrep_da),
(unsigned long)EXTRACT_32BITS(&ap->rrep6.rrep_ds),
- ip6addr_string(&ap->rrep6.rrep_oa),
- (unsigned long)EXTRACT_32BITS(&ap->rrep6.rrep_life));
+ ip6addr_string(ndo, &ap->rrep6.rrep_oa),
+ (unsigned long)EXTRACT_32BITS(&ap->rrep6.rrep_life)));
if (i >= sizeof(struct aodv_ext))
- aodv_extension((void *)(&ap->rrep6 + 1), i);
+ aodv_extension(ndo, (void *)(&ap->rrep6 + 1), i);
#else
- printf(" rrep %u", length);
+ ND_PRINT((ndo, " rrep %u", length));
#endif
}
static void
#ifdef INET6
-aodv_v6_rerr(const union aodv *ap, u_int length)
+aodv_v6_rerr(netdissect_options *ndo,
+ const union aodv *ap, u_int length)
#else
-aodv_v6_rerr(const union aodv *ap _U_, u_int length)
+aodv_v6_rerr(netdissect_options *ndo,
+ const union aodv *ap _U_, u_int length)
#endif
{
#ifdef INET6
@@ -266,43 +424,45 @@ aodv_v6_rerr(const union aodv *ap _U_, u_int length)
j = sizeof(ap->rerr.r.dest6[0]);
dp6 = &ap->rerr.r.dest6[0];
n = ap->rerr.rerr_dc * j;
- printf(" rerr %s [items %u] [%u]:",
+ ND_PRINT((ndo, " rerr %s [items %u] [%u]:",
ap->rerr.rerr_flags & RERR_NODELETE ? "[D]" : "",
- ap->rerr.rerr_dc, length);
+ ap->rerr.rerr_dc, length));
trunc = n - (i/j);
for (; i -= j >= 0; ++dp6) {
- printf(" {%s}(%ld)", ip6addr_string(&dp6->u_da),
- (unsigned long)EXTRACT_32BITS(&dp6->u_ds));
+ ND_PRINT((ndo, " {%s}(%ld)", ip6addr_string(ndo, &dp6->u_da),
+ (unsigned long)EXTRACT_32BITS(&dp6->u_ds)));
}
if (trunc)
- printf("[|rerr]");
+ ND_PRINT((ndo, "[|rerr]"));
#else
- printf(" rerr %u", length);
+ ND_PRINT((ndo, " rerr %u", length));
#endif
}
static void
#ifdef INET6
-aodv_v6_draft_01_rreq(const union aodv *ap, const u_char *dat, u_int length)
+aodv_v6_draft_01_rreq(netdissect_options *ndo,
+ const union aodv *ap, const u_char *dat, u_int length)
#else
-aodv_v6_draft_01_rreq(const union aodv *ap _U_, const u_char *dat _U_,
+aodv_v6_draft_01_rreq(netdissect_options *ndo,
+ const union aodv *ap _U_, const u_char *dat _U_,
u_int length)
#endif
{
#ifdef INET6
u_int i;
- if (snapend < dat) {
- printf(" [|aodv]");
+ if (ndo->ndo_snapend < dat) {
+ ND_PRINT((ndo, " [|aodv]"));
return;
}
- i = min(length, (u_int)(snapend - dat));
+ i = min(length, (u_int)(ndo->ndo_snapend - dat));
if (i < sizeof(ap->rreq6_draft_01)) {
- printf(" [|rreq6]");
+ ND_PRINT((ndo, " [|rreq6]"));
return;
}
i -= sizeof(ap->rreq6_draft_01);
- printf(" rreq %u %s%s%s%s%shops %u id 0x%08lx\n"
+ ND_PRINT((ndo, " rreq %u %s%s%s%s%shops %u id 0x%08lx\n"
"\tdst %s seq %lu src %s seq %lu", length,
ap->rreq6_draft_01.rreq_type & RREQ_JOIN ? "[J]" : "",
ap->rreq6_draft_01.rreq_type & RREQ_REPAIR ? "[R]" : "",
@@ -311,60 +471,64 @@ aodv_v6_draft_01_rreq(const union aodv *ap _U_, const u_char *dat _U_,
ap->rreq6_draft_01.rreq_type & RREQ_UNKNOWN ? "[U] " : " ",
ap->rreq6_draft_01.rreq_hops,
(unsigned long)EXTRACT_32BITS(&ap->rreq6_draft_01.rreq_id),
- ip6addr_string(&ap->rreq6_draft_01.rreq_da),
+ ip6addr_string(ndo, &ap->rreq6_draft_01.rreq_da),
(unsigned long)EXTRACT_32BITS(&ap->rreq6_draft_01.rreq_ds),
- ip6addr_string(&ap->rreq6_draft_01.rreq_oa),
- (unsigned long)EXTRACT_32BITS(&ap->rreq6_draft_01.rreq_os));
+ ip6addr_string(ndo, &ap->rreq6_draft_01.rreq_oa),
+ (unsigned long)EXTRACT_32BITS(&ap->rreq6_draft_01.rreq_os)));
if (i >= sizeof(struct aodv_ext))
- aodv_extension((void *)(&ap->rreq6_draft_01 + 1), i);
+ aodv_extension(ndo, (void *)(&ap->rreq6_draft_01 + 1), i);
#else
- printf(" rreq %u", length);
+ ND_PRINT((ndo, " rreq %u", length));
#endif
}
static void
#ifdef INET6
-aodv_v6_draft_01_rrep(const union aodv *ap, const u_char *dat, u_int length)
+aodv_v6_draft_01_rrep(netdissect_options *ndo,
+ const union aodv *ap, const u_char *dat, u_int length)
#else
-aodv_v6_draft_01_rrep(const union aodv *ap _U_, const u_char *dat _U_,
+aodv_v6_draft_01_rrep(netdissect_options *ndo,
+ const union aodv *ap _U_, const u_char *dat _U_,
u_int length)
#endif
{
#ifdef INET6
u_int i;
- if (snapend < dat) {
- printf(" [|aodv]");
+ if (ndo->ndo_snapend < dat) {
+ ND_PRINT((ndo, " [|aodv]"));
return;
}
- i = min(length, (u_int)(snapend - dat));
+ i = min(length, (u_int)(ndo->ndo_snapend - dat));
if (i < sizeof(ap->rrep6_draft_01)) {
- printf(" [|rrep6]");
+ ND_PRINT((ndo, " [|rrep6]"));
return;
}
i -= sizeof(ap->rrep6_draft_01);
- printf(" rrep %u %s%sprefix %u hops %u\n"
+ ND_PRINT((ndo, " rrep %u %s%sprefix %u hops %u\n"
"\tdst %s dseq %lu src %s %lu ms", length,
ap->rrep6_draft_01.rrep_type & RREP_REPAIR ? "[R]" : "",
ap->rrep6_draft_01.rrep_type & RREP_ACK ? "[A] " : " ",
ap->rrep6_draft_01.rrep_ps & RREP_PREFIX_MASK,
ap->rrep6_draft_01.rrep_hops,
- ip6addr_string(&ap->rrep6_draft_01.rrep_da),
+ ip6addr_string(ndo, &ap->rrep6_draft_01.rrep_da),
(unsigned long)EXTRACT_32BITS(&ap->rrep6_draft_01.rrep_ds),
- ip6addr_string(&ap->rrep6_draft_01.rrep_oa),
- (unsigned long)EXTRACT_32BITS(&ap->rrep6_draft_01.rrep_life));
+ ip6addr_string(ndo, &ap->rrep6_draft_01.rrep_oa),
+ (unsigned long)EXTRACT_32BITS(&ap->rrep6_draft_01.rrep_life)));
if (i >= sizeof(struct aodv_ext))
- aodv_extension((void *)(&ap->rrep6_draft_01 + 1), i);
+ aodv_extension(ndo, (void *)(&ap->rrep6_draft_01 + 1), i);
#else
- printf(" rrep %u", length);
+ ND_PRINT((ndo, " rrep %u", length));
#endif
}
static void
#ifdef INET6
-aodv_v6_draft_01_rerr(const union aodv *ap, u_int length)
+aodv_v6_draft_01_rerr(netdissect_options *ndo,
+ const union aodv *ap, u_int length)
#else
-aodv_v6_draft_01_rerr(const union aodv *ap _U_, u_int length)
+aodv_v6_draft_01_rerr(netdissect_options *ndo,
+ const union aodv *ap _U_, u_int length)
#endif
{
#ifdef INET6
@@ -375,81 +539,82 @@ aodv_v6_draft_01_rerr(const union aodv *ap _U_, u_int length)
j = sizeof(ap->rerr.r.dest6_draft_01[0]);
dp6 = &ap->rerr.r.dest6_draft_01[0];
n = ap->rerr.rerr_dc * j;
- printf(" rerr %s [items %u] [%u]:",
+ ND_PRINT((ndo, " rerr %s [items %u] [%u]:",
ap->rerr.rerr_flags & RERR_NODELETE ? "[D]" : "",
- ap->rerr.rerr_dc, length);
+ ap->rerr.rerr_dc, length));
trunc = n - (i/j);
for (; i -= j >= 0; ++dp6) {
- printf(" {%s}(%ld)", ip6addr_string(&dp6->u_da),
- (unsigned long)EXTRACT_32BITS(&dp6->u_ds));
+ ND_PRINT((ndo, " {%s}(%ld)", ip6addr_string(ndo, &dp6->u_da),
+ (unsigned long)EXTRACT_32BITS(&dp6->u_ds)));
}
if (trunc)
- printf("[|rerr]");
+ ND_PRINT((ndo, "[|rerr]"));
#else
- printf(" rerr %u", length);
+ ND_PRINT((ndo, " rerr %u", length));
#endif
}
void
-aodv_print(const u_char *dat, u_int length, int is_ip6)
+aodv_print(netdissect_options *ndo,
+ const u_char *dat, u_int length, int is_ip6)
{
const union aodv *ap;
ap = (union aodv *)dat;
- if (snapend < dat) {
- printf(" [|aodv]");
+ if (ndo->ndo_snapend < dat) {
+ ND_PRINT((ndo, " [|aodv]"));
return;
}
- if (min(length, (u_int)(snapend - dat)) < sizeof(ap->rrep_ack)) {
- printf(" [|aodv]");
+ if (min(length, (u_int)(ndo->ndo_snapend - dat)) < sizeof(ap->rrep_ack)) {
+ ND_PRINT((ndo, " [|aodv]"));
return;
}
- printf(" aodv");
+ ND_PRINT((ndo, " aodv"));
switch (ap->rerr.rerr_type) {
case AODV_RREQ:
if (is_ip6)
- aodv_v6_rreq(ap, dat, length);
+ aodv_v6_rreq(ndo, ap, dat, length);
else
- aodv_rreq(ap, dat, length);
+ aodv_rreq(ndo, ap, dat, length);
break;
case AODV_RREP:
if (is_ip6)
- aodv_v6_rrep(ap, dat, length);
+ aodv_v6_rrep(ndo, ap, dat, length);
else
- aodv_rrep(ap, dat, length);
+ aodv_rrep(ndo, ap, dat, length);
break;
case AODV_RERR:
if (is_ip6)
- aodv_v6_rerr(ap, length);
+ aodv_v6_rerr(ndo, ap, length);
else
- aodv_rerr(ap, dat, length);
+ aodv_rerr(ndo, ap, dat, length);
break;
case AODV_RREP_ACK:
- printf(" rrep-ack %u", length);
+ ND_PRINT((ndo, " rrep-ack %u", length));
break;
case AODV_V6_DRAFT_01_RREQ:
- aodv_v6_draft_01_rreq(ap, dat, length);
+ aodv_v6_draft_01_rreq(ndo, ap, dat, length);
break;
case AODV_V6_DRAFT_01_RREP:
- aodv_v6_draft_01_rrep(ap, dat, length);
+ aodv_v6_draft_01_rrep(ndo, ap, dat, length);
break;
case AODV_V6_DRAFT_01_RERR:
- aodv_v6_draft_01_rerr(ap, length);
+ aodv_v6_draft_01_rerr(ndo, ap, length);
break;
case AODV_V6_DRAFT_01_RREP_ACK:
- printf(" rrep-ack %u", length);
+ ND_PRINT((ndo, " rrep-ack %u", length));
break;
default:
- printf(" %u %u", ap->rreq.rreq_type, length);
+ ND_PRINT((ndo, " %u %u", ap->rreq.rreq_type, length));
}
}
diff --git a/contrib/tcpdump/print-aoe.c b/contrib/tcpdump/print-aoe.c
new file mode 100644
index 000000000000..f8bc1fc9b990
--- /dev/null
+++ b/contrib/tcpdump/print-aoe.c
@@ -0,0 +1,432 @@
+/*
+ * This module implements decoding of the ATA over Ethernet (AoE) protocol
+ * according to the following specification:
+ * http://support.coraid.com/documents/AoEr11.txt
+ *
+ * Copyright (c) 2014 The TCPDUMP project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 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 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#define NETDISSECT_REWORKED
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tcpdump-stdinc.h>
+
+#include "interface.h"
+#include "extract.h"
+#include "addrtoname.h"
+#include "ether.h"
+
+static const char tstr[] = " [|aoe]";
+static const char cstr[] = " (corrupt)";
+
+#define AOE_V1 1
+#define ATA_SECTOR_SIZE 512
+
+#define AOEV1_CMD_ISSUE_ATA_COMMAND 0
+#define AOEV1_CMD_QUERY_CONFIG_INFORMATION 1
+#define AOEV1_CMD_MAC_MASK_LIST 2
+#define AOEV1_CMD_RESERVE_RELEASE 3
+
+static const struct tok cmdcode_str[] = {
+ { AOEV1_CMD_ISSUE_ATA_COMMAND, "Issue ATA Command" },
+ { AOEV1_CMD_QUERY_CONFIG_INFORMATION, "Query Config Information" },
+ { AOEV1_CMD_MAC_MASK_LIST, "MAC Mask List" },
+ { AOEV1_CMD_RESERVE_RELEASE, "Reserve/Release" },
+ { 0, NULL }
+};
+
+#define AOEV1_COMMON_HDR_LEN 10U /* up to but w/o Arg */
+#define AOEV1_ISSUE_ARG_LEN 12U /* up to but w/o Data */
+#define AOEV1_QUERY_ARG_LEN 8U /* up to but w/o Config String */
+#define AOEV1_MAC_ARG_LEN 4U /* up to but w/o Directive 0 */
+#define AOEV1_RESERVE_ARG_LEN 2U /* up to but w/o Ethernet address 0 */
+#define AOEV1_MAX_CONFSTR_LEN 1024U
+
+#define AOEV1_FLAG_R 0x08
+#define AOEV1_FLAG_E 0x04
+
+static const struct tok aoev1_flag_str[] = {
+ { AOEV1_FLAG_R, "Response" },
+ { AOEV1_FLAG_E, "Error" },
+ { 0x02, "MBZ-0x02" },
+ { 0x01, "MBZ-0x01" },
+ { 0, NULL }
+};
+
+static const struct tok aoev1_errcode_str[] = {
+ { 1, "Unrecognized command code" },
+ { 2, "Bad argument parameter" },
+ { 3, "Device unavailable" },
+ { 4, "Config string present" },
+ { 5, "Unsupported version" },
+ { 6, "Target is reserved" },
+ { 0, NULL }
+};
+
+#define AOEV1_AFLAG_E 0x40
+#define AOEV1_AFLAG_D 0x10
+#define AOEV1_AFLAG_A 0x02
+#define AOEV1_AFLAG_W 0x01
+
+static const struct tok aoev1_aflag_str[] = {
+ { 0x08, "MBZ-0x08" },
+ { AOEV1_AFLAG_E, "Ext48" },
+ { 0x06, "MBZ-0x06" },
+ { AOEV1_AFLAG_D, "Device" },
+ { 0x04, "MBZ-0x04" },
+ { 0x03, "MBZ-0x03" },
+ { AOEV1_AFLAG_A, "Async" },
+ { AOEV1_AFLAG_W, "Write" },
+ { 0, NULL }
+};
+
+static const struct tok aoev1_ccmd_str[] = {
+ { 0, "read config string" },
+ { 1, "test config string" },
+ { 2, "test config string prefix" },
+ { 3, "set config string" },
+ { 4, "force set config string" },
+ { 0, NULL }
+};
+
+static const struct tok aoev1_mcmd_str[] = {
+ { 0, "Read Mac Mask List" },
+ { 1, "Edit Mac Mask List" },
+ { 0, NULL }
+};
+
+static const struct tok aoev1_merror_str[] = {
+ { 1, "Unspecified Error" },
+ { 2, "Bad DCmd directive" },
+ { 3, "Mask list full" },
+ { 0, NULL }
+};
+
+static const struct tok aoev1_dcmd_str[] = {
+ { 0, "No Directive" },
+ { 1, "Add mac address to mask list" },
+ { 2, "Delete mac address from mask list" },
+ { 0, NULL }
+};
+
+static const struct tok aoev1_rcmd_str[] = {
+ { 0, "Read reserve list" },
+ { 1, "Set reserve list" },
+ { 2, "Force set reserve list" },
+ { 0, NULL }
+};
+
+static void
+aoev1_issue_print(netdissect_options *ndo,
+ const u_char *cp, const u_int len)
+{
+ const u_char *ep = cp + len;
+
+ if (len < AOEV1_ISSUE_ARG_LEN)
+ goto corrupt;
+ /* AFlags */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, "\n\tAFlags: [%s]", bittok2str(aoev1_aflag_str, "none", *cp)));
+ cp += 1;
+ /* Err/Feature */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", Err/Feature: %u", *cp));
+ cp += 1;
+ /* Sector Count (not correlated with the length) */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", Sector Count: %u", *cp));
+ cp += 1;
+ /* Cmd/Status */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", Cmd/Status: %u", *cp));
+ cp += 1;
+ /* lba0 */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, "\n\tlba0: %u", *cp));
+ cp += 1;
+ /* lba1 */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", lba1: %u", *cp));
+ cp += 1;
+ /* lba2 */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", lba2: %u", *cp));
+ cp += 1;
+ /* lba3 */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", lba3: %u", *cp));
+ cp += 1;
+ /* lba4 */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", lba4: %u", *cp));
+ cp += 1;
+ /* lba5 */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", lba5: %u", *cp));
+ cp += 1;
+ /* Reserved */
+ ND_TCHECK2(*cp, 2);
+ cp += 2;
+ /* Data */
+ if (len > AOEV1_ISSUE_ARG_LEN)
+ ND_PRINT((ndo, "\n\tData: %u bytes", len - AOEV1_ISSUE_ARG_LEN));
+ return;
+
+corrupt:
+ ND_PRINT((ndo, "%s", cstr));
+ ND_TCHECK2(*cp, ep - cp);
+ return;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+}
+
+static void
+aoev1_query_print(netdissect_options *ndo,
+ const u_char *cp, const u_int len)
+{
+ const u_char *ep = cp + len;
+ uint16_t cslen;
+
+ if (len < AOEV1_QUERY_ARG_LEN)
+ goto corrupt;
+ /* Buffer Count */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, "\n\tBuffer Count: %u", EXTRACT_16BITS(cp)));
+ cp += 2;
+ /* Firmware Version */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, ", Firmware Version: %u", EXTRACT_16BITS(cp)));
+ cp += 2;
+ /* Sector Count */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", Sector Count: %u", *cp));
+ cp += 1;
+ /* AoE/CCmd */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", AoE: %u, CCmd: %s", (*cp & 0xF0) >> 4,
+ tok2str(aoev1_ccmd_str, "Unknown (0x02x)", *cp & 0x0F)));
+ cp += 1;
+ /* Config String Length */
+ ND_TCHECK2(*cp, 2);
+ cslen = EXTRACT_16BITS(cp);
+ cp += 2;
+ if (cslen > AOEV1_MAX_CONFSTR_LEN || AOEV1_QUERY_ARG_LEN + cslen > len)
+ goto corrupt;
+ /* Config String */
+ ND_TCHECK2(*cp, cslen);
+ if (cslen) {
+ ND_PRINT((ndo, "\n\tConfig String (length %u): ", cslen));
+ if (fn_printn(ndo, cp, cslen, ndo->ndo_snapend))
+ goto trunc;
+ }
+ return;
+
+corrupt:
+ ND_PRINT((ndo, "%s", cstr));
+ ND_TCHECK2(*cp, ep - cp);
+ return;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+}
+
+static void
+aoev1_mac_print(netdissect_options *ndo,
+ const u_char *cp, const u_int len)
+{
+ const u_char *ep = cp + len;
+ uint8_t dircount, i;
+
+ if (len < AOEV1_MAC_ARG_LEN)
+ goto corrupt;
+ /* Reserved */
+ ND_TCHECK2(*cp, 1);
+ cp += 1;
+ /* MCmd */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, "\n\tMCmd: %s", tok2str(aoev1_mcmd_str, "Unknown (0x%02x)", *cp)));
+ cp += 1;
+ /* MError */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", MError: %s", tok2str(aoev1_merror_str, "Unknown (0x%02x)", *cp)));
+ cp += 1;
+ /* Dir Count */
+ ND_TCHECK2(*cp, 1);
+ dircount = *cp;
+ cp += 1;
+ ND_PRINT((ndo, ", Dir Count: %u", dircount));
+ if (AOEV1_MAC_ARG_LEN + dircount * 8 > len)
+ goto corrupt;
+ /* directives */
+ for (i = 0; i < dircount; i++) {
+ /* Reserved */
+ ND_TCHECK2(*cp, 1);
+ cp += 1;
+ /* DCmd */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, "\n\t DCmd: %s", tok2str(aoev1_dcmd_str, "Unknown (0x%02x)", *cp)));
+ cp += 1;
+ /* Ethernet Address */
+ ND_TCHECK2(*cp, ETHER_ADDR_LEN);
+ ND_PRINT((ndo, ", Ethernet Address: %s", etheraddr_string(ndo, cp)));
+ cp += ETHER_ADDR_LEN;
+ }
+ return;
+
+corrupt:
+ ND_PRINT((ndo, "%s", cstr));
+ ND_TCHECK2(*cp, ep - cp);
+ return;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+}
+
+static void
+aoev1_reserve_print(netdissect_options *ndo,
+ const u_char *cp, const u_int len)
+{
+ const u_char *ep = cp + len;
+ uint8_t nmacs, i;
+
+ if (len < AOEV1_RESERVE_ARG_LEN || (len - AOEV1_RESERVE_ARG_LEN) % ETHER_ADDR_LEN)
+ goto corrupt;
+ /* RCmd */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, "\n\tRCmd: %s", tok2str(aoev1_rcmd_str, "Unknown (0x%02x)", *cp)));
+ cp += 1;
+ /* NMacs (correlated with the length) */
+ ND_TCHECK2(*cp, 1);
+ nmacs = *cp;
+ cp += 1;
+ ND_PRINT((ndo, ", NMacs: %u", nmacs));
+ if (AOEV1_RESERVE_ARG_LEN + nmacs * ETHER_ADDR_LEN != len)
+ goto corrupt;
+ /* addresses */
+ for (i = 0; i < nmacs; i++) {
+ ND_PRINT((ndo, "\n\tEthernet Address %u: %s", i, etheraddr_string(ndo, cp)));
+ cp += ETHER_ADDR_LEN;
+ }
+ return;
+
+corrupt:
+ ND_PRINT((ndo, "%s", cstr));
+ ND_TCHECK2(*cp, ep - cp);
+ return;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+}
+
+/* cp points to the Ver/Flags octet */
+static void
+aoev1_print(netdissect_options *ndo,
+ const u_char *cp, const u_int len)
+{
+ const u_char *ep = cp + len;
+ uint8_t flags, command;
+ void (*cmd_decoder)(netdissect_options *, const u_char *, const u_int);
+
+ if (len < AOEV1_COMMON_HDR_LEN)
+ goto corrupt;
+ /* Flags */
+ flags = *cp & 0x0F;
+ ND_PRINT((ndo, ", Flags: [%s]", bittok2str(aoev1_flag_str, "none", flags)));
+ cp += 1;
+ if (! ndo->ndo_vflag)
+ return;
+ /* Error */
+ ND_TCHECK2(*cp, 1);
+ if (flags & AOEV1_FLAG_E)
+ ND_PRINT((ndo, "\n\tError: %s", tok2str(aoev1_errcode_str, "Invalid (%u)", *cp)));
+ cp += 1;
+ /* Major */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, "\n\tMajor: 0x%04x", EXTRACT_16BITS(cp)));
+ cp += 2;
+ /* Minor */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", Minor: 0x%02x", *cp));
+ cp += 1;
+ /* Command */
+ ND_TCHECK2(*cp, 1);
+ command = *cp;
+ cp += 1;
+ ND_PRINT((ndo, ", Command: %s", tok2str(cmdcode_str, "Unknown (0x%02x)", command)));
+ /* Tag */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, ", Tag: 0x%08x", EXTRACT_32BITS(cp)));
+ cp += 4;
+ /* Arg */
+ cmd_decoder =
+ command == AOEV1_CMD_ISSUE_ATA_COMMAND ? aoev1_issue_print :
+ command == AOEV1_CMD_QUERY_CONFIG_INFORMATION ? aoev1_query_print :
+ command == AOEV1_CMD_MAC_MASK_LIST ? aoev1_mac_print :
+ command == AOEV1_CMD_RESERVE_RELEASE ? aoev1_reserve_print :
+ NULL;
+ if (cmd_decoder != NULL)
+ cmd_decoder(ndo, cp, len - AOEV1_COMMON_HDR_LEN);
+ return;
+
+corrupt:
+ ND_PRINT((ndo, "%s", cstr));
+ ND_TCHECK2(*cp, ep - cp);
+ return;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+}
+
+void
+aoe_print(netdissect_options *ndo,
+ const u_char *cp, const u_int len)
+{
+ const u_char *ep = cp + len;
+ uint8_t ver;
+
+ ND_PRINT((ndo, "AoE length %u", len));
+
+ if (len < 1)
+ goto corrupt;
+ /* Ver/Flags */
+ ND_TCHECK2(*cp, 1);
+ ver = (*cp & 0xF0) >> 4;
+ /* Don't advance cp yet: low order 4 bits are version-specific. */
+ ND_PRINT((ndo, ", Ver %u", ver));
+
+ switch (ver) {
+ case AOE_V1:
+ aoev1_print(ndo, cp, len);
+ break;
+ }
+ return;
+
+corrupt:
+ ND_PRINT((ndo, "%s", cstr));
+ ND_TCHECK2(*cp, ep - cp);
+ return;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+}
+
diff --git a/contrib/tcpdump/print-ap1394.c b/contrib/tcpdump/print-ap1394.c
index ab0713b5a7a2..3befe2335bd0 100644
--- a/contrib/tcpdump/print-ap1394.c
+++ b/contrib/tcpdump/print-ap1394.c
@@ -18,20 +18,14 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ap1394.c,v 1.5 2006-02-11 22:12:06 hannes Exp $ (LBL)";
-#endif
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <pcap.h>
-
#include "interface.h"
#include "extract.h"
#include "addrtoname.h"
@@ -55,27 +49,27 @@ struct firewire_header {
#define FIREWIRE_HDRLEN 18
static inline void
-ap1394_hdr_print(register const u_char *bp, u_int length)
+ap1394_hdr_print(netdissect_options *ndo, register const u_char *bp, u_int length)
{
register const struct firewire_header *fp;
- u_int16_t firewire_type;
+ uint16_t firewire_type;
fp = (const struct firewire_header *)bp;
- (void)printf("%s > %s",
- linkaddr_string(fp->firewire_dhost, LINKADDR_IEEE1394, FIREWIRE_EUI64_LEN),
- linkaddr_string(fp->firewire_shost, LINKADDR_IEEE1394, FIREWIRE_EUI64_LEN));
+ ND_PRINT((ndo, "%s > %s",
+ linkaddr_string(ndo, fp->firewire_dhost, LINKADDR_IEEE1394, FIREWIRE_EUI64_LEN),
+ linkaddr_string(ndo, fp->firewire_shost, LINKADDR_IEEE1394, FIREWIRE_EUI64_LEN)));
firewire_type = EXTRACT_16BITS(&fp->firewire_type);
- if (!qflag) {
- (void)printf(", ethertype %s (0x%04x)",
+ if (!ndo->ndo_qflag) {
+ ND_PRINT((ndo, ", ethertype %s (0x%04x)",
tok2str(ethertype_values,"Unknown", firewire_type),
- firewire_type);
+ firewire_type));
} else {
- (void)printf(", %s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", firewire_type));
+ ND_PRINT((ndo, ", %s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", firewire_type)));
}
- (void)printf(", length %u: ", length);
+ ND_PRINT((ndo, ", length %u: ", length));
}
/*
@@ -85,7 +79,7 @@ ap1394_hdr_print(register const u_char *bp, u_int length)
* is the number of bytes actually captured.
*/
u_int
-ap1394_if_print(const struct pcap_pkthdr *h, const u_char *p)
+ap1394_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
{
u_int length = h->len;
u_int caplen = h->caplen;
@@ -93,12 +87,12 @@ ap1394_if_print(const struct pcap_pkthdr *h, const u_char *p)
u_short ether_type;
if (caplen < FIREWIRE_HDRLEN) {
- printf("[|ap1394]");
+ ND_PRINT((ndo, "[|ap1394]"));
return FIREWIRE_HDRLEN;
}
- if (eflag)
- ap1394_hdr_print(p, length);
+ if (ndo->ndo_eflag)
+ ap1394_hdr_print(ndo, p, length);
length -= FIREWIRE_HDRLEN;
caplen -= FIREWIRE_HDRLEN;
@@ -106,14 +100,14 @@ ap1394_if_print(const struct pcap_pkthdr *h, const u_char *p)
p += FIREWIRE_HDRLEN;
ether_type = EXTRACT_16BITS(&fp->firewire_type);
- if (ethertype_print(gndo, ether_type, p, length, caplen) == 0) {
+ if (ethertype_print(ndo, ether_type, p, length, caplen) == 0) {
/* ether_type not known, print raw packet */
- if (!eflag)
- ap1394_hdr_print((u_char *)fp, length + FIREWIRE_HDRLEN);
+ if (!ndo->ndo_eflag)
+ ap1394_hdr_print(ndo, (u_char *)fp, length + FIREWIRE_HDRLEN);
- if (!suppress_default_print)
- default_print(p, caplen);
- }
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
+ }
return FIREWIRE_HDRLEN;
}
diff --git a/contrib/tcpdump/print-arcnet.c b/contrib/tcpdump/print-arcnet.c
index 9531f346bff7..cdd4a650513a 100644
--- a/contrib/tcpdump/print-arcnet.c
+++ b/contrib/tcpdump/print-arcnet.c
@@ -20,28 +20,90 @@
*
* From: NetBSD: print-arcnet.c,v 1.2 2000/04/24 13:02:28 itojun Exp
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-arcnet.c,v 1.20 2005-04-06 21:32:38 mcr Exp $ (LBL)";
-#endif
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <pcap.h>
-
#include "interface.h"
#include "extract.h"
-#include "arcnet.h"
-static int arcnet_encap_print(u_char arctype, const u_char *p,
+/*
+ * from: NetBSD: if_arc.h,v 1.13 1999/11/19 20:41:19 thorpej Exp
+ */
+
+/*
+ * Structure of a 2.5MB/s Arcnet header on the BSDs,
+ * as given to interface code.
+ */
+struct arc_header {
+ uint8_t arc_shost;
+ uint8_t arc_dhost;
+ uint8_t arc_type;
+ /*
+ * only present for newstyle encoding with LL fragmentation.
+ * Don't use sizeof(anything), use ARC_HDR{,NEW}LEN instead.
+ */
+ uint8_t arc_flag;
+ uint16_t arc_seqid;
+
+ /*
+ * only present in exception packets (arc_flag == 0xff)
+ */
+ uint8_t arc_type2; /* same as arc_type */
+ uint8_t arc_flag2; /* real flag value */
+ uint16_t arc_seqid2; /* real seqid value */
+};
+
+#define ARC_HDRLEN 3
+#define ARC_HDRNEWLEN 6
+#define ARC_HDRNEWLEN_EXC 10
+
+/* RFC 1051 */
+#define ARCTYPE_IP_OLD 240 /* IP protocol */
+#define ARCTYPE_ARP_OLD 241 /* address resolution protocol */
+
+/* RFC 1201 */
+#define ARCTYPE_IP 212 /* IP protocol */
+#define ARCTYPE_ARP 213 /* address resolution protocol */
+#define ARCTYPE_REVARP 214 /* reverse addr resolution protocol */
+
+#define ARCTYPE_ATALK 221 /* Appletalk */
+#define ARCTYPE_BANIAN 247 /* Banyan Vines */
+#define ARCTYPE_IPX 250 /* Novell IPX */
+
+#define ARCTYPE_INET6 0xc4 /* IPng */
+#define ARCTYPE_DIAGNOSE 0x80 /* as per ANSI/ATA 878.1 */
+
+/*
+ * Structure of a 2.5MB/s Arcnet header on Linux. Linux has
+ * an extra "offset" field when given to interface code, and
+ * never presents packets that look like exception frames.
+ */
+struct arc_linux_header {
+ uint8_t arc_shost;
+ uint8_t arc_dhost;
+ uint16_t arc_offset;
+ uint8_t arc_type;
+ /*
+ * only present for newstyle encoding with LL fragmentation.
+ * Don't use sizeof(anything), use ARC_LINUX_HDR{,NEW}LEN
+ * instead.
+ */
+ uint8_t arc_flag;
+ uint16_t arc_seqid;
+};
+
+#define ARC_LINUX_HDRLEN 5
+#define ARC_LINUX_HDRNEWLEN 8
+
+static int arcnet_encap_print(netdissect_options *, u_char arctype, const u_char *p,
u_int length, u_int caplen);
-struct tok arctypemap[] = {
+static const struct tok arctypemap[] = {
{ ARCTYPE_IP_OLD, "oldip" },
{ ARCTYPE_ARP_OLD, "oldarp" },
{ ARCTYPE_IP, "ip" },
@@ -56,7 +118,8 @@ struct tok arctypemap[] = {
};
static inline void
-arcnet_print(const u_char *bp, u_int length, int phds, int flag, u_int seqid)
+arcnet_print(netdissect_options *ndo, const u_char *bp, u_int length, int phds,
+ int flag, u_int seqid)
{
const struct arc_header *ap;
const char *arctypename;
@@ -65,40 +128,40 @@ arcnet_print(const u_char *bp, u_int length, int phds, int flag, u_int seqid)
ap = (const struct arc_header *)bp;
- if (qflag) {
- (void)printf("%02x %02x %d: ",
+ if (ndo->ndo_qflag) {
+ ND_PRINT((ndo, "%02x %02x %d: ",
ap->arc_shost,
ap->arc_dhost,
- length);
+ length));
return;
}
arctypename = tok2str(arctypemap, "%02x", ap->arc_type);
if (!phds) {
- (void)printf("%02x %02x %s %d: ",
+ ND_PRINT((ndo, "%02x %02x %s %d: ",
ap->arc_shost, ap->arc_dhost, arctypename,
- length);
+ length));
return;
}
if (flag == 0) {
- (void)printf("%02x %02x %s seqid %04x %d: ",
+ ND_PRINT((ndo, "%02x %02x %s seqid %04x %d: ",
ap->arc_shost, ap->arc_dhost, arctypename, seqid,
- length);
+ length));
return;
}
if (flag & 1)
- (void)printf("%02x %02x %s seqid %04x "
+ ND_PRINT((ndo, "%02x %02x %s seqid %04x "
"(first of %d fragments) %d: ",
ap->arc_shost, ap->arc_dhost, arctypename, seqid,
- (flag + 3) / 2, length);
+ (flag + 3) / 2, length));
else
- (void)printf("%02x %02x %s seqid %04x "
+ ND_PRINT((ndo, "%02x %02x %s seqid %04x "
"(fragment %d) %d: ",
ap->arc_shost, ap->arc_dhost, arctypename, seqid,
- flag/2 + 1, length);
+ flag/2 + 1, length));
}
/*
@@ -108,7 +171,7 @@ arcnet_print(const u_char *bp, u_int length, int phds, int flag, u_int seqid)
* is the number of bytes actually captured.
*/
u_int
-arcnet_if_print(const struct pcap_pkthdr *h, const u_char *p)
+arcnet_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
{
u_int caplen = h->caplen;
u_int length = h->len;
@@ -119,7 +182,7 @@ arcnet_if_print(const struct pcap_pkthdr *h, const u_char *p)
u_char arc_type;
if (caplen < ARC_HDRLEN) {
- printf("[|arcnet]");
+ ND_PRINT((ndo, "[|arcnet]"));
return (caplen);
}
@@ -140,15 +203,15 @@ arcnet_if_print(const struct pcap_pkthdr *h, const u_char *p)
if (phds) {
if (caplen < ARC_HDRNEWLEN) {
- arcnet_print(p, length, 0, 0, 0);
- printf("[|phds]");
+ arcnet_print(ndo, p, length, 0, 0, 0);
+ ND_PRINT((ndo, "[|phds]"));
return (caplen);
}
if (ap->arc_flag == 0xff) {
if (caplen < ARC_HDRNEWLEN_EXC) {
- arcnet_print(p, length, 0, 0, 0);
- printf("[|phds extended]");
+ arcnet_print(ndo, p, length, 0, 0, 0);
+ ND_PRINT((ndo, "[|phds extended]"));
return (caplen);
}
flag = ap->arc_flag2;
@@ -162,8 +225,8 @@ arcnet_if_print(const struct pcap_pkthdr *h, const u_char *p)
}
- if (eflag)
- arcnet_print(p, length, phds, flag, seqid);
+ if (ndo->ndo_eflag)
+ arcnet_print(ndo, p, length, phds, flag, seqid);
/*
* Go past the ARCNET header.
@@ -179,8 +242,8 @@ arcnet_if_print(const struct pcap_pkthdr *h, const u_char *p)
return (archdrlen);
}
- if (!arcnet_encap_print(arc_type, p, length, caplen))
- default_print(p, caplen);
+ if (!arcnet_encap_print(ndo, arc_type, p, length, caplen))
+ ND_DEFAULTPRINT(p, caplen);
return (archdrlen);
}
@@ -196,7 +259,7 @@ arcnet_if_print(const struct pcap_pkthdr *h, const u_char *p)
* extra "offset" field between the src/dest and packet type.
*/
u_int
-arcnet_linux_if_print(const struct pcap_pkthdr *h, const u_char *p)
+arcnet_linux_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
{
u_int caplen = h->caplen;
u_int length = h->len;
@@ -206,7 +269,7 @@ arcnet_linux_if_print(const struct pcap_pkthdr *h, const u_char *p)
u_char arc_type;
if (caplen < ARC_LINUX_HDRLEN) {
- printf("[|arcnet]");
+ ND_PRINT((ndo, "[|arcnet]"));
return (caplen);
}
@@ -217,7 +280,7 @@ arcnet_linux_if_print(const struct pcap_pkthdr *h, const u_char *p)
default:
archdrlen = ARC_LINUX_HDRNEWLEN;
if (caplen < ARC_LINUX_HDRNEWLEN) {
- printf("[|arcnet]");
+ ND_PRINT((ndo, "[|arcnet]"));
return (caplen);
}
break;
@@ -228,8 +291,8 @@ arcnet_linux_if_print(const struct pcap_pkthdr *h, const u_char *p)
break;
}
- if (eflag)
- arcnet_print(p, length, 0, 0, 0);
+ if (ndo->ndo_eflag)
+ arcnet_print(ndo, p, length, 0, 0, 0);
/*
* Go past the ARCNET header.
@@ -238,8 +301,8 @@ arcnet_linux_if_print(const struct pcap_pkthdr *h, const u_char *p)
caplen -= archdrlen;
p += archdrlen;
- if (!arcnet_encap_print(arc_type, p, length, caplen))
- default_print(p, caplen);
+ if (!arcnet_encap_print(ndo, arc_type, p, length, caplen))
+ ND_DEFAULTPRINT(p, caplen);
return (archdrlen);
}
@@ -253,36 +316,36 @@ arcnet_linux_if_print(const struct pcap_pkthdr *h, const u_char *p)
static int
-arcnet_encap_print(u_char arctype, const u_char *p,
+arcnet_encap_print(netdissect_options *ndo, u_char arctype, const u_char *p,
u_int length, u_int caplen)
{
switch (arctype) {
case ARCTYPE_IP_OLD:
case ARCTYPE_IP:
- ip_print(gndo, p, length);
+ ip_print(ndo, p, length);
return (1);
#ifdef INET6
case ARCTYPE_INET6:
- ip6_print(gndo, p, length);
+ ip6_print(ndo, p, length);
return (1);
#endif /*INET6*/
case ARCTYPE_ARP_OLD:
case ARCTYPE_ARP:
case ARCTYPE_REVARP:
- arp_print(gndo, p, length, caplen);
+ arp_print(ndo, p, length, caplen);
return (1);
case ARCTYPE_ATALK: /* XXX was this ever used? */
- if (vflag)
- fputs("et1 ", stdout);
- atalk_print(p, length);
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, "et1 "));
+ atalk_print(ndo, p, length);
return (1);
case ARCTYPE_IPX:
- ipx_print(p, length);
+ ipx_print(ndo, p, length);
return (1);
default:
diff --git a/contrib/tcpdump/print-arp.c b/contrib/tcpdump/print-arp.c
index fd985548705d..e2f73ae6946d 100644
--- a/contrib/tcpdump/print-arp.c
+++ b/contrib/tcpdump/print-arp.c
@@ -21,26 +21,23 @@
* $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-arp.c,v 1.66 2006-03-03 22:53:21 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
#include <string.h>
-#include "netdissect.h"
+#include "interface.h"
#include "addrtoname.h"
#include "ether.h"
#include "ethertype.h"
#include "extract.h" /* must come after interface.h */
+static const char tstr[] = "[|ARP]";
+
/*
* Address Resolution Protocol.
*
@@ -101,7 +98,7 @@ struct arp_pkthdr {
#define TPA(ap) (ar_tpa(ap))
-struct tok arpop_values[] = {
+static const struct tok arpop_values[] = {
{ ARPOP_REQUEST, "Request" },
{ ARPOP_REPLY, "Reply" },
{ ARPOP_REVREQUEST, "Reverse Request" },
@@ -112,7 +109,7 @@ struct tok arpop_values[] = {
{ 0, NULL }
};
-struct tok arphrd_values[] = {
+static const struct tok arphrd_values[] = {
{ ARPHRD_ETHER, "Ethernet" },
{ ARPHRD_IEEE802, "TokenRing" },
{ ARPHRD_ARCNET, "ArcNet" },
@@ -191,10 +188,10 @@ atmarp_addr_print(netdissect_options *ndo,
if (ha_len == 0)
ND_PRINT((ndo, "<No address>"));
else {
- ND_PRINT((ndo, "%s", linkaddr_string(ha, LINKADDR_ATM, ha_len)));
- if (srca_len != 0)
+ ND_PRINT((ndo, "%s", linkaddr_string(ndo, ha, LINKADDR_ATM, ha_len)));
+ if (srca_len != 0)
ND_PRINT((ndo, ",%s",
- linkaddr_string(srca, LINKADDR_ATM, srca_len)));
+ linkaddr_string(ndo, srca, LINKADDR_ATM, srca_len)));
}
}
@@ -213,7 +210,7 @@ atmarp_print(netdissect_options *ndo,
op = ATMOP(ap);
if (!ND_TTEST2(*aar_tpa(ap), ATMTPROTO_LEN(ap))) {
- ND_PRINT((ndo, "[|ARP]"));
+ ND_PRINT((ndo, "%s", tstr));
ND_DEFAULTPRINT((const u_char *)ap, length);
return;
}
@@ -239,25 +236,25 @@ atmarp_print(netdissect_options *ndo,
}
/* print operation */
- printf("%s%s ",
- ndo->ndo_vflag ? ", " : "",
- tok2str(arpop_values, "Unknown (%u)", op));
+ ND_PRINT((ndo, "%s%s ",
+ ndo->ndo_vflag ? ", " : "",
+ tok2str(arpop_values, "Unknown (%u)", op)));
switch (op) {
case ARPOP_REQUEST:
- ND_PRINT((ndo, "who-has %s", ipaddr_string(ATMTPA(ap))));
+ ND_PRINT((ndo, "who-has %s", ipaddr_string(ndo, ATMTPA(ap))));
if (ATMTHRD_LEN(ap) != 0) {
ND_PRINT((ndo, " ("));
atmarp_addr_print(ndo, ATMTHA(ap), ATMTHRD_LEN(ap),
ATMTSA(ap), ATMTSLN(ap));
ND_PRINT((ndo, ")"));
}
- ND_PRINT((ndo, "tell %s", ipaddr_string(ATMSPA(ap))));
+ ND_PRINT((ndo, "tell %s", ipaddr_string(ndo, ATMSPA(ap))));
break;
case ARPOP_REPLY:
- ND_PRINT((ndo, "%s is-at ", ipaddr_string(ATMSPA(ap))));
+ ND_PRINT((ndo, "%s is-at ", ipaddr_string(ndo, ATMSPA(ap))));
atmarp_addr_print(ndo, ATMSHA(ap), ATMSHRD_LEN(ap), ATMSSA(ap),
ATMSSLN(ap));
break;
@@ -274,11 +271,11 @@ atmarp_print(netdissect_options *ndo,
case ARPOP_INVREPLY:
atmarp_addr_print(ndo, ATMSHA(ap), ATMSHRD_LEN(ap), ATMSSA(ap),
ATMSSLN(ap));
- ND_PRINT((ndo, "at %s", ipaddr_string(ATMSPA(ap))));
+ ND_PRINT((ndo, "at %s", ipaddr_string(ndo, ATMSPA(ap))));
break;
case ARPOP_NAK:
- ND_PRINT((ndo, "for %s", ipaddr_string(ATMSPA(ap))));
+ ND_PRINT((ndo, "for %s", ipaddr_string(ndo, ATMSPA(ap))));
break;
default:
@@ -291,7 +288,7 @@ atmarp_print(netdissect_options *ndo,
return;
trunc:
- ND_PRINT((ndo, "[|ARP]"));
+ ND_PRINT((ndo, "%s", tstr));
}
void
@@ -308,11 +305,11 @@ arp_print(netdissect_options *ndo,
pro = PRO(ap);
op = OP(ap);
-
+
/* if its ATM then call the ATM ARP printer
for Frame-relay ARP most of the fields
are similar to Ethernet so overload the Ethernet Printer
- and set the linkaddr type for linkaddr_string() accordingly */
+ and set the linkaddr type for linkaddr_string(ndo, ) accordingly */
switch(hrd) {
case ARPHRD_ATM2225:
@@ -327,7 +324,7 @@ arp_print(netdissect_options *ndo,
}
if (!ND_TTEST2(*ar_tpa(ap), PROTO_LEN(ap))) {
- ND_PRINT((ndo, "[|ARP]"));
+ ND_PRINT((ndo, "%s", tstr));
ND_DEFAULTPRINT((const u_char *)ap, length);
return;
}
@@ -354,48 +351,48 @@ arp_print(netdissect_options *ndo,
}
/* print operation */
- printf("%s%s ",
- ndo->ndo_vflag ? ", " : "",
- tok2str(arpop_values, "Unknown (%u)", op));
+ ND_PRINT((ndo, "%s%s ",
+ ndo->ndo_vflag ? ", " : "",
+ tok2str(arpop_values, "Unknown (%u)", op)));
switch (op) {
case ARPOP_REQUEST:
- ND_PRINT((ndo, "who-has %s", ipaddr_string(TPA(ap))));
+ ND_PRINT((ndo, "who-has %s", ipaddr_string(ndo, TPA(ap))));
if (memcmp((const char *)ezero, (const char *)THA(ap), HRD_LEN(ap)) != 0)
ND_PRINT((ndo, " (%s)",
- linkaddr_string(THA(ap), linkaddr, HRD_LEN(ap))));
- ND_PRINT((ndo, " tell %s", ipaddr_string(SPA(ap))));
+ linkaddr_string(ndo, THA(ap), linkaddr, HRD_LEN(ap))));
+ ND_PRINT((ndo, " tell %s", ipaddr_string(ndo, SPA(ap))));
break;
case ARPOP_REPLY:
ND_PRINT((ndo, "%s is-at %s",
- ipaddr_string(SPA(ap)),
- linkaddr_string(SHA(ap), linkaddr, HRD_LEN(ap))));
+ ipaddr_string(ndo, SPA(ap)),
+ linkaddr_string(ndo, SHA(ap), linkaddr, HRD_LEN(ap))));
break;
case ARPOP_REVREQUEST:
ND_PRINT((ndo, "who-is %s tell %s",
- linkaddr_string(THA(ap), linkaddr, HRD_LEN(ap)),
- linkaddr_string(SHA(ap), linkaddr, HRD_LEN(ap))));
+ linkaddr_string(ndo, THA(ap), linkaddr, HRD_LEN(ap)),
+ linkaddr_string(ndo, SHA(ap), linkaddr, HRD_LEN(ap))));
break;
case ARPOP_REVREPLY:
ND_PRINT((ndo, "%s at %s",
- linkaddr_string(THA(ap), linkaddr, HRD_LEN(ap)),
- ipaddr_string(TPA(ap))));
+ linkaddr_string(ndo, THA(ap), linkaddr, HRD_LEN(ap)),
+ ipaddr_string(ndo, TPA(ap))));
break;
case ARPOP_INVREQUEST:
ND_PRINT((ndo, "who-is %s tell %s",
- linkaddr_string(THA(ap), linkaddr, HRD_LEN(ap)),
- linkaddr_string(SHA(ap), linkaddr, HRD_LEN(ap))));
+ linkaddr_string(ndo, THA(ap), linkaddr, HRD_LEN(ap)),
+ linkaddr_string(ndo, SHA(ap), linkaddr, HRD_LEN(ap))));
break;
case ARPOP_INVREPLY:
ND_PRINT((ndo,"%s at %s",
- linkaddr_string(THA(ap), linkaddr, HRD_LEN(ap)),
- ipaddr_string(TPA(ap))));
+ linkaddr_string(ndo, THA(ap), linkaddr, HRD_LEN(ap)),
+ ipaddr_string(ndo, TPA(ap))));
break;
default:
@@ -408,7 +405,7 @@ arp_print(netdissect_options *ndo,
return;
trunc:
- ND_PRINT((ndo, "[|ARP]"));
+ ND_PRINT((ndo, "%s", tstr));
}
/*
diff --git a/contrib/tcpdump/print-ascii.c b/contrib/tcpdump/print-ascii.c
index fa8793cb0641..96410da8faf6 100644
--- a/contrib/tcpdump/print-ascii.c
+++ b/contrib/tcpdump/print-ascii.c
@@ -36,14 +36,11 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ascii.c,v 1.17 2005-07-06 20:53:32 guy Exp $";
-#endif
#include <tcpdump-stdinc.h>
#include <stdio.h>
@@ -57,24 +54,39 @@ static const char rcsid[] _U_ =
(HEXDUMP_HEXSTUFF_PER_SHORT * HEXDUMP_SHORTS_PER_LINE)
void
-ascii_print(register const u_char *cp, register u_int length)
+ascii_print(netdissect_options *ndo,
+ const u_char *cp, u_int length)
{
- register int s;
+ register u_char s;
- putchar('\n');
+ ND_PRINT((ndo, "\n"));
while (length > 0) {
s = *cp++;
length--;
- if (!isgraph(s) &&
- (s != '\t' && s != ' ' && s != '\n' && s != '\r'))
- putchar('.');
- else
- putchar(s);
+ if (s == '\r') {
+ /*
+ * Don't print CRs at the end of the line; they
+ * don't belong at the ends of lines on UN*X,
+ * and the standard I/O library will give us one
+ * on Windows so we don't need to print one
+ * ourselves.
+ *
+ * In the middle of a line, just print a '.'.
+ */
+ if (length > 1 && *cp != '\n')
+ ND_PRINT((ndo, "."));
+ } else {
+ if (!ND_ISGRAPH(s) &&
+ (s != '\t' && s != ' ' && s != '\n'))
+ ND_PRINT((ndo, "."));
+ else
+ ND_PRINT((ndo, "%c", s));
+ }
}
}
void
-hex_and_ascii_print_with_offset(register const char *ident,
+hex_and_ascii_print_with_offset(netdissect_options *ndo, register const char *ident,
register const u_char *cp, register u_int length, register u_int oset)
{
register u_int i;
@@ -92,14 +104,14 @@ hex_and_ascii_print_with_offset(register const char *ident,
(void)snprintf(hsp, sizeof(hexstuff) - (hsp - hexstuff),
" %02x%02x", s1, s2);
hsp += HEXDUMP_HEXSTUFF_PER_SHORT;
- *(asp++) = (isgraph(s1) ? s1 : '.');
- *(asp++) = (isgraph(s2) ? s2 : '.');
+ *(asp++) = (ND_ISGRAPH(s1) ? s1 : '.');
+ *(asp++) = (ND_ISGRAPH(s2) ? s2 : '.');
i++;
if (i >= HEXDUMP_SHORTS_PER_LINE) {
*hsp = *asp = '\0';
- (void)printf("%s0x%04x: %-*s %s",
+ ND_PRINT((ndo, "%s0x%04x: %-*s %s",
ident, oset, HEXDUMP_HEXSTUFF_PER_LINE,
- hexstuff, asciistuff);
+ hexstuff, asciistuff));
i = 0; hsp = hexstuff; asp = asciistuff;
oset += HEXDUMP_BYTES_PER_LINE;
}
@@ -109,30 +121,31 @@ hex_and_ascii_print_with_offset(register const char *ident,
(void)snprintf(hsp, sizeof(hexstuff) - (hsp - hexstuff),
" %02x", s1);
hsp += 3;
- *(asp++) = (isgraph(s1) ? s1 : '.');
+ *(asp++) = (ND_ISGRAPH(s1) ? s1 : '.');
++i;
}
if (i > 0) {
*hsp = *asp = '\0';
- (void)printf("%s0x%04x: %-*s %s",
+ ND_PRINT((ndo, "%s0x%04x: %-*s %s",
ident, oset, HEXDUMP_HEXSTUFF_PER_LINE,
- hexstuff, asciistuff);
+ hexstuff, asciistuff));
}
}
void
-hex_and_ascii_print(register const char *ident, register const u_char *cp,
- register u_int length)
+hex_and_ascii_print(netdissect_options *ndo, register const char *ident,
+ register const u_char *cp, register u_int length)
{
- hex_and_ascii_print_with_offset(ident, cp, length, 0);
+ hex_and_ascii_print_with_offset(ndo, ident, cp, length, 0);
}
/*
* telnet_print() wants this. It is essentially default_print_unaligned()
*/
void
-hex_print_with_offset(register const char *ident, register const u_char *cp, register u_int length,
- register u_int oset)
+hex_print_with_offset(netdissect_options *ndo,
+ const char *ident, const u_char *cp, u_int length,
+ u_int oset)
{
register u_int i, s;
register int nshorts;
@@ -141,16 +154,16 @@ hex_print_with_offset(register const char *ident, register const u_char *cp, reg
i = 0;
while (--nshorts >= 0) {
if ((i++ % 8) == 0) {
- (void)printf("%s0x%04x: ", ident, oset);
+ ND_PRINT((ndo,"%s0x%04x: ", ident, oset));
oset += HEXDUMP_BYTES_PER_LINE;
}
s = *cp++;
- (void)printf(" %02x%02x", s, *cp++);
+ ND_PRINT((ndo," %02x%02x", s, *cp++));
}
if (length & 1) {
if ((i % 8) == 0)
- (void)printf("%s0x%04x: ", ident, oset);
- (void)printf(" %02x", *cp);
+ ND_PRINT((ndo,"%s0x%04x: ", ident, oset));
+ ND_PRINT((ndo," %02x", *cp));
}
}
@@ -158,9 +171,9 @@ hex_print_with_offset(register const char *ident, register const u_char *cp, reg
* just for completeness
*/
void
-hex_print(register const char *ident, register const u_char *cp, register u_int length)
+hex_print(netdissect_options *ndo,const char *ident, const u_char *cp, u_int length)
{
- hex_print_with_offset(ident, cp, length, 0);
+ hex_print_with_offset(ndo, ident, cp, length, 0);
}
#ifdef MAIN
diff --git a/contrib/tcpdump/print-atalk.c b/contrib/tcpdump/print-atalk.c
index d088ffe9fc68..7d210be8a4e0 100644
--- a/contrib/tcpdump/print-atalk.c
+++ b/contrib/tcpdump/print-atalk.c
@@ -23,11 +23,7 @@
* $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-atalk.c,v 1.81 2004-05-01 09:41:50 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -35,9 +31,7 @@ static const char rcsid[] _U_ =
#include <tcpdump-stdinc.h>
#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
-#include <pcap.h>
#include "interface.h"
#include "addrtoname.h"
@@ -45,7 +39,9 @@ static const char rcsid[] _U_ =
#include "extract.h" /* must come after interface.h */
#include "appletalk.h"
-static struct tok type2str[] = {
+static const char tstr[] = "[|atalk]";
+
+static const struct tok type2str[] = {
{ ddpRTMP, "rtmp" },
{ ddpRTMPrequest, "rtmpReq" },
{ ddpECHO, "echo" },
@@ -56,44 +52,43 @@ static struct tok type2str[] = {
};
struct aarp {
- u_int16_t htype, ptype;
- u_int8_t halen, palen;
- u_int16_t op;
- u_int8_t hsaddr[6];
- u_int8_t psaddr[4];
- u_int8_t hdaddr[6];
- u_int8_t pdaddr[4];
+ uint16_t htype, ptype;
+ uint8_t halen, palen;
+ uint16_t op;
+ uint8_t hsaddr[6];
+ uint8_t psaddr[4];
+ uint8_t hdaddr[6];
+ uint8_t pdaddr[4];
};
-static char tstr[] = "[|atalk]";
-
-static void atp_print(const struct atATP *, u_int);
-static void atp_bitmap_print(u_char);
-static void nbp_print(const struct atNBP *, u_int, u_short, u_char, u_char);
-static const char *print_cstring(const char *, const u_char *);
-static const struct atNBPtuple *nbp_tuple_print(const struct atNBPtuple *,
+static void atp_print(netdissect_options *, const struct atATP *, u_int);
+static void atp_bitmap_print(netdissect_options *, u_char);
+static void nbp_print(netdissect_options *, const struct atNBP *, u_int, u_short, u_char, u_char);
+static const struct atNBPtuple *nbp_tuple_print(netdissect_options *ndo, const struct atNBPtuple *,
const u_char *,
u_short, u_char, u_char);
-static const struct atNBPtuple *nbp_name_print(const struct atNBPtuple *,
+static const struct atNBPtuple *nbp_name_print(netdissect_options *, const struct atNBPtuple *,
const u_char *);
-static const char *ataddr_string(u_short, u_char);
-static void ddp_print(const u_char *, u_int, int, u_short, u_char, u_char);
-static const char *ddpskt_string(int);
+static const char *ataddr_string(netdissect_options *, u_short, u_char);
+static void ddp_print(netdissect_options *, const u_char *, u_int, int, u_short, u_char, u_char);
+static const char *ddpskt_string(netdissect_options *, int);
/*
* Print LLAP packets received on a physical LocalTalk interface.
*/
u_int
-ltalk_if_print(const struct pcap_pkthdr *h, const u_char *p)
+ltalk_if_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, const u_char *p)
{
- return (llap_print(p, h->caplen));
+ return (llap_print(ndo, p, h->caplen));
}
/*
* Print AppleTalk LLAP packets.
*/
u_int
-llap_print(register const u_char *bp, u_int length)
+llap_print(netdissect_options *ndo,
+ register const u_char *bp, u_int length)
{
register const struct LAP *lp;
register const struct atDDP *dp;
@@ -102,7 +97,7 @@ llap_print(register const u_char *bp, u_int length)
u_int hdrlen;
if (length < sizeof(*lp)) {
- (void)printf(" [|llap %u]", length);
+ ND_PRINT((ndo, " [|llap %u]", length));
return (length);
}
lp = (const struct LAP *)bp;
@@ -113,36 +108,36 @@ llap_print(register const u_char *bp, u_int length)
case lapShortDDP:
if (length < ddpSSize) {
- (void)printf(" [|sddp %u]", length);
+ ND_PRINT((ndo, " [|sddp %u]", length));
return (length);
}
sdp = (const struct atShortDDP *)bp;
- printf("%s.%s",
- ataddr_string(0, lp->src), ddpskt_string(sdp->srcSkt));
- printf(" > %s.%s:",
- ataddr_string(0, lp->dst), ddpskt_string(sdp->dstSkt));
+ ND_PRINT((ndo, "%s.%s",
+ ataddr_string(ndo, 0, lp->src), ddpskt_string(ndo, sdp->srcSkt)));
+ ND_PRINT((ndo, " > %s.%s:",
+ ataddr_string(ndo, 0, lp->dst), ddpskt_string(ndo, sdp->dstSkt)));
bp += ddpSSize;
length -= ddpSSize;
hdrlen += ddpSSize;
- ddp_print(bp, length, sdp->type, 0, lp->src, sdp->srcSkt);
+ ddp_print(ndo, bp, length, sdp->type, 0, lp->src, sdp->srcSkt);
break;
case lapDDP:
if (length < ddpSize) {
- (void)printf(" [|ddp %u]", length);
+ ND_PRINT((ndo, " [|ddp %u]", length));
return (length);
}
dp = (const struct atDDP *)bp;
snet = EXTRACT_16BITS(&dp->srcNet);
- printf("%s.%s", ataddr_string(snet, dp->srcNode),
- ddpskt_string(dp->srcSkt));
- printf(" > %s.%s:",
- ataddr_string(EXTRACT_16BITS(&dp->dstNet), dp->dstNode),
- ddpskt_string(dp->dstSkt));
+ ND_PRINT((ndo, "%s.%s", ataddr_string(ndo, snet, dp->srcNode),
+ ddpskt_string(ndo, dp->srcSkt)));
+ ND_PRINT((ndo, " > %s.%s:",
+ ataddr_string(ndo, EXTRACT_16BITS(&dp->dstNet), dp->dstNode),
+ ddpskt_string(ndo, dp->dstSkt)));
bp += ddpSize;
length -= ddpSize;
hdrlen += ddpSize;
- ddp_print(bp, length, dp->type, snet, dp->srcNode, dp->srcSkt);
+ ddp_print(ndo, bp, length, dp->type, snet, dp->srcNode, dp->srcSkt);
break;
#ifdef notdef
@@ -152,8 +147,8 @@ llap_print(register const u_char *bp, u_int length)
#endif
default:
- printf("%d > %d at-lap#%d %u",
- lp->src, lp->dst, lp->type, length);
+ ND_PRINT((ndo, "%d > %d at-lap#%d %u",
+ lp->src, lp->dst, lp->type, length));
break;
}
return (hdrlen);
@@ -165,39 +160,41 @@ llap_print(register const u_char *bp, u_int length)
* packets in them).
*/
void
-atalk_print(register const u_char *bp, u_int length)
+atalk_print(netdissect_options *ndo,
+ register const u_char *bp, u_int length)
{
register const struct atDDP *dp;
u_short snet;
- if(!eflag)
- printf("AT ");
+ if(!ndo->ndo_eflag)
+ ND_PRINT((ndo, "AT "));
if (length < ddpSize) {
- (void)printf(" [|ddp %u]", length);
+ ND_PRINT((ndo, " [|ddp %u]", length));
return;
}
dp = (const struct atDDP *)bp;
snet = EXTRACT_16BITS(&dp->srcNet);
- printf("%s.%s", ataddr_string(snet, dp->srcNode),
- ddpskt_string(dp->srcSkt));
- printf(" > %s.%s: ",
- ataddr_string(EXTRACT_16BITS(&dp->dstNet), dp->dstNode),
- ddpskt_string(dp->dstSkt));
+ ND_PRINT((ndo, "%s.%s", ataddr_string(ndo, snet, dp->srcNode),
+ ddpskt_string(ndo, dp->srcSkt)));
+ ND_PRINT((ndo, " > %s.%s: ",
+ ataddr_string(ndo, EXTRACT_16BITS(&dp->dstNet), dp->dstNode),
+ ddpskt_string(ndo, dp->dstSkt)));
bp += ddpSize;
length -= ddpSize;
- ddp_print(bp, length, dp->type, snet, dp->srcNode, dp->srcSkt);
+ ddp_print(ndo, bp, length, dp->type, snet, dp->srcNode, dp->srcSkt);
}
/* XXX should probably pass in the snap header and do checks like arp_print() */
void
-aarp_print(register const u_char *bp, u_int length)
+aarp_print(netdissect_options *ndo,
+ register const u_char *bp, u_int length)
{
register const struct aarp *ap;
-#define AT(member) ataddr_string((ap->member[1]<<8)|ap->member[2],ap->member[3])
+#define AT(member) ataddr_string(ndo, (ap->member[1]<<8)|ap->member[2],ap->member[3])
- printf("aarp ");
+ ND_PRINT((ndo, "aarp "));
ap = (const struct aarp *)bp;
if (EXTRACT_16BITS(&ap->htype) == 1 &&
EXTRACT_16BITS(&ap->ptype) == ETHERTYPE_ATALK &&
@@ -205,151 +202,151 @@ aarp_print(register const u_char *bp, u_int length)
switch (EXTRACT_16BITS(&ap->op)) {
case 1: /* request */
- (void)printf("who-has %s tell %s",
- AT(pdaddr), AT(psaddr));
+ ND_PRINT((ndo, "who-has %s tell %s", AT(pdaddr), AT(psaddr)));
return;
case 2: /* response */
- (void)printf("reply %s is-at %s",
- AT(psaddr), etheraddr_string(ap->hsaddr));
+ ND_PRINT((ndo, "reply %s is-at %s", AT(psaddr), etheraddr_string(ndo, ap->hsaddr)));
return;
case 3: /* probe (oy!) */
- (void)printf("probe %s tell %s",
- AT(pdaddr), AT(psaddr));
+ ND_PRINT((ndo, "probe %s tell %s", AT(pdaddr), AT(psaddr)));
return;
}
- (void)printf("len %u op %u htype %u ptype %#x halen %u palen %u",
+ ND_PRINT((ndo, "len %u op %u htype %u ptype %#x halen %u palen %u",
length, EXTRACT_16BITS(&ap->op), EXTRACT_16BITS(&ap->htype),
- EXTRACT_16BITS(&ap->ptype), ap->halen, ap->palen);
+ EXTRACT_16BITS(&ap->ptype), ap->halen, ap->palen));
}
/*
* Print AppleTalk Datagram Delivery Protocol packets.
*/
static void
-ddp_print(register const u_char *bp, register u_int length, register int t,
- register u_short snet, register u_char snode, u_char skt)
+ddp_print(netdissect_options *ndo,
+ register const u_char *bp, register u_int length, register int t,
+ register u_short snet, register u_char snode, u_char skt)
{
switch (t) {
case ddpNBP:
- nbp_print((const struct atNBP *)bp, length, snet, snode, skt);
+ nbp_print(ndo, (const struct atNBP *)bp, length, snet, snode, skt);
break;
case ddpATP:
- atp_print((const struct atATP *)bp, length);
+ atp_print(ndo, (const struct atATP *)bp, length);
break;
case ddpEIGRP:
- eigrp_print(bp, length);
+ eigrp_print(ndo, bp, length);
break;
default:
- (void)printf(" at-%s %d", tok2str(type2str, NULL, t), length);
+ ND_PRINT((ndo, " at-%s %d", tok2str(type2str, NULL, t), length));
break;
}
}
static void
-atp_print(register const struct atATP *ap, u_int length)
+atp_print(netdissect_options *ndo,
+ register const struct atATP *ap, u_int length)
{
char c;
- u_int32_t data;
+ uint32_t data;
- if ((const u_char *)(ap + 1) > snapend) {
+ if ((const u_char *)(ap + 1) > ndo->ndo_snapend) {
/* Just bail if we don't have the whole chunk. */
- fputs(tstr, stdout);
+ ND_PRINT((ndo, "%s", tstr));
return;
}
if (length < sizeof(*ap)) {
- (void)printf(" [|atp %u]", length);
+ ND_PRINT((ndo, " [|atp %u]", length));
return;
}
length -= sizeof(*ap);
switch (ap->control & 0xc0) {
case atpReqCode:
- (void)printf(" atp-req%s %d",
+ ND_PRINT((ndo, " atp-req%s %d",
ap->control & atpXO? " " : "*",
- EXTRACT_16BITS(&ap->transID));
+ EXTRACT_16BITS(&ap->transID)));
- atp_bitmap_print(ap->bitmap);
+ atp_bitmap_print(ndo, ap->bitmap);
if (length != 0)
- (void)printf(" [len=%u]", length);
+ ND_PRINT((ndo, " [len=%u]", length));
switch (ap->control & (atpEOM|atpSTS)) {
case atpEOM:
- (void)printf(" [EOM]");
+ ND_PRINT((ndo, " [EOM]"));
break;
case atpSTS:
- (void)printf(" [STS]");
+ ND_PRINT((ndo, " [STS]"));
break;
case atpEOM|atpSTS:
- (void)printf(" [EOM,STS]");
+ ND_PRINT((ndo, " [EOM,STS]"));
break;
}
break;
case atpRspCode:
- (void)printf(" atp-resp%s%d:%d (%u)",
+ ND_PRINT((ndo, " atp-resp%s%d:%d (%u)",
ap->control & atpEOM? "*" : " ",
- EXTRACT_16BITS(&ap->transID), ap->bitmap, length);
+ EXTRACT_16BITS(&ap->transID), ap->bitmap, length));
switch (ap->control & (atpXO|atpSTS)) {
case atpXO:
- (void)printf(" [XO]");
+ ND_PRINT((ndo, " [XO]"));
break;
case atpSTS:
- (void)printf(" [STS]");
+ ND_PRINT((ndo, " [STS]"));
break;
case atpXO|atpSTS:
- (void)printf(" [XO,STS]");
+ ND_PRINT((ndo, " [XO,STS]"));
break;
}
break;
case atpRelCode:
- (void)printf(" atp-rel %d", EXTRACT_16BITS(&ap->transID));
+ ND_PRINT((ndo, " atp-rel %d", EXTRACT_16BITS(&ap->transID)));
- atp_bitmap_print(ap->bitmap);
+ atp_bitmap_print(ndo, ap->bitmap);
/* length should be zero */
if (length)
- (void)printf(" [len=%u]", length);
+ ND_PRINT((ndo, " [len=%u]", length));
/* there shouldn't be any control flags */
if (ap->control & (atpXO|atpEOM|atpSTS)) {
c = '[';
if (ap->control & atpXO) {
- (void)printf("%cXO", c);
+ ND_PRINT((ndo, "%cXO", c));
c = ',';
}
if (ap->control & atpEOM) {
- (void)printf("%cEOM", c);
+ ND_PRINT((ndo, "%cEOM", c));
c = ',';
}
if (ap->control & atpSTS) {
- (void)printf("%cSTS", c);
+ ND_PRINT((ndo, "%cSTS", c));
c = ',';
}
- (void)printf("]");
+ ND_PRINT((ndo, "]"));
}
break;
default:
- (void)printf(" atp-0x%x %d (%u)", ap->control,
- EXTRACT_16BITS(&ap->transID), length);
+ ND_PRINT((ndo, " atp-0x%x %d (%u)", ap->control,
+ EXTRACT_16BITS(&ap->transID), length));
break;
}
data = EXTRACT_32BITS(&ap->userData);
if (data != 0)
- (void)printf(" 0x%x", data);
+ ND_PRINT((ndo, " 0x%x", data));
}
static void
-atp_bitmap_print(register u_char bm)
+atp_bitmap_print(netdissect_options *ndo,
+ register u_char bm)
{
register char c;
register int i;
@@ -363,25 +360,26 @@ atp_bitmap_print(register u_char bm)
c = '<';
for (i = 0; bm; ++i) {
if (bm & 1) {
- (void)printf("%c%d", c, i);
+ ND_PRINT((ndo, "%c%d", c, i));
c = ',';
}
bm >>= 1;
}
- (void)printf(">");
+ ND_PRINT((ndo, ">"));
} else {
for (i = 0; bm; ++i)
bm >>= 1;
if (i > 1)
- (void)printf("<0-%d>", i - 1);
+ ND_PRINT((ndo, "<0-%d>", i - 1));
else
- (void)printf("<0>");
+ ND_PRINT((ndo, "<0>"));
}
}
static void
-nbp_print(register const struct atNBP *np, u_int length, register u_short snet,
- register u_char snode, register u_char skt)
+nbp_print(netdissect_options *ndo,
+ register const struct atNBP *np, u_int length, register u_short snet,
+ register u_char snode, register u_char skt)
{
register const struct atNBPtuple *tp =
(const struct atNBPtuple *)((u_char *)np + nbpHeaderSize);
@@ -389,138 +387,137 @@ nbp_print(register const struct atNBP *np, u_int length, register u_short snet,
const u_char *ep;
if (length < nbpHeaderSize) {
- (void)printf(" truncated-nbp %u", length);
+ ND_PRINT((ndo, " truncated-nbp %u", length));
return;
}
length -= nbpHeaderSize;
if (length < 8) {
/* must be room for at least one tuple */
- (void)printf(" truncated-nbp %u", length + nbpHeaderSize);
+ ND_PRINT((ndo, " truncated-nbp %u", length + nbpHeaderSize));
return;
}
/* ep points to end of available data */
- ep = snapend;
+ ep = ndo->ndo_snapend;
if ((const u_char *)tp > ep) {
- fputs(tstr, stdout);
+ ND_PRINT((ndo, "%s", tstr));
return;
}
switch (i = np->control & 0xf0) {
case nbpBrRq:
case nbpLkUp:
- (void)printf(i == nbpLkUp? " nbp-lkup %d:":" nbp-brRq %d:",
- np->id);
+ ND_PRINT((ndo, i == nbpLkUp? " nbp-lkup %d:":" nbp-brRq %d:", np->id));
if ((const u_char *)(tp + 1) > ep) {
- fputs(tstr, stdout);
+ ND_PRINT((ndo, "%s", tstr));
return;
}
- (void)nbp_name_print(tp, ep);
+ (void)nbp_name_print(ndo, tp, ep);
/*
* look for anomalies: the spec says there can only
* be one tuple, the address must match the source
* address and the enumerator should be zero.
*/
if ((np->control & 0xf) != 1)
- (void)printf(" [ntup=%d]", np->control & 0xf);
+ ND_PRINT((ndo, " [ntup=%d]", np->control & 0xf));
if (tp->enumerator)
- (void)printf(" [enum=%d]", tp->enumerator);
+ ND_PRINT((ndo, " [enum=%d]", tp->enumerator));
if (EXTRACT_16BITS(&tp->net) != snet ||
tp->node != snode || tp->skt != skt)
- (void)printf(" [addr=%s.%d]",
- ataddr_string(EXTRACT_16BITS(&tp->net),
- tp->node), tp->skt);
+ ND_PRINT((ndo, " [addr=%s.%d]",
+ ataddr_string(ndo, EXTRACT_16BITS(&tp->net),
+ tp->node), tp->skt));
break;
case nbpLkUpReply:
- (void)printf(" nbp-reply %d:", np->id);
+ ND_PRINT((ndo, " nbp-reply %d:", np->id));
/* print each of the tuples in the reply */
for (i = np->control & 0xf; --i >= 0 && tp; )
- tp = nbp_tuple_print(tp, ep, snet, snode, skt);
+ tp = nbp_tuple_print(ndo, tp, ep, snet, snode, skt);
break;
default:
- (void)printf(" nbp-0x%x %d (%u)", np->control, np->id,
- length);
+ ND_PRINT((ndo, " nbp-0x%x %d (%u)", np->control, np->id, length));
break;
}
}
/* print a counted string */
static const char *
-print_cstring(register const char *cp, register const u_char *ep)
+print_cstring(netdissect_options *ndo,
+ register const char *cp, register const u_char *ep)
{
register u_int length;
if (cp >= (const char *)ep) {
- fputs(tstr, stdout);
+ ND_PRINT((ndo, "%s", tstr));
return (0);
}
length = *cp++;
/* Spec says string can be at most 32 bytes long */
if (length > 32) {
- (void)printf("[len=%u]", length);
+ ND_PRINT((ndo, "[len=%u]", length));
return (0);
}
while ((int)--length >= 0) {
if (cp >= (const char *)ep) {
- fputs(tstr, stdout);
+ ND_PRINT((ndo, "%s", tstr));
return (0);
}
- putchar(*cp++);
+ ND_PRINT((ndo, "%c", *cp++));
}
return (cp);
}
static const struct atNBPtuple *
-nbp_tuple_print(register const struct atNBPtuple *tp,
- register const u_char *ep,
- register u_short snet, register u_char snode,
- register u_char skt)
+nbp_tuple_print(netdissect_options *ndo,
+ register const struct atNBPtuple *tp, register const u_char *ep,
+ register u_short snet, register u_char snode, register u_char skt)
{
register const struct atNBPtuple *tpn;
if ((const u_char *)(tp + 1) > ep) {
- fputs(tstr, stdout);
+ ND_PRINT((ndo, "%s", tstr));
return 0;
}
- tpn = nbp_name_print(tp, ep);
+ tpn = nbp_name_print(ndo, tp, ep);
/* if the enumerator isn't 1, print it */
if (tp->enumerator != 1)
- (void)printf("(%d)", tp->enumerator);
+ ND_PRINT((ndo, "(%d)", tp->enumerator));
/* if the socket doesn't match the src socket, print it */
if (tp->skt != skt)
- (void)printf(" %d", tp->skt);
+ ND_PRINT((ndo, " %d", tp->skt));
/* if the address doesn't match the src address, it's an anomaly */
if (EXTRACT_16BITS(&tp->net) != snet || tp->node != snode)
- (void)printf(" [addr=%s]",
- ataddr_string(EXTRACT_16BITS(&tp->net), tp->node));
+ ND_PRINT((ndo, " [addr=%s]",
+ ataddr_string(ndo, EXTRACT_16BITS(&tp->net), tp->node)));
return (tpn);
}
static const struct atNBPtuple *
-nbp_name_print(const struct atNBPtuple *tp, register const u_char *ep)
+nbp_name_print(netdissect_options *ndo,
+ const struct atNBPtuple *tp, register const u_char *ep)
{
register const char *cp = (const char *)tp + nbpTupleSize;
- putchar(' ');
+ ND_PRINT((ndo, " "));
/* Object */
- putchar('"');
- if ((cp = print_cstring(cp, ep)) != NULL) {
+ ND_PRINT((ndo, "\""));
+ if ((cp = print_cstring(ndo, cp, ep)) != NULL) {
/* Type */
- putchar(':');
- if ((cp = print_cstring(cp, ep)) != NULL) {
+ ND_PRINT((ndo, ":"));
+ if ((cp = print_cstring(ndo, cp, ep)) != NULL) {
/* Zone */
- putchar('@');
- if ((cp = print_cstring(cp, ep)) != NULL)
- putchar('"');
+ ND_PRINT((ndo, "@"));
+ if ((cp = print_cstring(ndo, cp, ep)) != NULL)
+ ND_PRINT((ndo, "\""));
}
}
return ((const struct atNBPtuple *)cp);
@@ -538,11 +535,12 @@ struct hnamemem {
static struct hnamemem hnametable[HASHNAMESIZE];
static const char *
-ataddr_string(u_short atnet, u_char athost)
+ataddr_string(netdissect_options *ndo,
+ u_short atnet, u_char athost)
{
register struct hnamemem *tp, *tp2;
register int i = (atnet << 8) | athost;
- char nambuf[MAXHOSTNAMELEN + 20];
+ char nambuf[256+1];
static int first = 1;
FILE *fp;
@@ -550,7 +548,7 @@ ataddr_string(u_short atnet, u_char athost)
* if this is the first call, see if there's an AppleTalk
* number to name map file.
*/
- if (first && (first = 0, !nflag)
+ if (first && (first = 0, !ndo->ndo_nflag)
&& (fp = fopen("/etc/atalk.names", "r"))) {
char line[256];
int i1, i2;
@@ -604,7 +602,7 @@ ataddr_string(u_short atnet, u_char athost)
return (tp->name);
}
-static struct tok skt2str[] = {
+static const struct tok skt2str[] = {
{ rtmpSkt, "rtmp" }, /* routing table maintenance */
{ nbpSkt, "nis" }, /* name info socket */
{ echoSkt, "echo" }, /* AppleTalk echo protocol */
@@ -613,11 +611,12 @@ static struct tok skt2str[] = {
};
static const char *
-ddpskt_string(register int skt)
+ddpskt_string(netdissect_options *ndo,
+ register int skt)
{
static char buf[8];
- if (nflag) {
+ if (ndo->ndo_nflag) {
(void)snprintf(buf, sizeof(buf), "%d", skt);
return (buf);
}
diff --git a/contrib/tcpdump/print-atm.c b/contrib/tcpdump/print-atm.c
index b0fd6c2e844d..b352579ea4d9 100644
--- a/contrib/tcpdump/print-atm.c
+++ b/contrib/tcpdump/print-atm.c
@@ -20,43 +20,35 @@
*
* $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.49 2007-10-22 19:37:51 guy Exp $ (LBL)";
-#endif
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <pcap.h>
-#include <string.h>
-
#include "interface.h"
#include "extract.h"
#include "addrtoname.h"
-#include "ethertype.h"
#include "atm.h"
#include "atmuni31.h"
#include "llc.h"
-#include "ether.h"
+static const char tstr[] = "[|atm]";
#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[] = {
+static const struct tok oam_f_values[] = {
{ VCI_OAMF4SC, "OAM F4 (segment)" },
{ VCI_OAMF4EC, "OAM F4 (end)" },
{ 0, NULL }
};
-struct tok atm_pty_values[] = {
+static const struct tok atm_pty_values[] = {
{ 0x0, "user data, uncongested, SDU 0" },
{ 0x1, "user data, uncongested, SDU 1" },
{ 0x2, "user data, congested, SDU 0" },
@@ -72,7 +64,7 @@ struct tok atm_pty_values[] = {
#define OAM_CELLTYPE_AD 0x8
#define OAM_CELLTYPE_SM 0xf
-struct tok oam_celltype_values[] = {
+static const struct tok oam_celltype_values[] = {
{ OAM_CELLTYPE_FM, "Fault Management" },
{ OAM_CELLTYPE_PM, "Performance Management" },
{ OAM_CELLTYPE_AD, "activate/deactivate" },
@@ -85,7 +77,7 @@ struct tok oam_celltype_values[] = {
#define OAM_FM_FUNCTYPE_CONTCHECK 0x4
#define OAM_FM_FUNCTYPE_LOOPBACK 0x8
-struct tok oam_fm_functype_values[] = {
+static const struct tok oam_fm_functype_values[] = {
{ OAM_FM_FUNCTYPE_AIS, "AIS" },
{ OAM_FM_FUNCTYPE_RDI, "RDI" },
{ OAM_FM_FUNCTYPE_CONTCHECK, "Continuity Check" },
@@ -93,14 +85,14 @@ struct tok oam_fm_functype_values[] = {
{ 0, NULL }
};
-struct tok oam_pm_functype_values[] = {
+static const struct tok oam_pm_functype_values[] = {
{ 0x0, "Forward Monitoring" },
{ 0x1, "Backward Reporting" },
{ 0x2, "Monitoring and Reporting" },
{ 0, NULL }
};
-struct tok oam_ad_functype_values[] = {
+static const struct tok oam_ad_functype_values[] = {
{ 0x0, "Performance Monitoring" },
{ 0x1, "Continuity Check" },
{ 0, NULL }
@@ -108,7 +100,7 @@ struct tok oam_ad_functype_values[] = {
#define OAM_FM_LOOPBACK_INDICATOR_MASK 0x1
-struct tok oam_fm_loopback_indicator_values[] = {
+static const struct tok oam_fm_loopback_indicator_values[] = {
{ 0x0, "Reply" },
{ 0x1, "Request" },
{ 0, NULL }
@@ -137,19 +129,20 @@ static const struct tok *oam_functype_values[16] = {
* Print an RFC 1483 LLC-encapsulated ATM frame.
*/
static void
-atm_llc_print(const u_char *p, int length, int caplen)
+atm_llc_print(netdissect_options *ndo,
+ const u_char *p, int length, int caplen)
{
u_short extracted_ethertype;
- if (!llc_print(p, length, caplen, NULL, NULL,
+ if (!llc_print(ndo, p, length, caplen, NULL, NULL,
&extracted_ethertype)) {
/* ether_type not known, print raw packet */
if (extracted_ethertype) {
- printf("(LLC %s) ",
- etherproto_string(htons(extracted_ethertype)));
+ ND_PRINT((ndo, "(LLC %s) ",
+ etherproto_string(htons(extracted_ethertype))));
}
- if (!suppress_default_print)
- default_print(p, caplen);
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
}
}
@@ -166,23 +159,24 @@ atm_llc_print(const u_char *p, int length, int caplen)
* is the number of bytes actually captured.
*/
u_int
-atm_if_print(const struct pcap_pkthdr *h, const u_char *p)
+atm_if_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, const u_char *p)
{
u_int caplen = h->caplen;
u_int length = h->len;
- u_int32_t llchdr;
+ uint32_t llchdr;
u_int hdrlen = 0;
if (caplen < 8) {
- printf("[|atm]");
+ ND_PRINT((ndo, "%s", tstr));
return (caplen);
}
/* Cisco Style NLPID ? */
if (*p == LLC_UI) {
- if (eflag)
- printf("CNLPID ");
- isoclns_print(p+1, length-1, caplen-1);
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "CNLPID "));
+ isoclns_print(ndo, p + 1, length - 1, caplen - 1);
return hdrlen;
}
@@ -213,25 +207,25 @@ atm_if_print(const struct pcap_pkthdr *h, const u_char *p)
* packets? If so, could it be changed to use a
* new DLT_IEEE802_6 value if we added it?
*/
- if (eflag)
- printf("%08x%08x %08x%08x ",
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "%08x%08x %08x%08x ",
EXTRACT_32BITS(p),
EXTRACT_32BITS(p+4),
EXTRACT_32BITS(p+8),
- EXTRACT_32BITS(p+12));
+ EXTRACT_32BITS(p+12)));
p += 20;
length -= 20;
caplen -= 20;
hdrlen += 20;
}
- atm_llc_print(p, length, caplen);
+ atm_llc_print(ndo, p, length, caplen);
return (hdrlen);
}
/*
* ATM signalling.
*/
-static struct tok msgtype2str[] = {
+static const struct tok msgtype2str[] = {
{ CALL_PROCEED, "Call_proceeding" },
{ CONNECT, "Connect" },
{ CONNECT_ACK, "Connect_ack" },
@@ -251,26 +245,27 @@ static struct tok msgtype2str[] = {
};
static void
-sig_print(const u_char *p, int caplen)
+sig_print(netdissect_options *ndo,
+ const u_char *p, int caplen)
{
- bpf_u_int32 call_ref;
+ uint32_t call_ref;
if (caplen < PROTO_POS) {
- printf("[|atm]");
+ ND_PRINT((ndo, "%s", tstr));
return;
}
if (p[PROTO_POS] == Q2931) {
/*
- * protocol:Q.2931 for User to Network Interface
+ * protocol:Q.2931 for User to Network Interface
* (UNI 3.1) signalling
*/
- printf("Q.2931");
+ ND_PRINT((ndo, "Q.2931"));
if (caplen < MSG_TYPE_POS) {
- printf(" [|atm]");
+ ND_PRINT((ndo, " %s", tstr));
return;
}
- printf(":%s ",
- tok2str(msgtype2str, "msgtype#%d", p[MSG_TYPE_POS]));
+ ND_PRINT((ndo, ":%s ",
+ tok2str(msgtype2str, "msgtype#%d", p[MSG_TYPE_POS])));
/*
* The call reference comes before the message type,
@@ -279,10 +274,10 @@ sig_print(const u_char *p, int caplen)
* the call reference.
*/
call_ref = EXTRACT_24BITS(&p[CALL_REF_POS]);
- printf("CALL_REF:0x%06x", call_ref);
+ ND_PRINT((ndo, "CALL_REF:0x%06x", call_ref));
} else {
/* SCCOP with some unknown protocol atop it */
- printf("SSCOP, proto %d ", p[PROTO_POS]);
+ ND_PRINT((ndo, "SSCOP, proto %d ", p[PROTO_POS]));
}
}
@@ -290,35 +285,36 @@ sig_print(const u_char *p, int caplen)
* Print an ATM PDU (such as an AAL5 PDU).
*/
void
-atm_print(u_int vpi, u_int vci, u_int traftype, const u_char *p, u_int length,
- u_int caplen)
+atm_print(netdissect_options *ndo,
+ u_int vpi, u_int vci, u_int traftype, const u_char *p, u_int length,
+ u_int caplen)
{
- if (eflag)
- printf("VPI:%u VCI:%u ", vpi, vci);
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "VPI:%u VCI:%u ", vpi, vci));
if (vpi == 0) {
switch (vci) {
case VCI_PPC:
- sig_print(p, caplen);
+ sig_print(ndo, p, caplen);
return;
case VCI_BCC:
- printf("broadcast sig: ");
+ ND_PRINT((ndo, "broadcast sig: "));
return;
case VCI_OAMF4SC: /* fall through */
case VCI_OAMF4EC:
- oam_print(p, length, ATM_OAM_HEC);
+ oam_print(ndo, p, length, ATM_OAM_HEC);
return;
case VCI_METAC:
- printf("meta: ");
+ ND_PRINT((ndo, "meta: "));
return;
case VCI_ILMIC:
- printf("ilmi: ");
- snmp_print(p, length);
+ ND_PRINT((ndo, "ilmi: "));
+ snmp_print(ndo, p, length);
return;
}
}
@@ -330,35 +326,36 @@ atm_print(u_int vpi, u_int vci, u_int traftype, const u_char *p, u_int length,
/*
* Assumes traffic is LLC if unknown.
*/
- atm_llc_print(p, length, caplen);
+ atm_llc_print(ndo, p, length, caplen);
break;
case ATM_LANE:
- lane_print(p, length, caplen);
+ lane_print(ndo, p, length, caplen);
break;
}
}
struct oam_fm_loopback_t {
- u_int8_t loopback_indicator;
- u_int8_t correlation_tag[4];
- u_int8_t loopback_id[12];
- u_int8_t source_id[12];
- u_int8_t unused[16];
+ uint8_t loopback_indicator;
+ uint8_t correlation_tag[4];
+ uint8_t loopback_id[12];
+ uint8_t source_id[12];
+ uint8_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];
+ uint8_t failure_type;
+ uint8_t failure_location[16];
+ uint8_t unused[28];
};
-int
-oam_print (const u_char *p, u_int length, u_int hec) {
+int
+oam_print (netdissect_options *ndo,
+ const u_char *p, u_int length, u_int hec) {
- u_int32_t cell_header;
- u_int16_t vpi, vci, cksum, cksum_shouldbe, idx;
- u_int8_t cell_type, func_type, payload, clp;
+ uint32_t cell_header;
+ uint16_t vpi, vci, cksum, cksum_shouldbe, idx;
+ uint8_t cell_type, func_type, payload, clp;
union {
const struct oam_fm_loopback_t *oam_fm_loopback;
@@ -375,47 +372,47 @@ oam_print (const u_char *p, u_int length, u_int hec) {
payload = (cell_header>>1)&0x7;
clp = cell_header&0x1;
- printf("%s, vpi %u, vci %u, payload [ %s ], clp %u, length %u",
+ ND_PRINT((ndo, "%s, vpi %u, vci %u, payload [ %s ], clp %u, length %u",
tok2str(oam_f_values, "OAM F5", vci),
vpi, vci,
tok2str(atm_pty_values, "Unknown", payload),
- clp, length);
+ clp, length));
- if (!vflag) {
+ if (!ndo->ndo_vflag) {
return 1;
}
- printf("\n\tcell-type %s (%u)",
+ ND_PRINT((ndo, "\n\tcell-type %s (%u)",
tok2str(oam_celltype_values, "unknown", cell_type),
- cell_type);
+ cell_type));
if (oam_functype_values[cell_type] == NULL)
- printf(", func-type unknown (%u)", func_type);
+ ND_PRINT((ndo, ", func-type unknown (%u)", func_type));
else
- printf(", func-type %s (%u)",
+ ND_PRINT((ndo, ", func-type %s (%u)",
tok2str(oam_functype_values[cell_type],"none",func_type),
- func_type);
+ func_type));
p += ATM_HDR_LEN_NOHEC + hec;
switch (cell_type << 4 | func_type) {
case (OAM_CELLTYPE_FM << 4 | OAM_FM_FUNCTYPE_LOOPBACK):
oam_ptr.oam_fm_loopback = (const struct oam_fm_loopback_t *)(p + OAM_CELLTYPE_FUNCTYPE_LEN);
- printf("\n\tLoopback-Indicator %s, Correlation-Tag 0x%08x",
+ ND_PRINT((ndo, "\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 ");
+ EXTRACT_32BITS(&oam_ptr.oam_fm_loopback->correlation_tag)));
+ ND_PRINT((ndo, "\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]));
+ ND_PRINT((ndo, "%04x ", EXTRACT_16BITS(&oam_ptr.oam_fm_loopback->loopback_id[idx])));
}
}
- printf("\n\tSource-ID ");
+ ND_PRINT((ndo, "\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]));
+ ND_PRINT((ndo, "%04x ", EXTRACT_16BITS(&oam_ptr.oam_fm_loopback->source_id[idx])));
}
}
break;
@@ -423,11 +420,11 @@ oam_print (const u_char *p, u_int length, u_int hec) {
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 ");
+ ND_PRINT((ndo, "\n\tFailure-type 0x%02x", oam_ptr.oam_fm_ais_rdi->failure_type));
+ ND_PRINT((ndo, "\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]));
+ ND_PRINT((ndo, "%04x ", EXTRACT_16BITS(&oam_ptr.oam_fm_ais_rdi->failure_location[idx])));
}
}
break;
@@ -444,10 +441,10 @@ oam_print (const u_char *p, u_int length, u_int hec) {
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)",
+
+ ND_PRINT((ndo, "\n\tcksum 0x%03x (%scorrect)",
cksum,
- cksum_shouldbe == 0 ? "" : "in");
+ cksum_shouldbe == 0 ? "" : "in"));
return 1;
}
diff --git a/contrib/tcpdump/print-babel.c b/contrib/tcpdump/print-babel.c
index c15f958670fd..bb3401be5e07 100644
--- a/contrib/tcpdump/print-babel.c
+++ b/contrib/tcpdump/print-babel.c
@@ -26,6 +26,7 @@
* SUCH DAMAGE.
*/
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -35,41 +36,45 @@
#include <stdio.h>
#include <string.h>
-#include "addrtoname.h"
#include "interface.h"
+#include "addrtoname.h"
#include "extract.h"
-static void babel_print_v2(const u_char *cp, u_int length);
+static const char tstr[] = "[|babel]";
+
+static void babel_print_v2(netdissect_options *, const u_char *cp, u_int length);
void
-babel_print(const u_char *cp, u_int length) {
- printf("babel");
+babel_print(netdissect_options *ndo,
+ const u_char *cp, u_int length) {
+ ND_PRINT((ndo, "babel"));
- TCHECK2(*cp, 4);
+ ND_TCHECK2(*cp, 4);
if(cp[0] != 42) {
- printf(" malformed header");
+ ND_PRINT((ndo, " malformed header"));
return;
} else {
- printf(" %d", cp[1]);
+ ND_PRINT((ndo, " %d", cp[1]));
}
switch(cp[1]) {
case 2:
- babel_print_v2(cp,length);
+ babel_print_v2(ndo, cp, length);
break;
default:
- printf(" unknown version");
+ ND_PRINT((ndo, " unknown version"));
break;
}
return;
trunc:
- printf(" [|babel]");
+ ND_PRINT((ndo, " %s", tstr));
return;
}
+/* TLVs */
#define MESSAGE_PAD1 0
#define MESSAGE_PADN 1
#define MESSAGE_ACK_REQ 2
@@ -84,6 +89,19 @@ babel_print(const u_char *cp, u_int length) {
#define MESSAGE_TSPC 11
#define MESSAGE_HMAC 12
+/* sub-TLVs */
+#define MESSAGE_SUB_PAD1 0
+#define MESSAGE_SUB_PADN 1
+#define MESSAGE_SUB_DIVERSITY 2
+#define MESSAGE_SUB_TIMESTAMP 3
+
+/* Diversity sub-TLV channel codes */
+static const struct tok diversity_str[] = {
+ { 0, "reserved" },
+ { 255, "all" },
+ { 0, NULL }
+};
+
static const char *
format_id(const u_char *id)
{
@@ -98,14 +116,14 @@ static const unsigned char v4prefix[16] =
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 0, 0 };
static const char *
-format_prefix(const u_char *prefix, unsigned char plen)
+format_prefix(netdissect_options *ndo, const u_char *prefix, unsigned char plen)
{
static char buf[50];
if(plen >= 96 && memcmp(prefix, v4prefix, 12) == 0)
- snprintf(buf, 50, "%s/%u", ipaddr_string(prefix + 12), plen - 96);
+ snprintf(buf, 50, "%s/%u", ipaddr_string(ndo, prefix + 12), plen - 96);
else
#ifdef INET6
- snprintf(buf, 50, "%s/%u", ip6addr_string(prefix), plen);
+ snprintf(buf, 50, "%s/%u", ip6addr_string(ndo, prefix), plen);
#else
snprintf(buf, 50, "IPv6 addresses not supported");
#endif
@@ -114,18 +132,45 @@ format_prefix(const u_char *prefix, unsigned char plen)
}
static const char *
-format_address(const u_char *prefix)
+format_address(netdissect_options *ndo, const u_char *prefix)
{
if(memcmp(prefix, v4prefix, 12) == 0)
- return ipaddr_string(prefix + 12);
+ return ipaddr_string(ndo, prefix + 12);
else
#ifdef INET6
- return ip6addr_string(prefix);
+ return ip6addr_string(ndo, prefix);
#else
return "IPv6 addresses not supported";
#endif
}
+static const char *
+format_interval(const uint16_t i)
+{
+ static char buf[sizeof("000.00s")];
+
+ if (i == 0)
+ return "0.0s (bogus)";
+ snprintf(buf, sizeof(buf), "%u.%02us", i / 100, i % 100);
+ return buf;
+}
+
+static const char *
+format_interval_update(const uint16_t i)
+{
+ return i == 0xFFFF ? "infinity" : format_interval(i);
+}
+
+static const char *
+format_timestamp(const uint32_t i)
+{
+ static char buf[sizeof("0000.000000s")];
+ snprintf(buf, sizeof(buf), "%u.%06us", i / 1000000, i % 1000000);
+ return buf;
+}
+
+/* Return number of octets consumed from the input buffer (not the prefix length
+ * in bytes), or -1 for encoding error. */
static int
network_prefix(int ae, int plen, unsigned int omitted,
const unsigned char *p, const unsigned char *dp,
@@ -133,6 +178,7 @@ network_prefix(int ae, int plen, unsigned int omitted,
{
unsigned pb;
unsigned char prefix[16];
+ int consumed = 0;
if(plen >= 0)
pb = (plen + 7) / 8;
@@ -156,7 +202,10 @@ network_prefix(int ae, int plen, unsigned int omitted,
if (dp == NULL) return -1;
memcpy(prefix, dp, 12 + omitted);
}
- if(pb > omitted) memcpy(prefix + 12 + omitted, p, pb - omitted);
+ if(pb > omitted) {
+ memcpy(prefix + 12 + omitted, p, pb - omitted);
+ consumed = pb - omitted;
+ }
break;
case 2:
if(omitted > 16 || (pb > omitted && len < pb - omitted))
@@ -165,20 +214,26 @@ network_prefix(int ae, int plen, unsigned int omitted,
if (dp == NULL) return -1;
memcpy(prefix, dp, omitted);
}
- if(pb > omitted) memcpy(prefix + omitted, p, pb - omitted);
+ if(pb > omitted) {
+ memcpy(prefix + omitted, p, pb - omitted);
+ consumed = pb - omitted;
+ }
break;
case 3:
if(pb > 8 && len < pb - 8) return -1;
prefix[0] = 0xfe;
prefix[1] = 0x80;
- if(pb > 8) memcpy(prefix + 8, p, pb - 8);
+ if(pb > 8) {
+ memcpy(prefix + 8, p, pb - 8);
+ consumed = pb - 8;
+ }
break;
default:
return -1;
}
memcpy(p_r, prefix, 16);
- return 1;
+ return consumed;
}
static int
@@ -188,22 +243,115 @@ network_address(int ae, const unsigned char *a, unsigned int len,
return network_prefix(ae, -1, 0, a, NULL, len, a_r);
}
+/*
+ * Sub-TLVs consume the "extra data" of Babel TLVs (see Section 4.3 of RFC6126),
+ * their encoding is similar to the encoding of TLVs, but the type namespace is
+ * different:
+ *
+ * o Type 0 stands for Pad1 sub-TLV with the same encoding as the Pad1 TLV.
+ * o Type 1 stands for PadN sub-TLV with the same encoding as the PadN TLV.
+ * o Type 2 stands for Diversity sub-TLV, which propagates diversity routing
+ * data. Its body is a variable-length sequence of 8-bit unsigned integers,
+ * each representing per-hop number of interferring radio channel for the
+ * prefix. Channel 0 is invalid and must not be used in the sub-TLV, channel
+ * 255 interferes with any other channel.
+ * o Type 3 stands for Timestamp sub-TLV, used to compute RTT between
+ * neighbours. In the case of a Hello TLV, the body stores a 32-bits
+ * timestamp, while in the case of a IHU TLV, two 32-bits timestamps are
+ * stored.
+ *
+ * Sub-TLV types 0 and 1 are valid for any TLV type, whether sub-TLV type 2 is
+ * only valid for TLV type 8 (Update). Note that within an Update TLV a missing
+ * Diversity sub-TLV is not the same as a Diversity sub-TLV with an empty body.
+ * The former would mean a lack of any claims about the interference, and the
+ * latter would state that interference is definitely absent.
+ * A type 3 sub-TLV is valid both for Hello and IHU TLVs, though the exact
+ * semantic of the sub-TLV is different in each case.
+ */
+static void
+subtlvs_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, const uint8_t tlv_type) {
+ uint8_t subtype, sublen;
+ const char *sep;
+ uint32_t t1, t2;
+
+ while (cp < ep) {
+ subtype = *cp++;
+ if(subtype == MESSAGE_SUB_PAD1) {
+ ND_PRINT((ndo, " sub-pad1"));
+ continue;
+ }
+ if(cp == ep)
+ goto corrupt;
+ sublen = *cp++;
+ if(cp + sublen > ep)
+ goto corrupt;
+
+ switch(subtype) {
+ case MESSAGE_SUB_PADN:
+ ND_PRINT((ndo, " sub-padn"));
+ cp += sublen;
+ break;
+ case MESSAGE_SUB_DIVERSITY:
+ ND_PRINT((ndo, " sub-diversity"));
+ if (sublen == 0) {
+ ND_PRINT((ndo, " empty"));
+ break;
+ }
+ sep = " ";
+ while(sublen--) {
+ ND_PRINT((ndo, "%s%s", sep, tok2str(diversity_str, "%u", *cp++)));
+ sep = "-";
+ }
+ if(tlv_type != MESSAGE_UPDATE)
+ ND_PRINT((ndo, " (bogus)"));
+ break;
+ case MESSAGE_SUB_TIMESTAMP:
+ ND_PRINT((ndo, " sub-timestamp"));
+ if(tlv_type == MESSAGE_HELLO) {
+ if(sublen < 4)
+ goto corrupt;
+ t1 = EXTRACT_32BITS(cp);
+ ND_PRINT((ndo, " %s", format_timestamp(t1)));
+ } else if(tlv_type == MESSAGE_IHU) {
+ if(sublen < 8)
+ goto corrupt;
+ t1 = EXTRACT_32BITS(cp);
+ ND_PRINT((ndo, " %s", format_timestamp(t1)));
+ t2 = EXTRACT_32BITS(cp + 4);
+ ND_PRINT((ndo, "|%s", format_timestamp(t2)));
+ } else
+ ND_PRINT((ndo, " (bogus)"));
+ cp += sublen;
+ break;
+ default:
+ ND_PRINT((ndo, " sub-unknown-0x%02x", subtype));
+ cp += sublen;
+ } /* switch */
+ } /* while */
+ return;
+
+ corrupt:
+ ND_PRINT((ndo, " (corrupt)"));
+}
+
#define ICHECK(i, l) \
if ((i) + (l) > bodylen || (i) + (l) > length) goto corrupt;
static void
-babel_print_v2(const u_char *cp, u_int length) {
+babel_print_v2(netdissect_options *ndo,
+ const u_char *cp, u_int length) {
u_int i;
u_short bodylen;
u_char v4_prefix[16] =
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 0, 0 };
u_char v6_prefix[16] = {0};
- TCHECK2(*cp, 4);
+ ND_TCHECK2(*cp, 4);
if (length < 4)
goto corrupt;
bodylen = EXTRACT_16BITS(cp + 2);
- printf(" (%u)", bodylen);
+ ND_PRINT((ndo, " (%u)", bodylen));
/* Process the TLVs in the body */
i = 0;
@@ -212,133 +360,139 @@ babel_print_v2(const u_char *cp, u_int length) {
u_int type, len;
message = cp + 4 + i;
- TCHECK2(*message, 2);
+
+ ND_TCHECK2(*message, 1);
+ if((type = message[0]) == MESSAGE_PAD1) {
+ ND_PRINT((ndo, ndo->ndo_vflag ? "\n\tPad 1" : " pad1"));
+ i += 1;
+ continue;
+ }
+
+ ND_TCHECK2(*message, 2);
ICHECK(i, 2);
- type = message[0];
len = message[1];
- TCHECK2(*message, 2 + len);
+ ND_TCHECK2(*message, 2 + len);
ICHECK(i, 2 + len);
switch(type) {
- case MESSAGE_PAD1: {
- if(!vflag)
- printf(" pad1");
- else
- printf("\n\tPad 1");
- }
- break;
-
case MESSAGE_PADN: {
- if(!vflag)
- printf(" padN");
+ if (!ndo->ndo_vflag)
+ ND_PRINT((ndo, " padN"));
else
- printf("\n\tPad %d", len + 2);
+ ND_PRINT((ndo, "\n\tPad %d", len + 2));
}
break;
case MESSAGE_ACK_REQ: {
u_short nonce, interval;
- if(!vflag)
- printf(" ack-req");
+ if (!ndo->ndo_vflag)
+ ND_PRINT((ndo, " ack-req"));
else {
- printf("\n\tAcknowledgment Request ");
+ ND_PRINT((ndo, "\n\tAcknowledgment Request "));
if(len < 6) goto corrupt;
nonce = EXTRACT_16BITS(message + 4);
interval = EXTRACT_16BITS(message + 6);
- printf("%04x %d", nonce, interval);
+ ND_PRINT((ndo, "%04x %s", nonce, format_interval(interval)));
}
}
break;
case MESSAGE_ACK: {
u_short nonce;
- if(!vflag)
- printf(" ack");
+ if (!ndo->ndo_vflag)
+ ND_PRINT((ndo, " ack"));
else {
- printf("\n\tAcknowledgment ");
+ ND_PRINT((ndo, "\n\tAcknowledgment "));
if(len < 2) goto corrupt;
nonce = EXTRACT_16BITS(message + 2);
- printf("%04x", nonce);
+ ND_PRINT((ndo, "%04x", nonce));
}
}
break;
case MESSAGE_HELLO: {
u_short seqno, interval;
- if(!vflag)
- printf(" hello");
+ if (!ndo->ndo_vflag)
+ ND_PRINT((ndo, " hello"));
else {
- printf("\n\tHello ");
+ ND_PRINT((ndo, "\n\tHello "));
if(len < 6) goto corrupt;
seqno = EXTRACT_16BITS(message + 4);
interval = EXTRACT_16BITS(message + 6);
- printf("seqno %u interval %u", seqno, interval);
+ ND_PRINT((ndo, "seqno %u interval %s", seqno, format_interval(interval)));
+ /* Extra data. */
+ if(len > 6)
+ subtlvs_print(ndo, message + 8, message + 2 + len, type);
}
}
break;
case MESSAGE_IHU: {
unsigned short txcost, interval;
- if(!vflag)
- printf(" ihu");
+ if (!ndo->ndo_vflag)
+ ND_PRINT((ndo, " ihu"));
else {
u_char address[16];
int rc;
- printf("\n\tIHU ");
+ ND_PRINT((ndo, "\n\tIHU "));
if(len < 6) goto corrupt;
txcost = EXTRACT_16BITS(message + 4);
interval = EXTRACT_16BITS(message + 6);
rc = network_address(message[2], message + 8, len - 6, address);
- if(rc < 0) { printf("[|babel]"); break; }
- printf("%s txcost %u interval %d",
- format_address(address), txcost, interval);
+ if(rc < 0) { ND_PRINT((ndo, "%s", tstr)); break; }
+ ND_PRINT((ndo, "%s txcost %u interval %s",
+ format_address(ndo, address), txcost, format_interval(interval)));
+ /* Extra data. */
+ if((u_int)rc < len - 6)
+ subtlvs_print(ndo, message + 8 + rc, message + 2 + len,
+ type);
}
}
break;
case MESSAGE_ROUTER_ID: {
- if(!vflag)
- printf(" router-id");
+ if (!ndo->ndo_vflag)
+ ND_PRINT((ndo, " router-id"));
else {
- printf("\n\tRouter Id");
+ ND_PRINT((ndo, "\n\tRouter Id"));
if(len < 10) goto corrupt;
- printf(" %s", format_id(message + 4));
+ ND_PRINT((ndo, " %s", format_id(message + 4)));
}
}
break;
case MESSAGE_NH: {
- if(!vflag)
- printf(" nh");
+ if (!ndo->ndo_vflag)
+ ND_PRINT((ndo, " nh"));
else {
int rc;
u_char nh[16];
- printf("\n\tNext Hop");
+ ND_PRINT((ndo, "\n\tNext Hop"));
if(len < 2) goto corrupt;
rc = network_address(message[2], message + 4, len - 2, nh);
if(rc < 0) goto corrupt;
- printf(" %s", format_address(nh));
+ ND_PRINT((ndo, " %s", format_address(ndo, nh)));
}
}
break;
case MESSAGE_UPDATE: {
- if(!vflag) {
- printf(" update");
+ if (!ndo->ndo_vflag) {
+ ND_PRINT((ndo, " update"));
if(len < 1)
- printf("/truncated");
+ ND_PRINT((ndo, "/truncated"));
else
- printf("%s%s%s",
+ ND_PRINT((ndo, "%s%s%s",
(message[3] & 0x80) ? "/prefix": "",
(message[3] & 0x40) ? "/id" : "",
- (message[3] & 0x3f) ? "/unknown" : "");
+ (message[3] & 0x3f) ? "/unknown" : ""));
} else {
u_short interval, seqno, metric;
u_char plen;
int rc;
u_char prefix[16];
- printf("\n\tUpdate");
+ ND_PRINT((ndo, "\n\tUpdate"));
if(len < 10) goto corrupt;
plen = message[4] + (message[2] == 1 ? 96 : 0);
rc = network_prefix(message[2], message[4], message[5],
@@ -349,99 +503,101 @@ babel_print_v2(const u_char *cp, u_int length) {
interval = EXTRACT_16BITS(message + 6);
seqno = EXTRACT_16BITS(message + 8);
metric = EXTRACT_16BITS(message + 10);
- printf("%s%s%s %s metric %u seqno %u interval %u",
+ ND_PRINT((ndo, "%s%s%s %s metric %u seqno %u interval %s",
(message[3] & 0x80) ? "/prefix": "",
(message[3] & 0x40) ? "/id" : "",
(message[3] & 0x3f) ? "/unknown" : "",
- format_prefix(prefix, plen),
- metric, seqno, interval);
+ format_prefix(ndo, prefix, plen),
+ metric, seqno, format_interval_update(interval)));
if(message[3] & 0x80) {
if(message[2] == 1)
memcpy(v4_prefix, prefix, 16);
else
memcpy(v6_prefix, prefix, 16);
}
+ /* extra data? */
+ if((u_int)rc < len - 10)
+ subtlvs_print(ndo, message + 12 + rc, message + 2 + len, type);
}
}
break;
case MESSAGE_REQUEST: {
- if(!vflag)
- printf(" request");
+ if (!ndo->ndo_vflag)
+ ND_PRINT((ndo, " request"));
else {
int rc;
u_char prefix[16], plen;
- printf("\n\tRequest ");
+ ND_PRINT((ndo, "\n\tRequest "));
if(len < 2) goto corrupt;
plen = message[3] + (message[2] == 1 ? 96 : 0);
rc = network_prefix(message[2], message[3], 0,
message + 4, NULL, len - 2, prefix);
if(rc < 0) goto corrupt;
- plen = message[3] + (message[2] == 1 ? 96 : 0);
- printf("for %s",
- message[2] == 0 ? "any" : format_prefix(prefix, plen));
+ ND_PRINT((ndo, "for %s",
+ message[2] == 0 ? "any" : format_prefix(ndo, prefix, plen)));
}
}
break;
case MESSAGE_MH_REQUEST : {
- if(!vflag)
- printf(" mh-request");
+ if (!ndo->ndo_vflag)
+ ND_PRINT((ndo, " mh-request"));
else {
int rc;
u_short seqno;
u_char prefix[16], plen;
- printf("\n\tMH-Request ");
+ ND_PRINT((ndo, "\n\tMH-Request "));
if(len < 14) goto corrupt;
seqno = EXTRACT_16BITS(message + 4);
rc = network_prefix(message[2], message[3], 0,
message + 16, NULL, len - 14, prefix);
if(rc < 0) goto corrupt;
plen = message[3] + (message[2] == 1 ? 96 : 0);
- printf("(%u hops) for %s seqno %u id %s",
- message[6], format_prefix(prefix, plen),
- seqno, format_id(message + 8));
+ ND_PRINT((ndo, "(%u hops) for %s seqno %u id %s",
+ message[6], format_prefix(ndo, prefix, plen),
+ seqno, format_id(message + 8)));
}
}
break;
case MESSAGE_TSPC :
- if(!vflag)
- printf(" tspc");
+ if (!ndo->ndo_vflag)
+ ND_PRINT((ndo, " tspc"));
else {
- printf("\n\tTS/PC ");
+ ND_PRINT((ndo, "\n\tTS/PC "));
if(len < 6) goto corrupt;
- printf("timestamp %u packetcounter %u", EXTRACT_32BITS (message + 4),
- EXTRACT_16BITS(message + 2));
+ ND_PRINT((ndo, "timestamp %u packetcounter %u", EXTRACT_32BITS (message + 4),
+ EXTRACT_16BITS(message + 2)));
}
break;
case MESSAGE_HMAC : {
- if(!vflag)
- printf(" hmac");
+ if (!ndo->ndo_vflag)
+ ND_PRINT((ndo, " hmac"));
else {
unsigned j;
- printf("\n\tHMAC ");
+ ND_PRINT((ndo, "\n\tHMAC "));
if(len < 18) goto corrupt;
- printf("key-id %u digest-%u ", EXTRACT_16BITS(message + 2), len - 2);
+ ND_PRINT((ndo, "key-id %u digest-%u ", EXTRACT_16BITS(message + 2), len - 2));
for (j = 0; j < len - 2; j++)
- printf ("%02X", message[4 + j]);
+ ND_PRINT((ndo, "%02X", message[4 + j]));
}
}
break;
default:
- if(!vflag)
- printf(" unknown");
+ if (!ndo->ndo_vflag)
+ ND_PRINT((ndo, " unknown"));
else
- printf("\n\tUnknown message type %d", type);
+ ND_PRINT((ndo, "\n\tUnknown message type %d", type));
}
i += len + 2;
}
return;
trunc:
- printf(" [|babel]");
+ ND_PRINT((ndo, " %s", tstr));
return;
corrupt:
- printf(" (corrupt)");
+ ND_PRINT((ndo, " (corrupt)"));
return;
}
diff --git a/contrib/tcpdump/print-beep.c b/contrib/tcpdump/print-beep.c
index b476dbf96b61..7982feb5c362 100644
--- a/contrib/tcpdump/print-beep.c
+++ b/contrib/tcpdump/print-beep.c
@@ -9,26 +9,16 @@
*
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-beep.c,v 1.6 2003-11-16 09:36:13 guy Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#ifdef HAVE_MEMORY_H
-#include <memory.h>
-#endif
-#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
#include "interface.h"
-#include "extract.h"
/* Check for a string but not go beyond length
* Return TRUE on match, FALSE otherwise
@@ -36,8 +26,6 @@ static const char rcsid[] _U_ =
* Looks at the first few chars up to tl1 ...
*/
-static int l_strnstart(const char *, u_int, const char *, u_int);
-
static int
l_strnstart(const char *tstr1, u_int tl1, const char *str2, u_int l2)
{
@@ -49,23 +37,23 @@ l_strnstart(const char *tstr1, u_int tl1, const char *str2, u_int l2)
}
void
-beep_print(const u_char *bp, u_int length)
+beep_print(netdissect_options *ndo, const u_char *bp, u_int length)
{
if (l_strnstart("MSG", 4, (const char *)bp, length)) /* A REQuest */
- printf(" BEEP MSG");
+ ND_PRINT((ndo, " BEEP MSG"));
else if (l_strnstart("RPY ", 4, (const char *)bp, length))
- printf(" BEEP RPY");
+ ND_PRINT((ndo, " BEEP RPY"));
else if (l_strnstart("ERR ", 4, (const char *)bp, length))
- printf(" BEEP ERR");
+ ND_PRINT((ndo, " BEEP ERR"));
else if (l_strnstart("ANS ", 4, (const char *)bp, length))
- printf(" BEEP ANS");
+ ND_PRINT((ndo, " BEEP ANS"));
else if (l_strnstart("NUL ", 4, (const char *)bp, length))
- printf(" BEEP NUL");
+ ND_PRINT((ndo, " BEEP NUL"));
else if (l_strnstart("SEQ ", 4, (const char *)bp, length))
- printf(" BEEP SEQ");
+ ND_PRINT((ndo, " BEEP SEQ"));
else if (l_strnstart("END", 4, (const char *)bp, length))
- printf(" BEEP END");
+ ND_PRINT((ndo, " BEEP END"));
else
- printf(" BEEP (payload or undecoded)");
+ ND_PRINT((ndo, " BEEP (payload or undecoded)"));
}
diff --git a/contrib/tcpdump/print-bfd.c b/contrib/tcpdump/print-bfd.c
index f157684f075e..f1c2ee8cea8f 100644
--- a/contrib/tcpdump/print-bfd.c
+++ b/contrib/tcpdump/print-bfd.c
@@ -13,23 +13,15 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-bfd.c,v 1.10 2006-02-02 06:35:52 hannes Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <stdlib.h>
-
#include "interface.h"
#include "extract.h"
-#include "addrtoname.h"
#include "udp.h"
@@ -53,7 +45,7 @@ static const char rcsid[] _U_ =
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
-/*
+/*
* Control packet, BFDv1, draft-ietf-bfd-base-02.txt
*
* 0 1 2 3
@@ -74,15 +66,15 @@ static const char rcsid[] _U_ =
*/
struct bfd_header_t {
- u_int8_t version_diag;
- u_int8_t flags;
- u_int8_t detect_time_multiplier;
- u_int8_t length;
- u_int8_t my_discriminator[4];
- u_int8_t your_discriminator[4];
- u_int8_t desired_min_tx_interval[4];
- u_int8_t required_min_rx_interval[4];
- u_int8_t required_min_echo_interval[4];
+ uint8_t version_diag;
+ uint8_t flags;
+ uint8_t detect_time_multiplier;
+ uint8_t length;
+ uint8_t my_discriminator[4];
+ uint8_t your_discriminator[4];
+ uint8_t desired_min_tx_interval[4];
+ uint8_t required_min_rx_interval[4];
+ uint8_t required_min_echo_interval[4];
};
/*
@@ -96,9 +88,9 @@ struct bfd_header_t {
*/
struct bfd_auth_header_t {
- u_int8_t auth_type;
- u_int8_t auth_len;
- u_int8_t auth_data;
+ uint8_t auth_type;
+ uint8_t auth_len;
+ uint8_t auth_data;
};
static const struct tok bfd_v1_authentication_values[] = {
@@ -167,15 +159,16 @@ static const struct tok bfd_v1_state_values[] = {
};
void
-bfd_print(register const u_char *pptr, register u_int len, register u_int port)
+bfd_print(netdissect_options *ndo, register const u_char *pptr,
+ register u_int len, register u_int port)
{
const struct bfd_header_t *bfd_header;
const struct bfd_auth_header_t *bfd_auth_header;
- u_int8_t version = 0;
+ uint8_t version = 0;
bfd_header = (const struct bfd_header_t *)pptr;
if (port == BFD_CONTROL_PORT) {
- TCHECK(*bfd_header);
+ ND_TCHECK(*bfd_header);
version = BFD_EXTRACT_VERSION(bfd_header->version_diag);
} else if (port == BFD_ECHO_PORT) {
/* Echo is BFD v1 only */
@@ -185,79 +178,79 @@ bfd_print(register const u_char *pptr, register u_int len, register u_int port)
/* BFDv0 */
case (BFD_CONTROL_PORT << 8):
- if (vflag < 1 )
+ if (ndo->ndo_vflag < 1)
{
- printf("BFDv%u, %s, Flags: [%s], length: %u",
+ ND_PRINT((ndo, "BFDv%u, %s, Flags: [%s], length: %u",
version,
tok2str(bfd_port_values, "unknown (%u)", port),
bittok2str(bfd_v0_flag_values, "none", bfd_header->flags),
- len);
+ len));
return;
}
-
- printf("BFDv%u, length: %u\n\t%s, Flags: [%s], Diagnostic: %s (0x%02x)",
+
+ ND_PRINT((ndo, "BFDv%u, length: %u\n\t%s, Flags: [%s], Diagnostic: %s (0x%02x)",
version,
len,
tok2str(bfd_port_values, "unknown (%u)", port),
bittok2str(bfd_v0_flag_values, "none", bfd_header->flags),
tok2str(bfd_diag_values,"unknown",BFD_EXTRACT_DIAG(bfd_header->version_diag)),
- BFD_EXTRACT_DIAG(bfd_header->version_diag));
-
- printf("\n\tDetection Timer Multiplier: %u (%u ms Detection time), BFD Length: %u",
+ BFD_EXTRACT_DIAG(bfd_header->version_diag)));
+
+ ND_PRINT((ndo, "\n\tDetection Timer Multiplier: %u (%u ms Detection time), BFD Length: %u",
bfd_header->detect_time_multiplier,
bfd_header->detect_time_multiplier * EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000,
- bfd_header->length);
+ bfd_header->length));
- printf("\n\tMy Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->my_discriminator));
- printf(", Your Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->your_discriminator));
- printf("\n\t Desired min Tx Interval: %4u ms", EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000);
- printf("\n\t Required min Rx Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_rx_interval)/1000);
- printf("\n\t Required min Echo Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_echo_interval)/1000);
+ ND_PRINT((ndo, "\n\tMy Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->my_discriminator)));
+ ND_PRINT((ndo, ", Your Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->your_discriminator)));
+ ND_PRINT((ndo, "\n\t Desired min Tx Interval: %4u ms", EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000));
+ ND_PRINT((ndo, "\n\t Required min Rx Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_rx_interval)/1000));
+ ND_PRINT((ndo, "\n\t Required min Echo Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_echo_interval)/1000));
break;
/* BFDv1 */
case (BFD_CONTROL_PORT << 8 | 1):
- if (vflag < 1 )
+ if (ndo->ndo_vflag < 1)
{
- printf("BFDv%u, %s, State %s, Flags: [%s], length: %u",
+ ND_PRINT((ndo, "BFDv%u, %s, State %s, Flags: [%s], length: %u",
version,
tok2str(bfd_port_values, "unknown (%u)", port),
tok2str(bfd_v1_state_values, "unknown (%u)", (bfd_header->flags & 0xc0) >> 6),
bittok2str(bfd_v1_flag_values, "none", bfd_header->flags & 0x3f),
- len);
+ len));
return;
}
-
- printf("BFDv%u, length: %u\n\t%s, State %s, Flags: [%s], Diagnostic: %s (0x%02x)",
+
+ ND_PRINT((ndo, "BFDv%u, length: %u\n\t%s, State %s, Flags: [%s], Diagnostic: %s (0x%02x)",
version,
len,
tok2str(bfd_port_values, "unknown (%u)", port),
tok2str(bfd_v1_state_values, "unknown (%u)", (bfd_header->flags & 0xc0) >> 6),
bittok2str(bfd_v1_flag_values, "none", bfd_header->flags & 0x3f),
tok2str(bfd_diag_values,"unknown",BFD_EXTRACT_DIAG(bfd_header->version_diag)),
- BFD_EXTRACT_DIAG(bfd_header->version_diag));
-
- printf("\n\tDetection Timer Multiplier: %u (%u ms Detection time), BFD Length: %u",
+ BFD_EXTRACT_DIAG(bfd_header->version_diag)));
+
+ ND_PRINT((ndo, "\n\tDetection Timer Multiplier: %u (%u ms Detection time), BFD Length: %u",
bfd_header->detect_time_multiplier,
bfd_header->detect_time_multiplier * EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000,
- bfd_header->length);
+ bfd_header->length));
- printf("\n\tMy Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->my_discriminator));
- printf(", Your Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->your_discriminator));
- printf("\n\t Desired min Tx Interval: %4u ms", EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000);
- printf("\n\t Required min Rx Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_rx_interval)/1000);
- printf("\n\t Required min Echo Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_echo_interval)/1000);
+ ND_PRINT((ndo, "\n\tMy Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->my_discriminator)));
+ ND_PRINT((ndo, ", Your Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->your_discriminator)));
+ ND_PRINT((ndo, "\n\t Desired min Tx Interval: %4u ms", EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000));
+ ND_PRINT((ndo, "\n\t Required min Rx Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_rx_interval)/1000));
+ ND_PRINT((ndo, "\n\t Required min Echo Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_echo_interval)/1000));
if (bfd_header->flags & BFD_FLAG_AUTH) {
pptr += sizeof (const struct bfd_header_t);
bfd_auth_header = (const struct bfd_auth_header_t *)pptr;
- TCHECK2(*bfd_auth_header, sizeof(const struct bfd_auth_header_t));
- printf("\n\t%s (%u) Authentication, length %u present",
+ ND_TCHECK2(*bfd_auth_header, sizeof(const struct bfd_auth_header_t));
+ ND_PRINT((ndo, "\n\t%s (%u) Authentication, length %u present",
tok2str(bfd_v1_authentication_values,"Unknown",bfd_auth_header->auth_type),
bfd_auth_header->auth_type,
- bfd_auth_header->auth_len);
+ bfd_auth_header->auth_len));
}
break;
@@ -267,17 +260,23 @@ bfd_print(register const u_char *pptr, register u_int len, register u_int port)
case (BFD_ECHO_PORT << 8 | 1):
default:
- printf("BFD, %s, length: %u",
+ ND_PRINT((ndo, "BFD, %s, length: %u",
tok2str(bfd_port_values, "unknown (%u)", port),
- len);
- if (vflag >= 1) {
- if(!print_unknown_data(pptr,"\n\t",len))
- return;
+ len));
+ if (ndo->ndo_vflag >= 1) {
+ if(!print_unknown_data(ndo, pptr,"\n\t",len))
+ return;
}
break;
}
return;
trunc:
- printf("[|BFD]");
+ ND_PRINT((ndo, "[|BFD]"));
}
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
diff --git a/contrib/tcpdump/print-bgp.c b/contrib/tcpdump/print-bgp.c
index 4f7053c284c6..f5c02a1be985 100644
--- a/contrib/tcpdump/print-bgp.c
+++ b/contrib/tcpdump/print-bgp.c
@@ -30,32 +30,26 @@
* complete BGP support.
*/
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.118 2007-12-07 15:54:52 hannes Exp $";
-#endif
-
#include <tcpdump-stdinc.h>
#include <stdio.h>
#include <string.h>
#include "interface.h"
-#include "decode_prefix.h"
#include "addrtoname.h"
#include "extract.h"
-#include "bgp.h"
#include "af.h"
#include "l2vpn.h"
struct bgp {
- u_int8_t bgp_marker[16];
- u_int16_t bgp_len;
- u_int8_t bgp_type;
+ uint8_t bgp_marker[16];
+ uint16_t bgp_len;
+ uint8_t bgp_type;
};
#define BGP_SIZE 19 /* unaligned */
@@ -65,7 +59,7 @@ struct bgp {
#define BGP_KEEPALIVE 4
#define BGP_ROUTE_REFRESH 5
-static struct tok bgp_msg_values[] = {
+static const struct tok bgp_msg_values[] = {
{ BGP_OPEN, "Open"},
{ BGP_UPDATE, "Update"},
{ BGP_NOTIFICATION, "Notification"},
@@ -75,43 +69,43 @@ static struct tok bgp_msg_values[] = {
};
struct bgp_open {
- u_int8_t bgpo_marker[16];
- u_int16_t bgpo_len;
- u_int8_t bgpo_type;
- u_int8_t bgpo_version;
- u_int16_t bgpo_myas;
- u_int16_t bgpo_holdtime;
- u_int32_t bgpo_id;
- u_int8_t bgpo_optlen;
+ uint8_t bgpo_marker[16];
+ uint16_t bgpo_len;
+ uint8_t bgpo_type;
+ uint8_t bgpo_version;
+ uint16_t bgpo_myas;
+ uint16_t bgpo_holdtime;
+ uint32_t bgpo_id;
+ uint8_t bgpo_optlen;
/* options should follow */
};
#define BGP_OPEN_SIZE 29 /* unaligned */
struct bgp_opt {
- u_int8_t bgpopt_type;
- u_int8_t bgpopt_len;
+ uint8_t bgpopt_type;
+ uint8_t bgpopt_len;
/* variable length */
};
#define BGP_OPT_SIZE 2 /* some compilers may pad to 4 bytes */
#define BGP_CAP_HEADER_SIZE 2 /* some compilers may pad to 4 bytes */
struct bgp_notification {
- u_int8_t bgpn_marker[16];
- u_int16_t bgpn_len;
- u_int8_t bgpn_type;
- u_int8_t bgpn_major;
- u_int8_t bgpn_minor;
+ uint8_t bgpn_marker[16];
+ uint16_t bgpn_len;
+ uint8_t bgpn_type;
+ uint8_t bgpn_major;
+ uint8_t bgpn_minor;
};
#define BGP_NOTIFICATION_SIZE 21 /* unaligned */
struct bgp_route_refresh {
- u_int8_t bgp_marker[16];
- u_int16_t len;
- u_int8_t type;
- u_int8_t afi[2]; /* the compiler messes this structure up */
- u_int8_t res; /* when doing misaligned sequences of int8 and int16 */
- u_int8_t safi; /* afi should be int16 - so we have to access it using */
-}; /* EXTRACT_16BITS(&bgp_route_refresh->afi) (sigh) */
+ uint8_t bgp_marker[16];
+ uint16_t len;
+ uint8_t type;
+ uint8_t afi[2]; /* the compiler messes this structure up */
+ uint8_t res; /* when doing misaligned sequences of int8 and int16 */
+ uint8_t safi; /* afi should be int16 - so we have to access it using */
+}; /* EXTRACT_16BITS(&bgp_route_refresh->afi) (sigh) */
#define BGP_ROUTE_REFRESH_SIZE 23
#define bgp_attr_lenlen(flags, p) \
@@ -142,7 +136,7 @@ struct bgp_route_refresh {
#define BGP_MP_NLRI_MINSIZE 3 /* End of RIB Marker detection */
-static struct tok bgp_attr_values[] = {
+static const struct tok bgp_attr_values[] = {
{ BGPTYPE_ORIGIN, "Origin"},
{ BGPTYPE_AS_PATH, "AS Path"},
{ BGPTYPE_AS4_PATH, "AS4 Path"},
@@ -175,7 +169,7 @@ static struct tok bgp_attr_values[] = {
#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[] = {
+static const struct tok bgp_as_path_segment_open_values[] = {
{ BGP_AS_SEQUENCE, ""},
{ BGP_AS_SET, "{ "},
{ BGP_CONFED_AS_SEQUENCE, "( "},
@@ -183,7 +177,7 @@ static struct tok bgp_as_path_segment_open_values[] = {
{ 0, NULL}
};
-static struct tok bgp_as_path_segment_close_values[] = {
+static const struct tok bgp_as_path_segment_close_values[] = {
{ BGP_AS_SEQUENCE, ""},
{ BGP_AS_SET, "}"},
{ BGP_CONFED_AS_SEQUENCE, ")"},
@@ -195,7 +189,7 @@ static struct tok bgp_as_path_segment_close_values[] = {
#define BGP_OPT_CAP 2
-static struct tok bgp_opt_values[] = {
+static const struct tok bgp_opt_values[] = {
{ BGP_OPT_AUTH, "Authentication Information"},
{ BGP_OPT_CAP, "Capabilities Advertisement"},
{ 0, NULL}
@@ -209,7 +203,7 @@ static struct tok bgp_opt_values[] = {
#define BGP_CAPCODE_DYN_CAP 67 /* XXX */
#define BGP_CAPCODE_RR_CISCO 128
-static struct tok bgp_capcode_values[] = {
+static const struct tok bgp_capcode_values[] = {
{ BGP_CAPCODE_MP, "Multiprotocol Extensions"},
{ BGP_CAPCODE_RR, "Route Refresh"},
{ BGP_CAPCODE_ORF, "Cooperative Route Filtering"},
@@ -228,7 +222,7 @@ static struct tok bgp_capcode_values[] = {
#define BGP_NOTIFY_MAJOR_CEASE 6
#define BGP_NOTIFY_MAJOR_CAP 7
-static struct tok bgp_notify_major_values[] = {
+static const struct tok bgp_notify_major_values[] = {
{ BGP_NOTIFY_MAJOR_MSG, "Message Header Error"},
{ BGP_NOTIFY_MAJOR_OPEN, "OPEN Message Error"},
{ BGP_NOTIFY_MAJOR_UPDATE, "UPDATE Message Error"},
@@ -241,7 +235,7 @@ static struct tok bgp_notify_major_values[] = {
/* draft-ietf-idr-cease-subcode-02 */
#define BGP_NOTIFY_MINOR_CEASE_MAXPRFX 1
-static struct tok bgp_notify_minor_cease_values[] = {
+static const struct tok bgp_notify_minor_cease_values[] = {
{ BGP_NOTIFY_MINOR_CEASE_MAXPRFX, "Maximum Number of Prefixes Reached"},
{ 2, "Administratively Shutdown"},
{ 3, "Peer Unconfigured"},
@@ -252,14 +246,14 @@ static struct tok bgp_notify_minor_cease_values[] = {
{ 0, NULL}
};
-static struct tok bgp_notify_minor_msg_values[] = {
+static const struct tok bgp_notify_minor_msg_values[] = {
{ 1, "Connection Not Synchronized"},
{ 2, "Bad Message Length"},
{ 3, "Bad Message Type"},
{ 0, NULL}
};
-static struct tok bgp_notify_minor_open_values[] = {
+static const struct tok bgp_notify_minor_open_values[] = {
{ 1, "Unsupported Version Number"},
{ 2, "Bad Peer AS"},
{ 3, "Bad BGP Identifier"},
@@ -270,7 +264,7 @@ static struct tok bgp_notify_minor_open_values[] = {
{ 0, NULL}
};
-static struct tok bgp_notify_minor_update_values[] = {
+static const struct tok bgp_notify_minor_update_values[] = {
{ 1, "Malformed Attribute List"},
{ 2, "Unrecognized Well-known Attribute"},
{ 3, "Missing Well-known Attribute"},
@@ -285,7 +279,7 @@ static struct tok bgp_notify_minor_update_values[] = {
{ 0, NULL}
};
-static struct tok bgp_notify_minor_cap_values[] = {
+static const struct tok bgp_notify_minor_cap_values[] = {
{ 1, "Invalid Action Value" },
{ 2, "Invalid Capability Length" },
{ 3, "Malformed Capability Value" },
@@ -293,7 +287,7 @@ static struct tok bgp_notify_minor_cap_values[] = {
{ 0, NULL }
};
-static struct tok bgp_origin_values[] = {
+static const struct tok bgp_origin_values[] = {
{ 0, "IGP"},
{ 1, "EGP"},
{ 2, "Incomplete"},
@@ -308,7 +302,7 @@ static struct tok bgp_origin_values[] = {
#define BGP_PMSI_TUNNEL_INGRESS 6
#define BGP_PMSI_TUNNEL_LDP_MP2MP 7
-static struct tok bgp_pmsi_tunnel_values[] = {
+static const 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"},
@@ -319,7 +313,7 @@ static struct tok bgp_pmsi_tunnel_values[] = {
{ 0, NULL}
};
-static struct tok bgp_pmsi_flag_values[] = {
+static const struct tok bgp_pmsi_flag_values[] = {
{ 0x01, "Leaf Information required"},
{ 0, NULL}
};
@@ -347,7 +341,7 @@ static struct tok bgp_pmsi_flag_values[] = {
#define BGP_VPN_RD_LEN 8
-static struct tok bgp_safi_values[] = {
+static const struct tok bgp_safi_values[] = {
{ SAFNUM_RES, "Reserved"},
{ SAFNUM_UNICAST, "Unicast"},
{ SAFNUM_MULTICAST, "Multicast"},
@@ -387,7 +381,7 @@ static struct tok bgp_safi_values[] = {
#define BGP_EXT_COM_OSPF_RTYPE2 0x8000 /* duplicate - keep for backwards compatability */
#define BGP_EXT_COM_OSPF_RID 0x0107 /* OSPF Router ID,Format RouterID(4B):Unused(2B) */
-#define BGP_EXT_COM_OSPF_RID2 0x8001 /* duplicate - keep for backwards compatability */
+#define BGP_EXT_COM_OSPF_RID2 0x8001 /* duplicate - keep for backwards compatability */
#define BGP_EXT_COM_L2INFO 0x800a /* draft-kompella-ppvpn-l2vpn */
@@ -405,13 +399,13 @@ static struct tok bgp_safi_values[] = {
#define BGP_EXT_COM_EIGRP_EXT_REMAS_REMID 0x8804
#define BGP_EXT_COM_EIGRP_EXT_REMPROTO_REMMETRIC 0x8805
-static struct tok bgp_extd_comm_flag_values[] = {
+static const struct tok bgp_extd_comm_flag_values[] = {
{ 0x8000, "vendor-specific"},
{ 0x4000, "non-transitive"},
{ 0, NULL},
};
-static struct tok bgp_extd_comm_subtype_values[] = {
+static const struct tok bgp_extd_comm_subtype_values[] = {
{ BGP_EXT_COM_RT_0, "target"},
{ BGP_EXT_COM_RT_1, "target"},
{ BGP_EXT_COM_RT_2, "target"},
@@ -427,7 +421,7 @@ static struct tok bgp_extd_comm_subtype_values[] = {
{ BGP_EXT_COM_OSPF_RTYPE2, "ospf-route-type"},
{ BGP_EXT_COM_OSPF_RID, "ospf-router-id"},
{ BGP_EXT_COM_OSPF_RID2, "ospf-router-id"},
- { BGP_EXT_COM_L2INFO, "layer2-info"},
+ { BGP_EXT_COM_L2INFO, "layer2-info"},
{ BGP_EXT_COM_EIGRP_GEN , "eigrp-general-route (flag, tag)" },
{ BGP_EXT_COM_EIGRP_METRIC_AS_DELAY , "eigrp-route-metric (AS, delay)" },
{ BGP_EXT_COM_EIGRP_METRIC_REL_NH_BW , "eigrp-route-metric (reliability, nexthop, bandwidth)" },
@@ -450,13 +444,13 @@ static struct tok bgp_extd_comm_subtype_values[] = {
#define BGP_OSPF_RTYPE_SHAM 129 /* OSPF-MPLS-VPN Sham link */
#define BGP_OSPF_RTYPE_METRIC_TYPE 0x1 /* LSB of RTYPE Options Field */
-static struct tok bgp_extd_comm_ospf_rtype_values[] = {
- { BGP_OSPF_RTYPE_RTR, "Router" },
- { BGP_OSPF_RTYPE_NET, "Network" },
- { BGP_OSPF_RTYPE_SUM, "Summary" },
- { BGP_OSPF_RTYPE_EXT, "External" },
+static const struct tok bgp_extd_comm_ospf_rtype_values[] = {
+ { BGP_OSPF_RTYPE_RTR, "Router" },
+ { BGP_OSPF_RTYPE_NET, "Network" },
+ { BGP_OSPF_RTYPE_SUM, "Summary" },
+ { BGP_OSPF_RTYPE_EXT, "External" },
{ BGP_OSPF_RTYPE_NSSA,"NSSA External" },
- { BGP_OSPF_RTYPE_SHAM,"MPLS-VPN Sham" },
+ { BGP_OSPF_RTYPE_SHAM,"MPLS-VPN Sham" },
{ 0, NULL },
};
@@ -468,14 +462,15 @@ static char astostr[20];
*
* Convert an AS number into a string and return string pointer.
*
- * Bepending on bflag is set or not, AS number is converted into ASDOT notation
+ * Depending on bflag is set or not, AS number is converted into ASDOT notation
* or plain number notation.
*
*/
static char *
-as_printf (char *str, int size, u_int asnum)
+as_printf(netdissect_options *ndo,
+ char *str, int size, u_int asnum)
{
- if (!bflag || asnum <= 0xFFFF) {
+ if (!ndo->ndo_bflag || asnum <= 0xFFFF) {
snprintf(str, size, "%u", asnum);
} else {
snprintf(str, size, "%u.%u", asnum >> 16, asnum & 0xFFFF);
@@ -486,12 +481,13 @@ as_printf (char *str, int size, u_int asnum)
#define ITEMCHECK(minlen) if (itemlen < minlen) goto badtlv;
int
-decode_prefix4(const u_char *pptr, u_int itemlen, char *buf, u_int buflen)
+decode_prefix4(netdissect_options *ndo,
+ const u_char *pptr, u_int itemlen, char *buf, u_int buflen)
{
struct in_addr addr;
u_int plen, plenbytes;
- TCHECK(pptr[0]);
+ ND_TCHECK(pptr[0]);
ITEMCHECK(1);
plen = pptr[0];
if (32 < plen)
@@ -500,14 +496,14 @@ decode_prefix4(const u_char *pptr, u_int itemlen, char *buf, u_int buflen)
memset(&addr, 0, sizeof(addr));
plenbytes = (plen + 7) / 8;
- TCHECK2(pptr[1], plenbytes);
+ ND_TCHECK2(pptr[1], plenbytes);
ITEMCHECK(plenbytes);
memcpy(&addr, &pptr[1], plenbytes);
if (plen % 8) {
((u_char *)&addr)[plenbytes - 1] &=
((0xff00 >> (plen % 8)) & 0xff);
}
- snprintf(buf, buflen, "%s/%d", getname((u_char *)&addr), plen);
+ snprintf(buf, buflen, "%s/%d", getname(ndo, (u_char *)&addr), plen);
return 1 + plenbytes;
trunc:
@@ -518,13 +514,14 @@ badtlv:
}
static int
-decode_labeled_prefix4(const u_char *pptr, u_int itemlen, char *buf, u_int buflen)
+decode_labeled_prefix4(netdissect_options *ndo,
+ const u_char *pptr, u_int itemlen, char *buf, u_int buflen)
{
struct in_addr addr;
u_int plen, plenbytes;
/* prefix length and label = 4 bytes */
- TCHECK2(pptr[0], 4);
+ ND_TCHECK2(pptr[0], 4);
ITEMCHECK(4);
plen = pptr[0]; /* get prefix length */
@@ -547,7 +544,7 @@ decode_labeled_prefix4(const u_char *pptr, u_int itemlen, char *buf, u_int bufle
memset(&addr, 0, sizeof(addr));
plenbytes = (plen + 7) / 8;
- TCHECK2(pptr[4], plenbytes);
+ ND_TCHECK2(pptr[4], plenbytes);
ITEMCHECK(plenbytes);
memcpy(&addr, &pptr[4], plenbytes);
if (plen % 8) {
@@ -556,7 +553,7 @@ decode_labeled_prefix4(const u_char *pptr, u_int itemlen, char *buf, u_int bufle
}
/* the label may get offsetted by 4 bits so lets shift it right */
snprintf(buf, buflen, "%s/%d, label:%u %s",
- getname((u_char *)&addr),
+ getname(ndo, (u_char *)&addr),
plen,
EXTRACT_24BITS(pptr+1)>>4,
((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
@@ -576,7 +573,8 @@ badtlv:
* 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) {
+bgp_vpn_ip_print(netdissect_options *ndo,
+ 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")];
@@ -584,13 +582,13 @@ bgp_vpn_ip_print (const u_char *pptr, u_int addr_length) {
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));
+ ND_TCHECK2(pptr[0], sizeof(struct in_addr));
+ snprintf(pos, sizeof(addr), "%s", ipaddr_string(ndo, 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));
+ ND_TCHECK2(pptr[0], sizeof(struct in6_addr));
+ snprintf(pos, sizeof(addr), "%s", ip6addr_string(ndo, pptr));
break;
#endif
default:
@@ -623,38 +621,39 @@ trunc:
* return the number of bytes read from the wire.
*/
static int
-bgp_vpn_sg_print (const u_char *pptr, char *buf, u_int buflen) {
+bgp_vpn_sg_print(netdissect_options *ndo,
+ const u_char *pptr, char *buf, u_int buflen) {
- u_int8_t addr_length;
+ uint8_t addr_length;
u_int total_length, offset;
total_length = 0;
/* Source address length, encoded in bits */
- TCHECK2(pptr[0], 1);
+ ND_TCHECK2(pptr[0], 1);
addr_length = *pptr++;
/* Source address */
- TCHECK2(pptr[0], (addr_length >> 3));
+ ND_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));
+ bgp_vpn_ip_print(ndo, pptr, addr_length));
pptr += (addr_length >> 3);
}
-
+
/* Group address length, encoded in bits */
- TCHECK2(pptr[0], 1);
+ ND_TCHECK2(pptr[0], 1);
addr_length = *pptr++;
/* Group address */
- TCHECK2(pptr[0], (addr_length >> 3));
+ ND_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));
+ bgp_vpn_ip_print(ndo, pptr, addr_length));
pptr += (addr_length >> 3);
}
@@ -667,7 +666,8 @@ trunc:
* we use bgp_vpn_rd_print for
* printing route targets inside a NLRI */
char *
-bgp_vpn_rd_print (const u_char *pptr) {
+bgp_vpn_rd_print(netdissect_options *ndo,
+ const u_char *pptr) {
/* allocate space for the largest possible string */
static char rd[sizeof("xxxxxxxxxx:xxxxx (xxx.xxx.xxx.xxx:xxxxx)")];
@@ -693,7 +693,7 @@ bgp_vpn_rd_print (const u_char *pptr) {
/* 4-byte-AS:number fmt*/
case 2:
snprintf(pos, sizeof(rd) - (pos - rd), "%s:%u (%u.%u.%u.%u:%u)",
- as_printf(astostr, sizeof(astostr), EXTRACT_32BITS(pptr+2)),
+ as_printf(ndo, astostr, sizeof(astostr), EXTRACT_32BITS(pptr+2)),
EXTRACT_16BITS(pptr+6), *(pptr+2), *(pptr+3), *(pptr+4),
*(pptr+5), EXTRACT_16BITS(pptr+6));
break;
@@ -707,12 +707,13 @@ bgp_vpn_rd_print (const u_char *pptr) {
}
static int
-decode_rt_routing_info(const u_char *pptr, char *buf, u_int buflen)
+decode_rt_routing_info(netdissect_options *ndo,
+ const u_char *pptr, char *buf, u_int buflen)
{
- u_int8_t route_target[8];
+ uint8_t route_target[8];
u_int plen;
- TCHECK(pptr[0]);
+ ND_TCHECK(pptr[0]);
plen = pptr[0]; /* get prefix length */
if (0 == plen)
@@ -727,15 +728,15 @@ decode_rt_routing_info(const u_char *pptr, char *buf, u_int buflen)
return -1;
memset(&route_target, 0, sizeof(route_target));
- TCHECK2(pptr[1], (plen + 7) / 8);
+ ND_TCHECK2(pptr[1], (plen + 7) / 8);
memcpy(&route_target, &pptr[1], (plen + 7) / 8);
if (plen % 8) {
((u_char *)&route_target)[(plen + 7) / 8 - 1] &=
((0xff00 >> (plen % 8)) & 0xff);
}
snprintf(buf, buflen, "origin AS: %s, route target %s",
- as_printf(astostr, sizeof(astostr), EXTRACT_32BITS(pptr+1)),
- bgp_vpn_rd_print((u_char *)&route_target));
+ as_printf(ndo, astostr, sizeof(astostr), EXTRACT_32BITS(pptr+1)),
+ bgp_vpn_rd_print(ndo, (u_char *)&route_target));
return 5 + (plen + 7) / 8;
@@ -744,12 +745,13 @@ trunc:
}
static int
-decode_labeled_vpn_prefix4(const u_char *pptr, char *buf, u_int buflen)
+decode_labeled_vpn_prefix4(netdissect_options *ndo,
+ const u_char *pptr, char *buf, u_int buflen)
{
struct in_addr addr;
u_int plen;
- TCHECK(pptr[0]);
+ ND_TCHECK(pptr[0]);
plen = pptr[0]; /* get prefix length */
if ((24+64) > plen)
@@ -761,7 +763,7 @@ decode_labeled_vpn_prefix4(const u_char *pptr, char *buf, u_int buflen)
return -1;
memset(&addr, 0, sizeof(addr));
- TCHECK2(pptr[12], (plen + 7) / 8);
+ ND_TCHECK2(pptr[12], (plen + 7) / 8);
memcpy(&addr, &pptr[12], (plen + 7) / 8);
if (plen % 8) {
((u_char *)&addr)[(plen + 7) / 8 - 1] &=
@@ -769,8 +771,8 @@ decode_labeled_vpn_prefix4(const u_char *pptr, char *buf, u_int buflen)
}
/* the label may get offsetted by 4 bits so lets shift it right */
snprintf(buf, buflen, "RD: %s, %s/%d, label:%u %s",
- bgp_vpn_rd_print(pptr+4),
- getname((u_char *)&addr),
+ bgp_vpn_rd_print(ndo, pptr+4),
+ getname(ndo, (u_char *)&addr),
plen,
EXTRACT_24BITS(pptr+1)>>4,
((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
@@ -794,35 +796,36 @@ trunc:
#define MDT_VPN_NLRI_LEN 16
static int
-decode_mdt_vpn_nlri(const u_char *pptr, char *buf, u_int buflen)
+decode_mdt_vpn_nlri(netdissect_options *ndo,
+ const u_char *pptr, char *buf, u_int buflen)
{
const u_char *rd;
const u_char *vpn_ip;
-
- TCHECK(pptr[0]);
+
+ ND_TCHECK(pptr[0]);
/* if the NLRI is not predefined length, quit.*/
- if (*pptr != MDT_VPN_NLRI_LEN * NBBY)
+ if (*pptr != MDT_VPN_NLRI_LEN * 8)
return -1;
pptr++;
/* RD */
- TCHECK2(pptr[0], 8);
+ ND_TCHECK2(pptr[0], 8);
rd = pptr;
pptr+=8;
/* IPv4 address */
- TCHECK2(pptr[0], sizeof(struct in_addr));
+ ND_TCHECK2(pptr[0], sizeof(struct in_addr));
vpn_ip = pptr;
pptr+=sizeof(struct in_addr);
/* MDT Group Address */
- TCHECK2(pptr[0], sizeof(struct in_addr));
+ ND_TCHECK2(pptr[0], sizeof(struct in_addr));
snprintf(buf, buflen, "RD: %s, VPN IP Address: %s, MC Group Address: %s",
- bgp_vpn_rd_print(rd), ipaddr_string(vpn_ip), ipaddr_string(pptr));
-
+ bgp_vpn_rd_print(ndo, rd), ipaddr_string(ndo, vpn_ip), ipaddr_string(ndo, pptr));
+
return MDT_VPN_NLRI_LEN + 1;
trunc:
@@ -838,7 +841,7 @@ return -2;
#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[] = {
+static const 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"},
@@ -849,12 +852,13 @@ static struct tok bgp_multicast_vpn_route_type_values[] = {
};
static int
-decode_multicast_vpn(const u_char *pptr, char *buf, u_int buflen)
+decode_multicast_vpn(netdissect_options *ndo,
+ const u_char *pptr, char *buf, u_int buflen)
{
- u_int8_t route_type, route_length, addr_length, sg_length;
+ uint8_t route_type, route_length, addr_length, sg_length;
u_int offset;
- TCHECK2(pptr[0], 2);
+ ND_TCHECK2(pptr[0], 2);
route_type = *pptr++;
route_length = *pptr++;
@@ -865,59 +869,59 @@ decode_multicast_vpn(const u_char *pptr, char *buf, u_int buflen)
switch(route_type) {
case BGP_MULTICAST_VPN_ROUTE_TYPE_INTRA_AS_I_PMSI:
- TCHECK2(pptr[0], BGP_VPN_RD_LEN);
+ ND_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,
+ bgp_vpn_rd_print(ndo, pptr),
+ bgp_vpn_ip_print(ndo, 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);
+ ND_TCHECK2(pptr[0], BGP_VPN_RD_LEN + 4);
offset = strlen(buf);
snprintf(buf + offset, buflen - offset, ", RD: %s, Source-AS %s",
- bgp_vpn_rd_print(pptr),
- as_printf(astostr, sizeof(astostr),
+ bgp_vpn_rd_print(ndo, pptr),
+ as_printf(ndo, astostr, sizeof(astostr),
EXTRACT_32BITS(pptr + BGP_VPN_RD_LEN)));
break;
case BGP_MULTICAST_VPN_ROUTE_TYPE_S_PMSI:
- TCHECK2(pptr[0], BGP_VPN_RD_LEN);
+ ND_TCHECK2(pptr[0], BGP_VPN_RD_LEN);
offset = strlen(buf);
snprintf(buf + offset, buflen - offset, ", RD: %s",
- bgp_vpn_rd_print(pptr));
+ bgp_vpn_rd_print(ndo, pptr));
pptr += BGP_VPN_RD_LEN;
- sg_length = bgp_vpn_sg_print(pptr, buf, buflen);
+ sg_length = bgp_vpn_sg_print(ndo, pptr, buf, buflen);
addr_length = route_length - sg_length;
- TCHECK2(pptr[0], addr_length);
+ ND_TCHECK2(pptr[0], addr_length);
offset = strlen(buf);
snprintf(buf + offset, buflen - offset, ", Originator %s",
- bgp_vpn_ip_print(pptr, addr_length << 3));
+ bgp_vpn_ip_print(ndo, pptr, addr_length << 3));
break;
case BGP_MULTICAST_VPN_ROUTE_TYPE_SOURCE_ACTIVE:
- TCHECK2(pptr[0], BGP_VPN_RD_LEN);
+ ND_TCHECK2(pptr[0], BGP_VPN_RD_LEN);
offset = strlen(buf);
snprintf(buf + offset, buflen - offset, ", RD: %s",
- bgp_vpn_rd_print(pptr));
+ bgp_vpn_rd_print(ndo, pptr));
pptr += BGP_VPN_RD_LEN;
- bgp_vpn_sg_print(pptr, buf, buflen);
+ bgp_vpn_sg_print(ndo, 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);
+ ND_TCHECK2(pptr[0], BGP_VPN_RD_LEN);
offset = strlen(buf);
snprintf(buf + offset, buflen - offset, ", RD: %s, Source-AS %s",
- bgp_vpn_rd_print(pptr),
- as_printf(astostr, sizeof(astostr),
+ bgp_vpn_rd_print(ndo, pptr),
+ as_printf(ndo, astostr, sizeof(astostr),
EXTRACT_32BITS(pptr + BGP_VPN_RD_LEN)));
pptr += BGP_VPN_RD_LEN;
- bgp_vpn_sg_print(pptr, buf, buflen);
+ bgp_vpn_sg_print(ndo, pptr, buf, buflen);
break;
/*
@@ -955,11 +959,12 @@ trunc:
}
static int
-decode_labeled_vpn_l2(const u_char *pptr, char *buf, u_int buflen)
+decode_labeled_vpn_l2(netdissect_options *ndo,
+ const u_char *pptr, char *buf, u_int buflen)
{
int plen,tlen,strlen,tlv_type,tlv_len,ttlv_len;
- TCHECK2(pptr[0], 2);
+ ND_TCHECK2(pptr[0], 2);
plen=EXTRACT_16BITS(pptr);
tlen=plen;
pptr+=2;
@@ -967,27 +972,27 @@ decode_labeled_vpn_l2(const u_char *pptr, char *buf, u_int buflen)
* -> Assume a 12 Byte-length NLRI is auto-discovery-only
* and > 17 as old format. Complain for the middle case
*/
- if (plen==12) {
+ if (plen==12) {
/* assume AD-only with RD, BGPNH */
- TCHECK2(pptr[0],12);
+ ND_TCHECK2(pptr[0],12);
buf[0]='\0';
strlen=snprintf(buf, buflen, "RD: %s, BGPNH: %s",
- bgp_vpn_rd_print(pptr),
- /* need something like getname() here */
- getname(pptr+8)
+ bgp_vpn_rd_print(ndo, pptr),
+ /* need something like getname(ndo, ) here */
+ getname(ndo, pptr+8)
);
UPDATE_BUF_BUFLEN(buf, buflen, strlen);
pptr+=12;
tlen-=12;
return plen;
- } else if (plen>17) {
+ } else if (plen>17) {
/* assume old format */
/* RD, ID, LBLKOFF, LBLBASE */
- TCHECK2(pptr[0],15);
+ ND_TCHECK2(pptr[0],15);
buf[0]='\0';
strlen=snprintf(buf, buflen, "RD: %s, CE-ID: %u, Label-Block Offset: %u, Label Base %u",
- bgp_vpn_rd_print(pptr),
+ bgp_vpn_rd_print(ndo, pptr),
EXTRACT_16BITS(pptr+8),
EXTRACT_16BITS(pptr+10),
EXTRACT_24BITS(pptr+12)>>4); /* the label is offsetted by 4 bits so lets shift it right */
@@ -999,7 +1004,7 @@ decode_labeled_vpn_l2(const u_char *pptr, char *buf, u_int buflen)
while (tlen>0) {
if (tlen < 3)
return -1;
- TCHECK2(pptr[0], 3);
+ ND_TCHECK2(pptr[0], 3);
tlv_type=*pptr++;
tlv_len=EXTRACT_16BITS(pptr);
ttlv_len=tlv_len;
@@ -1015,7 +1020,7 @@ decode_labeled_vpn_l2(const u_char *pptr, char *buf, u_int buflen)
}
ttlv_len=ttlv_len/8+1; /* how many bytes do we need to read ? */
while (ttlv_len>0) {
- TCHECK(pptr[0]);
+ ND_TCHECK(pptr[0]);
if (buflen!=0) {
strlen=snprintf(buf,buflen, "%02x",*pptr++);
UPDATE_BUF_BUFLEN(buf, buflen, strlen);
@@ -1035,7 +1040,7 @@ decode_labeled_vpn_l2(const u_char *pptr, char *buf, u_int buflen)
tlen-=(tlv_len<<3); /* the tlv-length is expressed in bits so lets shift it right */
}
return plen+2;
-
+
} else {
/* complain bitterly ? */
/* fall through */
@@ -1048,12 +1053,13 @@ trunc:
#ifdef INET6
int
-decode_prefix6(const u_char *pd, u_int itemlen, char *buf, u_int buflen)
+decode_prefix6(netdissect_options *ndo,
+ const u_char *pd, u_int itemlen, char *buf, u_int buflen)
{
struct in6_addr addr;
u_int plen, plenbytes;
- TCHECK(pd[0]);
+ ND_TCHECK(pd[0]);
ITEMCHECK(1);
plen = pd[0];
if (128 < plen)
@@ -1062,14 +1068,14 @@ decode_prefix6(const u_char *pd, u_int itemlen, char *buf, u_int buflen)
memset(&addr, 0, sizeof(addr));
plenbytes = (plen + 7) / 8;
- TCHECK2(pd[1], plenbytes);
+ ND_TCHECK2(pd[1], plenbytes);
ITEMCHECK(plenbytes);
memcpy(&addr, &pd[1], plenbytes);
if (plen % 8) {
addr.s6_addr[plenbytes - 1] &=
((0xff00 >> (plen % 8)) & 0xff);
}
- snprintf(buf, buflen, "%s/%d", getname6((u_char *)&addr), plen);
+ snprintf(buf, buflen, "%s/%d", getname6(ndo, (u_char *)&addr), plen);
return 1 + plenbytes;
trunc:
@@ -1080,13 +1086,14 @@ badtlv:
}
static int
-decode_labeled_prefix6(const u_char *pptr, u_int itemlen, char *buf, u_int buflen)
+decode_labeled_prefix6(netdissect_options *ndo,
+ const u_char *pptr, u_int itemlen, char *buf, u_int buflen)
{
struct in6_addr addr;
u_int plen, plenbytes;
/* prefix length and label = 4 bytes */
- TCHECK2(pptr[0], 4);
+ ND_TCHECK2(pptr[0], 4);
ITEMCHECK(4);
plen = pptr[0]; /* get prefix length */
@@ -1101,7 +1108,7 @@ decode_labeled_prefix6(const u_char *pptr, u_int itemlen, char *buf, u_int bufle
memset(&addr, 0, sizeof(addr));
plenbytes = (plen + 7) / 8;
- TCHECK2(pptr[4], plenbytes);
+ ND_TCHECK2(pptr[4], plenbytes);
memcpy(&addr, &pptr[4], plenbytes);
if (plen % 8) {
addr.s6_addr[plenbytes - 1] &=
@@ -1109,7 +1116,7 @@ decode_labeled_prefix6(const u_char *pptr, u_int itemlen, char *buf, u_int bufle
}
/* the label may get offsetted by 4 bits so lets shift it right */
snprintf(buf, buflen, "%s/%d, label:%u %s",
- getname6((u_char *)&addr),
+ getname6(ndo, (u_char *)&addr),
plen,
EXTRACT_24BITS(pptr+1)>>4,
((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
@@ -1124,12 +1131,13 @@ badtlv:
}
static int
-decode_labeled_vpn_prefix6(const u_char *pptr, char *buf, u_int buflen)
+decode_labeled_vpn_prefix6(netdissect_options *ndo,
+ const u_char *pptr, char *buf, u_int buflen)
{
struct in6_addr addr;
u_int plen;
- TCHECK(pptr[0]);
+ ND_TCHECK(pptr[0]);
plen = pptr[0]; /* get prefix length */
if ((24+64) > plen)
@@ -1141,7 +1149,7 @@ decode_labeled_vpn_prefix6(const u_char *pptr, char *buf, u_int buflen)
return -1;
memset(&addr, 0, sizeof(addr));
- TCHECK2(pptr[12], (plen + 7) / 8);
+ ND_TCHECK2(pptr[12], (plen + 7) / 8);
memcpy(&addr, &pptr[12], (plen + 7) / 8);
if (plen % 8) {
addr.s6_addr[(plen + 7) / 8 - 1] &=
@@ -1149,8 +1157,8 @@ decode_labeled_vpn_prefix6(const u_char *pptr, char *buf, u_int buflen)
}
/* the label may get offsetted by 4 bits so lets shift it right */
snprintf(buf, buflen, "RD: %s, %s/%d, label:%u %s",
- bgp_vpn_rd_print(pptr+4),
- getname6((u_char *)&addr),
+ bgp_vpn_rd_print(ndo, pptr+4),
+ getname6(ndo, (u_char *)&addr),
plen,
EXTRACT_24BITS(pptr+1)>>4,
((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
@@ -1163,19 +1171,20 @@ trunc:
#endif
static int
-decode_clnp_prefix(const u_char *pptr, char *buf, u_int buflen)
+decode_clnp_prefix(netdissect_options *ndo,
+ const u_char *pptr, char *buf, u_int buflen)
{
- u_int8_t addr[19];
+ uint8_t addr[19];
u_int plen;
- TCHECK(pptr[0]);
+ ND_TCHECK(pptr[0]);
plen = pptr[0]; /* get prefix length */
if (152 < plen)
return -1;
memset(&addr, 0, sizeof(addr));
- TCHECK2(pptr[4], (plen + 7) / 8);
+ ND_TCHECK2(pptr[4], (plen + 7) / 8);
memcpy(&addr, &pptr[4], (plen + 7) / 8);
if (plen % 8) {
addr[(plen + 7) / 8 - 1] &=
@@ -1192,12 +1201,13 @@ trunc:
}
static int
-decode_labeled_vpn_clnp_prefix(const u_char *pptr, char *buf, u_int buflen)
+decode_labeled_vpn_clnp_prefix(netdissect_options *ndo,
+ const u_char *pptr, char *buf, u_int buflen)
{
- u_int8_t addr[19];
+ uint8_t addr[19];
u_int plen;
- TCHECK(pptr[0]);
+ ND_TCHECK(pptr[0]);
plen = pptr[0]; /* get prefix length */
if ((24+64) > plen)
@@ -1209,7 +1219,7 @@ decode_labeled_vpn_clnp_prefix(const u_char *pptr, char *buf, u_int buflen)
return -1;
memset(&addr, 0, sizeof(addr));
- TCHECK2(pptr[12], (plen + 7) / 8);
+ ND_TCHECK2(pptr[12], (plen + 7) / 8);
memcpy(&addr, &pptr[12], (plen + 7) / 8);
if (plen % 8) {
addr[(plen + 7) / 8 - 1] &=
@@ -1217,7 +1227,7 @@ decode_labeled_vpn_clnp_prefix(const u_char *pptr, char *buf, u_int buflen)
}
/* the label may get offsetted by 4 bits so lets shift it right */
snprintf(buf, buflen, "RD: %s, %s/%d, label:%u %s",
- bgp_vpn_rd_print(pptr+4),
+ bgp_vpn_rd_print(ndo, pptr+4),
isonsap_string(addr,(plen + 7) / 8),
plen,
EXTRACT_24BITS(pptr+1)>>4,
@@ -1237,7 +1247,8 @@ trunc:
* 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)
+bgp_attr_get_as_size(netdissect_options *ndo,
+ uint8_t bgpa_type, const u_char *pptr, int len)
{
const u_char *tptr = pptr;
@@ -1255,7 +1266,7 @@ bgp_attr_get_as_size (u_int8_t bgpa_type, const u_char *pptr, int len)
* each.
*/
while (tptr < pptr + len) {
- TCHECK(tptr[0]);
+ ND_TCHECK(tptr[0]);
/*
* If we do not find a valid segment type, our guess might be wrong.
@@ -1263,7 +1274,7 @@ bgp_attr_get_as_size (u_int8_t bgpa_type, const u_char *pptr, int len)
if (tptr[0] < BGP_AS_SEG_TYPE_MIN || tptr[0] > BGP_AS_SEG_TYPE_MAX) {
goto trunc;
}
- TCHECK(tptr[1]);
+ ND_TCHECK(tptr[1]);
tptr += 2 + tptr[1] * 2;
}
@@ -1287,14 +1298,15 @@ trunc:
}
static int
-bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
+bgp_attr_print(netdissect_options *ndo,
+ u_int atype, const u_char *pptr, u_int len)
{
int i;
- u_int16_t af;
- u_int8_t safi, snpa, nhlen;
+ uint16_t af;
+ uint8_t safi, snpa, nhlen;
union { /* copy buffer for bandwidth values */
- float f;
- u_int32_t i;
+ float f;
+ uint32_t i;
} bw;
int advance;
u_int tlen;
@@ -1309,13 +1321,13 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
switch (atype) {
case BGPTYPE_ORIGIN:
if (len != 1)
- printf("invalid len");
+ ND_PRINT((ndo, "invalid len"));
else {
- TCHECK(*tptr);
- printf("%s", tok2strbuf(bgp_origin_values,
+ ND_TCHECK(*tptr);
+ ND_PRINT((ndo, "%s", tok2strbuf(bgp_origin_values,
"Unknown Origin Typecode",
tptr[0],
- tokbuf, sizeof(tokbuf)));
+ tokbuf, sizeof(tokbuf))));
}
break;
@@ -1326,11 +1338,11 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
case BGPTYPE_AS4_PATH:
case BGPTYPE_AS_PATH:
if (len % 2) {
- printf("invalid len");
+ ND_PRINT((ndo, "invalid len"));
break;
}
if (!len) {
- printf("empty");
+ ND_PRINT((ndo, "empty"));
break;
}
@@ -1342,49 +1354,49 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
* 2 bytes first, and it does not pass, assume that ASs are
* encoded in 4 bytes format and move on.
*/
- as_size = bgp_attr_get_as_size(atype, pptr, len);
+ as_size = bgp_attr_get_as_size(ndo, atype, pptr, len);
while (tptr < pptr + len) {
- TCHECK(tptr[0]);
- printf("%s", tok2strbuf(bgp_as_path_segment_open_values,
+ ND_TCHECK(tptr[0]);
+ ND_PRINT((ndo, "%s", tok2strbuf(bgp_as_path_segment_open_values,
"?", tptr[0],
- tokbuf, sizeof(tokbuf)));
+ tokbuf, sizeof(tokbuf))));
for (i = 0; i < tptr[1] * as_size; i += as_size) {
- TCHECK2(tptr[2 + i], as_size);
- printf("%s ",
- as_printf(astostr, sizeof(astostr),
- as_size == 2 ?
+ ND_TCHECK2(tptr[2 + i], as_size);
+ ND_PRINT((ndo, "%s ",
+ as_printf(ndo, astostr, sizeof(astostr),
+ as_size == 2 ?
EXTRACT_16BITS(&tptr[2 + i]) :
- EXTRACT_32BITS(&tptr[2 + i])));
+ EXTRACT_32BITS(&tptr[2 + i]))));
}
- TCHECK(tptr[0]);
- printf("%s", tok2strbuf(bgp_as_path_segment_close_values,
+ ND_TCHECK(tptr[0]);
+ ND_PRINT((ndo, "%s", tok2strbuf(bgp_as_path_segment_close_values,
"?", tptr[0],
- tokbuf, sizeof(tokbuf)));
- TCHECK(tptr[1]);
+ tokbuf, sizeof(tokbuf))));
+ ND_TCHECK(tptr[1]);
tptr += 2 + tptr[1] * as_size;
}
break;
case BGPTYPE_NEXT_HOP:
if (len != 4)
- printf("invalid len");
+ ND_PRINT((ndo, "invalid len"));
else {
- TCHECK2(tptr[0], 4);
- printf("%s", getname(tptr));
+ ND_TCHECK2(tptr[0], 4);
+ ND_PRINT((ndo, "%s", getname(ndo, tptr)));
}
break;
case BGPTYPE_MULTI_EXIT_DISC:
case BGPTYPE_LOCAL_PREF:
if (len != 4)
- printf("invalid len");
+ ND_PRINT((ndo, "invalid len"));
else {
- TCHECK2(tptr[0], 4);
- printf("%u", EXTRACT_32BITS(tptr));
+ ND_TCHECK2(tptr[0], 4);
+ ND_PRINT((ndo, "%u", EXTRACT_32BITS(tptr)));
}
break;
case BGPTYPE_ATOMIC_AGGREGATE:
if (len != 0)
- printf("invalid len");
+ ND_PRINT((ndo, "invalid len"));
break;
case BGPTYPE_AGGREGATOR:
@@ -1393,54 +1405,54 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
* the length of this PA can be either 6 bytes or 8 bytes.
*/
if (len != 6 && len != 8) {
- printf("invalid len");
+ ND_PRINT((ndo, "invalid len"));
break;
}
- TCHECK2(tptr[0], len);
+ ND_TCHECK2(tptr[0], len);
if (len == 6) {
- printf(" AS #%s, origin %s",
- as_printf(astostr, sizeof(astostr), EXTRACT_16BITS(tptr)),
- getname(tptr + 2));
+ ND_PRINT((ndo, " AS #%s, origin %s",
+ as_printf(ndo, astostr, sizeof(astostr), EXTRACT_16BITS(tptr)),
+ getname(ndo, tptr + 2)));
} else {
- printf(" AS #%s, origin %s",
- as_printf(astostr, sizeof(astostr),
- EXTRACT_32BITS(tptr)), getname(tptr + 4));
+ ND_PRINT((ndo, " AS #%s, origin %s",
+ as_printf(ndo, astostr, sizeof(astostr),
+ EXTRACT_32BITS(tptr)), getname(ndo, tptr + 4)));
}
break;
case BGPTYPE_AGGREGATOR4:
if (len != 8) {
- printf("invalid len");
+ ND_PRINT((ndo, "invalid len"));
break;
}
- TCHECK2(tptr[0], 8);
- printf(" AS #%s, origin %s",
- as_printf(astostr, sizeof(astostr), EXTRACT_32BITS(tptr)),
- getname(tptr + 4));
+ ND_TCHECK2(tptr[0], 8);
+ ND_PRINT((ndo, " AS #%s, origin %s",
+ as_printf(ndo, astostr, sizeof(astostr), EXTRACT_32BITS(tptr)),
+ getname(ndo, tptr + 4)));
break;
case BGPTYPE_COMMUNITIES:
if (len % 4) {
- printf("invalid len");
+ ND_PRINT((ndo, "invalid len"));
break;
}
while (tlen>0) {
- u_int32_t comm;
- TCHECK2(tptr[0], 4);
+ uint32_t comm;
+ ND_TCHECK2(tptr[0], 4);
comm = EXTRACT_32BITS(tptr);
switch (comm) {
case BGP_COMMUNITY_NO_EXPORT:
- printf(" NO_EXPORT");
+ ND_PRINT((ndo, " NO_EXPORT"));
break;
case BGP_COMMUNITY_NO_ADVERT:
- printf(" NO_ADVERTISE");
+ ND_PRINT((ndo, " NO_ADVERTISE"));
break;
case BGP_COMMUNITY_NO_EXPORT_SUBCONFED:
- printf(" NO_EXPORT_SUBCONFED");
+ ND_PRINT((ndo, " NO_EXPORT_SUBCONFED"));
break;
default:
- printf("%u:%u%s",
+ ND_PRINT((ndo, "%u:%u%s",
(comm >> 16) & 0xffff,
comm & 0xffff,
- (tlen>4) ? ", " : "");
+ (tlen>4) ? ", " : ""));
break;
}
tlen -=4;
@@ -1449,39 +1461,39 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
break;
case BGPTYPE_ORIGINATOR_ID:
if (len != 4) {
- printf("invalid len");
+ ND_PRINT((ndo, "invalid len"));
break;
}
- TCHECK2(tptr[0], 4);
- printf("%s",getname(tptr));
+ ND_TCHECK2(tptr[0], 4);
+ ND_PRINT((ndo, "%s",getname(ndo, tptr)));
break;
case BGPTYPE_CLUSTER_LIST:
if (len % 4) {
- printf("invalid len");
+ ND_PRINT((ndo, "invalid len"));
break;
}
while (tlen>0) {
- TCHECK2(tptr[0], 4);
- printf("%s%s",
- getname(tptr),
- (tlen>4) ? ", " : "");
+ ND_TCHECK2(tptr[0], 4);
+ ND_PRINT((ndo, "%s%s",
+ getname(ndo, tptr),
+ (tlen>4) ? ", " : ""));
tlen -=4;
tptr +=4;
}
break;
case BGPTYPE_MP_REACH_NLRI:
- TCHECK2(tptr[0], 3);
+ ND_TCHECK2(tptr[0], 3);
af = EXTRACT_16BITS(tptr);
safi = tptr[2];
-
- printf("\n\t AFI: %s (%u), %sSAFI: %s (%u)",
+
+ ND_PRINT((ndo, "\n\t AFI: %s (%u), %sSAFI: %s (%u)",
tok2strbuf(af_values, "Unknown AFI", af,
tokbuf, sizeof(tokbuf)),
af,
(safi>128) ? "vendor specific " : "", /* 128 is meanwhile wellknown */
tok2strbuf(bgp_safi_values, "Unknown SAFI", safi,
tokbuf, sizeof(tokbuf)),
- safi);
+ safi));
switch(af<<8 | safi) {
case (AFNUM_INET<<8 | SAFNUM_UNICAST):
@@ -1493,7 +1505,7 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST):
case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST):
case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN):
- case (AFNUM_INET<<8 | SAFNUM_MDT):
+ case (AFNUM_INET<<8 | SAFNUM_MDT):
#ifdef INET6
case (AFNUM_INET6<<8 | SAFNUM_UNICAST):
case (AFNUM_INET6<<8 | SAFNUM_MULTICAST):
@@ -1515,27 +1527,27 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
case (AFNUM_VPLS<<8 | SAFNUM_VPLS):
break;
default:
- TCHECK2(tptr[0], tlen);
- printf("\n\t no AFI %u / SAFI %u decoder",af,safi);
- if (vflag <= 1)
- print_unknown_data(tptr,"\n\t ",tlen);
+ ND_TCHECK2(tptr[0], tlen);
+ ND_PRINT((ndo, "\n\t no AFI %u / SAFI %u decoder", af, safi));
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo, tptr, "\n\t ", tlen);
goto done;
break;
}
tptr +=3;
- TCHECK(tptr[0]);
+ ND_TCHECK(tptr[0]);
nhlen = tptr[0];
tlen = nhlen;
tptr++;
if (tlen) {
int nnh = 0;
- printf("\n\t nexthop: ");
+ ND_PRINT((ndo, "\n\t nexthop: "));
while (tlen > 0) {
if ( nnh++ > 0 ) {
- printf( ", " );
+ ND_PRINT((ndo, ", " ));
}
switch(af<<8 | safi) {
case (AFNUM_INET<<8 | SAFNUM_UNICAST):
@@ -1544,13 +1556,13 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
case (AFNUM_INET<<8 | SAFNUM_LABUNICAST):
case (AFNUM_INET<<8 | SAFNUM_RT_ROUTING_INFO):
case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN):
- case (AFNUM_INET<<8 | SAFNUM_MDT):
+ case (AFNUM_INET<<8 | SAFNUM_MDT):
if (tlen < (int)sizeof(struct in_addr)) {
- printf("invalid len");
+ ND_PRINT((ndo, "invalid len"));
tlen = 0;
} else {
- TCHECK2(tptr[0], sizeof(struct in_addr));
- printf("%s",getname(tptr));
+ ND_TCHECK2(tptr[0], sizeof(struct in_addr));
+ ND_PRINT((ndo, "%s",getname(ndo, tptr)));
tlen -= sizeof(struct in_addr);
tptr += sizeof(struct in_addr);
}
@@ -1559,13 +1571,13 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST):
case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST):
if (tlen < (int)(sizeof(struct in_addr)+BGP_VPN_RD_LEN)) {
- printf("invalid len");
+ ND_PRINT((ndo, "invalid len"));
tlen = 0;
} else {
- TCHECK2(tptr[0], sizeof(struct in_addr)+BGP_VPN_RD_LEN);
- printf("RD: %s, %s",
- bgp_vpn_rd_print(tptr),
- getname(tptr+BGP_VPN_RD_LEN));
+ ND_TCHECK2(tptr[0], sizeof(struct in_addr)+BGP_VPN_RD_LEN);
+ ND_PRINT((ndo, "RD: %s, %s",
+ bgp_vpn_rd_print(ndo, tptr),
+ getname(ndo, tptr+BGP_VPN_RD_LEN)));
tlen -= (sizeof(struct in_addr)+BGP_VPN_RD_LEN);
tptr += (sizeof(struct in_addr)+BGP_VPN_RD_LEN);
}
@@ -1576,11 +1588,11 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST):
case (AFNUM_INET6<<8 | SAFNUM_LABUNICAST):
if (tlen < (int)sizeof(struct in6_addr)) {
- printf("invalid len");
+ ND_PRINT((ndo, "invalid len"));
tlen = 0;
} else {
- TCHECK2(tptr[0], sizeof(struct in6_addr));
- printf("%s", getname6(tptr));
+ ND_TCHECK2(tptr[0], sizeof(struct in6_addr));
+ ND_PRINT((ndo, "%s", getname6(ndo, tptr)));
tlen -= sizeof(struct in6_addr);
tptr += sizeof(struct in6_addr);
}
@@ -1589,13 +1601,13 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST):
case (AFNUM_INET6<<8 | SAFNUM_VPNUNIMULTICAST):
if (tlen < (int)(sizeof(struct in6_addr)+BGP_VPN_RD_LEN)) {
- printf("invalid len");
+ ND_PRINT((ndo, "invalid len"));
tlen = 0;
} else {
- TCHECK2(tptr[0], sizeof(struct in6_addr)+BGP_VPN_RD_LEN);
- printf("RD: %s, %s",
- bgp_vpn_rd_print(tptr),
- getname6(tptr+BGP_VPN_RD_LEN));
+ ND_TCHECK2(tptr[0], sizeof(struct in6_addr)+BGP_VPN_RD_LEN);
+ ND_PRINT((ndo, "RD: %s, %s",
+ bgp_vpn_rd_print(ndo, tptr),
+ getname6(ndo, tptr+BGP_VPN_RD_LEN)));
tlen -= (sizeof(struct in6_addr)+BGP_VPN_RD_LEN);
tptr += (sizeof(struct in6_addr)+BGP_VPN_RD_LEN);
}
@@ -1606,11 +1618,11 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST):
case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNIMULTICAST):
if (tlen < (int)sizeof(struct in_addr)) {
- printf("invalid len");
+ ND_PRINT((ndo, "invalid len"));
tlen = 0;
} else {
- TCHECK2(tptr[0], sizeof(struct in_addr));
- printf("%s", getname(tptr));
+ ND_TCHECK2(tptr[0], sizeof(struct in_addr));
+ ND_PRINT((ndo, "%s", getname(ndo, tptr)));
tlen -= (sizeof(struct in_addr));
tptr += (sizeof(struct in_addr));
}
@@ -1618,8 +1630,8 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
case (AFNUM_NSAP<<8 | SAFNUM_UNICAST):
case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST):
case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST):
- TCHECK2(tptr[0], tlen);
- printf("%s",isonsap_string(tptr,tlen));
+ ND_TCHECK2(tptr[0], tlen);
+ ND_PRINT((ndo, "%s", isonsap_string(tptr, tlen)));
tptr += tlen;
tlen = 0;
break;
@@ -1628,30 +1640,30 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
case (AFNUM_NSAP<<8 | SAFNUM_VPNMULTICAST):
case (AFNUM_NSAP<<8 | SAFNUM_VPNUNIMULTICAST):
if (tlen < BGP_VPN_RD_LEN+1) {
- printf("invalid len");
+ ND_PRINT((ndo, "invalid len"));
tlen = 0;
} else {
- TCHECK2(tptr[0], tlen);
- printf("RD: %s, %s",
- bgp_vpn_rd_print(tptr),
- isonsap_string(tptr+BGP_VPN_RD_LEN,tlen-BGP_VPN_RD_LEN));
+ ND_TCHECK2(tptr[0], tlen);
+ ND_PRINT((ndo, "RD: %s, %s",
+ bgp_vpn_rd_print(ndo, tptr),
+ isonsap_string(tptr+BGP_VPN_RD_LEN,tlen-BGP_VPN_RD_LEN)));
/* rfc986 mapped IPv4 address ? */
if (EXTRACT_32BITS(tptr+BGP_VPN_RD_LEN) == 0x47000601)
- printf(" = %s", getname(tptr+BGP_VPN_RD_LEN+4));
+ ND_PRINT((ndo, " = %s", getname(ndo, tptr+BGP_VPN_RD_LEN+4)));
#ifdef INET6
/* rfc1888 mapped IPv6 address ? */
else if (EXTRACT_24BITS(tptr+BGP_VPN_RD_LEN) == 0x350000)
- printf(" = %s", getname6(tptr+BGP_VPN_RD_LEN+3));
+ ND_PRINT((ndo, " = %s", getname6(ndo, tptr+BGP_VPN_RD_LEN+3)));
#endif
tptr += tlen;
tlen = 0;
}
break;
default:
- TCHECK2(tptr[0], tlen);
- printf("no AFI %u/SAFI %u decoder",af,safi);
- if (vflag <= 1)
- print_unknown_data(tptr,"\n\t ",tlen);
+ ND_TCHECK2(tptr[0], tlen);
+ ND_PRINT((ndo, "no AFI %u/SAFI %u decoder", af, safi));
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo, tptr, "\n\t ", tlen);
tptr += tlen;
tlen = 0;
goto done;
@@ -1659,22 +1671,22 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
}
}
}
- printf(", nh-length: %u", nhlen);
+ ND_PRINT((ndo, ", nh-length: %u", nhlen));
tptr += tlen;
- TCHECK(tptr[0]);
+ ND_TCHECK(tptr[0]);
snpa = tptr[0];
tptr++;
if (snpa) {
- printf("\n\t %u SNPA", snpa);
+ ND_PRINT((ndo, "\n\t %u SNPA", snpa));
for (/*nothing*/; snpa > 0; snpa--) {
- TCHECK(tptr[0]);
- printf("\n\t %d bytes", tptr[0]);
+ ND_TCHECK(tptr[0]);
+ ND_PRINT((ndo, "\n\t %d bytes", tptr[0]));
tptr += tptr[0] + 1;
}
} else {
- printf(", no SNPA");
+ ND_PRINT((ndo, ", no SNPA"));
}
while (len - (tptr - pptr) > 0) {
@@ -1682,143 +1694,143 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
case (AFNUM_INET<<8 | SAFNUM_UNICAST):
case (AFNUM_INET<<8 | SAFNUM_MULTICAST):
case (AFNUM_INET<<8 | SAFNUM_UNIMULTICAST):
- advance = decode_prefix4(tptr, len, buf, sizeof(buf));
+ advance = decode_prefix4(ndo, tptr, len, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else if (advance == -3)
break; /* bytes left, but not enough */
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
break;
case (AFNUM_INET<<8 | SAFNUM_LABUNICAST):
- advance = decode_labeled_prefix4(tptr, len, buf, sizeof(buf));
+ advance = decode_labeled_prefix4(ndo, tptr, len, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else if (advance == -3)
break; /* bytes left, but not enough */
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
break;
case (AFNUM_INET<<8 | SAFNUM_VPNUNICAST):
case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST):
case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST):
- advance = decode_labeled_vpn_prefix4(tptr, buf, sizeof(buf));
+ advance = decode_labeled_vpn_prefix4(ndo, tptr, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
break;
case (AFNUM_INET<<8 | SAFNUM_RT_ROUTING_INFO):
- advance = decode_rt_routing_info(tptr, buf, sizeof(buf));
+ advance = decode_rt_routing_info(ndo, tptr, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\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));
+ advance = decode_multicast_vpn(ndo, tptr, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
break;
case (AFNUM_INET<<8 | SAFNUM_MDT):
- advance = decode_mdt_vpn_nlri(tptr, buf, sizeof(buf));
+ advance = decode_mdt_vpn_nlri(ndo, tptr, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
break;
#ifdef INET6
case (AFNUM_INET6<<8 | SAFNUM_UNICAST):
case (AFNUM_INET6<<8 | SAFNUM_MULTICAST):
case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST):
- advance = decode_prefix6(tptr, len, buf, sizeof(buf));
+ advance = decode_prefix6(ndo, tptr, len, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else if (advance == -3)
break; /* bytes left, but not enough */
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
break;
case (AFNUM_INET6<<8 | SAFNUM_LABUNICAST):
- advance = decode_labeled_prefix6(tptr, len, buf, sizeof(buf));
+ advance = decode_labeled_prefix6(ndo, tptr, len, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else if (advance == -3)
break; /* bytes left, but not enough */
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
break;
case (AFNUM_INET6<<8 | SAFNUM_VPNUNICAST):
case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST):
case (AFNUM_INET6<<8 | SAFNUM_VPNUNIMULTICAST):
- advance = decode_labeled_vpn_prefix6(tptr, buf, sizeof(buf));
+ advance = decode_labeled_vpn_prefix6(ndo, tptr, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
break;
#endif
case (AFNUM_VPLS<<8 | SAFNUM_VPLS):
case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST):
case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST):
case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNIMULTICAST):
- advance = decode_labeled_vpn_l2(tptr, buf, sizeof(buf));
+ advance = decode_labeled_vpn_l2(ndo, tptr, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal length)");
+ ND_PRINT((ndo, "\n\t (illegal length)"));
else if (advance == -2)
goto trunc;
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
break;
case (AFNUM_NSAP<<8 | SAFNUM_UNICAST):
case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST):
case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST):
- advance = decode_clnp_prefix(tptr, buf, sizeof(buf));
+ advance = decode_clnp_prefix(ndo, tptr, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
break;
case (AFNUM_NSAP<<8 | SAFNUM_VPNUNICAST):
case (AFNUM_NSAP<<8 | SAFNUM_VPNMULTICAST):
case (AFNUM_NSAP<<8 | SAFNUM_VPNUNIMULTICAST):
- advance = decode_labeled_vpn_clnp_prefix(tptr, buf, sizeof(buf));
+ advance = decode_labeled_vpn_clnp_prefix(ndo, tptr, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else
- printf("\n\t %s", buf);
- break;
+ ND_PRINT((ndo, "\n\t %s", buf));
+ break;
default:
- TCHECK2(*tptr,tlen);
- printf("\n\t no AFI %u / SAFI %u decoder",af,safi);
- if (vflag <= 1)
- print_unknown_data(tptr,"\n\t ",tlen);
+ ND_TCHECK2(*tptr,tlen);
+ ND_PRINT((ndo, "\n\t no AFI %u / SAFI %u decoder", af, safi));
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo, tptr, "\n\t ", tlen);
advance = 0;
tptr = pptr + len;
break;
@@ -1831,156 +1843,156 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
break;
case BGPTYPE_MP_UNREACH_NLRI:
- TCHECK2(tptr[0], BGP_MP_NLRI_MINSIZE);
+ ND_TCHECK2(tptr[0], BGP_MP_NLRI_MINSIZE);
af = EXTRACT_16BITS(tptr);
safi = tptr[2];
- printf("\n\t AFI: %s (%u), %sSAFI: %s (%u)",
+ ND_PRINT((ndo, "\n\t AFI: %s (%u), %sSAFI: %s (%u)",
tok2strbuf(af_values, "Unknown AFI", af,
tokbuf, sizeof(tokbuf)),
af,
(safi>128) ? "vendor specific " : "", /* 128 is meanwhile wellknown */
tok2strbuf(bgp_safi_values, "Unknown SAFI", safi,
tokbuf, sizeof(tokbuf)),
- safi);
+ safi));
if (len == BGP_MP_NLRI_MINSIZE)
- printf("\n\t End-of-Rib Marker (empty NLRI)");
+ ND_PRINT((ndo, "\n\t End-of-Rib Marker (empty NLRI)"));
tptr += 3;
-
+
while (len - (tptr - pptr) > 0) {
switch (af<<8 | safi) {
case (AFNUM_INET<<8 | SAFNUM_UNICAST):
case (AFNUM_INET<<8 | SAFNUM_MULTICAST):
case (AFNUM_INET<<8 | SAFNUM_UNIMULTICAST):
- advance = decode_prefix4(tptr, len, buf, sizeof(buf));
+ advance = decode_prefix4(ndo, tptr, len, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else if (advance == -3)
break; /* bytes left, but not enough */
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
break;
case (AFNUM_INET<<8 | SAFNUM_LABUNICAST):
- advance = decode_labeled_prefix4(tptr, len, buf, sizeof(buf));
+ advance = decode_labeled_prefix4(ndo, tptr, len, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else if (advance == -3)
break; /* bytes left, but not enough */
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
break;
case (AFNUM_INET<<8 | SAFNUM_VPNUNICAST):
case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST):
case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST):
- advance = decode_labeled_vpn_prefix4(tptr, buf, sizeof(buf));
+ advance = decode_labeled_vpn_prefix4(ndo, tptr, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
break;
#ifdef INET6
case (AFNUM_INET6<<8 | SAFNUM_UNICAST):
case (AFNUM_INET6<<8 | SAFNUM_MULTICAST):
case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST):
- advance = decode_prefix6(tptr, len, buf, sizeof(buf));
+ advance = decode_prefix6(ndo, tptr, len, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else if (advance == -3)
break; /* bytes left, but not enough */
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
break;
case (AFNUM_INET6<<8 | SAFNUM_LABUNICAST):
- advance = decode_labeled_prefix6(tptr, len, buf, sizeof(buf));
+ advance = decode_labeled_prefix6(ndo, tptr, len, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else if (advance == -3)
break; /* bytes left, but not enough */
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
break;
case (AFNUM_INET6<<8 | SAFNUM_VPNUNICAST):
case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST):
case (AFNUM_INET6<<8 | SAFNUM_VPNUNIMULTICAST):
- advance = decode_labeled_vpn_prefix6(tptr, buf, sizeof(buf));
+ advance = decode_labeled_vpn_prefix6(ndo, tptr, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
break;
#endif
case (AFNUM_VPLS<<8 | SAFNUM_VPLS):
case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST):
case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST):
case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNIMULTICAST):
- advance = decode_labeled_vpn_l2(tptr, buf, sizeof(buf));
+ advance = decode_labeled_vpn_l2(ndo, tptr, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal length)");
+ ND_PRINT((ndo, "\n\t (illegal length)"));
else if (advance == -2)
goto trunc;
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
break;
case (AFNUM_NSAP<<8 | SAFNUM_UNICAST):
case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST):
case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST):
- advance = decode_clnp_prefix(tptr, buf, sizeof(buf));
+ advance = decode_clnp_prefix(ndo, tptr, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
break;
case (AFNUM_NSAP<<8 | SAFNUM_VPNUNICAST):
case (AFNUM_NSAP<<8 | SAFNUM_VPNMULTICAST):
case (AFNUM_NSAP<<8 | SAFNUM_VPNUNIMULTICAST):
- advance = decode_labeled_vpn_clnp_prefix(tptr, buf, sizeof(buf));
+ advance = decode_labeled_vpn_clnp_prefix(ndo, tptr, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else
- printf("\n\t %s", buf);
- break;
+ ND_PRINT((ndo, "\n\t %s", buf));
+ break;
case (AFNUM_INET<<8 | SAFNUM_MDT):
- advance = decode_mdt_vpn_nlri(tptr, buf, sizeof(buf));
+ advance = decode_mdt_vpn_nlri(ndo, tptr, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\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));
+ advance = decode_multicast_vpn(ndo, tptr, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
break;
default:
- TCHECK2(*(tptr-3),tlen);
- printf("no AFI %u / SAFI %u decoder",af,safi);
- if (vflag <= 1)
- print_unknown_data(tptr-3,"\n\t ",tlen);
+ ND_TCHECK2(*(tptr-3),tlen);
+ ND_PRINT((ndo, "no AFI %u / SAFI %u decoder", af, safi));
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo, tptr-3, "\n\t ", tlen);
advance = 0;
tptr = pptr + len;
break;
@@ -1992,50 +2004,50 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
break;
case BGPTYPE_EXTD_COMMUNITIES:
if (len % 8) {
- printf("invalid len");
+ ND_PRINT((ndo, "invalid len"));
break;
}
while (tlen>0) {
- u_int16_t extd_comm;
+ uint16_t extd_comm;
- TCHECK2(tptr[0], 2);
+ ND_TCHECK2(tptr[0], 2);
extd_comm=EXTRACT_16BITS(tptr);
- printf("\n\t %s (0x%04x), Flags [%s]",
+ ND_PRINT((ndo, "\n\t %s (0x%04x), Flags [%s]",
tok2strbuf(bgp_extd_comm_subtype_values,
"unknown extd community typecode",
extd_comm, tokbuf, sizeof(tokbuf)),
extd_comm,
- bittok2str(bgp_extd_comm_flag_values, "none", extd_comm));
+ bittok2str(bgp_extd_comm_flag_values, "none", extd_comm)));
- TCHECK2(*(tptr+2), 6);
+ ND_TCHECK2(*(tptr+2), 6);
switch(extd_comm) {
case BGP_EXT_COM_RT_0:
case BGP_EXT_COM_RO_0:
case BGP_EXT_COM_L2VPN_RT_0:
- printf(": %u:%u (= %s)",
+ ND_PRINT((ndo, ": %u:%u (= %s)",
EXTRACT_16BITS(tptr+2),
EXTRACT_32BITS(tptr+4),
- getname(tptr+4));
+ getname(ndo, tptr+4)));
break;
case BGP_EXT_COM_RT_1:
case BGP_EXT_COM_RO_1:
case BGP_EXT_COM_L2VPN_RT_1:
case BGP_EXT_COM_VRF_RT_IMP:
- printf(": %s:%u",
- getname(tptr+2),
- EXTRACT_16BITS(tptr+6));
+ ND_PRINT((ndo, ": %s:%u",
+ getname(ndo, tptr+2),
+ EXTRACT_16BITS(tptr+6)));
break;
case BGP_EXT_COM_RT_2:
case BGP_EXT_COM_RO_2:
- printf(": %s:%u",
- as_printf(astostr, sizeof(astostr),
- EXTRACT_32BITS(tptr+2)), EXTRACT_16BITS(tptr+6));
+ ND_PRINT((ndo, ": %s:%u",
+ as_printf(ndo, astostr, sizeof(astostr),
+ EXTRACT_32BITS(tptr+2)), EXTRACT_16BITS(tptr+6)));
break;
case BGP_EXT_COM_LINKBAND:
bw.i = EXTRACT_32BITS(tptr+2);
- printf(": bandwidth: %.3f Mbps",
- bw.f*8/1000000);
+ ND_PRINT((ndo, ": bandwidth: %.3f Mbps",
+ bw.f*8/1000000));
break;
case BGP_EXT_COM_VPN_ORIGIN:
case BGP_EXT_COM_VPN_ORIGIN2:
@@ -2043,34 +2055,34 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
case BGP_EXT_COM_VPN_ORIGIN4:
case BGP_EXT_COM_OSPF_RID:
case BGP_EXT_COM_OSPF_RID2:
- printf("%s", getname(tptr+2));
+ ND_PRINT((ndo, "%s", getname(ndo, tptr+2)));
break;
case BGP_EXT_COM_OSPF_RTYPE:
- case BGP_EXT_COM_OSPF_RTYPE2:
- printf(": area:%s, router-type:%s, metric-type:%s%s",
- getname(tptr+2),
+ case BGP_EXT_COM_OSPF_RTYPE2:
+ ND_PRINT((ndo, ": area:%s, router-type:%s, metric-type:%s%s",
+ getname(ndo, tptr+2),
tok2strbuf(bgp_extd_comm_ospf_rtype_values,
"unknown (0x%02x)",
*(tptr+6),
tokbuf, sizeof(tokbuf)),
(*(tptr+7) & BGP_OSPF_RTYPE_METRIC_TYPE) ? "E2" : "",
- ((*(tptr+6) == BGP_OSPF_RTYPE_EXT) || (*(tptr+6) == BGP_OSPF_RTYPE_NSSA)) ? "E1" : "");
+ ((*(tptr+6) == BGP_OSPF_RTYPE_EXT) || (*(tptr+6) == BGP_OSPF_RTYPE_NSSA)) ? "E1" : ""));
break;
case BGP_EXT_COM_L2INFO:
- printf(": %s Control Flags [0x%02x]:MTU %u",
+ ND_PRINT((ndo, ": %s Control Flags [0x%02x]:MTU %u",
tok2strbuf(l2vpn_encaps_values,
"unknown encaps",
*(tptr+2),
tokbuf, sizeof(tokbuf)),
*(tptr+3),
- EXTRACT_16BITS(tptr+4));
+ EXTRACT_16BITS(tptr+4)));
break;
case BGP_EXT_COM_SOURCE_AS:
- printf(": AS %u", EXTRACT_16BITS(tptr+2));
+ ND_PRINT((ndo, ": AS %u", EXTRACT_16BITS(tptr+2)));
break;
default:
- TCHECK2(*tptr,8);
- print_unknown_data(tptr,"\n\t ",8);
+ ND_TCHECK2(*tptr,8);
+ print_unknown_data(ndo, tptr, "\n\t ", 8);
break;
}
tlen -=8;
@@ -2080,18 +2092,18 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
case BGPTYPE_PMSI_TUNNEL:
{
- u_int8_t tunnel_type, flags;
-
+ uint8_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",
+ ND_TCHECK2(tptr[0], 5);
+ ND_PRINT((ndo, "\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);
+ EXTRACT_24BITS(tptr+2)>>4));
tptr +=5;
tlen -= 5;
@@ -2099,56 +2111,56 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
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));
+ ND_TCHECK2(tptr[0], 8);
+ ND_PRINT((ndo, "\n\t Sender %s, P-Group %s",
+ ipaddr_string(ndo, tptr),
+ ipaddr_string(ndo, 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));
+ ND_TCHECK2(tptr[0], 8);
+ ND_PRINT((ndo, "\n\t Root-Node %s, P-Group %s",
+ ipaddr_string(ndo, tptr),
+ ipaddr_string(ndo, tptr+4)));
break;
case BGP_PMSI_TUNNEL_INGRESS:
- TCHECK2(tptr[0], 4);
- printf("\n\t Tunnel-Endpoint %s",
- ipaddr_string(tptr));
+ ND_TCHECK2(tptr[0], 4);
+ ND_PRINT((ndo, "\n\t Tunnel-Endpoint %s",
+ ipaddr_string(ndo, 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));
+ ND_TCHECK2(tptr[0], 8);
+ ND_PRINT((ndo, "\n\t Root-Node %s, LSP-ID 0x%08x",
+ ipaddr_string(ndo, 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));
+ ND_TCHECK2(tptr[0], 8);
+ ND_PRINT((ndo, "\n\t Extended-Tunnel-ID %s, P2MP-ID 0x%08x",
+ ipaddr_string(ndo, tptr),
+ EXTRACT_32BITS(tptr+4)));
break;
default:
- if (vflag <= 1) {
- print_unknown_data(tptr,"\n\t ",tlen);
+ if (ndo->ndo_vflag <= 1) {
+ print_unknown_data(ndo, tptr, "\n\t ", tlen);
}
}
break;
}
case BGPTYPE_ATTR_SET:
- TCHECK2(tptr[0], 4);
+ ND_TCHECK2(tptr[0], 4);
if (len < 4)
goto trunc;
- printf("\n\t Origin AS: %s",
- as_printf(astostr, sizeof(astostr), EXTRACT_32BITS(tptr)));
+ ND_PRINT((ndo, "\n\t Origin AS: %s",
+ as_printf(ndo, astostr, sizeof(astostr), EXTRACT_32BITS(tptr))));
tptr+=4;
len -=4;
while (len) {
u_int aflags, atype, alenlen, alen;
-
- TCHECK2(tptr[0], 2);
+
+ ND_TCHECK2(tptr[0], 2);
if (len < 2)
goto trunc;
aflags = *tptr;
@@ -2156,49 +2168,49 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
tptr += 2;
len -= 2;
alenlen = bgp_attr_lenlen(aflags, tptr);
- TCHECK2(tptr[0], alenlen);
+ ND_TCHECK2(tptr[0], alenlen);
if (len < alenlen)
goto trunc;
alen = bgp_attr_len(aflags, tptr);
tptr += alenlen;
len -= alenlen;
-
- printf("\n\t %s (%u), length: %u",
+
+ ND_PRINT((ndo, "\n\t %s (%u), length: %u",
tok2strbuf(bgp_attr_values,
"Unknown Attribute", atype,
tokbuf, sizeof(tokbuf)),
atype,
- alen);
-
+ alen));
+
if (aflags) {
- printf(", Flags [%s%s%s%s",
+ ND_PRINT((ndo, ", Flags [%s%s%s%s",
aflags & 0x80 ? "O" : "",
aflags & 0x40 ? "T" : "",
aflags & 0x20 ? "P" : "",
- aflags & 0x10 ? "E" : "");
+ aflags & 0x10 ? "E" : ""));
if (aflags & 0xf)
- printf("+%x", aflags & 0xf);
- printf("]: ");
+ ND_PRINT((ndo, "+%x", aflags & 0xf));
+ ND_PRINT((ndo, "]: "));
}
/* FIXME check for recursion */
- if (!bgp_attr_print(atype, tptr, alen))
+ if (!bgp_attr_print(ndo, atype, tptr, alen))
return 0;
tptr += alen;
len -= alen;
}
break;
-
+
default:
- TCHECK2(*pptr,len);
- printf("\n\t no Attribute %u decoder",atype); /* we have no decoder for the attribute */
- if (vflag <= 1)
- print_unknown_data(pptr,"\n\t ",len);
+ ND_TCHECK2(*pptr,len);
+ ND_PRINT((ndo, "\n\t no Attribute %u decoder", atype)); /* we have no decoder for the attribute */
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo, pptr, "\n\t ", len);
break;
}
- if (vflag > 1 && len) { /* omit zero length attributes*/
- TCHECK2(*pptr,len);
- print_unknown_data(pptr,"\n\t ",len);
+ if (ndo->ndo_vflag > 1 && len) { /* omit zero length attributes*/
+ ND_TCHECK2(*pptr,len);
+ print_unknown_data(ndo, pptr, "\n\t ", len);
}
return 1;
@@ -2207,7 +2219,8 @@ trunc:
}
static void
-bgp_capabilities_print(const u_char *opt, int caps_len)
+bgp_capabilities_print(netdissect_options *ndo,
+ const u_char *opt, int caps_len)
{
char tokbuf[TOKBUFSIZE];
char tokbuf2[TOKBUFSIZE];
@@ -2215,19 +2228,19 @@ bgp_capabilities_print(const u_char *opt, int caps_len)
int i = 0;
while (i < caps_len) {
- TCHECK2(opt[i], BGP_CAP_HEADER_SIZE);
+ ND_TCHECK2(opt[i], BGP_CAP_HEADER_SIZE);
cap_type=opt[i];
cap_len=opt[i+1];
tcap_len=cap_len;
- printf("\n\t %s (%u), length: %u",
+ ND_PRINT((ndo, "\n\t %s (%u), length: %u",
tok2strbuf(bgp_capcode_values, "Unknown",
cap_type, tokbuf, sizeof(tokbuf)),
cap_type,
- cap_len);
- TCHECK2(opt[i+2], cap_len);
+ cap_len));
+ ND_TCHECK2(opt[i+2], cap_len);
switch (cap_type) {
case BGP_CAPCODE_MP:
- printf("\n\t\tAFI %s (%u), SAFI %s (%u)",
+ ND_PRINT((ndo, "\n\t\tAFI %s (%u), SAFI %s (%u)",
tok2strbuf(af_values, "Unknown",
EXTRACT_16BITS(opt+i+2),
tokbuf, sizeof(tokbuf)),
@@ -2235,16 +2248,16 @@ bgp_capabilities_print(const u_char *opt, int caps_len)
tok2strbuf(bgp_safi_values, "Unknown",
opt[i+5],
tokbuf, sizeof(tokbuf)),
- opt[i+5]);
+ opt[i+5]));
break;
case BGP_CAPCODE_RESTART:
- printf("\n\t\tRestart Flags: [%s], Restart Time %us",
+ ND_PRINT((ndo, "\n\t\tRestart Flags: [%s], Restart Time %us",
((opt[i+2])&0x80) ? "R" : "none",
- EXTRACT_16BITS(opt+i+2)&0xfff);
+ EXTRACT_16BITS(opt+i+2)&0xfff));
tcap_len-=2;
cap_offset=4;
while(tcap_len>=4) {
- printf("\n\t\t AFI %s (%u), SAFI %s (%u), Forwarding state preserved: %s",
+ ND_PRINT((ndo, "\n\t\t AFI %s (%u), SAFI %s (%u), Forwarding state preserved: %s",
tok2strbuf(af_values,"Unknown",
EXTRACT_16BITS(opt+i+cap_offset),
tokbuf, sizeof(tokbuf)),
@@ -2253,7 +2266,7 @@ bgp_capabilities_print(const u_char *opt, int caps_len)
opt[i+cap_offset+2],
tokbuf2, sizeof(tokbuf2)),
opt[i+cap_offset+2],
- ((opt[i+cap_offset+3])&0x80) ? "yes" : "no" );
+ ((opt[i+cap_offset+3])&0x80) ? "yes" : "no" ));
tcap_len-=4;
cap_offset+=4;
}
@@ -2267,31 +2280,32 @@ bgp_capabilities_print(const u_char *opt, int caps_len)
* Extract the 4 byte AS number encoded.
*/
if (cap_len == 4) {
- printf("\n\t\t 4 Byte AS %s",
- as_printf(astostr, sizeof(astostr),
- EXTRACT_32BITS(opt + i + 2)));
+ ND_PRINT((ndo, "\n\t\t 4 Byte AS %s",
+ as_printf(ndo, astostr, sizeof(astostr),
+ EXTRACT_32BITS(opt + i + 2))));
}
break;
default:
- printf("\n\t\tno decoder for Capability %u",
- cap_type);
- if (vflag <= 1)
- print_unknown_data(&opt[i+2],"\n\t\t",cap_len);
+ ND_PRINT((ndo, "\n\t\tno decoder for Capability %u",
+ cap_type));
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo, &opt[i+2], "\n\t\t", cap_len);
break;
}
- if (vflag > 1 && cap_len > 0) {
- print_unknown_data(&opt[i+2],"\n\t\t",cap_len);
+ if (ndo->ndo_vflag > 1 && cap_len > 0) {
+ print_unknown_data(ndo, &opt[i+2], "\n\t\t", cap_len);
}
i += BGP_CAP_HEADER_SIZE + cap_len;
}
return;
trunc:
- printf("[|BGP]");
+ ND_PRINT((ndo, "[|BGP]"));
}
static void
-bgp_open_print(const u_char *dat, int length)
+bgp_open_print(netdissect_options *ndo,
+ const u_char *dat, int length)
{
struct bgp_open bgpo;
struct bgp_opt bgpopt;
@@ -2299,18 +2313,18 @@ bgp_open_print(const u_char *dat, int length)
int i;
char tokbuf[TOKBUFSIZE];
- TCHECK2(dat[0], BGP_OPEN_SIZE);
+ ND_TCHECK2(dat[0], BGP_OPEN_SIZE);
memcpy(&bgpo, dat, BGP_OPEN_SIZE);
- printf("\n\t Version %d, ", bgpo.bgpo_version);
- printf("my AS %s, ",
- as_printf(astostr, sizeof(astostr), ntohs(bgpo.bgpo_myas)));
- printf("Holdtime %us, ", ntohs(bgpo.bgpo_holdtime));
- printf("ID %s", getname((u_char *)&bgpo.bgpo_id));
- printf("\n\t Optional parameters, length: %u", bgpo.bgpo_optlen);
+ ND_PRINT((ndo, "\n\t Version %d, ", bgpo.bgpo_version));
+ ND_PRINT((ndo, "my AS %s, ",
+ as_printf(ndo, astostr, sizeof(astostr), ntohs(bgpo.bgpo_myas))));
+ ND_PRINT((ndo, "Holdtime %us, ", ntohs(bgpo.bgpo_holdtime)));
+ ND_PRINT((ndo, "ID %s", getname(ndo, (u_char *)&bgpo.bgpo_id)));
+ ND_PRINT((ndo, "\n\t Optional parameters, length: %u", bgpo.bgpo_optlen));
/* some little sanity checking */
- if (length < bgpo.bgpo_optlen+BGP_OPEN_SIZE)
+ if (length < bgpo.bgpo_optlen+BGP_OPEN_SIZE)
return;
/* ugly! */
@@ -2319,43 +2333,44 @@ bgp_open_print(const u_char *dat, int length)
i = 0;
while (i < bgpo.bgpo_optlen) {
- TCHECK2(opt[i], BGP_OPT_SIZE);
+ ND_TCHECK2(opt[i], BGP_OPT_SIZE);
memcpy(&bgpopt, &opt[i], BGP_OPT_SIZE);
if (i + 2 + bgpopt.bgpopt_len > bgpo.bgpo_optlen) {
- printf("\n\t Option %d, length: %u", bgpopt.bgpopt_type, bgpopt.bgpopt_len);
+ ND_PRINT((ndo, "\n\t Option %d, length: %u", bgpopt.bgpopt_type, bgpopt.bgpopt_len));
break;
}
- printf("\n\t Option %s (%u), length: %u",
+ ND_PRINT((ndo, "\n\t Option %s (%u), length: %u",
tok2strbuf(bgp_opt_values,"Unknown",
bgpopt.bgpopt_type,
tokbuf, sizeof(tokbuf)),
bgpopt.bgpopt_type,
- bgpopt.bgpopt_len);
+ bgpopt.bgpopt_len));
/* now let's decode the options we know*/
switch(bgpopt.bgpopt_type) {
case BGP_OPT_CAP:
- bgp_capabilities_print(&opt[i+BGP_OPT_SIZE],
+ bgp_capabilities_print(ndo, &opt[i+BGP_OPT_SIZE],
bgpopt.bgpopt_len);
break;
case BGP_OPT_AUTH:
default:
- printf("\n\t no decoder for option %u",
- bgpopt.bgpopt_type);
+ ND_PRINT((ndo, "\n\t no decoder for option %u",
+ bgpopt.bgpopt_type));
break;
}
i += BGP_OPT_SIZE + bgpopt.bgpopt_len;
}
return;
trunc:
- printf("[|BGP]");
+ ND_PRINT((ndo, "[|BGP]"));
}
static void
-bgp_update_print(const u_char *dat, int length)
+bgp_update_print(netdissect_options *ndo,
+ const u_char *dat, int length)
{
struct bgp bgp;
const u_char *p;
@@ -2368,7 +2383,7 @@ bgp_update_print(const u_char *dat, int length)
int wpfx;
#endif
- TCHECK2(dat[0], BGP_SIZE);
+ ND_TCHECK2(dat[0], BGP_SIZE);
if (length < BGP_SIZE)
goto trunc;
memcpy(&bgp, dat, BGP_SIZE);
@@ -2376,7 +2391,7 @@ bgp_update_print(const u_char *dat, int length)
length -= BGP_SIZE;
/* Unfeasible routes */
- TCHECK2(p[0], 2);
+ ND_TCHECK2(p[0], 2);
if (length < 2)
goto trunc;
withdrawn_routes_len = EXTRACT_16BITS(p);
@@ -2388,11 +2403,11 @@ bgp_update_print(const u_char *dat, int length)
* it's not possible to tell if this a v4 or v6 route,
* so only try to decode it if we're not v6 enabled.
*/
- TCHECK2(p[0], withdrawn_routes_len);
+ ND_TCHECK2(p[0], withdrawn_routes_len);
if (length < withdrawn_routes_len)
goto trunc;
#ifdef INET6
- printf("\n\t Withdrawn routes: %d bytes", withdrawn_routes_len);
+ ND_PRINT((ndo, "\n\t Withdrawn routes: %d bytes", withdrawn_routes_len));
p += withdrawn_routes_len;
length -= withdrawn_routes_len;
#else
@@ -2402,19 +2417,19 @@ bgp_update_print(const u_char *dat, int length)
withdrawn_routes_len -= 2;
- printf("\n\t Withdrawn routes:");
+ ND_PRINT((ndo, "\n\t Withdrawn routes:"));
while(withdrawn_routes_len > 0) {
- wpfx = decode_prefix4(p, withdrawn_routes_len, buf, sizeof(buf));
+ wpfx = decode_prefix4(ndo, p, withdrawn_routes_len, buf, sizeof(buf));
if (wpfx == -1) {
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
break;
} else if (wpfx == -2)
goto trunc;
else if (wpfx == -3)
goto trunc; /* bytes left, but not enough */
else {
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
p += wpfx;
length -= wpfx;
withdrawn_routes_len -= wpfx;
@@ -2423,7 +2438,7 @@ bgp_update_print(const u_char *dat, int length)
#endif
}
- TCHECK2(p[0], 2);
+ ND_TCHECK2(p[0], 2);
if (length < 2)
goto trunc;
len = EXTRACT_16BITS(p);
@@ -2432,7 +2447,7 @@ bgp_update_print(const u_char *dat, int length)
if (withdrawn_routes_len == 0 && len == 0 && length == 0) {
/* No withdrawn routes, no path attributes, no NLRI */
- printf("\n\t End-of-Rib Marker (empty NLRI)");
+ ND_PRINT((ndo, "\n\t End-of-Rib Marker (empty NLRI)"));
return;
}
@@ -2441,7 +2456,7 @@ bgp_update_print(const u_char *dat, int length)
while (len) {
int aflags, atype, alenlen, alen;
- TCHECK2(p[0], 2);
+ ND_TCHECK2(p[0], 2);
if (len < 2)
goto trunc;
if (length < 2)
@@ -2452,7 +2467,7 @@ bgp_update_print(const u_char *dat, int length)
len -= 2;
length -= 2;
alenlen = bgp_attr_lenlen(aflags, p);
- TCHECK2(p[0], alenlen);
+ ND_TCHECK2(p[0], alenlen);
if (len < alenlen)
goto trunc;
if (length < alenlen)
@@ -2462,34 +2477,34 @@ bgp_update_print(const u_char *dat, int length)
len -= alenlen;
length -= alenlen;
- printf("\n\t %s (%u), length: %u",
+ ND_PRINT((ndo, "\n\t %s (%u), length: %u",
tok2strbuf(bgp_attr_values, "Unknown Attribute",
atype,
tokbuf, sizeof(tokbuf)),
atype,
- alen);
+ alen));
if (aflags) {
- printf(", Flags [%s%s%s%s",
+ ND_PRINT((ndo, ", Flags [%s%s%s%s",
aflags & 0x80 ? "O" : "",
aflags & 0x40 ? "T" : "",
aflags & 0x20 ? "P" : "",
- aflags & 0x10 ? "E" : "");
+ aflags & 0x10 ? "E" : ""));
if (aflags & 0xf)
- printf("+%x", aflags & 0xf);
- printf("]: ");
+ ND_PRINT((ndo, "+%x", aflags & 0xf));
+ ND_PRINT((ndo, "]: "));
}
if (len < alen)
goto trunc;
if (length < alen)
goto trunc;
- if (!bgp_attr_print(atype, p, alen))
+ if (!bgp_attr_print(ndo, atype, p, alen))
goto trunc;
p += alen;
len -= alen;
length -= alen;
}
- }
+ }
if (length) {
/*
@@ -2500,19 +2515,19 @@ bgp_update_print(const u_char *dat, int length)
*
* http://tools.ietf.org/html/draft-ietf-idr-add-paths-06
*/
- printf("\n\t Updated routes:");
+ ND_PRINT((ndo, "\n\t Updated routes:"));
while (length) {
char buf[MAXHOSTNAMELEN + 100];
- i = decode_prefix4(p, length, buf, sizeof(buf));
+ i = decode_prefix4(ndo, p, length, buf, sizeof(buf));
if (i == -1) {
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
break;
} else if (i == -2)
goto trunc;
else if (i == -3)
goto trunc; /* bytes left, but not enough */
else {
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
p += i;
length -= i;
}
@@ -2520,74 +2535,75 @@ bgp_update_print(const u_char *dat, int length)
}
return;
trunc:
- printf("[|BGP]");
+ ND_PRINT((ndo, "[|BGP]"));
}
static void
-bgp_notification_print(const u_char *dat, int length)
+bgp_notification_print(netdissect_options *ndo,
+ const u_char *dat, int length)
{
struct bgp_notification bgpn;
const u_char *tptr;
char tokbuf[TOKBUFSIZE];
char tokbuf2[TOKBUFSIZE];
- TCHECK2(dat[0], BGP_NOTIFICATION_SIZE);
+ ND_TCHECK2(dat[0], BGP_NOTIFICATION_SIZE);
memcpy(&bgpn, dat, BGP_NOTIFICATION_SIZE);
/* some little sanity checking */
if (length<BGP_NOTIFICATION_SIZE)
return;
- printf(", %s (%u)",
+ ND_PRINT((ndo, ", %s (%u)",
tok2strbuf(bgp_notify_major_values, "Unknown Error",
bgpn.bgpn_major, tokbuf, sizeof(tokbuf)),
- bgpn.bgpn_major);
+ bgpn.bgpn_major));
switch (bgpn.bgpn_major) {
case BGP_NOTIFY_MAJOR_MSG:
- printf(", subcode %s (%u)",
+ ND_PRINT((ndo, ", subcode %s (%u)",
tok2strbuf(bgp_notify_minor_msg_values, "Unknown",
bgpn.bgpn_minor, tokbuf, sizeof(tokbuf)),
- bgpn.bgpn_minor);
+ bgpn.bgpn_minor));
break;
case BGP_NOTIFY_MAJOR_OPEN:
- printf(", subcode %s (%u)",
+ ND_PRINT((ndo, ", subcode %s (%u)",
tok2strbuf(bgp_notify_minor_open_values, "Unknown",
bgpn.bgpn_minor, tokbuf, sizeof(tokbuf)),
- bgpn.bgpn_minor);
+ bgpn.bgpn_minor));
break;
case BGP_NOTIFY_MAJOR_UPDATE:
- printf(", subcode %s (%u)",
+ ND_PRINT((ndo, ", subcode %s (%u)",
tok2strbuf(bgp_notify_minor_update_values, "Unknown",
bgpn.bgpn_minor, tokbuf, sizeof(tokbuf)),
- bgpn.bgpn_minor);
+ bgpn.bgpn_minor));
break;
case BGP_NOTIFY_MAJOR_CAP:
- printf(" subcode %s (%u)",
+ ND_PRINT((ndo, " subcode %s (%u)",
tok2strbuf(bgp_notify_minor_cap_values, "Unknown",
bgpn.bgpn_minor, tokbuf, sizeof(tokbuf)),
- bgpn.bgpn_minor);
+ bgpn.bgpn_minor));
case BGP_NOTIFY_MAJOR_CEASE:
- printf(", subcode %s (%u)",
+ ND_PRINT((ndo, ", subcode %s (%u)",
tok2strbuf(bgp_notify_minor_cease_values, "Unknown",
bgpn.bgpn_minor, tokbuf, sizeof(tokbuf)),
- bgpn.bgpn_minor);
+ bgpn.bgpn_minor));
/* draft-ietf-idr-cease-subcode-02 mentions optionally 7 bytes
* for the maxprefix subtype, which may contain AFI, SAFI and MAXPREFIXES
*/
if(bgpn.bgpn_minor == BGP_NOTIFY_MINOR_CEASE_MAXPRFX && length >= BGP_NOTIFICATION_SIZE + 7) {
tptr = dat + BGP_NOTIFICATION_SIZE;
- TCHECK2(*tptr, 7);
- printf(", AFI %s (%u), SAFI %s (%u), Max Prefixes: %u",
+ ND_TCHECK2(*tptr, 7);
+ ND_PRINT((ndo, ", AFI %s (%u), SAFI %s (%u), Max Prefixes: %u",
tok2strbuf(af_values, "Unknown",
EXTRACT_16BITS(tptr), tokbuf, sizeof(tokbuf)),
EXTRACT_16BITS(tptr),
tok2strbuf(bgp_safi_values, "Unknown", *(tptr+2),
tokbuf2, sizeof(tokbuf)),
*(tptr+2),
- EXTRACT_32BITS(tptr+3));
+ EXTRACT_32BITS(tptr+3)));
}
break;
default:
@@ -2596,17 +2612,18 @@ bgp_notification_print(const u_char *dat, int length)
return;
trunc:
- printf("[|BGP]");
+ ND_PRINT((ndo, "[|BGP]"));
}
static void
-bgp_route_refresh_print(const u_char *pptr, int len) {
+bgp_route_refresh_print(netdissect_options *ndo,
+ const u_char *pptr, int len) {
const struct bgp_route_refresh *bgp_route_refresh_header;
char tokbuf[TOKBUFSIZE];
char tokbuf2[TOKBUFSIZE];
- TCHECK2(pptr[0], BGP_ROUTE_REFRESH_SIZE);
+ ND_TCHECK2(pptr[0], BGP_ROUTE_REFRESH_SIZE);
/* some little sanity checking */
if (len<BGP_ROUTE_REFRESH_SIZE)
@@ -2614,72 +2631,74 @@ bgp_route_refresh_print(const u_char *pptr, int len) {
bgp_route_refresh_header = (const struct bgp_route_refresh *)pptr;
- printf("\n\t AFI %s (%u), SAFI %s (%u)",
+ ND_PRINT((ndo, "\n\t AFI %s (%u), SAFI %s (%u)",
tok2strbuf(af_values,"Unknown",
/* this stinks but the compiler pads the structure
* weird */
EXTRACT_16BITS(&bgp_route_refresh_header->afi),
- tokbuf, sizeof(tokbuf)),
+ tokbuf, sizeof(tokbuf)),
EXTRACT_16BITS(&bgp_route_refresh_header->afi),
tok2strbuf(bgp_safi_values,"Unknown",
bgp_route_refresh_header->safi,
tokbuf2, sizeof(tokbuf2)),
- bgp_route_refresh_header->safi);
+ bgp_route_refresh_header->safi));
- if (vflag > 1) {
- TCHECK2(*pptr, len);
- print_unknown_data(pptr,"\n\t ", len);
+ if (ndo->ndo_vflag > 1) {
+ ND_TCHECK2(*pptr, len);
+ print_unknown_data(ndo, pptr, "\n\t ", len);
}
-
+
return;
trunc:
- printf("[|BGP]");
+ ND_PRINT((ndo, "[|BGP]"));
}
static int
-bgp_header_print(const u_char *dat, int length)
+bgp_header_print(netdissect_options *ndo,
+ const u_char *dat, int length)
{
struct bgp bgp;
char tokbuf[TOKBUFSIZE];
- TCHECK2(dat[0], BGP_SIZE);
+ ND_TCHECK2(dat[0], BGP_SIZE);
memcpy(&bgp, dat, BGP_SIZE);
- printf("\n\t%s Message (%u), length: %u",
+ ND_PRINT((ndo, "\n\t%s Message (%u), length: %u",
tok2strbuf(bgp_msg_values, "Unknown", bgp.bgp_type,
tokbuf, sizeof(tokbuf)),
bgp.bgp_type,
- length);
+ length));
switch (bgp.bgp_type) {
case BGP_OPEN:
- bgp_open_print(dat, length);
+ bgp_open_print(ndo, dat, length);
break;
case BGP_UPDATE:
- bgp_update_print(dat, length);
+ bgp_update_print(ndo, dat, length);
break;
case BGP_NOTIFICATION:
- bgp_notification_print(dat, length);
+ bgp_notification_print(ndo, dat, length);
break;
case BGP_KEEPALIVE:
break;
case BGP_ROUTE_REFRESH:
- bgp_route_refresh_print(dat, length);
+ bgp_route_refresh_print(ndo, dat, length);
break;
default:
/* we have no decoder for the BGP message */
- TCHECK2(*dat, length);
- printf("\n\t no Message %u decoder",bgp.bgp_type);
- print_unknown_data(dat,"\n\t ",length);
+ ND_TCHECK2(*dat, length);
+ ND_PRINT((ndo, "\n\t no Message %u decoder", bgp.bgp_type));
+ print_unknown_data(ndo, dat, "\n\t ", length);
break;
}
return 1;
trunc:
- printf("[|BGP]");
+ ND_PRINT((ndo, "[|BGP]"));
return 0;
}
void
-bgp_print(const u_char *dat, int length)
+bgp_print(netdissect_options *ndo,
+ const u_char *dat, int length)
{
const u_char *p;
const u_char *ep;
@@ -2689,29 +2708,29 @@ bgp_print(const u_char *dat, int length)
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
};
struct bgp bgp;
- u_int16_t hlen;
+ uint16_t hlen;
char tokbuf[TOKBUFSIZE];
ep = dat + length;
- if (snapend < dat + length)
- ep = snapend;
+ if (ndo->ndo_snapend < dat + length)
+ ep = ndo->ndo_snapend;
- printf(": BGP, length: %u",length);
+ ND_PRINT((ndo, ": BGP, length: %u", length));
- if (vflag < 1) /* lets be less chatty */
+ if (ndo->ndo_vflag < 1) /* lets be less chatty */
return;
p = dat;
start = p;
while (p < ep) {
- if (!TTEST2(p[0], 1))
+ if (!ND_TTEST2(p[0], 1))
break;
if (p[0] != 0xff) {
p++;
continue;
}
- if (!TTEST2(p[0], sizeof(marker)))
+ if (!ND_TTEST2(p[0], sizeof(marker)))
break;
if (memcmp(p, marker, sizeof(marker)) != 0) {
p++;
@@ -2719,30 +2738,30 @@ bgp_print(const u_char *dat, int length)
}
/* found BGP header */
- TCHECK2(p[0], BGP_SIZE); /*XXX*/
+ ND_TCHECK2(p[0], BGP_SIZE); /*XXX*/
memcpy(&bgp, p, BGP_SIZE);
if (start != p)
- printf(" [|BGP]");
+ ND_PRINT((ndo, " [|BGP]"));
hlen = ntohs(bgp.bgp_len);
if (hlen < BGP_SIZE) {
- printf("\n[|BGP Bogus header length %u < %u]", hlen,
- BGP_SIZE);
+ ND_PRINT((ndo, "\n[|BGP Bogus header length %u < %u]", hlen,
+ BGP_SIZE));
break;
}
- if (TTEST2(p[0], hlen)) {
- if (!bgp_header_print(p, hlen))
+ if (ND_TTEST2(p[0], hlen)) {
+ if (!bgp_header_print(ndo, p, hlen))
return;
p += hlen;
start = p;
} else {
- printf("\n[|BGP %s]",
+ ND_PRINT((ndo, "\n[|BGP %s]",
tok2strbuf(bgp_msg_values,
"Unknown Message Type",
bgp.bgp_type,
- tokbuf, sizeof(tokbuf)));
+ tokbuf, sizeof(tokbuf))));
break;
}
}
@@ -2750,7 +2769,7 @@ bgp_print(const u_char *dat, int length)
return;
trunc:
- printf(" [|BGP]");
+ ND_PRINT((ndo, " [|BGP]"));
}
/*
diff --git a/contrib/tcpdump/print-bootp.c b/contrib/tcpdump/print-bootp.c
index 4791c2566ca6..dbca1f21ab6e 100644
--- a/contrib/tcpdump/print-bootp.c
+++ b/contrib/tcpdump/print-bootp.c
@@ -22,31 +22,26 @@
*
* $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.89 2008-04-22 09:45:08 hannes Exp $ (LBL)";
-#endif
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
#include <string.h>
#include "interface.h"
#include "addrtoname.h"
#include "extract.h"
-#include "ether.h"
#include "bootp.h"
-static void rfc1048_print(const u_char *);
-static void cmu_print(const u_char *);
-static char *client_fqdn_flags(u_int flags);
+static const char tstr[] = " [|bootp]";
-static char tstr[] = " [|bootp]";
+static void rfc1048_print(netdissect_options *, const u_char *);
+static void cmu_print(netdissect_options *, const u_char *);
+static char *client_fqdn_flags(u_int flags);
static const struct tok bootp_flag_values[] = {
{ 0x8000, "Broadcast" },
@@ -63,117 +58,118 @@ static const struct tok bootp_op_values[] = {
* Print bootp requests
*/
void
-bootp_print(register const u_char *cp, u_int length)
+bootp_print(netdissect_options *ndo,
+ register const u_char *cp, u_int length)
{
register const struct bootp *bp;
static const u_char vm_cmu[4] = VM_CMU;
static const u_char vm_rfc1048[4] = VM_RFC1048;
bp = (const struct bootp *)cp;
- TCHECK(bp->bp_op);
+ ND_TCHECK(bp->bp_op);
- printf("BOOTP/DHCP, %s",
- tok2str(bootp_op_values, "unknown (0x%02x)", bp->bp_op));
+ ND_PRINT((ndo, "BOOTP/DHCP, %s",
+ tok2str(bootp_op_values, "unknown (0x%02x)", bp->bp_op)));
if (bp->bp_htype == 1 && bp->bp_hlen == 6 && bp->bp_op == BOOTPREQUEST) {
- TCHECK2(bp->bp_chaddr[0], 6);
- printf(" from %s", etheraddr_string(bp->bp_chaddr));
+ ND_TCHECK2(bp->bp_chaddr[0], 6);
+ ND_PRINT((ndo, " from %s", etheraddr_string(ndo, bp->bp_chaddr)));
}
- printf(", length %u", length);
+ ND_PRINT((ndo, ", length %u", length));
- if (!vflag)
- return;
+ if (!ndo->ndo_vflag)
+ return;
- TCHECK(bp->bp_secs);
+ ND_TCHECK(bp->bp_secs);
/* The usual hardware address type is 1 (10Mb Ethernet) */
if (bp->bp_htype != 1)
- printf(", htype %d", bp->bp_htype);
+ ND_PRINT((ndo, ", htype %d", bp->bp_htype));
/* The usual length for 10Mb Ethernet address is 6 bytes */
if (bp->bp_htype != 1 || bp->bp_hlen != 6)
- printf(", hlen %d", bp->bp_hlen);
+ ND_PRINT((ndo, ", hlen %d", bp->bp_hlen));
/* Only print interesting fields */
if (bp->bp_hops)
- printf(", hops %d", bp->bp_hops);
- if (bp->bp_xid)
- printf(", xid 0x%x", EXTRACT_32BITS(&bp->bp_xid));
- if (bp->bp_secs)
- printf(", secs %d", EXTRACT_16BITS(&bp->bp_secs));
+ ND_PRINT((ndo, ", hops %d", bp->bp_hops));
+ if (EXTRACT_32BITS(&bp->bp_xid))
+ ND_PRINT((ndo, ", xid 0x%x", EXTRACT_32BITS(&bp->bp_xid)));
+ if (EXTRACT_16BITS(&bp->bp_secs))
+ ND_PRINT((ndo, ", secs %d", EXTRACT_16BITS(&bp->bp_secs)));
- printf(", Flags [%s]",
- bittok2str(bootp_flag_values, "none", EXTRACT_16BITS(&bp->bp_flags)));
- if (vflag > 1)
- printf(" (0x%04x)", EXTRACT_16BITS(&bp->bp_flags));
+ ND_PRINT((ndo, ", Flags [%s]",
+ bittok2str(bootp_flag_values, "none", EXTRACT_16BITS(&bp->bp_flags))));
+ if (ndo->ndo_vflag > 1)
+ ND_PRINT((ndo, " (0x%04x)", EXTRACT_16BITS(&bp->bp_flags)));
/* Client's ip address */
- TCHECK(bp->bp_ciaddr);
- if (bp->bp_ciaddr.s_addr)
- printf("\n\t Client-IP %s", ipaddr_string(&bp->bp_ciaddr));
+ ND_TCHECK(bp->bp_ciaddr);
+ if (EXTRACT_32BITS(&bp->bp_ciaddr.s_addr))
+ ND_PRINT((ndo, "\n\t Client-IP %s", ipaddr_string(ndo, &bp->bp_ciaddr)));
/* 'your' ip address (bootp client) */
- TCHECK(bp->bp_yiaddr);
- if (bp->bp_yiaddr.s_addr)
- printf("\n\t Your-IP %s", ipaddr_string(&bp->bp_yiaddr));
+ ND_TCHECK(bp->bp_yiaddr);
+ if (EXTRACT_32BITS(&bp->bp_yiaddr.s_addr))
+ ND_PRINT((ndo, "\n\t Your-IP %s", ipaddr_string(ndo, &bp->bp_yiaddr)));
/* Server's ip address */
- TCHECK(bp->bp_siaddr);
- if (bp->bp_siaddr.s_addr)
- printf("\n\t Server-IP %s", ipaddr_string(&bp->bp_siaddr));
+ ND_TCHECK(bp->bp_siaddr);
+ if (EXTRACT_32BITS(&bp->bp_siaddr.s_addr))
+ ND_PRINT((ndo, "\n\t Server-IP %s", ipaddr_string(ndo, &bp->bp_siaddr)));
/* Gateway's ip address */
- TCHECK(bp->bp_giaddr);
- if (bp->bp_giaddr.s_addr)
- printf("\n\t Gateway-IP %s", ipaddr_string(&bp->bp_giaddr));
+ ND_TCHECK(bp->bp_giaddr);
+ if (EXTRACT_32BITS(&bp->bp_giaddr.s_addr))
+ ND_PRINT((ndo, "\n\t Gateway-IP %s", ipaddr_string(ndo, &bp->bp_giaddr)));
/* Client's Ethernet address */
if (bp->bp_htype == 1 && bp->bp_hlen == 6) {
- TCHECK2(bp->bp_chaddr[0], 6);
- printf("\n\t Client-Ethernet-Address %s", etheraddr_string(bp->bp_chaddr));
+ ND_TCHECK2(bp->bp_chaddr[0], 6);
+ ND_PRINT((ndo, "\n\t Client-Ethernet-Address %s", etheraddr_string(ndo, bp->bp_chaddr)));
}
- TCHECK2(bp->bp_sname[0], 1); /* check first char only */
+ ND_TCHECK2(bp->bp_sname[0], 1); /* check first char only */
if (*bp->bp_sname) {
- printf("\n\t sname \"");
- if (fn_print(bp->bp_sname, snapend)) {
- putchar('"');
- fputs(tstr + 1, stdout);
+ ND_PRINT((ndo, "\n\t sname \""));
+ if (fn_print(ndo, bp->bp_sname, ndo->ndo_snapend)) {
+ ND_PRINT((ndo, "\""));
+ ND_PRINT((ndo, "%s", tstr + 1));
return;
}
- putchar('"');
+ ND_PRINT((ndo, "\""));
}
- TCHECK2(bp->bp_file[0], 1); /* check first char only */
+ ND_TCHECK2(bp->bp_file[0], 1); /* check first char only */
if (*bp->bp_file) {
- printf("\n\t file \"");
- if (fn_print(bp->bp_file, snapend)) {
- putchar('"');
- fputs(tstr + 1, stdout);
+ ND_PRINT((ndo, "\n\t file \""));
+ if (fn_print(ndo, bp->bp_file, ndo->ndo_snapend)) {
+ ND_PRINT((ndo, "\""));
+ ND_PRINT((ndo, "%s", tstr + 1));
return;
}
- putchar('"');
+ ND_PRINT((ndo, "\""));
}
/* Decode the vendor buffer */
- TCHECK(bp->bp_vend[0]);
+ ND_TCHECK(bp->bp_vend[0]);
if (memcmp((const char *)bp->bp_vend, vm_rfc1048,
- sizeof(u_int32_t)) == 0)
- rfc1048_print(bp->bp_vend);
+ sizeof(uint32_t)) == 0)
+ rfc1048_print(ndo, bp->bp_vend);
else if (memcmp((const char *)bp->bp_vend, vm_cmu,
- sizeof(u_int32_t)) == 0)
- cmu_print(bp->bp_vend);
+ sizeof(uint32_t)) == 0)
+ cmu_print(ndo, bp->bp_vend);
else {
- u_int32_t ul;
+ uint32_t ul;
ul = EXTRACT_32BITS(&bp->bp_vend);
if (ul != 0)
- printf("\n\t Vendor-#0x%x", ul);
+ ND_PRINT((ndo, "\n\t Vendor-#0x%x", ul));
}
return;
trunc:
- fputs(tstr, stdout);
+ ND_PRINT((ndo, "%s", tstr));
}
/*
@@ -189,7 +185,7 @@ trunc:
* B - on/off (8 bits)
* $ - special (explicit code to handle)
*/
-static struct tok tag2str[] = {
+static const struct tok tag2str[] = {
/* RFC1048 tags */
{ TAG_PAD, " PAD" },
{ TAG_SUBNET_MASK, "iSubnet-Mask" }, /* subnet mask (RFC950) */
@@ -310,12 +306,12 @@ static struct tok tag2str[] = {
{ 0, NULL }
};
/* 2-byte extended tags */
-static struct tok xtag2str[] = {
+static const struct tok xtag2str[] = {
{ 0, NULL }
};
/* DHCP "options overload" types */
-static struct tok oo2str[] = {
+static const struct tok oo2str[] = {
{ 1, "file" },
{ 2, "sname" },
{ 3, "file+sname" },
@@ -323,7 +319,7 @@ static struct tok oo2str[] = {
};
/* NETBIOS over TCP/IP node type options */
-static struct tok nbo2str[] = {
+static const struct tok nbo2str[] = {
{ 0x1, "b-node" },
{ 0x2, "p-node" },
{ 0x4, "m-node" },
@@ -332,7 +328,7 @@ static struct tok nbo2str[] = {
};
/* ARP Hardware types, for Client-ID option */
-static struct tok arp2str[] = {
+static const struct tok arp2str[] = {
{ 0x1, "ether" },
{ 0x6, "ieee802" },
{ 0x7, "arcnet" },
@@ -342,7 +338,7 @@ static struct tok arp2str[] = {
{ 0, NULL }
};
-static struct tok dhcp_msg_values[] = {
+static const struct tok dhcp_msg_values[] = {
{ DHCPDISCOVER, "Discover" },
{ DHCPOFFER, "Offer" },
{ DHCPREQUEST, "Request" },
@@ -357,7 +353,7 @@ static struct tok dhcp_msg_values[] = {
#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[] = {
+static const struct tok agent_suboption_values[] = {
{ AGENT_SUBOPTION_CIRCUIT_ID, "Circuit-ID" },
{ AGENT_SUBOPTION_REMOTE_ID, "Remote-ID" },
{ AGENT_SUBOPTION_SUBSCRIBER_ID, "Subscriber-ID" },
@@ -366,32 +362,33 @@ static struct tok agent_suboption_values[] = {
static void
-rfc1048_print(register const u_char *bp)
+rfc1048_print(netdissect_options *ndo,
+ register const u_char *bp)
{
- register u_int16_t tag;
+ register uint16_t tag;
register u_int len;
register const char *cp;
register char c;
int first, idx;
- u_int32_t ul;
- u_int16_t us;
- u_int8_t uc, subopt, suboptlen;
+ uint32_t ul;
+ uint16_t us;
+ uint8_t uc, subopt, suboptlen;
- printf("\n\t Vendor-rfc1048 Extensions");
+ ND_PRINT((ndo, "\n\t Vendor-rfc1048 Extensions"));
/* Step over magic cookie */
- printf("\n\t Magic Cookie 0x%08x", EXTRACT_32BITS(bp));
+ ND_PRINT((ndo, "\n\t Magic Cookie 0x%08x", EXTRACT_32BITS(bp)));
bp += sizeof(int32_t);
/* Loop while we there is a tag left in the buffer */
- while (TTEST2(*bp, 1)) {
+ while (ND_TTEST2(*bp, 1)) {
tag = *bp++;
- if (tag == TAG_PAD && vflag < 3)
+ if (tag == TAG_PAD && ndo->ndo_vflag < 3)
continue;
- if (tag == TAG_END && vflag < 3)
+ if (tag == TAG_END && ndo->ndo_vflag < 3)
return;
if (tag == TAG_EXTENDED_OPTION) {
- TCHECK2(*(bp + 1), 2);
+ ND_TCHECK2(*(bp + 1), 2);
tag = EXTRACT_16BITS(bp + 1);
/* XXX we don't know yet if the IANA will
* preclude overlap of 1-byte and 2-byte spaces.
@@ -406,32 +403,32 @@ rfc1048_print(register const u_char *bp)
len = 0;
else {
/* Get the length; check for truncation */
- TCHECK2(*bp, 1);
+ ND_TCHECK2(*bp, 1);
len = *bp++;
}
- printf("\n\t %s Option %u, length %u%s", cp, tag, len,
- len > 0 ? ": " : "");
+ ND_PRINT((ndo, "\n\t %s Option %u, length %u%s", cp, tag, len,
+ len > 0 ? ": " : ""));
- if (tag == TAG_PAD && vflag > 2) {
+ if (tag == TAG_PAD && ndo->ndo_vflag > 2) {
u_int ntag = 1;
- while (TTEST2(*bp, 1) && *bp == TAG_PAD) {
+ while (ND_TTEST2(*bp, 1) && *bp == TAG_PAD) {
bp++;
ntag++;
}
if (ntag > 1)
- printf(", occurs %u", ntag);
+ ND_PRINT((ndo, ", occurs %u", ntag));
}
- if (!TTEST2(*bp, len)) {
- printf("[|rfc1048 %u]", len);
+ if (!ND_TTEST2(*bp, len)) {
+ ND_PRINT((ndo, "[|rfc1048 %u]", len));
return;
}
if (tag == TAG_DHCP_MESSAGE && len == 1) {
uc = *bp++;
- printf("%s", tok2str(dhcp_msg_values, "Unknown (%u)", uc));
- continue;
+ ND_PRINT((ndo, "%s", tok2str(dhcp_msg_values, "Unknown (%u)", uc)));
+ continue;
}
if (tag == TAG_PARM_REQUEST) {
@@ -440,10 +437,10 @@ rfc1048_print(register const u_char *bp)
uc = *bp++;
cp = tok2str(tag2str, "?Option %u", uc);
if (idx % 4 == 0)
- printf("\n\t ");
+ ND_PRINT((ndo, "\n\t "));
else
- printf(", ");
- printf("%s", cp + 1);
+ ND_PRINT((ndo, ", "));
+ ND_PRINT((ndo, "%s", cp + 1));
idx++;
}
continue;
@@ -457,8 +454,8 @@ rfc1048_print(register const u_char *bp)
bp += 2;
cp = tok2str(xtag2str, "?xT%u", us);
if (!first)
- putchar('+');
- printf("%s", cp + 1);
+ ND_PRINT((ndo, "+"));
+ ND_PRINT((ndo, "%s", cp + 1));
first = 0;
}
continue;
@@ -479,12 +476,12 @@ rfc1048_print(register const u_char *bp)
case 'a':
/* ascii strings */
- putchar('"');
- if (fn_printn(bp, len, snapend)) {
- putchar('"');
+ ND_PRINT((ndo, "\""));
+ if (fn_printn(ndo, bp, len, ndo->ndo_snapend)) {
+ ND_PRINT((ndo, "\""));
goto trunc;
}
- putchar('"');
+ ND_PRINT((ndo, "\""));
bp += len;
len = 0;
break;
@@ -495,15 +492,15 @@ rfc1048_print(register const u_char *bp)
/* ip addresses/32-bit words */
while (len >= sizeof(ul)) {
if (!first)
- putchar(',');
+ ND_PRINT((ndo, ","));
ul = EXTRACT_32BITS(bp);
if (c == 'i') {
ul = htonl(ul);
- printf("%s", ipaddr_string(&ul));
+ ND_PRINT((ndo, "%s", ipaddr_string(ndo, &ul)));
} else if (c == 'L')
- printf("%d", ul);
+ ND_PRINT((ndo, "%d", ul));
else
- printf("%u", ul);
+ ND_PRINT((ndo, "%u", ul));
bp += sizeof(ul);
len -= sizeof(ul);
first = 0;
@@ -514,12 +511,12 @@ rfc1048_print(register const u_char *bp)
/* IP address pairs */
while (len >= 2*sizeof(ul)) {
if (!first)
- putchar(',');
+ ND_PRINT((ndo, ","));
memcpy((char *)&ul, (const char *)bp, sizeof(ul));
- printf("(%s:", ipaddr_string(&ul));
+ ND_PRINT((ndo, "(%s:", ipaddr_string(ndo, &ul)));
bp += sizeof(ul);
memcpy((char *)&ul, (const char *)bp, sizeof(ul));
- printf("%s)", ipaddr_string(&ul));
+ ND_PRINT((ndo, "%s)", ipaddr_string(ndo, &ul)));
bp += sizeof(ul);
len -= 2*sizeof(ul);
first = 0;
@@ -530,9 +527,9 @@ rfc1048_print(register const u_char *bp)
/* shorts */
while (len >= sizeof(us)) {
if (!first)
- putchar(',');
+ ND_PRINT((ndo, ","));
us = EXTRACT_16BITS(bp);
- printf("%u", us);
+ ND_PRINT((ndo, "%u", us));
bp += sizeof(us);
len -= sizeof(us);
first = 0;
@@ -543,16 +540,16 @@ rfc1048_print(register const u_char *bp)
/* boolean */
while (len > 0) {
if (!first)
- putchar(',');
+ ND_PRINT((ndo, ","));
switch (*bp) {
case 0:
- putchar('N');
+ ND_PRINT((ndo, "N"));
break;
case 1:
- putchar('Y');
+ ND_PRINT((ndo, "Y"));
break;
default:
- printf("%u?", *bp);
+ ND_PRINT((ndo, "%u?", *bp));
break;
}
++bp;
@@ -567,11 +564,11 @@ rfc1048_print(register const u_char *bp)
/* Bytes */
while (len > 0) {
if (!first)
- putchar(c == 'x' ? ':' : '.');
+ ND_PRINT((ndo, c == 'x' ? ":" : "."));
if (c == 'x')
- printf("%02x", *bp);
+ ND_PRINT((ndo, "%02x", *bp));
else
- printf("%u", *bp);
+ ND_PRINT((ndo, "%u", *bp));
++bp;
--len;
first = 0;
@@ -585,48 +582,48 @@ rfc1048_print(register const u_char *bp)
case TAG_NETBIOS_NODE:
/* this option should be at least 1 byte long */
if (len < 1) {
- printf("ERROR: option %u len %u < 1 bytes",
- TAG_NETBIOS_NODE, len);
+ ND_PRINT((ndo, "ERROR: option %u len %u < 1 bytes",
+ TAG_NETBIOS_NODE, len));
break;
}
tag = *bp++;
--len;
- fputs(tok2str(nbo2str, NULL, tag), stdout);
+ ND_PRINT((ndo, "%s", tok2str(nbo2str, NULL, tag)));
break;
case TAG_OPT_OVERLOAD:
/* this option should be at least 1 byte long */
if (len < 1) {
- printf("ERROR: option %u len %u < 1 bytes",
- TAG_OPT_OVERLOAD, len);
+ ND_PRINT((ndo, "ERROR: option %u len %u < 1 bytes",
+ TAG_OPT_OVERLOAD, len));
break;
}
tag = *bp++;
--len;
- fputs(tok2str(oo2str, NULL, tag), stdout);
+ ND_PRINT((ndo, "%s", tok2str(oo2str, NULL, tag)));
break;
case TAG_CLIENT_FQDN:
/* this option should be at least 3 bytes long */
if (len < 3) {
- printf("ERROR: option %u len %u < 3 bytes",
- TAG_CLIENT_FQDN, len);
+ ND_PRINT((ndo, "ERROR: option %u len %u < 3 bytes",
+ TAG_CLIENT_FQDN, len));
bp += len;
len = 0;
break;
}
if (*bp)
- printf("[%s] ", client_fqdn_flags(*bp));
+ ND_PRINT((ndo, "[%s] ", client_fqdn_flags(*bp)));
bp++;
if (*bp || *(bp+1))
- printf("%u/%u ", *bp, *(bp+1));
+ ND_PRINT((ndo, "%u/%u ", *bp, *(bp+1)));
bp += 2;
- putchar('"');
- if (fn_printn(bp, len - 3, snapend)) {
- putchar('"');
+ ND_PRINT((ndo, "\""));
+ if (fn_printn(ndo, bp, len - 3, ndo->ndo_snapend)) {
+ ND_PRINT((ndo, "\""));
goto trunc;
}
- putchar('"');
+ ND_PRINT((ndo, "\""));
bp += len - 3;
len = 0;
break;
@@ -636,28 +633,28 @@ rfc1048_print(register const u_char *bp)
/* this option should be at least 1 byte long */
if (len < 1) {
- printf("ERROR: option %u len %u < 1 bytes",
- TAG_CLIENT_ID, len);
+ ND_PRINT((ndo, "ERROR: option %u len %u < 1 bytes",
+ TAG_CLIENT_ID, len));
break;
}
type = *bp++;
len--;
if (type == 0) {
- putchar('"');
- if (fn_printn(bp, len, snapend)) {
- putchar('"');
+ ND_PRINT((ndo, "\""));
+ if (fn_printn(ndo, bp, len, ndo->ndo_snapend)) {
+ ND_PRINT((ndo, "\""));
goto trunc;
}
- putchar('"');
+ ND_PRINT((ndo, "\""));
bp += len;
len = 0;
break;
} else {
- printf("%s ", tok2str(arp2str, "hardware-type %u,", type));
+ ND_PRINT((ndo, "%s ", tok2str(arp2str, "hardware-type %u,", type)));
while (len > 0) {
if (!first)
- putchar(':');
- printf("%02x", *bp);
+ ND_PRINT((ndo, ":"));
+ ND_PRINT((ndo, "%02x", *bp));
++bp;
--len;
first = 0;
@@ -672,28 +669,28 @@ rfc1048_print(register const u_char *bp)
suboptlen = *bp++;
len -= 2;
if (suboptlen > len) {
- printf("\n\t %s SubOption %u, length %u: length goes past end of option",
+ ND_PRINT((ndo, "\n\t %s SubOption %u, length %u: length goes past end of option",
tok2str(agent_suboption_values, "Unknown", subopt),
subopt,
- suboptlen);
+ suboptlen));
bp += len;
len = 0;
break;
}
- printf("\n\t %s SubOption %u, length %u: ",
+ ND_PRINT((ndo, "\n\t %s SubOption %u, length %u: ",
tok2str(agent_suboption_values, "Unknown", subopt),
subopt,
- suboptlen);
+ suboptlen));
switch (subopt) {
- case AGENT_SUBOPTION_CIRCUIT_ID: /* fall through */
- case AGENT_SUBOPTION_REMOTE_ID:
- case AGENT_SUBOPTION_SUBSCRIBER_ID:
- fn_printn(bp, suboptlen, NULL);
- break;
+ case AGENT_SUBOPTION_CIRCUIT_ID: /* fall through */
+ case AGENT_SUBOPTION_REMOTE_ID:
+ case AGENT_SUBOPTION_SUBSCRIBER_ID:
+ fn_printn(ndo, bp, suboptlen, NULL);
+ break;
default:
- print_unknown_data(bp, "\n\t\t", suboptlen);
+ print_unknown_data(ndo, bp, "\n\t\t", suboptlen);
}
len -= suboptlen;
@@ -703,25 +700,25 @@ rfc1048_print(register const u_char *bp)
case TAG_CLASSLESS_STATIC_RT:
case TAG_CLASSLESS_STA_RT_MS:
- {
+ {
u_int mask_width, significant_octets, i;
/* this option should be at least 5 bytes long */
if (len < 5) {
- printf("ERROR: option %u len %u < 5 bytes",
- TAG_CLASSLESS_STATIC_RT, len);
+ ND_PRINT((ndo, "ERROR: option %u len %u < 5 bytes",
+ TAG_CLASSLESS_STATIC_RT, len));
bp += len;
len = 0;
break;
}
while (len > 0) {
if (!first)
- putchar(',');
+ ND_PRINT((ndo, ","));
mask_width = *bp++;
len--;
/* mask_width <= 32 */
if (mask_width > 32) {
- printf("[ERROR: Mask width (%d) > 32]", mask_width);
+ ND_PRINT((ndo, "[ERROR: Mask width (%d) > 32]", mask_width));
bp += len;
len = 0;
break;
@@ -729,26 +726,26 @@ rfc1048_print(register const u_char *bp)
significant_octets = (mask_width + 7) / 8;
/* significant octets + router(4) */
if (len < significant_octets + 4) {
- printf("[ERROR: Remaining length (%u) < %u bytes]", len, significant_octets + 4);
+ ND_PRINT((ndo, "[ERROR: Remaining length (%u) < %u bytes]", len, significant_octets + 4));
bp += len;
len = 0;
break;
}
- putchar('(');
+ ND_PRINT((ndo, "("));
if (mask_width == 0)
- printf("default");
+ ND_PRINT((ndo, "default"));
else {
for (i = 0; i < significant_octets ; i++) {
if (i > 0)
- putchar('.');
- printf("%d", *bp++);
+ ND_PRINT((ndo, "."));
+ ND_PRINT((ndo, "%d", *bp++));
}
for (i = significant_octets ; i < 4 ; i++)
- printf(".0");
- printf("/%d", mask_width);
+ ND_PRINT((ndo, ".0"));
+ ND_PRINT((ndo, "/%d", mask_width));
}
memcpy((char *)&ul, (const char *)bp, sizeof(ul));
- printf(":%s)", ipaddr_string(&ul));
+ ND_PRINT((ndo, ":%s)", ipaddr_string(ndo, &ul)));
bp += sizeof(ul);
len -= (significant_octets + 4);
first = 0;
@@ -757,8 +754,8 @@ rfc1048_print(register const u_char *bp)
break;
default:
- printf("[unknown special tag %u, size %u]",
- tag, len);
+ ND_PRINT((ndo, "[unknown special tag %u, size %u]",
+ tag, len));
bp += len;
len = 0;
break;
@@ -767,31 +764,32 @@ rfc1048_print(register const u_char *bp)
}
/* Data left over? */
if (len) {
- printf("\n\t trailing data length %u", len);
+ ND_PRINT((ndo, "\n\t trailing data length %u", len));
bp += len;
}
}
return;
trunc:
- printf("|[rfc1048]");
+ ND_PRINT((ndo, "|[rfc1048]"));
}
static void
-cmu_print(register const u_char *bp)
+cmu_print(netdissect_options *ndo,
+ register const u_char *bp)
{
register const struct cmu_vend *cmu;
-#define PRINTCMUADDR(m, s) { TCHECK(cmu->m); \
+#define PRINTCMUADDR(m, s) { ND_TCHECK(cmu->m); \
if (cmu->m.s_addr != 0) \
- printf(" %s:%s", s, ipaddr_string(&cmu->m.s_addr)); }
+ ND_PRINT((ndo, " %s:%s", s, ipaddr_string(ndo, &cmu->m.s_addr))); }
- printf(" vend-cmu");
+ ND_PRINT((ndo, " vend-cmu"));
cmu = (const struct cmu_vend *)bp;
/* Only print if there are unknown bits */
- TCHECK(cmu->v_flags);
+ ND_TCHECK(cmu->v_flags);
if ((cmu->v_flags & ~(VF_SMASK)) != 0)
- printf(" F:0x%x", cmu->v_flags);
+ ND_PRINT((ndo, " F:0x%x", cmu->v_flags));
PRINTCMUADDR(v_dgate, "DG");
PRINTCMUADDR(v_smask, cmu->v_flags & VF_SMASK ? "SM" : "SM*");
PRINTCMUADDR(v_dns1, "NS1");
@@ -803,7 +801,7 @@ cmu_print(register const u_char *bp)
return;
trunc:
- fputs(tstr, stdout);
+ ND_PRINT((ndo, "%s", tstr));
#undef PRINTCMUADDR
}
diff --git a/contrib/tcpdump/print-bt.c b/contrib/tcpdump/print-bt.c
index 259f3e5d9c76..128daade063f 100644
--- a/contrib/tcpdump/print-bt.c
+++ b/contrib/tcpdump/print-bt.c
@@ -9,32 +9,23 @@
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
- * ``This product includes software developed by Paolo Abeni.''
- * The name of author may not be used to endorse or promote products derived
+ * ``This product includes software developed by Paolo Abeni.''
+ * The name of author may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-bt.c,v 1.2 2008-09-25 21:45:50 guy Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <pcap.h>
-#include <stdio.h>
-#include <string.h>
-
#include "interface.h"
#include "extract.h"
-#include "addrtoname.h"
#if defined(DLT_BLUETOOTH_HCI_H4_WITH_PHDR) && defined(HAVE_PCAP_BLUETOOTH_H)
#include <pcap/bluetooth.h>
@@ -47,24 +38,24 @@ static const char rcsid[] _U_ =
* is the number of bytes actually captured.
*/
u_int
-bt_if_print(const struct pcap_pkthdr *h, const u_char *p)
+bt_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
{
u_int length = h->len;
u_int caplen = h->caplen;
const pcap_bluetooth_h4_header* hdr = (const pcap_bluetooth_h4_header*)p;
if (caplen < BT_HDRLEN) {
- printf("[|bt]");
+ ND_PRINT((ndo, "[|bt]"));
return (BT_HDRLEN);
}
caplen -= BT_HDRLEN;
length -= BT_HDRLEN;
p += BT_HDRLEN;
- if (eflag)
- (void)printf("hci length %d, direction %s, ", length, (EXTRACT_32BITS(&hdr->direction)&0x1)?"in":"out");
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "hci length %d, direction %s, ", length, (EXTRACT_32BITS(&hdr->direction)&0x1)?"in":"out"));
- if (!suppress_default_print)
- default_print(p, caplen);
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
return (BT_HDRLEN);
}
diff --git a/contrib/tcpdump/print-calm-fast.c b/contrib/tcpdump/print-calm-fast.c
new file mode 100644
index 000000000000..5cc39f418531
--- /dev/null
+++ b/contrib/tcpdump/print-calm-fast.c
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2013 The TCPDUMP project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code
+ * distributions retain the above copyright notice and this paragraph
+ * in its entirety, and (2) distributions including binary code include
+ * the above copyright notice and this paragraph in its entirety in
+ * the documentation or other materials provided with the distribution.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
+ * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
+ * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE.
+ *
+ * Original code by Ola Martin Lykkja (ola.lykkja@q-free.com)
+ */
+
+#define NETDISSECT_REWORKED
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tcpdump-stdinc.h>
+
+#include "interface.h"
+#include "addrtoname.h"
+
+/*
+ ISO 29281:2009
+ Intelligent Transport Systems . Communications access for land mobiles (CALM)
+ CALM non-IP networking
+*/
+
+/*
+ * This is the top level routine of the printer. 'bp' points
+ * to the calm header of the packet.
+ */
+void
+calm_fast_print(netdissect_options *ndo, const u_char *eth, const u_char *bp, u_int length)
+{
+ int srcNwref = bp[0];
+ int dstNwref = bp[1];
+ length -= 2;
+ bp += 2;
+
+ ND_PRINT((ndo, "CALM FAST src:%s; ", etheraddr_string(ndo, eth+6)));
+ ND_PRINT((ndo, "SrcNwref:%d; ", srcNwref));
+ ND_PRINT((ndo, "DstNwref:%d; ", dstNwref));
+
+ if (ndo->ndo_vflag)
+ ND_DEFAULTPRINT(bp, length);
+}
+
+
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
diff --git a/contrib/tcpdump/print-carp.c b/contrib/tcpdump/print-carp.c
index ba5be7c6217a..7b9f28ceae4f 100644
--- a/contrib/tcpdump/print-carp.c
+++ b/contrib/tcpdump/print-carp.c
@@ -34,55 +34,49 @@
*
*/
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include <netinet/in.h>
-
-#include "interface.h"
+#include "interface.h" /* for checksum structure and functions */
#include "extract.h"
-#include "addrtoname.h"
void
-carp_print(register const u_char *bp, register u_int len, int ttl)
+carp_print(netdissect_options *ndo, register const u_char *bp, register u_int len, int ttl)
{
int version, type;
const char *type_s;
- TCHECK(bp[0]);
+ ND_TCHECK(bp[0]);
version = (bp[0] & 0xf0) >> 4;
type = bp[0] & 0x0f;
if (type == 1)
type_s = "advertise";
else
type_s = "unknown";
- printf("CARPv%d-%s %d: ", version, type_s, len);
+ ND_PRINT((ndo, "CARPv%d-%s %d: ", version, type_s, len));
if (ttl != 255)
- printf("[ttl=%d!] ", ttl);
+ ND_PRINT((ndo, "[ttl=%d!] ", ttl));
if (version != 2 || type != 1)
return;
- TCHECK(bp[2]);
- TCHECK(bp[5]);
- printf("vhid=%d advbase=%d advskew=%d authlen=%d ",
- bp[1], bp[5], bp[2], bp[3]);
- if (vflag) {
+ ND_TCHECK(bp[2]);
+ ND_TCHECK(bp[5]);
+ ND_PRINT((ndo, "vhid=%d advbase=%d advskew=%d authlen=%d ",
+ bp[1], bp[5], bp[2], bp[3]));
+ if (ndo->ndo_vflag) {
struct cksum_vec vec[1];
- vec[0].ptr = (const u_int8_t *)bp;
+ vec[0].ptr = (const uint8_t *)bp;
vec[0].len = len;
- if (TTEST2(bp[0], len) && in_cksum(vec, 1))
- printf(" (bad carp cksum %x!)",
- EXTRACT_16BITS(&bp[6]));
+ if (ND_TTEST2(bp[0], len) && in_cksum(vec, 1))
+ ND_PRINT((ndo, " (bad carp cksum %x!)",
+ EXTRACT_16BITS(&bp[6])));
}
- printf("counter=%" PRIu64, EXTRACT_64BITS(&bp[8]));
+ ND_PRINT((ndo, "counter=%" PRIu64, EXTRACT_64BITS(&bp[8])));
return;
trunc:
- printf("[|carp]");
+ ND_PRINT((ndo, "[|carp]"));
}
diff --git a/contrib/tcpdump/print-cdp.c b/contrib/tcpdump/print-cdp.c
index 7bc617a96357..116f0fa522e8 100644
--- a/contrib/tcpdump/print-cdp.c
+++ b/contrib/tcpdump/print-cdp.c
@@ -24,18 +24,13 @@
* http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/frames.htm
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-cdp.c,v 1.25 2004-10-07 14:53:11 hannes Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
#include <string.h>
#include "interface.h"
@@ -43,9 +38,11 @@ static const char rcsid[] _U_ =
#include "extract.h" /* must come after interface.h */
#include "nlpid.h"
+static const char tstr[] = "[|cdp]";
+
#define CDP_HEADER_LEN 4
-static struct tok cdp_tlv_values[] = {
+static const struct tok cdp_tlv_values[] = {
{ 0x01, "Device-ID"},
{ 0x02, "Address"},
{ 0x03, "Port-ID"},
@@ -70,7 +67,7 @@ static struct tok cdp_tlv_values[] = {
{ 0, NULL}
};
-static struct tok cdp_capability_values[] = {
+static const struct tok cdp_capability_values[] = {
{ 0x01, "Router" },
{ 0x02, "Transparent Bridge" },
{ 0x04, "Source Route Bridge" },
@@ -81,144 +78,139 @@ static struct tok cdp_capability_values[] = {
{ 0, NULL }
};
-static int cdp_print_addr(const u_char *, int);
-static int cdp_print_prefixes(const u_char *, int);
+static int cdp_print_addr(netdissect_options *, const u_char *, int);
+static int cdp_print_prefixes(netdissect_options *, const u_char *, int);
static unsigned long cdp_get_number(const u_char *, int);
void
-cdp_print(const u_char *pptr, u_int length, u_int caplen)
+cdp_print(netdissect_options *ndo,
+ const u_char *pptr, u_int length, u_int caplen)
{
int type, len, i, j;
const u_char *tptr;
if (caplen < CDP_HEADER_LEN) {
- (void)printf("[|cdp]");
+ ND_PRINT((ndo, "%s", tstr));
return;
}
tptr = pptr; /* temporary pointer */
- if (!TTEST2(*tptr, CDP_HEADER_LEN))
- goto trunc;
- printf("CDPv%u, ttl: %us", *tptr, *(tptr+1));
- if (vflag)
- printf(", checksum: %u (unverified), length %u", EXTRACT_16BITS(tptr), length);
+ ND_TCHECK2(*tptr, CDP_HEADER_LEN);
+ ND_PRINT((ndo, "CDPv%u, ttl: %us", *tptr, *(tptr + 1)));
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, ", checksum: %u (unverified), length %u", EXTRACT_16BITS(tptr), length));
tptr += CDP_HEADER_LEN;
while (tptr < (pptr+length)) {
-
- if (!TTEST2(*tptr, 4)) /* read out Type and Length */
- goto trunc;
+ ND_TCHECK2(*tptr, 4); /* read out Type and Length */
type = EXTRACT_16BITS(tptr);
len = EXTRACT_16BITS(tptr+2); /* object length includes the 4 bytes header length */
tptr += 4;
len -= 4;
- if (!TTEST2(*tptr, len))
- goto trunc;
+ ND_TCHECK2(*tptr, len);
- if (vflag || type == 1) { /* in non-verbose mode just print Device-ID */
+ if (ndo->ndo_vflag || type == 1) { /* in non-verbose mode just print Device-ID */
- if (vflag)
- printf("\n\t%s (0x%02x), length: %u byte%s: ",
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, "\n\t%s (0x%02x), length: %u byte%s: ",
tok2str(cdp_tlv_values,"unknown field type", type),
type,
len,
- PLURAL_SUFFIX(len)); /* plural */
+ PLURAL_SUFFIX(len))); /* plural */
switch (type) {
case 0x01: /* Device-ID */
- if (!vflag)
- printf(", Device-ID ");
- printf("'");
- fn_printn(tptr, len, NULL);
- printf("'");
+ if (!ndo->ndo_vflag)
+ ND_PRINT((ndo, ", Device-ID "));
+ ND_PRINT((ndo, "'"));
+ fn_printn(ndo, tptr, len, NULL);
+ ND_PRINT((ndo, "'"));
break;
case 0x02: /* Address */
- if (cdp_print_addr(tptr, len) < 0)
+ if (cdp_print_addr(ndo, tptr, len) < 0)
goto trunc;
break;
case 0x03: /* Port-ID */
- printf("'");
- fn_printn(tptr, len, NULL);
- printf("'");
+ ND_PRINT((ndo, "'"));
+ fn_printn(ndo, tptr, len, NULL);
+ ND_PRINT((ndo, "'"));
break;
case 0x04: /* Capabilities */
- printf("(0x%08x): %s",
+ ND_PRINT((ndo, "(0x%08x): %s",
EXTRACT_32BITS(tptr),
- bittok2str(cdp_capability_values, "none",EXTRACT_32BITS(tptr)));
+ bittok2str(cdp_capability_values, "none", EXTRACT_32BITS(tptr))));
break;
case 0x05: /* Version */
- printf("\n\t ");
+ ND_PRINT((ndo, "\n\t "));
for (i=0;i<len;i++) {
j = *(tptr+i);
- putchar(j);
+ ND_PRINT((ndo, "%c", j));
if (j == 0x0a) /* lets rework the version string to get a nice identation */
- printf("\t ");
+ ND_PRINT((ndo, "\t "));
}
break;
case 0x06: /* Platform */
- printf("'");
- fn_printn(tptr, len, NULL);
- printf("'");
+ ND_PRINT((ndo, "'"));
+ fn_printn(ndo, tptr, len, NULL);
+ ND_PRINT((ndo, "'"));
break;
case 0x07: /* Prefixes */
- if (cdp_print_prefixes(tptr, len) < 0)
+ if (cdp_print_prefixes(ndo, tptr, len) < 0)
goto trunc;
break;
case 0x08: /* Protocol Hello Option - not documented */
break;
case 0x09: /* VTP Mgmt Domain - not documented */
- printf("'");
- fn_printn(tptr, len, NULL);
- printf("'");
+ ND_PRINT((ndo, "'"));
+ fn_printn(ndo, tptr, len, NULL);
+ ND_PRINT((ndo, "'"));
break;
case 0x0a: /* Native VLAN ID - not documented */
- printf("%d",EXTRACT_16BITS(tptr));
+ ND_PRINT((ndo, "%d", EXTRACT_16BITS(tptr)));
break;
case 0x0b: /* Duplex - not documented */
- printf("%s", *(tptr) ? "full": "half");
+ ND_PRINT((ndo, "%s", *(tptr) ? "full": "half"));
break;
/* http://www.cisco.com/univercd/cc/td/doc/product/voice/ata/atarn/186rn21m.htm
* plus more details from other sources
*/
case 0x0e: /* ATA-186 VoIP VLAN request - incomplete doc. */
- printf("app %d, vlan %d",
- *(tptr), EXTRACT_16BITS(tptr+1));
+ ND_PRINT((ndo, "app %d, vlan %d", *(tptr), EXTRACT_16BITS(tptr + 1)));
break;
case 0x10: /* ATA-186 VoIP VLAN assignment - incomplete doc. */
- printf("%1.2fW",
- cdp_get_number(tptr, len)/1000.0 );
+ ND_PRINT((ndo, "%1.2fW", cdp_get_number(tptr, len) / 1000.0));
break;
case 0x11: /* MTU - not documented */
- printf("%u bytes", EXTRACT_32BITS(tptr));
+ ND_PRINT((ndo, "%u bytes", EXTRACT_32BITS(tptr)));
break;
case 0x12: /* AVVID trust bitmap - not documented */
- printf("0x%02x", *(tptr) );
+ ND_PRINT((ndo, "0x%02x", *(tptr)));
break;
case 0x13: /* AVVID untrusted port CoS - not documented */
- printf("0x%02x", *(tptr));
+ ND_PRINT((ndo, "0x%02x", *(tptr)));
break;
case 0x14: /* System Name - not documented */
- printf("'");
- fn_printn(tptr, len, NULL);
- printf("'");
+ ND_PRINT((ndo, "'"));
+ fn_printn(ndo, tptr, len, NULL);
+ ND_PRINT((ndo, "'"));
break;
case 0x16: /* System Object ID - not documented */
- if (cdp_print_addr(tptr, len) < 0)
+ if (cdp_print_addr(ndo, tptr, len) < 0)
goto trunc;
break;
case 0x17: /* Physical Location - not documented */
- printf("0x%02x", *(tptr));
+ ND_PRINT((ndo, "0x%02x", *(tptr)));
if (len > 1) {
- printf("/");
- fn_printn(tptr + 1, len - 1, NULL);
+ ND_PRINT((ndo, "/"));
+ fn_printn(ndo, tptr + 1, len - 1, NULL);
}
break;
default:
- print_unknown_data(tptr,"\n\t ",len);
+ print_unknown_data(ndo, tptr, "\n\t ", len);
break;
}
}
@@ -227,12 +219,12 @@ cdp_print(const u_char *pptr, u_int length, u_int caplen)
break;
tptr = tptr+len;
}
- if (vflag < 1)
- printf(", length %u",caplen);
+ if (ndo->ndo_vflag < 1)
+ ND_PRINT((ndo, ", length %u", caplen));
return;
trunc:
- printf("[|cdp]");
+ ND_PRINT((ndo, "%s", tstr));
}
/*
@@ -247,29 +239,30 @@ trunc:
#define PT_IEEE_802_2 2 /* IEEE 802.2 LLC header */
static int
-cdp_print_addr(const u_char * p, int l)
+cdp_print_addr(netdissect_options *ndo,
+ const u_char * p, int l)
{
int pt, pl, al, num;
const u_char *endp = p + l;
#ifdef INET6
- static u_char prot_ipv6[] = {
+ static const u_char prot_ipv6[] = {
0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00, 0x86, 0xdd
};
#endif
- TCHECK2(*p, 2);
+ ND_TCHECK2(*p, 2);
num = EXTRACT_32BITS(p);
p += 4;
while (p < endp && num >= 0) {
- TCHECK2(*p, 2);
+ ND_TCHECK2(*p, 2);
if (p + 2 > endp)
goto trunc;
pt = p[0]; /* type of "protocol" field */
pl = p[1]; /* length of "protocol" field */
p += 2;
- TCHECK2(p[pl], 2);
+ ND_TCHECK2(p[pl], 2);
if (p + pl + 2 > endp)
goto trunc;
al = EXTRACT_16BITS(&p[pl]); /* address length */
@@ -282,12 +275,10 @@ cdp_print_addr(const u_char * p, int l)
*/
p += 3;
- TCHECK2(*p, 4);
+ ND_TCHECK2(*p, 4);
if (p + 4 > endp)
goto trunc;
- printf("IPv4 (%u) %s",
- num,
- ipaddr_string(p));
+ ND_PRINT((ndo, "IPv4 (%u) %s", num, ipaddr_string(ndo, p)));
p += 4;
}
#ifdef INET6
@@ -300,13 +291,11 @@ cdp_print_addr(const u_char * p, int l)
* Ethertype, address length = 16
*/
p += 10;
- TCHECK2(*p, al);
+ ND_TCHECK2(*p, al);
if (p + al > endp)
goto trunc;
- printf("IPv6 (%u) %s",
- num,
- ip6addr_string(p));
+ ND_PRINT((ndo, "IPv6 (%u) %s", num, ip6addr_string(ndo, p)));
p += al;
}
#endif
@@ -314,27 +303,27 @@ cdp_print_addr(const u_char * p, int l)
/*
* Generic case: just print raw data
*/
- TCHECK2(*p, pl);
+ ND_TCHECK2(*p, pl);
if (p + pl > endp)
goto trunc;
- printf("pt=0x%02x, pl=%d, pb=", *(p - 2), pl);
+ ND_PRINT((ndo, "pt=0x%02x, pl=%d, pb=", *(p - 2), pl));
while (pl-- > 0)
- printf(" %02x", *p++);
- TCHECK2(*p, 2);
+ ND_PRINT((ndo, " %02x", *p++));
+ ND_TCHECK2(*p, 2);
if (p + 2 > endp)
goto trunc;
al = (*p << 8) + *(p + 1);
- printf(", al=%d, a=", al);
+ ND_PRINT((ndo, ", al=%d, a=", al));
p += 2;
- TCHECK2(*p, al);
+ ND_TCHECK2(*p, al);
if (p + al > endp)
goto trunc;
while (al-- > 0)
- printf(" %02x", *p++);
+ ND_PRINT((ndo, " %02x", *p++));
}
num--;
if (num)
- printf(" ");
+ ND_PRINT((ndo, " "));
}
return 0;
@@ -345,15 +334,16 @@ trunc:
static int
-cdp_print_prefixes(const u_char * p, int l)
+cdp_print_prefixes(netdissect_options *ndo,
+ const u_char * p, int l)
{
if (l % 5)
goto trunc;
- printf(" IPv4 Prefixes (%d):", l / 5);
+ ND_PRINT((ndo, " IPv4 Prefixes (%d):", l / 5));
while (l > 0) {
- printf(" %u.%u.%u.%u/%u", p[0], p[1], p[2], p[3], p[4]);
+ ND_PRINT((ndo, " %u.%u.%u.%u/%u", p[0], p[1], p[2], p[3], p[4]));
l -= 5;
p += 5;
}
diff --git a/contrib/tcpdump/print-cfm.c b/contrib/tcpdump/print-cfm.c
index fb0476f5584c..e6aec0b91f38 100644
--- a/contrib/tcpdump/print-cfm.c
+++ b/contrib/tcpdump/print-cfm.c
@@ -17,11 +17,7 @@
* 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
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -29,8 +25,6 @@ static const char rcsid[] _U_ =
#include <tcpdump-stdinc.h>
#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include "interface.h"
#include "extract.h"
@@ -39,17 +33,11 @@ static const char rcsid[] _U_ =
#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;
+ uint8_t mdlevel_version;
+ uint8_t opcode;
+ uint8_t flags;
+ uint8_t first_tlv_offset;
};
#define CFM_VERSION 0
@@ -75,13 +63,13 @@ static const struct tok cfm_opcode_values[] = {
* 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];
+ uint8_t sequence[4];
+ uint8_t ma_epi[2];
+ uint8_t md_nameformat;
+ uint8_t md_namelength;
+ uint8_t md_name[46]; /* md name and short ma name */
+ uint8_t reserved_itu[16];
+ uint8_t reserved[6];
};
/*
@@ -126,17 +114,17 @@ static const struct tok cfm_ma_nameformat_values[] = {
};
struct cfm_lbm_t {
- u_int8_t transaction_id[4];
- u_int8_t reserved[4];
+ uint8_t transaction_id[4];
+ uint8_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];
+ uint8_t transaction_id[4];
+ uint8_t egress_id[8];
+ uint8_t ttl;
+ uint8_t original_mac[ETHER_ADDR_LEN];
+ uint8_t target_mac[ETHER_ADDR_LEN];
+ uint8_t reserved[3];
};
static const struct tok cfm_ltm_flag_values[] = {
@@ -145,17 +133,18 @@ static const struct tok cfm_ltm_flag_values[] = {
};
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];
+ uint8_t transaction_id[4];
+ uint8_t last_egress_id[8];
+ uint8_t next_egress_id[8];
+ uint8_t ttl;
+ uint8_t replay_action;
+ uint8_t reserved[6];
};
static const struct tok cfm_ltr_flag_values[] = {
- { 0x80, "Forwarded"},
- { 0x40, "Terminal MEP"},
+ { 0x80, "UseFDB Only"},
+ { 0x40, "FwdYes"},
+ { 0x20, "Terminal MEP"},
{ 0, NULL}
};
@@ -193,8 +182,8 @@ static const struct tok cfm_tlv_values[] = {
*/
struct cfm_tlv_header_t {
- u_int8_t type;
- u_int8_t length[2];
+ uint8_t type;
+ uint8_t length[2];
};
/* FIXME define TLV formats */
@@ -236,8 +225,9 @@ static const struct tok cfm_tlv_senderid_chassisid_values[] = {
};
-int
-cfm_mgmt_addr_print(register const u_char *tptr) {
+static int
+cfm_mgmt_addr_print(netdissect_options *ndo,
+ register const u_char *tptr) {
u_int mgmt_addr_type;
u_int hexdump = FALSE;
@@ -248,21 +238,21 @@ cfm_mgmt_addr_print(register const u_char *tptr) {
* is only once octet
*/
mgmt_addr_type = *tptr;
- printf("\n\t Management Address Type %s (%u)",
+ ND_PRINT((ndo, "\n\t Management Address Type %s (%u)",
tok2str(af_values, "Unknown", mgmt_addr_type),
- mgmt_addr_type);
+ mgmt_addr_type));
/*
* Resolve the passed in Address.
*/
switch(mgmt_addr_type) {
case AFNUM_INET:
- printf(", %s", ipaddr_string(tptr + 1));
+ ND_PRINT((ndo, ", %s", ipaddr_string(ndo, tptr + 1)));
break;
#ifdef INET6
case AFNUM_INET6:
- printf(", %s", ip6addr_string(tptr + 1));
+ ND_PRINT((ndo, ", %s", ip6addr_string(ndo, tptr + 1)));
break;
#endif
@@ -277,24 +267,25 @@ cfm_mgmt_addr_print(register const u_char *tptr) {
/*
* 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 const char *
+cfm_egress_id_string(netdissect_options *ndo, register const u_char *tptr) {
static char egress_id_buffer[80];
-
+
snprintf(egress_id_buffer, sizeof(egress_id_buffer),
- "MAC %0x4x-%s",
+ "MAC 0x%4x-%s",
EXTRACT_16BITS(tptr),
- etheraddr_string(tptr+2));
+ etheraddr_string(ndo, tptr+2));
return egress_id_buffer;
}
void
-cfm_print(register const u_char *pptr, register u_int length) {
+cfm_print(netdissect_options *ndo,
+ 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;
+ const uint8_t *tptr, *tlv_ptr, *ma_name, *ma_nameformat, *ma_namelength;
u_int hexdump, tlen, cfm_tlv_len, cfm_tlv_type, ccm_interval;
@@ -307,31 +298,31 @@ cfm_print(register const u_char *pptr, register u_int length) {
tptr=pptr;
cfm_common_header = (const struct cfm_common_header_t *)pptr;
- TCHECK(*cfm_common_header);
+ ND_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);
+ ND_PRINT((ndo, "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",
+ ND_PRINT((ndo, "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);
+ length));
/*
* In non-verbose mode just print the opcode and md-level.
*/
- if (vflag < 1) {
+ if (ndo->ndo_vflag < 1) {
return;
}
- printf("\n\tFirst TLV offset %u", cfm_common_header->first_tlv_offset);
+ ND_PRINT((ndo, "\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);
@@ -341,53 +332,53 @@ cfm_print(register const u_char *pptr, register u_int length) {
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]",
+ ND_PRINT((ndo, ", Flags [CCM Interval %u%s]",
ccm_interval,
cfm_common_header->flags & CFM_CCM_RDI_FLAG ?
- ", RDI" : "");
+ ", RDI" : ""));
/*
* Resolve the CCM interval field.
*/
if (ccm_interval) {
- printf("\n\t CCM Interval %.3fs"
+ ND_PRINT((ndo, "\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);
+ ccm_interval_base[ccm_interval] * CCM_INTERVAL_MAX_MULTIPLIER));
}
- printf("\n\t Sequence Number 0x%08x, MA-End-Point-ID 0x%04x",
+ ND_PRINT((ndo, "\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));
+ EXTRACT_16BITS(msg_ptr.cfm_ccm->ma_epi)));
/*
* Resolve the MD fields.
*/
- printf("\n\t MD Name Format %s (%u), MD Name length %u",
+ ND_PRINT((ndo, "\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);
+ msg_ptr.cfm_ccm->md_namelength));
if (msg_ptr.cfm_ccm->md_nameformat != CFM_CCM_MD_FORMAT_NONE) {
- printf("\n\t MD Name: ");
+ ND_PRINT((ndo, "\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);
+ safeputs(ndo, 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));
+ ND_PRINT((ndo, "\n\t MAC %s", etheraddr_string(ndo,
+ 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 ",
+ print_unknown_data(ndo, msg_ptr.cfm_ccm->md_name, "\n\t ",
msg_ptr.cfm_ccm->md_namelength);
}
}
@@ -400,16 +391,16 @@ cfm_print(register const u_char *pptr, register u_int length) {
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",
+ ND_PRINT((ndo, "\n\t MA Name-Format %s (%u), MA name length %u",
tok2str(cfm_ma_nameformat_values, "Unknown",
*ma_nameformat),
*ma_nameformat,
- *ma_namelength);
+ *ma_namelength));
- printf("\n\t MA Name: ");
+ ND_PRINT((ndo, "\n\t MA Name: "));
switch (*ma_nameformat) {
case CFM_CCM_MA_FORMAT_CHAR:
- safeputs((const char *)ma_name, *ma_namelength);
+ safeputs(ndo, ma_name, *ma_namelength);
break;
/* FIXME add printers for those MA formats - hexdump for now */
@@ -418,45 +409,45 @@ cfm_print(register const u_char *pptr, register u_int length) {
case CFM_CCM_MA_FORMAT_INT:
case CFM_CCM_MA_FORMAT_VPN:
default:
- print_unknown_data(ma_name, "\n\t ", *ma_namelength);
+ print_unknown_data(ndo, ma_name, "\n\t ", *ma_namelength);
}
break;
case CFM_OPCODE_LTM:
msg_ptr.cfm_ltm = (const struct cfm_ltm_t *)tptr;
- printf(", Flags [%s]",
- bittok2str(cfm_ltm_flag_values, "none", cfm_common_header->flags));
+ ND_PRINT((ndo, ", Flags [%s]",
+ bittok2str(cfm_ltm_flag_values, "none", cfm_common_header->flags)));
- printf("\n\t Transaction-ID 0x%08x, Egress-ID %s, ttl %u",
+ ND_PRINT((ndo, "\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);
+ cfm_egress_id_string(ndo, 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));
+ ND_PRINT((ndo, "\n\t Original-MAC %s, Target-MAC %s",
+ etheraddr_string(ndo, msg_ptr.cfm_ltm->original_mac),
+ etheraddr_string(ndo, msg_ptr.cfm_ltm->target_mac)));
break;
case CFM_OPCODE_LTR:
msg_ptr.cfm_ltr = (const struct cfm_ltr_t *)tptr;
- printf(", Flags [%s]",
- bittok2str(cfm_ltr_flag_values, "none", cfm_common_header->flags));
+ ND_PRINT((ndo, ", Flags [%s]",
+ bittok2str(cfm_ltr_flag_values, "none", cfm_common_header->flags)));
- printf("\n\t Transaction-ID 0x%08x, Last-Egress-ID %s",
+ ND_PRINT((ndo, "\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));
+ cfm_egress_id_string(ndo, 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);
+ ND_PRINT((ndo, "\n\t Next-Egress-ID %s, ttl %u",
+ cfm_egress_id_string(ndo, msg_ptr.cfm_ltr->next_egress_id),
+ msg_ptr.cfm_ltr->ttl));
- printf("\n\t Replay-Action %s (%u)",
+ ND_PRINT((ndo, "\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);
+ msg_ptr.cfm_ltr->replay_action));
break;
/*
@@ -467,7 +458,7 @@ cfm_print(register const u_char *pptr, register u_int length) {
case CFM_OPCODE_LBM:
default:
if (tlen > cfm_common_header->first_tlv_offset) {
- print_unknown_data(tptr, "\n\t ",
+ print_unknown_data(ndo, tptr, "\n\t ",
tlen - cfm_common_header->first_tlv_offset);
}
break;
@@ -482,32 +473,32 @@ cfm_print(register const u_char *pptr, register u_int length) {
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);
+ ND_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));
+ ND_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",
+ ND_PRINT((ndo, "\n\t%s TLV (0x%02x), length %u",
tok2str(cfm_tlv_values, "Unknown", cfm_tlv_type),
cfm_tlv_type,
- cfm_tlv_len);
+ 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);
+ print_unknown_data(ndo, tptr, "\n\t ", tlen);
return;
}
@@ -517,7 +508,7 @@ cfm_print(register const u_char *pptr, register u_int length) {
/* did we capture enough for fully decoding the object ? */
if (cfm_tlv_type != CFM_TLV_END) {
- TCHECK2(*tptr, cfm_tlv_len);
+ ND_TCHECK2(*tptr, cfm_tlv_len);
}
hexdump = FALSE;
@@ -527,22 +518,22 @@ cfm_print(register const u_char *pptr, register u_int length) {
return;
case CFM_TLV_PORT_STATUS:
- printf(", Status: %s (%u)",
+ ND_PRINT((ndo, ", Status: %s (%u)",
tok2str(cfm_tlv_port_status_values, "Unknown", *tptr),
- *tptr);
+ *tptr));
break;
case CFM_TLV_INTERFACE_STATUS:
- printf(", Status: %s (%u)",
+ ND_PRINT((ndo, ", Status: %s (%u)",
tok2str(cfm_tlv_interface_status_values, "Unknown", *tptr),
- *tptr);
+ *tptr));
break;
case CFM_TLV_PRIVATE:
- printf(", Vendor: %s (%u), Sub-Type %u",
+ ND_PRINT((ndo, ", Vendor: %s (%u), Sub-Type %u",
tok2str(oui_values,"Unknown", EXTRACT_24BITS(tptr)),
EXTRACT_24BITS(tptr),
- *(tptr+3));
+ *(tptr + 3)));
hexdump = TRUE;
break;
@@ -565,20 +556,20 @@ cfm_print(register const u_char *pptr, register u_int length) {
if (chassis_id_length) {
chassis_id_type = *tptr;
- printf("\n\t Chassis-ID Type %s (%u), Chassis-ID length %u",
+ ND_PRINT((ndo, "\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);
+ chassis_id_length));
switch (chassis_id_type) {
case CFM_CHASSIS_ID_MAC_ADDRESS:
- printf("\n\t MAC %s", etheraddr_string(tptr+1));
+ ND_PRINT((ndo, "\n\t MAC %s", etheraddr_string(ndo, tptr + 1)));
break;
case CFM_CHASSIS_ID_NETWORK_ADDRESS:
- hexdump |= cfm_mgmt_addr_print(tptr);
+ hexdump |= cfm_mgmt_addr_print(ndo, tptr);
break;
case CFM_CHASSIS_ID_INTERFACE_NAME: /* fall through */
@@ -586,7 +577,7 @@ cfm_print(register const u_char *pptr, register u_int length) {
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);
+ safeputs(ndo, tptr + 1, chassis_id_length);
break;
default:
@@ -611,7 +602,7 @@ cfm_print(register const u_char *pptr, register u_int length) {
tlen--;
if (mgmt_addr_length) {
- hexdump |= cfm_mgmt_addr_print(tptr);
+ hexdump |= cfm_mgmt_addr_print(ndo, tptr);
}
tptr += mgmt_addr_length;
@@ -633,13 +624,13 @@ cfm_print(register const u_char *pptr, register u_int length) {
break;
}
/* do we want to see an additional hexdump ? */
- if (hexdump || vflag > 1)
- print_unknown_data(tlv_ptr, "\n\t ", cfm_tlv_len);
+ if (hexdump || ndo->ndo_vflag > 1)
+ print_unknown_data(ndo, tlv_ptr, "\n\t ", cfm_tlv_len);
tptr+=cfm_tlv_len;
tlen-=cfm_tlv_len;
}
return;
trunc:
- printf("\n\t\t packet exceeded snapshot");
+ ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
}
diff --git a/contrib/tcpdump/print-chdlc.c b/contrib/tcpdump/print-chdlc.c
index 261b15ad7efd..c1f3d3464828 100644
--- a/contrib/tcpdump/print-chdlc.c
+++ b/contrib/tcpdump/print-chdlc.c
@@ -19,30 +19,22 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.43 2005-11-29 08:56:19 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <pcap.h>
-#include <stdio.h>
-
#include "interface.h"
#include "addrtoname.h"
#include "ethertype.h"
#include "extract.h"
-#include "ppp.h"
#include "chdlc.h"
-static void chdlc_slarp_print(const u_char *, u_int);
+static void chdlc_slarp_print(netdissect_options *, const u_char *, u_int);
-const struct tok chdlc_cast_values[] = {
+static const struct tok chdlc_cast_values[] = {
{ CHDLC_UNICAST, "unicast" },
{ CHDLC_BCAST, "bcast" },
{ 0, NULL}
@@ -51,29 +43,29 @@ const struct tok chdlc_cast_values[] = {
/* Standard CHDLC printer */
u_int
-chdlc_if_print(const struct pcap_pkthdr *h, register const u_char *p)
+chdlc_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p)
{
register u_int length = h->len;
register u_int caplen = h->caplen;
if (caplen < CHDLC_HDRLEN) {
- printf("[|chdlc]");
+ ND_PRINT((ndo, "[|chdlc]"));
return (caplen);
}
- return (chdlc_print(p,length));
+ return (chdlc_print(ndo, p,length));
}
u_int
-chdlc_print(register const u_char *p, u_int length) {
+chdlc_print(netdissect_options *ndo, register const u_char *p, u_int length) {
u_int proto;
proto = EXTRACT_16BITS(&p[2]);
- if (eflag) {
- printf("%s, ethertype %s (0x%04x), length %u: ",
+ if (ndo->ndo_eflag) {
+ ND_PRINT((ndo, "%s, ethertype %s (0x%04x), length %u: ",
tok2str(chdlc_cast_values, "0x%02x", p[0]),
tok2str(ethertype_values, "Unknown", proto),
proto,
- length);
+ length));
}
length -= CHDLC_HDRLEN;
@@ -81,15 +73,15 @@ chdlc_print(register const u_char *p, u_int length) {
switch (proto) {
case ETHERTYPE_IP:
- ip_print(gndo, p, length);
+ ip_print(ndo, p, length);
break;
#ifdef INET6
case ETHERTYPE_IPV6:
- ip6_print(gndo, p, length);
+ ip6_print(ndo, p, length);
break;
#endif
case CHDLC_TYPE_SLARP:
- chdlc_slarp_print(p, length);
+ chdlc_slarp_print(ndo, p, length);
break;
#if 0
case CHDLC_TYPE_CDP:
@@ -98,20 +90,20 @@ chdlc_print(register const u_char *p, u_int length) {
#endif
case ETHERTYPE_MPLS:
case ETHERTYPE_MPLS_MULTI:
- mpls_print(p, length);
+ mpls_print(ndo, p, length);
break;
case ETHERTYPE_ISO:
/* is the fudge byte set ? lets verify by spotting ISO headers */
if (*(p+1) == 0x81 ||
*(p+1) == 0x82 ||
*(p+1) == 0x83)
- isoclns_print(p+1, length-1, length-1);
+ isoclns_print(ndo, p + 1, length - 1, length - 1);
else
- isoclns_print(p, length, length);
+ isoclns_print(ndo, p, length, length);
break;
default:
- if (!eflag)
- printf("unknown CHDLC protocol (0x%04x)", proto);
+ if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, "unknown CHDLC protocol (0x%04x)", proto));
break;
}
@@ -122,19 +114,19 @@ chdlc_print(register const u_char *p, u_int length) {
* The fixed-length portion of a SLARP packet.
*/
struct cisco_slarp {
- u_int8_t code[4];
+ uint8_t code[4];
#define SLARP_REQUEST 0
#define SLARP_REPLY 1
#define SLARP_KEEPALIVE 2
union {
struct {
- u_int8_t addr[4];
- u_int8_t mask[4];
+ uint8_t addr[4];
+ uint8_t mask[4];
} addr;
struct {
- u_int8_t myseq[4];
- u_int8_t yourseq[4];
- u_int8_t rel[2];
+ uint8_t myseq[4];
+ uint8_t yourseq[4];
+ uint8_t rel[2];
} keep;
} un;
};
@@ -143,20 +135,20 @@ struct cisco_slarp {
#define SLARP_MAX_LEN 18
static void
-chdlc_slarp_print(const u_char *cp, u_int length)
+chdlc_slarp_print(netdissect_options *ndo, const u_char *cp, u_int length)
{
const struct cisco_slarp *slarp;
u_int sec,min,hrs,days;
- printf("SLARP (length: %u), ",length);
+ ND_PRINT((ndo, "SLARP (length: %u), ",length));
if (length < SLARP_MIN_LEN)
goto trunc;
slarp = (const struct cisco_slarp *)cp;
- TCHECK2(*slarp, SLARP_MIN_LEN);
+ ND_TCHECK2(*slarp, SLARP_MIN_LEN);
switch (EXTRACT_32BITS(&slarp->code)) {
case SLARP_REQUEST:
- printf("request");
+ ND_PRINT((ndo, "request"));
/*
* At least according to William "Chops" Westfield's
* message in
@@ -168,42 +160,41 @@ chdlc_slarp_print(const u_char *cp, u_int length)
*/
break;
case SLARP_REPLY:
- printf("reply %s/%s",
- ipaddr_string(&slarp->un.addr.addr),
- ipaddr_string(&slarp->un.addr.mask));
+ ND_PRINT((ndo, "reply %s/%s",
+ ipaddr_string(ndo, &slarp->un.addr.addr),
+ ipaddr_string(ndo, &slarp->un.addr.mask)));
break;
case SLARP_KEEPALIVE:
- printf("keepalive: mineseen=0x%08x, yourseen=0x%08x, reliability=0x%04x",
+ ND_PRINT((ndo, "keepalive: mineseen=0x%08x, yourseen=0x%08x, reliability=0x%04x",
EXTRACT_32BITS(&slarp->un.keep.myseq),
EXTRACT_32BITS(&slarp->un.keep.yourseq),
- EXTRACT_16BITS(&slarp->un.keep.rel));
+ EXTRACT_16BITS(&slarp->un.keep.rel)));
if (length >= SLARP_MAX_LEN) { /* uptime-stamp is optional */
cp += SLARP_MIN_LEN;
- if (!TTEST2(*cp, 4))
- goto trunc;
+ ND_TCHECK2(*cp, 4);
sec = EXTRACT_32BITS(cp) / 1000;
min = sec / 60; sec -= min * 60;
hrs = min / 60; min -= hrs * 60;
days = hrs / 24; hrs -= days * 24;
- printf(", link uptime=%ud%uh%um%us",days,hrs,min,sec);
+ ND_PRINT((ndo, ", link uptime=%ud%uh%um%us",days,hrs,min,sec));
}
break;
default:
- printf("0x%02x unknown", EXTRACT_32BITS(&slarp->code));
- if (vflag <= 1)
- print_unknown_data(cp+4,"\n\t",length-4);
+ ND_PRINT((ndo, "0x%02x unknown", EXTRACT_32BITS(&slarp->code)));
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo,cp+4,"\n\t",length-4);
break;
}
- if (SLARP_MAX_LEN < length && vflag)
- printf(", (trailing junk: %d bytes)", length - SLARP_MAX_LEN);
- if (vflag > 1)
- print_unknown_data(cp+4,"\n\t",length-4);
+ if (SLARP_MAX_LEN < length && ndo->ndo_vflag)
+ ND_PRINT((ndo, ", (trailing junk: %d bytes)", length - SLARP_MAX_LEN));
+ if (ndo->ndo_vflag > 1)
+ print_unknown_data(ndo,cp+4,"\n\t",length-4);
return;
trunc:
- printf("[|slarp]");
+ ND_PRINT((ndo, "[|slarp]"));
}
diff --git a/contrib/tcpdump/print-cip.c b/contrib/tcpdump/print-cip.c
index e9d672fe761b..91abe08d306a 100644
--- a/contrib/tcpdump/print-cip.c
+++ b/contrib/tcpdump/print-cip.c
@@ -20,11 +20,7 @@
*
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-cip.c,v 1.26 2005-07-07 01:22:17 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -33,17 +29,12 @@ static const char rcsid[] _U_ =
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <pcap.h>
-
#include "interface.h"
#include "addrtoname.h"
-#include "ethertype.h"
-#include "ether.h"
#define RFC1483LLC_LEN 8
-static unsigned char rfcllc[] = {
+static const unsigned char rfcllc[] = {
0xaa, /* DSAP: non-ISO */
0xaa, /* SSAP: non-ISO */
0x03, /* Ctrl: Unnumbered Information Command PDU */
@@ -52,12 +43,12 @@ static unsigned char rfcllc[] = {
0x00 };
static inline void
-cip_print(int length)
+cip_print(netdissect_options *ndo, int length)
{
/*
* There is no MAC-layer header, so just print the length.
*/
- printf("%d: ", length);
+ ND_PRINT((ndo, "%d: ", length));
}
/*
@@ -67,41 +58,41 @@ cip_print(int length)
* is the number of bytes actually captured.
*/
u_int
-cip_if_print(const struct pcap_pkthdr *h, const u_char *p)
+cip_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
{
u_int caplen = h->caplen;
u_int length = h->len;
u_short extracted_ethertype;
if (memcmp(rfcllc, p, sizeof(rfcllc))==0 && caplen < RFC1483LLC_LEN) {
- printf("[|cip]");
+ ND_PRINT((ndo, "[|cip]"));
return (0);
}
- if (eflag)
- cip_print(length);
+ if (ndo->ndo_eflag)
+ cip_print(ndo, length);
if (memcmp(rfcllc, p, sizeof(rfcllc)) == 0) {
/*
* LLC header is present. Try to print it & higher layers.
*/
- if (llc_print(p, length, caplen, NULL, NULL,
+ if (llc_print(ndo, p, length, caplen, NULL, NULL,
&extracted_ethertype) == 0) {
/* ether_type not known, print raw packet */
- if (!eflag)
- cip_print(length);
+ if (!ndo->ndo_eflag)
+ cip_print(ndo, length);
if (extracted_ethertype) {
- printf("(LLC %s) ",
- etherproto_string(htons(extracted_ethertype)));
+ ND_PRINT((ndo, "(LLC %s) ",
+ etherproto_string(htons(extracted_ethertype))));
}
- if (!suppress_default_print)
- default_print(p, caplen);
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
}
} else {
/*
* LLC header is absent; treat it as just IP.
*/
- ip_print(gndo, p, length);
+ ip_print(ndo, p, length);
}
return (0);
diff --git a/contrib/tcpdump/print-cnfp.c b/contrib/tcpdump/print-cnfp.c
index 86d71282963a..07c940cbc242 100644
--- a/contrib/tcpdump/print-cnfp.c
+++ b/contrib/tcpdump/print-cnfp.c
@@ -32,11 +32,7 @@
/* Cisco NetFlow protocol */
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-cnfp.c,v 1.17 2005-04-20 20:53:18 guy Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -54,32 +50,33 @@ static const char rcsid[] _U_ =
#include "ipproto.h"
struct nfhdr {
- u_int32_t ver_cnt; /* version [15], and # of records */
- u_int32_t msys_uptime;
- u_int32_t utc_sec;
- u_int32_t utc_nsec;
- u_int32_t sequence; /* v5 flow sequence number */
- u_int32_t reserved; /* v5 only */
+ uint32_t ver_cnt; /* version [15], and # of records */
+ uint32_t msys_uptime;
+ uint32_t utc_sec;
+ uint32_t utc_nsec;
+ uint32_t sequence; /* v5 flow sequence number */
+ uint32_t reserved; /* v5 only */
};
struct nfrec {
struct in_addr src_ina;
struct in_addr dst_ina;
struct in_addr nhop_ina;
- u_int32_t ifaces; /* src,dst ifaces */
- u_int32_t packets;
- u_int32_t octets;
- u_int32_t start_time; /* sys_uptime value */
- u_int32_t last_time; /* sys_uptime value */
- u_int32_t ports; /* src,dst ports */
- u_int32_t proto_tos; /* proto, tos, pad, flags(v5) */
- u_int32_t asses; /* v1: flags; v5: src,dst AS */
- u_int32_t masks; /* src,dst addr prefix; v6: encaps */
+ uint32_t ifaces; /* src,dst ifaces */
+ uint32_t packets;
+ uint32_t octets;
+ uint32_t start_time; /* sys_uptime value */
+ uint32_t last_time; /* sys_uptime value */
+ uint32_t ports; /* src,dst ports */
+ uint32_t proto_tos; /* proto, tos, pad, flags(v5) */
+ uint32_t asses; /* v1: flags; v5: src,dst AS */
+ uint32_t masks; /* src,dst addr prefix; v6: encaps */
struct in_addr peer_nexthop; /* v6: IP address of the nexthop within the peer (FIB)*/
};
void
-cnfp_print(const u_char *cp, const u_char *bp _U_)
+cnfp_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *bp _U_)
{
register const struct nfhdr *nh;
register const struct nfrec *nr;
@@ -91,7 +88,7 @@ cnfp_print(const u_char *cp, const u_char *bp _U_)
nh = (const struct nfhdr *)cp;
- if ((const u_char *)(nh + 1) > snapend)
+ if ((const u_char *)(nh + 1) > ndo->ndo_snapend)
return;
nrecs = EXTRACT_32BITS(&nh->ver_cnt) & 0xffff;
@@ -105,31 +102,31 @@ cnfp_print(const u_char *cp, const u_char *bp _U_)
t = EXTRACT_32BITS(&nh->utc_sec);
#endif
- printf("NetFlow v%x, %u.%03u uptime, %u.%09u, ", ver,
+ ND_PRINT((ndo, "NetFlow v%x, %u.%03u uptime, %u.%09u, ", ver,
EXTRACT_32BITS(&nh->msys_uptime)/1000,
EXTRACT_32BITS(&nh->msys_uptime)%1000,
- EXTRACT_32BITS(&nh->utc_sec), EXTRACT_32BITS(&nh->utc_nsec));
+ EXTRACT_32BITS(&nh->utc_sec), EXTRACT_32BITS(&nh->utc_nsec)));
if (ver == 5 || ver == 6) {
- printf("#%u, ", EXTRACT_32BITS(&nh->sequence));
+ ND_PRINT((ndo, "#%u, ", EXTRACT_32BITS(&nh->sequence)));
nr = (const struct nfrec *)&nh[1];
- snaplen -= 24;
+ ndo->ndo_snaplen -= 24;
} else {
nr = (const struct nfrec *)&nh->sequence;
- snaplen -= 16;
+ ndo->ndo_snaplen -= 16;
}
- printf("%2u recs", nrecs);
+ ND_PRINT((ndo, "%2u recs", nrecs));
- for (; nrecs-- && (const u_char *)(nr + 1) <= snapend; nr++) {
+ for (; nrecs-- && (const u_char *)(nr + 1) <= ndo->ndo_snapend; nr++) {
char buf[20];
char asbuf[20];
- printf("\n started %u.%03u, last %u.%03u",
+ ND_PRINT((ndo, "\n started %u.%03u, last %u.%03u",
EXTRACT_32BITS(&nr->start_time)/1000,
EXTRACT_32BITS(&nr->start_time)%1000,
EXTRACT_32BITS(&nr->last_time)/1000,
- EXTRACT_32BITS(&nr->last_time)%1000);
+ EXTRACT_32BITS(&nr->last_time)%1000));
asbuf[0] = buf[0] = '\0';
if (ver == 5 || ver == 6) {
@@ -138,8 +135,8 @@ cnfp_print(const u_char *cp, const u_char *bp _U_)
snprintf(asbuf, sizeof(asbuf), ":%u",
(EXTRACT_32BITS(&nr->asses) >> 16) & 0xffff);
}
- printf("\n %s%s%s:%u ", intoa(nr->src_ina.s_addr), buf, asbuf,
- EXTRACT_32BITS(&nr->ports) >> 16);
+ ND_PRINT((ndo, "\n %s%s%s:%u ", intoa(nr->src_ina.s_addr), buf, asbuf,
+ EXTRACT_32BITS(&nr->ports) >> 16));
if (ver == 5 || ver ==6) {
snprintf(buf, sizeof(buf), "/%d",
@@ -147,17 +144,17 @@ cnfp_print(const u_char *cp, const u_char *bp _U_)
snprintf(asbuf, sizeof(asbuf), ":%u",
EXTRACT_32BITS(&nr->asses) & 0xffff);
}
- printf("> %s%s%s:%u ", intoa(nr->dst_ina.s_addr), buf, asbuf,
- EXTRACT_32BITS(&nr->ports) & 0xffff);
+ ND_PRINT((ndo, "> %s%s%s:%u ", intoa(nr->dst_ina.s_addr), buf, asbuf,
+ EXTRACT_32BITS(&nr->ports) & 0xffff));
- printf(">> %s\n ", intoa(nr->nhop_ina.s_addr));
+ ND_PRINT((ndo, ">> %s\n ", intoa(nr->nhop_ina.s_addr)));
pent = getprotobynumber((EXTRACT_32BITS(&nr->proto_tos) >> 8) & 0xff);
- if (!pent || nflag)
- printf("%u ",
- (EXTRACT_32BITS(&nr->proto_tos) >> 8) & 0xff);
+ if (!pent || ndo->ndo_nflag)
+ ND_PRINT((ndo, "%u ",
+ (EXTRACT_32BITS(&nr->proto_tos) >> 8) & 0xff));
else
- printf("%s ", pent->p_name);
+ ND_PRINT((ndo, "%s ", pent->p_name));
/* tcp flags for tcp only */
if (pent && pent->p_proto == IPPROTO_TCP) {
@@ -166,14 +163,14 @@ cnfp_print(const u_char *cp, const u_char *bp _U_)
flags = (EXTRACT_32BITS(&nr->asses) >> 24) & 0xff;
else
flags = (EXTRACT_32BITS(&nr->proto_tos) >> 16) & 0xff;
- if (flags & TH_FIN) putchar('F');
- if (flags & TH_SYN) putchar('S');
- if (flags & TH_RST) putchar('R');
- if (flags & TH_PUSH) putchar('P');
- if (flags & TH_ACK) putchar('A');
- if (flags & TH_URG) putchar('U');
- if (flags)
- putchar(' ');
+ ND_PRINT((ndo, "%s%s%s%s%s%s%s",
+ flags & TH_FIN ? "F" : "",
+ flags & TH_SYN ? "S" : "",
+ flags & TH_RST ? "R" : "",
+ flags & TH_PUSH ? "P" : "",
+ flags & TH_ACK ? "A" : "",
+ flags & TH_URG ? "U" : "",
+ flags ? " " : ""));
}
buf[0]='\0';
@@ -182,9 +179,9 @@ cnfp_print(const u_char *cp, const u_char *bp _U_)
(EXTRACT_32BITS(&nr->masks) >> 8) & 0xff,
(EXTRACT_32BITS(&nr->masks)) & 0xff);
}
- printf("tos %u, %u (%u octets) %s",
+ ND_PRINT((ndo, "tos %u, %u (%u octets) %s",
EXTRACT_32BITS(&nr->proto_tos) & 0xff,
EXTRACT_32BITS(&nr->packets),
- EXTRACT_32BITS(&nr->octets), buf);
+ EXTRACT_32BITS(&nr->octets), buf));
}
}
diff --git a/contrib/tcpdump/print-dccp.c b/contrib/tcpdump/print-dccp.c
index 79ea5f72ee5f..34d78c3173b3 100644
--- a/contrib/tcpdump/print-dccp.c
+++ b/contrib/tcpdump/print-dccp.c
@@ -7,19 +7,13 @@
* BSD-style license that accompanies tcpdump or the GNU GPL version 2
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-dccp.c,v 1.8 2007-11-09 00:44:09 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include "dccp.h"
-
#include <stdio.h>
#include <string.h>
@@ -32,6 +26,125 @@ static const char rcsid[] _U_ =
#endif
#include "ipproto.h"
+/**
+ * struct dccp_hdr - generic part of DCCP packet header, with a 24-bit
+ * sequence number
+ *
+ * @dccph_sport - Relevant port on the endpoint that sent this packet
+ * @dccph_dport - Relevant port on the other endpoint
+ * @dccph_doff - Data Offset from the start of the DCCP header, in 32-bit words
+ * @dccph_ccval - Used by the HC-Sender CCID
+ * @dccph_cscov - Parts of the packet that are covered by the Checksum field
+ * @dccph_checksum - Internet checksum, depends on dccph_cscov
+ * @dccph_x - 0 = 24 bit sequence number, 1 = 48
+ * @dccph_type - packet type, see DCCP_PKT_ prefixed macros
+ * @dccph_seq - 24-bit sequence number
+ */
+struct dccp_hdr {
+ uint16_t dccph_sport,
+ dccph_dport;
+ uint8_t dccph_doff;
+ uint8_t dccph_ccval_cscov;
+ uint16_t dccph_checksum;
+ uint8_t dccph_xtr;
+ uint8_t dccph_seq[3];
+} UNALIGNED;
+
+/**
+ * struct dccp_hdr_ext - generic part of DCCP packet header, with a 48-bit
+ * sequence number
+ *
+ * @dccph_sport - Relevant port on the endpoint that sent this packet
+ * @dccph_dport - Relevant port on the other endpoint
+ * @dccph_doff - Data Offset from the start of the DCCP header, in 32-bit words
+ * @dccph_ccval - Used by the HC-Sender CCID
+ * @dccph_cscov - Parts of the packet that are covered by the Checksum field
+ * @dccph_checksum - Internet checksum, depends on dccph_cscov
+ * @dccph_x - 0 = 24 bit sequence number, 1 = 48
+ * @dccph_type - packet type, see DCCP_PKT_ prefixed macros
+ * @dccph_seq - 48-bit sequence number
+ */
+struct dccp_hdr_ext {
+ uint16_t dccph_sport,
+ dccph_dport;
+ uint8_t dccph_doff;
+ uint8_t dccph_ccval_cscov;
+ uint16_t dccph_checksum;
+ uint8_t dccph_xtr;
+ uint8_t reserved;
+ uint8_t dccph_seq[6];
+} UNALIGNED;
+
+#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_xtr & 1)
+#define DCCPH_TYPE(dh) (((dh)->dccph_xtr >> 1) & 0xF)
+
+/**
+ * struct dccp_hdr_request - Conection initiation request header
+ *
+ * @dccph_req_service - Service to which the client app wants to connect
+ */
+struct dccp_hdr_request {
+ uint32_t dccph_req_service;
+} UNALIGNED;
+
+/**
+ * struct dccp_hdr_response - Conection initiation response header
+ *
+ * @dccph_resp_ack - 48 bit ack number, contains GSR
+ * @dccph_resp_service - Echoes the Service Code on a received DCCP-Request
+ */
+struct dccp_hdr_response {
+ uint8_t dccph_resp_ack[8]; /* always 8 bytes */
+ uint32_t dccph_resp_service;
+} UNALIGNED;
+
+/**
+ * struct dccp_hdr_reset - Unconditionally shut down a connection
+ *
+ * @dccph_resp_ack - 48 bit ack number
+ * @dccph_reset_service - Echoes the Service Code on a received DCCP-Request
+ */
+struct dccp_hdr_reset {
+ uint8_t dccph_reset_ack[8]; /* always 8 bytes */
+ uint8_t dccph_reset_code,
+ dccph_reset_data[3];
+} UNALIGNED;
+
+enum dccp_pkt_type {
+ DCCP_PKT_REQUEST = 0,
+ DCCP_PKT_RESPONSE,
+ DCCP_PKT_DATA,
+ DCCP_PKT_ACK,
+ DCCP_PKT_DATAACK,
+ DCCP_PKT_CLOSEREQ,
+ DCCP_PKT_CLOSE,
+ DCCP_PKT_RESET,
+ DCCP_PKT_SYNC,
+ DCCP_PKT_SYNCACK,
+ DCCP_PKT_INVALID
+};
+
+enum dccp_reset_codes {
+ DCCP_RESET_CODE_UNSPECIFIED = 0,
+ DCCP_RESET_CODE_CLOSED,
+ DCCP_RESET_CODE_ABORTED,
+ DCCP_RESET_CODE_NO_CONNECTION,
+ DCCP_RESET_CODE_PACKET_ERROR,
+ DCCP_RESET_CODE_OPTION_ERROR,
+ DCCP_RESET_CODE_MANDATORY_ERROR,
+ DCCP_RESET_CODE_CONNECTION_REFUSED,
+ DCCP_RESET_CODE_BAD_SERVICE_CODE,
+ DCCP_RESET_CODE_TOO_BUSY,
+ DCCP_RESET_CODE_BAD_INIT_COOKIE,
+ DCCP_RESET_CODE_AGGRESSION_PENALTY,
+ __DCCP_RESET_CODE_LAST
+};
+
+static const char tstr[] = "[|dccp]";
+
static const char *dccp_reset_codes[] = {
"unspecified",
"closed",
@@ -48,60 +161,60 @@ static const char *dccp_reset_codes[] = {
};
static const char *dccp_feature_nums[] = {
- "reserved",
+ "reserved",
"ccid",
"allow_short_seqno",
"sequence_window",
- "ecn_incapable",
- "ack_ratio",
+ "ecn_incapable",
+ "ack_ratio",
"send_ack_vector",
- "send_ndp_count",
- "minimum checksum coverage",
+ "send_ndp_count",
+ "minimum checksum coverage",
"check data checksum",
};
static inline u_int dccp_csum_coverage(const struct dccp_hdr* dh, u_int len)
{
u_int cov;
-
+
if (DCCPH_CSCOV(dh) == 0)
return len;
- cov = (dh->dccph_doff + DCCPH_CSCOV(dh) - 1) * sizeof(u_int32_t);
+ cov = (dh->dccph_doff + DCCPH_CSCOV(dh) - 1) * sizeof(uint32_t);
return (cov > len)? len : cov;
}
-static int dccp_cksum(const struct ip *ip,
+static int dccp_cksum(netdissect_options *ndo, const struct ip *ip,
const struct dccp_hdr *dh, u_int len)
{
- return nextproto4_cksum(ip, (const u_int8_t *)(void *)dh,
- dccp_csum_coverage(dh, len), IPPROTO_DCCP);
+ return nextproto4_cksum(ndo, ip, (const uint8_t *)(void *)dh, len,
+ dccp_csum_coverage(dh, len), IPPROTO_DCCP);
}
#ifdef INET6
static int dccp6_cksum(const struct ip6_hdr *ip6, const struct dccp_hdr *dh, u_int len)
{
- return nextproto6_cksum(ip6, (const u_int8_t *)(void *)dh,
- dccp_csum_coverage(dh, len), IPPROTO_DCCP);
+ return nextproto6_cksum(ip6, (const uint8_t *)(void *)dh, len,
+ dccp_csum_coverage(dh, len), IPPROTO_DCCP);
}
#endif
-static const char *dccp_reset_code(u_int8_t code)
+static const char *dccp_reset_code(uint8_t code)
{
if (code >= __DCCP_RESET_CODE_LAST)
return "invalid";
return dccp_reset_codes[code];
}
-static u_int64_t dccp_seqno(const struct dccp_hdr *dh)
+static uint64_t dccp_seqno(const u_char *bp)
{
- u_int32_t seq_high = DCCPH_SEQ(dh);
- u_int64_t seqno = EXTRACT_24BITS(&seq_high) & 0xFFFFFF;
+ const struct dccp_hdr *dh = (const struct dccp_hdr *)bp;
+ uint64_t seqno;
if (DCCPH_X(dh) != 0) {
- const struct dccp_hdr_ext *dhx = (void *)(dh + 1);
- u_int32_t seq_low = dhx->dccph_seq_low;
- seqno &= 0x00FFFF; /* clear reserved field */
- seqno = (seqno << 32) + EXTRACT_32BITS(&seq_low);
+ const struct dccp_hdr_ext *dhx = (const struct dccp_hdr_ext *)bp;
+ seqno = EXTRACT_48BITS(dhx->dccph_seq);
+ } else {
+ seqno = EXTRACT_24BITS(dh->dccph_seq);
}
return seqno;
@@ -109,63 +222,38 @@ static u_int64_t dccp_seqno(const struct dccp_hdr *dh)
static inline unsigned int dccp_basic_hdr_len(const struct dccp_hdr *dh)
{
- return sizeof(*dh) + (DCCPH_X(dh) ? sizeof(struct dccp_hdr_ext) : 0);
+ return DCCPH_X(dh) ? sizeof(struct dccp_hdr_ext) : sizeof(struct dccp_hdr);
}
-static void dccp_print_ack_no(const u_char *bp)
+static void dccp_print_ack_no(netdissect_options *ndo, const u_char *bp)
{
const struct dccp_hdr *dh = (const struct dccp_hdr *)bp;
- const struct dccp_hdr_ack_bits *dh_ack =
- (struct dccp_hdr_ack_bits *)(bp + dccp_basic_hdr_len(dh));
- u_int32_t ack_high;
- u_int64_t ackno;
-
- TCHECK2(*dh_ack,4);
- ack_high = DCCPH_ACK(dh_ack);
- ackno = EXTRACT_24BITS(&ack_high) & 0xFFFFFF;
+ const u_char *ackp = bp + dccp_basic_hdr_len(dh);
+ uint64_t ackno;
if (DCCPH_X(dh) != 0) {
- u_int32_t ack_low;
-
- TCHECK2(*dh_ack,8);
- ack_low = dh_ack->dccph_ack_nr_low;
-
- ackno &= 0x00FFFF; /* clear reserved field */
- ackno = (ackno << 32) + EXTRACT_32BITS(&ack_low);
+ ND_TCHECK2(*ackp, 8);
+ ackno = EXTRACT_48BITS(ackp + 2);
+ } else {
+ ND_TCHECK2(*ackp, 4);
+ ackno = EXTRACT_24BITS(ackp + 1);
}
- (void)printf("(ack=%" PRIu64 ") ", ackno);
+ ND_PRINT((ndo, "(ack=%" PRIu64 ") ", ackno));
trunc:
return;
}
-static inline unsigned int dccp_packet_hdr_len(const u_int8_t type)
-{
- if (type == DCCP_PKT_DATA)
- return 0;
- if (type == DCCP_PKT_DATAACK ||
- type == DCCP_PKT_ACK ||
- type == DCCP_PKT_SYNC ||
- type == DCCP_PKT_SYNCACK ||
- type == DCCP_PKT_CLOSE ||
- type == DCCP_PKT_CLOSEREQ)
- return sizeof(struct dccp_hdr_ack_bits);
- if (type == DCCP_PKT_REQUEST)
- return sizeof(struct dccp_hdr_request);
- if (type == DCCP_PKT_RESPONSE)
- return sizeof(struct dccp_hdr_response);
- return sizeof(struct dccp_hdr_reset);
-}
-
-static int dccp_print_option(const u_char *option);
+static int dccp_print_option(netdissect_options *, const u_char *, u_int);
/**
* dccp_print - show dccp packet
* @bp - beginning of dccp packet
- * @data2 - beginning of enclosing
+ * @data2 - beginning of enclosing
* @len - lenght of ip packet
*/
-void dccp_print(const u_char *bp, const u_char *data2, u_int len)
+void dccp_print(netdissect_options *ndo, const u_char *bp, const u_char *data2,
+ u_int len)
{
const struct dccp_hdr *dh;
const struct ip *ip;
@@ -175,7 +263,7 @@ void dccp_print(const u_char *bp, const u_char *data2, u_int len)
const u_char *cp;
u_short sport, dport;
u_int hlen;
- u_int extlen = 0;
+ u_int fixed_hdrlen;
dh = (const struct dccp_hdr *)bp;
@@ -186,279 +274,363 @@ void dccp_print(const u_char *bp, const u_char *data2, u_int len)
else
ip6 = NULL;
#endif /*INET6*/
+
+ /* make sure we have enough data to look at the X bit */
cp = (const u_char *)(dh + 1);
- if (cp > snapend) {
- printf("[Invalid packet|dccp]");
+ if (cp > ndo->ndo_snapend) {
+ ND_PRINT((ndo, "[Invalid packet|dccp]"));
return;
}
-
if (len < sizeof(struct dccp_hdr)) {
- printf("truncated-dccp - %ld bytes missing!",
- (long)len - sizeof(struct dccp_hdr));
+ ND_PRINT((ndo, "truncated-dccp - %u bytes missing!",
+ len - (u_int)sizeof(struct dccp_hdr)));
return;
}
+ /* get the length of the generic header */
+ fixed_hdrlen = dccp_basic_hdr_len(dh);
+ if (len < fixed_hdrlen) {
+ ND_PRINT((ndo, "truncated-dccp - %u bytes missing!",
+ len - fixed_hdrlen));
+ return;
+ }
+ ND_TCHECK2(*dh, fixed_hdrlen);
+
sport = EXTRACT_16BITS(&dh->dccph_sport);
dport = EXTRACT_16BITS(&dh->dccph_dport);
hlen = dh->dccph_doff * 4;
#ifdef INET6
if (ip6) {
- (void)printf("%s.%d > %s.%d: ",
- ip6addr_string(&ip6->ip6_src), sport,
- ip6addr_string(&ip6->ip6_dst), dport);
+ ND_PRINT((ndo, "%s.%d > %s.%d: ",
+ ip6addr_string(ndo, &ip6->ip6_src), sport,
+ ip6addr_string(ndo, &ip6->ip6_dst), dport));
} else
#endif /*INET6*/
{
- (void)printf("%s.%d > %s.%d: ",
- ipaddr_string(&ip->ip_src), sport,
- ipaddr_string(&ip->ip_dst), dport);
+ ND_PRINT((ndo, "%s.%d > %s.%d: ",
+ ipaddr_string(ndo, &ip->ip_src), sport,
+ ipaddr_string(ndo, &ip->ip_dst), dport));
}
- fflush(stdout);
- if (qflag) {
- (void)printf(" %d", len - hlen);
+ if (ndo->ndo_qflag) {
+ ND_PRINT((ndo, " %d", len - hlen));
if (hlen > len) {
- (void)printf("dccp [bad hdr length %u - too long, > %u]",
- hlen, len);
+ ND_PRINT((ndo, "dccp [bad hdr length %u - too long, > %u]",
+ hlen, len));
}
return;
}
/* other variables in generic header */
- if (vflag) {
- (void)printf("CCVal %d, CsCov %d, ", DCCPH_CCVAL(dh), DCCPH_CSCOV(dh));
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "CCVal %d, CsCov %d, ", DCCPH_CCVAL(dh), DCCPH_CSCOV(dh)));
}
/* checksum calculation */
- if (vflag && TTEST2(bp[0], len)) {
- u_int16_t sum = 0, dccp_sum;
+ if (ndo->ndo_vflag && ND_TTEST2(bp[0], len)) {
+ uint16_t sum = 0, dccp_sum;
dccp_sum = EXTRACT_16BITS(&dh->dccph_checksum);
- (void)printf("cksum 0x%04x ", dccp_sum);
+ ND_PRINT((ndo, "cksum 0x%04x ", dccp_sum));
if (IP_V(ip) == 4)
- sum = dccp_cksum(ip, dh, len);
+ sum = dccp_cksum(ndo, ip, dh, len);
#ifdef INET6
else if (IP_V(ip) == 6)
sum = dccp6_cksum(ip6, dh, len);
#endif
if (sum != 0)
- (void)printf("(incorrect -> 0x%04x), ",in_cksum_shouldbe(dccp_sum, sum));
+ ND_PRINT((ndo, "(incorrect -> 0x%04x), ",in_cksum_shouldbe(dccp_sum, sum)));
else
- (void)printf("(correct), ");
+ ND_PRINT((ndo, "(correct), "));
}
switch (DCCPH_TYPE(dh)) {
case DCCP_PKT_REQUEST: {
struct dccp_hdr_request *dhr =
- (struct dccp_hdr_request *)(bp + dccp_basic_hdr_len(dh));
- TCHECK(*dhr);
- (void)printf("request (service=%d) ",
- EXTRACT_32BITS(&dhr->dccph_req_service));
- extlen += 4;
+ (struct dccp_hdr_request *)(bp + fixed_hdrlen);
+ fixed_hdrlen += 4;
+ if (len < fixed_hdrlen) {
+ ND_PRINT((ndo, "truncated-dccp request - %u bytes missing!",
+ len - fixed_hdrlen));
+ return;
+ }
+ ND_TCHECK(*dhr);
+ ND_PRINT((ndo, "request (service=%d) ",
+ EXTRACT_32BITS(&dhr->dccph_req_service)));
break;
}
case DCCP_PKT_RESPONSE: {
struct dccp_hdr_response *dhr =
- (struct dccp_hdr_response *)(bp + dccp_basic_hdr_len(dh));
- TCHECK(*dhr);
- (void)printf("response (service=%d) ",
- EXTRACT_32BITS(&dhr->dccph_resp_service));
- extlen += 12;
+ (struct dccp_hdr_response *)(bp + fixed_hdrlen);
+ fixed_hdrlen += 12;
+ if (len < fixed_hdrlen) {
+ ND_PRINT((ndo, "truncated-dccp response - %u bytes missing!",
+ len - fixed_hdrlen));
+ return;
+ }
+ ND_TCHECK(*dhr);
+ ND_PRINT((ndo, "response (service=%d) ",
+ EXTRACT_32BITS(&dhr->dccph_resp_service)));
break;
}
case DCCP_PKT_DATA:
- (void)printf("data ");
+ ND_PRINT((ndo, "data "));
break;
case DCCP_PKT_ACK: {
- (void)printf("ack ");
- extlen += 8;
+ fixed_hdrlen += 8;
+ if (len < fixed_hdrlen) {
+ ND_PRINT((ndo, "truncated-dccp ack - %u bytes missing!",
+ len - fixed_hdrlen));
+ return;
+ }
+ ND_PRINT((ndo, "ack "));
break;
}
case DCCP_PKT_DATAACK: {
- (void)printf("dataack ");
- extlen += 8;
+ fixed_hdrlen += 8;
+ if (len < fixed_hdrlen) {
+ ND_PRINT((ndo, "truncated-dccp dataack - %u bytes missing!",
+ len - fixed_hdrlen));
+ return;
+ }
+ ND_PRINT((ndo, "dataack "));
break;
}
case DCCP_PKT_CLOSEREQ:
- (void)printf("closereq ");
- extlen += 8;
+ fixed_hdrlen += 8;
+ if (len < fixed_hdrlen) {
+ ND_PRINT((ndo, "truncated-dccp closereq - %u bytes missing!",
+ len - fixed_hdrlen));
+ return;
+ }
+ ND_PRINT((ndo, "closereq "));
break;
case DCCP_PKT_CLOSE:
- (void)printf("close ");
- extlen += 8;
+ fixed_hdrlen += 8;
+ if (len < fixed_hdrlen) {
+ ND_PRINT((ndo, "truncated-dccp close - %u bytes missing!",
+ len - fixed_hdrlen));
+ return;
+ }
+ ND_PRINT((ndo, "close "));
break;
case DCCP_PKT_RESET: {
struct dccp_hdr_reset *dhr =
- (struct dccp_hdr_reset *)(bp + dccp_basic_hdr_len(dh));
- TCHECK(*dhr);
- (void)printf("reset (code=%s) ",
- dccp_reset_code(dhr->dccph_reset_code));
- extlen += 12;
+ (struct dccp_hdr_reset *)(bp + fixed_hdrlen);
+ fixed_hdrlen += 12;
+ if (len < fixed_hdrlen) {
+ ND_PRINT((ndo, "truncated-dccp reset - %u bytes missing!",
+ len - fixed_hdrlen));
+ return;
+ }
+ ND_TCHECK(*dhr);
+ ND_PRINT((ndo, "reset (code=%s) ",
+ dccp_reset_code(dhr->dccph_reset_code)));
break;
}
case DCCP_PKT_SYNC:
- (void)printf("sync ");
- extlen += 8;
+ fixed_hdrlen += 8;
+ if (len < fixed_hdrlen) {
+ ND_PRINT((ndo, "truncated-dccp sync - %u bytes missing!",
+ len - fixed_hdrlen));
+ return;
+ }
+ ND_PRINT((ndo, "sync "));
break;
case DCCP_PKT_SYNCACK:
- (void)printf("syncack ");
- extlen += 8;
+ fixed_hdrlen += 8;
+ if (len < fixed_hdrlen) {
+ ND_PRINT((ndo, "truncated-dccp syncack - %u bytes missing!",
+ len - fixed_hdrlen));
+ return;
+ }
+ ND_PRINT((ndo, "syncack "));
break;
default:
- (void)printf("invalid ");
+ ND_PRINT((ndo, "invalid "));
break;
}
- if ((DCCPH_TYPE(dh) != DCCP_PKT_DATA) &&
+ if ((DCCPH_TYPE(dh) != DCCP_PKT_DATA) &&
(DCCPH_TYPE(dh) != DCCP_PKT_REQUEST))
- dccp_print_ack_no(bp);
+ dccp_print_ack_no(ndo, bp);
- if (vflag < 2)
+ if (ndo->ndo_vflag < 2)
return;
- (void)printf("seq %" PRIu64, dccp_seqno(dh));
+ ND_PRINT((ndo, "seq %" PRIu64, dccp_seqno(bp)));
/* process options */
- if (hlen > dccp_basic_hdr_len(dh) + extlen){
+ if (hlen > fixed_hdrlen){
const u_char *cp;
u_int optlen;
- cp = bp + dccp_basic_hdr_len(dh) + extlen;
- printf(" <");
+ cp = bp + fixed_hdrlen;
+ ND_PRINT((ndo, " <"));
- hlen -= dccp_basic_hdr_len(dh) + extlen;
+ hlen -= fixed_hdrlen;
while(1){
- TCHECK(*cp);
- optlen = dccp_print_option(cp);
- if (!optlen) goto trunc2;
- if (hlen <= optlen) break;
+ optlen = dccp_print_option(ndo, cp, hlen);
+ if (!optlen)
+ break;
+ if (hlen <= optlen)
+ break;
hlen -= optlen;
cp += optlen;
- printf(", ");
+ ND_PRINT((ndo, ", "));
}
- printf(">");
+ ND_PRINT((ndo, ">"));
}
return;
trunc:
- printf("[|dccp]");
-trunc2:
+ ND_PRINT((ndo, "%s", tstr));
return;
}
-static int dccp_print_option(const u_char *option)
-{
- u_int8_t optlen, i;
+static const struct tok dccp_option_values[] = {
+ { 0, "nop" },
+ { 1, "mandatory" },
+ { 2, "slowreceiver" },
+ { 32, "change_l" },
+ { 33, "confirm_l" },
+ { 34, "change_r" },
+ { 35, "confirm_r" },
+ { 36, "initcookie" },
+ { 37, "ndp_count" },
+ { 38, "ack_vector0" },
+ { 39, "ack_vector1" },
+ { 40, "data_dropped" },
+ { 41, "timestamp" },
+ { 42, "timestamp_echo" },
+ { 43, "elapsed_time" },
+ { 44, "data_checksum" },
+ { 0, NULL }
+};
+
+static int dccp_print_option(netdissect_options *ndo, const u_char *option, u_int hlen)
+{
+ uint8_t optlen, i;
- TCHECK(*option);
+ ND_TCHECK(*option);
if (*option >= 32) {
- TCHECK(*(option+1));
+ ND_TCHECK(*(option+1));
optlen = *(option +1);
if (optlen < 2) {
- printf("Option %d optlen too short",*option);
- return 1;
- }
- } else optlen = 1;
-
- TCHECK2(*option,optlen);
-
- switch (*option){
- case 0:
- printf("nop");
- break;
- case 1:
- printf("mandatory");
- break;
- case 2:
- printf("slowreceiver");
- break;
- case 32:
- printf("change_l");
- if (*(option +2) < 10){
- printf(" %s", dccp_feature_nums[*(option +2)]);
- for (i = 0; i < optlen -3; i ++) printf(" %d", *(option +3 + i));
- }
- break;
- case 33:
- printf("confirm_l");
- if (*(option +2) < 10){
- printf(" %s", dccp_feature_nums[*(option +2)]);
- for (i = 0; i < optlen -3; i ++) printf(" %d", *(option +3 + i));
- }
- break;
- case 34:
- printf("change_r");
- if (*(option +2) < 10){
- printf(" %s", dccp_feature_nums[*(option +2)]);
- for (i = 0; i < optlen -3; i ++) printf(" %d", *(option +3 + i));
+ if (*option >= 128)
+ ND_PRINT((ndo, "CCID option %u optlen too short", *option));
+ else
+ ND_PRINT((ndo, "%s optlen too short",
+ tok2str(dccp_option_values, "Option %u", *option)));
+ return 0;
}
- break;
- case 35:
- printf("confirm_r");
- if (*(option +2) < 10){
- printf(" %s", dccp_feature_nums[*(option +2)]);
- for (i = 0; i < optlen -3; i ++) printf(" %d", *(option +3 + i));
- }
- break;
- case 36:
- printf("initcookie 0x");
- for (i = 0; i < optlen -2; i ++) printf("%02x", *(option +2 + i));
- break;
- case 37:
- printf("ndp_count");
- for (i = 0; i < optlen -2; i ++) printf(" %d", *(option +2 + i));
- break;
- case 38:
- printf("ack_vector0 0x");
- for (i = 0; i < optlen -2; i ++) printf("%02x", *(option +2 + i));
- break;
- case 39:
- printf("ack_vector1 0x");
- for (i = 0; i < optlen -2; i ++) printf("%02x", *(option +2 + i));
- break;
- case 40:
- printf("data_dropped 0x");
- for (i = 0; i < optlen -2; i ++) printf("%02x", *(option +2 + i));
- break;
- case 41:
- printf("timestamp %u", EXTRACT_32BITS(option + 2));
- break;
- case 42:
- printf("timestamp_echo %u", EXTRACT_32BITS(option + 2));
- break;
- case 43:
- printf("elapsed_time ");
- if (optlen == 6)
- printf("%u", EXTRACT_32BITS(option + 2));
+ } else
+ optlen = 1;
+
+ if (hlen < optlen) {
+ if (*option >= 128)
+ ND_PRINT((ndo, "CCID option %u optlen goes past header length",
+ *option));
else
- printf("%u", EXTRACT_16BITS(option + 2));
- break;
- case 44:
- printf("data_checksum ");
- for (i = 0; i < optlen -2; i ++) printf("%02x", *(option +2 + i));
- break;
- default :
- if (*option >= 128) {
- printf("CCID option %d",*option);
- switch (optlen) {
- case 4:
- printf(" %u", EXTRACT_16BITS(option + 2));
- break;
- case 6:
- printf(" %u", EXTRACT_32BITS(option + 2));
- break;
- default:
- break;
+ ND_PRINT((ndo, "%s optlen goes past header length",
+ tok2str(dccp_option_values, "Option %u", *option)));
+ return 0;
+ }
+ ND_TCHECK2(*option, optlen);
+
+ if (*option >= 128) {
+ ND_PRINT((ndo, "CCID option %d", *option));
+ switch (optlen) {
+ case 4:
+ ND_PRINT((ndo, " %u", EXTRACT_16BITS(option + 2)));
+ break;
+ case 6:
+ ND_PRINT((ndo, " %u", EXTRACT_32BITS(option + 2)));
+ break;
+ default:
+ break;
+ }
+ } else {
+ ND_PRINT((ndo, "%s", tok2str(dccp_option_values, "Option %u", *option)));
+ switch (*option) {
+ case 32:
+ case 33:
+ case 34:
+ case 35:
+ if (optlen < 3) {
+ ND_PRINT((ndo, " optlen too short"));
+ return optlen;
+ }
+ if (*(option + 2) < 10){
+ ND_PRINT((ndo, " %s", dccp_feature_nums[*(option + 2)]));
+ for (i = 0; i < optlen - 3; i++)
+ ND_PRINT((ndo, " %d", *(option + 3 + i)));
+ }
+ break;
+ case 36:
+ if (optlen > 2) {
+ ND_PRINT((ndo, " 0x"));
+ for (i = 0; i < optlen - 2; i++)
+ ND_PRINT((ndo, "%02x", *(option + 2 + i)));
+ }
+ break;
+ case 37:
+ for (i = 0; i < optlen - 2; i++)
+ ND_PRINT((ndo, " %d", *(option + 2 + i)));
+ break;
+ case 38:
+ if (optlen > 2) {
+ ND_PRINT((ndo, " 0x"));
+ for (i = 0; i < optlen - 2; i++)
+ ND_PRINT((ndo, "%02x", *(option + 2 + i)));
+ }
+ break;
+ case 39:
+ if (optlen > 2) {
+ ND_PRINT((ndo, " 0x"));
+ for (i = 0; i < optlen - 2; i++)
+ ND_PRINT((ndo, "%02x", *(option + 2 + i)));
+ }
+ break;
+ case 40:
+ if (optlen > 2) {
+ ND_PRINT((ndo, " 0x"));
+ for (i = 0; i < optlen - 2; i++)
+ ND_PRINT((ndo, "%02x", *(option + 2 + i)));
+ }
+ break;
+ case 41:
+ if (optlen == 4)
+ ND_PRINT((ndo, " %u", EXTRACT_32BITS(option + 2)));
+ else
+ ND_PRINT((ndo, " optlen != 4"));
+ break;
+ case 42:
+ if (optlen == 4)
+ ND_PRINT((ndo, " %u", EXTRACT_32BITS(option + 2)));
+ else
+ ND_PRINT((ndo, " optlen != 4"));
+ break;
+ case 43:
+ if (optlen == 6)
+ ND_PRINT((ndo, " %u", EXTRACT_32BITS(option + 2)));
+ else if (optlen == 4)
+ ND_PRINT((ndo, " %u", EXTRACT_16BITS(option + 2)));
+ else
+ ND_PRINT((ndo, " optlen != 4 or 6"));
+ break;
+ case 44:
+ if (optlen > 2) {
+ ND_PRINT((ndo, " "));
+ for (i = 0; i < optlen - 2; i++)
+ ND_PRINT((ndo, "%02x", *(option + 2 + i)));
}
break;
}
-
- printf("unknown_opt %d", *option);
- break;
}
return optlen;
trunc:
- printf("[|dccp]");
+ ND_PRINT((ndo, "%s", tstr));
return 0;
}
diff --git a/contrib/tcpdump/print-decnet.c b/contrib/tcpdump/print-decnet.c
index 7fea582e8a00..18045150c2d4 100644
--- a/contrib/tcpdump/print-decnet.c
+++ b/contrib/tcpdump/print-decnet.c
@@ -19,11 +19,7 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-decnet.c,v 1.39 2005-05-06 02:16:26 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -41,22 +37,462 @@ struct rtentry;
#include <stdlib.h>
#include <string.h>
-#include "decnet.h"
#include "extract.h"
#include "interface.h"
#include "addrtoname.h"
+static const char tstr[] = "[|decnet]";
+
+#ifndef WIN32
+typedef uint8_t byte[1]; /* single byte field */
+#else
+/*
+ * the keyword 'byte' generates conflicts in Windows
+ */
+typedef unsigned char Byte[1]; /* single byte field */
+#define byte Byte
+#endif /* WIN32 */
+typedef uint8_t word[2]; /* 2 byte field */
+typedef uint8_t longword[4]; /* 4 bytes field */
+
+/*
+ * Definitions for DECNET Phase IV protocol headers
+ */
+union etheraddress {
+ uint8_t dne_addr[6]; /* full ethernet address */
+ struct {
+ uint8_t dne_hiord[4]; /* DECnet HIORD prefix */
+ uint8_t dne_nodeaddr[2]; /* DECnet node address */
+ } dne_remote;
+};
+
+typedef union etheraddress etheraddr; /* Ethernet address */
+
+#define HIORD 0x000400aa /* high 32-bits of address (swapped) */
+
+#define AREAMASK 0176000 /* mask for area field */
+#define AREASHIFT 10 /* bit-offset for area field */
+#define NODEMASK 01777 /* mask for node address field */
+
+#define DN_MAXADDL 20 /* max size of DECnet address */
+struct dn_naddr {
+ uint16_t a_len; /* length of address */
+ uint8_t a_addr[DN_MAXADDL]; /* address as bytes */
+};
+
+/*
+ * Define long and short header formats.
+ */
+struct shorthdr
+ {
+ byte sh_flags; /* route flags */
+ word sh_dst; /* destination node address */
+ word sh_src; /* source node address */
+ byte sh_visits; /* visit count */
+ };
+
+struct longhdr
+ {
+ byte lg_flags; /* route flags */
+ byte lg_darea; /* destination area (reserved) */
+ byte lg_dsarea; /* destination subarea (reserved) */
+ etheraddr lg_dst; /* destination id */
+ byte lg_sarea; /* source area (reserved) */
+ byte lg_ssarea; /* source subarea (reserved) */
+ etheraddr lg_src; /* source id */
+ byte lg_nextl2; /* next level 2 router (reserved) */
+ byte lg_visits; /* visit count */
+ byte lg_service; /* service class (reserved) */
+ byte lg_pt; /* protocol type (reserved) */
+ };
+
+union routehdr
+ {
+ struct shorthdr rh_short; /* short route header */
+ struct longhdr rh_long; /* long route header */
+ };
+
+/*
+ * Define the values of various fields in the protocol messages.
+ *
+ * 1. Data packet formats.
+ */
+#define RMF_MASK 7 /* mask for message type */
+#define RMF_SHORT 2 /* short message format */
+#define RMF_LONG 6 /* long message format */
+#ifndef RMF_RQR
+#define RMF_RQR 010 /* request return to sender */
+#define RMF_RTS 020 /* returning to sender */
+#define RMF_IE 040 /* intra-ethernet packet */
+#endif /* RMR_RQR */
+#define RMF_FVER 0100 /* future version flag */
+#define RMF_PAD 0200 /* pad field */
+#define RMF_PADMASK 0177 /* pad field mask */
+
+#define VIS_MASK 077 /* visit field mask */
+
+/*
+ * 2. Control packet formats.
+ */
+#define RMF_CTLMASK 017 /* mask for message type */
+#define RMF_CTLMSG 01 /* control message indicator */
+#define RMF_INIT 01 /* initialization message */
+#define RMF_VER 03 /* verification message */
+#define RMF_TEST 05 /* hello and test message */
+#define RMF_L1ROUT 07 /* level 1 routing message */
+#define RMF_L2ROUT 011 /* level 2 routing message */
+#define RMF_RHELLO 013 /* router hello message */
+#define RMF_EHELLO 015 /* endnode hello message */
+
+#define TI_L2ROUT 01 /* level 2 router */
+#define TI_L1ROUT 02 /* level 1 router */
+#define TI_ENDNODE 03 /* endnode */
+#define TI_VERIF 04 /* verification required */
+#define TI_BLOCK 010 /* blocking requested */
+
+#define VE_VERS 2 /* version number (2) */
+#define VE_ECO 0 /* ECO number */
+#define VE_UECO 0 /* user ECO number (0) */
+
+#define P3_VERS 1 /* phase III version number (1) */
+#define P3_ECO 3 /* ECO number (3) */
+#define P3_UECO 0 /* user ECO number (0) */
+
+#define II_L2ROUT 01 /* level 2 router */
+#define II_L1ROUT 02 /* level 1 router */
+#define II_ENDNODE 03 /* endnode */
+#define II_VERIF 04 /* verification required */
+#define II_NOMCAST 040 /* no multicast traffic accepted */
+#define II_BLOCK 0100 /* blocking requested */
+#define II_TYPEMASK 03 /* mask for node type */
+
+#define TESTDATA 0252 /* test data bytes */
+#define TESTLEN 1 /* length of transmitted test data */
+
+/*
+ * Define control message formats.
+ */
+struct initmsgIII /* phase III initialization message */
+ {
+ byte inIII_flags; /* route flags */
+ word inIII_src; /* source node address */
+ byte inIII_info; /* routing layer information */
+ word inIII_blksize; /* maximum data link block size */
+ byte inIII_vers; /* version number */
+ byte inIII_eco; /* ECO number */
+ byte inIII_ueco; /* user ECO number */
+ byte inIII_rsvd; /* reserved image field */
+ };
+
+struct initmsg /* initialization message */
+ {
+ byte in_flags; /* route flags */
+ word in_src; /* source node address */
+ byte in_info; /* routing layer information */
+ word in_blksize; /* maximum data link block size */
+ byte in_vers; /* version number */
+ byte in_eco; /* ECO number */
+ byte in_ueco; /* user ECO number */
+ word in_hello; /* hello timer */
+ byte in_rsvd; /* reserved image field */
+ };
+
+struct verifmsg /* verification message */
+ {
+ byte ve_flags; /* route flags */
+ word ve_src; /* source node address */
+ byte ve_fcnval; /* function value image field */
+ };
+
+struct testmsg /* hello and test message */
+ {
+ byte te_flags; /* route flags */
+ word te_src; /* source node address */
+ byte te_data; /* test data image field */
+ };
+
+struct l1rout /* level 1 routing message */
+ {
+ byte r1_flags; /* route flags */
+ word r1_src; /* source node address */
+ byte r1_rsvd; /* reserved field */
+ };
+
+struct l2rout /* level 2 routing message */
+ {
+ byte r2_flags; /* route flags */
+ word r2_src; /* source node address */
+ byte r2_rsvd; /* reserved field */
+ };
+
+struct rhellomsg /* router hello message */
+ {
+ byte rh_flags; /* route flags */
+ byte rh_vers; /* version number */
+ byte rh_eco; /* ECO number */
+ byte rh_ueco; /* user ECO number */
+ etheraddr rh_src; /* source id */
+ byte rh_info; /* routing layer information */
+ word rh_blksize; /* maximum data link block size */
+ byte rh_priority; /* router's priority */
+ byte rh_area; /* reserved */
+ word rh_hello; /* hello timer */
+ byte rh_mpd; /* reserved */
+ };
+
+struct ehellomsg /* endnode hello message */
+ {
+ byte eh_flags; /* route flags */
+ byte eh_vers; /* version number */
+ byte eh_eco; /* ECO number */
+ byte eh_ueco; /* user ECO number */
+ etheraddr eh_src; /* source id */
+ byte eh_info; /* routing layer information */
+ word eh_blksize; /* maximum data link block size */
+ byte eh_area; /* area (reserved) */
+ byte eh_seed[8]; /* verification seed */
+ etheraddr eh_router; /* designated router */
+ word eh_hello; /* hello timer */
+ byte eh_mpd; /* (reserved) */
+ byte eh_data; /* test data image field */
+ };
+
+union controlmsg
+ {
+ struct initmsg cm_init; /* initialization message */
+ struct verifmsg cm_ver; /* verification message */
+ struct testmsg cm_test; /* hello and test message */
+ struct l1rout cm_l1rou; /* level 1 routing message */
+ struct l2rout cm_l2rout; /* level 2 routing message */
+ struct rhellomsg cm_rhello; /* router hello message */
+ struct ehellomsg cm_ehello; /* endnode hello message */
+ };
+
+/* Macros for decoding routing-info fields */
+#define RI_COST(x) ((x)&0777)
+#define RI_HOPS(x) (((x)>>10)&037)
+
+/*
+ * NSP protocol fields and values.
+ */
+
+#define NSP_TYPEMASK 014 /* mask to isolate type code */
+#define NSP_SUBMASK 0160 /* mask to isolate subtype code */
+#define NSP_SUBSHFT 4 /* shift to move subtype code */
+
+#define MFT_DATA 0 /* data message */
+#define MFT_ACK 04 /* acknowledgement message */
+#define MFT_CTL 010 /* control message */
+
+#define MFS_ILS 020 /* data or I/LS indicator */
+#define MFS_BOM 040 /* beginning of message (data) */
+#define MFS_MOM 0 /* middle of message (data) */
+#define MFS_EOM 0100 /* end of message (data) */
+#define MFS_INT 040 /* interrupt message */
+
+#define MFS_DACK 0 /* data acknowledgement */
+#define MFS_IACK 020 /* I/LS acknowledgement */
+#define MFS_CACK 040 /* connect acknowledgement */
+
+#define MFS_NOP 0 /* no operation */
+#define MFS_CI 020 /* connect initiate */
+#define MFS_CC 040 /* connect confirm */
+#define MFS_DI 060 /* disconnect initiate */
+#define MFS_DC 0100 /* disconnect confirm */
+#define MFS_RCI 0140 /* retransmitted connect initiate */
+
+#define SGQ_ACK 0100000 /* ack */
+#define SGQ_NAK 0110000 /* negative ack */
+#define SGQ_OACK 0120000 /* other channel ack */
+#define SGQ_ONAK 0130000 /* other channel negative ack */
+#define SGQ_MASK 07777 /* mask to isolate seq # */
+#define SGQ_OTHER 020000 /* other channel qualifier */
+#define SGQ_DELAY 010000 /* ack delay flag */
+
+#define SGQ_EOM 0100000 /* pseudo flag for end-of-message */
+
+#define LSM_MASK 03 /* mask for modifier field */
+#define LSM_NOCHANGE 0 /* no change */
+#define LSM_DONOTSEND 1 /* do not send data */
+#define LSM_SEND 2 /* send data */
+
+#define LSI_MASK 014 /* mask for interpretation field */
+#define LSI_DATA 0 /* data segment or message count */
+#define LSI_INTR 4 /* interrupt request count */
+#define LSI_INTM 0377 /* funny marker for int. message */
+
+#define COS_MASK 014 /* mask for flow control field */
+#define COS_NONE 0 /* no flow control */
+#define COS_SEGMENT 04 /* segment flow control */
+#define COS_MESSAGE 010 /* message flow control */
+#define COS_CRYPTSER 020 /* cryptographic services requested */
+#define COS_DEFAULT 1 /* default value for field */
+
+#define COI_MASK 3 /* mask for version field */
+#define COI_32 0 /* version 3.2 */
+#define COI_31 1 /* version 3.1 */
+#define COI_40 2 /* version 4.0 */
+#define COI_41 3 /* version 4.1 */
+
+#define MNU_MASK 140 /* mask for session control version */
+#define MNU_10 000 /* session V1.0 */
+#define MNU_20 040 /* session V2.0 */
+#define MNU_ACCESS 1 /* access control present */
+#define MNU_USRDATA 2 /* user data field present */
+#define MNU_INVKPROXY 4 /* invoke proxy field present */
+#define MNU_UICPROXY 8 /* use uic-based proxy */
+
+#define DC_NORESOURCES 1 /* no resource reason code */
+#define DC_NOLINK 41 /* no link terminate reason code */
+#define DC_COMPLETE 42 /* disconnect complete reason code */
+
+#define DI_NOERROR 0 /* user disconnect */
+#define DI_SHUT 3 /* node is shutting down */
+#define DI_NOUSER 4 /* destination end user does not exist */
+#define DI_INVDEST 5 /* invalid end user destination */
+#define DI_REMRESRC 6 /* insufficient remote resources */
+#define DI_TPA 8 /* third party abort */
+#define DI_PROTOCOL 7 /* protocol error discovered */
+#define DI_ABORT 9 /* user abort */
+#define DI_LOCALRESRC 32 /* insufficient local resources */
+#define DI_REMUSERRESRC 33 /* insufficient remote user resources */
+#define DI_BADACCESS 34 /* bad access control information */
+#define DI_BADACCNT 36 /* bad ACCOUNT information */
+#define DI_CONNECTABORT 38 /* connect request cancelled */
+#define DI_TIMEDOUT 38 /* remote node or user crashed */
+#define DI_UNREACHABLE 39 /* local timers expired due to ... */
+#define DI_BADIMAGE 43 /* bad image data in connect */
+#define DI_SERVMISMATCH 54 /* cryptographic service mismatch */
+
+#define UC_OBJREJECT 0 /* object rejected connect */
+#define UC_USERDISCONNECT 0 /* user disconnect */
+#define UC_RESOURCES 1 /* insufficient resources (local or remote) */
+#define UC_NOSUCHNODE 2 /* unrecognized node name */
+#define UC_REMOTESHUT 3 /* remote node shutting down */
+#define UC_NOSUCHOBJ 4 /* unrecognized object */
+#define UC_INVOBJFORMAT 5 /* invalid object name format */
+#define UC_OBJTOOBUSY 6 /* object too busy */
+#define UC_NETWORKABORT 8 /* network abort */
+#define UC_USERABORT 9 /* user abort */
+#define UC_INVNODEFORMAT 10 /* invalid node name format */
+#define UC_LOCALSHUT 11 /* local node shutting down */
+#define UC_ACCESSREJECT 34 /* invalid access control information */
+#define UC_NORESPONSE 38 /* no response from object */
+#define UC_UNREACHABLE 39 /* node unreachable */
+
+/*
+ * NSP message formats.
+ */
+struct nsphdr /* general nsp header */
+ {
+ byte nh_flags; /* message flags */
+ word nh_dst; /* destination link address */
+ word nh_src; /* source link address */
+ };
+
+struct seghdr /* data segment header */
+ {
+ byte sh_flags; /* message flags */
+ word sh_dst; /* destination link address */
+ word sh_src; /* source link address */
+ word sh_seq[3]; /* sequence numbers */
+ };
+
+struct minseghdr /* minimum data segment header */
+ {
+ byte ms_flags; /* message flags */
+ word ms_dst; /* destination link address */
+ word ms_src; /* source link address */
+ word ms_seq; /* sequence number */
+ };
+
+struct lsmsg /* link service message (after hdr) */
+ {
+ byte ls_lsflags; /* link service flags */
+ byte ls_fcval; /* flow control value */
+ };
+
+struct ackmsg /* acknowledgement message */
+ {
+ byte ak_flags; /* message flags */
+ word ak_dst; /* destination link address */
+ word ak_src; /* source link address */
+ word ak_acknum[2]; /* acknowledgement numbers */
+ };
+
+struct minackmsg /* minimum acknowledgement message */
+ {
+ byte mk_flags; /* message flags */
+ word mk_dst; /* destination link address */
+ word mk_src; /* source link address */
+ word mk_acknum; /* acknowledgement number */
+ };
+
+struct ciackmsg /* connect acknowledgement message */
+ {
+ byte ck_flags; /* message flags */
+ word ck_dst; /* destination link address */
+ };
+
+struct cimsg /* connect initiate message */
+ {
+ byte ci_flags; /* message flags */
+ word ci_dst; /* destination link address (0) */
+ word ci_src; /* source link address */
+ byte ci_services; /* requested services */
+ byte ci_info; /* information */
+ word ci_segsize; /* maximum segment size */
+ };
+
+struct ccmsg /* connect confirm message */
+ {
+ byte cc_flags; /* message flags */
+ word cc_dst; /* destination link address */
+ word cc_src; /* source link address */
+ byte cc_services; /* requested services */
+ byte cc_info; /* information */
+ word cc_segsize; /* maximum segment size */
+ byte cc_optlen; /* optional data length */
+ };
+
+struct cnmsg /* generic connect message */
+ {
+ byte cn_flags; /* message flags */
+ word cn_dst; /* destination link address */
+ word cn_src; /* source link address */
+ byte cn_services; /* requested services */
+ byte cn_info; /* information */
+ word cn_segsize; /* maximum segment size */
+ };
+
+struct dimsg /* disconnect initiate message */
+ {
+ byte di_flags; /* message flags */
+ word di_dst; /* destination link address */
+ word di_src; /* source link address */
+ word di_reason; /* reason code */
+ byte di_optlen; /* optional data length */
+ };
+
+struct dcmsg /* disconnect confirm message */
+ {
+ byte dc_flags; /* message flags */
+ word dc_dst; /* destination link address */
+ word dc_src; /* source link address */
+ word dc_reason; /* reason code */
+ };
+
/* Forwards */
-static int print_decnet_ctlmsg(const union routehdr *, u_int, u_int);
-static void print_t_info(int);
-static int print_l1_routes(const char *, u_int);
-static int print_l2_routes(const char *, u_int);
-static void print_i_info(int);
+static int print_decnet_ctlmsg(netdissect_options *, const union routehdr *, u_int, u_int);
+static void print_t_info(netdissect_options *, int);
+static int print_l1_routes(netdissect_options *, const char *, u_int);
+static int print_l2_routes(netdissect_options *, const char *, u_int);
+static void print_i_info(netdissect_options *, int);
static int print_elist(const char *, u_int);
-static int print_nsp(const u_char *, u_int);
-static void print_reason(int);
+static int print_nsp(netdissect_options *, const u_char *, u_int);
+static void print_reason(netdissect_options *, int);
#ifdef PRINT_NSPDATA
-static void pdata(u_char *, int);
+static void pdata(netdissect_options *, u_char *, u_int);
#endif
#ifndef HAVE_NETDNET_DNETDB_H_DNET_HTOA
@@ -64,8 +500,9 @@ extern char *dnet_htoa(struct dn_naddr *);
#endif
void
-decnet_print(register const u_char *ap, register u_int length,
- register u_int caplen)
+decnet_print(netdissect_options *ndo,
+ register const u_char *ap, register u_int length,
+ register u_int caplen)
{
register const union routehdr *rhp;
register int mflags;
@@ -74,36 +511,36 @@ decnet_print(register const u_char *ap, register u_int length,
const u_char *nspp;
if (length < sizeof(struct shorthdr)) {
- (void)printf("[|decnet]");
+ ND_PRINT((ndo, "%s", tstr));
return;
}
- TCHECK2(*ap, sizeof(short));
+ ND_TCHECK2(*ap, sizeof(short));
pktlen = EXTRACT_LE_16BITS(ap);
if (pktlen < sizeof(struct shorthdr)) {
- (void)printf("[|decnet]");
+ ND_PRINT((ndo, "%s", tstr));
return;
}
if (pktlen > length) {
- (void)printf("[|decnet]");
+ ND_PRINT((ndo, "%s", tstr));
return;
}
length = pktlen;
rhp = (const union routehdr *)&(ap[sizeof(short)]);
- TCHECK(rhp->rh_short.sh_flags);
+ ND_TCHECK(rhp->rh_short.sh_flags);
mflags = EXTRACT_LE_8BITS(rhp->rh_short.sh_flags);
if (mflags & RMF_PAD) {
/* pad bytes of some sort in front of message */
u_int padlen = mflags & RMF_PADMASK;
- if (vflag)
- (void) printf("[pad:%d] ", padlen);
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, "[pad:%d] ", padlen));
if (length < padlen + 2) {
- (void)printf("[|decnet]");
+ ND_PRINT((ndo, "%s", tstr));
return;
}
- TCHECK2(ap[sizeof(short)], padlen);
+ ND_TCHECK2(ap[sizeof(short)], padlen);
ap += padlen;
length -= padlen;
caplen -= padlen;
@@ -112,14 +549,14 @@ decnet_print(register const u_char *ap, register u_int length,
}
if (mflags & RMF_FVER) {
- (void) printf("future-version-decnet");
- default_print(ap, min(length, caplen));
+ ND_PRINT((ndo, "future-version-decnet"));
+ ND_DEFAULTPRINT(ap, min(length, caplen));
return;
}
/* is it a control message? */
if (mflags & RMF_CTLMSG) {
- if (!print_decnet_ctlmsg(rhp, length, caplen))
+ if (!print_decnet_ctlmsg(ndo, rhp, length, caplen))
goto trunc;
return;
}
@@ -127,10 +564,10 @@ decnet_print(register const u_char *ap, register u_int length,
switch (mflags & RMF_MASK) {
case RMF_LONG:
if (length < sizeof(struct longhdr)) {
- (void)printf("[|decnet]");
+ ND_PRINT((ndo, "%s", tstr));
return;
}
- TCHECK(rhp->rh_long);
+ ND_TCHECK(rhp->rh_long);
dst =
EXTRACT_LE_16BITS(rhp->rh_long.lg_dst.dne_remote.dne_nodeaddr);
src =
@@ -140,7 +577,7 @@ decnet_print(register const u_char *ap, register u_int length,
nsplen = length - sizeof(struct longhdr);
break;
case RMF_SHORT:
- TCHECK(rhp->rh_short);
+ ND_TCHECK(rhp->rh_short);
dst = EXTRACT_LE_16BITS(rhp->rh_short.sh_dst);
src = EXTRACT_LE_16BITS(rhp->rh_short.sh_src);
hops = (EXTRACT_LE_8BITS(rhp->rh_short.sh_visits) & VIS_MASK)+1;
@@ -148,35 +585,36 @@ decnet_print(register const u_char *ap, register u_int length,
nsplen = length - sizeof(struct shorthdr);
break;
default:
- (void) printf("unknown message flags under mask");
- default_print((u_char *)ap, min(length, caplen));
+ ND_PRINT((ndo, "unknown message flags under mask"));
+ ND_DEFAULTPRINT((u_char *)ap, min(length, caplen));
return;
}
- (void)printf("%s > %s %d ",
- dnaddr_string(src), dnaddr_string(dst), pktlen);
- if (vflag) {
+ ND_PRINT((ndo, "%s > %s %d ",
+ dnaddr_string(ndo, src), dnaddr_string(ndo, dst), pktlen));
+ if (ndo->ndo_vflag) {
if (mflags & RMF_RQR)
- (void)printf("RQR ");
+ ND_PRINT((ndo, "RQR "));
if (mflags & RMF_RTS)
- (void)printf("RTS ");
+ ND_PRINT((ndo, "RTS "));
if (mflags & RMF_IE)
- (void)printf("IE ");
- (void)printf("%d hops ", hops);
+ ND_PRINT((ndo, "IE "));
+ ND_PRINT((ndo, "%d hops ", hops));
}
- if (!print_nsp(nspp, nsplen))
+ if (!print_nsp(ndo, nspp, nsplen))
goto trunc;
return;
trunc:
- (void)printf("[|decnet]");
+ ND_PRINT((ndo, "%s", tstr));
return;
}
static int
-print_decnet_ctlmsg(register const union routehdr *rhp, u_int length,
- u_int caplen)
+print_decnet_ctlmsg(netdissect_options *ndo,
+ register const union routehdr *rhp, u_int length,
+ u_int caplen)
{
int mflags = EXTRACT_LE_8BITS(rhp->rh_short.sh_flags);
register union controlmsg *cmp = (union controlmsg *)rhp;
@@ -188,10 +626,10 @@ print_decnet_ctlmsg(register const union routehdr *rhp, u_int length,
switch (mflags & RMF_CTLMASK) {
case RMF_INIT:
- (void)printf("init ");
+ ND_PRINT((ndo, "init "));
if (length < sizeof(struct initmsg))
goto trunc;
- TCHECK(cmp->cm_init);
+ ND_TCHECK(cmp->cm_init);
src = EXTRACT_LE_16BITS(cmp->cm_init.in_src);
info = EXTRACT_LE_8BITS(cmp->cm_init.in_info);
blksize = EXTRACT_LE_16BITS(cmp->cm_init.in_blksize);
@@ -199,58 +637,58 @@ print_decnet_ctlmsg(register const union routehdr *rhp, u_int length,
eco = EXTRACT_LE_8BITS(cmp->cm_init.in_eco);
ueco = EXTRACT_LE_8BITS(cmp->cm_init.in_ueco);
hello = EXTRACT_LE_16BITS(cmp->cm_init.in_hello);
- print_t_info(info);
- (void)printf(
+ print_t_info(ndo, info);
+ ND_PRINT((ndo,
"src %sblksize %d vers %d eco %d ueco %d hello %d",
- dnaddr_string(src), blksize, vers, eco, ueco,
- hello);
+ dnaddr_string(ndo, src), blksize, vers, eco, ueco,
+ hello));
ret = 1;
break;
case RMF_VER:
- (void)printf("verification ");
+ ND_PRINT((ndo, "verification "));
if (length < sizeof(struct verifmsg))
goto trunc;
- TCHECK(cmp->cm_ver);
+ ND_TCHECK(cmp->cm_ver);
src = EXTRACT_LE_16BITS(cmp->cm_ver.ve_src);
other = EXTRACT_LE_8BITS(cmp->cm_ver.ve_fcnval);
- (void)printf("src %s fcnval %o", dnaddr_string(src), other);
+ ND_PRINT((ndo, "src %s fcnval %o", dnaddr_string(ndo, src), other));
ret = 1;
break;
case RMF_TEST:
- (void)printf("test ");
+ ND_PRINT((ndo, "test "));
if (length < sizeof(struct testmsg))
goto trunc;
- TCHECK(cmp->cm_test);
+ ND_TCHECK(cmp->cm_test);
src = EXTRACT_LE_16BITS(cmp->cm_test.te_src);
other = EXTRACT_LE_8BITS(cmp->cm_test.te_data);
- (void)printf("src %s data %o", dnaddr_string(src), other);
+ ND_PRINT((ndo, "src %s data %o", dnaddr_string(ndo, src), other));
ret = 1;
break;
case RMF_L1ROUT:
- (void)printf("lev-1-routing ");
+ ND_PRINT((ndo, "lev-1-routing "));
if (length < sizeof(struct l1rout))
goto trunc;
- TCHECK(cmp->cm_l1rou);
+ ND_TCHECK(cmp->cm_l1rou);
src = EXTRACT_LE_16BITS(cmp->cm_l1rou.r1_src);
- (void)printf("src %s ", dnaddr_string(src));
- ret = print_l1_routes(&(rhpx[sizeof(struct l1rout)]),
+ ND_PRINT((ndo, "src %s ", dnaddr_string(ndo, src)));
+ ret = print_l1_routes(ndo, &(rhpx[sizeof(struct l1rout)]),
length - sizeof(struct l1rout));
break;
case RMF_L2ROUT:
- (void)printf("lev-2-routing ");
+ ND_PRINT((ndo, "lev-2-routing "));
if (length < sizeof(struct l2rout))
goto trunc;
- TCHECK(cmp->cm_l2rout);
+ ND_TCHECK(cmp->cm_l2rout);
src = EXTRACT_LE_16BITS(cmp->cm_l2rout.r2_src);
- (void)printf("src %s ", dnaddr_string(src));
- ret = print_l2_routes(&(rhpx[sizeof(struct l2rout)]),
+ ND_PRINT((ndo, "src %s ", dnaddr_string(ndo, src)));
+ ret = print_l2_routes(ndo, &(rhpx[sizeof(struct l2rout)]),
length - sizeof(struct l2rout));
break;
case RMF_RHELLO:
- (void)printf("router-hello ");
+ ND_PRINT((ndo, "router-hello "));
if (length < sizeof(struct rhellomsg))
goto trunc;
- TCHECK(cmp->cm_rhello);
+ ND_TCHECK(cmp->cm_rhello);
vers = EXTRACT_LE_8BITS(cmp->cm_rhello.rh_vers);
eco = EXTRACT_LE_8BITS(cmp->cm_rhello.rh_eco);
ueco = EXTRACT_LE_8BITS(cmp->cm_rhello.rh_ueco);
@@ -261,19 +699,19 @@ print_decnet_ctlmsg(register const union routehdr *rhp, u_int length,
blksize = EXTRACT_LE_16BITS(cmp->cm_rhello.rh_blksize);
priority = EXTRACT_LE_8BITS(cmp->cm_rhello.rh_priority);
hello = EXTRACT_LE_16BITS(cmp->cm_rhello.rh_hello);
- print_i_info(info);
- (void)printf(
+ print_i_info(ndo, info);
+ ND_PRINT((ndo,
"vers %d eco %d ueco %d src %s blksize %d pri %d hello %d",
- vers, eco, ueco, dnaddr_string(src),
- blksize, priority, hello);
+ vers, eco, ueco, dnaddr_string(ndo, src),
+ blksize, priority, hello));
ret = print_elist(&(rhpx[sizeof(struct rhellomsg)]),
length - sizeof(struct rhellomsg));
break;
case RMF_EHELLO:
- (void)printf("endnode-hello ");
+ ND_PRINT((ndo, "endnode-hello "));
if (length < sizeof(struct ehellomsg))
goto trunc;
- TCHECK(cmp->cm_ehello);
+ ND_TCHECK(cmp->cm_ehello);
vers = EXTRACT_LE_8BITS(cmp->cm_ehello.eh_vers);
eco = EXTRACT_LE_8BITS(cmp->cm_ehello.eh_eco);
ueco = EXTRACT_LE_8BITS(cmp->cm_ehello.eh_ueco);
@@ -288,17 +726,17 @@ print_decnet_ctlmsg(register const union routehdr *rhp, u_int length,
dst = EXTRACT_LE_16BITS(rtea.dne_remote.dne_nodeaddr);
hello = EXTRACT_LE_16BITS(cmp->cm_ehello.eh_hello);
other = EXTRACT_LE_8BITS(cmp->cm_ehello.eh_data);
- print_i_info(info);
- (void)printf(
+ print_i_info(ndo, info);
+ ND_PRINT((ndo,
"vers %d eco %d ueco %d src %s blksize %d rtr %s hello %d data %o",
- vers, eco, ueco, dnaddr_string(src),
- blksize, dnaddr_string(dst), hello, other);
+ vers, eco, ueco, dnaddr_string(ndo, src),
+ blksize, dnaddr_string(ndo, dst), hello, other));
ret = 1;
break;
default:
- (void)printf("unknown control message");
- default_print((u_char *)rhp, min(length, caplen));
+ ND_PRINT((ndo, "unknown control message"));
+ ND_DEFAULTPRINT((u_char *)rhp, min(length, caplen));
ret = 1;
break;
}
@@ -309,23 +747,25 @@ trunc:
}
static void
-print_t_info(int info)
+print_t_info(netdissect_options *ndo,
+ int info)
{
int ntype = info & 3;
switch (ntype) {
- case 0: (void)printf("reserved-ntype? "); break;
- case TI_L2ROUT: (void)printf("l2rout "); break;
- case TI_L1ROUT: (void)printf("l1rout "); break;
- case TI_ENDNODE: (void)printf("endnode "); break;
+ case 0: ND_PRINT((ndo, "reserved-ntype? ")); break;
+ case TI_L2ROUT: ND_PRINT((ndo, "l2rout ")); break;
+ case TI_L1ROUT: ND_PRINT((ndo, "l1rout ")); break;
+ case TI_ENDNODE: ND_PRINT((ndo, "endnode ")); break;
}
if (info & TI_VERIF)
- (void)printf("verif ");
+ ND_PRINT((ndo, "verif "));
if (info & TI_BLOCK)
- (void)printf("blo ");
+ ND_PRINT((ndo, "blo "));
}
static int
-print_l1_routes(const char *rp, u_int len)
+print_l1_routes(netdissect_options *ndo,
+ const char *rp, u_int len)
{
int count;
int id;
@@ -333,7 +773,7 @@ print_l1_routes(const char *rp, u_int len)
/* The last short is a checksum */
while (len > (3 * sizeof(short))) {
- TCHECK2(*rp, 3 * sizeof(short));
+ ND_TCHECK2(*rp, 3 * sizeof(short));
count = EXTRACT_LE_16BITS(rp);
if (count > 1024)
return (1); /* seems to be bogus from here on */
@@ -345,8 +785,8 @@ print_l1_routes(const char *rp, u_int len)
info = EXTRACT_LE_16BITS(rp);
rp += sizeof(short);
len -= sizeof(short);
- (void)printf("{ids %d-%d cost %d hops %d} ", id, id + count,
- RI_COST(info), RI_HOPS(info));
+ ND_PRINT((ndo, "{ids %d-%d cost %d hops %d} ", id, id + count,
+ RI_COST(info), RI_HOPS(info)));
}
return (1);
@@ -355,7 +795,8 @@ trunc:
}
static int
-print_l2_routes(const char *rp, u_int len)
+print_l2_routes(netdissect_options *ndo,
+ const char *rp, u_int len)
{
int count;
int area;
@@ -363,7 +804,7 @@ print_l2_routes(const char *rp, u_int len)
/* The last short is a checksum */
while (len > (3 * sizeof(short))) {
- TCHECK2(*rp, 3 * sizeof(short));
+ ND_TCHECK2(*rp, 3 * sizeof(short));
count = EXTRACT_LE_16BITS(rp);
if (count > 1024)
return (1); /* seems to be bogus from here on */
@@ -375,8 +816,8 @@ print_l2_routes(const char *rp, u_int len)
info = EXTRACT_LE_16BITS(rp);
rp += sizeof(short);
len -= sizeof(short);
- (void)printf("{areas %d-%d cost %d hops %d} ", area, area + count,
- RI_COST(info), RI_HOPS(info));
+ ND_PRINT((ndo, "{areas %d-%d cost %d hops %d} ", area, area + count,
+ RI_COST(info), RI_HOPS(info)));
}
return (1);
@@ -385,21 +826,22 @@ trunc:
}
static void
-print_i_info(int info)
+print_i_info(netdissect_options *ndo,
+ int info)
{
int ntype = info & II_TYPEMASK;
switch (ntype) {
- case 0: (void)printf("reserved-ntype? "); break;
- case II_L2ROUT: (void)printf("l2rout "); break;
- case II_L1ROUT: (void)printf("l1rout "); break;
- case II_ENDNODE: (void)printf("endnode "); break;
+ case 0: ND_PRINT((ndo, "reserved-ntype? ")); break;
+ case II_L2ROUT: ND_PRINT((ndo, "l2rout ")); break;
+ case II_L1ROUT: ND_PRINT((ndo, "l1rout ")); break;
+ case II_ENDNODE: ND_PRINT((ndo, "endnode ")); break;
}
if (info & II_VERIF)
- (void)printf("verif ");
+ ND_PRINT((ndo, "verif "));
if (info & II_NOMCAST)
- (void)printf("nomcast ");
+ ND_PRINT((ndo, "nomcast "));
if (info & II_BLOCK)
- (void)printf("blo ");
+ ND_PRINT((ndo, "blo "));
}
static int
@@ -410,14 +852,15 @@ print_elist(const char *elp _U_, u_int len _U_)
}
static int
-print_nsp(const u_char *nspp, u_int nsplen)
+print_nsp(netdissect_options *ndo,
+ const u_char *nspp, u_int nsplen)
{
const struct nsphdr *nsphp = (struct nsphdr *)nspp;
int dst, src, flags;
if (nsplen < sizeof(struct nsphdr))
goto trunc;
- TCHECK(*nsphp);
+ ND_TCHECK(*nsphp);
flags = EXTRACT_LE_8BITS(nsphp->nh_flags);
dst = EXTRACT_LE_16BITS(nsphp->nh_dst);
src = EXTRACT_LE_16BITS(nsphp->nh_src);
@@ -429,7 +872,7 @@ print_nsp(const u_char *nspp, u_int nsplen)
case MFS_MOM:
case MFS_EOM:
case MFS_BOM+MFS_EOM:
- printf("data %d>%d ", src, dst);
+ ND_PRINT((ndo, "data %d>%d ", src, dst));
{
struct seghdr *shp = (struct seghdr *)nspp;
int ack;
@@ -440,42 +883,42 @@ print_nsp(const u_char *nspp, u_int nsplen)
if (nsplen < data_off)
goto trunc;
- TCHECK(shp->sh_seq[0]);
+ ND_TCHECK(shp->sh_seq[0]);
ack = EXTRACT_LE_16BITS(shp->sh_seq[0]);
if (ack & SGQ_ACK) { /* acknum field */
if ((ack & SGQ_NAK) == SGQ_NAK)
- (void)printf("nak %d ", ack & SGQ_MASK);
+ ND_PRINT((ndo, "nak %d ", ack & SGQ_MASK));
else
- (void)printf("ack %d ", ack & SGQ_MASK);
+ ND_PRINT((ndo, "ack %d ", ack & SGQ_MASK));
data_off += sizeof(short);
if (nsplen < data_off)
goto trunc;
- TCHECK(shp->sh_seq[1]);
+ ND_TCHECK(shp->sh_seq[1]);
ack = EXTRACT_LE_16BITS(shp->sh_seq[1]);
if (ack & SGQ_OACK) { /* ackoth field */
if ((ack & SGQ_ONAK) == SGQ_ONAK)
- (void)printf("onak %d ", ack & SGQ_MASK);
+ ND_PRINT((ndo, "onak %d ", ack & SGQ_MASK));
else
- (void)printf("oack %d ", ack & SGQ_MASK);
+ ND_PRINT((ndo, "oack %d ", ack & SGQ_MASK));
data_off += sizeof(short);
if (nsplen < data_off)
goto trunc;
- TCHECK(shp->sh_seq[2]);
+ ND_TCHECK(shp->sh_seq[2]);
ack = EXTRACT_LE_16BITS(shp->sh_seq[2]);
}
}
- (void)printf("seg %d ", ack & SGQ_MASK);
+ ND_PRINT((ndo, "seg %d ", ack & SGQ_MASK));
#ifdef PRINT_NSPDATA
if (nsplen > data_off) {
dp = &(nspp[data_off]);
- TCHECK2(*dp, nsplen - data_off);
- pdata(dp, nsplen - data_off);
+ ND_TCHECK2(*dp, nsplen - data_off);
+ pdata(ndo, dp, nsplen - data_off);
}
#endif
}
break;
case MFS_ILS+MFS_INT:
- printf("intr ");
+ ND_PRINT((ndo, "intr "));
{
struct seghdr *shp = (struct seghdr *)nspp;
int ack;
@@ -486,42 +929,42 @@ print_nsp(const u_char *nspp, u_int nsplen)
if (nsplen < data_off)
goto trunc;
- TCHECK(shp->sh_seq[0]);
+ ND_TCHECK(shp->sh_seq[0]);
ack = EXTRACT_LE_16BITS(shp->sh_seq[0]);
if (ack & SGQ_ACK) { /* acknum field */
if ((ack & SGQ_NAK) == SGQ_NAK)
- (void)printf("nak %d ", ack & SGQ_MASK);
+ ND_PRINT((ndo, "nak %d ", ack & SGQ_MASK));
else
- (void)printf("ack %d ", ack & SGQ_MASK);
+ ND_PRINT((ndo, "ack %d ", ack & SGQ_MASK));
data_off += sizeof(short);
if (nsplen < data_off)
goto trunc;
- TCHECK(shp->sh_seq[1]);
+ ND_TCHECK(shp->sh_seq[1]);
ack = EXTRACT_LE_16BITS(shp->sh_seq[1]);
if (ack & SGQ_OACK) { /* ackdat field */
if ((ack & SGQ_ONAK) == SGQ_ONAK)
- (void)printf("nakdat %d ", ack & SGQ_MASK);
+ ND_PRINT((ndo, "nakdat %d ", ack & SGQ_MASK));
else
- (void)printf("ackdat %d ", ack & SGQ_MASK);
+ ND_PRINT((ndo, "ackdat %d ", ack & SGQ_MASK));
data_off += sizeof(short);
if (nsplen < data_off)
goto trunc;
- TCHECK(shp->sh_seq[2]);
+ ND_TCHECK(shp->sh_seq[2]);
ack = EXTRACT_LE_16BITS(shp->sh_seq[2]);
}
}
- (void)printf("seg %d ", ack & SGQ_MASK);
+ ND_PRINT((ndo, "seg %d ", ack & SGQ_MASK));
#ifdef PRINT_NSPDATA
if (nsplen > data_off) {
dp = &(nspp[data_off]);
- TCHECK2(*dp, nsplen - data_off);
- pdata(dp, nsplen - data_off);
+ ND_TCHECK2(*dp, nsplen - data_off);
+ pdata(ndo, dp, nsplen - data_off);
}
#endif
}
break;
case MFS_ILS:
- (void)printf("link-service %d>%d ", src, dst);
+ ND_PRINT((ndo, "link-service %d>%d ", src, dst));
{
struct seghdr *shp = (struct seghdr *)nspp;
struct lsmsg *lsmp =
@@ -531,117 +974,117 @@ print_nsp(const u_char *nspp, u_int nsplen)
if (nsplen < sizeof(struct seghdr) + sizeof(struct lsmsg))
goto trunc;
- TCHECK(shp->sh_seq[0]);
+ ND_TCHECK(shp->sh_seq[0]);
ack = EXTRACT_LE_16BITS(shp->sh_seq[0]);
if (ack & SGQ_ACK) { /* acknum field */
if ((ack & SGQ_NAK) == SGQ_NAK)
- (void)printf("nak %d ", ack & SGQ_MASK);
+ ND_PRINT((ndo, "nak %d ", ack & SGQ_MASK));
else
- (void)printf("ack %d ", ack & SGQ_MASK);
- TCHECK(shp->sh_seq[1]);
+ ND_PRINT((ndo, "ack %d ", ack & SGQ_MASK));
+ ND_TCHECK(shp->sh_seq[1]);
ack = EXTRACT_LE_16BITS(shp->sh_seq[1]);
if (ack & SGQ_OACK) { /* ackdat field */
if ((ack & SGQ_ONAK) == SGQ_ONAK)
- (void)printf("nakdat %d ", ack & SGQ_MASK);
+ ND_PRINT((ndo, "nakdat %d ", ack & SGQ_MASK));
else
- (void)printf("ackdat %d ", ack & SGQ_MASK);
- TCHECK(shp->sh_seq[2]);
+ ND_PRINT((ndo, "ackdat %d ", ack & SGQ_MASK));
+ ND_TCHECK(shp->sh_seq[2]);
ack = EXTRACT_LE_16BITS(shp->sh_seq[2]);
}
}
- (void)printf("seg %d ", ack & SGQ_MASK);
- TCHECK(*lsmp);
+ ND_PRINT((ndo, "seg %d ", ack & SGQ_MASK));
+ ND_TCHECK(*lsmp);
lsflags = EXTRACT_LE_8BITS(lsmp->ls_lsflags);
fcval = EXTRACT_LE_8BITS(lsmp->ls_fcval);
switch (lsflags & LSI_MASK) {
case LSI_DATA:
- (void)printf("dat seg count %d ", fcval);
+ ND_PRINT((ndo, "dat seg count %d ", fcval));
switch (lsflags & LSM_MASK) {
case LSM_NOCHANGE:
break;
case LSM_DONOTSEND:
- (void)printf("donotsend-data ");
+ ND_PRINT((ndo, "donotsend-data "));
break;
case LSM_SEND:
- (void)printf("send-data ");
+ ND_PRINT((ndo, "send-data "));
break;
default:
- (void)printf("reserved-fcmod? %x", lsflags);
+ ND_PRINT((ndo, "reserved-fcmod? %x", lsflags));
break;
}
break;
case LSI_INTR:
- (void)printf("intr req count %d ", fcval);
+ ND_PRINT((ndo, "intr req count %d ", fcval));
break;
default:
- (void)printf("reserved-fcval-int? %x", lsflags);
+ ND_PRINT((ndo, "reserved-fcval-int? %x", lsflags));
break;
}
}
break;
default:
- (void)printf("reserved-subtype? %x %d > %d", flags, src, dst);
+ ND_PRINT((ndo, "reserved-subtype? %x %d > %d", flags, src, dst));
break;
}
break;
case MFT_ACK:
switch (flags & NSP_SUBMASK) {
case MFS_DACK:
- (void)printf("data-ack %d>%d ", src, dst);
+ ND_PRINT((ndo, "data-ack %d>%d ", src, dst));
{
struct ackmsg *amp = (struct ackmsg *)nspp;
int ack;
if (nsplen < sizeof(struct ackmsg))
goto trunc;
- TCHECK(*amp);
+ ND_TCHECK(*amp);
ack = EXTRACT_LE_16BITS(amp->ak_acknum[0]);
if (ack & SGQ_ACK) { /* acknum field */
if ((ack & SGQ_NAK) == SGQ_NAK)
- (void)printf("nak %d ", ack & SGQ_MASK);
+ ND_PRINT((ndo, "nak %d ", ack & SGQ_MASK));
else
- (void)printf("ack %d ", ack & SGQ_MASK);
+ ND_PRINT((ndo, "ack %d ", ack & SGQ_MASK));
ack = EXTRACT_LE_16BITS(amp->ak_acknum[1]);
if (ack & SGQ_OACK) { /* ackoth field */
if ((ack & SGQ_ONAK) == SGQ_ONAK)
- (void)printf("onak %d ", ack & SGQ_MASK);
+ ND_PRINT((ndo, "onak %d ", ack & SGQ_MASK));
else
- (void)printf("oack %d ", ack & SGQ_MASK);
+ ND_PRINT((ndo, "oack %d ", ack & SGQ_MASK));
}
}
}
break;
case MFS_IACK:
- (void)printf("ils-ack %d>%d ", src, dst);
+ ND_PRINT((ndo, "ils-ack %d>%d ", src, dst));
{
struct ackmsg *amp = (struct ackmsg *)nspp;
int ack;
if (nsplen < sizeof(struct ackmsg))
goto trunc;
- TCHECK(*amp);
+ ND_TCHECK(*amp);
ack = EXTRACT_LE_16BITS(amp->ak_acknum[0]);
if (ack & SGQ_ACK) { /* acknum field */
if ((ack & SGQ_NAK) == SGQ_NAK)
- (void)printf("nak %d ", ack & SGQ_MASK);
+ ND_PRINT((ndo, "nak %d ", ack & SGQ_MASK));
else
- (void)printf("ack %d ", ack & SGQ_MASK);
- TCHECK(amp->ak_acknum[1]);
+ ND_PRINT((ndo, "ack %d ", ack & SGQ_MASK));
+ ND_TCHECK(amp->ak_acknum[1]);
ack = EXTRACT_LE_16BITS(amp->ak_acknum[1]);
if (ack & SGQ_OACK) { /* ackdat field */
if ((ack & SGQ_ONAK) == SGQ_ONAK)
- (void)printf("nakdat %d ", ack & SGQ_MASK);
+ ND_PRINT((ndo, "nakdat %d ", ack & SGQ_MASK));
else
- (void)printf("ackdat %d ", ack & SGQ_MASK);
+ ND_PRINT((ndo, "ackdat %d ", ack & SGQ_MASK));
}
}
}
break;
case MFS_CACK:
- (void)printf("conn-ack %d", dst);
+ ND_PRINT((ndo, "conn-ack %d", dst));
break;
default:
- (void)printf("reserved-acktype? %x %d > %d", flags, src, dst);
+ ND_PRINT((ndo, "reserved-acktype? %x %d > %d", flags, src, dst));
break;
}
break;
@@ -650,10 +1093,10 @@ print_nsp(const u_char *nspp, u_int nsplen)
case MFS_CI:
case MFS_RCI:
if ((flags & NSP_SUBMASK) == MFS_CI)
- (void)printf("conn-initiate ");
+ ND_PRINT((ndo, "conn-initiate "));
else
- (void)printf("retrans-conn-initiate ");
- (void)printf("%d>%d ", src, dst);
+ ND_PRINT((ndo, "retrans-conn-initiate "));
+ ND_PRINT((ndo, "%d>%d ", src, dst));
{
struct cimsg *cimp = (struct cimsg *)nspp;
int services, info, segsize;
@@ -663,7 +1106,7 @@ print_nsp(const u_char *nspp, u_int nsplen)
if (nsplen < sizeof(struct cimsg))
goto trunc;
- TCHECK(*cimp);
+ ND_TCHECK(*cimp);
services = EXTRACT_LE_8BITS(cimp->ci_services);
info = EXTRACT_LE_8BITS(cimp->ci_info);
segsize = EXTRACT_LE_16BITS(cimp->ci_segsize);
@@ -672,41 +1115,41 @@ print_nsp(const u_char *nspp, u_int nsplen)
case COS_NONE:
break;
case COS_SEGMENT:
- (void)printf("seg ");
+ ND_PRINT((ndo, "seg "));
break;
case COS_MESSAGE:
- (void)printf("msg ");
+ ND_PRINT((ndo, "msg "));
break;
case COS_CRYPTSER:
- (void)printf("crypt ");
+ ND_PRINT((ndo, "crypt "));
break;
}
switch (info & COI_MASK) {
case COI_32:
- (void)printf("ver 3.2 ");
+ ND_PRINT((ndo, "ver 3.2 "));
break;
case COI_31:
- (void)printf("ver 3.1 ");
+ ND_PRINT((ndo, "ver 3.1 "));
break;
case COI_40:
- (void)printf("ver 4.0 ");
+ ND_PRINT((ndo, "ver 4.0 "));
break;
case COI_41:
- (void)printf("ver 4.1 ");
+ ND_PRINT((ndo, "ver 4.1 "));
break;
}
- (void)printf("segsize %d ", segsize);
+ ND_PRINT((ndo, "segsize %d ", segsize));
#ifdef PRINT_NSPDATA
if (nsplen > sizeof(struct cimsg)) {
dp = &(nspp[sizeof(struct cimsg)]);
- TCHECK2(*dp, nsplen - sizeof(struct cimsg));
- pdata(dp, nsplen - sizeof(struct cimsg));
+ ND_TCHECK2(*dp, nsplen - sizeof(struct cimsg));
+ pdata(ndo, dp, nsplen - sizeof(struct cimsg));
}
#endif
}
break;
case MFS_CC:
- (void)printf("conn-confirm %d>%d ", src, dst);
+ ND_PRINT((ndo, "conn-confirm %d>%d ", src, dst));
{
struct ccmsg *ccmp = (struct ccmsg *)nspp;
int services, info;
@@ -717,7 +1160,7 @@ print_nsp(const u_char *nspp, u_int nsplen)
if (nsplen < sizeof(struct ccmsg))
goto trunc;
- TCHECK(*ccmp);
+ ND_TCHECK(*ccmp);
services = EXTRACT_LE_8BITS(ccmp->cc_services);
info = EXTRACT_LE_8BITS(ccmp->cc_info);
segsize = EXTRACT_LE_16BITS(ccmp->cc_segsize);
@@ -727,44 +1170,44 @@ print_nsp(const u_char *nspp, u_int nsplen)
case COS_NONE:
break;
case COS_SEGMENT:
- (void)printf("seg ");
+ ND_PRINT((ndo, "seg "));
break;
case COS_MESSAGE:
- (void)printf("msg ");
+ ND_PRINT((ndo, "msg "));
break;
case COS_CRYPTSER:
- (void)printf("crypt ");
+ ND_PRINT((ndo, "crypt "));
break;
}
switch (info & COI_MASK) {
case COI_32:
- (void)printf("ver 3.2 ");
+ ND_PRINT((ndo, "ver 3.2 "));
break;
case COI_31:
- (void)printf("ver 3.1 ");
+ ND_PRINT((ndo, "ver 3.1 "));
break;
case COI_40:
- (void)printf("ver 4.0 ");
+ ND_PRINT((ndo, "ver 4.0 "));
break;
case COI_41:
- (void)printf("ver 4.1 ");
+ ND_PRINT((ndo, "ver 4.1 "));
break;
}
- (void)printf("segsize %d ", segsize);
+ ND_PRINT((ndo, "segsize %d ", segsize));
if (optlen) {
- (void)printf("optlen %d ", optlen);
+ ND_PRINT((ndo, "optlen %d ", optlen));
#ifdef PRINT_NSPDATA
if (optlen > nsplen - sizeof(struct ccmsg))
goto trunc;
dp = &(nspp[sizeof(struct ccmsg)]);
- TCHECK2(*dp, optlen);
- pdata(dp, optlen);
+ ND_TCHECK2(*dp, optlen);
+ pdata(ndo, dp, optlen);
#endif
}
}
break;
case MFS_DI:
- (void)printf("disconn-initiate %d>%d ", src, dst);
+ ND_PRINT((ndo, "disconn-initiate %d>%d ", src, dst));
{
struct dimsg *dimp = (struct dimsg *)nspp;
int reason;
@@ -775,42 +1218,42 @@ print_nsp(const u_char *nspp, u_int nsplen)
if (nsplen < sizeof(struct dimsg))
goto trunc;
- TCHECK(*dimp);
+ ND_TCHECK(*dimp);
reason = EXTRACT_LE_16BITS(dimp->di_reason);
optlen = EXTRACT_LE_8BITS(dimp->di_optlen);
- print_reason(reason);
+ print_reason(ndo, reason);
if (optlen) {
- (void)printf("optlen %d ", optlen);
+ ND_PRINT((ndo, "optlen %d ", optlen));
#ifdef PRINT_NSPDATA
if (optlen > nsplen - sizeof(struct dimsg))
goto trunc;
dp = &(nspp[sizeof(struct dimsg)]);
- TCHECK2(*dp, optlen);
- pdata(dp, optlen);
+ ND_TCHECK2(*dp, optlen);
+ pdata(ndo, dp, optlen);
#endif
}
}
break;
case MFS_DC:
- (void)printf("disconn-confirm %d>%d ", src, dst);
+ ND_PRINT((ndo, "disconn-confirm %d>%d ", src, dst));
{
struct dcmsg *dcmp = (struct dcmsg *)nspp;
int reason;
- TCHECK(*dcmp);
+ ND_TCHECK(*dcmp);
reason = EXTRACT_LE_16BITS(dcmp->dc_reason);
- print_reason(reason);
+ print_reason(ndo, reason);
}
break;
default:
- (void)printf("reserved-ctltype? %x %d > %d", flags, src, dst);
+ ND_PRINT((ndo, "reserved-ctltype? %x %d > %d", flags, src, dst));
break;
}
break;
default:
- (void)printf("reserved-type? %x %d > %d", flags, src, dst);
+ ND_PRINT((ndo, "reserved-type? %x %d > %d", flags, src, dst));
break;
}
return (1);
@@ -819,7 +1262,7 @@ trunc:
return (0);
}
-static struct tok reason2str[] = {
+static const struct tok reason2str[] = {
{ UC_OBJREJECT, "object rejected connect" },
{ UC_RESOURCES, "insufficient resources" },
{ UC_NOSUCHNODE, "unrecognized node name" },
@@ -846,9 +1289,10 @@ static struct tok reason2str[] = {
};
static void
-print_reason(register int reason)
+print_reason(netdissect_options *ndo,
+ register int reason)
{
- printf("%s ", tok2str(reason2str, "reason-%d", reason));
+ ND_PRINT((ndo, "%s ", tok2str(reason2str, "reason-%d", reason)));
}
const char *
@@ -882,14 +1326,15 @@ dnname_string(u_short dnaddr)
#ifdef PRINT_NSPDATA
static void
-pdata(u_char *dp, u_int maxlen)
+pdata(netdissect_options *ndo,
+ u_char *dp, u_int maxlen)
{
char c;
u_int x = maxlen;
while (x-- > 0) {
c = *dp++;
- safeputchar(c);
+ safeputchar(ndo, c);
}
}
#endif
diff --git a/contrib/tcpdump/print-dhcp6.c b/contrib/tcpdump/print-dhcp6.c
index 37c69dacfe6e..53b96ef954c9 100644
--- a/contrib/tcpdump/print-dhcp6.c
+++ b/contrib/tcpdump/print-dhcp6.c
@@ -28,7 +28,7 @@
*/
/*
* RFC3315: DHCPv6
- * supported DHCPv6 options:
+ * supported DHCPv6 options:
* RFC3319: Session Initiation Protocol (SIP) Servers options,
* RFC3633: IPv6 Prefix options,
* RFC3646: DNS Configuration options,
@@ -36,14 +36,11 @@
* RFC4075: Simple Network Time Protocol (SNTP) Configuration option,
* RFC4242: Information Refresh Time option,
* RFC4280: Broadcast and Multicast Control Servers options,
+ * RFC5908: Network Time Protocol (NTP) Server Option for DHCPv6
* RFC6334: Dual-Stack Lite option,
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-dhcp6.c,v 1.37 2008-02-06 10:26:09 guy Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -58,7 +55,7 @@ static const char rcsid[] _U_ =
#include "extract.h"
/* lease duration */
-#define DHCP6_DURATITION_INFINITE 0xffffffff
+#define DHCP6_DURATION_INFINITE 0xffffffff
/* Error Values */
#define DH6ERR_FAILURE 16
@@ -84,11 +81,30 @@ static const char rcsid[] _U_ =
#define DH6_LEASEQUERY 14
#define DH6_LQ_REPLY 15
+static const struct tok dh6_msgtype_str[] = {
+ { DH6_SOLICIT, "solicit" },
+ { DH6_ADVERTISE, "advertise" },
+ { DH6_REQUEST, "request" },
+ { DH6_CONFIRM, "confirm" },
+ { DH6_RENEW, "renew" },
+ { DH6_REBIND, "rebind" },
+ { DH6_REPLY, "reply" },
+ { DH6_RELEASE, "release" },
+ { DH6_DECLINE, "decline" },
+ { DH6_RECONFIGURE, "reconfigure" },
+ { DH6_INFORM_REQ, "inf-req" },
+ { DH6_RELAY_FORW, "relay-fwd" },
+ { DH6_RELAY_REPLY, "relay-reply" },
+ { DH6_LEASEQUERY, "leasequery" },
+ { DH6_LQ_REPLY, "leasequery-reply" },
+ { 0, NULL }
+};
+
/* DHCP6 base packet format */
struct dhcp6 {
union {
- u_int8_t m;
- u_int32_t x;
+ uint8_t m;
+ uint32_t x;
} dh6_msgtypexid;
/* options follow */
};
@@ -98,10 +114,10 @@ struct dhcp6 {
/* DHCPv6 relay messages */
struct dhcp6_relay {
- u_int8_t dh6relay_msgtype;
- u_int8_t dh6relay_hcnt;
- u_int8_t dh6relay_linkaddr[16]; /* XXX: badly aligned */
- u_int8_t dh6relay_peeraddr[16];
+ uint8_t dh6relay_msgtype;
+ uint8_t dh6relay_hcnt;
+ uint8_t dh6relay_linkaddr[16]; /* XXX: badly aligned */
+ uint8_t dh6relay_peeraddr[16];
/* options follow */
};
@@ -146,15 +162,15 @@ struct dhcp6_relay {
#define DH6OPT_RECONF_ACCEPT 20
#define DH6OPT_SIP_SERVER_D 21
#define DH6OPT_SIP_SERVER_A 22
-#define DH6OPT_DNS 23
-#define DH6OPT_DNSNAME 24
+#define DH6OPT_DNS_SERVERS 23
+#define DH6OPT_DOMAIN_LIST 24
#define DH6OPT_IA_PD 25
#define DH6OPT_IA_PD_PREFIX 26
#define DH6OPT_NIS_SERVERS 27
#define DH6OPT_NISP_SERVERS 28
#define DH6OPT_NIS_NAME 29
#define DH6OPT_NISP_NAME 30
-#define DH6OPT_NTP_SERVERS 31
+#define DH6OPT_SNTP_SERVERS 31
#define DH6OPT_LIFETIME 32
#define DH6OPT_BCMCS_SERVER_D 33
#define DH6OPT_BCMCS_SERVER_A 34
@@ -171,170 +187,106 @@ struct dhcp6_relay {
#define DH6OPT_CLT_TIME 46
#define DH6OPT_LQ_RELAY_DATA 47
#define DH6OPT_LQ_CLIENT_LINK 48
+#define DH6OPT_NTP_SERVER 56
+# define DH6OPT_NTP_SUBOPTION_SRV_ADDR 1
+# define DH6OPT_NTP_SUBOPTION_MC_ADDR 2
+# define DH6OPT_NTP_SUBOPTION_SRV_FQDN 3
#define DH6OPT_AFTR_NAME 64
+static const struct tok dh6opt_str[] = {
+ { DH6OPT_CLIENTID, "client-ID" },
+ { DH6OPT_SERVERID, "server-ID" },
+ { DH6OPT_IA_NA, "IA_NA" },
+ { DH6OPT_IA_TA, "IA_TA" },
+ { DH6OPT_IA_ADDR, "IA_ADDR" },
+ { DH6OPT_ORO, "option-request" },
+ { DH6OPT_PREFERENCE, "preference" },
+ { DH6OPT_ELAPSED_TIME, "elapsed-time" },
+ { DH6OPT_RELAY_MSG, "relay-message" },
+ { DH6OPT_AUTH, "authentication" },
+ { DH6OPT_UNICAST, "server-unicast" },
+ { DH6OPT_STATUS_CODE, "status-code" },
+ { DH6OPT_RAPID_COMMIT, "rapid-commit" },
+ { DH6OPT_USER_CLASS, "user-class" },
+ { DH6OPT_VENDOR_CLASS, "vendor-class" },
+ { DH6OPT_VENDOR_OPTS, "vendor-specific-info" },
+ { DH6OPT_INTERFACE_ID, "interface-ID" },
+ { DH6OPT_RECONF_MSG, "reconfigure-message" },
+ { DH6OPT_RECONF_ACCEPT, "reconfigure-accept" },
+ { DH6OPT_SIP_SERVER_D, "SIP-servers-domain" },
+ { DH6OPT_SIP_SERVER_A, "SIP-servers-address" },
+ { DH6OPT_DNS_SERVERS, "DNS-server" },
+ { DH6OPT_DOMAIN_LIST, "DNS-search-list" },
+ { DH6OPT_IA_PD, "IA_PD" },
+ { DH6OPT_IA_PD_PREFIX, "IA_PD-prefix" },
+ { DH6OPT_SNTP_SERVERS, "SNTP-servers" },
+ { DH6OPT_LIFETIME, "lifetime" },
+ { DH6OPT_NIS_SERVERS, "NIS-server" },
+ { DH6OPT_NISP_SERVERS, "NIS+-server" },
+ { DH6OPT_NIS_NAME, "NIS-domain-name" },
+ { DH6OPT_NISP_NAME, "NIS+-domain-name" },
+ { DH6OPT_BCMCS_SERVER_D, "BCMCS-domain-name" },
+ { DH6OPT_BCMCS_SERVER_A, "BCMCS-server" },
+ { DH6OPT_GEOCONF_CIVIC, "Geoconf-Civic" },
+ { DH6OPT_REMOTE_ID, "Remote-ID" },
+ { DH6OPT_SUBSCRIBER_ID, "Subscriber-ID" },
+ { DH6OPT_CLIENT_FQDN, "Client-FQDN" },
+ { DH6OPT_PANA_AGENT, "PANA-agent" },
+ { DH6OPT_NEW_POSIX_TIMEZONE, "POSIX-timezone" },
+ { DH6OPT_NEW_TZDB_TIMEZONE, "POSIX-tz-database" },
+ { DH6OPT_ERO, "Echo-request-option" },
+ { DH6OPT_LQ_QUERY, "Lease-query" },
+ { DH6OPT_CLIENT_DATA, "LQ-client-data" },
+ { DH6OPT_CLT_TIME, "Clt-time" },
+ { DH6OPT_LQ_RELAY_DATA, "LQ-relay-data" },
+ { DH6OPT_LQ_CLIENT_LINK, "LQ-client-link" },
+ { DH6OPT_NTP_SERVER, "NTP-server" },
+ { DH6OPT_AFTR_NAME, "AFTR-Name" },
+ { 0, NULL }
+};
+
+static const struct tok dh6opt_stcode_str[] = {
+ { DH6OPT_STCODE_SUCCESS, "success" },
+ { DH6OPT_STCODE_UNSPECFAIL, "unspec failure" },
+ { DH6OPT_STCODE_NOADDRAVAIL, "no addresses" },
+ { DH6OPT_STCODE_NOBINDING, "no binding" },
+ { DH6OPT_STCODE_NOTONLINK, "not on-link" },
+ { DH6OPT_STCODE_USEMULTICAST, "use multicast" },
+ { DH6OPT_STCODE_NOPREFIXAVAIL, "no prefixes" },
+ { DH6OPT_STCODE_UNKNOWNQUERYTYPE, "unknown query type" },
+ { DH6OPT_STCODE_MALFORMEDQUERY, "malformed query" },
+ { DH6OPT_STCODE_NOTCONFIGURED, "not configured" },
+ { DH6OPT_STCODE_NOTALLOWED, "not allowed" },
+ { 0, NULL }
+};
+
struct dhcp6opt {
- u_int16_t dh6opt_type;
- u_int16_t dh6opt_len;
+ uint16_t dh6opt_type;
+ uint16_t dh6opt_len;
/* type-dependent data follows */
};
static const char *
-dhcp6opt_name(int type)
+dhcp6stcode(const uint16_t code)
{
- static char genstr[sizeof("opt_65535") + 1]; /* XXX thread unsafe */
-
- if (type > 65535)
- return "INVALID-option";
-
- switch(type) {
- case DH6OPT_CLIENTID:
- return "client-ID";
- case DH6OPT_SERVERID:
- return "server-ID";
- case DH6OPT_IA_NA:
- return "IA_NA";
- case DH6OPT_IA_TA:
- return "IA_TA";
- case DH6OPT_IA_ADDR:
- return "IA_ADDR";
- case DH6OPT_ORO:
- return "option-request";
- case DH6OPT_PREFERENCE:
- return "preference";
- case DH6OPT_ELAPSED_TIME:
- return "elapsed-time";
- case DH6OPT_RELAY_MSG:
- return "relay-message";
- case DH6OPT_AUTH:
- return "authentication";
- case DH6OPT_UNICAST:
- return "server-unicast";
- case DH6OPT_STATUS_CODE:
- return "status-code";
- case DH6OPT_RAPID_COMMIT:
- return "rapid-commit";
- case DH6OPT_USER_CLASS:
- return "user-class";
- case DH6OPT_VENDOR_CLASS:
- return "vendor-class";
- case DH6OPT_VENDOR_OPTS:
- return "vendor-specific-info";
- case DH6OPT_INTERFACE_ID:
- return "interface-ID";
- case DH6OPT_RECONF_MSG:
- return "reconfigure-message";
- case DH6OPT_RECONF_ACCEPT:
- return "reconfigure-accept";
- case DH6OPT_SIP_SERVER_D:
- return "SIP-servers-domain";
- case DH6OPT_SIP_SERVER_A:
- return "SIP-servers-address";
- case DH6OPT_DNS:
- return "DNS-server";
- case DH6OPT_DNSNAME:
- return "DNS-search-list";
- case DH6OPT_IA_PD:
- return "IA_PD";
- case DH6OPT_IA_PD_PREFIX:
- return "IA_PD-prefix";
- case DH6OPT_NTP_SERVERS:
- return "NTP-server";
- case DH6OPT_LIFETIME:
- return "lifetime";
- case DH6OPT_NIS_SERVERS:
- return "NIS-server";
- case DH6OPT_NISP_SERVERS:
- return "NIS+-server";
- case DH6OPT_NIS_NAME:
- return "NIS-domain-name";
- case DH6OPT_NISP_NAME:
- return "NIS+-domain-name";
- case DH6OPT_BCMCS_SERVER_D:
- return "BCMCS-domain-name";
- case DH6OPT_BCMCS_SERVER_A:
- return "BCMCS-server";
- case DH6OPT_GEOCONF_CIVIC:
- return "Geoconf-Civic";
- case DH6OPT_REMOTE_ID:
- return "Remote-ID";
- case DH6OPT_SUBSCRIBER_ID:
- return "Subscriber-ID";
- case DH6OPT_CLIENT_FQDN:
- return "Client-FQDN";
- case DH6OPT_PANA_AGENT:
- return "PANA-agent";
- case DH6OPT_NEW_POSIX_TIMEZONE:
- return "POSIX-timezone";
- case DH6OPT_NEW_TZDB_TIMEZONE:
- return "POSIX-tz-database";
- case DH6OPT_ERO:
- return "Echo-request-option";
- case DH6OPT_LQ_QUERY:
- return "Lease-query";
- case DH6OPT_CLIENT_DATA:
- return "LQ-client-data";
- case DH6OPT_CLT_TIME:
- return "Clt-time";
- case DH6OPT_LQ_RELAY_DATA:
- return "LQ-relay-data";
- case DH6OPT_LQ_CLIENT_LINK:
- return "LQ-client-link";
- case DH6OPT_AFTR_NAME:
- return "AFTR-Name";
- default:
- snprintf(genstr, sizeof(genstr), "opt_%d", type);
- return(genstr);
- }
-}
-
-static const char *
-dhcp6stcode(int code)
-{
- static char genstr[sizeof("code255") + 1]; /* XXX thread unsafe */
-
- if (code > 255)
- return "INVALID code";
-
- switch(code) {
- case DH6OPT_STCODE_SUCCESS:
- return "success";
- case DH6OPT_STCODE_UNSPECFAIL:
- return "unspec failure";
- case DH6OPT_STCODE_NOADDRAVAIL:
- return "no addresses";
- case DH6OPT_STCODE_NOBINDING:
- return "no binding";
- case DH6OPT_STCODE_NOTONLINK:
- return "not on-link";
- case DH6OPT_STCODE_USEMULTICAST:
- return "use multicast";
- case DH6OPT_STCODE_NOPREFIXAVAIL:
- return "no prefixes";
- case DH6OPT_STCODE_UNKNOWNQUERYTYPE:
- return "unknown query type";
- case DH6OPT_STCODE_MALFORMEDQUERY:
- return "malformed query";
- case DH6OPT_STCODE_NOTCONFIGURED:
- return "not configured";
- case DH6OPT_STCODE_NOTALLOWED:
- return "not allowed";
- default:
- snprintf(genstr, sizeof(genstr), "code%d", code);
- return(genstr);
- }
+ return code > 255 ? "INVALID code" : tok2str(dh6opt_stcode_str, "code%u", code);
}
static void
-dhcp6opt_print(const u_char *cp, const u_char *ep)
+dhcp6opt_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep)
{
- struct dhcp6opt *dh6o;
- u_char *tp;
+ const struct dhcp6opt *dh6o;
+ const u_char *tp;
size_t i;
- u_int16_t opttype;
+ uint16_t opttype;
size_t optlen;
- u_int8_t auth_proto;
+ uint8_t auth_proto;
u_int authinfolen, authrealmlen;
+ int remain_len; /* Length of remaining options */
+ int label_len; /* Label length */
+ uint16_t subopt_code;
+ uint16_t subopt_len;
if (cp == ep)
return;
@@ -342,159 +294,159 @@ dhcp6opt_print(const u_char *cp, const u_char *ep)
if (ep < cp + sizeof(*dh6o))
goto trunc;
dh6o = (struct dhcp6opt *)cp;
- TCHECK(*dh6o);
+ ND_TCHECK(*dh6o);
optlen = EXTRACT_16BITS(&dh6o->dh6opt_len);
if (ep < cp + sizeof(*dh6o) + optlen)
goto trunc;
opttype = EXTRACT_16BITS(&dh6o->dh6opt_type);
- printf(" (%s", dhcp6opt_name(opttype));
+ ND_PRINT((ndo, " (%s", tok2str(dh6opt_str, "opt_%u", opttype)));
switch (opttype) {
case DH6OPT_CLIENTID:
case DH6OPT_SERVERID:
if (optlen < 2) {
/*(*/
- printf(" ?)");
+ ND_PRINT((ndo, " ?)"));
break;
}
tp = (u_char *)(dh6o + 1);
switch (EXTRACT_16BITS(tp)) {
case 1:
if (optlen >= 2 + 6) {
- printf(" hwaddr/time type %u time %u ",
+ ND_PRINT((ndo, " hwaddr/time type %u time %u ",
EXTRACT_16BITS(&tp[2]),
- EXTRACT_32BITS(&tp[4]));
+ EXTRACT_32BITS(&tp[4])));
for (i = 8; i < optlen; i++)
- printf("%02x", tp[i]);
+ ND_PRINT((ndo, "%02x", tp[i]));
/*(*/
- printf(")");
+ ND_PRINT((ndo, ")"));
} else {
/*(*/
- printf(" ?)");
+ ND_PRINT((ndo, " ?)"));
}
break;
case 2:
if (optlen >= 2 + 8) {
- printf(" vid ");
+ ND_PRINT((ndo, " vid "));
for (i = 2; i < 2 + 8; i++)
- printf("%02x", tp[i]);
+ ND_PRINT((ndo, "%02x", tp[i]));
/*(*/
- printf(")");
+ ND_PRINT((ndo, ")"));
} else {
/*(*/
- printf(" ?)");
+ ND_PRINT((ndo, " ?)"));
}
break;
case 3:
if (optlen >= 2 + 2) {
- printf(" hwaddr type %u ",
- EXTRACT_16BITS(&tp[2]));
+ ND_PRINT((ndo, " hwaddr type %u ",
+ EXTRACT_16BITS(&tp[2])));
for (i = 4; i < optlen; i++)
- printf("%02x", tp[i]);
+ ND_PRINT((ndo, "%02x", tp[i]));
/*(*/
- printf(")");
+ ND_PRINT((ndo, ")"));
} else {
/*(*/
- printf(" ?)");
+ ND_PRINT((ndo, " ?)"));
}
break;
default:
- printf(" type %d)", EXTRACT_16BITS(tp));
+ ND_PRINT((ndo, " type %d)", EXTRACT_16BITS(tp)));
break;
}
break;
case DH6OPT_IA_ADDR:
if (optlen < 24) {
/*(*/
- printf(" ?)");
+ ND_PRINT((ndo, " ?)"));
break;
}
tp = (u_char *)(dh6o + 1);
- printf(" %s", ip6addr_string(&tp[0]));
- printf(" pltime:%u vltime:%u",
+ ND_PRINT((ndo, " %s", ip6addr_string(ndo, &tp[0])));
+ ND_PRINT((ndo, " pltime:%u vltime:%u",
EXTRACT_32BITS(&tp[16]),
- EXTRACT_32BITS(&tp[20]));
+ EXTRACT_32BITS(&tp[20])));
if (optlen > 24) {
/* there are sub-options */
- dhcp6opt_print(tp + 24, tp + optlen);
+ dhcp6opt_print(ndo, tp + 24, tp + optlen);
}
- printf(")");
+ ND_PRINT((ndo, ")"));
break;
case DH6OPT_ORO:
case DH6OPT_ERO:
if (optlen % 2) {
- printf(" ?)");
+ ND_PRINT((ndo, " ?)"));
break;
}
tp = (u_char *)(dh6o + 1);
for (i = 0; i < optlen; i += 2) {
- printf(" %s",
- dhcp6opt_name(EXTRACT_16BITS(&tp[i])));
+ ND_PRINT((ndo, " %s",
+ tok2str(dh6opt_str, "opt_%u", EXTRACT_16BITS(&tp[i]))));
}
- printf(")");
+ ND_PRINT((ndo, ")"));
break;
case DH6OPT_PREFERENCE:
if (optlen != 1) {
- printf(" ?)");
+ ND_PRINT((ndo, " ?)"));
break;
}
tp = (u_char *)(dh6o + 1);
- printf(" %d)", *tp);
+ ND_PRINT((ndo, " %d)", *tp));
break;
case DH6OPT_ELAPSED_TIME:
if (optlen != 2) {
- printf(" ?)");
+ ND_PRINT((ndo, " ?)"));
break;
}
tp = (u_char *)(dh6o + 1);
- printf(" %d)", EXTRACT_16BITS(tp));
+ ND_PRINT((ndo, " %d)", EXTRACT_16BITS(tp)));
break;
case DH6OPT_RELAY_MSG:
- printf(" (");
+ ND_PRINT((ndo, " ("));
tp = (u_char *)(dh6o + 1);
- dhcp6_print(tp, optlen);
- printf(")");
+ dhcp6_print(ndo, tp, optlen);
+ ND_PRINT((ndo, ")"));
break;
case DH6OPT_AUTH:
if (optlen < 11) {
- printf(" ?)");
+ ND_PRINT((ndo, " ?)"));
break;
}
tp = (u_char *)(dh6o + 1);
auth_proto = *tp;
switch (auth_proto) {
case DH6OPT_AUTHPROTO_DELAYED:
- printf(" proto: delayed");
+ ND_PRINT((ndo, " proto: delayed"));
break;
case DH6OPT_AUTHPROTO_RECONFIG:
- printf(" proto: reconfigure");
+ ND_PRINT((ndo, " proto: reconfigure"));
break;
default:
- printf(" proto: %d", auth_proto);
+ ND_PRINT((ndo, " proto: %d", auth_proto));
break;
}
tp++;
switch (*tp) {
case DH6OPT_AUTHALG_HMACMD5:
/* XXX: may depend on the protocol */
- printf(", alg: HMAC-MD5");
+ ND_PRINT((ndo, ", alg: HMAC-MD5"));
break;
default:
- printf(", alg: %d", *tp);
+ ND_PRINT((ndo, ", alg: %d", *tp));
break;
}
tp++;
switch (*tp) {
case DH6OPT_AUTHRDM_MONOCOUNTER:
- printf(", RDM: mono");
+ ND_PRINT((ndo, ", RDM: mono"));
break;
default:
- printf(", RDM: %d", *tp);
+ ND_PRINT((ndo, ", RDM: %d", *tp));
break;
}
tp++;
- printf(", RD:");
+ ND_PRINT((ndo, ", RD:"));
for (i = 0; i < 4; i++, tp += 2)
- printf(" %04x", EXTRACT_16BITS(tp));
+ ND_PRINT((ndo, " %04x", EXTRACT_16BITS(tp)));
/* protocol dependent part */
authinfolen = optlen - 11;
@@ -503,50 +455,50 @@ dhcp6opt_print(const u_char *cp, const u_char *ep)
if (authinfolen == 0)
break;
if (authinfolen < 20) {
- printf(" ??");
+ ND_PRINT((ndo, " ??"));
break;
}
authrealmlen = authinfolen - 20;
if (authrealmlen > 0) {
- printf(", realm: ");
+ ND_PRINT((ndo, ", realm: "));
}
for (i = 0; i < authrealmlen; i++, tp++)
- printf("%02x", *tp);
- printf(", key ID: %08x", EXTRACT_32BITS(tp));
+ ND_PRINT((ndo, "%02x", *tp));
+ ND_PRINT((ndo, ", key ID: %08x", EXTRACT_32BITS(tp)));
tp += 4;
- printf(", HMAC-MD5:");
+ ND_PRINT((ndo, ", HMAC-MD5:"));
for (i = 0; i < 4; i++, tp+= 4)
- printf(" %08x", EXTRACT_32BITS(tp));
+ ND_PRINT((ndo, " %08x", EXTRACT_32BITS(tp)));
break;
case DH6OPT_AUTHPROTO_RECONFIG:
if (authinfolen != 17) {
- printf(" ??");
+ ND_PRINT((ndo, " ??"));
break;
}
switch (*tp++) {
case DH6OPT_AUTHRECONFIG_KEY:
- printf(" reconfig-key");
+ ND_PRINT((ndo, " reconfig-key"));
break;
case DH6OPT_AUTHRECONFIG_HMACMD5:
- printf(" type: HMAC-MD5");
+ ND_PRINT((ndo, " type: HMAC-MD5"));
break;
default:
- printf(" type: ??");
+ ND_PRINT((ndo, " type: ??"));
break;
}
- printf(" value:");
+ ND_PRINT((ndo, " value:"));
for (i = 0; i < 4; i++, tp+= 4)
- printf(" %08x", EXTRACT_32BITS(tp));
+ ND_PRINT((ndo, " %08x", EXTRACT_32BITS(tp)));
break;
default:
- printf(" ??");
+ ND_PRINT((ndo, " ??"));
break;
}
- printf(")");
+ ND_PRINT((ndo, ")"));
break;
case DH6OPT_RAPID_COMMIT: /* nothing todo */
- printf(")");
+ ND_PRINT((ndo, ")"));
break;
case DH6OPT_INTERFACE_ID:
case DH6OPT_SUBSCRIBER_ID:
@@ -555,194 +507,239 @@ dhcp6opt_print(const u_char *cp, const u_char *ep)
* at most 10 characters.
*/
tp = (u_char *)(dh6o + 1);
- printf(" ");
+ ND_PRINT((ndo, " "));
for (i = 0; i < optlen && i < 10; i++)
- printf("%02x", tp[i]);
- printf("...)");
+ ND_PRINT((ndo, "%02x", tp[i]));
+ ND_PRINT((ndo, "...)"));
break;
case DH6OPT_RECONF_MSG:
tp = (u_char *)(dh6o + 1);
switch (*tp) {
case DH6_RENEW:
- printf(" for renew)");
+ ND_PRINT((ndo, " for renew)"));
break;
case DH6_INFORM_REQ:
- printf(" for inf-req)");
+ ND_PRINT((ndo, " for inf-req)"));
break;
default:
- printf(" for ?\?\?(%02x))", *tp);
+ ND_PRINT((ndo, " for ?\?\?(%02x))", *tp));
break;
}
break;
case DH6OPT_RECONF_ACCEPT: /* nothing todo */
- printf(")");
+ ND_PRINT((ndo, ")"));
break;
case DH6OPT_SIP_SERVER_A:
- case DH6OPT_DNS:
- case DH6OPT_NTP_SERVERS:
+ case DH6OPT_DNS_SERVERS:
+ case DH6OPT_SNTP_SERVERS:
case DH6OPT_NIS_SERVERS:
case DH6OPT_NISP_SERVERS:
case DH6OPT_BCMCS_SERVER_A:
case DH6OPT_PANA_AGENT:
case DH6OPT_LQ_CLIENT_LINK:
if (optlen % 16) {
- printf(" ?)");
+ ND_PRINT((ndo, " ?)"));
break;
}
tp = (u_char *)(dh6o + 1);
for (i = 0; i < optlen; i += 16)
- printf(" %s", ip6addr_string(&tp[i]));
- printf(")");
+ ND_PRINT((ndo, " %s", ip6addr_string(ndo, &tp[i])));
+ ND_PRINT((ndo, ")"));
+ break;
+ case DH6OPT_SIP_SERVER_D:
+ case DH6OPT_DOMAIN_LIST:
+ tp = (u_char *)(dh6o + 1);
+ while (tp < cp + sizeof(*dh6o) + optlen) {
+ ND_PRINT((ndo, " "));
+ if ((tp = ns_nprint(ndo, tp, cp + sizeof(*dh6o) + optlen)) == NULL)
+ goto trunc;
+ }
+ ND_PRINT((ndo, ")"));
break;
case DH6OPT_STATUS_CODE:
if (optlen < 2) {
- printf(" ?)");
+ ND_PRINT((ndo, " ?)"));
break;
}
tp = (u_char *)(dh6o + 1);
- printf(" %s)", dhcp6stcode(EXTRACT_16BITS(&tp[0])));
+ ND_PRINT((ndo, " %s)", dhcp6stcode(EXTRACT_16BITS(&tp[0]))));
break;
case DH6OPT_IA_NA:
case DH6OPT_IA_PD:
if (optlen < 12) {
- printf(" ?)");
+ ND_PRINT((ndo, " ?)"));
break;
}
tp = (u_char *)(dh6o + 1);
- printf(" IAID:%u T1:%u T2:%u",
+ ND_PRINT((ndo, " IAID:%u T1:%u T2:%u",
EXTRACT_32BITS(&tp[0]),
EXTRACT_32BITS(&tp[4]),
- EXTRACT_32BITS(&tp[8]));
+ EXTRACT_32BITS(&tp[8])));
if (optlen > 12) {
/* there are sub-options */
- dhcp6opt_print(tp + 12, tp + optlen);
+ dhcp6opt_print(ndo, tp + 12, tp + optlen);
}
- printf(")");
+ ND_PRINT((ndo, ")"));
break;
case DH6OPT_IA_TA:
if (optlen < 4) {
- printf(" ?)");
+ ND_PRINT((ndo, " ?)"));
break;
}
tp = (u_char *)(dh6o + 1);
- printf(" IAID:%u", EXTRACT_32BITS(tp));
+ ND_PRINT((ndo, " IAID:%u", EXTRACT_32BITS(tp)));
if (optlen > 4) {
/* there are sub-options */
- dhcp6opt_print(tp + 4, tp + optlen);
+ dhcp6opt_print(ndo, tp + 4, tp + optlen);
}
- printf(")");
+ ND_PRINT((ndo, ")"));
break;
case DH6OPT_IA_PD_PREFIX:
if (optlen < 25) {
- printf(" ?)");
+ ND_PRINT((ndo, " ?)"));
break;
}
tp = (u_char *)(dh6o + 1);
- printf(" %s/%d", ip6addr_string(&tp[9]), tp[8]);
- printf(" pltime:%u vltime:%u",
+ ND_PRINT((ndo, " %s/%d", ip6addr_string(ndo, &tp[9]), tp[8]));
+ ND_PRINT((ndo, " pltime:%u vltime:%u",
EXTRACT_32BITS(&tp[0]),
- EXTRACT_32BITS(&tp[4]));
+ EXTRACT_32BITS(&tp[4])));
if (optlen > 25) {
/* there are sub-options */
- dhcp6opt_print(tp + 25, tp + optlen);
+ dhcp6opt_print(ndo, tp + 25, tp + optlen);
}
- printf(")");
+ ND_PRINT((ndo, ")"));
break;
case DH6OPT_LIFETIME:
case DH6OPT_CLT_TIME:
if (optlen != 4) {
- printf(" ?)");
+ ND_PRINT((ndo, " ?)"));
break;
}
tp = (u_char *)(dh6o + 1);
- printf(" %d)", EXTRACT_32BITS(tp));
+ ND_PRINT((ndo, " %d)", EXTRACT_32BITS(tp)));
break;
case DH6OPT_REMOTE_ID:
if (optlen < 4) {
- printf(" ?)");
+ ND_PRINT((ndo, " ?)"));
break;
}
tp = (u_char *)(dh6o + 1);
- printf(" %d ", EXTRACT_32BITS(tp));
+ ND_PRINT((ndo, " %d ", EXTRACT_32BITS(tp)));
/*
* Print hex dump first 10 characters.
*/
for (i = 4; i < optlen && i < 14; i++)
- printf("%02x", tp[i]);
- printf("...)");
+ ND_PRINT((ndo, "%02x", tp[i]));
+ ND_PRINT((ndo, "...)"));
break;
case DH6OPT_LQ_QUERY:
if (optlen < 17) {
- printf(" ?)");
+ ND_PRINT((ndo, " ?)"));
break;
}
tp = (u_char *)(dh6o + 1);
switch (*tp) {
case 1:
- printf(" by-address");
+ ND_PRINT((ndo, " by-address"));
break;
case 2:
- printf(" by-clientID");
+ ND_PRINT((ndo, " by-clientID"));
break;
default:
- printf(" type_%d", (int)*tp);
+ ND_PRINT((ndo, " type_%d", (int)*tp));
break;
}
- printf(" %s", ip6addr_string(&tp[1]));
+ ND_PRINT((ndo, " %s", ip6addr_string(ndo, &tp[1])));
if (optlen > 17) {
/* there are query-options */
- dhcp6opt_print(tp + 17, tp + optlen);
+ dhcp6opt_print(ndo, tp + 17, tp + optlen);
}
- printf(")");
+ ND_PRINT((ndo, ")"));
break;
case DH6OPT_CLIENT_DATA:
tp = (u_char *)(dh6o + 1);
if (optlen > 0) {
/* there are encapsulated options */
- dhcp6opt_print(tp, tp + optlen);
+ dhcp6opt_print(ndo, tp, tp + optlen);
}
- printf(")");
+ ND_PRINT((ndo, ")"));
break;
case DH6OPT_LQ_RELAY_DATA:
if (optlen < 16) {
- printf(" ?)");
+ ND_PRINT((ndo, " ?)"));
break;
}
tp = (u_char *)(dh6o + 1);
- printf(" %s ", ip6addr_string(&tp[0]));
+ ND_PRINT((ndo, " %s ", ip6addr_string(ndo, &tp[0])));
/*
* Print hex dump first 10 characters.
*/
for (i = 16; i < optlen && i < 26; i++)
- printf("%02x", tp[i]);
- printf("...)");
+ ND_PRINT((ndo, "%02x", tp[i]));
+ ND_PRINT((ndo, "...)"));
+ break;
+ case DH6OPT_NTP_SERVER:
+ if (optlen < 4) {
+ ND_PRINT((ndo, " ?)"));
+ break;
+ }
+ tp = (u_char *)(dh6o + 1);
+ while (tp < cp + sizeof(*dh6o) + optlen - 4) {
+ subopt_code = EXTRACT_16BITS(tp);
+ tp += 2;
+ subopt_len = EXTRACT_16BITS(tp);
+ tp += 2;
+ if (tp + subopt_len > cp + sizeof(*dh6o) + optlen)
+ goto trunc;
+ ND_PRINT((ndo, " subopt:%d", subopt_code));
+ switch (subopt_code) {
+ case DH6OPT_NTP_SUBOPTION_SRV_ADDR:
+ case DH6OPT_NTP_SUBOPTION_MC_ADDR:
+ if (subopt_len != 16) {
+ ND_PRINT((ndo, " ?"));
+ break;
+ }
+ ND_PRINT((ndo, " %s", ip6addr_string(ndo, &tp[0])));
+ break;
+ case DH6OPT_NTP_SUBOPTION_SRV_FQDN:
+ ND_PRINT((ndo, " "));
+ if (ns_nprint(ndo, tp, tp + subopt_len) == NULL)
+ goto trunc;
+ break;
+ default:
+ ND_PRINT((ndo, " ?"));
+ break;
+ }
+ tp += subopt_len;
+ }
+ ND_PRINT((ndo, ")"));
break;
case DH6OPT_AFTR_NAME:
if (optlen < 3) {
- printf(" ?)");
+ ND_PRINT((ndo, " ?)"));
break;
}
tp = (u_char *)(dh6o + 1);
- int remain_len = optlen;
- printf(" ");
+ remain_len = optlen;
+ ND_PRINT((ndo, " "));
/* Encoding is described in section 3.1 of RFC 1035 */
- int label_len; /* Label length */
while (remain_len && *tp) {
label_len = *tp++;
if (label_len < remain_len - 1) {
- printf("%.*s", label_len, tp);
+ ND_PRINT((ndo, "%.*s", label_len, tp));
tp += label_len;
remain_len -= (label_len + 1);
- if(*tp) printf(".");
+ if(*tp) ND_PRINT((ndo, "."));
} else {
- printf(" ?");
+ ND_PRINT((ndo, " ?"));
break;
}
}
- printf(")");
+ ND_PRINT((ndo, ")"));
break;
default:
- printf(")");
+ ND_PRINT((ndo, ")"));
break;
}
@@ -751,14 +748,15 @@ dhcp6opt_print(const u_char *cp, const u_char *ep)
return;
trunc:
- printf("[|dhcp6ext]");
+ ND_PRINT((ndo, "[|dhcp6ext]"));
}
/*
* Print dhcp6 packets
*/
void
-dhcp6_print(const u_char *cp, u_int length)
+dhcp6_print(netdissect_options *ndo,
+ const u_char *cp, u_int length)
{
struct dhcp6 *dh6;
struct dhcp6_relay *dh6relay;
@@ -766,104 +764,47 @@ dhcp6_print(const u_char *cp, u_int length)
u_char *extp;
const char *name;
- printf("dhcp6");
+ ND_PRINT((ndo, "dhcp6"));
- ep = (u_char *)snapend;
+ ep = (u_char *)ndo->ndo_snapend;
if (cp + length < ep)
ep = cp + length;
dh6 = (struct dhcp6 *)cp;
dh6relay = (struct dhcp6_relay *)cp;
- TCHECK(dh6->dh6_xid);
- switch (dh6->dh6_msgtype) {
- case DH6_SOLICIT:
- name = "solicit";
- break;
- case DH6_ADVERTISE:
- name = "advertise";
- break;
- case DH6_REQUEST:
- name = "request";
- break;
- case DH6_CONFIRM:
- name = "confirm";
- break;
- case DH6_RENEW:
- name = "renew";
- break;
- case DH6_REBIND:
- name = "rebind";
- break;
- case DH6_REPLY:
- name = "reply";
- break;
- case DH6_RELEASE:
- name = "release";
- break;
- case DH6_DECLINE:
- name = "decline";
- break;
- case DH6_RECONFIGURE:
- name = "reconfigure";
- break;
- case DH6_INFORM_REQ:
- name= "inf-req";
- break;
- case DH6_RELAY_FORW:
- name= "relay-fwd";
- break;
- case DH6_RELAY_REPLY:
- name= "relay-reply";
- break;
- case DH6_LEASEQUERY:
- name= "leasequery";
- break;
- case DH6_LQ_REPLY:
- name= "leasequery-reply";
- break;
- default:
- name = NULL;
- break;
- }
+ ND_TCHECK(dh6->dh6_xid);
+ name = tok2str(dh6_msgtype_str, "msgtype-%u", dh6->dh6_msgtype);
- if (!vflag) {
- if (name)
- printf(" %s", name);
- else if (dh6->dh6_msgtype != DH6_RELAY_FORW &&
- dh6->dh6_msgtype != DH6_RELAY_REPLY) {
- printf(" msgtype-%u", dh6->dh6_msgtype);
- }
+ if (!ndo->ndo_vflag) {
+ ND_PRINT((ndo, " %s", name));
return;
}
/* XXX relay agent messages have to be handled differently */
- if (name)
- printf(" %s (", name); /*)*/
- else
- printf(" msgtype-%u (", dh6->dh6_msgtype); /*)*/
+ ND_PRINT((ndo, " %s (", name)); /*)*/
if (dh6->dh6_msgtype != DH6_RELAY_FORW &&
dh6->dh6_msgtype != DH6_RELAY_REPLY) {
- printf("xid=%x", EXTRACT_32BITS(&dh6->dh6_xid) & DH6_XIDMASK);
+ ND_PRINT((ndo, "xid=%x", EXTRACT_32BITS(&dh6->dh6_xid) & DH6_XIDMASK));
extp = (u_char *)(dh6 + 1);
- dhcp6opt_print(extp, ep);
+ dhcp6opt_print(ndo, extp, ep);
} else { /* relay messages */
struct in6_addr addr6;
- TCHECK(dh6relay->dh6relay_peeraddr);
+ ND_TCHECK(dh6relay->dh6relay_peeraddr);
memcpy(&addr6, dh6relay->dh6relay_linkaddr, sizeof (addr6));
- printf("linkaddr=%s", ip6addr_string(&addr6));
+ ND_PRINT((ndo, "linkaddr=%s", ip6addr_string(ndo, &addr6)));
memcpy(&addr6, dh6relay->dh6relay_peeraddr, sizeof (addr6));
- printf(" peeraddr=%s", ip6addr_string(&addr6));
+ ND_PRINT((ndo, " peeraddr=%s", ip6addr_string(ndo, &addr6)));
- dhcp6opt_print((u_char *)(dh6relay + 1), ep);
+ dhcp6opt_print(ndo, (u_char *)(dh6relay + 1), ep);
}
/*(*/
- printf(")");
+ ND_PRINT((ndo, ")"));
return;
trunc:
- printf("[|dhcp6]");
+ ND_PRINT((ndo, "[|dhcp6]"));
}
diff --git a/contrib/tcpdump/print-domain.c b/contrib/tcpdump/print-domain.c
index ba7ee24df9fd..4e2d378b81c4 100644
--- a/contrib/tcpdump/print-domain.c
+++ b/contrib/tcpdump/print-domain.c
@@ -21,11 +21,7 @@
* $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.98 2007-12-09 01:40:32 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -34,7 +30,6 @@ static const char rcsid[] _U_ =
#include "nameser.h"
-#include <stdio.h>
#include <string.h>
#include "interface.h"
@@ -43,7 +38,7 @@ static const char rcsid[] _U_ =
static const char *ns_ops[] = {
"", " inv_q", " stat", " op3", " notify", " update", " op6", " op7",
- " op8", " updataA", " updateD", " updateDA",
+ " op8", " updateA", " updateD", " updateDA",
" updateM", " updateMA", " zoneInit", " zoneRef",
};
@@ -56,11 +51,12 @@ static const char *ns_resp[] = {
/* skip over a domain name */
static const u_char *
-ns_nskip(register const u_char *cp)
+ns_nskip(netdissect_options *ndo,
+ register const u_char *cp)
{
register u_char i;
- if (!TTEST2(*cp, 1))
+ if (!ND_TTEST2(*cp, 1))
return (NULL);
i = *cp++;
while (i) {
@@ -71,7 +67,7 @@ ns_nskip(register const u_char *cp)
if ((i & ~INDIR_MASK) != EDNS0_ELT_BITLABEL)
return(NULL); /* unknown ELT */
- if (!TTEST2(*cp, 1))
+ if (!ND_TTEST2(*cp, 1))
return (NULL);
if ((bitlen = *cp++) == 0)
bitlen = 256;
@@ -79,7 +75,7 @@ ns_nskip(register const u_char *cp)
cp += bytelen;
} else
cp += i;
- if (!TTEST2(*cp, 1))
+ if (!ND_TTEST2(*cp, 1))
return (NULL);
i = *cp++;
}
@@ -88,13 +84,14 @@ ns_nskip(register const u_char *cp)
/* print a <domain-name> */
static const u_char *
-blabel_print(const u_char *cp)
+blabel_print(netdissect_options *ndo,
+ const u_char *cp)
{
int bitlen, slen, b;
const u_char *bitp, *lim;
char tc;
- if (!TTEST2(*cp, 1))
+ if (!ND_TTEST2(*cp, 1))
return(NULL);
if ((bitlen = *cp) == 0)
bitlen = 256;
@@ -102,42 +99,43 @@ blabel_print(const u_char *cp)
lim = cp + 1 + slen;
/* print the bit string as a hex string */
- printf("\\[x");
+ ND_PRINT((ndo, "\\[x"));
for (bitp = cp + 1, b = bitlen; bitp < lim && b > 7; b -= 8, bitp++) {
- TCHECK(*bitp);
- printf("%02x", *bitp);
+ ND_TCHECK(*bitp);
+ ND_PRINT((ndo, "%02x", *bitp));
}
if (b > 4) {
- TCHECK(*bitp);
+ ND_TCHECK(*bitp);
tc = *bitp++;
- printf("%02x", tc & (0xff << (8 - b)));
+ ND_PRINT((ndo, "%02x", tc & (0xff << (8 - b))));
} else if (b > 0) {
- TCHECK(*bitp);
+ ND_TCHECK(*bitp);
tc = *bitp++;
- printf("%1x", ((tc >> 4) & 0x0f) & (0x0f << (4 - b)));
+ ND_PRINT((ndo, "%1x", ((tc >> 4) & 0x0f) & (0x0f << (4 - b))));
}
- printf("/%d]", bitlen);
+ ND_PRINT((ndo, "/%d]", bitlen));
return lim;
trunc:
- printf(".../%d]", bitlen);
+ ND_PRINT((ndo, ".../%d]", bitlen));
return NULL;
}
static int
-labellen(const u_char *cp)
+labellen(netdissect_options *ndo,
+ const u_char *cp)
{
register u_int i;
- if (!TTEST2(*cp, 1))
+ if (!ND_TTEST2(*cp, 1))
return(-1);
i = *cp;
if ((i & INDIR_MASK) == EDNS0_MASK) {
int bitlen, elt;
if ((elt = (i & ~INDIR_MASK)) != EDNS0_ELT_BITLABEL) {
- printf("<ELT %d>", elt);
+ ND_PRINT((ndo, "<ELT %d>", elt));
return(-1);
}
- if (!TTEST2(*(cp + 1), 1))
+ if (!ND_TTEST2(*(cp + 1), 1))
return(-1);
if ((bitlen = *(cp + 1)) == 0)
bitlen = 256;
@@ -147,18 +145,19 @@ labellen(const u_char *cp)
}
const u_char *
-ns_nprint(register const u_char *cp, register const u_char *bp)
+ns_nprint(netdissect_options *ndo,
+ register const u_char *cp, register const u_char *bp)
{
register u_int i, l;
register const u_char *rp = NULL;
register int compress = 0;
int chars_processed;
int elt;
- int data_size = snapend - bp;
+ int data_size = ndo->ndo_snapend - bp;
- if ((l = labellen(cp)) == (u_int)-1)
+ if ((l = labellen(ndo, cp)) == (u_int)-1)
return(NULL);
- if (!TTEST2(*cp, 1))
+ if (!ND_TTEST2(*cp, 1))
return(NULL);
chars_processed = 1;
if (((i = *cp++) & INDIR_MASK) != INDIR_MASK) {
@@ -167,18 +166,18 @@ ns_nprint(register const u_char *cp, register const u_char *bp)
}
if (i != 0)
- while (i && cp < snapend) {
+ while (i && cp < ndo->ndo_snapend) {
if ((i & INDIR_MASK) == INDIR_MASK) {
if (!compress) {
rp = cp + 1;
compress = 1;
}
- if (!TTEST2(*cp, 1))
+ if (!ND_TTEST2(*cp, 1))
return(NULL);
cp = bp + (((i << 8) | *cp) & 0x3fff);
- if ((l = labellen(cp)) == (u_int)-1)
+ if ((l = labellen(ndo, cp)) == (u_int)-1)
return(NULL);
- if (!TTEST2(*cp, 1))
+ if (!ND_TTEST2(*cp, 1))
return(NULL);
i = *cp++;
chars_processed++;
@@ -190,7 +189,7 @@ ns_nprint(register const u_char *cp, register const u_char *bp)
* which means we're looping.
*/
if (chars_processed >= data_size) {
- printf("<LOOP>");
+ ND_PRINT((ndo, "<LOOP>"));
return (NULL);
}
continue;
@@ -199,25 +198,25 @@ ns_nprint(register const u_char *cp, register const u_char *bp)
elt = (i & ~INDIR_MASK);
switch(elt) {
case EDNS0_ELT_BITLABEL:
- if (blabel_print(cp) == NULL)
+ if (blabel_print(ndo, cp) == NULL)
return (NULL);
break;
default:
/* unknown ELT */
- printf("<ELT %d>", elt);
+ ND_PRINT((ndo, "<ELT %d>", elt));
return(NULL);
}
} else {
- if (fn_printn(cp, l, snapend))
+ if (fn_printn(ndo, cp, l, ndo->ndo_snapend))
return(NULL);
}
cp += l;
chars_processed += l;
- putchar('.');
- if ((l = labellen(cp)) == (u_int)-1)
+ ND_PRINT((ndo, "."));
+ if ((l = labellen(ndo, cp)) == (u_int)-1)
return(NULL);
- if (!TTEST2(*cp, 1))
+ if (!ND_TTEST2(*cp, 1))
return(NULL);
i = *cp++;
chars_processed++;
@@ -225,26 +224,27 @@ ns_nprint(register const u_char *cp, register const u_char *bp)
rp += l + 1;
}
else
- putchar('.');
+ ND_PRINT((ndo, "."));
return (rp);
}
/* print a <character-string> */
static const u_char *
-ns_cprint(register const u_char *cp)
+ns_cprint(netdissect_options *ndo,
+ register const u_char *cp)
{
register u_int i;
- if (!TTEST2(*cp, 1))
+ if (!ND_TTEST2(*cp, 1))
return (NULL);
i = *cp++;
- if (fn_printn(cp, i, snapend))
+ if (fn_printn(ndo, cp, i, ndo->ndo_snapend))
return (NULL);
return (cp + i);
}
/* http://www.iana.org/assignments/dns-parameters */
-struct tok ns_type2str[] = {
+const struct tok ns_type2str[] = {
{ T_A, "A" }, /* RFC 1035 */
{ T_NS, "NS" }, /* RFC 1035 */
{ T_MD, "MD" }, /* RFC 1035 */
@@ -309,7 +309,7 @@ struct tok ns_type2str[] = {
{ 0, NULL }
};
-struct tok ns_class2str[] = {
+const struct tok ns_class2str[] = {
{ C_IN, "IN" }, /* Not used */
{ C_CHAOS, "CHAOS" },
{ C_HS, "HS" },
@@ -319,20 +319,21 @@ struct tok ns_class2str[] = {
/* print a query */
static const u_char *
-ns_qprint(register const u_char *cp, register const u_char *bp, int is_mdns)
+ns_qprint(netdissect_options *ndo,
+ register const u_char *cp, register const u_char *bp, int is_mdns)
{
register const u_char *np = cp;
register u_int i, class;
- cp = ns_nskip(cp);
+ cp = ns_nskip(ndo, cp);
- if (cp == NULL || !TTEST2(*cp, 4))
+ if (cp == NULL || !ND_TTEST2(*cp, 4))
return(NULL);
/* print the qtype */
i = EXTRACT_16BITS(cp);
cp += 2;
- printf(" %s", tok2str(ns_type2str, "Type%d", i));
+ ND_PRINT((ndo, " %s", tok2str(ns_type2str, "Type%d", i)));
/* print the qclass (if it's not IN) */
i = EXTRACT_16BITS(cp);
cp += 2;
@@ -341,36 +342,34 @@ ns_qprint(register const u_char *cp, register const u_char *bp, int is_mdns)
else
class = i;
if (class != C_IN)
- printf(" %s", tok2str(ns_class2str, "(Class %d)", class));
+ ND_PRINT((ndo, " %s", tok2str(ns_class2str, "(Class %d)", class)));
if (is_mdns) {
- if (i & C_QU)
- printf(" (QU)");
- else
- printf(" (QM)");
+ ND_PRINT((ndo, i & C_QU ? " (QU)" : " (QM)"));
}
- fputs("? ", stdout);
- cp = ns_nprint(np, bp);
+ ND_PRINT((ndo, "? "));
+ cp = ns_nprint(ndo, np, bp);
return(cp ? cp + 4 : NULL);
}
/* print a reply */
static const u_char *
-ns_rprint(register const u_char *cp, register const u_char *bp, int is_mdns)
+ns_rprint(netdissect_options *ndo,
+ register const u_char *cp, register const u_char *bp, int is_mdns)
{
register u_int i, class, opt_flags = 0;
register u_short typ, len;
register const u_char *rp;
- if (vflag) {
- putchar(' ');
- if ((cp = ns_nprint(cp, bp)) == NULL)
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, " "));
+ if ((cp = ns_nprint(ndo, cp, bp)) == NULL)
return NULL;
} else
- cp = ns_nskip(cp);
+ cp = ns_nskip(ndo, cp);
- if (cp == NULL || !TTEST2(*cp, 10))
- return (snapend);
+ if (cp == NULL || !ND_TTEST2(*cp, 10))
+ return (ndo->ndo_snapend);
/* print the type/qtype */
typ = EXTRACT_16BITS(cp);
@@ -383,10 +382,10 @@ ns_rprint(register const u_char *cp, register const u_char *bp, int is_mdns)
else
class = i;
if (class != C_IN && typ != T_OPT)
- printf(" %s", tok2str(ns_class2str, "(Class %d)", class));
+ ND_PRINT((ndo, " %s", tok2str(ns_class2str, "(Class %d)", class)));
if (is_mdns) {
if (i & C_CACHE_FLUSH)
- printf(" (Cache flush)");
+ ND_PRINT((ndo, " (Cache flush)"));
}
if (typ == T_OPT) {
@@ -395,11 +394,11 @@ ns_rprint(register const u_char *cp, register const u_char *bp, int is_mdns)
opt_flags = EXTRACT_16BITS(cp);
/* ignore rest of ttl field */
cp += 2;
- } else if (vflag > 2) {
+ } else if (ndo->ndo_vflag > 2) {
/* print ttl */
- printf(" [");
- relts_print(EXTRACT_32BITS(cp));
- printf("]");
+ ND_PRINT((ndo, " ["));
+ relts_print(ndo, EXTRACT_32BITS(cp));
+ ND_PRINT((ndo, "]"));
cp += 4;
} else {
/* ignore ttl */
@@ -411,15 +410,15 @@ ns_rprint(register const u_char *cp, register const u_char *bp, int is_mdns)
rp = cp + len;
- printf(" %s", tok2str(ns_type2str, "Type%d", typ));
- if (rp > snapend)
+ ND_PRINT((ndo, " %s", tok2str(ns_type2str, "Type%d", typ)));
+ if (rp > ndo->ndo_snapend)
return(NULL);
switch (typ) {
case T_A:
- if (!TTEST2(*cp, sizeof(struct in_addr)))
+ if (!ND_TTEST2(*cp, sizeof(struct in_addr)))
return(NULL);
- printf(" %s", intoa(htonl(EXTRACT_32BITS(cp))));
+ ND_PRINT((ndo, " %s", intoa(htonl(EXTRACT_32BITS(cp)))));
break;
case T_NS:
@@ -428,60 +427,60 @@ ns_rprint(register const u_char *cp, register const u_char *bp, int is_mdns)
#ifdef T_DNAME
case T_DNAME:
#endif
- putchar(' ');
- if (ns_nprint(cp, bp) == NULL)
+ ND_PRINT((ndo, " "));
+ if (ns_nprint(ndo, cp, bp) == NULL)
return(NULL);
break;
case T_SOA:
- if (!vflag)
+ if (!ndo->ndo_vflag)
break;
- putchar(' ');
- if ((cp = ns_nprint(cp, bp)) == NULL)
+ ND_PRINT((ndo, " "));
+ if ((cp = ns_nprint(ndo, cp, bp)) == NULL)
return(NULL);
- putchar(' ');
- if ((cp = ns_nprint(cp, bp)) == NULL)
+ ND_PRINT((ndo, " "));
+ if ((cp = ns_nprint(ndo, cp, bp)) == NULL)
return(NULL);
- if (!TTEST2(*cp, 5 * 4))
+ if (!ND_TTEST2(*cp, 5 * 4))
return(NULL);
- printf(" %u", EXTRACT_32BITS(cp));
+ ND_PRINT((ndo, " %u", EXTRACT_32BITS(cp)));
cp += 4;
- printf(" %u", EXTRACT_32BITS(cp));
+ ND_PRINT((ndo, " %u", EXTRACT_32BITS(cp)));
cp += 4;
- printf(" %u", EXTRACT_32BITS(cp));
+ ND_PRINT((ndo, " %u", EXTRACT_32BITS(cp)));
cp += 4;
- printf(" %u", EXTRACT_32BITS(cp));
+ ND_PRINT((ndo, " %u", EXTRACT_32BITS(cp)));
cp += 4;
- printf(" %u", EXTRACT_32BITS(cp));
+ ND_PRINT((ndo, " %u", EXTRACT_32BITS(cp)));
cp += 4;
break;
case T_MX:
- putchar(' ');
- if (!TTEST2(*cp, 2))
+ ND_PRINT((ndo, " "));
+ if (!ND_TTEST2(*cp, 2))
return(NULL);
- if (ns_nprint(cp + 2, bp) == NULL)
+ if (ns_nprint(ndo, cp + 2, bp) == NULL)
return(NULL);
- printf(" %d", EXTRACT_16BITS(cp));
+ ND_PRINT((ndo, " %d", EXTRACT_16BITS(cp)));
break;
case T_TXT:
while (cp < rp) {
- printf(" \"");
- cp = ns_cprint(cp);
+ ND_PRINT((ndo, " \""));
+ cp = ns_cprint(ndo, cp);
if (cp == NULL)
return(NULL);
- putchar('"');
+ ND_PRINT((ndo, "\""));
}
break;
case T_SRV:
- putchar(' ');
- if (!TTEST2(*cp, 6))
+ ND_PRINT((ndo, " "));
+ if (!ND_TTEST2(*cp, 6))
return(NULL);
- if (ns_nprint(cp + 6, bp) == NULL)
+ if (ns_nprint(ndo, cp + 6, bp) == NULL)
return(NULL);
- printf(":%d %d %d", EXTRACT_16BITS(cp + 4),
- EXTRACT_16BITS(cp), EXTRACT_16BITS(cp + 2));
+ ND_PRINT((ndo, ":%d %d %d", EXTRACT_16BITS(cp + 4),
+ EXTRACT_16BITS(cp), EXTRACT_16BITS(cp + 2)));
break;
#ifdef INET6
@@ -490,11 +489,11 @@ ns_rprint(register const u_char *cp, register const u_char *bp, int is_mdns)
struct in6_addr addr;
char ntop_buf[INET6_ADDRSTRLEN];
- if (!TTEST2(*cp, sizeof(struct in6_addr)))
+ if (!ND_TTEST2(*cp, sizeof(struct in6_addr)))
return(NULL);
memcpy(&addr, cp, sizeof(struct in6_addr));
- printf(" %s",
- inet_ntop(AF_INET6, &addr, ntop_buf, sizeof(ntop_buf)));
+ ND_PRINT((ndo, " %s",
+ inet_ntop(AF_INET6, &addr, ntop_buf, sizeof(ntop_buf))));
break;
}
@@ -505,24 +504,24 @@ ns_rprint(register const u_char *cp, register const u_char *bp, int is_mdns)
int pbit, pbyte;
char ntop_buf[INET6_ADDRSTRLEN];
- if (!TTEST2(*cp, 1))
+ if (!ND_TTEST2(*cp, 1))
return(NULL);
pbit = *cp;
pbyte = (pbit & ~7) / 8;
if (pbit > 128) {
- printf(" %u(bad plen)", pbit);
+ ND_PRINT((ndo, " %u(bad plen)", pbit));
break;
} else if (pbit < 128) {
- if (!TTEST2(*(cp + 1), sizeof(a) - pbyte))
+ if (!ND_TTEST2(*(cp + 1), sizeof(a) - pbyte))
return(NULL);
memset(&a, 0, sizeof(a));
memcpy(&a.s6_addr[pbyte], cp + 1, sizeof(a) - pbyte);
- printf(" %u %s", pbit,
- inet_ntop(AF_INET6, &a, ntop_buf, sizeof(ntop_buf)));
+ ND_PRINT((ndo, " %u %s", pbit,
+ inet_ntop(AF_INET6, &a, ntop_buf, sizeof(ntop_buf))));
}
if (pbit > 0) {
- putchar(' ');
- if (ns_nprint(cp + 1 + sizeof(a) - pbyte, bp) == NULL)
+ ND_PRINT((ndo, " "));
+ if (ns_nprint(ndo, cp + 1 + sizeof(a) - pbyte, bp) == NULL)
return(NULL);
}
break;
@@ -530,47 +529,47 @@ ns_rprint(register const u_char *cp, register const u_char *bp, int is_mdns)
#endif /*INET6*/
case T_OPT:
- printf(" UDPsize=%u", class);
+ ND_PRINT((ndo, " UDPsize=%u", class));
if (opt_flags & 0x8000)
- printf(" OK");
+ ND_PRINT((ndo, " OK"));
break;
case T_UNSPECA: /* One long string */
- if (!TTEST2(*cp, len))
+ if (!ND_TTEST2(*cp, len))
return(NULL);
- if (fn_printn(cp, len, snapend))
+ if (fn_printn(ndo, cp, len, ndo->ndo_snapend))
return(NULL);
break;
case T_TSIG:
{
- if (cp + len > snapend)
+ if (cp + len > ndo->ndo_snapend)
return(NULL);
- if (!vflag)
+ if (!ndo->ndo_vflag)
break;
- putchar(' ');
- if ((cp = ns_nprint(cp, bp)) == NULL)
+ ND_PRINT((ndo, " "));
+ if ((cp = ns_nprint(ndo, cp, bp)) == NULL)
return(NULL);
cp += 6;
- if (!TTEST2(*cp, 2))
+ if (!ND_TTEST2(*cp, 2))
return(NULL);
- printf(" fudge=%u", EXTRACT_16BITS(cp));
+ ND_PRINT((ndo, " fudge=%u", EXTRACT_16BITS(cp)));
cp += 2;
- if (!TTEST2(*cp, 2))
+ if (!ND_TTEST2(*cp, 2))
return(NULL);
- printf(" maclen=%u", EXTRACT_16BITS(cp));
+ ND_PRINT((ndo, " maclen=%u", EXTRACT_16BITS(cp)));
cp += 2 + EXTRACT_16BITS(cp);
- if (!TTEST2(*cp, 2))
+ if (!ND_TTEST2(*cp, 2))
return(NULL);
- printf(" origid=%u", EXTRACT_16BITS(cp));
+ ND_PRINT((ndo, " origid=%u", EXTRACT_16BITS(cp)));
cp += 2;
- if (!TTEST2(*cp, 2))
+ if (!ND_TTEST2(*cp, 2))
return(NULL);
- printf(" error=%u", EXTRACT_16BITS(cp));
+ ND_PRINT((ndo, " error=%u", EXTRACT_16BITS(cp)));
cp += 2;
- if (!TTEST2(*cp, 2))
+ if (!ND_TTEST2(*cp, 2))
return(NULL);
- printf(" otherlen=%u", EXTRACT_16BITS(cp));
+ ND_PRINT((ndo, " otherlen=%u", EXTRACT_16BITS(cp)));
cp += 2;
}
}
@@ -578,15 +577,16 @@ ns_rprint(register const u_char *cp, register const u_char *bp, int is_mdns)
}
void
-ns_print(register const u_char *bp, u_int length, int is_mdns)
+ns_print(netdissect_options *ndo,
+ register const u_char *bp, u_int length, int is_mdns)
{
register const HEADER *np;
register int qdcount, ancount, nscount, arcount;
register const u_char *cp;
- u_int16_t b2;
+ uint16_t b2;
np = (const HEADER *)bp;
- TCHECK(*np);
+ ND_TCHECK(*np);
/* get the byte-order right */
qdcount = EXTRACT_16BITS(&np->qdcount);
ancount = EXTRACT_16BITS(&np->ancount);
@@ -595,65 +595,65 @@ ns_print(register const u_char *bp, u_int length, int is_mdns)
if (DNS_QR(np)) {
/* this is a response */
- printf("%d%s%s%s%s%s%s",
+ ND_PRINT((ndo, "%d%s%s%s%s%s%s",
EXTRACT_16BITS(&np->id),
ns_ops[DNS_OPCODE(np)],
ns_resp[DNS_RCODE(np)],
DNS_AA(np)? "*" : "",
DNS_RA(np)? "" : "-",
DNS_TC(np)? "|" : "",
- DNS_AD(np)? "$" : "");
+ DNS_AD(np)? "$" : ""));
if (qdcount != 1)
- printf(" [%dq]", qdcount);
+ ND_PRINT((ndo, " [%dq]", qdcount));
/* Print QUESTION section on -vv */
cp = (const u_char *)(np + 1);
while (qdcount--) {
if (qdcount < EXTRACT_16BITS(&np->qdcount) - 1)
- putchar(',');
- if (vflag > 1) {
- fputs(" q:", stdout);
- if ((cp = ns_qprint(cp, bp, is_mdns)) == NULL)
+ ND_PRINT((ndo, ","));
+ if (ndo->ndo_vflag > 1) {
+ ND_PRINT((ndo, " q:"));
+ if ((cp = ns_qprint(ndo, cp, bp, is_mdns)) == NULL)
goto trunc;
} else {
- if ((cp = ns_nskip(cp)) == NULL)
+ if ((cp = ns_nskip(ndo, cp)) == NULL)
goto trunc;
cp += 4; /* skip QTYPE and QCLASS */
}
}
- printf(" %d/%d/%d", ancount, nscount, arcount);
+ ND_PRINT((ndo, " %d/%d/%d", ancount, nscount, arcount));
if (ancount--) {
- if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
+ if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL)
goto trunc;
- while (cp < snapend && ancount--) {
- putchar(',');
- if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
+ while (cp < ndo->ndo_snapend && ancount--) {
+ ND_PRINT((ndo, ","));
+ if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL)
goto trunc;
}
}
if (ancount > 0)
goto trunc;
/* Print NS and AR sections on -vv */
- if (vflag > 1) {
- if (cp < snapend && nscount--) {
- fputs(" ns:", stdout);
- if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
+ if (ndo->ndo_vflag > 1) {
+ if (cp < ndo->ndo_snapend && nscount--) {
+ ND_PRINT((ndo, " ns:"));
+ if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL)
goto trunc;
- while (cp < snapend && nscount--) {
- putchar(',');
- if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
+ while (cp < ndo->ndo_snapend && nscount--) {
+ ND_PRINT((ndo, ","));
+ if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL)
goto trunc;
}
}
if (nscount > 0)
goto trunc;
- if (cp < snapend && arcount--) {
- fputs(" ar:", stdout);
- if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
+ if (cp < ndo->ndo_snapend && arcount--) {
+ ND_PRINT((ndo, " ar:"));
+ if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL)
goto trunc;
- while (cp < snapend && arcount--) {
- putchar(',');
- if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
+ while (cp < ndo->ndo_snapend && arcount--) {
+ ND_PRINT((ndo, ","));
+ if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL)
goto trunc;
}
}
@@ -663,39 +663,39 @@ ns_print(register const u_char *bp, u_int length, int is_mdns)
}
else {
/* this is a request */
- printf("%d%s%s%s", EXTRACT_16BITS(&np->id), ns_ops[DNS_OPCODE(np)],
+ ND_PRINT((ndo, "%d%s%s%s", EXTRACT_16BITS(&np->id), ns_ops[DNS_OPCODE(np)],
DNS_RD(np) ? "+" : "",
- DNS_CD(np) ? "%" : "");
+ DNS_CD(np) ? "%" : ""));
/* any weirdness? */
b2 = EXTRACT_16BITS(((u_short *)np)+1);
if (b2 & 0x6cf)
- printf(" [b2&3=0x%x]", b2);
+ ND_PRINT((ndo, " [b2&3=0x%x]", b2));
if (DNS_OPCODE(np) == IQUERY) {
if (qdcount)
- printf(" [%dq]", qdcount);
+ ND_PRINT((ndo, " [%dq]", qdcount));
if (ancount != 1)
- printf(" [%da]", ancount);
+ ND_PRINT((ndo, " [%da]", ancount));
}
else {
if (ancount)
- printf(" [%da]", ancount);
+ ND_PRINT((ndo, " [%da]", ancount));
if (qdcount != 1)
- printf(" [%dq]", qdcount);
+ ND_PRINT((ndo, " [%dq]", qdcount));
}
if (nscount)
- printf(" [%dn]", nscount);
+ ND_PRINT((ndo, " [%dn]", nscount));
if (arcount)
- printf(" [%dau]", arcount);
+ ND_PRINT((ndo, " [%dau]", arcount));
cp = (const u_char *)(np + 1);
if (qdcount--) {
- cp = ns_qprint(cp, (const u_char *)np, is_mdns);
+ cp = ns_qprint(ndo, cp, (const u_char *)np, is_mdns);
if (!cp)
goto trunc;
- while (cp < snapend && qdcount--) {
- cp = ns_qprint((const u_char *)cp,
+ while (cp < ndo->ndo_snapend && qdcount--) {
+ cp = ns_qprint(ndo, (const u_char *)cp,
(const u_char *)np,
is_mdns);
if (!cp)
@@ -706,37 +706,37 @@ ns_print(register const u_char *bp, u_int length, int is_mdns)
goto trunc;
/* Print remaining sections on -vv */
- if (vflag > 1) {
+ if (ndo->ndo_vflag > 1) {
if (ancount--) {
- if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
+ if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL)
goto trunc;
- while (cp < snapend && ancount--) {
- putchar(',');
- if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
+ while (cp < ndo->ndo_snapend && ancount--) {
+ ND_PRINT((ndo, ","));
+ if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL)
goto trunc;
}
}
if (ancount > 0)
goto trunc;
- if (cp < snapend && nscount--) {
- fputs(" ns:", stdout);
- if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
+ if (cp < ndo->ndo_snapend && nscount--) {
+ ND_PRINT((ndo, " ns:"));
+ if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL)
goto trunc;
- while (nscount-- && cp < snapend) {
- putchar(',');
- if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
+ while (nscount-- && cp < ndo->ndo_snapend) {
+ ND_PRINT((ndo, ","));
+ if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL)
goto trunc;
}
}
if (nscount > 0)
goto trunc;
- if (cp < snapend && arcount--) {
- fputs(" ar:", stdout);
- if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
+ if (cp < ndo->ndo_snapend && arcount--) {
+ ND_PRINT((ndo, " ar:"));
+ if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL)
goto trunc;
- while (cp < snapend && arcount--) {
- putchar(',');
- if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
+ while (cp < ndo->ndo_snapend && arcount--) {
+ ND_PRINT((ndo, ","));
+ if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL)
goto trunc;
}
}
@@ -744,10 +744,9 @@ ns_print(register const u_char *bp, u_int length, int is_mdns)
goto trunc;
}
}
- printf(" (%d)", length);
+ ND_PRINT((ndo, " (%d)", length));
return;
trunc:
- printf("[|domain]");
- return;
+ ND_PRINT((ndo, "[|domain]"));
}
diff --git a/contrib/tcpdump/print-dtp.c b/contrib/tcpdump/print-dtp.c
index c358a8930743..5d84a770eeca 100644
--- a/contrib/tcpdump/print-dtp.c
+++ b/contrib/tcpdump/print-dtp.c
@@ -17,19 +17,16 @@
* Original code by Carles Kishimoto <carles.kishimoto@gmail.com>
*/
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <string.h>
-
#include "interface.h"
#include "addrtoname.h"
-#include "extract.h"
-#include "nlpid.h"
+#include "extract.h"
#define DTP_HEADER_LEN 1
#define DTP_DOMAIN_TLV 0x0001
@@ -37,7 +34,7 @@
#define DTP_DTP_TYPE_TLV 0x0003
#define DTP_NEIGHBOR_TLV 0x0004
-static struct tok dtp_tlv_values[] = {
+static const struct tok dtp_tlv_values[] = {
{ DTP_DOMAIN_TLV, "Domain TLV"},
{ DTP_STATUS_TLV, "Status TLV"},
{ DTP_DTP_TYPE_TLV, "DTP type TLV"},
@@ -46,7 +43,7 @@ static struct tok dtp_tlv_values[] = {
};
void
-dtp_print (const u_char *pptr, u_int length)
+dtp_print (netdissect_options *ndo, const u_char *pptr, u_int length)
{
int type, len;
const u_char *tptr;
@@ -54,19 +51,18 @@ dtp_print (const u_char *pptr, u_int length)
if (length < DTP_HEADER_LEN)
goto trunc;
- tptr = pptr;
+ tptr = pptr;
- if (!TTEST2(*tptr, DTP_HEADER_LEN))
- goto trunc;
+ ND_TCHECK2(*tptr, DTP_HEADER_LEN);
- printf("DTPv%u, length %u",
+ ND_PRINT((ndo, "DTPv%u, length %u",
(*tptr),
- length);
+ length));
/*
* In non-verbose mode, just print version.
*/
- if (vflag < 1) {
+ if (ndo->ndo_vflag < 1) {
return;
}
@@ -74,45 +70,44 @@ dtp_print (const u_char *pptr, u_int length)
while (tptr < (pptr+length)) {
- if (!TTEST2(*tptr, 4))
- goto trunc;
+ ND_TCHECK2(*tptr, 4);
type = EXTRACT_16BITS(tptr);
- len = EXTRACT_16BITS(tptr+2);
+ len = EXTRACT_16BITS(tptr+2);
/* infinite loop check */
if (type == 0 || len == 0) {
return;
}
- printf("\n\t%s (0x%04x) TLV, length %u",
+ ND_PRINT((ndo, "\n\t%s (0x%04x) TLV, length %u",
tok2str(dtp_tlv_values, "Unknown", type),
- type, len);
+ type, len));
switch (type) {
case DTP_DOMAIN_TLV:
- printf(", %s", tptr+4);
+ ND_PRINT((ndo, ", %s", tptr+4));
break;
- case DTP_STATUS_TLV:
+ case DTP_STATUS_TLV:
case DTP_DTP_TYPE_TLV:
- printf(", 0x%x", *(tptr+4));
+ ND_PRINT((ndo, ", 0x%x", *(tptr+4)));
break;
case DTP_NEIGHBOR_TLV:
- printf(", %s", etheraddr_string(tptr+4));
+ ND_PRINT((ndo, ", %s", etheraddr_string(ndo, tptr+4)));
break;
default:
break;
- }
+ }
tptr += len;
}
return;
trunc:
- printf("[|dtp]");
+ ND_PRINT((ndo, "[|dtp]"));
}
/*
diff --git a/contrib/tcpdump/print-dvmrp.c b/contrib/tcpdump/print-dvmrp.c
index 437e7160c7fa..96a0ee73f578 100644
--- a/contrib/tcpdump/print-dvmrp.c
+++ b/contrib/tcpdump/print-dvmrp.c
@@ -19,21 +19,13 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-dvmrp.c,v 1.27 2003-11-19 09:42:04 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
#include "interface.h"
#include "extract.h"
#include "addrtoname.h"
@@ -62,27 +54,28 @@ static const char rcsid[] _U_ =
#define DVMRP_NF_DISABLED 0x20 /* administratively disabled */
#define DVMRP_NF_QUERIER 0x40 /* I am the subnet's querier */
-static int print_probe(const u_char *, const u_char *, u_int);
-static int print_report(const u_char *, const u_char *, u_int);
-static int print_neighbors(const u_char *, const u_char *, u_int);
-static int print_neighbors2(const u_char *, const u_char *, u_int);
-static int print_prune(const u_char *);
-static int print_graft(const u_char *);
-static int print_graft_ack(const u_char *);
+static int print_probe(netdissect_options *, const u_char *, const u_char *, u_int);
+static int print_report(netdissect_options *, const u_char *, const u_char *, u_int);
+static int print_neighbors(netdissect_options *, const u_char *, const u_char *, u_int);
+static int print_neighbors2(netdissect_options *, const u_char *, const u_char *, u_int);
+static int print_prune(netdissect_options *, const u_char *);
+static int print_graft(netdissect_options *, const u_char *);
+static int print_graft_ack(netdissect_options *, const u_char *);
-static u_int32_t target_level;
+static uint32_t target_level;
void
-dvmrp_print(register const u_char *bp, register u_int len)
+dvmrp_print(netdissect_options *ndo,
+ register const u_char *bp, register u_int len)
{
register const u_char *ep;
register u_char type;
- ep = (const u_char *)snapend;
+ ep = (const u_char *)ndo->ndo_snapend;
if (bp >= ep)
return;
- TCHECK(bp[1]);
+ ND_TCHECK(bp[1]);
type = bp[1];
/* Skip IGMP header */
@@ -92,94 +85,95 @@ dvmrp_print(register const u_char *bp, register u_int len)
switch (type) {
case DVMRP_PROBE:
- printf(" Probe");
- if (vflag) {
- if (print_probe(bp, ep, len) < 0)
+ ND_PRINT((ndo, " Probe"));
+ if (ndo->ndo_vflag) {
+ if (print_probe(ndo, bp, ep, len) < 0)
goto trunc;
}
break;
case DVMRP_REPORT:
- printf(" Report");
- if (vflag > 1) {
- if (print_report(bp, ep, len) < 0)
+ ND_PRINT((ndo, " Report"));
+ if (ndo->ndo_vflag > 1) {
+ if (print_report(ndo, bp, ep, len) < 0)
goto trunc;
}
break;
case DVMRP_ASK_NEIGHBORS:
- printf(" Ask-neighbors(old)");
+ ND_PRINT((ndo, " Ask-neighbors(old)"));
break;
case DVMRP_NEIGHBORS:
- printf(" Neighbors(old)");
- if (print_neighbors(bp, ep, len) < 0)
+ ND_PRINT((ndo, " Neighbors(old)"));
+ if (print_neighbors(ndo, bp, ep, len) < 0)
goto trunc;
break;
case DVMRP_ASK_NEIGHBORS2:
- printf(" Ask-neighbors2");
+ ND_PRINT((ndo, " Ask-neighbors2"));
break;
case DVMRP_NEIGHBORS2:
- printf(" Neighbors2");
+ ND_PRINT((ndo, " Neighbors2"));
/*
* extract version and capabilities from IGMP group
* address field
*/
bp -= 4;
- TCHECK2(bp[0], 4);
+ ND_TCHECK2(bp[0], 4);
target_level = (bp[0] << 24) | (bp[1] << 16) |
(bp[2] << 8) | bp[3];
bp += 4;
- if (print_neighbors2(bp, ep, len) < 0)
+ if (print_neighbors2(ndo, bp, ep, len) < 0)
goto trunc;
break;
case DVMRP_PRUNE:
- printf(" Prune");
- if (print_prune(bp) < 0)
+ ND_PRINT((ndo, " Prune"));
+ if (print_prune(ndo, bp) < 0)
goto trunc;
break;
case DVMRP_GRAFT:
- printf(" Graft");
- if (print_graft(bp) < 0)
+ ND_PRINT((ndo, " Graft"));
+ if (print_graft(ndo, bp) < 0)
goto trunc;
break;
case DVMRP_GRAFT_ACK:
- printf(" Graft-ACK");
- if (print_graft_ack(bp) < 0)
+ ND_PRINT((ndo, " Graft-ACK"));
+ if (print_graft_ack(ndo, bp) < 0)
goto trunc;
break;
default:
- printf(" [type %d]", type);
+ ND_PRINT((ndo, " [type %d]", type));
break;
}
return;
trunc:
- printf("[|dvmrp]");
+ ND_PRINT((ndo, "[|dvmrp]"));
return;
}
-static int
-print_report(register const u_char *bp, register const u_char *ep,
- register u_int len)
+static int
+print_report(netdissect_options *ndo,
+ register const u_char *bp, register const u_char *ep,
+ register u_int len)
{
- register u_int32_t mask, origin;
+ register uint32_t mask, origin;
register int metric, done;
register u_int i, width;
while (len > 0) {
if (len < 3) {
- printf(" [|]");
+ ND_PRINT((ndo, " [|]"));
return (0);
}
- TCHECK2(bp[0], 3);
- mask = (u_int32_t)0xff << 24 | bp[0] << 16 | bp[1] << 8 | bp[2];
+ ND_TCHECK2(bp[0], 3);
+ mask = (uint32_t)0xff << 24 | bp[0] << 16 | bp[1] << 8 | bp[2];
width = 1;
if (bp[0])
width = 2;
@@ -188,32 +182,32 @@ print_report(register const u_char *bp, register const u_char *ep,
if (bp[2])
width = 4;
- printf("\n\tMask %s", intoa(htonl(mask)));
+ ND_PRINT((ndo, "\n\tMask %s", intoa(htonl(mask))));
bp += 3;
len -= 3;
do {
if (bp + width + 1 > ep) {
- printf(" [|]");
+ ND_PRINT((ndo, " [|]"));
return (0);
}
if (len < width + 1) {
- printf("\n\t [Truncated Report]");
+ ND_PRINT((ndo, "\n\t [Truncated Report]"));
return (0);
}
origin = 0;
for (i = 0; i < width; ++i) {
- TCHECK(*bp);
+ ND_TCHECK(*bp);
origin = origin << 8 | *bp++;
}
for ( ; i < 4; ++i)
origin <<= 8;
- TCHECK(*bp);
+ ND_TCHECK(*bp);
metric = *bp++;
done = metric & 0x80;
metric &= 0x7f;
- printf("\n\t %s metric %d", intoa(htonl(origin)),
- metric);
+ ND_PRINT((ndo, "\n\t %s metric %d", intoa(htonl(origin)),
+ metric));
len -= width + 1;
} while (!done);
}
@@ -223,31 +217,29 @@ trunc:
}
static int
-print_probe(register const u_char *bp, register const u_char *ep,
- register u_int len)
+print_probe(netdissect_options *ndo,
+ register const u_char *bp, register const u_char *ep,
+ register u_int len)
{
- register u_int32_t genid;
+ register uint32_t genid;
- TCHECK2(bp[0], 4);
+ ND_TCHECK2(bp[0], 4);
if ((len < 4) || ((bp + 4) > ep)) {
/* { (ctags) */
- printf(" [|}");
+ ND_PRINT((ndo, " [|}"));
return (0);
}
genid = (bp[0] << 24) | (bp[1] << 16) | (bp[2] << 8) | bp[3];
bp += 4;
len -= 4;
- if (vflag > 1)
- printf("\n\t");
- else
- printf(" ");
- printf("genid %u", genid);
- if (vflag < 2)
+ ND_PRINT((ndo, ndo->ndo_vflag > 1 ? "\n\t" : " "));
+ ND_PRINT((ndo, "genid %u", genid));
+ if (ndo->ndo_vflag < 2)
return (0);
while ((len > 0) && (bp < ep)) {
- TCHECK2(bp[0], 4);
- printf("\n\tneighbor %s", ipaddr_string(bp));
+ ND_TCHECK2(bp[0], 4);
+ ND_PRINT((ndo, "\n\tneighbor %s", ipaddr_string(ndo, bp)));
bp += 4; len -= 4;
}
return (0);
@@ -256,8 +248,9 @@ trunc:
}
static int
-print_neighbors(register const u_char *bp, register const u_char *ep,
- register u_int len)
+print_neighbors(netdissect_options *ndo,
+ register const u_char *bp, register const u_char *ep,
+ register u_int len)
{
const u_char *laddr;
register u_char metric;
@@ -265,7 +258,7 @@ print_neighbors(register const u_char *bp, register const u_char *ep,
register int ncount;
while (len > 0 && bp < ep) {
- TCHECK2(bp[0], 7);
+ ND_TCHECK2(bp[0], 7);
laddr = bp;
bp += 4;
metric = *bp++;
@@ -273,10 +266,10 @@ print_neighbors(register const u_char *bp, register const u_char *ep,
ncount = *bp++;
len -= 7;
while (--ncount >= 0) {
- TCHECK2(bp[0], 4);
- printf(" [%s ->", ipaddr_string(laddr));
- printf(" %s, (%d/%d)]",
- ipaddr_string(bp), metric, thresh);
+ ND_TCHECK2(bp[0], 4);
+ ND_PRINT((ndo, " [%s ->", ipaddr_string(ndo, laddr)));
+ ND_PRINT((ndo, " %s, (%d/%d)]",
+ ipaddr_string(ndo, bp), metric, thresh));
bp += 4;
len -= 4;
}
@@ -287,19 +280,20 @@ trunc:
}
static int
-print_neighbors2(register const u_char *bp, register const u_char *ep,
- register u_int len)
+print_neighbors2(netdissect_options *ndo,
+ register const u_char *bp, register const u_char *ep,
+ register u_int len)
{
const u_char *laddr;
register u_char metric, thresh, flags;
register int ncount;
- printf(" (v %d.%d):",
+ ND_PRINT((ndo, " (v %d.%d):",
(int)target_level & 0xff,
- (int)(target_level >> 8) & 0xff);
+ (int)(target_level >> 8) & 0xff));
while (len > 0 && bp < ep) {
- TCHECK2(bp[0], 8);
+ ND_TCHECK2(bp[0], 8);
laddr = bp;
bp += 4;
metric = *bp++;
@@ -308,25 +302,25 @@ print_neighbors2(register const u_char *bp, register const u_char *ep,
ncount = *bp++;
len -= 8;
while (--ncount >= 0 && (len >= 4) && (bp + 4) <= ep) {
- printf(" [%s -> ", ipaddr_string(laddr));
- printf("%s (%d/%d", ipaddr_string(bp),
- metric, thresh);
+ ND_PRINT((ndo, " [%s -> ", ipaddr_string(ndo, laddr)));
+ ND_PRINT((ndo, "%s (%d/%d", ipaddr_string(ndo, bp),
+ metric, thresh));
if (flags & DVMRP_NF_TUNNEL)
- printf("/tunnel");
+ ND_PRINT((ndo, "/tunnel"));
if (flags & DVMRP_NF_SRCRT)
- printf("/srcrt");
+ ND_PRINT((ndo, "/srcrt"));
if (flags & DVMRP_NF_QUERIER)
- printf("/querier");
+ ND_PRINT((ndo, "/querier"));
if (flags & DVMRP_NF_DISABLED)
- printf("/disabled");
+ ND_PRINT((ndo, "/disabled"));
if (flags & DVMRP_NF_DOWN)
- printf("/down");
- printf(")]");
+ ND_PRINT((ndo, "/down"));
+ ND_PRINT((ndo, ")]"));
bp += 4;
len -= 4;
}
if (ncount != -1) {
- printf(" [|]");
+ ND_PRINT((ndo, " [|]"));
return (0);
}
}
@@ -336,33 +330,36 @@ trunc:
}
static int
-print_prune(register const u_char *bp)
+print_prune(netdissect_options *ndo,
+ register const u_char *bp)
{
- TCHECK2(bp[0], 12);
- printf(" src %s grp %s", ipaddr_string(bp), ipaddr_string(bp + 4));
+ ND_TCHECK2(bp[0], 12);
+ ND_PRINT((ndo, " src %s grp %s", ipaddr_string(ndo, bp), ipaddr_string(ndo, bp + 4)));
bp += 8;
- (void)printf(" timer ");
- relts_print(EXTRACT_32BITS(bp));
+ ND_PRINT((ndo, " timer "));
+ relts_print(ndo, EXTRACT_32BITS(bp));
return (0);
trunc:
return (-1);
}
static int
-print_graft(register const u_char *bp)
+print_graft(netdissect_options *ndo,
+ register const u_char *bp)
{
- TCHECK2(bp[0], 8);
- printf(" src %s grp %s", ipaddr_string(bp), ipaddr_string(bp + 4));
+ ND_TCHECK2(bp[0], 8);
+ ND_PRINT((ndo, " src %s grp %s", ipaddr_string(ndo, bp), ipaddr_string(ndo, bp + 4)));
return (0);
trunc:
return (-1);
}
static int
-print_graft_ack(register const u_char *bp)
+print_graft_ack(netdissect_options *ndo,
+ register const u_char *bp)
{
- TCHECK2(bp[0], 8);
- printf(" src %s grp %s", ipaddr_string(bp), ipaddr_string(bp + 4));
+ ND_TCHECK2(bp[0], 8);
+ ND_PRINT((ndo, " src %s grp %s", ipaddr_string(ndo, bp), ipaddr_string(ndo, bp + 4)));
return (0);
trunc:
return (-1);
diff --git a/contrib/tcpdump/print-eap.c b/contrib/tcpdump/print-eap.c
index 9fb333ad86b1..0e2c2d38a1d8 100644
--- a/contrib/tcpdump/print-eap.c
+++ b/contrib/tcpdump/print-eap.c
@@ -21,25 +21,15 @@
*
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-eap.c,v 1.5 2007-10-04 16:41:33 hannes Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "netdissect.h"
#include "interface.h"
-#include "addrtoname.h"
#include "extract.h"
-#include "ether.h"
#define EAP_FRAME_TYPE_PACKET 0
#define EAP_FRAME_TYPE_START 1
@@ -113,7 +103,7 @@ static const struct tok eap_type_values[] = {
{ EAP_TYPE_EXPANDED_TYPES, "Expanded types" },
{ EAP_TYPE_EXPERIMENTAL, "Experimental" },
{ 0, NULL}
-};
+};
#define EAP_TLS_EXTRACT_BIT_L(x) (((x)&0x80)>>7)
@@ -159,7 +149,7 @@ static const struct tok eap_aka_subtype_values[] = {
* Print EAP requests / responses
*/
void
-eap_print(netdissect_options *ndo _U_,
+eap_print(netdissect_options *ndo,
register const u_char *cp,
u_int length _U_)
{
@@ -167,27 +157,27 @@ eap_print(netdissect_options *ndo _U_,
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);
+ ND_TCHECK(*eap);
/* in non-verbose mode just lets print the basic info */
- if (vflag < 1) {
- printf("%s (%u) v%u, len %u",
+ if (ndo->ndo_vflag < 1) {
+ ND_PRINT((ndo, "%s (%u) v%u, len %u",
tok2str(eap_frame_type_values, "unknown", eap->type),
eap->type,
eap->version,
- EXTRACT_16BITS(eap->length));
+ EXTRACT_16BITS(eap->length)));
return;
}
-
- printf("%s (%u) v%u, len %u",
+
+ ND_PRINT((ndo, "%s (%u) v%u, len %u",
tok2str(eap_frame_type_values, "unknown", eap->type),
eap->type,
eap->version,
- EXTRACT_16BITS(eap->length));
+ EXTRACT_16BITS(eap->length)));
tptr += sizeof(const struct eap_frame_t);
tlen -= sizeof(const struct eap_frame_t);
@@ -196,33 +186,32 @@ eap_print(netdissect_options *ndo _U_,
case EAP_FRAME_TYPE_PACKET:
type = *(tptr);
len = EXTRACT_16BITS(tptr+2);
- printf(", %s (%u), id %u, len %u",
+ ND_PRINT((ndo, ", %s (%u), id %u, len %u",
tok2str(eap_code_values, "unknown", type),
type,
*(tptr+1),
- len);
+ len));
- if (!TTEST2(*tptr, len))
- goto trunc;
+ ND_TCHECK2(*tptr, len);
if (type <= 2) { /* For EAP_REQUEST and EAP_RESPONSE only */
subtype = *(tptr+4);
- printf("\n\t\t Type %s (%u)",
+ ND_PRINT((ndo, "\n\t\t Type %s (%u)",
tok2str(eap_type_values, "unknown", *(tptr+4)),
- *(tptr+4));
+ *(tptr + 4)));
- switch (subtype) {
+ switch (subtype) {
case EAP_TYPE_IDENTITY:
if (len - 5 > 0) {
- printf(", Identity: ");
- safeputs((const char *)tptr+5, len-5);
+ ND_PRINT((ndo, ", Identity: "));
+ safeputs(ndo, tptr + 5, len - 5);
}
break;
case EAP_TYPE_NOTIFICATION:
if (len - 5 > 0) {
- printf(", Notification: ");
- safeputs((const char *)tptr+5, len-5);
+ ND_PRINT((ndo, ", Notification: "));
+ safeputs(ndo, tptr + 5, len - 5);
}
break;
@@ -234,36 +223,36 @@ eap_print(netdissect_options *ndo _U_,
* the desired authentication
* type one octet per type
*/
- while (count < len) {
- printf(" %s (%u),",
+ while (count < len) {
+ ND_PRINT((ndo, " %s (%u),",
tok2str(eap_type_values, "unknown", *(tptr+count)),
- *(tptr+count));
+ *(tptr + count)));
count++;
}
break;
case EAP_TYPE_TTLS:
- printf(" TTLSv%u",
- EAP_TTLS_VERSION(*(tptr+5))); /* fall through */
+ ND_PRINT((ndo, " TTLSv%u",
+ EAP_TTLS_VERSION(*(tptr + 5)))); /* fall through */
case EAP_TYPE_TLS:
- printf(" flags [%s] 0x%02x,",
+ ND_PRINT((ndo, " flags [%s] 0x%02x,",
bittok2str(eap_tls_flags_values, "none", *(tptr+5)),
- *(tptr+5));
+ *(tptr + 5)));
if (EAP_TLS_EXTRACT_BIT_L(*(tptr+5))) {
- printf(" len %u", EXTRACT_32BITS(tptr+6));
+ ND_PRINT((ndo, " len %u", EXTRACT_32BITS(tptr + 6)));
}
break;
case EAP_TYPE_FAST:
- printf(" FASTv%u",
- EAP_TTLS_VERSION(*(tptr+5)));
- printf(" flags [%s] 0x%02x,",
+ ND_PRINT((ndo, " FASTv%u",
+ EAP_TTLS_VERSION(*(tptr + 5))));
+ ND_PRINT((ndo, " flags [%s] 0x%02x,",
bittok2str(eap_tls_flags_values, "none", *(tptr+5)),
- *(tptr+5));
+ *(tptr + 5)));
if (EAP_TLS_EXTRACT_BIT_L(*(tptr+5))) {
- printf(" len %u", EXTRACT_32BITS(tptr+6));
+ ND_PRINT((ndo, " len %u", EXTRACT_32BITS(tptr + 6)));
}
/* FIXME - TLV attributes follow */
@@ -271,14 +260,14 @@ eap_print(netdissect_options *ndo _U_,
case EAP_TYPE_AKA:
case EAP_TYPE_SIM:
- printf(" subtype [%s] 0x%02x,",
+ ND_PRINT((ndo, " subtype [%s] 0x%02x,",
tok2str(eap_aka_subtype_values, "unknown", *(tptr+5)),
- *(tptr+5));
+ *(tptr + 5)));
/* FIXME - TLV attributes follow */
break;
- case EAP_TYPE_MD5_CHALLENGE:
+ case EAP_TYPE_MD5_CHALLENGE:
case EAP_TYPE_OTP:
case EAP_TYPE_GTC:
case EAP_TYPE_EXPANDED_TYPES:
@@ -287,7 +276,7 @@ eap_print(netdissect_options *ndo _U_,
break;
}
}
- break;
+ break;
case EAP_FRAME_TYPE_LOGOFF:
case EAP_FRAME_TYPE_ENCAP_ASF_ALERT:
@@ -297,7 +286,7 @@ eap_print(netdissect_options *ndo _U_,
return;
trunc:
- printf("\n\t[|EAP]");
+ ND_PRINT((ndo, "\n\t[|EAP]"));
}
/*
diff --git a/contrib/tcpdump/print-egp.c b/contrib/tcpdump/print-egp.c
index 4a1d046531be..9c5c811e74e5 100644
--- a/contrib/tcpdump/print-egp.c
+++ b/contrib/tcpdump/print-egp.c
@@ -18,35 +18,27 @@
* Initial contribution from Jeff Honig (jch@MITCHELL.CIT.CORNELL.EDU).
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-egp.c,v 1.38 2006-02-11 22:13:24 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-
#include "interface.h"
#include "addrtoname.h"
#include "extract.h"
-#include "ip.h"
-
struct egp_packet {
- u_int8_t egp_version;
+ uint8_t egp_version;
#define EGP_VERSION 2
- u_int8_t egp_type;
+ uint8_t egp_type;
#define EGPT_ACQUIRE 3
#define EGPT_REACH 5
#define EGPT_POLL 2
#define EGPT_UPDATE 1
#define EGPT_ERROR 8
- u_int8_t egp_code;
+ uint8_t egp_code;
#define EGPC_REQUEST 0
#define EGPC_CONFIRM 1
#define EGPC_REFUSE 2
@@ -54,7 +46,7 @@ struct egp_packet {
#define EGPC_CEASEACK 4
#define EGPC_HELLO 0
#define EGPC_HEARDU 1
- u_int8_t egp_status;
+ uint8_t egp_status;
#define EGPS_UNSPEC 0
#define EGPS_ACTIVE 1
#define EGPS_PASSIVE 2
@@ -67,13 +59,13 @@ struct egp_packet {
#define EGPS_UP 1
#define EGPS_DOWN 2
#define EGPS_UNSOL 0x80
- u_int16_t egp_checksum;
- u_int16_t egp_as;
- u_int16_t egp_sequence;
+ uint16_t egp_checksum;
+ uint16_t egp_as;
+ uint16_t egp_sequence;
union {
- u_int16_t egpu_hello;
- u_int8_t egpu_gws[2];
- u_int16_t egpu_reason;
+ uint16_t egpu_hello;
+ uint8_t egpu_gws[2];
+ uint16_t egpu_reason;
#define EGPR_UNSPEC 0
#define EGPR_BADHEAD 1
#define EGPR_BADDATA 2
@@ -87,14 +79,14 @@ struct egp_packet {
#define egp_extgw egp_handg.egpu_gws[1]
#define egp_reason egp_handg.egpu_reason
union {
- u_int16_t egpu_poll;
- u_int32_t egpu_sourcenet;
+ uint16_t egpu_poll;
+ uint32_t egpu_sourcenet;
} egp_pands;
#define egp_poll egp_pands.egpu_poll
#define egp_sourcenet egp_pands.egpu_sourcenet
};
-const char *egp_acquire_codes[] = {
+static const char *egp_acquire_codes[] = {
"request",
"confirm",
"refuse",
@@ -102,7 +94,7 @@ const char *egp_acquire_codes[] = {
"cease_ack"
};
-const char *egp_acquire_status[] = {
+static const char *egp_acquire_status[] = {
"unspecified",
"active_mode",
"passive_mode",
@@ -113,18 +105,18 @@ const char *egp_acquire_status[] = {
"protocol_violation"
};
-const char *egp_reach_codes[] = {
+static const char *egp_reach_codes[] = {
"hello",
"i-h-u"
};
-const char *egp_status_updown[] = {
+static const char *egp_status_updown[] = {
"indeterminate",
"up",
"down"
};
-const char *egp_reasons[] = {
+static const char *egp_reasons[] = {
"unspecified",
"bad_EGP_header_format",
"bad_EGP_data_field_format",
@@ -135,11 +127,12 @@ const char *egp_reasons[] = {
};
static void
-egpnrprint(register const struct egp_packet *egp)
+egpnrprint(netdissect_options *ndo,
+ register const struct egp_packet *egp)
{
- register const u_int8_t *cp;
- u_int32_t addr;
- register u_int32_t net;
+ register const uint8_t *cp;
+ uint32_t addr;
+ register uint32_t net;
register u_int netlen;
int gateways, distances, networks;
int t_gateways;
@@ -159,13 +152,13 @@ egpnrprint(register const struct egp_packet *egp)
net = 0;
netlen = 0;
}
- cp = (u_int8_t *)(egp + 1);
+ cp = (uint8_t *)(egp + 1);
t_gateways = egp->egp_intgw + egp->egp_extgw;
for (gateways = 0; gateways < t_gateways; ++gateways) {
/* Pickup host part of gateway address */
addr = 0;
- TCHECK2(cp[0], 4 - netlen);
+ ND_TCHECK2(cp[0], 4 - netlen);
switch (netlen) {
case 1:
@@ -178,43 +171,44 @@ egpnrprint(register const struct egp_packet *egp)
addr = (addr << 8) | *cp++;
}
addr |= net;
- TCHECK2(cp[0], 1);
+ ND_TCHECK2(cp[0], 1);
distances = *cp++;
- printf(" %s %s ",
+ ND_PRINT((ndo, " %s %s ",
gateways < (int)egp->egp_intgw ? "int" : "ext",
- ipaddr_string(&addr));
+ ipaddr_string(ndo, &addr)));
comma = "";
- putchar('(');
+ ND_PRINT((ndo, "("));
while (--distances >= 0) {
- TCHECK2(cp[0], 2);
- printf("%sd%d:", comma, (int)*cp++);
+ ND_TCHECK2(cp[0], 2);
+ ND_PRINT((ndo, "%sd%d:", comma, (int)*cp++));
comma = ", ";
networks = *cp++;
while (--networks >= 0) {
/* Pickup network number */
- TCHECK2(cp[0], 1);
- addr = (u_int32_t)*cp++ << 24;
+ ND_TCHECK2(cp[0], 1);
+ addr = (uint32_t)*cp++ << 24;
if (IN_CLASSB(addr)) {
- TCHECK2(cp[0], 1);
- addr |= (u_int32_t)*cp++ << 16;
+ ND_TCHECK2(cp[0], 1);
+ addr |= (uint32_t)*cp++ << 16;
} else if (!IN_CLASSA(addr)) {
- TCHECK2(cp[0], 2);
- addr |= (u_int32_t)*cp++ << 16;
- addr |= (u_int32_t)*cp++ << 8;
+ ND_TCHECK2(cp[0], 2);
+ addr |= (uint32_t)*cp++ << 16;
+ addr |= (uint32_t)*cp++ << 8;
}
- printf(" %s", ipaddr_string(&addr));
+ ND_PRINT((ndo, " %s", ipaddr_string(ndo, &addr)));
}
}
- putchar(')');
+ ND_PRINT((ndo, ")"));
}
return;
trunc:
- fputs("[|]", stdout);
+ ND_PRINT((ndo, "[|]"));
}
void
-egp_print(register const u_int8_t *bp, register u_int length)
+egp_print(netdissect_options *ndo,
+ register const uint8_t *bp, register u_int length)
{
register const struct egp_packet *egp;
register int status;
@@ -222,25 +216,25 @@ egp_print(register const u_int8_t *bp, register u_int length)
register int type;
egp = (struct egp_packet *)bp;
- if (!TTEST2(*egp, length)) {
- printf("[|egp]");
+ if (!ND_TTEST2(*egp, length)) {
+ ND_PRINT((ndo, "[|egp]"));
return;
}
- if (!vflag) {
- printf("EGPv%u, AS %u, seq %u, length %u",
+ if (!ndo->ndo_vflag) {
+ ND_PRINT((ndo, "EGPv%u, AS %u, seq %u, length %u",
egp->egp_version,
EXTRACT_16BITS(&egp->egp_as),
EXTRACT_16BITS(&egp->egp_sequence),
- length);
+ length));
return;
} else
- printf("EGPv%u, length %u",
+ ND_PRINT((ndo, "EGPv%u, length %u",
egp->egp_version,
- length);
+ length));
if (egp->egp_version != EGP_VERSION) {
- printf("[version %d]", egp->egp_version);
+ ND_PRINT((ndo, "[version %d]", egp->egp_version));
return;
}
@@ -250,31 +244,31 @@ egp_print(register const u_int8_t *bp, register u_int length)
switch (type) {
case EGPT_ACQUIRE:
- printf(" acquire");
+ ND_PRINT((ndo, " acquire"));
switch (code) {
case EGPC_REQUEST:
case EGPC_CONFIRM:
- printf(" %s", egp_acquire_codes[code]);
+ ND_PRINT((ndo, " %s", egp_acquire_codes[code]));
switch (status) {
case EGPS_UNSPEC:
case EGPS_ACTIVE:
case EGPS_PASSIVE:
- printf(" %s", egp_acquire_status[status]);
+ ND_PRINT((ndo, " %s", egp_acquire_status[status]));
break;
default:
- printf(" [status %d]", status);
+ ND_PRINT((ndo, " [status %d]", status));
break;
}
- printf(" hello:%d poll:%d",
+ ND_PRINT((ndo, " hello:%d poll:%d",
EXTRACT_16BITS(&egp->egp_hello),
- EXTRACT_16BITS(&egp->egp_poll));
+ EXTRACT_16BITS(&egp->egp_poll)));
break;
case EGPC_REFUSE:
case EGPC_CEASE:
case EGPC_CEASEACK:
- printf(" %s", egp_acquire_codes[code]);
+ ND_PRINT((ndo, " %s", egp_acquire_codes[code]));
switch (status ) {
case EGPS_UNSPEC:
case EGPS_NORES:
@@ -282,17 +276,17 @@ egp_print(register const u_int8_t *bp, register u_int length)
case EGPS_GODOWN:
case EGPS_PARAM:
case EGPS_PROTO:
- printf(" %s", egp_acquire_status[status]);
+ ND_PRINT((ndo, " %s", egp_acquire_status[status]));
break;
default:
- printf("[status %d]", status);
+ ND_PRINT((ndo, "[status %d]", status));
break;
}
break;
default:
- printf("[code %d]", code);
+ ND_PRINT((ndo, "[code %d]", code));
break;
}
break;
@@ -302,61 +296,61 @@ egp_print(register const u_int8_t *bp, register u_int length)
case EGPC_HELLO:
case EGPC_HEARDU:
- printf(" %s", egp_reach_codes[code]);
+ ND_PRINT((ndo, " %s", egp_reach_codes[code]));
if (status <= EGPS_DOWN)
- printf(" state:%s", egp_status_updown[status]);
+ ND_PRINT((ndo, " state:%s", egp_status_updown[status]));
else
- printf(" [status %d]", status);
+ ND_PRINT((ndo, " [status %d]", status));
break;
default:
- printf("[reach code %d]", code);
+ ND_PRINT((ndo, "[reach code %d]", code));
break;
}
break;
case EGPT_POLL:
- printf(" poll");
+ ND_PRINT((ndo, " poll"));
if (egp->egp_status <= EGPS_DOWN)
- printf(" state:%s", egp_status_updown[status]);
+ ND_PRINT((ndo, " state:%s", egp_status_updown[status]));
else
- printf(" [status %d]", status);
- printf(" net:%s", ipaddr_string(&egp->egp_sourcenet));
+ ND_PRINT((ndo, " [status %d]", status));
+ ND_PRINT((ndo, " net:%s", ipaddr_string(ndo, &egp->egp_sourcenet)));
break;
case EGPT_UPDATE:
- printf(" update");
+ ND_PRINT((ndo, " update"));
if (status & EGPS_UNSOL) {
status &= ~EGPS_UNSOL;
- printf(" unsolicited");
+ ND_PRINT((ndo, " unsolicited"));
}
if (status <= EGPS_DOWN)
- printf(" state:%s", egp_status_updown[status]);
+ ND_PRINT((ndo, " state:%s", egp_status_updown[status]));
else
- printf(" [status %d]", status);
- printf(" %s int %d ext %d",
- ipaddr_string(&egp->egp_sourcenet),
+ ND_PRINT((ndo, " [status %d]", status));
+ ND_PRINT((ndo, " %s int %d ext %d",
+ ipaddr_string(ndo, &egp->egp_sourcenet),
egp->egp_intgw,
- egp->egp_extgw);
- if (vflag)
- egpnrprint(egp);
+ egp->egp_extgw));
+ if (ndo->ndo_vflag)
+ egpnrprint(ndo, egp);
break;
case EGPT_ERROR:
- printf(" error");
+ ND_PRINT((ndo, " error"));
if (status <= EGPS_DOWN)
- printf(" state:%s", egp_status_updown[status]);
+ ND_PRINT((ndo, " state:%s", egp_status_updown[status]));
else
- printf(" [status %d]", status);
+ ND_PRINT((ndo, " [status %d]", status));
if (EXTRACT_16BITS(&egp->egp_reason) <= EGPR_UVERSION)
- printf(" %s", egp_reasons[EXTRACT_16BITS(&egp->egp_reason)]);
+ ND_PRINT((ndo, " %s", egp_reasons[EXTRACT_16BITS(&egp->egp_reason)]));
else
- printf(" [reason %d]", EXTRACT_16BITS(&egp->egp_reason));
+ ND_PRINT((ndo, " [reason %d]", EXTRACT_16BITS(&egp->egp_reason)));
break;
default:
- printf("[type %d]", type);
+ ND_PRINT((ndo, "[type %d]", type));
break;
}
}
diff --git a/contrib/tcpdump/print-eigrp.c b/contrib/tcpdump/print-eigrp.c
index 4f941d96629e..a3feb8ef4a7c 100644
--- a/contrib/tcpdump/print-eigrp.c
+++ b/contrib/tcpdump/print-eigrp.c
@@ -14,19 +14,13 @@
* FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-eigrp.c,v 1.7 2005-05-06 02:53:26 guy Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
#include "interface.h"
@@ -39,13 +33,13 @@ static const char rcsid[] _U_ =
*/
struct eigrp_common_header {
- u_int8_t version;
- u_int8_t opcode;
- u_int8_t checksum[2];
- u_int8_t flags[4];
- u_int8_t seq[4];
- u_int8_t ack[4];
- u_int8_t asn[4];
+ uint8_t version;
+ uint8_t opcode;
+ uint8_t checksum[2];
+ uint8_t flags[4];
+ uint8_t seq[4];
+ uint8_t ack[4];
+ uint8_t asn[4];
};
#define EIGRP_VERSION 2
@@ -74,8 +68,8 @@ static const struct tok eigrp_common_header_flag_values[] = {
};
struct eigrp_tlv_header {
- u_int8_t type[2];
- u_int8_t length[2];
+ uint8_t type[2];
+ uint8_t length[2];
};
#define EIGRP_TLV_GENERAL_PARM 0x0001
@@ -108,91 +102,91 @@ static const struct tok eigrp_tlv_values[] = {
};
struct eigrp_tlv_general_parm_t {
- u_int8_t k1;
- u_int8_t k2;
- u_int8_t k3;
- u_int8_t k4;
- u_int8_t k5;
- u_int8_t res;
- u_int8_t holdtime[2];
-};
+ uint8_t k1;
+ uint8_t k2;
+ uint8_t k3;
+ uint8_t k4;
+ uint8_t k5;
+ uint8_t res;
+ uint8_t holdtime[2];
+};
struct eigrp_tlv_sw_version_t {
- u_int8_t ios_major;
- u_int8_t ios_minor;
- u_int8_t eigrp_major;
- u_int8_t eigrp_minor;
-};
+ uint8_t ios_major;
+ uint8_t ios_minor;
+ uint8_t eigrp_major;
+ uint8_t eigrp_minor;
+};
struct eigrp_tlv_ip_int_t {
- u_int8_t nexthop[4];
- u_int8_t delay[4];
- u_int8_t bandwidth[4];
- u_int8_t mtu[3];
- u_int8_t hopcount;
- u_int8_t reliability;
- u_int8_t load;
- u_int8_t reserved[2];
- u_int8_t plen;
- u_int8_t destination; /* variable length [1-4] bytes encoding */
-};
+ uint8_t nexthop[4];
+ uint8_t delay[4];
+ uint8_t bandwidth[4];
+ uint8_t mtu[3];
+ uint8_t hopcount;
+ uint8_t reliability;
+ uint8_t load;
+ uint8_t reserved[2];
+ uint8_t plen;
+ uint8_t destination; /* variable length [1-4] bytes encoding */
+};
struct eigrp_tlv_ip_ext_t {
- u_int8_t nexthop[4];
- u_int8_t origin_router[4];
- u_int8_t origin_as[4];
- u_int8_t tag[4];
- u_int8_t metric[4];
- u_int8_t reserved[2];
- u_int8_t proto_id;
- u_int8_t flags;
- u_int8_t delay[4];
- u_int8_t bandwidth[4];
- u_int8_t mtu[3];
- u_int8_t hopcount;
- u_int8_t reliability;
- u_int8_t load;
- u_int8_t reserved2[2];
- u_int8_t plen;
- u_int8_t destination; /* variable length [1-4] bytes encoding */
-};
+ uint8_t nexthop[4];
+ uint8_t origin_router[4];
+ uint8_t origin_as[4];
+ uint8_t tag[4];
+ uint8_t metric[4];
+ uint8_t reserved[2];
+ uint8_t proto_id;
+ uint8_t flags;
+ uint8_t delay[4];
+ uint8_t bandwidth[4];
+ uint8_t mtu[3];
+ uint8_t hopcount;
+ uint8_t reliability;
+ uint8_t load;
+ uint8_t reserved2[2];
+ uint8_t plen;
+ uint8_t destination; /* variable length [1-4] bytes encoding */
+};
struct eigrp_tlv_at_cable_setup_t {
- u_int8_t cable_start[2];
- u_int8_t cable_end[2];
- u_int8_t router_id[4];
+ uint8_t cable_start[2];
+ uint8_t cable_end[2];
+ uint8_t router_id[4];
};
struct eigrp_tlv_at_int_t {
- u_int8_t nexthop[4];
- u_int8_t delay[4];
- u_int8_t bandwidth[4];
- u_int8_t mtu[3];
- u_int8_t hopcount;
- u_int8_t reliability;
- u_int8_t load;
- u_int8_t reserved[2];
- u_int8_t cable_start[2];
- u_int8_t cable_end[2];
-};
+ uint8_t nexthop[4];
+ uint8_t delay[4];
+ uint8_t bandwidth[4];
+ uint8_t mtu[3];
+ uint8_t hopcount;
+ uint8_t reliability;
+ uint8_t load;
+ uint8_t reserved[2];
+ uint8_t cable_start[2];
+ uint8_t cable_end[2];
+};
struct eigrp_tlv_at_ext_t {
- u_int8_t nexthop[4];
- u_int8_t origin_router[4];
- u_int8_t origin_as[4];
- u_int8_t tag[4];
- u_int8_t proto_id;
- u_int8_t flags;
- u_int8_t metric[2];
- u_int8_t delay[4];
- u_int8_t bandwidth[4];
- u_int8_t mtu[3];
- u_int8_t hopcount;
- u_int8_t reliability;
- u_int8_t load;
- u_int8_t reserved2[2];
- u_int8_t cable_start[2];
- u_int8_t cable_end[2];
+ uint8_t nexthop[4];
+ uint8_t origin_router[4];
+ uint8_t origin_as[4];
+ uint8_t tag[4];
+ uint8_t proto_id;
+ uint8_t flags;
+ uint8_t metric[2];
+ uint8_t delay[4];
+ uint8_t bandwidth[4];
+ uint8_t mtu[3];
+ uint8_t hopcount;
+ uint8_t reliability;
+ uint8_t load;
+ uint8_t reserved2[2];
+ uint8_t cable_start[2];
+ uint8_t cable_end[2];
};
static const struct tok eigrp_ext_proto_id_values[] = {
@@ -211,13 +205,13 @@ static const struct tok eigrp_ext_proto_id_values[] = {
};
void
-eigrp_print(register const u_char *pptr, register u_int len) {
+eigrp_print(netdissect_options *ndo, register const u_char *pptr, register u_int len) {
const struct eigrp_common_header *eigrp_com_header;
const struct eigrp_tlv_header *eigrp_tlv_header;
const u_char *tptr,*tlv_tptr;
u_int tlen,eigrp_tlv_len,eigrp_tlv_type,tlv_tlen, byte_length, bit_length;
- u_int8_t prefix[4];
+ uint8_t prefix[4];
union {
const struct eigrp_tlv_general_parm_t *eigrp_tlv_general_parm;
@@ -231,21 +225,21 @@ eigrp_print(register const u_char *pptr, register u_int len) {
tptr=pptr;
eigrp_com_header = (const struct eigrp_common_header *)pptr;
- TCHECK(*eigrp_com_header);
+ ND_TCHECK(*eigrp_com_header);
/*
* Sanity checking of the header.
*/
if (eigrp_com_header->version != EIGRP_VERSION) {
- printf("EIGRP version %u packet not supported",eigrp_com_header->version);
+ ND_PRINT((ndo, "EIGRP version %u packet not supported",eigrp_com_header->version));
return;
}
/* in non-verbose mode just lets print the basic Message Type*/
- if (vflag < 1) {
- printf("EIGRP %s, length: %u",
+ if (ndo->ndo_vflag < 1) {
+ ND_PRINT((ndo, "EIGRP %s, length: %u",
tok2str(eigrp_opcode_values, "unknown (%u)",eigrp_com_header->opcode),
- len);
+ len));
return;
}
@@ -254,7 +248,7 @@ eigrp_print(register const u_char *pptr, register u_int len) {
tlen=len-sizeof(struct eigrp_common_header);
/* FIXME print other header info */
- printf("\n\tEIGRP v%u, opcode: %s (%u), chksum: 0x%04x, Flags: [%s]\n\tseq: 0x%08x, ack: 0x%08x, AS: %u, length: %u",
+ ND_PRINT((ndo, "\n\tEIGRP v%u, opcode: %s (%u), chksum: 0x%04x, Flags: [%s]\n\tseq: 0x%08x, ack: 0x%08x, AS: %u, length: %u",
eigrp_com_header->version,
tok2str(eigrp_opcode_values, "unknown, type: %u",eigrp_com_header->opcode),
eigrp_com_header->opcode,
@@ -265,13 +259,13 @@ eigrp_print(register const u_char *pptr, register u_int len) {
EXTRACT_32BITS(&eigrp_com_header->seq),
EXTRACT_32BITS(&eigrp_com_header->ack),
EXTRACT_32BITS(&eigrp_com_header->asn),
- tlen);
+ tlen));
tptr+=sizeof(const struct eigrp_common_header);
while(tlen>0) {
/* did we capture enough for fully decoding the object header ? */
- TCHECK2(*tptr, sizeof(struct eigrp_tlv_header));
+ ND_TCHECK2(*tptr, sizeof(struct eigrp_tlv_header));
eigrp_tlv_header = (const struct eigrp_tlv_header *)tptr;
eigrp_tlv_len=EXTRACT_16BITS(&eigrp_tlv_header->length);
@@ -280,45 +274,45 @@ eigrp_print(register const u_char *pptr, register u_int len) {
if (eigrp_tlv_len < sizeof(struct eigrp_tlv_header) ||
eigrp_tlv_len > tlen) {
- print_unknown_data(tptr+sizeof(struct eigrp_tlv_header),"\n\t ",tlen);
+ print_unknown_data(ndo,tptr+sizeof(struct eigrp_tlv_header),"\n\t ",tlen);
return;
}
- printf("\n\t %s TLV (0x%04x), length: %u",
+ ND_PRINT((ndo, "\n\t %s TLV (0x%04x), length: %u",
tok2str(eigrp_tlv_values,
"Unknown",
eigrp_tlv_type),
eigrp_tlv_type,
- eigrp_tlv_len);
+ eigrp_tlv_len));
tlv_tptr=tptr+sizeof(struct eigrp_tlv_header);
tlv_tlen=eigrp_tlv_len-sizeof(struct eigrp_tlv_header);
/* did we capture enough for fully decoding the object ? */
- TCHECK2(*tptr, eigrp_tlv_len);
+ ND_TCHECK2(*tptr, eigrp_tlv_len);
switch(eigrp_tlv_type) {
case EIGRP_TLV_GENERAL_PARM:
tlv_ptr.eigrp_tlv_general_parm = (const struct eigrp_tlv_general_parm_t *)tlv_tptr;
- printf("\n\t holdtime: %us, k1 %u, k2 %u, k3 %u, k4 %u, k5 %u",
+ ND_PRINT((ndo, "\n\t holdtime: %us, k1 %u, k2 %u, k3 %u, k4 %u, k5 %u",
EXTRACT_16BITS(tlv_ptr.eigrp_tlv_general_parm->holdtime),
tlv_ptr.eigrp_tlv_general_parm->k1,
tlv_ptr.eigrp_tlv_general_parm->k2,
tlv_ptr.eigrp_tlv_general_parm->k3,
tlv_ptr.eigrp_tlv_general_parm->k4,
- tlv_ptr.eigrp_tlv_general_parm->k5);
+ tlv_ptr.eigrp_tlv_general_parm->k5));
break;
case EIGRP_TLV_SW_VERSION:
tlv_ptr.eigrp_tlv_sw_version = (const struct eigrp_tlv_sw_version_t *)tlv_tptr;
- printf("\n\t IOS version: %u.%u, EIGRP version %u.%u",
+ ND_PRINT((ndo, "\n\t IOS version: %u.%u, EIGRP version %u.%u",
tlv_ptr.eigrp_tlv_sw_version->ios_major,
tlv_ptr.eigrp_tlv_sw_version->ios_minor,
tlv_ptr.eigrp_tlv_sw_version->eigrp_major,
- tlv_ptr.eigrp_tlv_sw_version->eigrp_minor);
+ tlv_ptr.eigrp_tlv_sw_version->eigrp_minor));
break;
case EIGRP_TLV_IP_INT:
@@ -326,28 +320,28 @@ eigrp_print(register const u_char *pptr, register u_int len) {
bit_length = tlv_ptr.eigrp_tlv_ip_int->plen;
if (bit_length > 32) {
- printf("\n\t illegal prefix length %u",bit_length);
+ ND_PRINT((ndo, "\n\t illegal prefix length %u",bit_length));
break;
}
byte_length = (bit_length + 7) / 8; /* variable length encoding */
memset(prefix, 0, 4);
memcpy(prefix,&tlv_ptr.eigrp_tlv_ip_int->destination,byte_length);
- printf("\n\t IPv4 prefix: %15s/%u, nexthop: ",
- ipaddr_string(prefix),
- bit_length);
+ ND_PRINT((ndo, "\n\t IPv4 prefix: %15s/%u, nexthop: ",
+ ipaddr_string(ndo, prefix),
+ bit_length));
if (EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_ip_int->nexthop) == 0)
- printf("self");
+ ND_PRINT((ndo, "self"));
else
- printf("%s",ipaddr_string(&tlv_ptr.eigrp_tlv_ip_int->nexthop));
+ ND_PRINT((ndo, "%s",ipaddr_string(ndo, &tlv_ptr.eigrp_tlv_ip_int->nexthop)));
- printf("\n\t delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u",
+ ND_PRINT((ndo, "\n\t delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u",
(EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_ip_int->delay)/100),
EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_ip_int->bandwidth),
EXTRACT_24BITS(&tlv_ptr.eigrp_tlv_ip_int->mtu),
tlv_ptr.eigrp_tlv_ip_int->hopcount,
tlv_ptr.eigrp_tlv_ip_int->reliability,
- tlv_ptr.eigrp_tlv_ip_int->load);
+ tlv_ptr.eigrp_tlv_ip_int->load));
break;
case EIGRP_TLV_IP_EXT:
@@ -355,99 +349,99 @@ eigrp_print(register const u_char *pptr, register u_int len) {
bit_length = tlv_ptr.eigrp_tlv_ip_ext->plen;
if (bit_length > 32) {
- printf("\n\t illegal prefix length %u",bit_length);
+ ND_PRINT((ndo, "\n\t illegal prefix length %u",bit_length));
break;
}
byte_length = (bit_length + 7) / 8; /* variable length encoding */
memset(prefix, 0, 4);
memcpy(prefix,&tlv_ptr.eigrp_tlv_ip_ext->destination,byte_length);
- printf("\n\t IPv4 prefix: %15s/%u, nexthop: ",
- ipaddr_string(prefix),
- bit_length);
+ ND_PRINT((ndo, "\n\t IPv4 prefix: %15s/%u, nexthop: ",
+ ipaddr_string(ndo, prefix),
+ bit_length));
if (EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_ip_ext->nexthop) == 0)
- printf("self");
+ ND_PRINT((ndo, "self"));
else
- printf("%s",ipaddr_string(&tlv_ptr.eigrp_tlv_ip_ext->nexthop));
+ ND_PRINT((ndo, "%s",ipaddr_string(ndo, &tlv_ptr.eigrp_tlv_ip_ext->nexthop)));
- printf("\n\t origin-router %s, origin-as %u, origin-proto %s, flags [0x%02x], tag 0x%08x, metric %u",
- ipaddr_string(tlv_ptr.eigrp_tlv_ip_ext->origin_router),
+ ND_PRINT((ndo, "\n\t origin-router %s, origin-as %u, origin-proto %s, flags [0x%02x], tag 0x%08x, metric %u",
+ ipaddr_string(ndo, tlv_ptr.eigrp_tlv_ip_ext->origin_router),
EXTRACT_32BITS(tlv_ptr.eigrp_tlv_ip_ext->origin_as),
tok2str(eigrp_ext_proto_id_values,"unknown",tlv_ptr.eigrp_tlv_ip_ext->proto_id),
tlv_ptr.eigrp_tlv_ip_ext->flags,
EXTRACT_32BITS(tlv_ptr.eigrp_tlv_ip_ext->tag),
- EXTRACT_32BITS(tlv_ptr.eigrp_tlv_ip_ext->metric));
+ EXTRACT_32BITS(tlv_ptr.eigrp_tlv_ip_ext->metric)));
- printf("\n\t delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u",
+ ND_PRINT((ndo, "\n\t delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u",
(EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_ip_ext->delay)/100),
EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_ip_ext->bandwidth),
EXTRACT_24BITS(&tlv_ptr.eigrp_tlv_ip_ext->mtu),
tlv_ptr.eigrp_tlv_ip_ext->hopcount,
tlv_ptr.eigrp_tlv_ip_ext->reliability,
- tlv_ptr.eigrp_tlv_ip_ext->load);
+ tlv_ptr.eigrp_tlv_ip_ext->load));
break;
case EIGRP_TLV_AT_CABLE_SETUP:
tlv_ptr.eigrp_tlv_at_cable_setup = (const struct eigrp_tlv_at_cable_setup_t *)tlv_tptr;
- printf("\n\t Cable-range: %u-%u, Router-ID %u",
+ ND_PRINT((ndo, "\n\t Cable-range: %u-%u, Router-ID %u",
EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_cable_setup->cable_start),
EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_cable_setup->cable_end),
- EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_at_cable_setup->router_id));
+ EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_at_cable_setup->router_id)));
break;
case EIGRP_TLV_AT_INT:
tlv_ptr.eigrp_tlv_at_int = (const struct eigrp_tlv_at_int_t *)tlv_tptr;
- printf("\n\t Cable-Range: %u-%u, nexthop: ",
+ ND_PRINT((ndo, "\n\t Cable-Range: %u-%u, nexthop: ",
EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_int->cable_start),
- EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_int->cable_end));
+ EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_int->cable_end)));
if (EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_at_int->nexthop) == 0)
- printf("self");
+ ND_PRINT((ndo, "self"));
else
- printf("%u.%u",
+ ND_PRINT((ndo, "%u.%u",
EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_int->nexthop),
- EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_int->nexthop[2]));
+ EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_int->nexthop[2])));
- printf("\n\t delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u",
+ ND_PRINT((ndo, "\n\t delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u",
(EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_at_int->delay)/100),
EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_at_int->bandwidth),
EXTRACT_24BITS(&tlv_ptr.eigrp_tlv_at_int->mtu),
tlv_ptr.eigrp_tlv_at_int->hopcount,
tlv_ptr.eigrp_tlv_at_int->reliability,
- tlv_ptr.eigrp_tlv_at_int->load);
+ tlv_ptr.eigrp_tlv_at_int->load));
break;
case EIGRP_TLV_AT_EXT:
tlv_ptr.eigrp_tlv_at_ext = (const struct eigrp_tlv_at_ext_t *)tlv_tptr;
- printf("\n\t Cable-Range: %u-%u, nexthop: ",
+ ND_PRINT((ndo, "\n\t Cable-Range: %u-%u, nexthop: ",
EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_ext->cable_start),
- EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_ext->cable_end));
+ EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_ext->cable_end)));
if (EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_at_ext->nexthop) == 0)
- printf("self");
+ ND_PRINT((ndo, "self"));
else
- printf("%u.%u",
+ ND_PRINT((ndo, "%u.%u",
EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_ext->nexthop),
- EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_ext->nexthop[2]));
+ EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_ext->nexthop[2])));
- printf("\n\t origin-router %u, origin-as %u, origin-proto %s, flags [0x%02x], tag 0x%08x, metric %u",
+ ND_PRINT((ndo, "\n\t origin-router %u, origin-as %u, origin-proto %s, flags [0x%02x], tag 0x%08x, metric %u",
EXTRACT_32BITS(tlv_ptr.eigrp_tlv_at_ext->origin_router),
EXTRACT_32BITS(tlv_ptr.eigrp_tlv_at_ext->origin_as),
tok2str(eigrp_ext_proto_id_values,"unknown",tlv_ptr.eigrp_tlv_at_ext->proto_id),
tlv_ptr.eigrp_tlv_at_ext->flags,
EXTRACT_32BITS(tlv_ptr.eigrp_tlv_at_ext->tag),
- EXTRACT_16BITS(tlv_ptr.eigrp_tlv_at_ext->metric));
+ EXTRACT_16BITS(tlv_ptr.eigrp_tlv_at_ext->metric)));
- printf("\n\t delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u",
+ ND_PRINT((ndo, "\n\t delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u",
(EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_at_ext->delay)/100),
EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_at_ext->bandwidth),
EXTRACT_24BITS(&tlv_ptr.eigrp_tlv_at_ext->mtu),
tlv_ptr.eigrp_tlv_at_ext->hopcount,
tlv_ptr.eigrp_tlv_at_ext->reliability,
- tlv_ptr.eigrp_tlv_at_ext->load);
+ tlv_ptr.eigrp_tlv_at_ext->load));
break;
/*
@@ -462,13 +456,13 @@ eigrp_print(register const u_char *pptr, register u_int len) {
case EIGRP_TLV_IPX_EXT:
default:
- if (vflag <= 1)
- print_unknown_data(tlv_tptr,"\n\t ",tlv_tlen);
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo,tlv_tptr,"\n\t ",tlv_tlen);
break;
}
/* do we want to see an additionally hexdump ? */
- if (vflag > 1)
- print_unknown_data(tptr+sizeof(struct eigrp_tlv_header),"\n\t ",
+ if (ndo->ndo_vflag > 1)
+ print_unknown_data(ndo,tptr+sizeof(struct eigrp_tlv_header),"\n\t ",
eigrp_tlv_len-sizeof(struct eigrp_tlv_header));
tptr+=eigrp_tlv_len;
@@ -476,5 +470,5 @@ eigrp_print(register const u_char *pptr, register u_int len) {
}
return;
trunc:
- printf("\n\t\t packet exceeded snapshot");
+ ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
}
diff --git a/contrib/tcpdump/print-enc.c b/contrib/tcpdump/print-enc.c
index 5c01f3ef7b61..89daae1bb4a3 100644
--- a/contrib/tcpdump/print-enc.c
+++ b/contrib/tcpdump/print-enc.c
@@ -21,33 +21,72 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-enc.c,v 1.6 2008-11-18 07:35:32 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <pcap.h>
-
#include "interface.h"
#include "extract.h"
-#include "addrtoname.h"
-#include "enc.h"
+/* From $OpenBSD: if_enc.h,v 1.8 2001/06/25 05:14:00 angelos Exp $ */
+/*
+ * The authors of this code are John Ioannidis (ji@tla.org),
+ * Angelos D. Keromytis (kermit@csd.uch.gr) and
+ * Niels Provos (provos@physnet.uni-hamburg.de).
+ *
+ * This code was written by John Ioannidis for BSD/OS in Athens, Greece,
+ * in November 1995.
+ *
+ * Ported to OpenBSD and NetBSD, with additional transforms, in December 1996,
+ * by Angelos D. Keromytis.
+ *
+ * Additional transforms and features in 1997 and 1998 by Angelos D. Keromytis
+ * and Niels Provos.
+ *
+ * Copyright (C) 1995, 1996, 1997, 1998 by John Ioannidis, Angelos D. Keromytis
+ * and Niels Provos.
+ * Copyright (c) 2001, Angelos D. Keromytis.
+ *
+ * Permission to use, copy, and modify this software with or without fee
+ * is hereby granted, provided that this entire notice is included in
+ * all copies of any software which is or includes a copy or
+ * modification of this software.
+ * You may use this code under the GNU public license if you so wish. Please
+ * contribute changes back to the authors under this freer than GPL license
+ * so that we may further the use of strong encryption without limitations to
+ * all.
+ *
+ * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY
+ * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
+ * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
+ * PURPOSE.
+ */
+
+#define ENC_HDRLEN 12
+
+/* From $OpenBSD: mbuf.h,v 1.56 2002/01/25 15:50:23 art Exp $ */
+#define M_CONF 0x0400 /* packet was encrypted (ESP-transport) */
+#define M_AUTH 0x0800 /* packet was authenticated (AH) */
+
+struct enchdr {
+ uint32_t af;
+ uint32_t spi;
+ uint32_t flags;
+};
#define ENC_PRINT_TYPE(wh, xf, nam) \
if ((wh) & (xf)) { \
- printf("%s%s", nam, (wh) == (xf) ? "): " : ","); \
+ ND_PRINT((ndo, "%s%s", nam, (wh) == (xf) ? "): " : ",")); \
(wh) &= ~(xf); \
}
u_int
-enc_if_print(const struct pcap_pkthdr *h, register const u_char *p)
+enc_if_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, register const u_char *p)
{
register u_int length = h->len;
register u_int caplen = h->caplen;
@@ -55,32 +94,32 @@ enc_if_print(const struct pcap_pkthdr *h, register const u_char *p)
const struct enchdr *hdr;
if (caplen < ENC_HDRLEN) {
- printf("[|enc]");
+ ND_PRINT((ndo, "[|enc]"));
goto out;
}
hdr = (struct enchdr *)p;
flags = hdr->flags;
if (flags == 0)
- printf("(unprotected): ");
+ ND_PRINT((ndo, "(unprotected): "));
else
- printf("(");
+ ND_PRINT((ndo, "("));
ENC_PRINT_TYPE(flags, M_AUTH, "authentic");
ENC_PRINT_TYPE(flags, M_CONF, "confidential");
/* ENC_PRINT_TYPE(flags, M_TUNNEL, "tunnel"); */
- printf("SPI 0x%08x: ", EXTRACT_32BITS(&hdr->spi));
+ ND_PRINT((ndo, "SPI 0x%08x: ", EXTRACT_32BITS(&hdr->spi)));
length -= ENC_HDRLEN;
caplen -= ENC_HDRLEN;
p += ENC_HDRLEN;
-
+
switch (hdr->af) {
case AF_INET:
- ip_print(gndo, p, length);
+ ip_print(ndo, p, length);
break;
#ifdef INET6
case AF_INET6:
- ip6_print(gndo, p, length);
+ ip6_print(ndo, p, length);
break;
#endif /*INET6*/
}
diff --git a/contrib/tcpdump/print-esp.c b/contrib/tcpdump/print-esp.c
index ade654a33709..8e267d45cdf9 100644
--- a/contrib/tcpdump/print-esp.c
+++ b/contrib/tcpdump/print-esp.c
@@ -21,57 +21,92 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-esp.c,v 1.58 2007-12-07 00:03:07 mcr Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <string.h>
-
#include <tcpdump-stdinc.h>
+#include <string.h>
#include <stdlib.h>
+/* Any code in this file that depends on HAVE_LIBCRYPTO depends on
+ * HAVE_OPENSSL_EVP_H too. Undefining the former when the latter isn't defined
+ * is the simplest way of handling the dependency.
+ */
#ifdef HAVE_LIBCRYPTO
#ifdef HAVE_OPENSSL_EVP_H
#include <openssl/evp.h>
+#else
+#undef HAVE_LIBCRYPTO
#endif
#endif
-#include <stdio.h>
-
#include "ip.h"
-#include "esp.h"
#ifdef INET6
#include "ip6.h"
#endif
-#include "netdissect.h"
-#include "addrtoname.h"
+#include "interface.h"
#include "extract.h"
-#ifndef HAVE_SOCKADDR_STORAGE
-#ifdef INET6
-struct sockaddr_storage {
- union {
- struct sockaddr_in sin;
- struct sockaddr_in6 sin6;
- } un;
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * RFC1827/2406 Encapsulated Security Payload.
+ */
+
+struct newesp {
+ uint32_t esp_spi; /* ESP */
+ uint32_t esp_seq; /* Sequence number */
+ /*variable size*/ /* (IV and) Payload data */
+ /*variable size*/ /* padding */
+ /*8bit*/ /* pad size */
+ /*8bit*/ /* next header */
+ /*8bit*/ /* next header */
+ /*variable size, 32bit bound*/ /* Authentication data */
};
-#else
-#define sockaddr_storage sockaddr
-#endif
-#endif /* HAVE_SOCKADDR_STORAGE */
#ifdef HAVE_LIBCRYPTO
+union inaddr_u {
+ struct in_addr in4;
+#ifdef INET6
+ struct in6_addr in6;
+#endif
+};
struct sa_list {
struct sa_list *next;
- struct sockaddr_storage daddr;
- u_int32_t spi; /* if == 0, then IKEv2 */
+ u_int daddr_version;
+ union inaddr_u daddr;
+ uint32_t spi; /* if == 0, then IKEv2 */
int initiator;
u_char spii[8]; /* for IKEv2 */
u_char spir[8];
@@ -87,6 +122,7 @@ struct sa_list {
/*
* this will adjust ndo_packetp and ndo_snapend to new buffer!
*/
+USES_APPLE_DEPRECATED_API
int esp_print_decrypt_buffer_by_ikev2(netdissect_options *ndo,
int initiator,
u_char spii[8], u_char spir[8],
@@ -99,7 +135,7 @@ int esp_print_decrypt_buffer_by_ikev2(netdissect_options *ndo,
/* initiator arg is any non-zero value */
if(initiator) initiator=1;
-
+
/* see if we can find the SA, and if so, decode it */
for (sa = ndo->ndo_sa_list_head; sa != NULL; sa = sa->next) {
if (sa->spi == 0
@@ -134,8 +170,9 @@ int esp_print_decrypt_buffer_by_ikev2(netdissect_options *ndo,
ndo->ndo_snapend = end;
return 1;
-
+
}
+USES_APPLE_RST
static void esp_print_addsa(netdissect_options *ndo,
struct sa_list *sa, int sa_def)
@@ -192,12 +229,12 @@ int espprint_decode_hex(netdissect_options *ndo,
int i;
len = strlen(hex) / 2;
-
+
if (len > binbuf_len) {
(*ndo->ndo_warning)(ndo, "secret is too big: %d\n", len);
return 0;
}
-
+
i = 0;
while (hex[0] != '\0' && hex[1]!='\0') {
binbuf[i] = hex2byte(ndo, hex);
@@ -212,24 +249,23 @@ int espprint_decode_hex(netdissect_options *ndo,
* decode the form: SPINUM@IP <tab> ALGONAME:0xsecret
*/
+USES_APPLE_DEPRECATED_API
static int
espprint_decode_encalgo(netdissect_options *ndo,
char *decode, struct sa_list *sa)
{
- int len;
size_t i;
const EVP_CIPHER *evp;
int authlen = 0;
char *colon, *p;
-
+
colon = strchr(decode, ':');
if (colon == NULL) {
(*ndo->ndo_warning)(ndo, "failed to decode espsecret: %s\n", decode);
return 0;
}
*colon = '\0';
-
- len = colon - decode;
+
if (strlen(decode) > strlen("-hmac96") &&
!strcmp(decode + strlen(decode) - strlen("-hmac96"),
"-hmac96")) {
@@ -251,11 +287,11 @@ espprint_decode_encalgo(netdissect_options *ndo,
sa->ivlen = 0;
return 0;
}
-
+
sa->evp = evp;
sa->authlen = authlen;
sa->ivlen = EVP_CIPHER_iv_length(evp);
-
+
colon++;
if (colon[0] == '0' && colon[1] == 'x') {
/* decode some hex! */
@@ -265,7 +301,7 @@ espprint_decode_encalgo(netdissect_options *ndo,
if(sa->secretlen == 0) return 0;
} else {
i = strlen(colon);
-
+
if (i < sizeof(sa->secret)) {
memcpy(sa->secret, colon, i);
sa->secretlen = i;
@@ -277,6 +313,7 @@ espprint_decode_encalgo(netdissect_options *ndo,
return 1;
}
+USES_APPLE_RST
/*
* for the moment, ignore the auth algorith, just hard code the authenticator
@@ -294,7 +331,7 @@ espprint_decode_authalgo(netdissect_options *ndo,
return 0;
}
*colon = '\0';
-
+
if(strcasecmp(colon,"sha1") == 0 ||
strcasecmp(colon,"md5") == 0) {
sa->authlen = 12;
@@ -313,21 +350,21 @@ static void esp_print_decode_ikeline(netdissect_options *ndo, char *line,
int ilen, rlen;
char *authkey;
char *enckey;
-
+
init = strsep(&line, " \t");
icookie = strsep(&line, " \t");
rcookie = strsep(&line, " \t");
authkey = strsep(&line, " \t");
enckey = strsep(&line, " \t");
-
+
/* if any fields are missing */
if(!init || !icookie || !rcookie || !authkey || !enckey) {
(*ndo->ndo_warning)(ndo, "print_esp: failed to find all fields for ikev2 at %s:%u",
file, lineno);
-
+
return;
}
-
+
ilen = strlen(icookie);
rlen = strlen(rcookie);
@@ -341,7 +378,7 @@ static void esp_print_decode_ikeline(netdissect_options *ndo, char *line,
(*ndo->ndo_warning)(ndo, "init=%s icookie=%s(%u) rcookie=%s(%u)",
init, icookie, ilen, rcookie, rlen);
-
+
return;
}
@@ -356,7 +393,7 @@ static void esp_print_decode_ikeline(netdissect_options *ndo, char *line,
if(!espprint_decode_encalgo(ndo, enckey, &sa1)) return;
if(!espprint_decode_authalgo(ndo, authkey, &sa1)) return;
-
+
esp_print_addsa(ndo, &sa1, FALSE);
}
@@ -383,6 +420,7 @@ static void esp_print_decode_onesecret(netdissect_options *ndo, char *line,
if (line == NULL) {
decode = spikey;
spikey = NULL;
+ /* sa1.daddr.version = 0; */
/* memset(&sa1.daddr, 0, sizeof(sa1.daddr)); */
/* sa1.spi = 0; */
sa_def = 1;
@@ -422,42 +460,30 @@ static void esp_print_decode_onesecret(netdissect_options *ndo, char *line,
if (spikey && strcasecmp(spikey, "ikev2") == 0) {
esp_print_decode_ikeline(ndo, line, file, lineno);
return;
- }
+ }
if (spikey) {
-
+
char *spistr, *foo;
- u_int32_t spino;
- struct sockaddr_in *sin;
-#ifdef INET6
- struct sockaddr_in6 *sin6;
-#endif
-
+ uint32_t spino;
+
spistr = strsep(&spikey, "@");
-
+
spino = strtoul(spistr, &foo, 0);
if (spistr == foo || !spikey) {
(*ndo->ndo_warning)(ndo, "print_esp: failed to decode spi# %s\n", foo);
return;
}
-
+
sa1.spi = spino;
-
- sin = (struct sockaddr_in *)&sa1.daddr;
+
#ifdef INET6
- sin6 = (struct sockaddr_in6 *)&sa1.daddr;
- if (inet_pton(AF_INET6, spikey, &sin6->sin6_addr) == 1) {
-#ifdef HAVE_SOCKADDR_SA_LEN
- sin6->sin6_len = sizeof(struct sockaddr_in6);
-#endif
- sin6->sin6_family = AF_INET6;
+ if (inet_pton(AF_INET6, spikey, &sa1.daddr.in6) == 1) {
+ sa1.daddr_version = 6;
} else
#endif
- if (inet_pton(AF_INET, spikey, &sin->sin_addr) == 1) {
-#ifdef HAVE_SOCKADDR_SA_LEN
- sin->sin_len = sizeof(struct sockaddr_in);
-#endif
- sin->sin_family = AF_INET;
+ if (inet_pton(AF_INET, spikey, &sa1.daddr.in4) == 1) {
+ sa1.daddr_version = 4;
} else {
(*ndo->ndo_warning)(ndo, "print_esp: can not decode IP# %s\n", spikey);
return;
@@ -468,7 +494,7 @@ static void esp_print_decode_onesecret(netdissect_options *ndo, char *line,
/* skip any blank spaces */
while (isspace((unsigned char)*decode))
decode++;
-
+
if(!espprint_decode_encalgo(ndo, decode, &sa1)) {
return;
}
@@ -477,12 +503,14 @@ static void esp_print_decode_onesecret(netdissect_options *ndo, char *line,
esp_print_addsa(ndo, &sa1, sa_def);
}
+USES_APPLE_DEPRECATED_API
static void esp_init(netdissect_options *ndo _U_)
{
OpenSSL_add_all_algorithms();
EVP_add_cipher_alias(SN_des_ede3_cbc, "3des");
}
+USES_APPLE_RST
void esp_print_decodesecret(netdissect_options *ndo)
{
@@ -512,6 +540,9 @@ void esp_print_decodesecret(netdissect_options *ndo)
#endif
+#ifdef HAVE_LIBCRYPTO
+USES_APPLE_DEPRECATED_API
+#endif
int
esp_print(netdissect_options *ndo,
const u_char *bp, const int length, const u_char *bp2
@@ -535,7 +566,6 @@ esp_print(netdissect_options *ndo,
#ifdef HAVE_LIBCRYPTO
struct ip *ip;
struct sa_list *sa = NULL;
- int espsecret_keylen;
#ifdef INET6
struct ip6_hdr *ip6 = NULL;
#endif
@@ -546,7 +576,6 @@ esp_print(netdissect_options *ndo,
u_char *ivoff;
u_char *p;
EVP_CIPHER_CTX ctx;
- int blocksz;
#endif
esp = (struct newesp *)bp;
@@ -565,12 +594,12 @@ esp_print(netdissect_options *ndo,
ep = ndo->ndo_snapend;
if ((u_char *)(esp + 1) >= ep) {
- fputs("[|ESP]", stdout);
+ ND_PRINT((ndo, "[|ESP]"));
goto fail;
}
- (*ndo->ndo_printf)(ndo, "ESP(spi=0x%08x", EXTRACT_32BITS(&esp->esp_spi));
- (*ndo->ndo_printf)(ndo, ",seq=0x%x)", EXTRACT_32BITS(&esp->esp_seq));
- (*ndo->ndo_printf)(ndo, ", length %u", length);
+ ND_PRINT((ndo, "ESP(spi=0x%08x", EXTRACT_32BITS(&esp->esp_spi)));
+ ND_PRINT((ndo, ",seq=0x%x)", EXTRACT_32BITS(&esp->esp_seq)));
+ ND_PRINT((ndo, ", length %u", length));
#ifndef HAVE_LIBCRYPTO
goto fail;
@@ -599,10 +628,9 @@ esp_print(netdissect_options *ndo,
/* see if we can find the SA, and if so, decode it */
for (sa = ndo->ndo_sa_list_head; sa != NULL; sa = sa->next) {
- struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&sa->daddr;
if (sa->spi == EXTRACT_32BITS(&esp->esp_spi) &&
- sin6->sin6_family == AF_INET6 &&
- memcmp(&sin6->sin6_addr, &ip6->ip6_dst,
+ sa->daddr_version == 6 &&
+ UNALIGNED_MEMCMP(&sa->daddr.in6, &ip6->ip6_dst,
sizeof(struct in6_addr)) == 0) {
break;
}
@@ -617,10 +645,10 @@ esp_print(netdissect_options *ndo,
/* see if we can find the SA, and if so, decode it */
for (sa = ndo->ndo_sa_list_head; sa != NULL; sa = sa->next) {
- struct sockaddr_in *sin = (struct sockaddr_in *)&sa->daddr;
if (sa->spi == EXTRACT_32BITS(&esp->esp_spi) &&
- sin->sin_family == AF_INET &&
- sin->sin_addr.s_addr == ip->ip_dst.s_addr) {
+ sa->daddr_version == 4 &&
+ UNALIGNED_MEMCMP(&sa->daddr.in4, &ip->ip_dst,
+ sizeof(struct in_addr)) == 0) {
break;
}
}
@@ -634,7 +662,7 @@ esp_print(netdissect_options *ndo,
*/
if (sa == NULL)
sa = ndo->ndo_sa_default;
-
+
/* if not found fail */
if (sa == NULL)
goto fail;
@@ -650,7 +678,6 @@ esp_print(netdissect_options *ndo,
ivoff = (u_char *)(esp + 1) + 0;
ivlen = sa->ivlen;
secret = sa->secret;
- espsecret_keylen = sa->secretlen;
ep = ep - sa->authlen;
if (sa->evp) {
@@ -658,8 +685,6 @@ esp_print(netdissect_options *ndo,
if (EVP_CipherInit(&ctx, sa->evp, secret, NULL, 0) < 0)
(*ndo->ndo_warning)(ndo, "espkey init failed");
- blocksz = EVP_CIPHER_CTX_block_size(&ctx);
-
p = ivoff;
EVP_CipherInit(&ctx, NULL, NULL, p, 0);
EVP_Cipher(&ctx, p + ivlen, p + ivlen, ep - (p + ivlen));
@@ -678,13 +703,16 @@ esp_print(netdissect_options *ndo,
if (nhdr)
*nhdr = *(ep - 1);
- (ndo->ndo_printf)(ndo, ": ");
+ ND_PRINT((ndo, ": "));
return advance;
#endif
fail:
return -1;
}
+#ifdef HAVE_LIBCRYPTO
+USES_APPLE_RST
+#endif
/*
* Local Variables:
diff --git a/contrib/tcpdump/print-ether.c b/contrib/tcpdump/print-ether.c
index 22cb6478e188..8258cf1154d2 100644
--- a/contrib/tcpdump/print-ether.c
+++ b/contrib/tcpdump/print-ether.c
@@ -20,10 +20,6 @@
*
* $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.106 2008-02-06 10:47:53 guy Exp $ (LBL)";
-#endif
#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
@@ -32,16 +28,13 @@ static const char rcsid[] _U_ =
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <pcap.h>
-
#include "interface.h"
#include "extract.h"
#include "addrtoname.h"
#include "ethertype.h"
#include "ether.h"
-const struct tok ethertype_values[] = {
+const struct tok ethertype_values[] = {
{ ETHERTYPE_IP, "IPv4" },
{ ETHERTYPE_MPLS, "MPLS unicast" },
{ ETHERTYPE_MPLS_MULTI, "MPLS multicast" },
@@ -85,8 +78,13 @@ const struct tok ethertype_values[] = {
{ ETHERTYPE_GRE_ISO, "GRE-OSI" },
{ ETHERTYPE_CFM_OLD, "CFM (old)" },
{ ETHERTYPE_CFM, "CFM" },
+ { ETHERTYPE_IEEE1905_1, "IEEE1905.1" },
{ ETHERTYPE_LLDP, "LLDP" },
- { ETHERTYPE_TIPC, "TIPC"},
+ { ETHERTYPE_TIPC, "TIPC"},
+ { ETHERTYPE_GEONET_OLD, "GeoNet (old)"},
+ { ETHERTYPE_GEONET, "GeoNet"},
+ { ETHERTYPE_CALM_FAST, "CALM FAST"},
+ { ETHERTYPE_AOE, "AoE" },
{ 0, NULL}
};
@@ -95,30 +93,30 @@ ether_hdr_print(netdissect_options *ndo,
const u_char *bp, u_int length)
{
register const struct ether_header *ep;
- u_int16_t ether_type;
+ uint16_t ether_type;
ep = (const struct ether_header *)bp;
- (void)ND_PRINT((ndo, "%s > %s",
- etheraddr_string(ESRC(ep)),
- etheraddr_string(EDST(ep))));
+ ND_PRINT((ndo, "%s > %s",
+ etheraddr_string(ndo, ESRC(ep)),
+ etheraddr_string(ndo, EDST(ep))));
ether_type = EXTRACT_16BITS(&ep->ether_type);
if (!ndo->ndo_qflag) {
if (ether_type <= ETHERMTU)
- (void)ND_PRINT((ndo, ", 802.3"));
- else
- (void)ND_PRINT((ndo, ", ethertype %s (0x%04x)",
+ ND_PRINT((ndo, ", 802.3"));
+ else
+ ND_PRINT((ndo, ", ethertype %s (0x%04x)",
tok2str(ethertype_values,"Unknown", ether_type),
ether_type));
} else {
if (ether_type <= ETHERMTU)
- (void)ND_PRINT((ndo, ", 802.3"));
- else
- (void)ND_PRINT((ndo, ", %s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", ether_type)));
+ ND_PRINT((ndo, ", 802.3"));
+ else
+ ND_PRINT((ndo, ", %s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", ether_type)));
}
- (void)ND_PRINT((ndo, ", length %u: ", length));
+ ND_PRINT((ndo, ", length %u: ", length));
}
/*
@@ -162,7 +160,7 @@ recurse:
*/
if (ether_type <= ETHERMTU) {
/* Try to print the LLC-layer header & higher layers */
- if (llc_print(p, length, caplen, ESRC(ep), EDST(ep),
+ if (llc_print(ndo, p, length, caplen, ESRC(ep), EDST(ep),
&extracted_ether_type) == 0) {
/* ether_type not known, print raw packet */
if (!ndo->ndo_eflag) {
@@ -172,7 +170,7 @@ recurse:
}
if (!ndo->ndo_suppress_default_print)
- ndo->ndo_default_print(ndo, p, caplen);
+ ND_DEFAULTPRINT(p, caplen);
}
} else if (ether_type == ETHERTYPE_8021Q ||
ether_type == ETHERTYPE_8021Q9100 ||
@@ -187,7 +185,7 @@ recurse:
return;
}
if (ndo->ndo_eflag) {
- u_int16_t tag = EXTRACT_16BITS(p);
+ uint16_t tag = EXTRACT_16BITS(p);
ND_PRINT((ndo, "vlan %u, p %u%s, ",
tag & 0xfff,
@@ -213,7 +211,7 @@ recurse:
* there's an LLC header and payload.
*/
/* Try to print the LLC-layer header & higher layers */
- if (llc_print(p, length, caplen, ESRC(ep), EDST(ep),
+ if (llc_print(ndo, p, length, caplen, ESRC(ep), EDST(ep),
&extracted_ether_type) == 0) {
/* ether_type not known, print raw packet */
if (!ndo->ndo_eflag) {
@@ -223,7 +221,7 @@ recurse:
}
if (!ndo->ndo_suppress_default_print)
- ndo->ndo_default_print(ndo, p, caplen);
+ ND_DEFAULTPRINT(p, caplen);
}
} else {
if (ethertype_print(ndo, ether_type, p, length, caplen) == 0) {
@@ -235,7 +233,7 @@ recurse:
}
if (!ndo->ndo_suppress_default_print)
- ndo->ndo_default_print(ndo, p, caplen);
+ ND_DEFAULTPRINT(p, caplen);
}
}
}
@@ -272,7 +270,7 @@ netanalyzer_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
* Fail if we don't have enough data for the Hilscher pseudo-header.
*/
if (h->len < 4 || h->caplen < 4) {
- printf("[|netanalyzer]");
+ ND_PRINT((ndo, "[|netanalyzer]"));
return (h->caplen);
}
@@ -302,7 +300,7 @@ netanalyzer_transparent_if_print(netdissect_options *ndo,
* preamble, and SOF.
*/
if (h->len < 12 || h->caplen < 12) {
- printf("[|netanalyzer-transparent]");
+ ND_PRINT((ndo, "[|netanalyzer-transparent]"));
return (h->caplen);
}
@@ -342,33 +340,33 @@ ethertype_print(netdissect_options *ndo,
return (1);
case ETHERTYPE_DN:
- decnet_print(/*ndo,*/p, length, caplen);
+ decnet_print(ndo, p, length, caplen);
return (1);
case ETHERTYPE_ATALK:
if (ndo->ndo_vflag)
- fputs("et1 ", stdout);
- atalk_print(/*ndo,*/p, length);
+ ND_PRINT((ndo, "et1 "));
+ atalk_print(ndo, p, length);
return (1);
case ETHERTYPE_AARP:
- aarp_print(/*ndo,*/p, length);
+ aarp_print(ndo, p, length);
return (1);
case ETHERTYPE_IPX:
ND_PRINT((ndo, "(NOV-ETHII) "));
- ipx_print(/*ndo,*/p, length);
+ ipx_print(ndo, p, length);
return (1);
- case ETHERTYPE_ISO:
- isoclns_print(/*ndo,*/p+1, length-1, length-1);
- return(1);
+ case ETHERTYPE_ISO:
+ isoclns_print(ndo, p + 1, length - 1, length - 1);
+ return(1);
case ETHERTYPE_PPPOED:
case ETHERTYPE_PPPOES:
case ETHERTYPE_PPPOED2:
case ETHERTYPE_PPPOES2:
- pppoe_print(/*ndo,*/p, length);
+ pppoe_print(ndo, p, length);
return (1);
case ETHERTYPE_EAPOL:
@@ -381,34 +379,35 @@ ethertype_print(netdissect_options *ndo,
case ETHERTYPE_PPP:
if (length) {
- printf(": ");
- ppp_print(/*ndo,*/p, length);
+ ND_PRINT((ndo, ": "));
+ ppp_print(ndo, p, length);
}
return (1);
case ETHERTYPE_MPCP:
- mpcp_print(/*ndo,*/p, length);
+ mpcp_print(ndo, p, length);
return (1);
case ETHERTYPE_SLOW:
- slow_print(/*ndo,*/p, length);
+ slow_print(ndo, p, length);
return (1);
case ETHERTYPE_CFM:
case ETHERTYPE_CFM_OLD:
- cfm_print(/*ndo,*/p, length);
+ cfm_print(ndo, p, length);
return (1);
case ETHERTYPE_LLDP:
- lldp_print(/*ndo,*/p, length);
+ lldp_print(ndo, p, length);
return (1);
case ETHERTYPE_LOOPBACK:
+ loopback_print(ndo, p, length);
return (1);
case ETHERTYPE_MPLS:
case ETHERTYPE_MPLS_MULTI:
- mpls_print(/*ndo,*/p, length);
+ mpls_print(ndo, p, length);
return (1);
case ETHERTYPE_TIPC:
@@ -416,13 +415,27 @@ ethertype_print(netdissect_options *ndo,
return (1);
case ETHERTYPE_MS_NLB_HB:
- msnlb_print(ndo, p, length);
+ msnlb_print(ndo, p);
+ return (1);
+
+ case ETHERTYPE_GEONET_OLD:
+ case ETHERTYPE_GEONET:
+ geonet_print(ndo, p-14, p, length);
+ return (1);
+
+ case ETHERTYPE_CALM_FAST:
+ calm_fast_print(ndo, p-14, p, length);
+ return (1);
+
+ case ETHERTYPE_AOE:
+ aoe_print(ndo, p, length);
return (1);
case ETHERTYPE_LAT:
case ETHERTYPE_SCA:
case ETHERTYPE_MOPRC:
case ETHERTYPE_MOPDL:
+ case ETHERTYPE_IEEE1905_1:
/* default_print for now */
default:
return (0);
diff --git a/contrib/tcpdump/print-fddi.c b/contrib/tcpdump/print-fddi.c
index 94e9be7fb955..2b53c45bd9a5 100644
--- a/contrib/tcpdump/print-fddi.c
+++ b/contrib/tcpdump/print-fddi.c
@@ -21,27 +21,66 @@
* $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.66 2005-11-13 12:12:41 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <pcap.h>
-#include <stdio.h>
#include <string.h>
#include "interface.h"
#include "addrtoname.h"
-#include "ethertype.h"
-
#include "ether.h"
-#include "fddi.h"
+
+/*
+ * Based on Ultrix if_fddi.h
+ */
+
+struct fddi_header {
+ u_char fddi_fc; /* frame control */
+ u_char fddi_dhost[6];
+ u_char fddi_shost[6];
+};
+
+/*
+ * Length of an FDDI header; note that some compilers may pad
+ * "struct fddi_header" to a multiple of 4 bytes, for example, so
+ * "sizeof (struct fddi_header)" may not give the right
+ * answer.
+ */
+#define FDDI_HDRLEN 13
+
+/* Useful values for fddi_fc (frame control) field */
+
+/*
+ * FDDI Frame Control bits
+ */
+#define FDDIFC_C 0x80 /* Class bit */
+#define FDDIFC_L 0x40 /* Address length bit */
+#define FDDIFC_F 0x30 /* Frame format bits */
+#define FDDIFC_Z 0x0f /* Control bits */
+
+/*
+ * FDDI Frame Control values. (48-bit addressing only).
+ */
+#define FDDIFC_VOID 0x40 /* Void frame */
+#define FDDIFC_NRT 0x80 /* Nonrestricted token */
+#define FDDIFC_RT 0xc0 /* Restricted token */
+#define FDDIFC_SMT_INFO 0x41 /* SMT Info */
+#define FDDIFC_SMT_NSA 0x4F /* SMT Next station adrs */
+#define FDDIFC_MAC_BEACON 0xc2 /* MAC Beacon frame */
+#define FDDIFC_MAC_CLAIM 0xc3 /* MAC Claim frame */
+#define FDDIFC_LLC_ASYNC 0x50 /* Async. LLC frame */
+#define FDDIFC_LLC_SYNC 0xd0 /* Sync. LLC frame */
+#define FDDIFC_IMP_ASYNC 0x60 /* Implementor Async. */
+#define FDDIFC_IMP_SYNC 0xe0 /* Implementor Synch. */
+#define FDDIFC_SMT 0x40 /* SMT frame */
+#define FDDIFC_MAC 0xc0 /* MAC frame */
+
+#define FDDIFC_CLFF 0xF0 /* Class/Length/Format bits */
+#define FDDIFC_ZZZZ 0x0F /* Control bits */
/*
* Some FDDI interfaces use bit-swapped addresses.
@@ -82,7 +121,7 @@ int fddi_bitswap = 1;
* - vj
*/
-static u_char fddi_bit_swap[] = {
+static const u_char fddi_bit_swap[] = {
0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
@@ -121,67 +160,67 @@ static u_char fddi_bit_swap[] = {
* Print FDDI frame-control bits
*/
static inline void
-print_fddi_fc(u_char fc)
+print_fddi_fc(netdissect_options *ndo, u_char fc)
{
switch (fc) {
case FDDIFC_VOID: /* Void frame */
- printf("void ");
+ ND_PRINT((ndo, "void "));
break;
case FDDIFC_NRT: /* Nonrestricted token */
- printf("nrt ");
+ ND_PRINT((ndo, "nrt "));
break;
case FDDIFC_RT: /* Restricted token */
- printf("rt ");
+ ND_PRINT((ndo, "rt "));
break;
case FDDIFC_SMT_INFO: /* SMT Info */
- printf("info ");
+ ND_PRINT((ndo, "info "));
break;
case FDDIFC_SMT_NSA: /* SMT Next station adrs */
- printf("nsa ");
+ ND_PRINT((ndo, "nsa "));
break;
case FDDIFC_MAC_BEACON: /* MAC Beacon frame */
- printf("beacon ");
+ ND_PRINT((ndo, "beacon "));
break;
case FDDIFC_MAC_CLAIM: /* MAC Claim frame */
- printf("claim ");
+ ND_PRINT((ndo, "claim "));
break;
default:
switch (fc & FDDIFC_CLFF) {
case FDDIFC_MAC:
- printf("mac%1x ", fc & FDDIFC_ZZZZ);
+ ND_PRINT((ndo, "mac%1x ", fc & FDDIFC_ZZZZ));
break;
case FDDIFC_SMT:
- printf("smt%1x ", fc & FDDIFC_ZZZZ);
+ ND_PRINT((ndo, "smt%1x ", fc & FDDIFC_ZZZZ));
break;
case FDDIFC_LLC_ASYNC:
- printf("async%1x ", fc & FDDIFC_ZZZZ);
+ ND_PRINT((ndo, "async%1x ", fc & FDDIFC_ZZZZ));
break;
case FDDIFC_LLC_SYNC:
- printf("sync%1x ", fc & FDDIFC_ZZZZ);
+ ND_PRINT((ndo, "sync%1x ", fc & FDDIFC_ZZZZ));
break;
case FDDIFC_IMP_ASYNC:
- printf("imp_async%1x ", fc & FDDIFC_ZZZZ);
+ ND_PRINT((ndo, "imp_async%1x ", fc & FDDIFC_ZZZZ));
break;
case FDDIFC_IMP_SYNC:
- printf("imp_sync%1x ", fc & FDDIFC_ZZZZ);
+ ND_PRINT((ndo, "imp_sync%1x ", fc & FDDIFC_ZZZZ));
break;
default:
- printf("%02x ", fc);
+ ND_PRINT((ndo, "%02x ", fc));
break;
}
}
@@ -213,42 +252,43 @@ extract_fddi_addrs(const struct fddi_header *fddip, char *fsrc, char *fdst)
* Print the FDDI MAC header
*/
static inline void
-fddi_hdr_print(register const struct fddi_header *fddip, register u_int length,
- register const u_char *fsrc, register const u_char *fdst)
+fddi_hdr_print(netdissect_options *ndo,
+ register const struct fddi_header *fddip, register u_int length,
+ register const u_char *fsrc, register const u_char *fdst)
{
const char *srcname, *dstname;
- srcname = etheraddr_string(fsrc);
- dstname = etheraddr_string(fdst);
+ srcname = etheraddr_string(ndo, fsrc);
+ dstname = etheraddr_string(ndo, fdst);
- if (vflag)
- (void) printf("%02x %s %s %d: ",
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, "%02x %s %s %d: ",
fddip->fddi_fc,
srcname, dstname,
- length);
- else if (qflag)
- printf("%s %s %d: ", srcname, dstname, length);
+ length));
+ else if (ndo->ndo_qflag)
+ ND_PRINT((ndo, "%s %s %d: ", srcname, dstname, length));
else {
- (void) print_fddi_fc(fddip->fddi_fc);
- (void) printf("%s %s %d: ", srcname, dstname, length);
+ print_fddi_fc(ndo, fddip->fddi_fc);
+ ND_PRINT((ndo, "%s %s %d: ", srcname, dstname, length));
}
}
static inline void
-fddi_smt_print(const u_char *p _U_, u_int length _U_)
+fddi_smt_print(netdissect_options *ndo, const u_char *p _U_, u_int length _U_)
{
- printf("<SMT printer not yet implemented>");
+ ND_PRINT((ndo, "<SMT printer not yet implemented>"));
}
void
-fddi_print(const u_char *p, u_int length, u_int caplen)
+fddi_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
{
const struct fddi_header *fddip = (const struct fddi_header *)p;
struct ether_header ehdr;
u_short extracted_ethertype;
if (caplen < FDDI_HDRLEN) {
- printf("[|fddi]");
+ ND_PRINT((ndo, "[|fddi]"));
return;
}
@@ -257,8 +297,8 @@ fddi_print(const u_char *p, u_int length, u_int caplen)
*/
extract_fddi_addrs(fddip, (char *)ESRC(&ehdr), (char *)EDST(&ehdr));
- if (eflag)
- fddi_hdr_print(fddip, length, ESRC(&ehdr), EDST(&ehdr));
+ if (ndo->ndo_eflag)
+ fddi_hdr_print(ndo, fddip, length, ESRC(&ehdr), EDST(&ehdr));
/* Skip over FDDI MAC header */
length -= FDDI_HDRLEN;
@@ -268,31 +308,31 @@ fddi_print(const u_char *p, u_int length, u_int caplen)
/* Frame Control field determines interpretation of packet */
if ((fddip->fddi_fc & FDDIFC_CLFF) == FDDIFC_LLC_ASYNC) {
/* Try to print the LLC-layer header & higher layers */
- if (llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr),
+ if (llc_print(ndo, p, length, caplen, ESRC(&ehdr), EDST(&ehdr),
&extracted_ethertype) == 0) {
/*
* Some kinds of LLC packet we cannot
* handle intelligently
*/
- if (!eflag)
- fddi_hdr_print(fddip, length + FDDI_HDRLEN,
+ if (!ndo->ndo_eflag)
+ fddi_hdr_print(ndo, fddip, length + FDDI_HDRLEN,
ESRC(&ehdr), EDST(&ehdr));
if (extracted_ethertype) {
- printf("(LLC %s) ",
- etherproto_string(htons(extracted_ethertype)));
+ ND_PRINT((ndo, "(LLC %s) ",
+ etherproto_string(htons(extracted_ethertype))));
}
- if (!suppress_default_print)
- default_print(p, caplen);
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
}
} else if ((fddip->fddi_fc & FDDIFC_CLFF) == FDDIFC_SMT)
- fddi_smt_print(p, caplen);
+ fddi_smt_print(ndo, p, caplen);
else {
/* Some kinds of FDDI packet we cannot handle intelligently */
- if (!eflag)
- fddi_hdr_print(fddip, length + FDDI_HDRLEN, ESRC(&ehdr),
+ if (!ndo->ndo_eflag)
+ fddi_hdr_print(ndo, fddip, length + FDDI_HDRLEN, ESRC(&ehdr),
EDST(&ehdr));
- if (!suppress_default_print)
- default_print(p, caplen);
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
}
}
@@ -303,9 +343,9 @@ fddi_print(const u_char *p, u_int length, u_int caplen)
* is the number of bytes actually captured.
*/
u_int
-fddi_if_print(const struct pcap_pkthdr *h, register const u_char *p)
+fddi_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p)
{
- fddi_print(p, h->len, h->caplen);
+ fddi_print(ndo, p, h->len, h->caplen);
return (FDDI_HDRLEN);
}
diff --git a/contrib/tcpdump/print-forces.c b/contrib/tcpdump/print-forces.c
index 438aa279ec1d..45bd74f97009 100644
--- a/contrib/tcpdump/print-forces.c
+++ b/contrib/tcpdump/print-forces.c
@@ -14,25 +14,635 @@
*
*/
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <stdlib.h>
-
#include "interface.h"
#include "extract.h"
-#include "forces.h"
+static const char tstr[] = "[|forces]";
+
+/*
+ * Per draft-ietf-forces-protocol-22
+*/
+#define ForCES_VERS 1
+#define ForCES_HDRL 24
+#define ForCES_ALNL 4U
+#define TLV_HDRL 4
+#define ILV_HDRL 8
+
+#define TOM_RSVD 0x0
+#define TOM_ASSNSETUP 0x1
+#define TOM_ASSNTEARD 0x2
+#define TOM_CONFIG 0x3
+#define TOM_QUERY 0x4
+#define TOM_EVENTNOT 0x5
+#define TOM_PKTREDIR 0x6
+#define TOM_HEARTBT 0x0F
+#define TOM_ASSNSETREP 0x11
+#define TOM_CONFIGREP 0x13
+#define TOM_QUERYREP 0x14
+
+/*
+ * tom_h Flags: resv1(8b):maxtlvs(4b):resv2(2b):mintlv(2b)
+*/
+#define ZERO_TTLV 0x01
+#define ZERO_MORE_TTLV 0x02
+#define ONE_MORE_TTLV 0x04
+#define ZERO_TLV 0x00
+#define ONE_TLV 0x10
+#define TWO_TLV 0x20
+#define MAX_TLV 0xF0
+
+#define TTLV_T1 (ONE_MORE_TTLV|ONE_TLV)
+#define TTLV_T2 (ONE_MORE_TTLV|MAX_TLV)
+
+struct tom_h {
+ uint32_t v;
+ uint16_t flags;
+ uint16_t op_msk;
+ const char *s;
+ int (*print) (netdissect_options *ndo, register const u_char * pptr, register u_int len,
+ uint16_t op_msk, int indent);
+};
+
+enum {
+ TOM_RSV_I,
+ TOM_ASS_I,
+ TOM_AST_I,
+ TOM_CFG_I,
+ TOM_QRY_I,
+ TOM_EVN_I,
+ TOM_RED_I,
+ TOM_HBT_I,
+ TOM_ASR_I,
+ TOM_CNR_I,
+ TOM_QRR_I,
+ _TOM_RSV_MAX
+};
+#define TOM_MAX_IND (_TOM_RSV_MAX - 1)
+
+static inline int tom_valid(uint8_t tom)
+{
+ if (tom > 0) {
+ if (tom >= 0x7 && tom <= 0xe)
+ return 0;
+ if (tom == 0x10)
+ return 0;
+ if (tom > 0x14)
+ return 0;
+ return 1;
+ } else
+ return 0;
+}
+
+static inline const char *ForCES_node(uint32_t node)
+{
+ if (node <= 0x3FFFFFFF)
+ return "FE";
+ if (node >= 0x40000000 && node <= 0x7FFFFFFF)
+ return "CE";
+ if (node >= 0xC0000000 && node <= 0xFFFFFFEF)
+ return "AllMulticast";
+ if (node == 0xFFFFFFFD)
+ return "AllCEsBroadcast";
+ if (node == 0xFFFFFFFE)
+ return "AllFEsBroadcast";
+ if (node == 0xFFFFFFFF)
+ return "AllBroadcast";
+
+ return "ForCESreserved";
+
+}
+
+static const struct tok ForCES_ACKs[] = {
+ {0x0, "NoACK"},
+ {0x1, "SuccessACK"},
+ {0x2, "FailureACK"},
+ {0x3, "AlwaysACK"},
+ {0, NULL}
+};
+
+static const struct tok ForCES_EMs[] = {
+ {0x0, "EMReserved"},
+ {0x1, "execute-all-or-none"},
+ {0x2, "execute-until-failure"},
+ {0x3, "continue-execute-on-failure"},
+ {0, NULL}
+};
+
+static const struct tok ForCES_ATs[] = {
+ {0x0, "Standalone"},
+ {0x1, "2PCtransaction"},
+ {0, NULL}
+};
+
+static const struct tok ForCES_TPs[] = {
+ {0x0, "StartofTransaction"},
+ {0x1, "MiddleofTransaction"},
+ {0x2, "EndofTransaction"},
+ {0x3, "abort"},
+ {0, NULL}
+};
+
+/*
+ * Structure of forces header, naked of TLVs.
+ */
+struct forcesh {
+ uint8_t fm_vrsvd; /* version and reserved */
+#define ForCES_V(forcesh) ((forcesh)->fm_vrsvd >> 4)
+ uint8_t fm_tom; /* type of message */
+ uint16_t fm_len; /* total length * 4 bytes */
+#define ForCES_BLN(forcesh) ((uint32_t)(EXTRACT_16BITS(&(forcesh)->fm_len) << 2))
+ uint32_t fm_sid; /* Source ID */
+#define ForCES_SID(forcesh) EXTRACT_32BITS(&(forcesh)->fm_sid)
+ uint32_t fm_did; /* Destination ID */
+#define ForCES_DID(forcesh) EXTRACT_32BITS(&(forcesh)->fm_did)
+ uint8_t fm_cor[8]; /* correlator */
+ uint32_t fm_flags; /* flags */
+#define ForCES_ACK(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0xC0000000) >> 30)
+#define ForCES_PRI(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x38000000) >> 27)
+#define ForCES_RS1(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x07000000) >> 24)
+#define ForCES_EM(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x00C00000) >> 22)
+#define ForCES_AT(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x00200000) >> 21)
+#define ForCES_TP(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x00180000) >> 19)
+#define ForCES_RS2(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x0007FFFF) >> 0)
+};
+
+#define ForCES_HLN_VALID(fhl,tlen) ((tlen) >= ForCES_HDRL && \
+ (fhl) >= ForCES_HDRL && \
+ (fhl) == (tlen))
+
+#define F_LFB_RSVD 0x0
+#define F_LFB_FEO 0x1
+#define F_LFB_FEPO 0x2
+static const struct tok ForCES_LFBs[] = {
+ {F_LFB_RSVD, "Invalid TLV"},
+ {F_LFB_FEO, "FEObj LFB"},
+ {F_LFB_FEPO, "FEProtoObj LFB"},
+ {0, NULL}
+};
+
+enum {
+ F_OP_RSV,
+ F_OP_SET,
+ F_OP_SETPROP,
+ F_OP_SETRESP,
+ F_OP_SETPRESP,
+ F_OP_DEL,
+ F_OP_DELRESP,
+ F_OP_GET,
+ F_OP_GETPROP,
+ F_OP_GETRESP,
+ F_OP_GETPRESP,
+ F_OP_REPORT,
+ F_OP_COMMIT,
+ F_OP_RCOMMIT,
+ F_OP_RTRCOMP,
+ _F_OP_MAX
+};
+
+#define F_OP_MAX (_F_OP_MAX - 1)
+enum {
+ B_OP_SET = 1 << (F_OP_SET - 1),
+ B_OP_SETPROP = 1 << (F_OP_SETPROP - 1),
+ B_OP_SETRESP = 1 << (F_OP_SETRESP - 1),
+ B_OP_SETPRESP = 1 << (F_OP_SETPRESP - 1),
+ B_OP_DEL = 1 << (F_OP_DEL - 1),
+ B_OP_DELRESP = 1 << (F_OP_DELRESP - 1),
+ B_OP_GET = 1 << (F_OP_GET - 1),
+ B_OP_GETPROP = 1 << (F_OP_GETPROP - 1),
+ B_OP_GETRESP = 1 << (F_OP_GETRESP - 1),
+ B_OP_GETPRESP = 1 << (F_OP_GETPRESP - 1),
+ B_OP_REPORT = 1 << (F_OP_REPORT - 1),
+ B_OP_COMMIT = 1 << (F_OP_COMMIT - 1),
+ B_OP_RCOMMIT = 1 << (F_OP_RCOMMIT - 1),
+ B_OP_RTRCOMP = 1 << (F_OP_RTRCOMP - 1),
+};
+
+struct optlv_h {
+ uint16_t flags;
+ uint16_t op_msk;
+ const char *s;
+ int (*print) (netdissect_options *ndo, register const u_char * pptr, register u_int len,
+ uint16_t op_msk, int indent);
+};
+
+static int genoptlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
+ uint16_t op_msk, int indent);
+static int recpdoptlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
+ uint16_t op_msk, int indent);
+static int invoptlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
+ uint16_t op_msk, int indent);
+
+#define OP_MIN_SIZ 8
+struct pathdata_h {
+ uint16_t pflags;
+ uint16_t pIDcnt;
+};
+
+#define B_FULLD 0x1
+#define B_SPARD 0x2
+#define B_RESTV 0x4
+#define B_KEYIN 0x8
+#define B_APPND 0x10
+#define B_TRNG 0x20
+
+static const struct optlv_h OPTLV_msg[F_OP_MAX + 1] = {
+ /* F_OP_RSV */ {ZERO_TTLV, 0, "Invalid OPTLV", invoptlv_print},
+ /* F_OP_SET */ {TTLV_T2, B_FULLD | B_SPARD, " Set", recpdoptlv_print},
+ /* F_OP_SETPROP */
+ {TTLV_T2, B_FULLD | B_SPARD, " SetProp", recpdoptlv_print},
+ /* F_OP_SETRESP */ {TTLV_T2, B_RESTV, " SetResp", recpdoptlv_print},
+ /* F_OP_SETPRESP */ {TTLV_T2, B_RESTV, " SetPropResp", recpdoptlv_print},
+ /* F_OP_DEL */ {ZERO_TTLV, 0, " Del", recpdoptlv_print},
+ /* F_OP_DELRESP */ {TTLV_T2, B_RESTV, " DelResp", recpdoptlv_print},
+ /* F_OP_GET */ {ZERO_TTLV, 0, " Get", recpdoptlv_print},
+ /* F_OP_GETPROP */ {ZERO_TTLV, 0, " GetProp", recpdoptlv_print},
+ /* F_OP_GETRESP */
+ {TTLV_T2, B_FULLD | B_SPARD | B_RESTV, " GetResp", recpdoptlv_print},
+ /* F_OP_GETPRESP */
+ {TTLV_T2, B_FULLD | B_RESTV, " GetPropResp", recpdoptlv_print},
+ /* F_OP_REPORT */
+ {TTLV_T2, B_FULLD | B_SPARD, " Report", recpdoptlv_print},
+ /* F_OP_COMMIT */ {ZERO_TTLV, 0, " Commit", NULL},
+ /* F_OP_RCOMMIT */ {TTLV_T1, B_RESTV, " RCommit", genoptlv_print},
+ /* F_OP_RTRCOMP */ {ZERO_TTLV, 0, " RTRCOMP", NULL},
+};
+
+static inline const struct optlv_h *get_forces_optlv_h(uint16_t opt)
+{
+ if (opt > F_OP_MAX || opt <= F_OP_RSV)
+ return &OPTLV_msg[F_OP_RSV];
+
+ return &OPTLV_msg[opt];
+}
+
+#define IND_SIZE 256
+#define IND_CHR ' '
+#define IND_PREF '\n'
+#define IND_SUF 0x0
+char ind_buf[IND_SIZE];
+
+static inline char *indent_pr(int indent, int nlpref)
+{
+ int i = 0;
+ char *r = ind_buf;
+
+ if (indent > (IND_SIZE - 1))
+ indent = IND_SIZE - 1;
+
+ if (nlpref) {
+ r[i] = IND_PREF;
+ i++;
+ indent--;
+ }
+
+ while (--indent >= 0)
+ r[i++] = IND_CHR;
+
+ r[i] = IND_SUF;
+ return r;
+}
+
+static inline int op_valid(uint16_t op, uint16_t mask)
+{
+ int opb = 1 << (op - 1);
+
+ if (op == 0)
+ return 0;
+ if (opb & mask)
+ return 1;
+ /* I guess we should allow vendor operations? */
+ if (op >= 0x8000)
+ return 1;
+ return 0;
+}
+
+#define F_TLV_RSVD 0x0000
+#define F_TLV_REDR 0x0001
+#define F_TLV_ASRS 0x0010
+#define F_TLV_ASRT 0x0011
+#define F_TLV_LFBS 0x1000
+#define F_TLV_PDAT 0x0110
+#define F_TLV_KEYI 0x0111
+#define F_TLV_FULD 0x0112
+#define F_TLV_SPAD 0x0113
+#define F_TLV_REST 0x0114
+#define F_TLV_METD 0x0115
+#define F_TLV_REDD 0x0116
+#define F_TLV_TRNG 0x0117
+
+
+#define F_TLV_VNST 0x8000
+
+static const struct tok ForCES_TLV[] = {
+ {F_TLV_RSVD, "Invalid TLV"},
+ {F_TLV_REDR, "REDIRECT TLV"},
+ {F_TLV_ASRS, "ASResult TLV"},
+ {F_TLV_ASRT, "ASTreason TLV"},
+ {F_TLV_LFBS, "LFBselect TLV"},
+ {F_TLV_PDAT, "PATH-DATA TLV"},
+ {F_TLV_KEYI, "KEYINFO TLV"},
+ {F_TLV_FULD, "FULLDATA TLV"},
+ {F_TLV_SPAD, "SPARSEDATA TLV"},
+ {F_TLV_REST, "RESULT TLV"},
+ {F_TLV_METD, "METADATA TLV"},
+ {F_TLV_REDD, "REDIRECTDATA TLV"},
+ {0, NULL}
+};
+
+#define TLV_HLN 4
+static inline int ttlv_valid(uint16_t ttlv)
+{
+ if (ttlv > 0) {
+ if (ttlv == 1 || ttlv == 0x1000)
+ return 1;
+ if (ttlv >= 0x10 && ttlv <= 0x11)
+ return 1;
+ if (ttlv >= 0x110 && ttlv <= 0x116)
+ return 1;
+ if (ttlv >= 0x8000)
+ return 0; /* XXX: */
+ }
+
+ return 0;
+}
+
+struct forces_ilv {
+ uint32_t type;
+ uint32_t length;
+};
+
+struct forces_tlv {
+ uint16_t type;
+ uint16_t length;
+};
+
+#define F_ALN_LEN(len) ( ((len)+ForCES_ALNL-1) & ~(ForCES_ALNL-1) )
+#define GET_TOP_TLV(fhdr) ((struct forces_tlv *)((fhdr) + sizeof (struct forcesh)))
+#define TLV_SET_LEN(len) (F_ALN_LEN(TLV_HDRL) + (len))
+#define TLV_ALN_LEN(len) F_ALN_LEN(TLV_SET_LEN(len))
+#define TLV_RDAT_LEN(tlv) ((int)(EXTRACT_16BITS(&(tlv)->length) - TLV_SET_LEN(0))
+#define TLV_DATA(tlvp) ((void*)(((char*)(tlvp)) + TLV_SET_LEN(0)))
+#define GO_NXT_TLV(tlv,rlen) ((rlen) -= F_ALN_LEN(EXTRACT_16BITS(&(tlv)->length)), \
+ (struct forces_tlv*)(((char*)(tlv)) \
+ + F_ALN_LEN(EXTRACT_16BITS(&(tlv)->length))))
+#define ILV_SET_LEN(len) (F_ALN_LEN(ILV_HDRL) + (len))
+#define ILV_ALN_LEN(len) F_ALN_LEN(ILV_SET_LEN(len))
+#define ILV_RDAT_LEN(ilv) ((int)(EXTRACT_32BITS(&(ilv)->length)) - ILV_SET_LEN(0))
+#define ILV_DATA(ilvp) ((void*)(((char*)(ilvp)) + ILV_SET_LEN(0)))
+#define GO_NXT_ILV(ilv,rlen) ((rlen) -= F_ALN_LEN(EXTRACT_32BITS(&(ilv)->length)), \
+ (struct forces_ilv *)(((char*)(ilv)) \
+ + F_ALN_LEN(EXTRACT_32BITS(&(ilv)->length))))
+#define INVALID_RLEN 1
+#define INVALID_STLN 2
+#define INVALID_LTLN 3
+#define INVALID_ALEN 4
+
+static const struct tok ForCES_TLV_err[] = {
+ {INVALID_RLEN, "Invalid total length"},
+ {INVALID_STLN, "xLV too short"},
+ {INVALID_LTLN, "xLV too long"},
+ {INVALID_ALEN, "data padding missing"},
+ {0, NULL}
+};
+
+static inline u_int tlv_valid(const struct forces_tlv *tlv, u_int rlen)
+{
+ if (rlen < TLV_HDRL)
+ return INVALID_RLEN;
+ if (EXTRACT_16BITS(&tlv->length) < TLV_HDRL)
+ return INVALID_STLN;
+ if (EXTRACT_16BITS(&tlv->length) > rlen)
+ return INVALID_LTLN;
+ if (rlen < F_ALN_LEN(EXTRACT_16BITS(&tlv->length)))
+ return INVALID_ALEN;
+
+ return 0;
+}
+
+static inline int ilv_valid(const struct forces_ilv *ilv, u_int rlen)
+{
+ if (rlen < ILV_HDRL)
+ return INVALID_RLEN;
+ if (EXTRACT_32BITS(&ilv->length) < ILV_HDRL)
+ return INVALID_STLN;
+ if (EXTRACT_32BITS(&ilv->length) > rlen)
+ return INVALID_LTLN;
+ if (rlen < F_ALN_LEN(EXTRACT_32BITS(&ilv->length)))
+ return INVALID_ALEN;
+
+ return 0;
+}
+
+static int lfbselect_print(netdissect_options *, register const u_char * pptr, register u_int len,
+ uint16_t op_msk, int indent);
+static int redirect_print(netdissect_options *, register const u_char * pptr, register u_int len,
+ uint16_t op_msk, int indent);
+static int asrtlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
+ uint16_t op_msk, int indent);
+static int asttlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
+ uint16_t op_msk, int indent);
+
+struct forces_lfbsh {
+ uint32_t class;
+ uint32_t instance;
+};
+
+#define ASSNS_OPS (B_OP_REPORT)
+#define CFG_OPS (B_OP_SET|B_OP_SETPROP|B_OP_DEL|B_OP_COMMIT|B_OP_RTRCOMP)
+#define CFG_ROPS (B_OP_SETRESP|B_OP_SETPRESP|B_OP_DELRESP|B_OP_RCOMMIT)
+#define CFG_QY (B_OP_GET|B_OP_GETPROP)
+#define CFG_QYR (B_OP_GETRESP|B_OP_GETPRESP)
+#define CFG_EVN (B_OP_REPORT)
+
+static const struct tom_h ForCES_msg[TOM_MAX_IND + 1] = {
+ /* TOM_RSV_I */ {TOM_RSVD, ZERO_TTLV, 0, "Invalid message", NULL},
+ /* TOM_ASS_I */ {TOM_ASSNSETUP, ZERO_MORE_TTLV | TWO_TLV, ASSNS_OPS,
+ "Association Setup", lfbselect_print},
+ /* TOM_AST_I */
+ {TOM_ASSNTEARD, TTLV_T1, 0, "Association TearDown", asttlv_print},
+ /* TOM_CFG_I */ {TOM_CONFIG, TTLV_T2, CFG_OPS, "Config", lfbselect_print},
+ /* TOM_QRY_I */ {TOM_QUERY, TTLV_T2, CFG_QY, "Query", lfbselect_print},
+ /* TOM_EVN_I */ {TOM_EVENTNOT, TTLV_T1, CFG_EVN, "Event Notification",
+ lfbselect_print},
+ /* TOM_RED_I */
+ {TOM_PKTREDIR, TTLV_T2, 0, "Packet Redirect", redirect_print},
+ /* TOM_HBT_I */ {TOM_HEARTBT, ZERO_TTLV, 0, "HeartBeat", NULL},
+ /* TOM_ASR_I */
+ {TOM_ASSNSETREP, TTLV_T1, 0, "Association Response", asrtlv_print},
+ /* TOM_CNR_I */ {TOM_CONFIGREP, TTLV_T2, CFG_ROPS, "Config Response",
+ lfbselect_print},
+ /* TOM_QRR_I */
+ {TOM_QUERYREP, TTLV_T2, CFG_QYR, "Query Response", lfbselect_print},
+};
+
+static inline const struct tom_h *get_forces_tom(uint8_t tom)
+{
+ int i;
+ for (i = TOM_RSV_I; i <= TOM_MAX_IND; i++) {
+ const struct tom_h *th = &ForCES_msg[i];
+ if (th->v == tom)
+ return th;
+ }
+ return &ForCES_msg[TOM_RSV_I];
+}
+
+struct pdata_ops {
+ uint32_t v;
+ uint16_t flags;
+ uint16_t op_msk;
+ const char *s;
+ int (*print) (netdissect_options *, register const u_char * pptr, register u_int len,
+ uint16_t op_msk, int indent);
+};
+
+enum {
+ PD_RSV_I,
+ PD_SEL_I,
+ PD_FDT_I,
+ PD_SDT_I,
+ PD_RES_I,
+ PD_PDT_I,
+ _PD_RSV_MAX
+};
+#define PD_MAX_IND (_TOM_RSV_MAX - 1)
+
+static inline int pd_valid(uint16_t pd)
+{
+ if (pd >= F_TLV_PDAT && pd <= F_TLV_REST)
+ return 1;
+ return 0;
+}
+
+static inline void
+chk_op_type(netdissect_options *ndo,
+ uint16_t type, uint16_t msk, uint16_t omsk)
+{
+ if (type != F_TLV_PDAT) {
+ if (msk & B_KEYIN) {
+ if (type != F_TLV_KEYI) {
+ ND_PRINT((ndo, "Based on flags expected KEYINFO TLV!\n"));
+ }
+ } else {
+ if (!(msk & omsk)) {
+ ND_PRINT((ndo, "Illegal DATA encoding for type 0x%x programmed %x got %x \n",
+ type, omsk, msk));
+ }
+ }
+ }
+
+}
+
+#define F_SELKEY 1
+#define F_SELTABRANGE 2
+#define F_TABAPPEND 4
+
+struct res_val {
+ uint8_t result;
+ uint8_t resv1;
+ uint16_t resv2;
+};
+
+static int prestlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
+ uint16_t op_msk, int indent);
+static int pkeyitlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
+ uint16_t op_msk, int indent);
+static int fdatatlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
+ uint16_t op_msk, int indent);
+static int sdatatlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
+ uint16_t op_msk, int indent);
+
+static const struct pdata_ops ForCES_pdata[PD_MAX_IND + 1] = {
+ /* PD_RSV_I */ {0, 0, 0, "Invalid message", NULL},
+ /* PD_SEL_I */ {F_TLV_KEYI, 0, 0, "KEYINFO TLV", pkeyitlv_print},
+ /* PD_FDT_I */ {F_TLV_FULD, 0, B_FULLD, "FULLDATA TLV", fdatatlv_print},
+ /* PD_SDT_I */ {F_TLV_SPAD, 0, B_SPARD, "SPARSEDATA TLV", sdatatlv_print},
+ /* PD_RES_I */ {F_TLV_REST, 0, B_RESTV, "RESULT TLV", prestlv_print},
+ /* PD_PDT_I */
+ {F_TLV_PDAT, 0, 0, "Inner PATH-DATA TLV", recpdoptlv_print},
+};
+
+static inline const struct pdata_ops *get_forces_pd(uint16_t pd)
+{
+ int i;
+ for (i = PD_RSV_I + 1; i <= PD_MAX_IND; i++) {
+ const struct pdata_ops *pdo = &ForCES_pdata[i];
+ if (pdo->v == pd)
+ return pdo;
+ }
+ return &ForCES_pdata[TOM_RSV_I];
+}
+
+enum {
+ E_SUCCESS,
+ E_INVALID_HEADER,
+ E_LENGTH_MISMATCH,
+ E_VERSION_MISMATCH,
+ E_INVALID_DESTINATION_PID,
+ E_LFB_UNKNOWN,
+ E_LFB_NOT_FOUND,
+ E_LFB_INSTANCE_ID_NOT_FOUND,
+ E_INVALID_PATH,
+ E_COMPONENT_DOES_NOT_EXIST,
+ E_EXISTS,
+ E_NOT_FOUND,
+ E_READ_ONLY,
+ E_INVALID_ARRAY_CREATION,
+ E_VALUE_OUT_OF_RANGE,
+ E_CONTENTS_TOO_LONG,
+ E_INVALID_PARAMETERS,
+ E_INVALID_MESSAGE_TYPE,
+ E_INVALID_FLAGS,
+ E_INVALID_TLV,
+ E_EVENT_ERROR,
+ E_NOT_SUPPORTED,
+ E_MEMORY_ERROR,
+ E_INTERNAL_ERROR,
+ /* 0x18-0xFE are reserved .. */
+ E_UNSPECIFIED_ERROR = 0XFF
+};
+
+static const struct tok ForCES_errs[] = {
+ {E_SUCCESS, "SUCCESS"},
+ {E_INVALID_HEADER, "INVALID HEADER"},
+ {E_LENGTH_MISMATCH, "LENGTH MISMATCH"},
+ {E_VERSION_MISMATCH, "VERSION MISMATCH"},
+ {E_INVALID_DESTINATION_PID, "INVALID DESTINATION PID"},
+ {E_LFB_UNKNOWN, "LFB UNKNOWN"},
+ {E_LFB_NOT_FOUND, "LFB NOT FOUND"},
+ {E_LFB_INSTANCE_ID_NOT_FOUND, "LFB INSTANCE ID NOT FOUND"},
+ {E_INVALID_PATH, "INVALID PATH"},
+ {E_COMPONENT_DOES_NOT_EXIST, "COMPONENT DOES NOT EXIST"},
+ {E_EXISTS, "EXISTS ALREADY"},
+ {E_NOT_FOUND, "NOT FOUND"},
+ {E_READ_ONLY, "READ ONLY"},
+ {E_INVALID_ARRAY_CREATION, "INVALID ARRAY CREATION"},
+ {E_VALUE_OUT_OF_RANGE, "VALUE OUT OF RANGE"},
+ {E_CONTENTS_TOO_LONG, "CONTENTS TOO LONG"},
+ {E_INVALID_PARAMETERS, "INVALID PARAMETERS"},
+ {E_INVALID_MESSAGE_TYPE, "INVALID MESSAGE TYPE"},
+ {E_INVALID_FLAGS, "INVALID FLAGS"},
+ {E_INVALID_TLV, "INVALID TLV"},
+ {E_EVENT_ERROR, "EVENT ERROR"},
+ {E_NOT_SUPPORTED, "NOT SUPPORTED"},
+ {E_MEMORY_ERROR, "MEMORY ERROR"},
+ {E_INTERNAL_ERROR, "INTERNAL ERROR"},
+ {E_UNSPECIFIED_ERROR, "UNSPECIFIED ERROR"},
+ {0, NULL}
+};
#define RESLEN 4
-int
-prestlv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk _U_, int indent)
+static int
+prestlv_print(netdissect_options *ndo,
+ register const u_char * pptr, register u_int len,
+ uint16_t op_msk _U_, int indent)
{
const struct forces_tlv *tlv = (struct forces_tlv *)pptr;
register const u_char *tdp = (u_char *) TLV_DATA(tlv);
@@ -45,92 +655,97 @@ prestlv_print(register const u_char * pptr, register u_int len,
*/
dlen = len - TLV_HDRL;
if (dlen != RESLEN) {
- printf("illegal RESULT-TLV: %d bytes!\n", dlen);
+ ND_PRINT((ndo, "illegal RESULT-TLV: %d bytes!\n", dlen));
return -1;
}
- TCHECK(*r);
+ ND_TCHECK(*r);
if (r->result >= 0x18 && r->result <= 0xFE) {
- printf("illegal reserved result code: 0x%x!\n", r->result);
+ ND_PRINT((ndo, "illegal reserved result code: 0x%x!\n", r->result));
return -1;
}
- if (vflag >= 3) {
+ if (ndo->ndo_vflag >= 3) {
char *ib = indent_pr(indent, 0);
- printf("%s Result: %s (code 0x%x)\n", ib,
- tok2str(ForCES_errs, NULL, r->result), r->result);
+ ND_PRINT((ndo, "%s Result: %s (code 0x%x)\n", ib,
+ tok2str(ForCES_errs, NULL, r->result), r->result));
}
return 0;
trunc:
- fputs("[|forces]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
-int
-fdatatlv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk _U_, int indent)
+static int
+fdatatlv_print(netdissect_options *ndo,
+ register const u_char * pptr, register u_int len,
+ uint16_t op_msk _U_, int indent)
{
const struct forces_tlv *tlv = (struct forces_tlv *)pptr;
u_int rlen;
register const u_char *tdp = (u_char *) TLV_DATA(tlv);
- u_int16_t type;
+ uint16_t type;
/*
* pdatacnt_print() or pkeyitlv_print() has ensured that len
* (the TLV length) >= TLV_HDRL.
*/
rlen = len - TLV_HDRL;
- TCHECK(*tlv);
+ ND_TCHECK(*tlv);
type = EXTRACT_16BITS(&tlv->type);
if (type != F_TLV_FULD) {
- printf("Error: expecting FULLDATA!\n");
+ ND_PRINT((ndo, "Error: expecting FULLDATA!\n"));
return -1;
}
- if (vflag >= 3) {
+ if (ndo->ndo_vflag >= 3) {
char *ib = indent_pr(indent + 2, 1);
- printf("%s[", &ib[1]);
- hex_print_with_offset(ib, tdp, rlen, 0);
- printf("\n%s]\n", &ib[1]);
+ ND_PRINT((ndo, "%s[", &ib[1]));
+ hex_print_with_offset(ndo, ib, tdp, rlen, 0);
+ ND_PRINT((ndo, "\n%s]\n", &ib[1]));
}
return 0;
trunc:
- fputs("[|forces]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
-int
-sdatailv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk _U_, int indent)
+static int
+sdatailv_print(netdissect_options *ndo,
+ register const u_char * pptr, register u_int len,
+ uint16_t op_msk _U_, int indent)
{
u_int rlen;
const struct forces_ilv *ilv = (struct forces_ilv *)pptr;
int invilv;
if (len < ILV_HDRL) {
- printf("Error: BAD SPARSEDATA-TLV!\n");
+ ND_PRINT((ndo, "Error: BAD SPARSEDATA-TLV!\n"));
return -1;
}
rlen = len;
indent += 1;
while (rlen != 0) {
+#if 0
+ ND_PRINT((ndo, "Jamal - outstanding length <%d>\n", rlen));
+#endif
char *ib = indent_pr(indent, 1);
register const u_char *tdp = (u_char *) ILV_DATA(ilv);
- TCHECK(*ilv);
+ ND_TCHECK(*ilv);
invilv = ilv_valid(ilv, rlen);
if (invilv) {
- printf("%s[", &ib[1]);
- hex_print_with_offset(ib, tdp, rlen, 0);
- printf("\n%s]\n", &ib[1]);
+ ND_PRINT((ndo, "%s[", &ib[1]));
+ hex_print_with_offset(ndo, ib, tdp, rlen, 0);
+ ND_PRINT((ndo, "\n%s]\n", &ib[1]));
return -1;
}
- if (vflag >= 3) {
+ if (ndo->ndo_vflag >= 3) {
int ilvl = EXTRACT_32BITS(&ilv->length);
- printf("\n%s ILV: type %x length %d\n", &ib[1],
- EXTRACT_32BITS(&ilv->type), ilvl);
- hex_print_with_offset("\t\t[", tdp, ilvl-ILV_HDRL, 0);
+ ND_PRINT((ndo, "\n%s ILV: type %x length %d\n", &ib[1],
+ EXTRACT_32BITS(&ilv->type), ilvl));
+ hex_print_with_offset(ndo, "\t\t[", tdp, ilvl-ILV_HDRL, 0);
}
ilv = GO_NXT_ILV(ilv, rlen);
@@ -139,62 +754,64 @@ sdatailv_print(register const u_char * pptr, register u_int len,
return 0;
trunc:
- fputs("[|forces]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
-int
-sdatatlv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent)
+static int
+sdatatlv_print(netdissect_options *ndo,
+ register const u_char * pptr, register u_int len,
+ uint16_t op_msk, int indent)
{
const struct forces_tlv *tlv = (struct forces_tlv *)pptr;
u_int rlen;
register const u_char *tdp = (u_char *) TLV_DATA(tlv);
- u_int16_t type;
+ uint16_t type;
/*
* pdatacnt_print() has ensured that len (the TLV length)
* >= TLV_HDRL.
*/
rlen = len - TLV_HDRL;
- TCHECK(*tlv);
+ ND_TCHECK(*tlv);
type = EXTRACT_16BITS(&tlv->type);
if (type != F_TLV_SPAD) {
- printf("Error: expecting SPARSEDATA!\n");
+ ND_PRINT((ndo, "Error: expecting SPARSEDATA!\n"));
return -1;
}
- return sdatailv_print(tdp, rlen, op_msk, indent);
+ return sdatailv_print(ndo, tdp, rlen, op_msk, indent);
trunc:
- fputs("[|forces]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
-int
-pkeyitlv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent)
+static int
+pkeyitlv_print(netdissect_options *ndo,
+ register const u_char * pptr, register u_int len,
+ uint16_t op_msk, int indent)
{
const struct forces_tlv *tlv = (struct forces_tlv *)pptr;
register const u_char *tdp = (u_char *) TLV_DATA(tlv);
register const u_char *dp = tdp + 4;
const struct forces_tlv *kdtlv = (struct forces_tlv *)dp;
- u_int32_t id;
+ uint32_t id;
char *ib = indent_pr(indent, 0);
- u_int16_t type, tll;
- int invtlv;
+ uint16_t type, tll;
+ u_int invtlv;
- TCHECK(*tdp);
+ ND_TCHECK(*tdp);
id = EXTRACT_32BITS(tdp);
- printf("%sKeyinfo: Key 0x%x\n", ib, id);
- TCHECK(*kdtlv);
+ ND_PRINT((ndo, "%sKeyinfo: Key 0x%x\n", ib, id));
+ ND_TCHECK(*kdtlv);
type = EXTRACT_16BITS(&kdtlv->type);
invtlv = tlv_valid(kdtlv, len);
if (invtlv) {
- printf("%s TLV type 0x%x len %d\n",
+ ND_PRINT((ndo, "%s TLV type 0x%x len %d\n",
tok2str(ForCES_TLV_err, NULL, invtlv), type,
- EXTRACT_16BITS(&kdtlv->length));
+ EXTRACT_16BITS(&kdtlv->length)));
return -1;
}
/*
@@ -204,47 +821,113 @@ pkeyitlv_print(register const u_char * pptr, register u_int len,
*/
tll = EXTRACT_16BITS(&kdtlv->length);
dp = (u_char *) TLV_DATA(kdtlv);
- return fdatatlv_print(dp, tll, op_msk, indent);
+ return fdatatlv_print(ndo, dp, tll, op_msk, indent);
trunc:
- fputs("[|forces]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
-int
-pdatacnt_print(register const u_char * pptr, register u_int len,
- u_int16_t IDcnt, u_int16_t op_msk, int indent)
+#define PTH_DESC_SIZE 12
+
+static int
+pdatacnt_print(netdissect_options *ndo,
+ register const u_char * pptr, register u_int len,
+ uint16_t IDcnt, uint16_t op_msk, int indent)
{
u_int i;
- u_int32_t id;
+ uint32_t id;
char *ib = indent_pr(indent, 0);
+ if ((op_msk & B_APPND) && ndo->ndo_vflag >= 3) {
+ ND_PRINT((ndo, "%sTABLE APPEND\n", ib));
+ }
for (i = 0; i < IDcnt; i++) {
- TCHECK2(*pptr, 4);
+ ND_TCHECK2(*pptr, 4);
if (len < 4)
goto trunc;
id = EXTRACT_32BITS(pptr);
- if (vflag >= 3)
- printf("%s ID#%02u: %d\n", ib, i + 1, id);
+ if (ndo->ndo_vflag >= 3)
+ ND_PRINT((ndo, "%sID#%02u: %d\n", ib, i + 1, id));
len -= 4;
pptr += 4;
}
+
+ if ((op_msk & B_TRNG) || (op_msk & B_KEYIN)) {
+ if (op_msk & B_TRNG) {
+ uint32_t starti, endi;
+
+ if (len < PTH_DESC_SIZE) {
+ ND_PRINT((ndo, "pathlength %d with key/range too short %d\n",
+ len, PTH_DESC_SIZE));
+ return -1;
+ }
+
+ pptr += sizeof(struct forces_tlv);
+ len -= sizeof(struct forces_tlv);
+
+ starti = EXTRACT_32BITS(pptr);
+ pptr += 4;
+ len -= 4;
+
+ endi = EXTRACT_32BITS(pptr);
+ pptr += 4;
+ len -= 4;
+
+ if (ndo->ndo_vflag >= 3)
+ ND_PRINT((ndo, "%sTable range: [%d,%d]\n", ib, starti, endi));
+ }
+
+ if (op_msk & B_KEYIN) {
+ struct forces_tlv *keytlv;
+ uint16_t tll;
+
+ if (len < PTH_DESC_SIZE) {
+ ND_PRINT((ndo, "pathlength %d with key/range too short %d\n",
+ len, PTH_DESC_SIZE));
+ return -1;
+ }
+
+ /* skip keyid */
+ pptr += 4;
+ len -= 4;
+ keytlv = (struct forces_tlv *)pptr;
+ /* skip header */
+ pptr += sizeof(struct forces_tlv);
+ len -= sizeof(struct forces_tlv);
+ /* skip key content */
+ tll = EXTRACT_16BITS(&keytlv->length);
+ if (tll < TLV_HDRL) {
+ ND_PRINT((ndo, "key content length %u < %u\n",
+ tll, TLV_HDRL));
+ return -1;
+ }
+ tll -= TLV_HDRL;
+ if (len < tll) {
+ ND_PRINT((ndo, "key content too short\n"));
+ return -1;
+ }
+ pptr += tll;
+ len -= tll;
+ }
+
+ }
+
if (len) {
const struct forces_tlv *pdtlv = (struct forces_tlv *)pptr;
- u_int16_t type;
- u_int16_t tll;
+ uint16_t type;
+ uint16_t tll;
int pad = 0;
u_int aln;
- int invtlv;
+ u_int invtlv;
- TCHECK(*pdtlv);
+ ND_TCHECK(*pdtlv);
type = EXTRACT_16BITS(&pdtlv->type);
invtlv = tlv_valid(pdtlv, len);
if (invtlv) {
- printf
- ("%s Outstanding bytes %d for TLV type 0x%x TLV len %d\n",
- tok2str(ForCES_TLV_err, NULL, invtlv), len, type,
- EXTRACT_16BITS(&pdtlv->length));
+ ND_PRINT((ndo, "%s Outstanding bytes %d for TLV type 0x%x TLV len %d\n",
+ tok2str(ForCES_TLV_err, NULL, invtlv), len, type,
+ EXTRACT_16BITS(&pdtlv->length)));
goto pd_err;
}
/*
@@ -256,9 +939,9 @@ pdatacnt_print(register const u_char * pptr, register u_int len,
aln = F_ALN_LEN(EXTRACT_16BITS(&pdtlv->length));
if (aln > EXTRACT_16BITS(&pdtlv->length)) {
if (aln > len) {
- printf
- ("Invalid padded pathdata TLV type 0x%x len %d missing %d pad bytes\n",
- type, EXTRACT_16BITS(&pdtlv->length), aln - len);
+ ND_PRINT((ndo,
+ "Invalid padded pathdata TLV type 0x%x len %d missing %d pad bytes\n",
+ type, EXTRACT_16BITS(&pdtlv->length), aln - len));
} else {
pad = aln - EXTRACT_16BITS(&pdtlv->length);
}
@@ -266,34 +949,30 @@ pdatacnt_print(register const u_char * pptr, register u_int len,
if (pd_valid(type)) {
const struct pdata_ops *ops = get_forces_pd(type);
- if (vflag >= 3 && ops->v != F_TLV_PDAT) {
+ if (ndo->ndo_vflag >= 3 && ops->v != F_TLV_PDAT) {
if (pad)
- printf
- ("%s %s (Length %d DataLen %d pad %d Bytes)\n",
- ib, ops->s, EXTRACT_16BITS(&pdtlv->length),
- tll, pad);
+ ND_PRINT((ndo, "%s %s (Length %d DataLen %d pad %d Bytes)\n",
+ ib, ops->s, EXTRACT_16BITS(&pdtlv->length), tll, pad));
else
- printf
- ("%s %s (Length %d DataLen %d Bytes)\n",
- ib, ops->s, EXTRACT_16BITS(&pdtlv->length),
- tll);
+ ND_PRINT((ndo, "%s %s (Length %d DataLen %d Bytes)\n",
+ ib, ops->s, EXTRACT_16BITS(&pdtlv->length), tll));
}
- chk_op_type(type, op_msk, ops->op_msk);
+ chk_op_type(ndo, type, op_msk, ops->op_msk);
- if (ops->print((const u_char *)pdtlv,
+ if (ops->print(ndo, (const u_char *)pdtlv,
tll + pad + TLV_HDRL, op_msk,
indent + 2) == -1)
return -1;
len -= (TLV_HDRL + pad + tll);
} else {
- printf("Invalid path data content type 0x%x len %d\n",
- type, EXTRACT_16BITS(&pdtlv->length));
+ ND_PRINT((ndo, "Invalid path data content type 0x%x len %d\n",
+ type, EXTRACT_16BITS(&pdtlv->length)));
pd_err:
if (EXTRACT_16BITS(&pdtlv->length)) {
- hex_print_with_offset("Bad Data val\n\t [",
+ hex_print_with_offset(ndo, "Bad Data val\n\t [",
pptr, len, 0);
- printf("]\n");
+ ND_PRINT((ndo, "]\n"));
return -1;
}
@@ -302,73 +981,91 @@ pd_err:
return len;
trunc:
- fputs("[|forces]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
-int
-pdata_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent)
+static int
+pdata_print(netdissect_options *ndo,
+ register const u_char * pptr, register u_int len,
+ uint16_t op_msk, int indent)
{
const struct pathdata_h *pdh = (struct pathdata_h *)pptr;
char *ib = indent_pr(indent, 0);
u_int minsize = 0;
int more_pd = 0;
- u_int16_t idcnt = 0;
+ uint16_t idcnt = 0;
- TCHECK(*pdh);
+ ND_TCHECK(*pdh);
if (len < sizeof(struct pathdata_h))
goto trunc;
- if (vflag >= 3) {
- printf("\n%sPathdata: Flags 0x%x ID count %d\n",
- ib, EXTRACT_16BITS(&pdh->pflags), EXTRACT_16BITS(&pdh->pIDcnt));
+ if (ndo->ndo_vflag >= 3) {
+ ND_PRINT((ndo, "\n%sPathdata: Flags 0x%x ID count %d\n",
+ ib, EXTRACT_16BITS(&pdh->pflags), EXTRACT_16BITS(&pdh->pIDcnt)));
}
if (EXTRACT_16BITS(&pdh->pflags) & F_SELKEY) {
op_msk |= B_KEYIN;
}
+
+ /* Table GET Range operation */
+ if (EXTRACT_16BITS(&pdh->pflags) & F_SELTABRANGE) {
+ op_msk |= B_TRNG;
+ }
+ /* Table SET append operation */
+ if (EXTRACT_16BITS(&pdh->pflags) & F_TABAPPEND) {
+ op_msk |= B_APPND;
+ }
+
pptr += sizeof(struct pathdata_h);
len -= sizeof(struct pathdata_h);
idcnt = EXTRACT_16BITS(&pdh->pIDcnt);
minsize = idcnt * 4;
if (len < minsize) {
- printf("\t\t\ttruncated IDs expected %uB got %uB\n", minsize,
- len);
- hex_print_with_offset("\t\t\tID Data[", pptr, len, 0);
- printf("]\n");
+ ND_PRINT((ndo, "\t\t\ttruncated IDs expected %uB got %uB\n", minsize,
+ len));
+ hex_print_with_offset(ndo, "\t\t\tID Data[", pptr, len, 0);
+ ND_PRINT((ndo, "]\n"));
return -1;
}
- more_pd = pdatacnt_print(pptr, len, idcnt, op_msk, indent);
+
+ if ((op_msk & B_TRNG) && (op_msk & B_KEYIN)) {
+ ND_PRINT((ndo, "\t\t\tIllegal to have both Table ranges and keys\n"));
+ return -1;
+ }
+
+ more_pd = pdatacnt_print(ndo, pptr, len, idcnt, op_msk, indent);
if (more_pd > 0) {
int consumed = len - more_pd;
pptr += consumed;
- len = more_pd;
+ len = more_pd;
/* XXX: Argh, recurse some more */
- return recpdoptlv_print(pptr, len, op_msk, indent+1);
+ return recpdoptlv_print(ndo, pptr, len, op_msk, indent+1);
} else
return 0;
trunc:
- fputs("[|forces]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
-int
-genoptlv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent)
+static int
+genoptlv_print(netdissect_options *ndo,
+ register const u_char * pptr, register u_int len,
+ uint16_t op_msk, int indent)
{
const struct forces_tlv *pdtlv = (struct forces_tlv *)pptr;
- u_int16_t type;
+ uint16_t type;
int tll;
- int invtlv;
+ u_int invtlv;
char *ib = indent_pr(indent, 0);
- TCHECK(*pdtlv);
+ ND_TCHECK(*pdtlv);
type = EXTRACT_16BITS(&pdtlv->type);
tll = EXTRACT_16BITS(&pdtlv->length) - TLV_HDRL;
invtlv = tlv_valid(pdtlv, len);
- printf("genoptlvprint - %s TLV type 0x%x len %d\n",
- tok2str(ForCES_TLV, NULL, type), type, EXTRACT_16BITS(&pdtlv->length));
+ ND_PRINT((ndo, "genoptlvprint - %s TLV type 0x%x len %d\n",
+ tok2str(ForCES_TLV, NULL, type), type, EXTRACT_16BITS(&pdtlv->length)));
if (!invtlv) {
/*
* At this point, tlv_valid() has ensured that the TLV
@@ -377,40 +1074,41 @@ genoptlv_print(register const u_char * pptr, register u_int len,
*/
register const u_char *dp = (u_char *) TLV_DATA(pdtlv);
if (!ttlv_valid(type)) {
- printf("%s TLV type 0x%x len %d\n",
+ ND_PRINT((ndo, "%s TLV type 0x%x len %d\n",
tok2str(ForCES_TLV_err, NULL, invtlv), type,
- EXTRACT_16BITS(&pdtlv->length));
+ EXTRACT_16BITS(&pdtlv->length)));
return -1;
}
- if (vflag >= 3)
- printf("%s%s, length %d (data length %d Bytes)",
+ if (ndo->ndo_vflag >= 3)
+ ND_PRINT((ndo, "%s%s, length %d (data length %d Bytes)",
ib, tok2str(ForCES_TLV, NULL, type),
- EXTRACT_16BITS(&pdtlv->length), tll);
+ EXTRACT_16BITS(&pdtlv->length), tll));
- return pdata_print(dp, tll, op_msk, indent + 1);
+ return pdata_print(ndo, dp, tll, op_msk, indent + 1);
} else {
- printf("\t\t\tInvalid ForCES TLV type=%x", type);
+ ND_PRINT((ndo, "\t\t\tInvalid ForCES TLV type=%x", type));
return -1;
}
trunc:
- fputs("[|forces]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
-int
-recpdoptlv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent)
+static int
+recpdoptlv_print(netdissect_options *ndo,
+ register const u_char * pptr, register u_int len,
+ uint16_t op_msk, int indent)
{
const struct forces_tlv *pdtlv = (struct forces_tlv *)pptr;
int tll;
- int invtlv;
- u_int16_t type;
+ u_int invtlv;
+ uint16_t type;
register const u_char *dp;
char *ib;
while (len != 0) {
- TCHECK(*pdtlv);
+ ND_TCHECK(*pdtlv);
invtlv = tlv_valid(pdtlv, len);
if (invtlv) {
break;
@@ -426,51 +1124,53 @@ recpdoptlv_print(register const u_char * pptr, register u_int len,
dp = (u_char *) TLV_DATA(pdtlv);
tll = EXTRACT_16BITS(&pdtlv->length) - TLV_HDRL;
- if (vflag >= 3)
- printf
- ("%s%s, length %d (data encapsulated %d Bytes)",
- ib, tok2str(ForCES_TLV, NULL, type),
- EXTRACT_16BITS(&pdtlv->length),
- EXTRACT_16BITS(&pdtlv->length) - TLV_HDRL);
+ if (ndo->ndo_vflag >= 3)
+ ND_PRINT((ndo, "%s%s, length %d (data encapsulated %d Bytes)",
+ ib, tok2str(ForCES_TLV, NULL, type),
+ EXTRACT_16BITS(&pdtlv->length),
+ EXTRACT_16BITS(&pdtlv->length) - TLV_HDRL));
- if (pdata_print(dp, tll, op_msk, indent + 1) == -1)
+ if (pdata_print(ndo, dp, tll, op_msk, indent + 1) == -1)
return -1;
pdtlv = GO_NXT_TLV(pdtlv, len);
}
if (len) {
- printf
- ("\n\t\tMessy PATHDATA TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
- EXTRACT_16BITS(&pdtlv->type), len - EXTRACT_16BITS(&pdtlv->length));
+ ND_PRINT((ndo,
+ "\n\t\tMessy PATHDATA TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
+ EXTRACT_16BITS(&pdtlv->type), len - EXTRACT_16BITS(&pdtlv->length)));
return -1;
}
return 0;
trunc:
- fputs("[|forces]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
-int
-invoptlv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk _U_, int indent)
+static int
+invoptlv_print(netdissect_options *ndo,
+ register const u_char * pptr, register u_int len,
+ uint16_t op_msk _U_, int indent)
{
char *ib = indent_pr(indent, 1);
- if (vflag >= 3) {
- printf("%sData[", &ib[1]);
- hex_print_with_offset(ib, pptr, len, 0);
- printf("%s]\n", ib);
+ if (ndo->ndo_vflag >= 3) {
+ ND_PRINT((ndo, "%sData[", &ib[1]));
+ hex_print_with_offset(ndo, ib, pptr, len, 0);
+ ND_PRINT((ndo, "%s]\n", ib));
}
return -1;
}
-int otlv_print(const struct forces_tlv *otlv, u_int16_t op_msk _U_, int indent)
+static int
+otlv_print(netdissect_options *ndo,
+ const struct forces_tlv *otlv, uint16_t op_msk _U_, int indent)
{
int rc = 0;
register const u_char *dp = (u_char *) TLV_DATA(otlv);
- u_int16_t type;
+ uint16_t type;
int tll;
char *ib = indent_pr(indent, 0);
const struct optlv_h *ops;
@@ -479,45 +1179,46 @@ int otlv_print(const struct forces_tlv *otlv, u_int16_t op_msk _U_, int indent)
* lfbselect_print() has ensured that EXTRACT_16BITS(&otlv->length)
* >= TLV_HDRL.
*/
- TCHECK(*otlv);
+ ND_TCHECK(*otlv);
type = EXTRACT_16BITS(&otlv->type);
tll = EXTRACT_16BITS(&otlv->length) - TLV_HDRL;
ops = get_forces_optlv_h(type);
- if (vflag >= 3) {
- printf("%sOper TLV %s(0x%x) length %d\n", ib, ops->s, type,
- EXTRACT_16BITS(&otlv->length));
+ if (ndo->ndo_vflag >= 3) {
+ ND_PRINT((ndo, "%sOper TLV %s(0x%x) length %d\n", ib, ops->s, type,
+ EXTRACT_16BITS(&otlv->length)));
}
/* empty TLVs like COMMIT and TRCOMMIT are empty, we stop here .. */
if (!ops->flags & ZERO_TTLV) {
if (tll != 0) /* instead of "if (tll)" - for readability .. */
- printf("%s: Illegal - MUST be empty\n", ops->s);
+ ND_PRINT((ndo, "%s: Illegal - MUST be empty\n", ops->s));
return rc;
}
/* rest of ops must at least have 12B {pathinfo} */
if (tll < OP_MIN_SIZ) {
- printf("\t\tOper TLV %s(0x%x) length %d\n", ops->s, type,
- EXTRACT_16BITS(&otlv->length));
- printf("\t\tTruncated data size %d minimum required %d\n", tll,
- OP_MIN_SIZ);
- return invoptlv_print(dp, tll, ops->op_msk, indent);
+ ND_PRINT((ndo, "\t\tOper TLV %s(0x%x) length %d\n", ops->s, type,
+ EXTRACT_16BITS(&otlv->length)));
+ ND_PRINT((ndo, "\t\tTruncated data size %d minimum required %d\n", tll,
+ OP_MIN_SIZ));
+ return invoptlv_print(ndo, dp, tll, ops->op_msk, indent);
}
- rc = ops->print(dp, tll, ops->op_msk, indent + 1);
+ rc = ops->print(ndo, dp, tll, ops->op_msk, indent + 1);
return rc;
trunc:
- fputs("[|forces]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
#define ASTDLN 4
#define ASTMCD 255
-int
-asttlv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk _U_, int indent)
+static int
+asttlv_print(netdissect_options *ndo,
+ register const u_char * pptr, register u_int len,
+ uint16_t op_msk _U_, int indent)
{
- u_int32_t rescode;
+ uint32_t rescode;
u_int dlen;
char *ib = indent_pr(indent, 0);
@@ -527,54 +1228,55 @@ asttlv_print(register const u_char * pptr, register u_int len,
*/
dlen = len - TLV_HDRL;
if (dlen != ASTDLN) {
- printf("illegal ASTresult-TLV: %d bytes!\n", dlen);
+ ND_PRINT((ndo, "illegal ASTresult-TLV: %d bytes!\n", dlen));
return -1;
}
- TCHECK2(*pptr, 4);
+ ND_TCHECK2(*pptr, 4);
rescode = EXTRACT_32BITS(pptr);
if (rescode > ASTMCD) {
- printf("illegal ASTresult result code: %d!\n", rescode);
+ ND_PRINT((ndo, "illegal ASTresult result code: %d!\n", rescode));
return -1;
}
- if (vflag >= 3) {
- printf("Teardown reason:\n%s", ib);
+ if (ndo->ndo_vflag >= 3) {
+ ND_PRINT((ndo, "Teardown reason:\n%s", ib));
switch (rescode) {
case 0:
- printf("Normal Teardown");
+ ND_PRINT((ndo, "Normal Teardown"));
break;
case 1:
- printf("Loss of Heartbeats");
+ ND_PRINT((ndo, "Loss of Heartbeats"));
break;
case 2:
- printf("Out of bandwidth");
+ ND_PRINT((ndo, "Out of bandwidth"));
break;
case 3:
- printf("Out of Memory");
+ ND_PRINT((ndo, "Out of Memory"));
break;
case 4:
- printf("Application Crash");
+ ND_PRINT((ndo, "Application Crash"));
break;
default:
- printf("Unknown Teardown reason");
+ ND_PRINT((ndo, "Unknown Teardown reason"));
break;
}
- printf("(%x)\n%s", rescode, ib);
+ ND_PRINT((ndo, "(%x)\n%s", rescode, ib));
}
return 0;
trunc:
- fputs("[|forces]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
#define ASRDLN 4
#define ASRMCD 3
-int
-asrtlv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk _U_, int indent)
+static int
+asrtlv_print(netdissect_options *ndo,
+ register const u_char * pptr, register u_int len,
+ uint16_t op_msk _U_, int indent)
{
- u_int32_t rescode;
+ uint32_t rescode;
u_int dlen;
char *ib = indent_pr(indent, 0);
@@ -584,64 +1286,67 @@ asrtlv_print(register const u_char * pptr, register u_int len,
*/
dlen = len - TLV_HDRL;
if (dlen != ASRDLN) { /* id, instance, oper tlv */
- printf("illegal ASRresult-TLV: %d bytes!\n", dlen);
+ ND_PRINT((ndo, "illegal ASRresult-TLV: %d bytes!\n", dlen));
return -1;
}
- TCHECK2(*pptr, 4);
+ ND_TCHECK2(*pptr, 4);
rescode = EXTRACT_32BITS(pptr);
if (rescode > ASRMCD) {
- printf("illegal ASRresult result code: %d!\n", rescode);
+ ND_PRINT((ndo, "illegal ASRresult result code: %d!\n", rescode));
return -1;
}
- if (vflag >= 3) {
- printf("\n%s", ib);
+ if (ndo->ndo_vflag >= 3) {
+ ND_PRINT((ndo, "\n%s", ib));
switch (rescode) {
case 0:
- printf("Success ");
+ ND_PRINT((ndo, "Success "));
break;
case 1:
- printf("FE ID invalid ");
+ ND_PRINT((ndo, "FE ID invalid "));
break;
case 2:
- printf("permission denied ");
+ ND_PRINT((ndo, "permission denied "));
break;
default:
- printf("Unknown ");
+ ND_PRINT((ndo, "Unknown "));
break;
}
- printf("(%x)\n%s", rescode, ib);
+ ND_PRINT((ndo, "(%x)\n%s", rescode, ib));
}
return 0;
trunc:
- fputs("[|forces]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
+#if 0
/*
* XXX - not used.
*/
-int
-gentltlv_print(register const u_char * pptr _U_, register u_int len,
- u_int16_t op_msk _U_, int indent _U_)
+static int
+gentltlv_print(netdissect_options *ndo,
+ register const u_char * pptr _U_, register u_int len,
+ uint16_t op_msk _U_, int indent _U_)
{
u_int dlen = len - TLV_HDRL;
if (dlen < 4) { /* at least 32 bits must exist */
- printf("truncated TLV: %d bytes missing! ", 4 - dlen);
+ ND_PRINT((ndo, "truncated TLV: %d bytes missing! ", 4 - dlen));
return -1;
}
return 0;
}
+#endif
#define RD_MIN 8
-int
-print_metailv(register const u_char * pptr, register u_int len,
- u_int16_t op_msk _U_, int indent)
+
+static int
+print_metailv(netdissect_options *ndo,
+ register const u_char * pptr, uint16_t op_msk _U_, int indent)
{
- u_int dlen;
u_int rlen;
char *ib = indent_pr(indent, 0);
/* XXX: check header length */
@@ -651,22 +1356,25 @@ print_metailv(register const u_char * pptr, register u_int len,
* print_metatlv() has ensured that len (what remains in the
* ILV) >= ILV_HDRL.
*/
- dlen = len - ILV_HDRL;
- rlen = dlen;
- TCHECK(*ilv);
- printf("\n%sMetaID 0x%x length %d\n", ib, EXTRACT_32BITS(&ilv->type),
- EXTRACT_32BITS(&ilv->length));
- hex_print_with_offset("\n\t\t\t\t[", ILV_DATA(ilv), rlen, 0);
+ rlen = EXTRACT_32BITS(&ilv->length) - ILV_HDRL;
+ ND_TCHECK(*ilv);
+ ND_PRINT((ndo, "%sMetaID 0x%x length %d\n", ib, EXTRACT_32BITS(&ilv->type),
+ EXTRACT_32BITS(&ilv->length)));
+ if (ndo->ndo_vflag >= 3) {
+ hex_print_with_offset(ndo, "\t\t[", ILV_DATA(ilv), rlen, 0);
+ ND_PRINT((ndo, " ]\n"));
+ }
return 0;
trunc:
- fputs("[|forces]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
-int
-print_metatlv(register const u_char * pptr, register u_int len,
- u_int16_t op_msk _U_, int indent)
+static int
+print_metatlv(netdissect_options *ndo,
+ register const u_char * pptr, register u_int len,
+ uint16_t op_msk _U_, int indent)
{
u_int dlen;
char *ib = indent_pr(indent, 0);
@@ -680,85 +1388,62 @@ print_metatlv(register const u_char * pptr, register u_int len,
*/
dlen = len - TLV_HDRL;
rlen = dlen;
- printf("\n%s METADATA\n", ib);
+ ND_PRINT((ndo, "\n%s METADATA length %d \n", ib, rlen));
while (rlen != 0) {
- TCHECK(*ilv);
+ ND_TCHECK(*ilv);
invilv = ilv_valid(ilv, rlen);
- if (invilv)
+ if (invilv) {
break;
+ }
/*
* At this point, ilv_valid() has ensured that the ILV
* length is large enough but not too large (it doesn't
* go past the end of the containing TLV).
*/
- print_metailv((u_char *) ilv, rlen, 0, indent + 1);
-
+ print_metailv(ndo, (u_char *) ilv, 0, indent + 1);
ilv = GO_NXT_ILV(ilv, rlen);
}
return 0;
trunc:
- fputs("[|forces]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
-/*
-*/
-int
-print_reddata(register const u_char * pptr, register u_int len,
- u_int16_t op_msk _U_, int indent _U_)
+
+static int
+print_reddata(netdissect_options *ndo,
+ register const u_char * pptr, register u_int len,
+ uint16_t op_msk _U_, int indent _U_)
{
u_int dlen;
+ char *ib = indent_pr(indent, 0);
u_int rlen;
- int invtlv;
- const struct forces_tlv *tlv = (struct forces_tlv *)pptr;
- /*
- * redirect_print() has ensured that len (what remains in the
- * TLV) >= TLV_HDRL.
- */
dlen = len - TLV_HDRL;
- printf("\n\t\t Redirect DATA\n");
- if (dlen <= RD_MIN) {
- printf("\n\t\ttruncated Redirect data: %d bytes missing! ",
- RD_MIN - dlen);
- return -1;
- }
-
rlen = dlen;
- TCHECK(*tlv);
- invtlv = tlv_valid(tlv, rlen);
+ ND_PRINT((ndo, "\n%s Redirect Data length %d \n", ib, rlen));
- if (invtlv) {
- printf("Redir data type 0x%x len %d\n", EXTRACT_16BITS(&tlv->type),
- EXTRACT_16BITS(&tlv->length));
- return -1;
+ if (ndo->ndo_vflag >= 3) {
+ ND_PRINT((ndo, "\t\t["));
+ hex_print_with_offset(ndo, "\n\t\t", pptr, rlen, 0);
+ ND_PRINT((ndo, "\n\t\t]"));
}
- /*
- * At this point, tlv_valid() has ensured that the TLV
- * length is large enough but not too large (it doesn't
- * go past the end of the containing TLV).
- */
- rlen -= TLV_HDRL;
- hex_print_with_offset("\n\t\t\t[", TLV_DATA(tlv), rlen, 0);
return 0;
-
-trunc:
- fputs("[|forces]", stdout);
- return -1;
}
-int
-redirect_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk _U_, int indent)
+static int
+redirect_print(netdissect_options *ndo,
+ register const u_char * pptr, register u_int len,
+ uint16_t op_msk _U_, int indent)
{
const struct forces_tlv *tlv = (struct forces_tlv *)pptr;
u_int dlen;
u_int rlen;
- int invtlv;
+ u_int invtlv;
/*
* forces_type_print() has ensured that len (the TLV length)
@@ -766,18 +1451,20 @@ redirect_print(register const u_char * pptr, register u_int len,
*/
dlen = len - TLV_HDRL;
if (dlen <= RD_MIN) {
- printf("\n\t\ttruncated Redirect TLV: %d bytes missing! ",
- RD_MIN - dlen);
+ ND_PRINT((ndo, "\n\t\ttruncated Redirect TLV: %d bytes missing! ",
+ RD_MIN - dlen));
return -1;
}
rlen = dlen;
indent += 1;
while (rlen != 0) {
- TCHECK(*tlv);
+ ND_TCHECK(*tlv);
invtlv = tlv_valid(tlv, rlen);
- if (invtlv)
+ if (invtlv) {
+ ND_PRINT((ndo, "Bad Redirect data\n"));
break;
+ }
/*
* At this point, tlv_valid() has ensured that the TLV
@@ -785,44 +1472,49 @@ redirect_print(register const u_char * pptr, register u_int len,
* go past the end of the containing TLV).
*/
if (EXTRACT_16BITS(&tlv->type) == F_TLV_METD) {
- print_metatlv((u_char *) TLV_DATA(tlv), rlen, 0, indent);
+ print_metatlv(ndo, (u_char *) TLV_DATA(tlv),
+ EXTRACT_16BITS(&tlv->length), 0, indent);
} else if ((EXTRACT_16BITS(&tlv->type) == F_TLV_REDD)) {
- print_reddata((u_char *) TLV_DATA(tlv), rlen, 0, indent);
+ print_reddata(ndo, (u_char *) TLV_DATA(tlv),
+ EXTRACT_16BITS(&tlv->length), 0, indent);
} else {
- printf("Unknown REDIRECT TLV 0x%x len %d\n",
- EXTRACT_16BITS(&tlv->type), EXTRACT_16BITS(&tlv->length));
+ ND_PRINT((ndo, "Unknown REDIRECT TLV 0x%x len %d\n",
+ EXTRACT_16BITS(&tlv->type),
+ EXTRACT_16BITS(&tlv->length)));
}
tlv = GO_NXT_TLV(tlv, rlen);
}
if (rlen) {
- printf
- ("\n\t\tMessy Redirect TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
- EXTRACT_16BITS(&tlv->type), rlen - EXTRACT_16BITS(&tlv->length));
+ ND_PRINT((ndo,
+ "\n\t\tMessy Redirect TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
+ EXTRACT_16BITS(&tlv->type),
+ rlen - EXTRACT_16BITS(&tlv->length)));
return -1;
}
return 0;
trunc:
- fputs("[|forces]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
#define OP_OFF 8
#define OP_MIN 12
-int
-lfbselect_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent)
+static int
+lfbselect_print(netdissect_options *ndo,
+ register const u_char * pptr, register u_int len,
+ uint16_t op_msk, int indent)
{
const struct forces_lfbsh *lfbs;
const struct forces_tlv *otlv;
char *ib = indent_pr(indent, 0);
u_int dlen;
u_int rlen;
- int invtlv;
+ u_int invtlv;
/*
* forces_type_print() has ensured that len (the TLV length)
@@ -830,8 +1522,8 @@ lfbselect_print(register const u_char * pptr, register u_int len,
*/
dlen = len - TLV_HDRL;
if (dlen <= OP_MIN) { /* id, instance, oper tlv header .. */
- printf("\n\t\ttruncated lfb selector: %d bytes missing! ",
- OP_MIN - dlen);
+ ND_PRINT((ndo, "\n\t\ttruncated lfb selector: %d bytes missing! ",
+ OP_MIN - dlen));
return -1;
}
@@ -842,19 +1534,19 @@ lfbselect_print(register const u_char * pptr, register u_int len,
rlen = dlen - OP_OFF;
lfbs = (const struct forces_lfbsh *)pptr;
- TCHECK(*lfbs);
- if (vflag >= 3) {
- printf("\n%s%s(Classid %x) instance %x\n",
+ ND_TCHECK(*lfbs);
+ if (ndo->ndo_vflag >= 3) {
+ ND_PRINT((ndo, "\n%s%s(Classid %x) instance %x\n",
ib, tok2str(ForCES_LFBs, NULL, EXTRACT_32BITS(&lfbs->class)),
EXTRACT_32BITS(&lfbs->class),
- EXTRACT_32BITS(&lfbs->instance));
+ EXTRACT_32BITS(&lfbs->instance)));
}
otlv = (struct forces_tlv *)(lfbs + 1);
indent += 1;
while (rlen != 0) {
- TCHECK(*otlv);
+ ND_TCHECK(*otlv);
invtlv = tlv_valid(otlv, rlen);
if (invtlv)
break;
@@ -865,39 +1557,40 @@ lfbselect_print(register const u_char * pptr, register u_int len,
* go past the end of the containing TLV).
*/
if (op_valid(EXTRACT_16BITS(&otlv->type), op_msk)) {
- otlv_print(otlv, 0, indent);
+ otlv_print(ndo, otlv, 0, indent);
} else {
- if (vflag < 3)
- printf("\n");
- printf
- ("\t\tINValid oper-TLV type 0x%x length %d for this ForCES message\n",
- EXTRACT_16BITS(&otlv->type), EXTRACT_16BITS(&otlv->length));
- invoptlv_print((u_char *)otlv, rlen, 0, indent);
+ if (ndo->ndo_vflag < 3)
+ ND_PRINT((ndo, "\n"));
+ ND_PRINT((ndo,
+ "\t\tINValid oper-TLV type 0x%x length %d for this ForCES message\n",
+ EXTRACT_16BITS(&otlv->type), EXTRACT_16BITS(&otlv->length)));
+ invoptlv_print(ndo, (u_char *)otlv, rlen, 0, indent);
}
otlv = GO_NXT_TLV(otlv, rlen);
}
if (rlen) {
- printf
- ("\n\t\tMessy oper TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
- EXTRACT_16BITS(&otlv->type), rlen - EXTRACT_16BITS(&otlv->length));
+ ND_PRINT((ndo,
+ "\n\t\tMessy oper TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
+ EXTRACT_16BITS(&otlv->type), rlen - EXTRACT_16BITS(&otlv->length)));
return -1;
}
return 0;
trunc:
- fputs("[|forces]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
-int
-forces_type_print(register const u_char * pptr, const struct forcesh *fhdr _U_,
- register u_int mlen, const struct tom_h *tops)
+static int
+forces_type_print(netdissect_options *ndo,
+ register const u_char * pptr, const struct forcesh *fhdr _U_,
+ register u_int mlen, const struct tom_h *tops)
{
const struct forces_tlv *tltlv;
u_int rlen;
- int invtlv;
+ u_int invtlv;
int rc = 0;
int ttlv = 0;
@@ -909,14 +1602,14 @@ forces_type_print(register const u_char * pptr, const struct forcesh *fhdr _U_,
if (rlen > TLV_HLN) {
if (tops->flags & ZERO_TTLV) {
- printf("<0x%x>Illegal Top level TLV!\n", tops->flags);
+ ND_PRINT((ndo, "<0x%x>Illegal Top level TLV!\n", tops->flags));
return -1;
}
} else {
if (tops->flags & ZERO_MORE_TTLV)
return 0;
if (tops->flags & ONE_MORE_TTLV) {
- printf("\tTop level TLV Data missing!\n");
+ ND_PRINT((ndo, "\tTop level TLV Data missing!\n"));
return -1;
}
}
@@ -931,7 +1624,7 @@ forces_type_print(register const u_char * pptr, const struct forcesh *fhdr _U_,
/*XXX: 15 top level tlvs will probably be fine
You are nuts if you send more ;-> */
while (rlen != 0) {
- TCHECK(*tltlv);
+ ND_TCHECK(*tltlv);
invtlv = tlv_valid(tltlv, rlen);
if (invtlv)
break;
@@ -942,18 +1635,18 @@ forces_type_print(register const u_char * pptr, const struct forcesh *fhdr _U_,
* go past the end of the packet).
*/
if (!ttlv_valid(EXTRACT_16BITS(&tltlv->type))) {
- printf("\n\tInvalid ForCES Top TLV type=0x%x",
- EXTRACT_16BITS(&tltlv->type));
+ ND_PRINT((ndo, "\n\tInvalid ForCES Top TLV type=0x%x",
+ EXTRACT_16BITS(&tltlv->type)));
return -1;
}
- if (vflag >= 3)
- printf("\t%s, length %d (data length %d Bytes)",
+ if (ndo->ndo_vflag >= 3)
+ ND_PRINT((ndo, "\t%s, length %d (data length %d Bytes)",
tok2str(ForCES_TLV, NULL, EXTRACT_16BITS(&tltlv->type)),
EXTRACT_16BITS(&tltlv->length),
- EXTRACT_16BITS(&tltlv->length) - TLV_HDRL);
+ EXTRACT_16BITS(&tltlv->length) - TLV_HDRL));
- rc = tops->print((u_char *) TLV_DATA(tltlv),
+ rc = tops->print(ndo, (u_char *) TLV_DATA(tltlv),
EXTRACT_16BITS(&tltlv->length), tops->op_msk, 9);
if (rc < 0) {
return -1;
@@ -968,30 +1661,32 @@ forces_type_print(register const u_char * pptr, const struct forcesh *fhdr _U_,
* short, and didn't have *enough* TLVs in it?
*/
if (rlen) {
- printf("\tMess TopTLV header: min %u, total %d advertised %d ",
- TLV_HDRL, rlen, EXTRACT_16BITS(&tltlv->length));
+ ND_PRINT((ndo, "\tMess TopTLV header: min %u, total %d advertised %d ",
+ TLV_HDRL, rlen, EXTRACT_16BITS(&tltlv->length)));
return -1;
}
return 0;
trunc:
- fputs("[|forces]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
-void forces_print(register const u_char * pptr, register u_int len)
+void
+forces_print(netdissect_options *ndo,
+ register const u_char * pptr, register u_int len)
{
const struct forcesh *fhdr;
u_int mlen;
- u_int32_t flg_raw;
+ uint32_t flg_raw;
const struct tom_h *tops;
int rc = 0;
fhdr = (const struct forcesh *)pptr;
- TCHECK(*fhdr);
+ ND_TCHECK(*fhdr);
if (!tom_valid(fhdr->fm_tom)) {
- printf("Invalid ForCES message type %d\n", fhdr->fm_tom);
+ ND_PRINT((ndo, "Invalid ForCES message type %d\n", fhdr->fm_tom));
goto error;
}
@@ -999,57 +1694,68 @@ void forces_print(register const u_char * pptr, register u_int len)
tops = get_forces_tom(fhdr->fm_tom);
if (tops->v == TOM_RSVD) {
- printf("\n\tUnknown ForCES message type=0x%x", fhdr->fm_tom);
+ ND_PRINT((ndo, "\n\tUnknown ForCES message type=0x%x", fhdr->fm_tom));
goto error;
}
- printf("\n\tForCES %s ", tops->s);
+ ND_PRINT((ndo, "\n\tForCES %s ", tops->s));
if (!ForCES_HLN_VALID(mlen, len)) {
- printf
- ("Illegal ForCES pkt len - min %u, total recvd %d, advertised %d ",
- ForCES_HDRL, len, ForCES_BLN(fhdr));
+ ND_PRINT((ndo,
+ "Illegal ForCES pkt len - min %u, total recvd %d, advertised %d ",
+ ForCES_HDRL, len, ForCES_BLN(fhdr)));
goto error;
}
- TCHECK2(*(pptr + 20), 4);
+ ND_TCHECK2(*(pptr + 20), 4);
flg_raw = EXTRACT_32BITS(pptr + 20);
- if (vflag >= 1) {
- printf("\n\tForCES Version %d len %uB flags 0x%08x ",
- ForCES_V(fhdr), mlen, flg_raw);
- printf("\n\tSrcID 0x%x(%s) DstID 0x%x(%s) Correlator 0x%" PRIx64,
+ if (ndo->ndo_vflag >= 1) {
+ ND_PRINT((ndo, "\n\tForCES Version %d len %uB flags 0x%08x ",
+ ForCES_V(fhdr), mlen, flg_raw));
+ ND_PRINT((ndo,
+ "\n\tSrcID 0x%x(%s) DstID 0x%x(%s) Correlator 0x%" PRIx64,
ForCES_SID(fhdr), ForCES_node(ForCES_SID(fhdr)),
ForCES_DID(fhdr), ForCES_node(ForCES_DID(fhdr)),
- EXTRACT_64BITS(fhdr->fm_cor));
+ EXTRACT_64BITS(fhdr->fm_cor)));
}
- if (vflag >= 2) {
- printf
- ("\n\tForCES flags:\n\t %s(0x%x), prio=%d, %s(0x%x),\n\t %s(0x%x), %s(0x%x)\n",
- ForCES_ACKp(ForCES_ACK(fhdr)), ForCES_ACK(fhdr),
+ if (ndo->ndo_vflag >= 2) {
+ ND_PRINT((ndo,
+ "\n\tForCES flags:\n\t %s(0x%x), prio=%d, %s(0x%x),\n\t %s(0x%x), %s(0x%x)\n",
+ tok2str(ForCES_ACKs, "ACKUnknown", ForCES_ACK(fhdr)),
+ ForCES_ACK(fhdr),
ForCES_PRI(fhdr),
- ForCES_EMp(ForCES_EM(fhdr)), ForCES_EM(fhdr),
- ForCES_ATp(ForCES_AT(fhdr)), ForCES_AT(fhdr),
- ForCES_TPp(ForCES_TP(fhdr)), ForCES_TP(fhdr));
- printf
- ("\t Extra flags: rsv(b5-7) 0x%x rsv(b13-31) 0x%x\n",
- ForCES_RS1(fhdr), ForCES_RS2(fhdr));
+ tok2str(ForCES_EMs, "EMUnknown", ForCES_EM(fhdr)),
+ ForCES_EM(fhdr),
+ tok2str(ForCES_ATs, "ATUnknown", ForCES_AT(fhdr)),
+ ForCES_AT(fhdr),
+ tok2str(ForCES_TPs, "TPUnknown", ForCES_TP(fhdr)),
+ ForCES_TP(fhdr)));
+ ND_PRINT((ndo,
+ "\t Extra flags: rsv(b5-7) 0x%x rsv(b13-31) 0x%x\n",
+ ForCES_RS1(fhdr), ForCES_RS2(fhdr)));
}
- rc = forces_type_print(pptr, fhdr, mlen, tops);
+ rc = forces_type_print(ndo, pptr, fhdr, mlen, tops);
if (rc < 0) {
error:
- hex_print_with_offset("\n\t[", pptr, len, 0);
- printf("\n\t]");
+ hex_print_with_offset(ndo, "\n\t[", pptr, len, 0);
+ ND_PRINT((ndo, "\n\t]"));
return;
}
- if (vflag >= 4) {
- printf("\n\t Raw ForCES message\n\t [");
- hex_print_with_offset("\n\t ", pptr, len, 0);
- printf("\n\t ]");
+ if (ndo->ndo_vflag >= 4) {
+ ND_PRINT((ndo, "\n\t Raw ForCES message\n\t ["));
+ hex_print_with_offset(ndo, "\n\t ", pptr, len, 0);
+ ND_PRINT((ndo, "\n\t ]"));
}
- printf("\n");
+ ND_PRINT((ndo, "\n"));
return;
trunc:
- fputs("[|forces]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
}
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
diff --git a/contrib/tcpdump/print-fr.c b/contrib/tcpdump/print-fr.c
index 34db239bc634..ba6d92b47bfc 100644
--- a/contrib/tcpdump/print-fr.c
+++ b/contrib/tcpdump/print-fr.c
@@ -21,11 +21,7 @@
* $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#)$Header: /tcpdump/master/tcpdump/print-fr.c,v 1.51 2006-06-23 22:20:32 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -34,16 +30,15 @@ static const char rcsid[] _U_ =
#include <stdio.h>
#include <string.h>
-#include <pcap.h>
-#include "addrtoname.h"
#include "interface.h"
+#include "addrtoname.h"
#include "ethertype.h"
#include "nlpid.h"
#include "extract.h"
#include "oui.h"
-static void frf15_print(const u_char *, u_int);
+static void frf15_print(netdissect_options *ndo, const u_char *, u_int);
/*
* the frame relay header has a variable length
@@ -75,7 +70,7 @@ static void frf15_print(const u_char *, u_int);
#define FR_SDLC_BIT 0x00000002
-struct tok fr_header_flag_values[] = {
+static const struct tok fr_header_flag_values[] = {
{ FR_CR_BIT, "C!" },
{ FR_DE_BIT, "DE" },
{ FR_BECN_BIT, "BECN" },
@@ -92,7 +87,7 @@ struct tok fr_header_flag_values[] = {
#define MFR_CTRL_FRAME (MFR_B_BIT | MFR_E_BIT | MFR_C_BIT)
#define MFR_FRAG_FRAME (MFR_B_BIT | MFR_E_BIT )
-struct tok frf_flag_values[] = {
+static const struct tok frf_flag_values[] = {
{ MFR_B_BIT, "Begin" },
{ MFR_E_BIT, "End" },
{ MFR_C_BIT, "Control" },
@@ -103,7 +98,7 @@ struct tok frf_flag_values[] = {
* save the flags dep. on address length
*/
static int parse_q922_addr(const u_char *p, u_int *dlci,
- u_int *addr_len, u_int8_t *flags)
+ u_int *addr_len, uint8_t *flags)
{
if ((p[0] & FR_EA_BIT))
return -1;
@@ -140,7 +135,7 @@ static int parse_q922_addr(const u_char *p, u_int *dlci,
char *q922_string(const u_char *p) {
static u_int dlci, addr_len;
- static u_int8_t flags[4];
+ static uint8_t flags[4];
static char buffer[sizeof("DLCI xxxxxxxxxx")];
memset(buffer, 0, sizeof(buffer));
@@ -183,173 +178,177 @@ fr_hdrlen(const u_char *p, u_int addr_len)
{
if (!p[addr_len + 1] /* pad exist */)
return addr_len + 1 /* UI */ + 1 /* pad */ + 1 /* NLPID */;
- else
+ else
return addr_len + 1 /* UI */ + 1 /* NLPID */;
}
static void
-fr_hdr_print(int length, u_int addr_len, u_int dlci, u_int8_t *flags, u_int16_t nlpid)
+fr_hdr_print(netdissect_options *ndo,
+ int length, u_int addr_len, u_int dlci, uint8_t *flags, uint16_t nlpid)
{
- if (qflag) {
- (void)printf("Q.922, DLCI %u, length %u: ",
+ if (ndo->ndo_qflag) {
+ ND_PRINT((ndo, "Q.922, DLCI %u, length %u: ",
dlci,
- length);
+ length));
} else {
if (nlpid <= 0xff) /* if its smaller than 256 then its a NLPID */
- (void)printf("Q.922, hdr-len %u, DLCI %u, Flags [%s], NLPID %s (0x%02x), length %u: ",
+ ND_PRINT((ndo, "Q.922, hdr-len %u, DLCI %u, Flags [%s], NLPID %s (0x%02x), length %u: ",
addr_len,
dlci,
bittok2str(fr_header_flag_values, "none", EXTRACT_32BITS(flags)),
tok2str(nlpid_values,"unknown", nlpid),
nlpid,
- length);
+ length));
else /* must be an ethertype */
- (void)printf("Q.922, hdr-len %u, DLCI %u, Flags [%s], cisco-ethertype %s (0x%04x), length %u: ",
+ ND_PRINT((ndo, "Q.922, hdr-len %u, DLCI %u, Flags [%s], cisco-ethertype %s (0x%04x), length %u: ",
addr_len,
dlci,
bittok2str(fr_header_flag_values, "none", EXTRACT_32BITS(flags)),
tok2str(ethertype_values, "unknown", nlpid),
nlpid,
- length);
+ length));
}
}
u_int
-fr_if_print(const struct pcap_pkthdr *h, register const u_char *p)
+fr_if_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, register const u_char *p)
{
register u_int length = h->len;
register u_int caplen = h->caplen;
- TCHECK2(*p, 4); /* minimum frame header length */
+ ND_TCHECK2(*p, 4); /* minimum frame header length */
- if ((length = fr_print(p, length)) == 0)
+ if ((length = fr_print(ndo, p, length)) == 0)
return (0);
else
return length;
trunc:
- printf("[|fr]");
+ ND_PRINT((ndo, "[|fr]"));
return caplen;
}
u_int
-fr_print(register const u_char *p, u_int length)
+fr_print(netdissect_options *ndo,
+ register const u_char *p, u_int length)
{
- u_int16_t extracted_ethertype;
+ uint16_t extracted_ethertype;
u_int dlci;
u_int addr_len;
- u_int16_t nlpid;
+ uint16_t nlpid;
u_int hdr_len;
- u_int8_t flags[4];
+ uint8_t flags[4];
if (parse_q922_addr(p, &dlci, &addr_len, flags)) {
- printf("Q.922, invalid address");
+ ND_PRINT((ndo, "Q.922, invalid address"));
return 0;
}
- TCHECK2(*p,addr_len+1+1);
+ ND_TCHECK2(*p, addr_len+1+1);
hdr_len = fr_hdrlen(p, addr_len);
- TCHECK2(*p,hdr_len);
+ ND_TCHECK2(*p, hdr_len);
if (p[addr_len] != 0x03 && dlci != 0) {
/* lets figure out if we have cisco style encapsulation: */
extracted_ethertype = EXTRACT_16BITS(p+addr_len);
- if (eflag)
- fr_hdr_print(length, addr_len, dlci, flags, extracted_ethertype);
+ if (ndo->ndo_eflag)
+ fr_hdr_print(ndo, length, addr_len, dlci, flags, extracted_ethertype);
- if (ethertype_print(gndo, extracted_ethertype,
+ if (ethertype_print(ndo, extracted_ethertype,
p+addr_len+ETHERTYPE_LEN,
length-addr_len-ETHERTYPE_LEN,
length-addr_len-ETHERTYPE_LEN) == 0)
/* ether_type not known, probably it wasn't one */
- printf("UI %02x! ", p[addr_len]);
+ ND_PRINT((ndo, "UI %02x! ", p[addr_len]));
else
return hdr_len;
}
if (!p[addr_len + 1]) { /* pad byte should be used with 3-byte Q.922 */
if (addr_len != 3)
- printf("Pad! ");
+ ND_PRINT((ndo, "Pad! "));
} else if (addr_len == 3)
- printf("No pad! ");
+ ND_PRINT((ndo, "No pad! "));
nlpid = p[hdr_len - 1];
- if (eflag)
- fr_hdr_print(length, addr_len, dlci, flags, nlpid);
+ if (ndo->ndo_eflag)
+ fr_hdr_print(ndo, length, addr_len, dlci, flags, nlpid);
p += hdr_len;
length -= hdr_len;
switch (nlpid) {
case NLPID_IP:
- ip_print(gndo, p, length);
+ ip_print(ndo, p, length);
break;
#ifdef INET6
case NLPID_IP6:
- ip6_print(gndo, p, length);
+ ip6_print(ndo, p, length);
break;
#endif
case NLPID_CLNP:
case NLPID_ESIS:
case NLPID_ISIS:
- isoclns_print(p-1, length+1, length+1); /* OSI printers need the NLPID field */
+ isoclns_print(ndo, p - 1, length + 1, length + 1); /* OSI printers need the NLPID field */
break;
case NLPID_SNAP:
- if (snap_print(p, length, length, 0) == 0) {
+ if (snap_print(ndo, p, length, length, 0) == 0) {
/* ether_type not known, print raw packet */
- if (!eflag)
- fr_hdr_print(length + hdr_len, hdr_len,
+ if (!ndo->ndo_eflag)
+ fr_hdr_print(ndo, length + hdr_len, hdr_len,
dlci, flags, nlpid);
- if (!suppress_default_print)
- default_print(p - hdr_len, length + hdr_len);
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p - hdr_len, length + hdr_len);
}
break;
case NLPID_Q933:
- q933_print(p, length);
+ q933_print(ndo, p, length);
break;
case NLPID_MFR:
- frf15_print(p, length);
+ frf15_print(ndo, p, length);
break;
case NLPID_PPP:
- ppp_print(p, length);
+ ppp_print(ndo, p, length);
break;
default:
- if (!eflag)
- fr_hdr_print(length + hdr_len, addr_len,
+ if (!ndo->ndo_eflag)
+ fr_hdr_print(ndo, length + hdr_len, addr_len,
dlci, flags, nlpid);
- if (!xflag)
- default_print(p, length);
+ if (!ndo->ndo_xflag)
+ ND_DEFAULTPRINT(p, length);
}
return hdr_len;
trunc:
- printf("[|fr]");
+ ND_PRINT((ndo, "[|fr]"));
return 0;
}
u_int
-mfr_if_print(const struct pcap_pkthdr *h, register const u_char *p)
+mfr_if_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, register const u_char *p)
{
register u_int length = h->len;
register u_int caplen = h->caplen;
- TCHECK2(*p, 2); /* minimum frame header length */
+ ND_TCHECK2(*p, 2); /* minimum frame header length */
- if ((length = mfr_print(p, length)) == 0)
+ if ((length = mfr_print(ndo, p, length)) == 0)
return (0);
else
return length;
trunc:
- printf("[|mfr]");
+ ND_PRINT((ndo, "[|mfr]"));
return caplen;
}
@@ -362,7 +361,7 @@ mfr_if_print(const struct pcap_pkthdr *h, register const u_char *p)
#define MFR_CTRL_MSG_REMOVE_LINK 6
#define MFR_CTRL_MSG_REMOVE_LINK_ACK 7
-struct tok mfr_ctrl_msg_values[] = {
+static const struct tok mfr_ctrl_msg_values[] = {
{ MFR_CTRL_MSG_ADD_LINK, "Add Link" },
{ MFR_CTRL_MSG_ADD_LINK_ACK, "Add Link ACK" },
{ MFR_CTRL_MSG_ADD_LINK_REJ, "Add Link Reject" },
@@ -380,7 +379,7 @@ struct tok mfr_ctrl_msg_values[] = {
#define MFR_CTRL_IE_VENDOR_EXT 6
#define MFR_CTRL_IE_CAUSE 7
-struct tok mfr_ctrl_ie_values[] = {
+static const struct tok mfr_ctrl_ie_values[] = {
{ MFR_CTRL_IE_BUNDLE_ID, "Bundle ID"},
{ MFR_CTRL_IE_LINK_ID, "Link ID"},
{ MFR_CTRL_IE_MAGIC_NUM, "Magic Number"},
@@ -393,22 +392,23 @@ struct tok mfr_ctrl_ie_values[] = {
#define MFR_ID_STRING_MAXLEN 50
struct ie_tlv_header_t {
- u_int8_t ie_type;
- u_int8_t ie_len;
+ uint8_t ie_type;
+ uint8_t ie_len;
};
u_int
-mfr_print(register const u_char *p, u_int length)
+mfr_print(netdissect_options *ndo,
+ register const u_char *p, u_int length)
{
u_int tlen,idx,hdr_len = 0;
- u_int16_t sequence_num;
- u_int8_t ie_type,ie_len;
- const u_int8_t *tptr;
+ uint16_t sequence_num;
+ uint8_t ie_type,ie_len;
+ const uint8_t *tptr;
/*
* FRF.16 Link Integrity Control Frame
- *
+ *
* 7 6 5 4 3 2 1 0
* +----+----+----+----+----+----+----+----+
* | B | E | C=1| 0 0 0 0 | EA |
@@ -419,35 +419,35 @@ mfr_print(register const u_char *p, u_int length)
* +----+----+----+----+----+----+----+----+
*/
- TCHECK2(*p, 4); /* minimum frame header length */
+ ND_TCHECK2(*p, 4); /* minimum frame header length */
if ((p[0] & MFR_BEC_MASK) == MFR_CTRL_FRAME && p[1] == 0) {
- printf("FRF.16 Control, Flags [%s], %s, length %u",
+ ND_PRINT((ndo, "FRF.16 Control, Flags [%s], %s, length %u",
bittok2str(frf_flag_values,"none",(p[0] & MFR_BEC_MASK)),
tok2str(mfr_ctrl_msg_values,"Unknown Message (0x%02x)",p[2]),
- length);
+ length));
tptr = p + 3;
tlen = length -3;
hdr_len = 3;
- if (!vflag)
+ if (!ndo->ndo_vflag)
return hdr_len;
while (tlen>sizeof(struct ie_tlv_header_t)) {
- TCHECK2(*tptr, sizeof(struct ie_tlv_header_t));
+ ND_TCHECK2(*tptr, sizeof(struct ie_tlv_header_t));
ie_type=tptr[0];
ie_len=tptr[1];
- printf("\n\tIE %s (%u), length %u: ",
+ ND_PRINT((ndo, "\n\tIE %s (%u), length %u: ",
tok2str(mfr_ctrl_ie_values,"Unknown",ie_type),
ie_type,
- ie_len);
+ ie_len));
/* infinite loop check */
if (ie_type == 0 || ie_len <= sizeof(struct ie_tlv_header_t))
return hdr_len;
- TCHECK2(*tptr,ie_len);
+ ND_TCHECK2(*tptr, ie_len);
tptr+=sizeof(struct ie_tlv_header_t);
/* tlv len includes header */
ie_len-=sizeof(struct ie_tlv_header_t);
@@ -456,14 +456,14 @@ mfr_print(register const u_char *p, u_int length)
switch (ie_type) {
case MFR_CTRL_IE_MAGIC_NUM:
- printf("0x%08x",EXTRACT_32BITS(tptr));
+ ND_PRINT((ndo, "0x%08x", EXTRACT_32BITS(tptr)));
break;
case MFR_CTRL_IE_BUNDLE_ID: /* same message format */
case MFR_CTRL_IE_LINK_ID:
for (idx = 0; idx < ie_len && idx < MFR_ID_STRING_MAXLEN; idx++) {
if (*(tptr+idx) != 0) /* don't print null termination */
- safeputchar(*(tptr+idx));
+ safeputchar(ndo, *(tptr + idx));
else
break;
}
@@ -471,7 +471,7 @@ mfr_print(register const u_char *p, u_int length)
case MFR_CTRL_IE_TIMESTAMP:
if (ie_len == sizeof(struct timeval)) {
- ts_print((const struct timeval *)tptr);
+ ts_print(ndo, (const struct timeval *)tptr);
break;
}
/* fall through and hexdump if no unix timestamp */
@@ -485,15 +485,15 @@ mfr_print(register const u_char *p, u_int length)
case MFR_CTRL_IE_CAUSE:
default:
- if (vflag <= 1)
- print_unknown_data(tptr,"\n\t ",ie_len);
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo, tptr, "\n\t ", ie_len);
break;
}
/* do we want to see a hexdump of the IE ? */
- if (vflag > 1 )
- print_unknown_data(tptr,"\n\t ",ie_len);
-
+ if (ndo->ndo_vflag > 1 )
+ print_unknown_data(ndo, tptr, "\n\t ", ie_len);
+
tlen-=ie_len;
tptr+=ie_len;
}
@@ -501,7 +501,7 @@ mfr_print(register const u_char *p, u_int length)
}
/*
* FRF.16 Fragmentation Frame
- *
+ *
* 7 6 5 4 3 2 1 0
* +----+----+----+----+----+----+----+----+
* | B | E | C=0|seq. (high 4 bits) | EA |
@@ -518,30 +518,30 @@ mfr_print(register const u_char *p, u_int length)
/* whole packet or first fragment ? */
if ((p[0] & MFR_BEC_MASK) == MFR_FRAG_FRAME ||
(p[0] & MFR_BEC_MASK) == MFR_B_BIT) {
- printf("FRF.16 Frag, seq %u, Flags [%s], ",
+ ND_PRINT((ndo, "FRF.16 Frag, seq %u, Flags [%s], ",
sequence_num,
- bittok2str(frf_flag_values,"none",(p[0] & MFR_BEC_MASK)));
+ bittok2str(frf_flag_values,"none",(p[0] & MFR_BEC_MASK))));
hdr_len = 2;
- fr_print(p+hdr_len,length-hdr_len);
+ fr_print(ndo, p+hdr_len,length-hdr_len);
return hdr_len;
}
/* must be a middle or the last fragment */
- printf("FRF.16 Frag, seq %u, Flags [%s]",
+ ND_PRINT((ndo, "FRF.16 Frag, seq %u, Flags [%s]",
sequence_num,
- bittok2str(frf_flag_values,"none",(p[0] & MFR_BEC_MASK)));
- print_unknown_data(p,"\n\t",length);
+ bittok2str(frf_flag_values,"none",(p[0] & MFR_BEC_MASK))));
+ print_unknown_data(ndo, p, "\n\t", length);
return hdr_len;
trunc:
- printf("[|mfr]");
+ ND_PRINT((ndo, "[|mfr]"));
return length;
}
/* an NLPID of 0xb1 indicates a 2-byte
* FRF.15 header
- *
+ *
* 7 6 5 4 3 2 1 0
* +----+----+----+----+----+----+----+----+
* ~ Q.922 header ~
@@ -557,18 +557,19 @@ mfr_print(register const u_char *p, u_int length)
#define FR_FRF15_FRAGTYPE 0x01
static void
-frf15_print (const u_char *p, u_int length) {
-
- u_int16_t sequence_num, flags;
+frf15_print(netdissect_options *ndo,
+ const u_char *p, u_int length) {
+
+ uint16_t sequence_num, flags;
flags = p[0]&MFR_BEC_MASK;
sequence_num = (p[0]&0x1e)<<7 | p[1];
- printf("FRF.15, seq 0x%03x, Flags [%s],%s Fragmentation, length %u",
+ ND_PRINT((ndo, "FRF.15, seq 0x%03x, Flags [%s],%s Fragmentation, length %u",
sequence_num,
bittok2str(frf_flag_values,"none",flags),
p[0]&FR_FRF15_FRAGTYPE ? "Interface" : "End-to-End",
- length);
+ length));
/* TODO:
* depending on all permutations of the B, E and C bit
@@ -586,13 +587,13 @@ frf15_print (const u_char *p, u_int length) {
*/
/* Q.933 packet format
- Format of Other Protocols
+ Format of Other Protocols
using Q.933 NLPID
- +-------------------------------+
- | Q.922 Address |
+ +-------------------------------+
+ | Q.922 Address |
+ +---------------+---------------+
+ |Control 0x03 | NLPID 0x08 |
+---------------+---------------+
- |Control 0x03 | NLPID 0x08 |
- +---------------+---------------+
| L2 Protocol ID |
| octet 1 | octet 2 |
+-------------------------------+
@@ -628,7 +629,7 @@ frf15_print (const u_char *p, u_int length) {
#define MSG_TYPE_STATUS 0x7D
#define MSG_TYPE_STATUS_ENQ 0x75
-struct tok fr_q933_msg_values[] = {
+static const struct tok fr_q933_msg_values[] = {
{ MSG_TYPE_ESC_TO_NATIONAL, "ESC to National" },
{ MSG_TYPE_ALERT, "Alert" },
{ MSG_TYPE_CALL_PROCEEDING, "Call proceeding" },
@@ -657,7 +658,7 @@ struct tok fr_q933_msg_values[] = {
#define FR_LMI_CCITT_LINK_VERIFY_IE 0x53
#define FR_LMI_CCITT_PVC_STATUS_IE 0x57
-struct tok fr_q933_ie_values_codeset5[] = {
+static const struct tok fr_q933_ie_values_codeset5[] = {
{ FR_LMI_ANSI_REPORT_TYPE_IE, "ANSI Report Type" },
{ FR_LMI_ANSI_LINK_VERIFY_IE_91, "ANSI Link Verify" },
{ FR_LMI_ANSI_LINK_VERIFY_IE, "ANSI Link Verify" },
@@ -672,7 +673,7 @@ struct tok fr_q933_ie_values_codeset5[] = {
#define FR_LMI_REPORT_TYPE_IE_LINK_VERIFY 1
#define FR_LMI_REPORT_TYPE_IE_ASYNC_PVC 2
-struct tok fr_lmi_report_type_ie_values[] = {
+static const struct tok fr_lmi_report_type_ie_values[] = {
{ FR_LMI_REPORT_TYPE_IE_FULL_STATUS, "Full Status" },
{ FR_LMI_REPORT_TYPE_IE_LINK_VERIFY, "Link verify" },
{ FR_LMI_REPORT_TYPE_IE_ASYNC_PVC, "Async PVC Status" },
@@ -680,7 +681,7 @@ struct tok fr_lmi_report_type_ie_values[] = {
};
/* array of 16 codepages - currently we only support codepage 1,5 */
-static struct tok *fr_q933_ie_codesets[] = {
+static const struct tok *fr_q933_ie_codesets[] = {
NULL,
fr_q933_ie_values_codeset5,
NULL,
@@ -699,14 +700,14 @@ static struct tok *fr_q933_ie_codesets[] = {
NULL
};
-static int fr_q933_print_ie_codeset5(const struct ie_tlv_header_t *ie_p,
- const u_char *p);
+static int fr_q933_print_ie_codeset5(netdissect_options *ndo,
+ const struct ie_tlv_header_t *ie_p, const u_char *p);
-typedef int (*codeset_pr_func_t)(const struct ie_tlv_header_t *ie_p,
- const u_char *p);
+typedef int (*codeset_pr_func_t)(netdissect_options *,
+ const struct ie_tlv_header_t *ie_p, const u_char *p);
/* array of 16 codepages - currently we only support codepage 1,5 */
-static codeset_pr_func_t fr_q933_print_ie_codeset[] = {
+static const codeset_pr_func_t fr_q933_print_ie_codeset[] = {
NULL,
fr_q933_print_ie_codeset5,
NULL,
@@ -726,7 +727,8 @@ static codeset_pr_func_t fr_q933_print_ie_codeset[] = {
};
void
-q933_print(const u_char *p, u_int length)
+q933_print(netdissect_options *ndo,
+ const u_char *p, u_int length)
{
const u_char *ptemp = p;
struct ie_tlv_header_t *ie_p;
@@ -736,7 +738,7 @@ q933_print(const u_char *p, u_int length)
u_int ie_is_known = 0;
if (length < 9) { /* shortest: Q.933a LINK VERIFY */
- printf("[|q.933]");
+ ND_PRINT((ndo, "[|q.933]"));
return;
}
@@ -745,45 +747,45 @@ q933_print(const u_char *p, u_int length)
if (p[2] == MSG_ANSI_LOCKING_SHIFT) {
is_ansi = 1;
}
-
- printf("%s", eflag ? "" : "Q.933, ");
+
+ ND_PRINT((ndo, "%s", ndo->ndo_eflag ? "" : "Q.933, "));
/* printing out header part */
- printf("%s, codeset %u", is_ansi ? "ANSI" : "CCITT", codeset);
+ ND_PRINT((ndo, "%s, codeset %u", is_ansi ? "ANSI" : "CCITT", codeset));
if (p[0]) {
- printf(", Call Ref: 0x%02x", p[0]);
+ ND_PRINT((ndo, ", Call Ref: 0x%02x", p[0]));
}
- if (vflag) {
- printf(", %s (0x%02x), length %u",
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, ", %s (0x%02x), length %u",
tok2str(fr_q933_msg_values,
"unknown message", p[1]),
p[1],
- length);
+ length));
} else {
- printf(", %s",
+ ND_PRINT((ndo, ", %s",
tok2str(fr_q933_msg_values,
- "unknown message 0x%02x", p[1]));
+ "unknown message 0x%02x", p[1])));
}
olen = length; /* preserve the original length for non verbose mode */
if (length < (u_int)(2 - is_ansi)) {
- printf("[|q.933]");
+ ND_PRINT((ndo, "[|q.933]"));
return;
}
length -= 2 + is_ansi;
ptemp += 2 + is_ansi;
-
+
/* Loop through the rest of IE */
while (length > sizeof(struct ie_tlv_header_t)) {
ie_p = (struct ie_tlv_header_t *)ptemp;
if (length < sizeof(struct ie_tlv_header_t) ||
length < sizeof(struct ie_tlv_header_t) + ie_p->ie_len) {
- if (vflag) { /* not bark if there is just a trailer */
- printf("\n[|q.933]");
+ if (ndo->ndo_vflag) { /* not bark if there is just a trailer */
+ ND_PRINT((ndo, "\n[|q.933]"));
} else {
- printf(", length %u",olen);
+ ND_PRINT((ndo, ", length %u", olen));
}
return;
}
@@ -791,12 +793,12 @@ q933_print(const u_char *p, u_int length)
/* lets do the full IE parsing only in verbose mode
* however some IEs (DLCI Status, Link Verify)
* are also interestting in non-verbose mode */
- if (vflag) {
- printf("\n\t%s IE (0x%02x), length %u: ",
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "\n\t%s IE (0x%02x), length %u: ",
tok2str(fr_q933_ie_codesets[codeset],
"unknown", ie_p->ie_type),
ie_p->ie_type,
- ie_p->ie_len);
+ ie_p->ie_len));
}
/* sanity check */
@@ -805,28 +807,29 @@ q933_print(const u_char *p, u_int length)
}
if (fr_q933_print_ie_codeset[codeset] != NULL) {
- ie_is_known = fr_q933_print_ie_codeset[codeset](ie_p, ptemp);
- }
+ ie_is_known = fr_q933_print_ie_codeset[codeset](ndo, ie_p, ptemp);
+ }
- if (vflag >= 1 && !ie_is_known) {
- print_unknown_data(ptemp+2,"\n\t",ie_p->ie_len);
+ if (ndo->ndo_vflag >= 1 && !ie_is_known) {
+ print_unknown_data(ndo, ptemp+2, "\n\t", ie_p->ie_len);
}
/* do we want to see a hexdump of the IE ? */
- if (vflag> 1 && ie_is_known) {
- print_unknown_data(ptemp+2,"\n\t ",ie_p->ie_len);
+ if (ndo->ndo_vflag> 1 && ie_is_known) {
+ print_unknown_data(ndo, ptemp+2, "\n\t ", ie_p->ie_len);
}
length = length - ie_p->ie_len - 2;
ptemp = ptemp + ie_p->ie_len + 2;
}
- if (!vflag) {
- printf(", length %u",olen);
+ if (!ndo->ndo_vflag) {
+ ND_PRINT((ndo, ", length %u", olen));
}
}
static int
-fr_q933_print_ie_codeset5(const struct ie_tlv_header_t *ie_p, const u_char *p)
+fr_q933_print_ie_codeset5(netdissect_options *ndo,
+ const struct ie_tlv_header_t *ie_p, const u_char *p)
{
u_int dlci;
@@ -834,28 +837,28 @@ 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) {
- printf("%s (%u)",
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "%s (%u)",
tok2str(fr_lmi_report_type_ie_values,"unknown",p[2]),
- p[2]);
+ p[2]));
}
return 1;
case FR_LMI_ANSI_LINK_VERIFY_IE: /* fall through */
case FR_LMI_CCITT_LINK_VERIFY_IE:
case FR_LMI_ANSI_LINK_VERIFY_IE_91:
- if (!vflag) {
- printf(", ");
+ if (!ndo->ndo_vflag) {
+ ND_PRINT((ndo, ", "));
}
- printf("TX Seq: %3d, RX Seq: %3d", p[2], p[3]);
+ ND_PRINT((ndo, "TX Seq: %3d, RX Seq: %3d", p[2], p[3]));
return 1;
case FR_LMI_ANSI_PVC_STATUS_IE: /* fall through */
case FR_LMI_CCITT_PVC_STATUS_IE:
- if (!vflag) {
- printf(", ");
+ if (!ndo->ndo_vflag) {
+ ND_PRINT((ndo, ", "));
}
- /* now parse the DLCI information element. */
+ /* now parse the DLCI information element. */
if ((ie_p->ie_len < 3) ||
(p[2] & 0x80) ||
((ie_p->ie_len == 3) && !(p[3] & 0x80)) ||
@@ -864,9 +867,9 @@ fr_q933_print_ie_codeset5(const struct ie_tlv_header_t *ie_p, const u_char *p)
!(p[5] & 0x80))) ||
(ie_p->ie_len > 5) ||
!(p[ie_p->ie_len + 1] & 0x80)) {
- printf("Invalid DLCI IE");
+ ND_PRINT((ndo, "Invalid DLCI IE"));
}
-
+
dlci = ((p[2] & 0x3F) << 4) | ((p[3] & 0x78) >> 3);
if (ie_p->ie_len == 4) {
dlci = (dlci << 6) | ((p[4] & 0x7E) >> 1);
@@ -875,11 +878,17 @@ fr_q933_print_ie_codeset5(const struct ie_tlv_header_t *ie_p, const u_char *p)
dlci = (dlci << 13) | (p[4] & 0x7F) | ((p[5] & 0x7E) >> 1);
}
- printf("DLCI %u: status %s%s", dlci,
+ ND_PRINT((ndo, "DLCI %u: status %s%s", dlci,
p[ie_p->ie_len + 1] & 0x8 ? "New, " : "",
- p[ie_p->ie_len + 1] & 0x2 ? "Active" : "Inactive");
+ p[ie_p->ie_len + 1] & 0x2 ? "Active" : "Inactive"));
return 1;
}
return 0;
}
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
diff --git a/contrib/tcpdump/print-frag6.c b/contrib/tcpdump/print-frag6.c
index e125bd3ef9d2..129095288558 100644
--- a/contrib/tcpdump/print-frag6.c
+++ b/contrib/tcpdump/print-frag6.c
@@ -19,11 +19,7 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-frag6.c,v 1.20 2005-04-20 22:33:06 guy Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -32,16 +28,12 @@ static const char rcsid[] _U_ =
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-
#include "ip6.h"
-
#include "interface.h"
-#include "addrtoname.h"
#include "extract.h"
int
-frag6_print(register const u_char *bp, register const u_char *bp2)
+frag6_print(netdissect_options *ndo, register const u_char *bp, register const u_char *bp2)
{
register const struct ip6_frag *dp;
register const struct ip6_hdr *ip6;
@@ -49,34 +41,31 @@ frag6_print(register const u_char *bp, register const u_char *bp2)
dp = (const struct ip6_frag *)bp;
ip6 = (const struct ip6_hdr *)bp2;
- TCHECK(dp->ip6f_offlg);
+ ND_TCHECK(dp->ip6f_offlg);
- if (vflag) {
- printf("frag (0x%08x:%d|%ld)",
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "frag (0x%08x:%d|%ld)",
EXTRACT_32BITS(&dp->ip6f_ident),
EXTRACT_16BITS(&dp->ip6f_offlg) & IP6F_OFF_MASK,
sizeof(struct ip6_hdr) + EXTRACT_16BITS(&ip6->ip6_plen) -
- (long)(bp - bp2) - sizeof(struct ip6_frag));
+ (long)(bp - bp2) - sizeof(struct ip6_frag)));
} else {
- printf("frag (%d|%ld)",
+ ND_PRINT((ndo, "frag (%d|%ld)",
EXTRACT_16BITS(&dp->ip6f_offlg) & IP6F_OFF_MASK,
sizeof(struct ip6_hdr) + EXTRACT_16BITS(&ip6->ip6_plen) -
- (long)(bp - bp2) - sizeof(struct ip6_frag));
+ (long)(bp - bp2) - sizeof(struct ip6_frag)));
}
-#if 1
/* it is meaningless to decode non-first fragment */
if ((EXTRACT_16BITS(&dp->ip6f_offlg) & IP6F_OFF_MASK) != 0)
return -1;
else
-#endif
{
- fputs(" ", stdout);
+ ND_PRINT((ndo, " "));
return sizeof(struct ip6_frag);
}
trunc:
- fputs("[|frag]", stdout);
+ ND_PRINT((ndo, "[|frag]"));
return -1;
-#undef TCHECK
}
#endif /* INET6 */
diff --git a/contrib/tcpdump/print-geonet.c b/contrib/tcpdump/print-geonet.c
new file mode 100644
index 000000000000..d902066eff3a
--- /dev/null
+++ b/contrib/tcpdump/print-geonet.c
@@ -0,0 +1,247 @@
+/*
+ * Copyright (c) 2013 The TCPDUMP project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code
+ * distributions retain the above copyright notice and this paragraph
+ * in its entirety, and (2) distributions including binary code include
+ * the above copyright notice and this paragraph in its entirety in
+ * the documentation or other materials provided with the distribution.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
+ * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
+ * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE.
+ *
+ * Original code by Ola Martin Lykkja (ola.lykkja@q-free.com)
+ */
+
+#define NETDISSECT_REWORKED
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tcpdump-stdinc.h>
+
+#include "interface.h"
+#include "extract.h"
+#include "addrtoname.h"
+
+
+/*
+ ETSI TS 102 636-5-1 V1.1.1 (2011-02)
+ Intelligent Transport Systems (ITS); Vehicular Communications; GeoNetworking;
+ Part 5: Transport Protocols; Sub-part 1: Basic Transport Protocol
+
+ ETSI TS 102 636-4-1 V1.1.1 (2011-06)
+ Intelligent Transport Systems (ITS); Vehicular communications; GeoNetworking;
+ Part 4: Geographical addressing and forwarding for point-to-point and point-to-multipoint communications;
+ Sub-part 1: Media-Independent Functionality
+*/
+
+#define GEONET_ADDR_LEN 8
+
+static const struct tok msg_type_values[] = {
+ { 0, "CAM" },
+ { 1, "DENM" },
+ { 101, "TPEGM" },
+ { 102, "TSPDM" },
+ { 103, "VPM" },
+ { 104, "SRM" },
+ { 105, "SLAM" },
+ { 106, "ecoCAM" },
+ { 107, "ITM" },
+ { 150, "SA" },
+ { 0, NULL }
+};
+
+static void
+print_btp_body(netdissect_options *ndo,
+ const u_char *bp, u_int length)
+{
+ int version;
+ int msg_type;
+ const char *msg_type_str;
+
+ if (length <= 2) {
+ return;
+ }
+
+ /* Assuming ItsDpuHeader */
+ version = bp[0];
+ msg_type = bp[1];
+ msg_type_str = tok2str(msg_type_values, "unknown (%u)", msg_type);
+
+ ND_PRINT((ndo, "; ItsPduHeader v:%d t:%d-%s", version, msg_type, msg_type_str));
+}
+
+static void
+print_btp(netdissect_options *ndo,
+ const u_char *bp)
+{
+ uint16_t dest = EXTRACT_16BITS(bp+0);
+ uint16_t src = EXTRACT_16BITS(bp+2);
+ ND_PRINT((ndo, "; BTP Dst:%u Src:%u", dest, src));
+}
+
+static void
+print_long_pos_vector(netdissect_options *ndo,
+ const u_char *bp)
+{
+ uint32_t lat, lon;
+
+ ND_PRINT((ndo, "GN_ADDR:%s ", linkaddr_string (ndo, bp, 0, GEONET_ADDR_LEN)));
+
+ lat = EXTRACT_32BITS(bp+12);
+ ND_PRINT((ndo, "lat:%d ", lat));
+ lon = EXTRACT_32BITS(bp+16);
+ ND_PRINT((ndo, "lon:%d", lon));
+}
+
+
+/*
+ * This is the top level routine of the printer. 'p' points
+ * to the geonet header of the packet.
+ */
+void
+geonet_print(netdissect_options *ndo, const u_char *eth, const u_char *bp, u_int length)
+{
+ ND_PRINT((ndo, "GeoNet src:%s; ", etheraddr_string(ndo, eth+6)));
+
+ if (length >= 36) {
+ /* Process Common Header */
+ int version = bp[0] >> 4;
+ int next_hdr = bp[0] & 0x0f;
+ int hdr_type = bp[1] >> 4;
+ int hdr_subtype = bp[1] & 0x0f;
+ uint16_t payload_length = EXTRACT_16BITS(bp+4);
+ int hop_limit = bp[7];
+ const char *next_hdr_txt = "Unknown";
+ const char *hdr_type_txt = "Unknown";
+ int hdr_size = -1;
+
+ switch (next_hdr) {
+ case 0: next_hdr_txt = "Any"; break;
+ case 1: next_hdr_txt = "BTP-A"; break;
+ case 2: next_hdr_txt = "BTP-B"; break;
+ case 3: next_hdr_txt = "IPv6"; break;
+ }
+
+ switch (hdr_type) {
+ case 0: hdr_type_txt = "Any"; break;
+ case 1: hdr_type_txt = "Beacon"; break;
+ case 2: hdr_type_txt = "GeoUnicast"; break;
+ case 3: switch (hdr_subtype) {
+ case 0: hdr_type_txt = "GeoAnycastCircle"; break;
+ case 1: hdr_type_txt = "GeoAnycastRect"; break;
+ case 2: hdr_type_txt = "GeoAnycastElipse"; break;
+ }
+ break;
+ case 4: switch (hdr_subtype) {
+ case 0: hdr_type_txt = "GeoBroadcastCircle"; break;
+ case 1: hdr_type_txt = "GeoBroadcastRect"; break;
+ case 2: hdr_type_txt = "GeoBroadcastElipse"; break;
+ }
+ break;
+ case 5: switch (hdr_subtype) {
+ case 0: hdr_type_txt = "TopoScopeBcast-SH"; break;
+ case 1: hdr_type_txt = "TopoScopeBcast-MH"; break;
+ }
+ break;
+ case 6: switch (hdr_subtype) {
+ case 0: hdr_type_txt = "LocService-Request"; break;
+ case 1: hdr_type_txt = "LocService-Reply"; break;
+ }
+ break;
+ }
+
+ ND_PRINT((ndo, "v:%d ", version));
+ ND_PRINT((ndo, "NH:%d-%s ", next_hdr, next_hdr_txt));
+ ND_PRINT((ndo, "HT:%d-%d-%s ", hdr_type, hdr_subtype, hdr_type_txt));
+ ND_PRINT((ndo, "HopLim:%d ", hop_limit));
+ ND_PRINT((ndo, "Payload:%d ", payload_length));
+ print_long_pos_vector(ndo, bp + 8);
+
+ /* Skip Common Header */
+ length -= 36;
+ bp += 36;
+
+ /* Process Extended Headers */
+ switch (hdr_type) {
+ case 0: /* Any */
+ hdr_size = 0;
+ break;
+ case 1: /* Beacon */
+ hdr_size = 0;
+ break;
+ case 2: /* GeoUnicast */
+ break;
+ case 3: switch (hdr_subtype) {
+ case 0: /* GeoAnycastCircle */
+ break;
+ case 1: /* GeoAnycastRect */
+ break;
+ case 2: /* GeoAnycastElipse */
+ break;
+ }
+ break;
+ case 4: switch (hdr_subtype) {
+ case 0: /* GeoBroadcastCircle */
+ break;
+ case 1: /* GeoBroadcastRect */
+ break;
+ case 2: /* GeoBroadcastElipse */
+ break;
+ }
+ break;
+ case 5: switch (hdr_subtype) {
+ case 0: /* TopoScopeBcast-SH */
+ hdr_size = 0;
+ break;
+ case 1: /* TopoScopeBcast-MH */
+ hdr_size = 68 - 36;
+ break;
+ }
+ break;
+ case 6: switch (hdr_subtype) {
+ case 0: /* LocService-Request */
+ break;
+ case 1: /* LocService-Reply */
+ break;
+ }
+ break;
+ }
+
+ /* Skip Extended headers */
+ if (hdr_size >= 0) {
+ length -= hdr_size;
+ bp += hdr_size;
+ switch (next_hdr) {
+ case 0: /* Any */
+ break;
+ case 1:
+ case 2: /* BTP A/B */
+ print_btp(ndo, bp);
+ length -= 4;
+ bp += 4;
+ print_btp_body(ndo, bp, length);
+ break;
+ case 3: /* IPv6 */
+ break;
+ }
+ }
+ } else {
+ ND_PRINT((ndo, "Malformed (small) "));
+ }
+
+ /* Print user data part */
+ if (ndo->ndo_vflag)
+ ND_DEFAULTPRINT(bp, length);
+}
+
+
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
diff --git a/contrib/tcpdump/print-gre.c b/contrib/tcpdump/print-gre.c
index b6fa52236695..604a96960464 100644
--- a/contrib/tcpdump/print-gre.c
+++ b/contrib/tcpdump/print-gre.c
@@ -36,27 +36,21 @@
* RFC1701 (GRE), RFC1702 (GRE IPv4), and RFC2637 (Enhanced GRE)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-gre.c,v 1.28 2005-04-06 21:32:39 mcr Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
#include <string.h>
#include "interface.h"
-#include "addrtoname.h"
#include "extract.h"
-
-#include "ip.h"
#include "ethertype.h"
+static const char tstr[] = "[|gre]";
+
#define GRE_CP 0x8000 /* checksum present */
#define GRE_RP 0x4000 /* routing present */
#define GRE_KP 0x2000 /* key present */
@@ -65,11 +59,11 @@ static const char rcsid[] _U_ =
#define GRE_RECRS 0x0700 /* recursion count */
#define GRE_AP 0x0080 /* acknowledgment# present */
-struct tok gre_flag_values[] = {
+static const struct tok gre_flag_values[] = {
{ GRE_CP, "checksum present"},
- { GRE_RP, "routing present"},
- { GRE_KP, "key present"},
- { GRE_SP, "sequence# present"},
+ { GRE_RP, "routing present"},
+ { GRE_KP, "key present"},
+ { GRE_SP, "sequence# present"},
{ GRE_sP, "source routing present"},
{ GRE_RECRS, "recursion count"},
{ GRE_AP, "ack present"},
@@ -82,49 +76,47 @@ struct tok gre_flag_values[] = {
#define GRESRE_IP 0x0800 /* IP */
#define GRESRE_ASN 0xfffe /* ASN */
-void gre_print_0(const u_char *, u_int);
-void gre_print_1(const u_char *, u_int);
-void gre_sre_print(u_int16_t, u_int8_t, u_int8_t, const u_char *, u_int);
-void gre_sre_ip_print(u_int8_t, u_int8_t, const u_char *, u_int);
-void gre_sre_asn_print(u_int8_t, u_int8_t, const u_char *, u_int);
+static void gre_print_0(netdissect_options *, const u_char *, u_int);
+static void gre_print_1(netdissect_options *, const u_char *, u_int);
+static void gre_sre_print(netdissect_options *, uint16_t, uint8_t, uint8_t, const u_char *, u_int);
+static void gre_sre_ip_print(netdissect_options *, uint8_t, uint8_t, const u_char *, u_int);
+static void gre_sre_asn_print(netdissect_options *, uint8_t, uint8_t, const u_char *, u_int);
void
-gre_print(const u_char *bp, u_int length)
+gre_print(netdissect_options *ndo, const u_char *bp, u_int length)
{
u_int len = length, vers;
if (len < 2) {
- printf("[|gre]");
+ ND_PRINT((ndo, "%s", tstr));
return;
}
vers = EXTRACT_16BITS(bp) & GRE_VERS_MASK;
- printf("GREv%u",vers);
+ ND_PRINT((ndo, "GREv%u",vers));
switch(vers) {
case 0:
- gre_print_0(bp, len);
+ gre_print_0(ndo, bp, len);
break;
case 1:
- gre_print_1(bp, len);
+ gre_print_1(ndo, bp, len);
break;
default:
- printf(" ERROR: unknown-version");
+ ND_PRINT((ndo, " ERROR: unknown-version"));
break;
}
- return;
-
}
-void
-gre_print_0(const u_char *bp, u_int length)
+static void
+gre_print_0(netdissect_options *ndo, const u_char *bp, u_int length)
{
u_int len = length;
- u_int16_t flags, prot;
+ uint16_t flags, prot;
flags = EXTRACT_16BITS(bp);
- if (vflag)
- printf(", Flags [%s]",
- bittok2str(gre_flag_values,"none",flags));
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, ", Flags [%s]",
+ bittok2str(gre_flag_values,"none",flags)));
len -= 2;
bp += 2;
@@ -138,14 +130,14 @@ gre_print_0(const u_char *bp, u_int length)
if ((flags & GRE_CP) | (flags & GRE_RP)) {
if (len < 2)
goto trunc;
- if (vflag)
- printf(", sum 0x%x", EXTRACT_16BITS(bp));
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, ", sum 0x%x", EXTRACT_16BITS(bp)));
bp += 2;
len -= 2;
if (len < 2)
goto trunc;
- printf(", off 0x%x", EXTRACT_16BITS(bp));
+ ND_PRINT((ndo, ", off 0x%x", EXTRACT_16BITS(bp)));
bp += 2;
len -= 2;
}
@@ -153,7 +145,7 @@ gre_print_0(const u_char *bp, u_int length)
if (flags & GRE_KP) {
if (len < 4)
goto trunc;
- printf(", key=0x%x", EXTRACT_32BITS(bp));
+ ND_PRINT((ndo, ", key=0x%x", EXTRACT_32BITS(bp)));
bp += 4;
len -= 4;
}
@@ -161,16 +153,16 @@ gre_print_0(const u_char *bp, u_int length)
if (flags & GRE_SP) {
if (len < 4)
goto trunc;
- printf(", seq %u", EXTRACT_32BITS(bp));
+ ND_PRINT((ndo, ", seq %u", EXTRACT_32BITS(bp)));
bp += 4;
len -= 4;
}
if (flags & GRE_RP) {
for (;;) {
- u_int16_t af;
- u_int8_t sreoff;
- u_int8_t srelen;
+ uint16_t af;
+ uint8_t sreoff;
+ uint8_t srelen;
if (len < 4)
goto trunc;
@@ -183,7 +175,7 @@ gre_print_0(const u_char *bp, u_int length)
if (af == 0 && srelen == 0)
break;
- gre_sre_print(af, sreoff, srelen, bp, len);
+ gre_sre_print(ndo, af, sreoff, srelen, bp, len);
if (len < srelen)
goto trunc;
@@ -192,64 +184,64 @@ gre_print_0(const u_char *bp, u_int length)
}
}
- if (eflag)
- printf(", proto %s (0x%04x)",
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, ", proto %s (0x%04x)",
tok2str(ethertype_values,"unknown",prot),
- prot);
+ prot));
- printf(", length %u",length);
+ ND_PRINT((ndo, ", length %u",length));
- if (vflag < 1)
- printf(": "); /* put in a colon as protocol demarc */
+ if (ndo->ndo_vflag < 1)
+ ND_PRINT((ndo, ": ")); /* put in a colon as protocol demarc */
else
- printf("\n\t"); /* if verbose go multiline */
+ ND_PRINT((ndo, "\n\t")); /* if verbose go multiline */
switch (prot) {
case ETHERTYPE_IP:
- ip_print(gndo, bp, len);
+ ip_print(ndo, bp, len);
break;
#ifdef INET6
case ETHERTYPE_IPV6:
- ip6_print(gndo, bp, len);
+ ip6_print(ndo, bp, len);
break;
#endif
case ETHERTYPE_MPLS:
- mpls_print(bp, len);
+ mpls_print(ndo, bp, len);
break;
case ETHERTYPE_IPX:
- ipx_print(bp, len);
+ ipx_print(ndo, bp, len);
break;
case ETHERTYPE_ATALK:
- atalk_print(bp, len);
+ atalk_print(ndo, bp, len);
break;
case ETHERTYPE_GRE_ISO:
- isoclns_print(bp, len, len);
+ isoclns_print(ndo, bp, len, len);
break;
case ETHERTYPE_TEB:
- ether_print(gndo, bp, len, len, NULL, NULL);
+ ether_print(ndo, bp, len, len, NULL, NULL);
break;
default:
- printf("gre-proto-0x%x", prot);
+ ND_PRINT((ndo, "gre-proto-0x%x", prot));
}
return;
trunc:
- printf("[|gre]");
+ ND_PRINT((ndo, "%s", tstr));
}
-void
-gre_print_1(const u_char *bp, u_int length)
+static void
+gre_print_1(netdissect_options *ndo, const u_char *bp, u_int length)
{
u_int len = length;
- u_int16_t flags, prot;
+ uint16_t flags, prot;
flags = EXTRACT_16BITS(bp);
len -= 2;
bp += 2;
- if (vflag)
- printf(", Flags [%s]",
- bittok2str(gre_flag_values,"none",flags));
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, ", Flags [%s]",
+ bittok2str(gre_flag_values,"none",flags)));
if (len < 2)
goto trunc;
@@ -259,12 +251,12 @@ gre_print_1(const u_char *bp, u_int length)
if (flags & GRE_KP) {
- u_int32_t k;
+ uint32_t k;
if (len < 4)
goto trunc;
k = EXTRACT_32BITS(bp);
- printf(", call %d", k & 0xffff);
+ ND_PRINT((ndo, ", call %d", k & 0xffff));
len -= 4;
bp += 4;
}
@@ -272,7 +264,7 @@ gre_print_1(const u_char *bp, u_int length)
if (flags & GRE_SP) {
if (len < 4)
goto trunc;
- printf(", seq %u", EXTRACT_32BITS(bp));
+ ND_PRINT((ndo, ", seq %u", EXTRACT_32BITS(bp)));
bp += 4;
len -= 4;
}
@@ -280,78 +272,80 @@ gre_print_1(const u_char *bp, u_int length)
if (flags & GRE_AP) {
if (len < 4)
goto trunc;
- printf(", ack %u", EXTRACT_32BITS(bp));
+ ND_PRINT((ndo, ", ack %u", EXTRACT_32BITS(bp)));
bp += 4;
len -= 4;
}
if ((flags & GRE_SP) == 0)
- printf(", no-payload");
+ ND_PRINT((ndo, ", no-payload"));
- if (eflag)
- printf(", proto %s (0x%04x)",
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, ", proto %s (0x%04x)",
tok2str(ethertype_values,"unknown",prot),
- prot);
+ prot));
- printf(", length %u",length);
+ ND_PRINT((ndo, ", length %u",length));
if ((flags & GRE_SP) == 0)
return;
- if (vflag < 1)
- printf(": "); /* put in a colon as protocol demarc */
+ if (ndo->ndo_vflag < 1)
+ ND_PRINT((ndo, ": ")); /* put in a colon as protocol demarc */
else
- printf("\n\t"); /* if verbose go multiline */
+ ND_PRINT((ndo, "\n\t")); /* if verbose go multiline */
switch (prot) {
case ETHERTYPE_PPP:
- ppp_print(bp, len);
+ ppp_print(ndo, bp, len);
break;
default:
- printf("gre-proto-0x%x", prot);
+ ND_PRINT((ndo, "gre-proto-0x%x", prot));
break;
}
return;
trunc:
- printf("[|gre]");
+ ND_PRINT((ndo, "%s", tstr));
}
-void
-gre_sre_print(u_int16_t af, u_int8_t sreoff, u_int8_t srelen,
- const u_char *bp, u_int len)
+static void
+gre_sre_print(netdissect_options *ndo, uint16_t af, uint8_t sreoff,
+ uint8_t srelen, const u_char *bp, u_int len)
{
switch (af) {
case GRESRE_IP:
- printf(", (rtaf=ip");
- gre_sre_ip_print(sreoff, srelen, bp, len);
- printf(") ");
+ ND_PRINT((ndo, ", (rtaf=ip"));
+ gre_sre_ip_print(ndo, sreoff, srelen, bp, len);
+ ND_PRINT((ndo, ") "));
break;
case GRESRE_ASN:
- printf(", (rtaf=asn");
- gre_sre_asn_print(sreoff, srelen, bp, len);
- printf(") ");
+ ND_PRINT((ndo, ", (rtaf=asn"));
+ gre_sre_asn_print(ndo, sreoff, srelen, bp, len);
+ ND_PRINT((ndo, ") "));
break;
default:
- printf(", (rtaf=0x%x) ", af);
+ ND_PRINT((ndo, ", (rtaf=0x%x) ", af));
}
}
-void
-gre_sre_ip_print(u_int8_t sreoff, u_int8_t srelen, const u_char *bp, u_int len)
+
+static void
+gre_sre_ip_print(netdissect_options *ndo, uint8_t sreoff, uint8_t srelen,
+ const u_char *bp, u_int len)
{
struct in_addr a;
const u_char *up = bp;
if (sreoff & 3) {
- printf(", badoffset=%u", sreoff);
+ ND_PRINT((ndo, ", badoffset=%u", sreoff));
return;
}
if (srelen & 3) {
- printf(", badlength=%u", srelen);
+ ND_PRINT((ndo, ", badlength=%u", srelen));
return;
}
if (sreoff >= srelen) {
- printf(", badoff/len=%u/%u", sreoff, srelen);
+ ND_PRINT((ndo, ", badoff/len=%u/%u", sreoff, srelen));
return;
}
@@ -360,9 +354,9 @@ gre_sre_ip_print(u_int8_t sreoff, u_int8_t srelen, const u_char *bp, u_int len)
return;
memcpy(&a, bp, sizeof(a));
- printf(" %s%s",
+ ND_PRINT((ndo, " %s%s",
((bp - up) == sreoff) ? "*" : "",
- inet_ntoa(a));
+ inet_ntoa(a)));
bp += 4;
len -= 4;
@@ -370,21 +364,22 @@ gre_sre_ip_print(u_int8_t sreoff, u_int8_t srelen, const u_char *bp, u_int len)
}
}
-void
-gre_sre_asn_print(u_int8_t sreoff, u_int8_t srelen, const u_char *bp, u_int len)
+static void
+gre_sre_asn_print(netdissect_options *ndo, uint8_t sreoff, uint8_t srelen,
+ const u_char *bp, u_int len)
{
const u_char *up = bp;
if (sreoff & 1) {
- printf(", badoffset=%u", sreoff);
+ ND_PRINT((ndo, ", badoffset=%u", sreoff));
return;
}
if (srelen & 1) {
- printf(", badlength=%u", srelen);
+ ND_PRINT((ndo, ", badlength=%u", srelen));
return;
}
if (sreoff >= srelen) {
- printf(", badoff/len=%u/%u", sreoff, srelen);
+ ND_PRINT((ndo, ", badoff/len=%u/%u", sreoff, srelen));
return;
}
@@ -392,9 +387,9 @@ gre_sre_asn_print(u_int8_t sreoff, u_int8_t srelen, const u_char *bp, u_int len)
if (len < 2 || srelen == 0)
return;
- printf(" %s%x",
+ ND_PRINT((ndo, " %s%x",
((bp - up) == sreoff) ? "*" : "",
- EXTRACT_16BITS(bp));
+ EXTRACT_16BITS(bp)));
bp += 2;
len -= 2;
diff --git a/contrib/tcpdump/print-hsrp.c b/contrib/tcpdump/print-hsrp.c
index 06304fd5677b..0e2420f71276 100644
--- a/contrib/tcpdump/print-hsrp.c
+++ b/contrib/tcpdump/print-hsrp.c
@@ -29,19 +29,13 @@
/* Cisco Hot Standby Router Protocol (HSRP). */
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-hsrp.c,v 1.10 2005-05-06 07:56:52 guy Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-
#include "interface.h"
#include "addrtoname.h"
@@ -53,7 +47,7 @@ static const char *op_code_str[] = {
};
/* HSRP states and associated names. */
-static struct tok states[] = {
+static const struct tok states[] = {
{ 0, "initial" },
{ 1, "learn" },
{ 2, "listen" },
@@ -85,56 +79,56 @@ static struct tok states[] = {
/* HSRP protocol header. */
struct hsrp {
- u_int8_t hsrp_version;
- u_int8_t hsrp_op_code;
- u_int8_t hsrp_state;
- u_int8_t hsrp_hellotime;
- u_int8_t hsrp_holdtime;
- u_int8_t hsrp_priority;
- u_int8_t hsrp_group;
- u_int8_t hsrp_reserved;
- u_int8_t hsrp_authdata[HSRP_AUTH_SIZE];
+ uint8_t hsrp_version;
+ uint8_t hsrp_op_code;
+ uint8_t hsrp_state;
+ uint8_t hsrp_hellotime;
+ uint8_t hsrp_holdtime;
+ uint8_t hsrp_priority;
+ uint8_t hsrp_group;
+ uint8_t hsrp_reserved;
+ uint8_t hsrp_authdata[HSRP_AUTH_SIZE];
struct in_addr hsrp_virtaddr;
};
void
-hsrp_print(register const u_int8_t *bp, register u_int len)
+hsrp_print(netdissect_options *ndo, register const uint8_t *bp, register u_int len)
{
struct hsrp *hp = (struct hsrp *) bp;
- TCHECK(hp->hsrp_version);
- printf("HSRPv%d", hp->hsrp_version);
+ ND_TCHECK(hp->hsrp_version);
+ ND_PRINT((ndo, "HSRPv%d", hp->hsrp_version));
if (hp->hsrp_version != 0)
return;
- TCHECK(hp->hsrp_op_code);
- printf("-");
- printf("%s ", tok2strary(op_code_str, "unknown (%d)", hp->hsrp_op_code));
- printf("%d: ", len);
- TCHECK(hp->hsrp_state);
- printf("state=%s ", tok2str(states, "Unknown (%d)", hp->hsrp_state));
- TCHECK(hp->hsrp_group);
- printf("group=%d ", hp->hsrp_group);
- TCHECK(hp->hsrp_reserved);
+ ND_TCHECK(hp->hsrp_op_code);
+ ND_PRINT((ndo, "-"));
+ ND_PRINT((ndo, "%s ", tok2strary(op_code_str, "unknown (%d)", hp->hsrp_op_code)));
+ ND_PRINT((ndo, "%d: ", len));
+ ND_TCHECK(hp->hsrp_state);
+ ND_PRINT((ndo, "state=%s ", tok2str(states, "Unknown (%d)", hp->hsrp_state)));
+ ND_TCHECK(hp->hsrp_group);
+ ND_PRINT((ndo, "group=%d ", hp->hsrp_group));
+ ND_TCHECK(hp->hsrp_reserved);
if (hp->hsrp_reserved != 0) {
- printf("[reserved=%d!] ", hp->hsrp_reserved);
+ ND_PRINT((ndo, "[reserved=%d!] ", hp->hsrp_reserved));
}
- TCHECK(hp->hsrp_virtaddr);
- printf("addr=%s", ipaddr_string(&hp->hsrp_virtaddr));
- if (vflag) {
- printf(" hellotime=");
- relts_print(hp->hsrp_hellotime);
- printf(" holdtime=");
- relts_print(hp->hsrp_holdtime);
- printf(" priority=%d", hp->hsrp_priority);
- printf(" auth=\"");
- if (fn_printn(hp->hsrp_authdata, sizeof(hp->hsrp_authdata),
- snapend)) {
- printf("\"");
+ ND_TCHECK(hp->hsrp_virtaddr);
+ ND_PRINT((ndo, "addr=%s", ipaddr_string(ndo, &hp->hsrp_virtaddr)));
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, " hellotime="));
+ relts_print(ndo, hp->hsrp_hellotime);
+ ND_PRINT((ndo, " holdtime="));
+ relts_print(ndo, hp->hsrp_holdtime);
+ ND_PRINT((ndo, " priority=%d", hp->hsrp_priority));
+ ND_PRINT((ndo, " auth=\""));
+ if (fn_printn(ndo, hp->hsrp_authdata, sizeof(hp->hsrp_authdata),
+ ndo->ndo_snapend)) {
+ ND_PRINT((ndo, "\""));
goto trunc;
}
- printf("\"");
+ ND_PRINT((ndo, "\""));
}
return;
trunc:
- printf("[|hsrp]");
+ ND_PRINT((ndo, "[|hsrp]"));
}
diff --git a/contrib/tcpdump/print-icmp.c b/contrib/tcpdump/print-icmp.c
index f0644851de46..88df0e4c7876 100644
--- a/contrib/tcpdump/print-icmp.c
+++ b/contrib/tcpdump/print-icmp.c
@@ -21,11 +21,7 @@
* $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.87 2007-09-13 17:42:31 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -53,17 +49,17 @@ static const char rcsid[] _U_ =
* Structure of an icmp header.
*/
struct icmp {
- u_int8_t icmp_type; /* type of message, see below */
- u_int8_t icmp_code; /* type sub code */
- u_int16_t icmp_cksum; /* ones complement cksum of struct */
+ uint8_t icmp_type; /* type of message, see below */
+ uint8_t icmp_code; /* type sub code */
+ uint16_t icmp_cksum; /* ones complement cksum of struct */
union {
- u_int8_t ih_pptr; /* ICMP_PARAMPROB */
+ uint8_t ih_pptr; /* ICMP_PARAMPROB */
struct in_addr ih_gwaddr; /* ICMP_REDIRECT */
struct ih_idseq {
- u_int16_t icd_id;
- u_int16_t icd_seq;
+ uint16_t icd_id;
+ uint16_t icd_seq;
} ih_idseq;
- u_int32_t ih_void;
+ uint32_t ih_void;
} icmp_hun;
#define icmp_pptr icmp_hun.ih_pptr
#define icmp_gwaddr icmp_hun.ih_gwaddr
@@ -72,16 +68,16 @@ struct icmp {
#define icmp_void icmp_hun.ih_void
union {
struct id_ts {
- u_int32_t its_otime;
- u_int32_t its_rtime;
- u_int32_t its_ttime;
+ uint32_t its_otime;
+ uint32_t its_rtime;
+ uint32_t its_ttime;
} id_ts;
struct id_ip {
struct ip idi_ip;
/* options and then 64 bits of data */
} id_ip;
- u_int32_t id_mask;
- u_int8_t id_data[1];
+ uint32_t id_mask;
+ uint8_t id_data[1];
} icmp_dun;
#define icmp_otime icmp_dun.id_ts.its_otime
#define icmp_rtime icmp_dun.id_ts.its_rtime
@@ -91,7 +87,7 @@ struct icmp {
#define icmp_data icmp_dun.id_data
};
-#define ICMP_MPLS_EXT_EXTRACT_VERSION(x) (((x)&0xf0)>>4)
+#define ICMP_MPLS_EXT_EXTRACT_VERSION(x) (((x)&0xf0)>>4)
#define ICMP_MPLS_EXT_VERSION 2
/*
@@ -104,7 +100,7 @@ struct icmp {
*/
#define ICMP_MINLEN 8 /* abs minimum */
#define ICMP_EXTD_MINLEN (156 - sizeof (struct ip)) /* draft-bonica-internet-icmp-08 */
-#define ICMP_TSLEN (8 + 3 * sizeof (u_int32_t)) /* timestamp */
+#define ICMP_TSLEN (8 + 3 * sizeof (uint32_t)) /* timestamp */
#define ICMP_MASKLEN 12 /* address mask */
#define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */
#define ICMP_ADVLEN(p) (8 + (IP_HL(&(p)->icmp_ip) << 2) + 8)
@@ -196,7 +192,7 @@ struct icmp {
#endif
/* Most of the icmp types */
-static struct tok icmp2str[] = {
+static const struct tok icmp2str[] = {
{ ICMP_ECHOREPLY, "echo reply" },
{ ICMP_SOURCEQUENCH, "source quench" },
{ ICMP_ECHO, "echo request" },
@@ -210,7 +206,7 @@ static struct tok icmp2str[] = {
};
/* Formats for most of the ICMP_UNREACH codes */
-static struct tok unreach2str[] = {
+static const struct tok unreach2str[] = {
{ ICMP_UNREACH_NET, "net %s unreachable" },
{ ICMP_UNREACH_HOST, "host %s unreachable" },
{ ICMP_UNREACH_SRCFAIL,
@@ -237,7 +233,7 @@ static struct tok unreach2str[] = {
};
/* Formats for the ICMP_REDIRECT codes */
-static struct tok type2str[] = {
+static const struct tok type2str[] = {
{ ICMP_REDIRECT_NET, "redirect %s to net %s" },
{ ICMP_REDIRECT_HOST, "redirect %s to host %s" },
{ ICMP_REDIRECT_TOSNET, "redirect-tos %s to net %s" },
@@ -247,20 +243,20 @@ static struct tok type2str[] = {
/* rfc1191 */
struct mtu_discovery {
- u_int16_t unused;
- u_int16_t nexthopmtu;
+ uint16_t unused;
+ uint16_t nexthopmtu;
};
/* rfc1256 */
struct ih_rdiscovery {
- u_int8_t ird_addrnum;
- u_int8_t ird_addrsiz;
- u_int16_t ird_lifetime;
+ uint8_t ird_addrnum;
+ uint8_t ird_addrsiz;
+ uint16_t ird_lifetime;
};
struct id_rdiscovery {
- u_int32_t ird_addr;
- u_int32_t ird_pref;
+ uint32_t ird_addr;
+ uint32_t ird_pref;
};
/*
@@ -290,22 +286,22 @@ struct id_rdiscovery {
*/
struct icmp_ext_t {
- u_int8_t icmp_type;
- u_int8_t icmp_code;
- u_int8_t icmp_checksum[2];
- u_int8_t icmp_reserved;
- u_int8_t icmp_length;
- u_int8_t icmp_reserved2[2];
- u_int8_t icmp_ext_legacy_header[128]; /* extension header starts 128 bytes after ICMP header */
- u_int8_t icmp_ext_version_res[2];
- u_int8_t icmp_ext_checksum[2];
- u_int8_t icmp_ext_data[1];
+ uint8_t icmp_type;
+ uint8_t icmp_code;
+ uint8_t icmp_checksum[2];
+ uint8_t icmp_reserved;
+ uint8_t icmp_length;
+ uint8_t icmp_reserved2[2];
+ uint8_t icmp_ext_legacy_header[128]; /* extension header starts 128 bytes after ICMP header */
+ uint8_t icmp_ext_version_res[2];
+ uint8_t icmp_ext_checksum[2];
+ uint8_t icmp_ext_data[1];
};
struct icmp_mpls_ext_object_header_t {
- u_int8_t length[2];
- u_int8_t class_num;
- u_int8_t ctype;
+ uint8_t length[2];
+ uint8_t class_num;
+ uint8_t ctype;
};
static const struct tok icmp_mpls_ext_obj_values[] = {
@@ -331,9 +327,10 @@ icmp_tstamp_print(u_int tstamp) {
snprintf(buf, sizeof(buf), "%02u:%02u:%02u.%03u",hrs,min,sec,msec);
return buf;
}
-
+
void
-icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
+icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *bp2,
+ int fragmented)
{
char *cp;
const struct icmp *dp;
@@ -342,8 +339,8 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
const char *str, *fmt;
const struct ip *oip;
const struct udphdr *ouh;
- const u_int8_t *obj_tptr;
- u_int32_t raw_label;
+ const uint8_t *obj_tptr;
+ uint32_t raw_label;
const u_char *snapend_save;
const struct icmp_mpls_ext_object_header_t *icmp_mpls_ext_object_header;
u_int hlen, dport, mtu, obj_tlen, obj_class_num, obj_ctype;
@@ -355,12 +352,12 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
ip = (struct ip *)bp2;
str = buf;
- TCHECK(dp->icmp_code);
+ ND_TCHECK(dp->icmp_code);
switch (dp->icmp_type) {
case ICMP_ECHO:
case ICMP_ECHOREPLY:
- TCHECK(dp->icmp_seq);
+ ND_TCHECK(dp->icmp_seq);
(void)snprintf(buf, sizeof(buf), "echo %s, id %u, seq %u",
dp->icmp_type == ICMP_ECHO ?
"request" : "reply",
@@ -369,44 +366,44 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
break;
case ICMP_UNREACH:
- TCHECK(dp->icmp_ip.ip_dst);
+ ND_TCHECK(dp->icmp_ip.ip_dst);
switch (dp->icmp_code) {
case ICMP_UNREACH_PROTOCOL:
- TCHECK(dp->icmp_ip.ip_p);
+ ND_TCHECK(dp->icmp_ip.ip_p);
(void)snprintf(buf, sizeof(buf),
"%s protocol %d unreachable",
- ipaddr_string(&dp->icmp_ip.ip_dst),
+ ipaddr_string(ndo, &dp->icmp_ip.ip_dst),
dp->icmp_ip.ip_p);
break;
case ICMP_UNREACH_PORT:
- TCHECK(dp->icmp_ip.ip_p);
+ ND_TCHECK(dp->icmp_ip.ip_p);
oip = &dp->icmp_ip;
hlen = IP_HL(oip) * 4;
ouh = (struct udphdr *)(((u_char *)oip) + hlen);
- TCHECK(ouh->uh_dport);
+ ND_TCHECK(ouh->uh_dport);
dport = EXTRACT_16BITS(&ouh->uh_dport);
switch (oip->ip_p) {
case IPPROTO_TCP:
(void)snprintf(buf, sizeof(buf),
"%s tcp port %s unreachable",
- ipaddr_string(&oip->ip_dst),
+ ipaddr_string(ndo, &oip->ip_dst),
tcpport_string(dport));
break;
case IPPROTO_UDP:
(void)snprintf(buf, sizeof(buf),
"%s udp port %s unreachable",
- ipaddr_string(&oip->ip_dst),
+ ipaddr_string(ndo, &oip->ip_dst),
udpport_string(dport));
break;
default:
(void)snprintf(buf, sizeof(buf),
"%s protocol %d port %d unreachable",
- ipaddr_string(&oip->ip_dst),
+ ipaddr_string(ndo, &oip->ip_dst),
oip->ip_p, dport);
break;
}
@@ -420,11 +417,11 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
if (mtu) {
(void)snprintf(buf, sizeof(buf),
"%s unreachable - need to frag (mtu %d)",
- ipaddr_string(&dp->icmp_ip.ip_dst), mtu);
+ ipaddr_string(ndo, &dp->icmp_ip.ip_dst), mtu);
} else {
(void)snprintf(buf, sizeof(buf),
"%s unreachable - need to frag",
- ipaddr_string(&dp->icmp_ip.ip_dst));
+ ipaddr_string(ndo, &dp->icmp_ip.ip_dst));
}
}
break;
@@ -433,18 +430,18 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
fmt = tok2str(unreach2str, "#%d %%s unreachable",
dp->icmp_code);
(void)snprintf(buf, sizeof(buf), fmt,
- ipaddr_string(&dp->icmp_ip.ip_dst));
+ ipaddr_string(ndo, &dp->icmp_ip.ip_dst));
break;
}
break;
case ICMP_REDIRECT:
- TCHECK(dp->icmp_ip.ip_dst);
+ ND_TCHECK(dp->icmp_ip.ip_dst);
fmt = tok2str(type2str, "redirect-#%d %%s to net %%s",
dp->icmp_code);
(void)snprintf(buf, sizeof(buf), fmt,
- ipaddr_string(&dp->icmp_ip.ip_dst),
- ipaddr_string(&dp->icmp_gwaddr));
+ ipaddr_string(ndo, &dp->icmp_ip.ip_dst),
+ ipaddr_string(ndo, &dp->icmp_gwaddr));
break;
case ICMP_ROUTERADVERT:
@@ -457,7 +454,7 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
cp = buf + strlen(buf);
ihp = (struct ih_rdiscovery *)&dp->icmp_void;
- TCHECK(*ihp);
+ ND_TCHECK(*ihp);
(void)strncpy(cp, " lifetime ", sizeof(buf) - (cp - buf));
cp = buf + strlen(buf);
lifetime = EXTRACT_16BITS(&ihp->ird_lifetime);
@@ -488,9 +485,9 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
}
idp = (struct id_rdiscovery *)&dp->icmp_data;
while (num-- > 0) {
- TCHECK(*idp);
+ ND_TCHECK(*idp);
(void)snprintf(cp, sizeof(buf) - (cp - buf), " {%s %u}",
- ipaddr_string(&idp->ird_addr),
+ ipaddr_string(ndo, &idp->ird_addr),
EXTRACT_32BITS(&idp->ird_pref));
cp = buf + strlen(buf);
++idp;
@@ -499,7 +496,7 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
break;
case ICMP_TIMXCEED:
- TCHECK(dp->icmp_ip.ip_dst);
+ ND_TCHECK(dp->icmp_ip.ip_dst);
switch (dp->icmp_code) {
case ICMP_TIMXCEED_INTRANS:
@@ -522,20 +519,20 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
(void)snprintf(buf, sizeof(buf),
"parameter problem - code %d", dp->icmp_code);
else {
- TCHECK(dp->icmp_pptr);
+ ND_TCHECK(dp->icmp_pptr);
(void)snprintf(buf, sizeof(buf),
"parameter problem - octet %d", dp->icmp_pptr);
}
break;
case ICMP_MASKREPLY:
- TCHECK(dp->icmp_mask);
+ ND_TCHECK(dp->icmp_mask);
(void)snprintf(buf, sizeof(buf), "address mask is 0x%08x",
EXTRACT_32BITS(&dp->icmp_mask));
break;
case ICMP_TSTAMP:
- TCHECK(dp->icmp_seq);
+ ND_TCHECK(dp->icmp_seq);
(void)snprintf(buf, sizeof(buf),
"time stamp query id %u seq %u",
EXTRACT_16BITS(&dp->icmp_id),
@@ -543,7 +540,7 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
break;
case ICMP_TSTAMPREPLY:
- TCHECK(dp->icmp_ttime);
+ ND_TCHECK(dp->icmp_ttime);
(void)snprintf(buf, sizeof(buf),
"time stamp reply id %u seq %u: org %s",
EXTRACT_16BITS(&dp->icmp_id),
@@ -560,19 +557,19 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
str = tok2str(icmp2str, "type-#%d", dp->icmp_type);
break;
}
- (void)printf("ICMP %s, length %u", str, plen);
- if (vflag && !fragmented) { /* don't attempt checksumming if this is a frag */
- u_int16_t sum, icmp_sum;
+ ND_PRINT((ndo, "ICMP %s, length %u", str, plen));
+ if (ndo->ndo_vflag && !fragmented) { /* don't attempt checksumming if this is a frag */
+ uint16_t sum, icmp_sum;
struct cksum_vec vec[1];
- if (TTEST2(*bp, plen)) {
- vec[0].ptr = (const u_int8_t *)(void *)dp;
+ if (ND_TTEST2(*bp, plen)) {
+ vec[0].ptr = (const uint8_t *)(void *)dp;
vec[0].len = plen;
sum = in_cksum(vec, 1);
if (sum != 0) {
icmp_sum = EXTRACT_16BITS(&dp->icmp_cksum);
- (void)printf(" (wrong icmp cksum %x (->%x)!)",
+ ND_PRINT((ndo, " (wrong icmp cksum %x (->%x)!)",
icmp_sum,
- in_cksum_shouldbe(icmp_sum, sum));
+ in_cksum_shouldbe(icmp_sum, sum)));
}
}
}
@@ -581,22 +578,22 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
* print the remnants of the IP packet.
* save the snaplength as this may get overidden in the IP printer.
*/
- if (vflag >= 1 && !ICMP_INFOTYPE(dp->icmp_type)) {
+ if (ndo->ndo_vflag >= 1 && !ICMP_INFOTYPE(dp->icmp_type)) {
bp += 8;
- (void)printf("\n\t");
+ ND_PRINT((ndo, "\n\t"));
ip = (struct ip *)bp;
- snaplen = snapend - bp;
- snapend_save = snapend;
- ip_print(gndo, bp, EXTRACT_16BITS(&ip->ip_len));
- snapend = snapend_save;
+ ndo->ndo_snaplen = ndo->ndo_snapend - bp;
+ snapend_save = ndo->ndo_snapend;
+ ip_print(ndo, bp, EXTRACT_16BITS(&ip->ip_len));
+ ndo->ndo_snapend = snapend_save;
}
/*
* Attempt to decode the MPLS extensions only for some ICMP types.
*/
- if (vflag >= 1 && plen > ICMP_EXTD_MINLEN && ICMP_MPLS_EXT_TYPE(dp->icmp_type)) {
+ if (ndo->ndo_vflag >= 1 && plen > ICMP_EXTD_MINLEN && ICMP_MPLS_EXT_TYPE(dp->icmp_type)) {
- TCHECK(*ext_dp);
+ ND_TCHECK(*ext_dp);
/*
* Check first if the mpls extension header shows a non-zero length.
@@ -605,54 +602,54 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
* however not all implementations set the length field proper.
*/
if (!ext_dp->icmp_length) {
- vec[0].ptr = (const u_int8_t *)(void *)&ext_dp->icmp_ext_version_res;
+ vec[0].ptr = (const uint8_t *)(void *)&ext_dp->icmp_ext_version_res;
vec[0].len = plen - ICMP_EXTD_MINLEN;
if (in_cksum(vec, 1)) {
return;
}
}
- printf("\n\tMPLS extension v%u",
- ICMP_MPLS_EXT_EXTRACT_VERSION(*(ext_dp->icmp_ext_version_res)));
-
+ ND_PRINT((ndo, "\n\tMPLS extension v%u",
+ ICMP_MPLS_EXT_EXTRACT_VERSION(*(ext_dp->icmp_ext_version_res))));
+
/*
* Sanity checking of the header.
*/
if (ICMP_MPLS_EXT_EXTRACT_VERSION(*(ext_dp->icmp_ext_version_res)) !=
ICMP_MPLS_EXT_VERSION) {
- printf(" packet not supported");
+ ND_PRINT((ndo, " packet not supported"));
return;
}
hlen = plen - ICMP_EXTD_MINLEN;
- vec[0].ptr = (const u_int8_t *)(void *)&ext_dp->icmp_ext_version_res;
+ vec[0].ptr = (const uint8_t *)(void *)&ext_dp->icmp_ext_version_res;
vec[0].len = hlen;
- printf(", checksum 0x%04x (%scorrect), length %u",
+ ND_PRINT((ndo, ", checksum 0x%04x (%scorrect), length %u",
EXTRACT_16BITS(ext_dp->icmp_ext_checksum),
in_cksum(vec, 1) ? "in" : "",
- hlen);
+ hlen));
hlen -= 4; /* subtract common header size */
- obj_tptr = (u_int8_t *)ext_dp->icmp_ext_data;
+ obj_tptr = (uint8_t *)ext_dp->icmp_ext_data;
while (hlen > sizeof(struct icmp_mpls_ext_object_header_t)) {
icmp_mpls_ext_object_header = (struct icmp_mpls_ext_object_header_t *)obj_tptr;
- TCHECK(*icmp_mpls_ext_object_header);
+ ND_TCHECK(*icmp_mpls_ext_object_header);
obj_tlen = EXTRACT_16BITS(icmp_mpls_ext_object_header->length);
obj_class_num = icmp_mpls_ext_object_header->class_num;
obj_ctype = icmp_mpls_ext_object_header->ctype;
obj_tptr += sizeof(struct icmp_mpls_ext_object_header_t);
- printf("\n\t %s Object (%u), Class-Type: %u, length %u",
+ ND_PRINT((ndo, "\n\t %s Object (%u), Class-Type: %u, length %u",
tok2str(icmp_mpls_ext_obj_values,"unknown",obj_class_num),
obj_class_num,
obj_ctype,
- obj_tlen);
+ obj_tlen));
hlen-=sizeof(struct icmp_mpls_ext_object_header_t); /* length field includes tlv header */
- /* infinite loop protection */
+ /* infinite loop protection */
if ((obj_class_num == 0) ||
(obj_tlen < sizeof(struct icmp_mpls_ext_object_header_t))) {
return;
@@ -663,15 +660,15 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
case 1:
switch(obj_ctype) {
case 1:
- TCHECK2(*obj_tptr, 4);
+ ND_TCHECK2(*obj_tptr, 4);
raw_label = EXTRACT_32BITS(obj_tptr);
- printf("\n\t label %u, exp %u", MPLS_LABEL(raw_label), MPLS_EXP(raw_label));
+ ND_PRINT((ndo, "\n\t label %u, exp %u", MPLS_LABEL(raw_label), MPLS_EXP(raw_label)));
if (MPLS_STACK(raw_label))
- printf(", [S]");
- printf(", ttl %u", MPLS_TTL(raw_label));
+ ND_PRINT((ndo, ", [S]"));
+ ND_PRINT((ndo, ", ttl %u", MPLS_TTL(raw_label)));
break;
default:
- print_unknown_data(obj_tptr, "\n\t ", obj_tlen);
+ print_unknown_data(ndo, obj_tptr, "\n\t ", obj_tlen);
}
break;
@@ -681,7 +678,7 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
*/
case 2:
default:
- print_unknown_data(obj_tptr, "\n\t ", obj_tlen);
+ print_unknown_data(ndo, obj_tptr, "\n\t ", obj_tlen);
break;
}
if (hlen < obj_tlen)
@@ -693,5 +690,11 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
return;
trunc:
- fputs("[|icmp]", stdout);
+ ND_PRINT((ndo, "[|icmp]"));
}
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
diff --git a/contrib/tcpdump/print-icmp6.c b/contrib/tcpdump/print-icmp6.c
index 7e0322e37f6e..553bb46ee23a 100644
--- a/contrib/tcpdump/print-icmp6.c
+++ b/contrib/tcpdump/print-icmp6.c
@@ -19,11 +19,7 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-icmp6.c,v 1.86 2008-02-05 19:36:13 guy Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -40,32 +36,463 @@ static const char rcsid[] _U_ =
#include "extract.h"
#include "ip6.h"
-#include "icmp6.h"
#include "ipproto.h"
#include "udp.h"
#include "ah.h"
+/* NetBSD: icmp6.h,v 1.13 2000/08/03 16:30:37 itojun Exp */
+/* $KAME: icmp6.h,v 1.22 2000/08/03 15:25:16 jinmei Exp $ */
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+struct icmp6_hdr {
+ uint8_t icmp6_type; /* type field */
+ uint8_t icmp6_code; /* code field */
+ uint16_t icmp6_cksum; /* checksum field */
+ union {
+ uint32_t icmp6_un_data32[1]; /* type-specific field */
+ uint16_t icmp6_un_data16[2]; /* type-specific field */
+ uint8_t icmp6_un_data8[4]; /* type-specific field */
+ } icmp6_dataun;
+};
+
+#define icmp6_data32 icmp6_dataun.icmp6_un_data32
+#define icmp6_data16 icmp6_dataun.icmp6_un_data16
+#define icmp6_data8 icmp6_dataun.icmp6_un_data8
+#define icmp6_pptr icmp6_data32[0] /* parameter prob */
+#define icmp6_mtu icmp6_data32[0] /* packet too big */
+#define icmp6_id icmp6_data16[0] /* echo request/reply */
+#define icmp6_seq icmp6_data16[1] /* echo request/reply */
+#define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */
+
+#define ICMP6_DST_UNREACH 1 /* dest unreachable, codes: */
+#define ICMP6_PACKET_TOO_BIG 2 /* packet too big */
+#define ICMP6_TIME_EXCEEDED 3 /* time exceeded, code: */
+#define ICMP6_PARAM_PROB 4 /* ip6 header bad */
+
+#define ICMP6_ECHO_REQUEST 128 /* echo service */
+#define ICMP6_ECHO_REPLY 129 /* echo reply */
+#define ICMP6_MEMBERSHIP_QUERY 130 /* group membership query */
+#define MLD6_LISTENER_QUERY 130 /* multicast listener query */
+#define ICMP6_MEMBERSHIP_REPORT 131 /* group membership report */
+#define MLD6_LISTENER_REPORT 131 /* multicast listener report */
+#define ICMP6_MEMBERSHIP_REDUCTION 132 /* group membership termination */
+#define MLD6_LISTENER_DONE 132 /* multicast listener done */
+
+#define ND_ROUTER_SOLICIT 133 /* router solicitation */
+#define ND_ROUTER_ADVERT 134 /* router advertisement */
+#define ND_NEIGHBOR_SOLICIT 135 /* neighbor solicitation */
+#define ND_NEIGHBOR_ADVERT 136 /* neighbor advertisement */
+#define ND_REDIRECT 137 /* redirect */
+
+#define ICMP6_ROUTER_RENUMBERING 138 /* router renumbering */
+
+#define ICMP6_WRUREQUEST 139 /* who are you request */
+#define ICMP6_WRUREPLY 140 /* who are you reply */
+#define ICMP6_FQDN_QUERY 139 /* FQDN query */
+#define ICMP6_FQDN_REPLY 140 /* FQDN reply */
+#define ICMP6_NI_QUERY 139 /* node information request */
+#define ICMP6_NI_REPLY 140 /* node information reply */
+#define IND_SOLICIT 141 /* inverse neighbor solicitation */
+#define IND_ADVERT 142 /* inverse neighbor advertisement */
+
+#define ICMP6_V2_MEMBERSHIP_REPORT 143 /* v2 membership report */
+#define MLDV2_LISTENER_REPORT 143 /* v2 multicast listener report */
+#define ICMP6_HADISCOV_REQUEST 144
+#define ICMP6_HADISCOV_REPLY 145
+#define ICMP6_MOBILEPREFIX_SOLICIT 146
+#define ICMP6_MOBILEPREFIX_ADVERT 147
+
+#define MLD6_MTRACE_RESP 200 /* mtrace response(to sender) */
+#define MLD6_MTRACE 201 /* mtrace messages */
+
+#define ICMP6_MAXTYPE 201
+
+#define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */
+#define ICMP6_DST_UNREACH_ADMIN 1 /* administratively prohibited */
+#define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor(obsolete) */
+#define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */
+#define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */
+#define ICMP6_DST_UNREACH_NOPORT 4 /* port unreachable */
+
+#define ICMP6_TIME_EXCEED_TRANSIT 0 /* ttl==0 in transit */
+#define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* ttl==0 in reass */
+
+#define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */
+#define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized next header */
+#define ICMP6_PARAMPROB_OPTION 2 /* unrecognized option */
+
+#define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */
+
+#define ICMP6_NI_SUBJ_IPV6 0 /* Query Subject is an IPv6 address */
+#define ICMP6_NI_SUBJ_FQDN 1 /* Query Subject is a Domain name */
+#define ICMP6_NI_SUBJ_IPV4 2 /* Query Subject is an IPv4 address */
+
+#define ICMP6_NI_SUCCESS 0 /* node information successful reply */
+#define ICMP6_NI_REFUSED 1 /* node information request is refused */
+#define ICMP6_NI_UNKNOWN 2 /* unknown Qtype */
+
+#define ICMP6_ROUTER_RENUMBERING_COMMAND 0 /* rr command */
+#define ICMP6_ROUTER_RENUMBERING_RESULT 1 /* rr result */
+#define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 /* rr seq num reset */
+
+/* Used in kernel only */
+#define ND_REDIRECT_ONLINK 0 /* redirect to an on-link node */
+#define ND_REDIRECT_ROUTER 1 /* redirect to a better router */
+
+/*
+ * Multicast Listener Discovery
+ */
+struct mld6_hdr {
+ struct icmp6_hdr mld6_hdr;
+ struct in6_addr mld6_addr; /* multicast address */
+};
+
+#define mld6_type mld6_hdr.icmp6_type
+#define mld6_code mld6_hdr.icmp6_code
+#define mld6_cksum mld6_hdr.icmp6_cksum
+#define mld6_maxdelay mld6_hdr.icmp6_data16[0]
+#define mld6_reserved mld6_hdr.icmp6_data16[1]
+
+#define MLD_MINLEN 24
+#define MLDV2_MINLEN 28
+
+/*
+ * Neighbor Discovery
+ */
+
+struct nd_router_solicit { /* router solicitation */
+ struct icmp6_hdr nd_rs_hdr;
+ /* could be followed by options */
+};
+
+#define nd_rs_type nd_rs_hdr.icmp6_type
+#define nd_rs_code nd_rs_hdr.icmp6_code
+#define nd_rs_cksum nd_rs_hdr.icmp6_cksum
+#define nd_rs_reserved nd_rs_hdr.icmp6_data32[0]
+
+struct nd_router_advert { /* router advertisement */
+ struct icmp6_hdr nd_ra_hdr;
+ uint32_t nd_ra_reachable; /* reachable time */
+ uint32_t nd_ra_retransmit; /* retransmit timer */
+ /* could be followed by options */
+};
+
+#define nd_ra_type nd_ra_hdr.icmp6_type
+#define nd_ra_code nd_ra_hdr.icmp6_code
+#define nd_ra_cksum nd_ra_hdr.icmp6_cksum
+#define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0]
+#define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1]
+#define ND_RA_FLAG_MANAGED 0x80
+#define ND_RA_FLAG_OTHER 0x40
+#define ND_RA_FLAG_HOME_AGENT 0x20
+
+/*
+ * Router preference values based on draft-draves-ipngwg-router-selection-01.
+ * These are non-standard definitions.
+ */
+#define ND_RA_FLAG_RTPREF_MASK 0x18 /* 00011000 */
+
+#define ND_RA_FLAG_RTPREF_HIGH 0x08 /* 00001000 */
+#define ND_RA_FLAG_RTPREF_MEDIUM 0x00 /* 00000000 */
+#define ND_RA_FLAG_RTPREF_LOW 0x18 /* 00011000 */
+#define ND_RA_FLAG_RTPREF_RSV 0x10 /* 00010000 */
+
+#define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
+
+struct nd_neighbor_solicit { /* neighbor solicitation */
+ struct icmp6_hdr nd_ns_hdr;
+ struct in6_addr nd_ns_target; /*target address */
+ /* could be followed by options */
+};
+
+#define nd_ns_type nd_ns_hdr.icmp6_type
+#define nd_ns_code nd_ns_hdr.icmp6_code
+#define nd_ns_cksum nd_ns_hdr.icmp6_cksum
+#define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
+
+struct nd_neighbor_advert { /* neighbor advertisement */
+ struct icmp6_hdr nd_na_hdr;
+ struct in6_addr nd_na_target; /* target address */
+ /* could be followed by options */
+};
+
+#define nd_na_type nd_na_hdr.icmp6_type
+#define nd_na_code nd_na_hdr.icmp6_code
+#define nd_na_cksum nd_na_hdr.icmp6_cksum
+#define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0]
+
+#define ND_NA_FLAG_ROUTER 0x80000000
+#define ND_NA_FLAG_SOLICITED 0x40000000
+#define ND_NA_FLAG_OVERRIDE 0x20000000
+
+struct nd_redirect { /* redirect */
+ struct icmp6_hdr nd_rd_hdr;
+ struct in6_addr nd_rd_target; /* target address */
+ struct in6_addr nd_rd_dst; /* destination address */
+ /* could be followed by options */
+};
+
+#define nd_rd_type nd_rd_hdr.icmp6_type
+#define nd_rd_code nd_rd_hdr.icmp6_code
+#define nd_rd_cksum nd_rd_hdr.icmp6_cksum
+#define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
+
+struct nd_opt_hdr { /* Neighbor discovery option header */
+ uint8_t nd_opt_type;
+ uint8_t nd_opt_len;
+ /* followed by option specific data*/
+};
+
+#define ND_OPT_SOURCE_LINKADDR 1
+#define ND_OPT_TARGET_LINKADDR 2
+#define ND_OPT_PREFIX_INFORMATION 3
+#define ND_OPT_REDIRECTED_HEADER 4
+#define ND_OPT_MTU 5
+#define ND_OPT_ADVINTERVAL 7
+#define ND_OPT_HOMEAGENT_INFO 8
+#define ND_OPT_ROUTE_INFO 24 /* RFC4191 */
+#define ND_OPT_RDNSS 25
+#define ND_OPT_DNSSL 31
+
+struct nd_opt_prefix_info { /* prefix information */
+ uint8_t nd_opt_pi_type;
+ uint8_t nd_opt_pi_len;
+ uint8_t nd_opt_pi_prefix_len;
+ uint8_t nd_opt_pi_flags_reserved;
+ uint8_t nd_opt_pi_valid_time[4];
+ uint8_t nd_opt_pi_preferred_time[4];
+ uint8_t nd_opt_pi_reserved2[4];
+ struct in6_addr nd_opt_pi_prefix;
+};
+
+#define ND_OPT_PI_FLAG_ONLINK 0x80
+#define ND_OPT_PI_FLAG_AUTO 0x40
+#define ND_OPT_PI_FLAG_ROUTER 0x20 /*2292bis*/
+
+struct nd_opt_rd_hdr { /* redirected header */
+ uint8_t nd_opt_rh_type;
+ uint8_t nd_opt_rh_len;
+ uint16_t nd_opt_rh_reserved1;
+ uint32_t nd_opt_rh_reserved2;
+ /* followed by IP header and data */
+};
+
+struct nd_opt_mtu { /* MTU option */
+ uint8_t nd_opt_mtu_type;
+ uint8_t nd_opt_mtu_len;
+ uint16_t nd_opt_mtu_reserved;
+ uint32_t nd_opt_mtu_mtu;
+};
+
+struct nd_opt_rdnss { /* RDNSS RFC 6106 5.1 */
+ uint8_t nd_opt_rdnss_type;
+ uint8_t nd_opt_rdnss_len;
+ uint16_t nd_opt_rdnss_reserved;
+ uint32_t nd_opt_rdnss_lifetime;
+ struct in6_addr nd_opt_rdnss_addr[1]; /* variable-length */
+};
+
+struct nd_opt_dnssl { /* DNSSL RFC 6106 5.2 */
+ uint8_t nd_opt_dnssl_type;
+ uint8_t nd_opt_dnssl_len;
+ uint16_t nd_opt_dnssl_reserved;
+ uint32_t nd_opt_dnssl_lifetime;
+ /* followed by list of DNS search domains, variable-length */
+};
+
+struct nd_opt_advinterval { /* Advertisement interval option */
+ uint8_t nd_opt_adv_type;
+ uint8_t nd_opt_adv_len;
+ uint16_t nd_opt_adv_reserved;
+ uint32_t nd_opt_adv_interval;
+};
+
+struct nd_opt_homeagent_info { /* Home Agent info */
+ uint8_t nd_opt_hai_type;
+ uint8_t nd_opt_hai_len;
+ uint16_t nd_opt_hai_reserved;
+ int16_t nd_opt_hai_preference;
+ uint16_t nd_opt_hai_lifetime;
+};
+
+struct nd_opt_route_info { /* route info */
+ uint8_t nd_opt_rti_type;
+ uint8_t nd_opt_rti_len;
+ uint8_t nd_opt_rti_prefixlen;
+ uint8_t nd_opt_rti_flags;
+ uint32_t nd_opt_rti_lifetime;
+ /* prefix follows */
+};
+
+/*
+ * icmp6 namelookup
+ */
+
+struct icmp6_namelookup {
+ struct icmp6_hdr icmp6_nl_hdr;
+ uint8_t icmp6_nl_nonce[8];
+ int32_t icmp6_nl_ttl;
+#if 0
+ uint8_t icmp6_nl_len;
+ uint8_t icmp6_nl_name[3];
+#endif
+ /* could be followed by options */
+};
+
+/*
+ * icmp6 node information
+ */
+struct icmp6_nodeinfo {
+ struct icmp6_hdr icmp6_ni_hdr;
+ uint8_t icmp6_ni_nonce[8];
+ /* could be followed by reply data */
+};
+
+#define ni_type icmp6_ni_hdr.icmp6_type
+#define ni_code icmp6_ni_hdr.icmp6_code
+#define ni_cksum icmp6_ni_hdr.icmp6_cksum
+#define ni_qtype icmp6_ni_hdr.icmp6_data16[0]
+#define ni_flags icmp6_ni_hdr.icmp6_data16[1]
+
+#define NI_QTYPE_NOOP 0 /* NOOP */
+#define NI_QTYPE_SUPTYPES 1 /* Supported Qtypes */
+#define NI_QTYPE_FQDN 2 /* FQDN (draft 04) */
+#define NI_QTYPE_DNSNAME 2 /* DNS Name */
+#define NI_QTYPE_NODEADDR 3 /* Node Addresses */
+#define NI_QTYPE_IPV4ADDR 4 /* IPv4 Addresses */
+
+/* network endian */
+#define NI_SUPTYPE_FLAG_COMPRESS ((uint16_t)htons(0x1))
+#define NI_FQDN_FLAG_VALIDTTL ((uint16_t)htons(0x1))
+
+/* network endian */
+#define NI_NODEADDR_FLAG_TRUNCATE ((uint16_t)htons(0x1))
+#define NI_NODEADDR_FLAG_ALL ((uint16_t)htons(0x2))
+#define NI_NODEADDR_FLAG_COMPAT ((uint16_t)htons(0x4))
+#define NI_NODEADDR_FLAG_LINKLOCAL ((uint16_t)htons(0x8))
+#define NI_NODEADDR_FLAG_SITELOCAL ((uint16_t)htons(0x10))
+#define NI_NODEADDR_FLAG_GLOBAL ((uint16_t)htons(0x20))
+#define NI_NODEADDR_FLAG_ANYCAST ((uint16_t)htons(0x40)) /* just experimental. not in spec */
+
+struct ni_reply_fqdn {
+ uint32_t ni_fqdn_ttl; /* TTL */
+ uint8_t ni_fqdn_namelen; /* length in octets of the FQDN */
+ uint8_t ni_fqdn_name[3]; /* XXX: alignment */
+};
+
+/*
+ * Router Renumbering. as router-renum-08.txt
+ */
+struct icmp6_router_renum { /* router renumbering header */
+ struct icmp6_hdr rr_hdr;
+ uint8_t rr_segnum;
+ uint8_t rr_flags;
+ uint16_t rr_maxdelay;
+ uint32_t rr_reserved;
+};
+#define ICMP6_RR_FLAGS_TEST 0x80
+#define ICMP6_RR_FLAGS_REQRESULT 0x40
+#define ICMP6_RR_FLAGS_FORCEAPPLY 0x20
+#define ICMP6_RR_FLAGS_SPECSITE 0x10
+#define ICMP6_RR_FLAGS_PREVDONE 0x08
+
+#define rr_type rr_hdr.icmp6_type
+#define rr_code rr_hdr.icmp6_code
+#define rr_cksum rr_hdr.icmp6_cksum
+#define rr_seqnum rr_hdr.icmp6_data32[0]
+
+struct rr_pco_match { /* match prefix part */
+ uint8_t rpm_code;
+ uint8_t rpm_len;
+ uint8_t rpm_ordinal;
+ uint8_t rpm_matchlen;
+ uint8_t rpm_minlen;
+ uint8_t rpm_maxlen;
+ uint16_t rpm_reserved;
+ struct in6_addr rpm_prefix;
+};
+
+#define RPM_PCO_ADD 1
+#define RPM_PCO_CHANGE 2
+#define RPM_PCO_SETGLOBAL 3
+#define RPM_PCO_MAX 4
+
+struct rr_pco_use { /* use prefix part */
+ uint8_t rpu_uselen;
+ uint8_t rpu_keeplen;
+ uint8_t rpu_ramask;
+ uint8_t rpu_raflags;
+ uint32_t rpu_vltime;
+ uint32_t rpu_pltime;
+ uint32_t rpu_flags;
+ struct in6_addr rpu_prefix;
+};
+#define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x80
+#define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x40
+
+/* network endian */
+#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME ((uint32_t)htonl(0x80000000))
+#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME ((uint32_t)htonl(0x40000000))
+
+struct rr_result { /* router renumbering result message */
+ uint16_t rrr_flags;
+ uint8_t rrr_ordinal;
+ uint8_t rrr_matchedlen;
+ uint32_t rrr_ifid;
+ struct in6_addr rrr_prefix;
+};
+/* network endian */
+#define ICMP6_RR_RESULT_FLAGS_OOB ((uint16_t)htons(0x0002))
+#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN ((uint16_t)htons(0x0001))
+
static const char *get_rtpref(u_int);
-static const char *get_lifetime(u_int32_t);
-static void print_lladdr(const u_char *, size_t);
-static void icmp6_opt_print(const u_char *, int);
-static void mld6_print(const u_char *);
-static void mldv2_report_print(const u_char *, u_int);
-static void mldv2_query_print(const u_char *, u_int);
-static struct udphdr *get_upperlayer(u_char *, u_int *);
-static void dnsname_print(const u_char *, const u_char *);
-static void icmp6_nodeinfo_print(u_int, const u_char *, const u_char *);
-static void icmp6_rrenum_print(const u_char *, const u_char *);
+static const char *get_lifetime(uint32_t);
+static void print_lladdr(netdissect_options *ndo, const u_char *, size_t);
+static void icmp6_opt_print(netdissect_options *ndo, const u_char *, int);
+static void mld6_print(netdissect_options *ndo, const u_char *);
+static void mldv2_report_print(netdissect_options *ndo, const u_char *, u_int);
+static void mldv2_query_print(netdissect_options *ndo, const u_char *, u_int);
+static const struct udphdr *get_upperlayer(netdissect_options *ndo, const u_char *, u_int *);
+static void dnsname_print(netdissect_options *ndo, const u_char *, const u_char *);
+static void icmp6_nodeinfo_print(netdissect_options *ndo, u_int, const u_char *, const u_char *);
+static void icmp6_rrenum_print(netdissect_options *ndo, const u_char *, const u_char *);
#ifndef abs
#define abs(a) ((0 < (a)) ? (a) : -(a))
#endif
-/* inline the various RPL definitions */
-#define ND_RPL_MESSAGE 0x9B
+#include "rpl.h"
-static struct tok icmp6_type_values[] = {
+static const struct tok icmp6_type_values[] = {
{ ICMP6_DST_UNREACH, "destination unreachable"},
{ ICMP6_PACKET_TOO_BIG, "packet too big"},
{ ICMP6_TIME_EXCEEDED, "time exceeded in-transit"},
@@ -98,7 +525,7 @@ static struct tok icmp6_type_values[] = {
{ 0, NULL }
};
-static struct tok icmp6_dst_unreach_code_values[] = {
+static const struct tok icmp6_dst_unreach_code_values[] = {
{ ICMP6_DST_UNREACH_NOROUTE, "unreachable route" },
{ ICMP6_DST_UNREACH_ADMIN, " unreachable prohibited"},
{ ICMP6_DST_UNREACH_BEYONDSCOPE, "beyond scope"},
@@ -107,21 +534,21 @@ static struct tok icmp6_dst_unreach_code_values[] = {
{ 0, NULL }
};
-static struct tok icmp6_opt_pi_flag_values[] = {
+static const struct tok icmp6_opt_pi_flag_values[] = {
{ ND_OPT_PI_FLAG_ONLINK, "onlink" },
{ ND_OPT_PI_FLAG_AUTO, "auto" },
{ ND_OPT_PI_FLAG_ROUTER, "router" },
{ 0, NULL }
};
-static struct tok icmp6_opt_ra_flag_values[] = {
+static const struct tok icmp6_opt_ra_flag_values[] = {
{ ND_RA_FLAG_MANAGED, "managed" },
{ ND_RA_FLAG_OTHER, "other stateful"},
{ ND_RA_FLAG_HOME_AGENT, "home agent"},
{ 0, NULL }
};
-static struct tok icmp6_nd_na_flag_values[] = {
+static const struct tok icmp6_nd_na_flag_values[] = {
{ ND_NA_FLAG_ROUTER, "router" },
{ ND_NA_FLAG_SOLICITED, "solicited" },
{ ND_NA_FLAG_OVERRIDE, "override" },
@@ -129,7 +556,7 @@ static struct tok icmp6_nd_na_flag_values[] = {
};
-static struct tok icmp6_opt_values[] = {
+static const struct tok icmp6_opt_values[] = {
{ ND_OPT_SOURCE_LINKADDR, "source link-address"},
{ ND_OPT_TARGET_LINKADDR, "destination link-address"},
{ ND_OPT_PREFIX_INFORMATION, "prefix info"},
@@ -144,7 +571,7 @@ static struct tok icmp6_opt_values[] = {
};
/* mldv2 report types */
-static struct tok mldv2report2str[] = {
+static const struct tok mldv2report2str[] = {
{ 1, "is_in" },
{ 2, "is_ex" },
{ 3, "to_in" },
@@ -168,11 +595,11 @@ get_rtpref(u_int v)
}
static const char *
-get_lifetime(u_int32_t v)
+get_lifetime(uint32_t v)
{
static char buf[20];
- if (v == (u_int32_t)~0UL)
+ if (v == (uint32_t)~0UL)
return "infinity";
else {
snprintf(buf, sizeof(buf), "%us", v);
@@ -181,16 +608,16 @@ get_lifetime(u_int32_t v)
}
static void
-print_lladdr(const u_int8_t *p, size_t l)
+print_lladdr(netdissect_options *ndo, const uint8_t *p, size_t l)
{
- const u_int8_t *ep, *q;
+ const uint8_t *ep, *q;
q = p;
ep = p + l;
while (l > 0 && q < ep) {
if (q > p)
- printf(":");
- printf("%02x", *q++);
+ ND_PRINT((ndo,":"));
+ ND_PRINT((ndo,"%02x", *q++));
l--;
}
}
@@ -198,93 +625,249 @@ print_lladdr(const u_int8_t *p, size_t l)
static int icmp6_cksum(const struct ip6_hdr *ip6, const struct icmp6_hdr *icp,
u_int len)
{
- return (nextproto6_cksum(ip6, (const u_int8_t *)(void *)icp, len,
- IPPROTO_ICMPV6));
+ return nextproto6_cksum(ip6, (const uint8_t *)(void *)icp, len, len,
+ IPPROTO_ICMPV6);
}
-enum ND_RPL_CODE {
- ND_RPL_DIS =0x00,
- ND_RPL_DIO =0x01,
- ND_RPL_DAO =0x02,
- ND_RPL_DAO_ACK=0x03,
- ND_RPL_SDIS =0x80,
- ND_RPL_SDIO =0x81,
- ND_RPL_SDAO =0x82,
- ND_RPL_SDAO_ACK=0x83,
- ND_RPL_SCC =0x8A,
+const struct tok rpl_mop_values[] = {
+ { RPL_DIO_NONSTORING, "nonstoring"},
+ { RPL_DIO_STORING, "storing"},
+ { RPL_DIO_NONSTORING_MULTICAST, "nonstoring-multicast"},
+ { RPL_DIO_STORING_MULTICAST, "storing-multicast"},
+ { 0, NULL},
};
-enum ND_RPL_DIO_FLAGS {
- ND_RPL_DIO_GROUNDED = 0x80,
- ND_RPL_DIO_DATRIG = 0x40,
- ND_RPL_DIO_DASUPPORT= 0x20,
- ND_RPL_DIO_RES4 = 0x10,
- ND_RPL_DIO_RES3 = 0x08,
- ND_RPL_DIO_PRF_MASK = 0x07, /* 3-bit preference */
+const struct tok rpl_subopt_values[] = {
+ { RPL_OPT_PAD0, "pad0"},
+ { RPL_OPT_PADN, "padN"},
+ { RPL_DIO_METRICS, "metrics"},
+ { RPL_DIO_ROUTINGINFO, "routinginfo"},
+ { RPL_DIO_CONFIG, "config"},
+ { RPL_DAO_RPLTARGET, "rpltarget"},
+ { RPL_DAO_TRANSITINFO, "transitinfo"},
+ { RPL_DIO_DESTPREFIX, "destprefix"},
+ { RPL_DAO_RPLTARGET_DESC, "rpltargetdesc"},
+ { 0, NULL},
};
-struct nd_rpl_dio {
- u_int8_t rpl_flags;
- u_int8_t rpl_seq;
- u_int8_t rpl_instanceid;
- u_int8_t rpl_dagrank;
- u_int8_t rpl_dagid[16];
-};
+static void
+rpl_format_dagid(char dagid_str[65], const u_char *dagid)
+{
+ char *d = dagid_str;
+ int i;
+
+ for(i=0;i<16;i++) {
+ if(isprint(dagid[i])) {
+ *d++ = dagid[i];
+ } else {
+ snprintf(d,4,"0x%02x", dagid[i]);
+ d += 4;
+ }
+ }
+ *d++ = '\0';
+}
+
+static void
+rpl_dio_printopt(netdissect_options *ndo,
+ const struct rpl_dio_genoption *opt,
+ u_int length)
+{
+ if(length < RPL_DIO_GENOPTION_LEN) return;
+ length -= RPL_DIO_GENOPTION_LEN;
+
+ ND_TCHECK(opt->rpl_dio_len);
+
+ while((opt->rpl_dio_type == RPL_OPT_PAD0 &&
+ (u_char *)opt < ndo->ndo_snapend) ||
+ ND_TTEST2(*opt,(opt->rpl_dio_len+2))) {
+
+ unsigned int optlen = opt->rpl_dio_len+2;
+ if(opt->rpl_dio_type == RPL_OPT_PAD0) {
+ optlen = 1;
+ ND_PRINT((ndo, " opt:pad0"));
+ } else {
+ ND_PRINT((ndo, " opt:%s len:%u ",
+ tok2str(rpl_subopt_values, "%subopt:%u", opt->rpl_dio_type),
+ optlen));
+ if(ndo->ndo_vflag > 2) {
+ unsigned int paylen = opt->rpl_dio_len;
+ if(paylen > length) paylen = length;
+ hex_print(ndo,
+ " ",
+ ((uint8_t *)opt) + RPL_DIO_GENOPTION_LEN, /* content of DIO option */
+ paylen);
+ }
+ }
+ opt = (struct rpl_dio_genoption *)(((char *)opt) + optlen);
+ length -= optlen;
+ }
+ return;
+trunc:
+ ND_PRINT((ndo," [|truncated]"));
+ return;
+}
+
+static void
+rpl_dio_print(netdissect_options *ndo,
+ const u_char *bp, u_int length)
+{
+ const struct nd_rpl_dio *dio = (struct nd_rpl_dio *)bp;
+ char dagid_str[65];
+
+ ND_TCHECK(*dio);
+ rpl_format_dagid(dagid_str, dio->rpl_dagid);
+
+ ND_PRINT((ndo, " [dagid:%s,seq:%u,instance:%u,rank:%u,%smop:%s,prf:%u]",
+ dagid_str,
+ dio->rpl_dtsn,
+ dio->rpl_instanceid,
+ EXTRACT_16BITS(&dio->rpl_dagrank),
+ RPL_DIO_GROUNDED(dio->rpl_mopprf) ? "grounded,":"",
+ tok2str(rpl_mop_values, "mop%u", RPL_DIO_MOP(dio->rpl_mopprf)),
+ RPL_DIO_PRF(dio->rpl_mopprf)));
+
+ if(ndo->ndo_vflag > 1) {
+ struct rpl_dio_genoption *opt = (struct rpl_dio_genoption *)&dio[1];
+ rpl_dio_printopt(ndo, opt, length);
+ }
+ return;
+trunc:
+ ND_PRINT((ndo," [|truncated]"));
+ return;
+}
+
+static void
+rpl_dao_print(netdissect_options *ndo,
+ const u_char *bp, u_int length)
+{
+ const struct nd_rpl_dao *dao = (struct nd_rpl_dao *)bp;
+ char dagid_str[65];
+
+ ND_TCHECK(*dao);
+ if (length < ND_RPL_DAO_MIN_LEN)
+ goto tooshort;
+
+ strcpy(dagid_str,"<elided>");
+ bp += ND_RPL_DAO_MIN_LEN;
+ length -= ND_RPL_DAO_MIN_LEN;
+ if(RPL_DAO_D(dao->rpl_flags)) {
+ ND_TCHECK2(dao->rpl_dagid, DAGID_LEN);
+ if (length < DAGID_LEN)
+ goto tooshort;
+ rpl_format_dagid(dagid_str, dao->rpl_dagid);
+ bp += DAGID_LEN;
+ length -= DAGID_LEN;
+ }
+
+ ND_PRINT((ndo, " [dagid:%s,seq:%u,instance:%u%s%s,%02x]",
+ dagid_str,
+ dao->rpl_daoseq,
+ dao->rpl_instanceid,
+ RPL_DAO_K(dao->rpl_flags) ? ",acK":"",
+ RPL_DAO_D(dao->rpl_flags) ? ",Dagid":"",
+ dao->rpl_flags));
+
+ if(ndo->ndo_vflag > 1) {
+ const struct rpl_dio_genoption *opt = (struct rpl_dio_genoption *)bp;
+ rpl_dio_printopt(ndo, opt, length);
+ }
+ return;
+
+trunc:
+ ND_PRINT((ndo," [|truncated]"));
+ return;
+
+tooshort:
+ ND_PRINT((ndo," [|length too short]"));
+ return;
+}
+
+static void
+rpl_daoack_print(netdissect_options *ndo,
+ const u_char *bp, u_int length)
+{
+ const struct nd_rpl_daoack *daoack = (struct nd_rpl_daoack *)bp;
+ char dagid_str[65];
+
+ ND_TCHECK2(*daoack, ND_RPL_DAOACK_MIN_LEN);
+ if (length < ND_RPL_DAOACK_MIN_LEN)
+ goto tooshort;
+
+ strcpy(dagid_str,"<elided>");
+ bp += ND_RPL_DAOACK_MIN_LEN;
+ length -= ND_RPL_DAOACK_MIN_LEN;
+ if(RPL_DAOACK_D(daoack->rpl_flags)) {
+ ND_TCHECK2(daoack->rpl_dagid, 16);
+ if (length < DAGID_LEN)
+ goto tooshort;
+ rpl_format_dagid(dagid_str, daoack->rpl_dagid);
+ bp += DAGID_LEN;
+ length -= DAGID_LEN;
+ }
+
+ ND_PRINT((ndo, " [dagid:%s,seq:%u,instance:%u,status:%u]",
+ dagid_str,
+ daoack->rpl_daoseq,
+ daoack->rpl_instanceid,
+ daoack->rpl_status));
+
+ /* no officially defined options for DAOACK, but print any we find */
+ if(ndo->ndo_vflag > 1) {
+ const struct rpl_dio_genoption *opt = (struct rpl_dio_genoption *)bp;
+ rpl_dio_printopt(ndo, opt, length);
+ }
+ return;
+
+trunc:
+ ND_PRINT((ndo," [|dao-truncated]"));
+ return;
+
+tooshort:
+ ND_PRINT((ndo," [|dao-length too short]"));
+ return;
+}
static void
rpl_print(netdissect_options *ndo,
const struct icmp6_hdr *hdr,
- const u_char *bp, u_int length _U_)
+ const u_char *bp, u_int length)
{
- struct nd_rpl_dio *dio = (struct nd_rpl_dio *)bp;
int secured = hdr->icmp6_code & 0x80;
int basecode= hdr->icmp6_code & 0x7f;
- ND_TCHECK(dio->rpl_dagid);
-
if(secured) {
- ND_PRINT((ndo, ", (SEC)"));
+ ND_PRINT((ndo, ", (SEC) [worktodo]"));
+ /* XXX
+ * the next header pointer needs to move forward to
+ * skip the secure part.
+ */
+ return;
} else {
ND_PRINT((ndo, ", (CLR)"));
}
-
+
switch(basecode) {
- case ND_RPL_DIS:
+ case ND_RPL_DAG_IS:
ND_PRINT((ndo, "DODAG Information Solicitation"));
if(ndo->ndo_vflag) {
}
break;
- case ND_RPL_DIO:
+ case ND_RPL_DAG_IO:
ND_PRINT((ndo, "DODAG Information Object"));
if(ndo->ndo_vflag) {
- char dagid[65];
- char *d = dagid;
- int i;
- for(i=0;i<16;i++) {
- if(isprint(dio->rpl_dagid[i])) {
- *d++ = dio->rpl_dagid[i];
- } else {
- int cnt=snprintf(d,4,"0x%02x",
- dio->rpl_dagid[i]);
- d += cnt;
- }
- }
- *d++ = '\0';
- ND_PRINT((ndo, " [seq:%u,instance:%u,rank:%u,dagid:%s]",
- dio->rpl_seq,
- dio->rpl_instanceid,
- dio->rpl_dagrank,
- dagid));
+ rpl_dio_print(ndo, bp, length);
}
break;
case ND_RPL_DAO:
ND_PRINT((ndo, "Destination Advertisement Object"));
if(ndo->ndo_vflag) {
+ rpl_dao_print(ndo, bp, length);
}
break;
case ND_RPL_DAO_ACK:
ND_PRINT((ndo, "Destination Advertisement Object Ack"));
if(ndo->ndo_vflag) {
+ rpl_daoack_print(ndo, bp, length);
}
break;
default:
@@ -292,10 +875,13 @@ rpl_print(netdissect_options *ndo,
break;
}
return;
+
+#if 0
trunc:
ND_PRINT((ndo," [|truncated]"));
return;
-
+#endif
+
}
@@ -315,167 +901,167 @@ icmp6_print(netdissect_options *ndo,
ip = (struct ip6_hdr *)bp2;
oip = (struct ip6_hdr *)(dp + 1);
/* 'ep' points to the end of available data. */
- ep = snapend;
+ ep = ndo->ndo_snapend;
- TCHECK(dp->icmp6_cksum);
+ ND_TCHECK(dp->icmp6_cksum);
- if (vflag && !fragmented) {
- u_int16_t sum, udp_sum;
+ if (ndo->ndo_vflag && !fragmented) {
+ uint16_t sum, udp_sum;
- if (TTEST2(bp[0], length)) {
+ if (ND_TTEST2(bp[0], length)) {
udp_sum = EXTRACT_16BITS(&dp->icmp6_cksum);
sum = icmp6_cksum(ip, dp, length);
if (sum != 0)
- (void)printf("[bad icmp6 cksum 0x%04x -> 0x%04x!] ",
- udp_sum,
- in_cksum_shouldbe(udp_sum, sum));
+ ND_PRINT((ndo,"[bad icmp6 cksum 0x%04x -> 0x%04x!] ",
+ udp_sum,
+ in_cksum_shouldbe(udp_sum, sum)));
else
- (void)printf("[icmp6 sum ok] ");
+ ND_PRINT((ndo,"[icmp6 sum ok] "));
}
}
- printf("ICMP6, %s", tok2str(icmp6_type_values,"unknown icmp6 type (%u)",dp->icmp6_type));
+ ND_PRINT((ndo,"ICMP6, %s", tok2str(icmp6_type_values,"unknown icmp6 type (%u)",dp->icmp6_type)));
/* display cosmetics: print the packet length for printer that use the vflag now */
- if (vflag && (dp->icmp6_type == ND_ROUTER_SOLICIT ||
+ if (ndo->ndo_vflag && (dp->icmp6_type == ND_ROUTER_SOLICIT ||
dp->icmp6_type == ND_ROUTER_ADVERT ||
dp->icmp6_type == ND_NEIGHBOR_ADVERT ||
dp->icmp6_type == ND_NEIGHBOR_SOLICIT ||
dp->icmp6_type == ND_REDIRECT ||
dp->icmp6_type == ICMP6_HADISCOV_REPLY ||
dp->icmp6_type == ICMP6_MOBILEPREFIX_ADVERT ))
- printf(", length %u", length);
-
+ ND_PRINT((ndo,", length %u", length));
+
switch (dp->icmp6_type) {
case ICMP6_DST_UNREACH:
- TCHECK(oip->ip6_dst);
- printf(", %s", tok2str(icmp6_dst_unreach_code_values,"unknown unreach code (%u)",dp->icmp6_code));
+ ND_TCHECK(oip->ip6_dst);
+ ND_PRINT((ndo,", %s", tok2str(icmp6_dst_unreach_code_values,"unknown unreach code (%u)",dp->icmp6_code)));
switch (dp->icmp6_code) {
case ICMP6_DST_UNREACH_NOROUTE: /* fall through */
case ICMP6_DST_UNREACH_ADMIN:
case ICMP6_DST_UNREACH_ADDR:
- printf(" %s",ip6addr_string(&oip->ip6_dst));
+ ND_PRINT((ndo," %s",ip6addr_string(ndo, &oip->ip6_dst)));
break;
case ICMP6_DST_UNREACH_BEYONDSCOPE:
- printf(" %s, source address %s",
- ip6addr_string(&oip->ip6_dst),
- ip6addr_string(&oip->ip6_src));
+ ND_PRINT((ndo," %s, source address %s",
+ ip6addr_string(ndo, &oip->ip6_dst),
+ ip6addr_string(ndo, &oip->ip6_src)));
break;
case ICMP6_DST_UNREACH_NOPORT:
- if ((ouh = get_upperlayer((u_char *)oip, &prot))
+ if ((ouh = get_upperlayer(ndo, (u_char *)oip, &prot))
== NULL)
goto trunc;
dport = EXTRACT_16BITS(&ouh->uh_dport);
switch (prot) {
case IPPROTO_TCP:
- printf(", %s tcp port %s",
- ip6addr_string(&oip->ip6_dst),
- tcpport_string(dport));
+ ND_PRINT((ndo,", %s tcp port %s",
+ ip6addr_string(ndo, &oip->ip6_dst),
+ tcpport_string(dport)));
break;
case IPPROTO_UDP:
- printf(", %s udp port %s",
- ip6addr_string(&oip->ip6_dst),
- udpport_string(dport));
+ ND_PRINT((ndo,", %s udp port %s",
+ ip6addr_string(ndo, &oip->ip6_dst),
+ udpport_string(dport)));
break;
default:
- printf(", %s protocol %d port %d unreachable",
- ip6addr_string(&oip->ip6_dst),
- oip->ip6_nxt, dport);
+ ND_PRINT((ndo,", %s protocol %d port %d unreachable",
+ ip6addr_string(ndo, &oip->ip6_dst),
+ oip->ip6_nxt, dport));
break;
}
break;
default:
- if (vflag <= 1) {
- print_unknown_data(bp,"\n\t",length);
- return;
- }
+ if (ndo->ndo_vflag <= 1) {
+ print_unknown_data(ndo, bp,"\n\t",length);
+ return;
+ }
break;
}
break;
case ICMP6_PACKET_TOO_BIG:
- TCHECK(dp->icmp6_mtu);
- printf(", mtu %u", EXTRACT_32BITS(&dp->icmp6_mtu));
+ ND_TCHECK(dp->icmp6_mtu);
+ ND_PRINT((ndo,", mtu %u", EXTRACT_32BITS(&dp->icmp6_mtu)));
break;
case ICMP6_TIME_EXCEEDED:
- TCHECK(oip->ip6_dst);
+ ND_TCHECK(oip->ip6_dst);
switch (dp->icmp6_code) {
case ICMP6_TIME_EXCEED_TRANSIT:
- printf(" for %s",
- ip6addr_string(&oip->ip6_dst));
+ ND_PRINT((ndo," for %s",
+ ip6addr_string(ndo, &oip->ip6_dst)));
break;
case ICMP6_TIME_EXCEED_REASSEMBLY:
- printf(" (reassembly)");
+ ND_PRINT((ndo," (reassembly)"));
break;
default:
- printf(", unknown code (%u)", dp->icmp6_code);
+ ND_PRINT((ndo,", unknown code (%u)", dp->icmp6_code));
break;
}
break;
case ICMP6_PARAM_PROB:
- TCHECK(oip->ip6_dst);
+ ND_TCHECK(oip->ip6_dst);
switch (dp->icmp6_code) {
case ICMP6_PARAMPROB_HEADER:
- printf(", errorneous - octet %u", EXTRACT_32BITS(&dp->icmp6_pptr));
- break;
+ ND_PRINT((ndo,", erroneous - octet %u", EXTRACT_32BITS(&dp->icmp6_pptr)));
+ break;
case ICMP6_PARAMPROB_NEXTHEADER:
- printf(", next header - octet %u", EXTRACT_32BITS(&dp->icmp6_pptr));
- break;
+ ND_PRINT((ndo,", next header - octet %u", EXTRACT_32BITS(&dp->icmp6_pptr)));
+ break;
case ICMP6_PARAMPROB_OPTION:
- printf(", option - octet %u", EXTRACT_32BITS(&dp->icmp6_pptr));
- break;
+ ND_PRINT((ndo,", option - octet %u", EXTRACT_32BITS(&dp->icmp6_pptr)));
+ break;
default:
- printf(", code-#%d",
- dp->icmp6_code);
- break;
+ ND_PRINT((ndo,", code-#%d",
+ dp->icmp6_code));
+ break;
}
break;
case ICMP6_ECHO_REQUEST:
case ICMP6_ECHO_REPLY:
- TCHECK(dp->icmp6_seq);
- printf(", seq %u", EXTRACT_16BITS(&dp->icmp6_seq));
+ ND_TCHECK(dp->icmp6_seq);
+ ND_PRINT((ndo,", seq %u", EXTRACT_16BITS(&dp->icmp6_seq)));
break;
case ICMP6_MEMBERSHIP_QUERY:
if (length == MLD_MINLEN) {
- mld6_print((const u_char *)dp);
+ mld6_print(ndo, (const u_char *)dp);
} else if (length >= MLDV2_MINLEN) {
- printf(" v2");
- mldv2_query_print((const u_char *)dp, length);
+ ND_PRINT((ndo," v2"));
+ mldv2_query_print(ndo, (const u_char *)dp, length);
} else {
- printf(" unknown-version (len %u) ", length);
+ ND_PRINT((ndo," unknown-version (len %u) ", length));
}
break;
case ICMP6_MEMBERSHIP_REPORT:
- mld6_print((const u_char *)dp);
+ mld6_print(ndo, (const u_char *)dp);
break;
case ICMP6_MEMBERSHIP_REDUCTION:
- mld6_print((const u_char *)dp);
+ mld6_print(ndo, (const u_char *)dp);
break;
case ND_ROUTER_SOLICIT:
#define RTSOLLEN 8
- if (vflag) {
- icmp6_opt_print((const u_char *)dp + RTSOLLEN,
+ if (ndo->ndo_vflag) {
+ icmp6_opt_print(ndo, (const u_char *)dp + RTSOLLEN,
length - RTSOLLEN);
}
break;
case ND_ROUTER_ADVERT:
#define RTADVLEN 16
- if (vflag) {
+ if (ndo->ndo_vflag) {
struct nd_router_advert *p;
p = (struct nd_router_advert *)dp;
- TCHECK(p->nd_ra_retransmit);
- printf("\n\thop limit %u, Flags [%s]" \
- ", pref %s, router lifetime %us, reachable time %us, retrans time %us",
- (u_int)p->nd_ra_curhoplimit,
- bittok2str(icmp6_opt_ra_flag_values,"none",(p->nd_ra_flags_reserved)),
- get_rtpref(p->nd_ra_flags_reserved),
- EXTRACT_16BITS(&p->nd_ra_router_lifetime),
- EXTRACT_32BITS(&p->nd_ra_reachable),
- EXTRACT_32BITS(&p->nd_ra_retransmit));
-
- icmp6_opt_print((const u_char *)dp + RTADVLEN,
+ ND_TCHECK(p->nd_ra_retransmit);
+ ND_PRINT((ndo,"\n\thop limit %u, Flags [%s]" \
+ ", pref %s, router lifetime %us, reachable time %us, retrans time %us",
+ (u_int)p->nd_ra_curhoplimit,
+ bittok2str(icmp6_opt_ra_flag_values,"none",(p->nd_ra_flags_reserved)),
+ get_rtpref(p->nd_ra_flags_reserved),
+ EXTRACT_16BITS(&p->nd_ra_router_lifetime),
+ EXTRACT_32BITS(&p->nd_ra_reachable),
+ EXTRACT_32BITS(&p->nd_ra_retransmit)));
+
+ icmp6_opt_print(ndo, (const u_char *)dp + RTADVLEN,
length - RTADVLEN);
}
break;
@@ -483,11 +1069,11 @@ icmp6_print(netdissect_options *ndo,
{
struct nd_neighbor_solicit *p;
p = (struct nd_neighbor_solicit *)dp;
- TCHECK(p->nd_ns_target);
- printf(", who has %s", ip6addr_string(&p->nd_ns_target));
- if (vflag) {
+ ND_TCHECK(p->nd_ns_target);
+ ND_PRINT((ndo,", who has %s", ip6addr_string(ndo, &p->nd_ns_target)));
+ if (ndo->ndo_vflag) {
#define NDSOLLEN 24
- icmp6_opt_print((const u_char *)dp + NDSOLLEN,
+ icmp6_opt_print(ndo, (const u_char *)dp + NDSOLLEN,
length - NDSOLLEN);
}
}
@@ -497,16 +1083,16 @@ icmp6_print(netdissect_options *ndo,
struct nd_neighbor_advert *p;
p = (struct nd_neighbor_advert *)dp;
- TCHECK(p->nd_na_target);
- printf(", tgt is %s",
- ip6addr_string(&p->nd_na_target));
- if (vflag) {
- printf(", Flags [%s]",
- bittok2str(icmp6_nd_na_flag_values,
- "none",
- EXTRACT_32BITS(&p->nd_na_flags_reserved)));
+ ND_TCHECK(p->nd_na_target);
+ ND_PRINT((ndo,", tgt is %s",
+ ip6addr_string(ndo, &p->nd_na_target)));
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo,", Flags [%s]",
+ bittok2str(icmp6_nd_na_flag_values,
+ "none",
+ EXTRACT_32BITS(&p->nd_na_flags_reserved))));
#define NDADVLEN 24
- icmp6_opt_print((const u_char *)dp + NDADVLEN,
+ icmp6_opt_print(ndo, (const u_char *)dp + NDADVLEN,
length - NDADVLEN);
#undef NDADVLEN
}
@@ -514,99 +1100,100 @@ icmp6_print(netdissect_options *ndo,
break;
case ND_REDIRECT:
#define RDR(i) ((struct nd_redirect *)(i))
- TCHECK(RDR(dp)->nd_rd_dst);
- printf(", %s", getname6((const u_char *)&RDR(dp)->nd_rd_dst));
- TCHECK(RDR(dp)->nd_rd_target);
- printf(" to %s",
- getname6((const u_char*)&RDR(dp)->nd_rd_target));
+ ND_TCHECK(RDR(dp)->nd_rd_dst);
+ ND_PRINT((ndo,", %s", getname6(ndo, (const u_char *)&RDR(dp)->nd_rd_dst)));
+ ND_TCHECK(RDR(dp)->nd_rd_target);
+ ND_PRINT((ndo," to %s",
+ getname6(ndo, (const u_char*)&RDR(dp)->nd_rd_target)));
#define REDIRECTLEN 40
- if (vflag) {
- icmp6_opt_print((const u_char *)dp + REDIRECTLEN,
+ if (ndo->ndo_vflag) {
+ icmp6_opt_print(ndo, (const u_char *)dp + REDIRECTLEN,
length - REDIRECTLEN);
}
break;
#undef REDIRECTLEN
#undef RDR
case ICMP6_ROUTER_RENUMBERING:
- icmp6_rrenum_print(bp, ep);
+ icmp6_rrenum_print(ndo, bp, ep);
break;
case ICMP6_NI_QUERY:
case ICMP6_NI_REPLY:
- icmp6_nodeinfo_print(length, bp, ep);
+ icmp6_nodeinfo_print(ndo, length, bp, ep);
break;
case IND_SOLICIT:
case IND_ADVERT:
break;
case ICMP6_V2_MEMBERSHIP_REPORT:
- mldv2_report_print((const u_char *) dp, length);
+ mldv2_report_print(ndo, (const u_char *) dp, length);
break;
case ICMP6_MOBILEPREFIX_SOLICIT: /* fall through */
case ICMP6_HADISCOV_REQUEST:
- TCHECK(dp->icmp6_data16[0]);
- printf(", id 0x%04x", EXTRACT_16BITS(&dp->icmp6_data16[0]));
+ ND_TCHECK(dp->icmp6_data16[0]);
+ ND_PRINT((ndo,", id 0x%04x", EXTRACT_16BITS(&dp->icmp6_data16[0])));
break;
case ICMP6_HADISCOV_REPLY:
- if (vflag) {
+ if (ndo->ndo_vflag) {
struct in6_addr *in6;
u_char *cp;
- TCHECK(dp->icmp6_data16[0]);
- printf(", id 0x%04x", EXTRACT_16BITS(&dp->icmp6_data16[0]));
+ ND_TCHECK(dp->icmp6_data16[0]);
+ ND_PRINT((ndo,", id 0x%04x", EXTRACT_16BITS(&dp->icmp6_data16[0])));
cp = (u_char *)dp + length;
in6 = (struct in6_addr *)(dp + 1);
for (; (u_char *)in6 < cp; in6++) {
- TCHECK(*in6);
- printf(", %s", ip6addr_string(in6));
+ ND_TCHECK(*in6);
+ ND_PRINT((ndo,", %s", ip6addr_string(ndo, in6)));
}
}
break;
case ICMP6_MOBILEPREFIX_ADVERT:
- if (vflag) {
- TCHECK(dp->icmp6_data16[0]);
- printf(", id 0x%04x", EXTRACT_16BITS(&dp->icmp6_data16[0]));
+ if (ndo->ndo_vflag) {
+ ND_TCHECK(dp->icmp6_data16[0]);
+ ND_PRINT((ndo,", id 0x%04x", EXTRACT_16BITS(&dp->icmp6_data16[0])));
if (dp->icmp6_data16[1] & 0xc0)
- printf(" ");
+ ND_PRINT((ndo," "));
if (dp->icmp6_data16[1] & 0x80)
- printf("M");
+ ND_PRINT((ndo,"M"));
if (dp->icmp6_data16[1] & 0x40)
- printf("O");
+ ND_PRINT((ndo,"O"));
#define MPADVLEN 8
- icmp6_opt_print((const u_char *)dp + MPADVLEN,
+ icmp6_opt_print(ndo, (const u_char *)dp + MPADVLEN,
length - MPADVLEN);
}
break;
case ND_RPL_MESSAGE:
- rpl_print(ndo, dp, &dp->icmp6_data8[0], length);
+ /* plus 4, because struct icmp6_hdr contains 4 bytes of icmp payload */
+ rpl_print(ndo, dp, &dp->icmp6_data8[0], length-sizeof(struct icmp6_hdr)+4);
break;
default:
- printf(", length %u", length);
- if (vflag <= 1)
- print_unknown_data(bp,"\n\t", length);
+ ND_PRINT((ndo,", length %u", length));
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo, bp,"\n\t", length);
return;
}
- if (!vflag)
- printf(", length %u", length);
+ if (!ndo->ndo_vflag)
+ ND_PRINT((ndo,", length %u", length));
return;
trunc:
- fputs("[|icmp6]", stdout);
+ ND_PRINT((ndo, "[|icmp6]"));
}
-static struct udphdr *
-get_upperlayer(u_char *bp, u_int *prot)
+static const struct udphdr *
+get_upperlayer(netdissect_options *ndo, const u_char *bp, u_int *prot)
{
const u_char *ep;
- struct ip6_hdr *ip6 = (struct ip6_hdr *)bp;
- struct udphdr *uh;
- struct ip6_hbh *hbh;
- struct ip6_frag *fragh;
- struct ah *ah;
+ const struct ip6_hdr *ip6 = (struct ip6_hdr *)bp;
+ const struct udphdr *uh;
+ const struct ip6_hbh *hbh;
+ const struct ip6_frag *fragh;
+ const struct ah *ah;
u_int nh;
int hlen;
/* 'ep' points to the end of available data. */
- ep = snapend;
+ ep = ndo->ndo_snapend;
- if (!TTEST(ip6->ip6_nxt))
+ if (!ND_TTEST(ip6->ip6_nxt))
return NULL;
nh = ip6->ip6_nxt;
@@ -619,7 +1206,7 @@ get_upperlayer(u_char *bp, u_int *prot)
case IPPROTO_UDP:
case IPPROTO_TCP:
uh = (struct udphdr *)bp;
- if (TTEST(uh->uh_dport)) {
+ if (ND_TTEST(uh->uh_dport)) {
*prot = nh;
return(uh);
}
@@ -631,7 +1218,7 @@ get_upperlayer(u_char *bp, u_int *prot)
case IPPROTO_DSTOPTS:
case IPPROTO_ROUTING:
hbh = (struct ip6_hbh *)bp;
- if (!TTEST(hbh->ip6h_len))
+ if (!ND_TTEST(hbh->ip6h_len))
return(NULL);
nh = hbh->ip6h_nxt;
hlen = (hbh->ip6h_len + 1) << 3;
@@ -639,7 +1226,7 @@ get_upperlayer(u_char *bp, u_int *prot)
case IPPROTO_FRAGMENT: /* this should be odd, but try anyway */
fragh = (struct ip6_frag *)bp;
- if (!TTEST(fragh->ip6f_offlg))
+ if (!ND_TTEST(fragh->ip6f_offlg))
return(NULL);
/* fragments with non-zero offset are meaningless */
if ((EXTRACT_16BITS(&fragh->ip6f_offlg) & IP6F_OFF_MASK) != 0)
@@ -650,7 +1237,7 @@ get_upperlayer(u_char *bp, u_int *prot)
case IPPROTO_AH:
ah = (struct ah *)bp;
- if (!TTEST(ah->ah_len))
+ if (!ND_TTEST(ah->ah_len))
return(NULL);
nh = ah->ah_nxt;
hlen = (ah->ah_len + 2) << 2;
@@ -666,12 +1253,10 @@ get_upperlayer(u_char *bp, u_int *prot)
}
static void
-icmp6_opt_print(const u_char *bp, int resid)
+icmp6_opt_print(netdissect_options *ndo, const u_char *bp, int resid)
{
const struct nd_opt_hdr *op;
- const struct nd_opt_hdr *opl; /* why there's no struct? */
const struct nd_opt_prefix_info *opp;
- const struct icmp6_opts_redirect *opr;
const struct nd_opt_mtu *opm;
const struct nd_opt_rdnss *oprd;
const struct nd_opt_dnssl *opds;
@@ -687,7 +1272,7 @@ icmp6_opt_print(const u_char *bp, int resid)
cp = bp;
/* 'ep' points to the end of available data. */
- ep = snapend;
+ ep = ndo->ndo_snapend;
while (cp < ep) {
op = (struct nd_opt_hdr *)cp;
@@ -700,116 +1285,113 @@ icmp6_opt_print(const u_char *bp, int resid)
if (cp + (op->nd_opt_len << 3) > ep)
goto trunc;
- printf("\n\t %s option (%u), length %u (%u): ",
- tok2str(icmp6_opt_values, "unknown", op->nd_opt_type),
- op->nd_opt_type,
- op->nd_opt_len << 3,
- op->nd_opt_len);
+ ND_PRINT((ndo,"\n\t %s option (%u), length %u (%u): ",
+ tok2str(icmp6_opt_values, "unknown", op->nd_opt_type),
+ op->nd_opt_type,
+ op->nd_opt_len << 3,
+ op->nd_opt_len));
switch (op->nd_opt_type) {
case ND_OPT_SOURCE_LINKADDR:
- opl = (struct nd_opt_hdr *)op;
l = (op->nd_opt_len << 3) - 2;
- print_lladdr(cp + 2, l);
+ print_lladdr(ndo, cp + 2, l);
break;
case ND_OPT_TARGET_LINKADDR:
- opl = (struct nd_opt_hdr *)op;
l = (op->nd_opt_len << 3) - 2;
- print_lladdr(cp + 2, l);
+ print_lladdr(ndo, cp + 2, l);
break;
case ND_OPT_PREFIX_INFORMATION:
opp = (struct nd_opt_prefix_info *)op;
- TCHECK(opp->nd_opt_pi_prefix);
- printf("%s/%u%s, Flags [%s], valid time %s",
- ip6addr_string(&opp->nd_opt_pi_prefix),
- opp->nd_opt_pi_prefix_len,
- (op->nd_opt_len != 4) ? "badlen" : "",
- bittok2str(icmp6_opt_pi_flag_values, "none", opp->nd_opt_pi_flags_reserved),
- get_lifetime(EXTRACT_32BITS(&opp->nd_opt_pi_valid_time)));
- printf(", pref. time %s", get_lifetime(EXTRACT_32BITS(&opp->nd_opt_pi_preferred_time)));
+ ND_TCHECK(opp->nd_opt_pi_prefix);
+ ND_PRINT((ndo,"%s/%u%s, Flags [%s], valid time %s",
+ ip6addr_string(ndo, &opp->nd_opt_pi_prefix),
+ opp->nd_opt_pi_prefix_len,
+ (op->nd_opt_len != 4) ? "badlen" : "",
+ bittok2str(icmp6_opt_pi_flag_values, "none", opp->nd_opt_pi_flags_reserved),
+ get_lifetime(EXTRACT_32BITS(&opp->nd_opt_pi_valid_time))));
+ ND_PRINT((ndo,", pref. time %s", get_lifetime(EXTRACT_32BITS(&opp->nd_opt_pi_preferred_time))));
break;
case ND_OPT_REDIRECTED_HEADER:
- opr = (struct icmp6_opts_redirect *)op;
- print_unknown_data(bp,"\n\t ",op->nd_opt_len<<3);
+ print_unknown_data(ndo, bp,"\n\t ",op->nd_opt_len<<3);
/* xxx */
break;
case ND_OPT_MTU:
opm = (struct nd_opt_mtu *)op;
- TCHECK(opm->nd_opt_mtu_mtu);
- printf(" %u%s",
+ ND_TCHECK(opm->nd_opt_mtu_mtu);
+ ND_PRINT((ndo," %u%s",
EXTRACT_32BITS(&opm->nd_opt_mtu_mtu),
- (op->nd_opt_len != 1) ? "bad option length" : "" );
+ (op->nd_opt_len != 1) ? "bad option length" : "" ));
break;
case ND_OPT_RDNSS:
oprd = (struct nd_opt_rdnss *)op;
l = (op->nd_opt_len - 1) / 2;
- printf(" lifetime %us,",
- EXTRACT_32BITS(&oprd->nd_opt_rdnss_lifetime));
+ ND_PRINT((ndo," lifetime %us,",
+ EXTRACT_32BITS(&oprd->nd_opt_rdnss_lifetime)));
for (i = 0; i < l; i++) {
- TCHECK(oprd->nd_opt_rdnss_addr[i]);
- printf(" addr: %s",
- ip6addr_string(&oprd->nd_opt_rdnss_addr[i]));
+ ND_TCHECK(oprd->nd_opt_rdnss_addr[i]);
+ ND_PRINT((ndo," addr: %s",
+ ip6addr_string(ndo, &oprd->nd_opt_rdnss_addr[i])));
}
break;
case ND_OPT_DNSSL:
opds = (struct nd_opt_dnssl *)op;
- printf(" lifetime %us, domain(s):",
- EXTRACT_32BITS(&opds->nd_opt_dnssl_lifetime));
+ ND_PRINT((ndo," lifetime %us, domain(s):",
+ EXTRACT_32BITS(&opds->nd_opt_dnssl_lifetime)));
domp = cp + 8; /* domain names, variable-sized, RFC1035-encoded */
while (domp < cp + (op->nd_opt_len << 3) && *domp != '\0')
{
- printf (" ");
- if ((domp = ns_nprint (domp, bp)) == NULL)
+ ND_PRINT((ndo, " "));
+ if ((domp = ns_nprint (ndo, domp, bp)) == NULL)
goto trunc;
}
break;
case ND_OPT_ADVINTERVAL:
opa = (struct nd_opt_advinterval *)op;
- TCHECK(opa->nd_opt_adv_interval);
- printf(" %ums", EXTRACT_32BITS(&opa->nd_opt_adv_interval));
+ ND_TCHECK(opa->nd_opt_adv_interval);
+ ND_PRINT((ndo," %ums", EXTRACT_32BITS(&opa->nd_opt_adv_interval)));
break;
- case ND_OPT_HOMEAGENT_INFO:
+ case ND_OPT_HOMEAGENT_INFO:
oph = (struct nd_opt_homeagent_info *)op;
- TCHECK(oph->nd_opt_hai_lifetime);
- printf(" preference %u, lifetime %u",
- EXTRACT_16BITS(&oph->nd_opt_hai_preference),
- EXTRACT_16BITS(&oph->nd_opt_hai_lifetime));
+ ND_TCHECK(oph->nd_opt_hai_lifetime);
+ ND_PRINT((ndo," preference %u, lifetime %u",
+ EXTRACT_16BITS(&oph->nd_opt_hai_preference),
+ EXTRACT_16BITS(&oph->nd_opt_hai_lifetime)));
break;
case ND_OPT_ROUTE_INFO:
opri = (struct nd_opt_route_info *)op;
- TCHECK(opri->nd_opt_rti_lifetime);
+ ND_TCHECK(opri->nd_opt_rti_lifetime);
memset(&in6, 0, sizeof(in6));
in6p = (struct in6_addr *)(opri + 1);
switch (op->nd_opt_len) {
case 1:
break;
case 2:
- TCHECK2(*in6p, 8);
+ ND_TCHECK2(*in6p, 8);
memcpy(&in6, opri + 1, 8);
break;
case 3:
- TCHECK(*in6p);
+ ND_TCHECK(*in6p);
memcpy(&in6, opri + 1, sizeof(in6));
break;
default:
goto trunc;
}
- printf(" %s/%u", ip6addr_string(&in6),
- opri->nd_opt_rti_prefixlen);
- printf(", pref=%s", get_rtpref(opri->nd_opt_rti_flags));
- printf(", lifetime=%s",
- get_lifetime(EXTRACT_32BITS(&opri->nd_opt_rti_lifetime)));
+ ND_PRINT((ndo," %s/%u", ip6addr_string(ndo, &in6),
+ opri->nd_opt_rti_prefixlen));
+ ND_PRINT((ndo,", pref=%s", get_rtpref(opri->nd_opt_rti_flags)));
+ ND_PRINT((ndo,", lifetime=%s",
+ get_lifetime(EXTRACT_32BITS(&opri->nd_opt_rti_lifetime))));
break;
default:
- if (vflag <= 1) {
- print_unknown_data(cp+2,"\n\t ", (op->nd_opt_len << 3) - 2); /* skip option header */
+ if (ndo->ndo_vflag <= 1) {
+ print_unknown_data(ndo,cp+2,"\n\t ", (op->nd_opt_len << 3) - 2); /* skip option header */
return;
}
break;
}
/* do we want to see an additional hexdump ? */
- if (vflag> 1)
- print_unknown_data(cp+2,"\n\t ", (op->nd_opt_len << 3) - 2); /* skip option header */
+ if (ndo->ndo_vflag> 1)
+ print_unknown_data(ndo, cp+2,"\n\t ", (op->nd_opt_len << 3) - 2); /* skip option header */
cp += op->nd_opt_len << 3;
resid -= op->nd_opt_len << 3;
@@ -817,29 +1399,29 @@ icmp6_opt_print(const u_char *bp, int resid)
return;
trunc:
- fputs("[ndp opt]", stdout);
+ ND_PRINT((ndo, "[ndp opt]"));
return;
#undef ECHECK
}
static void
-mld6_print(const u_char *bp)
+mld6_print(netdissect_options *ndo, const u_char *bp)
{
- struct mld6_hdr *mp = (struct mld6_hdr *)bp;
+ const struct mld6_hdr *mp = (struct mld6_hdr *)bp;
const u_char *ep;
/* 'ep' points to the end of available data. */
- ep = snapend;
+ ep = ndo->ndo_snapend;
if ((u_char *)mp + sizeof(*mp) > ep)
return;
- printf("max resp delay: %d ", EXTRACT_16BITS(&mp->mld6_maxdelay));
- printf("addr: %s", ip6addr_string(&mp->mld6_addr));
+ ND_PRINT((ndo,"max resp delay: %d ", EXTRACT_16BITS(&mp->mld6_maxdelay)));
+ ND_PRINT((ndo,"addr: %s", ip6addr_string(ndo, &mp->mld6_addr)));
}
static void
-mldv2_report_print(const u_char *bp, u_int len)
+mldv2_report_print(netdissect_options *ndo, const u_char *bp, u_int len)
{
struct icmp6_hdr *icp = (struct icmp6_hdr *) bp;
u_int group, nsrcs, ngroups;
@@ -847,57 +1429,57 @@ mldv2_report_print(const u_char *bp, u_int len)
/* Minimum len is 8 */
if (len < 8) {
- printf(" [invalid len %d]", len);
- return;
+ ND_PRINT((ndo," [invalid len %d]", len));
+ return;
}
- TCHECK(icp->icmp6_data16[1]);
+ ND_TCHECK(icp->icmp6_data16[1]);
ngroups = EXTRACT_16BITS(&icp->icmp6_data16[1]);
- printf(", %d group record(s)", ngroups);
- if (vflag > 0) {
+ ND_PRINT((ndo,", %d group record(s)", ngroups));
+ if (ndo->ndo_vflag > 0) {
/* Print the group records */
group = 8;
for (i = 0; i < ngroups; i++) {
/* type(1) + auxlen(1) + numsrc(2) + grp(16) */
if (len < group + 20) {
- printf(" [invalid number of groups]");
- return;
+ ND_PRINT((ndo," [invalid number of groups]"));
+ return;
}
- TCHECK2(bp[group + 4], sizeof(struct in6_addr));
- printf(" [gaddr %s", ip6addr_string(&bp[group + 4]));
- printf(" %s", tok2str(mldv2report2str, " [v2-report-#%d]",
- bp[group]));
+ ND_TCHECK2(bp[group + 4], sizeof(struct in6_addr));
+ ND_PRINT((ndo," [gaddr %s", ip6addr_string(ndo, &bp[group + 4])));
+ ND_PRINT((ndo," %s", tok2str(mldv2report2str, " [v2-report-#%d]",
+ bp[group])));
nsrcs = (bp[group + 2] << 8) + bp[group + 3];
/* Check the number of sources and print them */
if (len < group + 20 + (nsrcs * sizeof(struct in6_addr))) {
- printf(" [invalid number of sources %d]", nsrcs);
- return;
+ ND_PRINT((ndo," [invalid number of sources %d]", nsrcs));
+ return;
}
- if (vflag == 1)
- printf(", %d source(s)", nsrcs);
+ if (ndo->ndo_vflag == 1)
+ ND_PRINT((ndo,", %d source(s)", nsrcs));
else {
/* Print the sources */
- (void)printf(" {");
+ ND_PRINT((ndo," {"));
for (j = 0; j < nsrcs; j++) {
- TCHECK2(bp[group + 20 + j * sizeof(struct in6_addr)],
+ ND_TCHECK2(bp[group + 20 + j * sizeof(struct in6_addr)],
sizeof(struct in6_addr));
- printf(" %s", ip6addr_string(&bp[group + 20 + j * sizeof(struct in6_addr)]));
+ ND_PRINT((ndo," %s", ip6addr_string(ndo, &bp[group + 20 + j * sizeof(struct in6_addr)])));
}
- (void)printf(" }");
+ ND_PRINT((ndo," }"));
}
/* Next group record */
group += 20 + nsrcs * sizeof(struct in6_addr);
- printf("]");
+ ND_PRINT((ndo,"]"));
}
}
return;
trunc:
- (void)printf("[|icmp6]");
+ ND_PRINT((ndo,"[|icmp6]"));
return;
}
static void
-mldv2_query_print(const u_char *bp, u_int len)
+mldv2_query_print(netdissect_options *ndo, const u_char *bp, u_int len)
{
struct icmp6_hdr *icp = (struct icmp6_hdr *) bp;
u_int mrc;
@@ -907,102 +1489,102 @@ mldv2_query_print(const u_char *bp, u_int len)
/* Minimum len is 28 */
if (len < 28) {
- printf(" [invalid len %d]", len);
+ ND_PRINT((ndo," [invalid len %d]", len));
return;
}
- TCHECK(icp->icmp6_data16[0]);
+ ND_TCHECK(icp->icmp6_data16[0]);
mrc = EXTRACT_16BITS(&icp->icmp6_data16[0]);
if (mrc < 32768) {
mrt = mrc;
} else {
mrt = ((mrc & 0x0fff) | 0x1000) << (((mrc & 0x7000) >> 12) + 3);
}
- if (vflag) {
- (void)printf(" [max resp delay=%d]", mrt);
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo," [max resp delay=%d]", mrt));
}
- TCHECK2(bp[8], sizeof(struct in6_addr));
- printf(" [gaddr %s", ip6addr_string(&bp[8]));
+ ND_TCHECK2(bp[8], sizeof(struct in6_addr));
+ ND_PRINT((ndo," [gaddr %s", ip6addr_string(ndo, &bp[8])));
- if (vflag) {
- TCHECK(bp[25]);
+ if (ndo->ndo_vflag) {
+ ND_TCHECK(bp[25]);
if (bp[24] & 0x08) {
- printf(" sflag");
+ ND_PRINT((ndo," sflag"));
}
if (bp[24] & 0x07) {
- printf(" robustness=%d", bp[24] & 0x07);
+ ND_PRINT((ndo," robustness=%d", bp[24] & 0x07));
}
if (bp[25] < 128) {
qqi = bp[25];
} else {
qqi = ((bp[25] & 0x0f) | 0x10) << (((bp[25] & 0x70) >> 4) + 3);
}
- printf(" qqi=%d", qqi);
+ ND_PRINT((ndo," qqi=%d", qqi));
}
- TCHECK2(bp[26], 2);
+ ND_TCHECK2(bp[26], 2);
nsrcs = EXTRACT_16BITS(&bp[26]);
if (nsrcs > 0) {
if (len < 28 + nsrcs * sizeof(struct in6_addr))
- printf(" [invalid number of sources]");
- else if (vflag > 1) {
- printf(" {");
+ ND_PRINT((ndo," [invalid number of sources]"));
+ else if (ndo->ndo_vflag > 1) {
+ ND_PRINT((ndo," {"));
for (i = 0; i < nsrcs; i++) {
- TCHECK2(bp[28 + i * sizeof(struct in6_addr)],
+ ND_TCHECK2(bp[28 + i * sizeof(struct in6_addr)],
sizeof(struct in6_addr));
- printf(" %s", ip6addr_string(&bp[28 + i * sizeof(struct in6_addr)]));
+ ND_PRINT((ndo," %s", ip6addr_string(ndo, &bp[28 + i * sizeof(struct in6_addr)])));
}
- printf(" }");
+ ND_PRINT((ndo," }"));
} else
- printf(", %d source(s)", nsrcs);
+ ND_PRINT((ndo,", %d source(s)", nsrcs));
}
- printf("]");
+ ND_PRINT((ndo,"]"));
return;
trunc:
- (void)printf("[|icmp6]");
+ ND_PRINT((ndo,"[|icmp6]"));
return;
}
static void
-dnsname_print(const u_char *cp, const u_char *ep)
+dnsname_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
{
int i;
/* DNS name decoding - no decompression */
- printf(", \"");
+ ND_PRINT((ndo,", \""));
while (cp < ep) {
i = *cp++;
if (i) {
if (i > ep - cp) {
- printf("???");
+ ND_PRINT((ndo,"???"));
break;
}
while (i-- && cp < ep) {
- safeputchar(*cp);
+ safeputchar(ndo, *cp);
cp++;
}
if (cp + 1 < ep && *cp)
- printf(".");
+ ND_PRINT((ndo,"."));
} else {
if (cp == ep) {
/* FQDN */
- printf(".");
+ ND_PRINT((ndo,"."));
} else if (cp + 1 == ep && *cp == '\0') {
/* truncated */
} else {
/* invalid */
- printf("???");
+ ND_PRINT((ndo,"???"));
}
break;
}
}
- printf("\"");
+ ND_PRINT((ndo,"\""));
}
static void
-icmp6_nodeinfo_print(u_int icmp6len, const u_char *bp, const u_char *ep)
+icmp6_nodeinfo_print(netdissect_options *ndo, u_int icmp6len, const u_char *bp, const u_char *ep)
{
- struct icmp6_nodeinfo *ni6;
- struct icmp6_hdr *dp;
+ const struct icmp6_nodeinfo *ni6;
+ const struct icmp6_hdr *dp;
const u_char *cp;
size_t siz, i;
int needcomma;
@@ -1017,240 +1599,239 @@ icmp6_nodeinfo_print(u_int icmp6len, const u_char *bp, const u_char *ep)
case ICMP6_NI_QUERY:
if (siz == sizeof(*dp) + 4) {
/* KAME who-are-you */
- printf(" who-are-you request");
+ ND_PRINT((ndo," who-are-you request"));
break;
}
- printf(" node information query");
+ ND_PRINT((ndo," node information query"));
- TCHECK2(*dp, sizeof(*ni6));
+ ND_TCHECK2(*dp, sizeof(*ni6));
ni6 = (struct icmp6_nodeinfo *)dp;
- printf(" ("); /*)*/
+ ND_PRINT((ndo," (")); /*)*/
switch (EXTRACT_16BITS(&ni6->ni_qtype)) {
case NI_QTYPE_NOOP:
- printf("noop");
+ ND_PRINT((ndo,"noop"));
break;
case NI_QTYPE_SUPTYPES:
- printf("supported qtypes");
+ ND_PRINT((ndo,"supported qtypes"));
i = EXTRACT_16BITS(&ni6->ni_flags);
if (i)
- printf(" [%s]", (i & 0x01) ? "C" : "");
- break;
+ ND_PRINT((ndo," [%s]", (i & 0x01) ? "C" : ""));
break;
case NI_QTYPE_FQDN:
- printf("DNS name");
+ ND_PRINT((ndo,"DNS name"));
break;
case NI_QTYPE_NODEADDR:
- printf("node addresses");
+ ND_PRINT((ndo,"node addresses"));
i = ni6->ni_flags;
if (!i)
break;
/* NI_NODEADDR_FLAG_TRUNCATE undefined for query */
- printf(" [%s%s%s%s%s%s]",
+ ND_PRINT((ndo," [%s%s%s%s%s%s]",
(i & NI_NODEADDR_FLAG_ANYCAST) ? "a" : "",
(i & NI_NODEADDR_FLAG_GLOBAL) ? "G" : "",
(i & NI_NODEADDR_FLAG_SITELOCAL) ? "S" : "",
(i & NI_NODEADDR_FLAG_LINKLOCAL) ? "L" : "",
(i & NI_NODEADDR_FLAG_COMPAT) ? "C" : "",
- (i & NI_NODEADDR_FLAG_ALL) ? "A" : "");
+ (i & NI_NODEADDR_FLAG_ALL) ? "A" : ""));
break;
default:
- printf("unknown");
+ ND_PRINT((ndo,"unknown"));
break;
}
if (ni6->ni_qtype == NI_QTYPE_NOOP ||
ni6->ni_qtype == NI_QTYPE_SUPTYPES) {
if (siz != sizeof(*ni6))
- if (vflag)
- printf(", invalid len");
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo,", invalid len"));
/*(*/
- printf(")");
+ ND_PRINT((ndo,")"));
break;
}
/* XXX backward compat, icmp-name-lookup-03 */
if (siz == sizeof(*ni6)) {
- printf(", 03 draft");
+ ND_PRINT((ndo,", 03 draft"));
/*(*/
- printf(")");
+ ND_PRINT((ndo,")"));
break;
}
switch (ni6->ni_code) {
case ICMP6_NI_SUBJ_IPV6:
- if (!TTEST2(*dp,
+ if (!ND_TTEST2(*dp,
sizeof(*ni6) + sizeof(struct in6_addr)))
break;
if (siz != sizeof(*ni6) + sizeof(struct in6_addr)) {
- if (vflag)
- printf(", invalid subject len");
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo,", invalid subject len"));
break;
}
- printf(", subject=%s",
- getname6((const u_char *)(ni6 + 1)));
+ ND_PRINT((ndo,", subject=%s",
+ getname6(ndo, (const u_char *)(ni6 + 1))));
break;
case ICMP6_NI_SUBJ_FQDN:
- printf(", subject=DNS name");
+ ND_PRINT((ndo,", subject=DNS name"));
cp = (const u_char *)(ni6 + 1);
if (cp[0] == ep - cp - 1) {
/* icmp-name-lookup-03, pascal string */
- if (vflag)
- printf(", 03 draft");
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo,", 03 draft"));
cp++;
- printf(", \"");
+ ND_PRINT((ndo,", \""));
while (cp < ep) {
- safeputchar(*cp);
+ safeputchar(ndo, *cp);
cp++;
}
- printf("\"");
+ ND_PRINT((ndo,"\""));
} else
- dnsname_print(cp, ep);
+ dnsname_print(ndo, cp, ep);
break;
case ICMP6_NI_SUBJ_IPV4:
- if (!TTEST2(*dp, sizeof(*ni6) + sizeof(struct in_addr)))
+ if (!ND_TTEST2(*dp, sizeof(*ni6) + sizeof(struct in_addr)))
break;
if (siz != sizeof(*ni6) + sizeof(struct in_addr)) {
- if (vflag)
- printf(", invalid subject len");
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo,", invalid subject len"));
break;
}
- printf(", subject=%s",
- getname((const u_char *)(ni6 + 1)));
+ ND_PRINT((ndo,", subject=%s",
+ getname(ndo, (const u_char *)(ni6 + 1))));
break;
default:
- printf(", unknown subject");
+ ND_PRINT((ndo,", unknown subject"));
break;
}
/*(*/
- printf(")");
+ ND_PRINT((ndo,")"));
break;
case ICMP6_NI_REPLY:
if (icmp6len > siz) {
- printf("[|icmp6: node information reply]");
+ ND_PRINT((ndo,"[|icmp6: node information reply]"));
break;
}
needcomma = 0;
ni6 = (struct icmp6_nodeinfo *)dp;
- printf(" node information reply");
- printf(" ("); /*)*/
+ ND_PRINT((ndo," node information reply"));
+ ND_PRINT((ndo," (")); /*)*/
switch (ni6->ni_code) {
case ICMP6_NI_SUCCESS:
- if (vflag) {
- printf("success");
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo,"success"));
needcomma++;
}
break;
case ICMP6_NI_REFUSED:
- printf("refused");
+ ND_PRINT((ndo,"refused"));
needcomma++;
if (siz != sizeof(*ni6))
- if (vflag)
- printf(", invalid length");
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo,", invalid length"));
break;
case ICMP6_NI_UNKNOWN:
- printf("unknown");
+ ND_PRINT((ndo,"unknown"));
needcomma++;
if (siz != sizeof(*ni6))
- if (vflag)
- printf(", invalid length");
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo,", invalid length"));
break;
}
if (ni6->ni_code != ICMP6_NI_SUCCESS) {
/*(*/
- printf(")");
+ ND_PRINT((ndo,")"));
break;
}
switch (EXTRACT_16BITS(&ni6->ni_qtype)) {
case NI_QTYPE_NOOP:
if (needcomma)
- printf(", ");
- printf("noop");
+ ND_PRINT((ndo,", "));
+ ND_PRINT((ndo,"noop"));
if (siz != sizeof(*ni6))
- if (vflag)
- printf(", invalid length");
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo,", invalid length"));
break;
case NI_QTYPE_SUPTYPES:
if (needcomma)
- printf(", ");
- printf("supported qtypes");
+ ND_PRINT((ndo,", "));
+ ND_PRINT((ndo,"supported qtypes"));
i = EXTRACT_16BITS(&ni6->ni_flags);
if (i)
- printf(" [%s]", (i & 0x01) ? "C" : "");
+ ND_PRINT((ndo," [%s]", (i & 0x01) ? "C" : ""));
break;
case NI_QTYPE_FQDN:
if (needcomma)
- printf(", ");
- printf("DNS name");
+ ND_PRINT((ndo,", "));
+ ND_PRINT((ndo,"DNS name"));
cp = (const u_char *)(ni6 + 1) + 4;
if (cp[0] == ep - cp - 1) {
/* icmp-name-lookup-03, pascal string */
- if (vflag)
- printf(", 03 draft");
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo,", 03 draft"));
cp++;
- printf(", \"");
+ ND_PRINT((ndo,", \""));
while (cp < ep) {
- safeputchar(*cp);
+ safeputchar(ndo, *cp);
cp++;
}
- printf("\"");
+ ND_PRINT((ndo,"\""));
} else
- dnsname_print(cp, ep);
+ dnsname_print(ndo, cp, ep);
if ((EXTRACT_16BITS(&ni6->ni_flags) & 0x01) != 0)
- printf(" [TTL=%u]", *(u_int32_t *)(ni6 + 1));
+ ND_PRINT((ndo," [TTL=%u]", *(uint32_t *)(ni6 + 1)));
break;
case NI_QTYPE_NODEADDR:
if (needcomma)
- printf(", ");
- printf("node addresses");
+ ND_PRINT((ndo,", "));
+ ND_PRINT((ndo,"node addresses"));
i = sizeof(*ni6);
while (i < siz) {
if (i + sizeof(struct in6_addr) + sizeof(int32_t) > siz)
break;
- printf(" %s", getname6(bp + i));
+ ND_PRINT((ndo," %s", getname6(ndo, bp + i)));
i += sizeof(struct in6_addr);
- printf("(%d)", (int32_t)EXTRACT_32BITS(bp + i));
+ ND_PRINT((ndo,"(%d)", (int32_t)EXTRACT_32BITS(bp + i)));
i += sizeof(int32_t);
}
i = ni6->ni_flags;
if (!i)
break;
- printf(" [%s%s%s%s%s%s%s]",
- (i & NI_NODEADDR_FLAG_ANYCAST) ? "a" : "",
- (i & NI_NODEADDR_FLAG_GLOBAL) ? "G" : "",
- (i & NI_NODEADDR_FLAG_SITELOCAL) ? "S" : "",
- (i & NI_NODEADDR_FLAG_LINKLOCAL) ? "L" : "",
- (i & NI_NODEADDR_FLAG_COMPAT) ? "C" : "",
- (i & NI_NODEADDR_FLAG_ALL) ? "A" : "",
- (i & NI_NODEADDR_FLAG_TRUNCATE) ? "T" : "");
+ ND_PRINT((ndo," [%s%s%s%s%s%s%s]",
+ (i & NI_NODEADDR_FLAG_ANYCAST) ? "a" : "",
+ (i & NI_NODEADDR_FLAG_GLOBAL) ? "G" : "",
+ (i & NI_NODEADDR_FLAG_SITELOCAL) ? "S" : "",
+ (i & NI_NODEADDR_FLAG_LINKLOCAL) ? "L" : "",
+ (i & NI_NODEADDR_FLAG_COMPAT) ? "C" : "",
+ (i & NI_NODEADDR_FLAG_ALL) ? "A" : "",
+ (i & NI_NODEADDR_FLAG_TRUNCATE) ? "T" : ""));
break;
default:
if (needcomma)
- printf(", ");
- printf("unknown");
+ ND_PRINT((ndo,", "));
+ ND_PRINT((ndo,"unknown"));
break;
}
/*(*/
- printf(")");
+ ND_PRINT((ndo,")"));
break;
}
return;
trunc:
- fputs("[|icmp6]", stdout);
+ ND_PRINT((ndo, "[|icmp6]"));
}
static void
-icmp6_rrenum_print(const u_char *bp, const u_char *ep)
+icmp6_rrenum_print(netdissect_options *ndo, const u_char *bp, const u_char *ep)
{
- struct icmp6_router_renum *rr6;
+ const struct icmp6_router_renum *rr6;
const char *cp;
struct rr_pco_match *match;
struct rr_pco_use *use;
@@ -1262,40 +1843,40 @@ icmp6_rrenum_print(const u_char *bp, const u_char *ep)
rr6 = (struct icmp6_router_renum *)bp;
cp = (const char *)(rr6 + 1);
- TCHECK(rr6->rr_reserved);
+ ND_TCHECK(rr6->rr_reserved);
switch (rr6->rr_code) {
case ICMP6_ROUTER_RENUMBERING_COMMAND:
- printf("router renum: command");
+ ND_PRINT((ndo,"router renum: command"));
break;
case ICMP6_ROUTER_RENUMBERING_RESULT:
- printf("router renum: result");
+ ND_PRINT((ndo,"router renum: result"));
break;
case ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET:
- printf("router renum: sequence number reset");
+ ND_PRINT((ndo,"router renum: sequence number reset"));
break;
default:
- printf("router renum: code-#%d", rr6->rr_code);
+ ND_PRINT((ndo,"router renum: code-#%d", rr6->rr_code));
break;
}
- printf(", seq=%u", EXTRACT_32BITS(&rr6->rr_seqnum));
+ ND_PRINT((ndo,", seq=%u", EXTRACT_32BITS(&rr6->rr_seqnum)));
- if (vflag) {
+ if (ndo->ndo_vflag) {
#define F(x, y) ((rr6->rr_flags) & (x) ? (y) : "")
- printf("["); /*]*/
+ ND_PRINT((ndo,"[")); /*]*/
if (rr6->rr_flags) {
- printf("%s%s%s%s%s,", F(ICMP6_RR_FLAGS_TEST, "T"),
- F(ICMP6_RR_FLAGS_REQRESULT, "R"),
- F(ICMP6_RR_FLAGS_FORCEAPPLY, "A"),
- F(ICMP6_RR_FLAGS_SPECSITE, "S"),
- F(ICMP6_RR_FLAGS_PREVDONE, "P"));
+ ND_PRINT((ndo,"%s%s%s%s%s,", F(ICMP6_RR_FLAGS_TEST, "T"),
+ F(ICMP6_RR_FLAGS_REQRESULT, "R"),
+ F(ICMP6_RR_FLAGS_FORCEAPPLY, "A"),
+ F(ICMP6_RR_FLAGS_SPECSITE, "S"),
+ F(ICMP6_RR_FLAGS_PREVDONE, "P")));
}
- printf("seg=%u,", rr6->rr_segnum);
- printf("maxdelay=%u", EXTRACT_16BITS(&rr6->rr_maxdelay));
+ ND_PRINT((ndo,"seg=%u,", rr6->rr_segnum));
+ ND_PRINT((ndo,"maxdelay=%u", EXTRACT_16BITS(&rr6->rr_maxdelay)));
if (rr6->rr_reserved)
- printf("rsvd=0x%x", EXTRACT_32BITS(&rr6->rr_reserved));
+ ND_PRINT((ndo,"rsvd=0x%x", EXTRACT_32BITS(&rr6->rr_reserved)));
/*[*/
- printf("]");
+ ND_PRINT((ndo,"]"));
#undef F
}
@@ -1303,31 +1884,31 @@ icmp6_rrenum_print(const u_char *bp, const u_char *ep)
match = (struct rr_pco_match *)cp;
cp = (const char *)(match + 1);
- TCHECK(match->rpm_prefix);
+ ND_TCHECK(match->rpm_prefix);
- if (vflag > 1)
- printf("\n\t");
+ if (ndo->ndo_vflag > 1)
+ ND_PRINT((ndo,"\n\t"));
else
- printf(" ");
- printf("match("); /*)*/
+ ND_PRINT((ndo," "));
+ ND_PRINT((ndo,"match(")); /*)*/
switch (match->rpm_code) {
- case RPM_PCO_ADD: printf("add"); break;
- case RPM_PCO_CHANGE: printf("change"); break;
- case RPM_PCO_SETGLOBAL: printf("setglobal"); break;
- default: printf("#%u", match->rpm_code); break;
+ case RPM_PCO_ADD: ND_PRINT((ndo,"add")); break;
+ case RPM_PCO_CHANGE: ND_PRINT((ndo,"change")); break;
+ case RPM_PCO_SETGLOBAL: ND_PRINT((ndo,"setglobal")); break;
+ default: ND_PRINT((ndo,"#%u", match->rpm_code)); break;
}
- if (vflag) {
- printf(",ord=%u", match->rpm_ordinal);
- printf(",min=%u", match->rpm_minlen);
- printf(",max=%u", match->rpm_maxlen);
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo,",ord=%u", match->rpm_ordinal));
+ ND_PRINT((ndo,",min=%u", match->rpm_minlen));
+ ND_PRINT((ndo,",max=%u", match->rpm_maxlen));
}
if (inet_ntop(AF_INET6, &match->rpm_prefix, hbuf, sizeof(hbuf)))
- printf(",%s/%u", hbuf, match->rpm_matchlen);
+ ND_PRINT((ndo,",%s/%u", hbuf, match->rpm_matchlen));
else
- printf(",?/%u", match->rpm_matchlen);
+ ND_PRINT((ndo,",?/%u", match->rpm_matchlen));
/*(*/
- printf(")");
+ ND_PRINT((ndo,")"));
n = match->rpm_len - 3;
if (n % 4)
@@ -1337,50 +1918,57 @@ icmp6_rrenum_print(const u_char *bp, const u_char *ep)
use = (struct rr_pco_use *)cp;
cp = (const char *)(use + 1);
- TCHECK(use->rpu_prefix);
+ ND_TCHECK(use->rpu_prefix);
- if (vflag > 1)
- printf("\n\t");
+ if (ndo->ndo_vflag > 1)
+ ND_PRINT((ndo,"\n\t"));
else
- printf(" ");
- printf("use("); /*)*/
+ ND_PRINT((ndo," "));
+ ND_PRINT((ndo,"use(")); /*)*/
if (use->rpu_flags) {
#define F(x, y) ((use->rpu_flags) & (x) ? (y) : "")
- printf("%s%s,",
- F(ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME, "V"),
- F(ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME, "P"));
+ ND_PRINT((ndo,"%s%s,",
+ F(ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME, "V"),
+ F(ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME, "P")));
#undef F
}
- if (vflag) {
- printf("mask=0x%x,", use->rpu_ramask);
- printf("raflags=0x%x,", use->rpu_raflags);
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo,"mask=0x%x,", use->rpu_ramask));
+ ND_PRINT((ndo,"raflags=0x%x,", use->rpu_raflags));
if (~use->rpu_vltime == 0)
- printf("vltime=infty,");
+ ND_PRINT((ndo,"vltime=infty,"));
else
- printf("vltime=%u,",
- EXTRACT_32BITS(&use->rpu_vltime));
+ ND_PRINT((ndo,"vltime=%u,",
+ EXTRACT_32BITS(&use->rpu_vltime)));
if (~use->rpu_pltime == 0)
- printf("pltime=infty,");
+ ND_PRINT((ndo,"pltime=infty,"));
else
- printf("pltime=%u,",
- EXTRACT_32BITS(&use->rpu_pltime));
+ ND_PRINT((ndo,"pltime=%u,",
+ EXTRACT_32BITS(&use->rpu_pltime)));
}
if (inet_ntop(AF_INET6, &use->rpu_prefix, hbuf,
sizeof(hbuf)))
- printf("%s/%u/%u", hbuf, use->rpu_uselen,
- use->rpu_keeplen);
+ ND_PRINT((ndo,"%s/%u/%u", hbuf, use->rpu_uselen,
+ use->rpu_keeplen));
else
- printf("?/%u/%u", use->rpu_uselen,
- use->rpu_keeplen);
+ ND_PRINT((ndo,"?/%u/%u", use->rpu_uselen,
+ use->rpu_keeplen));
/*(*/
- printf(")");
+ ND_PRINT((ndo,")"));
}
}
return;
trunc:
- fputs("[|icmp6]", stdout);
+ ND_PRINT((ndo,"[|icmp6]"));
}
#endif /* INET6 */
+
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
diff --git a/contrib/tcpdump/print-igmp.c b/contrib/tcpdump/print-igmp.c
index 4087ee098020..e4808a77861a 100644
--- a/contrib/tcpdump/print-igmp.c
+++ b/contrib/tcpdump/print-igmp.c
@@ -19,20 +19,13 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-igmp.c,v 1.15 2004-03-24 00:59:16 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <string.h>
-
#include "interface.h"
#include "addrtoname.h"
#include "extract.h" /* must come after interface.h */
@@ -41,16 +34,18 @@ static const char rcsid[] _U_ =
#define IN_CLASSD(i) (((int32_t)(i) & 0xf0000000) == 0xe0000000)
#endif
+static const char tstr[] = "[|igmp]";
+
/* (following from ipmulti/mrouted/prune.h) */
/*
* The packet format for a traceroute request.
*/
struct tr_query {
- u_int32_t tr_src; /* traceroute source */
- u_int32_t tr_dst; /* traceroute destination */
- u_int32_t tr_raddr; /* traceroute response address */
- u_int32_t tr_rttlqid; /* response ttl and qid */
+ uint32_t tr_src; /* traceroute source */
+ uint32_t tr_dst; /* traceroute destination */
+ uint32_t tr_raddr; /* traceroute response address */
+ uint32_t tr_rttlqid; /* response ttl and qid */
};
#define TR_GETTTL(x) (int)(((x) >> 24) & 0xff)
@@ -61,17 +56,17 @@ struct tr_query {
* beginning, followed by one tr_resp for each hop taken.
*/
struct tr_resp {
- u_int32_t tr_qarr; /* query arrival time */
- u_int32_t tr_inaddr; /* incoming interface address */
- u_int32_t tr_outaddr; /* outgoing interface address */
- u_int32_t tr_rmtaddr; /* parent address in source tree */
- u_int32_t tr_vifin; /* input packet count on interface */
- u_int32_t tr_vifout; /* output packet count on interface */
- u_int32_t tr_pktcnt; /* total incoming packets for src-grp */
- u_int8_t tr_rproto; /* routing proto deployed on router */
- u_int8_t tr_fttl; /* ttl required to forward on outvif */
- u_int8_t tr_smask; /* subnet mask for src addr */
- u_int8_t tr_rflags; /* forwarding error codes */
+ uint32_t tr_qarr; /* query arrival time */
+ uint32_t tr_inaddr; /* incoming interface address */
+ uint32_t tr_outaddr; /* outgoing interface address */
+ uint32_t tr_rmtaddr; /* parent address in source tree */
+ uint32_t tr_vifin; /* input packet count on interface */
+ uint32_t tr_vifout; /* output packet count on interface */
+ uint32_t tr_pktcnt; /* total incoming packets for src-grp */
+ uint8_t tr_rproto; /* routing proto deployed on router */
+ uint8_t tr_fttl; /* ttl required to forward on outvif */
+ uint8_t tr_smask; /* subnet mask for src addr */
+ uint8_t tr_rflags; /* forwarding error codes */
};
/* defs within mtrace */
@@ -96,7 +91,7 @@ struct tr_resp {
#define TR_PROTO_CBT 4
/* igmpv3 report types */
-static struct tok igmpv3report2str[] = {
+static const struct tok igmpv3report2str[] = {
{ 1, "is_in" },
{ 2, "is_ex" },
{ 3, "to_in" },
@@ -107,118 +102,119 @@ static struct tok igmpv3report2str[] = {
};
static void
-print_mtrace(register const u_char *bp, register u_int len)
+print_mtrace(netdissect_options *ndo,
+ register const u_char *bp, register u_int len)
{
register const struct tr_query *tr = (const struct tr_query *)(bp + 8);
- TCHECK(*tr);
+ ND_TCHECK(*tr);
if (len < 8 + sizeof (struct tr_query)) {
- (void)printf(" [invalid len %d]", len);
+ ND_PRINT((ndo, " [invalid len %d]", len));
return;
}
- printf("mtrace %u: %s to %s reply-to %s",
+ ND_PRINT((ndo, "mtrace %u: %s to %s reply-to %s",
TR_GETQID(EXTRACT_32BITS(&tr->tr_rttlqid)),
- ipaddr_string(&tr->tr_src), ipaddr_string(&tr->tr_dst),
- ipaddr_string(&tr->tr_raddr));
+ ipaddr_string(ndo, &tr->tr_src), ipaddr_string(ndo, &tr->tr_dst),
+ ipaddr_string(ndo, &tr->tr_raddr)));
if (IN_CLASSD(EXTRACT_32BITS(&tr->tr_raddr)))
- printf(" with-ttl %d", TR_GETTTL(EXTRACT_32BITS(&tr->tr_rttlqid)));
+ ND_PRINT((ndo, " with-ttl %d", TR_GETTTL(EXTRACT_32BITS(&tr->tr_rttlqid))));
return;
trunc:
- (void)printf("[|igmp]");
- return;
+ ND_PRINT((ndo, "%s", tstr));
}
static void
-print_mresp(register const u_char *bp, register u_int len)
+print_mresp(netdissect_options *ndo,
+ register const u_char *bp, register u_int len)
{
register const struct tr_query *tr = (const struct tr_query *)(bp + 8);
- TCHECK(*tr);
+ ND_TCHECK(*tr);
if (len < 8 + sizeof (struct tr_query)) {
- (void)printf(" [invalid len %d]", len);
+ ND_PRINT((ndo, " [invalid len %d]", len));
return;
}
- printf("mresp %lu: %s to %s reply-to %s",
+ ND_PRINT((ndo, "mresp %lu: %s to %s reply-to %s",
(u_long)TR_GETQID(EXTRACT_32BITS(&tr->tr_rttlqid)),
- ipaddr_string(&tr->tr_src), ipaddr_string(&tr->tr_dst),
- ipaddr_string(&tr->tr_raddr));
+ ipaddr_string(ndo, &tr->tr_src), ipaddr_string(ndo, &tr->tr_dst),
+ ipaddr_string(ndo, &tr->tr_raddr)));
if (IN_CLASSD(EXTRACT_32BITS(&tr->tr_raddr)))
- printf(" with-ttl %d", TR_GETTTL(EXTRACT_32BITS(&tr->tr_rttlqid)));
+ ND_PRINT((ndo, " with-ttl %d", TR_GETTTL(EXTRACT_32BITS(&tr->tr_rttlqid))));
return;
trunc:
- (void)printf("[|igmp]");
- return;
+ ND_PRINT((ndo, "%s", tstr));
}
static void
-print_igmpv3_report(register const u_char *bp, register u_int len)
+print_igmpv3_report(netdissect_options *ndo,
+ register const u_char *bp, register u_int len)
{
u_int group, nsrcs, ngroups;
register u_int i, j;
/* Minimum len is 16, and should be a multiple of 4 */
if (len < 16 || len & 0x03) {
- (void)printf(" [invalid len %d]", len);
+ ND_PRINT((ndo, " [invalid len %d]", len));
return;
}
- TCHECK2(bp[6], 2);
+ ND_TCHECK2(bp[6], 2);
ngroups = EXTRACT_16BITS(&bp[6]);
- (void)printf(", %d group record(s)", ngroups);
- if (vflag > 0) {
+ ND_PRINT((ndo, ", %d group record(s)", ngroups));
+ if (ndo->ndo_vflag > 0) {
/* Print the group records */
group = 8;
for (i=0; i<ngroups; i++) {
if (len < group+8) {
- (void)printf(" [invalid number of groups]");
+ ND_PRINT((ndo, " [invalid number of groups]"));
return;
}
- TCHECK2(bp[group+4], 4);
- (void)printf(" [gaddr %s", ipaddr_string(&bp[group+4]));
- (void)printf(" %s", tok2str(igmpv3report2str, " [v3-report-#%d]",
- bp[group]));
+ ND_TCHECK2(bp[group+4], 4);
+ ND_PRINT((ndo, " [gaddr %s", ipaddr_string(ndo, &bp[group+4])));
+ ND_PRINT((ndo, " %s", tok2str(igmpv3report2str, " [v3-report-#%d]",
+ bp[group])));
nsrcs = EXTRACT_16BITS(&bp[group+2]);
/* Check the number of sources and print them */
if (len < group+8+(nsrcs<<2)) {
- (void)printf(" [invalid number of sources %d]", nsrcs);
+ ND_PRINT((ndo, " [invalid number of sources %d]", nsrcs));
return;
}
- if (vflag == 1)
- (void)printf(", %d source(s)", nsrcs);
+ if (ndo->ndo_vflag == 1)
+ ND_PRINT((ndo, ", %d source(s)", nsrcs));
else {
/* Print the sources */
- (void)printf(" {");
+ ND_PRINT((ndo, " {"));
for (j=0; j<nsrcs; j++) {
- TCHECK2(bp[group+8+(j<<2)], 4);
- (void)printf(" %s", ipaddr_string(&bp[group+8+(j<<2)]));
+ ND_TCHECK2(bp[group+8+(j<<2)], 4);
+ ND_PRINT((ndo, " %s", ipaddr_string(ndo, &bp[group+8+(j<<2)])));
}
- (void)printf(" }");
+ ND_PRINT((ndo, " }"));
}
/* Next group record */
group += 8 + (nsrcs << 2);
- (void)printf("]");
+ ND_PRINT((ndo, "]"));
}
}
return;
trunc:
- (void)printf("[|igmp]");
- return;
+ ND_PRINT((ndo, "%s", tstr));
}
static void
-print_igmpv3_query(register const u_char *bp, register u_int len)
+print_igmpv3_query(netdissect_options *ndo,
+ register const u_char *bp, register u_int len)
{
u_int mrc;
int mrt;
u_int nsrcs;
register u_int i;
- (void)printf(" v3");
+ ND_PRINT((ndo, " v3"));
/* Minimum len is 12, and should be a multiple of 4 */
if (len < 12 || len & 0x03) {
- (void)printf(" [invalid len %d]", len);
+ ND_PRINT((ndo, " [invalid len %d]", len));
return;
}
- TCHECK(bp[1]);
+ ND_TCHECK(bp[1]);
mrc = bp[1];
if (mrc < 128) {
mrt = mrc;
@@ -226,119 +222,119 @@ print_igmpv3_query(register const u_char *bp, register u_int len)
mrt = ((mrc & 0x0f) | 0x10) << (((mrc & 0x70) >> 4) + 3);
}
if (mrc != 100) {
- (void)printf(" [max resp time ");
+ ND_PRINT((ndo, " [max resp time "));
if (mrt < 600) {
- (void)printf("%.1fs", mrt * 0.1);
+ ND_PRINT((ndo, "%.1fs", mrt * 0.1));
} else {
- relts_print(mrt / 10);
+ relts_print(ndo, mrt / 10);
}
- (void)printf("]");
+ ND_PRINT((ndo, "]"));
}
- TCHECK2(bp[4], 4);
+ ND_TCHECK2(bp[4], 4);
if (EXTRACT_32BITS(&bp[4]) == 0)
return;
- (void)printf(" [gaddr %s", ipaddr_string(&bp[4]));
- TCHECK2(bp[10], 2);
+ ND_PRINT((ndo, " [gaddr %s", ipaddr_string(ndo, &bp[4])));
+ ND_TCHECK2(bp[10], 2);
nsrcs = EXTRACT_16BITS(&bp[10]);
if (nsrcs > 0) {
if (len < 12 + (nsrcs << 2))
- (void)printf(" [invalid number of sources]");
- else if (vflag > 1) {
- (void)printf(" {");
+ ND_PRINT((ndo, " [invalid number of sources]"));
+ else if (ndo->ndo_vflag > 1) {
+ ND_PRINT((ndo, " {"));
for (i=0; i<nsrcs; i++) {
- TCHECK2(bp[12+(i<<2)], 4);
- (void)printf(" %s", ipaddr_string(&bp[12+(i<<2)]));
+ ND_TCHECK2(bp[12+(i<<2)], 4);
+ ND_PRINT((ndo, " %s", ipaddr_string(ndo, &bp[12+(i<<2)])));
}
- (void)printf(" }");
+ ND_PRINT((ndo, " }"));
} else
- (void)printf(", %d source(s)", nsrcs);
+ ND_PRINT((ndo, ", %d source(s)", nsrcs));
}
- (void)printf("]");
+ ND_PRINT((ndo, "]"));
return;
trunc:
- (void)printf("[|igmp]");
- return;
+ ND_PRINT((ndo, "%s", tstr));
}
void
-igmp_print(register const u_char *bp, register u_int len)
+igmp_print(netdissect_options *ndo,
+ register const u_char *bp, register u_int len)
{
struct cksum_vec vec[1];
- if (qflag) {
- (void)printf("igmp");
+ if (ndo->ndo_qflag) {
+ ND_PRINT((ndo, "igmp"));
return;
}
- TCHECK(bp[0]);
+ ND_TCHECK(bp[0]);
switch (bp[0]) {
case 0x11:
- (void)printf("igmp query");
+ ND_PRINT((ndo, "igmp query"));
if (len >= 12)
- print_igmpv3_query(bp, len);
+ print_igmpv3_query(ndo, bp, len);
else {
- TCHECK(bp[1]);
+ ND_TCHECK(bp[1]);
if (bp[1]) {
- (void)printf(" v2");
+ ND_PRINT((ndo, " v2"));
if (bp[1] != 100)
- (void)printf(" [max resp time %d]", bp[1]);
+ ND_PRINT((ndo, " [max resp time %d]", bp[1]));
} else
- (void)printf(" v1");
- TCHECK2(bp[4], 4);
+ ND_PRINT((ndo, " v1"));
+ ND_TCHECK2(bp[4], 4);
if (EXTRACT_32BITS(&bp[4]))
- (void)printf(" [gaddr %s]", ipaddr_string(&bp[4]));
+ ND_PRINT((ndo, " [gaddr %s]", ipaddr_string(ndo, &bp[4])));
if (len != 8)
- (void)printf(" [len %d]", len);
+ ND_PRINT((ndo, " [len %d]", len));
}
break;
case 0x12:
- TCHECK2(bp[4], 4);
- (void)printf("igmp v1 report %s", ipaddr_string(&bp[4]));
+ ND_TCHECK2(bp[4], 4);
+ ND_PRINT((ndo, "igmp v1 report %s", ipaddr_string(ndo, &bp[4])));
if (len != 8)
- (void)printf(" [len %d]", len);
+ ND_PRINT((ndo, " [len %d]", len));
break;
case 0x16:
- TCHECK2(bp[4], 4);
- (void)printf("igmp v2 report %s", ipaddr_string(&bp[4]));
+ ND_TCHECK2(bp[4], 4);
+ ND_PRINT((ndo, "igmp v2 report %s", ipaddr_string(ndo, &bp[4])));
break;
case 0x22:
- (void)printf("igmp v3 report");
- print_igmpv3_report(bp, len);
+ ND_PRINT((ndo, "igmp v3 report"));
+ print_igmpv3_report(ndo, bp, len);
break;
case 0x17:
- TCHECK2(bp[4], 4);
- (void)printf("igmp leave %s", ipaddr_string(&bp[4]));
+ ND_TCHECK2(bp[4], 4);
+ ND_PRINT((ndo, "igmp leave %s", ipaddr_string(ndo, &bp[4])));
break;
case 0x13:
- (void)printf("igmp dvmrp");
+ ND_PRINT((ndo, "igmp dvmrp"));
if (len < 8)
- (void)printf(" [len %d]", len);
+ ND_PRINT((ndo, " [len %d]", len));
else
- dvmrp_print(bp, len);
+ dvmrp_print(ndo, bp, len);
break;
case 0x14:
- (void)printf("igmp pimv1");
- pimv1_print(bp, len);
+ ND_PRINT((ndo, "igmp pimv1"));
+ pimv1_print(ndo, bp, len);
break;
case 0x1e:
- print_mresp(bp, len);
+ print_mresp(ndo, bp, len);
break;
case 0x1f:
- print_mtrace(bp, len);
+ print_mtrace(ndo, bp, len);
break;
default:
- (void)printf("igmp-%d", bp[0]);
+ ND_PRINT((ndo, "igmp-%d", bp[0]));
break;
}
- if (vflag && TTEST2(bp[0], len)) {
+ if (ndo->ndo_vflag && ND_TTEST2(bp[0], len)) {
/* Check the IGMP checksum */
vec[0].ptr = bp;
vec[0].len = len;
if (in_cksum(vec, 1))
- printf(" bad igmp cksum %x!", EXTRACT_16BITS(&bp[2]));
+ ND_PRINT((ndo, " bad igmp cksum %x!", EXTRACT_16BITS(&bp[2])));
}
return;
trunc:
- fputs("[|igmp]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
}
diff --git a/contrib/tcpdump/print-igrp.c b/contrib/tcpdump/print-igrp.c
index 3cede7ec89da..fbb313427c72 100644
--- a/contrib/tcpdump/print-igrp.c
+++ b/contrib/tcpdump/print-igrp.c
@@ -21,41 +21,65 @@
* Initial contribution from Francis Dupont (francis.dupont@inria.fr)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-igrp.c,v 1.21 2005-04-20 21:01:56 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-
#include "interface.h"
-#include "addrtoname.h"
-#include "igrp.h"
-#include "ip.h"
#include "extract.h" /* must come after interface.h */
+/* Cisco IGRP definitions */
+
+/* IGRP Header */
+
+struct igrphdr {
+ uint8_t ig_vop; /* protocol version number / opcode */
+#define IGRP_V(x) (((x) & 0xf0) >> 4)
+#define IGRP_OP(x) ((x) & 0x0f)
+ uint8_t ig_ed; /* edition number */
+ uint16_t ig_as; /* autonomous system number */
+ uint16_t ig_ni; /* number of subnet in local net */
+ uint16_t ig_ns; /* number of networks in AS */
+ uint16_t ig_nx; /* number of networks ouside AS */
+ uint16_t ig_sum; /* checksum of IGRP header & data */
+};
+
+#define IGRP_UPDATE 1
+#define IGRP_REQUEST 2
+
+/* IGRP routing entry */
+
+struct igrprte {
+ uint8_t igr_net[3]; /* 3 significant octets of IP address */
+ uint8_t igr_dly[3]; /* delay in tens of microseconds */
+ uint8_t igr_bw[3]; /* bandwidth in units of 1 kb/s */
+ uint8_t igr_mtu[2]; /* MTU in octets */
+ uint8_t igr_rel; /* percent packets successfully tx/rx */
+ uint8_t igr_ld; /* percent of channel occupied */
+ uint8_t igr_hct; /* hop count */
+};
+
+#define IGRP_RTE_SIZE 14 /* don't believe sizeof ! */
+
static void
-igrp_entry_print(register struct igrprte *igr, register int is_interior,
- register int is_exterior)
+igrp_entry_print(netdissect_options *ndo, register struct igrprte *igr,
+ register int is_interior, register int is_exterior)
{
register u_int delay, bandwidth;
u_int metric, mtu;
if (is_interior)
- printf(" *.%d.%d.%d", igr->igr_net[0],
- igr->igr_net[1], igr->igr_net[2]);
+ ND_PRINT((ndo, " *.%d.%d.%d", igr->igr_net[0],
+ igr->igr_net[1], igr->igr_net[2]));
else if (is_exterior)
- printf(" X%d.%d.%d.0", igr->igr_net[0],
- igr->igr_net[1], igr->igr_net[2]);
+ ND_PRINT((ndo, " X%d.%d.%d.0", igr->igr_net[0],
+ igr->igr_net[1], igr->igr_net[2]));
else
- printf(" %d.%d.%d.0", igr->igr_net[0],
- igr->igr_net[1], igr->igr_net[2]);
+ ND_PRINT((ndo, " %d.%d.%d.0", igr->igr_net[0],
+ igr->igr_net[1], igr->igr_net[2]));
delay = EXTRACT_24BITS(igr->igr_dly);
bandwidth = EXTRACT_24BITS(igr->igr_bw);
@@ -64,20 +88,20 @@ igrp_entry_print(register struct igrprte *igr, register int is_interior,
metric = 0xffffff;
mtu = EXTRACT_16BITS(igr->igr_mtu);
- printf(" d=%d b=%d r=%d l=%d M=%d mtu=%d in %d hops",
+ ND_PRINT((ndo, " d=%d b=%d r=%d l=%d M=%d mtu=%d in %d hops",
10 * delay, bandwidth == 0 ? 0 : 10000000 / bandwidth,
igr->igr_rel, igr->igr_ld, metric,
- mtu, igr->igr_hct);
+ mtu, igr->igr_hct));
}
-static struct tok op2str[] = {
+static const struct tok op2str[] = {
{ IGRP_UPDATE, "update" },
{ IGRP_REQUEST, "request" },
{ 0, NULL }
};
void
-igrp_print(register const u_char *bp, u_int length, const u_char *bp2 _U_)
+igrp_print(netdissect_options *ndo, register const u_char *bp, u_int length)
{
register struct igrphdr *hdr;
register u_char *cp;
@@ -85,39 +109,39 @@ igrp_print(register const u_char *bp, u_int length, const u_char *bp2 _U_)
hdr = (struct igrphdr *)bp;
cp = (u_char *)(hdr + 1);
- (void)printf("igrp:");
+ ND_PRINT((ndo, "igrp:"));
/* Header */
- TCHECK(*hdr);
+ ND_TCHECK(*hdr);
nint = EXTRACT_16BITS(&hdr->ig_ni);
nsys = EXTRACT_16BITS(&hdr->ig_ns);
next = EXTRACT_16BITS(&hdr->ig_nx);
- (void)printf(" %s V%d edit=%d AS=%d (%d/%d/%d)",
+ ND_PRINT((ndo, " %s V%d edit=%d AS=%d (%d/%d/%d)",
tok2str(op2str, "op-#%d", IGRP_OP(hdr->ig_vop)),
IGRP_V(hdr->ig_vop),
hdr->ig_ed,
EXTRACT_16BITS(&hdr->ig_as),
nint,
nsys,
- next);
+ next));
length -= sizeof(*hdr);
while (length >= IGRP_RTE_SIZE) {
if (nint > 0) {
- TCHECK2(*cp, IGRP_RTE_SIZE);
- igrp_entry_print((struct igrprte *)cp, 1, 0);
+ ND_TCHECK2(*cp, IGRP_RTE_SIZE);
+ igrp_entry_print(ndo, (struct igrprte *)cp, 1, 0);
--nint;
} else if (nsys > 0) {
- TCHECK2(*cp, IGRP_RTE_SIZE);
- igrp_entry_print((struct igrprte *)cp, 0, 0);
+ ND_TCHECK2(*cp, IGRP_RTE_SIZE);
+ igrp_entry_print(ndo, (struct igrprte *)cp, 0, 0);
--nsys;
} else if (next > 0) {
- TCHECK2(*cp, IGRP_RTE_SIZE);
- igrp_entry_print((struct igrprte *)cp, 0, 1);
+ ND_TCHECK2(*cp, IGRP_RTE_SIZE);
+ igrp_entry_print(ndo, (struct igrprte *)cp, 0, 1);
--next;
} else {
- (void)printf(" [extra bytes %d]", length);
+ ND_PRINT((ndo, " [extra bytes %d]", length));
break;
}
cp += IGRP_RTE_SIZE;
@@ -126,5 +150,5 @@ igrp_print(register const u_char *bp, u_int length, const u_char *bp2 _U_)
if (nint == 0 && nsys == 0 && next == 0)
return;
trunc:
- fputs(" [|igrp]", stdout);
+ ND_PRINT((ndo, " [|igrp]"));
}
diff --git a/contrib/tcpdump/print-ip.c b/contrib/tcpdump/print-ip.c
index 291901f0fc49..bfd2c75758a4 100644
--- a/contrib/tcpdump/print-ip.c
+++ b/contrib/tcpdump/print-ip.c
@@ -21,29 +21,25 @@
* $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.159 2007-09-14 01:29:28 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
-#include "addrtoname.h"
#include "interface.h"
+#include "addrtoname.h"
#include "extract.h" /* must come after interface.h */
#include "ip.h"
#include "ipproto.h"
-struct tok ip_option_values[] = {
+static const char tstr[] = "[|ip]";
+
+static const struct tok ip_option_values[] = {
{ IPOPT_EOL, "EOL" },
{ IPOPT_NOP, "NOP" },
{ IPOPT_TS, "timestamp" },
@@ -60,25 +56,26 @@ struct tok ip_option_values[] = {
* print the recorded route in an IP RR, LSRR or SSRR option.
*/
static void
-ip_printroute(register const u_char *cp, u_int length)
+ip_printroute(netdissect_options *ndo,
+ register const u_char *cp, u_int length)
{
register u_int ptr;
register u_int len;
if (length < 3) {
- printf(" [bad length %u]", length);
+ ND_PRINT((ndo, " [bad length %u]", length));
return;
}
if ((length + 1) & 3)
- printf(" [bad length %u]", length);
+ ND_PRINT((ndo, " [bad length %u]", length));
ptr = cp[2] - 1;
if (ptr < 3 || ((ptr + 1) & 3) || ptr > length + 1)
- printf(" [bad ptr %u]", cp[2]);
+ ND_PRINT((ndo, " [bad ptr %u]", cp[2]));
for (len = 3; len < length; len += 4) {
- printf(" %s", ipaddr_string(&cp[len]));
- if (ptr > len)
- printf(",");
+ ND_PRINT((ndo, " %s", ipaddr_string(ndo, &cp[len])));
+ if (ptr > len)
+ ND_PRINT((ndo, ","));
}
}
@@ -89,13 +86,14 @@ ip_printroute(register const u_char *cp, u_int length)
* This is used for UDP and TCP pseudo-header in the checksum
* calculation.
*/
-static u_int32_t
-ip_finddst(const struct ip *ip)
+static uint32_t
+ip_finddst(netdissect_options *ndo,
+ const struct ip *ip)
{
int length;
int len;
const u_char *cp;
- u_int32_t retval;
+ uint32_t retval;
cp = (const u_char *)(ip + 1);
length = (IP_HL(ip) << 2) - sizeof(struct ip);
@@ -103,31 +101,31 @@ ip_finddst(const struct ip *ip)
for (; length > 0; cp += len, length -= len) {
int tt;
- TCHECK(*cp);
+ ND_TCHECK(*cp);
tt = *cp;
if (tt == IPOPT_EOL)
break;
else if (tt == IPOPT_NOP)
len = 1;
else {
- TCHECK(cp[1]);
+ ND_TCHECK(cp[1]);
len = cp[1];
if (len < 2)
break;
}
- TCHECK2(*cp, len);
+ ND_TCHECK2(*cp, len);
switch (tt) {
case IPOPT_SSRR:
case IPOPT_LSRR:
if (len < 7)
break;
- memcpy(&retval, cp + len - 4, 4);
+ UNALIGNED_MEMCPY(&retval, cp + len - 4, 4);
return retval;
}
}
trunc:
- memcpy(&retval, &ip->ip_dst.s_addr, sizeof(u_int32_t));
+ UNALIGNED_MEMCPY(&retval, &ip->ip_dst.s_addr, sizeof(uint32_t));
return retval;
}
@@ -135,37 +133,39 @@ trunc:
* Compute a V4-style checksum by building a pseudoheader.
*/
int
-nextproto4_cksum(const struct ip *ip, const u_int8_t *data,
- u_int len, u_int next_proto)
+nextproto4_cksum(netdissect_options *ndo,
+ const struct ip *ip, const uint8_t *data,
+ u_int len, u_int covlen, u_int next_proto)
{
struct phdr {
- u_int32_t src;
- u_int32_t dst;
+ uint32_t src;
+ uint32_t dst;
u_char mbz;
u_char proto;
- u_int16_t len;
+ uint16_t len;
} ph;
struct cksum_vec vec[2];
/* pseudo-header.. */
- ph.len = htons((u_int16_t)len);
+ ph.len = htons((uint16_t)len);
ph.mbz = 0;
ph.proto = next_proto;
- memcpy(&ph.src, &ip->ip_src.s_addr, sizeof(u_int32_t));
+ UNALIGNED_MEMCPY(&ph.src, &ip->ip_src.s_addr, sizeof(uint32_t));
if (IP_HL(ip) == 5)
- memcpy(&ph.dst, &ip->ip_dst.s_addr, sizeof(u_int32_t));
+ UNALIGNED_MEMCPY(&ph.dst, &ip->ip_dst.s_addr, sizeof(uint32_t));
else
- ph.dst = ip_finddst(ip);
+ ph.dst = ip_finddst(ndo, ip);
- vec[0].ptr = (const u_int8_t *)(void *)&ph;
+ vec[0].ptr = (const uint8_t *)(void *)&ph;
vec[0].len = sizeof(ph);
vec[1].ptr = data;
- vec[1].len = len;
+ vec[1].len = covlen;
return (in_cksum(vec, 2));
}
static void
-ip_printts(register const u_char *cp, u_int length)
+ip_printts(netdissect_options *ndo,
+ register const u_char *cp, u_int length)
{
register u_int ptr;
register u_int len;
@@ -173,23 +173,23 @@ ip_printts(register const u_char *cp, u_int length)
const char *type;
if (length < 4) {
- printf("[bad length %u]", length);
+ ND_PRINT((ndo, "[bad length %u]", length));
return;
}
- printf(" TS{");
+ ND_PRINT((ndo, " TS{"));
hoplen = ((cp[3]&0xF) != IPOPT_TS_TSONLY) ? 8 : 4;
if ((length - 4) & (hoplen-1))
- printf("[bad length %u]", length);
+ ND_PRINT((ndo, "[bad length %u]", length));
ptr = cp[2] - 1;
len = 0;
if (ptr < 4 || ((ptr - 4) & (hoplen-1)) || ptr > length + 1)
- printf("[bad ptr %u]", cp[2]);
+ ND_PRINT((ndo, "[bad ptr %u]", cp[2]));
switch (cp[3]&0xF) {
case IPOPT_TS_TSONLY:
- printf("TSONLY");
+ ND_PRINT((ndo, "TSONLY"));
break;
case IPOPT_TS_TSANDADDR:
- printf("TS+ADDR");
+ ND_PRINT((ndo, "TS+ADDR"));
break;
/*
* prespecified should really be 3, but some ones might send 2
@@ -198,13 +198,13 @@ ip_printts(register const u_char *cp, u_int length)
*/
case 2:
- printf("PRESPEC2.0");
+ ND_PRINT((ndo, "PRESPEC2.0"));
break;
case 3: /* IPOPT_TS_PRESPEC */
- printf("PRESPEC");
+ ND_PRINT((ndo, "PRESPEC"));
break;
default:
- printf("[bad ts type %d]", cp[3]&0xF);
+ ND_PRINT((ndo, "[bad ts type %d]", cp[3]&0xF));
goto done;
}
@@ -212,25 +212,26 @@ ip_printts(register const u_char *cp, u_int length)
for (len = 4; len < length; len += hoplen) {
if (ptr == len)
type = " ^ ";
- printf("%s%d@%s", type, EXTRACT_32BITS(&cp[len+hoplen-4]),
- hoplen!=8 ? "" : ipaddr_string(&cp[len]));
+ ND_PRINT((ndo, "%s%d@%s", type, EXTRACT_32BITS(&cp[len+hoplen-4]),
+ hoplen!=8 ? "" : ipaddr_string(ndo, &cp[len])));
type = " ";
}
done:
- printf("%s", ptr == len ? " ^ " : "");
+ ND_PRINT((ndo, "%s", ptr == len ? " ^ " : ""));
if (cp[3]>>4)
- printf(" [%d hops not recorded]} ", cp[3]>>4);
+ ND_PRINT((ndo, " [%d hops not recorded]} ", cp[3]>>4));
else
- printf("}");
+ ND_PRINT((ndo, "}"));
}
/*
* print IP options.
*/
static void
-ip_optprint(register const u_char *cp, u_int length)
+ip_optprint(netdissect_options *ndo,
+ register const u_char *cp, u_int length)
{
register u_int option_len;
const char *sep = "";
@@ -238,57 +239,57 @@ ip_optprint(register const u_char *cp, u_int length)
for (; length > 0; cp += option_len, length -= option_len) {
u_int option_code;
- printf("%s", sep);
+ ND_PRINT((ndo, "%s", sep));
sep = ",";
- TCHECK(*cp);
+ ND_TCHECK(*cp);
option_code = *cp;
- printf("%s",
- tok2str(ip_option_values,"unknown %u",option_code));
+ ND_PRINT((ndo, "%s",
+ tok2str(ip_option_values,"unknown %u",option_code)));
if (option_code == IPOPT_NOP ||
option_code == IPOPT_EOL)
option_len = 1;
else {
- TCHECK(cp[1]);
+ ND_TCHECK(cp[1]);
option_len = cp[1];
if (option_len < 2) {
- printf(" [bad length %u]", option_len);
+ ND_PRINT((ndo, " [bad length %u]", option_len));
return;
}
}
if (option_len > length) {
- printf(" [bad length %u]", option_len);
+ ND_PRINT((ndo, " [bad length %u]", option_len));
return;
}
- TCHECK2(*cp, option_len);
+ ND_TCHECK2(*cp, option_len);
switch (option_code) {
case IPOPT_EOL:
return;
case IPOPT_TS:
- ip_printts(cp, option_len);
+ ip_printts(ndo, cp, option_len);
break;
case IPOPT_RR: /* fall through */
case IPOPT_SSRR:
case IPOPT_LSRR:
- ip_printroute(cp, option_len);
+ ip_printroute(ndo, cp, option_len);
break;
case IPOPT_RA:
if (option_len < 4) {
- printf(" [bad length %u]", option_len);
+ ND_PRINT((ndo, " [bad length %u]", option_len));
break;
}
- TCHECK(cp[3]);
- if (EXTRACT_16BITS(&cp[2]) != 0)
- printf(" value %u", EXTRACT_16BITS(&cp[2]));
+ ND_TCHECK(cp[3]);
+ if (EXTRACT_16BITS(&cp[2]) != 0)
+ ND_PRINT((ndo, " value %u", EXTRACT_16BITS(&cp[2])));
break;
case IPOPT_NOP: /* nothing to print - fall through */
@@ -300,12 +301,12 @@ ip_optprint(register const u_char *cp, u_int length)
return;
trunc:
- printf("[|ip]");
+ ND_PRINT((ndo, "%s", tstr));
}
#define IP_RES 0x8000
-static struct tok ip_frag_values[] = {
+static const struct tok ip_frag_values[] = {
{ IP_MF, "+" },
{ IP_DF, "DF" },
{ IP_RES, "rsvd" }, /* The RFC3514 evil ;-) bit */
@@ -332,7 +333,7 @@ again:
case IPPROTO_AH:
ipds->nh = *ipds->cp;
- ipds->advance = ah_print(ipds->cp);
+ ipds->advance = ah_print(ndo, ipds->cp);
if (ipds->advance <= 0)
break;
ipds->cp += ipds->advance;
@@ -356,7 +357,7 @@ again:
case IPPROTO_IPCOMP:
{
int enh;
- ipds->advance = ipcomp_print(ipds->cp, &enh);
+ ipds->advance = ipcomp_print(ndo, ipds->cp, &enh);
if (ipds->advance <= 0)
break;
ipds->cp += ipds->advance;
@@ -366,28 +367,28 @@ again:
}
case IPPROTO_SCTP:
- sctp_print(ipds->cp, (const u_char *)ipds->ip, ipds->len);
+ sctp_print(ndo, ipds->cp, (const u_char *)ipds->ip, ipds->len);
break;
case IPPROTO_DCCP:
- dccp_print(ipds->cp, (const u_char *)ipds->ip, ipds->len);
+ dccp_print(ndo, ipds->cp, (const u_char *)ipds->ip, ipds->len);
break;
case IPPROTO_TCP:
/* pass on the MF bit plus the offset to detect fragments */
- tcp_print(ipds->cp, ipds->len, (const u_char *)ipds->ip,
+ tcp_print(ndo, ipds->cp, ipds->len, (const u_char *)ipds->ip,
ipds->off & (IP_MF|IP_OFFMASK));
break;
case IPPROTO_UDP:
/* pass on the MF bit plus the offset to detect fragments */
- udp_print(ipds->cp, ipds->len, (const u_char *)ipds->ip,
+ udp_print(ndo, ipds->cp, ipds->len, (const u_char *)ipds->ip,
ipds->off & (IP_MF|IP_OFFMASK));
break;
case IPPROTO_ICMP:
/* pass on the MF bit plus the offset to detect fragments */
- icmp_print(ipds->cp, ipds->len, (const u_char *)ipds->ip,
+ icmp_print(ndo, ipds->cp, ipds->len, (const u_char *)ipds->ip,
ipds->off & (IP_MF|IP_OFFMASK));
break;
@@ -405,11 +406,11 @@ again:
* match was the current protocol number
* assignments say.
*/
- igrp_print(ipds->cp, ipds->len, (const u_char *)ipds->ip);
+ igrp_print(ndo, ipds->cp, ipds->len);
break;
case IPPROTO_EIGRP:
- eigrp_print(ipds->cp, ipds->len);
+ eigrp_print(ndo, ipds->cp, ipds->len);
break;
case IPPROTO_ND:
@@ -417,21 +418,21 @@ again:
break;
case IPPROTO_EGP:
- egp_print(ipds->cp, ipds->len);
+ egp_print(ndo, ipds->cp, ipds->len);
break;
case IPPROTO_OSPF:
- ospf_print(ipds->cp, ipds->len, (const u_char *)ipds->ip);
+ ospf_print(ndo, ipds->cp, ipds->len, (const u_char *)ipds->ip);
break;
case IPPROTO_IGMP:
- igmp_print(ipds->cp, ipds->len);
+ igmp_print(ndo, ipds->cp, ipds->len);
break;
case IPPROTO_IPV4:
/* DVMRP multicast tunnel (ip-in-ip encapsulation) */
ip_print(ndo, ipds->cp, ipds->len);
- if (! vflag) {
+ if (! ndo->ndo_vflag) {
ND_PRINT((ndo, " (ipip-proto-4)"));
return;
}
@@ -445,42 +446,43 @@ again:
#endif /*INET6*/
case IPPROTO_RSVP:
- rsvp_print(ipds->cp, ipds->len);
+ rsvp_print(ndo, ipds->cp, ipds->len);
break;
case IPPROTO_GRE:
/* do it */
- gre_print(ipds->cp, ipds->len);
+ gre_print(ndo, ipds->cp, ipds->len);
break;
case IPPROTO_MOBILE:
- mobile_print(ipds->cp, ipds->len);
+ mobile_print(ndo, ipds->cp, ipds->len);
break;
case IPPROTO_PIM:
vec[0].ptr = ipds->cp;
vec[0].len = ipds->len;
- pim_print(ipds->cp, ipds->len, in_cksum(vec, 1));
+ pim_print(ndo, ipds->cp, ipds->len, in_cksum(vec, 1));
break;
case IPPROTO_VRRP:
- if (packettype == PT_CARP) {
- if (vflag)
- (void)printf("carp %s > %s: ",
- ipaddr_string(&ipds->ip->ip_src),
- ipaddr_string(&ipds->ip->ip_dst));
- carp_print(ipds->cp, ipds->len, ipds->ip->ip_ttl);
+ if (ndo->ndo_packettype == PT_CARP) {
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, "carp %s > %s: ",
+ ipaddr_string(ndo, &ipds->ip->ip_src),
+ ipaddr_string(ndo, &ipds->ip->ip_dst)));
+ carp_print(ndo, ipds->cp, ipds->len, ipds->ip->ip_ttl);
} else {
- if (vflag)
- (void)printf("vrrp %s > %s: ",
- ipaddr_string(&ipds->ip->ip_src),
- ipaddr_string(&ipds->ip->ip_dst));
- vrrp_print(ipds->cp, ipds->len, ipds->ip->ip_ttl);
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, "vrrp %s > %s: ",
+ ipaddr_string(ndo, &ipds->ip->ip_src),
+ ipaddr_string(ndo, &ipds->ip->ip_dst)));
+ vrrp_print(ndo, ipds->cp, ipds->len,
+ (const u_char *)ipds->ip, ipds->ip->ip_ttl);
}
break;
case IPPROTO_PGM:
- pgm_print(ipds->cp, ipds->len, (const u_char *)ipds->ip);
+ pgm_print(ndo, ipds->cp, ipds->len, (const u_char *)ipds->ip);
break;
#if defined(HAVE_NET_PFVAR_H)
@@ -531,40 +533,40 @@ ip_print(netdissect_options *ndo,
const u_char *ipend;
u_int hlen;
struct cksum_vec vec[1];
- u_int16_t sum, ip_sum;
+ uint16_t sum, ip_sum;
struct protoent *proto;
ipds->ip = (const struct ip *)bp;
if (IP_V(ipds->ip) != 4) { /* print version if != 4 */
- printf("IP%u ", IP_V(ipds->ip));
+ ND_PRINT((ndo, "IP%u ", IP_V(ipds->ip)));
if (IP_V(ipds->ip) == 6)
- printf(", wrong link-layer encapsulation");
+ ND_PRINT((ndo, ", wrong link-layer encapsulation"));
}
- else if (!eflag)
- printf("IP ");
+ else if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, "IP "));
if ((u_char *)(ipds->ip + 1) > ndo->ndo_snapend) {
- printf("[|ip]");
+ ND_PRINT((ndo, "%s", tstr));
return;
}
if (length < sizeof (struct ip)) {
- (void)printf("truncated-ip %u", length);
+ ND_PRINT((ndo, "truncated-ip %u", length));
return;
}
hlen = IP_HL(ipds->ip) * 4;
if (hlen < sizeof (struct ip)) {
- (void)printf("bad-hlen %u", hlen);
+ ND_PRINT((ndo, "bad-hlen %u", hlen));
return;
}
ipds->len = EXTRACT_16BITS(&ipds->ip->ip_len);
if (length < ipds->len)
- (void)printf("truncated-ip - %u bytes missing! ",
- ipds->len - length);
+ ND_PRINT((ndo, "truncated-ip - %u bytes missing! ",
+ ipds->len - length));
if (ipds->len < hlen) {
#ifdef GUESS_TSO
if (ipds->len) {
- (void)printf("bad-len %u", ipds->len);
+ ND_PRINT((ndo, "bad-len %u", ipds->len));
return;
}
else {
@@ -572,7 +574,7 @@ ip_print(netdissect_options *ndo,
ipds->len = length;
}
#else
- (void)printf("bad-len %u", ipds->len);
+ ND_PRINT((ndo, "bad-len %u", ipds->len));
return;
#endif /* GUESS_TSO */
}
@@ -588,24 +590,24 @@ ip_print(netdissect_options *ndo,
ipds->off = EXTRACT_16BITS(&ipds->ip->ip_off);
- if (vflag) {
- (void)printf("(tos 0x%x", (int)ipds->ip->ip_tos);
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "(tos 0x%x", (int)ipds->ip->ip_tos));
/* ECN bits */
if (ipds->ip->ip_tos & 0x03) {
switch (ipds->ip->ip_tos & 0x03) {
case 1:
- (void)printf(",ECT(1)");
+ ND_PRINT((ndo, ",ECT(1)"));
break;
case 2:
- (void)printf(",ECT(0)");
+ ND_PRINT((ndo, ",ECT(0)"));
break;
case 3:
- (void)printf(",CE");
+ ND_PRINT((ndo, ",CE"));
}
}
if (ipds->ip->ip_ttl >= 1)
- (void)printf(", ttl %u", ipds->ip->ip_ttl);
+ ND_PRINT((ndo, ", ttl %u", ipds->ip->ip_ttl));
/*
* for the firewall guys, print id, offset.
@@ -613,33 +615,33 @@ ip_print(netdissect_options *ndo,
* For unfragmented datagrams, note the don't fragment flag.
*/
- (void)printf(", id %u, offset %u, flags [%s], proto %s (%u)",
+ ND_PRINT((ndo, ", id %u, offset %u, flags [%s], proto %s (%u)",
EXTRACT_16BITS(&ipds->ip->ip_id),
(ipds->off & 0x1fff) * 8,
bittok2str(ip_frag_values, "none", ipds->off&0xe000),
tok2str(ipproto_values,"unknown",ipds->ip->ip_p),
- ipds->ip->ip_p);
+ ipds->ip->ip_p));
- (void)printf(", length %u", EXTRACT_16BITS(&ipds->ip->ip_len));
+ ND_PRINT((ndo, ", length %u", EXTRACT_16BITS(&ipds->ip->ip_len)));
if ((hlen - sizeof(struct ip)) > 0) {
- printf(", options (");
- ip_optprint((u_char *)(ipds->ip + 1), hlen - sizeof(struct ip));
- printf(")");
+ ND_PRINT((ndo, ", options ("));
+ ip_optprint(ndo, (u_char *)(ipds->ip + 1), hlen - sizeof(struct ip));
+ ND_PRINT((ndo, ")"));
}
- if (!Kflag && (u_char *)ipds->ip + hlen <= ndo->ndo_snapend) {
- vec[0].ptr = (const u_int8_t *)(void *)ipds->ip;
+ if (!ndo->ndo_Kflag && (u_char *)ipds->ip + hlen <= ndo->ndo_snapend) {
+ vec[0].ptr = (const uint8_t *)(void *)ipds->ip;
vec[0].len = hlen;
sum = in_cksum(vec, 1);
if (sum != 0) {
ip_sum = EXTRACT_16BITS(&ipds->ip->ip_sum);
- (void)printf(", bad cksum %x (->%x)!", ip_sum,
- in_cksum_shouldbe(ip_sum, sum));
+ ND_PRINT((ndo, ", bad cksum %x (->%x)!", ip_sum,
+ in_cksum_shouldbe(ip_sum, sum)));
}
}
- printf(")\n ");
+ ND_PRINT((ndo, ")\n "));
}
/*
@@ -652,53 +654,52 @@ ip_print(netdissect_options *ndo,
if (ipds->nh != IPPROTO_TCP && ipds->nh != IPPROTO_UDP &&
ipds->nh != IPPROTO_SCTP && ipds->nh != IPPROTO_DCCP) {
- (void)printf("%s > %s: ",
- ipaddr_string(&ipds->ip->ip_src),
- ipaddr_string(&ipds->ip->ip_dst));
+ ND_PRINT((ndo, "%s > %s: ",
+ ipaddr_string(ndo, &ipds->ip->ip_src),
+ ipaddr_string(ndo, &ipds->ip->ip_dst)));
}
ip_print_demux(ndo, ipds);
} else {
/* Ultra quiet now means that all this stuff should be suppressed */
- if (qflag > 1) return;
+ if (ndo->ndo_qflag > 1) return;
/*
* if this isn't the first frag, we're missing the
* next level protocol header. print the ip addr
* and the protocol.
*/
- if (ipds->off & 0x1fff) {
- (void)printf("%s > %s:", ipaddr_string(&ipds->ip->ip_src),
- ipaddr_string(&ipds->ip->ip_dst));
- if (!ndo->ndo_nflag && (proto = getprotobynumber(ipds->ip->ip_p)) != NULL)
- (void)printf(" %s", proto->p_name);
- else
- (void)printf(" ip-proto-%d", ipds->ip->ip_p);
- }
+ if (ipds->off & 0x1fff) {
+ ND_PRINT((ndo, "%s > %s:", ipaddr_string(ndo, &ipds->ip->ip_src),
+ ipaddr_string(ndo, &ipds->ip->ip_dst)));
+ if (!ndo->ndo_nflag && (proto = getprotobynumber(ipds->ip->ip_p)) != NULL)
+ ND_PRINT((ndo, " %s", proto->p_name));
+ else
+ ND_PRINT((ndo, " ip-proto-%d", ipds->ip->ip_p));
+ }
}
}
void
-ipN_print(register const u_char *bp, register u_int length)
+ipN_print(netdissect_options *ndo, register const u_char *bp, register u_int length)
{
- struct ip *ip, hdr;
+ struct ip hdr;
- ip = (struct ip *)bp;
if (length < 4) {
- (void)printf("truncated-ip %d", length);
+ ND_PRINT((ndo, "truncated-ip %d", length));
return;
}
- memcpy (&hdr, (char *)ip, 4);
+ memcpy (&hdr, bp, 4);
switch (IP_V(&hdr)) {
case 4:
- ip_print (gndo, bp, length);
+ ip_print (ndo, bp, length);
return;
#ifdef INET6
case 6:
- ip6_print (gndo, bp, length);
+ ip6_print (ndo, bp, length);
return;
#endif
default:
- (void)printf("unknown ip %d", IP_V(&hdr));
+ ND_PRINT((ndo, "unknown ip %d", IP_V(&hdr)));
return;
}
}
diff --git a/contrib/tcpdump/print-ip6.c b/contrib/tcpdump/print-ip6.c
index b9039708085f..2df96cbbc9d9 100644
--- a/contrib/tcpdump/print-ip6.c
+++ b/contrib/tcpdump/print-ip6.c
@@ -21,11 +21,7 @@
* $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.52 2007-09-21 07:05:33 hannes Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -34,11 +30,8 @@ static const char rcsid[] _U_ =
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
-#include "netdissect.h"
#include "interface.h"
#include "addrtoname.h"
#include "extract.h"
@@ -50,29 +43,29 @@ static const char rcsid[] _U_ =
* Compute a V6-style checksum by building a pseudoheader.
*/
int
-nextproto6_cksum(const struct ip6_hdr *ip6, const u_int8_t *data,
- u_int len, u_int next_proto)
+nextproto6_cksum(const struct ip6_hdr *ip6, const uint8_t *data,
+ u_int len, u_int covlen, u_int next_proto)
{
struct {
struct in6_addr ph_src;
struct in6_addr ph_dst;
- u_int32_t ph_len;
- u_int8_t ph_zero[3];
- u_int8_t ph_nxt;
+ uint32_t ph_len;
+ uint8_t ph_zero[3];
+ uint8_t ph_nxt;
} ph;
struct cksum_vec vec[2];
/* pseudo-header */
memset(&ph, 0, sizeof(ph));
- ph.ph_src = ip6->ip6_src;
- ph.ph_dst = ip6->ip6_dst;
+ UNALIGNED_MEMCPY(&ph.ph_src, &ip6->ip6_src, sizeof (struct in6_addr));
+ UNALIGNED_MEMCPY(&ph.ph_dst, &ip6->ip6_dst, sizeof (struct in6_addr));
ph.ph_len = htonl(len);
ph.ph_nxt = next_proto;
- vec[0].ptr = (const u_int8_t *)(void *)&ph;
+ vec[0].ptr = (const uint8_t *)(void *)&ph;
vec[0].len = sizeof(ph);
vec[1].ptr = data;
- vec[1].len = len;
+ vec[1].len = covlen;
return in_cksum(vec, 2);
}
@@ -95,19 +88,24 @@ ip6_print(netdissect_options *ndo, const u_char *bp, u_int length)
ip6 = (const struct ip6_hdr *)bp;
- TCHECK(*ip6);
+ ND_TCHECK(*ip6);
if (length < sizeof (struct ip6_hdr)) {
- (void)ND_PRINT((ndo, "truncated-ip6 %u", length));
+ ND_PRINT((ndo, "truncated-ip6 %u", length));
return;
}
if (!ndo->ndo_eflag)
ND_PRINT((ndo, "IP6 "));
+ if (IP6_VERSION(ip6) != 6) {
+ ND_PRINT((ndo,"version error: %u != 6", IP6_VERSION(ip6)));
+ return;
+ }
+
payload_len = EXTRACT_16BITS(&ip6->ip6_plen);
len = payload_len + sizeof(struct ip6_hdr);
if (length < len)
- (void)ND_PRINT((ndo, "truncated-ip6 - %u bytes missing!",
+ ND_PRINT((ndo, "truncated-ip6 - %u bytes missing!",
len - length));
if (ndo->ndo_vflag) {
@@ -116,18 +114,18 @@ ip6_print(netdissect_options *ndo, const u_char *bp, u_int length)
#if 0
/* rfc1883 */
if (flow & 0x0f000000)
- (void)ND_PRINT((ndo, "pri 0x%02x, ", (flow & 0x0f000000) >> 24));
+ ND_PRINT((ndo, "pri 0x%02x, ", (flow & 0x0f000000) >> 24));
if (flow & 0x00ffffff)
- (void)ND_PRINT((ndo, "flowlabel 0x%06x, ", flow & 0x00ffffff));
+ ND_PRINT((ndo, "flowlabel 0x%06x, ", flow & 0x00ffffff));
#else
/* RFC 2460 */
if (flow & 0x0ff00000)
- (void)ND_PRINT((ndo, "class 0x%02x, ", (flow & 0x0ff00000) >> 20));
+ ND_PRINT((ndo, "class 0x%02x, ", (flow & 0x0ff00000) >> 20));
if (flow & 0x000fffff)
- (void)ND_PRINT((ndo, "flowlabel 0x%05x, ", flow & 0x000fffff));
+ ND_PRINT((ndo, "flowlabel 0x%05x, ", flow & 0x000fffff));
#endif
- (void)ND_PRINT((ndo, "hlim %u, next-header %s (%u) payload length: %u) ",
+ ND_PRINT((ndo, "hlim %u, next-header %s (%u) payload length: %u) ",
ip6->ip6_hlim,
tok2str(ipproto_values,"unknown",ip6->ip6_nxt),
ip6->ip6_nxt,
@@ -151,21 +149,21 @@ ip6_print(netdissect_options *ndo, const u_char *bp, u_int length)
if (cp == (const u_char *)(ip6 + 1) &&
nh != IPPROTO_TCP && nh != IPPROTO_UDP &&
nh != IPPROTO_DCCP && nh != IPPROTO_SCTP) {
- (void)ND_PRINT((ndo, "%s > %s: ", ip6addr_string(&ip6->ip6_src),
- ip6addr_string(&ip6->ip6_dst)));
+ ND_PRINT((ndo, "%s > %s: ", ip6addr_string(ndo, &ip6->ip6_src),
+ ip6addr_string(ndo, &ip6->ip6_dst)));
}
switch (nh) {
case IPPROTO_HOPOPTS:
- advance = hbhopt_print(cp);
+ advance = hbhopt_print(ndo, cp);
nh = *cp;
break;
case IPPROTO_DSTOPTS:
- advance = dstopt_print(cp);
+ advance = dstopt_print(ndo, cp);
nh = *cp;
break;
case IPPROTO_FRAGMENT:
- advance = frag6_print(cp, (const u_char *)ip6);
+ advance = frag6_print(ndo, cp, (const u_char *)ip6);
if (ndo->ndo_snapend <= cp + advance)
return;
nh = *cp;
@@ -184,30 +182,30 @@ ip6_print(netdissect_options *ndo, const u_char *bp, u_int length)
* which payload can be piggybacked atop a
* mobility header.
*/
- advance = mobility_print(cp, (const u_char *)ip6);
+ advance = mobility_print(ndo, cp, (const u_char *)ip6);
nh = *cp;
return;
case IPPROTO_ROUTING:
- advance = rt6_print(cp, (const u_char *)ip6);
+ advance = rt6_print(ndo, cp, (const u_char *)ip6);
nh = *cp;
break;
case IPPROTO_SCTP:
- sctp_print(cp, (const u_char *)ip6, len);
+ sctp_print(ndo, cp, (const u_char *)ip6, len);
return;
case IPPROTO_DCCP:
- dccp_print(cp, (const u_char *)ip6, len);
+ dccp_print(ndo, cp, (const u_char *)ip6, len);
return;
case IPPROTO_TCP:
- tcp_print(cp, len, (const u_char *)ip6, fragmented);
+ tcp_print(ndo, cp, len, (const u_char *)ip6, fragmented);
return;
case IPPROTO_UDP:
- udp_print(cp, len, (const u_char *)ip6, fragmented);
+ udp_print(ndo, cp, len, (const u_char *)ip6, fragmented);
return;
case IPPROTO_ICMPV6:
icmp6_print(ndo, cp, len, (const u_char *)ip6, fragmented);
return;
case IPPROTO_AH:
- advance = ah_print(cp);
+ advance = ah_print(ndo, cp);
nh = *cp;
break;
case IPPROTO_ESP:
@@ -221,18 +219,18 @@ ip6_print(netdissect_options *ndo, const u_char *bp, u_int length)
case IPPROTO_IPCOMP:
{
int enh;
- advance = ipcomp_print(cp, &enh);
+ advance = ipcomp_print(ndo, cp, &enh);
nh = enh & 0xff;
break;
}
case IPPROTO_PIM:
- pim_print(cp, len, nextproto6_cksum(ip6, cp, len,
+ pim_print(ndo, cp, len, nextproto6_cksum(ip6, cp, len, len,
IPPROTO_PIM));
return;
case IPPROTO_OSPF:
- ospf6_print(cp, len);
+ ospf6_print(ndo, cp, len);
return;
case IPPROTO_IPV6:
@@ -244,30 +242,30 @@ ip6_print(netdissect_options *ndo, const u_char *bp, u_int length)
return;
case IPPROTO_PGM:
- pgm_print(cp, len, (const u_char *)ip6);
+ pgm_print(ndo, cp, len, (const u_char *)ip6);
return;
case IPPROTO_GRE:
- gre_print(cp, len);
+ gre_print(ndo, cp, len);
return;
case IPPROTO_RSVP:
- rsvp_print(cp, len);
+ rsvp_print(ndo, cp, len);
return;
case IPPROTO_NONE:
- (void)ND_PRINT((ndo, "no next header"));
+ ND_PRINT((ndo, "no next header"));
return;
default:
- (void)ND_PRINT((ndo, "ip-proto-%d %d", nh, len));
+ ND_PRINT((ndo, "ip-proto-%d %d", nh, len));
return;
}
}
return;
trunc:
- (void)ND_PRINT((ndo, "[|ip6]"));
+ ND_PRINT((ndo, "[|ip6]"));
}
#endif /* INET6 */
diff --git a/contrib/tcpdump/print-ip6opts.c b/contrib/tcpdump/print-ip6opts.c
index 2121b46039ad..14ad42c3c99a 100644
--- a/contrib/tcpdump/print-ip6opts.c
+++ b/contrib/tcpdump/print-ip6opts.c
@@ -27,51 +27,22 @@
* SUCH DAMAGE.
*/
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ip6opts.c,v 1.18 2005-04-20 22:18:50 guy Exp $";
-#endif
-
#ifdef INET6
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-
#include "ip6.h"
#include "interface.h"
#include "addrtoname.h"
#include "extract.h"
-/* items outside of rfc2292bis */
-#ifndef IP6OPT_MINLEN
-#define IP6OPT_MINLEN 2
-#endif
-#ifndef IP6OPT_RTALERT_LEN
-#define IP6OPT_RTALERT_LEN 4
-#endif
-#ifndef IP6OPT_JUMBO_LEN
-#define IP6OPT_JUMBO_LEN 6
-#endif
-#define IP6OPT_HOMEADDR_MINLEN 18
-#define IP6OPT_BU_MINLEN 10
-#define IP6OPT_BA_MINLEN 13
-#define IP6OPT_BR_MINLEN 2
-#define IP6SOPT_UI 0x2
-#define IP6SOPT_UI_MINLEN 4
-#define IP6SOPT_ALTCOA 0x3
-#define IP6SOPT_ALTCOA_MINLEN 18
-#define IP6SOPT_AUTH 0x4
-#define IP6SOPT_AUTH_MINLEN 6
-
-static void ip6_sopt_print(const u_char *, int);
-
static void
-ip6_sopt_print(const u_char *bp, int len)
+ip6_sopt_print(netdissect_options *ndo, const u_char *bp, int len)
{
int i;
int optlen;
@@ -90,53 +61,32 @@ ip6_sopt_print(const u_char *bp, int len)
switch (bp[i]) {
case IP6OPT_PAD1:
- printf(", pad1");
+ ND_PRINT((ndo, ", pad1"));
break;
case IP6OPT_PADN:
if (len - i < IP6OPT_MINLEN) {
- printf(", padn: trunc");
+ ND_PRINT((ndo, ", padn: trunc"));
goto trunc;
}
- printf(", padn");
- break;
- case IP6SOPT_UI:
- if (len - i < IP6SOPT_UI_MINLEN) {
- printf(", ui: trunc");
- goto trunc;
- }
- printf(", ui: 0x%04x ", EXTRACT_16BITS(&bp[i + 2]));
- break;
- case IP6SOPT_ALTCOA:
- if (len - i < IP6SOPT_ALTCOA_MINLEN) {
- printf(", altcoa: trunc");
- goto trunc;
- }
- printf(", alt-CoA: %s", ip6addr_string(&bp[i+2]));
- break;
- case IP6SOPT_AUTH:
- if (len - i < IP6SOPT_AUTH_MINLEN) {
- printf(", auth: trunc");
- goto trunc;
- }
- printf(", auth spi: 0x%08x", EXTRACT_32BITS(&bp[i + 2]));
+ ND_PRINT((ndo, ", padn"));
break;
default:
if (len - i < IP6OPT_MINLEN) {
- printf(", sopt_type %d: trunc)", bp[i]);
+ ND_PRINT((ndo, ", sopt_type %d: trunc)", bp[i]));
goto trunc;
}
- printf(", sopt_type 0x%02x: len=%d", bp[i], bp[i + 1]);
+ ND_PRINT((ndo, ", sopt_type 0x%02x: len=%d", bp[i], bp[i + 1]));
break;
}
}
return;
trunc:
- printf("[trunc] ");
+ ND_PRINT((ndo, "[trunc] "));
}
-void
-ip6_opt_print(const u_char *bp, int len)
+static void
+ip6_opt_print(netdissect_options *ndo, const u_char *bp, int len)
{
int i;
int optlen = 0;
@@ -157,176 +107,108 @@ ip6_opt_print(const u_char *bp, int len)
switch (bp[i]) {
case IP6OPT_PAD1:
- printf("(pad1)");
+ ND_PRINT((ndo, "(pad1)"));
break;
case IP6OPT_PADN:
if (len - i < IP6OPT_MINLEN) {
- printf("(padn: trunc)");
+ ND_PRINT((ndo, "(padn: trunc)"));
goto trunc;
}
- printf("(padn)");
+ ND_PRINT((ndo, "(padn)"));
break;
case IP6OPT_ROUTER_ALERT:
if (len - i < IP6OPT_RTALERT_LEN) {
- printf("(rtalert: trunc)");
+ ND_PRINT((ndo, "(rtalert: trunc)"));
goto trunc;
}
if (bp[i + 1] != IP6OPT_RTALERT_LEN - 2) {
- printf("(rtalert: invalid len %d)", bp[i + 1]);
+ ND_PRINT((ndo, "(rtalert: invalid len %d)", bp[i + 1]));
goto trunc;
}
- printf("(rtalert: 0x%04x) ", EXTRACT_16BITS(&bp[i + 2]));
+ ND_PRINT((ndo, "(rtalert: 0x%04x) ", EXTRACT_16BITS(&bp[i + 2])));
break;
case IP6OPT_JUMBO:
if (len - i < IP6OPT_JUMBO_LEN) {
- printf("(jumbo: trunc)");
+ ND_PRINT((ndo, "(jumbo: trunc)"));
goto trunc;
}
if (bp[i + 1] != IP6OPT_JUMBO_LEN - 2) {
- printf("(jumbo: invalid len %d)", bp[i + 1]);
+ ND_PRINT((ndo, "(jumbo: invalid len %d)", bp[i + 1]));
goto trunc;
}
- printf("(jumbo: %u) ", EXTRACT_32BITS(&bp[i + 2]));
+ ND_PRINT((ndo, "(jumbo: %u) ", EXTRACT_32BITS(&bp[i + 2])));
break;
case IP6OPT_HOME_ADDRESS:
if (len - i < IP6OPT_HOMEADDR_MINLEN) {
- printf("(homeaddr: trunc)");
+ ND_PRINT((ndo, "(homeaddr: trunc)"));
goto trunc;
}
if (bp[i + 1] < IP6OPT_HOMEADDR_MINLEN - 2) {
- printf("(homeaddr: invalid len %d)", bp[i + 1]);
+ ND_PRINT((ndo, "(homeaddr: invalid len %d)", bp[i + 1]));
goto trunc;
}
- printf("(homeaddr: %s", ip6addr_string(&bp[i + 2]));
+ ND_PRINT((ndo, "(homeaddr: %s", ip6addr_string(ndo, &bp[i + 2])));
if (bp[i + 1] > IP6OPT_HOMEADDR_MINLEN - 2) {
- ip6_sopt_print(&bp[i + IP6OPT_HOMEADDR_MINLEN],
+ ip6_sopt_print(ndo, &bp[i + IP6OPT_HOMEADDR_MINLEN],
(optlen - IP6OPT_HOMEADDR_MINLEN));
}
- printf(")");
- break;
- case IP6OPT_BINDING_UPDATE:
- if (len - i < IP6OPT_BU_MINLEN) {
- printf("(bu: trunc)");
- goto trunc;
- }
- if (bp[i + 1] < IP6OPT_BU_MINLEN - 2) {
- printf("(bu: invalid len %d)", bp[i + 1]);
- goto trunc;
- }
- printf("(bu: ");
- if (bp[i + 2] & 0x80)
- printf("A");
- if (bp[i + 2] & 0x40)
- printf("H");
- if (bp[i + 2] & 0x20)
- printf("S");
- if (bp[i + 2] & 0x10)
- printf("D");
- if ((bp[i + 2] & 0x0f) || bp[i + 3] || bp[i + 4])
- printf("res");
- printf(", sequence: %u", bp[i + 5]);
- printf(", lifetime: %u", EXTRACT_32BITS(&bp[i + 6]));
-
- if (bp[i + 1] > IP6OPT_BU_MINLEN - 2) {
- ip6_sopt_print(&bp[i + IP6OPT_BU_MINLEN],
- (optlen - IP6OPT_BU_MINLEN));
- }
- printf(")");
- break;
- case IP6OPT_BINDING_ACK:
- if (len - i < IP6OPT_BA_MINLEN) {
- printf("(ba: trunc)");
- goto trunc;
- }
- if (bp[i + 1] < IP6OPT_BA_MINLEN - 2) {
- printf("(ba: invalid len %d)", bp[i + 1]);
- goto trunc;
- }
- printf("(ba: ");
- printf("status: %u", bp[i + 2]);
- if (bp[i + 3])
- printf("res");
- printf(", sequence: %u", bp[i + 4]);
- printf(", lifetime: %u", EXTRACT_32BITS(&bp[i + 5]));
- printf(", refresh: %u", EXTRACT_32BITS(&bp[i + 9]));
-
- if (bp[i + 1] > IP6OPT_BA_MINLEN - 2) {
- ip6_sopt_print(&bp[i + IP6OPT_BA_MINLEN],
- (optlen - IP6OPT_BA_MINLEN));
- }
- printf(")");
- break;
- case IP6OPT_BINDING_REQ:
- if (len - i < IP6OPT_BR_MINLEN) {
- printf("(br: trunc)");
- goto trunc;
- }
- printf("(br");
- if (bp[i + 1] > IP6OPT_BR_MINLEN - 2) {
- ip6_sopt_print(&bp[i + IP6OPT_BR_MINLEN],
- (optlen - IP6OPT_BR_MINLEN));
- }
- printf(")");
+ ND_PRINT((ndo, ")"));
break;
default:
if (len - i < IP6OPT_MINLEN) {
- printf("(type %d: trunc)", bp[i]);
+ ND_PRINT((ndo, "(type %d: trunc)", bp[i]));
goto trunc;
}
- printf("(opt_type 0x%02x: len=%d)", bp[i], bp[i + 1]);
+ ND_PRINT((ndo, "(opt_type 0x%02x: len=%d)", bp[i], bp[i + 1]));
break;
}
}
- printf(" ");
-
-#if 0
-end:
-#endif
+ ND_PRINT((ndo, " "));
return;
trunc:
- printf("[trunc] ");
+ ND_PRINT((ndo, "[trunc] "));
}
int
-hbhopt_print(register const u_char *bp)
+hbhopt_print(netdissect_options *ndo, register const u_char *bp)
{
const struct ip6_hbh *dp = (struct ip6_hbh *)bp;
int hbhlen = 0;
- TCHECK(dp->ip6h_len);
+ ND_TCHECK(dp->ip6h_len);
hbhlen = (int)((dp->ip6h_len + 1) << 3);
- TCHECK2(*dp, hbhlen);
- printf("HBH ");
- if (vflag)
- ip6_opt_print((const u_char *)dp + sizeof(*dp), hbhlen - sizeof(*dp));
+ ND_TCHECK2(*dp, hbhlen);
+ ND_PRINT((ndo, "HBH "));
+ if (ndo->ndo_vflag)
+ ip6_opt_print(ndo, (const u_char *)dp + sizeof(*dp), hbhlen - sizeof(*dp));
return(hbhlen);
trunc:
- fputs("[|HBH]", stdout);
+ ND_PRINT((ndo, "[|HBH]"));
return(-1);
}
int
-dstopt_print(register const u_char *bp)
+dstopt_print(netdissect_options *ndo, register const u_char *bp)
{
const struct ip6_dest *dp = (struct ip6_dest *)bp;
int dstoptlen = 0;
- TCHECK(dp->ip6d_len);
+ ND_TCHECK(dp->ip6d_len);
dstoptlen = (int)((dp->ip6d_len + 1) << 3);
- TCHECK2(*dp, dstoptlen);
- printf("DSTOPT ");
- if (vflag) {
- ip6_opt_print((const u_char *)dp + sizeof(*dp),
+ ND_TCHECK2(*dp, dstoptlen);
+ ND_PRINT((ndo, "DSTOPT "));
+ if (ndo->ndo_vflag) {
+ ip6_opt_print(ndo, (const u_char *)dp + sizeof(*dp),
dstoptlen - sizeof(*dp));
}
return(dstoptlen);
trunc:
- fputs("[|DSTOPT]", stdout);
+ ND_PRINT((ndo, "[|DSTOPT]"));
return(-1);
}
#endif /* INET6 */
diff --git a/contrib/tcpdump/print-ipcomp.c b/contrib/tcpdump/print-ipcomp.c
index 89130a373c07..1ba687e843e0 100644
--- a/contrib/tcpdump/print-ipcomp.c
+++ b/contrib/tcpdump/print-ipcomp.c
@@ -19,24 +19,17 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ipcomp.c,v 1.20 2003-11-19 00:36:08 guy Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <string.h>
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-
struct ipcomp {
- u_int8_t comp_nxt; /* Next Header */
- u_int8_t comp_flags; /* Length of data, in 32bit */
- u_int16_t comp_cpi; /* Compression parameter index */
+ uint8_t comp_nxt; /* Next Header */
+ uint8_t comp_flags; /* Length of data, in 32bit */
+ uint16_t comp_cpi; /* Compression parameter index */
};
#if defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H)
@@ -44,15 +37,14 @@ struct ipcomp {
#endif
#include "interface.h"
-#include "addrtoname.h"
#include "extract.h"
int
-ipcomp_print(register const u_char *bp, int *nhdr _U_)
+ipcomp_print(netdissect_options *ndo, register const u_char *bp, int *nhdr _U_)
{
register const struct ipcomp *ipcomp;
register const u_char *ep;
- u_int16_t cpi;
+ uint16_t cpi;
#if defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H)
int advance;
#endif
@@ -61,13 +53,13 @@ ipcomp_print(register const u_char *bp, int *nhdr _U_)
cpi = EXTRACT_16BITS(&ipcomp->comp_cpi);
/* 'ep' points to the end of available data. */
- ep = snapend;
+ ep = ndo->ndo_snapend;
if ((u_char *)(ipcomp + 1) >= ep - sizeof(struct ipcomp)) {
- fputs("[|IPCOMP]", stdout);
+ ND_PRINT((ndo, "[|IPCOMP]"));
goto fail;
}
- printf("IPComp(cpi=0x%04x)", cpi);
+ ND_PRINT((ndo, "IPComp(cpi=0x%04x)", cpi));
#if defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H)
if (1)
@@ -82,7 +74,7 @@ ipcomp_print(register const u_char *bp, int *nhdr _U_)
*nhdr = ipcomp->comp_nxt;
advance = sizeof(struct ipcomp);
- printf(": ");
+ ND_PRINT((ndo, ": "));
return advance;
#endif
diff --git a/contrib/tcpdump/print-ipfc.c b/contrib/tcpdump/print-ipfc.c
index c980765196b3..295ac0fdab3d 100644
--- a/contrib/tcpdump/print-ipfc.c
+++ b/contrib/tcpdump/print-ipfc.c
@@ -19,32 +19,31 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ipfc.c,v 1.9 2005-11-13 12:12:42 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <pcap.h>
-#include <stdio.h>
#include <string.h>
#include "interface.h"
#include "addrtoname.h"
-#include "ethertype.h"
#include "ether.h"
-#include "ipfc.h"
/*
* RFC 2625 IP-over-Fibre Channel.
*/
+struct ipfc_header {
+ u_char ipfc_dhost[8];
+ u_char ipfc_shost[8];
+};
+
+#define IPFC_HDRLEN 16
+
/* Extract src, dst addresses */
static inline void
extract_ipfc_addrs(const struct ipfc_header *ipfcp, char *ipfcsrc,
@@ -62,30 +61,31 @@ extract_ipfc_addrs(const struct ipfc_header *ipfcp, char *ipfcsrc,
* Print the Network_Header
*/
static inline void
-ipfc_hdr_print(register const struct ipfc_header *ipfcp _U_,
+ipfc_hdr_print(netdissect_options *ndo,
+ register const struct ipfc_header *ipfcp _U_,
register u_int length, register const u_char *ipfcsrc,
register const u_char *ipfcdst)
{
const char *srcname, *dstname;
- srcname = etheraddr_string(ipfcsrc);
- dstname = etheraddr_string(ipfcdst);
+ srcname = etheraddr_string(ndo, ipfcsrc);
+ dstname = etheraddr_string(ndo, ipfcdst);
/*
* XXX - show the upper 16 bits? Do so only if "vflag" is set?
*/
- (void) printf("%s %s %d: ", srcname, dstname, length);
+ ND_PRINT((ndo, "%s %s %d: ", srcname, dstname, length));
}
static void
-ipfc_print(const u_char *p, u_int length, u_int caplen)
+ipfc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
{
const struct ipfc_header *ipfcp = (const struct ipfc_header *)p;
struct ether_header ehdr;
u_short extracted_ethertype;
if (caplen < IPFC_HDRLEN) {
- printf("[|ipfc]");
+ ND_PRINT((ndo, "[|ipfc]"));
return;
}
/*
@@ -93,8 +93,8 @@ ipfc_print(const u_char *p, u_int length, u_int caplen)
*/
extract_ipfc_addrs(ipfcp, (char *)ESRC(&ehdr), (char *)EDST(&ehdr));
- if (eflag)
- ipfc_hdr_print(ipfcp, length, ESRC(&ehdr), EDST(&ehdr));
+ if (ndo->ndo_eflag)
+ ipfc_hdr_print(ndo, ipfcp, length, ESRC(&ehdr), EDST(&ehdr));
/* Skip over Network_Header */
length -= IPFC_HDRLEN;
@@ -102,21 +102,21 @@ ipfc_print(const u_char *p, u_int length, u_int caplen)
caplen -= IPFC_HDRLEN;
/* Try to print the LLC-layer header & higher layers */
- if (llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr),
+ if (llc_print(ndo, p, length, caplen, ESRC(&ehdr), EDST(&ehdr),
&extracted_ethertype) == 0) {
/*
* Some kinds of LLC packet we cannot
* handle intelligently
*/
- if (!eflag)
- ipfc_hdr_print(ipfcp, length + IPFC_HDRLEN,
+ if (!ndo->ndo_eflag)
+ ipfc_hdr_print(ndo, ipfcp, length + IPFC_HDRLEN,
ESRC(&ehdr), EDST(&ehdr));
if (extracted_ethertype) {
- printf("(LLC %s) ",
- etherproto_string(htons(extracted_ethertype)));
+ ND_PRINT((ndo, "(LLC %s) ",
+ etherproto_string(htons(extracted_ethertype))));
}
- if (!suppress_default_print)
- default_print(p, caplen);
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
}
}
@@ -127,9 +127,9 @@ ipfc_print(const u_char *p, u_int length, u_int caplen)
* is the number of bytes actually captured.
*/
u_int
-ipfc_if_print(const struct pcap_pkthdr *h, register const u_char *p)
+ipfc_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p)
{
- ipfc_print(p, h->len, h->caplen);
+ ipfc_print(ndo, p, h->len, h->caplen);
return (IPFC_HDRLEN);
}
diff --git a/contrib/tcpdump/print-ipnet.c b/contrib/tcpdump/print-ipnet.c
index 187f939d3f8c..e1cd59e19823 100644
--- a/contrib/tcpdump/print-ipnet.c
+++ b/contrib/tcpdump/print-ipnet.c
@@ -1,27 +1,36 @@
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <pcap.h>
-
-#include "netdissect.h"
#include "interface.h"
-#include "addrtoname.h"
-#include "ipnet.h"
+
+typedef struct ipnet_hdr {
+ uint8_t iph_version;
+ uint8_t iph_family;
+ uint16_t iph_htype;
+ uint32_t iph_pktlen;
+ uint32_t iph_ifindex;
+ uint32_t iph_grifindex;
+ uint32_t iph_zsrc;
+ uint32_t iph_zdst;
+} ipnet_hdr_t;
+
+#define IPH_AF_INET 2 /* Matches Solaris's AF_INET */
+#define IPH_AF_INET6 26 /* Matches Solaris's AF_INET6 */
#ifdef DLT_IPNET
-const struct tok ipnet_values[] = {
+static const struct tok ipnet_values[] = {
{ IPH_AF_INET, "IPv4" },
{ IPH_AF_INET6, "IPv6" },
{ 0, NULL }
};
static inline void
-ipnet_hdr_print(struct netdissect_options *ndo, const u_char *bp, u_int length)
+ipnet_hdr_print(netdissect_options *ndo, const u_char *bp, u_int length)
{
const ipnet_hdr_t *hdr;
hdr = (const ipnet_hdr_t *)bp;
@@ -44,7 +53,7 @@ ipnet_hdr_print(struct netdissect_options *ndo, const u_char *bp, u_int length)
}
static void
-ipnet_print(struct netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
+ipnet_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
{
ipnet_hdr_t *hdr;
@@ -79,7 +88,7 @@ ipnet_print(struct netdissect_options *ndo, const u_char *p, u_int length, u_int
length + sizeof(ipnet_hdr_t));
if (!ndo->ndo_suppress_default_print)
- ndo->ndo_default_print(ndo, p, caplen);
+ ND_DEFAULTPRINT(p, caplen);
break;
}
}
@@ -91,7 +100,7 @@ ipnet_print(struct netdissect_options *ndo, const u_char *p, u_int length, u_int
* is the number of bytes actually captured.
*/
u_int
-ipnet_if_print(struct netdissect_options *ndo,
+ipnet_if_print(netdissect_options *ndo,
const struct pcap_pkthdr *h, const u_char *p)
{
ipnet_print(ndo, p, h->len, h->caplen);
diff --git a/contrib/tcpdump/print-ipx.c b/contrib/tcpdump/print-ipx.c
index f067755d80ed..f076d0213f20 100644
--- a/contrib/tcpdump/print-ipx.c
+++ b/contrib/tcpdump/print-ipx.c
@@ -24,64 +24,81 @@
* $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ipx.c,v 1.42 2005-05-06 08:26:44 guy Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdlib.h>
#include <stdio.h>
-#include <string.h>
#include "interface.h"
#include "addrtoname.h"
-#include "ipx.h"
#include "extract.h"
-
-static const char *ipxaddr_string(u_int32_t, const u_char *);
-void ipx_decode(const struct ipxHdr *, const u_char *, u_int);
-void ipx_sap_print(const u_short *, u_int);
-void ipx_rip_print(const u_short *, u_int);
+/* well-known sockets */
+#define IPX_SKT_NCP 0x0451
+#define IPX_SKT_SAP 0x0452
+#define IPX_SKT_RIP 0x0453
+#define IPX_SKT_NETBIOS 0x0455
+#define IPX_SKT_DIAGNOSTICS 0x0456
+#define IPX_SKT_NWLINK_DGM 0x0553 /* NWLink datagram, may contain SMB */
+#define IPX_SKT_EIGRP 0x85be /* Cisco EIGRP over IPX */
+
+/* IPX transport header */
+struct ipxHdr {
+ uint16_t cksum; /* Checksum */
+ uint16_t length; /* Length, in bytes, including header */
+ uint8_t tCtl; /* Transport Control (i.e. hop count) */
+ uint8_t pType; /* Packet Type (i.e. level 2 protocol) */
+ uint16_t dstNet[2]; /* destination net */
+ uint8_t dstNode[6]; /* destination node */
+ uint16_t dstSkt; /* destination socket */
+ uint16_t srcNet[2]; /* source net */
+ uint8_t srcNode[6]; /* source node */
+ uint16_t srcSkt; /* source socket */
+};
+
+#define ipxSize 30
+
+static const char *ipxaddr_string(uint32_t, const u_char *);
+static void ipx_decode(netdissect_options *, const struct ipxHdr *, const u_char *, u_int);
+static void ipx_sap_print(netdissect_options *, const u_short *, u_int);
+static void ipx_rip_print(netdissect_options *, const u_short *, u_int);
/*
* Print IPX datagram packets.
*/
void
-ipx_print(const u_char *p, u_int length)
+ipx_print(netdissect_options *ndo, const u_char *p, u_int length)
{
const struct ipxHdr *ipx = (const struct ipxHdr *)p;
- if (!eflag)
- printf("IPX ");
+ if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, "IPX "));
- TCHECK(ipx->srcSkt);
- (void)printf("%s.%04x > ",
+ ND_TCHECK(ipx->srcSkt);
+ ND_PRINT((ndo, "%s.%04x > ",
ipxaddr_string(EXTRACT_32BITS(ipx->srcNet), ipx->srcNode),
- EXTRACT_16BITS(&ipx->srcSkt));
+ EXTRACT_16BITS(&ipx->srcSkt)));
- (void)printf("%s.%04x: ",
+ ND_PRINT((ndo, "%s.%04x: ",
ipxaddr_string(EXTRACT_32BITS(ipx->dstNet), ipx->dstNode),
- EXTRACT_16BITS(&ipx->dstSkt));
+ EXTRACT_16BITS(&ipx->dstSkt)));
/* take length from ipx header */
- TCHECK(ipx->length);
+ ND_TCHECK(ipx->length);
length = EXTRACT_16BITS(&ipx->length);
- ipx_decode(ipx, (u_char *)ipx + ipxSize, length - ipxSize);
+ ipx_decode(ndo, ipx, (u_char *)ipx + ipxSize, length - ipxSize);
return;
trunc:
- printf("[|ipx %d]", length);
+ ND_PRINT((ndo, "[|ipx %d]", length));
}
static const char *
-ipxaddr_string(u_int32_t net, const u_char *node)
+ipxaddr_string(uint32_t net, const u_char *node)
{
static char line[256];
@@ -91,52 +108,52 @@ ipxaddr_string(u_int32_t net, const u_char *node)
return line;
}
-void
-ipx_decode(const struct ipxHdr *ipx, const u_char *datap, u_int length)
+static void
+ipx_decode(netdissect_options *ndo, const struct ipxHdr *ipx, const u_char *datap, u_int length)
{
register u_short dstSkt;
dstSkt = EXTRACT_16BITS(&ipx->dstSkt);
switch (dstSkt) {
case IPX_SKT_NCP:
- (void)printf("ipx-ncp %d", length);
+ ND_PRINT((ndo, "ipx-ncp %d", length));
break;
case IPX_SKT_SAP:
- ipx_sap_print((u_short *)datap, length);
+ ipx_sap_print(ndo, (u_short *)datap, length);
break;
case IPX_SKT_RIP:
- ipx_rip_print((u_short *)datap, length);
+ ipx_rip_print(ndo, (u_short *)datap, length);
break;
case IPX_SKT_NETBIOS:
- (void)printf("ipx-netbios %d", length);
+ ND_PRINT((ndo, "ipx-netbios %d", length));
#ifdef TCPDUMP_DO_SMB
- ipx_netbios_print(datap, length);
+ ipx_netbios_print(ndo, datap, length);
#endif
break;
case IPX_SKT_DIAGNOSTICS:
- (void)printf("ipx-diags %d", length);
+ ND_PRINT((ndo, "ipx-diags %d", length));
break;
case IPX_SKT_NWLINK_DGM:
- (void)printf("ipx-nwlink-dgm %d", length);
+ ND_PRINT((ndo, "ipx-nwlink-dgm %d", length));
#ifdef TCPDUMP_DO_SMB
- ipx_netbios_print(datap, length);
+ ipx_netbios_print(ndo, datap, length);
#endif
break;
case IPX_SKT_EIGRP:
- eigrp_print(datap, length);
+ eigrp_print(ndo, datap, length);
break;
default:
- (void)printf("ipx-#%x %d", dstSkt, length);
+ ND_PRINT((ndo, "ipx-#%x %d", dstSkt, length));
break;
}
}
-void
-ipx_sap_print(const u_short *ipx, u_int length)
+static void
+ipx_sap_print(netdissect_options *ndo, const u_short *ipx, u_int length)
{
int command, i;
- TCHECK(ipx[0]);
+ ND_TCHECK(ipx[0]);
command = EXTRACT_16BITS(ipx);
ipx++;
length -= 2;
@@ -145,79 +162,79 @@ ipx_sap_print(const u_short *ipx, u_int length)
case 1:
case 3:
if (command == 1)
- (void)printf("ipx-sap-req");
+ ND_PRINT((ndo, "ipx-sap-req"));
else
- (void)printf("ipx-sap-nearest-req");
+ ND_PRINT((ndo, "ipx-sap-nearest-req"));
- TCHECK(ipx[0]);
- (void)printf(" %s", ipxsap_string(htons(EXTRACT_16BITS(&ipx[0]))));
+ ND_TCHECK(ipx[0]);
+ ND_PRINT((ndo, " %s", ipxsap_string(htons(EXTRACT_16BITS(&ipx[0])))));
break;
case 2:
case 4:
if (command == 2)
- (void)printf("ipx-sap-resp");
+ ND_PRINT((ndo, "ipx-sap-resp"));
else
- (void)printf("ipx-sap-nearest-resp");
+ ND_PRINT((ndo, "ipx-sap-nearest-resp"));
for (i = 0; i < 8 && length > 0; i++) {
- TCHECK(ipx[0]);
- (void)printf(" %s '", ipxsap_string(htons(EXTRACT_16BITS(&ipx[0]))));
- if (fn_printzp((u_char *)&ipx[1], 48, snapend)) {
- printf("'");
+ ND_TCHECK(ipx[0]);
+ ND_PRINT((ndo, " %s '", ipxsap_string(htons(EXTRACT_16BITS(&ipx[0])))));
+ if (fn_printzp(ndo, (u_char *)&ipx[1], 48, ndo->ndo_snapend)) {
+ ND_PRINT((ndo, "'"));
goto trunc;
}
- TCHECK2(ipx[25], 10);
- printf("' addr %s",
- ipxaddr_string(EXTRACT_32BITS(&ipx[25]), (u_char *)&ipx[27]));
+ ND_TCHECK2(ipx[25], 10);
+ ND_PRINT((ndo, "' addr %s",
+ ipxaddr_string(EXTRACT_32BITS(&ipx[25]), (u_char *)&ipx[27])));
ipx += 32;
length -= 64;
}
break;
default:
- (void)printf("ipx-sap-?%x", command);
+ ND_PRINT((ndo, "ipx-sap-?%x", command));
break;
}
return;
trunc:
- printf("[|ipx %d]", length);
+ ND_PRINT((ndo, "[|ipx %d]", length));
}
-void
-ipx_rip_print(const u_short *ipx, u_int length)
+static void
+ipx_rip_print(netdissect_options *ndo, const u_short *ipx, u_int length)
{
int command, i;
- TCHECK(ipx[0]);
+ ND_TCHECK(ipx[0]);
command = EXTRACT_16BITS(ipx);
ipx++;
length -= 2;
switch (command) {
case 1:
- (void)printf("ipx-rip-req");
+ ND_PRINT((ndo, "ipx-rip-req"));
if (length > 0) {
- TCHECK(ipx[3]);
- (void)printf(" %08x/%d.%d", EXTRACT_32BITS(&ipx[0]),
- EXTRACT_16BITS(&ipx[2]), EXTRACT_16BITS(&ipx[3]));
+ ND_TCHECK(ipx[3]);
+ ND_PRINT((ndo, " %08x/%d.%d", EXTRACT_32BITS(&ipx[0]),
+ EXTRACT_16BITS(&ipx[2]), EXTRACT_16BITS(&ipx[3])));
}
break;
case 2:
- (void)printf("ipx-rip-resp");
+ ND_PRINT((ndo, "ipx-rip-resp"));
for (i = 0; i < 50 && length > 0; i++) {
- TCHECK(ipx[3]);
- (void)printf(" %08x/%d.%d", EXTRACT_32BITS(&ipx[0]),
- EXTRACT_16BITS(&ipx[2]), EXTRACT_16BITS(&ipx[3]));
+ ND_TCHECK(ipx[3]);
+ ND_PRINT((ndo, " %08x/%d.%d", EXTRACT_32BITS(&ipx[0]),
+ EXTRACT_16BITS(&ipx[2]), EXTRACT_16BITS(&ipx[3])));
ipx += 4;
length -= 8;
}
break;
default:
- (void)printf("ipx-rip-?%x", command);
+ ND_PRINT((ndo, "ipx-rip-?%x", command));
break;
}
return;
trunc:
- printf("[|ipx %d]", length);
+ ND_PRINT((ndo, "[|ipx %d]", length));
}
diff --git a/contrib/tcpdump/print-isakmp.c b/contrib/tcpdump/print-isakmp.c
index 4f96afe38115..bef0b45ef7f9 100644
--- a/contrib/tcpdump/print-isakmp.c
+++ b/contrib/tcpdump/print-isakmp.c
@@ -28,25 +28,22 @@
*
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-isakmp.c,v 1.61 2008-02-05 19:34:25 guy Exp $ (LBL)";
-#endif
-
#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
+/* The functions from print-esp.c used in this file are only defined when both
+ * OpenSSL and evp.h are detected. Employ the same preprocessor device here.
+ */
+#ifndef HAVE_OPENSSL_EVP_H
+#undef HAVE_LIBCRYPTO
+#endif
+
#include <tcpdump-stdinc.h>
#include <string.h>
-#include <stdio.h>
-
-#include "isakmp.h"
-#include "ipsec_doi.h"
-#include "oakley.h"
#include "interface.h"
#include "addrtoname.h"
#include "extract.h" /* must come after interface.h */
@@ -56,18 +53,537 @@ static const char rcsid[] _U_ =
#include "ip6.h"
#endif
-#ifndef HAVE_SOCKADDR_STORAGE
-#define sockaddr_storage sockaddr
+/* refer to RFC 2408 */
+
+typedef u_char cookie_t[8];
+typedef u_char msgid_t[4];
+
+#define PORT_ISAKMP 500
+
+/* 3.1 ISAKMP Header Format (IKEv1 and IKEv2)
+ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ ! Initiator !
+ ! Cookie !
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ ! Responder !
+ ! Cookie !
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ ! Next Payload ! MjVer ! MnVer ! Exchange Type ! Flags !
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ ! Message ID !
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ ! Length !
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+*/
+struct isakmp {
+ cookie_t i_ck; /* Initiator Cookie */
+ cookie_t r_ck; /* Responder Cookie */
+ uint8_t np; /* Next Payload Type */
+ uint8_t vers;
+#define ISAKMP_VERS_MAJOR 0xf0
+#define ISAKMP_VERS_MAJOR_SHIFT 4
+#define ISAKMP_VERS_MINOR 0x0f
+#define ISAKMP_VERS_MINOR_SHIFT 0
+ uint8_t etype; /* Exchange Type */
+ uint8_t flags; /* Flags */
+ msgid_t msgid;
+ uint32_t len; /* Length */
+};
+
+/* Next Payload Type */
+#define ISAKMP_NPTYPE_NONE 0 /* NONE*/
+#define ISAKMP_NPTYPE_SA 1 /* Security Association */
+#define ISAKMP_NPTYPE_P 2 /* Proposal */
+#define ISAKMP_NPTYPE_T 3 /* Transform */
+#define ISAKMP_NPTYPE_KE 4 /* Key Exchange */
+#define ISAKMP_NPTYPE_ID 5 /* Identification */
+#define ISAKMP_NPTYPE_CERT 6 /* Certificate */
+#define ISAKMP_NPTYPE_CR 7 /* Certificate Request */
+#define ISAKMP_NPTYPE_HASH 8 /* Hash */
+#define ISAKMP_NPTYPE_SIG 9 /* Signature */
+#define ISAKMP_NPTYPE_NONCE 10 /* Nonce */
+#define ISAKMP_NPTYPE_N 11 /* Notification */
+#define ISAKMP_NPTYPE_D 12 /* Delete */
+#define ISAKMP_NPTYPE_VID 13 /* Vendor ID */
+#define ISAKMP_NPTYPE_v2E 46 /* v2 Encrypted payload */
+
+#define IKEv1_MAJOR_VERSION 1
+#define IKEv1_MINOR_VERSION 0
+
+#define IKEv2_MAJOR_VERSION 2
+#define IKEv2_MINOR_VERSION 0
+
+/* Flags */
+#define ISAKMP_FLAG_E 0x01 /* Encryption Bit */
+#define ISAKMP_FLAG_C 0x02 /* Commit Bit */
+#define ISAKMP_FLAG_extra 0x04
+
+/* IKEv2 */
+#define ISAKMP_FLAG_I (1 << 3) /* (I)nitiator */
+#define ISAKMP_FLAG_V (1 << 4) /* (V)ersion */
+#define ISAKMP_FLAG_R (1 << 5) /* (R)esponse */
+
+
+/* 3.2 Payload Generic Header
+ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ ! Next Payload ! RESERVED ! Payload Length !
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+*/
+struct isakmp_gen {
+ uint8_t np; /* Next Payload */
+ uint8_t critical; /* bit 7 - critical, rest is RESERVED */
+ uint16_t len; /* Payload Length */
+};
+
+/* 3.3 Data Attributes
+ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ !A! Attribute Type ! AF=0 Attribute Length !
+ !F! ! AF=1 Attribute Value !
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ . AF=0 Attribute Value .
+ . AF=1 Not Transmitted .
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+*/
+struct isakmp_data {
+ uint16_t type; /* defined by DOI-spec, and Attribute Format */
+ uint16_t lorv; /* if f equal 1, Attribute Length */
+ /* if f equal 0, Attribute Value */
+ /* if f equal 1, Attribute Value */
+};
+
+/* 3.4 Security Association Payload */
+ /* MAY NOT be used, because of being defined in ipsec-doi. */
+ /*
+ If the current payload is the last in the message,
+ then the value of the next payload field will be 0.
+ This field MUST NOT contain the
+ values for the Proposal or Transform payloads as they are considered
+ part of the security association negotiation. For example, this
+ field would contain the value "10" (Nonce payload) in the first
+ message of a Base Exchange (see Section 4.4) and the value "0" in the
+ first message of an Identity Protect Exchange (see Section 4.5).
+ */
+struct ikev1_pl_sa {
+ struct isakmp_gen h;
+ uint32_t doi; /* Domain of Interpretation */
+ uint32_t sit; /* Situation */
+};
+
+/* 3.5 Proposal Payload */
+ /*
+ The value of the next payload field MUST only contain the value "2"
+ or "0". If there are additional Proposal payloads in the message,
+ then this field will be 2. If the current Proposal payload is the
+ last within the security association proposal, then this field will
+ be 0.
+ */
+struct ikev1_pl_p {
+ struct isakmp_gen h;
+ uint8_t p_no; /* Proposal # */
+ uint8_t prot_id; /* Protocol */
+ uint8_t spi_size; /* SPI Size */
+ uint8_t num_t; /* Number of Transforms */
+ /* SPI */
+};
+
+/* 3.6 Transform Payload */
+ /*
+ The value of the next payload field MUST only contain the value "3"
+ or "0". If there are additional Transform payloads in the proposal,
+ then this field will be 3. If the current Transform payload is the
+ last within the proposal, then this field will be 0.
+ */
+struct ikev1_pl_t {
+ struct isakmp_gen h;
+ uint8_t t_no; /* Transform # */
+ uint8_t t_id; /* Transform-Id */
+ uint16_t reserved; /* RESERVED2 */
+ /* SA Attributes */
+};
+
+/* 3.7 Key Exchange Payload */
+struct ikev1_pl_ke {
+ struct isakmp_gen h;
+ /* Key Exchange Data */
+};
+
+/* 3.8 Identification Payload */
+ /* MUST NOT to be used, because of being defined in ipsec-doi. */
+struct ikev1_pl_id {
+ struct isakmp_gen h;
+ union {
+ uint8_t id_type; /* ID Type */
+ uint32_t doi_data; /* DOI Specific ID Data */
+ } d;
+ /* Identification Data */
+};
+
+/* 3.9 Certificate Payload */
+struct ikev1_pl_cert {
+ struct isakmp_gen h;
+ uint8_t encode; /* Cert Encoding */
+ char cert; /* Certificate Data */
+ /*
+ This field indicates the type of
+ certificate or certificate-related information contained in the
+ Certificate Data field.
+ */
+};
+
+/* 3.10 Certificate Request Payload */
+struct ikev1_pl_cr {
+ struct isakmp_gen h;
+ uint8_t num_cert; /* # Cert. Types */
+ /*
+ Certificate Types (variable length)
+ -- Contains a list of the types of certificates requested,
+ sorted in order of preference. Each individual certificate
+ type is 1 octet. This field is NOT requiredo
+ */
+ /* # Certificate Authorities (1 octet) */
+ /* Certificate Authorities (variable length) */
+};
+
+/* 3.11 Hash Payload */
+ /* may not be used, because of having only data. */
+struct ikev1_pl_hash {
+ struct isakmp_gen h;
+ /* Hash Data */
+};
+
+/* 3.12 Signature Payload */
+ /* may not be used, because of having only data. */
+struct ikev1_pl_sig {
+ struct isakmp_gen h;
+ /* Signature Data */
+};
+
+/* 3.13 Nonce Payload */
+ /* may not be used, because of having only data. */
+struct ikev1_pl_nonce {
+ struct isakmp_gen h;
+ /* Nonce Data */
+};
+
+/* 3.14 Notification Payload */
+struct ikev1_pl_n {
+ struct isakmp_gen h;
+ uint32_t doi; /* Domain of Interpretation */
+ uint8_t prot_id; /* Protocol-ID */
+ uint8_t spi_size; /* SPI Size */
+ uint16_t type; /* Notify Message Type */
+ /* SPI */
+ /* Notification Data */
+};
+
+/* 3.14.1 Notify Message Types */
+/* NOTIFY MESSAGES - ERROR TYPES */
+#define ISAKMP_NTYPE_INVALID_PAYLOAD_TYPE 1
+#define ISAKMP_NTYPE_DOI_NOT_SUPPORTED 2
+#define ISAKMP_NTYPE_SITUATION_NOT_SUPPORTED 3
+#define ISAKMP_NTYPE_INVALID_COOKIE 4
+#define ISAKMP_NTYPE_INVALID_MAJOR_VERSION 5
+#define ISAKMP_NTYPE_INVALID_MINOR_VERSION 6
+#define ISAKMP_NTYPE_INVALID_EXCHANGE_TYPE 7
+#define ISAKMP_NTYPE_INVALID_FLAGS 8
+#define ISAKMP_NTYPE_INVALID_MESSAGE_ID 9
+#define ISAKMP_NTYPE_INVALID_PROTOCOL_ID 10
+#define ISAKMP_NTYPE_INVALID_SPI 11
+#define ISAKMP_NTYPE_INVALID_TRANSFORM_ID 12
+#define ISAKMP_NTYPE_ATTRIBUTES_NOT_SUPPORTED 13
+#define ISAKMP_NTYPE_NO_PROPOSAL_CHOSEN 14
+#define ISAKMP_NTYPE_BAD_PROPOSAL_SYNTAX 15
+#define ISAKMP_NTYPE_PAYLOAD_MALFORMED 16
+#define ISAKMP_NTYPE_INVALID_KEY_INFORMATION 17
+#define ISAKMP_NTYPE_INVALID_ID_INFORMATION 18
+#define ISAKMP_NTYPE_INVALID_CERT_ENCODING 19
+#define ISAKMP_NTYPE_INVALID_CERTIFICATE 20
+#define ISAKMP_NTYPE_BAD_CERT_REQUEST_SYNTAX 21
+#define ISAKMP_NTYPE_INVALID_CERT_AUTHORITY 22
+#define ISAKMP_NTYPE_INVALID_HASH_INFORMATION 23
+#define ISAKMP_NTYPE_AUTHENTICATION_FAILED 24
+#define ISAKMP_NTYPE_INVALID_SIGNATURE 25
+#define ISAKMP_NTYPE_ADDRESS_NOTIFICATION 26
+
+/* 3.15 Delete Payload */
+struct ikev1_pl_d {
+ struct isakmp_gen h;
+ uint32_t doi; /* Domain of Interpretation */
+ uint8_t prot_id; /* Protocol-Id */
+ uint8_t spi_size; /* SPI Size */
+ uint16_t num_spi; /* # of SPIs */
+ /* SPI(es) */
+};
+
+struct ikev1_ph1tab {
+ struct ikev1_ph1 *head;
+ struct ikev1_ph1 *tail;
+ int len;
+};
+
+struct isakmp_ph2tab {
+ struct ikev1_ph2 *head;
+ struct ikev1_ph2 *tail;
+ int len;
+};
+
+/* IKEv2 (RFC4306) */
+
+/* 3.3 Security Association Payload -- generic header */
+/* 3.3.1. Proposal Substructure */
+struct ikev2_p {
+ struct isakmp_gen h;
+ uint8_t p_no; /* Proposal # */
+ uint8_t prot_id; /* Protocol */
+ uint8_t spi_size; /* SPI Size */
+ uint8_t num_t; /* Number of Transforms */
+};
+
+/* 3.3.2. Transform Substructure */
+struct ikev2_t {
+ struct isakmp_gen h;
+ uint8_t t_type; /* Transform Type (ENCR,PRF,INTEG,etc.*/
+ uint8_t res2; /* reserved byte */
+ uint16_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;
+ uint16_t ke_group;
+ uint16_t ke_res1;
+ /* KE data */
+};
+
+
+/* 3.5. Identification Payloads */
+enum ikev2_id_type {
+ ID_IPV4_ADDR=1,
+ ID_FQDN=2,
+ ID_RFC822_ADDR=3,
+ ID_IPV6_ADDR=5,
+ ID_DER_ASN1_DN=9,
+ ID_DER_ASN1_GN=10,
+ ID_KEY_ID=11,
+};
+struct ikev2_id {
+ struct isakmp_gen h;
+ uint8_t type; /* ID type */
+ uint8_t res1;
+ uint16_t res2;
+ /* SPI */
+ /* Notification Data */
+};
+
+/* 3.10 Notification Payload */
+struct ikev2_n {
+ struct isakmp_gen h;
+ uint8_t prot_id; /* Protocol-ID */
+ uint8_t spi_size; /* SPI Size */
+ uint16_t type; /* Notify Message Type */
+};
+
+enum ikev2_n_type {
+ IV2_NOTIFY_UNSUPPORTED_CRITICAL_PAYLOAD = 1,
+ IV2_NOTIFY_INVALID_IKE_SPI = 4,
+ IV2_NOTIFY_INVALID_MAJOR_VERSION = 5,
+ IV2_NOTIFY_INVALID_SYNTAX = 7,
+ IV2_NOTIFY_INVALID_MESSAGE_ID = 9,
+ IV2_NOTIFY_INVALID_SPI =11,
+ IV2_NOTIFY_NO_PROPOSAL_CHOSEN =14,
+ IV2_NOTIFY_INVALID_KE_PAYLOAD =17,
+ IV2_NOTIFY_AUTHENTICATION_FAILED =24,
+ IV2_NOTIFY_SINGLE_PAIR_REQUIRED =34,
+ IV2_NOTIFY_NO_ADDITIONAL_SAS =35,
+ IV2_NOTIFY_INTERNAL_ADDRESS_FAILURE =36,
+ IV2_NOTIFY_FAILED_CP_REQUIRED =37,
+ IV2_NOTIFY_INVALID_SELECTORS =39,
+ IV2_NOTIFY_INITIAL_CONTACT =16384,
+ IV2_NOTIFY_SET_WINDOW_SIZE =16385,
+ IV2_NOTIFY_ADDITIONAL_TS_POSSIBLE =16386,
+ IV2_NOTIFY_IPCOMP_SUPPORTED =16387,
+ IV2_NOTIFY_NAT_DETECTION_SOURCE_IP =16388,
+ IV2_NOTIFY_NAT_DETECTION_DESTINATION_IP =16389,
+ IV2_NOTIFY_COOKIE =16390,
+ IV2_NOTIFY_USE_TRANSPORT_MODE =16391,
+ IV2_NOTIFY_HTTP_CERT_LOOKUP_SUPPORTED =16392,
+ IV2_NOTIFY_REKEY_SA =16393,
+ IV2_NOTIFY_ESP_TFC_PADDING_NOT_SUPPORTED =16394,
+ IV2_NOTIFY_NON_FIRST_FRAGMENTS_ALSO =16395
+};
+
+struct notify_messages {
+ uint16_t type;
+ char *msg;
+};
+
+/* 3.8 Notification Payload */
+struct ikev2_auth {
+ struct isakmp_gen h;
+ uint8_t auth_method; /* Protocol-ID */
+ uint8_t reserved[3];
+ /* authentication data */
+};
+
+enum ikev2_auth_type {
+ IV2_RSA_SIG = 1,
+ IV2_SHARED = 2,
+ IV2_DSS_SIG = 3,
+};
+
+/* refer to RFC 2409 */
+
+#if 0
+/* isakmp sa structure */
+struct oakley_sa {
+ uint8_t proto_id; /* OAKLEY */
+ vchar_t *spi; /* spi */
+ uint8_t dhgrp; /* DH; group */
+ uint8_t auth_t; /* method of authentication */
+ uint8_t prf_t; /* type of prf */
+ uint8_t hash_t; /* type of hash */
+ uint8_t enc_t; /* type of cipher */
+ uint8_t life_t; /* type of duration of lifetime */
+ uint32_t ldur; /* life duration */
+};
#endif
+/* refer to RFC 2407 */
+
+#define IPSEC_DOI 1
+
+/* 4.2 IPSEC Situation Definition */
+#define IPSECDOI_SIT_IDENTITY_ONLY 0x00000001
+#define IPSECDOI_SIT_SECRECY 0x00000002
+#define IPSECDOI_SIT_INTEGRITY 0x00000004
+
+/* 4.4.1 IPSEC Security Protocol Identifiers */
+ /* 4.4.2 IPSEC ISAKMP Transform Values */
+#define IPSECDOI_PROTO_ISAKMP 1
+#define IPSECDOI_KEY_IKE 1
+
+/* 4.4.1 IPSEC Security Protocol Identifiers */
+#define IPSECDOI_PROTO_IPSEC_AH 2
+ /* 4.4.3 IPSEC AH Transform Values */
+#define IPSECDOI_AH_MD5 2
+#define IPSECDOI_AH_SHA 3
+#define IPSECDOI_AH_DES 4
+#define IPSECDOI_AH_SHA2_256 5
+#define IPSECDOI_AH_SHA2_384 6
+#define IPSECDOI_AH_SHA2_512 7
+
+/* 4.4.1 IPSEC Security Protocol Identifiers */
+#define IPSECDOI_PROTO_IPSEC_ESP 3
+ /* 4.4.4 IPSEC ESP Transform Identifiers */
+#define IPSECDOI_ESP_DES_IV64 1
+#define IPSECDOI_ESP_DES 2
+#define IPSECDOI_ESP_3DES 3
+#define IPSECDOI_ESP_RC5 4
+#define IPSECDOI_ESP_IDEA 5
+#define IPSECDOI_ESP_CAST 6
+#define IPSECDOI_ESP_BLOWFISH 7
+#define IPSECDOI_ESP_3IDEA 8
+#define IPSECDOI_ESP_DES_IV32 9
+#define IPSECDOI_ESP_RC4 10
+#define IPSECDOI_ESP_NULL 11
+#define IPSECDOI_ESP_RIJNDAEL 12
+#define IPSECDOI_ESP_AES 12
+
+/* 4.4.1 IPSEC Security Protocol Identifiers */
+#define IPSECDOI_PROTO_IPCOMP 4
+ /* 4.4.5 IPSEC IPCOMP Transform Identifiers */
+#define IPSECDOI_IPCOMP_OUI 1
+#define IPSECDOI_IPCOMP_DEFLATE 2
+#define IPSECDOI_IPCOMP_LZS 3
+
+/* 4.5 IPSEC Security Association Attributes */
+#define IPSECDOI_ATTR_SA_LTYPE 1 /* B */
+#define IPSECDOI_ATTR_SA_LTYPE_DEFAULT 1
+#define IPSECDOI_ATTR_SA_LTYPE_SEC 1
+#define IPSECDOI_ATTR_SA_LTYPE_KB 2
+#define IPSECDOI_ATTR_SA_LDUR 2 /* V */
+#define IPSECDOI_ATTR_SA_LDUR_DEFAULT 28800 /* 8 hours */
+#define IPSECDOI_ATTR_GRP_DESC 3 /* B */
+#define IPSECDOI_ATTR_ENC_MODE 4 /* B */
+ /* default value: host dependent */
+#define IPSECDOI_ATTR_ENC_MODE_TUNNEL 1
+#define IPSECDOI_ATTR_ENC_MODE_TRNS 2
+#define IPSECDOI_ATTR_AUTH 5 /* B */
+ /* 0 means not to use authentication. */
+#define IPSECDOI_ATTR_AUTH_HMAC_MD5 1
+#define IPSECDOI_ATTR_AUTH_HMAC_SHA1 2
+#define IPSECDOI_ATTR_AUTH_DES_MAC 3
+#define IPSECDOI_ATTR_AUTH_KPDK 4 /*RFC-1826(Key/Pad/Data/Key)*/
+ /*
+ * When negotiating ESP without authentication, the Auth
+ * Algorithm attribute MUST NOT be included in the proposal.
+ * When negotiating ESP without confidentiality, the Auth
+ * Algorithm attribute MUST be included in the proposal and
+ * the ESP transform ID must be ESP_NULL.
+ */
+#define IPSECDOI_ATTR_KEY_LENGTH 6 /* B */
+#define IPSECDOI_ATTR_KEY_ROUNDS 7 /* B */
+#define IPSECDOI_ATTR_COMP_DICT_SIZE 8 /* B */
+#define IPSECDOI_ATTR_COMP_PRIVALG 9 /* V */
+
+/* 4.6.1 Security Association Payload */
+struct ipsecdoi_sa {
+ struct isakmp_gen h;
+ uint32_t doi; /* Domain of Interpretation */
+ uint32_t sit; /* Situation */
+};
+
+struct ipsecdoi_secrecy_h {
+ uint16_t len;
+ uint16_t reserved;
+};
+
+/* 4.6.2.1 Identification Type Values */
+struct ipsecdoi_id {
+ struct isakmp_gen h;
+ uint8_t type; /* ID Type */
+ uint8_t proto_id; /* Protocol ID */
+ uint16_t port; /* Port */
+ /* Identification Data */
+};
+
+#define IPSECDOI_ID_IPV4_ADDR 1
+#define IPSECDOI_ID_FQDN 2
+#define IPSECDOI_ID_USER_FQDN 3
+#define IPSECDOI_ID_IPV4_ADDR_SUBNET 4
+#define IPSECDOI_ID_IPV6_ADDR 5
+#define IPSECDOI_ID_IPV6_ADDR_SUBNET 6
+#define IPSECDOI_ID_IPV4_ADDR_RANGE 7
+#define IPSECDOI_ID_IPV6_ADDR_RANGE 8
+#define IPSECDOI_ID_DER_ASN1_DN 9
+#define IPSECDOI_ID_DER_ASN1_GN 10
+#define IPSECDOI_ID_KEY_ID 11
+
+/* 4.6.3 IPSEC DOI Notify Message Types */
+/* Notify Messages - Status Types */
+#define IPSECDOI_NTYPE_RESPONDER_LIFETIME 24576
+#define IPSECDOI_NTYPE_REPLAY_STATUS 24577
+#define IPSECDOI_NTYPE_INITIAL_CONTACT 24578
+
#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)
+ uint32_t phase,\
+ uint32_t doi0, \
+ uint32_t proto0, int depth)
DECLARE_PRINTER(v1_sa);
DECLARE_PRINTER(v1_p);
@@ -101,28 +617,27 @@ static const u_char *ikev2_e_print(netdissect_options *ndo,
struct isakmp *base,
u_char tpay,
const struct isakmp_gen *ext,
- u_int item_len,
- const u_char *end_pointer,
- u_int32_t phase,
- u_int32_t doi0,
- u_int32_t proto0, int depth);
+ u_int item_len,
+ const u_char *end_pointer,
+ uint32_t phase,
+ uint32_t doi0,
+ uint32_t proto0, int depth);
static const u_char *ike_sub0_print(netdissect_options *ndo,u_char, const struct isakmp_gen *,
- const u_char *, u_int32_t, u_int32_t, u_int32_t, int);
+ const u_char *, uint32_t, uint32_t, uint32_t, int);
static const u_char *ikev1_sub_print(netdissect_options *ndo,u_char, const struct isakmp_gen *,
- const u_char *, u_int32_t, u_int32_t, u_int32_t, int);
+ const u_char *, uint32_t, uint32_t, uint32_t, int);
static const u_char *ikev2_sub_print(netdissect_options *ndo,
struct isakmp *base,
u_char np, const struct isakmp_gen *ext,
- const u_char *ep, u_int32_t phase,
- u_int32_t doi, u_int32_t proto,
+ const u_char *ep, uint32_t phase,
+ uint32_t doi, uint32_t proto,
int depth);
static char *numstr(int);
-static void safememcpy(void *, const void *, size_t);
static void
ikev1_print(netdissect_options *ndo,
@@ -131,10 +646,17 @@ ikev1_print(netdissect_options *ndo,
#define MAXINITIATORS 20
int ninitiator = 0;
+union inaddr_u {
+ struct in_addr in4;
+#ifdef INET6
+ struct in6_addr in6;
+#endif
+};
struct {
cookie_t initiator;
- struct sockaddr_storage iaddr;
- struct sockaddr_storage raddr;
+ u_int version;
+ union inaddr_u iaddr;
+ union inaddr_u raddr;
} cookiecache[MAXINITIATORS];
/* protocol id */
@@ -154,17 +676,17 @@ static const char *npstr[] = {
"v2cr", "v2auth","v2nonce", "v2n", "v2d", /* 38- 42 */
"v2vid", "v2TSi", "v2TSr", "v2e", "v2cp", /* 43- 47 */
"v2eap", /* 48 */
-
+
};
/* isakmp->np */
-static const u_char *(*npfunc[])(netdissect_options *ndo, u_char tpay,
+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) = {
+ uint32_t phase,
+ uint32_t doi0,
+ uint32_t proto0, int depth) = {
NULL,
ikev1_sa_print,
ikev1_p_print,
@@ -224,7 +746,7 @@ static const char *etypestr[] = {
ND_PRINT((ndo," [|%s]", NPSTR(np))); \
goto done; \
}
-
+
#define NPFUNC(x) \
(((x) < sizeof(npfunc)/sizeof(npfunc[0]) && npfunc[(x)]) \
@@ -260,10 +782,8 @@ cookie_record(cookie_t *in, const u_char *bp2)
{
int i;
struct ip *ip;
- struct sockaddr_in *sin;
#ifdef INET6
struct ip6_hdr *ip6;
- struct sockaddr_in6 *sin6;
#endif
i = cookie_find(in);
@@ -275,50 +795,22 @@ cookie_record(cookie_t *in, const u_char *bp2)
ip = (struct ip *)bp2;
switch (IP_V(ip)) {
case 4:
- memset(&cookiecache[ninitiator].iaddr, 0,
- sizeof(cookiecache[ninitiator].iaddr));
- memset(&cookiecache[ninitiator].raddr, 0,
- sizeof(cookiecache[ninitiator].raddr));
-
- sin = (struct sockaddr_in *)&cookiecache[ninitiator].iaddr;
-#ifdef HAVE_SOCKADDR_SA_LEN
- sin->sin_len = sizeof(struct sockaddr_in);
-#endif
- sin->sin_family = AF_INET;
- memcpy(&sin->sin_addr, &ip->ip_src, sizeof(ip->ip_src));
- sin = (struct sockaddr_in *)&cookiecache[ninitiator].raddr;
-#ifdef HAVE_SOCKADDR_SA_LEN
- sin->sin_len = sizeof(struct sockaddr_in);
-#endif
- sin->sin_family = AF_INET;
- memcpy(&sin->sin_addr, &ip->ip_dst, sizeof(ip->ip_dst));
+ cookiecache[ninitiator].version = 4;
+ UNALIGNED_MEMCPY(&cookiecache[ninitiator].iaddr.in4, &ip->ip_src, sizeof(struct in_addr));
+ UNALIGNED_MEMCPY(&cookiecache[ninitiator].raddr.in4, &ip->ip_dst, sizeof(struct in_addr));
break;
#ifdef INET6
case 6:
- memset(&cookiecache[ninitiator].iaddr, 0,
- sizeof(cookiecache[ninitiator].iaddr));
- memset(&cookiecache[ninitiator].raddr, 0,
- sizeof(cookiecache[ninitiator].raddr));
-
ip6 = (struct ip6_hdr *)bp2;
- sin6 = (struct sockaddr_in6 *)&cookiecache[ninitiator].iaddr;
-#ifdef HAVE_SOCKADDR_SA_LEN
- sin6->sin6_len = sizeof(struct sockaddr_in6);
-#endif
- sin6->sin6_family = AF_INET6;
- memcpy(&sin6->sin6_addr, &ip6->ip6_src, sizeof(ip6->ip6_src));
- sin6 = (struct sockaddr_in6 *)&cookiecache[ninitiator].raddr;
-#ifdef HAVE_SOCKADDR_SA_LEN
- sin6->sin6_len = sizeof(struct sockaddr_in6);
-#endif
- sin6->sin6_family = AF_INET6;
- memcpy(&sin6->sin6_addr, &ip6->ip6_dst, sizeof(ip6->ip6_dst));
+ cookiecache[ninitiator].version = 6;
+ UNALIGNED_MEMCPY(&cookiecache[ninitiator].iaddr.in6, &ip6->ip6_src, sizeof(struct in6_addr));
+ UNALIGNED_MEMCPY(&cookiecache[ninitiator].raddr.in6, &ip6->ip6_dst, sizeof(struct in6_addr));
break;
#endif
default:
return;
}
- memcpy(&cookiecache[ninitiator].initiator, in, sizeof(*in));
+ UNALIGNED_MEMCPY(&cookiecache[ninitiator].initiator, in, sizeof(*in));
ninitiator = (ninitiator + 1) % MAXINITIATORS;
}
@@ -327,78 +819,42 @@ cookie_record(cookie_t *in, const u_char *bp2)
static int
cookie_sidecheck(int i, const u_char *bp2, int initiator)
{
- struct sockaddr_storage ss;
- struct sockaddr *sa;
struct ip *ip;
- struct sockaddr_in *sin;
#ifdef INET6
struct ip6_hdr *ip6;
- struct sockaddr_in6 *sin6;
#endif
- int salen;
- memset(&ss, 0, sizeof(ss));
ip = (struct ip *)bp2;
switch (IP_V(ip)) {
case 4:
- sin = (struct sockaddr_in *)&ss;
-#ifdef HAVE_SOCKADDR_SA_LEN
- sin->sin_len = sizeof(struct sockaddr_in);
-#endif
- sin->sin_family = AF_INET;
- memcpy(&sin->sin_addr, &ip->ip_src, sizeof(ip->ip_src));
+ if (cookiecache[i].version != 4)
+ return 0;
+ if (initiator) {
+ if (UNALIGNED_MEMCMP(&ip->ip_src, &cookiecache[i].iaddr.in4, sizeof(struct in_addr)) == 0)
+ return 1;
+ } else {
+ if (UNALIGNED_MEMCMP(&ip->ip_src, &cookiecache[i].raddr.in4, sizeof(struct in_addr)) == 0)
+ return 1;
+ }
break;
#ifdef INET6
case 6:
+ if (cookiecache[i].version != 6)
+ return 0;
ip6 = (struct ip6_hdr *)bp2;
- sin6 = (struct sockaddr_in6 *)&ss;
-#ifdef HAVE_SOCKADDR_SA_LEN
- sin6->sin6_len = sizeof(struct sockaddr_in6);
-#endif
- sin6->sin6_family = AF_INET6;
- memcpy(&sin6->sin6_addr, &ip6->ip6_src, sizeof(ip6->ip6_src));
+ if (initiator) {
+ if (UNALIGNED_MEMCMP(&ip6->ip6_src, &cookiecache[i].iaddr.in6, sizeof(struct in6_addr)) == 0)
+ return 1;
+ } else {
+ if (UNALIGNED_MEMCMP(&ip6->ip6_src, &cookiecache[i].raddr.in6, sizeof(struct in6_addr)) == 0)
+ return 1;
+ }
break;
-#endif
+#endif /* INET6 */
default:
- return 0;
+ break;
}
- sa = (struct sockaddr *)&ss;
- if (initiator) {
- if (sa->sa_family != ((struct sockaddr *)&cookiecache[i].iaddr)->sa_family)
- return 0;
-#ifdef HAVE_SOCKADDR_SA_LEN
- salen = sa->sa_len;
-#else
-#ifdef INET6
- if (sa->sa_family == AF_INET6)
- salen = sizeof(struct sockaddr_in6);
- else
- salen = sizeof(struct sockaddr);
-#else
- salen = sizeof(struct sockaddr);
-#endif
-#endif
- if (memcmp(&ss, &cookiecache[i].iaddr, salen) == 0)
- return 1;
- } else {
- if (sa->sa_family != ((struct sockaddr *)&cookiecache[i].raddr)->sa_family)
- return 0;
-#ifdef HAVE_SOCKADDR_SA_LEN
- salen = sa->sa_len;
-#else
-#ifdef INET6
- if (sa->sa_family == AF_INET6)
- salen = sizeof(struct sockaddr_in6);
- else
- salen = sizeof(struct sockaddr);
-#else
- salen = sizeof(struct sockaddr);
-#endif
-#endif
- if (memcmp(&ss, &cookiecache[i].raddr, salen) == 0)
- return 1;
- }
return 0;
}
@@ -428,7 +884,7 @@ trunc:
/*
* returns false if we run out of data buffer
*/
-static int ike_show_somedata(struct netdissect_options *ndo,
+static int ike_show_somedata(netdissect_options *ndo,
const u_char *cp, const u_char *ep)
{
/* there is too much data, just show some of it */
@@ -438,13 +894,13 @@ static int ike_show_somedata(struct netdissect_options *ndo,
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, "..."));
@@ -469,36 +925,34 @@ ikev1_attrmap_print(netdissect_options *ndo,
const u_char *p, const u_char *ep,
const struct attrmap *map, size_t nmap)
{
- u_int16_t *q;
int totlen;
- u_int32_t t, v;
+ uint32_t t, v;
- q = (u_int16_t *)p;
if (p[0] & 0x80)
totlen = 4;
else
- totlen = 4 + EXTRACT_16BITS(&q[1]);
+ totlen = 4 + EXTRACT_16BITS(&p[2]);
if (ep < p + totlen) {
ND_PRINT((ndo,"[|attr]"));
return ep + 1;
}
ND_PRINT((ndo,"("));
- t = EXTRACT_16BITS(&q[0]) & 0x7fff;
+ t = EXTRACT_16BITS(&p[0]) & 0x7fff;
if (map && t < nmap && map[t].type)
ND_PRINT((ndo,"type=%s ", map[t].type));
else
ND_PRINT((ndo,"type=#%d ", t));
if (p[0] & 0x80) {
ND_PRINT((ndo,"value="));
- v = EXTRACT_16BITS(&q[1]);
+ v = EXTRACT_16BITS(&p[2]);
if (map && t < nmap && v < map[t].nvalue && map[t].value[v])
ND_PRINT((ndo,"%s", map[t].value[v]));
else
- rawprint(ndo, (caddr_t)&q[1], 2);
+ rawprint(ndo, (caddr_t)&p[2], 2);
} else {
- ND_PRINT((ndo,"len=%d value=", EXTRACT_16BITS(&q[1])));
- rawprint(ndo, (caddr_t)&p[4], EXTRACT_16BITS(&q[1]));
+ ND_PRINT((ndo,"len=%d value=", EXTRACT_16BITS(&p[2])));
+ rawprint(ndo, (caddr_t)&p[4], EXTRACT_16BITS(&p[2]));
}
ND_PRINT((ndo,")"));
return p + totlen;
@@ -507,30 +961,28 @@ ikev1_attrmap_print(netdissect_options *ndo,
static const u_char *
ikev1_attr_print(netdissect_options *ndo, const u_char *p, const u_char *ep)
{
- u_int16_t *q;
int totlen;
- u_int32_t t;
+ uint32_t t;
- q = (u_int16_t *)p;
if (p[0] & 0x80)
totlen = 4;
else
- totlen = 4 + EXTRACT_16BITS(&q[1]);
+ totlen = 4 + EXTRACT_16BITS(&p[2]);
if (ep < p + totlen) {
ND_PRINT((ndo,"[|attr]"));
return ep + 1;
}
ND_PRINT((ndo,"("));
- t = EXTRACT_16BITS(&q[0]) & 0x7fff;
+ t = EXTRACT_16BITS(&p[0]) & 0x7fff;
ND_PRINT((ndo,"type=#%d ", t));
if (p[0] & 0x80) {
ND_PRINT((ndo,"value="));
- t = q[1];
- rawprint(ndo, (caddr_t)&q[1], 2);
+ t = p[2];
+ rawprint(ndo, (caddr_t)&p[2], 2);
} else {
- ND_PRINT((ndo,"len=%d value=", EXTRACT_16BITS(&q[1])));
- rawprint(ndo, (caddr_t)&p[2], EXTRACT_16BITS(&q[1]));
+ ND_PRINT((ndo,"len=%d value=", EXTRACT_16BITS(&p[2])));
+ rawprint(ndo, (caddr_t)&p[4], EXTRACT_16BITS(&p[2]));
}
ND_PRINT((ndo,")"));
return p + totlen;
@@ -540,13 +992,12 @@ static const u_char *
ikev1_sa_print(netdissect_options *ndo, u_char tpay _U_,
const struct isakmp_gen *ext,
u_int item_len _U_,
- const u_char *ep, u_int32_t phase, u_int32_t doi0 _U_,
- u_int32_t proto0, int depth)
+ const u_char *ep, uint32_t phase, uint32_t doi0 _U_,
+ uint32_t proto0, int depth)
{
const struct ikev1_pl_sa *p;
struct ikev1_pl_sa sa;
- const u_int32_t *q;
- u_int32_t doi, sit, ident;
+ uint32_t doi, sit, ident;
const u_char *cp, *np;
int t;
@@ -554,17 +1005,16 @@ ikev1_sa_print(netdissect_options *ndo, u_char tpay _U_,
p = (struct ikev1_pl_sa *)ext;
ND_TCHECK(*p);
- safememcpy(&sa, ext, sizeof(sa));
+ UNALIGNED_MEMCPY(&sa, ext, sizeof(sa));
doi = ntohl(sa.doi);
sit = ntohl(sa.sit);
if (doi != 1) {
ND_PRINT((ndo," doi=%d", doi));
- ND_PRINT((ndo," situation=%u", (u_int32_t)ntohl(sa.sit)));
+ ND_PRINT((ndo," situation=%u", (uint32_t)ntohl(sa.sit)));
return (u_char *)(p + 1);
}
ND_PRINT((ndo," doi=ipsec"));
- q = (u_int32_t *)&sa.sit;
ND_PRINT((ndo," situation="));
t = 0;
if (sit & 0x01) {
@@ -581,8 +1031,8 @@ ikev1_sa_print(netdissect_options *ndo, u_char tpay _U_,
np = (u_char *)ext + sizeof(sa);
if (sit != 0x01) {
ND_TCHECK2(*(ext + 1), sizeof(ident));
- safememcpy(&ident, ext + 1, sizeof(ident));
- ND_PRINT((ndo," ident=%u", (u_int32_t)ntohl(ident)));
+ UNALIGNED_MEMCPY(&ident, ext + 1, sizeof(ident));
+ ND_PRINT((ndo," ident=%u", (uint32_t)ntohl(ident)));
np += sizeof(ident);
}
@@ -601,8 +1051,8 @@ trunc:
static const u_char *
ikev1_p_print(netdissect_options *ndo, u_char tpay _U_,
const struct isakmp_gen *ext, u_int item_len _U_,
- const u_char *ep, u_int32_t phase, u_int32_t doi0,
- u_int32_t proto0 _U_, int depth)
+ const u_char *ep, uint32_t phase, uint32_t doi0,
+ uint32_t proto0 _U_, int depth)
{
const struct ikev1_pl_p *p;
struct ikev1_pl_p prop;
@@ -612,7 +1062,7 @@ ikev1_p_print(netdissect_options *ndo, u_char tpay _U_,
p = (struct ikev1_pl_p *)ext;
ND_TCHECK(*p);
- safememcpy(&prop, ext, sizeof(prop));
+ UNALIGNED_MEMCPY(&prop, ext, sizeof(prop));
ND_PRINT((ndo," #%d protoid=%s transform=%d",
prop.p_no, PROTOIDSTR(prop.prot_id), prop.num_t));
if (prop.spi_size) {
@@ -623,10 +1073,10 @@ ikev1_p_print(netdissect_options *ndo, u_char tpay _U_,
ext = (struct isakmp_gen *)((u_char *)(p + 1) + prop.spi_size);
ND_TCHECK(*ext);
-
+
cp = ikev1_sub_print(ndo, ISAKMP_NPTYPE_T, ext, ep, phase, doi0,
prop.prot_id, depth);
-
+
return cp;
trunc:
ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_P)));
@@ -686,7 +1136,7 @@ static const char *ipcomp_p_map[] = {
NULL, "oui", "deflate", "lzs",
};
-const struct attrmap ipsec_t_map[] = {
+static const struct attrmap ipsec_t_map[] = {
{ NULL, 0, { NULL } },
{ "lifetype", 3, { NULL, "sec", "kb", }, },
{ "life", 0, { NULL } },
@@ -713,7 +1163,7 @@ const struct attrmap ipsec_t_map[] = {
{ "privalg", 0, { NULL } },
};
-const struct attrmap encr_t_map[] = {
+static 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 */
@@ -724,7 +1174,7 @@ const struct attrmap encr_t_map[] = {
{ "keylen", 14, { NULL }},
};
-const struct attrmap oakley_t_map[] = {
+static const struct attrmap oakley_t_map[] = {
{ NULL, 0, { NULL } },
{ "enc", 8, { NULL, "1des", "idea", "blowfish", "rc5",
"3des", "cast", "aes", }, },
@@ -764,8 +1214,8 @@ const struct attrmap oakley_t_map[] = {
static const u_char *
ikev1_t_print(netdissect_options *ndo, u_char tpay _U_,
const struct isakmp_gen *ext, u_int item_len,
- const u_char *ep, u_int32_t phase _U_, u_int32_t doi _U_,
- u_int32_t proto, int depth _U_)
+ const u_char *ep, uint32_t phase _U_, uint32_t doi _U_,
+ uint32_t proto, int depth _U_)
{
const struct ikev1_pl_t *p;
struct ikev1_pl_t t;
@@ -779,7 +1229,7 @@ ikev1_t_print(netdissect_options *ndo, u_char tpay _U_,
p = (struct ikev1_pl_t *)ext;
ND_TCHECK(*p);
- safememcpy(&t, ext, sizeof(t));
+ UNALIGNED_MEMCPY(&t, ext, sizeof(t));
switch (proto) {
case 1:
@@ -833,15 +1283,15 @@ trunc:
static const u_char *
ikev1_ke_print(netdissect_options *ndo, u_char tpay _U_,
const struct isakmp_gen *ext, u_int item_len _U_,
- const u_char *ep _U_, u_int32_t phase _U_, u_int32_t doi _U_,
- u_int32_t proto _U_, int depth _U_)
+ const u_char *ep _U_, uint32_t phase _U_, uint32_t doi _U_,
+ uint32_t proto _U_, int depth _U_)
{
struct isakmp_gen e;
ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_KE)));
ND_TCHECK(*ext);
- safememcpy(&e, ext, sizeof(e));
+ UNALIGNED_MEMCPY(&e, ext, sizeof(e));
ND_PRINT((ndo," key len=%d", ntohs(e.len) - 4));
if (2 < ndo->ndo_vflag && 4 < ntohs(e.len)) {
ND_PRINT((ndo," "));
@@ -856,9 +1306,9 @@ trunc:
static const u_char *
ikev1_id_print(netdissect_options *ndo, u_char tpay _U_,
- const struct isakmp_gen *ext, u_int item_len _U_,
- const u_char *ep _U_, u_int32_t phase, u_int32_t doi _U_,
- u_int32_t proto _U_, int depth _U_)
+ const struct isakmp_gen *ext, u_int item_len,
+ const u_char *ep _U_, uint32_t phase, uint32_t doi _U_,
+ uint32_t proto _U_, int depth _U_)
{
#define USE_IPSECDOI_IN_PHASE1 1
const struct ikev1_pl_id *p;
@@ -878,7 +1328,7 @@ ikev1_id_print(netdissect_options *ndo, u_char tpay _U_,
p = (struct ikev1_pl_id *)ext;
ND_TCHECK(*p);
- safememcpy(&id, ext, sizeof(id));
+ UNALIGNED_MEMCPY(&id, ext, sizeof(id));
if (sizeof(*p) < item_len) {
data = (u_char *)(p + 1);
len = item_len - sizeof(*p);
@@ -897,7 +1347,7 @@ ikev1_id_print(netdissect_options *ndo, u_char tpay _U_,
default:
ND_PRINT((ndo," idtype=%s", STR_OR_ID(id.d.id_type, idtypestr)));
ND_PRINT((ndo," doi_data=%u",
- (u_int32_t)(ntohl(id.d.doi_data) & 0xffffff)));
+ (uint32_t)(ntohl(id.d.doi_data) & 0xffffff)));
break;
#ifdef USE_IPSECDOI_IN_PHASE1
@@ -911,22 +1361,14 @@ ikev1_id_print(netdissect_options *ndo, u_char tpay _U_,
p = (struct ipsecdoi_id *)ext;
ND_TCHECK(*p);
- safememcpy(&id, ext, sizeof(id));
+ UNALIGNED_MEMCPY(&id, ext, sizeof(id));
ND_PRINT((ndo," idtype=%s", STR_OR_ID(id.type, ipsecidtypestr)));
- if (id.proto_id) {
-#ifndef WIN32
- setprotoent(1);
-#endif /* WIN32 */
- pe = getprotobynumber(id.proto_id);
- if (pe)
- ND_PRINT((ndo," protoid=%s", pe->p_name));
-#ifndef WIN32
- endprotoent();
-#endif /* WIN32 */
- } else {
- /* it DOES NOT mean IPPROTO_IP! */
- ND_PRINT((ndo," protoid=%s", "0"));
- }
+ /* A protocol ID of 0 DOES NOT mean IPPROTO_IP! */
+ pe = id.proto_id ? getprotobynumber(id.proto_id) : NULL;
+ if (pe)
+ ND_PRINT((ndo," protoid=%s", pe->p_name));
+ else
+ ND_PRINT((ndo," protoid=%u", id.proto_id));
ND_PRINT((ndo," port=%d", ntohs(id.port)));
if (!len)
break;
@@ -938,7 +1380,7 @@ ikev1_id_print(netdissect_options *ndo, u_char tpay _U_,
if (len < 4)
ND_PRINT((ndo," len=%d [bad: < 4]", len));
else
- ND_PRINT((ndo," len=%d %s", len, ipaddr_string(data)));
+ ND_PRINT((ndo," len=%d %s", len, ipaddr_string(ndo, data)));
len = 0;
break;
case IPSECDOI_ID_FQDN:
@@ -947,7 +1389,7 @@ ikev1_id_print(netdissect_options *ndo, u_char tpay _U_,
int i;
ND_PRINT((ndo," len=%d ", len));
for (i = 0; i < len; i++)
- safeputchar(data[i]);
+ safeputchar(ndo, data[i]);
len = 0;
break;
}
@@ -959,7 +1401,7 @@ ikev1_id_print(netdissect_options *ndo, u_char tpay _U_,
else {
mask = data + sizeof(struct in_addr);
ND_PRINT((ndo," len=%d %s/%u.%u.%u.%u", len,
- ipaddr_string(data),
+ ipaddr_string(ndo, data),
mask[0], mask[1], mask[2], mask[3]));
}
len = 0;
@@ -970,20 +1412,23 @@ ikev1_id_print(netdissect_options *ndo, u_char tpay _U_,
if (len < 16)
ND_PRINT((ndo," len=%d [bad: < 16]", len));
else
- ND_PRINT((ndo," len=%d %s", len, ip6addr_string(data)));
+ ND_PRINT((ndo," len=%d %s", len, ip6addr_string(ndo, data)));
len = 0;
break;
case IPSECDOI_ID_IPV6_ADDR_SUBNET:
{
- const u_int32_t *mask;
+ const u_char *mask;
if (len < 20)
ND_PRINT((ndo," len=%d [bad: < 20]", len));
else {
- mask = (u_int32_t *)(data + sizeof(struct in6_addr));
+ mask = (u_char *)(data + sizeof(struct in6_addr));
/*XXX*/
- ND_PRINT((ndo," len=%d %s/0x%08x%08x%08x%08x", len,
- ip6addr_string(data),
- mask[0], mask[1], mask[2], mask[3]));
+ ND_PRINT((ndo," len=%d %s/0x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", len,
+ ip6addr_string(ndo, data),
+ mask[0], mask[1], mask[2], mask[3],
+ mask[4], mask[5], mask[6], mask[7],
+ mask[8], mask[9], mask[10], mask[11],
+ mask[12], mask[13], mask[14], mask[15]));
}
len = 0;
break;
@@ -994,8 +1439,8 @@ ikev1_id_print(netdissect_options *ndo, u_char tpay _U_,
ND_PRINT((ndo," len=%d [bad: < 8]", len));
else {
ND_PRINT((ndo," len=%d %s-%s", len,
- ipaddr_string(data),
- ipaddr_string(data + sizeof(struct in_addr))));
+ ipaddr_string(ndo, data),
+ ipaddr_string(ndo, data + sizeof(struct in_addr))));
}
len = 0;
break;
@@ -1005,8 +1450,8 @@ ikev1_id_print(netdissect_options *ndo, u_char tpay _U_,
ND_PRINT((ndo," len=%d [bad: < 32]", len));
else {
ND_PRINT((ndo," len=%d %s-%s", len,
- ip6addr_string(data),
- ip6addr_string(data + sizeof(struct in6_addr))));
+ ip6addr_string(ndo, data),
+ ip6addr_string(ndo, data + sizeof(struct in6_addr))));
}
len = 0;
break;
@@ -1036,9 +1481,9 @@ trunc:
static const u_char *
ikev1_cert_print(netdissect_options *ndo, u_char tpay _U_,
const struct isakmp_gen *ext, u_int item_len _U_,
- const u_char *ep _U_, u_int32_t phase _U_,
- u_int32_t doi0 _U_,
- u_int32_t proto0 _U_, int depth _U_)
+ const u_char *ep _U_, uint32_t phase _U_,
+ uint32_t doi0 _U_,
+ uint32_t proto0 _U_, int depth _U_)
{
const struct ikev1_pl_cert *p;
struct ikev1_pl_cert cert;
@@ -1052,7 +1497,7 @@ ikev1_cert_print(netdissect_options *ndo, u_char tpay _U_,
p = (struct ikev1_pl_cert *)ext;
ND_TCHECK(*p);
- safememcpy(&cert, ext, sizeof(cert));
+ UNALIGNED_MEMCPY(&cert, ext, sizeof(cert));
ND_PRINT((ndo," len=%d", item_len - 4));
ND_PRINT((ndo," type=%s", STR_OR_ID((cert.encode), certstr)));
if (2 < ndo->ndo_vflag && 4 < item_len) {
@@ -1069,8 +1514,8 @@ trunc:
static const u_char *
ikev1_cr_print(netdissect_options *ndo, u_char tpay _U_,
const struct isakmp_gen *ext, u_int item_len _U_,
- const u_char *ep _U_, u_int32_t phase _U_, u_int32_t doi0 _U_,
- u_int32_t proto0 _U_, int depth _U_)
+ const u_char *ep _U_, uint32_t phase _U_, uint32_t doi0 _U_,
+ uint32_t proto0 _U_, int depth _U_)
{
const struct ikev1_pl_cert *p;
struct ikev1_pl_cert cert;
@@ -1084,7 +1529,7 @@ ikev1_cr_print(netdissect_options *ndo, u_char tpay _U_,
p = (struct ikev1_pl_cert *)ext;
ND_TCHECK(*p);
- safememcpy(&cert, ext, sizeof(cert));
+ UNALIGNED_MEMCPY(&cert, ext, sizeof(cert));
ND_PRINT((ndo," len=%d", item_len - 4));
ND_PRINT((ndo," type=%s", STR_OR_ID((cert.encode), certstr)));
if (2 < ndo->ndo_vflag && 4 < item_len) {
@@ -1101,15 +1546,15 @@ trunc:
static const u_char *
ikev1_hash_print(netdissect_options *ndo, u_char tpay _U_,
const struct isakmp_gen *ext, u_int item_len _U_,
- const u_char *ep _U_, u_int32_t phase _U_, u_int32_t doi _U_,
- u_int32_t proto _U_, int depth _U_)
+ const u_char *ep _U_, uint32_t phase _U_, uint32_t doi _U_,
+ uint32_t proto _U_, int depth _U_)
{
struct isakmp_gen e;
ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_HASH)));
ND_TCHECK(*ext);
- safememcpy(&e, ext, sizeof(e));
+ UNALIGNED_MEMCPY(&e, ext, sizeof(e));
ND_PRINT((ndo," len=%d", ntohs(e.len) - 4));
if (2 < ndo->ndo_vflag && 4 < ntohs(e.len)) {
ND_PRINT((ndo," "));
@@ -1125,15 +1570,15 @@ trunc:
static const u_char *
ikev1_sig_print(netdissect_options *ndo, u_char tpay _U_,
const struct isakmp_gen *ext, u_int item_len _U_,
- const u_char *ep _U_, u_int32_t phase _U_, u_int32_t doi _U_,
- u_int32_t proto _U_, int depth _U_)
+ const u_char *ep _U_, uint32_t phase _U_, uint32_t doi _U_,
+ uint32_t proto _U_, int depth _U_)
{
struct isakmp_gen e;
ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_SIG)));
ND_TCHECK(*ext);
- safememcpy(&e, ext, sizeof(e));
+ UNALIGNED_MEMCPY(&e, ext, sizeof(e));
ND_PRINT((ndo," len=%d", ntohs(e.len) - 4));
if (2 < ndo->ndo_vflag && 4 < ntohs(e.len)) {
ND_PRINT((ndo," "));
@@ -1151,15 +1596,15 @@ 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_)
+ uint32_t phase _U_, uint32_t doi _U_,
+ uint32_t proto _U_, int depth _U_)
{
struct isakmp_gen e;
ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_NONCE)));
ND_TCHECK(*ext);
- safememcpy(&e, ext, sizeof(e));
+ UNALIGNED_MEMCPY(&e, ext, sizeof(e));
ND_PRINT((ndo," n len=%d", ntohs(e.len) - 4));
if (2 < ndo->ndo_vflag && 4 < ntohs(e.len)) {
ND_PRINT((ndo," "));
@@ -1179,14 +1624,14 @@ trunc:
static const u_char *
ikev1_n_print(netdissect_options *ndo, u_char tpay _U_,
const struct isakmp_gen *ext, u_int item_len,
- const u_char *ep, u_int32_t phase, u_int32_t doi0 _U_,
- u_int32_t proto0 _U_, int depth)
+ const u_char *ep, uint32_t phase, uint32_t doi0 _U_,
+ uint32_t proto0 _U_, int depth)
{
struct ikev1_pl_n *p, n;
const u_char *cp;
u_char *ep2;
- u_int32_t doi;
- u_int32_t proto;
+ uint32_t doi;
+ uint32_t proto;
static const char *notify_error_str[] = {
NULL, "INVALID-PAYLOAD-TYPE",
"DOI-NOT-SUPPORTED", "SITUATION-NOT-SUPPORTED",
@@ -1237,7 +1682,7 @@ ikev1_n_print(netdissect_options *ndo, u_char tpay _U_,
p = (struct ikev1_pl_n *)ext;
ND_TCHECK(*p);
- safememcpy(&n, ext, sizeof(n));
+ UNALIGNED_MEMCPY(&n, ext, sizeof(n));
doi = ntohl(n.doi);
proto = n.prot_id;
if (doi != 1) {
@@ -1295,7 +1740,7 @@ ikev1_n_print(netdissect_options *ndo, u_char tpay _U_,
}
case IPSECDOI_NTYPE_REPLAY_STATUS:
ND_PRINT((ndo,"replay detection %sabled",
- (*(u_int32_t *)cp) ? "en" : "dis"));
+ EXTRACT_32BITS(cp) ? "en" : "dis"));
break;
case ISAKMP_NTYPE_NO_PROPOSAL_CHOSEN:
if (ikev1_sub_print(ndo, ISAKMP_NPTYPE_SA,
@@ -1320,21 +1765,21 @@ trunc:
static const u_char *
ikev1_d_print(netdissect_options *ndo, u_char tpay _U_,
const struct isakmp_gen *ext, u_int item_len _U_,
- const u_char *ep _U_, u_int32_t phase _U_, u_int32_t doi0 _U_,
- u_int32_t proto0 _U_, int depth _U_)
+ const u_char *ep _U_, uint32_t phase _U_, uint32_t doi0 _U_,
+ uint32_t proto0 _U_, int depth _U_)
{
const struct ikev1_pl_d *p;
struct ikev1_pl_d d;
- const u_int8_t *q;
- u_int32_t doi;
- u_int32_t proto;
+ const uint8_t *q;
+ uint32_t doi;
+ uint32_t proto;
int i;
ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_D)));
p = (struct ikev1_pl_d *)ext;
ND_TCHECK(*p);
- safememcpy(&d, ext, sizeof(d));
+ UNALIGNED_MEMCPY(&d, ext, sizeof(d));
doi = ntohl(d.doi);
proto = d.prot_id;
if (doi != 1) {
@@ -1347,7 +1792,7 @@ ikev1_d_print(netdissect_options *ndo, u_char tpay _U_,
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);
+ q = (uint8_t *)(p + 1);
for (i = 0; i < ntohs(d.num_spi); i++) {
if (i != 0)
ND_PRINT((ndo,","));
@@ -1365,15 +1810,15 @@ static const u_char *
ikev1_vid_print(netdissect_options *ndo, u_char tpay _U_,
const struct isakmp_gen *ext,
u_int item_len _U_, const u_char *ep _U_,
- u_int32_t phase _U_, u_int32_t doi _U_,
- u_int32_t proto _U_, int depth _U_)
+ uint32_t phase _U_, uint32_t doi _U_,
+ uint32_t proto _U_, int depth _U_)
{
struct isakmp_gen e;
ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_VID)));
ND_TCHECK(*ext);
- safememcpy(&e, ext, sizeof(e));
+ UNALIGNED_MEMCPY(&e, ext, sizeof(e));
ND_PRINT((ndo," len=%d", ntohs(e.len) - 4));
if (2 < ndo->ndo_vflag && 4 < ntohs(e.len)) {
ND_PRINT((ndo," "));
@@ -1405,7 +1850,7 @@ ikev2_gen_print(netdissect_options *ndo, u_char tpay,
struct isakmp_gen e;
ND_TCHECK(*ext);
- safememcpy(&e, ext, sizeof(e));
+ UNALIGNED_MEMCPY(&e, ext, sizeof(e));
ikev2_pay_print(ndo, NPSTR(tpay), e.critical);
ND_PRINT((ndo," len=%d", ntohs(e.len) - 4));
@@ -1423,12 +1868,12 @@ trunc:
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 u_char *ep, uint32_t phase _U_, uint32_t doi _U_,
+ uint32_t proto _U_, int depth _U_)
{
const struct ikev2_t *p;
struct ikev2_t t;
- u_int16_t t_id;
+ uint16_t t_id;
const u_char *cp;
const char *idstr;
const struct attrmap *map;
@@ -1437,11 +1882,11 @@ ikev2_t_print(netdissect_options *ndo, u_char tpay _U_, int pcount,
p = (struct ikev2_t *)ext;
ND_TCHECK(*p);
- safememcpy(&t, ext, sizeof(t));
+ UNALIGNED_MEMCPY(&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;
@@ -1501,8 +1946,8 @@ trunc:
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 u_char *ep, uint32_t phase, uint32_t doi0,
+ uint32_t proto0 _U_, int depth)
{
const struct ikev2_p *p;
struct ikev2_p prop;
@@ -1510,7 +1955,7 @@ ikev2_p_print(netdissect_options *ndo, u_char tpay _U_, int pcount _U_,
p = (struct ikev2_p *)ext;
ND_TCHECK(*p);
- safememcpy(&prop, ext, sizeof(prop));
+ UNALIGNED_MEMCPY(&prop, ext, sizeof(prop));
ikev2_pay_print(ndo, NPSTR(ISAKMP_NPTYPE_P), prop.h.critical);
ND_PRINT((ndo," #%u protoid=%s transform=%d len=%u",
@@ -1527,7 +1972,7 @@ ikev2_p_print(netdissect_options *ndo, u_char tpay _U_, int pcount _U_,
cp = ikev2_sub_print(ndo, NULL, ISAKMP_NPTYPE_T, ext, ep, phase, doi0,
prop.prot_id, depth);
-
+
return cp;
trunc:
ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_P)));
@@ -1535,17 +1980,17 @@ trunc:
}
static const u_char *
-ikev2_sa_print(netdissect_options *ndo, u_char tpay,
+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_)
+ uint32_t phase _U_, uint32_t doi _U_,
+ uint32_t proto _U_, int depth _U_)
{
struct isakmp_gen e;
int osa_length, sa_length;
ND_TCHECK(*ext1);
- safememcpy(&e, ext1, sizeof(e));
+ UNALIGNED_MEMCPY(&e, ext1, sizeof(e));
ikev2_pay_print(ndo, "sa", e.critical);
osa_length= ntohs(e.len);
@@ -1563,23 +2008,23 @@ trunc:
}
static const u_char *
-ikev2_ke_print(netdissect_options *ndo, u_char tpay,
+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_)
+ uint32_t phase _U_, uint32_t doi _U_,
+ uint32_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));
+ UNALIGNED_MEMCPY(&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))
@@ -1592,11 +2037,11 @@ trunc:
}
static const u_char *
-ikev2_ID_print(netdissect_options *ndo, u_char tpay,
+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_)
+ uint32_t phase _U_, uint32_t doi _U_,
+ uint32_t proto _U_, int depth _U_)
{
struct ikev2_id id;
int id_len, idtype_len, i;
@@ -1604,7 +2049,7 @@ ikev2_ID_print(netdissect_options *ndo, u_char tpay,
unsigned char *typedata;
ND_TCHECK(*ext);
- safememcpy(&id, ext, sizeof(id));
+ UNALIGNED_MEMCPY(&id, ext, sizeof(id));
ikev2_pay_print(ndo, NPSTR(tpay), id.h.critical);
id_len = ntohs(id.h.len);
@@ -1655,7 +2100,7 @@ ikev2_ID_print(netdissect_options *ndo, u_char tpay,
if(dumpascii) {
ND_TCHECK2(*typedata, idtype_len);
for(i=0; i<idtype_len; i++) {
- if(isprint(typedata[i])) {
+ if(ND_ISPRINT(typedata[i])) {
ND_PRINT((ndo, "%c", typedata[i]));
} else {
ND_PRINT((ndo, "."));
@@ -1674,31 +2119,31 @@ trunc:
}
static const u_char *
-ikev2_cert_print(netdissect_options *ndo, u_char tpay,
+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_)
+ uint32_t phase _U_, uint32_t doi _U_,
+ uint32_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,
+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_)
+ uint32_t phase _U_, uint32_t doi _U_,
+ uint32_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,
+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_)
+ uint32_t phase _U_, uint32_t doi _U_,
+ uint32_t proto _U_, int depth _U_)
{
struct ikev2_auth a;
const char *v2_auth[]={ "invalid", "rsasig",
@@ -1707,11 +2152,11 @@ ikev2_auth_print(netdissect_options *ndo, u_char tpay,
unsigned int len;
ND_TCHECK(*ext);
- safememcpy(&a, ext, sizeof(a));
+ UNALIGNED_MEMCPY(&a, ext, sizeof(a));
ikev2_pay_print(ndo, NPSTR(tpay), a.h.critical);
len = ntohs(a.h.len);
- ND_PRINT((ndo," len=%d method=%s", len-4,
+ ND_PRINT((ndo," len=%d method=%s", len-4,
STR_OR_ID(a.auth_method, v2_auth)));
if (1 < ndo->ndo_vflag && 4 < len) {
@@ -1730,16 +2175,16 @@ trunc:
}
static const u_char *
-ikev2_nonce_print(netdissect_options *ndo, u_char tpay,
+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_)
+ uint32_t phase _U_, uint32_t doi _U_,
+ uint32_t proto _U_, int depth _U_)
{
struct isakmp_gen e;
ND_TCHECK(*ext);
- safememcpy(&e, ext, sizeof(e));
+ UNALIGNED_MEMCPY(&e, ext, sizeof(e));
ikev2_pay_print(ndo, "nonce", e.critical);
ND_PRINT((ndo," len=%d", ntohs(e.len) - 4));
@@ -1760,22 +2205,21 @@ trunc:
/* notify payloads */
static const u_char *
-ikev2_n_print(netdissect_options *ndo, u_char tpay _U_,
+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_)
+ uint32_t phase _U_, uint32_t doi _U_,
+ uint32_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;
+ uint32_t type;
p = (struct ikev2_n *)ext;
ND_TCHECK(*p);
- safememcpy(&n, ext, sizeof(n));
+ UNALIGNED_MEMCPY(&n, ext, sizeof(n));
ikev2_pay_print(ndo, NPSTR(ISAKMP_NPTYPE_N), n.h.critical);
showspi = 1;
@@ -1849,7 +2293,7 @@ ikev2_n_print(netdissect_options *ndo, u_char tpay _U_,
showspi = 0;
break;
- case IV2_NOTIFY_FAILED_CP_REQUIRED:
+ case IV2_NOTIFY_FAILED_CP_REQUIRED:
notify_name = "failed:cp_required";
showspi = 0;
break;
@@ -1864,7 +2308,7 @@ ikev2_n_print(netdissect_options *ndo, u_char tpay _U_,
showspi = 0;
break;
- case IV2_NOTIFY_SET_WINDOW_SIZE:
+ case IV2_NOTIFY_SET_WINDOW_SIZE:
notify_name = "set_window_size";
showspi = 0;
break;
@@ -1874,7 +2318,7 @@ ikev2_n_print(netdissect_options *ndo, u_char tpay _U_,
showspi = 0;
break;
- case IV2_NOTIFY_IPCOMP_SUPPORTED:
+ case IV2_NOTIFY_IPCOMP_SUPPORTED:
notify_name = "ipcomp_supported";
showspi = 0;
break;
@@ -1936,7 +2380,7 @@ ikev2_n_print(netdissect_options *ndo, u_char tpay _U_,
if(notify_name) {
ND_PRINT((ndo," type=%u(%s)", type, notify_name));
}
-
+
if (showspi && n.spi_size) {
ND_PRINT((ndo," spi="));
@@ -1945,7 +2389,6 @@ ikev2_n_print(netdissect_options *ndo, u_char tpay _U_,
}
cp = (u_char *)(p + 1) + n.spi_size;
- ep2 = (u_char *)p + item_len;
if(3 < ndo->ndo_vflag) {
showdata = 1;
@@ -1961,7 +2404,7 @@ ikev2_n_print(netdissect_options *ndo, u_char tpay _U_,
} 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)));
@@ -1969,36 +2412,36 @@ trunc:
}
static const u_char *
-ikev2_d_print(netdissect_options *ndo, u_char tpay,
+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_)
+ uint32_t phase _U_, uint32_t doi _U_,
+ uint32_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,
+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_)
+ uint32_t phase _U_, uint32_t doi _U_,
+ uint32_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));
+ UNALIGNED_MEMCPY(&e, ext, sizeof(e));
ikev2_pay_print(ndo, NPSTR(tpay), e.critical);
ND_PRINT((ndo," len=%d vid=", ntohs(e.len) - 4));
-
+
vid = (const u_char *)(ext+1);
len = ntohs(e.len) - 4;
ND_TCHECK2(*vid, len);
for(i=0; i<len; i++) {
- if(isprint(vid[i])) ND_PRINT((ndo, "%c", vid[i]));
+ if(ND_ISPRINT(vid[i])) ND_PRINT((ndo, "%c", vid[i]));
else ND_PRINT((ndo, "."));
}
if (2 < ndo->ndo_vflag && 4 < len) {
@@ -2013,11 +2456,11 @@ trunc:
}
static const u_char *
-ikev2_TS_print(netdissect_options *ndo, u_char tpay,
+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_)
+ uint32_t phase _U_, uint32_t doi _U_,
+ uint32_t proto _U_, int depth _U_)
{
return ikev2_gen_print(ndo, tpay, ext);
}
@@ -2028,21 +2471,21 @@ ikev2_e_print(netdissect_options *ndo,
_U_
#endif
struct isakmp *base,
- u_char tpay,
+ u_char tpay,
const struct isakmp_gen *ext,
u_int item_len _U_, const u_char *ep _U_,
#ifndef HAVE_LIBCRYPTO
_U_
#endif
- u_int32_t phase,
+ uint32_t phase,
#ifndef HAVE_LIBCRYPTO
_U_
#endif
- u_int32_t doi,
+ uint32_t doi,
#ifndef HAVE_LIBCRYPTO
_U_
#endif
- u_int32_t proto,
+ uint32_t proto,
#ifndef HAVE_LIBCRYPTO
_U_
#endif
@@ -2053,7 +2496,7 @@ ikev2_e_print(netdissect_options *ndo,
volatile int dlen;
ND_TCHECK(*ext);
- safememcpy(&e, ext, sizeof(e));
+ UNALIGNED_MEMCPY(&e, ext, sizeof(e));
ikev2_pay_print(ndo, NPSTR(tpay), e.critical);
dlen = ntohs(e.len)-4;
@@ -2067,14 +2510,14 @@ ikev2_e_print(netdissect_options *ndo,
dat = (u_char *)(ext+1);
ND_TCHECK2(*dat, dlen);
-
+
#ifdef HAVE_LIBCRYPTO
/* try to decypt it! */
if(esp_print_decrypt_buffer_by_ikev2(ndo,
base->flags & ISAKMP_FLAG_I,
base->i_ck, base->r_ck,
dat, dat+dlen)) {
-
+
ext = (const struct isakmp_gen *)ndo->ndo_packetp;
/* got it decrypted, print stuff inside. */
@@ -2082,7 +2525,7 @@ ikev2_e_print(netdissect_options *ndo,
phase, doi, proto, depth+1);
}
#endif
-
+
/* always return NULL, because E must be at end, and NP refers
* to what was inside.
@@ -2094,21 +2537,21 @@ trunc:
}
static const u_char *
-ikev2_cp_print(netdissect_options *ndo, u_char tpay,
+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_)
+ uint32_t phase _U_, uint32_t doi _U_,
+ uint32_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,
+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_)
+ uint32_t phase _U_, uint32_t doi _U_,
+ uint32_t proto _U_, int depth _U_)
{
return ikev2_gen_print(ndo, tpay, ext);
}
@@ -2117,7 +2560,7 @@ 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)
+ uint32_t phase, uint32_t doi, uint32_t proto, int depth)
{
const u_char *cp;
struct isakmp_gen e;
@@ -2125,7 +2568,7 @@ ike_sub0_print(netdissect_options *ndo,
cp = (u_char *)ext;
ND_TCHECK(*ext);
- safememcpy(&e, ext, sizeof(e));
+ UNALIGNED_MEMCPY(&e, ext, sizeof(e));
/*
* Since we can't have a payload length of less than 4 bytes,
@@ -2157,7 +2600,7 @@ trunc:
static const u_char *
ikev1_sub_print(netdissect_options *ndo,
u_char np, const struct isakmp_gen *ext, const u_char *ep,
- u_int32_t phase, u_int32_t doi, u_int32_t proto, int depth)
+ uint32_t phase, uint32_t doi, uint32_t proto, int depth)
{
const u_char *cp;
int i;
@@ -2167,8 +2610,8 @@ ikev1_sub_print(netdissect_options *ndo,
while (np) {
ND_TCHECK(*ext);
-
- safememcpy(&e, ext, sizeof(e));
+
+ UNALIGNED_MEMCPY(&e, ext, sizeof(e));
ND_TCHECK2(*ext, ntohs(e.len));
@@ -2203,17 +2646,6 @@ numstr(int x)
return buf;
}
-/*
- * some compiler tries to optimize memcpy(), using the alignment constraint
- * on the argument pointer type. by using this function, we try to avoid the
- * optimization.
- */
-static void
-safememcpy(void *p, const void *q, size_t l)
-{
- memcpy(p, q, l);
-}
-
static void
ikev1_print(netdissect_options *ndo,
const u_char *bp, u_int length,
@@ -2224,16 +2656,16 @@ ikev1_print(netdissect_options *ndo,
u_char np;
int i;
int phase;
-
+
p = (const struct isakmp *)bp;
ep = ndo->ndo_snapend;
-
- phase = (*(u_int32_t *)base->msgid == 0) ? 1 : 2;
+
+ phase = (EXTRACT_32BITS(base->msgid) == 0) ? 1 : 2;
if (phase == 1)
ND_PRINT((ndo," phase %d", phase));
else
ND_PRINT((ndo," phase %d/others", phase));
-
+
i = cookie_find(&base->i_ck);
if (i < 0) {
if (iszero((u_char *)&base->r_ck, sizeof(base->r_ck))) {
@@ -2251,19 +2683,18 @@ ikev1_print(netdissect_options *ndo,
else
ND_PRINT((ndo," ?"));
}
-
+
ND_PRINT((ndo," %s", ETYPESTR(base->etype)));
if (base->flags) {
ND_PRINT((ndo,"[%s%s]", base->flags & ISAKMP_FLAG_E ? "E" : "",
base->flags & ISAKMP_FLAG_C ? "C" : ""));
}
-
+
if (ndo->ndo_vflag) {
const struct isakmp_gen *ext;
- int nparen;
-
+
ND_PRINT((ndo,":"));
-
+
/* regardless of phase... */
if (base->flags & ISAKMP_FLAG_E) {
/*
@@ -2273,19 +2704,18 @@ ikev1_print(netdissect_options *ndo,
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));
+ (uint32_t)ntohl(base->len), length));
}
}
}
@@ -2294,7 +2724,7 @@ static const u_char *
ikev2_sub0_print(netdissect_options *ndo, struct isakmp *base,
u_char np, int pcount,
const struct isakmp_gen *ext, const u_char *ep,
- u_int32_t phase, u_int32_t doi, u_int32_t proto, int depth)
+ uint32_t phase, uint32_t doi, uint32_t proto, int depth)
{
const u_char *cp;
struct isakmp_gen e;
@@ -2302,7 +2732,7 @@ ikev2_sub0_print(netdissect_options *ndo, struct isakmp *base,
cp = (u_char *)ext;
ND_TCHECK(*ext);
- safememcpy(&e, ext, sizeof(e));
+ UNALIGNED_MEMCPY(&e, ext, sizeof(e));
/*
* Since we can't have a payload length of less than 4 bytes,
@@ -2345,7 +2775,7 @@ static const u_char *
ikev2_sub_print(netdissect_options *ndo,
struct isakmp *base,
u_char np, const struct isakmp_gen *ext, const u_char *ep,
- u_int32_t phase, u_int32_t doi, u_int32_t proto, int depth)
+ uint32_t phase, uint32_t doi, uint32_t proto, int depth)
{
const u_char *cp;
int i;
@@ -2353,12 +2783,12 @@ ikev2_sub_print(netdissect_options *ndo,
struct isakmp_gen e;
cp = (const u_char *)ext;
- pcount = 0;
+ pcount = 0;
while (np) {
pcount++;
ND_TCHECK(*ext);
-
- safememcpy(&e, ext, sizeof(e));
+
+ UNALIGNED_MEMCPY(&e, ext, sizeof(e));
ND_TCHECK2(*ext, ntohs(e.len));
@@ -2399,7 +2829,7 @@ ikev2_print(netdissect_options *ndo,
p = (const struct isakmp *)bp;
ep = ndo->ndo_snapend;
- phase = (*(u_int32_t *)base->msgid == 0) ? 1 : 2;
+ phase = (EXTRACT_32BITS(base->msgid) == 0) ? 1 : 2;
if (phase == 1)
ND_PRINT((ndo, " parent_sa"));
else
@@ -2415,7 +2845,6 @@ ikev2_print(netdissect_options *ndo,
if (ndo->ndo_vflag) {
const struct isakmp_gen *ext;
- int nparen;
ND_PRINT((ndo, ":"));
@@ -2429,7 +2858,6 @@ ikev2_print(netdissect_options *ndo,
goto done;
}
- nparen = 0;
CHECKLEN(p + 1, base->np)
np = base->np;
@@ -2441,7 +2869,7 @@ 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));
+ (uint32_t)ntohl(base->len), length));
}
}
}
@@ -2472,7 +2900,7 @@ isakmp_print(netdissect_options *ndo,
return;
}
- safememcpy(&base, p, sizeof(base));
+ UNALIGNED_MEMCPY(&base, p, sizeof(base));
ND_PRINT((ndo,"isakmp"));
major = (base.vers & ISAKMP_VERS_MAJOR)
@@ -2513,8 +2941,6 @@ isakmp_rfc3948_print(netdissect_options *ndo,
const u_char *bp, u_int length,
const u_char *bp2)
{
- const u_char *ep;
- ep = ndo->ndo_snapend;
if(length == 1 && bp[0]==0xff) {
ND_PRINT((ndo, "isakmp-nat-keep-alive"));
@@ -2524,7 +2950,7 @@ isakmp_rfc3948_print(netdissect_options *ndo,
if(length < 4) {
goto trunc;
}
-
+
/*
* see if this is an IKE packet
*/
@@ -2548,7 +2974,7 @@ isakmp_rfc3948_print(netdissect_options *ndo,
bp += advance;
length -= advance + padlen;
nh = enh & 0xff;
-
+
ip_print_inner(ndo, bp, length, nh, bp2);
return;
}
@@ -2566,5 +2992,5 @@ trunc:
*/
-
+
diff --git a/contrib/tcpdump/print-isoclns.c b/contrib/tcpdump/print-isoclns.c
index 2bbd46d143f0..0f9ba3d769ca 100644
--- a/contrib/tcpdump/print-isoclns.c
+++ b/contrib/tcpdump/print-isoclns.c
@@ -26,23 +26,17 @@
* $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.165 2008-08-16 13:38:15 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
#include <string.h>
#include "interface.h"
#include "addrtoname.h"
-#include "ethertype.h"
#include "ether.h"
#include "nlpid.h"
#include "extract.h"
@@ -78,7 +72,7 @@ static const char rcsid[] _U_ =
#define ISIS_PDU_L1_PSNP 26
#define ISIS_PDU_L2_PSNP 27
-static struct tok isis_pdu_values[] = {
+static const struct tok isis_pdu_values[] = {
{ ISIS_PDU_L1_LAN_IIH, "L1 Lan IIH"},
{ ISIS_PDU_L2_LAN_IIH, "L2 Lan IIH"},
{ ISIS_PDU_PTP_IIH, "p2p IIH"},
@@ -148,7 +142,7 @@ static struct tok isis_pdu_values[] = {
#define ISIS_TLV_VENDOR_PRIVATE 250 /* draft-ietf-isis-experimental-tlv-01 */
#define ISIS_TLV_VENDOR_PRIVATE_MINLEN 3
-static struct tok isis_tlv_values[] = {
+static const struct tok isis_tlv_values[] = {
{ ISIS_TLV_AREA_ADDR, "Area address(es)"},
{ ISIS_TLV_IS_REACH, "IS Reachability"},
{ ISIS_TLV_ESNEIGH, "ES Neighbor(s)"},
@@ -200,7 +194,7 @@ static struct tok isis_tlv_values[] = {
#define ESIS_OPTION_ADDRESS_MASK 225 /* iso9542 */
#define ESIS_OPTION_SNPA_MASK 226 /* iso9542 */
-static struct tok esis_option_values[] = {
+static const struct tok esis_option_values[] = {
{ ESIS_OPTION_PROTOCOLS, "Protocols supported"},
{ ESIS_OPTION_QOS_MAINTENANCE, "QoS Maintenance" },
{ ESIS_OPTION_SECURITY, "Security" },
@@ -219,7 +213,7 @@ static struct tok esis_option_values[] = {
#define CLNP_OPTION_PADDING 204 /* iso8473 */
#define CLNP_OPTION_PRIORITY 205 /* iso8473 */
-static struct tok clnp_option_values[] = {
+static const struct tok clnp_option_values[] = {
{ CLNP_OPTION_DISCARD_REASON, "Discard Reason"},
{ CLNP_OPTION_PRIORITY, "Priority"},
{ CLNP_OPTION_QOS_MAINTENANCE, "QoS Maintenance"},
@@ -230,7 +224,7 @@ static struct tok clnp_option_values[] = {
{ 0, NULL }
};
-static struct tok clnp_option_rfd_class_values[] = {
+static const struct tok clnp_option_rfd_class_values[] = {
{ 0x0, "General"},
{ 0x8, "Address"},
{ 0x9, "Source Routeing"},
@@ -240,7 +234,7 @@ static struct tok clnp_option_rfd_class_values[] = {
{ 0, NULL }
};
-static struct tok clnp_option_rfd_general_values[] = {
+static const struct tok clnp_option_rfd_general_values[] = {
{ 0x0, "Reason not specified"},
{ 0x1, "Protocol procedure error"},
{ 0x2, "Incorrect checksum"},
@@ -252,13 +246,13 @@ static struct tok clnp_option_rfd_general_values[] = {
{ 0, NULL }
};
-static struct tok clnp_option_rfd_address_values[] = {
+static const struct tok clnp_option_rfd_address_values[] = {
{ 0x0, "Destination address unreachable"},
{ 0x1, "Destination address unknown"},
{ 0, NULL }
};
-static struct tok clnp_option_rfd_source_routeing_values[] = {
+static const struct tok clnp_option_rfd_source_routeing_values[] = {
{ 0x0, "Unspecified source routeing error"},
{ 0x1, "Syntax error in source routeing field"},
{ 0x2, "Unknown address in source routeing field"},
@@ -266,13 +260,13 @@ static struct tok clnp_option_rfd_source_routeing_values[] = {
{ 0, NULL }
};
-static struct tok clnp_option_rfd_lifetime_values[] = {
+static const struct tok clnp_option_rfd_lifetime_values[] = {
{ 0x0, "Lifetime expired while data unit in transit"},
{ 0x1, "Lifetime expired during reassembly"},
{ 0, NULL }
};
-static struct tok clnp_option_rfd_pdu_discard_values[] = {
+static const struct tok clnp_option_rfd_pdu_discard_values[] = {
{ 0x0, "Unsupported option not specified"},
{ 0x1, "Unsupported protocol version"},
{ 0x2, "Unsupported security option"},
@@ -281,13 +275,13 @@ static struct tok clnp_option_rfd_pdu_discard_values[] = {
{ 0, NULL }
};
-static struct tok clnp_option_rfd_reassembly_values[] = {
+static const struct tok clnp_option_rfd_reassembly_values[] = {
{ 0x0, "Reassembly interference"},
{ 0, NULL }
};
/* array of 16 error-classes */
-static struct tok *clnp_option_rfd_error_class[] = {
+static const struct tok *clnp_option_rfd_error_class[] = {
clnp_option_rfd_general_values,
NULL,
NULL,
@@ -312,26 +306,26 @@ static struct tok *clnp_option_rfd_error_class[] = {
#define CLNP_OPTION_SCOPE_DA_SPEC 0x80
#define CLNP_OPTION_SCOPE_GLOBAL 0xc0
-static struct tok clnp_option_scope_values[] = {
+static const struct tok clnp_option_scope_values[] = {
{ CLNP_OPTION_SCOPE_SA_SPEC, "Source Address Specific"},
{ CLNP_OPTION_SCOPE_DA_SPEC, "Destination Address Specific"},
{ CLNP_OPTION_SCOPE_GLOBAL, "Globally unique"},
{ 0, NULL }
};
-static struct tok clnp_option_sr_rr_values[] = {
+static const struct tok clnp_option_sr_rr_values[] = {
{ 0x0, "partial"},
{ 0x1, "complete"},
{ 0, NULL }
};
-static struct tok clnp_option_sr_rr_string_values[] = {
+static const struct tok clnp_option_sr_rr_string_values[] = {
{ CLNP_OPTION_SOURCE_ROUTING, "source routing"},
{ CLNP_OPTION_ROUTE_RECORDING, "recording of route in progress"},
{ 0, NULL }
};
-static struct tok clnp_option_qos_global_values[] = {
+static const struct tok clnp_option_qos_global_values[] = {
{ 0x20, "reserved"},
{ 0x10, "sequencing vs. delay"},
{ 0x08, "congested"},
@@ -358,7 +352,7 @@ static struct tok clnp_option_qos_global_values[] = {
#define ISIS_SUBTLV_SPB_METRIC 29 /* rfc6329 */
-static struct tok isis_ext_is_reach_subtlv_values[] = {
+static const struct tok isis_ext_is_reach_subtlv_values[] = {
{ ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP, "Administrative groups" },
{ ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID, "Link Local/Remote Identifier" },
{ ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID, "Link Remote Identifier" },
@@ -387,14 +381,14 @@ static struct tok isis_ext_is_reach_subtlv_values[] = {
#define ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64 2 /* draft-ietf-isis-admin-tags-01 */
#define ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR 117 /* draft-ietf-isis-wg-multi-topology-05 */
-static struct tok isis_ext_ip_reach_subtlv_values[] = {
+static const struct tok isis_ext_ip_reach_subtlv_values[] = {
{ ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32, "32-Bit Administrative tag" },
{ ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64, "64-Bit Administrative tag" },
{ ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR, "Management Prefix Color" },
{ 0, NULL }
};
-static struct tok isis_subtlv_link_attribute_values[] = {
+static const struct tok isis_subtlv_link_attribute_values[] = {
{ 0x01, "Local Protection Available" },
{ 0x02, "Link excluded from local protection path" },
{ 0x04, "Local maintenance required"},
@@ -407,7 +401,7 @@ static struct tok isis_subtlv_link_attribute_values[] = {
#define ISIS_SUBTLV_AUTH_MD5_LEN 16
#define ISIS_SUBTLV_AUTH_PRIVATE 255
-static struct tok isis_subtlv_auth_values[] = {
+static const struct tok isis_subtlv_auth_values[] = {
{ ISIS_SUBTLV_AUTH_SIMPLE, "simple text password"},
{ ISIS_SUBTLV_AUTH_GENERIC, "Generic Crypto key-id"},
{ ISIS_SUBTLV_AUTH_MD5, "HMAC-MD5 password"},
@@ -419,7 +413,7 @@ static struct tok isis_subtlv_auth_values[] = {
#define ISIS_SUBTLV_IDRP_LOCAL 1
#define ISIS_SUBTLV_IDRP_ASN 2
-static struct tok isis_subtlv_idrp_values[] = {
+static const struct tok isis_subtlv_idrp_values[] = {
{ ISIS_SUBTLV_IDRP_RES, "Reserved"},
{ ISIS_SUBTLV_IDRP_LOCAL, "Routing-Domain Specific"},
{ ISIS_SUBTLV_IDRP_ASN, "AS Number Tag"},
@@ -440,24 +434,24 @@ static struct tok isis_subtlv_idrp_values[] = {
#define ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN 19
#define ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN 8
-static struct tok isis_mt_port_cap_subtlv_values[] = {
+static const struct tok isis_mt_port_cap_subtlv_values[] = {
{ ISIS_SUBTLV_SPB_MCID, "SPB MCID" },
{ ISIS_SUBTLV_SPB_DIGEST, "SPB Digest" },
{ ISIS_SUBTLV_SPB_BVID, "SPB BVID" },
{ 0, NULL }
};
-static struct tok isis_mt_capability_subtlv_values[] = {
+static const struct tok isis_mt_capability_subtlv_values[] = {
{ ISIS_SUBTLV_SPB_INSTANCE, "SPB Instance" },
{ ISIS_SUBTLV_SPBM_SI, "SPBM Service Identifier and Unicast Address" },
{ 0, NULL }
};
struct isis_spb_mcid {
- u_int8_t format_id;
- u_int8_t name[32];
- u_int8_t revision_lvl[2];
- u_int8_t digest[16];
+ uint8_t format_id;
+ uint8_t name[32];
+ uint8_t revision_lvl[2];
+ uint8_t digest[16];
};
struct isis_subtlv_spb_mcid {
@@ -466,18 +460,18 @@ struct isis_subtlv_spb_mcid {
};
struct isis_subtlv_spb_instance {
- u_int8_t cist_root_id[8];
- u_int8_t cist_external_root_path_cost[4];
- u_int8_t bridge_priority[2];
- u_int8_t spsourceid[4];
- u_int8_t no_of_trees;
+ uint8_t cist_root_id[8];
+ uint8_t cist_external_root_path_cost[4];
+ uint8_t bridge_priority[2];
+ uint8_t spsourceid[4];
+ uint8_t no_of_trees;
};
#define CLNP_SEGMENT_PART 0x80
#define CLNP_MORE_SEGMENTS 0x40
#define CLNP_REQUEST_ER 0x20
-static struct tok clnp_flag_values[] = {
+static const struct tok clnp_flag_values[] = {
{ CLNP_SEGMENT_PART, "Segmentation permitted"},
{ CLNP_MORE_SEGMENTS, "more Segments"},
{ CLNP_REQUEST_ER, "request Error Report"},
@@ -496,7 +490,7 @@ static struct tok clnp_flag_values[] = {
#define ISIS_MASK_MTID(x) ((x)&0x0fff)
#define ISIS_MASK_MTFLAGS(x) ((x)&0xf000)
-static struct tok isis_mt_flag_values[] = {
+static const struct tok isis_mt_flag_values[] = {
{ 0x4000, "ATT bit set"},
{ 0x8000, "Overload bit set"},
{ 0, NULL}
@@ -515,7 +509,7 @@ static struct tok isis_mt_flag_values[] = {
#define ISIS_MASK_TLV_SHARED_RISK_GROUP(x) ((x)&0x1)
-static struct tok isis_mt_values[] = {
+static const struct tok isis_mt_values[] = {
{ 0, "IPv4 unicast"},
{ 1, "In-Band Management"},
{ 2, "IPv6 unicast"},
@@ -524,7 +518,7 @@ static struct tok isis_mt_values[] = {
{ 0, NULL }
};
-static struct tok isis_iih_circuit_type_values[] = {
+static const struct tok isis_iih_circuit_type_values[] = {
{ 1, "Level 1 only"},
{ 2, "Level 2 only"},
{ 3, "Level 1, Level 2"},
@@ -536,7 +530,7 @@ static struct tok isis_iih_circuit_type_values[] = {
#define ISIS_LSP_TYPE_UNUSED2 2
#define ISIS_LSP_TYPE_LEVEL_2 3
-static struct tok isis_lsp_istype_values[] = {
+static const struct tok isis_lsp_istype_values[] = {
{ ISIS_LSP_TYPE_UNUSED0, "Unused 0x0 (invalid)"},
{ ISIS_LSP_TYPE_LEVEL_1, "L1 IS"},
{ ISIS_LSP_TYPE_UNUSED2, "Unused 0x2 (invalid)"},
@@ -553,7 +547,7 @@ static struct tok isis_lsp_istype_values[] = {
#define ISIS_PTP_ADJ_INIT 1
#define ISIS_PTP_ADJ_DOWN 2
-static struct tok isis_ptp_adjancey_values[] = {
+static const struct tok isis_ptp_adjancey_values[] = {
{ ISIS_PTP_ADJ_UP, "Up" },
{ ISIS_PTP_ADJ_INIT, "Initializing" },
{ ISIS_PTP_ADJ_DOWN, "Down" },
@@ -561,48 +555,48 @@ static struct tok isis_ptp_adjancey_values[] = {
};
struct isis_tlv_ptp_adj {
- u_int8_t adjacency_state;
- u_int8_t extd_local_circuit_id[4];
- u_int8_t neighbor_sysid[SYSTEM_ID_LEN];
- u_int8_t neighbor_extd_local_circuit_id[4];
+ uint8_t adjacency_state;
+ uint8_t extd_local_circuit_id[4];
+ uint8_t neighbor_sysid[SYSTEM_ID_LEN];
+ uint8_t neighbor_extd_local_circuit_id[4];
};
-static void osi_print_cksum(const u_int8_t *pptr, u_int16_t checksum,
+static void osi_print_cksum(netdissect_options *, const uint8_t *pptr, uint16_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);
+static int clnp_print(netdissect_options *, const uint8_t *, u_int);
+static void esis_print(netdissect_options *, const uint8_t *, u_int);
+static int isis_print(netdissect_options *, const uint8_t *, u_int);
struct isis_metric_block {
- u_int8_t metric_default;
- u_int8_t metric_delay;
- u_int8_t metric_expense;
- u_int8_t metric_error;
+ uint8_t metric_default;
+ uint8_t metric_delay;
+ uint8_t metric_expense;
+ uint8_t metric_error;
};
struct isis_tlv_is_reach {
struct isis_metric_block isis_metric_block;
- u_int8_t neighbor_nodeid[NODE_ID_LEN];
+ uint8_t neighbor_nodeid[NODE_ID_LEN];
};
struct isis_tlv_es_reach {
struct isis_metric_block isis_metric_block;
- u_int8_t neighbor_sysid[SYSTEM_ID_LEN];
+ uint8_t neighbor_sysid[SYSTEM_ID_LEN];
};
struct isis_tlv_ip_reach {
struct isis_metric_block isis_metric_block;
- u_int8_t prefix[4];
- u_int8_t mask[4];
+ uint8_t prefix[4];
+ uint8_t mask[4];
};
-static struct tok isis_is_reach_virtual_values[] = {
+static const struct tok isis_is_reach_virtual_values[] = {
{ 0, "IsNotVirtual"},
{ 1, "IsVirtual"},
{ 0, NULL }
};
-static struct tok isis_restart_flag_values[] = {
+static const struct tok isis_restart_flag_values[] = {
{ 0x1, "Restart Request"},
{ 0x2, "Restart Acknowledgement"},
{ 0x4, "Suppress adjacency advertisement"},
@@ -610,59 +604,59 @@ static struct tok isis_restart_flag_values[] = {
};
struct isis_common_header {
- u_int8_t nlpid;
- u_int8_t fixed_len;
- u_int8_t version; /* Protocol version */
- u_int8_t id_length;
- u_int8_t pdu_type; /* 3 MSbits are reserved */
- u_int8_t pdu_version; /* Packet format version */
- u_int8_t reserved;
- u_int8_t max_area;
+ uint8_t nlpid;
+ uint8_t fixed_len;
+ uint8_t version; /* Protocol version */
+ uint8_t id_length;
+ uint8_t pdu_type; /* 3 MSbits are reserved */
+ uint8_t pdu_version; /* Packet format version */
+ uint8_t reserved;
+ uint8_t max_area;
};
struct isis_iih_lan_header {
- u_int8_t circuit_type;
- u_int8_t source_id[SYSTEM_ID_LEN];
- u_int8_t holding_time[2];
- u_int8_t pdu_len[2];
- u_int8_t priority;
- u_int8_t lan_id[NODE_ID_LEN];
+ uint8_t circuit_type;
+ uint8_t source_id[SYSTEM_ID_LEN];
+ uint8_t holding_time[2];
+ uint8_t pdu_len[2];
+ uint8_t priority;
+ uint8_t lan_id[NODE_ID_LEN];
};
struct isis_iih_ptp_header {
- u_int8_t circuit_type;
- u_int8_t source_id[SYSTEM_ID_LEN];
- u_int8_t holding_time[2];
- u_int8_t pdu_len[2];
- u_int8_t circuit_id;
+ uint8_t circuit_type;
+ uint8_t source_id[SYSTEM_ID_LEN];
+ uint8_t holding_time[2];
+ uint8_t pdu_len[2];
+ uint8_t circuit_id;
};
struct isis_lsp_header {
- u_int8_t pdu_len[2];
- u_int8_t remaining_lifetime[2];
- u_int8_t lsp_id[LSP_ID_LEN];
- u_int8_t sequence_number[4];
- u_int8_t checksum[2];
- u_int8_t typeblock;
+ uint8_t pdu_len[2];
+ uint8_t remaining_lifetime[2];
+ uint8_t lsp_id[LSP_ID_LEN];
+ uint8_t sequence_number[4];
+ uint8_t checksum[2];
+ uint8_t typeblock;
};
struct isis_csnp_header {
- u_int8_t pdu_len[2];
- u_int8_t source_id[NODE_ID_LEN];
- u_int8_t start_lsp_id[LSP_ID_LEN];
- u_int8_t end_lsp_id[LSP_ID_LEN];
+ uint8_t pdu_len[2];
+ uint8_t source_id[NODE_ID_LEN];
+ uint8_t start_lsp_id[LSP_ID_LEN];
+ uint8_t end_lsp_id[LSP_ID_LEN];
};
struct isis_psnp_header {
- u_int8_t pdu_len[2];
- u_int8_t source_id[NODE_ID_LEN];
+ uint8_t pdu_len[2];
+ uint8_t source_id[NODE_ID_LEN];
};
struct isis_tlv_lsp {
- u_int8_t remaining_lifetime[2];
- u_int8_t lsp_id[LSP_ID_LEN];
- u_int8_t sequence_number[4];
- u_int8_t checksum[2];
+ uint8_t remaining_lifetime[2];
+ uint8_t lsp_id[LSP_ID_LEN];
+ uint8_t sequence_number[4];
+ uint8_t checksum[2];
};
#define ISIS_COMMON_HEADER_SIZE (sizeof(struct isis_common_header))
@@ -672,66 +666,61 @@ struct isis_tlv_lsp {
#define ISIS_CSNP_HEADER_SIZE (sizeof(struct isis_csnp_header))
#define ISIS_PSNP_HEADER_SIZE (sizeof(struct isis_psnp_header))
-void isoclns_print(const u_int8_t *p, u_int length, u_int caplen)
+void isoclns_print(netdissect_options *ndo,
+ const uint8_t *p, u_int length, u_int caplen)
{
- if (caplen <= 1) { /* enough bytes on the wire ? */
- printf("|OSI");
- return;
- }
+ if (caplen <= 1) { /* enough bytes on the wire ? */
+ ND_PRINT((ndo, "|OSI"));
+ return;
+ }
+
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "OSI NLPID %s (0x%02x): ", tok2str(nlpid_values, "Unknown", *p), *p));
- if (eflag)
- printf("OSI NLPID %s (0x%02x): ",
- tok2str(nlpid_values,"Unknown",*p),
- *p);
-
switch (*p) {
case NLPID_CLNP:
- if (!clnp_print(p, length))
- print_unknown_data(p,"\n\t",caplen);
+ if (!clnp_print(ndo, p, length))
+ print_unknown_data(ndo, p, "\n\t", caplen);
break;
case NLPID_ESIS:
- esis_print(p, length);
+ esis_print(ndo, p, length);
return;
case NLPID_ISIS:
- if (!isis_print(p, length))
- print_unknown_data(p,"\n\t",caplen);
+ if (!isis_print(ndo, p, length))
+ print_unknown_data(ndo, p, "\n\t", caplen);
break;
case NLPID_NULLNS:
- (void)printf("%slength: %u",
- eflag ? "" : ", ",
- length);
+ ND_PRINT((ndo, "%slength: %u", ndo->ndo_eflag ? "" : ", ", length));
break;
- case NLPID_Q933:
- q933_print(p+1, length-1);
- break;
+ case NLPID_Q933:
+ q933_print(ndo, p + 1, length - 1);
+ break;
- case NLPID_IP:
- ip_print(gndo, p+1, length-1);
- break;
+ case NLPID_IP:
+ ip_print(ndo, p + 1, length - 1);
+ break;
#ifdef INET6
- case NLPID_IP6:
- ip6_print(gndo, p+1, length-1);
- break;
+ case NLPID_IP6:
+ ip6_print(ndo, p + 1, length - 1);
+ break;
#endif
- case NLPID_PPP:
- ppp_print(p+1, length-1);
- break;
+ case NLPID_PPP:
+ ppp_print(ndo, p + 1, length - 1);
+ break;
default:
- if (!eflag)
- printf("OSI NLPID 0x%02x unknown",*p);
- (void)printf("%slength: %u",
- eflag ? "" : ", ",
- length);
+ if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, "OSI NLPID 0x%02x unknown", *p));
+ ND_PRINT((ndo, "%slength: %u", ndo->ndo_eflag ? "" : ", ", length));
if (caplen > 1)
- print_unknown_data(p,"\n\t",caplen);
+ print_unknown_data(ndo, p, "\n\t", caplen);
break;
}
}
@@ -742,7 +731,7 @@ void isoclns_print(const u_int8_t *p, u_int length, u_int caplen)
#define CLNP_PDU_ERQ 30
#define CLNP_PDU_ERP 31
-static struct tok clnp_pdu_values[] = {
+static const struct tok clnp_pdu_values[] = {
{ CLNP_PDU_ER, "Error Report"},
{ CLNP_PDU_MD, "MD"},
{ CLNP_PDU_DT, "Data"},
@@ -752,19 +741,19 @@ static struct tok clnp_pdu_values[] = {
};
struct clnp_header_t {
- u_int8_t nlpid;
- u_int8_t length_indicator;
- u_int8_t version;
- u_int8_t lifetime; /* units of 500ms */
- u_int8_t type;
- u_int8_t segment_length[2];
- u_int8_t cksum[2];
+ uint8_t nlpid;
+ uint8_t length_indicator;
+ uint8_t version;
+ uint8_t lifetime; /* units of 500ms */
+ uint8_t type;
+ uint8_t segment_length[2];
+ uint8_t cksum[2];
};
struct clnp_segment_header_t {
- u_int8_t data_unit_id[2];
- u_int8_t segment_offset[2];
- u_int8_t total_length[2];
+ uint8_t data_unit_id[2];
+ uint8_t segment_offset[2];
+ uint8_t total_length[2];
};
/*
@@ -772,29 +761,31 @@ struct clnp_segment_header_t {
* Decode CLNP packets. Return 0 on error.
*/
-static int clnp_print (const u_int8_t *pptr, u_int length)
+static int
+clnp_print(netdissect_options *ndo,
+ const uint8_t *pptr, u_int length)
{
- const u_int8_t *optr,*source_address,*dest_address;
+ const uint8_t *optr,*source_address,*dest_address;
u_int li,tlen,nsap_offset,source_address_length,dest_address_length, clnp_pdu_type, clnp_flags;
const struct clnp_header_t *clnp_header;
const struct clnp_segment_header_t *clnp_segment_header;
- u_int8_t rfd_error_major,rfd_error_minor;
+ uint8_t rfd_error_major,rfd_error_minor;
clnp_header = (const struct clnp_header_t *) pptr;
- TCHECK(*clnp_header);
+ ND_TCHECK(*clnp_header);
li = clnp_header->length_indicator;
optr = pptr;
- if (!eflag)
- printf("CLNP");
+ if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, "CLNP"));
/*
* Sanity checking of the header.
*/
if (clnp_header->version != CLNP_VERSION) {
- printf("version %d packet not supported", clnp_header->version);
+ ND_PRINT((ndo, "version %d packet not supported", clnp_header->version));
return (0);
}
@@ -816,45 +807,45 @@ static int clnp_print (const u_int8_t *pptr, u_int length)
pptr += (1 + source_address_length);
li -= (1 + source_address_length);
- if (vflag < 1) {
- printf("%s%s > %s, %s, length %u",
- eflag ? "" : ", ",
+ if (ndo->ndo_vflag < 1) {
+ ND_PRINT((ndo, "%s%s > %s, %s, length %u",
+ ndo->ndo_eflag ? "" : ", ",
isonsap_string(source_address, source_address_length),
isonsap_string(dest_address, dest_address_length),
tok2str(clnp_pdu_values,"unknown (%u)",clnp_pdu_type),
- length);
+ length));
return (1);
}
- printf("%slength %u",eflag ? "" : ", ",length);
+ ND_PRINT((ndo, "%slength %u", ndo->ndo_eflag ? "" : ", ", length));
- printf("\n\t%s PDU, hlen: %u, v: %u, lifetime: %u.%us, Segment PDU length: %u, checksum: 0x%04x",
+ ND_PRINT((ndo, "\n\t%s PDU, hlen: %u, v: %u, lifetime: %u.%us, Segment PDU length: %u, checksum: 0x%04x",
tok2str(clnp_pdu_values, "unknown (%u)",clnp_pdu_type),
clnp_header->length_indicator,
clnp_header->version,
clnp_header->lifetime/2,
(clnp_header->lifetime%2)*5,
EXTRACT_16BITS(clnp_header->segment_length),
- EXTRACT_16BITS(clnp_header->cksum));
+ EXTRACT_16BITS(clnp_header->cksum)));
- osi_print_cksum(optr, EXTRACT_16BITS(clnp_header->cksum), 7,
+ osi_print_cksum(ndo, optr, EXTRACT_16BITS(clnp_header->cksum), 7,
clnp_header->length_indicator);
- printf("\n\tFlags [%s]",
- bittok2str(clnp_flag_values,"none",clnp_flags));
+ ND_PRINT((ndo, "\n\tFlags [%s]",
+ bittok2str(clnp_flag_values, "none", clnp_flags)));
- printf("\n\tsource address (length %u): %s\n\tdest address (length %u): %s",
+ ND_PRINT((ndo, "\n\tsource address (length %u): %s\n\tdest address (length %u): %s",
source_address_length,
isonsap_string(source_address, source_address_length),
dest_address_length,
- isonsap_string(dest_address,dest_address_length));
+ isonsap_string(dest_address, dest_address_length)));
if (clnp_flags & CLNP_SEGMENT_PART) {
clnp_segment_header = (const struct clnp_segment_header_t *) pptr;
- TCHECK(*clnp_segment_header);
- printf("\n\tData Unit ID: 0x%04x, Segment Offset: %u, Total PDU Length: %u",
+ ND_TCHECK(*clnp_segment_header);
+ ND_PRINT((ndo, "\n\tData Unit ID: 0x%04x, Segment Offset: %u, Total PDU Length: %u",
EXTRACT_16BITS(clnp_segment_header->data_unit_id),
EXTRACT_16BITS(clnp_segment_header->segment_offset),
- EXTRACT_16BITS(clnp_segment_header->total_length));
+ EXTRACT_16BITS(clnp_segment_header->total_length)));
pptr+=sizeof(const struct clnp_segment_header_t);
li-=sizeof(const struct clnp_segment_header_t);
}
@@ -862,46 +853,46 @@ static int clnp_print (const u_int8_t *pptr, u_int length)
/* now walk the options */
while (li >= 2) {
u_int op, opli;
- const u_int8_t *tptr;
-
- TCHECK2(*pptr, 2);
+ const uint8_t *tptr;
+
+ ND_TCHECK2(*pptr, 2);
if (li < 2) {
- printf(", bad opts/li");
+ ND_PRINT((ndo, ", bad opts/li"));
return (0);
}
op = *pptr++;
opli = *pptr++;
li -= 2;
- TCHECK2(*pptr, opli);
+ ND_TCHECK2(*pptr, opli);
if (opli > li) {
- printf(", opt (%d) too long", op);
+ ND_PRINT((ndo, ", opt (%d) too long", op));
return (0);
}
li -= opli;
tptr = pptr;
tlen = opli;
-
- printf("\n\t %s Option #%u, length %u, value: ",
+
+ ND_PRINT((ndo, "\n\t %s Option #%u, length %u, value: ",
tok2str(clnp_option_values,"Unknown",op),
op,
- opli);
+ opli));
switch (op) {
case CLNP_OPTION_ROUTE_RECORDING: /* those two options share the format */
- case CLNP_OPTION_SOURCE_ROUTING:
- printf("%s %s",
+ case CLNP_OPTION_SOURCE_ROUTING:
+ ND_PRINT((ndo, "%s %s",
tok2str(clnp_option_sr_rr_values,"Unknown",*tptr),
- tok2str(clnp_option_sr_rr_string_values,"Unknown Option %u",op));
+ tok2str(clnp_option_sr_rr_string_values, "Unknown Option %u", op)));
nsap_offset=*(tptr+1);
if (nsap_offset == 0) {
- printf(" Bad NSAP offset (0)");
+ ND_PRINT((ndo, " Bad NSAP offset (0)"));
break;
}
nsap_offset-=1; /* offset to nsap list */
if (nsap_offset > tlen) {
- printf(" Bad NSAP offset (past end of option)");
+ ND_PRINT((ndo, " Bad NSAP offset (past end of option)"));
break;
}
tptr+=nsap_offset;
@@ -909,53 +900,53 @@ static int clnp_print (const u_int8_t *pptr, u_int length)
while (tlen > 0) {
source_address_length=*tptr;
if (tlen < source_address_length+1) {
- printf("\n\t NSAP address goes past end of option");
+ ND_PRINT((ndo, "\n\t NSAP address goes past end of option"));
break;
}
if (source_address_length > 0) {
source_address=(tptr+1);
- TCHECK2(*source_address, source_address_length);
- printf("\n\t NSAP address (length %u): %s",
+ ND_TCHECK2(*source_address, source_address_length);
+ ND_PRINT((ndo, "\n\t NSAP address (length %u): %s",
source_address_length,
- isonsap_string(source_address, source_address_length));
+ isonsap_string(source_address, source_address_length)));
}
tlen-=source_address_length+1;
}
break;
case CLNP_OPTION_PRIORITY:
- printf("0x%1x", *tptr&0x0f);
+ ND_PRINT((ndo, "0x%1x", *tptr&0x0f));
break;
case CLNP_OPTION_QOS_MAINTENANCE:
- printf("\n\t Format Code: %s",
- tok2str(clnp_option_scope_values,"Reserved",*tptr&CLNP_OPTION_SCOPE_MASK));
+ ND_PRINT((ndo, "\n\t Format Code: %s",
+ tok2str(clnp_option_scope_values, "Reserved", *tptr&CLNP_OPTION_SCOPE_MASK)));
if ((*tptr&CLNP_OPTION_SCOPE_MASK) == CLNP_OPTION_SCOPE_GLOBAL)
- printf("\n\t QoS Flags [%s]",
+ ND_PRINT((ndo, "\n\t QoS Flags [%s]",
bittok2str(clnp_option_qos_global_values,
"none",
- *tptr&CLNP_OPTION_OPTION_QOS_MASK));
+ *tptr&CLNP_OPTION_OPTION_QOS_MASK)));
break;
case CLNP_OPTION_SECURITY:
- printf("\n\t Format Code: %s, Security-Level %u",
+ ND_PRINT((ndo, "\n\t Format Code: %s, Security-Level %u",
tok2str(clnp_option_scope_values,"Reserved",*tptr&CLNP_OPTION_SCOPE_MASK),
- *(tptr+1));
+ *(tptr+1)));
break;
case CLNP_OPTION_DISCARD_REASON:
rfd_error_major = (*tptr&0xf0) >> 4;
rfd_error_minor = *tptr&0x0f;
- printf("\n\t Class: %s Error (0x%01x), %s (0x%01x)",
+ ND_PRINT((ndo, "\n\t Class: %s Error (0x%01x), %s (0x%01x)",
tok2str(clnp_option_rfd_class_values,"Unknown",rfd_error_major),
rfd_error_major,
tok2str(clnp_option_rfd_error_class[rfd_error_major],"Unknown",rfd_error_minor),
- rfd_error_minor);
+ rfd_error_minor));
break;
case CLNP_OPTION_PADDING:
- printf("padding data");
+ ND_PRINT((ndo, "padding data"));
break;
/*
@@ -964,11 +955,11 @@ static int clnp_print (const u_int8_t *pptr, u_int length)
*/
default:
- print_unknown_data(tptr,"\n\t ",opli);
+ print_unknown_data(ndo, tptr, "\n\t ", opli);
break;
}
- if (vflag > 1)
- print_unknown_data(pptr,"\n\t ",opli);
+ if (ndo->ndo_vflag > 1)
+ print_unknown_data(ndo, pptr, "\n\t ", opli);
pptr += opli;
}
@@ -976,30 +967,30 @@ static int clnp_print (const u_int8_t *pptr, u_int length)
case CLNP_PDU_ER: /* fall through */
case CLNP_PDU_ERP:
- TCHECK(*pptr);
+ ND_TCHECK(*pptr);
if (*(pptr) == NLPID_CLNP) {
- printf("\n\t-----original packet-----\n\t");
+ ND_PRINT((ndo, "\n\t-----original packet-----\n\t"));
/* FIXME recursion protection */
- clnp_print(pptr, length-clnp_header->length_indicator);
+ clnp_print(ndo, pptr, length - clnp_header->length_indicator);
break;
- }
+ }
case CLNP_PDU_DT:
case CLNP_PDU_MD:
case CLNP_PDU_ERQ:
-
+
default:
/* dump the PDU specific data */
if (length-(pptr-optr) > 0) {
- printf("\n\t undecoded non-header data, length %u",length-clnp_header->length_indicator);
- print_unknown_data(pptr,"\n\t ",length-(pptr-optr));
+ ND_PRINT((ndo, "\n\t undecoded non-header data, length %u", length-clnp_header->length_indicator));
+ print_unknown_data(ndo, pptr, "\n\t ", length - (pptr - optr));
}
}
return (1);
trunc:
- fputs("[|clnp]", stdout);
+ ND_PRINT((ndo, "[|clnp]"));
return (1);
}
@@ -1009,7 +1000,7 @@ static int clnp_print (const u_int8_t *pptr, u_int length)
#define ESIS_PDU_ESH 2
#define ESIS_PDU_ISH 4
-static struct tok esis_pdu_values[] = {
+static const struct tok esis_pdu_values[] = {
{ ESIS_PDU_REDIRECT, "redirect"},
{ ESIS_PDU_ESH, "ESH"},
{ ESIS_PDU_ISH, "ISH"},
@@ -1017,35 +1008,33 @@ static struct tok esis_pdu_values[] = {
};
struct esis_header_t {
- u_int8_t nlpid;
- u_int8_t length_indicator;
- u_int8_t version;
- u_int8_t reserved;
- u_int8_t type;
- u_int8_t holdtime[2];
- u_int8_t cksum[2];
+ uint8_t nlpid;
+ uint8_t length_indicator;
+ uint8_t version;
+ uint8_t reserved;
+ uint8_t type;
+ uint8_t holdtime[2];
+ uint8_t cksum[2];
};
static void
-esis_print(const u_int8_t *pptr, u_int length)
+esis_print(netdissect_options *ndo,
+ const uint8_t *pptr, u_int length)
{
- const u_int8_t *optr;
+ const uint8_t *optr;
u_int li,esis_pdu_type,source_address_length, source_address_number;
const struct esis_header_t *esis_header;
- if (!eflag)
- printf("ES-IS");
+ if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, "ES-IS"));
if (length <= 2) {
- if (qflag)
- printf("bad pkt!");
- else
- printf("no header at all!");
+ ND_PRINT((ndo, ndo->ndo_qflag ? "bad pkt!" : "no header at all!"));
return;
}
esis_header = (const struct esis_header_t *) pptr;
- TCHECK(*esis_header);
+ ND_TCHECK(*esis_header);
li = esis_header->length_indicator;
optr = pptr;
@@ -1054,104 +1043,105 @@ esis_print(const u_int8_t *pptr, u_int length)
*/
if (esis_header->nlpid != NLPID_ESIS) {
- printf(" nlpid 0x%02x packet not supported", esis_header->nlpid);
+ ND_PRINT((ndo, " nlpid 0x%02x packet not supported", esis_header->nlpid));
return;
}
if (esis_header->version != ESIS_VERSION) {
- printf(" version %d packet not supported", esis_header->version);
+ ND_PRINT((ndo, " version %d packet not supported", esis_header->version));
return;
}
-
+
if (li > length) {
- printf(" length indicator(%d) > PDU size (%d)!", li, length);
+ ND_PRINT((ndo, " length indicator(%d) > PDU size (%d)!", li, length));
return;
}
if (li < sizeof(struct esis_header_t) + 2) {
- printf(" length indicator < min PDU size %d:", li);
+ ND_PRINT((ndo, " length indicator < min PDU size %d:", li));
while (--length != 0)
- printf("%02X", *pptr++);
+ ND_PRINT((ndo, "%02X", *pptr++));
return;
}
esis_pdu_type = esis_header->type & ESIS_PDU_TYPE_MASK;
- if (vflag < 1) {
- printf("%s%s, length %u",
- eflag ? "" : ", ",
+ if (ndo->ndo_vflag < 1) {
+ ND_PRINT((ndo, "%s%s, length %u",
+ ndo->ndo_eflag ? "" : ", ",
tok2str(esis_pdu_values,"unknown type (%u)",esis_pdu_type),
- length);
+ length));
return;
} else
- printf("%slength %u\n\t%s (%u)",
- eflag ? "" : ", ",
+ ND_PRINT((ndo, "%slength %u\n\t%s (%u)",
+ ndo->ndo_eflag ? "" : ", ",
length,
tok2str(esis_pdu_values,"unknown type: %u", esis_pdu_type),
- esis_pdu_type);
+ esis_pdu_type));
- printf(", v: %u%s", esis_header->version, esis_header->version == ESIS_VERSION ? "" : "unsupported" );
- printf(", checksum: 0x%04x", EXTRACT_16BITS(esis_header->cksum));
+ ND_PRINT((ndo, ", v: %u%s", esis_header->version, esis_header->version == ESIS_VERSION ? "" : "unsupported" ));
+ ND_PRINT((ndo, ", checksum: 0x%04x", EXTRACT_16BITS(esis_header->cksum)));
- osi_print_cksum(pptr, EXTRACT_16BITS(esis_header->cksum), 7, li);
+ osi_print_cksum(ndo, pptr, EXTRACT_16BITS(esis_header->cksum), 7, li);
- printf(", holding time: %us, length indicator: %u",EXTRACT_16BITS(esis_header->holdtime),li);
+ ND_PRINT((ndo, ", holding time: %us, length indicator: %u",
+ EXTRACT_16BITS(esis_header->holdtime), li));
- if (vflag > 1)
- print_unknown_data(optr,"\n\t",sizeof(struct esis_header_t));
+ if (ndo->ndo_vflag > 1)
+ print_unknown_data(ndo, optr, "\n\t", sizeof(struct esis_header_t));
pptr += sizeof(struct esis_header_t);
li -= sizeof(struct esis_header_t);
switch (esis_pdu_type) {
case ESIS_PDU_REDIRECT: {
- const u_int8_t *dst, *snpa, *neta;
+ const uint8_t *dst, *snpa, *neta;
u_int dstl, snpal, netal;
- TCHECK(*pptr);
+ ND_TCHECK(*pptr);
if (li < 1) {
- printf(", bad redirect/li");
+ ND_PRINT((ndo, ", bad redirect/li"));
return;
}
dstl = *pptr;
pptr++;
li--;
- TCHECK2(*pptr, dstl);
+ ND_TCHECK2(*pptr, dstl);
if (li < dstl) {
- printf(", bad redirect/li");
+ ND_PRINT((ndo, ", bad redirect/li"));
return;
}
dst = pptr;
pptr += dstl;
li -= dstl;
- printf("\n\t %s", isonsap_string(dst,dstl));
+ ND_PRINT((ndo, "\n\t %s", isonsap_string(dst, dstl)));
- TCHECK(*pptr);
+ ND_TCHECK(*pptr);
if (li < 1) {
- printf(", bad redirect/li");
+ ND_PRINT((ndo, ", bad redirect/li"));
return;
}
snpal = *pptr;
pptr++;
li--;
- TCHECK2(*pptr, snpal);
+ ND_TCHECK2(*pptr, snpal);
if (li < snpal) {
- printf(", bad redirect/li");
+ ND_PRINT((ndo, ", bad redirect/li"));
return;
}
snpa = pptr;
pptr += snpal;
li -= snpal;
- TCHECK(*pptr);
+ ND_TCHECK(*pptr);
if (li < 1) {
- printf(", bad redirect/li");
+ ND_PRINT((ndo, ", bad redirect/li"));
return;
}
netal = *pptr;
pptr++;
- TCHECK2(*pptr, netal);
+ ND_TCHECK2(*pptr, netal);
if (li < netal) {
- printf(", bad redirect/li");
+ ND_PRINT((ndo, ", bad redirect/li"));
return;
}
neta = pptr;
@@ -1159,42 +1149,42 @@ esis_print(const u_int8_t *pptr, u_int length)
li -= netal;
if (netal == 0)
- printf("\n\t %s", etheraddr_string(snpa));
+ ND_PRINT((ndo, "\n\t %s", etheraddr_string(ndo, snpa)));
else
- printf("\n\t %s", isonsap_string(neta,netal));
+ ND_PRINT((ndo, "\n\t %s", isonsap_string(neta, netal)));
break;
}
case ESIS_PDU_ESH:
- TCHECK(*pptr);
+ ND_TCHECK(*pptr);
if (li < 1) {
- printf(", bad esh/li");
+ ND_PRINT((ndo, ", bad esh/li"));
return;
}
source_address_number = *pptr;
pptr++;
li--;
- printf("\n\t Number of Source Addresses: %u", source_address_number);
-
+ ND_PRINT((ndo, "\n\t Number of Source Addresses: %u", source_address_number));
+
while (source_address_number > 0) {
- TCHECK(*pptr);
+ ND_TCHECK(*pptr);
if (li < 1) {
- printf(", bad esh/li");
+ ND_PRINT((ndo, ", bad esh/li"));
return;
}
source_address_length = *pptr;
pptr++;
li--;
- TCHECK2(*pptr, source_address_length);
+ ND_TCHECK2(*pptr, source_address_length);
if (li < source_address_length) {
- printf(", bad esh/li");
+ ND_PRINT((ndo, ", bad esh/li"));
return;
}
- printf("\n\t NET (length: %u): %s",
+ ND_PRINT((ndo, "\n\t NET (length: %u): %s",
source_address_length,
- isonsap_string(pptr,source_address_length));
+ isonsap_string(pptr, source_address_length)));
pptr += source_address_length;
li -= source_address_length;
source_address_number--;
@@ -1203,78 +1193,78 @@ esis_print(const u_int8_t *pptr, u_int length)
break;
case ESIS_PDU_ISH: {
- TCHECK(*pptr);
+ ND_TCHECK(*pptr);
if (li < 1) {
- printf(", bad ish/li");
+ ND_PRINT((ndo, ", bad ish/li"));
return;
}
source_address_length = *pptr;
pptr++;
li--;
- TCHECK2(*pptr, source_address_length);
+ ND_TCHECK2(*pptr, source_address_length);
if (li < source_address_length) {
- printf(", bad ish/li");
+ ND_PRINT((ndo, ", bad ish/li"));
return;
}
- printf("\n\t NET (length: %u): %s", source_address_length, isonsap_string(pptr, source_address_length));
+ ND_PRINT((ndo, "\n\t NET (length: %u): %s", source_address_length, isonsap_string(pptr, source_address_length)));
pptr += source_address_length;
li -= source_address_length;
break;
}
default:
- if (vflag <= 1) {
- if (pptr < snapend)
- print_unknown_data(pptr,"\n\t ",snapend-pptr);
- }
- return;
+ if (ndo->ndo_vflag <= 1) {
+ if (pptr < ndo->ndo_snapend)
+ print_unknown_data(ndo, pptr, "\n\t ", ndo->ndo_snapend - pptr);
+ }
+ return;
}
/* now walk the options */
while (li != 0) {
u_int op, opli;
- const u_int8_t *tptr;
-
+ const uint8_t *tptr;
+
if (li < 2) {
- printf(", bad opts/li");
+ ND_PRINT((ndo, ", bad opts/li"));
return;
}
- TCHECK2(*pptr, 2);
+ ND_TCHECK2(*pptr, 2);
op = *pptr++;
opli = *pptr++;
li -= 2;
if (opli > li) {
- printf(", opt (%d) too long", op);
+ ND_PRINT((ndo, ", opt (%d) too long", op));
return;
}
li -= opli;
tptr = pptr;
-
- printf("\n\t %s Option #%u, length %u, value: ",
+
+ ND_PRINT((ndo, "\n\t %s Option #%u, length %u, value: ",
tok2str(esis_option_values,"Unknown",op),
op,
- opli);
+ opli));
switch (op) {
case ESIS_OPTION_ES_CONF_TIME:
if (opli == 2) {
- TCHECK2(*pptr, 2);
- printf("%us", EXTRACT_16BITS(tptr));
+ ND_TCHECK2(*pptr, 2);
+ ND_PRINT((ndo, "%us", EXTRACT_16BITS(tptr)));
} else
- printf("(bad length)");
+ ND_PRINT((ndo, "(bad length)"));
break;
case ESIS_OPTION_PROTOCOLS:
while (opli>0) {
- TCHECK(*pptr);
- printf("%s (0x%02x)",
+ ND_TCHECK(*pptr);
+ ND_PRINT((ndo, "%s (0x%02x)",
tok2str(nlpid_values,
"unknown",
*tptr),
- *tptr);
+ *tptr));
if (opli>1) /* further NPLIDs ? - put comma */
- printf(", ");
+ ND_PRINT((ndo, ", "));
tptr++;
opli--;
}
@@ -1292,43 +1282,43 @@ esis_print(const u_int8_t *pptr, u_int length)
case ESIS_OPTION_SNPA_MASK:
default:
- print_unknown_data(tptr,"\n\t ",opli);
+ print_unknown_data(ndo, tptr, "\n\t ", opli);
break;
}
- if (vflag > 1)
- print_unknown_data(pptr,"\n\t ",opli);
+ if (ndo->ndo_vflag > 1)
+ print_unknown_data(ndo, pptr, "\n\t ", opli);
pptr += opli;
}
trunc:
return;
-}
-
+}
static void
-isis_print_mcid (const struct isis_spb_mcid *mcid)
+isis_print_mcid(netdissect_options *ndo,
+ const struct isis_spb_mcid *mcid)
{
int i;
- printf( "ID: %d, Name: ", mcid->format_id);
+ ND_PRINT((ndo, "ID: %d, Name: ", mcid->format_id));
- for(i=0; i<32; i++)
- {
- printf("%c", mcid->name[i]);
+ for(i=0; i<32; i++)
+ {
+ ND_PRINT((ndo, "%c", mcid->name[i]));
if(mcid->name[i] == '\0')
break;
}
- printf("\n\t Lvl: %d",
- EXTRACT_16BITS(mcid->revision_lvl));
+ ND_PRINT((ndo, "\n\t Lvl: %d", EXTRACT_16BITS(mcid->revision_lvl)));
- printf( ", Digest: ");
+ ND_PRINT((ndo, ", Digest: "));
- for(i=0;i<16;i++)
- printf("%.2x ",mcid->digest[i]);
+ for(i=0;i<16;i++)
+ ND_PRINT((ndo, "%.2x ", mcid->digest[i]));
}
static int
-isis_print_mt_port_cap_subtlv (const u_int8_t *tptr, int len)
+isis_print_mt_port_cap_subtlv(netdissect_options *ndo,
+ const uint8_t *tptr, int len)
{
int stlv_type, stlv_len;
const struct isis_subtlv_spb_mcid *subtlv_spb_mcid;
@@ -1340,10 +1330,10 @@ isis_print_mt_port_cap_subtlv (const u_int8_t *tptr, int len)
stlv_len = *(tptr++);
/* first lets see if we know the subTLVs name*/
- printf("\n\t %s subTLV #%u, length: %u",
+ ND_PRINT((ndo, "\n\t %s subTLV #%u, length: %u",
tok2str(isis_mt_port_cap_subtlv_values, "unknown", stlv_type),
stlv_type,
- stlv_len);
+ stlv_len));
/*len -= TLV_TYPE_LEN_OFFSET;*/
len = len -2;
@@ -1352,19 +1342,19 @@ isis_print_mt_port_cap_subtlv (const u_int8_t *tptr, int len)
{
case ISIS_SUBTLV_SPB_MCID:
{
- if (!TTEST2(*(tptr), ISIS_SUBTLV_SPB_MCID_MIN_LEN))
+ if (!ND_TTEST2(*(tptr), ISIS_SUBTLV_SPB_MCID_MIN_LEN))
goto trunctlv;
subtlv_spb_mcid = (struct isis_subtlv_spb_mcid *)tptr;
- printf( "\n\t MCID: ");
- isis_print_mcid (&(subtlv_spb_mcid->mcid));
+ ND_PRINT((ndo, "\n\t MCID: "));
+ isis_print_mcid(ndo, &(subtlv_spb_mcid->mcid));
/*tptr += SPB_MCID_MIN_LEN;
len -= SPB_MCID_MIN_LEN; */
- printf( "\n\t AUX-MCID: ");
- isis_print_mcid (&(subtlv_spb_mcid->aux_mcid));
+ ND_PRINT((ndo, "\n\t AUX-MCID: "));
+ isis_print_mcid(ndo, &(subtlv_spb_mcid->aux_mcid));
/*tptr += SPB_MCID_MIN_LEN;
len -= SPB_MCID_MIN_LEN; */
@@ -1376,22 +1366,22 @@ isis_print_mt_port_cap_subtlv (const u_int8_t *tptr, int len)
case ISIS_SUBTLV_SPB_DIGEST:
{
- if (!TTEST2(*(tptr), ISIS_SUBTLV_SPB_DIGEST_MIN_LEN))
+ if (!ND_TTEST2(*(tptr), ISIS_SUBTLV_SPB_DIGEST_MIN_LEN))
goto trunctlv;
- printf ("\n\t RES: %d V: %d A: %d D: %d",
+ ND_PRINT((ndo, "\n\t RES: %d V: %d A: %d D: %d",
(*(tptr) >> 5), (((*tptr)>> 4) & 0x01),
- ((*(tptr) >> 2) & 0x03), ((*tptr) & 0x03));
+ ((*(tptr) >> 2) & 0x03), ((*tptr) & 0x03)));
tptr++;
- printf( "\n\t Digest: ");
-
+ ND_PRINT((ndo, "\n\t Digest: "));
+
for(i=1;i<=8; i++)
{
- printf("%08x ", EXTRACT_32BITS(tptr));
+ ND_PRINT((ndo, "%08x ", EXTRACT_32BITS(tptr)));
if (i%4 == 0 && i != 8)
- printf("\n\t ");
+ ND_PRINT((ndo, "\n\t "));
tptr = tptr + 4;
}
@@ -1402,23 +1392,23 @@ isis_print_mt_port_cap_subtlv (const u_int8_t *tptr, int len)
case ISIS_SUBTLV_SPB_BVID:
{
- if (!TTEST2(*(tptr), stlv_len))
+ if (!ND_TTEST2(*(tptr), stlv_len))
goto trunctlv;
while (len)
{
- if (!TTEST2(*(tptr), ISIS_SUBTLV_SPB_BVID_MIN_LEN))
+ if (!ND_TTEST2(*(tptr), ISIS_SUBTLV_SPB_BVID_MIN_LEN))
goto trunctlv;
- printf("\n\t ECT: %08x",
- EXTRACT_32BITS(tptr));
+ ND_PRINT((ndo, "\n\t ECT: %08x",
+ EXTRACT_32BITS(tptr)));
tptr = tptr+4;
- printf(" BVID: %d, U:%01x M:%01x ",
+ ND_PRINT((ndo, " BVID: %d, U:%01x M:%01x ",
(EXTRACT_16BITS (tptr) >> 4) ,
(EXTRACT_16BITS (tptr) >> 3) & 0x01,
- (EXTRACT_16BITS (tptr) >> 2) & 0x01);
+ (EXTRACT_16BITS (tptr) >> 2) & 0x01));
tptr = tptr + 2;
len = len - ISIS_SUBTLV_SPB_BVID_MIN_LEN;
@@ -1426,7 +1416,7 @@ isis_print_mt_port_cap_subtlv (const u_int8_t *tptr, int len)
break;
}
-
+
default:
break;
}
@@ -1435,51 +1425,52 @@ isis_print_mt_port_cap_subtlv (const u_int8_t *tptr, int len)
return 0;
trunctlv:
- printf("\n\t\t packet exceeded snapshot");
- return(1);
+ ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
+ return(1);
}
static int
-isis_print_mt_capability_subtlv (const u_int8_t *tptr, int len)
+isis_print_mt_capability_subtlv(netdissect_options *ndo,
+ const uint8_t *tptr, int len)
{
int stlv_type, stlv_len, tmp;
- while (len > 0)
- {
+ while (len > 0)
+ {
stlv_type = *(tptr++);
stlv_len = *(tptr++);
/* first lets see if we know the subTLVs name*/
- printf("\n\t %s subTLV #%u, length: %u",
+ ND_PRINT((ndo, "\n\t %s subTLV #%u, length: %u",
tok2str(isis_mt_capability_subtlv_values, "unknown", stlv_type),
stlv_type,
- stlv_len);
-
+ stlv_len));
+
len = len - 2;
switch (stlv_type)
- {
+ {
case ISIS_SUBTLV_SPB_INSTANCE:
- if (!TTEST2(*(tptr), ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN))
+ if (!ND_TTEST2(*(tptr), ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN))
goto trunctlv;
- printf("\n\t CIST Root-ID: %08x", EXTRACT_32BITS(tptr));
+ ND_PRINT((ndo, "\n\t CIST Root-ID: %08x", EXTRACT_32BITS(tptr)));
tptr = tptr+4;
- printf(" %08x", EXTRACT_32BITS(tptr));
+ ND_PRINT((ndo, " %08x", EXTRACT_32BITS(tptr)));
tptr = tptr+4;
- printf(", Path Cost: %08x", EXTRACT_32BITS(tptr));
+ ND_PRINT((ndo, ", Path Cost: %08x", EXTRACT_32BITS(tptr)));
tptr = tptr+4;
- printf(", Prio: %d", EXTRACT_16BITS(tptr));
- tptr = tptr + 2;
- printf("\n\t RES: %d",
- EXTRACT_16BITS(tptr) >> 5);
- printf(", V: %d",
- (EXTRACT_16BITS(tptr) >> 4) & 0x0001);
- printf(", SPSource-ID: %d",
- (EXTRACT_32BITS(tptr) & 0x000fffff));
+ ND_PRINT((ndo, ", Prio: %d", EXTRACT_16BITS(tptr)));
+ tptr = tptr + 2;
+ ND_PRINT((ndo, "\n\t RES: %d",
+ EXTRACT_16BITS(tptr) >> 5));
+ ND_PRINT((ndo, ", V: %d",
+ (EXTRACT_16BITS(tptr) >> 4) & 0x0001));
+ ND_PRINT((ndo, ", SPSource-ID: %d",
+ (EXTRACT_32BITS(tptr) & 0x000fffff)));
tptr = tptr+4;
- printf(", No of Trees: %x", *(tptr));
+ ND_PRINT((ndo, ", No of Trees: %x", *(tptr)));
tmp = *(tptr++);
@@ -1487,42 +1478,42 @@ isis_print_mt_capability_subtlv (const u_int8_t *tptr, int len)
while (tmp)
{
- if (!TTEST2(*(tptr), ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN))
+ if (!ND_TTEST2(*(tptr), ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN))
goto trunctlv;
- printf ("\n\t U:%d, M:%d, A:%d, RES:%d",
+ ND_PRINT((ndo, "\n\t U:%d, M:%d, A:%d, RES:%d",
*(tptr) >> 7, (*(tptr) >> 6) & 0x01,
- (*(tptr) >> 5) & 0x01, (*(tptr) & 0x1f));
-
+ (*(tptr) >> 5) & 0x01, (*(tptr) & 0x1f)));
+
tptr++;
-
- printf (", ECT: %08x", EXTRACT_32BITS(tptr));
+
+ ND_PRINT((ndo, ", ECT: %08x", EXTRACT_32BITS(tptr)));
tptr = tptr + 4;
- printf (", BVID: %d, SPVID: %d",
+ ND_PRINT((ndo, ", BVID: %d, SPVID: %d",
(EXTRACT_24BITS(tptr) >> 12) & 0x000fff,
- EXTRACT_24BITS(tptr) & 0x000fff);
+ EXTRACT_24BITS(tptr) & 0x000fff));
tptr = tptr + 3;
len = len - ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN;
- tmp--;
+ tmp--;
}
break;
case ISIS_SUBTLV_SPBM_SI:
- if (!TTEST2(*(tptr), 6))
+ if (!ND_TTEST2(*(tptr), 6))
goto trunctlv;
- printf("\n\t BMAC: %08x", EXTRACT_32BITS(tptr));
+ ND_PRINT((ndo, "\n\t BMAC: %08x", EXTRACT_32BITS(tptr)));
tptr = tptr+4;
- printf("%04x", EXTRACT_16BITS(tptr));
+ ND_PRINT((ndo, "%04x", EXTRACT_16BITS(tptr)));
tptr = tptr+2;
- printf (", RES: %d, VID: %d", EXTRACT_16BITS(tptr) >> 12,
- (EXTRACT_16BITS(tptr)) & 0x0fff);
+ ND_PRINT((ndo, ", RES: %d, VID: %d", EXTRACT_16BITS(tptr) >> 12,
+ (EXTRACT_16BITS(tptr)) & 0x0fff));
tptr = tptr+2;
len = len - 8;
@@ -1530,11 +1521,11 @@ isis_print_mt_capability_subtlv (const u_int8_t *tptr, int len)
while (stlv_len)
{
- printf("\n\t T: %d, R: %d, RES: %d, ISID: %d",
+ ND_PRINT((ndo, "\n\t T: %d, R: %d, RES: %d, ISID: %d",
(EXTRACT_32BITS(tptr) >> 31),
(EXTRACT_32BITS(tptr) >> 30) & 0x01,
(EXTRACT_32BITS(tptr) >> 24) & 0x03f,
- (EXTRACT_32BITS(tptr)) & 0x0ffffff);
+ (EXTRACT_32BITS(tptr)) & 0x0ffffff));
tptr = tptr + 4;
len = len - 4;
@@ -1550,14 +1541,13 @@ isis_print_mt_capability_subtlv (const u_int8_t *tptr, int len)
return 0;
trunctlv:
- printf("\n\t\t packet exceeded snapshot");
+ ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
return(1);
}
-
/* shared routine for printing system, node and lsp-ids */
static char *
-isis_print_id(const u_int8_t *cp, int id_len)
+isis_print_id(const uint8_t *cp, int id_len)
{
int i;
static char id[sizeof("xxxx.xxxx.xxxx.yy-zz")];
@@ -1580,29 +1570,31 @@ isis_print_id(const u_int8_t *cp, int id_len)
/* print the 4-byte metric block which is common found in the old-style TLVs */
static int
-isis_print_metric_block (const struct isis_metric_block *isis_metric_block)
+isis_print_metric_block(netdissect_options *ndo,
+ const struct isis_metric_block *isis_metric_block)
{
- printf(", Default Metric: %d, %s",
+ ND_PRINT((ndo, ", Default Metric: %d, %s",
ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_default),
- ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_default) ? "External" : "Internal");
+ ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_default) ? "External" : "Internal"));
if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block->metric_delay))
- printf("\n\t\t Delay Metric: %d, %s",
+ ND_PRINT((ndo, "\n\t\t Delay Metric: %d, %s",
ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_delay),
- ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_delay) ? "External" : "Internal");
+ ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_delay) ? "External" : "Internal"));
if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block->metric_expense))
- printf("\n\t\t Expense Metric: %d, %s",
+ ND_PRINT((ndo, "\n\t\t Expense Metric: %d, %s",
ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_expense),
- ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_expense) ? "External" : "Internal");
+ ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_expense) ? "External" : "Internal"));
if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block->metric_error))
- printf("\n\t\t Error Metric: %d, %s",
+ ND_PRINT((ndo, "\n\t\t Error Metric: %d, %s",
ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_error),
- ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_error) ? "External" : "Internal");
+ ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_error) ? "External" : "Internal"));
return(1); /* everything is ok */
}
static int
-isis_print_tlv_ip_reach (const u_int8_t *cp, const char *ident, int length)
+isis_print_tlv_ip_reach(netdissect_options *ndo,
+ const uint8_t *cp, const char *ident, int length)
{
int prefix_len;
const struct isis_tlv_ip_reach *tlv_ip_reach;
@@ -1611,50 +1603,50 @@ isis_print_tlv_ip_reach (const u_int8_t *cp, const char *ident, int length)
while (length > 0) {
if ((size_t)length < sizeof(*tlv_ip_reach)) {
- printf("short IPv4 Reachability (%d vs %lu)",
+ ND_PRINT((ndo, "short IPv4 Reachability (%d vs %lu)",
length,
- (unsigned long)sizeof(*tlv_ip_reach));
+ (unsigned long)sizeof(*tlv_ip_reach)));
return (0);
}
- if (!TTEST(*tlv_ip_reach))
+ if (!ND_TTEST(*tlv_ip_reach))
return (0);
prefix_len = mask2plen(EXTRACT_32BITS(tlv_ip_reach->mask));
if (prefix_len == -1)
- printf("%sIPv4 prefix: %s mask %s",
+ ND_PRINT((ndo, "%sIPv4 prefix: %s mask %s",
ident,
- ipaddr_string((tlv_ip_reach->prefix)),
- ipaddr_string((tlv_ip_reach->mask)));
+ ipaddr_string(ndo, (tlv_ip_reach->prefix)),
+ ipaddr_string(ndo, (tlv_ip_reach->mask))));
else
- printf("%sIPv4 prefix: %15s/%u",
+ ND_PRINT((ndo, "%sIPv4 prefix: %15s/%u",
ident,
- ipaddr_string((tlv_ip_reach->prefix)),
- prefix_len);
+ ipaddr_string(ndo, (tlv_ip_reach->prefix)),
+ prefix_len));
- printf(", Distribution: %s, Metric: %u, %s",
+ ND_PRINT((ndo, ", Distribution: %s, Metric: %u, %s",
ISIS_LSP_TLV_METRIC_UPDOWN(tlv_ip_reach->isis_metric_block.metric_default) ? "down" : "up",
ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_default),
- ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_default) ? "External" : "Internal");
+ ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_default) ? "External" : "Internal"));
if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach->isis_metric_block.metric_delay))
- printf("%s Delay Metric: %u, %s",
+ ND_PRINT((ndo, "%s Delay Metric: %u, %s",
ident,
ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_delay),
- ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_delay) ? "External" : "Internal");
-
+ ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_delay) ? "External" : "Internal"));
+
if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach->isis_metric_block.metric_expense))
- printf("%s Expense Metric: %u, %s",
+ ND_PRINT((ndo, "%s Expense Metric: %u, %s",
ident,
ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_expense),
- ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_expense) ? "External" : "Internal");
-
+ ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_expense) ? "External" : "Internal"));
+
if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach->isis_metric_block.metric_error))
- printf("%s Error Metric: %u, %s",
+ ND_PRINT((ndo, "%s Error Metric: %u, %s",
ident,
ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_error),
- ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_error) ? "External" : "Internal");
+ ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_error) ? "External" : "Internal"));
length -= sizeof(struct isis_tlv_ip_reach);
tlv_ip_reach++;
@@ -1668,50 +1660,47 @@ isis_print_tlv_ip_reach (const u_int8_t *cp, const char *ident, int length)
*/
static int
-isis_print_ip_reach_subtlv (const u_int8_t *tptr,int subt,int subl,const char *ident) {
+isis_print_ip_reach_subtlv(netdissect_options *ndo,
+ const uint8_t *tptr, int subt, int subl,
+ const char *ident) {
/* first lets see if we know the subTLVs name*/
- printf("%s%s subTLV #%u, length: %u",
- ident,
- tok2str(isis_ext_ip_reach_subtlv_values,
- "unknown",
- subt),
- subt,
- subl);
+ ND_PRINT((ndo, "%s%s subTLV #%u, length: %u",
+ ident, tok2str(isis_ext_ip_reach_subtlv_values, "unknown", subt),
+ subt, subl));
- if (!TTEST2(*tptr,subl))
+ if (!ND_TTEST2(*tptr,subl))
goto trunctlv;
switch(subt) {
case ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR: /* fall through */
case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32:
while (subl >= 4) {
- printf(", 0x%08x (=%u)",
+ ND_PRINT((ndo, ", 0x%08x (=%u)",
EXTRACT_32BITS(tptr),
- EXTRACT_32BITS(tptr));
+ EXTRACT_32BITS(tptr)));
tptr+=4;
subl-=4;
}
break;
case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64:
while (subl >= 8) {
- printf(", 0x%08x%08x",
+ ND_PRINT((ndo, ", 0x%08x%08x",
EXTRACT_32BITS(tptr),
- EXTRACT_32BITS(tptr+4));
+ EXTRACT_32BITS(tptr+4)));
tptr+=8;
subl-=8;
}
break;
default:
- if(!print_unknown_data(tptr,"\n\t\t ",
- subl))
+ if (!print_unknown_data(ndo, tptr, "\n\t\t ", subl))
return(0);
break;
}
return(1);
-
+
trunctlv:
- printf("%spacket exceeded snapshot",ident);
+ ND_PRINT((ndo, "%spacket exceeded snapshot", ident));
return(0);
}
@@ -1721,121 +1710,120 @@ trunctlv:
*/
static int
-isis_print_is_reach_subtlv (const u_int8_t *tptr,u_int subt,u_int subl,const char *ident) {
+isis_print_is_reach_subtlv(netdissect_options *ndo,
+ const uint8_t *tptr, u_int subt, u_int subl,
+ const char *ident) {
u_int te_class,priority_level,gmpls_switch_cap;
union { /* int to float conversion buffer for several subTLVs */
- float f;
- u_int32_t i;
+ float f;
+ uint32_t i;
} bw;
/* first lets see if we know the subTLVs name*/
- printf("%s%s subTLV #%u, length: %u",
- ident,
- tok2str(isis_ext_is_reach_subtlv_values,
- "unknown",
- subt),
- subt,
- subl);
+ ND_PRINT((ndo, "%s%s subTLV #%u, length: %u",
+ ident, tok2str(isis_ext_is_reach_subtlv_values, "unknown", subt),
+ subt, subl));
- if (!TTEST2(*tptr,subl))
+ if (!ND_TTEST2(*tptr,subl))
goto trunctlv;
switch(subt) {
- case ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP:
+ case ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP:
case ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID:
case ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID:
if (subl >= 4) {
- printf(", 0x%08x", EXTRACT_32BITS(tptr));
+ ND_PRINT((ndo, ", 0x%08x", EXTRACT_32BITS(tptr)));
if (subl == 8) /* rfc4205 */
- printf(", 0x%08x", EXTRACT_32BITS(tptr+4));
+ ND_PRINT((ndo, ", 0x%08x", EXTRACT_32BITS(tptr+4)));
}
break;
case ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR:
case ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR:
if (subl >= sizeof(struct in_addr))
- printf(", %s", ipaddr_string(tptr));
+ ND_PRINT((ndo, ", %s", ipaddr_string(ndo, tptr)));
break;
case ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW :
- case ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW:
+ case ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW:
if (subl >= 4) {
bw.i = EXTRACT_32BITS(tptr);
- printf(", %.3f Mbps", bw.f*8/1000000 );
+ ND_PRINT((ndo, ", %.3f Mbps", bw.f * 8 / 1000000));
}
break;
case ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW :
if (subl >= 32) {
for (te_class = 0; te_class < 8; te_class++) {
bw.i = EXTRACT_32BITS(tptr);
- printf("%s TE-Class %u: %.3f Mbps",
+ ND_PRINT((ndo, "%s TE-Class %u: %.3f Mbps",
ident,
te_class,
- bw.f*8/1000000 );
+ bw.f * 8 / 1000000));
tptr+=4;
}
}
break;
case ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS: /* fall through */
case ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD:
- printf("%sBandwidth Constraints Model ID: %s (%u)",
+ ND_PRINT((ndo, "%sBandwidth Constraints Model ID: %s (%u)",
ident,
tok2str(diffserv_te_bc_values, "unknown", *tptr),
- *tptr);
+ *tptr));
tptr++;
/* decode BCs until the subTLV ends */
for (te_class = 0; te_class < (subl-1)/4; te_class++) {
bw.i = EXTRACT_32BITS(tptr);
- printf("%s Bandwidth constraint CT%u: %.3f Mbps",
+ ND_PRINT((ndo, "%s Bandwidth constraint CT%u: %.3f Mbps",
ident,
te_class,
- bw.f*8/1000000 );
+ bw.f * 8 / 1000000));
tptr+=4;
}
break;
case ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC:
if (subl >= 3)
- printf(", %u", EXTRACT_24BITS(tptr));
+ ND_PRINT((ndo, ", %u", EXTRACT_24BITS(tptr)));
break;
case ISIS_SUBTLV_EXT_IS_REACH_LINK_ATTRIBUTE:
if (subl == 2) {
- printf(", [ %s ] (0x%04x)",
+ ND_PRINT((ndo, ", [ %s ] (0x%04x)",
bittok2str(isis_subtlv_link_attribute_values,
"Unknown",
EXTRACT_16BITS(tptr)),
- EXTRACT_16BITS(tptr));
+ EXTRACT_16BITS(tptr)));
}
break;
case ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE:
if (subl >= 2) {
- printf(", %s, Priority %u",
+ ND_PRINT((ndo, ", %s, Priority %u",
bittok2str(gmpls_link_prot_values, "none", *tptr),
- *(tptr+1));
+ *(tptr+1)));
}
break;
case ISIS_SUBTLV_SPB_METRIC:
if (subl >= 6) {
- printf (", LM: %u", EXTRACT_24BITS(tptr));
+ ND_PRINT((ndo, ", LM: %u", EXTRACT_24BITS(tptr)));
tptr=tptr+3;
- printf (", P: %u", *(tptr));
- printf (", P-ID: %u", EXTRACT_16BITS(++tptr));
+ ND_PRINT((ndo, ", P: %u", *(tptr)));
+ tptr++;
+ ND_PRINT((ndo, ", P-ID: %u", EXTRACT_16BITS(tptr)));
}
break;
case ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR:
if (subl >= 36) {
gmpls_switch_cap = *tptr;
- printf("%s Interface Switching Capability:%s",
+ ND_PRINT((ndo, "%s Interface Switching Capability:%s",
ident,
- tok2str(gmpls_switch_cap_values, "Unknown", gmpls_switch_cap));
- printf(", LSP Encoding: %s",
- tok2str(gmpls_encoding_values, "Unknown", *(tptr+1)));
+ tok2str(gmpls_switch_cap_values, "Unknown", gmpls_switch_cap)));
+ ND_PRINT((ndo, ", LSP Encoding: %s",
+ tok2str(gmpls_encoding_values, "Unknown", *(tptr + 1))));
tptr+=4;
- printf("%s Max LSP Bandwidth:",ident);
+ ND_PRINT((ndo, "%s Max LSP Bandwidth:", ident));
for (priority_level = 0; priority_level < 8; priority_level++) {
bw.i = EXTRACT_32BITS(tptr);
- printf("%s priority level %d: %.3f Mbps",
+ ND_PRINT((ndo, "%s priority level %d: %.3f Mbps",
ident,
priority_level,
- bw.f*8/1000000 );
+ bw.f * 8 / 1000000));
tptr+=4;
}
subl-=36;
@@ -1845,36 +1833,34 @@ isis_print_is_reach_subtlv (const u_int8_t *tptr,u_int subt,u_int subl,const cha
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));
+ ND_PRINT((ndo, "%s Min LSP Bandwidth: %.3f Mbps", ident, bw.f * 8 / 1000000));
+ ND_PRINT((ndo, "%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)));
+ ND_PRINT((ndo, "%s Min LSP Bandwidth: %.3f Mbps", ident, bw.f * 8 / 1000000));
+ ND_PRINT((ndo, "%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))
+ if (!print_unknown_data(ndo, tptr, "\n\t\t ", subl))
return(0);
}
}
}
break;
default:
- if(!print_unknown_data(tptr,"\n\t\t ",
- subl))
+ if (!print_unknown_data(ndo, tptr, "\n\t\t ", subl))
return(0);
break;
}
return(1);
trunctlv:
- printf("%spacket exceeded snapshot",ident);
+ ND_PRINT((ndo, "%spacket exceeded snapshot", ident));
return(0);
}
@@ -1885,40 +1871,41 @@ trunctlv:
*/
static int
-isis_print_ext_is_reach (const u_int8_t *tptr,const char *ident, int tlv_type) {
+isis_print_ext_is_reach(netdissect_options *ndo,
+ const uint8_t *tptr, const char *ident, int tlv_type) {
char ident_buffer[20];
int subtlv_type,subtlv_len,subtlv_sum_len;
int proc_bytes = 0; /* how many bytes did we process ? */
-
- if (!TTEST2(*tptr, NODE_ID_LEN))
+
+ if (!ND_TTEST2(*tptr, NODE_ID_LEN))
return(0);
- printf("%sIS Neighbor: %s", ident, isis_print_id(tptr, NODE_ID_LEN));
+ ND_PRINT((ndo, "%sIS Neighbor: %s", ident, isis_print_id(tptr, NODE_ID_LEN)));
tptr+=(NODE_ID_LEN);
if (tlv_type != ISIS_TLV_IS_ALIAS_ID) { /* the Alias TLV Metric field is implicit 0 */
- if (!TTEST2(*tptr, 3)) /* and is therefore skipped */
+ if (!ND_TTEST2(*tptr, 3)) /* and is therefore skipped */
return(0);
- printf(", Metric: %d",EXTRACT_24BITS(tptr));
+ ND_PRINT((ndo, ", Metric: %d", EXTRACT_24BITS(tptr)));
tptr+=3;
}
-
- if (!TTEST2(*tptr, 1))
+
+ if (!ND_TTEST2(*tptr, 1))
return(0);
subtlv_sum_len=*(tptr++); /* read out subTLV length */
proc_bytes=NODE_ID_LEN+3+1;
- printf(", %ssub-TLVs present",subtlv_sum_len ? "" : "no ");
+ ND_PRINT((ndo, ", %ssub-TLVs present",subtlv_sum_len ? "" : "no "));
if (subtlv_sum_len) {
- printf(" (%u)",subtlv_sum_len);
+ ND_PRINT((ndo, " (%u)", subtlv_sum_len));
while (subtlv_sum_len>0) {
- if (!TTEST2(*tptr,2))
+ if (!ND_TTEST2(*tptr,2))
return(0);
subtlv_type=*(tptr++);
subtlv_len=*(tptr++);
/* prepend the ident string */
snprintf(ident_buffer, sizeof(ident_buffer), "%s ",ident);
- if(!isis_print_is_reach_subtlv(tptr,subtlv_type,subtlv_len,ident_buffer))
+ if (!isis_print_is_reach_subtlv(ndo, tptr, subtlv_type, subtlv_len, ident_buffer))
return(0);
tptr+=subtlv_len;
subtlv_sum_len-=(subtlv_len+2);
@@ -1934,20 +1921,21 @@ isis_print_ext_is_reach (const u_int8_t *tptr,const char *ident, int tlv_type) {
*/
static int
-isis_print_mtid (const u_int8_t *tptr,const char *ident) {
-
- if (!TTEST2(*tptr, 2))
+isis_print_mtid(netdissect_options *ndo,
+ const uint8_t *tptr, const char *ident) {
+
+ if (!ND_TTEST2(*tptr, 2))
return(0);
- printf("%s%s",
+ ND_PRINT((ndo, "%s%s",
ident,
tok2str(isis_mt_values,
"Reserved for IETF Consensus",
- ISIS_MASK_MTID(EXTRACT_16BITS(tptr))));
+ ISIS_MASK_MTID(EXTRACT_16BITS(tptr)))));
- printf(" Topology (0x%03x), Flags: [%s]",
+ ND_PRINT((ndo, " Topology (0x%03x), Flags: [%s]",
ISIS_MASK_MTID(EXTRACT_16BITS(tptr)),
- bittok2str(isis_mt_flag_values, "none",ISIS_MASK_MTFLAGS(EXTRACT_16BITS(tptr))));
+ bittok2str(isis_mt_flag_values, "none",ISIS_MASK_MTFLAGS(EXTRACT_16BITS(tptr)))));
return(2);
}
@@ -1960,44 +1948,45 @@ isis_print_mtid (const u_int8_t *tptr,const char *ident) {
*/
static int
-isis_print_extd_ip_reach (const u_int8_t *tptr, const char *ident, u_int16_t afi) {
+isis_print_extd_ip_reach(netdissect_options *ndo,
+ const uint8_t *tptr, const char *ident, uint16_t afi) {
char ident_buffer[20];
#ifdef INET6
- u_int8_t prefix[sizeof(struct in6_addr)]; /* shared copy buffer for IPv4 and IPv6 prefixes */
+ uint8_t prefix[sizeof(struct in6_addr)]; /* shared copy buffer for IPv4 and IPv6 prefixes */
#else
- u_int8_t prefix[sizeof(struct in_addr)]; /* shared copy buffer for IPv4 prefixes */
+ uint8_t prefix[sizeof(struct in_addr)]; /* shared copy buffer for IPv4 prefixes */
#endif
u_int metric, status_byte, bit_length, byte_length, sublen, processed, subtlvtype, subtlvlen;
- if (!TTEST2(*tptr, 4))
+ if (!ND_TTEST2(*tptr, 4))
return (0);
metric = EXTRACT_32BITS(tptr);
processed=4;
tptr+=4;
-
+
if (afi == AF_INET) {
- if (!TTEST2(*tptr, 1)) /* fetch status byte */
+ if (!ND_TTEST2(*tptr, 1)) /* fetch status byte */
return (0);
status_byte=*(tptr++);
bit_length = status_byte&0x3f;
if (bit_length > 32) {
- printf("%sIPv4 prefix: bad bit length %u",
+ ND_PRINT((ndo, "%sIPv4 prefix: bad bit length %u",
ident,
- bit_length);
+ bit_length));
return (0);
}
processed++;
#ifdef INET6
} else if (afi == AF_INET6) {
- if (!TTEST2(*tptr, 1)) /* fetch status & prefix_len byte */
+ if (!ND_TTEST2(*tptr, 1)) /* fetch status & prefix_len byte */
return (0);
status_byte=*(tptr++);
bit_length=*(tptr++);
if (bit_length > 128) {
- printf("%sIPv6 prefix: bad bit length %u",
+ ND_PRINT((ndo, "%sIPv6 prefix: bad bit length %u",
ident,
- bit_length);
+ bit_length));
return (0);
}
processed+=2;
@@ -2006,8 +1995,8 @@ isis_print_extd_ip_reach (const u_int8_t *tptr, const char *ident, u_int16_t afi
return (0); /* somebody is fooling us */
byte_length = (bit_length + 7) / 8; /* prefix has variable length encoding */
-
- if (!TTEST2(*tptr, byte_length))
+
+ if (!ND_TTEST2(*tptr, byte_length))
return (0);
memset(prefix, 0, sizeof prefix); /* clear the copy buffer */
memcpy(prefix,tptr,byte_length); /* copy as much as is stored in the TLV */
@@ -2015,31 +2004,31 @@ isis_print_extd_ip_reach (const u_int8_t *tptr, const char *ident, u_int16_t afi
processed+=byte_length;
if (afi == AF_INET)
- printf("%sIPv4 prefix: %15s/%u",
+ ND_PRINT((ndo, "%sIPv4 prefix: %15s/%u",
ident,
- ipaddr_string(prefix),
- bit_length);
+ ipaddr_string(ndo, prefix),
+ bit_length));
#ifdef INET6
if (afi == AF_INET6)
- printf("%sIPv6 prefix: %s/%u",
+ ND_PRINT((ndo, "%sIPv6 prefix: %s/%u",
ident,
- ip6addr_string(prefix),
- bit_length);
-#endif
-
- printf(", Distribution: %s, Metric: %u",
+ ip6addr_string(ndo, prefix),
+ bit_length));
+#endif
+
+ ND_PRINT((ndo, ", Distribution: %s, Metric: %u",
ISIS_MASK_TLV_EXTD_IP_UPDOWN(status_byte) ? "down" : "up",
- metric);
+ metric));
if (afi == AF_INET && ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte))
- printf(", sub-TLVs present");
+ ND_PRINT((ndo, ", sub-TLVs present"));
#ifdef INET6
if (afi == AF_INET6)
- printf(", %s%s",
+ ND_PRINT((ndo, ", %s%s",
ISIS_MASK_TLV_EXTD_IP6_IE(status_byte) ? "External" : "Internal",
- ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte) ? ", sub-TLVs present" : "");
+ ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte) ? ", sub-TLVs present" : ""));
#endif
-
+
if ((afi == AF_INET && ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte))
#ifdef INET6
|| (afi == AF_INET6 && ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte))
@@ -2049,20 +2038,20 @@ isis_print_extd_ip_reach (const u_int8_t *tptr, const char *ident, u_int16_t afi
than one subTLV - therefore the first byte must reflect
the aggregate bytecount of the subTLVs for this prefix
*/
- if (!TTEST2(*tptr, 1))
+ if (!ND_TTEST2(*tptr, 1))
return (0);
sublen=*(tptr++);
processed+=sublen+1;
- printf(" (%u)",sublen); /* print out subTLV length */
-
+ ND_PRINT((ndo, " (%u)", sublen)); /* print out subTLV length */
+
while (sublen>0) {
- if (!TTEST2(*tptr,2))
+ if (!ND_TTEST2(*tptr,2))
return (0);
subtlvtype=*(tptr++);
subtlvlen=*(tptr++);
/* prepend the ident string */
snprintf(ident_buffer, sizeof(ident_buffer), "%s ",ident);
- if(!isis_print_ip_reach_subtlv(tptr,subtlvtype,subtlvlen,ident_buffer))
+ if (!isis_print_ip_reach_subtlv(ndo, tptr, subtlvtype, subtlvlen, ident_buffer))
return(0);
tptr+=subtlvlen;
sublen-=(subtlvlen+2);
@@ -2076,7 +2065,9 @@ isis_print_extd_ip_reach (const u_int8_t *tptr, const char *ident, u_int16_t afi
* Decode IS-IS packets. Return 0 on error.
*/
-static int isis_print (const u_int8_t *p, u_int length)
+static int
+isis_print(netdissect_options *ndo,
+ const uint8_t *p, u_int length)
{
const struct isis_common_header *isis_header;
@@ -2091,9 +2082,9 @@ static int isis_print (const u_int8_t *p, u_int length)
const struct isis_tlv_is_reach *tlv_is_reach;
const struct isis_tlv_es_reach *tlv_es_reach;
- u_int8_t pdu_type, max_area, id_length, tlv_type, tlv_len, tmp, alen, lan_alen, prefix_len;
- u_int8_t ext_is_len, ext_ip_len, mt_len;
- const u_int8_t *optr, *pptr, *tptr;
+ uint8_t pdu_type, max_area, id_length, tlv_type, tlv_len, tmp, alen, lan_alen, prefix_len;
+ uint8_t ext_is_len, ext_ip_len, mt_len;
+ const uint8_t *optr, *pptr, *tptr;
u_short packet_len,pdu_len, key_id;
u_int i,vendor_id;
int sigcheck;
@@ -2103,7 +2094,7 @@ static int isis_print (const u_int8_t *p, u_int length)
need it for parsing the checksum TLV and authentication
TLV verification */
isis_header = (const struct isis_common_header *)p;
- TCHECK(*isis_header);
+ ND_TCHECK(*isis_header);
pptr = p+(ISIS_COMMON_HEADER_SIZE);
header_iih_lan = (const struct isis_iih_lan_header *)pptr;
header_iih_ptp = (const struct isis_iih_ptp_header *)pptr;
@@ -2111,26 +2102,26 @@ static int isis_print (const u_int8_t *p, u_int length)
header_csnp = (const struct isis_csnp_header *)pptr;
header_psnp = (const struct isis_psnp_header *)pptr;
- if (!eflag)
- printf("IS-IS");
+ if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, "IS-IS"));
/*
* Sanity checking of the header.
*/
if (isis_header->version != ISIS_VERSION) {
- printf("version %d packet not supported", isis_header->version);
+ ND_PRINT((ndo, "version %d packet not supported", isis_header->version));
return (0);
}
if ((isis_header->id_length != SYSTEM_ID_LEN) && (isis_header->id_length != 0)) {
- printf("system ID length of %d is not supported",
- isis_header->id_length);
+ ND_PRINT((ndo, "system ID length of %d is not supported",
+ isis_header->id_length));
return (0);
}
if (isis_header->pdu_version != ISIS_VERSION) {
- printf("version %d packet not supported", isis_header->pdu_version);
+ ND_PRINT((ndo, "version %d packet not supported", isis_header->pdu_version));
return (0);
}
@@ -2140,7 +2131,7 @@ static int isis_print (const u_int8_t *p, u_int length)
max_area = 3; /* silly shit */
break;
case 255:
- printf("bad packet -- 255 areas");
+ ND_PRINT((ndo, "bad packet -- 255 areas"));
return (0);
default:
break;
@@ -2168,58 +2159,58 @@ static int isis_print (const u_int8_t *p, u_int length)
}
/* toss any non 6-byte sys-ID len PDUs */
- if (id_length != 6 ) {
- printf("bad packet -- illegal sys-ID length (%u)", id_length);
+ if (id_length != 6 ) {
+ ND_PRINT((ndo, "bad packet -- illegal sys-ID length (%u)", id_length));
return (0);
}
pdu_type=isis_header->pdu_type;
/* in non-verbose mode print the basic PDU Type plus PDU specific brief information*/
- if (vflag < 1) {
- printf("%s%s",
- eflag ? "" : ", ",
- tok2str(isis_pdu_values,"unknown PDU-Type %u",pdu_type));
+ if (ndo->ndo_vflag < 1) {
+ ND_PRINT((ndo, "%s%s",
+ ndo->ndo_eflag ? "" : ", ",
+ tok2str(isis_pdu_values, "unknown PDU-Type %u", pdu_type)));
switch (pdu_type) {
case ISIS_PDU_L1_LAN_IIH:
case ISIS_PDU_L2_LAN_IIH:
- printf(", src-id %s",
- isis_print_id(header_iih_lan->source_id,SYSTEM_ID_LEN));
- printf(", lan-id %s, prio %u",
+ ND_PRINT((ndo, ", src-id %s",
+ isis_print_id(header_iih_lan->source_id, SYSTEM_ID_LEN)));
+ ND_PRINT((ndo, ", lan-id %s, prio %u",
isis_print_id(header_iih_lan->lan_id,NODE_ID_LEN),
- header_iih_lan->priority);
+ header_iih_lan->priority));
break;
case ISIS_PDU_PTP_IIH:
- printf(", src-id %s", isis_print_id(header_iih_ptp->source_id,SYSTEM_ID_LEN));
+ ND_PRINT((ndo, ", src-id %s", isis_print_id(header_iih_ptp->source_id, SYSTEM_ID_LEN)));
break;
case ISIS_PDU_L1_LSP:
case ISIS_PDU_L2_LSP:
- printf(", lsp-id %s, seq 0x%08x, lifetime %5us",
+ ND_PRINT((ndo, ", lsp-id %s, seq 0x%08x, lifetime %5us",
isis_print_id(header_lsp->lsp_id, LSP_ID_LEN),
EXTRACT_32BITS(header_lsp->sequence_number),
- EXTRACT_16BITS(header_lsp->remaining_lifetime));
+ EXTRACT_16BITS(header_lsp->remaining_lifetime)));
break;
case ISIS_PDU_L1_CSNP:
case ISIS_PDU_L2_CSNP:
- printf(", src-id %s", isis_print_id(header_csnp->source_id,NODE_ID_LEN));
+ ND_PRINT((ndo, ", src-id %s", isis_print_id(header_csnp->source_id, NODE_ID_LEN)));
break;
case ISIS_PDU_L1_PSNP:
case ISIS_PDU_L2_PSNP:
- printf(", src-id %s", isis_print_id(header_psnp->source_id,NODE_ID_LEN));
+ ND_PRINT((ndo, ", src-id %s", isis_print_id(header_psnp->source_id, NODE_ID_LEN)));
break;
}
- printf(", length %u", length);
+ ND_PRINT((ndo, ", length %u", length));
return(1);
}
/* ok they seem to want to know everything - lets fully decode it */
- printf("%slength %u", eflag ? "" : ", ",length);
+ ND_PRINT((ndo, "%slength %u", ndo->ndo_eflag ? "" : ", ", length));
- printf("\n\t%s, hlen: %u, v: %u, pdu-v: %u, sys-id-len: %u (%u), max-area: %u (%u)",
+ ND_PRINT((ndo, "\n\t%s, hlen: %u, v: %u, pdu-v: %u, sys-id-len: %u (%u), max-area: %u (%u)",
tok2str(isis_pdu_values,
"unknown, type %u",
pdu_type),
@@ -2229,10 +2220,10 @@ static int isis_print (const u_int8_t *p, u_int length)
id_length,
isis_header->id_length,
max_area,
- isis_header->max_area);
+ isis_header->max_area));
- if (vflag > 1) {
- if(!print_unknown_data(optr,"\n\t",8)) /* provide the _o_riginal pointer */
+ if (ndo->ndo_vflag > 1) {
+ if (!print_unknown_data(ndo, optr, "\n\t", 8)) /* provide the _o_riginal pointer */
return(0); /* for optionally debugging the common header */
}
@@ -2241,8 +2232,8 @@ static int isis_print (const u_int8_t *p, u_int length)
case ISIS_PDU_L1_LAN_IIH:
case ISIS_PDU_L2_LAN_IIH:
if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE)) {
- printf(", bogus fixed header length %u should be %lu",
- isis_header->fixed_len, (unsigned long)ISIS_IIH_LAN_HEADER_SIZE);
+ ND_PRINT((ndo, ", bogus fixed header length %u should be %lu",
+ isis_header->fixed_len, (unsigned long)ISIS_IIH_LAN_HEADER_SIZE));
return (0);
}
@@ -2252,23 +2243,23 @@ static int isis_print (const u_int8_t *p, u_int length)
length=pdu_len;
}
- TCHECK(*header_iih_lan);
- printf("\n\t source-id: %s, holding time: %us, Flags: [%s]",
+ ND_TCHECK(*header_iih_lan);
+ ND_PRINT((ndo, "\n\t source-id: %s, holding time: %us, Flags: [%s]",
isis_print_id(header_iih_lan->source_id,SYSTEM_ID_LEN),
EXTRACT_16BITS(header_iih_lan->holding_time),
tok2str(isis_iih_circuit_type_values,
"unknown circuit type 0x%02x",
- header_iih_lan->circuit_type));
+ header_iih_lan->circuit_type)));
- printf("\n\t lan-id: %s, Priority: %u, PDU length: %u",
+ ND_PRINT((ndo, "\n\t lan-id: %s, Priority: %u, PDU length: %u",
isis_print_id(header_iih_lan->lan_id, NODE_ID_LEN),
(header_iih_lan->priority) & ISIS_LAN_PRIORITY_MASK,
- pdu_len);
+ pdu_len));
- if (vflag > 1) {
- if(!print_unknown_data(pptr,"\n\t ",ISIS_IIH_LAN_HEADER_SIZE))
- return(0);
- }
+ if (ndo->ndo_vflag > 1) {
+ if (!print_unknown_data(ndo, pptr, "\n\t ", ISIS_IIH_LAN_HEADER_SIZE))
+ return(0);
+ }
packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE);
pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE);
@@ -2276,8 +2267,8 @@ static int isis_print (const u_int8_t *p, u_int length)
case ISIS_PDU_PTP_IIH:
if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE)) {
- printf(", bogus fixed header length %u should be %lu",
- isis_header->fixed_len, (unsigned long)ISIS_IIH_PTP_HEADER_SIZE);
+ ND_PRINT((ndo, ", bogus fixed header length %u should be %lu",
+ isis_header->fixed_len, (unsigned long)ISIS_IIH_PTP_HEADER_SIZE));
return (0);
}
@@ -2287,22 +2278,22 @@ static int isis_print (const u_int8_t *p, u_int length)
length=pdu_len;
}
- TCHECK(*header_iih_ptp);
- printf("\n\t source-id: %s, holding time: %us, Flags: [%s]",
+ ND_TCHECK(*header_iih_ptp);
+ ND_PRINT((ndo, "\n\t source-id: %s, holding time: %us, Flags: [%s]",
isis_print_id(header_iih_ptp->source_id,SYSTEM_ID_LEN),
EXTRACT_16BITS(header_iih_ptp->holding_time),
tok2str(isis_iih_circuit_type_values,
"unknown circuit type 0x%02x",
- header_iih_ptp->circuit_type));
+ header_iih_ptp->circuit_type)));
- printf("\n\t circuit-id: 0x%02x, PDU length: %u",
+ ND_PRINT((ndo, "\n\t circuit-id: 0x%02x, PDU length: %u",
header_iih_ptp->circuit_id,
- pdu_len);
+ pdu_len));
- if (vflag > 1) {
- if(!print_unknown_data(pptr,"\n\t ",ISIS_IIH_PTP_HEADER_SIZE))
- return(0);
- }
+ if (ndo->ndo_vflag > 1) {
+ if (!print_unknown_data(ndo, pptr, "\n\t ", ISIS_IIH_PTP_HEADER_SIZE))
+ return(0);
+ }
packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE);
pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE);
@@ -2311,8 +2302,8 @@ static int isis_print (const u_int8_t *p, u_int length)
case ISIS_PDU_L1_LSP:
case ISIS_PDU_L2_LSP:
if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE)) {
- printf(", bogus fixed header length %u should be %lu",
- isis_header->fixed_len, (unsigned long)ISIS_LSP_HEADER_SIZE);
+ ND_PRINT((ndo, ", bogus fixed header length %u should be %lu",
+ isis_header->fixed_len, (unsigned long)ISIS_LSP_HEADER_SIZE));
return (0);
}
@@ -2322,15 +2313,15 @@ static int isis_print (const u_int8_t *p, u_int length)
length=pdu_len;
}
- TCHECK(*header_lsp);
- printf("\n\t lsp-id: %s, seq: 0x%08x, lifetime: %5us\n\t chksum: 0x%04x",
+ ND_TCHECK(*header_lsp);
+ ND_PRINT((ndo, "\n\t lsp-id: %s, seq: 0x%08x, lifetime: %5us\n\t chksum: 0x%04x",
isis_print_id(header_lsp->lsp_id, LSP_ID_LEN),
EXTRACT_32BITS(header_lsp->sequence_number),
EXTRACT_16BITS(header_lsp->remaining_lifetime),
- EXTRACT_16BITS(header_lsp->checksum));
+ EXTRACT_16BITS(header_lsp->checksum)));
- osi_print_cksum((u_int8_t *)header_lsp->lsp_id,
+ osi_print_cksum(ndo, (uint8_t *)header_lsp->lsp_id,
EXTRACT_16BITS(header_lsp->checksum), 12, length-12);
/*
@@ -2340,26 +2331,27 @@ static int isis_print (const u_int8_t *p, u_int length)
header_lsp->checksum[1] = 0;
header_lsp->remaining_lifetime[0] = 0;
header_lsp->remaining_lifetime[1] = 0;
-
- printf(", PDU length: %u, Flags: [ %s",
+
+ ND_PRINT((ndo, ", PDU length: %u, Flags: [ %s",
pdu_len,
- ISIS_MASK_LSP_OL_BIT(header_lsp->typeblock) ? "Overload bit set, " : "");
+ ISIS_MASK_LSP_OL_BIT(header_lsp->typeblock) ? "Overload bit set, " : ""));
if (ISIS_MASK_LSP_ATT_BITS(header_lsp->typeblock)) {
- printf("%s", ISIS_MASK_LSP_ATT_DEFAULT_BIT(header_lsp->typeblock) ? "default " : "");
- printf("%s", ISIS_MASK_LSP_ATT_DELAY_BIT(header_lsp->typeblock) ? "delay " : "");
- printf("%s", ISIS_MASK_LSP_ATT_EXPENSE_BIT(header_lsp->typeblock) ? "expense " : "");
- printf("%s", ISIS_MASK_LSP_ATT_ERROR_BIT(header_lsp->typeblock) ? "error " : "");
- printf("ATT bit set, ");
+ ND_PRINT((ndo, "%s", ISIS_MASK_LSP_ATT_DEFAULT_BIT(header_lsp->typeblock) ? "default " : ""));
+ ND_PRINT((ndo, "%s", ISIS_MASK_LSP_ATT_DELAY_BIT(header_lsp->typeblock) ? "delay " : ""));
+ ND_PRINT((ndo, "%s", ISIS_MASK_LSP_ATT_EXPENSE_BIT(header_lsp->typeblock) ? "expense " : ""));
+ ND_PRINT((ndo, "%s", ISIS_MASK_LSP_ATT_ERROR_BIT(header_lsp->typeblock) ? "error " : ""));
+ ND_PRINT((ndo, "ATT bit set, "));
}
- printf("%s", ISIS_MASK_LSP_PARTITION_BIT(header_lsp->typeblock) ? "P bit set, " : "");
- printf("%s ]", tok2str(isis_lsp_istype_values,"Unknown(0x%x)",ISIS_MASK_LSP_ISTYPE_BITS(header_lsp->typeblock)));
+ ND_PRINT((ndo, "%s", ISIS_MASK_LSP_PARTITION_BIT(header_lsp->typeblock) ? "P bit set, " : ""));
+ ND_PRINT((ndo, "%s ]", tok2str(isis_lsp_istype_values, "Unknown(0x%x)",
+ ISIS_MASK_LSP_ISTYPE_BITS(header_lsp->typeblock))));
- if (vflag > 1) {
- if(!print_unknown_data(pptr,"\n\t ",ISIS_LSP_HEADER_SIZE))
- return(0);
- }
+ if (ndo->ndo_vflag > 1) {
+ if (!print_unknown_data(ndo, pptr, "\n\t ", ISIS_LSP_HEADER_SIZE))
+ return(0);
+ }
packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE);
pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE);
@@ -2368,8 +2360,8 @@ static int isis_print (const u_int8_t *p, u_int length)
case ISIS_PDU_L1_CSNP:
case ISIS_PDU_L2_CSNP:
if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE)) {
- printf(", bogus fixed header length %u should be %lu",
- isis_header->fixed_len, (unsigned long)ISIS_CSNP_HEADER_SIZE);
+ ND_PRINT((ndo, ", bogus fixed header length %u should be %lu",
+ isis_header->fixed_len, (unsigned long)ISIS_CSNP_HEADER_SIZE));
return (0);
}
@@ -2379,19 +2371,19 @@ static int isis_print (const u_int8_t *p, u_int length)
length=pdu_len;
}
- TCHECK(*header_csnp);
- printf("\n\t source-id: %s, PDU length: %u",
+ ND_TCHECK(*header_csnp);
+ ND_PRINT((ndo, "\n\t source-id: %s, PDU length: %u",
isis_print_id(header_csnp->source_id, NODE_ID_LEN),
- pdu_len);
- printf("\n\t start lsp-id: %s",
- isis_print_id(header_csnp->start_lsp_id, LSP_ID_LEN));
- printf("\n\t end lsp-id: %s",
- isis_print_id(header_csnp->end_lsp_id, LSP_ID_LEN));
-
- if (vflag > 1) {
- if(!print_unknown_data(pptr,"\n\t ",ISIS_CSNP_HEADER_SIZE))
- return(0);
- }
+ pdu_len));
+ ND_PRINT((ndo, "\n\t start lsp-id: %s",
+ isis_print_id(header_csnp->start_lsp_id, LSP_ID_LEN)));
+ ND_PRINT((ndo, "\n\t end lsp-id: %s",
+ isis_print_id(header_csnp->end_lsp_id, LSP_ID_LEN)));
+
+ if (ndo->ndo_vflag > 1) {
+ if (!print_unknown_data(ndo, pptr, "\n\t ", ISIS_CSNP_HEADER_SIZE))
+ return(0);
+ }
packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE);
pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE);
@@ -2400,8 +2392,8 @@ static int isis_print (const u_int8_t *p, u_int length)
case ISIS_PDU_L1_PSNP:
case ISIS_PDU_L2_PSNP:
if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE)) {
- printf("- bogus fixed header length %u should be %lu",
- isis_header->fixed_len, (unsigned long)ISIS_PSNP_HEADER_SIZE);
+ ND_PRINT((ndo, "- bogus fixed header length %u should be %lu",
+ isis_header->fixed_len, (unsigned long)ISIS_PSNP_HEADER_SIZE));
return (0);
}
@@ -2411,22 +2403,22 @@ static int isis_print (const u_int8_t *p, u_int length)
length=pdu_len;
}
- TCHECK(*header_psnp);
- printf("\n\t source-id: %s, PDU length: %u",
+ ND_TCHECK(*header_psnp);
+ ND_PRINT((ndo, "\n\t source-id: %s, PDU length: %u",
isis_print_id(header_psnp->source_id, NODE_ID_LEN),
- pdu_len);
+ pdu_len));
- if (vflag > 1) {
- if(!print_unknown_data(pptr,"\n\t ",ISIS_PSNP_HEADER_SIZE))
- return(0);
- }
+ if (ndo->ndo_vflag > 1) {
+ if (!print_unknown_data(ndo, pptr, "\n\t ", ISIS_PSNP_HEADER_SIZE))
+ return(0);
+ }
packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE);
pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE);
break;
default:
- if(!print_unknown_data(pptr,"\n\t ",length))
+ if (!print_unknown_data(ndo, pptr, "\n\t ", length))
return(0);
return (0);
}
@@ -2436,13 +2428,13 @@ static int isis_print (const u_int8_t *p, u_int length)
*/
while (packet_len >= 2) {
- if (pptr == snapend) {
- return (1);
+ if (pptr == ndo->ndo_snapend) {
+ return (1);
}
- if (!TTEST2(*pptr, 2)) {
- printf("\n\t\t packet exceeded snapshot (%ld) bytes",
- (long)(pptr-snapend));
+ if (!ND_TTEST2(*pptr, 2)) {
+ ND_PRINT((ndo, "\n\t\t packet exceeded snapshot (%ld) bytes",
+ (long)(pptr - ndo->ndo_snapend)));
return (1);
}
tlv_type = *pptr++;
@@ -2455,12 +2447,12 @@ static int isis_print (const u_int8_t *p, u_int length)
}
/* first lets see if we know the TLVs name*/
- printf("\n\t %s TLV #%u, length: %u",
+ ND_PRINT((ndo, "\n\t %s TLV #%u, length: %u",
tok2str(isis_tlv_values,
"unknown",
tlv_type),
tlv_type,
- tlv_len);
+ tlv_len));
if (tlv_len == 0) /* something is malformed */
continue;
@@ -2468,46 +2460,46 @@ static int isis_print (const u_int8_t *p, u_int length)
/* now check if we have a decoder otherwise do a hexdump at the end*/
switch (tlv_type) {
case ISIS_TLV_AREA_ADDR:
- if (!TTEST2(*tptr, 1))
+ if (!ND_TTEST2(*tptr, 1))
goto trunctlv;
alen = *tptr++;
while (tmp && alen < tmp) {
- printf("\n\t Area address (length: %u): %s",
+ ND_PRINT((ndo, "\n\t Area address (length: %u): %s",
alen,
- isonsap_string(tptr,alen));
+ isonsap_string(tptr, alen)));
tptr += alen;
tmp -= alen + 1;
if (tmp==0) /* if this is the last area address do not attemt a boundary check */
break;
- if (!TTEST2(*tptr, 1))
+ if (!ND_TTEST2(*tptr, 1))
goto trunctlv;
alen = *tptr++;
}
break;
case ISIS_TLV_ISNEIGH:
while (tmp >= ETHER_ADDR_LEN) {
- if (!TTEST2(*tptr, ETHER_ADDR_LEN))
+ if (!ND_TTEST2(*tptr, ETHER_ADDR_LEN))
goto trunctlv;
- printf("\n\t SNPA: %s",isis_print_id(tptr,ETHER_ADDR_LEN));
+ ND_PRINT((ndo, "\n\t SNPA: %s", isis_print_id(tptr, ETHER_ADDR_LEN)));
tmp -= ETHER_ADDR_LEN;
tptr += ETHER_ADDR_LEN;
}
break;
case ISIS_TLV_ISNEIGH_VARLEN:
- if (!TTEST2(*tptr, 1) || tmp < 3) /* min. TLV length */
+ if (!ND_TTEST2(*tptr, 1) || tmp < 3) /* min. TLV length */
goto trunctlv;
lan_alen = *tptr++; /* LAN address length */
if (lan_alen == 0) {
- printf("\n\t LAN address length 0 bytes (invalid)");
+ ND_PRINT((ndo, "\n\t LAN address length 0 bytes (invalid)"));
break;
}
tmp --;
- printf("\n\t LAN address length %u bytes ",lan_alen);
+ ND_PRINT((ndo, "\n\t LAN address length %u bytes ", lan_alen));
while (tmp >= lan_alen) {
- if (!TTEST2(*tptr, lan_alen))
+ if (!ND_TTEST2(*tptr, lan_alen))
goto trunctlv;
- printf("\n\t\tIS Neighbor: %s",isis_print_id(tptr,lan_alen));
+ ND_PRINT((ndo, "\n\t\tIS Neighbor: %s", isis_print_id(tptr, lan_alen)));
tmp -= lan_alen;
tptr +=lan_alen;
}
@@ -2517,16 +2509,16 @@ static int isis_print (const u_int8_t *p, u_int length)
break;
case ISIS_TLV_MT_IS_REACH:
- mt_len = isis_print_mtid(tptr, "\n\t ");
+ mt_len = isis_print_mtid(ndo, tptr, "\n\t ");
if (mt_len == 0) /* did something go wrong ? */
goto trunctlv;
tptr+=mt_len;
tmp-=mt_len;
while (tmp >= 2+NODE_ID_LEN+3+1) {
- ext_is_len = isis_print_ext_is_reach(tptr,"\n\t ",tlv_type);
+ ext_is_len = isis_print_ext_is_reach(ndo, tptr, "\n\t ", tlv_type);
if (ext_is_len == 0) /* did something go wrong ? */
goto trunctlv;
-
+
tmp-=ext_is_len;
tptr+=ext_is_len;
}
@@ -2534,7 +2526,7 @@ static int isis_print (const u_int8_t *p, u_int length)
case ISIS_TLV_IS_ALIAS_ID:
while (tmp >= NODE_ID_LEN+1) { /* is it worth attempting a decode ? */
- ext_is_len = isis_print_ext_is_reach(tptr,"\n\t ",tlv_type);
+ ext_is_len = isis_print_ext_is_reach(ndo, tptr, "\n\t ", tlv_type);
if (ext_is_len == 0) /* did something go wrong ? */
goto trunctlv;
tmp-=ext_is_len;
@@ -2544,27 +2536,27 @@ static int isis_print (const u_int8_t *p, u_int length)
case ISIS_TLV_EXT_IS_REACH:
while (tmp >= NODE_ID_LEN+3+1) { /* is it worth attempting a decode ? */
- ext_is_len = isis_print_ext_is_reach(tptr,"\n\t ",tlv_type);
+ ext_is_len = isis_print_ext_is_reach(ndo, tptr, "\n\t ", tlv_type);
if (ext_is_len == 0) /* did something go wrong ? */
- goto trunctlv;
+ goto trunctlv;
tmp-=ext_is_len;
tptr+=ext_is_len;
}
break;
case ISIS_TLV_IS_REACH:
- if (!TTEST2(*tptr,1)) /* check if there is one byte left to read out the virtual flag */
+ if (!ND_TTEST2(*tptr,1)) /* check if there is one byte left to read out the virtual flag */
goto trunctlv;
- printf("\n\t %s",
+ ND_PRINT((ndo, "\n\t %s",
tok2str(isis_is_reach_virtual_values,
"bogus virtual flag 0x%02x",
- *tptr++));
+ *tptr++)));
tlv_is_reach = (const struct isis_tlv_is_reach *)tptr;
while (tmp >= sizeof(struct isis_tlv_is_reach)) {
- if (!TTEST(*tlv_is_reach))
+ if (!ND_TTEST(*tlv_is_reach))
goto trunctlv;
- printf("\n\t IS Neighbor: %s",
- isis_print_id(tlv_is_reach->neighbor_nodeid, NODE_ID_LEN));
- isis_print_metric_block(&tlv_is_reach->isis_metric_block);
+ ND_PRINT((ndo, "\n\t IS Neighbor: %s",
+ isis_print_id(tlv_is_reach->neighbor_nodeid, NODE_ID_LEN)));
+ isis_print_metric_block(ndo, &tlv_is_reach->isis_metric_block);
tmp -= sizeof(struct isis_tlv_is_reach);
tlv_is_reach++;
}
@@ -2573,11 +2565,11 @@ static int isis_print (const u_int8_t *p, u_int length)
case ISIS_TLV_ESNEIGH:
tlv_es_reach = (const struct isis_tlv_es_reach *)tptr;
while (tmp >= sizeof(struct isis_tlv_es_reach)) {
- if (!TTEST(*tlv_es_reach))
+ if (!ND_TTEST(*tlv_es_reach))
goto trunctlv;
- printf("\n\t ES Neighbor: %s",
- isis_print_id(tlv_es_reach->neighbor_sysid,SYSTEM_ID_LEN));
- isis_print_metric_block(&tlv_es_reach->isis_metric_block);
+ ND_PRINT((ndo, "\n\t ES Neighbor: %s",
+ isis_print_id(tlv_es_reach->neighbor_sysid, SYSTEM_ID_LEN)));
+ isis_print_metric_block(ndo, &tlv_es_reach->isis_metric_block);
tmp -= sizeof(struct isis_tlv_es_reach);
tlv_es_reach++;
}
@@ -2586,13 +2578,13 @@ static int isis_print (const u_int8_t *p, u_int length)
/* those two TLVs share the same format */
case ISIS_TLV_INT_IP_REACH:
case ISIS_TLV_EXT_IP_REACH:
- if (!isis_print_tlv_ip_reach(pptr, "\n\t ", tlv_len))
- return (1);
- break;
+ if (!isis_print_tlv_ip_reach(ndo, pptr, "\n\t ", tlv_len))
+ return (1);
+ break;
case ISIS_TLV_EXTD_IP_REACH:
while (tmp>0) {
- ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", AF_INET);
+ ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, "\n\t ", AF_INET);
if (ext_ip_len == 0) /* did something go wrong ? */
goto trunctlv;
tptr+=ext_ip_len;
@@ -2601,7 +2593,7 @@ static int isis_print (const u_int8_t *p, u_int length)
break;
case ISIS_TLV_MT_IP_REACH:
- mt_len = isis_print_mtid(tptr, "\n\t ");
+ mt_len = isis_print_mtid(ndo, tptr, "\n\t ");
if (mt_len == 0) { /* did something go wrong ? */
goto trunctlv;
}
@@ -2609,7 +2601,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 ", AF_INET);
+ ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, "\n\t ", AF_INET);
if (ext_ip_len == 0) /* did something go wrong ? */
goto trunctlv;
tptr+=ext_ip_len;
@@ -2620,7 +2612,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 ", AF_INET6);
+ ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, "\n\t ", AF_INET6);
if (ext_ip_len == 0) /* did something go wrong ? */
goto trunctlv;
tptr+=ext_ip_len;
@@ -2629,7 +2621,7 @@ static int isis_print (const u_int8_t *p, u_int length)
break;
case ISIS_TLV_MT_IP6_REACH:
- mt_len = isis_print_mtid(tptr, "\n\t ");
+ mt_len = isis_print_mtid(ndo, tptr, "\n\t ");
if (mt_len == 0) { /* did something go wrong ? */
goto trunctlv;
}
@@ -2637,7 +2629,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 ", AF_INET6);
+ ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, "\n\t ", AF_INET6);
if (ext_ip_len == 0) /* did something go wrong ? */
goto trunctlv;
tptr+=ext_ip_len;
@@ -2647,11 +2639,11 @@ static int isis_print (const u_int8_t *p, u_int length)
case ISIS_TLV_IP6ADDR:
while (tmp>=sizeof(struct in6_addr)) {
- if (!TTEST2(*tptr, sizeof(struct in6_addr)))
+ if (!ND_TTEST2(*tptr, sizeof(struct in6_addr)))
goto trunctlv;
- printf("\n\t IPv6 interface address: %s",
- ip6addr_string(tptr));
+ ND_PRINT((ndo, "\n\t IPv6 interface address: %s",
+ ip6addr_string(ndo, tptr)));
tptr += sizeof(struct in6_addr);
tmp -= sizeof(struct in6_addr);
@@ -2659,52 +2651,52 @@ static int isis_print (const u_int8_t *p, u_int length)
break;
#endif
case ISIS_TLV_AUTH:
- if (!TTEST2(*tptr, 1))
+ if (!ND_TTEST2(*tptr, 1))
goto trunctlv;
- printf("\n\t %s: ",
+ ND_PRINT((ndo, "\n\t %s: ",
tok2str(isis_subtlv_auth_values,
"unknown Authentication type 0x%02x",
- *tptr));
+ *tptr)));
switch (*tptr) {
case ISIS_SUBTLV_AUTH_SIMPLE:
for(i=1;i<tlv_len;i++) {
- if (!TTEST2(*(tptr+i), 1))
+ if (!ND_TTEST2(*(tptr + i), 1))
goto trunctlv;
- printf("%c",*(tptr+i));
+ ND_PRINT((ndo, "%c", *(tptr + i)));
}
break;
case ISIS_SUBTLV_AUTH_MD5:
for(i=1;i<tlv_len;i++) {
- if (!TTEST2(*(tptr+i), 1))
+ if (!ND_TTEST2(*(tptr + i), 1))
goto trunctlv;
- printf("%02x",*(tptr+i));
+ ND_PRINT((ndo, "%02x", *(tptr + i)));
}
if (tlv_len != ISIS_SUBTLV_AUTH_MD5_LEN+1)
- printf(", (malformed subTLV) ");
+ ND_PRINT((ndo, ", (malformed subTLV) "));
#ifdef HAVE_LIBCRYPTO
- sigcheck = signature_verify(optr, length,
+ sigcheck = signature_verify(ndo, optr, length,
(unsigned char *)tptr + 1);
#else
sigcheck = CANT_CHECK_SIGNATURE;
#endif
- printf(" (%s)", tok2str(signature_check_values, "Unknown", sigcheck));
+ ND_PRINT((ndo, " (%s)", tok2str(signature_check_values, "Unknown", sigcheck)));
break;
case ISIS_SUBTLV_AUTH_GENERIC:
key_id = EXTRACT_16BITS((tptr+1));
- printf("%u, password: ", key_id);
- for(i=1 + sizeof(u_int16_t);i<tlv_len;i++) {
- if (!TTEST2(*(tptr+i), 1))
+ ND_PRINT((ndo, "%u, password: ", key_id));
+ for(i=1 + sizeof(uint16_t);i<tlv_len;i++) {
+ if (!ND_TTEST2(*(tptr + i), 1))
goto trunctlv;
- printf("%02x",*(tptr+i));
+ ND_PRINT((ndo, "%02x", *(tptr + i)));
}
break;
case ISIS_SUBTLV_AUTH_PRIVATE:
default:
- if(!print_unknown_data(tptr+1,"\n\t\t ",tlv_len-1))
+ if (!print_unknown_data(ndo, tptr + 1, "\n\t\t ", tlv_len - 1))
return(0);
break;
}
@@ -2713,49 +2705,49 @@ static int isis_print (const u_int8_t *p, u_int length)
case ISIS_TLV_PTP_ADJ:
tlv_ptp_adj = (const struct isis_tlv_ptp_adj *)tptr;
if(tmp>=1) {
- if (!TTEST2(*tptr, 1))
+ if (!ND_TTEST2(*tptr, 1))
goto trunctlv;
- printf("\n\t Adjacency State: %s (%u)",
+ ND_PRINT((ndo, "\n\t Adjacency State: %s (%u)",
tok2str(isis_ptp_adjancey_values, "unknown", *tptr),
- *tptr);
+ *tptr));
tmp--;
}
if(tmp>sizeof(tlv_ptp_adj->extd_local_circuit_id)) {
- if (!TTEST2(tlv_ptp_adj->extd_local_circuit_id,
+ if (!ND_TTEST2(tlv_ptp_adj->extd_local_circuit_id,
sizeof(tlv_ptp_adj->extd_local_circuit_id)))
goto trunctlv;
- printf("\n\t Extended Local circuit-ID: 0x%08x",
- EXTRACT_32BITS(tlv_ptp_adj->extd_local_circuit_id));
+ ND_PRINT((ndo, "\n\t Extended Local circuit-ID: 0x%08x",
+ EXTRACT_32BITS(tlv_ptp_adj->extd_local_circuit_id)));
tmp-=sizeof(tlv_ptp_adj->extd_local_circuit_id);
}
if(tmp>=SYSTEM_ID_LEN) {
- if (!TTEST2(tlv_ptp_adj->neighbor_sysid, SYSTEM_ID_LEN))
+ if (!ND_TTEST2(tlv_ptp_adj->neighbor_sysid, SYSTEM_ID_LEN))
goto trunctlv;
- printf("\n\t Neighbor System-ID: %s",
- isis_print_id(tlv_ptp_adj->neighbor_sysid,SYSTEM_ID_LEN));
+ ND_PRINT((ndo, "\n\t Neighbor System-ID: %s",
+ isis_print_id(tlv_ptp_adj->neighbor_sysid, SYSTEM_ID_LEN)));
tmp-=SYSTEM_ID_LEN;
}
if(tmp>=sizeof(tlv_ptp_adj->neighbor_extd_local_circuit_id)) {
- if (!TTEST2(tlv_ptp_adj->neighbor_extd_local_circuit_id,
+ if (!ND_TTEST2(tlv_ptp_adj->neighbor_extd_local_circuit_id,
sizeof(tlv_ptp_adj->neighbor_extd_local_circuit_id)))
goto trunctlv;
- printf("\n\t Neighbor Extended Local circuit-ID: 0x%08x",
- EXTRACT_32BITS(tlv_ptp_adj->neighbor_extd_local_circuit_id));
+ ND_PRINT((ndo, "\n\t Neighbor Extended Local circuit-ID: 0x%08x",
+ EXTRACT_32BITS(tlv_ptp_adj->neighbor_extd_local_circuit_id)));
}
break;
case ISIS_TLV_PROTOCOLS:
- printf("\n\t NLPID(s): ");
+ ND_PRINT((ndo, "\n\t NLPID(s): "));
while (tmp>0) {
- if (!TTEST2(*(tptr), 1))
+ if (!ND_TTEST2(*(tptr), 1))
goto trunctlv;
- printf("%s (0x%02x)",
+ ND_PRINT((ndo, "%s (0x%02x)",
tok2str(nlpid_values,
"unknown",
*tptr),
- *tptr);
+ *tptr));
if (tmp>1) /* further NPLIDs ? - put comma */
- printf(", ");
+ ND_PRINT((ndo, ", "));
tptr++;
tmp--;
}
@@ -2763,62 +2755,62 @@ static int isis_print (const u_int8_t *p, u_int length)
case ISIS_TLV_MT_PORT_CAP:
{
- if (!TTEST2(*(tptr), 2))
+ if (!ND_TTEST2(*(tptr), 2))
goto trunctlv;
- printf("\n\t RES: %d, MTID(s): %d",
- (EXTRACT_16BITS (tptr) >> 12),
- (EXTRACT_16BITS (tptr) & 0x0fff));
+ ND_PRINT((ndo, "\n\t RES: %d, MTID(s): %d",
+ (EXTRACT_16BITS (tptr) >> 12),
+ (EXTRACT_16BITS (tptr) & 0x0fff)));
tmp = tmp-2;
tptr = tptr+2;
if (tmp)
- isis_print_mt_port_cap_subtlv (tptr, tmp);
+ isis_print_mt_port_cap_subtlv(ndo, tptr, tmp);
break;
}
case ISIS_TLV_MT_CAPABILITY:
- if (!TTEST2(*(tptr), 2))
+ if (!ND_TTEST2(*(tptr), 2))
goto trunctlv;
- printf("\n\t O: %d, RES: %d, MTID(s): %d",
+ ND_PRINT((ndo, "\n\t O: %d, RES: %d, MTID(s): %d",
(EXTRACT_16BITS(tptr) >> 15) & 0x01,
(EXTRACT_16BITS(tptr) >> 12) & 0x07,
- EXTRACT_16BITS(tptr) & 0x0fff);
+ EXTRACT_16BITS(tptr) & 0x0fff));
tmp = tmp-2;
tptr = tptr+2;
if (tmp)
- isis_print_mt_capability_subtlv (tptr, tmp);
+ isis_print_mt_capability_subtlv(ndo, tptr, tmp);
break;
case ISIS_TLV_TE_ROUTER_ID:
- if (!TTEST2(*pptr, sizeof(struct in_addr)))
+ if (!ND_TTEST2(*pptr, sizeof(struct in_addr)))
goto trunctlv;
- printf("\n\t Traffic Engineering Router ID: %s", ipaddr_string(pptr));
+ ND_PRINT((ndo, "\n\t Traffic Engineering Router ID: %s", ipaddr_string(ndo, pptr)));
break;
case ISIS_TLV_IPADDR:
while (tmp>=sizeof(struct in_addr)) {
- if (!TTEST2(*tptr, sizeof(struct in_addr)))
+ if (!ND_TTEST2(*tptr, sizeof(struct in_addr)))
goto trunctlv;
- printf("\n\t IPv4 interface address: %s", ipaddr_string(tptr));
+ ND_PRINT((ndo, "\n\t IPv4 interface address: %s", ipaddr_string(ndo, tptr)));
tptr += sizeof(struct in_addr);
tmp -= sizeof(struct in_addr);
}
break;
case ISIS_TLV_HOSTNAME:
- printf("\n\t Hostname: ");
+ ND_PRINT((ndo, "\n\t Hostname: "));
while (tmp>0) {
- if (!TTEST2(*tptr, 1))
+ if (!ND_TTEST2(*tptr, 1))
goto trunctlv;
- printf("%c",*tptr++);
+ ND_PRINT((ndo, "%c", *tptr++));
tmp--;
}
break;
@@ -2826,39 +2818,39 @@ static int isis_print (const u_int8_t *p, u_int length)
case ISIS_TLV_SHARED_RISK_GROUP:
if (tmp < NODE_ID_LEN)
break;
- if (!TTEST2(*tptr, NODE_ID_LEN))
+ if (!ND_TTEST2(*tptr, NODE_ID_LEN))
goto trunctlv;
- printf("\n\t IS Neighbor: %s", isis_print_id(tptr, NODE_ID_LEN));
+ ND_PRINT((ndo, "\n\t IS Neighbor: %s", isis_print_id(tptr, NODE_ID_LEN)));
tptr+=(NODE_ID_LEN);
tmp-=(NODE_ID_LEN);
if (tmp < 1)
break;
- if (!TTEST2(*tptr, 1))
+ if (!ND_TTEST2(*tptr, 1))
goto trunctlv;
- printf(", Flags: [%s]", ISIS_MASK_TLV_SHARED_RISK_GROUP(*tptr++) ? "numbered" : "unnumbered");
+ ND_PRINT((ndo, ", Flags: [%s]", ISIS_MASK_TLV_SHARED_RISK_GROUP(*tptr++) ? "numbered" : "unnumbered"));
tmp--;
if (tmp < sizeof(struct in_addr))
break;
- if (!TTEST2(*tptr,sizeof(struct in_addr)))
+ if (!ND_TTEST2(*tptr, sizeof(struct in_addr)))
goto trunctlv;
- printf("\n\t IPv4 interface address: %s", ipaddr_string(tptr));
+ ND_PRINT((ndo, "\n\t IPv4 interface address: %s", ipaddr_string(ndo, tptr)));
tptr+=sizeof(struct in_addr);
tmp-=sizeof(struct in_addr);
if (tmp < sizeof(struct in_addr))
break;
- if (!TTEST2(*tptr,sizeof(struct in_addr)))
+ if (!ND_TTEST2(*tptr, sizeof(struct in_addr)))
goto trunctlv;
- printf("\n\t IPv4 neighbor address: %s", ipaddr_string(tptr));
+ ND_PRINT((ndo, "\n\t IPv4 neighbor address: %s", ipaddr_string(ndo, tptr)));
tptr+=sizeof(struct in_addr);
tmp-=sizeof(struct in_addr);
while (tmp>=4) {
- if (!TTEST2(*tptr, 4))
+ if (!ND_TTEST2(*tptr, 4))
goto trunctlv;
- printf("\n\t Link-ID: 0x%08x", EXTRACT_32BITS(tptr));
+ ND_PRINT((ndo, "\n\t Link-ID: 0x%08x", EXTRACT_32BITS(tptr)));
tptr+=4;
tmp-=4;
}
@@ -2867,19 +2859,19 @@ static int isis_print (const u_int8_t *p, u_int length)
case ISIS_TLV_LSP:
tlv_lsp = (const struct isis_tlv_lsp *)tptr;
while(tmp>=sizeof(struct isis_tlv_lsp)) {
- if (!TTEST((tlv_lsp->lsp_id)[LSP_ID_LEN-1]))
+ if (!ND_TTEST((tlv_lsp->lsp_id)[LSP_ID_LEN-1]))
goto trunctlv;
- printf("\n\t lsp-id: %s",
- isis_print_id(tlv_lsp->lsp_id, LSP_ID_LEN));
- if (!TTEST2(tlv_lsp->sequence_number, 4))
+ ND_PRINT((ndo, "\n\t lsp-id: %s",
+ isis_print_id(tlv_lsp->lsp_id, LSP_ID_LEN)));
+ if (!ND_TTEST2(tlv_lsp->sequence_number, 4))
goto trunctlv;
- printf(", seq: 0x%08x",EXTRACT_32BITS(tlv_lsp->sequence_number));
- if (!TTEST2(tlv_lsp->remaining_lifetime, 2))
+ ND_PRINT((ndo, ", seq: 0x%08x", EXTRACT_32BITS(tlv_lsp->sequence_number)));
+ if (!ND_TTEST2(tlv_lsp->remaining_lifetime, 2))
goto trunctlv;
- printf(", lifetime: %5ds",EXTRACT_16BITS(tlv_lsp->remaining_lifetime));
- if (!TTEST2(tlv_lsp->checksum, 2))
+ ND_PRINT((ndo, ", lifetime: %5ds", EXTRACT_16BITS(tlv_lsp->remaining_lifetime)));
+ if (!ND_TTEST2(tlv_lsp->checksum, 2))
goto trunctlv;
- printf(", chksum: 0x%04x",EXTRACT_16BITS(tlv_lsp->checksum));
+ ND_PRINT((ndo, ", chksum: 0x%04x", EXTRACT_16BITS(tlv_lsp->checksum)));
tmp-=sizeof(struct isis_tlv_lsp);
tlv_lsp++;
}
@@ -2888,15 +2880,15 @@ static int isis_print (const u_int8_t *p, u_int length)
case ISIS_TLV_CHECKSUM:
if (tmp < ISIS_TLV_CHECKSUM_MINLEN)
break;
- if (!TTEST2(*tptr, ISIS_TLV_CHECKSUM_MINLEN))
+ if (!ND_TTEST2(*tptr, ISIS_TLV_CHECKSUM_MINLEN))
goto trunctlv;
- printf("\n\t checksum: 0x%04x ", EXTRACT_16BITS(tptr));
+ ND_PRINT((ndo, "\n\t checksum: 0x%04x ", EXTRACT_16BITS(tptr)));
/* do not attempt to verify the checksum if it is zero
* most likely a HMAC-MD5 TLV is also present and
* to avoid conflicts the checksum TLV is zeroed.
* see rfc3358 for details
*/
- osi_print_cksum(optr, EXTRACT_16BITS(tptr), tptr-optr, length);
+ osi_print_cksum(ndo, optr, EXTRACT_16BITS(tptr), tptr-optr, length);
break;
case ISIS_TLV_MT_SUPPORTED:
@@ -2906,13 +2898,13 @@ static int isis_print (const u_int8_t *p, u_int length)
/* length can only be a multiple of 2, otherwise there is
something broken -> so decode down until length is 1 */
if (tmp!=1) {
- mt_len = isis_print_mtid(tptr, "\n\t ");
+ mt_len = isis_print_mtid(ndo, tptr, "\n\t ");
if (mt_len == 0) /* did something go wrong ? */
goto trunctlv;
tptr+=mt_len;
tmp-=mt_len;
} else {
- printf("\n\t malformed MT-ID");
+ ND_PRINT((ndo, "\n\t malformed MT-ID"));
break;
}
}
@@ -2922,10 +2914,10 @@ static int isis_print (const u_int8_t *p, u_int length)
/* first attempt to decode the flags */
if (tmp < ISIS_TLV_RESTART_SIGNALING_FLAGLEN)
break;
- if (!TTEST2(*tptr, ISIS_TLV_RESTART_SIGNALING_FLAGLEN))
+ if (!ND_TTEST2(*tptr, ISIS_TLV_RESTART_SIGNALING_FLAGLEN))
goto trunctlv;
- printf("\n\t Flags [%s]",
- bittok2str(isis_restart_flag_values, "none", *tptr));
+ ND_PRINT((ndo, "\n\t Flags [%s]",
+ bittok2str(isis_restart_flag_values, "none", *tptr)));
tptr+=ISIS_TLV_RESTART_SIGNALING_FLAGLEN;
tmp-=ISIS_TLV_RESTART_SIGNALING_FLAGLEN;
@@ -2935,40 +2927,40 @@ static int isis_print (const u_int8_t *p, u_int length)
if (tmp < ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN)
break;
- if (!TTEST2(*tptr, ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN))
+ if (!ND_TTEST2(*tptr, ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN))
goto trunctlv;
- printf(", Remaining holding time %us", EXTRACT_16BITS(tptr));
+ ND_PRINT((ndo, ", Remaining holding time %us", EXTRACT_16BITS(tptr)));
tptr+=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN;
tmp-=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN;
/* is there an additional sysid field present ?*/
if (tmp == SYSTEM_ID_LEN) {
- if (!TTEST2(*tptr, SYSTEM_ID_LEN))
+ if (!ND_TTEST2(*tptr, SYSTEM_ID_LEN))
goto trunctlv;
- printf(", for %s",isis_print_id(tptr,SYSTEM_ID_LEN));
- }
+ ND_PRINT((ndo, ", for %s", isis_print_id(tptr,SYSTEM_ID_LEN)));
+ }
break;
case ISIS_TLV_IDRP_INFO:
if (tmp < ISIS_TLV_IDRP_INFO_MINLEN)
break;
- if (!TTEST2(*tptr, ISIS_TLV_IDRP_INFO_MINLEN))
+ if (!ND_TTEST2(*tptr, ISIS_TLV_IDRP_INFO_MINLEN))
goto trunctlv;
- printf("\n\t Inter-Domain Information Type: %s",
+ ND_PRINT((ndo, "\n\t Inter-Domain Information Type: %s",
tok2str(isis_subtlv_idrp_values,
"Unknown (0x%02x)",
- *tptr));
+ *tptr)));
switch (*tptr++) {
case ISIS_SUBTLV_IDRP_ASN:
- if (!TTEST2(*tptr, 2)) /* fetch AS number */
+ if (!ND_TTEST2(*tptr, 2)) /* fetch AS number */
goto trunctlv;
- printf("AS Number: %u",EXTRACT_16BITS(tptr));
+ ND_PRINT((ndo, "AS Number: %u", EXTRACT_16BITS(tptr)));
break;
case ISIS_SUBTLV_IDRP_LOCAL:
case ISIS_SUBTLV_IDRP_RES:
default:
- if(!print_unknown_data(tptr,"\n\t ",tlv_len-1))
+ if (!print_unknown_data(ndo, tptr, "\n\t ", tlv_len - 1))
return(0);
break;
}
@@ -2977,16 +2969,16 @@ static int isis_print (const u_int8_t *p, u_int length)
case ISIS_TLV_LSP_BUFFERSIZE:
if (tmp < ISIS_TLV_LSP_BUFFERSIZE_MINLEN)
break;
- if (!TTEST2(*tptr, ISIS_TLV_LSP_BUFFERSIZE_MINLEN))
+ if (!ND_TTEST2(*tptr, ISIS_TLV_LSP_BUFFERSIZE_MINLEN))
goto trunctlv;
- printf("\n\t LSP Buffersize: %u",EXTRACT_16BITS(tptr));
+ ND_PRINT((ndo, "\n\t LSP Buffersize: %u", EXTRACT_16BITS(tptr)));
break;
case ISIS_TLV_PART_DIS:
while (tmp >= SYSTEM_ID_LEN) {
- if (!TTEST2(*tptr, SYSTEM_ID_LEN))
+ if (!ND_TTEST2(*tptr, SYSTEM_ID_LEN))
goto trunctlv;
- printf("\n\t %s",isis_print_id(tptr,SYSTEM_ID_LEN));
+ ND_PRINT((ndo, "\n\t %s", isis_print_id(tptr, SYSTEM_ID_LEN)));
tptr+=SYSTEM_ID_LEN;
tmp-=SYSTEM_ID_LEN;
}
@@ -2995,29 +2987,28 @@ static int isis_print (const u_int8_t *p, u_int length)
case ISIS_TLV_PREFIX_NEIGH:
if (tmp < sizeof(struct isis_metric_block))
break;
- if (!TTEST2(*tptr, sizeof(struct isis_metric_block)))
+ if (!ND_TTEST2(*tptr, sizeof(struct isis_metric_block)))
goto trunctlv;
- printf("\n\t Metric Block");
- isis_print_metric_block((const struct isis_metric_block *)tptr);
+ ND_PRINT((ndo, "\n\t Metric Block"));
+ isis_print_metric_block(ndo, (const struct isis_metric_block *)tptr);
tptr+=sizeof(struct isis_metric_block);
tmp-=sizeof(struct isis_metric_block);
while(tmp>0) {
- if (!TTEST2(*tptr, 1))
+ if (!ND_TTEST2(*tptr, 1))
goto trunctlv;
prefix_len=*tptr++; /* read out prefix length in semioctets*/
if (prefix_len < 2) {
- printf("\n\t\tAddress: prefix length %u < 2", prefix_len);
+ ND_PRINT((ndo, "\n\t\tAddress: prefix length %u < 2", prefix_len));
break;
}
tmp--;
if (tmp < prefix_len/2)
break;
- if (!TTEST2(*tptr, prefix_len/2))
+ if (!ND_TTEST2(*tptr, prefix_len / 2))
goto trunctlv;
- printf("\n\t\tAddress: %s/%u",
- isonsap_string(tptr,prefix_len/2),
- prefix_len*4);
+ ND_PRINT((ndo, "\n\t\tAddress: %s/%u",
+ isonsap_string(tptr, prefix_len / 2), prefix_len * 4));
tptr+=prefix_len/2;
tmp-=prefix_len/2;
}
@@ -3026,24 +3017,24 @@ static int isis_print (const u_int8_t *p, u_int length)
case ISIS_TLV_IIH_SEQNR:
if (tmp < ISIS_TLV_IIH_SEQNR_MINLEN)
break;
- if (!TTEST2(*tptr, ISIS_TLV_IIH_SEQNR_MINLEN)) /* check if four bytes are on the wire */
+ if (!ND_TTEST2(*tptr, ISIS_TLV_IIH_SEQNR_MINLEN)) /* check if four bytes are on the wire */
goto trunctlv;
- printf("\n\t Sequence number: %u", EXTRACT_32BITS(tptr) );
+ ND_PRINT((ndo, "\n\t Sequence number: %u", EXTRACT_32BITS(tptr)));
break;
case ISIS_TLV_VENDOR_PRIVATE:
if (tmp < ISIS_TLV_VENDOR_PRIVATE_MINLEN)
break;
- if (!TTEST2(*tptr, ISIS_TLV_VENDOR_PRIVATE_MINLEN)) /* check if enough byte for a full oui */
+ if (!ND_TTEST2(*tptr, ISIS_TLV_VENDOR_PRIVATE_MINLEN)) /* check if enough byte for a full oui */
goto trunctlv;
vendor_id = EXTRACT_24BITS(tptr);
- printf("\n\t Vendor: %s (%u)",
- tok2str(oui_values,"Unknown",vendor_id),
- vendor_id);
+ ND_PRINT((ndo, "\n\t Vendor: %s (%u)",
+ tok2str(oui_values, "Unknown", vendor_id),
+ vendor_id));
tptr+=3;
tmp-=3;
if (tmp > 0) /* hexdump the rest */
- if(!print_unknown_data(tptr,"\n\t\t",tmp))
+ if (!print_unknown_data(ndo, tptr, "\n\t\t", tmp))
return(0);
break;
/*
@@ -3058,51 +3049,52 @@ static int isis_print (const u_int8_t *p, u_int length)
case ISIS_TLV_NORTEL_PRIVATE2:
default:
- if (vflag <= 1) {
- if(!print_unknown_data(pptr,"\n\t\t",tlv_len))
- return(0);
- }
- break;
+ if (ndo->ndo_vflag <= 1) {
+ if (!print_unknown_data(ndo, pptr, "\n\t\t", tlv_len))
+ return(0);
+ }
+ break;
}
/* do we want to see an additionally hexdump ? */
- if (vflag> 1) {
- if(!print_unknown_data(pptr,"\n\t ",tlv_len))
- return(0);
- }
+ if (ndo->ndo_vflag> 1) {
+ if (!print_unknown_data(ndo, pptr, "\n\t ", tlv_len))
+ return(0);
+ }
pptr += tlv_len;
packet_len -= tlv_len;
}
if (packet_len != 0) {
- printf("\n\t %u straggler bytes", packet_len);
+ ND_PRINT((ndo, "\n\t %u straggler bytes", packet_len));
}
return (1);
trunc:
- fputs("[|isis]", stdout);
+ ND_PRINT((ndo, "[|isis]"));
return (1);
trunctlv:
- printf("\n\t\t packet exceeded snapshot");
+ ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
return(1);
}
static void
-osi_print_cksum (const u_int8_t *pptr, u_int16_t checksum,
+osi_print_cksum(netdissect_options *ndo,
+ const uint8_t *pptr, uint16_t checksum,
u_int checksum_offset, u_int length)
{
- u_int16_t calculated_checksum;
+ uint16_t calculated_checksum;
/* do not attempt to verify the checksum if it is zero */
if (!checksum) {
- printf("(unverified)");
+ ND_PRINT((ndo, "(unverified)"));
} else {
calculated_checksum = create_osi_cksum(pptr, checksum_offset, length);
if (checksum == calculated_checksum) {
- printf(" (correct)");
+ ND_PRINT((ndo, " (correct)"));
} else {
- printf(" (incorrect should be 0x%04x)", calculated_checksum);
+ ND_PRINT((ndo, " (incorrect should be 0x%04x)", calculated_checksum));
}
}
}
diff --git a/contrib/tcpdump/print-juniper.c b/contrib/tcpdump/print-juniper.c
index 3bf68c382797..f2aa8cfa1daa 100644
--- a/contrib/tcpdump/print-juniper.c
+++ b/contrib/tcpdump/print-juniper.c
@@ -1,6 +1,6 @@
/* NetBSD: print-juniper.c,v 1.2 2007/07/24 11:53:45 drochner Exp */
-/*
+/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code
* distributions retain the above copyright notice and this paragraph
@@ -16,21 +16,17 @@
*/
#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-juniper.c,v 1.34 2007-08-29 02:31:44 mcr Exp $ (LBL)";
#else
__RCSID("NetBSD: print-juniper.c,v 1.3 2007/07/25 06:31:32 dogcow Exp ");
#endif
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <pcap.h>
-#include <stdio.h>
-
#include "interface.h"
#include "addrtoname.h"
#include "extract.h"
@@ -65,7 +61,7 @@ __RCSID("NetBSD: print-juniper.c,v 1.3 2007/07/25 06:31:32 dogcow Exp ");
#define JUNIPER_IPSEC_O_AH_AUTHENTICATION_TYPE 4
#define JUNIPER_IPSEC_O_ESP_ENCRYPTION_TYPE 5
-static struct tok juniper_ipsec_type_values[] = {
+static const struct tok juniper_ipsec_type_values[] = {
{ JUNIPER_IPSEC_O_ESP_ENCRYPT_ESP_AUTHEN_TYPE, "ESP ENCR-AUTH" },
{ JUNIPER_IPSEC_O_ESP_ENCRYPT_AH_AUTHEN_TYPE, "ESP ENCR-AH AUTH" },
{ JUNIPER_IPSEC_O_ESP_AUTHENTICATION_TYPE, "ESP AUTH" },
@@ -74,7 +70,7 @@ static struct tok juniper_ipsec_type_values[] = {
{ 0, NULL}
};
-static struct tok juniper_direction_values[] = {
+static const struct tok juniper_direction_values[] = {
{ JUNIPER_BPF_IN, "In"},
{ JUNIPER_BPF_OUT, "Out"},
{ 0, NULL}
@@ -87,15 +83,15 @@ enum {
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_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[] = {
+static const 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" },
@@ -107,7 +103,7 @@ struct tok jnx_ext_tlv_values[] = {
{ 0, NULL }
};
-struct tok jnx_flag_values[] = {
+static const struct tok jnx_flag_values[] = {
{ JUNIPER_BPF_EXT, "Ext" },
{ JUNIPER_BPF_FILTER, "Filter" },
{ JUNIPER_BPF_IIF, "IIF" },
@@ -177,7 +173,7 @@ struct tok jnx_flag_values[] = {
#define JUNIPER_IFML_DFC 59
#define JUNIPER_IFML_PICPEER 60
-struct tok juniper_ifmt_values[] = {
+static const struct tok juniper_ifmt_values[] = {
{ JUNIPER_IFML_ETHER, "Ethernet" },
{ JUNIPER_IFML_FDDI, "FDDI" },
{ JUNIPER_IFML_TOKENRING, "Token-Ring" },
@@ -300,7 +296,7 @@ struct tok juniper_ifmt_values[] = {
#define JUNIPER_IFLE_DFC 66
#define JUNIPER_IFLE_PICPEER 67
-struct tok juniper_ifle_values[] = {
+static const 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" },
@@ -366,12 +362,12 @@ struct tok juniper_ifle_values[] = {
};
struct juniper_cookie_table_t {
- u_int32_t pictype; /* pic type */
- u_int8_t cookie_len; /* cookie len */
+ uint32_t pictype; /* pic type */
+ uint8_t cookie_len; /* cookie len */
const char *s; /* pic name */
};
-static struct juniper_cookie_table_t juniper_cookie_table[] = {
+static const struct juniper_cookie_table_t juniper_cookie_table[] = {
#ifdef DLT_JUNIPER_ATM1
{ DLT_JUNIPER_ATM1, 4, "ATM1"},
#endif
@@ -409,17 +405,17 @@ static struct juniper_cookie_table_t juniper_cookie_table[] = {
};
struct juniper_l2info_t {
- u_int32_t length;
- u_int32_t caplen;
- u_int32_t pictype;
- u_int8_t direction;
- u_int8_t header_len;
- u_int8_t cookie_len;
- u_int8_t cookie_type;
- u_int8_t cookie[8];
- u_int8_t bundle;
- u_int16_t proto;
- u_int8_t flags;
+ uint32_t length;
+ uint32_t caplen;
+ uint32_t pictype;
+ uint8_t direction;
+ uint8_t header_len;
+ uint8_t cookie_len;
+ uint8_t cookie_type;
+ uint8_t cookie[8];
+ uint8_t bundle;
+ uint16_t proto;
+ uint8_t flags;
};
#define LS_COOKIE_ID 0x54
@@ -439,59 +435,59 @@ struct juniper_l2info_t {
#define MFR_BE_MASK 0xc0
-static struct tok juniper_protocol_values[] = {
+static const struct tok juniper_protocol_values[] = {
{ JUNIPER_PROTO_NULL, "Null" },
{ JUNIPER_PROTO_IPV4, "IPv4" },
{ JUNIPER_PROTO_IPV6, "IPv6" },
{ 0, NULL}
};
-int ip_heuristic_guess(register const u_char *, u_int);
-int juniper_ppp_heuristic_guess(register const u_char *, u_int);
-int juniper_read_tlv_value(const u_char *, u_int, u_int);
-static int juniper_parse_header (const u_char *, const struct pcap_pkthdr *, struct juniper_l2info_t *);
+static int ip_heuristic_guess(netdissect_options *, register const u_char *, u_int);
+static int juniper_ppp_heuristic_guess(netdissect_options *, register const u_char *, u_int);
+static int juniper_parse_header(netdissect_options *, const u_char *, const struct pcap_pkthdr *, struct juniper_l2info_t *);
#ifdef DLT_JUNIPER_GGSN
u_int
-juniper_ggsn_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_ggsn_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, register const u_char *p)
{
struct juniper_l2info_t l2info;
struct juniper_ggsn_header {
- u_int8_t svc_id;
- u_int8_t flags_len;
- u_int8_t proto;
- u_int8_t flags;
- u_int8_t vlan_id[2];
- u_int8_t res[2];
+ uint8_t svc_id;
+ uint8_t flags_len;
+ uint8_t proto;
+ uint8_t flags;
+ uint8_t vlan_id[2];
+ uint8_t res[2];
};
const struct juniper_ggsn_header *gh;
l2info.pictype = DLT_JUNIPER_GGSN;
- if(juniper_parse_header(p, h, &l2info) == 0)
+ if (juniper_parse_header(ndo, p, h, &l2info) == 0)
return l2info.header_len;
p+=l2info.header_len;
gh = (struct juniper_ggsn_header *)&l2info.cookie;
- if (eflag) {
- printf("proto %s (%u), vlan %u: ",
+ if (ndo->ndo_eflag) {
+ ND_PRINT((ndo, "proto %s (%u), vlan %u: ",
tok2str(juniper_protocol_values,"Unknown",gh->proto),
gh->proto,
- EXTRACT_16BITS(&gh->vlan_id[0]));
+ EXTRACT_16BITS(&gh->vlan_id[0])));
}
switch (gh->proto) {
case JUNIPER_PROTO_IPV4:
- ip_print(gndo, p, l2info.length);
+ ip_print(ndo, p, l2info.length);
break;
#ifdef INET6
case JUNIPER_PROTO_IPV6:
- ip6_print(gndo, p, l2info.length);
+ ip6_print(ndo, p, l2info.length);
break;
#endif /* INET6 */
default:
- if (!eflag)
- printf("unknown GGSN proto (%u)", gh->proto);
+ if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, "unknown GGSN proto (%u)", gh->proto));
}
return l2info.header_len;
@@ -500,22 +496,23 @@ juniper_ggsn_print(const struct pcap_pkthdr *h, register const u_char *p)
#ifdef DLT_JUNIPER_ES
u_int
-juniper_es_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_es_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, register const u_char *p)
{
struct juniper_l2info_t l2info;
struct juniper_ipsec_header {
- u_int8_t sa_index[2];
- u_int8_t ttl;
- u_int8_t type;
- u_int8_t spi[4];
- u_int8_t src_ip[4];
- u_int8_t dst_ip[4];
+ uint8_t sa_index[2];
+ uint8_t ttl;
+ uint8_t type;
+ uint8_t spi[4];
+ uint8_t src_ip[4];
+ uint8_t dst_ip[4];
};
u_int rewrite_len,es_type_bundle;
const struct juniper_ipsec_header *ih;
l2info.pictype = DLT_JUNIPER_ES;
- if(juniper_parse_header(p, h, &l2info) == 0)
+ if (juniper_parse_header(ndo, p, h, &l2info) == 0)
return l2info.header_len;
p+=l2info.header_len;
@@ -532,70 +529,72 @@ juniper_es_print(const struct pcap_pkthdr *h, register const u_char *p)
case JUNIPER_IPSEC_O_ESP_ENCRYPTION_TYPE:
rewrite_len = 16;
es_type_bundle = 0;
+ break;
default:
- printf("ES Invalid type %u, length %u",
+ ND_PRINT((ndo, "ES Invalid type %u, length %u",
ih->type,
- l2info.length);
+ l2info.length));
return l2info.header_len;
}
l2info.length-=rewrite_len;
p+=rewrite_len;
- if (eflag) {
+ if (ndo->ndo_eflag) {
if (!es_type_bundle) {
- printf("ES SA, index %u, ttl %u type %s (%u), spi %u, Tunnel %s > %s, length %u\n",
+ ND_PRINT((ndo, "ES SA, index %u, ttl %u type %s (%u), spi %u, Tunnel %s > %s, length %u\n",
EXTRACT_16BITS(&ih->sa_index),
- ih->ttl,
+ ih->ttl,
tok2str(juniper_ipsec_type_values,"Unknown",ih->type),
ih->type,
EXTRACT_32BITS(&ih->spi),
- ipaddr_string(&ih->src_ip),
- ipaddr_string(&ih->dst_ip),
- l2info.length);
+ ipaddr_string(ndo, &ih->src_ip),
+ ipaddr_string(ndo, &ih->dst_ip),
+ l2info.length));
} else {
- printf("ES SA, index %u, ttl %u type %s (%u), length %u\n",
+ ND_PRINT((ndo, "ES SA, index %u, ttl %u type %s (%u), length %u\n",
EXTRACT_16BITS(&ih->sa_index),
- ih->ttl,
+ ih->ttl,
tok2str(juniper_ipsec_type_values,"Unknown",ih->type),
ih->type,
- l2info.length);
+ l2info.length));
}
}
- ip_print(gndo, p, l2info.length);
+ ip_print(ndo, p, l2info.length);
return l2info.header_len;
}
#endif
#ifdef DLT_JUNIPER_MONITOR
u_int
-juniper_monitor_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_monitor_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, register const u_char *p)
{
struct juniper_l2info_t l2info;
struct juniper_monitor_header {
- u_int8_t pkt_type;
- u_int8_t padding;
- u_int8_t iif[2];
- u_int8_t service_id[4];
+ uint8_t pkt_type;
+ uint8_t padding;
+ uint8_t iif[2];
+ uint8_t service_id[4];
};
const struct juniper_monitor_header *mh;
l2info.pictype = DLT_JUNIPER_MONITOR;
- if(juniper_parse_header(p, h, &l2info) == 0)
+ if (juniper_parse_header(ndo, p, h, &l2info) == 0)
return l2info.header_len;
p+=l2info.header_len;
mh = (struct juniper_monitor_header *)p;
- if (eflag)
- printf("service-id %u, iif %u, pkt-type %u: ",
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "service-id %u, iif %u, pkt-type %u: ",
EXTRACT_32BITS(&mh->service_id),
EXTRACT_16BITS(&mh->iif),
- mh->pkt_type);
+ mh->pkt_type));
/* no proto field - lets guess by first byte of IP header*/
- ip_heuristic_guess(p, l2info.length);
+ ip_heuristic_guess (ndo, p, l2info.length);
return l2info.header_len;
}
@@ -603,33 +602,34 @@ juniper_monitor_print(const struct pcap_pkthdr *h, register const u_char *p)
#ifdef DLT_JUNIPER_SERVICES
u_int
-juniper_services_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_services_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, register const u_char *p)
{
struct juniper_l2info_t l2info;
struct juniper_services_header {
- u_int8_t svc_id;
- u_int8_t flags_len;
- u_int8_t svc_set_id[2];
- u_int8_t dir_iif[4];
+ uint8_t svc_id;
+ uint8_t flags_len;
+ uint8_t svc_set_id[2];
+ uint8_t dir_iif[4];
};
const struct juniper_services_header *sh;
l2info.pictype = DLT_JUNIPER_SERVICES;
- if(juniper_parse_header(p, h, &l2info) == 0)
+ if (juniper_parse_header(ndo, p, h, &l2info) == 0)
return l2info.header_len;
p+=l2info.header_len;
sh = (struct juniper_services_header *)p;
- if (eflag)
- printf("service-id %u flags 0x%02x service-set-id 0x%04x iif %u: ",
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "service-id %u flags 0x%02x service-set-id 0x%04x iif %u: ",
sh->svc_id,
sh->flags_len,
EXTRACT_16BITS(&sh->svc_set_id),
- EXTRACT_24BITS(&sh->dir_iif[1]));
+ EXTRACT_24BITS(&sh->dir_iif[1])));
/* no proto field - lets guess by first byte of IP header*/
- ip_heuristic_guess(p, l2info.length);
+ ip_heuristic_guess (ndo, p, l2info.length);
return l2info.header_len;
}
@@ -637,98 +637,104 @@ juniper_services_print(const struct pcap_pkthdr *h, register const u_char *p)
#ifdef DLT_JUNIPER_PPPOE
u_int
-juniper_pppoe_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_pppoe_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, register const u_char *p)
{
struct juniper_l2info_t l2info;
l2info.pictype = DLT_JUNIPER_PPPOE;
- if(juniper_parse_header(p, h, &l2info) == 0)
+ if (juniper_parse_header(ndo, p, h, &l2info) == 0)
return l2info.header_len;
p+=l2info.header_len;
/* this DLT contains nothing but raw ethernet frames */
- ether_print(gndo, p, l2info.length, l2info.caplen, NULL, NULL);
+ ether_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL);
return l2info.header_len;
}
#endif
#ifdef DLT_JUNIPER_ETHER
u_int
-juniper_ether_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_ether_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, register const u_char *p)
{
struct juniper_l2info_t l2info;
l2info.pictype = DLT_JUNIPER_ETHER;
- if(juniper_parse_header(p, h, &l2info) == 0)
+ if (juniper_parse_header(ndo, p, h, &l2info) == 0)
return l2info.header_len;
p+=l2info.header_len;
/* this DLT contains nothing but raw Ethernet frames */
- ether_print(gndo, p, l2info.length, l2info.caplen, NULL, NULL);
+ ether_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL);
return l2info.header_len;
}
#endif
#ifdef DLT_JUNIPER_PPP
u_int
-juniper_ppp_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_ppp_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, register const u_char *p)
{
struct juniper_l2info_t l2info;
l2info.pictype = DLT_JUNIPER_PPP;
- if(juniper_parse_header(p, h, &l2info) == 0)
+ if (juniper_parse_header(ndo, p, h, &l2info) == 0)
return l2info.header_len;
p+=l2info.header_len;
/* this DLT contains nothing but raw ppp frames */
- ppp_print(p, l2info.length);
+ ppp_print(ndo, p, l2info.length);
return l2info.header_len;
}
#endif
#ifdef DLT_JUNIPER_FRELAY
u_int
-juniper_frelay_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_frelay_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, register const u_char *p)
{
struct juniper_l2info_t l2info;
l2info.pictype = DLT_JUNIPER_FRELAY;
- if(juniper_parse_header(p, h, &l2info) == 0)
+ if (juniper_parse_header(ndo, p, h, &l2info) == 0)
return l2info.header_len;
p+=l2info.header_len;
/* this DLT contains nothing but raw frame-relay frames */
- fr_print(p, l2info.length);
+ fr_print(ndo, p, l2info.length);
return l2info.header_len;
}
#endif
#ifdef DLT_JUNIPER_CHDLC
u_int
-juniper_chdlc_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_chdlc_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, register const u_char *p)
{
struct juniper_l2info_t l2info;
l2info.pictype = DLT_JUNIPER_CHDLC;
- if(juniper_parse_header(p, h, &l2info) == 0)
+ if (juniper_parse_header(ndo, p, h, &l2info) == 0)
return l2info.header_len;
p+=l2info.header_len;
/* this DLT contains nothing but raw c-hdlc frames */
- chdlc_print(p, l2info.length);
+ chdlc_print(ndo, p, l2info.length);
return l2info.header_len;
}
#endif
#ifdef DLT_JUNIPER_PPPOE_ATM
u_int
-juniper_pppoe_atm_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_pppoe_atm_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, register const u_char *p)
{
struct juniper_l2info_t l2info;
- u_int16_t extracted_ethertype;
+ uint16_t extracted_ethertype;
l2info.pictype = DLT_JUNIPER_PPPOE_ATM;
- if(juniper_parse_header(p, h, &l2info) == 0)
+ if (juniper_parse_header(ndo, p, h, &l2info) == 0)
return l2info.header_len;
p+=l2info.header_len;
@@ -736,33 +742,34 @@ juniper_pppoe_atm_print(const struct pcap_pkthdr *h, register const u_char *p)
extracted_ethertype = EXTRACT_16BITS(p);
/* this DLT contains nothing but raw PPPoE frames,
* prepended with a type field*/
- if (ethertype_print(gndo, extracted_ethertype,
+ if (ethertype_print(ndo, extracted_ethertype,
p+ETHERTYPE_LEN,
l2info.length-ETHERTYPE_LEN,
l2info.caplen-ETHERTYPE_LEN) == 0)
/* ether_type not known, probably it wasn't one */
- printf("unknown ethertype 0x%04x", extracted_ethertype);
-
+ ND_PRINT((ndo, "unknown ethertype 0x%04x", extracted_ethertype));
+
return l2info.header_len;
}
#endif
#ifdef DLT_JUNIPER_MLPPP
u_int
-juniper_mlppp_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_mlppp_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, register const u_char *p)
{
struct juniper_l2info_t l2info;
l2info.pictype = DLT_JUNIPER_MLPPP;
- if(juniper_parse_header(p, h, &l2info) == 0)
+ if (juniper_parse_header(ndo, p, h, &l2info) == 0)
return l2info.header_len;
/* suppress Bundle-ID if frame was captured on a child-link
* best indicator if the cookie looks like a proto */
- if (eflag &&
+ if (ndo->ndo_eflag &&
EXTRACT_16BITS(&l2info.cookie) != PPP_OSI &&
EXTRACT_16BITS(&l2info.cookie) != (PPP_ADDRESS << 8 | PPP_CONTROL))
- printf("Bundle-ID %u: ",l2info.bundle);
+ ND_PRINT((ndo, "Bundle-ID %u: ", l2info.bundle));
p+=l2info.header_len;
@@ -773,20 +780,20 @@ juniper_mlppp_print(const struct pcap_pkthdr *h, register const u_char *p)
* -> this must be incoming IS-IS over PPP
*/
if (l2info.cookie[4] == (JUNIPER_LSQ_COOKIE_RE|JUNIPER_LSQ_COOKIE_DIR))
- ppp_print(p, l2info.length);
+ ppp_print(ndo, p, l2info.length);
else
- ip_print(gndo, p, l2info.length);
+ ip_print(ndo, p, l2info.length);
return l2info.header_len;
#ifdef INET6
case JUNIPER_LSQ_L3_PROTO_IPV6:
- ip6_print(gndo, p,l2info.length);
+ ip6_print(ndo, p,l2info.length);
return l2info.header_len;
#endif
case JUNIPER_LSQ_L3_PROTO_MPLS:
- mpls_print(p,l2info.length);
+ mpls_print(ndo, p, l2info.length);
return l2info.header_len;
case JUNIPER_LSQ_L3_PROTO_ISO:
- isoclns_print(p,l2info.length,l2info.caplen);
+ isoclns_print(ndo, p, l2info.length, l2info.caplen);
return l2info.header_len;
default:
break;
@@ -795,11 +802,11 @@ juniper_mlppp_print(const struct pcap_pkthdr *h, register const u_char *p)
/* zero length cookie ? */
switch (EXTRACT_16BITS(&l2info.cookie)) {
case PPP_OSI:
- ppp_print(p-2,l2info.length+2);
+ ppp_print(ndo, p - 2, l2info.length + 2);
break;
case (PPP_ADDRESS << 8 | PPP_CONTROL): /* fall through */
default:
- ppp_print(p,l2info.length);
+ ppp_print(ndo, p, l2info.length);
break;
}
@@ -810,19 +817,20 @@ juniper_mlppp_print(const struct pcap_pkthdr *h, register const u_char *p)
#ifdef DLT_JUNIPER_MFR
u_int
-juniper_mfr_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_mfr_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, register const u_char *p)
{
struct juniper_l2info_t l2info;
l2info.pictype = DLT_JUNIPER_MFR;
- if(juniper_parse_header(p, h, &l2info) == 0)
+ if (juniper_parse_header(ndo, p, h, &l2info) == 0)
return l2info.header_len;
-
+
p+=l2info.header_len;
/* child-link ? */
if (l2info.cookie_len == 0) {
- mfr_print(p,l2info.length);
+ mfr_print(ndo, p, l2info.length);
return l2info.header_len;
}
@@ -830,18 +838,18 @@ juniper_mfr_print(const struct pcap_pkthdr *h, register const u_char *p)
if (l2info.cookie_len == AS_PIC_COOKIE_LEN) {
switch(l2info.proto) {
case JUNIPER_LSQ_L3_PROTO_IPV4:
- ip_print(gndo, p, l2info.length);
+ ip_print(ndo, p, l2info.length);
return l2info.header_len;
#ifdef INET6
case JUNIPER_LSQ_L3_PROTO_IPV6:
- ip6_print(gndo, p,l2info.length);
+ ip6_print(ndo, p,l2info.length);
return l2info.header_len;
#endif
case JUNIPER_LSQ_L3_PROTO_MPLS:
- mpls_print(p,l2info.length);
+ mpls_print(ndo, p, l2info.length);
return l2info.header_len;
case JUNIPER_LSQ_L3_PROTO_ISO:
- isoclns_print(p,l2info.length,l2info.caplen);
+ isoclns_print(ndo, p, l2info.length, l2info.caplen);
return l2info.header_len;
default:
break;
@@ -850,19 +858,20 @@ juniper_mfr_print(const struct pcap_pkthdr *h, register const u_char *p)
}
/* suppress Bundle-ID if frame was captured on a child-link */
- if (eflag && EXTRACT_32BITS(l2info.cookie) != 1) printf("Bundle-ID %u, ",l2info.bundle);
+ if (ndo->ndo_eflag && EXTRACT_32BITS(l2info.cookie) != 1)
+ ND_PRINT((ndo, "Bundle-ID %u, ", l2info.bundle));
switch (l2info.proto) {
case (LLCSAP_ISONS<<8 | LLCSAP_ISONS):
- isoclns_print(p+1, l2info.length-1, l2info.caplen-1);
+ isoclns_print(ndo, p + 1, l2info.length - 1, l2info.caplen - 1);
break;
case (LLC_UI<<8 | NLPID_Q933):
case (LLC_UI<<8 | NLPID_IP):
case (LLC_UI<<8 | NLPID_IP6):
/* pass IP{4,6} to the OSI layer for proper link-layer printing */
- isoclns_print(p-1, l2info.length+1, l2info.caplen+1);
+ isoclns_print(ndo, p - 1, l2info.length + 1, l2info.caplen + 1);
break;
default:
- printf("unknown protocol 0x%04x, length %u",l2info.proto, l2info.length);
+ ND_PRINT((ndo, "unknown protocol 0x%04x, length %u", l2info.proto, l2info.length));
}
return l2info.header_len;
@@ -871,31 +880,33 @@ juniper_mfr_print(const struct pcap_pkthdr *h, register const u_char *p)
#ifdef DLT_JUNIPER_MLFR
u_int
-juniper_mlfr_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_mlfr_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, register const u_char *p)
{
struct juniper_l2info_t l2info;
l2info.pictype = DLT_JUNIPER_MLFR;
- if(juniper_parse_header(p, h, &l2info) == 0)
+ if (juniper_parse_header(ndo, p, h, &l2info) == 0)
return l2info.header_len;
p+=l2info.header_len;
/* suppress Bundle-ID if frame was captured on a child-link */
- if (eflag && EXTRACT_32BITS(l2info.cookie) != 1) printf("Bundle-ID %u, ",l2info.bundle);
+ if (ndo->ndo_eflag && EXTRACT_32BITS(l2info.cookie) != 1)
+ ND_PRINT((ndo, "Bundle-ID %u, ", l2info.bundle));
switch (l2info.proto) {
case (LLC_UI):
case (LLC_UI<<8):
- isoclns_print(p, l2info.length, l2info.caplen);
+ isoclns_print(ndo, p, l2info.length, l2info.caplen);
break;
case (LLC_UI<<8 | NLPID_Q933):
case (LLC_UI<<8 | NLPID_IP):
case (LLC_UI<<8 | NLPID_IP6):
/* pass IP{4,6} to the OSI layer for proper link-layer printing */
- isoclns_print(p-1, l2info.length+1, l2info.caplen+1);
+ isoclns_print(ndo, p - 1, l2info.length + 1, l2info.caplen + 1);
break;
default:
- printf("unknown protocol 0x%04x, length %u",l2info.proto, l2info.length);
+ ND_PRINT((ndo, "unknown protocol 0x%04x, length %u", l2info.proto, l2info.length));
}
return l2info.header_len;
@@ -912,38 +923,39 @@ juniper_mlfr_print(const struct pcap_pkthdr *h, register const u_char *p)
#ifdef DLT_JUNIPER_ATM1
u_int
-juniper_atm1_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_atm1_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, register const u_char *p)
{
- u_int16_t extracted_ethertype;
+ uint16_t extracted_ethertype;
struct juniper_l2info_t l2info;
l2info.pictype = DLT_JUNIPER_ATM1;
- if(juniper_parse_header(p, h, &l2info) == 0)
+ if (juniper_parse_header(ndo, p, h, &l2info) == 0)
return l2info.header_len;
p+=l2info.header_len;
if (l2info.cookie[0] == 0x80) { /* OAM cell ? */
- oam_print(p,l2info.length,ATM_OAM_NOHEC);
+ oam_print(ndo, p, l2info.length, ATM_OAM_NOHEC);
return l2info.header_len;
}
if (EXTRACT_24BITS(p) == 0xfefe03 || /* NLPID encaps ? */
EXTRACT_24BITS(p) == 0xaaaa03) { /* SNAP encaps ? */
- if (llc_print(p, l2info.length, l2info.caplen, NULL, NULL,
+ if (llc_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL,
&extracted_ethertype) != 0)
return l2info.header_len;
}
if (p[0] == 0x03) { /* Cisco style NLPID encaps ? */
- isoclns_print(p + 1, l2info.length - 1, l2info.caplen - 1);
+ isoclns_print(ndo, p + 1, l2info.length - 1, l2info.caplen - 1);
/* FIXME check if frame was recognized */
return l2info.header_len;
}
- if(ip_heuristic_guess(p, l2info.length) != 0) /* last try - vcmux encaps ? */
+ if (ip_heuristic_guess(ndo, p, l2info.length) != 0) /* last try - vcmux encaps ? */
return l2info.header_len;
return l2info.header_len;
@@ -960,47 +972,48 @@ juniper_atm1_print(const struct pcap_pkthdr *h, register const u_char *p)
#ifdef DLT_JUNIPER_ATM2
u_int
-juniper_atm2_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_atm2_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, register const u_char *p)
{
- u_int16_t extracted_ethertype;
+ uint16_t extracted_ethertype;
struct juniper_l2info_t l2info;
l2info.pictype = DLT_JUNIPER_ATM2;
- if(juniper_parse_header(p, h, &l2info) == 0)
+ if (juniper_parse_header(ndo, p, h, &l2info) == 0)
return l2info.header_len;
p+=l2info.header_len;
if (l2info.cookie[7] & ATM2_PKT_TYPE_MASK) { /* OAM cell ? */
- oam_print(p,l2info.length,ATM_OAM_NOHEC);
+ oam_print(ndo, p, l2info.length, ATM_OAM_NOHEC);
return l2info.header_len;
}
if (EXTRACT_24BITS(p) == 0xfefe03 || /* NLPID encaps ? */
EXTRACT_24BITS(p) == 0xaaaa03) { /* SNAP encaps ? */
- if (llc_print(p, l2info.length, l2info.caplen, NULL, NULL,
+ if (llc_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL,
&extracted_ethertype) != 0)
return l2info.header_len;
}
if (l2info.direction != JUNIPER_BPF_PKT_IN && /* ether-over-1483 encaps ? */
(EXTRACT_32BITS(l2info.cookie) & ATM2_GAP_COUNT_MASK)) {
- ether_print(gndo, p, l2info.length, l2info.caplen, NULL, NULL);
+ ether_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL);
return l2info.header_len;
}
if (p[0] == 0x03) { /* Cisco style NLPID encaps ? */
- isoclns_print(p + 1, l2info.length - 1, l2info.caplen - 1);
+ isoclns_print(ndo, p + 1, l2info.length - 1, l2info.caplen - 1);
/* FIXME check if frame was recognized */
return l2info.header_len;
}
- if(juniper_ppp_heuristic_guess(p, l2info.length) != 0) /* PPPoA vcmux encaps ? */
+ if(juniper_ppp_heuristic_guess(ndo, p, l2info.length) != 0) /* PPPoA vcmux encaps ? */
return l2info.header_len;
- if(ip_heuristic_guess(p, l2info.length) != 0) /* last try - vcmux encaps ? */
+ if (ip_heuristic_guess(ndo, p, l2info.length) != 0) /* last try - vcmux encaps ? */
return l2info.header_len;
return l2info.header_len;
@@ -1010,8 +1023,9 @@ juniper_atm2_print(const struct pcap_pkthdr *h, register const u_char *p)
/* try to guess, based on all PPP protos that are supported in
* a juniper router if the payload data is encapsulated using PPP */
-int
-juniper_ppp_heuristic_guess(register const u_char *p, u_int length) {
+static int
+juniper_ppp_heuristic_guess(netdissect_options *ndo,
+ register const u_char *p, u_int length) {
switch(EXTRACT_16BITS(p)) {
case PPP_IP :
@@ -1029,7 +1043,7 @@ juniper_ppp_heuristic_guess(register const u_char *p, u_int length) {
case PPP_IPV6 :
case PPP_IPV6CP :
#endif
- ppp_print(p, length);
+ ppp_print(ndo, p, length);
break;
default:
@@ -1039,8 +1053,9 @@ juniper_ppp_heuristic_guess(register const u_char *p, u_int length) {
return 1; /* we printed a ppp packet */
}
-int
-ip_heuristic_guess(register const u_char *p, u_int length) {
+static int
+ip_heuristic_guess(netdissect_options *ndo,
+ register const u_char *p, u_int length) {
switch(p[0]) {
case 0x45:
@@ -1054,7 +1069,7 @@ ip_heuristic_guess(register const u_char *p, u_int length) {
case 0x4d:
case 0x4e:
case 0x4f:
- ip_print(gndo, p, length);
+ ip_print(ndo, p, length);
break;
#ifdef INET6
case 0x60:
@@ -1073,7 +1088,7 @@ ip_heuristic_guess(register const u_char *p, u_int length) {
case 0x6d:
case 0x6e:
case 0x6f:
- ip6_print(gndo, p, length);
+ ip6_print(ndo, p, length);
break;
#endif
default:
@@ -1083,7 +1098,7 @@ ip_heuristic_guess(register const u_char *p, u_int length) {
return 1; /* we printed an v4/v6 packet */
}
-int
+static int
juniper_read_tlv_value(const u_char *p, u_int tlv_type, u_int tlv_len) {
int tlv_value;
@@ -1131,12 +1146,13 @@ juniper_read_tlv_value(const u_char *p, u_int tlv_type, u_int tlv_len) {
}
static int
-juniper_parse_header (const u_char *p, const struct pcap_pkthdr *h, struct juniper_l2info_t *l2info) {
+juniper_parse_header(netdissect_options *ndo,
+ const u_char *p, const struct pcap_pkthdr *h, struct juniper_l2info_t *l2info) {
- struct juniper_cookie_table_t *lp = juniper_cookie_table;
+ const struct juniper_cookie_table_t *lp = juniper_cookie_table;
u_int idx, jnx_ext_len, jnx_header_len = 0;
- u_int8_t tlv_type,tlv_len;
- u_int32_t control_word;
+ uint8_t tlv_type,tlv_len;
+ uint32_t control_word;
int tlv_value;
const u_char *tptr;
@@ -1148,24 +1164,24 @@ 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);
+ ND_TCHECK2(p[0], 4);
l2info->flags = p[3];
l2info->direction = p[3]&JUNIPER_BPF_PKT_IN;
-
+
if (EXTRACT_24BITS(p) != JUNIPER_MGC_NUMBER) { /* magic number found ? */
- printf("no magic-number found!");
+ ND_PRINT((ndo, "no magic-number found!"));
return 0;
- }
+ }
- if (eflag) /* print direction */
- printf("%3s ",tok2str(juniper_direction_values,"---",l2info->direction));
+ if (ndo->ndo_eflag) /* print direction */
+ ND_PRINT((ndo, "%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));
+ if (ndo->ndo_vflag > 1)
+ ND_PRINT((ndo, "\n\tJuniper PCAP Flags [%s]",
+ bittok2str(jnx_flag_values, "none", l2info->flags)));
/* extensions present ? - calculate how much bytes to skip */
if ((l2info->flags & JUNIPER_BPF_EXT ) == JUNIPER_BPF_EXT ) {
@@ -1173,36 +1189,35 @@ juniper_parse_header (const u_char *p, const struct pcap_pkthdr *h, struct junip
tptr = p+jnx_header_len;
/* ok to read extension length ? */
- TCHECK2(tptr[0], 2);
+ ND_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);
+
+ if (ndo->ndo_vflag > 1)
+ ND_PRINT((ndo, ", PCAP Extension(s) total length %u", jnx_ext_len));
+
+ ND_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 ",
+
+ if (ndo->ndo_vflag > 1)
+ ND_PRINT((ndo, "\n\t %s Extension TLV #%u, length %u, value ",
tok2str(jnx_ext_tlv_values,"Unknown",tlv_type),
tlv_type,
- tlv_len);
-
+ tlv_len));
+
tlv_value = juniper_read_tlv_value(tptr, tlv_type, tlv_len);
switch (tlv_type) {
case JUNIPER_EXT_TLV_IFD_NAME:
@@ -1211,19 +1226,19 @@ juniper_parse_header (const u_char *p, const struct pcap_pkthdr *h, struct junip
case JUNIPER_EXT_TLV_IFD_MEDIATYPE:
case JUNIPER_EXT_TLV_TTP_IFD_MEDIATYPE:
if (tlv_value != -1) {
- if (vflag>1)
- printf("%s (%u)",
+ if (ndo->ndo_vflag > 1)
+ ND_PRINT((ndo, "%s (%u)",
tok2str(juniper_ifmt_values, "Unknown", tlv_value),
- 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)",
+ if (ndo->ndo_vflag > 1)
+ ND_PRINT((ndo, "%s (%u)",
tok2str(juniper_ifle_values, "Unknown", tlv_value),
- tlv_value);
+ tlv_value));
}
break;
case JUNIPER_EXT_TLV_IFL_IDX: /* fall through */
@@ -1231,35 +1246,36 @@ juniper_parse_header (const u_char *p, const struct pcap_pkthdr *h, struct junip
case JUNIPER_EXT_TLV_IFD_IDX:
default:
if (tlv_value != -1) {
- if (vflag>1)
- printf("%u",tlv_value);
+ if (ndo->ndo_vflag > 1)
+ ND_PRINT((ndo, "%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, ");
+
+ if (ndo->ndo_vflag > 1)
+ ND_PRINT((ndo, "\n\t-----original packet-----\n\t"));
+ }
+
+ if ((l2info->flags & JUNIPER_BPF_NO_L2 ) == JUNIPER_BPF_NO_L2 ) {
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "no-L2-hdr, "));
/* there is no link-layer present -
* perform the v4/v6 heuristics
* to figure out what it is
*/
- TCHECK2(p[jnx_header_len+4],1);
- if(ip_heuristic_guess(p+jnx_header_len+4,l2info->length-(jnx_header_len+4)) == 0)
- printf("no IP-hdr found!");
+ ND_TCHECK2(p[jnx_header_len + 4], 1);
+ if (ip_heuristic_guess(ndo, p + jnx_header_len + 4,
+ l2info->length - (jnx_header_len + 4)) == 0)
+ ND_PRINT((ndo, "no IP-hdr found!"));
l2info->header_len=jnx_header_len+4;
return 0; /* stop parsing the output further */
-
+
}
l2info->header_len = jnx_header_len;
p+=l2info->header_len;
@@ -1281,7 +1297,7 @@ juniper_parse_header (const u_char *p, const struct pcap_pkthdr *h, struct junip
l2info->cookie_type = AS_COOKIE_ID;
l2info->cookie_len = 8;
break;
-
+
default:
l2info->bundle = l2info->cookie[0];
break;
@@ -1300,25 +1316,25 @@ juniper_parse_header (const u_char *p, const struct pcap_pkthdr *h, struct junip
l2info->length -= l2info->cookie_len;
l2info->caplen -= l2info->cookie_len;
- if (eflag)
- printf("%s-PIC, cookie-len %u",
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "%s-PIC, cookie-len %u",
lp->s,
- l2info->cookie_len);
+ l2info->cookie_len));
if (l2info->cookie_len > 0) {
- TCHECK2(p[0],l2info->cookie_len);
- if (eflag)
- printf(", cookie 0x");
+ ND_TCHECK2(p[0], l2info->cookie_len);
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, ", cookie 0x"));
for (idx = 0; idx < l2info->cookie_len; idx++) {
l2info->cookie[idx] = p[idx]; /* copy cookie data */
- if (eflag) printf("%02x",p[idx]);
+ if (ndo->ndo_eflag) ND_PRINT((ndo, "%02x", p[idx]));
}
}
- if (eflag) printf(": "); /* print demarc b/w L2/L3*/
-
+ if (ndo->ndo_eflag) ND_PRINT((ndo, ": ")); /* print demarc b/w L2/L3*/
+
- l2info->proto = EXTRACT_16BITS(p+l2info->cookie_len);
+ l2info->proto = EXTRACT_16BITS(p+l2info->cookie_len);
break;
}
++lp;
@@ -1335,7 +1351,7 @@ juniper_parse_header (const u_char *p, const struct pcap_pkthdr *h, struct junip
break;
case AS_COOKIE_ID:
l2info->bundle = (EXTRACT_16BITS(&l2info->cookie[6])>>3)&0xfff;
- l2info->proto = (l2info->cookie[5])&JUNIPER_LSQ_L3_PROTO_MASK;
+ l2info->proto = (l2info->cookie[5])&JUNIPER_LSQ_L3_PROTO_MASK;
break;
default:
l2info->bundle = l2info->cookie[0];
@@ -1348,7 +1364,7 @@ juniper_parse_header (const u_char *p, const struct pcap_pkthdr *h, struct junip
switch (l2info->cookie_type) {
case LS_COOKIE_ID:
l2info->bundle = l2info->cookie[1];
- l2info->proto = EXTRACT_16BITS(p);
+ l2info->proto = EXTRACT_16BITS(p);
l2info->header_len += 2;
l2info->length -= 2;
l2info->caplen -= 2;
@@ -1371,7 +1387,7 @@ juniper_parse_header (const u_char *p, const struct pcap_pkthdr *h, struct junip
switch (l2info->cookie_type) {
case LS_COOKIE_ID:
l2info->bundle = l2info->cookie[1];
- l2info->proto = EXTRACT_16BITS(p);
+ l2info->proto = EXTRACT_16BITS(p);
l2info->header_len += 2;
l2info->length -= 2;
l2info->caplen -= 2;
@@ -1388,7 +1404,7 @@ juniper_parse_header (const u_char *p, const struct pcap_pkthdr *h, struct junip
#endif
#ifdef DLT_JUNIPER_ATM2
case DLT_JUNIPER_ATM2:
- TCHECK2(p[0],4);
+ ND_TCHECK2(p[0], 4);
/* ATM cell relay control word present ? */
if (l2info->cookie[7] & ATM2_PKT_TYPE_MASK) {
control_word = EXTRACT_32BITS(p);
@@ -1402,9 +1418,9 @@ juniper_parse_header (const u_char *p, const struct pcap_pkthdr *h, struct junip
default:
break;
}
-
- if (eflag)
- printf("control-word 0x%08x ", control_word);
+
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "control-word 0x%08x ", control_word));
}
break;
#endif
@@ -1434,16 +1450,16 @@ juniper_parse_header (const u_char *p, const struct pcap_pkthdr *h, struct junip
#endif
default:
- printf("Unknown Juniper DLT_ type %u: ", l2info->pictype);
+ ND_PRINT((ndo, "Unknown Juniper DLT_ type %u: ", l2info->pictype));
break;
}
-
- if (eflag > 1)
- printf("hlen %u, proto 0x%04x, ",l2info->header_len,l2info->proto);
+
+ if (ndo->ndo_eflag > 1)
+ ND_PRINT((ndo, "hlen %u, proto 0x%04x, ", l2info->header_len, l2info->proto));
return 1; /* everything went ok so far. continue parsing */
trunc:
- printf("[|juniper_hdr], length %u",h->len);
+ ND_PRINT((ndo, "[|juniper_hdr], length %u", h->len));
return 0;
}
diff --git a/contrib/tcpdump/print-krb.c b/contrib/tcpdump/print-krb.c
index 213db642db63..2eebfa69bb83 100644
--- a/contrib/tcpdump/print-krb.c
+++ b/contrib/tcpdump/print-krb.c
@@ -21,26 +21,21 @@
* Initial contribution from John Hawkinson (jhawk@mit.edu).
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-krb.c,v 1.23 2003-11-16 09:36:26 guy Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-
#include "interface.h"
-#include "addrtoname.h"
#include "extract.h"
-static const u_char *c_print(register const u_char *, register const u_char *);
-static const u_char *krb4_print_hdr(const u_char *);
-static void krb4_print(const u_char *);
+static const char tstr[] = " [|kerberos]";
+
+static const u_char *c_print(netdissect_options *, register const u_char *, register const u_char *);
+static const u_char *krb4_print_hdr(netdissect_options *, const u_char *);
+static void krb4_print(netdissect_options *, const u_char *);
#define AUTH_MSG_KDC_REQUEST 1<<1
#define AUTH_MSG_KDC_REPLY 2<<1
@@ -65,13 +60,11 @@ static void krb4_print(const u_char *);
#define KERB_ERR_NULL_KEY 10
struct krb {
- u_int8_t pvno; /* Protocol Version */
- u_int8_t type; /* Type+B */
+ uint8_t pvno; /* Protocol Version */
+ uint8_t type; /* Type+B */
};
-static char tstr[] = " [|kerberos]";
-
-static struct tok type2str[] = {
+static const struct tok type2str[] = {
{ AUTH_MSG_KDC_REQUEST, "KDC_REQUEST" },
{ AUTH_MSG_KDC_REPLY, "KDC_REPLY" },
{ AUTH_MSG_APPL_REQUEST, "APPL_REQUEST" },
@@ -84,7 +77,7 @@ static struct tok type2str[] = {
{ 0, NULL }
};
-static struct tok kerr2str[] = {
+static const struct tok kerr2str[] = {
{ KERB_ERR_OK, "OK" },
{ KERB_ERR_NAME_EXP, "NAME_EXP" },
{ KERB_ERR_SERVICE_EXP, "SERVICE_EXP" },
@@ -100,7 +93,8 @@ static struct tok kerr2str[] = {
};
static const u_char *
-c_print(register const u_char *s, register const u_char *ep)
+c_print(netdissect_options *ndo,
+ register const u_char *s, register const u_char *ep)
{
register u_char c;
register int flag;
@@ -112,16 +106,15 @@ c_print(register const u_char *s, register const u_char *ep)
flag = 0;
break;
}
- if (!isascii(c)) {
- c = toascii(c);
- putchar('M');
- putchar('-');
+ if (!ND_ISASCII(c)) {
+ c = ND_TOASCII(c);
+ ND_PRINT((ndo, "M-"));
}
- if (!isprint(c)) {
+ if (!ND_ISPRINT(c)) {
c ^= 0x40; /* DEL to ?, others to alpha */
- putchar('^');
+ ND_PRINT((ndo, "^"));
}
- putchar(c);
+ ND_PRINT((ndo, "%c", c));
}
if (flag)
return NULL;
@@ -129,112 +122,115 @@ c_print(register const u_char *s, register const u_char *ep)
}
static const u_char *
-krb4_print_hdr(const u_char *cp)
+krb4_print_hdr(netdissect_options *ndo,
+ const u_char *cp)
{
cp += 2;
-#define PRINT if ((cp = c_print(cp, snapend)) == NULL) goto trunc
+#define PRINT if ((cp = c_print(ndo, cp, ndo->ndo_snapend)) == NULL) goto trunc
PRINT;
- putchar('.');
+ ND_PRINT((ndo, "."));
PRINT;
- putchar('@');
+ ND_PRINT((ndo, "@"));
PRINT;
return (cp);
trunc:
- fputs(tstr, stdout);
+ ND_PRINT((ndo, "%s", tstr));
return (NULL);
#undef PRINT
}
static void
-krb4_print(const u_char *cp)
+krb4_print(netdissect_options *ndo,
+ const u_char *cp)
{
register const struct krb *kp;
u_char type;
u_short len;
-#define PRINT if ((cp = c_print(cp, snapend)) == NULL) goto trunc
+#define PRINT if ((cp = c_print(ndo, cp, ndo->ndo_snapend)) == NULL) goto trunc
/* True if struct krb is little endian */
#define IS_LENDIAN(kp) (((kp)->type & 0x01) != 0)
#define KTOHSP(kp, cp) (IS_LENDIAN(kp) ? EXTRACT_LE_16BITS(cp) : EXTRACT_16BITS(cp))
kp = (struct krb *)cp;
- if ((&kp->type) >= snapend) {
- fputs(tstr, stdout);
+ if ((&kp->type) >= ndo->ndo_snapend) {
+ ND_PRINT((ndo, "%s", tstr));
return;
}
type = kp->type & (0xFF << 1);
- printf(" %s %s: ",
- IS_LENDIAN(kp) ? "le" : "be", tok2str(type2str, NULL, type));
+ ND_PRINT((ndo, " %s %s: ",
+ IS_LENDIAN(kp) ? "le" : "be", tok2str(type2str, NULL, type)));
switch (type) {
case AUTH_MSG_KDC_REQUEST:
- if ((cp = krb4_print_hdr(cp)) == NULL)
+ if ((cp = krb4_print_hdr(ndo, cp)) == NULL)
return;
cp += 4; /* ctime */
- TCHECK(*cp);
- printf(" %dmin ", *cp++ * 5);
+ ND_TCHECK(*cp);
+ ND_PRINT((ndo, " %dmin ", *cp++ * 5));
PRINT;
- putchar('.');
+ ND_PRINT((ndo, "."));
PRINT;
break;
case AUTH_MSG_APPL_REQUEST:
cp += 2;
- TCHECK(*cp);
- printf("v%d ", *cp++);
+ ND_TCHECK(*cp);
+ ND_PRINT((ndo, "v%d ", *cp++));
PRINT;
- TCHECK(*cp);
- printf(" (%d)", *cp++);
- TCHECK(*cp);
- printf(" (%d)", *cp);
+ ND_TCHECK(*cp);
+ ND_PRINT((ndo, " (%d)", *cp++));
+ ND_TCHECK(*cp);
+ ND_PRINT((ndo, " (%d)", *cp));
break;
case AUTH_MSG_KDC_REPLY:
- if ((cp = krb4_print_hdr(cp)) == NULL)
+ if ((cp = krb4_print_hdr(ndo, cp)) == NULL)
return;
cp += 10; /* timestamp + n + exp + kvno */
- TCHECK2(*cp, sizeof(short));
+ ND_TCHECK2(*cp, sizeof(short));
len = KTOHSP(kp, cp);
- printf(" (%d)", len);
+ ND_PRINT((ndo, " (%d)", len));
break;
case AUTH_MSG_ERR_REPLY:
- if ((cp = krb4_print_hdr(cp)) == NULL)
+ if ((cp = krb4_print_hdr(ndo, cp)) == NULL)
return;
cp += 4; /* timestamp */
- TCHECK2(*cp, sizeof(short));
- printf(" %s ", tok2str(kerr2str, NULL, KTOHSP(kp, cp)));
+ ND_TCHECK2(*cp, sizeof(short));
+ ND_PRINT((ndo, " %s ", tok2str(kerr2str, NULL, KTOHSP(kp, cp))));
cp += 4;
PRINT;
break;
default:
- fputs("(unknown)", stdout);
+ ND_PRINT((ndo, "(unknown)"));
break;
}
return;
trunc:
- fputs(tstr, stdout);
+ ND_PRINT((ndo, "%s", tstr));
}
void
-krb_print(const u_char *dat)
+krb_print(netdissect_options *ndo,
+ const u_char *dat)
{
register const struct krb *kp;
kp = (struct krb *)dat;
- if (dat >= snapend) {
- fputs(tstr, stdout);
+ if (dat >= ndo->ndo_snapend) {
+ ND_PRINT((ndo, "%s", tstr));
return;
}
@@ -243,17 +239,17 @@ krb_print(const u_char *dat)
case 1:
case 2:
case 3:
- printf(" v%d", kp->pvno);
+ ND_PRINT((ndo, " v%d", kp->pvno));
break;
case 4:
- printf(" v%d", kp->pvno);
- krb4_print((const u_char *)kp);
+ ND_PRINT((ndo, " v%d", kp->pvno));
+ krb4_print(ndo, (const u_char *)kp);
break;
case 106:
case 107:
- fputs(" v5", stdout);
+ ND_PRINT((ndo, " v5"));
/* Decode ASN.1 here "someday" */
break;
}
diff --git a/contrib/tcpdump/print-l2tp.c b/contrib/tcpdump/print-l2tp.c
index 2f726574e4ee..346dae9d52c6 100644
--- a/contrib/tcpdump/print-l2tp.c
+++ b/contrib/tcpdump/print-l2tp.c
@@ -21,24 +21,53 @@
* L2TP support contributed by Motonori Shindo (mshindo@mshindo.net)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-l2tp.c,v 1.20 2006-06-23 02:03:09 hannes Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-
-#include "l2tp.h"
#include "interface.h"
#include "extract.h"
-static char tstr[] = " [|l2tp]";
+#define L2TP_FLAG_TYPE 0x8000 /* Type (0=Data, 1=Control) */
+#define L2TP_FLAG_LENGTH 0x4000 /* Length */
+#define L2TP_FLAG_SEQUENCE 0x0800 /* Sequence */
+#define L2TP_FLAG_OFFSET 0x0200 /* Offset */
+#define L2TP_FLAG_PRIORITY 0x0100 /* Priority */
+
+#define L2TP_VERSION_MASK 0x000f /* Version Mask */
+#define L2TP_VERSION_L2F 0x0001 /* L2F */
+#define L2TP_VERSION_L2TP 0x0002 /* L2TP */
+
+#define L2TP_AVP_HDR_FLAG_MANDATORY 0x8000 /* Mandatory Flag */
+#define L2TP_AVP_HDR_FLAG_HIDDEN 0x4000 /* Hidden Flag */
+#define L2TP_AVP_HDR_LEN_MASK 0x03ff /* Length Mask */
+
+#define L2TP_FRAMING_CAP_SYNC_MASK 0x00000001 /* Synchronous */
+#define L2TP_FRAMING_CAP_ASYNC_MASK 0x00000002 /* Asynchronous */
+
+#define L2TP_FRAMING_TYPE_SYNC_MASK 0x00000001 /* Synchronous */
+#define L2TP_FRAMING_TYPE_ASYNC_MASK 0x00000002 /* Asynchronous */
+
+#define L2TP_BEARER_CAP_DIGITAL_MASK 0x00000001 /* Digital */
+#define L2TP_BEARER_CAP_ANALOG_MASK 0x00000002 /* Analog */
+
+#define L2TP_BEARER_TYPE_DIGITAL_MASK 0x00000001 /* Digital */
+#define L2TP_BEARER_TYPE_ANALOG_MASK 0x00000002 /* Analog */
+
+/* Authen Type */
+#define L2TP_AUTHEN_TYPE_RESERVED 0x0000 /* Reserved */
+#define L2TP_AUTHEN_TYPE_TEXTUAL 0x0001 /* Textual username/password exchange */
+#define L2TP_AUTHEN_TYPE_CHAP 0x0002 /* PPP CHAP */
+#define L2TP_AUTHEN_TYPE_PAP 0x0003 /* PPP PAP */
+#define L2TP_AUTHEN_TYPE_NO_AUTH 0x0004 /* No Authentication */
+#define L2TP_AUTHEN_TYPE_MSCHAPv1 0x0005 /* MSCHAPv1 */
+
+#define L2TP_PROXY_AUTH_ID_MASK 0x00ff
+
+static const char tstr[] = " [|l2tp]";
#define L2TP_MSGTYPE_SCCRQ 1 /* Start-Control-Connection-Request */
#define L2TP_MSGTYPE_SCCRP 2 /* Start-Control-Connection-Reply */
@@ -55,7 +84,7 @@ static char tstr[] = " [|l2tp]";
#define L2TP_MSGTYPE_WEN 15 /* WAN-Error-Notify */
#define L2TP_MSGTYPE_SLI 16 /* Set-Link-Info */
-static struct tok l2tp_msgtype2str[] = {
+static const struct tok l2tp_msgtype2str[] = {
{ L2TP_MSGTYPE_SCCRQ, "SCCRQ" },
{ L2TP_MSGTYPE_SCCRP, "SCCRP" },
{ L2TP_MSGTYPE_SCCCN, "SCCCN" },
@@ -115,7 +144,7 @@ static struct tok l2tp_msgtype2str[] = {
#define L2TP_AVP_SEQ_REQUIRED 39 /* Sequencing Required */
#define L2TP_AVP_PPP_DISCON_CC 46 /* PPP Disconnect Cause Code */
-static struct tok l2tp_avp2str[] = {
+static const struct tok l2tp_avp2str[] = {
{ L2TP_AVP_MSGTYPE, "MSGTYPE" },
{ L2TP_AVP_RESULT_CODE, "RESULT_CODE" },
{ L2TP_AVP_PROTO_VER, "PROTO_VER" },
@@ -160,7 +189,7 @@ static struct tok l2tp_avp2str[] = {
{ 0, NULL }
};
-static struct tok l2tp_authentype2str[] = {
+static const struct tok l2tp_authentype2str[] = {
{ L2TP_AUTHEN_TYPE_RESERVED, "Reserved" },
{ L2TP_AUTHEN_TYPE_TEXTUAL, "Textual" },
{ L2TP_AUTHEN_TYPE_CHAP, "CHAP" },
@@ -174,7 +203,7 @@ static struct tok l2tp_authentype2str[] = {
#define L2TP_PPP_DISCON_CC_DIRECTION_AT_PEER 1
#define L2TP_PPP_DISCON_CC_DIRECTION_AT_LOCAL 2
-static struct tok l2tp_cc_direction2str[] = {
+static const struct tok l2tp_cc_direction2str[] = {
{ L2TP_PPP_DISCON_CC_DIRECTION_GLOBAL, "global error" },
{ L2TP_PPP_DISCON_CC_DIRECTION_AT_PEER, "at peer" },
{ L2TP_PPP_DISCON_CC_DIRECTION_AT_LOCAL,"at local" },
@@ -234,236 +263,236 @@ static char *l2tp_error_code_general[] = {
/* generic print out routines */
/******************************/
static void
-print_string(const u_char *dat, u_int length)
+print_string(netdissect_options *ndo, const u_char *dat, u_int length)
{
u_int i;
for (i=0; i<length; i++) {
- printf("%c", *dat++);
+ ND_PRINT((ndo, "%c", *dat++));
}
}
static void
-print_octets(const u_char *dat, u_int length)
+print_octets(netdissect_options *ndo, const u_char *dat, u_int length)
{
u_int i;
for (i=0; i<length; i++) {
- printf("%02x", *dat++);
+ ND_PRINT((ndo, "%02x", *dat++));
}
}
static void
-print_16bits_val(const u_int16_t *dat)
+print_16bits_val(netdissect_options *ndo, const uint16_t *dat)
{
- printf("%u", EXTRACT_16BITS(dat));
+ ND_PRINT((ndo, "%u", EXTRACT_16BITS(dat)));
}
static void
-print_32bits_val(const u_int32_t *dat)
+print_32bits_val(netdissect_options *ndo, const uint32_t *dat)
{
- printf("%lu", (u_long)EXTRACT_32BITS(dat));
+ ND_PRINT((ndo, "%lu", (u_long)EXTRACT_32BITS(dat)));
}
/***********************************/
/* AVP-specific print out routines */
/***********************************/
static void
-l2tp_msgtype_print(const u_char *dat)
+l2tp_msgtype_print(netdissect_options *ndo, const u_char *dat)
{
- u_int16_t *ptr = (u_int16_t*)dat;
+ uint16_t *ptr = (uint16_t*)dat;
- printf("%s", tok2str(l2tp_msgtype2str, "MSGTYPE-#%u",
- EXTRACT_16BITS(ptr)));
+ ND_PRINT((ndo, "%s", tok2str(l2tp_msgtype2str, "MSGTYPE-#%u",
+ EXTRACT_16BITS(ptr))));
}
static void
-l2tp_result_code_print(const u_char *dat, u_int length)
+l2tp_result_code_print(netdissect_options *ndo, const u_char *dat, u_int length)
{
- u_int16_t *ptr = (u_int16_t *)dat;
+ uint16_t *ptr = (uint16_t *)dat;
- printf("%u", EXTRACT_16BITS(ptr)); ptr++; /* Result Code */
+ ND_PRINT((ndo, "%u", EXTRACT_16BITS(ptr))); ptr++; /* Result Code */
if (length > 2) { /* Error Code (opt) */
- printf("/%u", EXTRACT_16BITS(ptr)); ptr++;
+ ND_PRINT((ndo, "/%u", EXTRACT_16BITS(ptr))); ptr++;
}
if (length > 4) { /* Error Message (opt) */
- printf(" ");
- print_string((u_char *)ptr, length - 4);
+ ND_PRINT((ndo, " "));
+ print_string(ndo, (u_char *)ptr, length - 4);
}
}
static void
-l2tp_proto_ver_print(const u_int16_t *dat)
+l2tp_proto_ver_print(netdissect_options *ndo, const uint16_t *dat)
{
- printf("%u.%u", (EXTRACT_16BITS(dat) >> 8),
- (EXTRACT_16BITS(dat) & 0xff));
+ ND_PRINT((ndo, "%u.%u", (EXTRACT_16BITS(dat) >> 8),
+ (EXTRACT_16BITS(dat) & 0xff)));
}
static void
-l2tp_framing_cap_print(const u_char *dat)
+l2tp_framing_cap_print(netdissect_options *ndo, const u_char *dat)
{
- u_int32_t *ptr = (u_int32_t *)dat;
+ uint32_t *ptr = (uint32_t *)dat;
if (EXTRACT_32BITS(ptr) & L2TP_FRAMING_CAP_ASYNC_MASK) {
- printf("A");
+ ND_PRINT((ndo, "A"));
}
if (EXTRACT_32BITS(ptr) & L2TP_FRAMING_CAP_SYNC_MASK) {
- printf("S");
+ ND_PRINT((ndo, "S"));
}
}
static void
-l2tp_bearer_cap_print(const u_char *dat)
+l2tp_bearer_cap_print(netdissect_options *ndo, const u_char *dat)
{
- u_int32_t *ptr = (u_int32_t *)dat;
+ uint32_t *ptr = (uint32_t *)dat;
if (EXTRACT_32BITS(ptr) & L2TP_BEARER_CAP_ANALOG_MASK) {
- printf("A");
+ ND_PRINT((ndo, "A"));
}
if (EXTRACT_32BITS(ptr) & L2TP_BEARER_CAP_DIGITAL_MASK) {
- printf("D");
+ ND_PRINT((ndo, "D"));
}
}
static void
-l2tp_q931_cc_print(const u_char *dat, u_int length)
+l2tp_q931_cc_print(netdissect_options *ndo, const u_char *dat, u_int length)
{
- print_16bits_val((u_int16_t *)dat);
- printf(", %02x", dat[2]);
+ print_16bits_val(ndo, (uint16_t *)dat);
+ ND_PRINT((ndo, ", %02x", dat[2]));
if (length > 3) {
- printf(" ");
- print_string(dat+3, length-3);
+ ND_PRINT((ndo, " "));
+ print_string(ndo, dat+3, length-3);
}
}
static void
-l2tp_bearer_type_print(const u_char *dat)
+l2tp_bearer_type_print(netdissect_options *ndo, const u_char *dat)
{
- u_int32_t *ptr = (u_int32_t *)dat;
+ uint32_t *ptr = (uint32_t *)dat;
if (EXTRACT_32BITS(ptr) & L2TP_BEARER_TYPE_ANALOG_MASK) {
- printf("A");
+ ND_PRINT((ndo, "A"));
}
if (EXTRACT_32BITS(ptr) & L2TP_BEARER_TYPE_DIGITAL_MASK) {
- printf("D");
+ ND_PRINT((ndo, "D"));
}
}
static void
-l2tp_framing_type_print(const u_char *dat)
+l2tp_framing_type_print(netdissect_options *ndo, const u_char *dat)
{
- u_int32_t *ptr = (u_int32_t *)dat;
+ uint32_t *ptr = (uint32_t *)dat;
if (EXTRACT_32BITS(ptr) & L2TP_FRAMING_TYPE_ASYNC_MASK) {
- printf("A");
+ ND_PRINT((ndo, "A"));
}
if (EXTRACT_32BITS(ptr) & L2TP_FRAMING_TYPE_SYNC_MASK) {
- printf("S");
+ ND_PRINT((ndo, "S"));
}
}
static void
-l2tp_packet_proc_delay_print(void)
+l2tp_packet_proc_delay_print(netdissect_options *ndo)
{
- printf("obsolete");
+ ND_PRINT((ndo, "obsolete"));
}
static void
-l2tp_proxy_auth_type_print(const u_char *dat)
+l2tp_proxy_auth_type_print(netdissect_options *ndo, const u_char *dat)
{
- u_int16_t *ptr = (u_int16_t *)dat;
+ uint16_t *ptr = (uint16_t *)dat;
- printf("%s", tok2str(l2tp_authentype2str,
- "AuthType-#%u", EXTRACT_16BITS(ptr)));
+ ND_PRINT((ndo, "%s", tok2str(l2tp_authentype2str,
+ "AuthType-#%u", EXTRACT_16BITS(ptr))));
}
static void
-l2tp_proxy_auth_id_print(const u_char *dat)
+l2tp_proxy_auth_id_print(netdissect_options *ndo, const u_char *dat)
{
- u_int16_t *ptr = (u_int16_t *)dat;
+ uint16_t *ptr = (uint16_t *)dat;
- printf("%u", EXTRACT_16BITS(ptr) & L2TP_PROXY_AUTH_ID_MASK);
+ ND_PRINT((ndo, "%u", EXTRACT_16BITS(ptr) & L2TP_PROXY_AUTH_ID_MASK));
}
static void
-l2tp_call_errors_print(const u_char *dat)
+l2tp_call_errors_print(netdissect_options *ndo, const u_char *dat)
{
- u_int16_t *ptr = (u_int16_t *)dat;
- u_int16_t val_h, val_l;
+ uint16_t *ptr = (uint16_t *)dat;
+ uint16_t val_h, val_l;
ptr++; /* skip "Reserved" */
val_h = EXTRACT_16BITS(ptr); ptr++;
val_l = EXTRACT_16BITS(ptr); ptr++;
- printf("CRCErr=%u ", (val_h<<16) + val_l);
+ ND_PRINT((ndo, "CRCErr=%u ", (val_h<<16) + val_l));
val_h = EXTRACT_16BITS(ptr); ptr++;
val_l = EXTRACT_16BITS(ptr); ptr++;
- printf("FrameErr=%u ", (val_h<<16) + val_l);
+ ND_PRINT((ndo, "FrameErr=%u ", (val_h<<16) + val_l));
val_h = EXTRACT_16BITS(ptr); ptr++;
val_l = EXTRACT_16BITS(ptr); ptr++;
- printf("HardOver=%u ", (val_h<<16) + val_l);
+ ND_PRINT((ndo, "HardOver=%u ", (val_h<<16) + val_l));
val_h = EXTRACT_16BITS(ptr); ptr++;
val_l = EXTRACT_16BITS(ptr); ptr++;
- printf("BufOver=%u ", (val_h<<16) + val_l);
+ ND_PRINT((ndo, "BufOver=%u ", (val_h<<16) + val_l));
val_h = EXTRACT_16BITS(ptr); ptr++;
val_l = EXTRACT_16BITS(ptr); ptr++;
- printf("Timeout=%u ", (val_h<<16) + val_l);
+ ND_PRINT((ndo, "Timeout=%u ", (val_h<<16) + val_l));
val_h = EXTRACT_16BITS(ptr); ptr++;
val_l = EXTRACT_16BITS(ptr); ptr++;
- printf("AlignErr=%u ", (val_h<<16) + val_l);
+ ND_PRINT((ndo, "AlignErr=%u ", (val_h<<16) + val_l));
}
static void
-l2tp_accm_print(const u_char *dat)
+l2tp_accm_print(netdissect_options *ndo, const u_char *dat)
{
- u_int16_t *ptr = (u_int16_t *)dat;
- u_int16_t val_h, val_l;
+ uint16_t *ptr = (uint16_t *)dat;
+ uint16_t val_h, val_l;
ptr++; /* skip "Reserved" */
val_h = EXTRACT_16BITS(ptr); ptr++;
val_l = EXTRACT_16BITS(ptr); ptr++;
- printf("send=%08x ", (val_h<<16) + val_l);
+ ND_PRINT((ndo, "send=%08x ", (val_h<<16) + val_l));
val_h = EXTRACT_16BITS(ptr); ptr++;
val_l = EXTRACT_16BITS(ptr); ptr++;
- printf("recv=%08x ", (val_h<<16) + val_l);
+ ND_PRINT((ndo, "recv=%08x ", (val_h<<16) + val_l));
}
static void
-l2tp_ppp_discon_cc_print(const u_char *dat, u_int length)
+l2tp_ppp_discon_cc_print(netdissect_options *ndo, const u_char *dat, u_int length)
{
- u_int16_t *ptr = (u_int16_t *)dat;
+ uint16_t *ptr = (uint16_t *)dat;
- printf("%04x, ", EXTRACT_16BITS(ptr)); ptr++; /* Disconnect Code */
- printf("%04x ", EXTRACT_16BITS(ptr)); ptr++; /* Control Protocol Number */
- printf("%s", tok2str(l2tp_cc_direction2str,
- "Direction-#%u", *((u_char *)ptr++)));
+ ND_PRINT((ndo, "%04x, ", EXTRACT_16BITS(ptr))); ptr++; /* Disconnect Code */
+ ND_PRINT((ndo, "%04x ", EXTRACT_16BITS(ptr))); ptr++; /* Control Protocol Number */
+ ND_PRINT((ndo, "%s", tok2str(l2tp_cc_direction2str,
+ "Direction-#%u", *((u_char *)ptr++))));
if (length > 5) {
- printf(" ");
- print_string((const u_char *)ptr, length-5);
+ ND_PRINT((ndo, " "));
+ print_string(ndo, (const u_char *)ptr, length-5);
}
}
static void
-l2tp_avp_print(const u_char *dat, int length)
+l2tp_avp_print(netdissect_options *ndo, const u_char *dat, int length)
{
u_int len;
- const u_int16_t *ptr = (u_int16_t *)dat;
- u_int16_t attr_type;
+ const uint16_t *ptr = (uint16_t *)dat;
+ uint16_t attr_type;
int hidden = FALSE;
if (length <= 0) {
return;
}
- printf(" ");
+ ND_PRINT((ndo, " "));
- TCHECK(*ptr); /* Flags & Length */
+ ND_TCHECK(*ptr); /* Flags & Length */
len = EXTRACT_16BITS(ptr) & L2TP_AVP_HDR_LEN_MASK;
/* If it is not long enough to contain the header, we'll give up. */
@@ -477,58 +506,58 @@ l2tp_avp_print(const u_char *dat, int length)
/* If it goes past the end of the remaining length of the captured
data, we'll give up. */
- TCHECK2(*ptr, len);
+ ND_TCHECK2(*ptr, len);
/* After this point, no need to worry about truncation */
if (EXTRACT_16BITS(ptr) & L2TP_AVP_HDR_FLAG_MANDATORY) {
- printf("*");
+ ND_PRINT((ndo, "*"));
}
if (EXTRACT_16BITS(ptr) & L2TP_AVP_HDR_FLAG_HIDDEN) {
hidden = TRUE;
- printf("?");
+ ND_PRINT((ndo, "?"));
}
ptr++;
if (EXTRACT_16BITS(ptr)) {
/* Vendor Specific Attribute */
- printf("VENDOR%04x:", EXTRACT_16BITS(ptr)); ptr++;
- printf("ATTR%04x", EXTRACT_16BITS(ptr)); ptr++;
- printf("(");
- print_octets((u_char *)ptr, len-6);
- printf(")");
+ ND_PRINT((ndo, "VENDOR%04x:", EXTRACT_16BITS(ptr))); ptr++;
+ ND_PRINT((ndo, "ATTR%04x", EXTRACT_16BITS(ptr))); ptr++;
+ ND_PRINT((ndo, "("));
+ print_octets(ndo, (u_char *)ptr, len-6);
+ ND_PRINT((ndo, ")"));
} else {
/* IETF-defined Attributes */
ptr++;
attr_type = EXTRACT_16BITS(ptr); ptr++;
- printf("%s", tok2str(l2tp_avp2str, "AVP-#%u", attr_type));
- printf("(");
+ ND_PRINT((ndo, "%s", tok2str(l2tp_avp2str, "AVP-#%u", attr_type)));
+ ND_PRINT((ndo, "("));
if (hidden) {
- printf("???");
+ ND_PRINT((ndo, "???"));
} else {
switch (attr_type) {
case L2TP_AVP_MSGTYPE:
- l2tp_msgtype_print((u_char *)ptr);
+ l2tp_msgtype_print(ndo, (u_char *)ptr);
break;
case L2TP_AVP_RESULT_CODE:
- l2tp_result_code_print((u_char *)ptr, len-6);
+ l2tp_result_code_print(ndo, (u_char *)ptr, len-6);
break;
case L2TP_AVP_PROTO_VER:
- l2tp_proto_ver_print(ptr);
+ l2tp_proto_ver_print(ndo, ptr);
break;
case L2TP_AVP_FRAMING_CAP:
- l2tp_framing_cap_print((u_char *)ptr);
+ l2tp_framing_cap_print(ndo, (u_char *)ptr);
break;
case L2TP_AVP_BEARER_CAP:
- l2tp_bearer_cap_print((u_char *)ptr);
+ l2tp_bearer_cap_print(ndo, (u_char *)ptr);
break;
case L2TP_AVP_TIE_BREAKER:
- print_octets((u_char *)ptr, 8);
+ print_octets(ndo, (u_char *)ptr, 8);
break;
case L2TP_AVP_FIRM_VER:
case L2TP_AVP_ASSND_TUN_ID:
case L2TP_AVP_RECV_WIN_SIZE:
case L2TP_AVP_ASSND_SESS_ID:
- print_16bits_val(ptr);
+ print_16bits_val(ndo, ptr);
break;
case L2TP_AVP_HOST_NAME:
case L2TP_AVP_VENDOR_NAME:
@@ -537,7 +566,7 @@ l2tp_avp_print(const u_char *dat, int length)
case L2TP_AVP_SUB_ADDRESS:
case L2TP_AVP_PROXY_AUTH_NAME:
case L2TP_AVP_PRIVATE_GRP_ID:
- print_string((u_char *)ptr, len-6);
+ print_string(ndo, (u_char *)ptr, len-6);
break;
case L2TP_AVP_CHALLENGE:
case L2TP_AVP_INI_RECV_LCP:
@@ -546,13 +575,13 @@ l2tp_avp_print(const u_char *dat, int length)
case L2TP_AVP_PROXY_AUTH_CHAL:
case L2TP_AVP_PROXY_AUTH_RESP:
case L2TP_AVP_RANDOM_VECTOR:
- print_octets((u_char *)ptr, len-6);
+ print_octets(ndo, (u_char *)ptr, len-6);
break;
case L2TP_AVP_Q931_CC:
- l2tp_q931_cc_print((u_char *)ptr, len-6);
+ l2tp_q931_cc_print(ndo, (u_char *)ptr, len-6);
break;
case L2TP_AVP_CHALLENGE_RESP:
- print_octets((u_char *)ptr, 16);
+ print_octets(ndo, (u_char *)ptr, 16);
break;
case L2TP_AVP_CALL_SER_NUM:
case L2TP_AVP_MINIMUM_BPS:
@@ -560,97 +589,97 @@ l2tp_avp_print(const u_char *dat, int length)
case L2TP_AVP_TX_CONN_SPEED:
case L2TP_AVP_PHY_CHANNEL_ID:
case L2TP_AVP_RX_CONN_SPEED:
- print_32bits_val((u_int32_t *)ptr);
+ print_32bits_val(ndo, (uint32_t *)ptr);
break;
case L2TP_AVP_BEARER_TYPE:
- l2tp_bearer_type_print((u_char *)ptr);
+ l2tp_bearer_type_print(ndo, (u_char *)ptr);
break;
case L2TP_AVP_FRAMING_TYPE:
- l2tp_framing_type_print((u_char *)ptr);
+ l2tp_framing_type_print(ndo, (u_char *)ptr);
break;
case L2TP_AVP_PACKET_PROC_DELAY:
- l2tp_packet_proc_delay_print();
+ l2tp_packet_proc_delay_print(ndo);
break;
case L2TP_AVP_PROXY_AUTH_TYPE:
- l2tp_proxy_auth_type_print((u_char *)ptr);
+ l2tp_proxy_auth_type_print(ndo, (u_char *)ptr);
break;
case L2TP_AVP_PROXY_AUTH_ID:
- l2tp_proxy_auth_id_print((u_char *)ptr);
+ l2tp_proxy_auth_id_print(ndo, (u_char *)ptr);
break;
case L2TP_AVP_CALL_ERRORS:
- l2tp_call_errors_print((u_char *)ptr);
+ l2tp_call_errors_print(ndo, (u_char *)ptr);
break;
case L2TP_AVP_ACCM:
- l2tp_accm_print((u_char *)ptr);
+ l2tp_accm_print(ndo, (u_char *)ptr);
break;
case L2TP_AVP_SEQ_REQUIRED:
break; /* No Attribute Value */
case L2TP_AVP_PPP_DISCON_CC:
- l2tp_ppp_discon_cc_print((u_char *)ptr, len-6);
+ l2tp_ppp_discon_cc_print(ndo, (u_char *)ptr, len-6);
break;
default:
break;
}
}
- printf(")");
+ ND_PRINT((ndo, ")"));
}
- l2tp_avp_print(dat+len, length-len);
+ l2tp_avp_print(ndo, dat+len, length-len);
return;
trunc:
- printf("|...");
+ ND_PRINT((ndo, "|..."));
}
void
-l2tp_print(const u_char *dat, u_int length)
+l2tp_print(netdissect_options *ndo, const u_char *dat, u_int length)
{
const u_char *ptr = dat;
u_int cnt = 0; /* total octets consumed */
- u_int16_t pad;
+ uint16_t pad;
int flag_t, flag_l, flag_s, flag_o;
- u_int16_t l2tp_len;
+ uint16_t l2tp_len;
flag_t = flag_l = flag_s = flag_o = FALSE;
- TCHECK2(*ptr, 2); /* Flags & Version */
+ ND_TCHECK2(*ptr, 2); /* Flags & Version */
if ((EXTRACT_16BITS(ptr) & L2TP_VERSION_MASK) == L2TP_VERSION_L2TP) {
- printf(" l2tp:");
+ ND_PRINT((ndo, " l2tp:"));
} else if ((EXTRACT_16BITS(ptr) & L2TP_VERSION_MASK) == L2TP_VERSION_L2F) {
- printf(" l2f:");
+ ND_PRINT((ndo, " l2f:"));
return; /* nothing to do */
} else {
- printf(" Unknown Version, neither L2F(1) nor L2TP(2)");
+ ND_PRINT((ndo, " Unknown Version, neither L2F(1) nor L2TP(2)"));
return; /* nothing we can do */
}
- printf("[");
+ ND_PRINT((ndo, "["));
if (EXTRACT_16BITS(ptr) & L2TP_FLAG_TYPE) {
flag_t = TRUE;
- printf("T");
+ ND_PRINT((ndo, "T"));
}
if (EXTRACT_16BITS(ptr) & L2TP_FLAG_LENGTH) {
flag_l = TRUE;
- printf("L");
+ ND_PRINT((ndo, "L"));
}
if (EXTRACT_16BITS(ptr) & L2TP_FLAG_SEQUENCE) {
flag_s = TRUE;
- printf("S");
+ ND_PRINT((ndo, "S"));
}
if (EXTRACT_16BITS(ptr) & L2TP_FLAG_OFFSET) {
flag_o = TRUE;
- printf("O");
+ ND_PRINT((ndo, "O"));
}
if (EXTRACT_16BITS(ptr) & L2TP_FLAG_PRIORITY)
- printf("P");
- printf("]");
+ ND_PRINT((ndo, "P"));
+ ND_PRINT((ndo, "]"));
ptr += 2;
cnt += 2;
if (flag_l) {
- TCHECK2(*ptr, 2); /* Length */
+ ND_TCHECK2(*ptr, 2); /* Length */
l2tp_len = EXTRACT_16BITS(ptr);
ptr += 2;
cnt += 2;
@@ -658,28 +687,28 @@ l2tp_print(const u_char *dat, u_int length)
l2tp_len = 0;
}
- TCHECK2(*ptr, 2); /* Tunnel ID */
- printf("(%u/", EXTRACT_16BITS(ptr));
+ ND_TCHECK2(*ptr, 2); /* Tunnel ID */
+ ND_PRINT((ndo, "(%u/", EXTRACT_16BITS(ptr)));
ptr += 2;
cnt += 2;
- TCHECK2(*ptr, 2); /* Session ID */
- printf("%u)", EXTRACT_16BITS(ptr));
+ ND_TCHECK2(*ptr, 2); /* Session ID */
+ ND_PRINT((ndo, "%u)", EXTRACT_16BITS(ptr)));
ptr += 2;
cnt += 2;
if (flag_s) {
- TCHECK2(*ptr, 2); /* Ns */
- printf("Ns=%u,", EXTRACT_16BITS(ptr));
+ ND_TCHECK2(*ptr, 2); /* Ns */
+ ND_PRINT((ndo, "Ns=%u,", EXTRACT_16BITS(ptr)));
ptr += 2;
cnt += 2;
- TCHECK2(*ptr, 2); /* Nr */
- printf("Nr=%u", EXTRACT_16BITS(ptr));
+ ND_TCHECK2(*ptr, 2); /* Nr */
+ ND_PRINT((ndo, "Nr=%u", EXTRACT_16BITS(ptr)));
ptr += 2;
cnt += 2;
}
if (flag_o) {
- TCHECK2(*ptr, 2); /* Offset Size */
+ ND_TCHECK2(*ptr, 2); /* Offset Size */
pad = EXTRACT_16BITS(ptr);
ptr += (2 + pad);
cnt += (2 + pad);
@@ -687,33 +716,33 @@ l2tp_print(const u_char *dat, u_int length)
if (flag_l) {
if (length < l2tp_len) {
- printf(" Length %u larger than packet", l2tp_len);
+ ND_PRINT((ndo, " Length %u larger than packet", l2tp_len));
return;
}
length = l2tp_len;
}
if (length < cnt) {
- printf(" Length %u smaller than header length", length);
+ ND_PRINT((ndo, " Length %u smaller than header length", length));
return;
}
if (flag_t) {
if (!flag_l) {
- printf(" No length");
+ ND_PRINT((ndo, " No length"));
return;
}
if (length - cnt == 0) {
- printf(" ZLB");
+ ND_PRINT((ndo, " ZLB"));
} else {
- l2tp_avp_print(ptr, length - cnt);
+ l2tp_avp_print(ndo, ptr, length - cnt);
}
} else {
- printf(" {");
- ppp_print(ptr, length - cnt);
- printf("}");
+ ND_PRINT((ndo, " {"));
+ ppp_print(ndo, ptr, length - cnt);
+ ND_PRINT((ndo, "}"));
}
return;
trunc:
- printf("%s", tstr);
+ ND_PRINT((ndo, "%s", tstr));
}
diff --git a/contrib/tcpdump/print-lane.c b/contrib/tcpdump/print-lane.c
index aa7931154911..c1e0b2e8e11f 100644
--- a/contrib/tcpdump/print-lane.c
+++ b/contrib/tcpdump/print-lane.c
@@ -20,25 +20,30 @@
*
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.25 2005-11-13 12:12:42 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <pcap.h>
-
#include "interface.h"
-#include "addrtoname.h"
#include "extract.h"
#include "ether.h"
-#include "lane.h"
+
+struct lecdatahdr_8023 {
+ uint16_t le_header;
+ uint8_t h_dest[ETHER_ADDR_LEN];
+ uint8_t h_source[ETHER_ADDR_LEN];
+ uint16_t h_type;
+};
+
+struct lane_controlhdr {
+ uint16_t lec_header;
+ uint8_t lec_proto;
+ uint8_t lec_vers;
+ uint16_t lec_opcode;
+};
static const struct tok lecop2str[] = {
{ 0x0001, "configure request" },
@@ -63,7 +68,7 @@ static const struct tok lecop2str[] = {
static void
lane_hdr_print(netdissect_options *ndo, const u_char *bp)
{
- (void)ND_PRINT((ndo, "lecid:%x ", EXTRACT_16BITS(bp)));
+ ND_PRINT((ndo, "lecid:%x ", EXTRACT_16BITS(bp)));
}
/*
@@ -75,12 +80,12 @@ lane_hdr_print(netdissect_options *ndo, const u_char *bp)
* This assumes 802.3, not 802.5, LAN emulation.
*/
void
-lane_print(const u_char *p, u_int length, u_int caplen)
+lane_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
{
struct lane_controlhdr *lec;
if (caplen < sizeof(struct lane_controlhdr)) {
- printf("[|lane]");
+ ND_PRINT((ndo, "[|lane]"));
return;
}
@@ -89,9 +94,9 @@ lane_print(const u_char *p, u_int length, u_int caplen)
/*
* LE Control.
*/
- printf("lec: proto %x vers %x %s",
+ ND_PRINT((ndo, "lec: proto %x vers %x %s",
lec->lec_proto, lec->lec_vers,
- tok2str(lecop2str, "opcode-#%u", EXTRACT_16BITS(&lec->lec_opcode)));
+ tok2str(lecop2str, "opcode-#%u", EXTRACT_16BITS(&lec->lec_opcode))));
return;
}
@@ -106,13 +111,13 @@ lane_print(const u_char *p, u_int length, u_int caplen)
* Now print the encapsulated frame, under the assumption
* that it's an Ethernet frame.
*/
- ether_print(gndo, p, length, caplen, lane_hdr_print, p - 2);
+ ether_print(ndo, p, length, caplen, lane_hdr_print, p - 2);
}
u_int
-lane_if_print(const struct pcap_pkthdr *h, const u_char *p)
+lane_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
{
- lane_print(p, h->len, h->caplen);
+ lane_print(ndo, p, h->len, h->caplen);
return (sizeof(struct lecdatahdr_8023));
}
diff --git a/contrib/tcpdump/print-ldp.c b/contrib/tcpdump/print-ldp.c
index 262c9bda71b6..fc5ff42e67fb 100644
--- a/contrib/tcpdump/print-ldp.c
+++ b/contrib/tcpdump/print-ldp.c
@@ -14,23 +14,14 @@
* and Steinar Haug (sthaug@nethelp.no)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ldp.c,v 1.20 2006-06-23 02:03:09 hannes Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
#include "interface.h"
-#include "decode_prefix.h"
#include "extract.h"
#include "addrtoname.h"
@@ -53,10 +44,10 @@ static const char rcsid[] _U_ =
*/
struct ldp_common_header {
- u_int8_t version[2];
- u_int8_t pdu_length[2];
- u_int8_t lsr_id[4];
- u_int8_t label_space[2];
+ uint8_t version[2];
+ uint8_t pdu_length[2];
+ uint8_t lsr_id[4];
+ uint8_t label_space[2];
};
#define LDP_VERSION 1
@@ -86,13 +77,13 @@ struct ldp_common_header {
*/
struct ldp_msg_header {
- u_int8_t type[2];
- u_int8_t length[2];
- u_int8_t id[4];
+ uint8_t type[2];
+ uint8_t length[2];
+ uint8_t id[4];
};
-#define LDP_MASK_MSG_TYPE(x) ((x)&0x7fff)
-#define LDP_MASK_U_BIT(x) ((x)&0x8000)
+#define LDP_MASK_MSG_TYPE(x) ((x)&0x7fff)
+#define LDP_MASK_U_BIT(x) ((x)&0x8000)
#define LDP_MSG_NOTIF 0x0001
#define LDP_MSG_HELLO 0x0100
@@ -126,8 +117,8 @@ static const struct tok ldp_msg_values[] = {
{ 0, NULL}
};
-#define LDP_MASK_TLV_TYPE(x) ((x)&0x3fff)
-#define LDP_MASK_F_BIT(x) ((x)&0x4000)
+#define LDP_MASK_TLV_TYPE(x) ((x)&0x3fff)
+#define LDP_MASK_F_BIT(x) ((x)&0x4000)
#define LDP_TLV_FEC 0x0100
#define LDP_TLV_ADDRESS_LIST 0x0101
@@ -218,10 +209,9 @@ static const struct tok ldp_fec_martini_ifparm_vccv_cv_values[] = {
{ 0, NULL}
};
-int ldp_msg_print(register const u_char *);
-int ldp_tlv_print(register const u_char *);
-
-/*
+static int ldp_msg_print(netdissect_options *, register const u_char *);
+
+/*
* ldp tlv header
*
* 0 1 2 3
@@ -239,14 +229,15 @@ int ldp_tlv_print(register const u_char *);
*/
#define TLV_TCHECK(minlen) \
- TCHECK2(*tptr, minlen); if (tlv_tlen < minlen) goto badtlv;
+ ND_TCHECK2(*tptr, minlen); if (tlv_tlen < minlen) goto badtlv;
-int
-ldp_tlv_print(register const u_char *tptr) {
+static int
+ldp_tlv_print(netdissect_options *ndo,
+ register const u_char *tptr) {
struct ldp_tlv_header {
- u_int8_t type[2];
- u_int8_t length[2];
+ uint8_t type[2];
+ uint8_t length[2];
};
const struct ldp_tlv_header *ldp_tlv_header;
@@ -256,20 +247,20 @@ ldp_tlv_print(register const u_char *tptr) {
char buf[100];
int i;
- ldp_tlv_header = (const struct ldp_tlv_header *)tptr;
+ ldp_tlv_header = (const struct ldp_tlv_header *)tptr;
tlv_len=EXTRACT_16BITS(ldp_tlv_header->length);
tlv_tlen=tlv_len;
tlv_type=LDP_MASK_TLV_TYPE(EXTRACT_16BITS(ldp_tlv_header->type));
/* FIXME vendor private / experimental check */
- printf("\n\t %s TLV (0x%04x), length: %u, Flags: [%s and %s forward if unknown]",
+ ND_PRINT((ndo, "\n\t %s TLV (0x%04x), length: %u, Flags: [%s and %s forward if unknown]",
tok2str(ldp_tlv_values,
"Unknown",
tlv_type),
tlv_type,
tlv_len,
LDP_MASK_U_BIT(EXTRACT_16BITS(&ldp_tlv_header->type)) ? "continue processing" : "ignore",
- LDP_MASK_F_BIT(EXTRACT_16BITS(&ldp_tlv_header->type)) ? "do" : "don't");
+ LDP_MASK_F_BIT(EXTRACT_16BITS(&ldp_tlv_header->type)) ? "do" : "don't"));
tptr+=sizeof(struct ldp_tlv_header);
@@ -277,25 +268,25 @@ ldp_tlv_print(register const u_char *tptr) {
case LDP_TLV_COMMON_HELLO:
TLV_TCHECK(4);
- printf("\n\t Hold Time: %us, Flags: [%s Hello%s]",
+ ND_PRINT((ndo, "\n\t Hold Time: %us, Flags: [%s Hello%s]",
EXTRACT_16BITS(tptr),
(EXTRACT_16BITS(tptr+2)&0x8000) ? "Targeted" : "Link",
- (EXTRACT_16BITS(tptr+2)&0x4000) ? ", Request for targeted Hellos" : "");
+ (EXTRACT_16BITS(tptr+2)&0x4000) ? ", Request for targeted Hellos" : ""));
break;
case LDP_TLV_IPV4_TRANSPORT_ADDR:
TLV_TCHECK(4);
- printf("\n\t IPv4 Transport Address: %s", ipaddr_string(tptr));
+ ND_PRINT((ndo, "\n\t IPv4 Transport Address: %s", ipaddr_string(ndo, tptr)));
break;
#ifdef INET6
case LDP_TLV_IPV6_TRANSPORT_ADDR:
TLV_TCHECK(16);
- printf("\n\t IPv6 Transport Address: %s", ip6addr_string(tptr));
+ ND_PRINT((ndo, "\n\t IPv6 Transport Address: %s", ip6addr_string(ndo, tptr)));
break;
#endif
case LDP_TLV_CONFIG_SEQ_NUMBER:
TLV_TCHECK(4);
- printf("\n\t Sequence Number: %u", EXTRACT_32BITS(tptr));
+ ND_PRINT((ndo, "\n\t Sequence Number: %u", EXTRACT_32BITS(tptr)));
break;
case LDP_TLV_ADDRESS_LIST:
@@ -303,24 +294,24 @@ ldp_tlv_print(register const u_char *tptr) {
af = EXTRACT_16BITS(tptr);
tptr+=LDP_TLV_ADDRESS_LIST_AFNUM_LEN;
tlv_tlen -= LDP_TLV_ADDRESS_LIST_AFNUM_LEN;
- printf("\n\t Address Family: %s, addresses",
- tok2str(af_values, "Unknown (%u)", af));
+ ND_PRINT((ndo, "\n\t Address Family: %s, addresses",
+ tok2str(af_values, "Unknown (%u)", af)));
switch (af) {
case AFNUM_INET:
while(tlv_tlen >= sizeof(struct in_addr)) {
- TCHECK2(*tptr, sizeof(struct in_addr));
- printf(" %s",ipaddr_string(tptr));
+ ND_TCHECK2(*tptr, sizeof(struct in_addr));
+ ND_PRINT((ndo, " %s", ipaddr_string(ndo, tptr)));
tlv_tlen-=sizeof(struct in_addr);
- tptr+=sizeof(struct in_addr);
+ tptr+=sizeof(struct in_addr);
}
break;
#ifdef INET6
case AFNUM_INET6:
while(tlv_tlen >= sizeof(struct in6_addr)) {
- TCHECK2(*tptr, sizeof(struct in6_addr));
- printf(" %s",ip6addr_string(tptr));
+ ND_TCHECK2(*tptr, sizeof(struct in6_addr));
+ ND_PRINT((ndo, " %s", ip6addr_string(ndo, tptr)));
tlv_tlen-=sizeof(struct in6_addr);
- tptr+=sizeof(struct in6_addr);
+ tptr+=sizeof(struct in6_addr);
}
break;
#endif
@@ -332,19 +323,19 @@ ldp_tlv_print(register const u_char *tptr) {
case LDP_TLV_COMMON_SESSION:
TLV_TCHECK(8);
- printf("\n\t Version: %u, Keepalive: %us, Flags: [Downstream %s, Loop Detection %s]",
+ ND_PRINT((ndo, "\n\t Version: %u, Keepalive: %us, Flags: [Downstream %s, Loop Detection %s]",
EXTRACT_16BITS(tptr), EXTRACT_16BITS(tptr+2),
(EXTRACT_16BITS(tptr+6)&0x8000) ? "On Demand" : "Unsolicited",
(EXTRACT_16BITS(tptr+6)&0x4000) ? "Enabled" : "Disabled"
- );
+ ));
break;
case LDP_TLV_FEC:
TLV_TCHECK(1);
fec_type = *tptr;
- printf("\n\t %s FEC (0x%02x)",
+ ND_PRINT((ndo, "\n\t %s FEC (0x%02x)",
tok2str(ldp_fec_values, "Unknown", fec_type),
- fec_type);
+ fec_type));
tptr+=1;
tlv_tlen-=1;
@@ -358,31 +349,31 @@ ldp_tlv_print(register const u_char *tptr) {
tptr+=LDP_TLV_ADDRESS_LIST_AFNUM_LEN;
tlv_tlen-=LDP_TLV_ADDRESS_LIST_AFNUM_LEN;
if (af == AFNUM_INET) {
- i=decode_prefix4(tptr,tlv_tlen,buf,sizeof(buf));
+ i=decode_prefix4(ndo, tptr, tlv_tlen, buf, sizeof(buf));
if (i == -2)
goto trunc;
if (i == -3)
- printf(": IPv4 prefix (goes past end of TLV)");
+ ND_PRINT((ndo, ": IPv4 prefix (goes past end of TLV)"));
else if (i == -1)
- printf(": IPv4 prefix (invalid length)");
+ ND_PRINT((ndo, ": IPv4 prefix (invalid length)"));
else
- printf(": IPv4 prefix %s",buf);
+ ND_PRINT((ndo, ": IPv4 prefix %s", buf));
}
#ifdef INET6
else if (af == AFNUM_INET6) {
- i=decode_prefix6(tptr,tlv_tlen,buf,sizeof(buf));
+ i=decode_prefix6(ndo, tptr, tlv_tlen, buf, sizeof(buf));
if (i == -2)
goto trunc;
if (i == -3)
- printf(": IPv4 prefix (goes past end of TLV)");
+ ND_PRINT((ndo, ": IPv4 prefix (goes past end of TLV)"));
else if (i == -1)
- printf(": IPv6 prefix (invalid length)");
+ ND_PRINT((ndo, ": IPv6 prefix (invalid length)"));
else
- printf(": IPv6 prefix %s",buf);
+ ND_PRINT((ndo, ": IPv6 prefix %s", buf));
}
#endif
else
- printf(": Address family %u prefix", af);
+ ND_PRINT((ndo, ": Address family %u prefix", af));
break;
case LDP_FEC_HOSTADDRESS:
break;
@@ -396,22 +387,22 @@ ldp_tlv_print(register const u_char *tptr) {
vc_info_len = *(tptr+2);
if (vc_info_len == 0) {
- printf(": %s, %scontrol word, group-ID %u, VC-info-length: %u",
+ ND_PRINT((ndo, ": %s, %scontrol word, group-ID %u, VC-info-length: %u",
tok2str(l2vpn_encaps_values, "Unknown", EXTRACT_16BITS(tptr)&0x7fff),
EXTRACT_16BITS(tptr)&0x8000 ? "" : "no ",
EXTRACT_32BITS(tptr+3),
- vc_info_len);
+ vc_info_len));
break;
}
/* Make sure we have the VC ID as well */
TLV_TCHECK(11);
- printf(": %s, %scontrol word, group-ID %u, VC-ID %u, VC-info-length: %u",
+ ND_PRINT((ndo, ": %s, %scontrol word, group-ID %u, VC-ID %u, VC-info-length: %u",
tok2str(l2vpn_encaps_values, "Unknown", EXTRACT_16BITS(tptr)&0x7fff),
EXTRACT_16BITS(tptr)&0x8000 ? "" : "no ",
EXTRACT_32BITS(tptr+3),
EXTRACT_32BITS(tptr+7),
- vc_info_len);
+ vc_info_len));
if (vc_info_len < 4)
goto trunc; /* minimum 4, for the VC ID */
vc_info_len -= 4; /* subtract out the VC ID, giving the length of the interface parameters */
@@ -429,33 +420,33 @@ ldp_tlv_print(register const u_char *tptr) {
if (vc_info_len < vc_info_tlv_len)
break;
- printf("\n\t\tInterface Parameter: %s (0x%02x), len %u",
+ ND_PRINT((ndo, "\n\t\tInterface Parameter: %s (0x%02x), len %u",
tok2str(ldp_fec_martini_ifparm_values,"Unknown",vc_info_tlv_type),
vc_info_tlv_type,
- vc_info_tlv_len);
+ vc_info_tlv_len));
switch(vc_info_tlv_type) {
case LDP_FEC_MARTINI_IFPARM_MTU:
- printf(": %u",EXTRACT_16BITS(tptr+2));
+ ND_PRINT((ndo, ": %u", EXTRACT_16BITS(tptr+2)));
break;
case LDP_FEC_MARTINI_IFPARM_DESC:
- printf(": ");
+ ND_PRINT((ndo, ": "));
for (idx = 2; idx < vc_info_tlv_len; idx++)
- safeputchar(*(tptr+idx));
+ safeputchar(ndo, *(tptr + idx));
break;
case LDP_FEC_MARTINI_IFPARM_VCCV:
- printf("\n\t\t Control Channels (0x%02x) = [%s]",
+ ND_PRINT((ndo, "\n\t\t Control Channels (0x%02x) = [%s]",
*(tptr+2),
- bittok2str(ldp_fec_martini_ifparm_vccv_cc_values,"none",*(tptr+2)));
- printf("\n\t\t CV Types (0x%02x) = [%s]",
+ bittok2str(ldp_fec_martini_ifparm_vccv_cc_values, "none", *(tptr+2))));
+ ND_PRINT((ndo, "\n\t\t CV Types (0x%02x) = [%s]",
*(tptr+3),
- bittok2str(ldp_fec_martini_ifparm_vccv_cv_values,"none",*(tptr+3)));
+ bittok2str(ldp_fec_martini_ifparm_vccv_cv_values, "none", *(tptr+3))));
break;
default:
- print_unknown_data(tptr+2,"\n\t\t ",vc_info_tlv_len-2);
+ print_unknown_data(ndo, tptr+2, "\n\t\t ", vc_info_tlv_len-2);
break;
}
@@ -469,45 +460,45 @@ ldp_tlv_print(register const u_char *tptr) {
case LDP_TLV_GENERIC_LABEL:
TLV_TCHECK(4);
- printf("\n\t Label: %u", EXTRACT_32BITS(tptr) & 0xfffff);
+ ND_PRINT((ndo, "\n\t Label: %u", EXTRACT_32BITS(tptr) & 0xfffff));
break;
case LDP_TLV_STATUS:
TLV_TCHECK(8);
ui = EXTRACT_32BITS(tptr);
tptr+=4;
- printf("\n\t Status: 0x%02x, Flags: [%s and %s forward]",
+ ND_PRINT((ndo, "\n\t Status: 0x%02x, Flags: [%s and %s forward]",
ui&0x3fffffff,
ui&0x80000000 ? "Fatal error" : "Advisory Notification",
- ui&0x40000000 ? "do" : "don't");
+ ui&0x40000000 ? "do" : "don't"));
ui = EXTRACT_32BITS(tptr);
tptr+=4;
if (ui)
- printf(", causing Message ID: 0x%08x", ui);
+ ND_PRINT((ndo, ", causing Message ID: 0x%08x", ui));
break;
case LDP_TLV_FT_SESSION:
TLV_TCHECK(8);
ft_flags = EXTRACT_16BITS(tptr);
- printf("\n\t Flags: [%sReconnect, %sSave State, %sAll-Label Protection, %s Checkpoint, %sRe-Learn State]",
+ ND_PRINT((ndo, "\n\t Flags: [%sReconnect, %sSave State, %sAll-Label Protection, %s Checkpoint, %sRe-Learn State]",
ft_flags&0x8000 ? "" : "No ",
ft_flags&0x8 ? "" : "Don't ",
ft_flags&0x4 ? "" : "No ",
ft_flags&0x2 ? "Sequence Numbered Label" : "All Labels",
- ft_flags&0x1 ? "" : "Don't ");
+ ft_flags&0x1 ? "" : "Don't "));
tptr+=4;
ui = EXTRACT_32BITS(tptr);
if (ui)
- printf(", Reconnect Timeout: %ums", ui);
+ ND_PRINT((ndo, ", Reconnect Timeout: %ums", ui));
tptr+=4;
ui = EXTRACT_32BITS(tptr);
if (ui)
- printf(", Recovery Time: %ums", ui);
+ ND_PRINT((ndo, ", Recovery Time: %ums", ui));
break;
case LDP_TLV_MTU:
TLV_TCHECK(2);
- printf("\n\t MTU: %u", EXTRACT_16BITS(tptr));
+ ND_PRINT((ndo, "\n\t MTU: %u", EXTRACT_16BITS(tptr)));
break;
@@ -528,27 +519,28 @@ ldp_tlv_print(register const u_char *tptr) {
case LDP_TLV_LABEL_REQUEST_MSG_ID:
default:
- if (vflag <= 1)
- print_unknown_data(tptr,"\n\t ",tlv_tlen);
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo, tptr, "\n\t ", tlv_tlen);
break;
}
return(tlv_len+4); /* Type & Length fields not included */
-
+
trunc:
- printf("\n\t\t packet exceeded snapshot");
+ ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
return 0;
badtlv:
- printf("\n\t\t TLV contents go past end of TLV");
+ ND_PRINT((ndo, "\n\t\t TLV contents go past end of TLV"));
return(tlv_len+4); /* Type & Length fields not included */
}
void
-ldp_print(register const u_char *pptr, register u_int len) {
+ldp_print(netdissect_options *ndo,
+ register const u_char *pptr, register u_int len) {
int processed;
while (len > (sizeof(struct ldp_common_header) + sizeof(struct ldp_msg_header))) {
- processed = ldp_msg_print(pptr);
+ processed = ldp_msg_print(ndo, pptr);
if (processed == 0)
return;
len -= processed;
@@ -556,9 +548,9 @@ ldp_print(register const u_char *pptr, register u_int len) {
}
}
-
-int
-ldp_msg_print(register const u_char *pptr) {
+static int
+ldp_msg_print(netdissect_options *ndo,
+ register const u_char *pptr) {
const struct ldp_common_header *ldp_com_header;
const struct ldp_msg_header *ldp_msg_header;
@@ -569,28 +561,28 @@ ldp_msg_print(register const u_char *pptr) {
tptr=pptr;
ldp_com_header = (const struct ldp_common_header *)pptr;
- TCHECK(*ldp_com_header);
+ ND_TCHECK(*ldp_com_header);
/*
* Sanity checking of the header.
*/
if (EXTRACT_16BITS(&ldp_com_header->version) != LDP_VERSION) {
- printf("%sLDP version %u packet not supported",
- (vflag < 1) ? "" : "\n\t",
- EXTRACT_16BITS(&ldp_com_header->version));
+ ND_PRINT((ndo, "%sLDP version %u packet not supported",
+ (ndo->ndo_vflag < 1) ? "" : "\n\t",
+ EXTRACT_16BITS(&ldp_com_header->version)));
return 0;
}
/* print the LSR-ID, label-space & length */
pdu_len = EXTRACT_16BITS(&ldp_com_header->pdu_length);
- printf("%sLDP, Label-Space-ID: %s:%u, pdu-length: %u",
- (vflag < 1) ? "" : "\n\t",
- ipaddr_string(&ldp_com_header->lsr_id),
+ ND_PRINT((ndo, "%sLDP, Label-Space-ID: %s:%u, pdu-length: %u",
+ (ndo->ndo_vflag < 1) ? "" : "\n\t",
+ ipaddr_string(ndo, &ldp_com_header->lsr_id),
EXTRACT_16BITS(&ldp_com_header->label_space),
- pdu_len);
+ pdu_len));
- /* bail out if non-verbose */
- if (vflag < 1)
+ /* bail out if non-verbose */
+ if (ndo->ndo_vflag < 1)
return 0;
/* ok they seem to want to know everything - lets fully decode it */
@@ -601,21 +593,21 @@ ldp_msg_print(register const u_char *pptr) {
while(tlen>0) {
/* did we capture enough for fully decoding the msg header ? */
- TCHECK2(*tptr, sizeof(struct ldp_msg_header));
+ ND_TCHECK2(*tptr, sizeof(struct ldp_msg_header));
ldp_msg_header = (const struct ldp_msg_header *)tptr;
msg_len=EXTRACT_16BITS(ldp_msg_header->length);
msg_type=LDP_MASK_MSG_TYPE(EXTRACT_16BITS(ldp_msg_header->type));
/* FIXME vendor private / experimental check */
- printf("\n\t %s Message (0x%04x), length: %u, Message ID: 0x%08x, Flags: [%s if unknown]",
+ ND_PRINT((ndo, "\n\t %s Message (0x%04x), length: %u, Message ID: 0x%08x, Flags: [%s if unknown]",
tok2str(ldp_msg_values,
"Unknown",
msg_type),
msg_type,
msg_len,
EXTRACT_32BITS(&ldp_msg_header->id),
- LDP_MASK_U_BIT(EXTRACT_16BITS(&ldp_msg_header->type)) ? "continue processing" : "ignore");
+ LDP_MASK_U_BIT(EXTRACT_16BITS(&ldp_msg_header->type)) ? "continue processing" : "ignore"));
if (msg_len == 0) /* infinite loop protection */
return 0;
@@ -624,11 +616,11 @@ ldp_msg_print(register const u_char *pptr) {
msg_tlen=msg_len-sizeof(struct ldp_msg_header)+4; /* Type & Length fields not included */
/* did we capture enough for fully decoding the message ? */
- TCHECK2(*tptr, msg_len);
+ ND_TCHECK2(*tptr, msg_len);
hexdump=FALSE;
switch(msg_type) {
-
+
case LDP_MSG_NOTIF:
case LDP_MSG_HELLO:
case LDP_MSG_INIT:
@@ -638,7 +630,7 @@ ldp_msg_print(register const u_char *pptr) {
case LDP_MSG_ADDRESS_WITHDRAW:
case LDP_MSG_LABEL_WITHDRAW:
while(msg_tlen >= 4) {
- processed = ldp_tlv_print(msg_tptr);
+ processed = ldp_tlv_print(ndo, msg_tptr);
if (processed == 0)
break;
msg_tlen-=processed;
@@ -656,13 +648,13 @@ ldp_msg_print(register const u_char *pptr) {
case LDP_MSG_LABEL_ABORT_REQUEST:
default:
- if (vflag <= 1)
- print_unknown_data(msg_tptr,"\n\t ",msg_tlen);
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo, msg_tptr, "\n\t ", msg_tlen);
break;
}
/* do we want to see an additionally hexdump ? */
- if (vflag > 1 || hexdump==TRUE)
- print_unknown_data(tptr+sizeof(struct ldp_msg_header),"\n\t ",
+ if (ndo->ndo_vflag > 1 || hexdump==TRUE)
+ print_unknown_data(ndo, tptr+sizeof(struct ldp_msg_header), "\n\t ",
msg_len);
tptr += msg_len+4;
@@ -670,7 +662,13 @@ ldp_msg_print(register const u_char *pptr) {
}
return pdu_len+4;
trunc:
- printf("\n\t\t packet exceeded snapshot");
+ ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
return 0;
}
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
diff --git a/contrib/tcpdump/print-llc.c b/contrib/tcpdump/print-llc.c
index f304dd34d741..82da55b1d732 100644
--- a/contrib/tcpdump/print-llc.c
+++ b/contrib/tcpdump/print-llc.c
@@ -24,20 +24,13 @@
* $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.75 2007-04-13 09:43:11 hannes Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <string.h>
-
#include "interface.h"
#include "addrtoname.h"
#include "extract.h" /* must come after interface.h */
@@ -46,7 +39,7 @@ static const char rcsid[] _U_ =
#include "ethertype.h"
#include "oui.h"
-static struct tok llc_values[] = {
+static const struct tok llc_values[] = {
{ LLCSAP_NULL, "Null" },
{ LLCSAP_GLOBAL, "Global" },
{ LLCSAP_8021B_I, "802.1B I" },
@@ -65,7 +58,7 @@ static struct tok llc_values[] = {
{ 0, NULL },
};
-static struct tok llc_cmd_values[] = {
+static const struct tok llc_cmd_values[] = {
{ LLC_UI, "ui" },
{ LLC_TEST, "test" },
{ LLC_XID, "xid" },
@@ -77,7 +70,7 @@ static struct tok llc_cmd_values[] = {
{ 0, NULL }
};
-static const struct tok llc_flag_values[] = {
+static const struct tok llc_flag_values[] = {
{ 0, "Command" },
{ LLC_GSAP, "Response" },
{ LLC_U_POLL, "Poll" },
@@ -88,14 +81,14 @@ static const struct tok llc_flag_values[] = {
};
-static const struct tok llc_ig_flag_values[] = {
+static const struct tok llc_ig_flag_values[] = {
{ 0, "Individual" },
{ LLC_IG, "Group" },
{ 0, NULL }
};
-static const struct tok llc_supervisory_values[] = {
+static const struct tok llc_supervisory_values[] = {
{ 0, "Receiver Ready" },
{ 1, "Receiver not Ready" },
{ 2, "Reject" },
@@ -103,16 +96,17 @@ static const struct tok llc_supervisory_values[] = {
};
-static const struct tok cisco_values[] = {
+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" },
+ { PID_CISCO_VLANBRIDGE, "VLAN Bridge" },
{ 0, NULL }
};
-static const struct tok bridged_values[] = {
+static const struct tok bridged_values[] = {
{ PID_RFC2684_ETH_FCS, "Ethernet + FCS" },
{ PID_RFC2684_ETH_NOFCS, "Ethernet w/o FCS" },
{ PID_RFC2684_802_4_FCS, "802.4 + FCS" },
@@ -127,12 +121,12 @@ static const struct tok bridged_values[] = {
{ 0, NULL },
};
-static const struct tok null_values[] = {
+static const struct tok null_values[] = {
{ 0, NULL }
};
struct oui_tok {
- u_int32_t oui;
+ uint32_t oui;
const struct tok *tok;
};
@@ -149,19 +143,19 @@ static const struct oui_tok oui_to_tok[] = {
* Returns non-zero IFF it succeeds in printing the header
*/
int
-llc_print(const u_char *p, u_int length, u_int caplen,
+llc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen,
const u_char *esrc, const u_char *edst, u_short *extracted_ethertype)
{
- u_int8_t dsap_field, dsap, ssap_field, ssap;
- u_int16_t control;
+ uint8_t dsap_field, dsap, ssap_field, ssap;
+ uint16_t control;
int is_u;
register int ret;
*extracted_ethertype = 0;
if (caplen < 3) {
- (void)printf("[|llc]");
- default_print((u_char *)p, caplen);
+ ND_PRINT((ndo, "[|llc]"));
+ ND_DEFAULTPRINT((u_char *)p, caplen);
return(0);
}
@@ -186,8 +180,8 @@ llc_print(const u_char *p, u_int length, u_int caplen,
* 2 bytes...
*/
if (caplen < 4) {
- (void)printf("[|llc]");
- default_print((u_char *)p, caplen);
+ ND_PRINT((ndo, "[|llc]"));
+ ND_DEFAULTPRINT((u_char *)p, caplen);
return(0);
}
@@ -214,41 +208,41 @@ llc_print(const u_char *p, u_int length, u_int caplen,
* least one capture file.)
*/
- if (eflag)
- printf("IPX 802.3: ");
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "IPX 802.3: "));
- ipx_print(p, length);
+ ipx_print(ndo, p, length);
return (1);
}
dsap = dsap_field & ~LLC_IG;
ssap = ssap_field & ~LLC_GSAP;
- if (eflag) {
- printf("LLC, dsap %s (0x%02x) %s, ssap %s (0x%02x) %s",
+ if (ndo->ndo_eflag) {
+ ND_PRINT((ndo, "LLC, dsap %s (0x%02x) %s, ssap %s (0x%02x) %s",
tok2str(llc_values, "Unknown", dsap),
dsap,
tok2str(llc_ig_flag_values, "Unknown", dsap_field & LLC_IG),
tok2str(llc_values, "Unknown", ssap),
ssap,
- tok2str(llc_flag_values, "Unknown", ssap_field & LLC_GSAP));
+ tok2str(llc_flag_values, "Unknown", ssap_field & LLC_GSAP)));
if (is_u) {
- printf(", ctrl 0x%02x: ", control);
+ ND_PRINT((ndo, ", ctrl 0x%02x: ", control));
} else {
- printf(", ctrl 0x%04x: ", control);
+ ND_PRINT((ndo, ", ctrl 0x%04x: ", control));
}
}
if (ssap == LLCSAP_8021D && dsap == LLCSAP_8021D &&
control == LLC_UI) {
- stp_print(p+3, length-3);
+ stp_print(ndo, p+3, length-3);
return (1);
}
if (ssap == LLCSAP_IP && dsap == LLCSAP_IP &&
control == LLC_UI) {
- ip_print(gndo, p+4, length-4);
+ ip_print(ndo, p+4, length-4);
return (1);
}
@@ -261,10 +255,10 @@ llc_print(const u_char *p, u_int length, u_int caplen,
*
* Skip DSAP, LSAP, and control field.
*/
- if (eflag)
- printf("IPX 802.2: ");
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "IPX 802.2: "));
- ipx_print(p+3, length-3);
+ ipx_print(ndo, p+3, length-3);
return (1);
}
@@ -288,19 +282,17 @@ llc_print(const u_char *p, u_int length, u_int caplen,
if (is_u) {
p += 3;
length -= 3;
- caplen -= 3;
} else {
p += 4;
length -= 4;
- caplen -= 4;
}
- netbeui_print(control, p, length);
+ netbeui_print(ndo, control, p, length);
return (1);
}
#endif
if (ssap == LLCSAP_ISONS && dsap == LLCSAP_ISONS
&& control == LLC_UI) {
- isoclns_print(p + 3, length - 3, caplen - 3);
+ isoclns_print(ndo, p + 3, length - 3, caplen - 3);
return (1);
}
@@ -311,85 +303,77 @@ llc_print(const u_char *p, u_int length, u_int caplen,
* Does anybody ever bridge one form of LAN traffic
* over a networking type that uses 802.2 LLC?
*/
- ret = snap_print(p+3, length-3, caplen-3, 2);
+ ret = snap_print(ndo, p+3, length-3, caplen-3, 2);
if (ret)
return (ret);
}
- if (!eflag) {
+ if (!ndo->ndo_eflag) {
if (ssap == dsap) {
if (esrc == NULL || edst == NULL)
- (void)printf("%s ", tok2str(llc_values, "Unknown DSAP 0x%02x", dsap));
+ ND_PRINT((ndo, "%s ", tok2str(llc_values, "Unknown DSAP 0x%02x", dsap)));
else
- (void)printf("%s > %s %s ",
- etheraddr_string(esrc),
- etheraddr_string(edst),
- tok2str(llc_values, "Unknown DSAP 0x%02x", dsap));
+ ND_PRINT((ndo, "%s > %s %s ",
+ etheraddr_string(ndo, esrc),
+ etheraddr_string(ndo, edst),
+ tok2str(llc_values, "Unknown DSAP 0x%02x", dsap)));
} else {
if (esrc == NULL || edst == NULL)
- (void)printf("%s > %s ",
+ ND_PRINT((ndo, "%s > %s ",
tok2str(llc_values, "Unknown SSAP 0x%02x", ssap),
- tok2str(llc_values, "Unknown DSAP 0x%02x", dsap));
+ tok2str(llc_values, "Unknown DSAP 0x%02x", dsap)));
else
- (void)printf("%s %s > %s %s ",
- etheraddr_string(esrc),
+ ND_PRINT((ndo, "%s %s > %s %s ",
+ etheraddr_string(ndo, esrc),
tok2str(llc_values, "Unknown SSAP 0x%02x", ssap),
- etheraddr_string(edst),
- tok2str(llc_values, "Unknown DSAP 0x%02x", dsap));
+ etheraddr_string(ndo, edst),
+ tok2str(llc_values, "Unknown DSAP 0x%02x", dsap)));
}
}
if (is_u) {
- printf("Unnumbered, %s, Flags [%s], length %u",
+ ND_PRINT((ndo, "Unnumbered, %s, Flags [%s], length %u",
tok2str(llc_cmd_values, "%02x", LLC_U_CMD(control)),
tok2str(llc_flag_values,"?",(ssap_field & LLC_GSAP) | (control & LLC_U_POLL)),
- length);
+ length));
p += 3;
- length -= 3;
- caplen -= 3;
if ((control & ~LLC_U_POLL) == LLC_XID) {
if (*p == LLC_XID_FI) {
- printf(": %02x %02x", p[1], p[2]);
- p += 3;
- length -= 3;
- caplen -= 3;
+ ND_PRINT((ndo, ": %02x %02x", p[1], p[2]));
}
}
} else {
if ((control & LLC_S_FMT) == LLC_S_FMT) {
- (void)printf("Supervisory, %s, rcv seq %u, Flags [%s], length %u",
+ ND_PRINT((ndo, "Supervisory, %s, rcv seq %u, Flags [%s], length %u",
tok2str(llc_supervisory_values,"?",LLC_S_CMD(control)),
LLC_IS_NR(control),
tok2str(llc_flag_values,"?",(ssap_field & LLC_GSAP) | (control & LLC_IS_POLL)),
- length);
+ length));
} else {
- (void)printf("Information, send seq %u, rcv seq %u, Flags [%s], length %u",
+ ND_PRINT((ndo, "Information, send seq %u, rcv seq %u, Flags [%s], length %u",
LLC_I_NS(control),
LLC_IS_NR(control),
tok2str(llc_flag_values,"?",(ssap_field & LLC_GSAP) | (control & LLC_IS_POLL)),
- length);
+ length));
}
- p += 4;
- length -= 4;
- caplen -= 4;
}
return(1);
}
int
-snap_print(const u_char *p, u_int length, u_int caplen, u_int bridge_pad)
+snap_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen, u_int bridge_pad)
{
- u_int32_t orgcode;
+ uint32_t orgcode;
register u_short et;
register int ret;
- TCHECK2(*p, 5);
+ ND_TCHECK2(*p, 5);
orgcode = EXTRACT_24BITS(p);
et = EXTRACT_16BITS(p + 3);
- if (eflag) {
+ if (ndo->ndo_eflag) {
const struct tok *tok = null_values;
const struct oui_tok *otp;
@@ -399,12 +383,12 @@ snap_print(const u_char *p, u_int length, u_int caplen, u_int bridge_pad)
break;
}
}
- (void)printf("oui %s (0x%06x), %s %s (0x%04x): ",
+ ND_PRINT((ndo, "oui %s (0x%06x), %s %s (0x%04x): ",
tok2str(oui_values, "Unknown", orgcode),
orgcode,
(orgcode == 0x000000 ? "ethertype" : "pid"),
tok2str(tok, "Unknown", et),
- et);
+ et));
}
p += 5;
length -= 5;
@@ -419,7 +403,7 @@ snap_print(const u_char *p, u_int length, u_int caplen, u_int bridge_pad)
* Cisco hardware; the protocol ID is
* an Ethernet protocol type.
*/
- ret = ethertype_print(gndo, et, p, length, caplen);
+ ret = ethertype_print(ndo, et, p, length, caplen);
if (ret)
return (ret);
break;
@@ -434,7 +418,7 @@ snap_print(const u_char *p, u_int length, u_int caplen, u_int bridge_pad)
* but used 0x000000 and an Ethernet
* packet type for AARP packets.
*/
- ret = ethertype_print(gndo, et, p, length, caplen);
+ ret = ethertype_print(ndo, et, p, length, caplen);
if (ret)
return (ret);
}
@@ -443,23 +427,25 @@ snap_print(const u_char *p, u_int length, u_int caplen, u_int bridge_pad)
case OUI_CISCO:
switch (et) {
case PID_CISCO_CDP:
- cdp_print(p, length, caplen);
+ cdp_print(ndo, p, length, caplen);
return (1);
case PID_CISCO_DTP:
- dtp_print(p, length);
+ dtp_print(ndo, p, length);
return (1);
case PID_CISCO_UDLD:
- udld_print(p, length);
+ udld_print(ndo, p, length);
return (1);
case PID_CISCO_VTP:
- vtp_print(p, length);
+ vtp_print(ndo, p, length);
return (1);
case PID_CISCO_PVST:
- stp_print(p, length);
+ case PID_CISCO_VLANBRIDGE:
+ stp_print(ndo, p, length);
return (1);
default:
break;
}
+ break;
case OUI_RFC2684:
switch (et) {
@@ -473,7 +459,7 @@ snap_print(const u_char *p, u_int length, u_int caplen, u_int bridge_pad)
/*
* Skip the padding.
*/
- TCHECK2(*p, bridge_pad);
+ ND_TCHECK2(*p, bridge_pad);
caplen -= bridge_pad;
length -= bridge_pad;
p += bridge_pad;
@@ -481,7 +467,7 @@ snap_print(const u_char *p, u_int length, u_int caplen, u_int bridge_pad)
/*
* What remains is an Ethernet packet.
*/
- ether_print(gndo, p, length, caplen, NULL, NULL);
+ ether_print(ndo, p, length, caplen, NULL, NULL);
return (1);
case PID_RFC2684_802_5_FCS:
@@ -494,7 +480,7 @@ snap_print(const u_char *p, u_int length, u_int caplen, u_int bridge_pad)
* Skip the padding, but not the Access
* Control field.
*/
- TCHECK2(*p, bridge_pad);
+ ND_TCHECK2(*p, bridge_pad);
caplen -= bridge_pad;
length -= bridge_pad;
p += bridge_pad;
@@ -503,7 +489,7 @@ snap_print(const u_char *p, u_int length, u_int caplen, u_int bridge_pad)
* What remains is an 802.5 Token Ring
* packet.
*/
- token_print(p, length, caplen);
+ token_print(ndo, p, length, caplen);
return (1);
case PID_RFC2684_FDDI_FCS:
@@ -515,7 +501,7 @@ snap_print(const u_char *p, u_int length, u_int caplen, u_int bridge_pad)
/*
* Skip the padding.
*/
- TCHECK2(*p, bridge_pad + 1);
+ ND_TCHECK2(*p, bridge_pad + 1);
caplen -= bridge_pad + 1;
length -= bridge_pad + 1;
p += bridge_pad + 1;
@@ -523,18 +509,18 @@ snap_print(const u_char *p, u_int length, u_int caplen, u_int bridge_pad)
/*
* What remains is an FDDI packet.
*/
- fddi_print(p, length, caplen);
+ fddi_print(ndo, p, length, caplen);
return (1);
case PID_RFC2684_BPDU:
- stp_print(p, length);
+ stp_print(ndo, p, length);
return (1);
}
}
return (0);
trunc:
- (void)printf("[|snap]");
+ ND_PRINT((ndo, "[|snap]"));
return (1);
}
diff --git a/contrib/tcpdump/print-lldp.c b/contrib/tcpdump/print-lldp.c
index 297f07a257f8..e499507bba7e 100644
--- a/contrib/tcpdump/print-lldp.c
+++ b/contrib/tcpdump/print-lldp.c
@@ -19,11 +19,7 @@
* DCBX extensions by Kaladhar Musunuru <kaladharm@sourceforge.net>
*/
-#ifndef lint
-static const char rcsid[] _U_ =
-"@(#) $Header: /tcpdump/master/tcpdump/print-lldp.c,v 1.10 2008-03-20 09:30:56 hannes Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -31,8 +27,6 @@ static const char rcsid[] _U_ =
#include <tcpdump-stdinc.h>
#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include "interface.h"
#include "extract.h"
@@ -40,8 +34,8 @@ static const char rcsid[] _U_ =
#include "af.h"
#include "oui.h"
-#define LLDP_EXTRACT_TYPE(x) (((x)&0xfe00)>>9)
-#define LLDP_EXTRACT_LEN(x) ((x)&0x01ff)
+#define LLDP_EXTRACT_TYPE(x) (((x)&0xfe00)>>9)
+#define LLDP_EXTRACT_LEN(x) ((x)&0x01ff)
/*
* TLV type codes
@@ -143,12 +137,26 @@ static const struct tok lldp_cap_values[] = {
#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
+#define LLDP_PRIVATE_8021_SUBTYPE_CONGESTION_NOTIFICATION 8
+#define LLDP_PRIVATE_8021_SUBTYPE_ETS_CONFIGURATION 9
+#define LLDP_PRIVATE_8021_SUBTYPE_ETS_RECOMMENDATION 10
+#define LLDP_PRIVATE_8021_SUBTYPE_PFC_CONFIGURATION 11
+#define LLDP_PRIVATE_8021_SUBTYPE_APPLICATION_PRIORITY 12
+#define LLDP_PRIVATE_8021_SUBTYPE_EVB 13
+#define LLDP_PRIVATE_8021_SUBTYPE_CDCP 14
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"},
+ { LLDP_PRIVATE_8021_SUBTYPE_CONGESTION_NOTIFICATION, "Congestion Notification"},
+ { LLDP_PRIVATE_8021_SUBTYPE_ETS_CONFIGURATION, "ETS Configuration"},
+ { LLDP_PRIVATE_8021_SUBTYPE_ETS_RECOMMENDATION, "ETS Recommendation"},
+ { LLDP_PRIVATE_8021_SUBTYPE_PFC_CONFIGURATION, "Priority Flow Control Configuration"},
+ { LLDP_PRIVATE_8021_SUBTYPE_APPLICATION_PRIORITY, "Application Priority"},
+ { LLDP_PRIVATE_8021_SUBTYPE_EVB, "EVB"},
+ { LLDP_PRIVATE_8021_SUBTYPE_CDCP,"CDCP"},
{ 0, NULL}
};
@@ -230,7 +238,7 @@ static const struct tok lldp_tia_location_lci_catype_values[] = {
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"},
+ { 1, "location of the network element believed to be closest to the client"},
{ 2, "location of the client"},
{ 0, NULL}
};
@@ -459,7 +467,7 @@ static const struct tok lldp_tia_inventory_values[] = {
/*
* 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)
@@ -573,47 +581,101 @@ static const struct tok lldp_intf_numb_subtype_values[] = {
#define LLDP_INTF_NUM_LEN 5
+#define LLDP_EVB_MODE_NOT_SUPPORTED 0
+#define LLDP_EVB_MODE_EVB_BRIDGE 1
+#define LLDP_EVB_MODE_EVB_STATION 2
+#define LLDP_EVB_MODE_RESERVED 3
+
+static const struct tok lldp_evb_mode_values[]={
+ { LLDP_EVB_MODE_NOT_SUPPORTED, "Not Supported"},
+ { LLDP_EVB_MODE_EVB_BRIDGE, "EVB Bridge"},
+ { LLDP_EVB_MODE_EVB_STATION, "EVB Staion"},
+ { LLDP_EVB_MODE_RESERVED, "Reserved for future Standardization"},
+};
+
+#define NO_OF_BITS 8
+#define LLDP_PRIVATE_8021_SUBTYPE_CONGESTION_NOTIFICATION_LENGTH 6
+#define LLDP_PRIVATE_8021_SUBTYPE_ETS_CONFIGURATION_LENGTH 25
+#define LLDP_PRIVATE_8021_SUBTYPE_ETS_RECOMMENDATION_LENGTH 25
+#define LLDP_PRIVATE_8021_SUBTYPE_PFC_CONFIGURATION_LENGTH 6
+#define LLDP_PRIVATE_8021_SUBTYPE_APPLICATION_PRIORITY_MIN_LENGTH 5
+#define LLDP_PRIVATE_8021_SUBTYPE_EVB_LENGTH 9
+#define LLDP_PRIVATE_8021_SUBTYPE_CDCP_MIN_LENGTH 8
+
+static void
+print_ets_priority_assignment_table(netdissect_options *ndo,
+ const u_char *ptr)
+{
+ ND_PRINT((ndo, "\n\t Priority Assignment Table"));
+ ND_PRINT((ndo, "\n\t Priority : 0 1 2 3 4 5 6 7"));
+ ND_PRINT((ndo, "\n\t Value : %-3d %-3d %-3d %-3d %-3d %-3d %-3d %-3d",
+ ptr[0]>>4,ptr[0]&0x0f,ptr[1]>>4,ptr[1]&0x0f,ptr[2]>>4,
+ ptr[2] & 0x0f, ptr[3] >> 4, ptr[3] & 0x0f));
+}
+
+static void
+print_tc_bandwidth_table(netdissect_options *ndo,
+ const u_char *ptr)
+{
+ ND_PRINT((ndo, "\n\t TC Bandwidth Table"));
+ ND_PRINT((ndo, "\n\t TC%% : 0 1 2 3 4 5 6 7"));
+ ND_PRINT((ndo, "\n\t Value : %-3d %-3d %-3d %-3d %-3d %-3d %-3d %-3d",
+ ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5], ptr[6], ptr[7]));
+}
+
+static void
+print_tsa_assignment_table(netdissect_options *ndo,
+ const u_char *ptr)
+{
+ ND_PRINT((ndo, "\n\t TSA Assignment Table"));
+ ND_PRINT((ndo, "\n\t Traffic Class: 0 1 2 3 4 5 6 7"));
+ ND_PRINT((ndo, "\n\t Value : %-3d %-3d %-3d %-3d %-3d %-3d %-3d %-3d",
+ ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5], ptr[6], ptr[7]));
+}
+
/*
* Print IEEE 802.1 private extensions. (802.1AB annex E)
*/
static int
-lldp_private_8021_print(const u_char *tptr, u_int tlv_len)
+lldp_private_8021_print(netdissect_options *ndo,
+ const u_char *tptr, u_int tlv_len)
{
int subtype, hexdump = FALSE;
u_int sublen;
+ u_int tval;
+ uint8_t i;
if (tlv_len < 4) {
return hexdump;
}
subtype = *(tptr+3);
- printf("\n\t %s Subtype (%u)",
+ ND_PRINT((ndo, "\n\t %s Subtype (%u)",
tok2str(lldp_8021_subtype_values, "unknown", subtype),
- subtype);
+ subtype));
switch (subtype) {
case LLDP_PRIVATE_8021_SUBTYPE_PORT_VLAN_ID:
if (tlv_len < 6) {
return hexdump;
}
- printf("\n\t port vlan id (PVID): %u",
- EXTRACT_16BITS(tptr+4));
+ ND_PRINT((ndo, "\n\t port vlan id (PVID): %u",
+ EXTRACT_16BITS(tptr + 4)));
break;
case LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_VLAN_ID:
if (tlv_len < 7) {
return hexdump;
}
- printf("\n\t port and protocol vlan id (PPVID): %u, flags [%s] (0x%02x)",
+ ND_PRINT((ndo, "\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));
+ *(tptr + 4)));
break;
case LLDP_PRIVATE_8021_SUBTYPE_VLAN_NAME:
if (tlv_len < 6) {
return hexdump;
}
- printf("\n\t vlan id (VID): %u",
- EXTRACT_16BITS(tptr+4));
+ ND_PRINT((ndo, "\n\t vlan id (VID): %u", EXTRACT_16BITS(tptr + 4)));
if (tlv_len < 7) {
return hexdump;
}
@@ -621,8 +683,8 @@ lldp_private_8021_print(const u_char *tptr, u_int tlv_len)
if (tlv_len < 7+sublen) {
return hexdump;
}
- printf("\n\t vlan name: ");
- safeputs((const char *)tptr+7, sublen);
+ ND_PRINT((ndo, "\n\t vlan name: "));
+ safeputs(ndo, tptr + 7, sublen);
break;
case LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_IDENTITY:
if (tlv_len < 5) {
@@ -632,8 +694,138 @@ lldp_private_8021_print(const u_char *tptr, u_int tlv_len)
if (tlv_len < 5+sublen) {
return hexdump;
}
- printf("\n\t protocol identity: ");
- safeputs((const char *)tptr+5, sublen);
+ ND_PRINT((ndo, "\n\t protocol identity: "));
+ safeputs(ndo, tptr + 5, sublen);
+ break;
+ case LLDP_PRIVATE_8021_SUBTYPE_CONGESTION_NOTIFICATION:
+ if(tlv_len<LLDP_PRIVATE_8021_SUBTYPE_CONGESTION_NOTIFICATION_LENGTH){
+ return hexdump;
+ }
+ tval=*(tptr+4);
+ ND_PRINT((ndo, "\n\t Pre-Priority CNPV Indicator"));
+ ND_PRINT((ndo, "\n\t Priority : 0 1 2 3 4 5 6 7"));
+ ND_PRINT((ndo, "\n\t Value : "));
+ for(i=0;i<NO_OF_BITS;i++)
+ ND_PRINT((ndo, "%-2d ", (tval >> i) & 0x01));
+ tval=*(tptr+5);
+ ND_PRINT((ndo, "\n\t Pre-Priority Ready Indicator"));
+ ND_PRINT((ndo, "\n\t Priority : 0 1 2 3 4 5 6 7"));
+ ND_PRINT((ndo, "\n\t Value : "));
+ for(i=0;i<NO_OF_BITS;i++)
+ ND_PRINT((ndo, "%-2d ", (tval >> i) & 0x01));
+ break;
+
+ case LLDP_PRIVATE_8021_SUBTYPE_ETS_CONFIGURATION:
+ if(tlv_len<LLDP_PRIVATE_8021_SUBTYPE_ETS_CONFIGURATION_LENGTH) {
+ return hexdump;
+ }
+ tval=*(tptr+4);
+ ND_PRINT((ndo, "\n\t Willing:%d, CBS:%d, RES:%d, Max TCs:%d",
+ tval >> 7, (tval >> 6) & 0x02, (tval >> 3) & 0x07, tval & 0x07));
+
+ /*Print Priority Assignment Table*/
+ print_ets_priority_assignment_table(ndo, tptr + 5);
+
+ /*Print TC Bandwidth Table*/
+ print_tc_bandwidth_table(ndo, tptr + 9);
+
+ /* Print TSA Assignment Table */
+ print_tsa_assignment_table(ndo, tptr + 17);
+
+ break;
+
+ case LLDP_PRIVATE_8021_SUBTYPE_ETS_RECOMMENDATION:
+ if(tlv_len<LLDP_PRIVATE_8021_SUBTYPE_ETS_RECOMMENDATION_LENGTH) {
+ return hexdump;
+ }
+ ND_PRINT((ndo, "\n\t RES: %d", *(tptr + 4)));
+ /*Print Priority Assignment Table */
+ print_ets_priority_assignment_table(ndo, tptr + 5);
+ /*Print TC Bandwidth Table */
+ print_tc_bandwidth_table(ndo, tptr + 9);
+ /* Print TSA Assignment Table */
+ print_tsa_assignment_table(ndo, tptr + 17);
+ break;
+
+ case LLDP_PRIVATE_8021_SUBTYPE_PFC_CONFIGURATION:
+ if(tlv_len<LLDP_PRIVATE_8021_SUBTYPE_PFC_CONFIGURATION_LENGTH) {
+ return hexdump;
+ }
+ tval=*(tptr+4);
+ ND_PRINT((ndo, "\n\t Willing: %d, MBC: %d, RES: %d, PFC cap:%d ",
+ tval >> 7, (tval >> 6) & 0x01, (tval >> 4) & 0x03, (tval & 0x0f)));
+ ND_PRINT((ndo, "\n\t PFC Enable"));
+ tval=*(tptr+5);
+ ND_PRINT((ndo, "\n\t Priority : 0 1 2 3 4 5 6 7"));
+ ND_PRINT((ndo, "\n\t Value : "));
+ for(i=0;i<NO_OF_BITS;i++)
+ ND_PRINT((ndo, "%-2d ", (tval >> i) & 0x01));
+ break;
+
+ case LLDP_PRIVATE_8021_SUBTYPE_APPLICATION_PRIORITY:
+ if(tlv_len<LLDP_PRIVATE_8021_SUBTYPE_APPLICATION_PRIORITY_MIN_LENGTH) {
+ return hexdump;
+ }
+ ND_PRINT((ndo, "\n\t RES: %d", *(tptr + 4)));
+ if(tlv_len<=LLDP_PRIVATE_8021_SUBTYPE_APPLICATION_PRIORITY_MIN_LENGTH){
+ return hexdump;
+ }
+ /* Length of Application Priority Table */
+ sublen=tlv_len-5;
+ if(sublen%3!=0){
+ return hexdump;
+ }
+ i=0;
+ ND_PRINT((ndo, "\n\t Application Priority Table"));
+ while(i<sublen) {
+ tval=*(tptr+i+5);
+ ND_PRINT((ndo, "\n\t Priority: %d, RES: %d, Sel: %d",
+ tval >> 5, (tval >> 3) & 0x03, (tval & 0x07)));
+ ND_PRINT((ndo, "Protocol ID: %d", EXTRACT_16BITS(tptr + i + 5)));
+ i=i+3;
+ }
+ break;
+ case LLDP_PRIVATE_8021_SUBTYPE_EVB:
+ if(tlv_len<LLDP_PRIVATE_8021_SUBTYPE_EVB_LENGTH){
+ return hexdump;
+ }
+ ND_PRINT((ndo, "\n\t EVB Bridge Status"));
+ tval=*(tptr+4);
+ ND_PRINT((ndo, "\n\t RES: %d, BGID: %d, RRCAP: %d, RRCTR: %d",
+ tval >> 3, (tval >> 2) & 0x01, (tval >> 1) & 0x01, tval & 0x01));
+ ND_PRINT((ndo, "\n\t EVB Station Status"));
+ tval=*(tptr+5);
+ ND_PRINT((ndo, "\n\t RES: %d, SGID: %d, RRREQ: %d,RRSTAT: %d",
+ tval >> 4, (tval >> 3) & 0x01, (tval >> 2) & 0x01, tval & 0x03));
+ tval=*(tptr+6);
+ ND_PRINT((ndo, "\n\t R: %d, RTE: %d, ",tval >> 5, tval & 0x1f));
+ tval=*(tptr+7);
+ ND_PRINT((ndo, "EVB Mode: %s [%d]",
+ tok2str(lldp_evb_mode_values, "unknown", tval >> 6), tval >> 6));
+ ND_PRINT((ndo, "\n\t ROL: %d, RWD: %d, ", (tval >> 5) & 0x01, tval & 0x1f));
+ tval=*(tptr+8);
+ ND_PRINT((ndo, "RES: %d, ROL: %d, RKA: %d", tval >> 6, (tval >> 5) & 0x01, tval & 0x1f));
+ break;
+
+ case LLDP_PRIVATE_8021_SUBTYPE_CDCP:
+ if(tlv_len<LLDP_PRIVATE_8021_SUBTYPE_CDCP_MIN_LENGTH){
+ return hexdump;
+ }
+ tval=*(tptr+4);
+ ND_PRINT((ndo, "\n\t Role: %d, RES: %d, Scomp: %d ",
+ tval >> 7, (tval >> 4) & 0x07, (tval >> 3) & 0x01));
+ ND_PRINT((ndo, "ChnCap: %d", EXTRACT_16BITS(tptr + 6) & 0x0fff));
+ sublen=tlv_len-8;
+ if(sublen%3!=0) {
+ return hexdump;
+ }
+ i=0;
+ while(i<sublen) {
+ tval=EXTRACT_24BITS(tptr+i+8);
+ ND_PRINT((ndo, "\n\t SCID: %d, SVID: %d",
+ tval >> 12, tval & 0x000fff));
+ i=i+3;
+ }
break;
default:
@@ -648,7 +840,8 @@ lldp_private_8021_print(const u_char *tptr, u_int tlv_len)
* Print IEEE 802.3 private extensions. (802.3bc)
*/
static int
-lldp_private_8023_print(const u_char *tptr, u_int tlv_len)
+lldp_private_8023_print(netdissect_options *ndo,
+ const u_char *tptr, u_int tlv_len)
{
int subtype, hexdump = FALSE;
@@ -657,47 +850,47 @@ lldp_private_8023_print(const u_char *tptr, u_int tlv_len)
}
subtype = *(tptr+3);
- printf("\n\t %s Subtype (%u)",
+ ND_PRINT((ndo, "\n\t %s Subtype (%u)",
tok2str(lldp_8023_subtype_values, "unknown", subtype),
- subtype);
+ subtype));
switch (subtype) {
case LLDP_PRIVATE_8023_SUBTYPE_MACPHY:
if (tlv_len < 9) {
return hexdump;
}
- printf("\n\t autonegotiation [%s] (0x%02x)",
+ ND_PRINT((ndo, "\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)",
+ *(tptr + 4)));
+ ND_PRINT((ndo, "\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)",
+ EXTRACT_16BITS(tptr + 5)));
+ ND_PRINT((ndo, "\n\t MAU type %s (0x%04x)",
tok2str(lldp_mau_types_values, "unknown", EXTRACT_16BITS(tptr+7)),
- EXTRACT_16BITS(tptr+7));
+ EXTRACT_16BITS(tptr + 7)));
break;
case LLDP_PRIVATE_8023_SUBTYPE_MDIPOWER:
if (tlv_len < 7) {
return hexdump;
}
- printf("\n\t MDI power support [%s], power pair %s, power class %s",
+ ND_PRINT((ndo, "\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)));
+ tok2str(lldp_mdi_power_class_values, "unknown", *(tptr + 6))));
break;
case LLDP_PRIVATE_8023_SUBTYPE_LINKAGGR:
if (tlv_len < 9) {
return hexdump;
}
- printf("\n\t aggregation status [%s], aggregation port ID %u",
+ ND_PRINT((ndo, "\n\t aggregation status [%s], aggregation port ID %u",
bittok2str(lldp_aggregation_values, "none", *(tptr+4)),
- EXTRACT_32BITS(tptr+5));
+ EXTRACT_32BITS(tptr + 5)));
break;
case LLDP_PRIVATE_8023_SUBTYPE_MTU:
- printf("\n\t MTU size %u", EXTRACT_16BITS(tptr+4));
+ ND_PRINT((ndo, "\n\t MTU size %u", EXTRACT_16BITS(tptr + 4)));
break;
default:
@@ -711,10 +904,10 @@ lldp_private_8023_print(const u_char *tptr, u_int tlv_len)
/*
* Extract 34bits of latitude/longitude coordinates.
*/
-static u_int64_t
+static uint64_t
lldp_extract_latlon(const u_char *tptr)
{
- u_int64_t latlon;
+ uint64_t latlon;
latlon = *tptr & 0x3;
latlon = (latlon << 32) | EXTRACT_32BITS(tptr+1);
@@ -726,51 +919,52 @@ lldp_extract_latlon(const u_char *tptr)
* Print private TIA extensions.
*/
static int
-lldp_private_tia_print(const u_char *tptr, u_int tlv_len)
+lldp_private_tia_print(netdissect_options *ndo,
+ const u_char *tptr, u_int tlv_len)
{
int subtype, hexdump = FALSE;
- u_int8_t location_format;
- u_int16_t power_val;
+ uint8_t location_format;
+ uint16_t power_val;
u_int lci_len;
- u_int8_t ca_type, ca_len;
+ uint8_t ca_type, ca_len;
if (tlv_len < 4) {
return hexdump;
}
subtype = *(tptr+3);
- printf("\n\t %s Subtype (%u)",
+ ND_PRINT((ndo, "\n\t %s Subtype (%u)",
tok2str(lldp_tia_subtype_values, "unknown", subtype),
- subtype);
+ subtype));
switch (subtype) {
case LLDP_PRIVATE_TIA_SUBTYPE_CAPABILITIES:
if (tlv_len < 7) {
return hexdump;
}
- printf("\n\t Media capabilities [%s] (0x%04x)",
+ ND_PRINT((ndo, "\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)",
+ EXTRACT_16BITS(tptr + 4)), EXTRACT_16BITS(tptr + 4)));
+ ND_PRINT((ndo, "\n\t Device type [%s] (0x%02x)",
tok2str(lldp_tia_device_type_values, "unknown", *(tptr+6)),
- *(tptr+6));
+ *(tptr + 6)));
break;
case LLDP_PRIVATE_TIA_SUBTYPE_NETWORK_POLICY:
if (tlv_len < 8) {
return hexdump;
}
- printf("\n\t Application type [%s] (0x%02x)",
+ ND_PRINT((ndo, "\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)));
+ *(tptr + 4)));
+ ND_PRINT((ndo, ", Flags [%s]", bittok2str(
+ lldp_tia_network_policy_bits_values, "none", *(tptr + 5))));
+ ND_PRINT((ndo, "\n\t Vlan id %u",
+ LLDP_EXTRACT_NETWORK_POLICY_VLAN(EXTRACT_16BITS(tptr + 5))));
+ ND_PRINT((ndo, ", L2 priority %u",
+ LLDP_EXTRACT_NETWORK_POLICY_L2_PRIORITY(EXTRACT_16BITS(tptr + 6))));
+ ND_PRINT((ndo, ", DSCP value %u",
+ LLDP_EXTRACT_NETWORK_POLICY_DSCP(EXTRACT_16BITS(tptr + 6))));
break;
case LLDP_PRIVATE_TIA_SUBTYPE_LOCAL_ID:
@@ -778,28 +972,28 @@ lldp_private_tia_print(const u_char *tptr, u_int tlv_len)
return hexdump;
}
location_format = *(tptr+4);
- printf("\n\t Location data format %s (0x%02x)",
+ ND_PRINT((ndo, "\n\t Location data format %s (0x%02x)",
tok2str(lldp_tia_location_data_format_values, "unknown", location_format),
- location_format);
+ location_format));
switch (location_format) {
case LLDP_TIA_LOCATION_DATA_FORMAT_COORDINATE_BASED:
if (tlv_len < 21) {
return hexdump;
}
- printf("\n\t Latitude resolution %u, latitude value %" PRIu64,
- (*(tptr+5)>>2), lldp_extract_latlon(tptr+5));
- printf("\n\t Longitude resolution %u, longitude value %" PRIu64,
- (*(tptr+10)>>2), lldp_extract_latlon(tptr+10));
- printf("\n\t Altitude type %s (%u)",
+ ND_PRINT((ndo, "\n\t Latitude resolution %u, latitude value %" PRIu64,
+ (*(tptr + 5) >> 2), lldp_extract_latlon(tptr + 5)));
+ ND_PRINT((ndo, "\n\t Longitude resolution %u, longitude value %" PRIu64,
+ (*(tptr + 10) >> 2), lldp_extract_latlon(tptr + 10)));
+ ND_PRINT((ndo, "\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",
+ (*(tptr + 15) >> 4)));
+ ND_PRINT((ndo, "\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)",
+ ((EXTRACT_32BITS(tptr + 16) & 0x3fffffff))));
+ ND_PRINT((ndo, "\n\t Datum %s (0x%02x)",
tok2str(lldp_tia_location_datum_type_values, "unknown", *(tptr+20)),
- *(tptr+20));
+ *(tptr + 20)));
break;
case LLDP_TIA_LOCATION_DATA_FORMAT_CIVIC_ADDRESS:
@@ -813,18 +1007,18 @@ lldp_private_tia_print(const u_char *tptr, u_int tlv_len)
if (tlv_len < 7+lci_len) {
return hexdump;
}
- printf("\n\t LCI length %u, LCI what %s (0x%02x), Country-code ",
+ ND_PRINT((ndo, "\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));
+ *(tptr + 6)));
/* Country code */
- safeputs((const char *)(tptr+7), 2);
+ safeputs(ndo, tptr + 7, 2);
lci_len = lci_len-3;
tptr = tptr + 9;
- /* Decode each civic address element */
+ /* Decode each civic address element */
while (lci_len > 0) {
if (lci_len < 2) {
return hexdump;
@@ -833,11 +1027,11 @@ lldp_private_tia_print(const u_char *tptr, u_int tlv_len)
ca_len = *(tptr+1);
tptr += 2;
- lci_len -= 2;
+ lci_len -= 2;
- printf("\n\t CA type \'%s\' (%u), length %u: ",
+ ND_PRINT((ndo, "\n\t CA type \'%s\' (%u), length %u: ",
tok2str(lldp_tia_location_lci_catype_values, "unknown", ca_type),
- ca_type, ca_len);
+ ca_type, ca_len));
/* basic sanity check */
if ( ca_type == 0 || ca_len == 0) {
@@ -847,20 +1041,20 @@ lldp_private_tia_print(const u_char *tptr, u_int tlv_len)
return hexdump;
}
- safeputs((const char *)tptr, ca_len);
+ safeputs(ndo, 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);
+ ND_PRINT((ndo, "\n\t ECS ELIN id "));
+ safeputs(ndo, tptr + 5, tlv_len - 5);
break;
default:
- printf("\n\t Location ID ");
- print_unknown_data(tptr+5, "\n\t ", tlv_len-5);
+ ND_PRINT((ndo, "\n\t Location ID "));
+ print_unknown_data(ndo, tptr + 5, "\n\t ", tlv_len - 5);
}
break;
@@ -868,18 +1062,18 @@ lldp_private_tia_print(const u_char *tptr, u_int tlv_len)
if (tlv_len < 7) {
return hexdump;
}
- printf("\n\t Power type [%s]",
- (*(tptr+4)&0xC0>>6) ? "PD device" : "PSE device");
- printf(", Power source [%s]",
- tok2str(lldp_tia_power_source_values, "none", (*(tptr+4)&0x30)>>4));
- printf("\n\t Power priority [%s] (0x%02x)",
+ ND_PRINT((ndo, "\n\t Power type [%s]",
+ (*(tptr + 4) & 0xC0 >> 6) ? "PD device" : "PSE device"));
+ ND_PRINT((ndo, ", Power source [%s]",
+ tok2str(lldp_tia_power_source_values, "none", (*(tptr + 4) & 0x30) >> 4)));
+ ND_PRINT((ndo, "\n\t Power priority [%s] (0x%02x)",
tok2str(lldp_tia_power_priority_values, "none", *(tptr+4)&0x0f),
- *(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);
+ ND_PRINT((ndo, ", Power %.1f Watts", ((float)power_val) / 10));
} else {
- printf(", Power %u (Reserved)", power_val);
+ ND_PRINT((ndo, ", Power %u (Reserved)", power_val));
}
break;
@@ -890,9 +1084,9 @@ lldp_private_tia_print(const u_char *tptr, u_int tlv_len)
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);
+ ND_PRINT((ndo, "\n\t %s ",
+ tok2str(lldp_tia_inventory_values, "unknown", subtype)));
+ safeputs(ndo, tptr + 4, tlv_len - 4);
break;
default:
@@ -907,12 +1101,13 @@ lldp_private_tia_print(const u_char *tptr, u_int tlv_len)
* Print DCBX Protocol fields (V 1.01).
*/
static int
-lldp_private_dcbx_print(const u_char *pptr, u_int len)
+lldp_private_dcbx_print(netdissect_options *ndo,
+ const u_char *pptr, u_int len)
{
int subtype, hexdump = FALSE;
- u_int8_t tval;
- u_int16_t tlv;
- u_int32_t i, pgval, uval;
+ uint8_t tval;
+ uint16_t tlv;
+ uint32_t i, pgval, uval;
u_int tlen, tlv_type, tlv_len;
const u_char *tptr, *mptr;
@@ -921,9 +1116,9 @@ lldp_private_dcbx_print(const u_char *pptr, u_int len)
}
subtype = *(pptr+3);
- printf("\n\t %s Subtype (%u)",
+ ND_PRINT((ndo, "\n\t %s Subtype (%u)",
tok2str(lldp_dcbx_subtype_values, "unknown", subtype),
- subtype);
+ subtype));
/* by passing old version */
if (subtype == LLDP_DCBX_SUBTYPE_1)
@@ -934,7 +1129,7 @@ lldp_private_dcbx_print(const u_char *pptr, u_int len)
while (tlen >= sizeof(tlv)) {
- TCHECK2(*tptr, sizeof(tlv));
+ ND_TCHECK2(*tptr, sizeof(tlv));
tlv = EXTRACT_16BITS(tptr);
@@ -950,7 +1145,7 @@ lldp_private_dcbx_print(const u_char *pptr, u_int len)
break;
}
- TCHECK2(*tptr, tlv_len);
+ ND_TCHECK2(*tptr, tlv_len);
if (tlen < tlv_len) {
goto trunc;
}
@@ -961,89 +1156,92 @@ lldp_private_dcbx_print(const u_char *pptr, u_int len)
if (tlv_len < 10) {
goto trunc;
}
- printf("\n\t Control - Protocol Control (type 0x%x, length %d)",
- LLDP_DCBX_CONTROL_TLV, tlv_len);
- printf("\n\t Oper_Version: %d", *tptr);
- printf("\n\t Max_Version: %d", *(tptr+1));
- printf("\n\t Sequence Number: %d", EXTRACT_32BITS(tptr+2));
- printf("\n\t Acknowledgement Number: %d",
- EXTRACT_32BITS(tptr+6));
+ ND_PRINT((ndo, "\n\t Control - Protocol Control (type 0x%x, length %d)",
+ LLDP_DCBX_CONTROL_TLV, tlv_len));
+ ND_PRINT((ndo, "\n\t Oper_Version: %d", *tptr));
+ ND_PRINT((ndo, "\n\t Max_Version: %d", *(tptr + 1)));
+ ND_PRINT((ndo, "\n\t Sequence Number: %d", EXTRACT_32BITS(tptr + 2)));
+ ND_PRINT((ndo, "\n\t Acknowledgement Number: %d",
+ EXTRACT_32BITS(tptr + 6)));
break;
case LLDP_DCBX_PRIORITY_GROUPS_TLV:
if (tlv_len < 17) {
goto trunc;
}
- printf("\n\t Feature - Priority Group (type 0x%x, length %d)",
- LLDP_DCBX_PRIORITY_GROUPS_TLV, tlv_len);
- printf("\n\t Oper_Version: %d", *tptr);
- printf("\n\t Max_Version: %d", *(tptr+1));
- printf("\n\t Info block(0x%02X): ", *(tptr+2));
+ ND_PRINT((ndo, "\n\t Feature - Priority Group (type 0x%x, length %d)",
+ LLDP_DCBX_PRIORITY_GROUPS_TLV, tlv_len));
+ ND_PRINT((ndo, "\n\t Oper_Version: %d", *tptr));
+ ND_PRINT((ndo, "\n\t Max_Version: %d", *(tptr + 1)));
+ ND_PRINT((ndo, "\n\t Info block(0x%02X): ", *(tptr + 2)));
tval = *(tptr+2);
- printf("Enable bit: %d, Willing bit: %d, Error Bit: %d",
+ ND_PRINT((ndo, "Enable bit: %d, Willing bit: %d, Error Bit: %d",
(tval & 0x80) ? 1 : 0, (tval & 0x40) ? 1 : 0,
- (tval & 0x20) ? 1 : 0);
- printf("\n\t SubType: %d", *(tptr+3));
- printf("\n\t Priority Allocation");
-
+ (tval & 0x20) ? 1 : 0));
+ ND_PRINT((ndo, "\n\t SubType: %d", *(tptr + 3)));
+ ND_PRINT((ndo, "\n\t Priority Allocation"));
+
+ /*
+ * Array of 8 4-bit priority group ID values; we fetch all
+ * 32 bits and extract each nibble.
+ */
pgval = EXTRACT_32BITS(tptr+4);
for (i = 0; i <= 7; i++) {
- tval = *(tptr+4+(i/2));
- printf("\n\t PgId_%d: %d",
- i, (pgval >> (28-4*i)) & 0xF);
+ ND_PRINT((ndo, "\n\t PgId_%d: %d",
+ i, (pgval >> (28 - 4 * i)) & 0xF));
}
- printf("\n\t Priority Group Allocation");
+ ND_PRINT((ndo, "\n\t Priority Group Allocation"));
for (i = 0; i <= 7; i++)
- printf("\n\t Pg percentage[%d]: %d", i, *(tptr+8+i));
- printf("\n\t NumTCsSupported: %d", *(tptr+8+8));
+ ND_PRINT((ndo, "\n\t Pg percentage[%d]: %d", i, *(tptr + 8 + i)));
+ ND_PRINT((ndo, "\n\t NumTCsSupported: %d", *(tptr + 8 + 8)));
break;
case LLDP_DCBX_PRIORITY_FLOW_CONTROL_TLV:
if (tlv_len < 6) {
goto trunc;
}
- printf("\n\t Feature - Priority Flow Control");
- printf(" (type 0x%x, length %d)",
- LLDP_DCBX_PRIORITY_FLOW_CONTROL_TLV, tlv_len);
- printf("\n\t Oper_Version: %d", *tptr);
- printf("\n\t Max_Version: %d", *(tptr+1));
- printf("\n\t Info block(0x%02X): ", *(tptr+2));
+ ND_PRINT((ndo, "\n\t Feature - Priority Flow Control"));
+ ND_PRINT((ndo, " (type 0x%x, length %d)",
+ LLDP_DCBX_PRIORITY_FLOW_CONTROL_TLV, tlv_len));
+ ND_PRINT((ndo, "\n\t Oper_Version: %d", *tptr));
+ ND_PRINT((ndo, "\n\t Max_Version: %d", *(tptr + 1)));
+ ND_PRINT((ndo, "\n\t Info block(0x%02X): ", *(tptr + 2)));
tval = *(tptr+2);
- printf("Enable bit: %d, Willing bit: %d, Error Bit: %d",
+ ND_PRINT((ndo, "Enable bit: %d, Willing bit: %d, Error Bit: %d",
(tval & 0x80) ? 1 : 0, (tval & 0x40) ? 1 : 0,
- (tval & 0x20) ? 1 : 0);
- printf("\n\t SubType: %d", *(tptr+3));
+ (tval & 0x20) ? 1 : 0));
+ ND_PRINT((ndo, "\n\t SubType: %d", *(tptr + 3)));
tval = *(tptr+4);
- printf("\n\t PFC Config (0x%02X)", *(tptr+4));
+ ND_PRINT((ndo, "\n\t PFC Config (0x%02X)", *(tptr + 4)));
for (i = 0; i <= 7; i++)
- printf("\n\t Priority Bit %d: %s",
- i, (tval & (1 << i)) ? "Enabled" : "Disabled");
- printf("\n\t NumTCPFCSupported: %d", *(tptr+5));
+ ND_PRINT((ndo, "\n\t Priority Bit %d: %s",
+ i, (tval & (1 << i)) ? "Enabled" : "Disabled"));
+ ND_PRINT((ndo, "\n\t NumTCPFCSupported: %d", *(tptr + 5)));
break;
case LLDP_DCBX_APPLICATION_TLV:
if (tlv_len < 4) {
goto trunc;
}
- printf("\n\t Feature - Application (type 0x%x, length %d)",
- LLDP_DCBX_APPLICATION_TLV, tlv_len);
- printf("\n\t Oper_Version: %d", *tptr);
- printf("\n\t Max_Version: %d", *(tptr+1));
- printf("\n\t Info block(0x%02X): ", *(tptr+2));
+ ND_PRINT((ndo, "\n\t Feature - Application (type 0x%x, length %d)",
+ LLDP_DCBX_APPLICATION_TLV, tlv_len));
+ ND_PRINT((ndo, "\n\t Oper_Version: %d", *tptr));
+ ND_PRINT((ndo, "\n\t Max_Version: %d", *(tptr + 1)));
+ ND_PRINT((ndo, "\n\t Info block(0x%02X): ", *(tptr + 2)));
tval = *(tptr+2);
- printf("Enable bit: %d, Willing bit: %d, Error Bit: %d",
+ ND_PRINT((ndo, "Enable bit: %d, Willing bit: %d, Error Bit: %d",
(tval & 0x80) ? 1 : 0, (tval & 0x40) ? 1 : 0,
- (tval & 0x20) ? 1 : 0);
- printf("\n\t SubType: %d", *(tptr+3));
+ (tval & 0x20) ? 1 : 0));
+ ND_PRINT((ndo, "\n\t SubType: %d", *(tptr + 3)));
tval = tlv_len - 4;
mptr = tptr + 4;
while (tval >= 6) {
- printf("\n\t Application Value");
- printf("\n\t Application Protocol ID: 0x%04x",
- EXTRACT_16BITS(mptr));
+ ND_PRINT((ndo, "\n\t Application Value"));
+ ND_PRINT((ndo, "\n\t Application Protocol ID: 0x%04x",
+ EXTRACT_16BITS(mptr)));
uval = EXTRACT_24BITS(mptr+2);
- printf("\n\t SF (0x%x) Application Protocol ID is %s",
+ ND_PRINT((ndo, "\n\t SF (0x%x) Application Protocol ID is %s",
(uval >> 22),
- (uval >> 22) ? "Socket Number" : "L2 EtherType");
- printf("\n\t OUI: 0x%06x", uval & 0x3fffff);
- printf("\n\t User Priority Map: 0x%02x", *(mptr+5));
+ (uval >> 22) ? "Socket Number" : "L2 EtherType"));
+ ND_PRINT((ndo, "\n\t OUI: 0x%06x", uval & 0x3fffff));
+ ND_PRINT((ndo, "\n\t User Priority Map: 0x%02x", *(mptr + 5)));
tval = tval - 6;
mptr = mptr + 6;
}
@@ -1054,8 +1252,8 @@ lldp_private_dcbx_print(const u_char *pptr, u_int len)
}
/* do we also want to see a hex dump ? */
- if (vflag > 1 || (vflag && hexdump)) {
- print_unknown_data(tptr,"\n\t ", tlv_len);
+ if (ndo->ndo_vflag > 1 || (ndo->ndo_vflag && hexdump)) {
+ print_unknown_data(ndo, tptr, "\n\t ", tlv_len);
}
tlen -= tlv_len;
@@ -1067,11 +1265,11 @@ lldp_private_dcbx_print(const u_char *pptr, u_int len)
}
static char *
-lldp_network_addr_print(const u_char *tptr, u_int len) {
+lldp_network_addr_print(netdissect_options *ndo, const u_char *tptr, u_int len) {
- u_int8_t af;
+ uint8_t af;
static char buf[BUFSIZE];
- const char * (*pfunc)(const u_char *);
+ const char * (*pfunc)(netdissect_options *, const u_char *);
if (len < 1)
return NULL;
@@ -1081,7 +1279,7 @@ lldp_network_addr_print(const u_char *tptr, u_int len) {
case AFNUM_INET:
if (len < 4)
return NULL;
- pfunc = getname;
+ pfunc = getname;
break;
#ifdef INET6
case AFNUM_INET6:
@@ -1105,20 +1303,21 @@ lldp_network_addr_print(const u_char *tptr, u_int len) {
tok2str(af_values, "Unknown", af), af);
} else {
snprintf(buf, sizeof(buf), "AFI %s (%u): %s",
- tok2str(af_values, "Unknown", af), af, (*pfunc)(tptr+1));
+ tok2str(af_values, "Unknown", af), af, (*pfunc)(ndo, tptr+1));
}
return buf;
}
static int
-lldp_mgmt_addr_tlv_print(const u_char *pptr, u_int len) {
+lldp_mgmt_addr_tlv_print(netdissect_options *ndo,
+ const u_char *pptr, u_int len) {
- u_int8_t mgmt_addr_len, intf_num_subtype, oid_len;
+ uint8_t mgmt_addr_len, intf_num_subtype, oid_len;
const u_char *tptr;
u_int tlen;
char *mgmt_addr;
-
+
tlen = len;
tptr = pptr;
@@ -1132,12 +1331,12 @@ lldp_mgmt_addr_tlv_print(const u_char *pptr, u_int len) {
return 0;
}
- mgmt_addr = lldp_network_addr_print(tptr, mgmt_addr_len);
+ mgmt_addr = lldp_network_addr_print(ndo, tptr, mgmt_addr_len);
if (mgmt_addr == NULL) {
return 0;
}
- printf("\n\t Management Address length %u, %s",
- mgmt_addr_len, mgmt_addr);
+ ND_PRINT((ndo, "\n\t Management Address length %u, %s",
+ mgmt_addr_len, mgmt_addr));
tptr += mgmt_addr_len;
tlen -= mgmt_addr_len;
@@ -1146,10 +1345,10 @@ lldp_mgmt_addr_tlv_print(const u_char *pptr, u_int len) {
}
intf_num_subtype = *tptr;
- printf("\n\t %s Interface Numbering (%u): %u",
+ ND_PRINT((ndo, "\n\t %s Interface Numbering (%u): %u",
tok2str(lldp_intf_numb_subtype_values, "Unknown", intf_num_subtype),
intf_num_subtype,
- EXTRACT_32BITS(tptr+1));
+ EXTRACT_32BITS(tptr + 1)));
tptr += LLDP_INTF_NUM_LEN;
tlen -= LLDP_INTF_NUM_LEN;
@@ -1164,31 +1363,32 @@ lldp_mgmt_addr_tlv_print(const u_char *pptr, u_int len) {
return 0;
}
if (oid_len) {
- printf("\n\t OID length %u", oid_len);
- safeputs((const char *)tptr+1, oid_len);
+ ND_PRINT((ndo, "\n\t OID length %u", oid_len));
+ safeputs(ndo, tptr + 1, oid_len);
}
}
return 1;
-}
+}
void
-lldp_print(register const u_char *pptr, register u_int len) {
+lldp_print(netdissect_options *ndo,
+ register const u_char *pptr, register u_int len) {
- u_int8_t subtype;
- u_int16_t tlv, cap, ena_cap;
+ uint8_t subtype;
+ uint16_t tlv, cap, ena_cap;
u_int oui, tlen, hexdump, tlv_type, tlv_len;
const u_char *tptr;
char *network_addr;
-
+
tptr = pptr;
tlen = len;
- printf("LLDP, length %u", len);
+ ND_PRINT((ndo, "LLDP, length %u", len));
while (tlen >= sizeof(tlv)) {
- TCHECK2(*tptr, sizeof(tlv));
+ ND_TCHECK2(*tptr, sizeof(tlv));
tlv = EXTRACT_16BITS(tptr);
@@ -1199,10 +1399,10 @@ lldp_print(register const u_char *pptr, register u_int len) {
tlen -= sizeof(tlv);
tptr += sizeof(tlv);
- if (vflag) {
- printf("\n\t%s TLV (%u), length %u",
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "\n\t%s TLV (%u), length %u",
tok2str(lldp_tlv_values, "Unknown", tlv_type),
- tlv_type, tlv_len);
+ tlv_type, tlv_len));
}
/* infinite loop check */
@@ -1210,7 +1410,7 @@ lldp_print(register const u_char *pptr, register u_int len) {
break;
}
- TCHECK2(*tptr, tlv_len);
+ ND_TCHECK2(*tptr, tlv_len);
if (tlen < tlv_len) {
goto trunc;
}
@@ -1218,21 +1418,21 @@ lldp_print(register const u_char *pptr, register u_int len) {
switch (tlv_type) {
case LLDP_CHASSIS_ID_TLV:
- if (vflag) {
+ if (ndo->ndo_vflag) {
if (tlv_len < 2) {
goto trunc;
}
subtype = *tptr;
- printf("\n\t Subtype %s (%u): ",
+ ND_PRINT((ndo, "\n\t Subtype %s (%u): ",
tok2str(lldp_chassis_subtype_values, "Unknown", subtype),
- subtype);
+ subtype));
switch (subtype) {
case LLDP_CHASSIS_MAC_ADDR_SUBTYPE:
if (tlv_len < 1+6) {
goto trunc;
}
- printf("%s", etheraddr_string(tptr+1));
+ ND_PRINT((ndo, "%s", etheraddr_string(ndo, tptr + 1)));
break;
case LLDP_CHASSIS_INTF_NAME_SUBTYPE: /* fall through */
@@ -1240,15 +1440,15 @@ lldp_print(register const u_char *pptr, register u_int len) {
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);
+ safeputs(ndo, tptr + 1, tlv_len - 1);
break;
case LLDP_CHASSIS_NETWORK_ADDR_SUBTYPE:
- network_addr = lldp_network_addr_print(tptr+1, tlv_len-1);
+ network_addr = lldp_network_addr_print(ndo, tptr+1, tlv_len-1);
if (network_addr == NULL) {
goto trunc;
}
- printf("%s", network_addr);
+ ND_PRINT((ndo, "%s", network_addr));
break;
default:
@@ -1259,21 +1459,21 @@ lldp_print(register const u_char *pptr, register u_int len) {
break;
case LLDP_PORT_ID_TLV:
- if (vflag) {
+ if (ndo->ndo_vflag) {
if (tlv_len < 2) {
goto trunc;
}
subtype = *tptr;
- printf("\n\t Subtype %s (%u): ",
+ ND_PRINT((ndo, "\n\t Subtype %s (%u): ",
tok2str(lldp_port_subtype_values, "Unknown", subtype),
- subtype);
+ subtype));
switch (subtype) {
case LLDP_PORT_MAC_ADDR_SUBTYPE:
if (tlv_len < 1+6) {
goto trunc;
}
- printf("%s", etheraddr_string(tptr+1));
+ ND_PRINT((ndo, "%s", etheraddr_string(ndo, tptr + 1)));
break;
case LLDP_PORT_INTF_NAME_SUBTYPE: /* fall through */
@@ -1281,15 +1481,15 @@ lldp_print(register const u_char *pptr, register u_int len) {
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);
+ safeputs(ndo, tptr + 1, tlv_len - 1);
break;
case LLDP_PORT_NETWORK_ADDR_SUBTYPE:
- network_addr = lldp_network_addr_print(tptr+1, tlv_len-1);
+ network_addr = lldp_network_addr_print(ndo, tptr+1, tlv_len-1);
if (network_addr == NULL) {
goto trunc;
}
- printf("%s", network_addr);
+ ND_PRINT((ndo, "%s", network_addr));
break;
default:
@@ -1300,18 +1500,18 @@ lldp_print(register const u_char *pptr, register u_int len) {
break;
case LLDP_TTL_TLV:
- if (vflag) {
+ if (ndo->ndo_vflag) {
if (tlv_len < 2) {
goto trunc;
}
- printf(": TTL %us", EXTRACT_16BITS(tptr));
+ ND_PRINT((ndo, ": TTL %us", EXTRACT_16BITS(tptr)));
}
break;
case LLDP_PORT_DESCR_TLV:
- if (vflag) {
- printf(": ");
- safeputs((const char *)tptr, tlv_len);
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, ": "));
+ safeputs(ndo, tptr, tlv_len);
}
break;
@@ -1320,19 +1520,19 @@ lldp_print(register const u_char *pptr, register u_int len) {
* The system name is also print in non-verbose mode
* similar to the CDP printer.
*/
- printf(": ");
- safeputs((const char *)tptr, tlv_len);
+ ND_PRINT((ndo, ": "));
+ safeputs(ndo, tptr, tlv_len);
break;
case LLDP_SYSTEM_DESCR_TLV:
- if (vflag) {
- printf("\n\t ");
- safeputs((const char *)tptr, tlv_len);
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "\n\t "));
+ safeputs(ndo, tptr, tlv_len);
}
break;
case LLDP_SYSTEM_CAP_TLV:
- if (vflag) {
+ if (ndo->ndo_vflag) {
/*
* XXX - IEEE Std 802.1AB-2009 says the first octet
* if a chassis ID subtype, with the system
@@ -1344,41 +1544,41 @@ lldp_print(register const u_char *pptr, register u_int len) {
}
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);
+ ND_PRINT((ndo, "\n\t System Capabilities [%s] (0x%04x)",
+ bittok2str(lldp_cap_values, "none", cap), cap));
+ ND_PRINT((ndo, "\n\t Enabled Capabilities [%s] (0x%04x)",
+ bittok2str(lldp_cap_values, "none", ena_cap), ena_cap));
}
break;
case LLDP_MGMT_ADDR_TLV:
- if (vflag) {
- if (!lldp_mgmt_addr_tlv_print(tptr, tlv_len)) {
+ if (ndo->ndo_vflag) {
+ if (!lldp_mgmt_addr_tlv_print(ndo, tptr, tlv_len)) {
goto trunc;
}
}
break;
case LLDP_PRIVATE_TLV:
- if (vflag) {
+ if (ndo->ndo_vflag) {
if (tlv_len < 3) {
goto trunc;
}
oui = EXTRACT_24BITS(tptr);
- printf(": OUI %s (0x%06x)", tok2str(oui_values, "Unknown", oui), oui);
-
+ ND_PRINT((ndo, ": OUI %s (0x%06x)", tok2str(oui_values, "Unknown", oui), oui));
+
switch (oui) {
case OUI_IEEE_8021_PRIVATE:
- hexdump = lldp_private_8021_print(tptr, tlv_len);
+ hexdump = lldp_private_8021_print(ndo, tptr, tlv_len);
break;
case OUI_IEEE_8023_PRIVATE:
- hexdump = lldp_private_8023_print(tptr, tlv_len);
+ hexdump = lldp_private_8023_print(ndo, tptr, tlv_len);
break;
case OUI_TIA:
- hexdump = lldp_private_tia_print(tptr, tlv_len);
+ hexdump = lldp_private_tia_print(ndo, tptr, tlv_len);
break;
case OUI_DCBX:
- hexdump = lldp_private_dcbx_print(tptr, tlv_len);
+ hexdump = lldp_private_dcbx_print(ndo, tptr, tlv_len);
break;
default:
hexdump = TRUE;
@@ -1393,8 +1593,8 @@ lldp_print(register const u_char *pptr, register u_int len) {
}
/* do we also want to see a hex dump ? */
- if (vflag > 1 || (vflag && hexdump)) {
- print_unknown_data(tptr,"\n\t ", tlv_len);
+ if (ndo->ndo_vflag > 1 || (ndo->ndo_vflag && hexdump)) {
+ print_unknown_data(ndo, tptr, "\n\t ", tlv_len);
}
tlen -= tlv_len;
@@ -1402,7 +1602,7 @@ lldp_print(register const u_char *pptr, register u_int len) {
}
return;
trunc:
- printf("\n\t[|LLDP]");
+ ND_PRINT((ndo, "\n\t[|LLDP]"));
}
/*
diff --git a/contrib/tcpdump/print-lmp.c b/contrib/tcpdump/print-lmp.c
index e09b89fc22ed..8d68e858fb7b 100644
--- a/contrib/tcpdump/print-lmp.c
+++ b/contrib/tcpdump/print-lmp.c
@@ -17,21 +17,13 @@
* by Manu Pathak (mapathak@cisco.com), May 2005
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-lmp.c,v 1.11 2007-08-02 17:32:49 hannes Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
#include "interface.h"
#include "extract.h"
#include "addrtoname.h"
@@ -50,15 +42,15 @@ static const char rcsid[] _U_ =
*/
struct lmp_common_header {
- u_int8_t version_res[2];
- u_int8_t flags;
- u_int8_t msg_type;
- u_int8_t length[2];
- u_int8_t reserved[2];
+ uint8_t version_res[2];
+ uint8_t flags;
+ uint8_t msg_type;
+ uint8_t length[2];
+ uint8_t reserved[2];
};
#define LMP_VERSION 1
-#define LMP_EXTRACT_VERSION(x) (((x)&0xf0)>>4)
+#define LMP_EXTRACT_VERSION(x) (((x)&0xf0)>>4)
static const struct tok lmp_header_flag_values[] = {
{ 0x01, "Control Channel Down"},
@@ -205,7 +197,7 @@ static const struct tok lmp_msg_type_values[] = {
{ 0, NULL}
};
-/*
+/*
* LMP object header
*
* 0 1 2 3
@@ -216,20 +208,20 @@ static const struct tok lmp_msg_type_values[] = {
* | |
* // (object contents) //
* | |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
struct lmp_object_header {
- u_int8_t ctype;
- u_int8_t class_num;
- u_int8_t length[2];
+ uint8_t ctype;
+ uint8_t class_num;
+ uint8_t length[2];
};
#define LMP_OBJ_CC_ID 1
#define LMP_OBJ_NODE_ID 2
#define LMP_OBJ_LINK_ID 3
#define LMP_OBJ_INTERFACE_ID 4
-#define LMP_OBJ_MESSAGE_ID 5
+#define LMP_OBJ_MESSAGE_ID 5
#define LMP_OBJ_CONFIG 6
#define LMP_OBJ_HELLO 7
#define LMP_OBJ_VERIFY_BEGIN 8
@@ -279,13 +271,13 @@ static const struct tok lmp_data_link_subobj[] = {
#define LMP_CTYPE_LOC 1
#define LMP_CTYPE_RMT 2
#define LMP_CTYPE_UNMD 3
-
+
#define LMP_CTYPE_IPV4_LOC 1
#define LMP_CTYPE_IPV4_RMT 2
#define LMP_CTYPE_IPV6_LOC 3
#define LMP_CTYPE_IPV6_RMT 4
-#define LMP_CTYPE_UNMD_LOC 5
-#define LMP_CTYPE_UNMD_RMT 6
+#define LMP_CTYPE_UNMD_LOC 5
+#define LMP_CTYPE_UNMD_RMT 6
#define LMP_CTYPE_1 1
#define LMP_CTYPE_2 2
@@ -302,7 +294,7 @@ static const struct tok lmp_data_link_subobj[] = {
#define LMP_CTYPE_SERVICE_CONFIG_TRANSPARENCY_TCM 3
#define LMP_CTYPE_SERVICE_CONFIG_NETWORK_DIVERSITY 4
-/*
+/*
* Different link types allowed in the Client Port Service Attributes
* subobject defined for LMP Service Discovery in the UNI 1.0 spec
*/
@@ -361,7 +353,8 @@ static const struct tok lmp_ctype_values[] = {
};
void
-lmp_print(register const u_char *pptr, register u_int len) {
+lmp_print(netdissect_options *ndo,
+ register const u_char *pptr, register u_int len) {
const struct lmp_common_header *lmp_com_header;
const struct lmp_object_header *lmp_obj_header;
@@ -372,29 +365,29 @@ lmp_print(register const u_char *pptr, register u_int len) {
int link_type;
union { /* int to float conversion buffer */
- float f;
- u_int32_t i;
+ float f;
+ uint32_t i;
} bw;
tptr=pptr;
lmp_com_header = (const struct lmp_common_header *)pptr;
- TCHECK(*lmp_com_header);
+ ND_TCHECK(*lmp_com_header);
/*
* Sanity checking of the header.
*/
if (LMP_EXTRACT_VERSION(lmp_com_header->version_res[0]) != LMP_VERSION) {
- printf("LMP version %u packet not supported",
- LMP_EXTRACT_VERSION(lmp_com_header->version_res[0]));
+ ND_PRINT((ndo, "LMP version %u packet not supported",
+ LMP_EXTRACT_VERSION(lmp_com_header->version_res[0])));
return;
}
/* in non-verbose mode just lets print the basic Message Type*/
- if (vflag < 1) {
- printf("LMPv%u %s Message, length: %u",
+ if (ndo->ndo_vflag < 1) {
+ ND_PRINT((ndo, "LMPv%u %s Message, length: %u",
LMP_EXTRACT_VERSION(lmp_com_header->version_res[0]),
tok2str(lmp_msg_type_values, "unknown (%u)",lmp_com_header->msg_type),
- len);
+ len));
return;
}
@@ -402,19 +395,18 @@ lmp_print(register const u_char *pptr, register u_int len) {
tlen=EXTRACT_16BITS(lmp_com_header->length);
- printf("\n\tLMPv%u, msg-type: %s, Flags: [%s], length: %u",
+ ND_PRINT((ndo, "\n\tLMPv%u, msg-type: %s, Flags: [%s], length: %u",
LMP_EXTRACT_VERSION(lmp_com_header->version_res[0]),
tok2str(lmp_msg_type_values, "unknown, type: %u",lmp_com_header->msg_type),
bittok2str(lmp_header_flag_values,"none",lmp_com_header->flags),
- tlen);
+ tlen));
tptr+=sizeof(const struct lmp_common_header);
tlen-=sizeof(const struct lmp_common_header);
while(tlen>0) {
/* did we capture enough for fully decoding the object header ? */
- if (!TTEST2(*tptr, sizeof(struct lmp_object_header)))
- goto trunc;
+ ND_TCHECK2(*tptr, sizeof(struct lmp_object_header));
lmp_obj_header = (const struct lmp_object_header *)tptr;
lmp_obj_len=EXTRACT_16BITS(lmp_obj_header->length);
@@ -423,7 +415,7 @@ lmp_print(register const u_char *pptr, register u_int len) {
if(lmp_obj_len % 4 || lmp_obj_len < 4)
return;
- printf("\n\t %s Object (%u), Class-Type: %s (%u) Flags: [%snegotiable], length: %u",
+ ND_PRINT((ndo, "\n\t %s Object (%u), Class-Type: %s (%u) Flags: [%snegotiable], length: %u",
tok2str(lmp_obj_values,
"Unknown",
lmp_obj_header->class_num),
@@ -433,14 +425,13 @@ lmp_print(register const u_char *pptr, register u_int len) {
((lmp_obj_header->class_num)<<8)+lmp_obj_ctype),
lmp_obj_ctype,
(lmp_obj_header->ctype)&0x80 ? "" : "non-",
- lmp_obj_len);
+ lmp_obj_len));
obj_tptr=tptr+sizeof(struct lmp_object_header);
obj_tlen=lmp_obj_len-sizeof(struct lmp_object_header);
/* did we capture enough for fully decoding the object ? */
- if (!TTEST2(*tptr, lmp_obj_len))
- goto trunc;
+ ND_TCHECK2(*tptr, lmp_obj_len);
hexdump=FALSE;
switch(lmp_obj_header->class_num) {
@@ -449,9 +440,9 @@ lmp_print(register const u_char *pptr, register u_int len) {
switch(lmp_obj_ctype) {
case LMP_CTYPE_LOC:
case LMP_CTYPE_RMT:
- printf("\n\t Control Channel ID: %u (0x%08x)",
+ ND_PRINT((ndo, "\n\t Control Channel ID: %u (0x%08x)",
EXTRACT_32BITS(obj_tptr),
- EXTRACT_32BITS(obj_tptr));
+ EXTRACT_32BITS(obj_tptr)));
break;
default:
@@ -464,23 +455,23 @@ lmp_print(register const u_char *pptr, register u_int len) {
switch(lmp_obj_ctype) {
case LMP_CTYPE_IPV4_LOC:
case LMP_CTYPE_IPV4_RMT:
- printf("\n\t IPv4 Link ID: %s (0x%08x)",
- ipaddr_string(obj_tptr),
- EXTRACT_32BITS(obj_tptr));
+ ND_PRINT((ndo, "\n\t IPv4 Link ID: %s (0x%08x)",
+ ipaddr_string(ndo, obj_tptr),
+ EXTRACT_32BITS(obj_tptr)));
break;
#ifdef INET6
case LMP_CTYPE_IPV6_LOC:
case LMP_CTYPE_IPV6_RMT:
- printf("\n\t IPv6 Link ID: %s (0x%08x)",
- ip6addr_string(obj_tptr),
- EXTRACT_32BITS(obj_tptr));
+ ND_PRINT((ndo, "\n\t IPv6 Link ID: %s (0x%08x)",
+ ip6addr_string(ndo, obj_tptr),
+ EXTRACT_32BITS(obj_tptr)));
break;
#endif
case LMP_CTYPE_UNMD_LOC:
case LMP_CTYPE_UNMD_RMT:
- printf("\n\t Link ID: %u (0x%08x)",
+ ND_PRINT((ndo, "\n\t Link ID: %u (0x%08x)",
EXTRACT_32BITS(obj_tptr),
- EXTRACT_32BITS(obj_tptr));
+ EXTRACT_32BITS(obj_tptr)));
break;
default:
hexdump=TRUE;
@@ -490,14 +481,14 @@ lmp_print(register const u_char *pptr, register u_int len) {
case LMP_OBJ_MESSAGE_ID:
switch(lmp_obj_ctype) {
case LMP_CTYPE_1:
- printf("\n\t Message ID: %u (0x%08x)",
+ ND_PRINT((ndo, "\n\t Message ID: %u (0x%08x)",
EXTRACT_32BITS(obj_tptr),
- EXTRACT_32BITS(obj_tptr));
+ EXTRACT_32BITS(obj_tptr)));
break;
case LMP_CTYPE_2:
- printf("\n\t Message ID Ack: %u (0x%08x)",
+ ND_PRINT((ndo, "\n\t Message ID Ack: %u (0x%08x)",
EXTRACT_32BITS(obj_tptr),
- EXTRACT_32BITS(obj_tptr));
+ EXTRACT_32BITS(obj_tptr)));
break;
default:
hexdump=TRUE;
@@ -508,9 +499,9 @@ lmp_print(register const u_char *pptr, register u_int len) {
switch(lmp_obj_ctype) {
case LMP_CTYPE_LOC:
case LMP_CTYPE_RMT:
- printf("\n\t Node ID: %s (0x%08x)",
- ipaddr_string(obj_tptr),
- EXTRACT_32BITS(obj_tptr));
+ ND_PRINT((ndo, "\n\t Node ID: %s (0x%08x)",
+ ipaddr_string(ndo, obj_tptr),
+ EXTRACT_32BITS(obj_tptr)));
break;
default:
@@ -521,45 +512,45 @@ lmp_print(register const u_char *pptr, register u_int len) {
case LMP_OBJ_CONFIG:
switch(lmp_obj_ctype) {
case LMP_CTYPE_HELLO_CONFIG:
- printf("\n\t Hello Interval: %u\n\t Hello Dead Interval: %u",
+ ND_PRINT((ndo, "\n\t Hello Interval: %u\n\t Hello Dead Interval: %u",
EXTRACT_16BITS(obj_tptr),
- EXTRACT_16BITS(obj_tptr+2));
+ EXTRACT_16BITS(obj_tptr+2)));
break;
default:
hexdump=TRUE;
}
break;
-
+
case LMP_OBJ_HELLO:
switch(lmp_obj_ctype) {
case LMP_CTYPE_HELLO:
- printf("\n\t Tx Seq: %u, Rx Seq: %u",
+ ND_PRINT((ndo, "\n\t Tx Seq: %u, Rx Seq: %u",
EXTRACT_32BITS(obj_tptr),
- EXTRACT_32BITS(obj_tptr+4));
+ EXTRACT_32BITS(obj_tptr+4)));
break;
default:
hexdump=TRUE;
}
- break;
-
+ break;
+
case LMP_OBJ_TE_LINK:
- printf("\n\t Flags: [%s]",
+ ND_PRINT((ndo, "\n\t Flags: [%s]",
bittok2str(lmp_obj_te_link_flag_values,
"none",
- EXTRACT_16BITS(obj_tptr)>>8));
-
+ EXTRACT_16BITS(obj_tptr)>>8)));
+
switch(lmp_obj_ctype) {
case LMP_CTYPE_IPV4:
- printf("\n\t Local Link-ID: %s (0x%08x) \
- \n\t Remote Link-ID: %s (0x%08x)",
- ipaddr_string(obj_tptr+4),
+ ND_PRINT((ndo, "\n\t Local Link-ID: %s (0x%08x)"
+ "\n\t Remote Link-ID: %s (0x%08x)",
+ ipaddr_string(ndo, obj_tptr+4),
EXTRACT_32BITS(obj_tptr+4),
- ipaddr_string(obj_tptr+8),
- EXTRACT_32BITS(obj_tptr+8));
+ ipaddr_string(ndo, obj_tptr+8),
+ EXTRACT_32BITS(obj_tptr+8)));
break;
-
+
#ifdef INET6
case LMP_CTYPE_IPV6:
#endif
@@ -568,56 +559,56 @@ lmp_print(register const u_char *pptr, register u_int len) {
hexdump=TRUE;
}
break;
-
+
case LMP_OBJ_DATA_LINK:
- printf("\n\t Flags: [%s]",
+ ND_PRINT((ndo, "\n\t Flags: [%s]",
bittok2str(lmp_obj_data_link_flag_values,
"none",
- EXTRACT_16BITS(obj_tptr)>>8));
-
+ EXTRACT_16BITS(obj_tptr)>>8)));
+
switch(lmp_obj_ctype) {
case LMP_CTYPE_IPV4:
case LMP_CTYPE_UNMD:
- printf("\n\t Local Interface ID: %s (0x%08x) \
- \n\t Remote Interface ID: %s (0x%08x)",
- ipaddr_string(obj_tptr+4),
+ ND_PRINT((ndo, "\n\t Local Interface ID: %s (0x%08x)"
+ "\n\t Remote Interface ID: %s (0x%08x)",
+ ipaddr_string(ndo, obj_tptr+4),
EXTRACT_32BITS(obj_tptr+4),
- ipaddr_string(obj_tptr+8),
- EXTRACT_32BITS(obj_tptr+8));
-
- total_subobj_len = lmp_obj_len - 16;
+ ipaddr_string(ndo, obj_tptr+8),
+ EXTRACT_32BITS(obj_tptr+8)));
+
+ total_subobj_len = lmp_obj_len - 16;
offset = 12;
while (total_subobj_len > 0 && hexdump == FALSE ) {
subobj_type = EXTRACT_16BITS(obj_tptr+offset)>>8;
subobj_len = EXTRACT_16BITS(obj_tptr+offset)&0x00FF;
- printf("\n\t Subobject, Type: %s (%u), Length: %u",
+ ND_PRINT((ndo, "\n\t Subobject, Type: %s (%u), Length: %u",
tok2str(lmp_data_link_subobj,
"Unknown",
subobj_type),
subobj_type,
- subobj_len);
+ subobj_len));
switch(subobj_type) {
case INT_SWITCHING_TYPE_SUBOBJ:
- printf("\n\t Switching Type: %s (%u)",
- tok2str(gmpls_switch_cap_values,
- "Unknown",
+ ND_PRINT((ndo, "\n\t Switching Type: %s (%u)",
+ tok2str(gmpls_switch_cap_values,
+ "Unknown",
EXTRACT_16BITS(obj_tptr+offset+2)>>8),
- EXTRACT_16BITS(obj_tptr+offset+2)>>8);
- printf("\n\t Encoding Type: %s (%u)",
- tok2str(gmpls_encoding_values,
- "Unknown",
+ EXTRACT_16BITS(obj_tptr+offset+2)>>8));
+ ND_PRINT((ndo, "\n\t Encoding Type: %s (%u)",
+ tok2str(gmpls_encoding_values,
+ "Unknown",
EXTRACT_16BITS(obj_tptr+offset+2)&0x00FF),
- EXTRACT_16BITS(obj_tptr+offset+2)&0x00FF);
+ EXTRACT_16BITS(obj_tptr+offset+2)&0x00FF));
bw.i = EXTRACT_32BITS(obj_tptr+offset+4);
- printf("\n\t Min Reservable Bandwidth: %.3f Mbps",
- bw.f*8/1000000);
+ ND_PRINT((ndo, "\n\t Min Reservable Bandwidth: %.3f Mbps",
+ bw.f*8/1000000));
bw.i = EXTRACT_32BITS(obj_tptr+offset+8);
- printf("\n\t Max Reservable Bandwidth: %.3f Mbps",
- bw.f*8/1000000);
- break;
+ ND_PRINT((ndo, "\n\t Max Reservable Bandwidth: %.3f Mbps",
+ bw.f*8/1000000));
+ break;
case WAVELENGTH_SUBOBJ:
- printf("\n\t Wavelength: %u",
- EXTRACT_32BITS(obj_tptr+offset+4));
+ ND_PRINT((ndo, "\n\t Wavelength: %u",
+ EXTRACT_32BITS(obj_tptr+offset+4)));
break;
default:
/* Any Unknown Subobject ==> Exit loop */
@@ -627,70 +618,70 @@ lmp_print(register const u_char *pptr, register u_int len) {
total_subobj_len-=subobj_len;
offset+=subobj_len;
}
-
+
break;
-#ifdef INET6
+#ifdef INET6
case LMP_CTYPE_IPV6:
#endif
default:
hexdump=TRUE;
}
- break;
-
+ break;
+
case LMP_OBJ_VERIFY_BEGIN:
switch(lmp_obj_ctype) {
case LMP_CTYPE_1:
- printf("\n\t Flags: %s",
+ ND_PRINT((ndo, "\n\t Flags: %s",
bittok2str(lmp_obj_begin_verify_flag_values,
"none",
- EXTRACT_16BITS(obj_tptr)));
- printf("\n\t Verify Interval: %u",
- EXTRACT_16BITS(obj_tptr+2));
- printf("\n\t Data links: %u",
- EXTRACT_32BITS(obj_tptr+4));
- printf("\n\t Encoding type: %s",
- tok2str(gmpls_encoding_values, "Unknown", *(obj_tptr+8)));
- printf("\n\t Verify Tranport Mechanism: %u (0x%x) %s",
+ EXTRACT_16BITS(obj_tptr))));
+ ND_PRINT((ndo, "\n\t Verify Interval: %u",
+ EXTRACT_16BITS(obj_tptr+2)));
+ ND_PRINT((ndo, "\n\t Data links: %u",
+ EXTRACT_32BITS(obj_tptr+4)));
+ ND_PRINT((ndo, "\n\t Encoding type: %s",
+ tok2str(gmpls_encoding_values, "Unknown", *(obj_tptr+8))));
+ ND_PRINT((ndo, "\n\t Verify Transport Mechanism: %u (0x%x)%s",
EXTRACT_16BITS(obj_tptr+10),
EXTRACT_16BITS(obj_tptr+10),
- EXTRACT_16BITS(obj_tptr+10)&8000 ? "(Payload test messages capable)" : "");
+ EXTRACT_16BITS(obj_tptr+10)&8000 ? " (Payload test messages capable)" : ""));
bw.i = EXTRACT_32BITS(obj_tptr+12);
- printf("\n\t Transmission Rate: %.3f Mbps",bw.f*8/1000000);
- printf("\n\t Wavelength: %u",
- EXTRACT_32BITS(obj_tptr+16));
+ ND_PRINT((ndo, "\n\t Transmission Rate: %.3f Mbps",bw.f*8/1000000));
+ ND_PRINT((ndo, "\n\t Wavelength: %u",
+ EXTRACT_32BITS(obj_tptr+16)));
break;
-
+
default:
hexdump=TRUE;
}
- break;
-
+ break;
+
case LMP_OBJ_VERIFY_BEGIN_ACK:
switch(lmp_obj_ctype) {
case LMP_CTYPE_1:
- printf("\n\t Verify Dead Interval: %u \
- \n\t Verify Transport Response: %u",
+ ND_PRINT((ndo, "\n\t Verify Dead Interval: %u"
+ "\n\t Verify Transport Response: %u",
EXTRACT_16BITS(obj_tptr),
- EXTRACT_16BITS(obj_tptr+2));
+ EXTRACT_16BITS(obj_tptr+2)));
break;
-
+
default:
hexdump=TRUE;
}
- break;
-
+ break;
+
case LMP_OBJ_VERIFY_ID:
switch(lmp_obj_ctype) {
case LMP_CTYPE_1:
- printf("\n\t Verify ID: %u",
- EXTRACT_32BITS(obj_tptr));
+ ND_PRINT((ndo, "\n\t Verify ID: %u",
+ EXTRACT_32BITS(obj_tptr)));
break;
-
+
default:
hexdump=TRUE;
}
- break;
-
+ break;
+
case LMP_OBJ_CHANNEL_STATUS:
switch(lmp_obj_ctype) {
case LMP_CTYPE_IPV4:
@@ -698,164 +689,164 @@ lmp_print(register const u_char *pptr, register u_int len) {
offset = 0;
/* Decode pairs: <Interface_ID (4 bytes), Channel_status (4 bytes)> */
while (offset < (lmp_obj_len-(int)sizeof(struct lmp_object_header)) ) {
- printf("\n\t Interface ID: %s (0x%08x)",
- ipaddr_string(obj_tptr+offset),
- EXTRACT_32BITS(obj_tptr+offset));
-
- printf("\n\t\t Active: %s (%u)", (EXTRACT_32BITS(obj_tptr+offset+4)>>31) ?
+ ND_PRINT((ndo, "\n\t Interface ID: %s (0x%08x)",
+ ipaddr_string(ndo, obj_tptr+offset),
+ EXTRACT_32BITS(obj_tptr+offset)));
+
+ ND_PRINT((ndo, "\n\t\t Active: %s (%u)", (EXTRACT_32BITS(obj_tptr+offset+4)>>31) ?
"Allocated" : "Non-allocated",
- (EXTRACT_32BITS(obj_tptr+offset+4)>>31));
-
- printf("\n\t\t Direction: %s (%u)", (EXTRACT_32BITS(obj_tptr+offset+4)>>30)&0x1 ?
+ (EXTRACT_32BITS(obj_tptr+offset+4)>>31)));
+
+ ND_PRINT((ndo, "\n\t\t Direction: %s (%u)", (EXTRACT_32BITS(obj_tptr+offset+4)>>30)&0x1 ?
"Transmit" : "Receive",
- (EXTRACT_32BITS(obj_tptr+offset+4)>>30)&0x1);
-
- printf("\n\t\t Channel Status: %s (%u)",
+ (EXTRACT_32BITS(obj_tptr+offset+4)>>30)&0x1));
+
+ ND_PRINT((ndo, "\n\t\t Channel Status: %s (%u)",
tok2str(lmp_obj_channel_status_values,
"Unknown",
EXTRACT_32BITS(obj_tptr+offset+4)&0x3FFFFFF),
- EXTRACT_32BITS(obj_tptr+offset+4)&0x3FFFFFF);
+ EXTRACT_32BITS(obj_tptr+offset+4)&0x3FFFFFF));
offset+=8;
}
break;
-#ifdef INET6
+#ifdef INET6
case LMP_CTYPE_IPV6:
#endif
default:
hexdump=TRUE;
}
- break;
-
+ break;
+
case LMP_OBJ_CHANNEL_STATUS_REQ:
switch(lmp_obj_ctype) {
case LMP_CTYPE_IPV4:
case LMP_CTYPE_UNMD:
offset = 0;
while (offset < (lmp_obj_len-(int)sizeof(struct lmp_object_header)) ) {
- printf("\n\t Interface ID: %s (0x%08x)",
- ipaddr_string(obj_tptr+offset),
- EXTRACT_32BITS(obj_tptr+offset));
+ ND_PRINT((ndo, "\n\t Interface ID: %s (0x%08x)",
+ ipaddr_string(ndo, obj_tptr+offset),
+ EXTRACT_32BITS(obj_tptr+offset)));
offset+=4;
}
break;
-#ifdef INET6
+#ifdef INET6
case LMP_CTYPE_IPV6:
#endif
default:
hexdump=TRUE;
}
- break;
-
+ break;
+
case LMP_OBJ_ERROR_CODE:
switch(lmp_obj_ctype) {
case LMP_CTYPE_BEGIN_VERIFY_ERROR:
- printf("\n\t Error Code: %s",
+ ND_PRINT((ndo, "\n\t Error Code: %s",
bittok2str(lmp_obj_begin_verify_error_values,
"none",
- EXTRACT_32BITS(obj_tptr)));
+ EXTRACT_32BITS(obj_tptr))));
break;
-
+
case LMP_CTYPE_LINK_SUMMARY_ERROR:
- printf("\n\t Error Code: %s",
+ ND_PRINT((ndo, "\n\t Error Code: %s",
bittok2str(lmp_obj_link_summary_error_values,
"none",
- EXTRACT_32BITS(obj_tptr)));
+ EXTRACT_32BITS(obj_tptr))));
break;
default:
hexdump=TRUE;
}
- break;
+ break;
case LMP_OBJ_SERVICE_CONFIG:
switch (lmp_obj_ctype) {
case LMP_CTYPE_SERVICE_CONFIG_SP:
-
- printf("\n\t Flags: %s",
+
+ ND_PRINT((ndo, "\n\t Flags: %s",
bittok2str(lmp_obj_service_config_sp_flag_values,
- "none",
- EXTRACT_16BITS(obj_tptr)>>8));
+ "none",
+ EXTRACT_16BITS(obj_tptr)>>8)));
- printf("\n\t UNI Version: %u",
- EXTRACT_16BITS(obj_tptr) & 0x00FF);
+ ND_PRINT((ndo, "\n\t UNI Version: %u",
+ EXTRACT_16BITS(obj_tptr) & 0x00FF));
break;
-
+
case LMP_CTYPE_SERVICE_CONFIG_CPSA:
-
+
link_type = EXTRACT_16BITS(obj_tptr)>>8;
-
- printf("\n\t Link Type: %s (%u)",
+
+ ND_PRINT((ndo, "\n\t Link Type: %s (%u)",
tok2str(lmp_sd_service_config_cpsa_link_type_values,
"Unknown", link_type),
- link_type);
-
+ link_type));
+
if (link_type == LMP_SD_SERVICE_CONFIG_CPSA_LINK_TYPE_SDH) {
- printf("\n\t Signal Type: %s (%u)",
+ ND_PRINT((ndo, "\n\t Signal Type: %s (%u)",
tok2str(lmp_sd_service_config_cpsa_signal_type_sdh_values,
"Unknown",
EXTRACT_16BITS(obj_tptr) & 0x00FF),
- EXTRACT_16BITS(obj_tptr) & 0x00FF);
+ EXTRACT_16BITS(obj_tptr) & 0x00FF));
}
-
+
if (link_type == LMP_SD_SERVICE_CONFIG_CPSA_LINK_TYPE_SONET) {
- printf("\n\t Signal Type: %s (%u)",
+ ND_PRINT((ndo, "\n\t Signal Type: %s (%u)",
tok2str(lmp_sd_service_config_cpsa_signal_type_sonet_values,
"Unknown",
EXTRACT_16BITS(obj_tptr) & 0x00FF),
- EXTRACT_16BITS(obj_tptr) & 0x00FF);
+ EXTRACT_16BITS(obj_tptr) & 0x00FF));
}
-
- printf("\n\t Transparency: %s",
+
+ ND_PRINT((ndo, "\n\t Transparency: %s",
bittok2str(lmp_obj_service_config_cpsa_tp_flag_values,
"none",
- EXTRACT_16BITS(obj_tptr+2)>>8));
-
- printf("\n\t Contiguous Concatenation Types: %s",
+ EXTRACT_16BITS(obj_tptr+2)>>8)));
+
+ ND_PRINT((ndo, "\n\t Contiguous Concatenation Types: %s",
bittok2str(lmp_obj_service_config_cpsa_cct_flag_values,
"none",
- EXTRACT_16BITS(obj_tptr+2)>>8 & 0x00FF));
-
- printf("\n\t Minimum NCC: %u",
- EXTRACT_16BITS(obj_tptr+4));
-
- printf("\n\t Maximum NCC: %u",
- EXTRACT_16BITS(obj_tptr+6));
-
- printf("\n\t Minimum NVC:%u",
- EXTRACT_16BITS(obj_tptr+8));
-
- printf("\n\t Maximum NVC:%u",
- EXTRACT_16BITS(obj_tptr+10));
-
- printf("\n\t Local Interface ID: %s (0x%08x)",
- ipaddr_string(obj_tptr+12),
- EXTRACT_32BITS(obj_tptr+12));
-
+ EXTRACT_16BITS(obj_tptr+2)>>8 & 0x00FF)));
+
+ ND_PRINT((ndo, "\n\t Minimum NCC: %u",
+ EXTRACT_16BITS(obj_tptr+4)));
+
+ ND_PRINT((ndo, "\n\t Maximum NCC: %u",
+ EXTRACT_16BITS(obj_tptr+6)));
+
+ ND_PRINT((ndo, "\n\t Minimum NVC:%u",
+ EXTRACT_16BITS(obj_tptr+8)));
+
+ ND_PRINT((ndo, "\n\t Maximum NVC:%u",
+ EXTRACT_16BITS(obj_tptr+10)));
+
+ ND_PRINT((ndo, "\n\t Local Interface ID: %s (0x%08x)",
+ ipaddr_string(ndo, obj_tptr+12),
+ EXTRACT_32BITS(obj_tptr+12)));
+
break;
-
+
case LMP_CTYPE_SERVICE_CONFIG_TRANSPARENCY_TCM:
-
- printf("\n\t Transparency Flags: %s",
+
+ ND_PRINT((ndo, "\n\t Transparency Flags: %s",
bittok2str(
lmp_obj_service_config_nsa_transparency_flag_values,
"none",
- EXTRACT_32BITS(obj_tptr)));
+ EXTRACT_32BITS(obj_tptr))));
- printf("\n\t TCM Monitoring Flags: %s",
+ ND_PRINT((ndo, "\n\t TCM Monitoring Flags: %s",
bittok2str(
lmp_obj_service_config_nsa_tcm_flag_values,
"none",
- EXTRACT_16BITS(obj_tptr+6) & 0x00FF));
-
+ EXTRACT_16BITS(obj_tptr+6) & 0x00FF)));
+
break;
-
+
case LMP_CTYPE_SERVICE_CONFIG_NETWORK_DIVERSITY:
-
- printf("\n\t Diversity: Flags: %s",
+
+ ND_PRINT((ndo, "\n\t Diversity: Flags: %s",
bittok2str(
lmp_obj_service_config_nsa_network_diversity_flag_values,
"none",
- EXTRACT_16BITS(obj_tptr+2) & 0x00FF));
+ EXTRACT_16BITS(obj_tptr+2) & 0x00FF)));
break;
default:
@@ -865,13 +856,13 @@ lmp_print(register const u_char *pptr, register u_int len) {
break;
default:
- if (vflag <= 1)
- print_unknown_data(obj_tptr,"\n\t ",obj_tlen);
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo,obj_tptr,"\n\t ",obj_tlen);
break;
}
/* do we want to see an additionally hexdump ? */
- if (vflag > 1 || hexdump==TRUE)
- print_unknown_data(tptr+sizeof(struct lmp_object_header),"\n\t ",
+ if (ndo->ndo_vflag > 1 || hexdump==TRUE)
+ print_unknown_data(ndo,tptr+sizeof(struct lmp_object_header),"\n\t ",
lmp_obj_len-sizeof(struct lmp_object_header));
tptr+=lmp_obj_len;
@@ -879,5 +870,11 @@ lmp_print(register const u_char *pptr, register u_int len) {
}
return;
trunc:
- printf("\n\t\t packet exceeded snapshot");
+ ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
}
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
diff --git a/contrib/tcpdump/print-loopback.c b/contrib/tcpdump/print-loopback.c
new file mode 100644
index 000000000000..9a74ae611397
--- /dev/null
+++ b/contrib/tcpdump/print-loopback.c
@@ -0,0 +1,136 @@
+/*
+ * This module implements decoding of the Loopback Protocol, originally
+ * defined as the Configuration Testing Protocol. It is based on the following
+ * specification:
+ * http://www.mit.edu/people/jhawk/ctp.pdf
+ *
+ * Copyright (c) 2014 The TCPDUMP project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 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 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#define NETDISSECT_REWORKED
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tcpdump-stdinc.h>
+
+#include "interface.h"
+#include "extract.h"
+#include "ether.h"
+#include "addrtoname.h"
+
+static const char tstr[] = " [|loopback]";
+static const char cstr[] = " (corrupt)";
+
+#define LOOPBACK_REPLY 1
+#define LOOPBACK_FWDDATA 2
+
+static const struct tok fcode_str[] = {
+ { LOOPBACK_REPLY, "Reply" },
+ { LOOPBACK_FWDDATA, "Forward Data" },
+ { 0, NULL }
+};
+
+static void
+loopback_message_print(netdissect_options *ndo, const u_char *cp, const u_int len)
+{
+ const u_char *ep = cp + len;
+ uint16_t function;
+
+ if (len < 2)
+ goto corrupt;
+ /* function */
+ ND_TCHECK2(*cp, 2);
+ function = EXTRACT_LE_16BITS(cp);
+ cp += 2;
+ ND_PRINT((ndo, ", %s", tok2str(fcode_str, " invalid (%u)", function)));
+
+ switch (function) {
+ case LOOPBACK_REPLY:
+ if (len < 4)
+ goto corrupt;
+ /* receipt number */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, ", receipt number %u", EXTRACT_LE_16BITS(cp)));
+ cp += 2;
+ /* data */
+ ND_PRINT((ndo, ", data (%u octets)", len - 4));
+ ND_TCHECK2(*cp, len - 4);
+ break;
+ case LOOPBACK_FWDDATA:
+ if (len < 8)
+ goto corrupt;
+ /* forwarding address */
+ ND_TCHECK2(*cp, ETHER_ADDR_LEN);
+ ND_PRINT((ndo, ", forwarding address %s", etheraddr_string(ndo, cp)));
+ cp += ETHER_ADDR_LEN;
+ /* data */
+ ND_PRINT((ndo, ", data (%u octets)", len - 8));
+ ND_TCHECK2(*cp, len - 8);
+ break;
+ default:
+ ND_TCHECK2(*cp, len - 2);
+ break;
+ }
+ return;
+
+corrupt:
+ ND_PRINT((ndo, "%s", cstr));
+ ND_TCHECK2(*cp, ep - cp);
+ return;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+}
+
+void
+loopback_print(netdissect_options *ndo, const u_char *cp, const u_int len)
+{
+ const u_char *ep = cp + len;
+ uint16_t skipCount;
+
+ ND_PRINT((ndo, "Loopback"));
+ if (len < 2)
+ goto corrupt;
+ /* skipCount */
+ ND_TCHECK2(*cp, 2);
+ skipCount = EXTRACT_LE_16BITS(cp);
+ cp += 2;
+ ND_PRINT((ndo, ", skipCount %u", skipCount));
+ if (skipCount % 8)
+ ND_PRINT((ndo, " (bogus)"));
+ if (skipCount > len - 2)
+ goto corrupt;
+ loopback_message_print(ndo, cp + skipCount, len - 2 - skipCount);
+ return;
+
+corrupt:
+ ND_PRINT((ndo, "%s", cstr));
+ ND_TCHECK2(*cp, ep - cp);
+ return;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+}
+
diff --git a/contrib/tcpdump/print-lspping.c b/contrib/tcpdump/print-lspping.c
index 2ca57fb05cf9..3124ca0815eb 100644
--- a/contrib/tcpdump/print-lspping.c
+++ b/contrib/tcpdump/print-lspping.c
@@ -13,26 +13,17 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-lspping.c,v 1.20 2008-01-28 14:20:43 hannes Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
#include "interface.h"
#include "extract.h"
#include "addrtoname.h"
-#include "bgp.h"
#include "l2vpn.h"
#include "oui.h"
@@ -65,18 +56,18 @@ static const char rcsid[] _U_ =
*/
struct lspping_common_header {
- u_int8_t version[2];
- u_int8_t reserved[2];
- u_int8_t msg_type;
- u_int8_t reply_mode;
- u_int8_t return_code;
- u_int8_t return_subcode;
- u_int8_t sender_handle[4];
- u_int8_t seq_number[4];
- u_int8_t ts_sent_sec[4];
- u_int8_t ts_sent_usec[4];
- u_int8_t ts_rcvd_sec[4];
- u_int8_t ts_rcvd_usec[4];
+ uint8_t version[2];
+ uint8_t reserved[2];
+ uint8_t msg_type;
+ uint8_t reply_mode;
+ uint8_t return_code;
+ uint8_t return_subcode;
+ uint8_t sender_handle[4];
+ uint8_t seq_number[4];
+ uint8_t ts_sent_sec[4];
+ uint8_t ts_sent_usec[4];
+ uint8_t ts_rcvd_sec[4];
+ uint8_t ts_rcvd_usec[4];
};
#define LSPPING_VERSION 1
@@ -112,7 +103,7 @@ static const struct tok lspping_return_code_values[] = {
};
-/*
+/*
* LSPPING TLV header
* 0 1 2 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
@@ -128,8 +119,8 @@ static const struct tok lspping_return_code_values[] = {
*/
struct lspping_tlv_header {
- u_int8_t type[2];
- u_int8_t length[2];
+ uint8_t type[2];
+ uint8_t length[2];
};
#define LSPPING_TLV_TARGET_FEC_STACK 1
@@ -195,8 +186,8 @@ static const struct tok lspping_tlvtargetfec_subtlv_values[] = {
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t {
- u_int8_t prefix [4];
- u_int8_t prefix_len;
+ uint8_t prefix [4];
+ uint8_t prefix_len;
};
/*
@@ -212,8 +203,8 @@ struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t {
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t {
- u_int8_t prefix [16];
- u_int8_t prefix_len;
+ uint8_t prefix [16];
+ uint8_t prefix_len;
};
/*
@@ -227,9 +218,9 @@ struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t {
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t {
- u_int8_t sender_id [4];
- u_int8_t prefix [4];
- u_int8_t prefix_len;
+ uint8_t sender_id [4];
+ uint8_t prefix [4];
+ uint8_t prefix_len;
};
/*
@@ -249,9 +240,9 @@ struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t {
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t {
- u_int8_t sender_id [16];
- u_int8_t prefix [16];
- u_int8_t prefix_len;
+ uint8_t sender_id [16];
+ uint8_t prefix [16];
+ uint8_t prefix_len;
};
/*
@@ -270,13 +261,13 @@ struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t {
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t {
- u_int8_t tunnel_endpoint [4];
- u_int8_t res[2];
- u_int8_t tunnel_id[2];
- u_int8_t extended_tunnel_id[4];
- u_int8_t tunnel_sender [4];
- u_int8_t res2[2];
- u_int8_t lsp_id [2];
+ uint8_t tunnel_endpoint [4];
+ uint8_t res[2];
+ uint8_t tunnel_id[2];
+ uint8_t extended_tunnel_id[4];
+ uint8_t tunnel_sender [4];
+ uint8_t res2[2];
+ uint8_t lsp_id [2];
};
/*
@@ -304,13 +295,13 @@ struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t {
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t {
- u_int8_t tunnel_endpoint [16];
- u_int8_t res[2];
- u_int8_t tunnel_id[2];
- u_int8_t extended_tunnel_id[16];
- u_int8_t tunnel_sender [16];
- u_int8_t res2[2];
- u_int8_t lsp_id [2];
+ uint8_t tunnel_endpoint [16];
+ uint8_t res[2];
+ uint8_t tunnel_id[2];
+ uint8_t extended_tunnel_id[16];
+ uint8_t tunnel_sender [16];
+ uint8_t res2[2];
+ uint8_t lsp_id [2];
};
/*
@@ -326,9 +317,9 @@ struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t {
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t {
- u_int8_t rd [8];
- u_int8_t prefix [4];
- u_int8_t prefix_len;
+ uint8_t rd [8];
+ uint8_t prefix [4];
+ uint8_t prefix_len;
};
/*
@@ -347,9 +338,9 @@ struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t {
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t {
- u_int8_t rd [8];
- u_int8_t prefix [16];
- u_int8_t prefix_len;
+ uint8_t rd [8];
+ uint8_t prefix [16];
+ uint8_t prefix_len;
};
/*
@@ -366,10 +357,10 @@ struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t {
* 0 1 2 3
*/
struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t {
- u_int8_t rd [8];
- u_int8_t sender_ce_id [2];
- u_int8_t receiver_ce_id [2];
- u_int8_t encapsulation[2];
+ uint8_t rd [8];
+ uint8_t sender_ce_id [2];
+ uint8_t receiver_ce_id [2];
+ uint8_t encapsulation[2];
};
/*
@@ -383,9 +374,9 @@ struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t {
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_old_t {
- u_int8_t remote_pe_address [4];
- u_int8_t vc_id [4];
- u_int8_t encapsulation[2];
+ uint8_t remote_pe_address [4];
+ uint8_t vc_id [4];
+ uint8_t encapsulation[2];
};
/*
@@ -401,10 +392,10 @@ struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_old_t {
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_t {
- u_int8_t sender_pe_address [4];
- u_int8_t remote_pe_address [4];
- u_int8_t vc_id [4];
- u_int8_t encapsulation[2];
+ uint8_t sender_pe_address [4];
+ uint8_t remote_pe_address [4];
+ uint8_t vc_id [4];
+ uint8_t encapsulation[2];
};
/*
@@ -433,25 +424,25 @@ struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_t {
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
struct lspping_tlv_downstream_map_ipv4_t {
- u_int8_t mtu [2];
- u_int8_t address_type;
- u_int8_t res;
- u_int8_t downstream_ip[4];
- u_int8_t downstream_interface[4];
+ uint8_t mtu [2];
+ uint8_t address_type;
+ uint8_t res;
+ uint8_t downstream_ip[4];
+ uint8_t downstream_interface[4];
};
struct lspping_tlv_downstream_map_ipv6_t {
- u_int8_t mtu [2];
- u_int8_t address_type;
- u_int8_t res;
- u_int8_t downstream_ip[16];
- u_int8_t downstream_interface[16];
+ uint8_t mtu [2];
+ uint8_t address_type;
+ uint8_t res;
+ uint8_t downstream_ip[16];
+ uint8_t downstream_interface[16];
};
struct lspping_tlv_downstream_map_info_t {
- u_int8_t hash_key_type;
- u_int8_t depth_limit;
- u_int8_t multipath_length [2];
+ uint8_t hash_key_type;
+ uint8_t depth_limit;
+ uint8_t multipath_length [2];
};
#define LSPPING_AFI_IPV4 1
@@ -466,7 +457,8 @@ static const struct tok lspping_tlv_downstream_addr_values[] = {
};
void
-lspping_print(register const u_char *pptr, register u_int len) {
+lspping_print(netdissect_options *ndo,
+ register const u_char *pptr, register u_int len) {
const struct lspping_common_header *lspping_com_header;
const struct lspping_tlv_header *lspping_tlv_header;
@@ -475,7 +467,7 @@ lspping_print(register const u_char *pptr, register u_int len) {
int tlen,lspping_tlv_len,lspping_tlv_type,tlv_tlen;
int tlv_hexdump,subtlv_hexdump;
int lspping_subtlv_len,lspping_subtlv_type;
- struct timeval timestamp;
+ struct timeval timestamp;
union {
const struct lspping_tlv_downstream_map_ipv4_t *lspping_tlv_downstream_map_ipv4;
@@ -499,24 +491,24 @@ lspping_print(register const u_char *pptr, register u_int len) {
tptr=pptr;
lspping_com_header = (const struct lspping_common_header *)pptr;
- TCHECK(*lspping_com_header);
+ ND_TCHECK(*lspping_com_header);
/*
* Sanity checking of the header.
*/
if (EXTRACT_16BITS(&lspping_com_header->version[0]) != LSPPING_VERSION) {
- printf("LSP-PING version %u packet not supported",
- EXTRACT_16BITS(&lspping_com_header->version[0]));
+ ND_PRINT((ndo, "LSP-PING version %u packet not supported",
+ EXTRACT_16BITS(&lspping_com_header->version[0])));
return;
}
/* in non-verbose mode just lets print the basic Message Type*/
- if (vflag < 1) {
- printf("LSP-PINGv%u, %s, seq %u, length: %u",
+ if (ndo->ndo_vflag < 1) {
+ ND_PRINT((ndo, "LSP-PINGv%u, %s, seq %u, length: %u",
EXTRACT_16BITS(&lspping_com_header->version[0]),
tok2str(lspping_msg_type_values, "unknown (%u)",lspping_com_header->msg_type),
EXTRACT_32BITS(lspping_com_header->seq_number),
- len);
+ len));
return;
}
@@ -524,13 +516,13 @@ lspping_print(register const u_char *pptr, register u_int len) {
tlen=len;
- printf("\n\tLSP-PINGv%u, msg-type: %s (%u), length: %u\n\t reply-mode: %s (%u)",
+ ND_PRINT((ndo, "\n\tLSP-PINGv%u, msg-type: %s (%u), length: %u\n\t reply-mode: %s (%u)",
EXTRACT_16BITS(&lspping_com_header->version[0]),
tok2str(lspping_msg_type_values, "unknown",lspping_com_header->msg_type),
lspping_com_header->msg_type,
len,
tok2str(lspping_reply_mode_values, "unknown",lspping_com_header->reply_mode),
- lspping_com_header->reply_mode);
+ lspping_com_header->reply_mode));
/*
* the following return codes require that the subcode is attached
@@ -542,33 +534,33 @@ lspping_print(register const u_char *pptr, register u_int len) {
lspping_com_header->return_code == 10 ||
lspping_com_header->return_code == 11 ||
lspping_com_header->return_code == 12 )
- printf("\n\t Return Code: %s %u (%u)\n\t Return Subcode: (%u)",
+ ND_PRINT((ndo, "\n\t Return Code: %s %u (%u)\n\t Return Subcode: (%u)",
tok2str(lspping_return_code_values, "unknown",lspping_com_header->return_code),
- lspping_com_header->return_subcode,
+ lspping_com_header->return_subcode,
lspping_com_header->return_code,
- lspping_com_header->return_subcode);
+ lspping_com_header->return_subcode));
else
- printf("\n\t Return Code: %s (%u)\n\t Return Subcode: (%u)",
- tok2str(lspping_return_code_values, "unknown",lspping_com_header->return_code),
+ ND_PRINT((ndo, "\n\t Return Code: %s (%u)\n\t Return Subcode: (%u)",
+ tok2str(lspping_return_code_values, "unknown",lspping_com_header->return_code),
lspping_com_header->return_code,
- lspping_com_header->return_subcode);
-
- printf("\n\t Sender Handle: 0x%08x, Sequence: %u",
+ lspping_com_header->return_subcode));
+
+ ND_PRINT((ndo, "\n\t Sender Handle: 0x%08x, Sequence: %u",
EXTRACT_32BITS(lspping_com_header->sender_handle),
- EXTRACT_32BITS(lspping_com_header->seq_number));
+ EXTRACT_32BITS(lspping_com_header->seq_number)));
timestamp.tv_sec=EXTRACT_32BITS(lspping_com_header->ts_sent_sec);
- timestamp.tv_usec=EXTRACT_32BITS(lspping_com_header->ts_sent_usec);
- printf("\n\t Sender Timestamp: ");
- ts_print(&timestamp);
+ timestamp.tv_usec=EXTRACT_32BITS(lspping_com_header->ts_sent_usec);
+ ND_PRINT((ndo, "\n\t Sender Timestamp: "));
+ ts_print(ndo, &timestamp);
timestamp.tv_sec=EXTRACT_32BITS(lspping_com_header->ts_rcvd_sec);
- timestamp.tv_usec=EXTRACT_32BITS(lspping_com_header->ts_rcvd_usec);
- printf("Receiver Timestamp: ");
+ timestamp.tv_usec=EXTRACT_32BITS(lspping_com_header->ts_rcvd_usec);
+ ND_PRINT((ndo, "Receiver Timestamp: "));
if ((timestamp.tv_sec != 0) && (timestamp.tv_usec != 0))
- ts_print(&timestamp);
+ ts_print(ndo, &timestamp);
else
- printf("no timestamp");
+ ND_PRINT((ndo, "no timestamp"));
tptr+=sizeof(const struct lspping_common_header);
tlen-=sizeof(const struct lspping_common_header);
@@ -576,8 +568,7 @@ lspping_print(register const u_char *pptr, register u_int len) {
while(tlen>(int)sizeof(struct lspping_tlv_header)) {
/* did we capture enough for fully decoding the tlv header ? */
- if (!TTEST2(*tptr, sizeof(struct lspping_tlv_header)))
- goto trunc;
+ ND_TCHECK2(*tptr, sizeof(struct lspping_tlv_header));
lspping_tlv_header = (const struct lspping_tlv_header *)tptr;
lspping_tlv_type=EXTRACT_16BITS(lspping_tlv_header->type);
@@ -588,23 +579,22 @@ lspping_print(register const u_char *pptr, register u_int len) {
return;
if(lspping_tlv_len < 4) {
- printf("\n\t ERROR: TLV %u bogus size %u",lspping_tlv_type,lspping_tlv_len);
+ ND_PRINT((ndo, "\n\t ERROR: TLV %u bogus size %u",lspping_tlv_type,lspping_tlv_len));
return;
}
- printf("\n\t %s TLV (%u), length: %u",
+ ND_PRINT((ndo, "\n\t %s TLV (%u), length: %u",
tok2str(lspping_tlv_values,
"Unknown",
lspping_tlv_type),
lspping_tlv_type,
- lspping_tlv_len);
+ lspping_tlv_len));
tlv_tptr=tptr+sizeof(struct lspping_tlv_header);
tlv_tlen=lspping_tlv_len; /* header not included -> no adjustment */
/* did we capture enough for fully decoding the tlv ? */
- if (!TTEST2(*tptr, lspping_tlv_len))
- goto trunc;
+ ND_TCHECK2(*tptr, lspping_tlv_len);
tlv_hexdump=FALSE;
switch(lspping_tlv_type) {
@@ -612,154 +602,153 @@ lspping_print(register const u_char *pptr, register u_int len) {
while(tlv_tlen>(int)sizeof(struct lspping_tlv_header)) {
/* did we capture enough for fully decoding the subtlv header ? */
- if (!TTEST2(*tptr, sizeof(struct lspping_tlv_header)))
- goto trunc;
+ ND_TCHECK2(*tptr, sizeof(struct lspping_tlv_header));
subtlv_hexdump=FALSE;
lspping_subtlv_header = (const struct lspping_tlv_header *)tlv_tptr;
lspping_subtlv_type=EXTRACT_16BITS(lspping_subtlv_header->type);
lspping_subtlv_len=EXTRACT_16BITS(lspping_subtlv_header->length);
subtlv_tptr=tlv_tptr+sizeof(struct lspping_tlv_header);
-
+
if (lspping_subtlv_len == 0)
break;
- printf("\n\t %s subTLV (%u), length: %u",
+ ND_PRINT((ndo, "\n\t %s subTLV (%u), length: %u",
tok2str(lspping_tlvtargetfec_subtlv_values,
"Unknown",
lspping_subtlv_type),
lspping_subtlv_type,
- lspping_subtlv_len);
+ lspping_subtlv_len));
switch(lspping_subtlv_type) {
case LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4:
subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4 = \
(const struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t *)subtlv_tptr;
- printf("\n\t %s/%u",
- ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4->prefix),
- subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4->prefix_len);
+ ND_PRINT((ndo, "\n\t %s/%u",
+ ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4->prefix),
+ subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4->prefix_len));
break;
#ifdef INET6
case LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6:
subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6 = \
(const struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t *)subtlv_tptr;
- printf("\n\t %s/%u",
- ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6->prefix),
- subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6->prefix_len);
+ ND_PRINT((ndo, "\n\t %s/%u",
+ ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6->prefix),
+ subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6->prefix_len));
break;
#endif
case LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4:
subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4 = \
(const struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t *)subtlv_tptr;
- printf("\n\t %s/%u, sender-id %s",
- ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->prefix),
+ ND_PRINT((ndo, "\n\t %s/%u, sender-id %s",
+ ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->prefix),
subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->prefix_len,
- ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->sender_id));
+ ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->sender_id)));
break;
#ifdef INET6
case LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6:
subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6 = \
(const struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t *)subtlv_tptr;
- printf("\n\t %s/%u, sender-id %s",
- ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->prefix),
+ ND_PRINT((ndo, "\n\t %s/%u, sender-id %s",
+ ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->prefix),
subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->prefix_len,
- ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->sender_id));
+ ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->sender_id)));
break;
#endif
case LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4:
subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4 = \
(const struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t *)subtlv_tptr;
- printf("\n\t tunnel end-point %s, tunnel sender %s, lsp-id 0x%04x" \
+ ND_PRINT((ndo, "\n\t tunnel end-point %s, tunnel sender %s, lsp-id 0x%04x" \
"\n\t tunnel-id 0x%04x, extended tunnel-id %s",
- ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_endpoint),
- ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_sender),
+ ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_endpoint),
+ ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_sender),
EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->lsp_id),
EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_id),
- ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->extended_tunnel_id));
+ ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->extended_tunnel_id)));
break;
#ifdef INET6
case LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6:
subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6 = \
(const struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t *)subtlv_tptr;
- printf("\n\t tunnel end-point %s, tunnel sender %s, lsp-id 0x%04x" \
+ ND_PRINT((ndo, "\n\t tunnel end-point %s, tunnel sender %s, lsp-id 0x%04x" \
"\n\t tunnel-id 0x%04x, extended tunnel-id %s",
- ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_endpoint),
- ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_sender),
+ ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_endpoint),
+ ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_sender),
EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->lsp_id),
EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_id),
- ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->extended_tunnel_id));
+ ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->extended_tunnel_id)));
break;
#endif
case LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4:
subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4 = \
(const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t *)subtlv_tptr;
- printf("\n\t RD: %s, %s/%u",
- bgp_vpn_rd_print(subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->rd),
- ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->prefix),
- subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->prefix_len);
+ ND_PRINT((ndo, "\n\t RD: %s, %s/%u",
+ bgp_vpn_rd_print(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->rd),
+ ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->prefix),
+ subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->prefix_len));
break;
#ifdef INET6
case LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6:
subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6 = \
(const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t *)subtlv_tptr;
- printf("\n\t RD: %s, %s/%u",
- bgp_vpn_rd_print(subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->rd),
- ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->prefix),
- subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->prefix_len);
+ ND_PRINT((ndo, "\n\t RD: %s, %s/%u",
+ bgp_vpn_rd_print(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->rd),
+ ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->prefix),
+ subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->prefix_len));
break;
#endif
case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT:
subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt = \
(const struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t *)subtlv_tptr;
- printf("\n\t RD: %s, Sender CE-ID: %u, Receiver CE-ID: %u" \
+ ND_PRINT((ndo, "\n\t RD: %s, Sender CE-ID: %u, Receiver CE-ID: %u" \
"\n\t Encapsulation Type: %s (%u)",
- bgp_vpn_rd_print(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->rd),
+ bgp_vpn_rd_print(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->rd),
EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->sender_ce_id),
EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->receiver_ce_id),
tok2str(l2vpn_encaps_values,
"unknown",
EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->encapsulation)),
- EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->encapsulation));
-
+ EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->encapsulation)));
+
break;
/* the old L2VPN VCID subTLV does not have support for the sender field */
case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID_OLD:
subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old = \
(const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_old_t *)subtlv_tptr;
- printf("\n\t Remote PE: %s" \
+ ND_PRINT((ndo, "\n\t Remote PE: %s" \
"\n\t VC-ID: 0x%08x, Encapsulation Type: %s (%u)",
- ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->remote_pe_address),
+ ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->remote_pe_address),
EXTRACT_32BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->vc_id),
tok2str(l2vpn_encaps_values,
"unknown",
EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->encapsulation)),
- EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->encapsulation));
-
+ EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->encapsulation)));
+
break;
case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID:
subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid = \
(const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_t *)subtlv_tptr;
- printf("\n\t Sender PE: %s, Remote PE: %s" \
+ ND_PRINT((ndo, "\n\t Sender PE: %s, Remote PE: %s" \
"\n\t VC-ID: 0x%08x, Encapsulation Type: %s (%u)",
- ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->sender_pe_address),
- ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->remote_pe_address),
+ ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->sender_pe_address),
+ ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->remote_pe_address),
EXTRACT_32BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->vc_id),
tok2str(l2vpn_encaps_values,
"unknown",
EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->encapsulation)),
- EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->encapsulation));
-
+ EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->encapsulation)));
+
break;
default:
@@ -767,8 +756,8 @@ lspping_print(register const u_char *pptr, register u_int len) {
break;
}
/* do we want to see an additionally subtlv hexdump ? */
- if (vflag > 1 || subtlv_hexdump==TRUE)
- print_unknown_data(tlv_tptr+sizeof(struct lspping_tlv_header), \
+ if (ndo->ndo_vflag > 1 || subtlv_hexdump==TRUE)
+ print_unknown_data(ndo, tlv_tptr+sizeof(struct lspping_tlv_header), \
"\n\t ",
lspping_subtlv_len);
@@ -786,38 +775,38 @@ lspping_print(register const u_char *pptr, register u_int len) {
(const struct lspping_tlv_downstream_map_ipv4_t *)tlv_tptr;
tlv_ptr.lspping_tlv_downstream_map_ipv6= \
(const struct lspping_tlv_downstream_map_ipv6_t *)tlv_tptr;
- printf("\n\t MTU: %u, Address-Type: %s (%u)",
+ ND_PRINT((ndo, "\n\t MTU: %u, Address-Type: %s (%u)",
EXTRACT_16BITS(tlv_ptr.lspping_tlv_downstream_map_ipv4->mtu),
tok2str(lspping_tlv_downstream_addr_values,
"unknown",
tlv_ptr.lspping_tlv_downstream_map_ipv4->address_type),
- tlv_ptr.lspping_tlv_downstream_map_ipv4->address_type);
+ tlv_ptr.lspping_tlv_downstream_map_ipv4->address_type));
switch(tlv_ptr.lspping_tlv_downstream_map_ipv4->address_type) {
case LSPPING_AFI_IPV4:
- printf("\n\t Downstream IP: %s" \
+ ND_PRINT((ndo, "\n\t Downstream IP: %s" \
"\n\t Downstream Interface IP: %s",
- ipaddr_string(tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_ip),
- ipaddr_string(tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_interface));
+ ipaddr_string(ndo, tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_ip),
+ ipaddr_string(ndo, tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_interface)));
tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_ipv4_t);
tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_ipv4_t);
break;
#ifdef INET6
case LSPPING_AFI_IPV6:
- printf("\n\t Downstream IP: %s" \
+ ND_PRINT((ndo, "\n\t Downstream IP: %s" \
"\n\t Downstream Interface IP: %s",
- ip6addr_string(tlv_ptr.lspping_tlv_downstream_map_ipv6->downstream_ip),
- ip6addr_string(tlv_ptr.lspping_tlv_downstream_map_ipv6->downstream_interface));
+ ip6addr_string(ndo, tlv_ptr.lspping_tlv_downstream_map_ipv6->downstream_ip),
+ ip6addr_string(ndo, tlv_ptr.lspping_tlv_downstream_map_ipv6->downstream_interface)));
tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_ipv6_t);
tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_ipv6_t);
break;
#endif
case LSPPING_AFI_UNMB:
- printf("\n\t Downstream IP: %s" \
+ ND_PRINT((ndo, "\n\t Downstream IP: %s" \
"\n\t Downstream Interface Index: 0x%08x",
- ipaddr_string(tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_ip),
- EXTRACT_32BITS(tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_interface));
+ ipaddr_string(ndo, tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_ip),
+ EXTRACT_32BITS(tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_interface)));
tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_ipv4_t);
tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_ipv4_t);
break;
@@ -829,7 +818,7 @@ lspping_print(register const u_char *pptr, register u_int len) {
tlv_ptr.lspping_tlv_downstream_map_info= \
(const struct lspping_tlv_downstream_map_info_t *)tlv_tptr;
-
+
/* FIXME add hash-key type, depth limit, multipath processing */
@@ -845,21 +834,19 @@ lspping_print(register const u_char *pptr, register u_int len) {
case LSPPING_TLV_BFD_DISCRIMINATOR:
tptr += sizeof(struct lspping_tlv_header);
- if (!TTEST2(*tptr, LSPPING_TLV_BFD_DISCRIMINATOR_LEN))
- goto trunc;
- printf("\n\t BFD Discriminator 0x%08x", EXTRACT_32BITS(tptr));
+ ND_TCHECK2(*tptr, LSPPING_TLV_BFD_DISCRIMINATOR_LEN);
+ ND_PRINT((ndo, "\n\t BFD Discriminator 0x%08x", EXTRACT_32BITS(tptr)));
break;
case LSPPING_TLV_VENDOR_ENTERPRISE:
{
- u_int32_t vendor_id;
+ uint32_t vendor_id;
- if (!TTEST2(*tptr, LSPPING_TLV_VENDOR_ENTERPRISE_LEN))
- goto trunc;
+ ND_TCHECK2(*tptr, LSPPING_TLV_VENDOR_ENTERPRISE_LEN);
vendor_id = EXTRACT_32BITS(tlv_tptr);
- printf("\n\t Vendor: %s (0x%04x)",
+ ND_PRINT((ndo, "\n\t Vendor: %s (0x%04x)",
tok2str(smi_values, "Unknown", vendor_id),
- vendor_id);
+ vendor_id));
}
break;
@@ -870,15 +857,15 @@ lspping_print(register const u_char *pptr, register u_int len) {
case LSPPING_TLV_PAD:
case LSPPING_TLV_ERROR_CODE:
case LSPPING_TLV_VENDOR_PRIVATE:
-
+
default:
- if (vflag <= 1)
- print_unknown_data(tlv_tptr,"\n\t ",tlv_tlen);
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo, tlv_tptr, "\n\t ", tlv_tlen);
break;
}
/* do we want to see an additionally tlv hexdump ? */
- if (vflag > 1 || tlv_hexdump==TRUE)
- print_unknown_data(tptr+sizeof(struct lspping_tlv_header),"\n\t ",
+ if (ndo->ndo_vflag > 1 || tlv_hexdump==TRUE)
+ print_unknown_data(ndo, tptr+sizeof(struct lspping_tlv_header), "\n\t ",
lspping_tlv_len);
@@ -892,5 +879,11 @@ lspping_print(register const u_char *pptr, register u_int len) {
}
return;
trunc:
- printf("\n\t\t packet exceeded snapshot");
+ ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
}
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
diff --git a/contrib/tcpdump/print-lwapp.c b/contrib/tcpdump/print-lwapp.c
index 154876f54a8e..6e02cd481c0e 100644
--- a/contrib/tcpdump/print-lwapp.c
+++ b/contrib/tcpdump/print-lwapp.c
@@ -17,26 +17,18 @@
* Original code by Carles Kishimoto <carles.kishimoto@gmail.com>
*/
-#ifndef lint
-static const char rcsid[] _U_ =
-"@(#) $Header: /tcpdump/master/tcpdump/print-lwapp.c,v 1.1 2007-07-24 16:07:30 hannes Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
#include "interface.h"
#include "extract.h"
#include "addrtoname.h"
-/*
+/*
* LWAPP transport (common) header
* 0 1 2 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
@@ -49,10 +41,10 @@ static const char rcsid[] _U_ =
*/
struct lwapp_transport_header {
- u_int8_t version;
- u_int8_t frag_id;
- u_int8_t length[2];
- u_int16_t status;
+ uint8_t version;
+ uint8_t frag_id;
+ uint8_t length[2];
+ uint16_t status;
};
/*
@@ -69,16 +61,16 @@ struct lwapp_transport_header {
*/
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];
+ uint8_t msg_type;
+ uint8_t seq_num;
+ uint8_t len[2];
+ uint8_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)
+#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"},
@@ -154,9 +146,9 @@ static const struct tok lwapp_msg_type_values[] = {
{ 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
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -164,12 +156,13 @@ static const struct tok lwapp_msg_type_values[] = {
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
struct lwapp_message_header {
- u_int8_t type;
- u_int8_t length[2];
+ uint8_t type;
+ uint8_t length[2];
};
void
-lwapp_control_print(const u_char *pptr, u_int len, int has_ap_ident) {
+lwapp_control_print(netdissect_options *ndo,
+ 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;
@@ -181,47 +174,45 @@ lwapp_control_print(const u_char *pptr, u_int len, int has_ap_ident) {
if (has_ap_ident) {
/* check if enough bytes for AP identity */
- if (!TTEST2(*tptr, 6))
- goto trunc;
+ ND_TCHECK2(*tptr, 6);
lwapp_trans_header = (const struct lwapp_transport_header *)(pptr+6);
} else {
lwapp_trans_header = (const struct lwapp_transport_header *)pptr;
}
- TCHECK(*lwapp_trans_header);
+ ND_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));
+ ND_PRINT((ndo, "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",
+ if (ndo->ndo_vflag < 1) {
+ ND_PRINT((ndo, "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);
+ 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",
+ ND_PRINT((ndo, "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);
+ tlen));
if (has_ap_ident) {
- printf("\n\tAP identity: %s",
- etheraddr_string(tptr));
+ ND_PRINT((ndo, "\n\tAP identity: %s", etheraddr_string(ndo, tptr)));
tptr+=sizeof(const struct lwapp_transport_header)+6;
} else {
tptr+=sizeof(const struct lwapp_transport_header);
@@ -230,23 +221,21 @@ lwapp_control_print(const u_char *pptr, u_int len, int has_ap_ident) {
while(tlen>0) {
/* did we capture enough for fully decoding the object header ? */
- if (!TTEST2(*tptr, sizeof(struct lwapp_control_header)))
- goto trunc;
+ ND_TCHECK2(*tptr, sizeof(struct lwapp_control_header));
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",
+ /* print message header */
+ ND_PRINT((ndo, "\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));
+ EXTRACT_32BITS(lwapp_control_header->session_id)));
/* did we capture enough for fully decoding the message */
- if (!TTEST2(*tptr, msg_tlen))
- goto trunc;
+ ND_TCHECK2(*tptr, msg_tlen);
/* XXX - Decode sub messages for each message */
switch(lwapp_control_header->msg_type) {
@@ -291,11 +280,12 @@ lwapp_control_print(const u_char *pptr, u_int len, int has_ap_ident) {
return;
trunc:
- printf("\n\t\t packet exceeded snapshot");
+ ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
}
void
-lwapp_data_print(const u_char *pptr, u_int len) {
+lwapp_data_print(netdissect_options *ndo,
+ const u_char *pptr, u_int len) {
const struct lwapp_transport_header *lwapp_trans_header;
const u_char *tptr;
@@ -304,51 +294,50 @@ lwapp_data_print(const u_char *pptr, u_int len) {
tptr=pptr;
/* check if enough bytes for AP identity */
- if (!TTEST2(*tptr, 6))
- goto trunc;
+ ND_TCHECK2(*tptr, 6);
lwapp_trans_header = (const struct lwapp_transport_header *)pptr;
- TCHECK(*lwapp_trans_header);
+ ND_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));
+ ND_PRINT((ndo, "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",
+ if (ndo->ndo_vflag < 1) {
+ ND_PRINT((ndo, "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);
+ 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",
+ ND_PRINT((ndo, "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);
+ 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);
+ print_unknown_data(ndo, tptr, "\n\t", tlen);
return;
trunc:
- printf("\n\t\t packet exceeded snapshot");
+ ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
}
/*
diff --git a/contrib/tcpdump/print-lwres.c b/contrib/tcpdump/print-lwres.c
index aad4eee3843b..d78c9a906859 100644
--- a/contrib/tcpdump/print-lwres.c
+++ b/contrib/tcpdump/print-lwres.c
@@ -27,11 +27,7 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-lwres.c,v 1.13 2004-03-24 01:54:29 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -48,9 +44,9 @@ static const char rcsid[] _U_ =
#include "extract.h" /* must come after interface.h */
/* BIND9 lib/lwres/include/lwres */
-typedef u_int32_t lwres_uint32_t;
-typedef u_int16_t lwres_uint16_t;
-typedef u_int8_t lwres_uint8_t;
+typedef uint32_t lwres_uint32_t;
+typedef uint16_t lwres_uint16_t;
+typedef uint8_t lwres_uint8_t;
struct lwres_lwpacket {
lwres_uint32_t length;
@@ -175,7 +171,7 @@ typedef struct {
#define LWRES_MAX_ALIASES 16 /* max # of aliases */
#define LWRES_MAX_ADDRS 64 /* max # of addrs */
-struct tok opcode[] = {
+static const struct tok opcode[] = {
{ LWRES_OPCODE_NOOP, "noop", },
{ LWRES_OPCODE_GETADDRSBYNAME, "getaddrsbyname", },
{ LWRES_OPCODE_GETNAMEBYADDR, "getnamebyaddr", },
@@ -184,28 +180,24 @@ struct tok opcode[] = {
};
/* print-domain.c */
-extern struct tok ns_type2str[];
-extern struct tok ns_class2str[];
-
-static int lwres_printname(size_t, const char *);
-static int lwres_printnamelen(const char *);
-static int lwres_printbinlen(const char *);
-static int lwres_printaddr(lwres_addr_t *);
+extern const struct tok ns_type2str[];
+extern const struct tok ns_class2str[];
static int
-lwres_printname(size_t l, const char *p0)
+lwres_printname(netdissect_options *ndo,
+ size_t l, const char *p0)
{
const char *p;
size_t i;
p = p0;
/* + 1 for terminating \0 */
- if (p + l + 1 > (const char *)snapend)
+ if (p + l + 1 > (const char *)ndo->ndo_snapend)
goto trunc;
- printf(" ");
+ ND_PRINT((ndo, " "));
for (i = 0; i < l; i++)
- safeputchar(*p++);
+ safeputchar(ndo, *p++);
p++; /* skip terminating \0 */
return p - p0;
@@ -215,15 +207,16 @@ lwres_printname(size_t l, const char *p0)
}
static int
-lwres_printnamelen(const char *p)
+lwres_printnamelen(netdissect_options *ndo,
+ const char *p)
{
- u_int16_t l;
+ uint16_t l;
int advance;
- if (p + 2 > (const char *)snapend)
+ if (p + 2 > (const char *)ndo->ndo_snapend)
goto trunc;
l = EXTRACT_16BITS(p);
- advance = lwres_printname(l, p + 2);
+ advance = lwres_printname(ndo, l, p + 2);
if (advance < 0)
goto trunc;
return 2 + advance;
@@ -233,21 +226,22 @@ lwres_printnamelen(const char *p)
}
static int
-lwres_printbinlen(const char *p0)
+lwres_printbinlen(netdissect_options *ndo,
+ const char *p0)
{
const char *p;
- u_int16_t l;
+ uint16_t l;
int i;
p = p0;
- if (p + 2 > (const char *)snapend)
+ if (p + 2 > (const char *)ndo->ndo_snapend)
goto trunc;
l = EXTRACT_16BITS(p);
- if (p + 2 + l > (const char *)snapend)
+ if (p + 2 + l > (const char *)ndo->ndo_snapend)
goto trunc;
p += 2;
for (i = 0; i < l; i++)
- printf("%02x", *p++);
+ ND_PRINT((ndo, "%02x", *p++));
return p - p0;
trunc:
@@ -255,37 +249,38 @@ lwres_printbinlen(const char *p0)
}
static int
-lwres_printaddr(lwres_addr_t *ap)
+lwres_printaddr(netdissect_options *ndo,
+ lwres_addr_t *ap)
{
- u_int16_t l;
+ uint16_t l;
const char *p;
int i;
- TCHECK(ap->length);
+ ND_TCHECK(ap->length);
l = EXTRACT_16BITS(&ap->length);
/* XXX ap points to packed struct */
p = (const char *)&ap->length + sizeof(ap->length);
- TCHECK2(*p, l);
+ ND_TCHECK2(*p, l);
switch (EXTRACT_32BITS(&ap->family)) {
case 1: /* IPv4 */
if (l < 4)
return -1;
- printf(" %s", ipaddr_string(p));
+ ND_PRINT((ndo, " %s", ipaddr_string(ndo, p)));
p += sizeof(struct in_addr);
break;
#ifdef INET6
case 2: /* IPv6 */
if (l < 16)
return -1;
- printf(" %s", ip6addr_string(p));
+ ND_PRINT((ndo, " %s", ip6addr_string(ndo, p)));
p += sizeof(struct in6_addr);
break;
#endif
default:
- printf(" %u/", EXTRACT_32BITS(&ap->family));
+ ND_PRINT((ndo, " %u/", EXTRACT_32BITS(&ap->family)));
for (i = 0; i < l; i++)
- printf("%02x", *p++);
+ ND_PRINT((ndo, "%02x", *p++));
}
return p - (const char *)ap;
@@ -295,22 +290,23 @@ lwres_printaddr(lwres_addr_t *ap)
}
void
-lwres_print(register const u_char *bp, u_int length)
+lwres_print(netdissect_options *ndo,
+ register const u_char *bp, u_int length)
{
const struct lwres_lwpacket *np;
- u_int32_t v;
+ uint32_t v;
const char *s;
int response;
int advance;
int unsupported = 0;
np = (const struct lwres_lwpacket *)bp;
- TCHECK(np->authlength);
+ ND_TCHECK(np->authlength);
- printf(" lwres");
+ ND_PRINT((ndo, " lwres"));
v = EXTRACT_16BITS(&np->version);
- if (vflag || v != LWRES_LWPACKETVERSION_0)
- printf(" v%u", v);
+ if (ndo->ndo_vflag || v != LWRES_LWPACKETVERSION_0)
+ ND_PRINT((ndo, " v%u", v));
if (v != LWRES_LWPACKETVERSION_0) {
s = (const char *)np + EXTRACT_32BITS(&np->length);
goto tail;
@@ -321,25 +317,25 @@ lwres_print(register const u_char *bp, u_int length)
/* opcode and pktflags */
v = EXTRACT_32BITS(&np->opcode);
s = tok2str(opcode, "#0x%x", v);
- printf(" %s%s", s, response ? "" : "?");
+ ND_PRINT((ndo, " %s%s", s, response ? "" : "?"));
/* pktflags */
v = EXTRACT_16BITS(&np->pktflags);
if (v & ~LWRES_LWPACKETFLAG_RESPONSE)
- printf("[0x%x]", v);
+ ND_PRINT((ndo, "[0x%x]", v));
- if (vflag > 1) {
- printf(" ("); /*)*/
- printf("serial:0x%x", EXTRACT_32BITS(&np->serial));
- printf(" result:0x%x", EXTRACT_32BITS(&np->result));
- printf(" recvlen:%u", EXTRACT_32BITS(&np->recvlength));
+ if (ndo->ndo_vflag > 1) {
+ ND_PRINT((ndo, " (")); /*)*/
+ ND_PRINT((ndo, "serial:0x%x", EXTRACT_32BITS(&np->serial)));
+ ND_PRINT((ndo, " result:0x%x", EXTRACT_32BITS(&np->result)));
+ ND_PRINT((ndo, " recvlen:%u", EXTRACT_32BITS(&np->recvlength)));
/* BIND910: not used */
- if (vflag > 2) {
- printf(" authtype:0x%x", EXTRACT_16BITS(&np->authtype));
- printf(" authlen:%u", EXTRACT_16BITS(&np->authlength));
+ if (ndo->ndo_vflag > 2) {
+ ND_PRINT((ndo, " authtype:0x%x", EXTRACT_16BITS(&np->authtype)));
+ ND_PRINT((ndo, " authlen:%u", EXTRACT_16BITS(&np->authlength)));
}
/*(*/
- printf(")");
+ ND_PRINT((ndo, ")"));
}
/* per-opcode content */
@@ -350,7 +346,7 @@ lwres_print(register const u_char *bp, u_int length)
lwres_gabnrequest_t *gabn;
lwres_gnbarequest_t *gnba;
lwres_grbnrequest_t *grbn;
- u_int32_t l;
+ uint32_t l;
gabn = NULL;
gnba = NULL;
@@ -361,51 +357,51 @@ lwres_print(register const u_char *bp, u_int length)
break;
case LWRES_OPCODE_GETADDRSBYNAME:
gabn = (lwres_gabnrequest_t *)(np + 1);
- TCHECK(gabn->namelen);
+ ND_TCHECK(gabn->namelen);
/* XXX gabn points to packed struct */
s = (const char *)&gabn->namelen +
sizeof(gabn->namelen);
l = EXTRACT_16BITS(&gabn->namelen);
/* BIND910: not used */
- if (vflag > 2) {
- printf(" flags:0x%x",
- EXTRACT_32BITS(&gabn->flags));
+ if (ndo->ndo_vflag > 2) {
+ ND_PRINT((ndo, " flags:0x%x",
+ EXTRACT_32BITS(&gabn->flags)));
}
v = EXTRACT_32BITS(&gabn->addrtypes);
switch (v & (LWRES_ADDRTYPE_V4 | LWRES_ADDRTYPE_V6)) {
case LWRES_ADDRTYPE_V4:
- printf(" IPv4");
+ ND_PRINT((ndo, " IPv4"));
break;
case LWRES_ADDRTYPE_V6:
- printf(" IPv6");
+ ND_PRINT((ndo, " IPv6"));
break;
case LWRES_ADDRTYPE_V4 | LWRES_ADDRTYPE_V6:
- printf(" IPv4/6");
+ ND_PRINT((ndo, " IPv4/6"));
break;
}
if (v & ~(LWRES_ADDRTYPE_V4 | LWRES_ADDRTYPE_V6))
- printf("[0x%x]", v);
+ ND_PRINT((ndo, "[0x%x]", v));
- advance = lwres_printname(l, s);
+ advance = lwres_printname(ndo, l, s);
if (advance < 0)
goto trunc;
s += advance;
break;
case LWRES_OPCODE_GETNAMEBYADDR:
gnba = (lwres_gnbarequest_t *)(np + 1);
- TCHECK(gnba->addr);
+ ND_TCHECK(gnba->addr);
/* BIND910: not used */
- if (vflag > 2) {
- printf(" flags:0x%x",
- EXTRACT_32BITS(&gnba->flags));
+ if (ndo->ndo_vflag > 2) {
+ ND_PRINT((ndo, " flags:0x%x",
+ EXTRACT_32BITS(&gnba->flags)));
}
s = (const char *)&gnba->addr;
- advance = lwres_printaddr(&gnba->addr);
+ advance = lwres_printaddr(ndo, &gnba->addr);
if (advance < 0)
goto trunc;
s += advance;
@@ -413,19 +409,19 @@ lwres_print(register const u_char *bp, u_int length)
case LWRES_OPCODE_GETRDATABYNAME:
/* XXX no trace, not tested */
grbn = (lwres_grbnrequest_t *)(np + 1);
- TCHECK(grbn->namelen);
+ ND_TCHECK(grbn->namelen);
/* BIND910: not used */
- if (vflag > 2) {
- printf(" flags:0x%x",
- EXTRACT_32BITS(&grbn->flags));
+ if (ndo->ndo_vflag > 2) {
+ ND_PRINT((ndo, " flags:0x%x",
+ EXTRACT_32BITS(&grbn->flags)));
}
- printf(" %s", tok2str(ns_type2str, "Type%d",
- EXTRACT_16BITS(&grbn->rdtype)));
+ ND_PRINT((ndo, " %s", tok2str(ns_type2str, "Type%d",
+ EXTRACT_16BITS(&grbn->rdtype))));
if (EXTRACT_16BITS(&grbn->rdclass) != C_IN) {
- printf(" %s", tok2str(ns_class2str, "Class%d",
- EXTRACT_16BITS(&grbn->rdclass)));
+ ND_PRINT((ndo, " %s", tok2str(ns_class2str, "Class%d",
+ EXTRACT_16BITS(&grbn->rdclass))));
}
/* XXX grbn points to packed struct */
@@ -433,7 +429,7 @@ lwres_print(register const u_char *bp, u_int length)
sizeof(grbn->namelen);
l = EXTRACT_16BITS(&grbn->namelen);
- advance = lwres_printname(l, s);
+ advance = lwres_printname(ndo, l, s);
if (advance < 0)
goto trunc;
s += advance;
@@ -449,8 +445,8 @@ lwres_print(register const u_char *bp, u_int length)
lwres_gabnresponse_t *gabn;
lwres_gnbaresponse_t *gnba;
lwres_grbnresponse_t *grbn;
- u_int32_t l, na;
- u_int32_t i;
+ uint32_t l, na;
+ uint32_t i;
gabn = NULL;
gnba = NULL;
@@ -461,22 +457,22 @@ lwres_print(register const u_char *bp, u_int length)
break;
case LWRES_OPCODE_GETADDRSBYNAME:
gabn = (lwres_gabnresponse_t *)(np + 1);
- TCHECK(gabn->realnamelen);
+ ND_TCHECK(gabn->realnamelen);
/* XXX gabn points to packed struct */
s = (const char *)&gabn->realnamelen +
sizeof(gabn->realnamelen);
l = EXTRACT_16BITS(&gabn->realnamelen);
/* BIND910: not used */
- if (vflag > 2) {
- printf(" flags:0x%x",
- EXTRACT_32BITS(&gabn->flags));
+ if (ndo->ndo_vflag > 2) {
+ ND_PRINT((ndo, " flags:0x%x",
+ EXTRACT_32BITS(&gabn->flags)));
}
- printf(" %u/%u", EXTRACT_16BITS(&gabn->naliases),
- EXTRACT_16BITS(&gabn->naddrs));
+ ND_PRINT((ndo, " %u/%u", EXTRACT_16BITS(&gabn->naliases),
+ EXTRACT_16BITS(&gabn->naddrs)));
- advance = lwres_printname(l, s);
+ advance = lwres_printname(ndo, l, s);
if (advance < 0)
goto trunc;
s += advance;
@@ -484,7 +480,7 @@ lwres_print(register const u_char *bp, u_int length)
/* aliases */
na = EXTRACT_16BITS(&gabn->naliases);
for (i = 0; i < na; i++) {
- advance = lwres_printnamelen(s);
+ advance = lwres_printnamelen(ndo, s);
if (advance < 0)
goto trunc;
s += advance;
@@ -493,7 +489,7 @@ lwres_print(register const u_char *bp, u_int length)
/* addrs */
na = EXTRACT_16BITS(&gabn->naddrs);
for (i = 0; i < na; i++) {
- advance = lwres_printaddr((lwres_addr_t *)s);
+ advance = lwres_printaddr(ndo, (lwres_addr_t *)s);
if (advance < 0)
goto trunc;
s += advance;
@@ -501,21 +497,21 @@ lwres_print(register const u_char *bp, u_int length)
break;
case LWRES_OPCODE_GETNAMEBYADDR:
gnba = (lwres_gnbaresponse_t *)(np + 1);
- TCHECK(gnba->realnamelen);
+ ND_TCHECK(gnba->realnamelen);
/* XXX gnba points to packed struct */
s = (const char *)&gnba->realnamelen +
sizeof(gnba->realnamelen);
l = EXTRACT_16BITS(&gnba->realnamelen);
/* BIND910: not used */
- if (vflag > 2) {
- printf(" flags:0x%x",
- EXTRACT_32BITS(&gnba->flags));
+ if (ndo->ndo_vflag > 2) {
+ ND_PRINT((ndo, " flags:0x%x",
+ EXTRACT_32BITS(&gnba->flags)));
}
- printf(" %u", EXTRACT_16BITS(&gnba->naliases));
+ ND_PRINT((ndo, " %u", EXTRACT_16BITS(&gnba->naliases)));
- advance = lwres_printname(l, s);
+ advance = lwres_printname(ndo, l, s);
if (advance < 0)
goto trunc;
s += advance;
@@ -523,7 +519,7 @@ lwres_print(register const u_char *bp, u_int length)
/* aliases */
na = EXTRACT_16BITS(&gnba->naliases);
for (i = 0; i < na; i++) {
- advance = lwres_printnamelen(s);
+ advance = lwres_printnamelen(ndo, s);
if (advance < 0)
goto trunc;
s += advance;
@@ -532,29 +528,29 @@ lwres_print(register const u_char *bp, u_int length)
case LWRES_OPCODE_GETRDATABYNAME:
/* XXX no trace, not tested */
grbn = (lwres_grbnresponse_t *)(np + 1);
- TCHECK(grbn->nsigs);
+ ND_TCHECK(grbn->nsigs);
/* BIND910: not used */
- if (vflag > 2) {
- printf(" flags:0x%x",
- EXTRACT_32BITS(&grbn->flags));
+ if (ndo->ndo_vflag > 2) {
+ ND_PRINT((ndo, " flags:0x%x",
+ EXTRACT_32BITS(&grbn->flags)));
}
- printf(" %s", tok2str(ns_type2str, "Type%d",
- EXTRACT_16BITS(&grbn->rdtype)));
+ ND_PRINT((ndo, " %s", tok2str(ns_type2str, "Type%d",
+ EXTRACT_16BITS(&grbn->rdtype))));
if (EXTRACT_16BITS(&grbn->rdclass) != C_IN) {
- printf(" %s", tok2str(ns_class2str, "Class%d",
- EXTRACT_16BITS(&grbn->rdclass)));
+ ND_PRINT((ndo, " %s", tok2str(ns_class2str, "Class%d",
+ EXTRACT_16BITS(&grbn->rdclass))));
}
- printf(" TTL ");
- relts_print(EXTRACT_32BITS(&grbn->ttl));
- printf(" %u/%u", EXTRACT_16BITS(&grbn->nrdatas),
- EXTRACT_16BITS(&grbn->nsigs));
+ ND_PRINT((ndo, " TTL "));
+ relts_print(ndo, EXTRACT_32BITS(&grbn->ttl));
+ ND_PRINT((ndo, " %u/%u", EXTRACT_16BITS(&grbn->nrdatas),
+ EXTRACT_16BITS(&grbn->nsigs)));
/* XXX grbn points to packed struct */
s = (const char *)&grbn->nsigs+ sizeof(grbn->nsigs);
- advance = lwres_printnamelen(s);
+ advance = lwres_printnamelen(ndo, s);
if (advance < 0)
goto trunc;
s += advance;
@@ -563,7 +559,7 @@ lwres_print(register const u_char *bp, u_int length)
na = EXTRACT_16BITS(&grbn->nrdatas);
for (i = 0; i < na; i++) {
/* XXX should decode resource data */
- advance = lwres_printbinlen(s);
+ advance = lwres_printbinlen(ndo, s);
if (advance < 0)
goto trunc;
s += advance;
@@ -573,7 +569,7 @@ lwres_print(register const u_char *bp, u_int length)
na = EXTRACT_16BITS(&grbn->nsigs);
for (i = 0; i < na; i++) {
/* XXX how should we print it? */
- advance = lwres_printbinlen(s);
+ advance = lwres_printbinlen(ndo, s);
if (advance < 0)
goto trunc;
s += advance;
@@ -588,14 +584,13 @@ lwres_print(register const u_char *bp, u_int length)
tail:
/* length mismatch */
if (EXTRACT_32BITS(&np->length) != length) {
- printf(" [len: %u != %u]", EXTRACT_32BITS(&np->length),
- length);
+ ND_PRINT((ndo, " [len: %u != %u]", EXTRACT_32BITS(&np->length),
+ length));
}
if (!unsupported && s < (const char *)np + EXTRACT_32BITS(&np->length))
- printf("[extra]");
+ ND_PRINT((ndo, "[extra]"));
return;
trunc:
- printf("[|lwres]");
- return;
+ ND_PRINT((ndo, "[|lwres]"));
}
diff --git a/contrib/tcpdump/print-m3ua.c b/contrib/tcpdump/print-m3ua.c
new file mode 100644
index 000000000000..33f8777977f8
--- /dev/null
+++ b/contrib/tcpdump/print-m3ua.c
@@ -0,0 +1,339 @@
+/* Copyright (c) 2013, The TCPDUMP project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#define NETDISSECT_REWORKED
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tcpdump-stdinc.h>
+
+#include "interface.h"
+#include "extract.h"
+
+static const char tstr[] = " [|m3ua]";
+static const char cstr[] = " (corrupt)";
+
+/* RFC 4666 */
+
+#define M3UA_REL_1_0 1
+
+struct m3ua_common_header {
+ uint8_t v;
+ uint8_t reserved;
+ uint8_t msg_class;
+ uint8_t msg_type;
+ uint32_t len;
+};
+
+struct m3ua_param_header {
+ uint16_t tag;
+ uint16_t len;
+};
+
+/* message classes */
+#define M3UA_MSGC_MGMT 0
+#define M3UA_MSGC_TRANSFER 1
+#define M3UA_MSGC_SSNM 2
+#define M3UA_MSGC_ASPSM 3
+#define M3UA_MSGC_ASPTM 4
+/* reserved values */
+#define M3UA_MSGC_RKM 9
+
+static const struct tok MessageClasses[] = {
+ { M3UA_MSGC_MGMT, "Management" },
+ { M3UA_MSGC_TRANSFER, "Transfer" },
+ { M3UA_MSGC_SSNM, "SS7" },
+ { M3UA_MSGC_ASPSM, "ASP" },
+ { M3UA_MSGC_ASPTM, "ASP" },
+ { M3UA_MSGC_RKM, "Routing Key Managment" },
+ { 0, NULL }
+};
+
+/* management messages */
+#define M3UA_MGMT_ERROR 0
+#define M3UA_MGMT_NOTIFY 1
+
+static const struct tok MgmtMessages[] = {
+ { M3UA_MGMT_ERROR, "Error" },
+ { M3UA_MGMT_NOTIFY, "Notify" },
+ { 0, NULL }
+};
+
+/* transfer messages */
+#define M3UA_TRANSFER_DATA 1
+
+static const struct tok TransferMessages[] = {
+ { M3UA_TRANSFER_DATA, "Data" },
+ { 0, NULL }
+};
+
+/* SS7 Signaling Network Management messages */
+#define M3UA_SSNM_DUNA 1
+#define M3UA_SSNM_DAVA 2
+#define M3UA_SSNM_DAUD 3
+#define M3UA_SSNM_SCON 4
+#define M3UA_SSNM_DUPU 5
+#define M3UA_SSNM_DRST 6
+
+static const struct tok SS7Messages[] = {
+ { M3UA_SSNM_DUNA, "Destination Unavailable" },
+ { M3UA_SSNM_DAVA, "Destination Available" },
+ { M3UA_SSNM_DAUD, "Destination State Audit" },
+ { M3UA_SSNM_SCON, "Signalling Congestion" },
+ { M3UA_SSNM_DUPU, "Destination User Part Unavailable" },
+ { M3UA_SSNM_DRST, "Destination Restricted" },
+ { 0, NULL }
+};
+
+/* ASP State Maintenance messages */
+#define M3UA_ASP_UP 1
+#define M3UA_ASP_DN 2
+#define M3UA_ASP_BEAT 3
+#define M3UA_ASP_UP_ACK 4
+#define M3UA_ASP_DN_ACK 5
+#define M3UA_ASP_BEAT_ACK 6
+
+static const struct tok ASPStateMessages[] = {
+ { M3UA_ASP_UP, "Up" },
+ { M3UA_ASP_DN, "Down" },
+ { M3UA_ASP_BEAT, "Heartbeat" },
+ { M3UA_ASP_UP_ACK, "Up Acknowledgement" },
+ { M3UA_ASP_DN_ACK, "Down Acknowledgement" },
+ { M3UA_ASP_BEAT_ACK, "Heartbeat Acknowledgement" },
+ { 0, NULL }
+};
+
+/* ASP Traffic Maintenance messages */
+#define M3UA_ASP_AC 1
+#define M3UA_ASP_IA 2
+#define M3UA_ASP_AC_ACK 3
+#define M3UA_ASP_IA_ACK 4
+
+static const struct tok ASPTrafficMessages[] = {
+ { M3UA_ASP_AC, "Active" },
+ { M3UA_ASP_IA, "Inactive" },
+ { M3UA_ASP_AC_ACK, "Active Acknowledgement" },
+ { M3UA_ASP_IA_ACK, "Inactive Acknowledgement" },
+ { 0, NULL }
+};
+
+/* Routing Key Management messages */
+#define M3UA_RKM_REQ 1
+#define M3UA_RKM_RSP 2
+#define M3UA_RKM_DEREQ 3
+#define M3UA_RKM_DERSP 4
+
+static const struct tok RoutingKeyMgmtMessages[] = {
+ { M3UA_RKM_REQ, "Registration Request" },
+ { M3UA_RKM_RSP, "Registration Response" },
+ { M3UA_RKM_DEREQ, "Deregistration Request" },
+ { M3UA_RKM_DERSP, "Deregistration Response" },
+ { 0, NULL }
+};
+
+/* M3UA Parameters */
+#define M3UA_PARAM_INFO 0x0004
+#define M3UA_PARAM_ROUTING_CTX 0x0006
+#define M3UA_PARAM_DIAGNOSTIC 0x0007
+#define M3UA_PARAM_HB_DATA 0x0009
+#define M3UA_PARAM_TRAFFIC_MODE_TYPE 0x000b
+#define M3UA_PARAM_ERROR_CODE 0x000c
+#define M3UA_PARAM_STATUS 0x000d
+#define M3UA_PARAM_ASP_ID 0x0011
+#define M3UA_PARAM_AFFECTED_POINT_CODE 0x0012
+#define M3UA_PARAM_CORR_ID 0x0013
+
+#define M3UA_PARAM_NETWORK_APPEARANCE 0x0200
+#define M3UA_PARAM_USER 0x0204
+#define M3UA_PARAM_CONGESTION_INDICATION 0x0205
+#define M3UA_PARAM_CONCERNED_DST 0x0206
+#define M3UA_PARAM_ROUTING_KEY 0x0207
+#define M3UA_PARAM_REG_RESULT 0x0208
+#define M3UA_PARAM_DEREG_RESULT 0x0209
+#define M3UA_PARAM_LOCAL_ROUTING_KEY_ID 0x020a
+#define M3UA_PARAM_DST_POINT_CODE 0x020b
+#define M3UA_PARAM_SI 0x020c
+#define M3UA_PARAM_ORIGIN_POINT_CODE_LIST 0x020e
+#define M3UA_PARAM_PROTO_DATA 0x0210
+#define M3UA_PARAM_REG_STATUS 0x0212
+#define M3UA_PARAM_DEREG_STATUS 0x0213
+
+static const struct tok ParamName[] = {
+ { M3UA_PARAM_INFO, "INFO String" },
+ { M3UA_PARAM_ROUTING_CTX, "Routing Context" },
+ { M3UA_PARAM_DIAGNOSTIC, "Diagnostic Info" },
+ { M3UA_PARAM_HB_DATA, "Heartbeat Data" },
+ { M3UA_PARAM_TRAFFIC_MODE_TYPE, "Traffic Mode Type" },
+ { M3UA_PARAM_ERROR_CODE, "Error Code" },
+ { M3UA_PARAM_STATUS, "Status" },
+ { M3UA_PARAM_ASP_ID, "ASP Identifier" },
+ { M3UA_PARAM_AFFECTED_POINT_CODE, "Affected Point Code" },
+ { M3UA_PARAM_CORR_ID, "Correlation ID" },
+ { M3UA_PARAM_NETWORK_APPEARANCE, "Network Appearance" },
+ { M3UA_PARAM_USER, "User/Cause" },
+ { M3UA_PARAM_CONGESTION_INDICATION, "Congestion Indications" },
+ { M3UA_PARAM_CONCERNED_DST, "Concerned Destination" },
+ { M3UA_PARAM_ROUTING_KEY, "Routing Key" },
+ { M3UA_PARAM_REG_RESULT, "Registration Result" },
+ { M3UA_PARAM_DEREG_RESULT, "Deregistration Result" },
+ { M3UA_PARAM_LOCAL_ROUTING_KEY_ID, "Local Routing Key Identifier" },
+ { M3UA_PARAM_DST_POINT_CODE, "Destination Point Code" },
+ { M3UA_PARAM_SI, "Service Indicators" },
+ { M3UA_PARAM_ORIGIN_POINT_CODE_LIST, "Originating Point Code List" },
+ { M3UA_PARAM_PROTO_DATA, "Protocol Data" },
+ { M3UA_PARAM_REG_STATUS, "Registration Status" },
+ { M3UA_PARAM_DEREG_STATUS, "Deregistration Status" },
+ { 0, NULL }
+};
+
+static void
+tag_value_print(netdissect_options *ndo,
+ const u_char *buf, const uint16_t tag, const uint16_t size)
+{
+ switch (tag) {
+ case M3UA_PARAM_NETWORK_APPEARANCE:
+ case M3UA_PARAM_ROUTING_CTX:
+ case M3UA_PARAM_CORR_ID:
+ /* buf and size don't include the header */
+ if (size < 4)
+ goto corrupt;
+ ND_TCHECK2(*buf, size);
+ ND_PRINT((ndo, "0x%08x", EXTRACT_32BITS(buf)));
+ break;
+ /* ... */
+ default:
+ ND_PRINT((ndo, "(length %u)", size + (u_int)sizeof(struct m3ua_param_header)));
+ ND_TCHECK2(*buf, size);
+ }
+ return;
+
+corrupt:
+ ND_PRINT((ndo, "%s", cstr));
+ ND_TCHECK2(*buf, size);
+ return;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+}
+
+/*
+ * 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
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Parameter Tag | Parameter Length |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * \ \
+ * / Parameter Value /
+ * \ \
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+static void
+m3ua_tags_print(netdissect_options *ndo,
+ const u_char *buf, const u_int size)
+{
+ const u_char *p = buf;
+ int align;
+ uint16_t hdr_tag;
+ uint16_t hdr_len;
+
+ while (p < buf + size) {
+ if (p + sizeof(struct m3ua_param_header) > buf + size)
+ goto corrupt;
+ ND_TCHECK2(*p, sizeof(struct m3ua_param_header));
+ /* Parameter Tag */
+ hdr_tag = EXTRACT_16BITS(p);
+ ND_PRINT((ndo, "\n\t\t\t%s: ", tok2str(ParamName, "Unknown Parameter (0x%04x)", hdr_tag)));
+ /* Parameter Length */
+ hdr_len = EXTRACT_16BITS(p + 2);
+ if (hdr_len < sizeof(struct m3ua_param_header))
+ goto corrupt;
+ /* Parameter Value */
+ align = (p + hdr_len - buf) % 4;
+ align = align ? 4 - align : 0;
+ ND_TCHECK2(*p, hdr_len + align);
+ tag_value_print(ndo, p, hdr_tag, hdr_len - sizeof(struct m3ua_param_header));
+ p += hdr_len + align;
+ }
+ return;
+
+corrupt:
+ ND_PRINT((ndo, "%s", cstr));
+ ND_TCHECK2(*buf, size);
+ return;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+}
+
+/*
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Version | Reserved | Message Class | Message Type |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Message Length |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * \ \
+ * / /
+ */
+void
+m3ua_print(netdissect_options *ndo,
+ const u_char *buf, const u_int size)
+{
+ const struct m3ua_common_header *hdr = (const struct m3ua_common_header *) buf;
+ const struct tok *dict;
+
+ /* size includes the header */
+ if (size < sizeof(struct m3ua_common_header))
+ goto corrupt;
+ ND_TCHECK(*hdr);
+ if (hdr->v != M3UA_REL_1_0)
+ return;
+
+ dict =
+ hdr->msg_class == M3UA_MSGC_MGMT ? MgmtMessages :
+ hdr->msg_class == M3UA_MSGC_TRANSFER ? TransferMessages :
+ hdr->msg_class == M3UA_MSGC_SSNM ? SS7Messages :
+ hdr->msg_class == M3UA_MSGC_ASPSM ? ASPStateMessages :
+ hdr->msg_class == M3UA_MSGC_ASPTM ? ASPTrafficMessages :
+ hdr->msg_class == M3UA_MSGC_RKM ? RoutingKeyMgmtMessages :
+ NULL;
+
+ ND_PRINT((ndo, "\n\t\t%s", tok2str(MessageClasses, "Unknown message class %i", hdr->msg_class)));
+ if (dict != NULL)
+ ND_PRINT((ndo, " %s Message", tok2str(dict, "Unknown (0x%02x)", hdr->msg_type)));
+
+ if (size != EXTRACT_32BITS(&hdr->len))
+ ND_PRINT((ndo, "\n\t\t\t@@@@@@ Corrupted length %u of message @@@@@@", EXTRACT_32BITS(&hdr->len)));
+ else
+ m3ua_tags_print(ndo, buf + sizeof(struct m3ua_common_header), EXTRACT_32BITS(&hdr->len) - sizeof(struct m3ua_common_header));
+ return;
+
+corrupt:
+ ND_PRINT((ndo, "%s", cstr));
+ ND_TCHECK2(*buf, size);
+ return;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+}
+
diff --git a/contrib/tcpdump/print-mobile.c b/contrib/tcpdump/print-mobile.c
index de4eab1dce3b..df412eeb2897 100644
--- a/contrib/tcpdump/print-mobile.c
+++ b/contrib/tcpdump/print-mobile.c
@@ -36,19 +36,13 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-mobile.c,v 1.15 2004-03-24 01:58:14 guy Exp $";
-#endif
-
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-
#include "interface.h"
#include "addrtoname.h"
#include "extract.h" /* must come after interface.h */
@@ -56,10 +50,10 @@ static const char rcsid[] _U_ =
#define MOBILE_SIZE (8)
struct mobile_ip {
- u_int16_t proto;
- u_int16_t hcheck;
- u_int32_t odst;
- u_int32_t osrc;
+ uint16_t proto;
+ uint16_t hcheck;
+ uint32_t odst;
+ uint32_t osrc;
};
#define OSRC_PRES 0x0080 /* old source is present */
@@ -68,9 +62,8 @@ struct mobile_ip {
* Deencapsulate and print a mobile-tunneled IP datagram
*/
void
-mobile_print(const u_char *bp, u_int length)
+mobile_print(netdissect_options *ndo, const u_char *bp, u_int length)
{
- const u_char *cp = bp +8 ;
const struct mobile_ip *mob;
struct cksum_vec vec[1];
u_short proto,crc;
@@ -78,35 +71,32 @@ mobile_print(const u_char *bp, u_int length)
mob = (const struct mobile_ip *)bp;
- if (length < MOBILE_SIZE || !TTEST(*mob)) {
- fputs("[|mobile]", stdout);
+ if (length < MOBILE_SIZE || !ND_TTEST(*mob)) {
+ ND_PRINT((ndo, "[|mobile]"));
return;
}
- fputs("mobile: ", stdout);
+ ND_PRINT((ndo, "mobile: "));
proto = EXTRACT_16BITS(&mob->proto);
crc = EXTRACT_16BITS(&mob->hcheck);
if (proto & OSRC_PRES) {
osp=1;
- cp +=4 ;
}
if (osp) {
- fputs("[S] ",stdout);
- if (vflag)
- (void)printf("%s ",ipaddr_string(&mob->osrc));
+ ND_PRINT((ndo, "[S] "));
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, "%s ", ipaddr_string(ndo, &mob->osrc)));
} else {
- fputs("[] ",stdout);
+ ND_PRINT((ndo, "[] "));
}
- if (vflag) {
- (void)printf("> %s ",ipaddr_string(&mob->odst));
- (void)printf("(oproto=%d)",proto>>8);
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "> %s ", ipaddr_string(ndo, &mob->odst)));
+ ND_PRINT((ndo, "(oproto=%d)", proto>>8));
}
- vec[0].ptr = (const u_int8_t *)(void *)mob;
+ vec[0].ptr = (const uint8_t *)(void *)mob;
vec[0].len = osp ? 12 : 8;
if (in_cksum(vec, 1)!=0) {
- (void)printf(" (bad checksum %d)",crc);
+ ND_PRINT((ndo, " (bad checksum %d)", crc));
}
-
- return;
}
diff --git a/contrib/tcpdump/print-mobility.c b/contrib/tcpdump/print-mobility.c
index 1490b72e721c..83447cff15d4 100644
--- a/contrib/tcpdump/print-mobility.c
+++ b/contrib/tcpdump/print-mobility.c
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2002 WIDE Project.
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -13,7 +13,7 @@
* 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -27,36 +27,29 @@
* SUCH DAMAGE.
*/
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-mobility.c,v 1.12 2005-04-20 22:21:00 guy Exp $";
-#endif
-
#ifdef INET6
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-
#include "ip6.h"
-
#include "interface.h"
#include "addrtoname.h"
#include "extract.h" /* must come after interface.h */
/* Mobility header */
struct ip6_mobility {
- u_int8_t ip6m_pproto; /* following payload protocol (for PG) */
- u_int8_t ip6m_len; /* length in units of 8 octets */
- u_int8_t ip6m_type; /* message type */
- u_int8_t reserved; /* reserved */
- u_int16_t ip6m_cksum; /* sum of IPv6 pseudo-header and MH */
+ uint8_t ip6m_pproto; /* following payload protocol (for PG) */
+ uint8_t ip6m_len; /* length in units of 8 octets */
+ uint8_t ip6m_type; /* message type */
+ uint8_t reserved; /* reserved */
+ uint16_t ip6m_cksum; /* sum of IPv6 pseudo-header and MH */
union {
- u_int16_t ip6m_un_data16[1]; /* type-specific field */
- u_int8_t ip6m_un_data8[2]; /* type-specific fiedl */
+ uint16_t ip6m_un_data16[1]; /* type-specific field */
+ uint8_t ip6m_un_data8[2]; /* type-specific field */
} ip6m_dataun;
};
@@ -65,6 +58,8 @@ struct ip6_mobility {
#define IP6M_MINLEN 8
+/* http://www.iana.org/assignments/mobility-parameters/mobility-parameters.xhtml */
+
/* message type */
#define IP6M_BINDING_REQUEST 0 /* Binding Refresh Request */
#define IP6M_HOME_TEST_INIT 1 /* Home Test Init */
@@ -75,6 +70,11 @@ struct ip6_mobility {
#define IP6M_BINDING_ACK 6 /* Binding Acknowledgement */
#define IP6M_BINDING_ERROR 7 /* Binding Error */
+/* XXX: unused */
+#define IP6MOPT_BU_MINLEN 10
+#define IP6MOPT_BA_MINLEN 13
+#define IP6MOPT_BR_MINLEN 2
+
/* Mobility Header Options */
#define IP6MOPT_MINLEN 2
#define IP6MOPT_PAD1 0x0 /* Pad1 */
@@ -89,10 +89,10 @@ struct ip6_mobility {
#define IP6MOPT_AUTH_MINLEN 12
static void
-mobility_opt_print(const u_char *bp, int len)
+mobility_opt_print(netdissect_options *ndo,
+ const u_char *bp, const unsigned len)
{
- int i;
- int optlen;
+ unsigned i, optlen;
for (i = 0; i < len; i += optlen) {
if (bp[i] == IP6MOPT_PAD1)
@@ -108,78 +108,80 @@ mobility_opt_print(const u_char *bp, int len)
switch (bp[i]) {
case IP6MOPT_PAD1:
- printf("(pad1)");
+ ND_PRINT((ndo, "(pad1)"));
break;
case IP6MOPT_PADN:
if (len - i < IP6MOPT_MINLEN) {
- printf("(padn: trunc)");
+ ND_PRINT((ndo, "(padn: trunc)"));
goto trunc;
}
- printf("(padn)");
+ ND_PRINT((ndo, "(padn)"));
break;
case IP6MOPT_REFRESH:
if (len - i < IP6MOPT_REFRESH_MINLEN) {
- printf("(refresh: trunc)");
+ ND_PRINT((ndo, "(refresh: trunc)"));
goto trunc;
}
/* units of 4 secs */
- printf("(refresh: %d)",
- EXTRACT_16BITS(&bp[i+2]) << 2);
+ ND_PRINT((ndo, "(refresh: %u)",
+ EXTRACT_16BITS(&bp[i+2]) << 2));
break;
case IP6MOPT_ALTCOA:
if (len - i < IP6MOPT_ALTCOA_MINLEN) {
- printf("(altcoa: trunc)");
+ ND_PRINT((ndo, "(altcoa: trunc)"));
goto trunc;
}
- printf("(alt-CoA: %s)", ip6addr_string(&bp[i+2]));
+ ND_PRINT((ndo, "(alt-CoA: %s)", ip6addr_string(ndo, &bp[i+2])));
break;
case IP6MOPT_NONCEID:
if (len - i < IP6MOPT_NONCEID_MINLEN) {
- printf("(ni: trunc)");
+ ND_PRINT((ndo, "(ni: trunc)"));
goto trunc;
}
- printf("(ni: ho=0x%04x co=0x%04x)",
+ ND_PRINT((ndo, "(ni: ho=0x%04x co=0x%04x)",
EXTRACT_16BITS(&bp[i+2]),
- EXTRACT_16BITS(&bp[i+4]));
+ EXTRACT_16BITS(&bp[i+4])));
break;
case IP6MOPT_AUTH:
if (len - i < IP6MOPT_AUTH_MINLEN) {
- printf("(auth: trunc)");
+ ND_PRINT((ndo, "(auth: trunc)"));
goto trunc;
}
- printf("(auth)");
+ ND_PRINT((ndo, "(auth)"));
break;
default:
if (len - i < IP6MOPT_MINLEN) {
- printf("(sopt_type %d: trunc)", bp[i]);
+ ND_PRINT((ndo, "(sopt_type %u: trunc)", bp[i]));
goto trunc;
}
- printf("(type-0x%02x: len=%d)", bp[i], bp[i + 1]);
+ ND_PRINT((ndo, "(type-0x%02x: len=%u)", bp[i], bp[i + 1]));
break;
}
}
return;
trunc:
- printf("[trunc] ");
+ ND_PRINT((ndo, "[trunc] "));
}
/*
* Mobility Header
*/
int
-mobility_print(const u_char *bp, const u_char *bp2 _U_)
+mobility_print(netdissect_options *ndo,
+ const u_char *bp, const u_char *bp2 _U_)
{
const struct ip6_mobility *mh;
const u_char *ep;
- int mhlen, hlen, type;
+ unsigned mhlen, hlen;
+ uint8_t type;
mh = (struct ip6_mobility *)bp;
/* 'ep' points to the end of available data. */
- ep = snapend;
+ ep = ndo->ndo_snapend;
- if (!TTEST(mh->ip6m_len)) {
+ if (!ND_TTEST(mh->ip6m_len)) {
/*
* There's not enough captured data to include the
* mobility header length.
@@ -195,118 +197,118 @@ mobility_print(const u_char *bp, const u_char *bp2 _U_)
mhlen = ep - bp;
goto trunc;
}
- mhlen = (int)((mh->ip6m_len + 1) << 3);
+ mhlen = (mh->ip6m_len + 1) << 3;
/* XXX ip6m_cksum */
- TCHECK(mh->ip6m_type);
+ ND_TCHECK(mh->ip6m_type);
type = mh->ip6m_type;
switch (type) {
case IP6M_BINDING_REQUEST:
- printf("mobility: BRR");
+ ND_PRINT((ndo, "mobility: BRR"));
hlen = IP6M_MINLEN;
break;
case IP6M_HOME_TEST_INIT:
case IP6M_CAREOF_TEST_INIT:
- printf("mobility: %soTI",
- type == IP6M_HOME_TEST_INIT ? "H" : "C");
+ ND_PRINT((ndo, "mobility: %soTI",
+ type == IP6M_HOME_TEST_INIT ? "H" : "C"));
hlen = IP6M_MINLEN;
- if (vflag) {
- TCHECK2(*mh, hlen + 8);
- printf(" %s Init Cookie=%08x:%08x",
+ if (ndo->ndo_vflag) {
+ ND_TCHECK2(*mh, hlen + 8);
+ ND_PRINT((ndo, " %s Init Cookie=%08x:%08x",
type == IP6M_HOME_TEST_INIT ? "Home" : "Care-of",
EXTRACT_32BITS(&bp[hlen]),
- EXTRACT_32BITS(&bp[hlen + 4]));
+ EXTRACT_32BITS(&bp[hlen + 4])));
}
hlen += 8;
break;
case IP6M_HOME_TEST:
case IP6M_CAREOF_TEST:
- printf("mobility: %soT",
- type == IP6M_HOME_TEST ? "H" : "C");
- TCHECK(mh->ip6m_data16[0]);
- printf(" nonce id=0x%x", EXTRACT_16BITS(&mh->ip6m_data16[0]));
+ ND_PRINT((ndo, "mobility: %soT",
+ type == IP6M_HOME_TEST ? "H" : "C"));
+ ND_TCHECK(mh->ip6m_data16[0]);
+ ND_PRINT((ndo, " nonce id=0x%x", EXTRACT_16BITS(&mh->ip6m_data16[0])));
hlen = IP6M_MINLEN;
- if (vflag) {
- TCHECK2(*mh, hlen + 8);
- printf(" %s Init Cookie=%08x:%08x",
+ if (ndo->ndo_vflag) {
+ ND_TCHECK2(*mh, hlen + 8);
+ ND_PRINT((ndo, " %s Init Cookie=%08x:%08x",
type == IP6M_HOME_TEST ? "Home" : "Care-of",
EXTRACT_32BITS(&bp[hlen]),
- EXTRACT_32BITS(&bp[hlen + 4]));
+ EXTRACT_32BITS(&bp[hlen + 4])));
}
hlen += 8;
- if (vflag) {
- TCHECK2(*mh, hlen + 8);
- printf(" %s Keygen Token=%08x:%08x",
+ if (ndo->ndo_vflag) {
+ ND_TCHECK2(*mh, hlen + 8);
+ ND_PRINT((ndo, " %s Keygen Token=%08x:%08x",
type == IP6M_HOME_TEST ? "Home" : "Care-of",
EXTRACT_32BITS(&bp[hlen]),
- EXTRACT_32BITS(&bp[hlen + 4]));
+ EXTRACT_32BITS(&bp[hlen + 4])));
}
hlen += 8;
break;
case IP6M_BINDING_UPDATE:
- printf("mobility: BU");
- TCHECK(mh->ip6m_data16[0]);
- printf(" seq#=%d", EXTRACT_16BITS(&mh->ip6m_data16[0]));
+ ND_PRINT((ndo, "mobility: BU"));
+ ND_TCHECK(mh->ip6m_data16[0]);
+ ND_PRINT((ndo, " seq#=%u", EXTRACT_16BITS(&mh->ip6m_data16[0])));
hlen = IP6M_MINLEN;
- TCHECK2(*mh, hlen + 1);
+ ND_TCHECK2(*mh, hlen + 1);
if (bp[hlen] & 0xf0)
- printf(" ");
+ ND_PRINT((ndo, " "));
if (bp[hlen] & 0x80)
- printf("A");
+ ND_PRINT((ndo, "A"));
if (bp[hlen] & 0x40)
- printf("H");
+ ND_PRINT((ndo, "H"));
if (bp[hlen] & 0x20)
- printf("L");
+ ND_PRINT((ndo, "L"));
if (bp[hlen] & 0x10)
- printf("K");
+ ND_PRINT((ndo, "K"));
/* Reserved (4bits) */
hlen += 1;
/* Reserved (8bits) */
hlen += 1;
- TCHECK2(*mh, hlen + 2);
+ ND_TCHECK2(*mh, hlen + 2);
/* units of 4 secs */
- printf(" lifetime=%d", EXTRACT_16BITS(&bp[hlen]) << 2);
+ ND_PRINT((ndo, " lifetime=%u", EXTRACT_16BITS(&bp[hlen]) << 2));
hlen += 2;
break;
case IP6M_BINDING_ACK:
- printf("mobility: BA");
- TCHECK(mh->ip6m_data8[0]);
- printf(" status=%d", mh->ip6m_data8[0]);
+ ND_PRINT((ndo, "mobility: BA"));
+ ND_TCHECK(mh->ip6m_data8[0]);
+ ND_PRINT((ndo, " status=%u", mh->ip6m_data8[0]));
if (mh->ip6m_data8[1] & 0x80)
- printf(" K");
+ ND_PRINT((ndo, " K"));
/* Reserved (7bits) */
hlen = IP6M_MINLEN;
- TCHECK2(*mh, hlen + 2);
- printf(" seq#=%d", EXTRACT_16BITS(&bp[hlen]));
+ ND_TCHECK2(*mh, hlen + 2);
+ ND_PRINT((ndo, " seq#=%u", EXTRACT_16BITS(&bp[hlen])));
hlen += 2;
- TCHECK2(*mh, hlen + 2);
+ ND_TCHECK2(*mh, hlen + 2);
/* units of 4 secs */
- printf(" lifetime=%d", EXTRACT_16BITS(&bp[hlen]) << 2);
+ ND_PRINT((ndo, " lifetime=%u", EXTRACT_16BITS(&bp[hlen]) << 2));
hlen += 2;
break;
case IP6M_BINDING_ERROR:
- printf("mobility: BE");
- TCHECK(mh->ip6m_data8[0]);
- printf(" status=%d", mh->ip6m_data8[0]);
+ ND_PRINT((ndo, "mobility: BE"));
+ ND_TCHECK(mh->ip6m_data8[0]);
+ ND_PRINT((ndo, " status=%u", mh->ip6m_data8[0]));
/* Reserved */
hlen = IP6M_MINLEN;
- TCHECK2(*mh, hlen + 16);
- printf(" homeaddr %s", ip6addr_string(&bp[hlen]));
+ ND_TCHECK2(*mh, hlen + 16);
+ ND_PRINT((ndo, " homeaddr %s", ip6addr_string(ndo, &bp[hlen])));
hlen += 16;
break;
default:
- printf("mobility: type-#%d len=%d", type, mh->ip6m_len);
+ ND_PRINT((ndo, "mobility: type-#%u len=%u", type, mh->ip6m_len));
return(mhlen);
break;
}
- if (vflag)
- mobility_opt_print(&bp[hlen], mhlen - hlen);
+ if (ndo->ndo_vflag)
+ mobility_opt_print(ndo, &bp[hlen], mhlen - hlen);
return(mhlen);
trunc:
- fputs("[|MOBILITY]", stdout);
+ ND_PRINT((ndo, "[|MOBILITY]"));
return(mhlen);
}
#endif /* INET6 */
diff --git a/contrib/tcpdump/print-mpcp.c b/contrib/tcpdump/print-mpcp.c
index 244f2802bb44..7ddfb1d12e38 100644
--- a/contrib/tcpdump/print-mpcp.c
+++ b/contrib/tcpdump/print-mpcp.c
@@ -17,32 +17,22 @@
* 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
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
#include "interface.h"
#include "extract.h"
-#include "addrtoname.h"
-#include "ether.h"
#define MPCP_TIMESTAMP_LEN 4
#define MPCP_TIMESTAMP_DURATION_LEN 2
struct mpcp_common_header_t {
- u_int8_t opcode[2];
- u_int8_t timestamp[MPCP_TIMESTAMP_LEN];
+ uint8_t opcode[2];
+ uint8_t timestamp[MPCP_TIMESTAMP_LEN];
};
#define MPCP_OPCODE_PAUSE 0x0001
@@ -63,7 +53,7 @@ static const struct tok mpcp_opcode_values[] = {
};
#define MPCP_GRANT_NUMBER_LEN 1
-#define MPCP_GRANT_NUMBER_MASK 0x7
+#define MPCP_GRANT_NUMBER_MASK 0x7
static const struct tok mpcp_grant_flag_values[] = {
{ 0x08, "Discovery" },
{ 0x10, "Force Grant #1" },
@@ -74,13 +64,13 @@ static const struct tok mpcp_grant_flag_values[] = {
};
struct mpcp_grant_t {
- u_int8_t starttime[MPCP_TIMESTAMP_LEN];
- u_int8_t duration[MPCP_TIMESTAMP_DURATION_LEN];
+ uint8_t starttime[MPCP_TIMESTAMP_LEN];
+ uint8_t duration[MPCP_TIMESTAMP_DURATION_LEN];
};
struct mpcp_reg_req_t {
- u_int8_t flags;
- u_int8_t pending_grants;
+ uint8_t flags;
+ uint8_t pending_grants;
};
@@ -91,10 +81,10 @@ static const struct tok mpcp_reg_req_flag_values[] = {
};
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;
+ uint8_t assigned_port[2];
+ uint8_t flags;
+ uint8_t sync_time[MPCP_TIMESTAMP_DURATION_LEN];
+ uint8_t echoed_pending_grants;
};
static const struct tok mpcp_reg_flag_values[] = {
@@ -120,9 +110,9 @@ static const struct tok mpcp_report_bitmap_values[] = {
};
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];
+ uint8_t flags;
+ uint8_t echoed_assigned_port[2];
+ uint8_t echoed_sync_time[MPCP_TIMESTAMP_DURATION_LEN];
};
static const struct tok mpcp_reg_ack_flag_values[] = {
@@ -132,7 +122,7 @@ static const struct tok mpcp_reg_ack_flag_values[] = {
};
void
-mpcp_print(register const u_char *pptr, register u_int length) {
+mpcp_print(netdissect_options *ndo, register const u_char *pptr, register u_int length) {
union {
const struct mpcp_common_header_t *common_header;
@@ -144,23 +134,22 @@ mpcp_print(register const u_char *pptr, register u_int length) {
const u_char *tptr;
- u_int16_t opcode;
- u_int8_t grant_numbers, grant;
- u_int8_t queue_sets, queue_set, report_bitmap, report;
+ uint16_t opcode;
+ uint8_t grant_numbers, grant;
+ uint8_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;
+ ND_TCHECK2(*tptr, sizeof(const struct mpcp_common_header_t));
opcode = EXTRACT_16BITS(mpcp.common_header->opcode);
- printf("MPCP, Opcode %s", tok2str(mpcp_opcode_values, "Unknown (%u)", opcode));
+ ND_PRINT((ndo, "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));
+ ND_PRINT((ndo, ", Timestamp %u ticks", EXTRACT_32BITS(mpcp.common_header->timestamp)));
}
- printf(", length %u", length);
+ ND_PRINT((ndo, ", length %u", length));
- if (!vflag)
+ if (!ndo->ndo_vflag)
return;
tptr += sizeof(const struct mpcp_common_header_t);
@@ -170,57 +159,51 @@ mpcp_print(register const u_char *pptr, register u_int length) {
break;
case MPCP_OPCODE_GATE:
- if (!TTEST2(*tptr, MPCP_GRANT_NUMBER_LEN))
- goto trunc;
+ ND_TCHECK2(*tptr, MPCP_GRANT_NUMBER_LEN);
grant_numbers = *tptr & MPCP_GRANT_NUMBER_MASK;
- printf("\n\tGrant Numbers %u, Flags [ %s ]",
+ ND_PRINT((ndo, "\n\tGrant Numbers %u, Flags [ %s ]",
grant_numbers,
bittok2str(mpcp_grant_flag_values,
"?",
- *tptr &~ MPCP_GRANT_NUMBER_MASK));
+ *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",
+ ND_TCHECK2(*tptr, sizeof(const struct mpcp_grant_t));
+ mpcp.grant = (const struct mpcp_grant_t *)tptr;
+ ND_PRINT((ndo, "\n\tGrant #%u, Start-Time %u ticks, duration %u ticks",
grant,
EXTRACT_32BITS(mpcp.grant->starttime),
- EXTRACT_16BITS(mpcp.grant->duration));
+ 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));
+ ND_TCHECK2(*tptr, MPCP_TIMESTAMP_DURATION_LEN);
+ ND_PRINT((ndo, "\n\tSync-Time %u ticks", EXTRACT_16BITS(tptr)));
break;
case MPCP_OPCODE_REPORT:
- if (!TTEST2(*tptr, MPCP_REPORT_QUEUESETS_LEN))
- goto trunc;
+ ND_TCHECK2(*tptr, MPCP_REPORT_QUEUESETS_LEN);
queue_sets = *tptr;
tptr+=MPCP_REPORT_QUEUESETS_LEN;
- printf("\n\tTotal Queue-Sets %u", queue_sets);
+ ND_PRINT((ndo, "\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;
+ ND_TCHECK2(*tptr, MPCP_REPORT_REPORTBITMAP_LEN);
report_bitmap = *(tptr);
- printf("\n\t Queue-Set #%u, Report-Bitmap [ %s ]",
+ ND_PRINT((ndo, "\n\t Queue-Set #%u, Report-Bitmap [ %s ]",
queue_sets,
- bittok2str(mpcp_report_bitmap_values, "Unknown", report_bitmap));
+ bittok2str(mpcp_report_bitmap_values, "Unknown", report_bitmap)));
tptr++;
report=1;
- while (report_bitmap != 0) {
+ 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",
+ ND_TCHECK2(*tptr, MPCP_TIMESTAMP_DURATION_LEN);
+ ND_PRINT((ndo, "\n\t Q%u Report, Duration %u ticks",
report,
- EXTRACT_16BITS(tptr));
+ EXTRACT_16BITS(tptr)));
tptr+=MPCP_TIMESTAMP_DURATION_LEN;
}
report++;
@@ -230,45 +213,48 @@ mpcp_print(register const u_char *pptr, register u_int length) {
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",
+ ND_TCHECK2(*tptr, sizeof(const struct mpcp_reg_req_t));
+ mpcp.reg_req = (const struct mpcp_reg_req_t *)tptr;
+ ND_PRINT((ndo, "\n\tFlags [ %s ], Pending-Grants %u",
bittok2str(mpcp_reg_req_flag_values, "Reserved", mpcp.reg_req->flags),
- mpcp.reg_req->pending_grants);
+ 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 ]" \
+ ND_TCHECK2(*tptr, sizeof(const struct mpcp_reg_t));
+ mpcp.reg = (const struct mpcp_reg_t *)tptr;
+ ND_PRINT((ndo, "\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);
+ 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 ]" \
+ ND_TCHECK2(*tptr, sizeof(const struct mpcp_reg_ack_t));
+ mpcp.reg_ack = (const struct mpcp_reg_ack_t *)tptr;
+ ND_PRINT((ndo, "\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));
+ EXTRACT_16BITS(mpcp.reg_ack->echoed_sync_time)));
break;
default:
/* unknown opcode - hexdump for now */
- print_unknown_data(pptr, "\n\t", length);
+ print_unknown_data(ndo,pptr, "\n\t", length);
break;
}
return;
trunc:
- printf("\n\t[|MPCP]");
+ ND_PRINT((ndo, "\n\t[|MPCP]"));
}
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
diff --git a/contrib/tcpdump/print-mpls.c b/contrib/tcpdump/print-mpls.c
index d97cce5278b4..039781ada2d1 100644
--- a/contrib/tcpdump/print-mpls.c
+++ b/contrib/tcpdump/print-mpls.c
@@ -26,22 +26,13 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-mpls.c,v 1.14 2005-07-05 09:38:19 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "addrtoname.h"
#include "interface.h"
#include "extract.h" /* must come after interface.h */
#include "mpls.h"
@@ -65,29 +56,29 @@ enum mpls_packet_type {
* RFC3032: MPLS label stack encoding
*/
void
-mpls_print(const u_char *bp, u_int length)
+mpls_print(netdissect_options *ndo, const u_char *bp, u_int length)
{
const u_char *p;
- u_int32_t label_entry;
- u_int16_t label_stack_depth = 0;
+ uint32_t label_entry;
+ uint16_t label_stack_depth = 0;
enum mpls_packet_type pt = PT_UNKNOWN;
p = bp;
- printf("MPLS");
+ ND_PRINT((ndo, "MPLS"));
do {
- TCHECK2(*p, sizeof(label_entry));
+ ND_TCHECK2(*p, sizeof(label_entry));
label_entry = EXTRACT_32BITS(p);
- printf("%s(label %u",
- (label_stack_depth && vflag) ? "\n\t" : " ",
- MPLS_LABEL(label_entry));
+ ND_PRINT((ndo, "%s(label %u",
+ (label_stack_depth && ndo->ndo_vflag) ? "\n\t" : " ",
+ MPLS_LABEL(label_entry)));
label_stack_depth++;
- if (vflag &&
+ if (ndo->ndo_vflag &&
MPLS_LABEL(label_entry) < sizeof(mpls_labelname) / sizeof(mpls_labelname[0]))
- printf(" (%s)", mpls_labelname[MPLS_LABEL(label_entry)]);
- printf(", exp %u", MPLS_EXP(label_entry));
+ ND_PRINT((ndo, " (%s)", mpls_labelname[MPLS_LABEL(label_entry)]));
+ ND_PRINT((ndo, ", exp %u", MPLS_EXP(label_entry)));
if (MPLS_STACK(label_entry))
- printf(", [S]");
- printf(", ttl %u)", MPLS_TTL(label_entry));
+ ND_PRINT((ndo, ", [S]"));
+ ND_PRINT((ndo, ", ttl %u)", MPLS_TTL(label_entry)));
p += sizeof(label_entry);
} while (!MPLS_STACK(label_entry));
@@ -147,7 +138,7 @@ mpls_print(const u_char *bp, u_int length)
case 0x4f:
pt = PT_IPV4;
break;
-
+
case 0x60:
case 0x61:
case 0x62:
@@ -183,30 +174,27 @@ mpls_print(const u_char *bp, u_int length)
* Print the payload.
*/
if (pt == PT_UNKNOWN) {
- if (!suppress_default_print)
- default_print(p, length - (p - bp));
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, length - (p - bp));
return;
}
- if (vflag)
- printf("\n\t");
- else
- printf(" ");
+ ND_PRINT((ndo, ndo->ndo_vflag ? "\n\t" : " "));
switch (pt) {
case PT_IPV4:
- ip_print(gndo, p, length - (p - bp));
+ ip_print(ndo, p, length - (p - bp));
break;
case PT_IPV6:
#ifdef INET6
- ip6_print(gndo, p, length - (p - bp));
+ ip6_print(ndo, p, length - (p - bp));
#else
- printf("IPv6, length: %u", length);
+ ND_PRINT((ndo, "IPv6, length: %u", length));
#endif
break;
case PT_OSI:
- isoclns_print(p, length - (p - bp), length - (p - bp));
+ isoclns_print(ndo, p, length - (p - bp), length - (p - bp));
break;
default:
@@ -215,7 +203,7 @@ mpls_print(const u_char *bp, u_int length)
return;
trunc:
- printf("[|MPLS]");
+ ND_PRINT((ndo, "[|MPLS]"));
}
diff --git a/contrib/tcpdump/print-mptcp.c b/contrib/tcpdump/print-mptcp.c
new file mode 100644
index 000000000000..f85f1d24a886
--- /dev/null
+++ b/contrib/tcpdump/print-mptcp.c
@@ -0,0 +1,429 @@
+/**
+ * Copyright (c) 2012
+ *
+ * Gregory Detal <gregory.detal@uclouvain.be>
+ * Christoph Paasch <christoph.paasch@uclouvain.be>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the University nor of the Laboratory may be used
+ * to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#define NETDISSECT_REWORKED
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tcpdump-stdinc.h>
+
+#include "interface.h"
+#include "extract.h"
+#include "addrtoname.h"
+
+#include "tcp.h"
+
+#define MPTCP_SUB_CAPABLE 0x0
+#define MPTCP_SUB_JOIN 0x1
+#define MPTCP_SUB_DSS 0x2
+#define MPTCP_SUB_ADD_ADDR 0x3
+#define MPTCP_SUB_REMOVE_ADDR 0x4
+#define MPTCP_SUB_PRIO 0x5
+#define MPTCP_SUB_FAIL 0x6
+#define MPTCP_SUB_FCLOSE 0x7
+
+struct mptcp_option {
+ uint8_t kind;
+ uint8_t len;
+ uint8_t sub_etc; /* subtype upper 4 bits, other stuff lower 4 bits */
+};
+
+#define MPTCP_OPT_SUBTYPE(sub_etc) (((sub_etc) >> 4) & 0xF)
+
+struct mp_capable {
+ uint8_t kind;
+ uint8_t len;
+ uint8_t sub_ver;
+ uint8_t flags;
+ uint8_t sender_key[8];
+ uint8_t receiver_key[8];
+};
+
+#define MP_CAPABLE_OPT_VERSION(sub_ver) (((sub_ver) >> 0) & 0xF)
+#define MP_CAPABLE_C 0x80
+#define MP_CAPABLE_S 0x01
+
+struct mp_join {
+ uint8_t kind;
+ uint8_t len;
+ uint8_t sub_b;
+ uint8_t addr_id;
+ union {
+ struct {
+ uint8_t token[4];
+ uint8_t nonce[4];
+ } syn;
+ struct {
+ uint8_t mac[8];
+ uint8_t nonce[4];
+ } synack;
+ struct {
+ uint8_t mac[20];
+ } ack;
+ } u;
+};
+
+#define MP_JOIN_B 0x01
+
+struct mp_dss {
+ uint8_t kind;
+ uint8_t len;
+ uint8_t sub;
+ uint8_t flags;
+};
+
+#define MP_DSS_F 0x10
+#define MP_DSS_m 0x08
+#define MP_DSS_M 0x04
+#define MP_DSS_a 0x02
+#define MP_DSS_A 0x01
+
+struct mp_add_addr {
+ uint8_t kind;
+ uint8_t len;
+ uint8_t sub_ipver;
+ uint8_t addr_id;
+ union {
+ struct {
+ uint8_t addr[4];
+ uint8_t port[2];
+ } v4;
+ struct {
+ uint8_t addr[16];
+ uint8_t port[2];
+ } v6;
+ } u;
+};
+
+#define MP_ADD_ADDR_IPVER(sub_ipver) (((sub_ipver) >> 0) & 0xF)
+
+struct mp_remove_addr {
+ uint8_t kind;
+ uint8_t len;
+ uint8_t sub;
+ /* list of addr_id */
+ uint8_t addrs_id;
+};
+
+struct mp_fail {
+ uint8_t kind;
+ uint8_t len;
+ uint8_t sub;
+ uint8_t resv;
+ uint8_t data_seq[8];
+};
+
+struct mp_close {
+ uint8_t kind;
+ uint8_t len;
+ uint8_t sub;
+ uint8_t rsv;
+ uint8_t key[8];
+};
+
+struct mp_prio {
+ uint8_t kind;
+ uint8_t len;
+ uint8_t sub_b;
+ uint8_t addr_id;
+};
+
+#define MP_PRIO_B 0x01
+
+static int
+dummy_print(netdissect_options *ndo _U_,
+ const u_char *opt _U_, u_int opt_len _U_, u_char flags _U_)
+{
+ return 1;
+}
+
+static int
+mp_capable_print(netdissect_options *ndo,
+ const u_char *opt, u_int opt_len, u_char flags)
+{
+ struct mp_capable *mpc = (struct mp_capable *) opt;
+
+ if (!(opt_len == 12 && flags & TH_SYN) &&
+ !(opt_len == 20 && (flags & (TH_SYN | TH_ACK)) == TH_ACK))
+ return 0;
+
+ if (MP_CAPABLE_OPT_VERSION(mpc->sub_ver) != 0) {
+ ND_PRINT((ndo, " Unknown Version (%d)", MP_CAPABLE_OPT_VERSION(mpc->sub_ver)));
+ return 1;
+ }
+
+ if (mpc->flags & MP_CAPABLE_C)
+ ND_PRINT((ndo, " csum"));
+ ND_PRINT((ndo, " {0x%" PRIx64, EXTRACT_64BITS(mpc->sender_key)));
+ if (opt_len == 20) /* ACK */
+ ND_PRINT((ndo, ",0x%" PRIx64, EXTRACT_64BITS(mpc->receiver_key)));
+ ND_PRINT((ndo, "}"));
+ return 1;
+}
+
+static int
+mp_join_print(netdissect_options *ndo,
+ const u_char *opt, u_int opt_len, u_char flags)
+{
+ struct mp_join *mpj = (struct mp_join *) opt;
+
+ if (!(opt_len == 12 && flags & TH_SYN) &&
+ !(opt_len == 16 && (flags & (TH_SYN | TH_ACK)) == (TH_SYN | TH_ACK)) &&
+ !(opt_len == 24 && flags & TH_ACK))
+ return 0;
+
+ if (opt_len != 24) {
+ if (mpj->sub_b & MP_JOIN_B)
+ ND_PRINT((ndo, " backup"));
+ ND_PRINT((ndo, " id %u", mpj->addr_id));
+ }
+
+ switch (opt_len) {
+ case 12: /* SYN */
+ ND_PRINT((ndo, " token 0x%x" " nonce 0x%x",
+ EXTRACT_32BITS(mpj->u.syn.token),
+ EXTRACT_32BITS(mpj->u.syn.nonce)));
+ break;
+ case 16: /* SYN/ACK */
+ ND_PRINT((ndo, " hmac 0x%" PRIx64 " nonce 0x%x",
+ EXTRACT_64BITS(mpj->u.synack.mac),
+ EXTRACT_32BITS(mpj->u.synack.nonce)));
+ break;
+ case 24: {/* ACK */
+ size_t i;
+ ND_PRINT((ndo, " hmac 0x"));
+ for (i = 0; i < sizeof(mpj->u.ack.mac); ++i)
+ ND_PRINT((ndo, "%02x", mpj->u.ack.mac[i]));
+ }
+ default:
+ break;
+ }
+ return 1;
+}
+
+static u_int mp_dss_len(struct mp_dss *m, int csum)
+{
+ u_int len;
+
+ len = 4;
+ if (m->flags & MP_DSS_A) {
+ /* Ack present - 4 or 8 octets */
+ len += (m->flags & MP_DSS_a) ? 8 : 4;
+ }
+ if (m->flags & MP_DSS_M) {
+ /*
+ * Data Sequence Number (DSN), Subflow Sequence Number (SSN),
+ * Data-Level Length present, and Checksum possibly present.
+ * All but the Checksum are 10 bytes if the m flag is
+ * clear (4-byte DSN) and 14 bytes if the m flag is set
+ * (8-byte DSN).
+ */
+ len += (m->flags & MP_DSS_m) ? 14 : 10;
+
+ /*
+ * The Checksum is present only if negotiated.
+ */
+ if (csum)
+ len += 2;
+ }
+ return len;
+}
+
+static int
+mp_dss_print(netdissect_options *ndo,
+ const u_char *opt, u_int opt_len, u_char flags)
+{
+ struct mp_dss *mdss = (struct mp_dss *) opt;
+
+ if ((opt_len != mp_dss_len(mdss, 1) &&
+ opt_len != mp_dss_len(mdss, 0)) || flags & TH_SYN)
+ return 0;
+
+ if (mdss->flags & MP_DSS_F)
+ ND_PRINT((ndo, " fin"));
+
+ opt += 4;
+ if (mdss->flags & MP_DSS_A) {
+ ND_PRINT((ndo, " ack "));
+ if (mdss->flags & MP_DSS_a) {
+ ND_PRINT((ndo, "%" PRIu64, EXTRACT_64BITS(opt)));
+ opt += 8;
+ } else {
+ ND_PRINT((ndo, "%u", EXTRACT_32BITS(opt)));
+ opt += 4;
+ }
+ }
+
+ if (mdss->flags & MP_DSS_M) {
+ ND_PRINT((ndo, " seq "));
+ if (mdss->flags & MP_DSS_m) {
+ ND_PRINT((ndo, "%" PRIu64, EXTRACT_64BITS(opt)));
+ opt += 8;
+ } else {
+ ND_PRINT((ndo, "%u", EXTRACT_32BITS(opt)));
+ opt += 4;
+ }
+ ND_PRINT((ndo, " subseq %u", EXTRACT_32BITS(opt)));
+ opt += 4;
+ ND_PRINT((ndo, " len %u", EXTRACT_16BITS(opt)));
+ opt += 2;
+
+ if (opt_len == mp_dss_len(mdss, 1))
+ ND_PRINT((ndo, " csum 0x%x", EXTRACT_16BITS(opt)));
+ }
+ return 1;
+}
+
+static int
+add_addr_print(netdissect_options *ndo,
+ const u_char *opt, u_int opt_len, u_char flags _U_)
+{
+ struct mp_add_addr *add_addr = (struct mp_add_addr *) opt;
+ u_int ipver = MP_ADD_ADDR_IPVER(add_addr->sub_ipver);
+
+ if (!((opt_len == 8 || opt_len == 10) && ipver == 4) &&
+ !((opt_len == 20 || opt_len == 22) && ipver == 6))
+ return 0;
+
+ ND_PRINT((ndo, " id %u", add_addr->addr_id));
+ switch (ipver) {
+ case 4:
+ ND_PRINT((ndo, " %s", ipaddr_string(ndo, add_addr->u.v4.addr)));
+ if (opt_len == 10)
+ ND_PRINT((ndo, ":%u", EXTRACT_16BITS(add_addr->u.v4.port)));
+ break;
+ case 6:
+#ifdef INET6
+ ND_PRINT((ndo, " %s", ip6addr_string(ndo, add_addr->u.v6.addr)));
+#endif
+ if (opt_len == 22)
+ ND_PRINT((ndo, ":%u", EXTRACT_16BITS(add_addr->u.v6.port)));
+ break;
+ default:
+ return 0;
+ }
+
+ return 1;
+}
+
+static int
+remove_addr_print(netdissect_options *ndo,
+ const u_char *opt, u_int opt_len, u_char flags _U_)
+{
+ struct mp_remove_addr *remove_addr = (struct mp_remove_addr *) opt;
+ uint8_t *addr_id = &remove_addr->addrs_id;
+
+ if (opt_len < 4)
+ return 0;
+
+ opt_len -= 3;
+ ND_PRINT((ndo, " id"));
+ while (opt_len--)
+ ND_PRINT((ndo, " %u", *addr_id++));
+ return 1;
+}
+
+static int
+mp_prio_print(netdissect_options *ndo,
+ const u_char *opt, u_int opt_len, u_char flags _U_)
+{
+ struct mp_prio *mpp = (struct mp_prio *) opt;
+
+ if (opt_len != 3 && opt_len != 4)
+ return 0;
+
+ if (mpp->sub_b & MP_PRIO_B)
+ ND_PRINT((ndo, " backup"));
+ else
+ ND_PRINT((ndo, " non-backup"));
+ if (opt_len == 4)
+ ND_PRINT((ndo, " id %u", mpp->addr_id));
+
+ return 1;
+}
+
+static int
+mp_fail_print(netdissect_options *ndo,
+ const u_char *opt, u_int opt_len, u_char flags _U_)
+{
+ if (opt_len != 12)
+ return 0;
+
+ ND_PRINT((ndo, " seq %" PRIu64, EXTRACT_64BITS(opt + 4)));
+ return 1;
+}
+
+static int
+mp_fast_close_print(netdissect_options *ndo,
+ const u_char *opt, u_int opt_len, u_char flags _U_)
+{
+ if (opt_len != 12)
+ return 0;
+
+ ND_PRINT((ndo, " key 0x%" PRIx64, EXTRACT_64BITS(opt + 4)));
+ return 1;
+}
+
+static const struct {
+ const char *name;
+ int (*print)(netdissect_options *, const u_char *, u_int, u_char);
+} mptcp_options[] = {
+ { "capable", mp_capable_print},
+ { "join", mp_join_print },
+ { "dss", mp_dss_print },
+ { "add-addr", add_addr_print },
+ { "rem-addr", remove_addr_print },
+ { "prio", mp_prio_print },
+ { "fail", mp_fail_print },
+ { "fast-close", mp_fast_close_print },
+ { "unknown", dummy_print },
+};
+
+int
+mptcp_print(netdissect_options *ndo,
+ const u_char *cp, u_int len, u_char flags)
+{
+ struct mptcp_option *opt;
+ u_int subtype;
+
+ if (len < 3)
+ return 0;
+
+ opt = (struct mptcp_option *) cp;
+ subtype = min(MPTCP_OPT_SUBTYPE(opt->sub_etc), MPTCP_SUB_FCLOSE + 1);
+
+ ND_PRINT((ndo, " %s", mptcp_options[subtype].name));
+ return mptcp_options[subtype].print(ndo, cp, len, flags);
+}
diff --git a/contrib/tcpdump/print-msdp.c b/contrib/tcpdump/print-msdp.c
index a228ab7cec53..fb802b58fd4d 100644
--- a/contrib/tcpdump/print-msdp.c
+++ b/contrib/tcpdump/print-msdp.c
@@ -15,20 +15,14 @@
* LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-msdp.c,v 1.7 2005-04-06 21:32:41 mcr Exp $";
-#endif
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <stdlib.h>
-
#include "interface.h"
#include "addrtoname.h"
#include "extract.h"
@@ -36,23 +30,23 @@ static const char rcsid[] _U_ =
#define MSDP_TYPE_MAX 7
void
-msdp_print(const unsigned char *sp, u_int length)
+msdp_print(netdissect_options *ndo, const u_char *sp, u_int length)
{
unsigned int type, len;
- TCHECK2(*sp, 3);
+ ND_TCHECK2(*sp, 3);
/* See if we think we're at the beginning of a compound packet */
type = *sp;
len = EXTRACT_16BITS(sp + 1);
if (len > 1500 || len < 3 || type == 0 || type > MSDP_TYPE_MAX)
goto trunc; /* not really truncated, but still not decodable */
- (void)printf(" msdp:");
+ ND_PRINT((ndo, " msdp:"));
while (length > 0) {
- TCHECK2(*sp, 3);
+ ND_TCHECK2(*sp, 3);
type = *sp;
len = EXTRACT_16BITS(sp + 1);
- if (len > 1400 || vflag)
- printf(" [len %u]", len);
+ if (len > 1400 || ndo->ndo_vflag)
+ ND_PRINT((ndo, " [len %u]", len));
if (len < 3)
goto trunc;
sp += 3;
@@ -61,35 +55,35 @@ msdp_print(const unsigned char *sp, u_int length)
case 1: /* IPv4 Source-Active */
case 3: /* IPv4 Source-Active Response */
if (type == 1)
- (void)printf(" SA");
+ ND_PRINT((ndo, " SA"));
else
- (void)printf(" SA-Response");
- TCHECK(*sp);
- (void)printf(" %u entries", *sp);
+ ND_PRINT((ndo, " SA-Response"));
+ ND_TCHECK(*sp);
+ ND_PRINT((ndo, " %u entries", *sp));
if ((u_int)((*sp * 12) + 8) < len) {
- (void)printf(" [w/data]");
- if (vflag > 1) {
- (void)printf(" ");
- ip_print(gndo, sp + *sp * 12 + 8 - 3,
+ ND_PRINT((ndo, " [w/data]"));
+ if (ndo->ndo_vflag > 1) {
+ ND_PRINT((ndo, " "));
+ ip_print(ndo, sp + *sp * 12 + 8 - 3,
len - (*sp * 12 + 8));
}
}
break;
case 2:
- (void)printf(" SA-Request");
- TCHECK2(*sp, 5);
- (void)printf(" for %s", ipaddr_string(sp + 1));
+ ND_PRINT((ndo, " SA-Request"));
+ ND_TCHECK2(*sp, 5);
+ ND_PRINT((ndo, " for %s", ipaddr_string(ndo, sp + 1)));
break;
case 4:
- (void)printf(" Keepalive");
+ ND_PRINT((ndo, " Keepalive"));
if (len != 3)
- (void)printf("[len=%d] ", len);
+ ND_PRINT((ndo, "[len=%d] ", len));
break;
case 5:
- (void)printf(" Notification");
+ ND_PRINT((ndo, " Notification"));
break;
default:
- (void)printf(" [type=%d len=%d]", type, len);
+ ND_PRINT((ndo, " [type=%d len=%d]", type, len));
break;
}
sp += (len - 3);
@@ -97,7 +91,7 @@ msdp_print(const unsigned char *sp, u_int length)
}
return;
trunc:
- (void)printf(" [|msdp]");
+ ND_PRINT((ndo, " [|msdp]"));
}
/*
diff --git a/contrib/tcpdump/print-msnlb.c b/contrib/tcpdump/print-msnlb.c
index 4c5fb0cbb45e..fcd000648268 100644
--- a/contrib/tcpdump/print-msnlb.c
+++ b/contrib/tcpdump/print-msnlb.c
@@ -26,30 +26,28 @@
* SUCH DAMAGE.
*/
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "netdissect.h"
+#include "interface.h"
#include "addrtoname.h"
#include "extract.h"
struct msnlb_heartbeat_pkt {
- u_int32_t unknown1;
- u_int32_t unknown2;
- u_int32_t host_prio; /* little-endian */
- u_int32_t virtual_ip;
- u_int32_t host_ip;
+ uint32_t unknown1;
+ uint32_t unknown2;
+ uint32_t host_prio; /* little-endian */
+ uint32_t virtual_ip;
+ uint32_t host_ip;
/* the protocol is undocumented so we ignore the rest */
};
void
-msnlb_print(netdissect_options *ndo, const u_char *bp, u_int length)
+msnlb_print(netdissect_options *ndo, const u_char *bp)
{
const struct msnlb_heartbeat_pkt *hb;
@@ -58,8 +56,8 @@ msnlb_print(netdissect_options *ndo, const u_char *bp, u_int length)
ND_PRINT((ndo, "MS NLB heartbeat, host priority: %u,",
EXTRACT_LE_32BITS(&(hb->host_prio))));
- ND_PRINT((ndo, " cluster IP: %s,", ipaddr_string(&(hb->virtual_ip))));
- ND_PRINT((ndo, " host IP: %s", ipaddr_string(&(hb->host_ip))));
+ ND_PRINT((ndo, " cluster IP: %s,", ipaddr_string(ndo, &(hb->virtual_ip))));
+ ND_PRINT((ndo, " host IP: %s", ipaddr_string(ndo, &(hb->host_ip))));
return;
trunc:
ND_PRINT((ndo, "[|MS NLB]"));
diff --git a/contrib/tcpdump/print-netbios.c b/contrib/tcpdump/print-netbios.c
deleted file mode 100644
index c92eb9e6b144..000000000000
--- a/contrib/tcpdump/print-netbios.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 1994, 1995, 1996
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that: (1) source code distributions
- * retain the above copyright notice and this paragraph in its entirety, (2)
- * distributions including binary code include the above copyright notice and
- * this paragraph in its entirety in the documentation or other materials
- * provided with the distribution, and (3) all advertising materials mentioning
- * features or use of this software display the following acknowledgement:
- * ``This product includes software developed by the University of California,
- * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
- * the University nor the names of its contributors may be used to endorse
- * or promote products derived from this software without specific prior
- * written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Format and print NETBIOS packets.
- * Contributed by Brad Parker (brad@fcr.com).
- */
-
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-netbios.c,v 1.20 2003-11-16 09:36:29 guy Exp $";
-#endif
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <tcpdump-stdinc.h>
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "interface.h"
-#include "addrtoname.h"
-#include "netbios.h"
-#include "extract.h"
-
-/*
- * Print NETBIOS packets.
- */
-void
-netbios_print(struct p8022Hdr *nb, u_int length)
-{
- if (length < p8022Size) {
- (void)printf(" truncated-netbios %d", length);
- return;
- }
-
- if (nb->flags == UI) {
- (void)printf("802.1 UI ");
- } else {
- (void)printf("802.1 CONN ");
- }
-
- if ((u_char *)(nb + 1) > snapend) {
- printf(" [|netbios]");
- return;
- }
-
-/*
- netbios_decode(nb, (u_char *)nb + p8022Size, length - p8022Size);
-*/
-}
-
-#ifdef never
- (void)printf("%s.%d > ",
- ipxaddr_string(EXTRACT_32BITS(ipx->srcNet), ipx->srcNode),
- EXTRACT_16BITS(ipx->srcSkt));
-
- (void)printf("%s.%d:",
- ipxaddr_string(EXTRACT_32BITS(ipx->dstNet), ipx->dstNode),
- EXTRACT_16BITS(ipx->dstSkt));
-
- if ((u_char *)(ipx + 1) > snapend) {
- printf(" [|ipx]");
- return;
- }
-
- /* take length from ipx header */
- length = EXTRACT_16BITS(&ipx->length);
-
- ipx_decode(ipx, (u_char *)ipx + ipxSize, length - ipxSize);
-#endif
-
diff --git a/contrib/tcpdump/print-nflog.c b/contrib/tcpdump/print-nflog.c
new file mode 100644
index 000000000000..cd0428bc2862
--- /dev/null
+++ b/contrib/tcpdump/print-nflog.c
@@ -0,0 +1,167 @@
+/*
+ * Copyright (c) 2013, Petar Alilovic,
+ * Faculty of Electrical Engineering and Computing, University of Zagreb
+ * 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 AUTHOR 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 AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+
+#define NETDISSECT_REWORKED
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tcpdump-stdinc.h>
+
+#include "interface.h"
+
+#if defined(DLT_NFLOG) && defined(HAVE_PCAP_NFLOG_H)
+#include <pcap/nflog.h>
+
+static const struct tok nflog_values[] = {
+ { AF_INET, "IPv4" },
+#ifdef INET6
+ { AF_INET6, "IPv6" },
+#endif /*INET6*/
+ { 0, NULL }
+};
+
+static inline void
+nflog_hdr_print(netdissect_options *ndo, const nflog_hdr_t *hdr, u_int length)
+{
+ ND_PRINT((ndo, "version %d, resource ID %d", hdr->nflog_version, ntohs(hdr->nflog_rid)));
+
+ if (!ndo->ndo_qflag) {
+ ND_PRINT((ndo,", family %s (%d)",
+ tok2str(nflog_values, "Unknown",
+ hdr->nflog_family),
+ hdr->nflog_family));
+ } else {
+ ND_PRINT((ndo,", %s",
+ tok2str(nflog_values,
+ "Unknown NFLOG (0x%02x)",
+ hdr->nflog_family)));
+ }
+
+ ND_PRINT((ndo, ", length %u: ", length));
+}
+
+u_int
+nflog_if_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, const u_char *p)
+{
+ const nflog_hdr_t *hdr = (const nflog_hdr_t *)p;
+ const nflog_tlv_t *tlv;
+ uint16_t size;
+ uint16_t h_size = sizeof(nflog_hdr_t);
+ u_int caplen = h->caplen;
+ u_int length = h->len;
+
+ if (caplen < (int) sizeof(nflog_hdr_t) || length < (int) sizeof(nflog_hdr_t)) {
+ ND_PRINT((ndo, "[|nflog]"));
+ return h_size;
+ }
+
+ if (!(hdr->nflog_version) == 0) {
+ ND_PRINT((ndo, "version %u (unknown)", hdr->nflog_version));
+ return h_size;
+ }
+
+ if (ndo->ndo_eflag)
+ nflog_hdr_print(ndo, hdr, length);
+
+ p += sizeof(nflog_hdr_t);
+ length -= sizeof(nflog_hdr_t);
+ caplen -= sizeof(nflog_hdr_t);
+
+ while (length > 0) {
+ /* We have some data. Do we have enough for the TLV header? */
+ if (caplen < sizeof(nflog_tlv_t) || length < sizeof(nflog_tlv_t)) {
+ /* No. */
+ ND_PRINT((ndo, "[|nflog]"));
+ return h_size;
+ }
+
+ tlv = (const nflog_tlv_t *) p;
+ size = tlv->tlv_length;
+ if (size % 4 != 0)
+ size += 4 - size % 4;
+
+ /* Is the TLV's length less than the minimum? */
+ if (size < sizeof(nflog_tlv_t)) {
+ /* Yes. Give up now. */
+ ND_PRINT((ndo, "[|nflog]"));
+ return h_size;
+ }
+
+ /* Do we have enough data for the full TLV? */
+ if (caplen < size || length < size) {
+ /* No. */
+ ND_PRINT((ndo, "[|nflog]"));
+ return h_size;
+ }
+
+ if (tlv->tlv_type == NFULA_PAYLOAD) {
+ /*
+ * This TLV's data is the packet payload.
+ * Skip past the TLV header, and break out
+ * of the loop so we print the packet data.
+ */
+ p += sizeof(nflog_tlv_t);
+ h_size += sizeof(nflog_tlv_t);
+ length -= sizeof(nflog_tlv_t);
+ caplen -= sizeof(nflog_tlv_t);
+ break;
+ }
+
+ p += size;
+ h_size += size;
+ length -= size;
+ caplen -= size;
+ }
+
+ switch (hdr->nflog_family) {
+
+ case AF_INET:
+ ip_print(ndo, p, length);
+ break;
+
+#ifdef INET6
+ case AF_INET6:
+ ip6_print(ndo, p, length);
+ break;
+#endif /*INET6*/
+
+ default:
+ if (!ndo->ndo_eflag)
+ nflog_hdr_print(ndo, hdr,
+ length + sizeof(nflog_hdr_t));
+
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
+ break;
+ }
+
+ return h_size;
+}
+
+#endif /* defined(DLT_NFLOG) && defined(HAVE_PCAP_NFLOG_H) */
diff --git a/contrib/tcpdump/print-nfs.c b/contrib/tcpdump/print-nfs.c
index 8d71fdc564de..d08fd95a6dec 100644
--- a/contrib/tcpdump/print-nfs.c
+++ b/contrib/tcpdump/print-nfs.c
@@ -21,18 +21,13 @@
* $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-nfs.c,v 1.111 2007-12-22 03:08:04 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <pcap.h>
#include <stdio.h>
#include <string.h>
@@ -50,19 +45,19 @@ static const char rcsid[] _U_ =
#include "rpc_auth.h"
#include "rpc_msg.h"
-static void nfs_printfh(const u_int32_t *, const u_int);
-static int xid_map_enter(const struct sunrpc_msg *, const u_char *);
-static int32_t xid_map_find(const struct sunrpc_msg *, const u_char *,
- u_int32_t *, u_int32_t *);
-static void interp_reply(const struct sunrpc_msg *, u_int32_t, u_int32_t, int);
-static const u_int32_t *parse_post_op_attr(const u_int32_t *, int);
-static void print_sattr3(const struct nfsv3_sattr *sa3, int verbose);
-static void print_nfsaddr(const u_char *, const char *, const char *);
+static const char tstr[] = " [|nfs]";
+
+static void nfs_printfh(netdissect_options *, const uint32_t *, const u_int);
+static int xid_map_enter(netdissect_options *, const struct sunrpc_msg *, const u_char *);
+static int xid_map_find(const struct sunrpc_msg *, const u_char *,
+ uint32_t *, uint32_t *);
+static void interp_reply(netdissect_options *, const struct sunrpc_msg *, uint32_t, uint32_t, int);
+static const uint32_t *parse_post_op_attr(netdissect_options *, const uint32_t *, int);
/*
* Mapping of old NFS Version 2 RPC numbers to generic numbers.
*/
-u_int32_t nfsv3_procid[NFS_NPROCS] = {
+uint32_t nfsv3_procid[NFS_NPROCS] = {
NFSPROC_NULL,
NFSPROC_GETATTR,
NFSPROC_SETATTR,
@@ -91,6 +86,33 @@ u_int32_t nfsv3_procid[NFS_NPROCS] = {
NFSPROC_NOOP
};
+static const struct tok nfsproc_str[] = {
+ { NFSPROC_NOOP, "nop" },
+ { NFSPROC_NULL, "null" },
+ { NFSPROC_GETATTR, "getattr" },
+ { NFSPROC_SETATTR, "setattr" },
+ { NFSPROC_LOOKUP, "lookup" },
+ { NFSPROC_ACCESS, "access" },
+ { NFSPROC_READLINK, "readlink" },
+ { NFSPROC_READ, "read" },
+ { NFSPROC_WRITE, "write" },
+ { NFSPROC_CREATE, "create" },
+ { NFSPROC_MKDIR, "mkdir" },
+ { NFSPROC_SYMLINK, "symlink" },
+ { NFSPROC_MKNOD, "mknod" },
+ { NFSPROC_REMOVE, "remove" },
+ { NFSPROC_RMDIR, "rmdir" },
+ { NFSPROC_RENAME, "rename" },
+ { NFSPROC_LINK, "link" },
+ { NFSPROC_READDIR, "readdir" },
+ { NFSPROC_READDIRPLUS, "readdirplus" },
+ { NFSPROC_FSSTAT, "fsstat" },
+ { NFSPROC_FSINFO, "fsinfo" },
+ { NFSPROC_PATHCONF, "pathconf" },
+ { NFSPROC_COMMIT, "commit" },
+ { 0, NULL }
+};
+
/*
* NFS V2 and V3 status values.
*
@@ -102,7 +124,7 @@ u_int32_t nfsv3_procid[NFS_NPROCS] = {
* the first NFS server was the SunOS 2.0 one, and until 5.0 SunOS
* was primarily BSD-derived.
*/
-static struct tok status2str[] = {
+static const struct tok status2str[] = {
{ 1, "Operation not permitted" }, /* EPERM */
{ 2, "No such file or directory" }, /* ENOENT */
{ 5, "Input/output error" }, /* EIO */
@@ -140,14 +162,14 @@ static struct tok status2str[] = {
{ 0, NULL }
};
-static struct tok nfsv3_writemodes[] = {
+static const struct tok nfsv3_writemodes[] = {
{ 0, "unstable" },
{ 1, "datasync" },
{ 2, "filesync" },
{ 0, NULL }
};
-static struct tok type2str[] = {
+static const struct tok type2str[] = {
{ NFNON, "NON" },
{ NFREG, "REG" },
{ NFDIR, "DIR" },
@@ -158,8 +180,30 @@ static struct tok type2str[] = {
{ 0, NULL }
};
+static const struct tok sunrpc_auth_str[] = {
+ { SUNRPC_AUTH_OK, "OK" },
+ { SUNRPC_AUTH_BADCRED, "Bogus Credentials (seal broken)" },
+ { SUNRPC_AUTH_REJECTEDCRED, "Rejected Credentials (client should begin new session)" },
+ { SUNRPC_AUTH_BADVERF, "Bogus Verifier (seal broken)" },
+ { SUNRPC_AUTH_REJECTEDVERF, "Verifier expired or was replayed" },
+ { SUNRPC_AUTH_TOOWEAK, "Credentials are too weak" },
+ { SUNRPC_AUTH_INVALIDRESP, "Bogus response verifier" },
+ { SUNRPC_AUTH_FAILED, "Unknown failure" },
+ { 0, NULL }
+};
+
+static const struct tok sunrpc_str[] = {
+ { SUNRPC_PROG_UNAVAIL, "PROG_UNAVAIL" },
+ { SUNRPC_PROG_MISMATCH, "PROG_MISMATCH" },
+ { SUNRPC_PROC_UNAVAIL, "PROC_UNAVAIL" },
+ { SUNRPC_GARBAGE_ARGS, "GARBAGE_ARGS" },
+ { SUNRPC_SYSTEM_ERR, "SYSTEM_ERR" },
+ { 0, NULL }
+};
+
static void
-print_nfsaddr(const u_char *bp, const char *s, const char *d)
+print_nfsaddr(netdissect_options *ndo,
+ const u_char *bp, const char *s, const char *d)
{
struct ip *ip;
#ifdef INET6
@@ -176,15 +220,15 @@ print_nfsaddr(const u_char *bp, const char *s, const char *d)
switch (IP_V((struct ip *)bp)) {
case 4:
ip = (struct ip *)bp;
- strlcpy(srcaddr, ipaddr_string(&ip->ip_src), sizeof(srcaddr));
- strlcpy(dstaddr, ipaddr_string(&ip->ip_dst), sizeof(dstaddr));
+ strlcpy(srcaddr, ipaddr_string(ndo, &ip->ip_src), sizeof(srcaddr));
+ strlcpy(dstaddr, ipaddr_string(ndo, &ip->ip_dst), sizeof(dstaddr));
break;
#ifdef INET6
case 6:
ip6 = (struct ip6_hdr *)bp;
- strlcpy(srcaddr, ip6addr_string(&ip6->ip6_src),
+ strlcpy(srcaddr, ip6addr_string(ndo, &ip6->ip6_src),
sizeof(srcaddr));
- strlcpy(dstaddr, ip6addr_string(&ip6->ip6_dst),
+ strlcpy(dstaddr, ip6addr_string(ndo, &ip6->ip6_dst),
sizeof(dstaddr));
break;
#endif
@@ -194,64 +238,65 @@ print_nfsaddr(const u_char *bp, const char *s, const char *d)
break;
}
- (void)printf("%s.%s > %s.%s: ", srcaddr, s, dstaddr, d);
+ ND_PRINT((ndo, "%s.%s > %s.%s: ", srcaddr, s, dstaddr, d));
}
-static const u_int32_t *
-parse_sattr3(const u_int32_t *dp, struct nfsv3_sattr *sa3)
+static const uint32_t *
+parse_sattr3(netdissect_options *ndo,
+ const uint32_t *dp, struct nfsv3_sattr *sa3)
{
- TCHECK(dp[0]);
+ ND_TCHECK(dp[0]);
sa3->sa_modeset = EXTRACT_32BITS(dp);
dp++;
if (sa3->sa_modeset) {
- TCHECK(dp[0]);
+ ND_TCHECK(dp[0]);
sa3->sa_mode = EXTRACT_32BITS(dp);
dp++;
}
- TCHECK(dp[0]);
+ ND_TCHECK(dp[0]);
sa3->sa_uidset = EXTRACT_32BITS(dp);
dp++;
if (sa3->sa_uidset) {
- TCHECK(dp[0]);
+ ND_TCHECK(dp[0]);
sa3->sa_uid = EXTRACT_32BITS(dp);
dp++;
}
- TCHECK(dp[0]);
+ ND_TCHECK(dp[0]);
sa3->sa_gidset = EXTRACT_32BITS(dp);
dp++;
if (sa3->sa_gidset) {
- TCHECK(dp[0]);
+ ND_TCHECK(dp[0]);
sa3->sa_gid = EXTRACT_32BITS(dp);
dp++;
}
- TCHECK(dp[0]);
+ ND_TCHECK(dp[0]);
sa3->sa_sizeset = EXTRACT_32BITS(dp);
dp++;
if (sa3->sa_sizeset) {
- TCHECK(dp[0]);
+ ND_TCHECK(dp[0]);
sa3->sa_size = EXTRACT_32BITS(dp);
dp++;
}
- TCHECK(dp[0]);
+ ND_TCHECK(dp[0]);
sa3->sa_atimetype = EXTRACT_32BITS(dp);
dp++;
if (sa3->sa_atimetype == NFSV3SATTRTIME_TOCLIENT) {
- TCHECK(dp[1]);
+ ND_TCHECK(dp[1]);
sa3->sa_atime.nfsv3_sec = EXTRACT_32BITS(dp);
dp++;
sa3->sa_atime.nfsv3_nsec = EXTRACT_32BITS(dp);
dp++;
}
- TCHECK(dp[0]);
+ ND_TCHECK(dp[0]);
sa3->sa_mtimetype = EXTRACT_32BITS(dp);
dp++;
if (sa3->sa_mtimetype == NFSV3SATTRTIME_TOCLIENT) {
- TCHECK(dp[1]);
+ ND_TCHECK(dp[1]);
sa3->sa_mtime.nfsv3_sec = EXTRACT_32BITS(dp);
dp++;
sa3->sa_mtime.nfsv3_nsec = EXTRACT_32BITS(dp);
@@ -266,41 +311,38 @@ trunc:
static int nfserr; /* true if we error rather than trunc */
static void
-print_sattr3(const struct nfsv3_sattr *sa3, int verbose)
+print_sattr3(netdissect_options *ndo,
+ const struct nfsv3_sattr *sa3, int verbose)
{
if (sa3->sa_modeset)
- printf(" mode %o", sa3->sa_mode);
+ ND_PRINT((ndo, " mode %o", sa3->sa_mode));
if (sa3->sa_uidset)
- printf(" uid %u", sa3->sa_uid);
+ ND_PRINT((ndo, " uid %u", sa3->sa_uid));
if (sa3->sa_gidset)
- printf(" gid %u", sa3->sa_gid);
+ ND_PRINT((ndo, " gid %u", sa3->sa_gid));
if (verbose > 1) {
if (sa3->sa_atimetype == NFSV3SATTRTIME_TOCLIENT)
- printf(" atime %u.%06u", sa3->sa_atime.nfsv3_sec,
- sa3->sa_atime.nfsv3_nsec);
+ ND_PRINT((ndo, " atime %u.%06u", sa3->sa_atime.nfsv3_sec,
+ sa3->sa_atime.nfsv3_nsec));
if (sa3->sa_mtimetype == NFSV3SATTRTIME_TOCLIENT)
- printf(" mtime %u.%06u", sa3->sa_mtime.nfsv3_sec,
- sa3->sa_mtime.nfsv3_nsec);
+ ND_PRINT((ndo, " mtime %u.%06u", sa3->sa_mtime.nfsv3_sec,
+ sa3->sa_mtime.nfsv3_nsec));
}
}
void
-nfsreply_print(register const u_char *bp, u_int length,
- register const u_char *bp2)
+nfsreply_print(netdissect_options *ndo,
+ register const u_char *bp, u_int length,
+ register const u_char *bp2)
{
register const struct sunrpc_msg *rp;
- u_int32_t proc, vers, reply_stat;
char srcid[20], dstid[20]; /*fits 32bit*/
- enum sunrpc_reject_stat rstat;
- u_int32_t rlow;
- u_int32_t rhigh;
- enum sunrpc_auth_stat rwhy;
nfserr = 0; /* assume no error */
rp = (const struct sunrpc_msg *)bp;
- TCHECK(rp->rm_xid);
- if (!nflag) {
+ ND_TCHECK(rp->rm_xid);
+ if (!ndo->ndo_nflag) {
strlcpy(srcid, "nfs", sizeof(srcid));
snprintf(dstid, sizeof(dstid), "%u",
EXTRACT_32BITS(&rp->rm_xid));
@@ -309,118 +351,101 @@ nfsreply_print(register const u_char *bp, u_int length,
snprintf(dstid, sizeof(dstid), "%u",
EXTRACT_32BITS(&rp->rm_xid));
}
- print_nfsaddr(bp2, srcid, dstid);
- TCHECK(rp->rm_reply.rp_stat);
+ print_nfsaddr(ndo, bp2, srcid, dstid);
+
+ nfsreply_print_noaddr(ndo, bp, length, bp2);
+ return;
+
+trunc:
+ if (!nfserr)
+ ND_PRINT((ndo, "%s", tstr));
+}
+
+void
+nfsreply_print_noaddr(netdissect_options *ndo,
+ register const u_char *bp, u_int length,
+ register const u_char *bp2)
+{
+ register const struct sunrpc_msg *rp;
+ uint32_t proc, vers, reply_stat;
+ enum sunrpc_reject_stat rstat;
+ uint32_t rlow;
+ uint32_t rhigh;
+ enum sunrpc_auth_stat rwhy;
+
+ nfserr = 0; /* assume no error */
+ rp = (const struct sunrpc_msg *)bp;
+
+ ND_TCHECK(rp->rm_reply.rp_stat);
reply_stat = EXTRACT_32BITS(&rp->rm_reply.rp_stat);
switch (reply_stat) {
case SUNRPC_MSG_ACCEPTED:
- (void)printf("reply ok %u", length);
+ ND_PRINT((ndo, "reply ok %u", length));
if (xid_map_find(rp, bp2, &proc, &vers) >= 0)
- interp_reply(rp, proc, vers, length);
+ interp_reply(ndo, rp, proc, vers, length);
break;
case SUNRPC_MSG_DENIED:
- (void)printf("reply ERR %u: ", length);
- TCHECK(rp->rm_reply.rp_reject.rj_stat);
+ ND_PRINT((ndo, "reply ERR %u: ", length));
+ ND_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);
+ ND_TCHECK(rp->rm_reply.rp_reject.rj_vers.high);
rlow = EXTRACT_32BITS(&rp->rm_reply.rp_reject.rj_vers.low);
rhigh = EXTRACT_32BITS(&rp->rm_reply.rp_reject.rj_vers.high);
- (void)printf("RPC Version mismatch (%u-%u)",
- rlow, rhigh);
+ ND_PRINT((ndo, "RPC Version mismatch (%u-%u)", rlow, rhigh));
break;
case SUNRPC_AUTH_ERROR:
- TCHECK(rp->rm_reply.rp_reject.rj_why);
+ ND_TCHECK(rp->rm_reply.rp_reject.rj_why);
rwhy = EXTRACT_32BITS(&rp->rm_reply.rp_reject.rj_why);
- (void)printf("Auth ");
- switch (rwhy) {
-
- case SUNRPC_AUTH_OK:
- (void)printf("OK");
- break;
-
- case SUNRPC_AUTH_BADCRED:
- (void)printf("Bogus Credentials (seal broken)");
- break;
-
- case SUNRPC_AUTH_REJECTEDCRED:
- (void)printf("Rejected Credentials (client should begin new session)");
- break;
-
- case SUNRPC_AUTH_BADVERF:
- (void)printf("Bogus Verifier (seal broken)");
- break;
-
- case SUNRPC_AUTH_REJECTEDVERF:
- (void)printf("Verifier expired or was replayed");
- break;
-
- case SUNRPC_AUTH_TOOWEAK:
- (void)printf("Credentials are too weak");
- break;
-
- case SUNRPC_AUTH_INVALIDRESP:
- (void)printf("Bogus response verifier");
- break;
-
- case SUNRPC_AUTH_FAILED:
- (void)printf("Unknown failure");
- break;
-
- default:
- (void)printf("Invalid failure code %u",
- (unsigned int)rwhy);
- break;
- }
+ ND_PRINT((ndo, "Auth %s", tok2str(sunrpc_auth_str, "Invalid failure code %u", rwhy)));
break;
default:
- (void)printf("Unknown reason for rejecting rpc message %u",
- (unsigned int)rstat);
+ ND_PRINT((ndo, "Unknown reason for rejecting rpc message %u", (unsigned int)rstat));
break;
}
break;
default:
- (void)printf("reply Unknown rpc response code=%u %u",
- reply_stat, length);
+ ND_PRINT((ndo, "reply Unknown rpc response code=%u %u", reply_stat, length));
break;
}
return;
trunc:
if (!nfserr)
- fputs(" [|nfs]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
}
/*
* Return a pointer to the first file handle in the packet.
* If the packet was truncated, return 0.
*/
-static const u_int32_t *
-parsereq(register const struct sunrpc_msg *rp, register u_int length)
+static const uint32_t *
+parsereq(netdissect_options *ndo,
+ register const struct sunrpc_msg *rp, register u_int length)
{
- register const u_int32_t *dp;
+ register const uint32_t *dp;
register u_int len;
/*
* find the start of the req data (if we captured it)
*/
- dp = (u_int32_t *)&rp->rm_call.cb_cred;
- TCHECK(dp[1]);
+ dp = (uint32_t *)&rp->rm_call.cb_cred;
+ ND_TCHECK(dp[1]);
len = EXTRACT_32BITS(&dp[1]);
if (len < length) {
dp += (len + (2 * sizeof(*dp) + 3)) / sizeof(*dp);
- TCHECK(dp[1]);
+ ND_TCHECK(dp[1]);
len = EXTRACT_32BITS(&dp[1]);
if (len < length) {
dp += (len + (2 * sizeof(*dp) + 3)) / sizeof(*dp);
- TCHECK2(dp[0], 0);
+ ND_TCHECK2(dp[0], 0);
return (dp);
}
}
@@ -432,20 +457,21 @@ trunc:
* Print out an NFS file handle and return a pointer to following word.
* If packet was truncated, return 0.
*/
-static const u_int32_t *
-parsefh(register const u_int32_t *dp, int v3)
+static const uint32_t *
+parsefh(netdissect_options *ndo,
+ register const uint32_t *dp, int v3)
{
u_int len;
if (v3) {
- TCHECK(dp[0]);
+ ND_TCHECK(dp[0]);
len = EXTRACT_32BITS(dp) / 4;
dp++;
} else
len = NFSX_V2FH / 4;
- if (TTEST2(*dp, len * sizeof(*dp))) {
- nfs_printfh(dp, len);
+ if (ND_TTEST2(*dp, len * sizeof(*dp))) {
+ nfs_printfh(ndo, dp, len);
return (dp + len);
}
trunc:
@@ -456,30 +482,31 @@ trunc:
* Print out a file name and return pointer to 32-bit word past it.
* If packet was truncated, return 0.
*/
-static const u_int32_t *
-parsefn(register const u_int32_t *dp)
+static const uint32_t *
+parsefn(netdissect_options *ndo,
+ register const uint32_t *dp)
{
- register u_int32_t len;
+ register uint32_t len;
register const u_char *cp;
/* Bail if we don't have the string length */
- TCHECK(*dp);
+ ND_TCHECK(*dp);
/* Fetch string length; convert to host order */
len = *dp++;
NTOHL(len);
- TCHECK2(*dp, ((len + 3) & ~3));
+ ND_TCHECK2(*dp, ((len + 3) & ~3));
cp = (u_char *)dp;
/* Update 32-bit pointer (NFS filenames padded to 32-bit boundaries) */
dp += ((len + 3) & ~3) / sizeof(*dp);
- putchar('"');
- if (fn_printn(cp, len, snapend)) {
- putchar('"');
+ ND_PRINT((ndo, "\""));
+ if (fn_printn(ndo, cp, len, ndo->ndo_snapend)) {
+ ND_PRINT((ndo, "\""));
goto trunc;
}
- putchar('"');
+ ND_PRINT((ndo, "\""));
return (dp);
trunc:
@@ -491,46 +518,35 @@ trunc:
* Return pointer to 32-bit word past file name.
* If packet was truncated (or there was some other error), return 0.
*/
-static const u_int32_t *
-parsefhn(register const u_int32_t *dp, int v3)
+static const uint32_t *
+parsefhn(netdissect_options *ndo,
+ register const uint32_t *dp, int v3)
{
- dp = parsefh(dp, v3);
+ dp = parsefh(ndo, dp, v3);
if (dp == NULL)
return (NULL);
- putchar(' ');
- return (parsefn(dp));
+ ND_PRINT((ndo, " "));
+ return (parsefn(ndo, dp));
}
void
-nfsreq_print(register const u_char *bp, u_int length,
- register const u_char *bp2)
+nfsreq_print_noaddr(netdissect_options *ndo,
+ register const u_char *bp, u_int length,
+ register const u_char *bp2)
{
register const struct sunrpc_msg *rp;
- register const u_int32_t *dp;
+ register const uint32_t *dp;
nfs_type type;
int v3;
- u_int32_t proc;
- u_int32_t access_flags;
+ uint32_t proc;
+ uint32_t access_flags;
struct nfsv3_sattr sa3;
- char srcid[20], dstid[20]; /*fits 32bit*/
+ ND_PRINT((ndo, "%d", 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));
- strlcpy(dstid, "nfs", sizeof(dstid));
- } else {
- snprintf(srcid, sizeof(srcid), "%u",
- EXTRACT_32BITS(&rp->rm_xid));
- snprintf(dstid, sizeof(dstid), "%u", NFS_PORT);
- }
- print_nfsaddr(bp2, srcid, dstid);
- (void)printf("%d", length);
-
- if (!xid_map_enter(rp, bp2)) /* record proc number for later on */
+ if (!xid_map_enter(ndo, rp, bp2)) /* record proc number for later on */
goto trunc;
v3 = (EXTRACT_32BITS(&rp->rm_call.cb_vers) == NFS_VER3);
@@ -539,307 +555,235 @@ nfsreq_print(register const u_char *bp, u_int length,
if (!v3 && proc < NFS_NPROCS)
proc = nfsv3_procid[proc];
+ ND_PRINT((ndo, " %s", tok2str(nfsproc_str, "proc-%u", proc)));
switch (proc) {
- case NFSPROC_NOOP:
- printf(" nop");
- return;
- case NFSPROC_NULL:
- printf(" null");
- return;
case NFSPROC_GETATTR:
- printf(" getattr");
- if ((dp = parsereq(rp, length)) != NULL &&
- parsefh(dp, v3) != NULL)
- return;
- break;
-
case NFSPROC_SETATTR:
- printf(" setattr");
- if ((dp = parsereq(rp, length)) != NULL &&
- parsefh(dp, v3) != NULL)
+ case NFSPROC_READLINK:
+ case NFSPROC_FSSTAT:
+ case NFSPROC_FSINFO:
+ case NFSPROC_PATHCONF:
+ if ((dp = parsereq(ndo, rp, length)) != NULL &&
+ parsefh(ndo, dp, v3) != NULL)
return;
break;
case NFSPROC_LOOKUP:
- printf(" lookup");
- if ((dp = parsereq(rp, length)) != NULL &&
- parsefhn(dp, v3) != NULL)
+ case NFSPROC_CREATE:
+ case NFSPROC_MKDIR:
+ case NFSPROC_REMOVE:
+ case NFSPROC_RMDIR:
+ if ((dp = parsereq(ndo, rp, length)) != NULL &&
+ parsefhn(ndo, dp, v3) != NULL)
return;
break;
case NFSPROC_ACCESS:
- printf(" access");
- if ((dp = parsereq(rp, length)) != NULL &&
- (dp = parsefh(dp, v3)) != NULL) {
- TCHECK(dp[0]);
+ if ((dp = parsereq(ndo, rp, length)) != NULL &&
+ (dp = parsefh(ndo, dp, v3)) != NULL) {
+ ND_TCHECK(dp[0]);
access_flags = EXTRACT_32BITS(&dp[0]);
if (access_flags & ~NFSV3ACCESS_FULL) {
/* NFSV3ACCESS definitions aren't up to date */
- printf(" %04x", access_flags);
+ ND_PRINT((ndo, " %04x", access_flags));
} else if ((access_flags & NFSV3ACCESS_FULL) == NFSV3ACCESS_FULL) {
- printf(" NFS_ACCESS_FULL");
+ ND_PRINT((ndo, " NFS_ACCESS_FULL"));
} else {
char separator = ' ';
if (access_flags & NFSV3ACCESS_READ) {
- printf(" NFS_ACCESS_READ");
+ ND_PRINT((ndo, " NFS_ACCESS_READ"));
separator = '|';
}
if (access_flags & NFSV3ACCESS_LOOKUP) {
- printf("%cNFS_ACCESS_LOOKUP", separator);
+ ND_PRINT((ndo, "%cNFS_ACCESS_LOOKUP", separator));
separator = '|';
}
if (access_flags & NFSV3ACCESS_MODIFY) {
- printf("%cNFS_ACCESS_MODIFY", separator);
+ ND_PRINT((ndo, "%cNFS_ACCESS_MODIFY", separator));
separator = '|';
}
if (access_flags & NFSV3ACCESS_EXTEND) {
- printf("%cNFS_ACCESS_EXTEND", separator);
+ ND_PRINT((ndo, "%cNFS_ACCESS_EXTEND", separator));
separator = '|';
}
if (access_flags & NFSV3ACCESS_DELETE) {
- printf("%cNFS_ACCESS_DELETE", separator);
+ ND_PRINT((ndo, "%cNFS_ACCESS_DELETE", separator));
separator = '|';
}
if (access_flags & NFSV3ACCESS_EXECUTE)
- printf("%cNFS_ACCESS_EXECUTE", separator);
+ ND_PRINT((ndo, "%cNFS_ACCESS_EXECUTE", separator));
}
return;
}
break;
- case NFSPROC_READLINK:
- printf(" readlink");
- if ((dp = parsereq(rp, length)) != NULL &&
- parsefh(dp, v3) != NULL)
- return;
- break;
-
case NFSPROC_READ:
- printf(" read");
- if ((dp = parsereq(rp, length)) != NULL &&
- (dp = parsefh(dp, v3)) != NULL) {
+ if ((dp = parsereq(ndo, rp, length)) != NULL &&
+ (dp = parsefh(ndo, dp, v3)) != NULL) {
if (v3) {
- TCHECK(dp[2]);
- printf(" %u bytes @ %" PRIu64,
+ ND_TCHECK(dp[2]);
+ ND_PRINT((ndo, " %u bytes @ %" PRIu64,
EXTRACT_32BITS(&dp[2]),
- EXTRACT_64BITS(&dp[0]));
+ EXTRACT_64BITS(&dp[0])));
} else {
- TCHECK(dp[1]);
- printf(" %u bytes @ %u",
+ ND_TCHECK(dp[1]);
+ ND_PRINT((ndo, " %u bytes @ %u",
EXTRACT_32BITS(&dp[1]),
- EXTRACT_32BITS(&dp[0]));
+ EXTRACT_32BITS(&dp[0])));
}
return;
}
break;
case NFSPROC_WRITE:
- printf(" write");
- if ((dp = parsereq(rp, length)) != NULL &&
- (dp = parsefh(dp, v3)) != NULL) {
+ if ((dp = parsereq(ndo, rp, length)) != NULL &&
+ (dp = parsefh(ndo, dp, v3)) != NULL) {
if (v3) {
- TCHECK(dp[2]);
- printf(" %u (%u) bytes @ %" PRIu64,
+ ND_TCHECK(dp[2]);
+ ND_PRINT((ndo, " %u (%u) bytes @ %" PRIu64,
EXTRACT_32BITS(&dp[4]),
EXTRACT_32BITS(&dp[2]),
- EXTRACT_64BITS(&dp[0]));
- if (vflag) {
+ EXTRACT_64BITS(&dp[0])));
+ if (ndo->ndo_vflag) {
dp += 3;
- TCHECK(dp[0]);
- printf(" <%s>",
+ ND_TCHECK(dp[0]);
+ ND_PRINT((ndo, " <%s>",
tok2str(nfsv3_writemodes,
- NULL, EXTRACT_32BITS(dp)));
+ NULL, EXTRACT_32BITS(dp))));
}
} else {
- TCHECK(dp[3]);
- printf(" %u (%u) bytes @ %u (%u)",
+ ND_TCHECK(dp[3]);
+ ND_PRINT((ndo, " %u (%u) bytes @ %u (%u)",
EXTRACT_32BITS(&dp[3]),
EXTRACT_32BITS(&dp[2]),
EXTRACT_32BITS(&dp[1]),
- EXTRACT_32BITS(&dp[0]));
+ EXTRACT_32BITS(&dp[0])));
}
return;
}
break;
- case NFSPROC_CREATE:
- printf(" create");
- if ((dp = parsereq(rp, length)) != NULL &&
- parsefhn(dp, v3) != NULL)
- return;
- break;
-
- case NFSPROC_MKDIR:
- printf(" mkdir");
- if ((dp = parsereq(rp, length)) != 0 && parsefhn(dp, v3) != 0)
- return;
- break;
-
case NFSPROC_SYMLINK:
- printf(" symlink");
- if ((dp = parsereq(rp, length)) != 0 &&
- (dp = parsefhn(dp, v3)) != 0) {
- fputs(" ->", stdout);
- if (v3 && (dp = parse_sattr3(dp, &sa3)) == 0)
+ if ((dp = parsereq(ndo, rp, length)) != 0 &&
+ (dp = parsefhn(ndo, dp, v3)) != 0) {
+ ND_PRINT((ndo, " ->"));
+ if (v3 && (dp = parse_sattr3(ndo, dp, &sa3)) == 0)
break;
- if (parsefn(dp) == 0)
+ if (parsefn(ndo, dp) == 0)
break;
- if (v3 && vflag)
- print_sattr3(&sa3, vflag);
+ if (v3 && ndo->ndo_vflag)
+ print_sattr3(ndo, &sa3, ndo->ndo_vflag);
return;
}
break;
case NFSPROC_MKNOD:
- printf(" mknod");
- if ((dp = parsereq(rp, length)) != 0 &&
- (dp = parsefhn(dp, v3)) != 0) {
- TCHECK(*dp);
+ if ((dp = parsereq(ndo, rp, length)) != 0 &&
+ (dp = parsefhn(ndo, dp, v3)) != 0) {
+ ND_TCHECK(*dp);
type = (nfs_type)EXTRACT_32BITS(dp);
dp++;
- if ((dp = parse_sattr3(dp, &sa3)) == 0)
+ if ((dp = parse_sattr3(ndo, dp, &sa3)) == 0)
break;
- printf(" %s", tok2str(type2str, "unk-ft %d", type));
- if (vflag && (type == NFCHR || type == NFBLK)) {
- TCHECK(dp[1]);
- printf(" %u/%u",
+ ND_PRINT((ndo, " %s", tok2str(type2str, "unk-ft %d", type)));
+ if (ndo->ndo_vflag && (type == NFCHR || type == NFBLK)) {
+ ND_TCHECK(dp[1]);
+ ND_PRINT((ndo, " %u/%u",
EXTRACT_32BITS(&dp[0]),
- EXTRACT_32BITS(&dp[1]));
+ EXTRACT_32BITS(&dp[1])));
dp += 2;
}
- if (vflag)
- print_sattr3(&sa3, vflag);
+ if (ndo->ndo_vflag)
+ print_sattr3(ndo, &sa3, ndo->ndo_vflag);
return;
}
break;
- case NFSPROC_REMOVE:
- printf(" remove");
- if ((dp = parsereq(rp, length)) != NULL &&
- parsefhn(dp, v3) != NULL)
- return;
- break;
-
- case NFSPROC_RMDIR:
- printf(" rmdir");
- if ((dp = parsereq(rp, length)) != NULL &&
- parsefhn(dp, v3) != NULL)
- return;
- break;
-
case NFSPROC_RENAME:
- printf(" rename");
- if ((dp = parsereq(rp, length)) != NULL &&
- (dp = parsefhn(dp, v3)) != NULL) {
- fputs(" ->", stdout);
- if (parsefhn(dp, v3) != NULL)
+ if ((dp = parsereq(ndo, rp, length)) != NULL &&
+ (dp = parsefhn(ndo, dp, v3)) != NULL) {
+ ND_PRINT((ndo, " ->"));
+ if (parsefhn(ndo, dp, v3) != NULL)
return;
}
break;
case NFSPROC_LINK:
- printf(" link");
- if ((dp = parsereq(rp, length)) != NULL &&
- (dp = parsefh(dp, v3)) != NULL) {
- fputs(" ->", stdout);
- if (parsefhn(dp, v3) != NULL)
+ if ((dp = parsereq(ndo, rp, length)) != NULL &&
+ (dp = parsefh(ndo, dp, v3)) != NULL) {
+ ND_PRINT((ndo, " ->"));
+ if (parsefhn(ndo, dp, v3) != NULL)
return;
}
break;
case NFSPROC_READDIR:
- printf(" readdir");
- if ((dp = parsereq(rp, length)) != NULL &&
- (dp = parsefh(dp, v3)) != NULL) {
+ if ((dp = parsereq(ndo, rp, length)) != NULL &&
+ (dp = parsefh(ndo, dp, v3)) != NULL) {
if (v3) {
- TCHECK(dp[4]);
+ ND_TCHECK(dp[4]);
/*
* We shouldn't really try to interpret the
* offset cookie here.
*/
- printf(" %u bytes @ %" PRId64,
+ ND_PRINT((ndo, " %u bytes @ %" PRId64,
EXTRACT_32BITS(&dp[4]),
- EXTRACT_64BITS(&dp[0]));
- if (vflag)
- printf(" verf %08x%08x", dp[2],
- dp[3]);
+ EXTRACT_64BITS(&dp[0])));
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, " verf %08x%08x", dp[2], dp[3]));
} else {
- TCHECK(dp[1]);
+ ND_TCHECK(dp[1]);
/*
* Print the offset as signed, since -1 is
* common, but offsets > 2^31 aren't.
*/
- printf(" %u bytes @ %d",
+ ND_PRINT((ndo, " %u bytes @ %d",
EXTRACT_32BITS(&dp[1]),
- EXTRACT_32BITS(&dp[0]));
+ EXTRACT_32BITS(&dp[0])));
}
return;
}
break;
case NFSPROC_READDIRPLUS:
- printf(" readdirplus");
- if ((dp = parsereq(rp, length)) != NULL &&
- (dp = parsefh(dp, v3)) != NULL) {
- TCHECK(dp[4]);
+ if ((dp = parsereq(ndo, rp, length)) != NULL &&
+ (dp = parsefh(ndo, dp, v3)) != NULL) {
+ ND_TCHECK(dp[4]);
/*
* We don't try to interpret the offset
* cookie here.
*/
- printf(" %u bytes @ %" PRId64,
+ ND_PRINT((ndo, " %u bytes @ %" PRId64,
EXTRACT_32BITS(&dp[4]),
- EXTRACT_64BITS(&dp[0]));
- if (vflag) {
- TCHECK(dp[5]);
- printf(" max %u verf %08x%08x",
- EXTRACT_32BITS(&dp[5]), dp[2], dp[3]);
+ EXTRACT_64BITS(&dp[0])));
+ if (ndo->ndo_vflag) {
+ ND_TCHECK(dp[5]);
+ ND_PRINT((ndo, " max %u verf %08x%08x",
+ EXTRACT_32BITS(&dp[5]), dp[2], dp[3]));
}
return;
}
break;
- case NFSPROC_FSSTAT:
- printf(" fsstat");
- if ((dp = parsereq(rp, length)) != NULL &&
- parsefh(dp, v3) != NULL)
- return;
- break;
-
- case NFSPROC_FSINFO:
- printf(" fsinfo");
- if ((dp = parsereq(rp, length)) != NULL &&
- parsefh(dp, v3) != NULL)
- return;
- break;
-
- case NFSPROC_PATHCONF:
- printf(" pathconf");
- if ((dp = parsereq(rp, length)) != NULL &&
- parsefh(dp, v3) != NULL)
- return;
- break;
-
case NFSPROC_COMMIT:
- printf(" commit");
- if ((dp = parsereq(rp, length)) != NULL &&
- (dp = parsefh(dp, v3)) != NULL) {
- TCHECK(dp[2]);
- printf(" %u bytes @ %" PRIu64,
+ if ((dp = parsereq(ndo, rp, length)) != NULL &&
+ (dp = parsefh(ndo, dp, v3)) != NULL) {
+ ND_TCHECK(dp[2]);
+ ND_PRINT((ndo, " %u bytes @ %" PRIu64,
EXTRACT_32BITS(&dp[2]),
- EXTRACT_64BITS(&dp[0]));
+ EXTRACT_64BITS(&dp[0])));
return;
}
break;
default:
- printf(" proc-%u", EXTRACT_32BITS(&rp->rm_call.cb_proc));
return;
}
trunc:
if (!nfserr)
- fputs(" [|nfs]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
}
/*
@@ -852,23 +796,24 @@ trunc:
* additional hacking on the parser code.
*/
static void
-nfs_printfh(register const u_int32_t *dp, const u_int len)
+nfs_printfh(netdissect_options *ndo,
+ register const uint32_t *dp, const u_int len)
{
my_fsid fsid;
- ino_t ino;
+ uint32_t ino;
const char *sfsname = NULL;
char *spacep;
- if (uflag) {
+ if (ndo->ndo_uflag) {
u_int i;
char const *sep = "";
- printf(" fh[");
+ ND_PRINT((ndo, " fh["));
for (i=0; i<len; i++) {
- (void)printf("%s%x", sep, dp[i]);
+ ND_PRINT((ndo, "%s%x", sep, dp[i]));
sep = ":";
}
- printf("]");
+ ND_PRINT((ndo, "]"));
return;
}
@@ -886,17 +831,17 @@ nfs_printfh(register const u_int32_t *dp, const u_int len)
if (spacep)
*spacep = '\0';
- (void)printf(" fh %s/", temp);
+ ND_PRINT((ndo, " fh %s/", temp));
} else {
- (void)printf(" fh %d,%d/",
- fsid.Fsid_dev.Major, fsid.Fsid_dev.Minor);
+ ND_PRINT((ndo, " fh %d,%d/",
+ fsid.Fsid_dev.Major, fsid.Fsid_dev.Minor));
}
if(fsid.Fsid_dev.Minor == 257)
/* Print the undecoded handle */
- (void)printf("%s", fsid.Opaque_Handle);
+ ND_PRINT((ndo, "%s", fsid.Opaque_Handle));
else
- (void)printf("%ld", (long) ino);
+ ND_PRINT((ndo, "%ld", (long) ino));
}
/*
@@ -906,7 +851,7 @@ nfs_printfh(register const u_int32_t *dp, const u_int len)
*/
struct xid_map_entry {
- u_int32_t xid; /* transaction ID (net order) */
+ uint32_t xid; /* transaction ID (net order) */
int ipver; /* IP version (4 or 6) */
#ifdef INET6
struct in6_addr client; /* client IP address (net order) */
@@ -915,8 +860,8 @@ struct xid_map_entry {
struct in_addr client; /* client IP address (net order) */
struct in_addr server; /* server IP address (net order) */
#endif
- u_int32_t proc; /* call proc number (host order) */
- u_int32_t vers; /* program version (host order) */
+ uint32_t proc; /* call proc number (host order) */
+ uint32_t vers; /* program version (host order) */
};
/*
@@ -933,7 +878,8 @@ int xid_map_next = 0;
int xid_map_hint = 0;
static int
-xid_map_enter(const struct sunrpc_msg *rp, const u_char *bp)
+xid_map_enter(netdissect_options *ndo,
+ const struct sunrpc_msg *rp, const u_char *bp)
{
struct ip *ip = NULL;
#ifdef INET6
@@ -941,7 +887,7 @@ 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))
+ if (!ND_TTEST(rp->rm_call.cb_vers))
return (0);
switch (IP_V((struct ip *)bp)) {
case 4:
@@ -961,17 +907,17 @@ xid_map_enter(const struct sunrpc_msg *rp, const u_char *bp)
if (++xid_map_next >= XIDMAPSIZE)
xid_map_next = 0;
- xmep->xid = rp->rm_xid;
+ UNALIGNED_MEMCPY(&xmep->xid, &rp->rm_xid, sizeof(xmep->xid));
if (ip) {
xmep->ipver = 4;
- memcpy(&xmep->client, &ip->ip_src, sizeof(ip->ip_src));
- memcpy(&xmep->server, &ip->ip_dst, sizeof(ip->ip_dst));
+ UNALIGNED_MEMCPY(&xmep->client, &ip->ip_src, sizeof(ip->ip_src));
+ UNALIGNED_MEMCPY(&xmep->server, &ip->ip_dst, sizeof(ip->ip_dst));
}
#ifdef INET6
else if (ip6) {
xmep->ipver = 6;
- memcpy(&xmep->client, &ip6->ip6_src, sizeof(ip6->ip6_src));
- memcpy(&xmep->server, &ip6->ip6_dst, sizeof(ip6->ip6_dst));
+ UNALIGNED_MEMCPY(&xmep->client, &ip6->ip6_src, sizeof(ip6->ip6_src));
+ UNALIGNED_MEMCPY(&xmep->server, &ip6->ip6_dst, sizeof(ip6->ip6_dst));
}
#endif
xmep->proc = EXTRACT_32BITS(&rp->rm_call.cb_proc);
@@ -984,12 +930,12 @@ xid_map_enter(const struct sunrpc_msg *rp, const u_char *bp)
* version in vers return, or returns -1 on failure
*/
static int
-xid_map_find(const struct sunrpc_msg *rp, const u_char *bp, u_int32_t *proc,
- u_int32_t *vers)
+xid_map_find(const struct sunrpc_msg *rp, const u_char *bp, uint32_t *proc,
+ uint32_t *vers)
{
int i;
struct xid_map_entry *xmep;
- u_int32_t xid = rp->rm_xid;
+ uint32_t xid = rp->rm_xid;
struct ip *ip = (struct ip *)bp;
#ifdef INET6
struct ip6_hdr *ip6 = (struct ip6_hdr *)bp;
@@ -1005,18 +951,18 @@ xid_map_find(const struct sunrpc_msg *rp, const u_char *bp, u_int32_t *proc,
goto nextitem;
switch (xmep->ipver) {
case 4:
- if (memcmp(&ip->ip_src, &xmep->server,
+ if (UNALIGNED_MEMCMP(&ip->ip_src, &xmep->server,
sizeof(ip->ip_src)) != 0 ||
- memcmp(&ip->ip_dst, &xmep->client,
+ UNALIGNED_MEMCMP(&ip->ip_dst, &xmep->client,
sizeof(ip->ip_dst)) != 0) {
cmp = 0;
}
break;
#ifdef INET6
case 6:
- if (memcmp(&ip6->ip6_src, &xmep->server,
+ if (UNALIGNED_MEMCMP(&ip6->ip6_src, &xmep->server,
sizeof(ip6->ip6_src)) != 0 ||
- memcmp(&ip6->ip6_dst, &xmep->client,
+ UNALIGNED_MEMCMP(&ip6->ip6_dst, &xmep->client,
sizeof(ip6->ip6_dst)) != 0) {
cmp = 0;
}
@@ -1050,10 +996,11 @@ xid_map_find(const struct sunrpc_msg *rp, const u_char *bp, u_int32_t *proc,
* Return a pointer to the beginning of the actual results.
* If the packet was truncated, return 0.
*/
-static const u_int32_t *
-parserep(register const struct sunrpc_msg *rp, register u_int length)
+static const uint32_t *
+parserep(netdissect_options *ndo,
+ register const struct sunrpc_msg *rp, register u_int length)
{
- register const u_int32_t *dp;
+ register const uint32_t *dp;
u_int len;
enum sunrpc_accept_stat astat;
@@ -1061,7 +1008,7 @@ parserep(register const struct sunrpc_msg *rp, register u_int length)
* Portability note:
* Here we find the address of the ar_verf credentials.
* Originally, this calculation was
- * dp = (u_int32_t *)&rp->rm_reply.rp_acpt.ar_verf
+ * dp = (uint32_t *)&rp->rm_reply.rp_acpt.ar_verf
* On the wire, the rp_acpt field starts immediately after
* the (32 bit) rp_stat field. However, rp_acpt (which is a
* "struct accepted_reply") contains a "struct opaque_auth",
@@ -1072,77 +1019,48 @@ parserep(register const struct sunrpc_msg *rp, register u_int length)
* representation. Instead, we skip past the rp_stat field,
* which is an "enum" and so occupies one 32-bit word.
*/
- dp = ((const u_int32_t *)&rp->rm_reply) + 1;
- TCHECK(dp[1]);
+ dp = ((const uint32_t *)&rp->rm_reply) + 1;
+ ND_TCHECK(dp[1]);
len = EXTRACT_32BITS(&dp[1]);
if (len >= length)
return (NULL);
/*
* skip past the ar_verf credentials.
*/
- dp += (len + (2*sizeof(u_int32_t) + 3)) / sizeof(u_int32_t);
- TCHECK2(dp[0], 0);
+ dp += (len + (2*sizeof(uint32_t) + 3)) / sizeof(uint32_t);
+ ND_TCHECK2(dp[0], 0);
/*
* now we can check the ar_stat field
*/
astat = (enum sunrpc_accept_stat) EXTRACT_32BITS(dp);
- switch (astat) {
-
- case SUNRPC_SUCCESS:
- break;
-
- case SUNRPC_PROG_UNAVAIL:
- printf(" PROG_UNAVAIL");
- nfserr = 1; /* suppress trunc string */
- return (NULL);
-
- case SUNRPC_PROG_MISMATCH:
- printf(" PROG_MISMATCH");
- nfserr = 1; /* suppress trunc string */
- return (NULL);
-
- case SUNRPC_PROC_UNAVAIL:
- printf(" PROC_UNAVAIL");
- nfserr = 1; /* suppress trunc string */
- return (NULL);
-
- case SUNRPC_GARBAGE_ARGS:
- printf(" GARBAGE_ARGS");
- nfserr = 1; /* suppress trunc string */
- return (NULL);
-
- case SUNRPC_SYSTEM_ERR:
- printf(" SYSTEM_ERR");
- nfserr = 1; /* suppress trunc string */
- return (NULL);
-
- default:
- printf(" ar_stat %d", astat);
+ if (astat != SUNRPC_SUCCESS) {
+ ND_PRINT((ndo, " %s", tok2str(sunrpc_str, "ar_stat %d", astat)));
nfserr = 1; /* suppress trunc string */
return (NULL);
}
/* successful return */
- TCHECK2(*dp, sizeof(astat));
- return ((u_int32_t *) (sizeof(astat) + ((char *)dp)));
+ ND_TCHECK2(*dp, sizeof(astat));
+ return ((uint32_t *) (sizeof(astat) + ((char *)dp)));
trunc:
return (0);
}
-static const u_int32_t *
-parsestatus(const u_int32_t *dp, int *er)
+static const uint32_t *
+parsestatus(netdissect_options *ndo,
+ const uint32_t *dp, int *er)
{
int errnum;
- TCHECK(dp[0]);
+ ND_TCHECK(dp[0]);
errnum = EXTRACT_32BITS(&dp[0]);
if (er)
*er = errnum;
if (errnum != 0) {
- if (!qflag)
- printf(" ERROR: %s",
- tok2str(status2str, "unk %d", errnum));
+ if (!ndo->ndo_qflag)
+ ND_PRINT((ndo, " ERROR: %s",
+ tok2str(status2str, "unk %d", errnum)));
nfserr = 1;
}
return (dp + 1);
@@ -1150,166 +1068,171 @@ trunc:
return NULL;
}
-static const u_int32_t *
-parsefattr(const u_int32_t *dp, int verbose, int v3)
+static const uint32_t *
+parsefattr(netdissect_options *ndo,
+ const uint32_t *dp, int verbose, int v3)
{
const struct nfs_fattr *fap;
fap = (const struct nfs_fattr *)dp;
- TCHECK(fap->fa_gid);
+ ND_TCHECK(fap->fa_gid);
if (verbose) {
- printf(" %s %o ids %d/%d",
+ ND_PRINT((ndo, " %s %o ids %d/%d",
tok2str(type2str, "unk-ft %d ",
EXTRACT_32BITS(&fap->fa_type)),
EXTRACT_32BITS(&fap->fa_mode),
EXTRACT_32BITS(&fap->fa_uid),
- EXTRACT_32BITS(&fap->fa_gid));
+ EXTRACT_32BITS(&fap->fa_gid)));
if (v3) {
- TCHECK(fap->fa3_size);
- printf(" sz %" PRIu64,
- EXTRACT_64BITS((u_int32_t *)&fap->fa3_size));
+ ND_TCHECK(fap->fa3_size);
+ ND_PRINT((ndo, " sz %" PRIu64,
+ EXTRACT_64BITS((uint32_t *)&fap->fa3_size)));
} else {
- TCHECK(fap->fa2_size);
- printf(" sz %d", EXTRACT_32BITS(&fap->fa2_size));
+ ND_TCHECK(fap->fa2_size);
+ ND_PRINT((ndo, " sz %d", EXTRACT_32BITS(&fap->fa2_size)));
}
}
/* print lots more stuff */
if (verbose > 1) {
if (v3) {
- TCHECK(fap->fa3_ctime);
- printf(" nlink %d rdev %d/%d",
+ ND_TCHECK(fap->fa3_ctime);
+ ND_PRINT((ndo, " nlink %d rdev %d/%d",
EXTRACT_32BITS(&fap->fa_nlink),
EXTRACT_32BITS(&fap->fa3_rdev.specdata1),
- EXTRACT_32BITS(&fap->fa3_rdev.specdata2));
- printf(" fsid %" PRIx64,
- EXTRACT_64BITS((u_int32_t *)&fap->fa3_fsid));
- printf(" fileid %" PRIx64,
- EXTRACT_64BITS((u_int32_t *)&fap->fa3_fileid));
- printf(" a/m/ctime %u.%06u",
+ EXTRACT_32BITS(&fap->fa3_rdev.specdata2)));
+ ND_PRINT((ndo, " fsid %" PRIx64,
+ EXTRACT_64BITS((uint32_t *)&fap->fa3_fsid)));
+ ND_PRINT((ndo, " fileid %" PRIx64,
+ EXTRACT_64BITS((uint32_t *)&fap->fa3_fileid)));
+ ND_PRINT((ndo, " a/m/ctime %u.%06u",
EXTRACT_32BITS(&fap->fa3_atime.nfsv3_sec),
- EXTRACT_32BITS(&fap->fa3_atime.nfsv3_nsec));
- printf(" %u.%06u",
+ EXTRACT_32BITS(&fap->fa3_atime.nfsv3_nsec)));
+ ND_PRINT((ndo, " %u.%06u",
EXTRACT_32BITS(&fap->fa3_mtime.nfsv3_sec),
- EXTRACT_32BITS(&fap->fa3_mtime.nfsv3_nsec));
- printf(" %u.%06u",
+ EXTRACT_32BITS(&fap->fa3_mtime.nfsv3_nsec)));
+ ND_PRINT((ndo, " %u.%06u",
EXTRACT_32BITS(&fap->fa3_ctime.nfsv3_sec),
- EXTRACT_32BITS(&fap->fa3_ctime.nfsv3_nsec));
+ EXTRACT_32BITS(&fap->fa3_ctime.nfsv3_nsec)));
} else {
- TCHECK(fap->fa2_ctime);
- printf(" nlink %d rdev %x fsid %x nodeid %x a/m/ctime",
+ ND_TCHECK(fap->fa2_ctime);
+ ND_PRINT((ndo, " nlink %d rdev 0x%x fsid 0x%x nodeid 0x%x a/m/ctime",
EXTRACT_32BITS(&fap->fa_nlink),
EXTRACT_32BITS(&fap->fa2_rdev),
EXTRACT_32BITS(&fap->fa2_fsid),
- EXTRACT_32BITS(&fap->fa2_fileid));
- printf(" %u.%06u",
+ EXTRACT_32BITS(&fap->fa2_fileid)));
+ ND_PRINT((ndo, " %u.%06u",
EXTRACT_32BITS(&fap->fa2_atime.nfsv2_sec),
- EXTRACT_32BITS(&fap->fa2_atime.nfsv2_usec));
- printf(" %u.%06u",
+ EXTRACT_32BITS(&fap->fa2_atime.nfsv2_usec)));
+ ND_PRINT((ndo, " %u.%06u",
EXTRACT_32BITS(&fap->fa2_mtime.nfsv2_sec),
- EXTRACT_32BITS(&fap->fa2_mtime.nfsv2_usec));
- printf(" %u.%06u",
+ EXTRACT_32BITS(&fap->fa2_mtime.nfsv2_usec)));
+ ND_PRINT((ndo, " %u.%06u",
EXTRACT_32BITS(&fap->fa2_ctime.nfsv2_sec),
- EXTRACT_32BITS(&fap->fa2_ctime.nfsv2_usec));
+ EXTRACT_32BITS(&fap->fa2_ctime.nfsv2_usec)));
}
}
- return ((const u_int32_t *)((unsigned char *)dp +
+ return ((const uint32_t *)((unsigned char *)dp +
(v3 ? NFSX_V3FATTR : NFSX_V2FATTR)));
trunc:
return (NULL);
}
static int
-parseattrstat(const u_int32_t *dp, int verbose, int v3)
+parseattrstat(netdissect_options *ndo,
+ const uint32_t *dp, int verbose, int v3)
{
int er;
- dp = parsestatus(dp, &er);
+ dp = parsestatus(ndo, dp, &er);
if (dp == NULL)
return (0);
if (er)
return (1);
- return (parsefattr(dp, verbose, v3) != NULL);
+ return (parsefattr(ndo, dp, verbose, v3) != NULL);
}
static int
-parsediropres(const u_int32_t *dp)
+parsediropres(netdissect_options *ndo,
+ const uint32_t *dp)
{
int er;
- if (!(dp = parsestatus(dp, &er)))
+ if (!(dp = parsestatus(ndo, dp, &er)))
return (0);
if (er)
return (1);
- dp = parsefh(dp, 0);
+ dp = parsefh(ndo, dp, 0);
if (dp == NULL)
return (0);
- return (parsefattr(dp, vflag, 0) != NULL);
+ return (parsefattr(ndo, dp, ndo->ndo_vflag, 0) != NULL);
}
static int
-parselinkres(const u_int32_t *dp, int v3)
+parselinkres(netdissect_options *ndo,
+ const uint32_t *dp, int v3)
{
int er;
- dp = parsestatus(dp, &er);
+ dp = parsestatus(ndo, dp, &er);
if (dp == NULL)
return(0);
if (er)
return(1);
- if (v3 && !(dp = parse_post_op_attr(dp, vflag)))
+ if (v3 && !(dp = parse_post_op_attr(ndo, dp, ndo->ndo_vflag)))
return (0);
- putchar(' ');
- return (parsefn(dp) != NULL);
+ ND_PRINT((ndo, " "));
+ return (parsefn(ndo, dp) != NULL);
}
static int
-parsestatfs(const u_int32_t *dp, int v3)
+parsestatfs(netdissect_options *ndo,
+ const uint32_t *dp, int v3)
{
const struct nfs_statfs *sfsp;
int er;
- dp = parsestatus(dp, &er);
+ dp = parsestatus(ndo, dp, &er);
if (dp == NULL)
return (0);
if (!v3 && er)
return (1);
- if (qflag)
+ if (ndo->ndo_qflag)
return(1);
if (v3) {
- if (vflag)
- printf(" POST:");
- if (!(dp = parse_post_op_attr(dp, vflag)))
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, " POST:"));
+ if (!(dp = parse_post_op_attr(ndo, dp, ndo->ndo_vflag)))
return (0);
}
- TCHECK2(*dp, (v3 ? NFSX_V3STATFS : NFSX_V2STATFS));
+ ND_TCHECK2(*dp, (v3 ? NFSX_V3STATFS : NFSX_V2STATFS));
sfsp = (const struct nfs_statfs *)dp;
if (v3) {
- printf(" tbytes %" PRIu64 " fbytes %" PRIu64 " abytes %" PRIu64,
- EXTRACT_64BITS((u_int32_t *)&sfsp->sf_tbytes),
- EXTRACT_64BITS((u_int32_t *)&sfsp->sf_fbytes),
- EXTRACT_64BITS((u_int32_t *)&sfsp->sf_abytes));
- if (vflag) {
- printf(" tfiles %" PRIu64 " ffiles %" PRIu64 " afiles %" PRIu64 " invar %u",
- EXTRACT_64BITS((u_int32_t *)&sfsp->sf_tfiles),
- EXTRACT_64BITS((u_int32_t *)&sfsp->sf_ffiles),
- EXTRACT_64BITS((u_int32_t *)&sfsp->sf_afiles),
- EXTRACT_32BITS(&sfsp->sf_invarsec));
+ ND_PRINT((ndo, " tbytes %" PRIu64 " fbytes %" PRIu64 " abytes %" PRIu64,
+ EXTRACT_64BITS((uint32_t *)&sfsp->sf_tbytes),
+ EXTRACT_64BITS((uint32_t *)&sfsp->sf_fbytes),
+ EXTRACT_64BITS((uint32_t *)&sfsp->sf_abytes)));
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, " tfiles %" PRIu64 " ffiles %" PRIu64 " afiles %" PRIu64 " invar %u",
+ EXTRACT_64BITS((uint32_t *)&sfsp->sf_tfiles),
+ EXTRACT_64BITS((uint32_t *)&sfsp->sf_ffiles),
+ EXTRACT_64BITS((uint32_t *)&sfsp->sf_afiles),
+ EXTRACT_32BITS(&sfsp->sf_invarsec)));
}
} else {
- printf(" tsize %d bsize %d blocks %d bfree %d bavail %d",
+ ND_PRINT((ndo, " tsize %d bsize %d blocks %d bfree %d bavail %d",
EXTRACT_32BITS(&sfsp->sf_tsize),
EXTRACT_32BITS(&sfsp->sf_bsize),
EXTRACT_32BITS(&sfsp->sf_blocks),
EXTRACT_32BITS(&sfsp->sf_bfree),
- EXTRACT_32BITS(&sfsp->sf_bavail));
+ EXTRACT_32BITS(&sfsp->sf_bavail)));
}
return (1);
@@ -1318,52 +1241,55 @@ trunc:
}
static int
-parserddires(const u_int32_t *dp)
+parserddires(netdissect_options *ndo,
+ const uint32_t *dp)
{
int er;
- dp = parsestatus(dp, &er);
+ dp = parsestatus(ndo, dp, &er);
if (dp == NULL)
return (0);
if (er)
return (1);
- if (qflag)
+ if (ndo->ndo_qflag)
return (1);
- TCHECK(dp[2]);
- printf(" offset %x size %d ",
- EXTRACT_32BITS(&dp[0]), EXTRACT_32BITS(&dp[1]));
+ ND_TCHECK(dp[2]);
+ ND_PRINT((ndo, " offset 0x%x size %d ",
+ EXTRACT_32BITS(&dp[0]), EXTRACT_32BITS(&dp[1])));
if (dp[2] != 0)
- printf(" eof");
+ ND_PRINT((ndo, " eof"));
return (1);
trunc:
return (0);
}
-static const u_int32_t *
-parse_wcc_attr(const u_int32_t *dp)
+static const uint32_t *
+parse_wcc_attr(netdissect_options *ndo,
+ const uint32_t *dp)
{
- printf(" sz %" PRIu64, EXTRACT_64BITS(&dp[0]));
- printf(" mtime %u.%06u ctime %u.%06u",
+ ND_PRINT((ndo, " sz %" PRIu64, EXTRACT_64BITS(&dp[0])));
+ ND_PRINT((ndo, " mtime %u.%06u ctime %u.%06u",
EXTRACT_32BITS(&dp[2]), EXTRACT_32BITS(&dp[3]),
- EXTRACT_32BITS(&dp[4]), EXTRACT_32BITS(&dp[5]));
+ EXTRACT_32BITS(&dp[4]), EXTRACT_32BITS(&dp[5])));
return (dp + 6);
}
/*
* Pre operation attributes. Print only if vflag > 1.
*/
-static const u_int32_t *
-parse_pre_op_attr(const u_int32_t *dp, int verbose)
+static const uint32_t *
+parse_pre_op_attr(netdissect_options *ndo,
+ const uint32_t *dp, int verbose)
{
- TCHECK(dp[0]);
+ ND_TCHECK(dp[0]);
if (!EXTRACT_32BITS(&dp[0]))
return (dp + 1);
dp++;
- TCHECK2(*dp, 24);
+ ND_TCHECK2(*dp, 24);
if (verbose > 1) {
- return parse_wcc_attr(dp);
+ return parse_wcc_attr(ndo, dp);
} else {
/* If not verbose enough, just skip over wcc_attr */
return (dp + 6);
@@ -1375,56 +1301,59 @@ trunc:
/*
* Post operation attributes are printed if vflag >= 1
*/
-static const u_int32_t *
-parse_post_op_attr(const u_int32_t *dp, int verbose)
+static const uint32_t *
+parse_post_op_attr(netdissect_options *ndo,
+ const uint32_t *dp, int verbose)
{
- TCHECK(dp[0]);
+ ND_TCHECK(dp[0]);
if (!EXTRACT_32BITS(&dp[0]))
return (dp + 1);
dp++;
if (verbose) {
- return parsefattr(dp, verbose, 1);
+ return parsefattr(ndo, dp, verbose, 1);
} else
- return (dp + (NFSX_V3FATTR / sizeof (u_int32_t)));
+ return (dp + (NFSX_V3FATTR / sizeof (uint32_t)));
trunc:
return (NULL);
}
-static const u_int32_t *
-parse_wcc_data(const u_int32_t *dp, int verbose)
+static const uint32_t *
+parse_wcc_data(netdissect_options *ndo,
+ const uint32_t *dp, int verbose)
{
if (verbose > 1)
- printf(" PRE:");
- if (!(dp = parse_pre_op_attr(dp, verbose)))
+ ND_PRINT((ndo, " PRE:"));
+ if (!(dp = parse_pre_op_attr(ndo, dp, verbose)))
return (0);
if (verbose)
- printf(" POST:");
- return parse_post_op_attr(dp, verbose);
+ ND_PRINT((ndo, " POST:"));
+ return parse_post_op_attr(ndo, dp, verbose);
}
-static const u_int32_t *
-parsecreateopres(const u_int32_t *dp, int verbose)
+static const uint32_t *
+parsecreateopres(netdissect_options *ndo,
+ const uint32_t *dp, int verbose)
{
int er;
- if (!(dp = parsestatus(dp, &er)))
+ if (!(dp = parsestatus(ndo, dp, &er)))
return (0);
if (er)
- dp = parse_wcc_data(dp, verbose);
+ dp = parse_wcc_data(ndo, dp, verbose);
else {
- TCHECK(dp[0]);
+ ND_TCHECK(dp[0]);
if (!EXTRACT_32BITS(&dp[0]))
return (dp + 1);
dp++;
- if (!(dp = parsefh(dp, 1)))
+ if (!(dp = parsefh(ndo, dp, 1)))
return (0);
if (verbose) {
- if (!(dp = parse_post_op_attr(dp, verbose)))
+ if (!(dp = parse_post_op_attr(ndo, dp, verbose)))
return (0);
- if (vflag > 1) {
- printf(" dir attr:");
- dp = parse_wcc_data(dp, verbose);
+ if (ndo->ndo_vflag > 1) {
+ ND_PRINT((ndo, " dir attr:"));
+ dp = parse_wcc_data(ndo, dp, verbose);
}
}
}
@@ -1434,31 +1363,33 @@ trunc:
}
static int
-parsewccres(const u_int32_t *dp, int verbose)
+parsewccres(netdissect_options *ndo,
+ const uint32_t *dp, int verbose)
{
int er;
- if (!(dp = parsestatus(dp, &er)))
+ if (!(dp = parsestatus(ndo, dp, &er)))
return (0);
- return parse_wcc_data(dp, verbose) != 0;
+ return parse_wcc_data(ndo, dp, verbose) != 0;
}
-static const u_int32_t *
-parsev3rddirres(const u_int32_t *dp, int verbose)
+static const uint32_t *
+parsev3rddirres(netdissect_options *ndo,
+ const uint32_t *dp, int verbose)
{
int er;
- if (!(dp = parsestatus(dp, &er)))
+ if (!(dp = parsestatus(ndo, dp, &er)))
return (0);
- if (vflag)
- printf(" POST:");
- if (!(dp = parse_post_op_attr(dp, verbose)))
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, " POST:"));
+ if (!(dp = parse_post_op_attr(ndo, dp, verbose)))
return (0);
if (er)
return dp;
- if (vflag) {
- TCHECK(dp[1]);
- printf(" verf %08x%08x", dp[0], dp[1]);
+ if (ndo->ndo_vflag) {
+ ND_TCHECK(dp[1]);
+ ND_PRINT((ndo, " verf %08x%08x", dp[0], dp[1]));
dp += 2;
}
return dp;
@@ -1467,36 +1398,37 @@ trunc:
}
static int
-parsefsinfo(const u_int32_t *dp)
+parsefsinfo(netdissect_options *ndo,
+ const uint32_t *dp)
{
struct nfsv3_fsinfo *sfp;
int er;
- if (!(dp = parsestatus(dp, &er)))
+ if (!(dp = parsestatus(ndo, dp, &er)))
return (0);
- if (vflag)
- printf(" POST:");
- if (!(dp = parse_post_op_attr(dp, vflag)))
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, " POST:"));
+ if (!(dp = parse_post_op_attr(ndo, dp, ndo->ndo_vflag)))
return (0);
if (er)
return (1);
sfp = (struct nfsv3_fsinfo *)dp;
- TCHECK(*sfp);
- printf(" rtmax %u rtpref %u wtmax %u wtpref %u dtpref %u",
+ ND_TCHECK(*sfp);
+ ND_PRINT((ndo, " rtmax %u rtpref %u wtmax %u wtpref %u dtpref %u",
EXTRACT_32BITS(&sfp->fs_rtmax),
EXTRACT_32BITS(&sfp->fs_rtpref),
EXTRACT_32BITS(&sfp->fs_wtmax),
EXTRACT_32BITS(&sfp->fs_wtpref),
- EXTRACT_32BITS(&sfp->fs_dtpref));
- if (vflag) {
- printf(" rtmult %u wtmult %u maxfsz %" PRIu64,
+ EXTRACT_32BITS(&sfp->fs_dtpref)));
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, " rtmult %u wtmult %u maxfsz %" PRIu64,
EXTRACT_32BITS(&sfp->fs_rtmult),
EXTRACT_32BITS(&sfp->fs_wtmult),
- EXTRACT_64BITS((u_int32_t *)&sfp->fs_maxfilesize));
- printf(" delta %u.%06u ",
+ EXTRACT_64BITS((uint32_t *)&sfp->fs_maxfilesize)));
+ ND_PRINT((ndo, " delta %u.%06u ",
EXTRACT_32BITS(&sfp->fs_timedelta.nfsv3_sec),
- EXTRACT_32BITS(&sfp->fs_timedelta.nfsv3_nsec));
+ EXTRACT_32BITS(&sfp->fs_timedelta.nfsv3_nsec)));
}
return (1);
trunc:
@@ -1504,39 +1436,41 @@ trunc:
}
static int
-parsepathconf(const u_int32_t *dp)
+parsepathconf(netdissect_options *ndo,
+ const uint32_t *dp)
{
int er;
struct nfsv3_pathconf *spp;
- if (!(dp = parsestatus(dp, &er)))
+ if (!(dp = parsestatus(ndo, dp, &er)))
return (0);
- if (vflag)
- printf(" POST:");
- if (!(dp = parse_post_op_attr(dp, vflag)))
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, " POST:"));
+ if (!(dp = parse_post_op_attr(ndo, dp, ndo->ndo_vflag)))
return (0);
if (er)
return (1);
spp = (struct nfsv3_pathconf *)dp;
- TCHECK(*spp);
+ ND_TCHECK(*spp);
- printf(" linkmax %u namemax %u %s %s %s %s",
+ ND_PRINT((ndo, " linkmax %u namemax %u %s %s %s %s",
EXTRACT_32BITS(&spp->pc_linkmax),
EXTRACT_32BITS(&spp->pc_namemax),
EXTRACT_32BITS(&spp->pc_notrunc) ? "notrunc" : "",
EXTRACT_32BITS(&spp->pc_chownrestricted) ? "chownres" : "",
EXTRACT_32BITS(&spp->pc_caseinsensitive) ? "igncase" : "",
- EXTRACT_32BITS(&spp->pc_casepreserving) ? "keepcase" : "");
+ EXTRACT_32BITS(&spp->pc_casepreserving) ? "keepcase" : ""));
return (1);
trunc:
return (0);
}
static void
-interp_reply(const struct sunrpc_msg *rp, u_int32_t proc, u_int32_t vers, int length)
+interp_reply(netdissect_options *ndo,
+ const struct sunrpc_msg *rp, uint32_t proc, uint32_t vers, int length)
{
- register const u_int32_t *dp;
+ register const uint32_t *dp;
register int v3;
int er;
@@ -1545,309 +1479,258 @@ interp_reply(const struct sunrpc_msg *rp, u_int32_t proc, u_int32_t vers, int le
if (!v3 && proc < NFS_NPROCS)
proc = nfsv3_procid[proc];
+ ND_PRINT((ndo, " %s", tok2str(nfsproc_str, "proc-%u", proc)));
switch (proc) {
- case NFSPROC_NOOP:
- printf(" nop");
- return;
-
- case NFSPROC_NULL:
- printf(" null");
- return;
-
case NFSPROC_GETATTR:
- printf(" getattr");
- dp = parserep(rp, length);
- if (dp != NULL && parseattrstat(dp, !qflag, v3) != 0)
+ dp = parserep(ndo, rp, length);
+ if (dp != NULL && parseattrstat(ndo, dp, !ndo->ndo_qflag, v3) != 0)
return;
break;
case NFSPROC_SETATTR:
- printf(" setattr");
- if (!(dp = parserep(rp, length)))
+ if (!(dp = parserep(ndo, rp, length)))
return;
if (v3) {
- if (parsewccres(dp, vflag))
+ if (parsewccres(ndo, dp, ndo->ndo_vflag))
return;
} else {
- if (parseattrstat(dp, !qflag, 0) != 0)
+ if (parseattrstat(ndo, dp, !ndo->ndo_qflag, 0) != 0)
return;
}
break;
case NFSPROC_LOOKUP:
- printf(" lookup");
- if (!(dp = parserep(rp, length)))
+ if (!(dp = parserep(ndo, rp, length)))
break;
if (v3) {
- if (!(dp = parsestatus(dp, &er)))
+ if (!(dp = parsestatus(ndo, dp, &er)))
break;
if (er) {
- if (vflag > 1) {
- printf(" post dattr:");
- dp = parse_post_op_attr(dp, vflag);
+ if (ndo->ndo_vflag > 1) {
+ ND_PRINT((ndo, " post dattr:"));
+ dp = parse_post_op_attr(ndo, dp, ndo->ndo_vflag);
}
} else {
- if (!(dp = parsefh(dp, v3)))
+ if (!(dp = parsefh(ndo, dp, v3)))
break;
- if ((dp = parse_post_op_attr(dp, vflag)) &&
- vflag > 1) {
- printf(" post dattr:");
- dp = parse_post_op_attr(dp, vflag);
+ if ((dp = parse_post_op_attr(ndo, dp, ndo->ndo_vflag)) &&
+ ndo->ndo_vflag > 1) {
+ ND_PRINT((ndo, " post dattr:"));
+ dp = parse_post_op_attr(ndo, dp, ndo->ndo_vflag);
}
}
if (dp)
return;
} else {
- if (parsediropres(dp) != 0)
+ if (parsediropres(ndo, dp) != 0)
return;
}
break;
case NFSPROC_ACCESS:
- printf(" access");
- if (!(dp = parserep(rp, length)))
+ if (!(dp = parserep(ndo, rp, length)))
break;
- if (!(dp = parsestatus(dp, &er)))
+ if (!(dp = parsestatus(ndo, dp, &er)))
break;
- if (vflag)
- printf(" attr:");
- if (!(dp = parse_post_op_attr(dp, vflag)))
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, " attr:"));
+ if (!(dp = parse_post_op_attr(ndo, dp, ndo->ndo_vflag)))
break;
if (!er)
- printf(" c %04x", EXTRACT_32BITS(&dp[0]));
+ ND_PRINT((ndo, " c %04x", EXTRACT_32BITS(&dp[0])));
return;
case NFSPROC_READLINK:
- printf(" readlink");
- dp = parserep(rp, length);
- if (dp != NULL && parselinkres(dp, v3) != 0)
+ dp = parserep(ndo, rp, length);
+ if (dp != NULL && parselinkres(ndo, dp, v3) != 0)
return;
break;
case NFSPROC_READ:
- printf(" read");
- if (!(dp = parserep(rp, length)))
+ if (!(dp = parserep(ndo, rp, length)))
break;
if (v3) {
- if (!(dp = parsestatus(dp, &er)))
+ if (!(dp = parsestatus(ndo, dp, &er)))
break;
- if (!(dp = parse_post_op_attr(dp, vflag)))
+ if (!(dp = parse_post_op_attr(ndo, dp, ndo->ndo_vflag)))
break;
if (er)
return;
- if (vflag) {
- TCHECK(dp[1]);
- printf(" %u bytes", EXTRACT_32BITS(&dp[0]));
+ if (ndo->ndo_vflag) {
+ ND_TCHECK(dp[1]);
+ ND_PRINT((ndo, " %u bytes", EXTRACT_32BITS(&dp[0])));
if (EXTRACT_32BITS(&dp[1]))
- printf(" EOF");
+ ND_PRINT((ndo, " EOF"));
}
return;
} else {
- if (parseattrstat(dp, vflag, 0) != 0)
+ if (parseattrstat(ndo, dp, ndo->ndo_vflag, 0) != 0)
return;
}
break;
case NFSPROC_WRITE:
- printf(" write");
- if (!(dp = parserep(rp, length)))
+ if (!(dp = parserep(ndo, rp, length)))
break;
if (v3) {
- if (!(dp = parsestatus(dp, &er)))
+ if (!(dp = parsestatus(ndo, dp, &er)))
break;
- if (!(dp = parse_wcc_data(dp, vflag)))
+ if (!(dp = parse_wcc_data(ndo, dp, ndo->ndo_vflag)))
break;
if (er)
return;
- if (vflag) {
- TCHECK(dp[0]);
- printf(" %u bytes", EXTRACT_32BITS(&dp[0]));
- if (vflag > 1) {
- TCHECK(dp[1]);
- printf(" <%s>",
+ if (ndo->ndo_vflag) {
+ ND_TCHECK(dp[0]);
+ ND_PRINT((ndo, " %u bytes", EXTRACT_32BITS(&dp[0])));
+ if (ndo->ndo_vflag > 1) {
+ ND_TCHECK(dp[1]);
+ ND_PRINT((ndo, " <%s>",
tok2str(nfsv3_writemodes,
- NULL, EXTRACT_32BITS(&dp[1])));
+ NULL, EXTRACT_32BITS(&dp[1]))));
}
return;
}
} else {
- if (parseattrstat(dp, vflag, v3) != 0)
+ if (parseattrstat(ndo, dp, ndo->ndo_vflag, v3) != 0)
return;
}
break;
case NFSPROC_CREATE:
- printf(" create");
- if (!(dp = parserep(rp, length)))
- break;
- if (v3) {
- if (parsecreateopres(dp, vflag) != 0)
- return;
- } else {
- if (parsediropres(dp) != 0)
- return;
- }
- break;
-
case NFSPROC_MKDIR:
- printf(" mkdir");
- if (!(dp = parserep(rp, length)))
+ if (!(dp = parserep(ndo, rp, length)))
break;
if (v3) {
- if (parsecreateopres(dp, vflag) != 0)
+ if (parsecreateopres(ndo, dp, ndo->ndo_vflag) != 0)
return;
} else {
- if (parsediropres(dp) != 0)
+ if (parsediropres(ndo, dp) != 0)
return;
}
break;
case NFSPROC_SYMLINK:
- printf(" symlink");
- if (!(dp = parserep(rp, length)))
+ if (!(dp = parserep(ndo, rp, length)))
break;
if (v3) {
- if (parsecreateopres(dp, vflag) != 0)
+ if (parsecreateopres(ndo, dp, ndo->ndo_vflag) != 0)
return;
} else {
- if (parsestatus(dp, &er) != 0)
+ if (parsestatus(ndo, dp, &er) != 0)
return;
}
break;
case NFSPROC_MKNOD:
- printf(" mknod");
- if (!(dp = parserep(rp, length)))
+ if (!(dp = parserep(ndo, rp, length)))
break;
- if (parsecreateopres(dp, vflag) != 0)
+ if (parsecreateopres(ndo, dp, ndo->ndo_vflag) != 0)
return;
break;
case NFSPROC_REMOVE:
- printf(" remove");
- if (!(dp = parserep(rp, length)))
- break;
- if (v3) {
- if (parsewccres(dp, vflag))
- return;
- } else {
- if (parsestatus(dp, &er) != 0)
- return;
- }
- break;
-
case NFSPROC_RMDIR:
- printf(" rmdir");
- if (!(dp = parserep(rp, length)))
+ if (!(dp = parserep(ndo, rp, length)))
break;
if (v3) {
- if (parsewccres(dp, vflag))
+ if (parsewccres(ndo, dp, ndo->ndo_vflag))
return;
} else {
- if (parsestatus(dp, &er) != 0)
+ if (parsestatus(ndo, dp, &er) != 0)
return;
}
break;
case NFSPROC_RENAME:
- printf(" rename");
- if (!(dp = parserep(rp, length)))
+ if (!(dp = parserep(ndo, rp, length)))
break;
if (v3) {
- if (!(dp = parsestatus(dp, &er)))
+ if (!(dp = parsestatus(ndo, dp, &er)))
break;
- if (vflag) {
- printf(" from:");
- if (!(dp = parse_wcc_data(dp, vflag)))
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, " from:"));
+ if (!(dp = parse_wcc_data(ndo, dp, ndo->ndo_vflag)))
break;
- printf(" to:");
- if (!(dp = parse_wcc_data(dp, vflag)))
+ ND_PRINT((ndo, " to:"));
+ if (!(dp = parse_wcc_data(ndo, dp, ndo->ndo_vflag)))
break;
}
return;
} else {
- if (parsestatus(dp, &er) != 0)
+ if (parsestatus(ndo, dp, &er) != 0)
return;
}
break;
case NFSPROC_LINK:
- printf(" link");
- if (!(dp = parserep(rp, length)))
+ if (!(dp = parserep(ndo, rp, length)))
break;
if (v3) {
- if (!(dp = parsestatus(dp, &er)))
+ if (!(dp = parsestatus(ndo, dp, &er)))
break;
- if (vflag) {
- printf(" file POST:");
- if (!(dp = parse_post_op_attr(dp, vflag)))
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, " file POST:"));
+ if (!(dp = parse_post_op_attr(ndo, dp, ndo->ndo_vflag)))
break;
- printf(" dir:");
- if (!(dp = parse_wcc_data(dp, vflag)))
+ ND_PRINT((ndo, " dir:"));
+ if (!(dp = parse_wcc_data(ndo, dp, ndo->ndo_vflag)))
break;
return;
}
} else {
- if (parsestatus(dp, &er) != 0)
+ if (parsestatus(ndo, dp, &er) != 0)
return;
}
break;
case NFSPROC_READDIR:
- printf(" readdir");
- if (!(dp = parserep(rp, length)))
+ if (!(dp = parserep(ndo, rp, length)))
break;
if (v3) {
- if (parsev3rddirres(dp, vflag))
+ if (parsev3rddirres(ndo, dp, ndo->ndo_vflag))
return;
} else {
- if (parserddires(dp) != 0)
+ if (parserddires(ndo, dp) != 0)
return;
}
break;
case NFSPROC_READDIRPLUS:
- printf(" readdirplus");
- if (!(dp = parserep(rp, length)))
+ if (!(dp = parserep(ndo, rp, length)))
break;
- if (parsev3rddirres(dp, vflag))
+ if (parsev3rddirres(ndo, dp, ndo->ndo_vflag))
return;
break;
case NFSPROC_FSSTAT:
- printf(" fsstat");
- dp = parserep(rp, length);
- if (dp != NULL && parsestatfs(dp, v3) != 0)
+ dp = parserep(ndo, rp, length);
+ if (dp != NULL && parsestatfs(ndo, dp, v3) != 0)
return;
break;
case NFSPROC_FSINFO:
- printf(" fsinfo");
- dp = parserep(rp, length);
- if (dp != NULL && parsefsinfo(dp) != 0)
+ dp = parserep(ndo, rp, length);
+ if (dp != NULL && parsefsinfo(ndo, dp) != 0)
return;
break;
case NFSPROC_PATHCONF:
- printf(" pathconf");
- dp = parserep(rp, length);
- if (dp != NULL && parsepathconf(dp) != 0)
+ dp = parserep(ndo, rp, length);
+ if (dp != NULL && parsepathconf(ndo, dp) != 0)
return;
break;
case NFSPROC_COMMIT:
- printf(" commit");
- dp = parserep(rp, length);
- if (dp != NULL && parsewccres(dp, vflag) != 0)
+ dp = parserep(ndo, rp, length);
+ if (dp != NULL && parsewccres(ndo, dp, ndo->ndo_vflag) != 0)
return;
break;
default:
- printf(" proc-%u", proc);
return;
}
trunc:
if (!nfserr)
- fputs(" [|nfs]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
}
diff --git a/contrib/tcpdump/print-ntp.c b/contrib/tcpdump/print-ntp.c
index ff5b73547fc6..860390606d3e 100644
--- a/contrib/tcpdump/print-ntp.c
+++ b/contrib/tcpdump/print-ntp.c
@@ -25,19 +25,13 @@
* $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ntp.c,v 1.43 2007-11-30 13:45:10 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <string.h>
#ifdef HAVE_STRFTIME
#include <time.h>
#endif
@@ -45,16 +39,141 @@ static const char rcsid[] _U_ =
#include "interface.h"
#include "addrtoname.h"
#include "extract.h"
+
+/*
+ * Based on ntp.h from the U of MD implementation
+ * This file is based on Version 2 of the NTP spec (RFC1119).
+ */
+
+/*
+ * Definitions for the masses
+ */
+#define JAN_1970 2208988800U /* 1970 - 1900 in seconds */
+
+/*
+ * Structure definitions for NTP fixed point values
+ *
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Integer Part |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Fraction Part |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Integer Part | Fraction Part |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+*/
+struct l_fixedpt {
+ uint32_t int_part;
+ uint32_t fraction;
+};
+
+struct s_fixedpt {
+ uint16_t int_part;
+ uint16_t fraction;
+};
+
+/* rfc2030
+ * 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |LI | VN |Mode | Stratum | Poll | Precision |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Root Delay |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Root Dispersion |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Reference Identifier |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | |
+ * | Reference Timestamp (64) |
+ * | |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | |
+ * | Originate Timestamp (64) |
+ * | |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | |
+ * | Receive Timestamp (64) |
+ * | |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | |
+ * | Transmit Timestamp (64) |
+ * | |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Key Identifier (optional) (32) |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | |
+ * | |
+ * | Message Digest (optional) (128) |
+ * | |
+ * | |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+struct ntpdata {
+ u_char status; /* status of local clock and leap info */
+ u_char stratum; /* Stratum level */
+ u_char ppoll; /* poll value */
+ int precision:8;
+ struct s_fixedpt root_delay;
+ struct s_fixedpt root_dispersion;
+ uint32_t refid;
+ struct l_fixedpt ref_timestamp;
+ struct l_fixedpt org_timestamp;
+ struct l_fixedpt rec_timestamp;
+ struct l_fixedpt xmt_timestamp;
+ uint32_t key_id;
+ uint8_t message_digest[16];
+};
+/*
+ * Leap Second Codes (high order two bits)
+ */
+#define NO_WARNING 0x00 /* no warning */
+#define PLUS_SEC 0x40 /* add a second (61 seconds) */
+#define MINUS_SEC 0x80 /* minus a second (59 seconds) */
+#define ALARM 0xc0 /* alarm condition (clock unsynchronized) */
+
+/*
+ * Clock Status Bits that Encode Version
+ */
+#define NTPVERSION_1 0x08
+#define VERSIONMASK 0x38
+#define LEAPMASK 0xc0
#ifdef MODEMASK
#undef MODEMASK /* Solaris sucks */
#endif
-#include "ntp.h"
+#define MODEMASK 0x07
-static void p_sfix(const struct s_fixedpt *);
-static void p_ntp_time(const struct l_fixedpt *);
-static void p_ntp_delta(const struct l_fixedpt *, const struct l_fixedpt *);
+/*
+ * Code values
+ */
+#define MODE_UNSPEC 0 /* unspecified */
+#define MODE_SYM_ACT 1 /* symmetric active */
+#define MODE_SYM_PAS 2 /* symmetric passive */
+#define MODE_CLIENT 3 /* client */
+#define MODE_SERVER 4 /* server */
+#define MODE_BROADCAST 5 /* broadcast */
+#define MODE_RES1 6 /* reserved */
+#define MODE_RES2 7 /* reserved */
-static struct tok ntp_mode_values[] = {
+/*
+ * Stratum Definitions
+ */
+#define UNSPECIFIED 0
+#define PRIM_REF 1 /* radio clock */
+#define INFO_QUERY 62 /* **** THIS implementation dependent **** */
+#define INFO_REPLY 63 /* **** THIS implementation dependent **** */
+
+static void p_sfix(netdissect_options *ndo, const struct s_fixedpt *);
+static void p_ntp_time(netdissect_options *, const struct l_fixedpt *);
+static void p_ntp_delta(netdissect_options *, const struct l_fixedpt *, const struct l_fixedpt *);
+
+static const struct tok ntp_mode_values[] = {
{ MODE_UNSPEC, "unspecified" },
{ MODE_SYM_ACT, "symmetric active" },
{ MODE_SYM_PAS, "symmetric passive" },
@@ -66,7 +185,7 @@ static struct tok ntp_mode_values[] = {
{ 0, NULL }
};
-static struct tok ntp_leapind_values[] = {
+static const struct tok ntp_leapind_values[] = {
{ NO_WARNING, "" },
{ PLUS_SEC, "+1s" },
{ MINUS_SEC, "-1s" },
@@ -74,7 +193,7 @@ static struct tok ntp_leapind_values[] = {
{ 0, NULL }
};
-static struct tok ntp_stratum_values[] = {
+static const struct tok ntp_stratum_values[] = {
{ UNSPECIFIED, "unspecified" },
{ PRIM_REF, "primary reference" },
{ 0, NULL }
@@ -84,127 +203,129 @@ static struct tok ntp_stratum_values[] = {
* Print ntp requests
*/
void
-ntp_print(register const u_char *cp, u_int length)
+ntp_print(netdissect_options *ndo,
+ register const u_char *cp, u_int length)
{
register const struct ntpdata *bp;
int mode, version, leapind;
bp = (struct ntpdata *)cp;
- TCHECK(bp->status);
+ ND_TCHECK(bp->status);
version = (int)(bp->status & VERSIONMASK) >> 3;
- printf("NTPv%d", version);
+ ND_PRINT((ndo, "NTPv%d", version));
mode = bp->status & MODEMASK;
- if (!vflag) {
- printf (", %s, length %u",
- tok2str(ntp_mode_values, "Unknown mode", mode),
- length);
- return;
- }
-
- printf (", length %u\n\t%s",
- length,
- tok2str(ntp_mode_values, "Unknown mode", mode));
+ if (!ndo->ndo_vflag) {
+ ND_PRINT((ndo, ", %s, length %u",
+ tok2str(ntp_mode_values, "Unknown mode", mode),
+ length));
+ return;
+ }
+
+ ND_PRINT((ndo, ", length %u\n\t%s",
+ length,
+ tok2str(ntp_mode_values, "Unknown mode", mode)));
leapind = bp->status & LEAPMASK;
- printf (", Leap indicator: %s (%u)",
- tok2str(ntp_leapind_values, "Unknown", leapind),
- leapind);
+ ND_PRINT((ndo, ", Leap indicator: %s (%u)",
+ tok2str(ntp_leapind_values, "Unknown", leapind),
+ leapind));
- TCHECK(bp->stratum);
- printf(", Stratum %u (%s)",
+ ND_TCHECK(bp->stratum);
+ ND_PRINT((ndo, ", Stratum %u (%s)",
bp->stratum,
- tok2str(ntp_stratum_values, (bp->stratum >=2 && bp->stratum<=15) ? "secondary reference" : "reserved", bp->stratum));
+ tok2str(ntp_stratum_values, (bp->stratum >=2 && bp->stratum<=15) ? "secondary reference" : "reserved", bp->stratum)));
- TCHECK(bp->ppoll);
- printf(", poll %u (%us)", bp->ppoll, 1 << bp->ppoll);
+ ND_TCHECK(bp->ppoll);
+ ND_PRINT((ndo, ", poll %u (%us)", bp->ppoll, 1 << bp->ppoll));
- /* Can't TCHECK bp->precision bitfield so bp->distance + 0 instead */
- TCHECK2(bp->root_delay, 0);
- printf(", precision %d", bp->precision);
+ /* Can't ND_TCHECK bp->precision bitfield so bp->distance + 0 instead */
+ ND_TCHECK2(bp->root_delay, 0);
+ ND_PRINT((ndo, ", precision %d", bp->precision));
- TCHECK(bp->root_delay);
- fputs("\n\tRoot Delay: ", stdout);
- p_sfix(&bp->root_delay);
+ ND_TCHECK(bp->root_delay);
+ ND_PRINT((ndo, "\n\tRoot Delay: "));
+ p_sfix(ndo, &bp->root_delay);
- TCHECK(bp->root_dispersion);
- fputs(", Root dispersion: ", stdout);
- p_sfix(&bp->root_dispersion);
+ ND_TCHECK(bp->root_dispersion);
+ ND_PRINT((ndo, ", Root dispersion: "));
+ p_sfix(ndo, &bp->root_dispersion);
- TCHECK(bp->refid);
- fputs(", Reference-ID: ", stdout);
+ ND_TCHECK(bp->refid);
+ ND_PRINT((ndo, ", Reference-ID: "));
/* Interpretation depends on stratum */
switch (bp->stratum) {
case UNSPECIFIED:
- printf("(unspec)");
+ ND_PRINT((ndo, "(unspec)"));
break;
case PRIM_REF:
- if (fn_printn((u_char *)&(bp->refid), 4, snapend))
+ if (fn_printn(ndo, (u_char *)&(bp->refid), 4, ndo->ndo_snapend))
goto trunc;
break;
case INFO_QUERY:
- printf("%s INFO_QUERY", ipaddr_string(&(bp->refid)));
+ ND_PRINT((ndo, "%s INFO_QUERY", ipaddr_string(ndo, &(bp->refid))));
/* this doesn't have more content */
return;
case INFO_REPLY:
- printf("%s INFO_REPLY", ipaddr_string(&(bp->refid)));
+ ND_PRINT((ndo, "%s INFO_REPLY", ipaddr_string(ndo, &(bp->refid))));
/* this is too complex to be worth printing */
return;
default:
- printf("%s", ipaddr_string(&(bp->refid)));
+ ND_PRINT((ndo, "%s", ipaddr_string(ndo, &(bp->refid))));
break;
}
- TCHECK(bp->ref_timestamp);
- fputs("\n\t Reference Timestamp: ", stdout);
- p_ntp_time(&(bp->ref_timestamp));
+ ND_TCHECK(bp->ref_timestamp);
+ ND_PRINT((ndo, "\n\t Reference Timestamp: "));
+ p_ntp_time(ndo, &(bp->ref_timestamp));
- TCHECK(bp->org_timestamp);
- fputs("\n\t Originator Timestamp: ", stdout);
- p_ntp_time(&(bp->org_timestamp));
+ ND_TCHECK(bp->org_timestamp);
+ ND_PRINT((ndo, "\n\t Originator Timestamp: "));
+ p_ntp_time(ndo, &(bp->org_timestamp));
- TCHECK(bp->rec_timestamp);
- fputs("\n\t Receive Timestamp: ", stdout);
- p_ntp_time(&(bp->rec_timestamp));
+ ND_TCHECK(bp->rec_timestamp);
+ ND_PRINT((ndo, "\n\t Receive Timestamp: "));
+ p_ntp_time(ndo, &(bp->rec_timestamp));
- TCHECK(bp->xmt_timestamp);
- fputs("\n\t Transmit Timestamp: ", stdout);
- p_ntp_time(&(bp->xmt_timestamp));
+ ND_TCHECK(bp->xmt_timestamp);
+ ND_PRINT((ndo, "\n\t Transmit Timestamp: "));
+ p_ntp_time(ndo, &(bp->xmt_timestamp));
- fputs("\n\t Originator - Receive Timestamp: ", stdout);
- p_ntp_delta(&(bp->org_timestamp), &(bp->rec_timestamp));
+ ND_PRINT((ndo, "\n\t Originator - Receive Timestamp: "));
+ p_ntp_delta(ndo, &(bp->org_timestamp), &(bp->rec_timestamp));
- fputs("\n\t Originator - Transmit Timestamp: ", stdout);
- p_ntp_delta(&(bp->org_timestamp), &(bp->xmt_timestamp));
+ ND_PRINT((ndo, "\n\t Originator - Transmit Timestamp: "));
+ p_ntp_delta(ndo, &(bp->org_timestamp), &(bp->xmt_timestamp));
if ( (sizeof(struct ntpdata) - length) == 16) { /* Optional: key-id */
- TCHECK(bp->key_id);
- printf("\n\tKey id: %u", bp->key_id);
+ ND_TCHECK(bp->key_id);
+ ND_PRINT((ndo, "\n\tKey id: %u", bp->key_id));
} else if ( (sizeof(struct ntpdata) - length) == 0) { /* Optional: key-id + authentication */
- TCHECK(bp->key_id);
- printf("\n\tKey id: %u", bp->key_id);
- TCHECK2(bp->message_digest, sizeof (bp->message_digest));
- printf("\n\tAuthentication: %08x%08x%08x%08x",
+ ND_TCHECK(bp->key_id);
+ ND_PRINT((ndo, "\n\tKey id: %u", bp->key_id));
+ ND_TCHECK2(bp->message_digest, sizeof (bp->message_digest));
+ ND_PRINT((ndo, "\n\tAuthentication: %08x%08x%08x%08x",
EXTRACT_32BITS(bp->message_digest),
EXTRACT_32BITS(bp->message_digest + 4),
EXTRACT_32BITS(bp->message_digest + 8),
- EXTRACT_32BITS(bp->message_digest + 12));
+ EXTRACT_32BITS(bp->message_digest + 12)));
}
return;
trunc:
- fputs(" [|ntp]", stdout);
+ ND_PRINT((ndo, " [|ntp]"));
}
static void
-p_sfix(register const struct s_fixedpt *sfp)
+p_sfix(netdissect_options *ndo,
+ register const struct s_fixedpt *sfp)
{
register int i;
register int f;
@@ -214,17 +335,18 @@ p_sfix(register const struct s_fixedpt *sfp)
f = EXTRACT_16BITS(&sfp->fraction);
ff = f / 65536.0; /* shift radix point by 16 bits */
f = ff * 1000000.0; /* Treat fraction as parts per million */
- printf("%d.%06d", i, f);
+ ND_PRINT((ndo, "%d.%06d", i, f));
}
#define FMAXINT (4294967296.0) /* floating point rep. of MAXINT */
static void
-p_ntp_time(register const struct l_fixedpt *lfp)
+p_ntp_time(netdissect_options *ndo,
+ register const struct l_fixedpt *lfp)
{
register int32_t i;
- register u_int32_t uf;
- register u_int32_t f;
+ register uint32_t uf;
+ register uint32_t f;
register float ff;
i = EXTRACT_32BITS(&lfp->int_part);
@@ -234,7 +356,7 @@ p_ntp_time(register const struct l_fixedpt *lfp)
ff += FMAXINT;
ff = ff / FMAXINT; /* shift radix point by 32 bits */
f = ff * 1000000000.0; /* treat fraction as parts per billion */
- printf("%u.%09d", i, f);
+ ND_PRINT((ndo, "%u.%09d", i, f));
#ifdef HAVE_STRFTIME
/*
@@ -247,20 +369,21 @@ p_ntp_time(register const struct l_fixedpt *lfp)
tm = localtime(&seconds);
strftime(time_buf, sizeof (time_buf), "%Y/%m/%d %H:%M:%S", tm);
- printf (" (%s)", time_buf);
+ ND_PRINT((ndo, " (%s)", time_buf));
}
#endif
}
/* Prints time difference between *lfp and *olfp */
static void
-p_ntp_delta(register const struct l_fixedpt *olfp,
- register const struct l_fixedpt *lfp)
+p_ntp_delta(netdissect_options *ndo,
+ register const struct l_fixedpt *olfp,
+ register const struct l_fixedpt *lfp)
{
register int32_t i;
- register u_int32_t u, uf;
- register u_int32_t ou, ouf;
- register u_int32_t f;
+ register uint32_t u, uf;
+ register uint32_t ou, ouf;
+ register uint32_t f;
register float ff;
int signbit;
@@ -269,7 +392,7 @@ p_ntp_delta(register const struct l_fixedpt *olfp,
uf = EXTRACT_32BITS(&lfp->fraction);
ouf = EXTRACT_32BITS(&olfp->fraction);
if (ou == 0 && ouf == 0) {
- p_ntp_time(lfp);
+ p_ntp_time(ndo, lfp);
return;
}
@@ -301,10 +424,6 @@ p_ntp_delta(register const struct l_fixedpt *olfp,
ff += FMAXINT;
ff = ff / FMAXINT; /* shift radix point by 32 bits */
f = ff * 1000000000.0; /* treat fraction as parts per billion */
- if (signbit)
- putchar('-');
- else
- putchar('+');
- printf("%d.%09d", i, f);
+ ND_PRINT((ndo, "%s%d.%09d", signbit ? "-" : "+", i, f));
}
diff --git a/contrib/tcpdump/print-null.c b/contrib/tcpdump/print-null.c
index 926e8d8a231f..02416e334f5c 100644
--- a/contrib/tcpdump/print-null.c
+++ b/contrib/tcpdump/print-null.c
@@ -21,28 +21,16 @@
* $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.57 2006-03-23 14:58:44 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <pcap.h>
-#include <stdio.h>
#include <string.h>
#include "interface.h"
-#include "addrtoname.h"
-
-#include "ip.h"
-#ifdef INET6
-#include "ip6.h"
-#endif
#include "af.h"
/*
@@ -66,17 +54,17 @@ static const char rcsid[] _U_ =
((((y)&0xff)<<24) | (((y)&0xff00)<<8) | (((y)&0xff0000)>>8) | (((y)>>24)&0xff))
static inline void
-null_hdr_print(u_int family, u_int length)
+null_hdr_print(netdissect_options *ndo, u_int family, u_int length)
{
- if (!qflag) {
- (void)printf("AF %s (%u)",
- tok2str(bsd_af_values,"Unknown",family),family);
+ if (!ndo->ndo_qflag) {
+ ND_PRINT((ndo, "AF %s (%u)",
+ tok2str(bsd_af_values,"Unknown",family),family));
} else {
- (void)printf("%s",
- tok2str(bsd_af_values,"Unknown AF %u",family));
+ ND_PRINT((ndo, "%s",
+ tok2str(bsd_af_values,"Unknown AF %u",family)));
}
- (void)printf(", length %u: ", length);
+ ND_PRINT((ndo, ", length %u: ", length));
}
/*
@@ -86,14 +74,14 @@ null_hdr_print(u_int family, u_int length)
* is the number of bytes actually captured.
*/
u_int
-null_if_print(const struct pcap_pkthdr *h, const u_char *p)
+null_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
{
u_int length = h->len;
u_int caplen = h->caplen;
u_int family;
if (caplen < NULL_HDRLEN) {
- printf("[|null]");
+ ND_PRINT((ndo, "[|null]"));
return (NULL_HDRLEN);
}
@@ -110,8 +98,8 @@ null_if_print(const struct pcap_pkthdr *h, const u_char *p)
if ((family & 0xFFFF0000) != 0)
family = SWAPLONG(family);
- if (eflag)
- null_hdr_print(family, length);
+ if (ndo->ndo_eflag)
+ null_hdr_print(ndo, family, length);
length -= NULL_HDRLEN;
caplen -= NULL_HDRLEN;
@@ -120,35 +108,35 @@ null_if_print(const struct pcap_pkthdr *h, const u_char *p)
switch (family) {
case BSD_AFNUM_INET:
- ip_print(gndo, p, length);
+ ip_print(ndo, p, length);
break;
#ifdef INET6
case BSD_AFNUM_INET6_BSD:
case BSD_AFNUM_INET6_FREEBSD:
case BSD_AFNUM_INET6_DARWIN:
- ip6_print(gndo, p, length);
+ ip6_print(ndo, p, length);
break;
#endif
case BSD_AFNUM_ISO:
- isoclns_print(p, length, caplen);
+ isoclns_print(ndo, p, length, caplen);
break;
case BSD_AFNUM_APPLETALK:
- atalk_print(p, length);
+ atalk_print(ndo, p, length);
break;
case BSD_AFNUM_IPX:
- ipx_print(p, length);
+ ipx_print(ndo, p, length);
break;
default:
/* unknown AF_ value */
- if (!eflag)
- null_hdr_print(family, length + NULL_HDRLEN);
- if (!suppress_default_print)
- default_print(p, caplen);
+ if (!ndo->ndo_eflag)
+ null_hdr_print(ndo, family, length + NULL_HDRLEN);
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
}
return (NULL_HDRLEN);
diff --git a/contrib/tcpdump/print-olsr.c b/contrib/tcpdump/print-olsr.c
index ba0ed2bede8a..6fa0d76c3cd1 100644
--- a/contrib/tcpdump/print-olsr.c
+++ b/contrib/tcpdump/print-olsr.c
@@ -19,19 +19,16 @@
* IPv6 additions by Florian Forster <octo at verplant.org>
*/
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <string.h>
-
#include "interface.h"
#include "addrtoname.h"
#include "extract.h"
-#include "ip.h"
/*
* RFC 3626 common header
@@ -65,8 +62,8 @@
*/
struct olsr_common {
- u_int8_t packet_len[2];
- u_int8_t packet_seq[2];
+ uint8_t packet_len[2];
+ uint8_t packet_seq[2];
};
#define OLSR_HELLO_MSG 1 /* rfc3626 */
@@ -78,7 +75,7 @@ struct olsr_common {
#define OLSR_HELLO_LQ_MSG 201 /* LQ extensions olsr.org */
#define OLSR_TC_LQ_MSG 202 /* LQ extensions olsr.org */
-static struct tok olsr_msg_values[] = {
+static const struct tok olsr_msg_values[] = {
{ OLSR_HELLO_MSG, "Hello" },
{ OLSR_TC_MSG, "TC" },
{ OLSR_MID_MSG, "MID" },
@@ -91,57 +88,57 @@ static struct tok olsr_msg_values[] = {
};
struct olsr_msg4 {
- u_int8_t msg_type;
- u_int8_t vtime;
- u_int8_t msg_len[2];
- u_int8_t originator[4];
- u_int8_t ttl;
- u_int8_t hopcount;
- u_int8_t msg_seq[2];
+ uint8_t msg_type;
+ uint8_t vtime;
+ uint8_t msg_len[2];
+ uint8_t originator[4];
+ uint8_t ttl;
+ uint8_t hopcount;
+ uint8_t msg_seq[2];
};
struct olsr_msg6 {
- u_int8_t msg_type;
- u_int8_t vtime;
- u_int8_t msg_len[2];
- u_int8_t originator[16];
- u_int8_t ttl;
- u_int8_t hopcount;
- u_int8_t msg_seq[2];
+ uint8_t msg_type;
+ uint8_t vtime;
+ uint8_t msg_len[2];
+ uint8_t originator[16];
+ uint8_t ttl;
+ uint8_t hopcount;
+ uint8_t msg_seq[2];
};
struct olsr_hello {
- u_int8_t res[2];
- u_int8_t htime;
- u_int8_t will;
+ uint8_t res[2];
+ uint8_t htime;
+ uint8_t will;
};
struct olsr_hello_link {
- u_int8_t link_code;
- u_int8_t res;
- u_int8_t len[2];
+ uint8_t link_code;
+ uint8_t res;
+ uint8_t len[2];
};
struct olsr_tc {
- u_int8_t ans_seq[2];
- u_int8_t res[2];
+ uint8_t ans_seq[2];
+ uint8_t res[2];
};
struct olsr_hna4 {
- u_int8_t network[4];
- u_int8_t mask[4];
+ uint8_t network[4];
+ uint8_t mask[4];
};
struct olsr_hna6 {
- u_int8_t network[16];
- u_int8_t mask[16];
+ uint8_t network[16];
+ uint8_t mask[16];
};
#define OLSR_EXTRACT_LINK_TYPE(link_code) (link_code & 0x3)
#define OLSR_EXTRACT_NEIGHBOR_TYPE(link_code) (link_code >> 2)
-static struct tok olsr_link_type_values[] = {
+static const struct tok olsr_link_type_values[] = {
{ 0, "Unspecified" },
{ 1, "Asymmetric" },
{ 2, "Symmetric" },
@@ -149,7 +146,7 @@ static struct tok olsr_link_type_values[] = {
{ 0, NULL}
};
-static struct tok olsr_neighbor_type_values[] = {
+static const struct tok olsr_neighbor_type_values[] = {
{ 0, "Not-Neighbor" },
{ 1, "Symmetric" },
{ 2, "Symmetric-MPR" },
@@ -157,17 +154,17 @@ static struct tok olsr_neighbor_type_values[] = {
};
struct olsr_lq_neighbor4 {
- u_int8_t neighbor[4];
- u_int8_t link_quality;
- u_int8_t neighbor_link_quality;
- u_int8_t res[2];
+ uint8_t neighbor[4];
+ uint8_t link_quality;
+ uint8_t neighbor_link_quality;
+ uint8_t res[2];
};
struct olsr_lq_neighbor6 {
- u_int8_t neighbor[16];
- u_int8_t link_quality;
- u_int8_t neighbor_link_quality;
- u_int8_t res[2];
+ uint8_t neighbor[16];
+ uint8_t link_quality;
+ uint8_t neighbor_link_quality;
+ uint8_t res[2];
};
/*
@@ -182,7 +179,8 @@ struct olsr_lq_neighbor6 {
* print a neighbor list with LQ extensions.
*/
static void
-olsr_print_lq_neighbor4 (const u_char *msg_data, u_int hello_len)
+olsr_print_lq_neighbor4(netdissect_options *ndo,
+ const u_char *msg_data, u_int hello_len)
{
struct olsr_lq_neighbor4 *lq_neighbor;
@@ -190,11 +188,11 @@ olsr_print_lq_neighbor4 (const u_char *msg_data, u_int hello_len)
lq_neighbor = (struct olsr_lq_neighbor4 *)msg_data;
- printf("\n\t neighbor %s, link-quality %.2lf%%"
+ ND_PRINT((ndo, "\n\t neighbor %s, link-quality %.2lf%%"
", neighbor-link-quality %.2lf%%",
- ipaddr_string(lq_neighbor->neighbor),
+ ipaddr_string(ndo, lq_neighbor->neighbor),
((double)lq_neighbor->link_quality/2.55),
- ((double)lq_neighbor->neighbor_link_quality/2.55));
+ ((double)lq_neighbor->neighbor_link_quality/2.55)));
msg_data += sizeof(struct olsr_lq_neighbor4);
hello_len -= sizeof(struct olsr_lq_neighbor4);
@@ -203,7 +201,8 @@ olsr_print_lq_neighbor4 (const u_char *msg_data, u_int hello_len)
#if INET6
static void
-olsr_print_lq_neighbor6 (const u_char *msg_data, u_int hello_len)
+olsr_print_lq_neighbor6(netdissect_options *ndo,
+ const u_char *msg_data, u_int hello_len)
{
struct olsr_lq_neighbor6 *lq_neighbor;
@@ -211,11 +210,11 @@ olsr_print_lq_neighbor6 (const u_char *msg_data, u_int hello_len)
lq_neighbor = (struct olsr_lq_neighbor6 *)msg_data;
- printf("\n\t neighbor %s, link-quality %.2lf%%"
+ ND_PRINT((ndo, "\n\t neighbor %s, link-quality %.2lf%%"
", neighbor-link-quality %.2lf%%",
- ip6addr_string(lq_neighbor->neighbor),
+ ip6addr_string(ndo, lq_neighbor->neighbor),
((double)lq_neighbor->link_quality/2.55),
- ((double)lq_neighbor->neighbor_link_quality/2.55));
+ ((double)lq_neighbor->neighbor_link_quality/2.55)));
msg_data += sizeof(struct olsr_lq_neighbor6);
hello_len -= sizeof(struct olsr_lq_neighbor6);
@@ -227,19 +226,20 @@ olsr_print_lq_neighbor6 (const u_char *msg_data, u_int hello_len)
* print a neighbor list.
*/
static void
-olsr_print_neighbor (const u_char *msg_data, u_int hello_len)
+olsr_print_neighbor(netdissect_options *ndo,
+ const u_char *msg_data, u_int hello_len)
{
int neighbor;
- printf("\n\t neighbor\n\t\t");
+ ND_PRINT((ndo, "\n\t neighbor\n\t\t"));
neighbor = 1;
while (hello_len >= sizeof(struct in_addr)) {
/* print 4 neighbors per line */
- printf("%s%s", ipaddr_string(msg_data),
- neighbor % 4 == 0 ? "\n\t\t" : " ");
+ ND_PRINT((ndo, "%s%s", ipaddr_string(ndo, msg_data),
+ neighbor % 4 == 0 ? "\n\t\t" : " "));
msg_data += sizeof(struct in_addr);
hello_len -= sizeof(struct in_addr);
@@ -248,7 +248,8 @@ olsr_print_neighbor (const u_char *msg_data, u_int hello_len)
void
-olsr_print (const u_char *pptr, u_int length, int is_ipv6)
+olsr_print(netdissect_options *ndo,
+ const u_char *pptr, u_int length, int is_ipv6)
{
union {
const struct olsr_common *common;
@@ -261,9 +262,9 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6)
} ptr;
u_int msg_type, msg_len, msg_tlen, hello_len;
- u_int16_t name_entry_type, name_entry_len;
+ uint16_t name_entry_type, name_entry_len;
u_int name_entry_padding;
- u_int8_t link_type, neighbor_type;
+ uint8_t link_type, neighbor_type;
const u_char *tptr, *msg_data;
tptr = pptr;
@@ -272,24 +273,22 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6)
goto trunc;
}
- if (!TTEST2(*tptr, sizeof(struct olsr_common))) {
- goto trunc;
- }
+ ND_TCHECK2(*tptr, sizeof(struct olsr_common));
ptr.common = (struct olsr_common *)tptr;
- length = MIN(length, EXTRACT_16BITS(ptr.common->packet_len));
+ length = min(length, EXTRACT_16BITS(ptr.common->packet_len));
- printf("OLSRv%i, seq 0x%04x, length %u",
+ ND_PRINT((ndo, "OLSRv%i, seq 0x%04x, length %u",
(is_ipv6 == 0) ? 4 : 6,
EXTRACT_16BITS(ptr.common->packet_seq),
- length);
+ length));
tptr += sizeof(struct olsr_common);
/*
* In non-verbose mode, just print version.
*/
- if (vflag < 1) {
+ if (ndo->ndo_vflag < 1) {
return;
}
@@ -301,8 +300,7 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6)
} msgptr;
int msg_len_valid = 0;
- if (!TTEST2(*tptr, sizeof(struct olsr_msg4)))
- goto trunc;
+ ND_TCHECK2(*tptr, sizeof(struct olsr_msg4));
#if INET6
if (is_ipv6)
@@ -319,15 +317,15 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6)
return;
}
- printf("\n\t%s Message (%#04x), originator %s, ttl %u, hop %u"
+ ND_PRINT((ndo, "\n\t%s Message (%#04x), originator %s, ttl %u, hop %u"
"\n\t vtime %.3lfs, msg-seq 0x%04x, length %u%s",
tok2str(olsr_msg_values, "Unknown", msg_type),
- msg_type, ip6addr_string(msgptr.v6->originator),
+ msg_type, ip6addr_string(ndo, msgptr.v6->originator),
msgptr.v6->ttl,
msgptr.v6->hopcount,
ME_TO_DOUBLE(msgptr.v6->vtime),
EXTRACT_16BITS(msgptr.v6->msg_seq),
- msg_len, (msg_len_valid == 0) ? " (invalid)" : "");
+ msg_len, (msg_len_valid == 0) ? " (invalid)" : ""));
msg_tlen = msg_len - sizeof(struct olsr_msg6);
msg_data = tptr + sizeof(struct olsr_msg6);
@@ -347,15 +345,15 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6)
return;
}
- printf("\n\t%s Message (%#04x), originator %s, ttl %u, hop %u"
+ ND_PRINT((ndo, "\n\t%s Message (%#04x), originator %s, ttl %u, hop %u"
"\n\t vtime %.3lfs, msg-seq 0x%04x, length %u%s",
tok2str(olsr_msg_values, "Unknown", msg_type),
- msg_type, ipaddr_string(msgptr.v4->originator),
+ msg_type, ipaddr_string(ndo, msgptr.v4->originator),
msgptr.v4->ttl,
msgptr.v4->hopcount,
ME_TO_DOUBLE(msgptr.v4->vtime),
EXTRACT_16BITS(msgptr.v4->msg_seq),
- msg_len, (msg_len_valid == 0) ? " (invalid)" : "");
+ msg_len, (msg_len_valid == 0) ? " (invalid)" : ""));
msg_tlen = msg_len - sizeof(struct olsr_msg4);
msg_data = tptr + sizeof(struct olsr_msg4);
@@ -364,12 +362,11 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6)
switch (msg_type) {
case OLSR_HELLO_MSG:
case OLSR_HELLO_LQ_MSG:
- if (!TTEST2(*msg_data, sizeof(struct olsr_hello)))
- goto trunc;
+ ND_TCHECK2(*msg_data, sizeof(struct olsr_hello));
ptr.hello = (struct olsr_hello *)msg_data;
- printf("\n\t hello-time %.3lfs, MPR willingness %u",
- ME_TO_DOUBLE(ptr.hello->htime), ptr.hello->will);
+ ND_PRINT((ndo, "\n\t hello-time %.3lfs, MPR willingness %u",
+ ME_TO_DOUBLE(ptr.hello->htime), ptr.hello->will));
msg_data += sizeof(struct olsr_hello);
msg_tlen -= sizeof(struct olsr_hello);
@@ -379,8 +376,7 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6)
/*
* link-type.
*/
- if (!TTEST2(*msg_data, sizeof(struct olsr_hello_link)))
- goto trunc;
+ ND_TCHECK2(*msg_data, sizeof(struct olsr_hello_link));
ptr.hello_link = (struct olsr_hello_link *)msg_data;
@@ -392,11 +388,11 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6)
&& (hello_len >= sizeof(struct olsr_hello_link)))
hello_len_valid = 1;
- printf("\n\t link-type %s, neighbor-type %s, len %u%s",
+ ND_PRINT((ndo, "\n\t link-type %s, neighbor-type %s, len %u%s",
tok2str(olsr_link_type_values, "Unknown", link_type),
tok2str(olsr_neighbor_type_values, "Unknown", neighbor_type),
hello_len,
- (hello_len_valid == 0) ? " (invalid)" : "");
+ (hello_len_valid == 0) ? " (invalid)" : ""));
if (hello_len_valid == 0)
break;
@@ -406,14 +402,14 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6)
hello_len -= sizeof(struct olsr_hello_link);
if (msg_type == OLSR_HELLO_MSG) {
- olsr_print_neighbor(msg_data, hello_len);
+ olsr_print_neighbor(ndo, msg_data, hello_len);
} else {
#if INET6
if (is_ipv6)
- olsr_print_lq_neighbor6(msg_data, hello_len);
+ olsr_print_lq_neighbor6(ndo, msg_data, hello_len);
else
#endif
- olsr_print_lq_neighbor4(msg_data, hello_len);
+ olsr_print_lq_neighbor4(ndo, msg_data, hello_len);
}
msg_data += hello_len;
@@ -423,24 +419,23 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6)
case OLSR_TC_MSG:
case OLSR_TC_LQ_MSG:
- if (!TTEST2(*msg_data, sizeof(struct olsr_tc)))
- goto trunc;
+ ND_TCHECK2(*msg_data, sizeof(struct olsr_tc));
ptr.tc = (struct olsr_tc *)msg_data;
- printf("\n\t advertised neighbor seq 0x%04x",
- EXTRACT_16BITS(ptr.tc->ans_seq));
+ ND_PRINT((ndo, "\n\t advertised neighbor seq 0x%04x",
+ EXTRACT_16BITS(ptr.tc->ans_seq)));
msg_data += sizeof(struct olsr_tc);
msg_tlen -= sizeof(struct olsr_tc);
if (msg_type == OLSR_TC_MSG) {
- olsr_print_neighbor(msg_data, msg_tlen);
+ olsr_print_neighbor(ndo, msg_data, msg_tlen);
} else {
#if INET6
if (is_ipv6)
- olsr_print_lq_neighbor6(msg_data, msg_tlen);
+ olsr_print_lq_neighbor6(ndo, msg_data, msg_tlen);
else
#endif
- olsr_print_lq_neighbor4(msg_data, msg_tlen);
+ olsr_print_lq_neighbor4(ndo, msg_data, msg_tlen);
}
break;
@@ -454,14 +449,16 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6)
#endif
while (msg_tlen >= addr_size) {
- if (!TTEST2(*msg_data, addr_size))
- goto trunc;
-
- printf("\n\t interface address %s",
+ ND_TCHECK2(*msg_data, addr_size);
#if INET6
- is_ipv6 ? ip6addr_string(msg_data) :
+ ND_PRINT((ndo, "\n\t interface address %s",
+ is_ipv6 ? ip6addr_string(ndo, msg_data) :
+ ipaddr_string(ndo, msg_data)));
+#else
+ ND_PRINT((ndo, "\n\t interface address %s",
+ ipaddr_string(ndo, msg_data)));
#endif
- ipaddr_string(msg_data));
+
msg_data += addr_size;
msg_tlen -= addr_size;
}
@@ -469,8 +466,8 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6)
}
case OLSR_HNA_MSG:
- printf("\n\t Advertised networks (total %u)",
- (unsigned int) (msg_tlen / sizeof(struct olsr_hna6)));
+ ND_PRINT((ndo, "\n\t Advertised networks (total %u)",
+ (unsigned int) (msg_tlen / sizeof(struct olsr_hna6))));
#if INET6
if (is_ipv6)
{
@@ -478,14 +475,13 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6)
while (msg_tlen >= sizeof(struct olsr_hna6)) {
struct olsr_hna6 *hna6;
- if (!TTEST2(*msg_data, sizeof(struct olsr_hna6)))
- goto trunc;
+ ND_TCHECK2(*msg_data, sizeof(struct olsr_hna6));
hna6 = (struct olsr_hna6 *)msg_data;
- printf("\n\t #%i: %s/%u",
- i, ip6addr_string(hna6->network),
- mask62plen (hna6->mask));
+ ND_PRINT((ndo, "\n\t #%i: %s/%u",
+ i, ip6addr_string(ndo, hna6->network),
+ mask62plen (hna6->mask)));
msg_data += sizeof(struct olsr_hna6);
msg_tlen -= sizeof(struct olsr_hna6);
@@ -496,20 +492,15 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6)
{
int col = 0;
while (msg_tlen >= sizeof(struct olsr_hna4)) {
- if (!TTEST2(*msg_data, sizeof(struct olsr_hna4)))
- goto trunc;
+ ND_TCHECK2(*msg_data, sizeof(struct olsr_hna4));
ptr.hna = (struct olsr_hna4 *)msg_data;
/* print 4 prefixes per line */
- if (col == 0)
- printf ("\n\t ");
- else
- printf (", ");
-
- printf("%s/%u",
- ipaddr_string(ptr.hna->network),
- mask2plen(EXTRACT_32BITS(ptr.hna->mask)));
+ ND_PRINT((ndo, "%s%s/%u",
+ col == 0 ? "\n\t " : ", ",
+ ipaddr_string(ndo, ptr.hna->network),
+ mask2plen(EXTRACT_32BITS(ptr.hna->mask))));
msg_data += sizeof(struct olsr_hna4);
msg_tlen -= sizeof(struct olsr_hna4);
@@ -535,12 +526,11 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6)
if (msg_tlen < 4)
goto trunc;
- if (!TTEST2(*msg_data, 4))
- goto trunc;
+ ND_TCHECK2(*msg_data, 4);
- printf("\n\t Version %u, Entries %u%s",
+ ND_PRINT((ndo, "\n\t Version %u, Entries %u%s",
EXTRACT_16BITS(msg_data),
- name_entries, (name_entries_valid == 0) ? " (invalid)" : "");
+ name_entries, (name_entries_valid == 0) ? " (invalid)" : ""));
if (name_entries_valid == 0)
break;
@@ -553,8 +543,7 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6)
if (msg_tlen < 4)
break;
- if (!TTEST2(*msg_data, 4))
- goto trunc;
+ ND_TCHECK2(*msg_data, 4);
name_entry_type = EXTRACT_16BITS(msg_data);
name_entry_len = EXTRACT_16BITS(msg_data+2);
@@ -565,9 +554,9 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6)
if ((name_entry_len > 0) && ((addr_size + name_entry_len) <= msg_tlen))
name_entry_len_valid = 1;
- printf("\n\t #%u: type %#06x, length %u%s",
+ ND_PRINT((ndo, "\n\t #%u: type %#06x, length %u%s",
(unsigned int) i, name_entry_type,
- name_entry_len, (name_entry_len_valid == 0) ? " (invalid)" : "");
+ name_entry_len, (name_entry_len_valid == 0) ? " (invalid)" : ""));
if (name_entry_len_valid == 0)
break;
@@ -580,19 +569,18 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6)
if (msg_tlen < addr_size + name_entry_len + name_entry_padding)
goto trunc;
- if (!TTEST2(*msg_data, addr_size + name_entry_len + name_entry_padding))
- goto trunc;
+ ND_TCHECK2(*msg_data, addr_size + name_entry_len + name_entry_padding);
#if INET6
if (is_ipv6)
- printf(", address %s, name \"",
- ip6addr_string(msg_data));
+ ND_PRINT((ndo, ", address %s, name \"",
+ ip6addr_string(ndo, msg_data)));
else
#endif
- printf(", address %s, name \"",
- ipaddr_string(msg_data));
- fn_printn(msg_data + addr_size, name_entry_len, NULL);
- printf("\"");
+ ND_PRINT((ndo, ", address %s, name \"",
+ ipaddr_string(ndo, msg_data)));
+ fn_printn(ndo, msg_data + addr_size, name_entry_len, NULL);
+ ND_PRINT((ndo, "\""));
msg_data += addr_size + name_entry_len + name_entry_padding;
msg_tlen -= addr_size + name_entry_len + name_entry_padding;
@@ -606,7 +594,7 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6)
*/
case OLSR_POWERINFO_MSG:
default:
- print_unknown_data(msg_data, "\n\t ", msg_tlen);
+ print_unknown_data(ndo, msg_data, "\n\t ", msg_tlen);
break;
} /* switch (msg_type) */
tptr += msg_len;
@@ -615,7 +603,7 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6)
return;
trunc:
- printf("[|olsr]");
+ ND_PRINT((ndo, "[|olsr]"));
}
/*
diff --git a/contrib/tcpdump/print-openflow-1.0.c b/contrib/tcpdump/print-openflow-1.0.c
new file mode 100644
index 000000000000..a26f2dc0cdb3
--- /dev/null
+++ b/contrib/tcpdump/print-openflow-1.0.c
@@ -0,0 +1,2078 @@
+/*
+ * This module implements decoding of OpenFlow protocol version 1.0 (wire
+ * protocol 0x01). The decoder implements terse (default), detailed (-v) and
+ * full (-vv) output formats and, as much as each format implies, detects and
+ * tries to work around sizing anomalies inside the messages. The decoder marks
+ * up bogus values of selected message fields and decodes partially captured
+ * messages up to the snapshot end. It is based on the specification below:
+ *
+ * [OF10] http://www.openflow.org/documents/openflow-spec-v1.0.0.pdf
+ *
+ * Decoding of Ethernet frames nested in OFPT_PACKET_IN and OFPT_PACKET_OUT
+ * messages is done only when the verbosity level set by command-line argument
+ * is "-vvv" or higher. In that case the verbosity level is temporarily
+ * decremented by 3 during the nested frame decoding. For example, running
+ * tcpdump with "-vvvv" will do full decoding of OpenFlow and "-v" decoding of
+ * the nested frames.
+ *
+ *
+ * Copyright (c) 2013 The TCPDUMP project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 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 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#define NETDISSECT_REWORKED
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tcpdump-stdinc.h>
+
+#include "interface.h"
+#include "extract.h"
+#include "addrtoname.h"
+#include "ether.h"
+#include "ethertype.h"
+#include "ipproto.h"
+#include "openflow.h"
+
+static const char tstr[] = " [|openflow]";
+static const char cstr[] = " (corrupt)";
+
+#define OFPT_HELLO 0x00
+#define OFPT_ERROR 0x01
+#define OFPT_ECHO_REQUEST 0x02
+#define OFPT_ECHO_REPLY 0x03
+#define OFPT_VENDOR 0x04
+#define OFPT_FEATURES_REQUEST 0x05
+#define OFPT_FEATURES_REPLY 0x06
+#define OFPT_GET_CONFIG_REQUEST 0x07
+#define OFPT_GET_CONFIG_REPLY 0x08
+#define OFPT_SET_CONFIG 0x09
+#define OFPT_PACKET_IN 0x0a
+#define OFPT_FLOW_REMOVED 0x0b
+#define OFPT_PORT_STATUS 0x0c
+#define OFPT_PACKET_OUT 0x0d
+#define OFPT_FLOW_MOD 0x0e
+#define OFPT_PORT_MOD 0x0f
+#define OFPT_STATS_REQUEST 0x10
+#define OFPT_STATS_REPLY 0x11
+#define OFPT_BARRIER_REQUEST 0x12
+#define OFPT_BARRIER_REPLY 0x13
+#define OFPT_QUEUE_GET_CONFIG_REQUEST 0x14
+#define OFPT_QUEUE_GET_CONFIG_REPLY 0x15
+static const struct tok ofpt_str[] = {
+ { OFPT_HELLO, "HELLO" },
+ { OFPT_ERROR, "ERROR" },
+ { OFPT_ECHO_REQUEST, "ECHO_REQUEST" },
+ { OFPT_ECHO_REPLY, "ECHO_REPLY" },
+ { OFPT_VENDOR, "VENDOR" },
+ { OFPT_FEATURES_REQUEST, "FEATURES_REQUEST" },
+ { OFPT_FEATURES_REPLY, "FEATURES_REPLY" },
+ { OFPT_GET_CONFIG_REQUEST, "GET_CONFIG_REQUEST" },
+ { OFPT_GET_CONFIG_REPLY, "GET_CONFIG_REPLY" },
+ { OFPT_SET_CONFIG, "SET_CONFIG" },
+ { OFPT_PACKET_IN, "PACKET_IN" },
+ { OFPT_FLOW_REMOVED, "FLOW_REMOVED" },
+ { OFPT_PORT_STATUS, "PORT_STATUS" },
+ { OFPT_PACKET_OUT, "PACKET_OUT" },
+ { OFPT_FLOW_MOD, "FLOW_MOD" },
+ { OFPT_PORT_MOD, "PORT_MOD" },
+ { OFPT_STATS_REQUEST, "STATS_REQUEST" },
+ { OFPT_STATS_REPLY, "STATS_REPLY" },
+ { OFPT_BARRIER_REQUEST, "BARRIER_REQUEST" },
+ { OFPT_BARRIER_REPLY, "BARRIER_REPLY" },
+ { OFPT_QUEUE_GET_CONFIG_REQUEST, "QUEUE_GET_CONFIG_REQUEST" },
+ { OFPT_QUEUE_GET_CONFIG_REPLY, "QUEUE_GET_CONFIG_REPLY" },
+ { 0, NULL }
+};
+
+#define OFPPC_PORT_DOWN (1 << 0)
+#define OFPPC_NO_STP (1 << 1)
+#define OFPPC_NO_RECV (1 << 2)
+#define OFPPC_NO_RECV_STP (1 << 3)
+#define OFPPC_NO_FLOOD (1 << 4)
+#define OFPPC_NO_FWD (1 << 5)
+#define OFPPC_NO_PACKET_IN (1 << 6)
+static const struct tok ofppc_bm[] = {
+ { OFPPC_PORT_DOWN, "PORT_DOWN" },
+ { OFPPC_NO_STP, "NO_STP" },
+ { OFPPC_NO_RECV, "NO_RECV" },
+ { OFPPC_NO_RECV_STP, "NO_RECV_STP" },
+ { OFPPC_NO_FLOOD, "NO_FLOOD" },
+ { OFPPC_NO_FWD, "NO_FWD" },
+ { OFPPC_NO_PACKET_IN, "NO_PACKET_IN" },
+ { 0, NULL }
+};
+#define OFPPC_U (~(OFPPC_PORT_DOWN | OFPPC_NO_STP | OFPPC_NO_RECV | \
+ OFPPC_NO_RECV_STP | OFPPC_NO_FLOOD | OFPPC_NO_FWD | \
+ OFPPC_NO_PACKET_IN))
+
+#define OFPPS_LINK_DOWN (1 << 0)
+#define OFPPS_STP_LISTEN (0 << 8)
+#define OFPPS_STP_LEARN (1 << 8)
+#define OFPPS_STP_FORWARD (2 << 8)
+#define OFPPS_STP_BLOCK (3 << 8)
+#define OFPPS_STP_MASK (3 << 8)
+static const struct tok ofpps_bm[] = {
+ { OFPPS_LINK_DOWN, "LINK_DOWN" },
+ { OFPPS_STP_LISTEN, "STP_LISTEN" },
+ { OFPPS_STP_LEARN, "STP_LEARN" },
+ { OFPPS_STP_FORWARD, "STP_FORWARD" },
+ { OFPPS_STP_BLOCK, "STP_BLOCK" },
+ { 0, NULL }
+};
+#define OFPPS_U (~(OFPPS_LINK_DOWN | OFPPS_STP_LISTEN | OFPPS_STP_LEARN | \
+ OFPPS_STP_FORWARD | OFPPS_STP_BLOCK))
+
+#define OFPP_MAX 0xff00
+#define OFPP_IN_PORT 0xfff8
+#define OFPP_TABLE 0xfff9
+#define OFPP_NORMAL 0xfffa
+#define OFPP_FLOOD 0xfffb
+#define OFPP_ALL 0xfffc
+#define OFPP_CONTROLLER 0xfffd
+#define OFPP_LOCAL 0xfffe
+#define OFPP_NONE 0xffff
+static const struct tok ofpp_str[] = {
+ { OFPP_MAX, "MAX" },
+ { OFPP_IN_PORT, "IN_PORT" },
+ { OFPP_TABLE, "TABLE" },
+ { OFPP_NORMAL, "NORMAL" },
+ { OFPP_FLOOD, "FLOOD" },
+ { OFPP_ALL, "ALL" },
+ { OFPP_CONTROLLER, "CONTROLLER" },
+ { OFPP_LOCAL, "LOCAL" },
+ { OFPP_NONE, "NONE" },
+ { 0, NULL }
+};
+
+#define OFPPF_10MB_HD (1 << 0)
+#define OFPPF_10MB_FD (1 << 1)
+#define OFPPF_100MB_HD (1 << 2)
+#define OFPPF_100MB_FD (1 << 3)
+#define OFPPF_1GB_HD (1 << 4)
+#define OFPPF_1GB_FD (1 << 5)
+#define OFPPF_10GB_FD (1 << 6)
+#define OFPPF_COPPER (1 << 7)
+#define OFPPF_FIBER (1 << 8)
+#define OFPPF_AUTONEG (1 << 9)
+#define OFPPF_PAUSE (1 << 10)
+#define OFPPF_PAUSE_ASYM (1 << 11)
+static const struct tok ofppf_bm[] = {
+ { OFPPF_10MB_HD, "10MB_HD" },
+ { OFPPF_10MB_FD, "10MB_FD" },
+ { OFPPF_100MB_HD, "100MB_HD" },
+ { OFPPF_100MB_FD, "100MB_FD" },
+ { OFPPF_1GB_HD, "1GB_HD" },
+ { OFPPF_1GB_FD, "1GB_FD" },
+ { OFPPF_10GB_FD, "10GB_FD" },
+ { OFPPF_COPPER, "COPPER" },
+ { OFPPF_FIBER, "FIBER" },
+ { OFPPF_AUTONEG, "AUTONEG" },
+ { OFPPF_PAUSE, "PAUSE" },
+ { OFPPF_PAUSE_ASYM, "PAUSE_ASYM" },
+ { 0, NULL }
+};
+#define OFPPF_U (~(OFPPF_10MB_HD | OFPPF_10MB_FD | OFPPF_100MB_HD | \
+ OFPPF_100MB_FD | OFPPF_1GB_HD | OFPPF_1GB_FD | \
+ OFPPF_10GB_FD | OFPPF_COPPER | OFPPF_FIBER | \
+ OFPPF_AUTONEG | OFPPF_PAUSE | OFPPF_PAUSE_ASYM))
+
+#define OFPQT_NONE 0x0000
+#define OFPQT_MIN_RATE 0x0001
+static const struct tok ofpqt_str[] = {
+ { OFPQT_NONE, "NONE" },
+ { OFPQT_MIN_RATE, "MIN_RATE" },
+ { 0, NULL }
+};
+
+#define OFPFW_IN_PORT (1 << 0)
+#define OFPFW_DL_VLAN (1 << 1)
+#define OFPFW_DL_SRC (1 << 2)
+#define OFPFW_DL_DST (1 << 3)
+#define OFPFW_DL_TYPE (1 << 4)
+#define OFPFW_NW_PROTO (1 << 5)
+#define OFPFW_TP_SRC (1 << 6)
+#define OFPFW_TP_DST (1 << 7)
+#define OFPFW_NW_SRC_SHIFT 8
+#define OFPFW_NW_SRC_BITS 6
+#define OFPFW_NW_SRC_MASK (((1 << OFPFW_NW_SRC_BITS) - 1) << OFPFW_NW_SRC_SHIFT)
+#define OFPFW_NW_DST_SHIFT 14
+#define OFPFW_NW_DST_BITS 6
+#define OFPFW_NW_DST_MASK (((1 << OFPFW_NW_DST_BITS) - 1) << OFPFW_NW_DST_SHIFT)
+#define OFPFW_DL_VLAN_PCP (1 << 20)
+#define OFPFW_NW_TOS (1 << 21)
+#define OFPFW_ALL ((1 << 22) - 1)
+static const struct tok ofpfw_bm[] = {
+ { OFPFW_IN_PORT, "IN_PORT" },
+ { OFPFW_DL_VLAN, "DL_VLAN" },
+ { OFPFW_DL_SRC, "DL_SRC" },
+ { OFPFW_DL_DST, "DL_DST" },
+ { OFPFW_DL_TYPE, "DL_TYPE" },
+ { OFPFW_NW_PROTO, "NW_PROTO" },
+ { OFPFW_TP_SRC, "TP_SRC" },
+ { OFPFW_TP_DST, "TP_DST" },
+ { OFPFW_DL_VLAN_PCP, "DL_VLAN_PCP" },
+ { OFPFW_NW_TOS, "NW_TOS" },
+ { 0, NULL }
+};
+/* The above array does not include bits 8~13 (OFPFW_NW_SRC_*) and 14~19
+ * (OFPFW_NW_DST_*), which are not a part of the bitmap and require decoding
+ * other than that of tok2str(). The macro below includes these bits such that
+ * they are not reported as bogus in the decoding. */
+#define OFPFW_U (~(OFPFW_ALL))
+
+#define OFPAT_OUTPUT 0x0000
+#define OFPAT_SET_VLAN_VID 0x0001
+#define OFPAT_SET_VLAN_PCP 0x0002
+#define OFPAT_STRIP_VLAN 0x0003
+#define OFPAT_SET_DL_SRC 0x0004
+#define OFPAT_SET_DL_DST 0x0005
+#define OFPAT_SET_NW_SRC 0x0006
+#define OFPAT_SET_NW_DST 0x0007
+#define OFPAT_SET_NW_TOS 0x0008
+#define OFPAT_SET_TP_SRC 0x0009
+#define OFPAT_SET_TP_DST 0x000a
+#define OFPAT_ENQUEUE 0x000b
+#define OFPAT_VENDOR 0xffff
+static const struct tok ofpat_str[] = {
+ { OFPAT_OUTPUT, "OUTPUT" },
+ { OFPAT_SET_VLAN_VID, "SET_VLAN_VID" },
+ { OFPAT_SET_VLAN_PCP, "SET_VLAN_PCP" },
+ { OFPAT_STRIP_VLAN, "STRIP_VLAN" },
+ { OFPAT_SET_DL_SRC, "SET_DL_SRC" },
+ { OFPAT_SET_DL_DST, "SET_DL_DST" },
+ { OFPAT_SET_NW_SRC, "SET_NW_SRC" },
+ { OFPAT_SET_NW_DST, "SET_NW_DST" },
+ { OFPAT_SET_NW_TOS, "SET_NW_TOS" },
+ { OFPAT_SET_TP_SRC, "SET_TP_SRC" },
+ { OFPAT_SET_TP_DST, "SET_TP_DST" },
+ { OFPAT_ENQUEUE, "ENQUEUE" },
+ { OFPAT_VENDOR, "VENDOR" },
+ { 0, NULL }
+};
+
+/* bit-shifted, w/o vendor action */
+static const struct tok ofpat_bm[] = {
+ { 1 << OFPAT_OUTPUT, "OUTPUT" },
+ { 1 << OFPAT_SET_VLAN_VID, "SET_VLAN_VID" },
+ { 1 << OFPAT_SET_VLAN_PCP, "SET_VLAN_PCP" },
+ { 1 << OFPAT_STRIP_VLAN, "STRIP_VLAN" },
+ { 1 << OFPAT_SET_DL_SRC, "SET_DL_SRC" },
+ { 1 << OFPAT_SET_DL_DST, "SET_DL_DST" },
+ { 1 << OFPAT_SET_NW_SRC, "SET_NW_SRC" },
+ { 1 << OFPAT_SET_NW_DST, "SET_NW_DST" },
+ { 1 << OFPAT_SET_NW_TOS, "SET_NW_TOS" },
+ { 1 << OFPAT_SET_TP_SRC, "SET_TP_SRC" },
+ { 1 << OFPAT_SET_TP_DST, "SET_TP_DST" },
+ { 1 << OFPAT_ENQUEUE, "ENQUEUE" },
+ { 0, NULL }
+};
+#define OFPAT_U (~(1 << OFPAT_OUTPUT | 1 << OFPAT_SET_VLAN_VID | \
+ 1 << OFPAT_SET_VLAN_PCP | 1 << OFPAT_STRIP_VLAN | \
+ 1 << OFPAT_SET_DL_SRC | 1 << OFPAT_SET_DL_DST | \
+ 1 << OFPAT_SET_NW_SRC | 1 << OFPAT_SET_NW_DST | \
+ 1 << OFPAT_SET_NW_TOS | 1 << OFPAT_SET_TP_SRC | \
+ 1 << OFPAT_SET_TP_DST | 1 << OFPAT_ENQUEUE))
+
+#define OFPC_FLOW_STATS (1 << 0)
+#define OFPC_TABLE_STATS (1 << 1)
+#define OFPC_PORT_STATS (1 << 2)
+#define OFPC_STP (1 << 3)
+#define OFPC_RESERVED (1 << 4)
+#define OFPC_IP_REASM (1 << 5)
+#define OFPC_QUEUE_STATS (1 << 6)
+#define OFPC_ARP_MATCH_IP (1 << 7)
+static const struct tok ofp_capabilities_bm[] = {
+ { OFPC_FLOW_STATS, "FLOW_STATS" },
+ { OFPC_TABLE_STATS, "TABLE_STATS" },
+ { OFPC_PORT_STATS, "PORT_STATS" },
+ { OFPC_STP, "STP" },
+ { OFPC_RESERVED, "RESERVED" }, /* not in the mask below */
+ { OFPC_IP_REASM, "IP_REASM" },
+ { OFPC_QUEUE_STATS, "QUEUE_STATS" },
+ { OFPC_ARP_MATCH_IP, "ARP_MATCH_IP" },
+ { 0, NULL }
+};
+#define OFPCAP_U (~(OFPC_FLOW_STATS | OFPC_TABLE_STATS | OFPC_PORT_STATS | \
+ OFPC_STP | OFPC_IP_REASM | OFPC_QUEUE_STATS | \
+ OFPC_ARP_MATCH_IP))
+
+#define OFPC_FRAG_NORMAL 0x0000
+#define OFPC_FRAG_DROP 0x0001
+#define OFPC_FRAG_REASM 0x0002
+#define OFPC_FRAG_MASK 0x0003
+static const struct tok ofp_config_str[] = {
+ { OFPC_FRAG_NORMAL, "FRAG_NORMAL" },
+ { OFPC_FRAG_DROP, "FRAG_DROP" },
+ { OFPC_FRAG_REASM, "FRAG_REASM" },
+ { 0, NULL }
+};
+
+#define OFPFC_ADD 0x0000
+#define OFPFC_MODIFY 0x0001
+#define OFPFC_MODIFY_STRICT 0x0002
+#define OFPFC_DELETE 0x0003
+#define OFPFC_DELETE_STRICT 0x0004
+static const struct tok ofpfc_str[] = {
+ { OFPFC_ADD, "ADD" },
+ { OFPFC_MODIFY, "MODIFY" },
+ { OFPFC_MODIFY_STRICT, "MODIFY_STRICT" },
+ { OFPFC_DELETE, "DELETE" },
+ { OFPFC_DELETE_STRICT, "DELETE_STRICT" },
+ { 0, NULL }
+};
+
+static const struct tok bufferid_str[] = {
+ { 0xffffffff, "NONE" },
+ { 0, NULL }
+};
+
+#define OFPFF_SEND_FLOW_REM (1 << 0)
+#define OFPFF_CHECK_OVERLAP (1 << 1)
+#define OFPFF_EMERG (1 << 2)
+static const struct tok ofpff_bm[] = {
+ { OFPFF_SEND_FLOW_REM, "SEND_FLOW_REM" },
+ { OFPFF_CHECK_OVERLAP, "CHECK_OVERLAP" },
+ { OFPFF_EMERG, "EMERG" },
+ { 0, NULL }
+};
+#define OFPFF_U (~(OFPFF_SEND_FLOW_REM | OFPFF_CHECK_OVERLAP | OFPFF_EMERG))
+
+#define OFPST_DESC 0x0000
+#define OFPST_FLOW 0x0001
+#define OFPST_AGGREGATE 0x0002
+#define OFPST_TABLE 0x0003
+#define OFPST_PORT 0x0004
+#define OFPST_QUEUE 0x0005
+#define OFPST_VENDOR 0xffff
+static const struct tok ofpst_str[] = {
+ { OFPST_DESC, "DESC" },
+ { OFPST_FLOW, "FLOW" },
+ { OFPST_AGGREGATE, "AGGREGATE" },
+ { OFPST_TABLE, "TABLE" },
+ { OFPST_PORT, "PORT" },
+ { OFPST_QUEUE, "QUEUE" },
+ { OFPST_VENDOR, "VENDOR" },
+ { 0, NULL }
+};
+
+static const struct tok tableid_str[] = {
+ { 0xfe, "EMERG" },
+ { 0xff, "ALL" },
+ { 0, NULL }
+};
+
+#define OFPQ_ALL 0xffffffff
+static const struct tok ofpq_str[] = {
+ { OFPQ_ALL, "ALL" },
+ { 0, NULL }
+};
+
+#define OFPSF_REPLY_MORE 0x0001
+static const struct tok ofpsf_reply_bm[] = {
+ { OFPSF_REPLY_MORE, "MORE" },
+ { 0, NULL }
+};
+#define OFPSF_REPLY_U (~(OFPSF_REPLY_MORE))
+
+#define OFPR_NO_MATCH 0x00
+#define OFPR_ACTION 0x01
+static const struct tok ofpr_str[] = {
+ { OFPR_NO_MATCH, "NO_MATCH" },
+ { OFPR_ACTION, "ACTION" },
+ { 0, NULL }
+};
+
+#define OFPRR_IDLE_TIMEOUT 0x00
+#define OFPRR_HARD_TIMEOUT 0x01
+#define OFPRR_DELETE 0x02
+static const struct tok ofprr_str[] = {
+ { OFPRR_IDLE_TIMEOUT, "IDLE_TIMEOUT" },
+ { OFPRR_HARD_TIMEOUT, "HARD_TIMEOUT" },
+ { OFPRR_DELETE, "DELETE" },
+ { 0, NULL }
+};
+
+#define OFPPR_ADD 0x00
+#define OFPPR_DELETE 0x01
+#define OFPPR_MODIFY 0x02
+static const struct tok ofppr_str[] = {
+ { OFPPR_ADD, "ADD" },
+ { OFPPR_DELETE, "DELETE" },
+ { OFPPR_MODIFY, "MODIFY" },
+ { 0, NULL }
+};
+
+#define OFPET_HELLO_FAILED 0x0000
+#define OFPET_BAD_REQUEST 0x0001
+#define OFPET_BAD_ACTION 0x0002
+#define OFPET_FLOW_MOD_FAILED 0x0003
+#define OFPET_PORT_MOD_FAILED 0x0004
+#define OFPET_QUEUE_OP_FAILED 0x0005
+static const struct tok ofpet_str[] = {
+ { OFPET_HELLO_FAILED, "HELLO_FAILED" },
+ { OFPET_BAD_REQUEST, "BAD_REQUEST" },
+ { OFPET_BAD_ACTION, "BAD_ACTION" },
+ { OFPET_FLOW_MOD_FAILED, "FLOW_MOD_FAILED" },
+ { OFPET_PORT_MOD_FAILED, "PORT_MOD_FAILED" },
+ { OFPET_QUEUE_OP_FAILED, "QUEUE_OP_FAILED" },
+ { 0, NULL }
+};
+
+#define OFPHFC_INCOMPATIBLE 0x0000
+#define OFPHFC_EPERM 0x0001
+static const struct tok ofphfc_str[] = {
+ { OFPHFC_INCOMPATIBLE, "INCOMPATIBLE" },
+ { OFPHFC_EPERM, "EPERM" },
+ { 0, NULL }
+};
+
+#define OFPBRC_BAD_VERSION 0x0000
+#define OFPBRC_BAD_TYPE 0x0001
+#define OFPBRC_BAD_STAT 0x0002
+#define OFPBRC_BAD_VENDOR 0x0003
+#define OFPBRC_BAD_SUBTYPE 0x0004
+#define OFPBRC_EPERM 0x0005
+#define OFPBRC_BAD_LEN 0x0006
+#define OFPBRC_BUFFER_EMPTY 0x0007
+#define OFPBRC_BUFFER_UNKNOWN 0x0008
+static const struct tok ofpbrc_str[] = {
+ { OFPBRC_BAD_VERSION, "BAD_VERSION" },
+ { OFPBRC_BAD_TYPE, "BAD_TYPE" },
+ { OFPBRC_BAD_STAT, "BAD_STAT" },
+ { OFPBRC_BAD_VENDOR, "BAD_VENDOR" },
+ { OFPBRC_BAD_SUBTYPE, "BAD_SUBTYPE" },
+ { OFPBRC_EPERM, "EPERM" },
+ { OFPBRC_BAD_LEN, "BAD_LEN" },
+ { OFPBRC_BUFFER_EMPTY, "BUFFER_EMPTY" },
+ { OFPBRC_BUFFER_UNKNOWN, "BUFFER_UNKNOWN" },
+ { 0, NULL }
+};
+
+#define OFPBAC_BAD_TYPE 0x0000
+#define OFPBAC_BAD_LEN 0x0001
+#define OFPBAC_BAD_VENDOR 0x0002
+#define OFPBAC_BAD_VENDOR_TYPE 0x0003
+#define OFPBAC_BAD_OUT_PORT 0x0004
+#define OFPBAC_BAD_ARGUMENT 0x0005
+#define OFPBAC_EPERM 0x0006
+#define OFPBAC_TOO_MANY 0x0007
+#define OFPBAC_BAD_QUEUE 0x0008
+static const struct tok ofpbac_str[] = {
+ { OFPBAC_BAD_TYPE, "BAD_TYPE" },
+ { OFPBAC_BAD_LEN, "BAD_LEN" },
+ { OFPBAC_BAD_VENDOR, "BAD_VENDOR" },
+ { OFPBAC_BAD_VENDOR_TYPE, "BAD_VENDOR_TYPE" },
+ { OFPBAC_BAD_OUT_PORT, "BAD_OUT_PORT" },
+ { OFPBAC_BAD_ARGUMENT, "BAD_ARGUMENT" },
+ { OFPBAC_EPERM, "EPERM" },
+ { OFPBAC_TOO_MANY, "TOO_MANY" },
+ { OFPBAC_BAD_QUEUE, "BAD_QUEUE" },
+ { 0, NULL }
+};
+
+#define OFPFMFC_ALL_TABLES_FULL 0x0000
+#define OFPFMFC_OVERLAP 0x0001
+#define OFPFMFC_EPERM 0x0002
+#define OFPFMFC_BAD_EMERG_TIMEOUT 0x0003
+#define OFPFMFC_BAD_COMMAND 0x0004
+#define OFPFMFC_UNSUPPORTED 0x0005
+static const struct tok ofpfmfc_str[] = {
+ { OFPFMFC_ALL_TABLES_FULL, "ALL_TABLES_FULL" },
+ { OFPFMFC_OVERLAP, "OVERLAP" },
+ { OFPFMFC_EPERM, "EPERM" },
+ { OFPFMFC_BAD_EMERG_TIMEOUT, "BAD_EMERG_TIMEOUT" },
+ { OFPFMFC_BAD_COMMAND, "BAD_COMMAND" },
+ { OFPFMFC_UNSUPPORTED, "UNSUPPORTED" },
+ { 0, NULL }
+};
+
+#define OFPPMFC_BAD_PORT 0x0000
+#define OFPPMFC_BAD_HW_ADDR 0x0001
+static const struct tok ofppmfc_str[] = {
+ { OFPPMFC_BAD_PORT, "BAD_PORT" },
+ { OFPPMFC_BAD_HW_ADDR, "BAD_HW_ADDR" },
+ { 0, NULL }
+};
+
+#define OFPQOFC_BAD_PORT 0x0000
+#define OFPQOFC_BAD_QUEUE 0x0001
+#define OFPQOFC_EPERM 0x0002
+static const struct tok ofpqofc_str[] = {
+ { OFPQOFC_BAD_PORT, "BAD_PORT" },
+ { OFPQOFC_BAD_QUEUE, "BAD_QUEUE" },
+ { OFPQOFC_EPERM, "EPERM" },
+ { 0, NULL }
+};
+
+static const struct tok empty_str[] = {
+ { 0, NULL }
+};
+
+/* lengths (fixed or minimal) of particular protocol structures */
+#define OF_SWITCH_CONFIG_LEN 12
+#define OF_PHY_PORT_LEN 48
+#define OF_SWITCH_FEATURES_LEN 32
+#define OF_PORT_STATUS_LEN 64
+#define OF_PORT_MOD_LEN 32
+#define OF_PACKET_IN_LEN 20
+#define OF_ACTION_OUTPUT_LEN 8
+#define OF_ACTION_VLAN_VID_LEN 8
+#define OF_ACTION_VLAN_PCP_LEN 8
+#define OF_ACTION_DL_ADDR_LEN 16
+#define OF_ACTION_NW_ADDR_LEN 8
+#define OF_ACTION_TP_PORT_LEN 8
+#define OF_ACTION_NW_TOS_LEN 8
+#define OF_ACTION_VENDOR_HEADER_LEN 8
+#define OF_ACTION_HEADER_LEN 8
+#define OF_PACKET_OUT_LEN 16
+#define OF_MATCH_LEN 40
+#define OF_FLOW_MOD_LEN 72
+#define OF_FLOW_REMOVED_LEN 88
+#define OF_ERROR_MSG_LEN 12
+#define OF_STATS_REQUEST_LEN 12
+#define OF_STATS_REPLY_LEN 12
+#define OF_DESC_STATS_LEN 1056
+#define OF_FLOW_STATS_REQUEST_LEN 44
+#define OF_FLOW_STATS_LEN 88
+#define OF_AGGREGATE_STATS_REQUEST_LEN 44
+#define OF_AGGREGATE_STATS_REPLY_LEN 24
+#define OF_TABLE_STATS_LEN 64
+#define OF_PORT_STATS_REQUEST_LEN 8
+#define OF_PORT_STATS_LEN 104
+#define OF_VENDOR_HEADER_LEN 12
+#define OF_QUEUE_PROP_HEADER_LEN 8
+#define OF_QUEUE_PROP_MIN_RATE_LEN 16
+#define OF_PACKET_QUEUE_LEN 8
+#define OF_QUEUE_GET_CONFIG_REQUEST_LEN 12
+#define OF_QUEUE_GET_CONFIG_REPLY_LEN 16
+#define OF_ACTION_ENQUEUE_LEN 16
+#define OF_QUEUE_STATS_REQUEST_LEN 8
+#define OF_QUEUE_STATS_LEN 32
+
+/* miscellaneous constants from [OF10] */
+#define OFP_MAX_TABLE_NAME_LEN 32
+#define OFP_MAX_PORT_NAME_LEN 16
+#define DESC_STR_LEN 256
+#define SERIAL_NUM_LEN 32
+#define OFP_VLAN_NONE 0xffff
+
+static const char *
+vlan_str(const uint16_t vid) {
+ static char buf[sizeof("65535 (bogus)")];
+ const char *fmt;
+
+ if (vid == OFP_VLAN_NONE)
+ return "NONE";
+ fmt = (vid > 0 && vid < 0x0fff) ? "%u" : "%u (bogus)";
+ snprintf(buf, sizeof(buf), fmt, vid);
+ return buf;
+}
+
+static const char *
+pcp_str(const uint8_t pcp) {
+ static char buf[sizeof("255 (bogus)")];
+ snprintf(buf, sizeof(buf), pcp <= 7 ? "%u" : "%u (bogus)", pcp);
+ return buf;
+}
+
+static void
+of10_bitmap_print(netdissect_options *ndo,
+ const struct tok *t, const uint32_t v, const uint32_t u) {
+ const char *sep = " (";
+
+ if (v == 0)
+ return;
+ /* assigned bits */
+ for (; t->s != NULL; t++)
+ if (v & t->v) {
+ ND_PRINT((ndo, "%s%s", sep, t->s));
+ sep = ", ";
+ }
+ /* unassigned bits? */
+ ND_PRINT((ndo, v & u ? ") (bogus)" : ")"));
+}
+
+static const u_char *
+of10_data_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, const u_int len) {
+ if (len == 0)
+ return cp;
+ /* data */
+ ND_PRINT((ndo, "\n\t data (%u octets)", len));
+ ND_TCHECK2(*cp, len);
+ if (ndo->ndo_vflag >= 2)
+ hex_and_ascii_print(ndo, "\n\t ", cp, len);
+ return cp + len;
+
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* Vendor ID is mandatory, data is optional. */
+static const u_char *
+of10_vendor_data_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, const u_int len) {
+ if (len < 4)
+ goto corrupt;
+ /* vendor */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, ", vendor 0x%08x", EXTRACT_32BITS(cp)));
+ cp += 4;
+ /* data */
+ return of10_data_print(ndo, cp, ep, len - 4);
+
+corrupt: /* skip the undersized data */
+ ND_PRINT((ndo, "%s", cstr));
+ ND_TCHECK2(*cp, len);
+ return cp + len;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+static const u_char *
+of10_packet_data_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, const u_int len) {
+ if (len == 0)
+ return cp;
+ /* data */
+ ND_PRINT((ndo, "\n\t data (%u octets)", len));
+ if (ndo->ndo_vflag < 3)
+ return cp + len;
+ ND_TCHECK2(*cp, len);
+ ndo->ndo_vflag -= 3;
+ ND_PRINT((ndo, ", frame decoding below\n"));
+ ether_print(ndo, cp, len, ndo->ndo_snapend - cp, NULL, NULL);
+ ndo->ndo_vflag += 3;
+ return cp + len;
+
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* [OF10] Section 5.2.1 */
+static const u_char *
+of10_phy_ports_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, u_int len) {
+ const u_char *cp0 = cp;
+ const u_int len0 = len;
+
+ while (len) {
+ if (len < OF_PHY_PORT_LEN)
+ goto corrupt;
+ /* port_no */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, "\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
+ cp += 2;
+ /* hw_addr */
+ ND_TCHECK2(*cp, ETHER_ADDR_LEN);
+ ND_PRINT((ndo, ", hw_addr %s", etheraddr_string(ndo, cp)));
+ cp += ETHER_ADDR_LEN;
+ /* name */
+ ND_TCHECK2(*cp, OFP_MAX_PORT_NAME_LEN);
+ ND_PRINT((ndo, ", name '"));
+ fn_print(ndo, cp, cp + OFP_MAX_PORT_NAME_LEN);
+ ND_PRINT((ndo, "'"));
+ cp += OFP_MAX_PORT_NAME_LEN;
+
+ if (ndo->ndo_vflag < 2) {
+ ND_TCHECK2(*cp, 24);
+ cp += 24;
+ goto next_port;
+ }
+ /* config */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, "\n\t config 0x%08x", EXTRACT_32BITS(cp)));
+ of10_bitmap_print(ndo, ofppc_bm, EXTRACT_32BITS(cp), OFPPC_U);
+ cp += 4;
+ /* state */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, "\n\t state 0x%08x", EXTRACT_32BITS(cp)));
+ of10_bitmap_print(ndo, ofpps_bm, EXTRACT_32BITS(cp), OFPPS_U);
+ cp += 4;
+ /* curr */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, "\n\t curr 0x%08x", EXTRACT_32BITS(cp)));
+ of10_bitmap_print(ndo, ofppf_bm, EXTRACT_32BITS(cp), OFPPF_U);
+ cp += 4;
+ /* advertised */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, "\n\t advertised 0x%08x", EXTRACT_32BITS(cp)));
+ of10_bitmap_print(ndo, ofppf_bm, EXTRACT_32BITS(cp), OFPPF_U);
+ cp += 4;
+ /* supported */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, "\n\t supported 0x%08x", EXTRACT_32BITS(cp)));
+ of10_bitmap_print(ndo, ofppf_bm, EXTRACT_32BITS(cp), OFPPF_U);
+ cp += 4;
+ /* peer */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, "\n\t peer 0x%08x", EXTRACT_32BITS(cp)));
+ of10_bitmap_print(ndo, ofppf_bm, EXTRACT_32BITS(cp), OFPPF_U);
+ cp += 4;
+next_port:
+ len -= OF_PHY_PORT_LEN;
+ } /* while */
+ return cp;
+
+corrupt: /* skip the undersized trailing data */
+ ND_PRINT((ndo, "%s", cstr));
+ ND_TCHECK2(*cp0, len0);
+ return cp0 + len0;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* [OF10] Section 5.2.2 */
+static const u_char *
+of10_queue_props_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, u_int len) {
+ const u_char *cp0 = cp;
+ const u_int len0 = len;
+ uint16_t property, plen, rate;
+
+ while (len) {
+ u_char plen_bogus = 0, skip = 0;
+
+ if (len < OF_QUEUE_PROP_HEADER_LEN)
+ goto corrupt;
+ /* property */
+ ND_TCHECK2(*cp, 2);
+ property = EXTRACT_16BITS(cp);
+ cp += 2;
+ ND_PRINT((ndo, "\n\t property %s", tok2str(ofpqt_str, "invalid (0x%04x)", property)));
+ /* len */
+ ND_TCHECK2(*cp, 2);
+ plen = EXTRACT_16BITS(cp);
+ cp += 2;
+ ND_PRINT((ndo, ", len %u", plen));
+ if (plen < OF_QUEUE_PROP_HEADER_LEN || plen > len)
+ goto corrupt;
+ /* pad */
+ ND_TCHECK2(*cp, 4);
+ cp += 4;
+ /* property-specific constraints and decoding */
+ switch (property) {
+ case OFPQT_NONE:
+ plen_bogus = plen != OF_QUEUE_PROP_HEADER_LEN;
+ break;
+ case OFPQT_MIN_RATE:
+ plen_bogus = plen != OF_QUEUE_PROP_MIN_RATE_LEN;
+ break;
+ default:
+ skip = 1;
+ }
+ if (plen_bogus) {
+ ND_PRINT((ndo, " (bogus)"));
+ skip = 1;
+ }
+ if (skip) {
+ ND_TCHECK2(*cp, plen - 4);
+ cp += plen - 4;
+ goto next_property;
+ }
+ if (property == OFPQT_MIN_RATE) { /* the only case of property decoding */
+ /* rate */
+ ND_TCHECK2(*cp, 2);
+ rate = EXTRACT_16BITS(cp);
+ cp += 2;
+ if (rate > 1000)
+ ND_PRINT((ndo, ", rate disabled"));
+ else
+ ND_PRINT((ndo, ", rate %u.%u%%", rate / 10, rate % 10));
+ /* pad */
+ ND_TCHECK2(*cp, 6);
+ cp += 6;
+ }
+next_property:
+ len -= plen;
+ } /* while */
+ return cp;
+
+corrupt: /* skip the rest of queue properties */
+ ND_PRINT((ndo, "%s", cstr));
+ ND_TCHECK2(*cp0, len0);
+ return cp0 + len0;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* ibid */
+static const u_char *
+of10_queues_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, u_int len) {
+ const u_char *cp0 = cp;
+ const u_int len0 = len;
+ uint16_t desclen;
+
+ while (len) {
+ if (len < OF_PACKET_QUEUE_LEN)
+ goto corrupt;
+ /* queue_id */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, "\n\t queue_id %u", EXTRACT_32BITS(cp)));
+ cp += 4;
+ /* len */
+ ND_TCHECK2(*cp, 2);
+ desclen = EXTRACT_16BITS(cp);
+ cp += 2;
+ ND_PRINT((ndo, ", len %u", desclen));
+ if (desclen < OF_PACKET_QUEUE_LEN || desclen > len)
+ goto corrupt;
+ /* pad */
+ ND_TCHECK2(*cp, 2);
+ cp += 2;
+ /* properties */
+ if (ndo->ndo_vflag < 2) {
+ ND_TCHECK2(*cp, desclen - OF_PACKET_QUEUE_LEN);
+ cp += desclen - OF_PACKET_QUEUE_LEN;
+ goto next_queue;
+ }
+ if (ep == (cp = of10_queue_props_print(ndo, cp, ep, desclen - OF_PACKET_QUEUE_LEN)))
+ return ep; /* end of snapshot */
+next_queue:
+ len -= desclen;
+ } /* while */
+ return cp;
+
+corrupt: /* skip the rest of queues */
+ ND_PRINT((ndo, "%s", cstr));
+ ND_TCHECK2(*cp0, len0);
+ return cp0 + len0;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* [OF10] Section 5.2.3 */
+static const u_char *
+of10_match_print(netdissect_options *ndo,
+ const char *pfx, const u_char *cp, const u_char *ep) {
+ uint32_t wildcards;
+ uint16_t dl_type;
+ uint8_t nw_proto;
+ u_char nw_bits;
+ const char *field_name;
+
+ /* wildcards */
+ ND_TCHECK2(*cp, 4);
+ wildcards = EXTRACT_32BITS(cp);
+ if (wildcards & OFPFW_U)
+ ND_PRINT((ndo, "%swildcards 0x%08x (bogus)", pfx, wildcards));
+ cp += 4;
+ /* in_port */
+ ND_TCHECK2(*cp, 2);
+ if (! (wildcards & OFPFW_IN_PORT))
+ ND_PRINT((ndo, "%smatch in_port %s", pfx, tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
+ cp += 2;
+ /* dl_src */
+ ND_TCHECK2(*cp, ETHER_ADDR_LEN);
+ if (! (wildcards & OFPFW_DL_SRC))
+ ND_PRINT((ndo, "%smatch dl_src %s", pfx, etheraddr_string(ndo, cp)));
+ cp += ETHER_ADDR_LEN;
+ /* dl_dst */
+ ND_TCHECK2(*cp, ETHER_ADDR_LEN);
+ if (! (wildcards & OFPFW_DL_DST))
+ ND_PRINT((ndo, "%smatch dl_dst %s", pfx, etheraddr_string(ndo, cp)));
+ cp += ETHER_ADDR_LEN;
+ /* dl_vlan */
+ ND_TCHECK2(*cp, 2);
+ if (! (wildcards & OFPFW_DL_VLAN))
+ ND_PRINT((ndo, "%smatch dl_vlan %s", pfx, vlan_str(EXTRACT_16BITS(cp))));
+ cp += 2;
+ /* dl_vlan_pcp */
+ ND_TCHECK2(*cp, 1);
+ if (! (wildcards & OFPFW_DL_VLAN_PCP))
+ ND_PRINT((ndo, "%smatch dl_vlan_pcp %s", pfx, pcp_str(*cp)));
+ cp += 1;
+ /* pad1 */
+ ND_TCHECK2(*cp, 1);
+ cp += 1;
+ /* dl_type */
+ ND_TCHECK2(*cp, 2);
+ dl_type = EXTRACT_16BITS(cp);
+ cp += 2;
+ if (! (wildcards & OFPFW_DL_TYPE))
+ ND_PRINT((ndo, "%smatch dl_type 0x%04x", pfx, dl_type));
+ /* nw_tos */
+ ND_TCHECK2(*cp, 1);
+ if (! (wildcards & OFPFW_NW_TOS))
+ ND_PRINT((ndo, "%smatch nw_tos 0x%02x", pfx, *cp));
+ cp += 1;
+ /* nw_proto */
+ ND_TCHECK2(*cp, 1);
+ nw_proto = *cp;
+ cp += 1;
+ if (! (wildcards & OFPFW_NW_PROTO)) {
+ field_name = ! (wildcards & OFPFW_DL_TYPE) && dl_type == ETHERTYPE_ARP
+ ? "arp_opcode" : "nw_proto";
+ ND_PRINT((ndo, "%smatch %s %u", pfx, field_name, nw_proto));
+ }
+ /* pad2 */
+ ND_TCHECK2(*cp, 2);
+ cp += 2;
+ /* nw_src */
+ ND_TCHECK2(*cp, 4);
+ nw_bits = (wildcards & OFPFW_NW_SRC_MASK) >> OFPFW_NW_SRC_SHIFT;
+ if (nw_bits < 32)
+ ND_PRINT((ndo, "%smatch nw_src %s/%u", pfx, ipaddr_string(ndo, cp), 32 - nw_bits));
+ cp += 4;
+ /* nw_dst */
+ ND_TCHECK2(*cp, 4);
+ nw_bits = (wildcards & OFPFW_NW_DST_MASK) >> OFPFW_NW_DST_SHIFT;
+ if (nw_bits < 32)
+ ND_PRINT((ndo, "%smatch nw_dst %s/%u", pfx, ipaddr_string(ndo, cp), 32 - nw_bits));
+ cp += 4;
+ /* tp_src */
+ ND_TCHECK2(*cp, 2);
+ if (! (wildcards & OFPFW_TP_SRC)) {
+ field_name = ! (wildcards & OFPFW_DL_TYPE) && dl_type == ETHERTYPE_IP
+ && ! (wildcards & OFPFW_NW_PROTO) && nw_proto == IPPROTO_ICMP
+ ? "icmp_type" : "tp_src";
+ ND_PRINT((ndo, "%smatch %s %u", pfx, field_name, EXTRACT_16BITS(cp)));
+ }
+ cp += 2;
+ /* tp_dst */
+ ND_TCHECK2(*cp, 2);
+ if (! (wildcards & OFPFW_TP_DST)) {
+ field_name = ! (wildcards & OFPFW_DL_TYPE) && dl_type == ETHERTYPE_IP
+ && ! (wildcards & OFPFW_NW_PROTO) && nw_proto == IPPROTO_ICMP
+ ? "icmp_code" : "tp_dst";
+ ND_PRINT((ndo, "%smatch %s %u", pfx, field_name, EXTRACT_16BITS(cp)));
+ }
+ return cp + 2;
+
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* [OF10] Section 5.2.4 */
+static const u_char *
+of10_actions_print(netdissect_options *ndo,
+ const char *pfx, const u_char *cp, const u_char *ep,
+ u_int len) {
+ const u_char *cp0 = cp;
+ const u_int len0 = len;
+ uint16_t type, alen, output_port;
+
+ while (len) {
+ u_char alen_bogus = 0, skip = 0;
+
+ if (len < OF_ACTION_HEADER_LEN)
+ goto corrupt;
+ /* type */
+ ND_TCHECK2(*cp, 2);
+ type = EXTRACT_16BITS(cp);
+ cp += 2;
+ ND_PRINT((ndo, "%saction type %s", pfx, tok2str(ofpat_str, "invalid (0x%04x)", type)));
+ /* length */
+ ND_TCHECK2(*cp, 2);
+ alen = EXTRACT_16BITS(cp);
+ cp += 2;
+ ND_PRINT((ndo, ", len %u", alen));
+ /* On action size underrun/overrun skip the rest of the action list. */
+ if (alen < OF_ACTION_HEADER_LEN || alen > len)
+ goto corrupt;
+ /* On action size inappropriate for the given type or invalid type just skip
+ * the current action, as the basic length constraint has been met. */
+ switch (type) {
+ case OFPAT_OUTPUT:
+ case OFPAT_SET_VLAN_VID:
+ case OFPAT_SET_VLAN_PCP:
+ case OFPAT_STRIP_VLAN:
+ case OFPAT_SET_NW_SRC:
+ case OFPAT_SET_NW_DST:
+ case OFPAT_SET_NW_TOS:
+ case OFPAT_SET_TP_SRC:
+ case OFPAT_SET_TP_DST:
+ alen_bogus = alen != 8;
+ break;
+ case OFPAT_SET_DL_SRC:
+ case OFPAT_SET_DL_DST:
+ case OFPAT_ENQUEUE:
+ alen_bogus = alen != 16;
+ break;
+ case OFPAT_VENDOR:
+ alen_bogus = alen % 8 != 0; /* already >= 8 so far */
+ break;
+ default:
+ skip = 1;
+ }
+ if (alen_bogus) {
+ ND_PRINT((ndo, " (bogus)"));
+ skip = 1;
+ }
+ if (skip) {
+ ND_TCHECK2(*cp, alen - 4);
+ cp += alen - 4;
+ goto next_action;
+ }
+ /* OK to decode the rest of the action structure */
+ switch (type) {
+ case OFPAT_OUTPUT:
+ /* port */
+ ND_TCHECK2(*cp, 2);
+ output_port = EXTRACT_16BITS(cp);
+ cp += 2;
+ ND_PRINT((ndo, ", port %s", tok2str(ofpp_str, "%u", output_port)));
+ /* max_len */
+ ND_TCHECK2(*cp, 2);
+ if (output_port == OFPP_CONTROLLER)
+ ND_PRINT((ndo, ", max_len %u", EXTRACT_16BITS(cp)));
+ cp += 2;
+ break;
+ case OFPAT_SET_VLAN_VID:
+ /* vlan_vid */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, ", vlan_vid %s", vlan_str(EXTRACT_16BITS(cp))));
+ cp += 2;
+ /* pad */
+ ND_TCHECK2(*cp, 2);
+ cp += 2;
+ break;
+ case OFPAT_SET_VLAN_PCP:
+ /* vlan_pcp */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", vlan_pcp %s", pcp_str(*cp)));
+ cp += 1;
+ /* pad */
+ ND_TCHECK2(*cp, 3);
+ cp += 3;
+ break;
+ case OFPAT_SET_DL_SRC:
+ case OFPAT_SET_DL_DST:
+ /* dl_addr */
+ ND_TCHECK2(*cp, ETHER_ADDR_LEN);
+ ND_PRINT((ndo, ", dl_addr %s", etheraddr_string(ndo, cp)));
+ cp += ETHER_ADDR_LEN;
+ /* pad */
+ ND_TCHECK2(*cp, 6);
+ cp += 6;
+ break;
+ case OFPAT_SET_NW_SRC:
+ case OFPAT_SET_NW_DST:
+ /* nw_addr */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, ", nw_addr %s", ipaddr_string(ndo, cp)));
+ cp += 4;
+ break;
+ case OFPAT_SET_NW_TOS:
+ /* nw_tos */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", nw_tos 0x%02x", *cp));
+ cp += 1;
+ /* pad */
+ ND_TCHECK2(*cp, 3);
+ cp += 3;
+ break;
+ case OFPAT_SET_TP_SRC:
+ case OFPAT_SET_TP_DST:
+ /* nw_tos */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, ", tp_port %u", EXTRACT_16BITS(cp)));
+ cp += 2;
+ /* pad */
+ ND_TCHECK2(*cp, 2);
+ cp += 2;
+ break;
+ case OFPAT_ENQUEUE:
+ /* port */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, ", port %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
+ cp += 2;
+ /* pad */
+ ND_TCHECK2(*cp, 6);
+ cp += 6;
+ /* queue_id */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, ", queue_id %s", tok2str(ofpq_str, "%u", EXTRACT_32BITS(cp))));
+ cp += 4;
+ break;
+ case OFPAT_VENDOR:
+ if (ep == (cp = of10_vendor_data_print(ndo, cp, ep, alen - 4)))
+ return ep; /* end of snapshot */
+ break;
+ case OFPAT_STRIP_VLAN:
+ /* pad */
+ ND_TCHECK2(*cp, 4);
+ cp += 4;
+ break;
+ } /* switch */
+next_action:
+ len -= alen;
+ } /* while */
+ return cp;
+
+corrupt: /* skip the rest of actions */
+ ND_PRINT((ndo, "%s", cstr));
+ ND_TCHECK2(*cp0, len0);
+ return cp0 + len0;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* [OF10] Section 5.3.1 */
+static const u_char *
+of10_features_reply_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, const u_int len) {
+ /* datapath_id */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, "\n\t dpid 0x%016" PRIx64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* n_buffers */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, ", n_buffers %u", EXTRACT_32BITS(cp)));
+ cp += 4;
+ /* n_tables */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", n_tables %u", *cp));
+ cp += 1;
+ /* pad */
+ ND_TCHECK2(*cp, 3);
+ cp += 3;
+ /* capabilities */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, "\n\t capabilities 0x%08x", EXTRACT_32BITS(cp)));
+ of10_bitmap_print(ndo, ofp_capabilities_bm, EXTRACT_32BITS(cp), OFPCAP_U);
+ cp += 4;
+ /* actions */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, "\n\t actions 0x%08x", EXTRACT_32BITS(cp)));
+ of10_bitmap_print(ndo, ofpat_bm, EXTRACT_32BITS(cp), OFPAT_U);
+ cp += 4;
+ /* ports */
+ return of10_phy_ports_print(ndo, cp, ep, len - OF_SWITCH_FEATURES_LEN);
+
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* [OF10] Section 5.3.3 */
+static const u_char *
+of10_flow_mod_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, const u_int len) {
+ uint16_t command;
+
+ /* match */
+ if (ep == (cp = of10_match_print(ndo, "\n\t ", cp, ep)))
+ return ep; /* end of snapshot */
+ /* cookie */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, "\n\t cookie 0x%016" PRIx64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* command */
+ ND_TCHECK2(*cp, 2);
+ command = EXTRACT_16BITS(cp);
+ ND_PRINT((ndo, ", command %s", tok2str(ofpfc_str, "invalid (0x%04x)", command)));
+ cp += 2;
+ /* idle_timeout */
+ ND_TCHECK2(*cp, 2);
+ if (EXTRACT_16BITS(cp))
+ ND_PRINT((ndo, ", idle_timeout %u", EXTRACT_16BITS(cp)));
+ cp += 2;
+ /* hard_timeout */
+ ND_TCHECK2(*cp, 2);
+ if (EXTRACT_16BITS(cp))
+ ND_PRINT((ndo, ", hard_timeout %u", EXTRACT_16BITS(cp)));
+ cp += 2;
+ /* priority */
+ ND_TCHECK2(*cp, 2);
+ if (EXTRACT_16BITS(cp))
+ ND_PRINT((ndo, ", priority %u", EXTRACT_16BITS(cp)));
+ cp += 2;
+ /* buffer_id */
+ ND_TCHECK2(*cp, 4);
+ if (command == OFPFC_ADD || command == OFPFC_MODIFY ||
+ command == OFPFC_MODIFY_STRICT)
+ ND_PRINT((ndo, ", buffer_id %s", tok2str(bufferid_str, "0x%08x", EXTRACT_32BITS(cp))));
+ cp += 4;
+ /* out_port */
+ ND_TCHECK2(*cp, 2);
+ if (command == OFPFC_DELETE || command == OFPFC_DELETE_STRICT)
+ ND_PRINT((ndo, ", out_port %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
+ cp += 2;
+ /* flags */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, ", flags 0x%04x", EXTRACT_16BITS(cp)));
+ of10_bitmap_print(ndo, ofpff_bm, EXTRACT_16BITS(cp), OFPFF_U);
+ cp += 2;
+ /* actions */
+ return of10_actions_print(ndo, "\n\t ", cp, ep, len - OF_FLOW_MOD_LEN);
+
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* ibid */
+static const u_char *
+of10_port_mod_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep) {
+ /* port_no */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, "\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
+ cp += 2;
+ /* hw_addr */
+ ND_TCHECK2(*cp, ETHER_ADDR_LEN);
+ ND_PRINT((ndo, ", hw_addr %s", etheraddr_string(ndo, cp)));
+ cp += ETHER_ADDR_LEN;
+ /* config */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, "\n\t config 0x%08x", EXTRACT_32BITS(cp)));
+ of10_bitmap_print(ndo, ofppc_bm, EXTRACT_32BITS(cp), OFPPC_U);
+ cp += 4;
+ /* mask */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, "\n\t mask 0x%08x", EXTRACT_32BITS(cp)));
+ of10_bitmap_print(ndo, ofppc_bm, EXTRACT_32BITS(cp), OFPPC_U);
+ cp += 4;
+ /* advertise */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, "\n\t advertise 0x%08x", EXTRACT_32BITS(cp)));
+ of10_bitmap_print(ndo, ofppf_bm, EXTRACT_32BITS(cp), OFPPF_U);
+ cp += 4;
+ /* pad */
+ ND_TCHECK2(*cp, 4);
+ return cp + 4;
+
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* [OF10] Section 5.3.5 */
+static const u_char *
+of10_stats_request_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, u_int len) {
+ const u_char *cp0 = cp;
+ const u_int len0 = len;
+ uint16_t type;
+
+ /* type */
+ ND_TCHECK2(*cp, 2);
+ type = EXTRACT_16BITS(cp);
+ cp += 2;
+ ND_PRINT((ndo, "\n\t type %s", tok2str(ofpst_str, "invalid (0x%04x)", type)));
+ /* flags */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, ", flags 0x%04x", EXTRACT_16BITS(cp)));
+ if (EXTRACT_16BITS(cp))
+ ND_PRINT((ndo, " (bogus)"));
+ cp += 2;
+ /* type-specific body of one of fixed lengths */
+ len -= OF_STATS_REQUEST_LEN;
+ switch(type) {
+ case OFPST_DESC:
+ case OFPST_TABLE:
+ if (len)
+ goto corrupt;
+ return cp;
+ case OFPST_FLOW:
+ case OFPST_AGGREGATE:
+ if (len != OF_FLOW_STATS_REQUEST_LEN)
+ goto corrupt;
+ /* match */
+ if (ep == (cp = of10_match_print(ndo, "\n\t ", cp, ep)))
+ return ep; /* end of snapshot */
+ /* table_id */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, "\n\t table_id %s", tok2str(tableid_str, "%u", *cp)));
+ cp += 1;
+ /* pad */
+ ND_TCHECK2(*cp, 1);
+ cp += 1;
+ /* out_port */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, ", out_port %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
+ return cp + 2;
+ case OFPST_PORT:
+ if (len != OF_PORT_STATS_REQUEST_LEN)
+ goto corrupt;
+ /* port_no */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, "\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
+ cp += 2;
+ /* pad */
+ ND_TCHECK2(*cp, 6);
+ return cp + 6;
+ case OFPST_QUEUE:
+ if (len != OF_QUEUE_STATS_REQUEST_LEN)
+ goto corrupt;
+ /* port_no */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, "\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
+ cp += 2;
+ /* pad */
+ ND_TCHECK2(*cp, 2);
+ cp += 2;
+ /* queue_id */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, ", queue_id %s", tok2str(ofpq_str, "%u", EXTRACT_32BITS(cp))));
+ return cp + 4;
+ case OFPST_VENDOR:
+ return of10_vendor_data_print(ndo, cp, ep, len);
+ }
+ return cp;
+
+corrupt: /* skip the message body */
+ ND_PRINT((ndo, "%s", cstr));
+ ND_TCHECK2(*cp0, len0);
+ return cp0 + len0;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* ibid */
+static const u_char *
+of10_desc_stats_reply_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, const u_int len) {
+ if (len != OF_DESC_STATS_LEN)
+ goto corrupt;
+ /* mfr_desc */
+ ND_TCHECK2(*cp, DESC_STR_LEN);
+ ND_PRINT((ndo, "\n\t mfr_desc '"));
+ fn_print(ndo, cp, cp + DESC_STR_LEN);
+ ND_PRINT((ndo, "'"));
+ cp += DESC_STR_LEN;
+ /* hw_desc */
+ ND_TCHECK2(*cp, DESC_STR_LEN);
+ ND_PRINT((ndo, "\n\t hw_desc '"));
+ fn_print(ndo, cp, cp + DESC_STR_LEN);
+ ND_PRINT((ndo, "'"));
+ cp += DESC_STR_LEN;
+ /* sw_desc */
+ ND_TCHECK2(*cp, DESC_STR_LEN);
+ ND_PRINT((ndo, "\n\t sw_desc '"));
+ fn_print(ndo, cp, cp + DESC_STR_LEN);
+ ND_PRINT((ndo, "'"));
+ cp += DESC_STR_LEN;
+ /* serial_num */
+ ND_TCHECK2(*cp, SERIAL_NUM_LEN);
+ ND_PRINT((ndo, "\n\t serial_num '"));
+ fn_print(ndo, cp, cp + SERIAL_NUM_LEN);
+ ND_PRINT((ndo, "'"));
+ cp += SERIAL_NUM_LEN;
+ /* dp_desc */
+ ND_TCHECK2(*cp, DESC_STR_LEN);
+ ND_PRINT((ndo, "\n\t dp_desc '"));
+ fn_print(ndo, cp, cp + DESC_STR_LEN);
+ ND_PRINT((ndo, "'"));
+ return cp + DESC_STR_LEN;
+
+corrupt: /* skip the message body */
+ ND_PRINT((ndo, "%s", cstr));
+ ND_TCHECK2(*cp, len);
+ return cp + len;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* ibid */
+static const u_char *
+of10_flow_stats_reply_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, u_int len) {
+ const u_char *cp0 = cp;
+ const u_int len0 = len;
+ uint16_t entry_len;
+
+ while (len) {
+ if (len < OF_FLOW_STATS_LEN)
+ goto corrupt;
+ /* length */
+ ND_TCHECK2(*cp, 2);
+ entry_len = EXTRACT_16BITS(cp);
+ ND_PRINT((ndo, "\n\t length %u", entry_len));
+ if (entry_len < OF_FLOW_STATS_LEN || entry_len > len)
+ goto corrupt;
+ cp += 2;
+ /* table_id */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", table_id %s", tok2str(tableid_str, "%u", *cp)));
+ cp += 1;
+ /* pad */
+ ND_TCHECK2(*cp, 1);
+ cp += 1;
+ /* match */
+ if (ep == (cp = of10_match_print(ndo, "\n\t ", cp, ep)))
+ return ep; /* end of snapshot */
+ /* duration_sec */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, "\n\t duration_sec %u", EXTRACT_32BITS(cp)));
+ cp += 4;
+ /* duration_nsec */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, ", duration_nsec %u", EXTRACT_32BITS(cp)));
+ cp += 4;
+ /* priority */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, ", priority %u", EXTRACT_16BITS(cp)));
+ cp += 2;
+ /* idle_timeout */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, ", idle_timeout %u", EXTRACT_16BITS(cp)));
+ cp += 2;
+ /* hard_timeout */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, ", hard_timeout %u", EXTRACT_16BITS(cp)));
+ cp += 2;
+ /* pad2 */
+ ND_TCHECK2(*cp, 6);
+ cp += 6;
+ /* cookie */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", cookie 0x%016" PRIx64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* packet_count */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", packet_count %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* byte_count */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", byte_count %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* actions */
+ if (ep == (cp = of10_actions_print(ndo, "\n\t ", cp, ep, entry_len - OF_FLOW_STATS_LEN)))
+ return ep; /* end of snapshot */
+
+ len -= entry_len;
+ } /* while */
+ return cp;
+
+corrupt: /* skip the rest of flow statistics entries */
+ ND_PRINT((ndo, "%s", cstr));
+ ND_TCHECK2(*cp0, len0);
+ return cp0 + len0;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* ibid */
+static const u_char *
+of10_aggregate_stats_reply_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep,
+ const u_int len) {
+ if (len != OF_AGGREGATE_STATS_REPLY_LEN)
+ goto corrupt;
+ /* packet_count */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, "\n\t packet_count %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* byte_count */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", byte_count %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* flow_count */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, ", flow_count %u", EXTRACT_32BITS(cp)));
+ cp += 4;
+ /* pad */
+ ND_TCHECK2(*cp, 4);
+ return cp + 4;
+
+corrupt: /* skip the message body */
+ ND_PRINT((ndo, "%s", cstr));
+ ND_TCHECK2(*cp, len);
+ return cp + len;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* ibid */
+static const u_char *
+of10_table_stats_reply_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, u_int len) {
+ const u_char *cp0 = cp;
+ const u_int len0 = len;
+
+ while (len) {
+ if (len < OF_TABLE_STATS_LEN)
+ goto corrupt;
+ /* table_id */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, "\n\t table_id %s", tok2str(tableid_str, "%u", *cp)));
+ cp += 1;
+ /* pad */
+ ND_TCHECK2(*cp, 3);
+ cp += 3;
+ /* name */
+ ND_TCHECK2(*cp, OFP_MAX_TABLE_NAME_LEN);
+ ND_PRINT((ndo, ", name '"));
+ fn_print(ndo, cp, cp + OFP_MAX_TABLE_NAME_LEN);
+ ND_PRINT((ndo, "'"));
+ cp += OFP_MAX_TABLE_NAME_LEN;
+ /* wildcards */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, "\n\t wildcards 0x%08x", EXTRACT_32BITS(cp)));
+ of10_bitmap_print(ndo, ofpfw_bm, EXTRACT_32BITS(cp), OFPFW_U);
+ cp += 4;
+ /* max_entries */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, "\n\t max_entries %u", EXTRACT_32BITS(cp)));
+ cp += 4;
+ /* active_count */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, ", active_count %u", EXTRACT_32BITS(cp)));
+ cp += 4;
+ /* lookup_count */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", lookup_count %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* matched_count */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", matched_count %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+
+ len -= OF_TABLE_STATS_LEN;
+ } /* while */
+ return cp;
+
+corrupt: /* skip the undersized trailing data */
+ ND_PRINT((ndo, "%s", cstr));
+ ND_TCHECK2(*cp0, len0);
+ return cp0 + len0;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* ibid */
+static const u_char *
+of10_port_stats_reply_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, u_int len) {
+ const u_char *cp0 = cp;
+ const u_int len0 = len;
+
+ while (len) {
+ if (len < OF_PORT_STATS_LEN)
+ goto corrupt;
+ /* port_no */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, "\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
+ cp += 2;
+ if (ndo->ndo_vflag < 2) {
+ ND_TCHECK2(*cp, OF_PORT_STATS_LEN - 2);
+ cp += OF_PORT_STATS_LEN - 2;
+ goto next_port;
+ }
+ /* pad */
+ ND_TCHECK2(*cp, 6);
+ cp += 6;
+ /* rx_packets */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", rx_packets %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* tx_packets */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", tx_packets %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* rx_bytes */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", rx_bytes %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* tx_bytes */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", tx_bytes %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* rx_dropped */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", rx_dropped %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* tx_dropped */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", tx_dropped %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* rx_errors */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", rx_errors %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* tx_errors */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", tx_errors %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* rx_frame_err */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", rx_frame_err %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* rx_over_err */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", rx_over_err %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* rx_crc_err */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", rx_crc_err %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* collisions */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", collisions %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+next_port:
+ len -= OF_PORT_STATS_LEN;
+ } /* while */
+ return cp;
+
+corrupt: /* skip the undersized trailing data */
+ ND_PRINT((ndo, "%s", cstr));
+ ND_TCHECK2(*cp0, len0);
+ return cp0 + len0;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* ibid */
+static const u_char *
+of10_queue_stats_reply_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, u_int len) {
+ const u_char *cp0 = cp;
+ const u_int len0 = len;
+
+ while (len) {
+ if (len < OF_QUEUE_STATS_LEN)
+ goto corrupt;
+ /* port_no */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, "\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
+ cp += 2;
+ /* pad */
+ ND_TCHECK2(*cp, 2);
+ cp += 2;
+ /* queue_id */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, ", queue_id %u", EXTRACT_32BITS(cp)));
+ cp += 4;
+ /* tx_bytes */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", tx_bytes %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* tx_packets */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", tx_packets %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* tx_errors */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", tx_errors %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+
+ len -= OF_QUEUE_STATS_LEN;
+ } /* while */
+ return cp;
+
+corrupt: /* skip the undersized trailing data */
+ ND_PRINT((ndo, "%s", cstr));
+ ND_TCHECK2(*cp0, len0);
+ return cp0 + len0;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* ibid */
+static const u_char *
+of10_stats_reply_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, const u_int len) {
+ const u_char *cp0 = cp;
+ uint16_t type;
+
+ /* type */
+ ND_TCHECK2(*cp, 2);
+ type = EXTRACT_16BITS(cp);
+ ND_PRINT((ndo, "\n\t type %s", tok2str(ofpst_str, "invalid (0x%04x)", type)));
+ cp += 2;
+ /* flags */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, ", flags 0x%04x", EXTRACT_16BITS(cp)));
+ of10_bitmap_print(ndo, ofpsf_reply_bm, EXTRACT_16BITS(cp), OFPSF_REPLY_U);
+ cp += 2;
+
+ if (ndo->ndo_vflag > 0) {
+ const u_char *(*decoder)(netdissect_options *, const u_char *, const u_char *, u_int) =
+ type == OFPST_DESC ? of10_desc_stats_reply_print :
+ type == OFPST_FLOW ? of10_flow_stats_reply_print :
+ type == OFPST_AGGREGATE ? of10_aggregate_stats_reply_print :
+ type == OFPST_TABLE ? of10_table_stats_reply_print :
+ type == OFPST_PORT ? of10_port_stats_reply_print :
+ type == OFPST_QUEUE ? of10_queue_stats_reply_print :
+ type == OFPST_VENDOR ? of10_vendor_data_print :
+ NULL;
+ if (decoder != NULL)
+ return decoder(ndo, cp, ep, len - OF_STATS_REPLY_LEN);
+ }
+ ND_TCHECK2(*cp0, len);
+ return cp0 + len;
+
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* [OF10] Section 5.3.6 */
+static const u_char *
+of10_packet_out_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, const u_int len) {
+ const u_char *cp0 = cp;
+ const u_int len0 = len;
+ uint16_t actions_len;
+
+ /* buffer_id */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, "\n\t buffer_id 0x%08x", EXTRACT_32BITS(cp)));
+ cp += 4;
+ /* in_port */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, ", in_port %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
+ cp += 2;
+ /* actions_len */
+ ND_TCHECK2(*cp, 2);
+ actions_len = EXTRACT_16BITS(cp);
+ cp += 2;
+ if (actions_len > len - OF_PACKET_OUT_LEN)
+ goto corrupt;
+ /* actions */
+ if (ep == (cp = of10_actions_print(ndo, "\n\t ", cp, ep, actions_len)))
+ return ep; /* end of snapshot */
+ /* data */
+ return of10_packet_data_print(ndo, cp, ep, len - OF_PACKET_OUT_LEN - actions_len);
+
+corrupt: /* skip the rest of the message body */
+ ND_PRINT((ndo, "%s", cstr));
+ ND_TCHECK2(*cp0, len0);
+ return cp0 + len0;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* [OF10] Section 5.4.1 */
+static const u_char *
+of10_packet_in_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, const u_int len) {
+ /* buffer_id */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, "\n\t buffer_id %s", tok2str(bufferid_str, "0x%08x", EXTRACT_32BITS(cp))));
+ cp += 4;
+ /* total_len */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, ", total_len %u", EXTRACT_16BITS(cp)));
+ cp += 2;
+ /* in_port */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, ", in_port %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
+ cp += 2;
+ /* reason */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", reason %s", tok2str(ofpr_str, "invalid (0x%02x)", *cp)));
+ cp += 1;
+ /* pad */
+ ND_TCHECK2(*cp, 1);
+ cp += 1;
+ /* data */
+ /* 2 mock octets count in OF_PACKET_IN_LEN but not in len */
+ return of10_packet_data_print(ndo, cp, ep, len - (OF_PACKET_IN_LEN - 2));
+
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* [OF10] Section 5.4.2 */
+static const u_char *
+of10_flow_removed_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep) {
+ /* match */
+ if (ep == (cp = of10_match_print(ndo, "\n\t ", cp, ep)))
+ return ep; /* end of snapshot */
+ /* cookie */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, "\n\t cookie 0x%016" PRIx64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* priority */
+ ND_TCHECK2(*cp, 2);
+ if (EXTRACT_16BITS(cp))
+ ND_PRINT((ndo, ", priority %u", EXTRACT_16BITS(cp)));
+ cp += 2;
+ /* reason */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", reason %s", tok2str(ofprr_str, "unknown (0x%02x)", *cp)));
+ cp += 1;
+ /* pad */
+ ND_TCHECK2(*cp, 1);
+ cp += 1;
+ /* duration_sec */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, ", duration_sec %u", EXTRACT_32BITS(cp)));
+ cp += 4;
+ /* duration_nsec */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, ", duration_nsec %u", EXTRACT_32BITS(cp)));
+ cp += 4;
+ /* idle_timeout */
+ ND_TCHECK2(*cp, 2);
+ if (EXTRACT_16BITS(cp))
+ ND_PRINT((ndo, ", idle_timeout %u", EXTRACT_16BITS(cp)));
+ cp += 2;
+ /* pad2 */
+ ND_TCHECK2(*cp, 2);
+ cp += 2;
+ /* packet_count */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", packet_count %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* byte_count */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", byte_count %" PRIu64, EXTRACT_64BITS(cp)));
+ return cp + 8;
+
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* [OF10] Section 5.4.4 */
+static const u_char *
+of10_error_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, const u_int len) {
+ uint16_t type;
+ const struct tok *code_str;
+
+ /* type */
+ ND_TCHECK2(*cp, 2);
+ type = EXTRACT_16BITS(cp);
+ cp += 2;
+ ND_PRINT((ndo, "\n\t type %s", tok2str(ofpet_str, "invalid (0x%04x)", type)));
+ /* code */
+ ND_TCHECK2(*cp, 2);
+ code_str =
+ type == OFPET_HELLO_FAILED ? ofphfc_str :
+ type == OFPET_BAD_REQUEST ? ofpbrc_str :
+ type == OFPET_BAD_ACTION ? ofpbac_str :
+ type == OFPET_FLOW_MOD_FAILED ? ofpfmfc_str :
+ type == OFPET_PORT_MOD_FAILED ? ofppmfc_str :
+ type == OFPET_QUEUE_OP_FAILED ? ofpqofc_str :
+ empty_str;
+ ND_PRINT((ndo, ", code %s", tok2str(code_str, "invalid (0x%04x)", EXTRACT_16BITS(cp))));
+ cp += 2;
+ /* data */
+ return of10_data_print(ndo, cp, ep, len - OF_ERROR_MSG_LEN);
+
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+const u_char *
+of10_header_body_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, const uint8_t type,
+ const uint16_t len, const uint32_t xid) {
+ const u_char *cp0 = cp;
+ const u_int len0 = len;
+ /* Thus far message length is not less than the basic header size, but most
+ * message types have additional assorted constraints on the length. Wherever
+ * possible, check that message length meets the constraint, in remaining
+ * cases check that the length is OK to begin decoding and leave any final
+ * verification up to a lower-layer function. When the current message is
+ * corrupt, proceed to the next message. */
+
+ /* [OF10] Section 5.1 */
+ ND_PRINT((ndo, "\n\tversion 1.0, type %s, length %u, xid 0x%08x",
+ tok2str(ofpt_str, "invalid (0x%02x)", type), len, xid));
+ switch (type) {
+ /* OpenFlow header only. */
+ case OFPT_FEATURES_REQUEST: /* [OF10] Section 5.3.1 */
+ case OFPT_GET_CONFIG_REQUEST: /* [OF10] Section 5.3.2 */
+ case OFPT_BARRIER_REQUEST: /* [OF10] Section 5.3.7 */
+ case OFPT_BARRIER_REPLY: /* ibid */
+ if (len != OF_HEADER_LEN)
+ goto corrupt;
+ break;
+
+ /* OpenFlow header and fixed-size message body. */
+ case OFPT_SET_CONFIG: /* [OF10] Section 5.3.2 */
+ case OFPT_GET_CONFIG_REPLY: /* ibid */
+ if (len != OF_SWITCH_CONFIG_LEN)
+ goto corrupt;
+ if (ndo->ndo_vflag < 1)
+ goto next_message;
+ /* flags */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, "\n\t flags %s", tok2str(ofp_config_str, "invalid (0x%04x)", EXTRACT_16BITS(cp))));
+ cp += 2;
+ /* miss_send_len */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, ", miss_send_len %u", EXTRACT_16BITS(cp)));
+ return cp + 2;
+ case OFPT_PORT_MOD:
+ if (len != OF_PORT_MOD_LEN)
+ goto corrupt;
+ if (ndo->ndo_vflag < 1)
+ goto next_message;
+ return of10_port_mod_print(ndo, cp, ep);
+ case OFPT_QUEUE_GET_CONFIG_REQUEST: /* [OF10] Section 5.3.4 */
+ if (len != OF_QUEUE_GET_CONFIG_REQUEST_LEN)
+ goto corrupt;
+ if (ndo->ndo_vflag < 1)
+ goto next_message;
+ /* port */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, "\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
+ cp += 2;
+ /* pad */
+ ND_TCHECK2(*cp, 2);
+ return cp + 2;
+ case OFPT_FLOW_REMOVED:
+ if (len != OF_FLOW_REMOVED_LEN)
+ goto corrupt;
+ if (ndo->ndo_vflag < 1)
+ goto next_message;
+ return of10_flow_removed_print(ndo, cp, ep);
+ case OFPT_PORT_STATUS: /* [OF10] Section 5.4.3 */
+ if (len != OF_PORT_STATUS_LEN)
+ goto corrupt;
+ if (ndo->ndo_vflag < 1)
+ goto next_message;
+ /* reason */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, "\n\t reason %s", tok2str(ofppr_str, "invalid (0x%02x)", *cp)));
+ cp += 1;
+ /* pad */
+ ND_TCHECK2(*cp, 7);
+ cp += 7;
+ /* desc */
+ return of10_phy_ports_print(ndo, cp, ep, OF_PHY_PORT_LEN);
+
+ /* OpenFlow header, fixed-size message body and n * fixed-size data units. */
+ case OFPT_FEATURES_REPLY:
+ if (len < OF_SWITCH_FEATURES_LEN)
+ goto corrupt;
+ if (ndo->ndo_vflag < 1)
+ goto next_message;
+ return of10_features_reply_print(ndo, cp, ep, len);
+
+ /* OpenFlow header and variable-size data. */
+ case OFPT_HELLO: /* [OF10] Section 5.5.1 */
+ case OFPT_ECHO_REQUEST: /* [OF10] Section 5.5.2 */
+ case OFPT_ECHO_REPLY: /* [OF10] Section 5.5.3 */
+ if (ndo->ndo_vflag < 1)
+ goto next_message;
+ return of10_data_print(ndo, cp, ep, len - OF_HEADER_LEN);
+
+ /* OpenFlow header, fixed-size message body and variable-size data. */
+ case OFPT_ERROR:
+ if (len < OF_ERROR_MSG_LEN)
+ goto corrupt;
+ if (ndo->ndo_vflag < 1)
+ goto next_message;
+ return of10_error_print(ndo, cp, ep, len);
+ case OFPT_VENDOR:
+ /* [OF10] Section 5.5.4 */
+ if (len < OF_VENDOR_HEADER_LEN)
+ goto corrupt;
+ if (ndo->ndo_vflag < 1)
+ goto next_message;
+ return of10_vendor_data_print(ndo, cp, ep, len - OF_HEADER_LEN);
+ case OFPT_PACKET_IN:
+ /* 2 mock octets count in OF_PACKET_IN_LEN but not in len */
+ if (len < OF_PACKET_IN_LEN - 2)
+ goto corrupt;
+ if (ndo->ndo_vflag < 1)
+ goto next_message;
+ return of10_packet_in_print(ndo, cp, ep, len);
+
+ /* a. OpenFlow header. */
+ /* b. OpenFlow header and one of the fixed-size message bodies. */
+ /* c. OpenFlow header, fixed-size message body and variable-size data. */
+ case OFPT_STATS_REQUEST:
+ if (len < OF_STATS_REQUEST_LEN)
+ goto corrupt;
+ if (ndo->ndo_vflag < 1)
+ goto next_message;
+ return of10_stats_request_print(ndo, cp, ep, len);
+
+ /* a. OpenFlow header and fixed-size message body. */
+ /* b. OpenFlow header and n * fixed-size data units. */
+ /* c. OpenFlow header and n * variable-size data units. */
+ /* d. OpenFlow header, fixed-size message body and variable-size data. */
+ case OFPT_STATS_REPLY:
+ if (len < OF_STATS_REPLY_LEN)
+ goto corrupt;
+ if (ndo->ndo_vflag < 1)
+ goto next_message;
+ return of10_stats_reply_print(ndo, cp, ep, len);
+
+ /* OpenFlow header and n * variable-size data units and variable-size data. */
+ case OFPT_PACKET_OUT:
+ if (len < OF_PACKET_OUT_LEN)
+ goto corrupt;
+ if (ndo->ndo_vflag < 1)
+ goto next_message;
+ return of10_packet_out_print(ndo, cp, ep, len);
+
+ /* OpenFlow header, fixed-size message body and n * variable-size data units. */
+ case OFPT_FLOW_MOD:
+ if (len < OF_FLOW_MOD_LEN)
+ goto corrupt;
+ if (ndo->ndo_vflag < 1)
+ goto next_message;
+ return of10_flow_mod_print(ndo, cp, ep, len);
+
+ /* OpenFlow header, fixed-size message body and n * variable-size data units. */
+ case OFPT_QUEUE_GET_CONFIG_REPLY: /* [OF10] Section 5.3.4 */
+ if (len < OF_QUEUE_GET_CONFIG_REPLY_LEN)
+ goto corrupt;
+ if (ndo->ndo_vflag < 1)
+ goto next_message;
+ /* port */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, "\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
+ cp += 2;
+ /* pad */
+ ND_TCHECK2(*cp, 6);
+ cp += 6;
+ /* queues */
+ return of10_queues_print(ndo, cp, ep, len - OF_QUEUE_GET_CONFIG_REPLY_LEN);
+ } /* switch (type) */
+ goto next_message;
+
+corrupt: /* skip the message body */
+ ND_PRINT((ndo, "%s", cstr));
+next_message:
+ ND_TCHECK2(*cp0, len0 - OF_HEADER_LEN);
+ return cp0 + len0 - OF_HEADER_LEN;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
diff --git a/contrib/tcpdump/print-openflow.c b/contrib/tcpdump/print-openflow.c
new file mode 100644
index 000000000000..9a675855302c
--- /dev/null
+++ b/contrib/tcpdump/print-openflow.c
@@ -0,0 +1,119 @@
+/*
+ * This module implements printing of the very basic (version-independent)
+ * OpenFlow header and iteration over OpenFlow messages. It is intended for
+ * dispatching of version-specific OpenFlow message decoding.
+ *
+ *
+ * Copyright (c) 2013 The TCPDUMP project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 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 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#define NETDISSECT_REWORKED
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tcpdump-stdinc.h>
+
+#include "interface.h"
+#include "extract.h"
+#include "openflow.h"
+
+static const char tstr[] = " [|openflow]";
+static const char cstr[] = " (corrupt)";
+
+#define OF_VER_1_0 0x01
+
+static void
+of_header_print(netdissect_options *ndo, const uint8_t version, const uint8_t type,
+ const uint16_t length, const uint32_t xid) {
+ ND_PRINT((ndo, "\n\tversion unknown (0x%02x), type 0x%02x, length %u, xid 0x%08x",
+ version, type, length, xid));
+}
+
+/* Print a single OpenFlow message. */
+static const u_char *
+of_header_body_print(netdissect_options *ndo, const u_char *cp, const u_char *ep) {
+ uint8_t version, type;
+ uint16_t length;
+ uint32_t xid;
+
+ if (ep < cp + OF_HEADER_LEN)
+ goto corrupt;
+ /* version */
+ ND_TCHECK2(*cp, 1);
+ version = *cp;
+ cp += 1;
+ /* type */
+ ND_TCHECK2(*cp, 1);
+ type = *cp;
+ cp += 1;
+ /* length */
+ ND_TCHECK2(*cp, 2);
+ length = EXTRACT_16BITS(cp);
+ cp += 2;
+ /* xid */
+ ND_TCHECK2(*cp, 4);
+ xid = EXTRACT_32BITS(cp);
+ cp += 4;
+ /* Message length includes the header length and a message always includes
+ * the basic header. A message length underrun fails decoding of the rest of
+ * the current packet. At the same time, try decoding as much of the current
+ * message as possible even when it does not end within the current TCP
+ * segment. */
+ if (length < OF_HEADER_LEN) {
+ of_header_print(ndo, version, type, length, xid);
+ goto corrupt;
+ }
+ /* Decode known protocol versions further without printing the header (the
+ * type decoding is version-specific. */
+ switch (version) {
+ case OF_VER_1_0:
+ return of10_header_body_print(ndo, cp, ep, type, length, xid);
+ default:
+ of_header_print(ndo, version, type, length, xid);
+ ND_TCHECK2(*cp, length - OF_HEADER_LEN);
+ return cp + length - OF_HEADER_LEN; /* done with current message */
+ }
+
+corrupt: /* fail current packet */
+ ND_PRINT((ndo, "%s", cstr));
+ ND_TCHECK2(*cp, ep - cp);
+ return ep;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* Print a TCP segment worth of OpenFlow messages presuming the segment begins
+ * on a message boundary. */
+void
+openflow_print(netdissect_options *ndo, const u_char *cp, const u_int len) {
+ const u_char *ep = cp + len;
+
+ ND_PRINT((ndo, ": OpenFlow"));
+ while (cp < ep)
+ cp = of_header_body_print(ndo, cp, ep);
+}
diff --git a/contrib/tcpdump/print-ospf.c b/contrib/tcpdump/print-ospf.c
index f8ff4aeac5b0..b64438fa676f 100644
--- a/contrib/tcpdump/print-ospf.c
+++ b/contrib/tcpdump/print-ospf.c
@@ -21,19 +21,13 @@
* OSPF support contributed by Jeffrey Honig (jch@mitchell.cit.cornell.edu)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ospf.c,v 1.66 2007-10-08 07:53:21 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-
#include "interface.h"
#include "addrtoname.h"
#include "extract.h"
@@ -41,9 +35,9 @@ static const char rcsid[] _U_ =
#include "ospf.h"
-#include "ip.h"
+static const char tstr[] = " [|ospf2]";
-static struct tok ospf_option_values[] = {
+static const struct tok ospf_option_values[] = {
{ OSPF_OPTION_T, "MultiTopology" }, /* draft-ietf-ospf-mt-09 */
{ OSPF_OPTION_E, "External" },
{ OSPF_OPTION_MC, "Multicast" },
@@ -55,14 +49,14 @@ static struct tok ospf_option_values[] = {
{ 0, NULL }
};
-static struct tok ospf_authtype_values[] = {
+static const struct tok ospf_authtype_values[] = {
{ OSPF_AUTH_NONE, "none" },
{ OSPF_AUTH_SIMPLE, "simple" },
{ OSPF_AUTH_MD5, "MD5" },
{ 0, NULL }
};
-static struct tok ospf_rla_flag_values[] = {
+static const struct tok ospf_rla_flag_values[] = {
{ RLA_FLAG_B, "ABR" },
{ RLA_FLAG_E, "ASBR" },
{ RLA_FLAG_W1, "Virtual" },
@@ -70,7 +64,7 @@ static struct tok ospf_rla_flag_values[] = {
{ 0, NULL }
};
-static struct tok type2str[] = {
+static const struct tok type2str[] = {
{ OSPF_TYPE_UMD, "UMD" },
{ OSPF_TYPE_HELLO, "Hello" },
{ OSPF_TYPE_DD, "Database Description" },
@@ -80,7 +74,7 @@ static struct tok type2str[] = {
{ 0, NULL }
};
-static struct tok lsa_values[] = {
+static const struct tok lsa_values[] = {
{ LS_TYPE_ROUTER, "Router" },
{ LS_TYPE_NETWORK, "Network" },
{ LS_TYPE_SUM_IP, "Summary" },
@@ -94,7 +88,7 @@ static struct tok lsa_values[] = {
{ 0, NULL }
};
-static struct tok ospf_dd_flag_values[] = {
+static const struct tok ospf_dd_flag_values[] = {
{ OSPF_DB_INIT, "Init" },
{ OSPF_DB_MORE, "More" },
{ OSPF_DB_MASTER, "Master" },
@@ -102,20 +96,20 @@ static struct tok ospf_dd_flag_values[] = {
{ 0, NULL }
};
-static struct tok lsa_opaque_values[] = {
+static const struct tok lsa_opaque_values[] = {
{ LS_OPAQUE_TYPE_TE, "Traffic Engineering" },
{ LS_OPAQUE_TYPE_GRACE, "Graceful restart" },
{ LS_OPAQUE_TYPE_RI, "Router Information" },
{ 0, NULL }
};
-static struct tok lsa_opaque_te_tlv_values[] = {
+static const struct tok lsa_opaque_te_tlv_values[] = {
{ LS_OPAQUE_TE_TLV_ROUTER, "Router Address" },
{ LS_OPAQUE_TE_TLV_LINK, "Link" },
{ 0, NULL }
};
-static struct tok lsa_opaque_te_link_tlv_subtlv_values[] = {
+static const struct tok lsa_opaque_te_link_tlv_subtlv_values[] = {
{ LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE, "Link Type" },
{ LS_OPAQUE_TE_LINK_SUBTLV_LINK_ID, "Link ID" },
{ LS_OPAQUE_TE_LINK_SUBTLV_LOCAL_IP, "Local Interface IP address" },
@@ -133,14 +127,14 @@ static struct tok lsa_opaque_te_link_tlv_subtlv_values[] = {
{ 0, NULL }
};
-static struct tok lsa_opaque_grace_tlv_values[] = {
+static const struct tok lsa_opaque_grace_tlv_values[] = {
{ LS_OPAQUE_GRACE_TLV_PERIOD, "Grace Period" },
{ LS_OPAQUE_GRACE_TLV_REASON, "Graceful restart Reason" },
{ LS_OPAQUE_GRACE_TLV_INT_ADDRESS, "IPv4 interface address" },
{ 0, NULL }
};
-static struct tok lsa_opaque_grace_tlv_reason_values[] = {
+static const struct tok lsa_opaque_grace_tlv_reason_values[] = {
{ LS_OPAQUE_GRACE_TLV_REASON_UNKNOWN, "Unknown" },
{ LS_OPAQUE_GRACE_TLV_REASON_SW_RESTART, "Software Restart" },
{ LS_OPAQUE_GRACE_TLV_REASON_SW_UPGRADE, "Software Reload/Upgrade" },
@@ -148,18 +142,18 @@ static struct tok lsa_opaque_grace_tlv_reason_values[] = {
{ 0, NULL }
};
-static struct tok lsa_opaque_te_tlv_link_type_sub_tlv_values[] = {
+static const struct tok lsa_opaque_te_tlv_link_type_sub_tlv_values[] = {
{ LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE_PTP, "Point-to-point" },
{ LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE_MA, "Multi-Access" },
{ 0, NULL }
};
-static struct tok lsa_opaque_ri_tlv_values[] = {
+static const struct tok lsa_opaque_ri_tlv_values[] = {
{ LS_OPAQUE_RI_TLV_CAP, "Router Capabilities" },
{ 0, NULL }
};
-static struct tok lsa_opaque_ri_tlv_cap_values[] = {
+static const struct tok lsa_opaque_ri_tlv_cap_values[] = {
{ 1, "Reserved" },
{ 2, "Reserved" },
{ 4, "Reserved" },
@@ -173,54 +167,44 @@ static struct tok lsa_opaque_ri_tlv_cap_values[] = {
{ 0, NULL }
};
-static struct tok ospf_lls_tlv_values[] = {
+static const 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[] = {
+static const 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
-#endif /* WIN32 */
-
-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 (const u_int8_t *tptr, u_int ls_length) {
+ospf_print_grace_lsa(netdissect_options *ndo,
+ const uint8_t *tptr, u_int ls_length) {
u_int tlv_type, tlv_length;
while (ls_length > 0) {
- TCHECK2(*tptr, 4);
+ ND_TCHECK2(*tptr, 4);
if (ls_length < 4) {
- printf("\n\t Remaining LS length %u < 4", ls_length);
+ ND_PRINT((ndo, "\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: ",
+
+ ND_PRINT((ndo, "\n\t %s TLV (%u), length %u, value: ",
tok2str(lsa_opaque_grace_tlv_values,"unknown",tlv_type),
tlv_type,
- tlv_length);
+ tlv_length));
if (tlv_length > ls_length) {
- printf("\n\t Bogus length %u > %u", tlv_length,
- ls_length);
+ ND_PRINT((ndo, "\n\t Bogus length %u > %u", tlv_length,
+ ls_length));
return -1;
}
@@ -229,38 +213,38 @@ ospf_print_grace_lsa (const u_int8_t *tptr, u_int ls_length) {
return -1;
}
- TCHECK2(*tptr, tlv_length);
+ ND_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);
+ ND_PRINT((ndo, "\n\t Bogus length %u != 4", tlv_length));
return -1;
}
- printf("%us",EXTRACT_32BITS(tptr));
+ ND_PRINT((ndo, "%us", EXTRACT_32BITS(tptr)));
break;
case LS_OPAQUE_GRACE_TLV_REASON:
if (tlv_length != 1) {
- printf("\n\t Bogus length %u != 1", tlv_length);
+ ND_PRINT((ndo, "\n\t Bogus length %u != 1", tlv_length));
return -1;
}
- printf("%s (%u)",
+ ND_PRINT((ndo, "%s (%u)",
tok2str(lsa_opaque_grace_tlv_reason_values, "Unknown", *tptr),
- *tptr);
+ *tptr));
break;
case LS_OPAQUE_GRACE_TLV_INT_ADDRESS:
if (tlv_length != 4) {
- printf("\n\t Bogus length %u != 4", tlv_length);
+ ND_PRINT((ndo, "\n\t Bogus length %u != 4", tlv_length));
return -1;
}
- printf("%s", ipaddr_string(tptr));
+ ND_PRINT((ndo, "%s", ipaddr_string(ndo, tptr)));
break;
default:
- if (vflag <= 1) {
- if(!print_unknown_data(tptr,"\n\t ",tlv_length))
+ if (ndo->ndo_vflag <= 1) {
+ if (!print_unknown_data(ndo, tptr, "\n\t ", tlv_length))
return -1;
}
break;
@@ -279,34 +263,35 @@ trunc:
}
int
-ospf_print_te_lsa (const u_int8_t *tptr, u_int ls_length) {
+ospf_print_te_lsa(netdissect_options *ndo,
+ const uint8_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;
+ float f;
+ uint32_t i;
} bw;
while (ls_length != 0) {
- TCHECK2(*tptr, 4);
+ ND_TCHECK2(*tptr, 4);
if (ls_length < 4) {
- printf("\n\t Remaining LS length %u < 4", ls_length);
+ ND_PRINT((ndo, "\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",
+
+ ND_PRINT((ndo, "\n\t %s TLV (%u), length: %u",
tok2str(lsa_opaque_te_tlv_values,"unknown",tlv_type),
tlv_type,
- tlv_length);
+ tlv_length));
if (tlv_length > ls_length) {
- printf("\n\t Bogus length %u > %u", tlv_length,
- ls_length);
+ ND_PRINT((ndo, "\n\t Bogus length %u > %u", tlv_length,
+ ls_length));
return -1;
}
@@ -319,108 +304,108 @@ ospf_print_te_lsa (const u_int8_t *tptr, u_int ls_length) {
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);
+ ND_PRINT((ndo, "\n\t Remaining TLV length %u < 4",
+ tlv_length));
return -1;
}
- TCHECK2(*tptr, 4);
+ ND_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",
+
+ ND_PRINT((ndo, "\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);
+ subtlv_length));
+
+ ND_TCHECK2(*tptr, subtlv_length);
switch(subtlv_type) {
case LS_OPAQUE_TE_LINK_SUBTLV_ADMIN_GROUP:
- printf(", 0x%08x", EXTRACT_32BITS(tptr));
+ ND_PRINT((ndo, ", 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));
+ ND_PRINT((ndo, ", %s (0x%08x)",
+ ipaddr_string(ndo, tptr),
+ EXTRACT_32BITS(tptr)));
if (subtlv_length == 8) /* rfc4203 */
- printf(", %s (0x%08x)",
- ipaddr_string(tptr+4),
- EXTRACT_32BITS(tptr+4));
+ ND_PRINT((ndo, ", %s (0x%08x)",
+ ipaddr_string(ndo, 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));
+ ND_PRINT((ndo, ", %s", ipaddr_string(ndo, 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 );
+ ND_PRINT((ndo, ", %.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",
+ ND_PRINT((ndo, "\n\t\tTE-Class %u: %.3f Mbps",
te_class,
- bw.f*8/1000000 );
+ bw.f * 8 / 1000000));
}
break;
case LS_OPAQUE_TE_LINK_SUBTLV_BW_CONSTRAINTS:
- printf("\n\t\tBandwidth Constraints Model ID: %s (%u)",
+ ND_PRINT((ndo, "\n\t\tBandwidth Constraints Model ID: %s (%u)",
tok2str(diffserv_te_bc_values, "unknown", *tptr),
- *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",
+ ND_PRINT((ndo, "\n\t\t Bandwidth constraint CT%u: %.3f Mbps",
te_class,
- bw.f*8/1000000 );
+ bw.f * 8 / 1000000));
}
break;
case LS_OPAQUE_TE_LINK_SUBTLV_TE_METRIC:
- printf(", Metric %u", EXTRACT_32BITS(tptr));
+ ND_PRINT((ndo, ", Metric %u", EXTRACT_32BITS(tptr)));
break;
case LS_OPAQUE_TE_LINK_SUBTLV_LINK_PROTECTION_TYPE:
- printf(", %s, Priority %u",
+ ND_PRINT((ndo, ", %s, Priority %u",
bittok2str(gmpls_link_prot_values, "none", *tptr),
- *(tptr+1));
+ *(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)));
+ ND_PRINT((ndo, "\n\t\tInterface Switching Capability: %s",
+ tok2str(gmpls_switch_cap_values, "Unknown", *(tptr))));
+ ND_PRINT((ndo, "\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",
+ ND_PRINT((ndo, "\n\t\t priority level %d: %.3f Mbps",
priority_level,
- bw.f*8/1000000 );
+ bw.f * 8 / 1000000));
}
break;
case LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE:
- printf(", %s (%u)",
+ ND_PRINT((ndo, ", %s (%u)",
tok2str(lsa_opaque_te_tlv_link_type_sub_tlv_values,"unknown",*tptr),
- *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: ");
+ ND_PRINT((ndo, "\n\t\t Shared risk group: "));
while (count_srlg > 0) {
bw.i = EXTRACT_32BITS(tptr);
- printf("%d",bw.i);
+ ND_PRINT((ndo, "%d", bw.i));
tptr+=4;
count_srlg--;
if (count_srlg > 0)
- printf(", ");
+ ND_PRINT((ndo, ", "));
}
break;
default:
- if (vflag <= 1) {
- if(!print_unknown_data(tptr,"\n\t\t",subtlv_length))
+ if (ndo->ndo_vflag <= 1) {
+ if (!print_unknown_data(ndo, tptr, "\n\t\t", subtlv_length))
return -1;
}
break;
@@ -428,25 +413,25 @@ ospf_print_te_lsa (const u_int8_t *tptr, u_int ls_length) {
/* 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);
+ ND_PRINT((ndo, "\n\t TLV length %u < 4", tlv_length));
return -1;
}
- TCHECK2(*tptr, 4);
- printf(", %s", ipaddr_string(tptr));
+ ND_TCHECK2(*tptr, 4);
+ ND_PRINT((ndo, ", %s", ipaddr_string(ndo, tptr)));
break;
-
+
default:
- if (vflag <= 1) {
- if(!print_unknown_data(tptr,"\n\t ",tlv_length))
+ if (ndo->ndo_vflag <= 1) {
+ if (!print_unknown_data(ndo, tptr, "\n\t ", tlv_length))
return -1;
}
break;
@@ -462,34 +447,34 @@ trunc:
return -1;
}
-
static int
-ospf_print_lshdr(register const struct lsa_hdr *lshp)
+ospf_print_lshdr(netdissect_options *ndo,
+ register const struct lsa_hdr *lshp)
{
u_int ls_length;
- TCHECK(lshp->ls_length);
+ ND_TCHECK(lshp->ls_length);
ls_length = EXTRACT_16BITS(&lshp->ls_length);
if (ls_length < sizeof(struct lsa_hdr)) {
- printf("\n\t Bogus length %u < header (%lu)", ls_length,
- (unsigned long)sizeof(struct lsa_hdr));
+ ND_PRINT((ndo, "\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",
- ipaddr_string(&lshp->ls_router),
- EXTRACT_32BITS(&lshp->ls_seq),
- EXTRACT_16BITS(&lshp->ls_age),
- ls_length-(u_int)sizeof(struct lsa_hdr));
+ ND_TCHECK(lshp->ls_seq); /* XXX - ls_length check checked this */
+ ND_PRINT((ndo, "\n\t Advertising Router %s, seq 0x%08x, age %us, length %u",
+ ipaddr_string(ndo, &lshp->ls_router),
+ EXTRACT_32BITS(&lshp->ls_seq),
+ EXTRACT_16BITS(&lshp->ls_age),
+ ls_length - (u_int)sizeof(struct lsa_hdr)));
- TCHECK(lshp->ls_type); /* XXX - ls_length check checked this */
+ ND_TCHECK(lshp->ls_type); /* XXX - ls_length check checked this */
switch (lshp->ls_type) {
- /* the LSA header for opaque LSAs was slightly changed */
+ /* the LSA header for opaque LSAs was slightly changed */
case LS_TYPE_OPAQUE_LL:
case LS_TYPE_OPAQUE_AL:
case LS_TYPE_OPAQUE_DW:
- printf("\n\t %s LSA (%d), Opaque-Type %s LSA (%u), Opaque-ID %u",
+ ND_PRINT((ndo, "\n\t %s LSA (%d), Opaque-Type %s LSA (%u), Opaque-ID %u",
tok2str(lsa_values,"unknown",lshp->ls_type),
lshp->ls_type,
@@ -498,21 +483,21 @@ ospf_print_lshdr(register const struct lsa_hdr *lshp)
*(&lshp->un_lsa_id.opaque_field.opaque_type)),
*(&lshp->un_lsa_id.opaque_field.opaque_type),
EXTRACT_24BITS(&lshp->un_lsa_id.opaque_field.opaque_id)
-
- );
+
+ ));
break;
- /* all other LSA types use regular style LSA headers */
- default:
- printf("\n\t %s LSA (%d), LSA-ID: %s",
+ /* all other LSA types use regular style LSA headers */
+ default:
+ ND_PRINT((ndo, "\n\t %s LSA (%d), LSA-ID: %s",
tok2str(lsa_values,"unknown",lshp->ls_type),
lshp->ls_type,
- ipaddr_string(&lshp->un_lsa_id.lsa_id));
+ ipaddr_string(ndo, &lshp->un_lsa_id.lsa_id)));
break;
}
- TCHECK(lshp->ls_options); /* XXX - ls_length check checked this */
- printf("\n\t Options: [%s]", bittok2str(ospf_option_values,"none",lshp->ls_options));
+ ND_TCHECK(lshp->ls_options); /* XXX - ls_length check checked this */
+ ND_PRINT((ndo, "\n\t Options: [%s]", bittok2str(ospf_option_values, "none", lshp->ls_options)));
return (ls_length);
trunc:
@@ -520,7 +505,7 @@ trunc:
}
/* draft-ietf-ospf-mt-09 */
-static struct tok ospf_topology_values[] = {
+static const struct tok ospf_topology_values[] = {
{ 0, "default " },
{ 1, "multicast " },
{ 2, "management " },
@@ -531,7 +516,8 @@ static struct tok ospf_topology_values[] = {
* Print all the per-topology metrics.
*/
static void
-ospf_print_tos_metrics(const union un_tos *tos)
+ospf_print_tos_metrics(netdissect_options *ndo,
+ const union un_tos *tos)
{
int metric_count;
int toscount;
@@ -542,12 +528,12 @@ ospf_print_tos_metrics(const union un_tos *tos)
/*
* All but the first metric contain a valid topology id.
*/
- while (toscount) {
- printf("\n\t\ttopology %s(%u), metric %u",
+ while (toscount) {
+ ND_PRINT((ndo, "\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));
+ EXTRACT_16BITS(&tos->metrics.tos_metric)));
metric_count++;
tos++;
toscount--;
@@ -559,71 +545,73 @@ ospf_print_tos_metrics(const union un_tos *tos)
* field is less than the length of the LSA header, return NULl, else
* return pointer to data past end of LSA.
*/
-static const u_int8_t *
-ospf_print_lsa(register const struct lsa *lsap)
+static const uint8_t *
+ospf_print_lsa(netdissect_options *ndo,
+ register const struct lsa *lsap)
{
- register const u_int8_t *ls_end;
+ register const uint8_t *ls_end;
register const struct rlalink *rlp;
register const struct in_addr *ap;
register const struct aslametric *almp;
register const struct mcla *mcp;
- register const u_int32_t *lp;
+ register const uint32_t *lp;
register int j, tlv_type, tlv_length, topology;
register int ls_length;
- const u_int8_t *tptr;
+ const uint8_t *tptr;
- tptr = (u_int8_t *)lsap->lsa_un.un_unknown; /* squelch compiler warnings */
- ls_length = ospf_print_lshdr(&lsap->ls_hdr);
+ tptr = (uint8_t *)lsap->lsa_un.un_unknown; /* squelch compiler warnings */
+ ls_length = ospf_print_lshdr(ndo, &lsap->ls_hdr);
if (ls_length == -1)
return(NULL);
- ls_end = (u_int8_t *)lsap + ls_length;
+ ls_end = (uint8_t *)lsap + ls_length;
ls_length -= sizeof(struct lsa_hdr);
switch (lsap->ls_hdr.ls_type) {
case LS_TYPE_ROUTER:
- TCHECK(lsap->lsa_un.un_rla.rla_flags);
- printf("\n\t Router LSA Options: [%s]", bittok2str(ospf_rla_flag_values,"none",lsap->lsa_un.un_rla.rla_flags));
+ ND_TCHECK(lsap->lsa_un.un_rla.rla_flags);
+ ND_PRINT((ndo, "\n\t Router LSA Options: [%s]",
+ bittok2str(ospf_rla_flag_values, "none", lsap->lsa_un.un_rla.rla_flags)));
- TCHECK(lsap->lsa_un.un_rla.rla_count);
+ ND_TCHECK(lsap->lsa_un.un_rla.rla_count);
j = EXTRACT_16BITS(&lsap->lsa_un.un_rla.rla_count);
- TCHECK(lsap->lsa_un.un_rla.rla_link);
+ ND_TCHECK(lsap->lsa_un.un_rla.rla_link);
rlp = lsap->lsa_un.un_rla.rla_link;
while (j--) {
- TCHECK(*rlp);
+ ND_TCHECK(*rlp);
switch (rlp->un_tos.link.link_type) {
case RLA_TYPE_VIRTUAL:
- printf("\n\t Virtual Link: Neighbor Router-ID: %s, Interface Address: %s",
- ipaddr_string(&rlp->link_id),
- ipaddr_string(&rlp->link_data));
- break;
+ ND_PRINT((ndo, "\n\t Virtual Link: Neighbor Router-ID: %s, Interface Address: %s",
+ ipaddr_string(ndo, &rlp->link_id),
+ ipaddr_string(ndo, &rlp->link_data)));
+ break;
case RLA_TYPE_ROUTER:
- printf("\n\t Neighbor Router-ID: %s, Interface Address: %s",
- ipaddr_string(&rlp->link_id),
- ipaddr_string(&rlp->link_data));
+ ND_PRINT((ndo, "\n\t Neighbor Router-ID: %s, Interface Address: %s",
+ ipaddr_string(ndo, &rlp->link_id),
+ ipaddr_string(ndo, &rlp->link_data)));
break;
case RLA_TYPE_TRANSIT:
- printf("\n\t Neighbor Network-ID: %s, Interface Address: %s",
- ipaddr_string(&rlp->link_id),
- ipaddr_string(&rlp->link_data));
+ ND_PRINT((ndo, "\n\t Neighbor Network-ID: %s, Interface Address: %s",
+ ipaddr_string(ndo, &rlp->link_id),
+ ipaddr_string(ndo, &rlp->link_data)));
break;
case RLA_TYPE_STUB:
- printf("\n\t Stub Network: %s, Mask: %s",
- ipaddr_string(&rlp->link_id),
- ipaddr_string(&rlp->link_data));
+ ND_PRINT((ndo, "\n\t Stub Network: %s, Mask: %s",
+ ipaddr_string(ndo, &rlp->link_id),
+ ipaddr_string(ndo, &rlp->link_data)));
break;
default:
- printf("\n\t Unknown Router Link Type (%u)",
- rlp->un_tos.link.link_type);
+ ND_PRINT((ndo, "\n\t Unknown Router Link Type (%u)",
+ rlp->un_tos.link.link_type));
return (ls_end);
}
- ospf_print_tos_metrics(&rlp->un_tos);
+ ospf_print_tos_metrics(ndo, &rlp->un_tos);
rlp = (struct rlalink *)((u_char *)(rlp + 1) +
((rlp->un_tos.link.link_tos_count) * sizeof(union un_tos)));
@@ -631,86 +619,84 @@ ospf_print_lsa(register const struct lsa *lsap)
break;
case LS_TYPE_NETWORK:
- TCHECK(lsap->lsa_un.un_nla.nla_mask);
- printf("\n\t Mask %s\n\t Connected Routers:",
- ipaddr_string(&lsap->lsa_un.un_nla.nla_mask));
+ ND_TCHECK(lsap->lsa_un.un_nla.nla_mask);
+ ND_PRINT((ndo, "\n\t Mask %s\n\t Connected Routers:",
+ ipaddr_string(ndo, &lsap->lsa_un.un_nla.nla_mask)));
ap = lsap->lsa_un.un_nla.nla_router;
while ((u_char *)ap < ls_end) {
- TCHECK(*ap);
- printf("\n\t %s", ipaddr_string(ap));
+ ND_TCHECK(*ap);
+ ND_PRINT((ndo, "\n\t %s", ipaddr_string(ndo, ap)));
++ap;
}
break;
case LS_TYPE_SUM_IP:
- TCHECK(lsap->lsa_un.un_nla.nla_mask);
- printf("\n\t Mask %s",
- ipaddr_string(&lsap->lsa_un.un_sla.sla_mask));
- TCHECK(lsap->lsa_un.un_sla.sla_tosmetric);
+ ND_TCHECK(lsap->lsa_un.un_nla.nla_mask);
+ ND_PRINT((ndo, "\n\t Mask %s",
+ ipaddr_string(ndo, &lsap->lsa_un.un_sla.sla_mask)));
+ ND_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;
+ register uint32_t ul;
- TCHECK(*lp);
+ ND_TCHECK(*lp);
ul = EXTRACT_32BITS(lp);
topology = (ul & SLA_MASK_TOS) >> SLA_SHIFT_TOS;
- printf("\n\t\ttopology %s(%u) metric %d",
+ ND_PRINT((ndo, "\n\t\ttopology %s(%u) metric %d",
tok2str(ospf_topology_values, "", topology),
topology,
- ul & SLA_MASK_METRIC);
+ ul & SLA_MASK_METRIC));
++lp;
}
break;
case LS_TYPE_SUM_ABR:
- TCHECK(lsap->lsa_un.un_sla.sla_tosmetric);
+ ND_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;
+ register uint32_t ul;
- TCHECK(*lp);
+ ND_TCHECK(*lp);
ul = EXTRACT_32BITS(lp);
topology = (ul & SLA_MASK_TOS) >> SLA_SHIFT_TOS;
- printf("\n\t\ttopology %s(%u) metric %d",
+ ND_PRINT((ndo, "\n\t\ttopology %s(%u) metric %d",
tok2str(ospf_topology_values, "", topology),
topology,
- ul & SLA_MASK_METRIC);
+ ul & SLA_MASK_METRIC));
++lp;
}
break;
case LS_TYPE_ASE:
case LS_TYPE_NSSA: /* fall through - those LSAs share the same format */
- TCHECK(lsap->lsa_un.un_nla.nla_mask);
- printf("\n\t Mask %s",
- ipaddr_string(&lsap->lsa_un.un_asla.asla_mask));
+ ND_TCHECK(lsap->lsa_un.un_nla.nla_mask);
+ ND_PRINT((ndo, "\n\t Mask %s",
+ ipaddr_string(ndo, &lsap->lsa_un.un_asla.asla_mask)));
- TCHECK(lsap->lsa_un.un_sla.sla_tosmetric);
+ ND_TCHECK(lsap->lsa_un.un_sla.sla_tosmetric);
almp = lsap->lsa_un.un_asla.asla_metric;
while ((u_char *)almp < ls_end) {
- register u_int32_t ul;
+ register uint32_t ul;
- TCHECK(almp->asla_tosmetric);
+ ND_TCHECK(almp->asla_tosmetric);
ul = EXTRACT_32BITS(&almp->asla_tosmetric);
topology = ((ul & ASLA_MASK_TOS) >> ASLA_SHIFT_TOS);
- printf("\n\t\ttopology %s(%u), type %d, metric",
+ ND_PRINT((ndo, "\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
- printf(" %d", (ul & ASLA_MASK_METRIC));
+ (ul & ASLA_FLAG_EXTERNAL) ? 2 : 1));
+ if ((ul & ASLA_MASK_METRIC) == 0xffffff)
+ ND_PRINT((ndo, " infinite"));
+ else
+ ND_PRINT((ndo, " %d", (ul & ASLA_MASK_METRIC)));
- TCHECK(almp->asla_forward);
+ ND_TCHECK(almp->asla_forward);
if (almp->asla_forward.s_addr) {
- printf(", forward %s",
- ipaddr_string(&almp->asla_forward));
+ ND_PRINT((ndo, ", forward %s", ipaddr_string(ndo, &almp->asla_forward)));
}
- TCHECK(almp->asla_tag);
+ ND_TCHECK(almp->asla_tag);
if (almp->asla_tag.s_addr) {
- printf(", tag %s",
- ipaddr_string(&almp->asla_tag));
+ ND_PRINT((ndo, ", tag %s", ipaddr_string(ndo, &almp->asla_tag)));
}
++almp;
}
@@ -720,22 +706,22 @@ ospf_print_lsa(register const struct lsa *lsap)
/* Multicast extensions as of 23 July 1991 */
mcp = lsap->lsa_un.un_mcla;
while ((u_char *)mcp < ls_end) {
- TCHECK(mcp->mcla_vid);
+ ND_TCHECK(mcp->mcla_vid);
switch (EXTRACT_32BITS(&mcp->mcla_vtype)) {
case MCLA_VERTEX_ROUTER:
- printf("\n\t Router Router-ID %s",
- ipaddr_string(&mcp->mcla_vid));
+ ND_PRINT((ndo, "\n\t Router Router-ID %s",
+ ipaddr_string(ndo, &mcp->mcla_vid)));
break;
case MCLA_VERTEX_NETWORK:
- printf("\n\t Network Designated Router %s",
- ipaddr_string(&mcp->mcla_vid));
+ ND_PRINT((ndo, "\n\t Network Designated Router %s",
+ ipaddr_string(ndo, &mcp->mcla_vid)));
break;
default:
- printf("\n\t unknown VertexType (%u)",
- EXTRACT_32BITS(&mcp->mcla_vtype));
+ ND_PRINT((ndo, "\n\t unknown VertexType (%u)",
+ EXTRACT_32BITS(&mcp->mcla_vtype)));
break;
}
++mcp;
@@ -743,48 +729,48 @@ ospf_print_lsa(register const struct lsa *lsap)
break;
case LS_TYPE_OPAQUE_LL: /* fall through */
- case LS_TYPE_OPAQUE_AL:
+ case LS_TYPE_OPAQUE_AL:
case LS_TYPE_OPAQUE_DW:
switch (*(&lsap->ls_hdr.un_lsa_id.opaque_field.opaque_type)) {
case LS_OPAQUE_TYPE_RI:
- tptr = (u_int8_t *)(&lsap->lsa_un.un_ri_tlv.type);
+ tptr = (uint8_t *)(&lsap->lsa_un.un_ri_tlv.type);
while (ls_length != 0) {
- TCHECK2(*tptr, 4);
+ ND_TCHECK2(*tptr, 4);
if (ls_length < 4) {
- printf("\n\t Remaining LS length %u < 4", ls_length);
+ ND_PRINT((ndo, "\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: ",
+
+ ND_PRINT((ndo, "\n\t %s TLV (%u), length: %u, value: ",
tok2str(lsa_opaque_ri_tlv_values,"unknown",tlv_type),
tlv_type,
- tlv_length);
+ tlv_length));
if (tlv_length > ls_length) {
- printf("\n\t Bogus length %u > %u", tlv_length,
- ls_length);
+ ND_PRINT((ndo, "\n\t Bogus length %u > %u", tlv_length,
+ ls_length));
return(ls_end);
}
- TCHECK2(*tptr, tlv_length);
+ ND_TCHECK2(*tptr, tlv_length);
switch(tlv_type) {
case LS_OPAQUE_RI_TLV_CAP:
if (tlv_length != 4) {
- printf("\n\t Bogus length %u != 4", tlv_length);
+ ND_PRINT((ndo, "\n\t Bogus length %u != 4", tlv_length));
return(ls_end);
}
- printf("Capabilities: %s",
- bittok2str(lsa_opaque_ri_tlv_cap_values, "Unknown", EXTRACT_32BITS(tptr)));
+ ND_PRINT((ndo, "Capabilities: %s",
+ bittok2str(lsa_opaque_ri_tlv_cap_values, "Unknown", EXTRACT_32BITS(tptr))));
break;
default:
- if (vflag <= 1) {
- if(!print_unknown_data(tptr,"\n\t ",tlv_length))
+ if (ndo->ndo_vflag <= 1) {
+ if (!print_unknown_data(ndo, tptr, "\n\t ", tlv_length))
return(ls_end);
}
break;
@@ -796,50 +782,50 @@ ospf_print_lsa(register const struct lsa *lsap)
break;
case LS_OPAQUE_TYPE_GRACE:
- if (ospf_print_grace_lsa((u_int8_t *)(&lsap->lsa_un.un_grace_tlv.type),
+ if (ospf_print_grace_lsa(ndo, (uint8_t *)(&lsap->lsa_un.un_grace_tlv.type),
ls_length) == -1) {
return(ls_end);
}
break;
case LS_OPAQUE_TYPE_TE:
- if (ospf_print_te_lsa((u_int8_t *)(&lsap->lsa_un.un_te_lsa_tlv.type),
+ if (ospf_print_te_lsa(ndo, (uint8_t *)(&lsap->lsa_un.un_te_lsa_tlv.type),
ls_length) == -1) {
return(ls_end);
}
break;
default:
- if (vflag <= 1) {
- if(!print_unknown_data((u_int8_t *)lsap->lsa_un.un_unknown,
+ if (ndo->ndo_vflag <= 1) {
+ if (!print_unknown_data(ndo, (uint8_t *)lsap->lsa_un.un_unknown,
"\n\t ", ls_length))
return(ls_end);
- }
+ }
break;
}
}
/* do we want to see an additionally hexdump ? */
- if (vflag> 1)
- if(!print_unknown_data((u_int8_t *)lsap->lsa_un.un_unknown,
+ if (ndo->ndo_vflag> 1)
+ if (!print_unknown_data(ndo, (uint8_t *)lsap->lsa_un.un_unknown,
"\n\t ", ls_length)) {
return(ls_end);
}
-
+
return (ls_end);
trunc:
return (NULL);
}
static int
-ospf_decode_lls(register const struct ospfhdr *op,
- register u_int length)
+ospf_decode_lls(netdissect_options *ndo,
+ 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;
+ register uint16_t lls_type, lls_len;
+ register uint32_t lls_flags;
switch (op->ospf_type) {
@@ -867,51 +853,51 @@ ospf_decode_lls(register const struct ospfhdr *op,
length2 += op->ospf_authdata[3];
}
if (length2 >= length) {
- printf("\n\t[LLS truncated]");
+ ND_PRINT((ndo, "\n\t[LLS truncated]"));
return (1);
}
- TCHECK2(*dptr, 2);
- printf("\n\t LLS: checksum: 0x%04x", (u_int)EXTRACT_16BITS(dptr));
+ ND_TCHECK2(*dptr, 2);
+ ND_PRINT((ndo, "\n\t LLS: checksum: 0x%04x", (u_int)EXTRACT_16BITS(dptr)));
dptr += 2;
- TCHECK2(*dptr, 2);
+ ND_TCHECK2(*dptr, 2);
length2 = EXTRACT_16BITS(dptr);
- printf(", length: %u", length2);
+ ND_PRINT((ndo, ", length: %u", length2));
dptr += 2;
- TCHECK(*dptr);
+ ND_TCHECK(*dptr);
while (dptr < dataend) {
- TCHECK2(*dptr, 2);
+ ND_TCHECK2(*dptr, 2);
lls_type = EXTRACT_16BITS(dptr);
- printf("\n\t %s (%u)",
+ ND_PRINT((ndo, "\n\t %s (%u)",
tok2str(ospf_lls_tlv_values,"Unknown TLV",lls_type),
- lls_type);
+ lls_type));
dptr += 2;
- TCHECK2(*dptr, 2);
+ ND_TCHECK2(*dptr, 2);
lls_len = EXTRACT_16BITS(dptr);
- printf(", length: %u", lls_len);
+ ND_PRINT((ndo, ", length: %u", lls_len));
dptr += 2;
switch (lls_type) {
case OSPF_LLS_EO:
if (lls_len != 4) {
- printf(" [should be 4]");
+ ND_PRINT((ndo, " [should be 4]"));
lls_len = 4;
}
- TCHECK2(*dptr, 4);
+ ND_TCHECK2(*dptr, 4);
lls_flags = EXTRACT_32BITS(dptr);
- printf("\n\t Options: 0x%08x [%s]", lls_flags,
- bittok2str(ospf_lls_eo_options,"?",lls_flags));
+ ND_PRINT((ndo, "\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]");
+ ND_PRINT((ndo, " [should be 20]"));
lls_len = 20;
}
- TCHECK2(*dptr, 4);
- printf("\n\t Sequence number: 0x%08x", EXTRACT_32BITS(dptr));
+ ND_TCHECK2(*dptr, 4);
+ ND_PRINT((ndo, "\n\t Sequence number: 0x%08x", EXTRACT_32BITS(dptr)));
break;
}
@@ -924,14 +910,14 @@ trunc:
}
static int
-ospf_decode_v2(register const struct ospfhdr *op,
- register const u_char *dataend)
+ospf_decode_v2(netdissect_options *ndo,
+ register const struct ospfhdr *op, register const u_char *dataend)
{
register const struct in_addr *ap;
register const struct lsr *lsrp;
register const struct lsa_hdr *lshp;
register const struct lsa *lsap;
- register u_int32_t lsa_count,lsa_count_max;
+ register uint32_t lsa_count,lsa_count_max;
switch (op->ospf_type) {
@@ -943,95 +929,95 @@ ospf_decode_v2(register const struct ospfhdr *op,
break;
case OSPF_TYPE_HELLO:
- printf("\n\tOptions [%s]",
- bittok2str(ospf_option_values,"none",op->ospf_hello.hello_options));
+ ND_PRINT((ndo, "\n\tOptions [%s]",
+ bittok2str(ospf_option_values,"none",op->ospf_hello.hello_options)));
- TCHECK(op->ospf_hello.hello_deadint);
- printf("\n\t Hello Timer %us, Dead Timer %us, Mask %s, Priority %u",
- EXTRACT_16BITS(&op->ospf_hello.hello_helloint),
- EXTRACT_32BITS(&op->ospf_hello.hello_deadint),
- ipaddr_string(&op->ospf_hello.hello_mask),
- op->ospf_hello.hello_priority);
+ ND_TCHECK(op->ospf_hello.hello_deadint);
+ ND_PRINT((ndo, "\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(ndo, &op->ospf_hello.hello_mask),
+ op->ospf_hello.hello_priority));
- TCHECK(op->ospf_hello.hello_dr);
+ ND_TCHECK(op->ospf_hello.hello_dr);
if (op->ospf_hello.hello_dr.s_addr != 0)
- printf("\n\t Designated Router %s",
- ipaddr_string(&op->ospf_hello.hello_dr));
+ ND_PRINT((ndo, "\n\t Designated Router %s",
+ ipaddr_string(ndo, &op->ospf_hello.hello_dr)));
- TCHECK(op->ospf_hello.hello_bdr);
+ ND_TCHECK(op->ospf_hello.hello_bdr);
if (op->ospf_hello.hello_bdr.s_addr != 0)
- printf(", Backup Designated Router %s",
- ipaddr_string(&op->ospf_hello.hello_bdr));
-
- ap = op->ospf_hello.hello_neighbor;
- if ((u_char *)ap < dataend)
- printf("\n\t Neighbor List:");
- while ((u_char *)ap < dataend) {
- TCHECK(*ap);
- printf("\n\t %s", ipaddr_string(ap));
- ++ap;
- }
+ ND_PRINT((ndo, ", Backup Designated Router %s",
+ ipaddr_string(ndo, &op->ospf_hello.hello_bdr)));
+
+ ap = op->ospf_hello.hello_neighbor;
+ if ((u_char *)ap < dataend)
+ ND_PRINT((ndo, "\n\t Neighbor List:"));
+ while ((u_char *)ap < dataend) {
+ ND_TCHECK(*ap);
+ ND_PRINT((ndo, "\n\t %s", ipaddr_string(ndo, ap)));
+ ++ap;
+ }
break; /* HELLO */
case OSPF_TYPE_DD:
- TCHECK(op->ospf_db.db_options);
- printf("\n\tOptions [%s]",
- bittok2str(ospf_option_values,"none",op->ospf_db.db_options));
- TCHECK(op->ospf_db.db_flags);
- 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", EXTRACT_16BITS(&op->ospf_db.db_ifmtu));
- }
- TCHECK(op->ospf_db.db_seq);
- printf(", Sequence: 0x%08x", EXTRACT_32BITS(&op->ospf_db.db_seq));
+ ND_TCHECK(op->ospf_db.db_options);
+ ND_PRINT((ndo, "\n\tOptions [%s]",
+ bittok2str(ospf_option_values, "none", op->ospf_db.db_options)));
+ ND_TCHECK(op->ospf_db.db_flags);
+ ND_PRINT((ndo, ", DD Flags [%s]",
+ bittok2str(ospf_dd_flag_values, "none", op->ospf_db.db_flags)));
+ ND_TCHECK(op->ospf_db.db_ifmtu);
+ if (op->ospf_db.db_ifmtu) {
+ ND_PRINT((ndo, ", MTU: %u", EXTRACT_16BITS(&op->ospf_db.db_ifmtu)));
+ }
+ ND_TCHECK(op->ospf_db.db_seq);
+ ND_PRINT((ndo, ", Sequence: 0x%08x", EXTRACT_32BITS(&op->ospf_db.db_seq)));
- /* Print all the LS adv's */
- lshp = op->ospf_db.db_lshdr;
- while (((u_char *)lshp < dataend) && 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(ndo, lshp) != -1) {
+ ++lshp;
+ }
break;
case OSPF_TYPE_LS_REQ:
lsrp = op->ospf_lsr;
while ((u_char *)lsrp < dataend) {
- TCHECK(*lsrp);
+ ND_TCHECK(*lsrp);
- printf("\n\t Advertising Router: %s, %s LSA (%u)",
- ipaddr_string(&lsrp->ls_router),
+ ND_PRINT((ndo, "\n\t Advertising Router: %s, %s LSA (%u)",
+ ipaddr_string(ndo, &lsrp->ls_router),
tok2str(lsa_values,"unknown",EXTRACT_32BITS(lsrp->ls_type)),
- EXTRACT_32BITS(&lsrp->ls_type));
+ EXTRACT_32BITS(&lsrp->ls_type)));
switch (EXTRACT_32BITS(lsrp->ls_type)) {
/* the LSA header for opaque LSAs was slightly changed */
case LS_TYPE_OPAQUE_LL:
case LS_TYPE_OPAQUE_AL:
case LS_TYPE_OPAQUE_DW:
- printf(", Opaque-Type: %s LSA (%u), Opaque-ID: %u",
+ ND_PRINT((ndo, ", Opaque-Type: %s LSA (%u), Opaque-ID: %u",
tok2str(lsa_opaque_values, "unknown",lsrp->un_ls_stateid.opaque_field.opaque_type),
lsrp->un_ls_stateid.opaque_field.opaque_type,
- EXTRACT_24BITS(&lsrp->un_ls_stateid.opaque_field.opaque_id));
+ EXTRACT_24BITS(&lsrp->un_ls_stateid.opaque_field.opaque_id)));
break;
default:
- printf(", LSA-ID: %s",
- ipaddr_string(&lsrp->un_ls_stateid.ls_stateid));
+ ND_PRINT((ndo, ", LSA-ID: %s",
+ ipaddr_string(ndo, &lsrp->un_ls_stateid.ls_stateid)));
break;
}
-
+
++lsrp;
}
break;
case OSPF_TYPE_LS_UPDATE:
lsap = op->ospf_lsu.lsu_lsa;
- TCHECK(op->ospf_lsu.lsu_count);
+ ND_TCHECK(op->ospf_lsu.lsu_count);
lsa_count_max = EXTRACT_32BITS(&op->ospf_lsu.lsu_count);
- printf(", %d LSA%s",lsa_count_max, PLURAL_SUFFIX(lsa_count_max));
+ ND_PRINT((ndo, ", %d LSA%s", lsa_count_max, PLURAL_SUFFIX(lsa_count_max)));
for (lsa_count=1;lsa_count <= lsa_count_max;lsa_count++) {
- printf("\n\t LSA #%u",lsa_count);
- lsap = (const struct lsa *)ospf_print_lsa(lsap);
+ ND_PRINT((ndo, "\n\t LSA #%u", lsa_count));
+ lsap = (const struct lsa *)ospf_print_lsa(ndo, lsap);
if (lsap == NULL)
goto trunc;
}
@@ -1039,7 +1025,7 @@ ospf_decode_v2(register const struct ospfhdr *op,
case OSPF_TYPE_LS_ACK:
lshp = op->ospf_lsa.lsa_lshdr;
- while (ospf_print_lshdr(lshp) != -1) {
+ while (ospf_print_lshdr(ndo, lshp) != -1) {
++lshp;
}
break;
@@ -1053,8 +1039,9 @@ trunc:
}
void
-ospf_print(register const u_char *bp, register u_int length,
- const u_char *bp2 _U_)
+ospf_print(netdissect_options *ndo,
+ register const u_char *bp, register u_int length,
+ const u_char *bp2 _U_)
{
register const struct ospfhdr *op;
register const u_char *dataend;
@@ -1062,31 +1049,28 @@ ospf_print(register const u_char *bp, register u_int length,
op = (struct ospfhdr *)bp;
- /* XXX Before we do anything else, strip off the MD5 trailer */
- TCHECK(op->ospf_authtype);
- if (EXTRACT_16BITS(&op->ospf_authtype) == OSPF_AUTH_MD5) {
- length -= OSPF_AUTH_MD5_LEN;
- snapend -= OSPF_AUTH_MD5_LEN;
- }
+ /* XXX Before we do anything else, strip off the MD5 trailer */
+ ND_TCHECK(op->ospf_authtype);
+ if (EXTRACT_16BITS(&op->ospf_authtype) == OSPF_AUTH_MD5) {
+ length -= OSPF_AUTH_MD5_LEN;
+ ndo->ndo_snapend -= OSPF_AUTH_MD5_LEN;
+ }
/* If the type is valid translate it, or just print the type */
/* value. If it's not valid, say so and return */
- TCHECK(op->ospf_type);
+ ND_TCHECK(op->ospf_type);
cp = tok2str(type2str, "unknown LS-type", op->ospf_type);
- printf("OSPFv%u, %s, length %u",
- op->ospf_version,
- cp,
- length);
+ ND_PRINT((ndo, "OSPFv%u, %s, length %u", op->ospf_version, cp, length));
if (*cp == 'u')
return;
- if(!vflag) { /* non verbose - so lets bail out here */
- return;
- }
+ if (!ndo->ndo_vflag) { /* non verbose - so lets bail out here */
+ return;
+ }
- TCHECK(op->ospf_len);
+ ND_TCHECK(op->ospf_len);
if (length != EXTRACT_16BITS(&op->ospf_len)) {
- printf(" [len %d]", EXTRACT_16BITS(&op->ospf_len));
+ ND_PRINT((ndo, " [len %d]", EXTRACT_16BITS(&op->ospf_len)));
}
if (length > EXTRACT_16BITS(&op->ospf_len)) {
@@ -1095,22 +1079,22 @@ ospf_print(register const u_char *bp, register u_int length,
dataend = bp + length;
}
- TCHECK(op->ospf_routerid);
- printf("\n\tRouter-ID %s", ipaddr_string(&op->ospf_routerid));
+ ND_TCHECK(op->ospf_routerid);
+ ND_PRINT((ndo, "\n\tRouter-ID %s", ipaddr_string(ndo, &op->ospf_routerid)));
- TCHECK(op->ospf_areaid);
+ ND_TCHECK(op->ospf_areaid);
if (op->ospf_areaid.s_addr != 0)
- printf(", Area %s", ipaddr_string(&op->ospf_areaid));
+ ND_PRINT((ndo, ", Area %s", ipaddr_string(ndo, &op->ospf_areaid)));
else
- printf(", Backbone Area");
+ ND_PRINT((ndo, ", Backbone Area"));
- if (vflag) {
+ if (ndo->ndo_vflag) {
/* Print authentication data (should we really do this?) */
- TCHECK2(op->ospf_authdata[0], sizeof(op->ospf_authdata));
+ ND_TCHECK2(op->ospf_authdata[0], sizeof(op->ospf_authdata));
- printf(", Authentication Type: %s (%u)",
- tok2str(ospf_authtype_values,"unknown",EXTRACT_16BITS(&op->ospf_authtype)),
- EXTRACT_16BITS(&op->ospf_authtype));
+ ND_PRINT((ndo, ", Authentication Type: %s (%u)",
+ tok2str(ospf_authtype_values, "unknown", EXTRACT_16BITS(&op->ospf_authtype)),
+ EXTRACT_16BITS(&op->ospf_authtype)));
switch (EXTRACT_16BITS(&op->ospf_authtype)) {
@@ -1118,15 +1102,15 @@ ospf_print(register const u_char *bp, register u_int length,
break;
case OSPF_AUTH_SIMPLE:
- printf("\n\tSimple text password: ");
- safeputs((const char *)op->ospf_authdata, OSPF_AUTH_SIMPLE_LEN);
+ ND_PRINT((ndo, "\n\tSimple text password: "));
+ safeputs(ndo, op->ospf_authdata, OSPF_AUTH_SIMPLE_LEN);
break;
case OSPF_AUTH_MD5:
- printf("\n\tKey-ID: %u, Auth-Length: %u, Crypto Sequence Number: 0x%08x",
- *((op->ospf_authdata)+2),
- *((op->ospf_authdata)+3),
- EXTRACT_32BITS((op->ospf_authdata)+4));
+ ND_PRINT((ndo, "\n\tKey-ID: %u, Auth-Length: %u, Crypto Sequence Number: 0x%08x",
+ *((op->ospf_authdata) + 2),
+ *((op->ospf_authdata) + 3),
+ EXTRACT_32BITS((op->ospf_authdata) + 4)));
break;
default:
@@ -1138,20 +1122,20 @@ ospf_print(register const u_char *bp, register u_int length,
case 2:
/* ospf version 2 */
- if (ospf_decode_v2(op, dataend))
+ if (ospf_decode_v2(ndo, op, dataend))
goto trunc;
if (length > EXTRACT_16BITS(&op->ospf_len)) {
- if (ospf_decode_lls(op, length))
+ if (ospf_decode_lls(ndo, op, length))
goto trunc;
}
break;
default:
- printf(" ospf [version %d]", op->ospf_version);
+ ND_PRINT((ndo, " ospf [version %d]", op->ospf_version));
break;
} /* end switch on version */
return;
trunc:
- fputs(tstr, stdout);
+ ND_PRINT((ndo, "%s", tstr));
}
diff --git a/contrib/tcpdump/print-ospf6.c b/contrib/tcpdump/print-ospf6.c
index fb62b3968597..49210bc04dc5 100644
--- a/contrib/tcpdump/print-ospf6.c
+++ b/contrib/tcpdump/print-ospf6.c
@@ -21,18 +21,13 @@
* OSPF support contributed by Jeffrey Honig (jch@mitchell.cit.cornell.edu)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ospf6.c,v 1.15 2006-09-13 06:31:11 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
#include <string.h>
#include "interface.h"
@@ -40,15 +35,266 @@ static const char rcsid[] _U_ =
#include "extract.h"
#include "ospf.h"
-#include "ospf6.h"
+
+#define OSPF_TYPE_HELLO 1 /* Hello */
+#define OSPF_TYPE_DD 2 /* Database Description */
+#define OSPF_TYPE_LS_REQ 3 /* Link State Request */
+#define OSPF_TYPE_LS_UPDATE 4 /* Link State Update */
+#define OSPF_TYPE_LS_ACK 5 /* Link State Ack */
+
+/* Options *_options */
+#define OSPF6_OPTION_V6 0x01 /* V6 bit: A bit for peeping tom */
+#define OSPF6_OPTION_E 0x02 /* E bit: External routes advertised */
+#define OSPF6_OPTION_MC 0x04 /* MC bit: Multicast capable */
+#define OSPF6_OPTION_N 0x08 /* N bit: For type-7 LSA */
+#define OSPF6_OPTION_R 0x10 /* R bit: Router bit */
+#define OSPF6_OPTION_DC 0x20 /* DC bit: Demand circuits */
+/* The field is actually 24-bit (RFC5340 Section A.2). */
+#define OSPF6_OPTION_AF 0x0100 /* AF bit: Multiple address families */
+#define OSPF6_OPTION_L 0x0200 /* L bit: Link-local signaling (LLS) */
+#define OSPF6_OPTION_AT 0x0400 /* AT bit: Authentication trailer */
+
+
+/* db_flags */
+#define OSPF6_DB_INIT 0x04 /* */
+#define OSPF6_DB_MORE 0x02
+#define OSPF6_DB_MASTER 0x01
+#define OSPF6_DB_M6 0x10 /* IPv6 MTU */
+
+/* ls_type */
+#define LS_TYPE_ROUTER 1 /* router link */
+#define LS_TYPE_NETWORK 2 /* network link */
+#define LS_TYPE_INTER_AP 3 /* Inter-Area-Prefix */
+#define LS_TYPE_INTER_AR 4 /* Inter-Area-Router */
+#define LS_TYPE_ASE 5 /* ASE */
+#define LS_TYPE_GROUP 6 /* Group membership */
+#define LS_TYPE_NSSA 7 /* NSSA */
+#define LS_TYPE_LINK 8 /* Link LSA */
+#define LS_TYPE_INTRA_AP 9 /* Intra-Area-Prefix */
+#define LS_TYPE_INTRA_ATE 10 /* Intra-Area-TE */
+#define LS_TYPE_GRACE 11 /* Grace LSA */
+#define LS_TYPE_RI 12 /* Router information */
+#define LS_TYPE_INTER_ASTE 13 /* Inter-AS-TE */
+#define LS_TYPE_L1VPN 14 /* L1VPN */
+#define LS_TYPE_MASK 0x1fff
+
+#define LS_SCOPE_LINKLOCAL 0x0000
+#define LS_SCOPE_AREA 0x2000
+#define LS_SCOPE_AS 0x4000
+#define LS_SCOPE_MASK 0x6000
+#define LS_SCOPE_U 0x8000
+
+/* rla_link.link_type */
+#define RLA_TYPE_ROUTER 1 /* point-to-point to another router */
+#define RLA_TYPE_TRANSIT 2 /* connection to transit network */
+#define RLA_TYPE_VIRTUAL 4 /* virtual link */
+
+/* rla_flags */
+#define RLA_FLAG_B 0x01
+#define RLA_FLAG_E 0x02
+#define RLA_FLAG_V 0x04
+#define RLA_FLAG_W 0x08
+#define RLA_FLAG_N 0x10
+
+/* lsa_prefix options */
+#define LSA_PREFIX_OPT_NU 0x01
+#define LSA_PREFIX_OPT_LA 0x02
+#define LSA_PREFIX_OPT_MC 0x04
+#define LSA_PREFIX_OPT_P 0x08
+#define LSA_PREFIX_OPT_DN 0x10
+
+/* sla_tosmetric breakdown */
+#define SLA_MASK_TOS 0x7f000000
+#define SLA_MASK_METRIC 0x00ffffff
+#define SLA_SHIFT_TOS 24
+
+/* asla_metric */
+#define ASLA_FLAG_FWDADDR 0x02000000
+#define ASLA_FLAG_ROUTETAG 0x01000000
+#define ASLA_MASK_METRIC 0x00ffffff
+
+/* RFC6506 Section 4.1 */
+#define OSPF6_AT_HDRLEN 16U
+#define OSPF6_AUTH_TYPE_HMAC 0x0001
+
+typedef uint32_t rtrid_t;
+
+/* link state advertisement header */
+struct lsa6_hdr {
+ uint16_t ls_age;
+ uint16_t ls_type;
+ rtrid_t ls_stateid;
+ rtrid_t ls_router;
+ uint32_t ls_seq;
+ uint16_t ls_chksum;
+ uint16_t ls_length;
+};
+
+/* Length of an IPv6 address, in bytes. */
+#define IPV6_ADDR_LEN_BYTES (128/8)
+
+struct lsa6_prefix {
+ uint8_t lsa_p_len;
+ uint8_t lsa_p_opt;
+ uint16_t lsa_p_metric;
+ uint8_t lsa_p_prefix[IPV6_ADDR_LEN_BYTES]; /* maximum length */
+};
+
+/* link state advertisement */
+struct lsa6 {
+ struct lsa6_hdr ls_hdr;
+
+ /* Link state types */
+ union {
+ /* Router links advertisements */
+ struct {
+ union {
+ uint8_t flg;
+ uint32_t opt;
+ } rla_flgandopt;
+#define rla_flags rla_flgandopt.flg
+#define rla_options rla_flgandopt.opt
+ struct rlalink6 {
+ uint8_t link_type;
+ uint8_t link_zero[1];
+ uint16_t link_metric;
+ uint32_t link_ifid;
+ uint32_t link_nifid;
+ rtrid_t link_nrtid;
+ } rla_link[1]; /* may repeat */
+ } un_rla;
+
+ /* Network links advertisements */
+ struct {
+ uint32_t nla_options;
+ rtrid_t nla_router[1]; /* may repeat */
+ } un_nla;
+
+ /* Inter Area Prefix LSA */
+ struct {
+ uint32_t inter_ap_metric;
+ struct lsa6_prefix inter_ap_prefix[1];
+ } un_inter_ap;
+
+ /* AS external links advertisements */
+ struct {
+ uint32_t asla_metric;
+ struct lsa6_prefix asla_prefix[1];
+ /* some optional fields follow */
+ } un_asla;
+
+#if 0
+ /* Summary links advertisements */
+ struct {
+ struct in_addr sla_mask;
+ uint32_t sla_tosmetric[1]; /* may repeat */
+ } un_sla;
+
+ /* Multicast group membership */
+ struct mcla {
+ uint32_t mcla_vtype;
+ struct in_addr mcla_vid;
+ } un_mcla[1];
+#endif
+
+ /* Type 7 LSA */
+
+ /* Link LSA */
+ struct llsa {
+ union {
+ uint8_t pri;
+ uint32_t opt;
+ } llsa_priandopt;
+#define llsa_priority llsa_priandopt.pri
+#define llsa_options llsa_priandopt.opt
+ struct in6_addr llsa_lladdr;
+ uint32_t llsa_nprefix;
+ struct lsa6_prefix llsa_prefix[1];
+ } un_llsa;
+
+ /* Intra-Area-Prefix */
+ struct {
+ uint16_t intra_ap_nprefix;
+ uint16_t intra_ap_lstype;
+ rtrid_t intra_ap_lsid;
+ rtrid_t intra_ap_rtid;
+ struct lsa6_prefix intra_ap_prefix[1];
+ } un_intra_ap;
+ } lsa_un;
+};
+
+/*
+ * the main header
+ */
+struct ospf6hdr {
+ uint8_t ospf6_version;
+ uint8_t ospf6_type;
+ uint16_t ospf6_len;
+ rtrid_t ospf6_routerid;
+ rtrid_t ospf6_areaid;
+ uint16_t ospf6_chksum;
+ uint8_t ospf6_instanceid;
+ uint8_t ospf6_rsvd;
+};
+
+/*
+ * The OSPF6 header length is 16 bytes, regardless of how your compiler
+ * might choose to pad the above structure.
+ */
+#define OSPF6HDR_LEN 16
+
+/* Hello packet */
+struct hello6 {
+ uint32_t hello_ifid;
+ union {
+ uint8_t pri;
+ uint32_t opt;
+ } hello_priandopt;
+#define hello_priority hello_priandopt.pri
+#define hello_options hello_priandopt.opt
+ uint16_t hello_helloint;
+ uint16_t hello_deadint;
+ rtrid_t hello_dr;
+ rtrid_t hello_bdr;
+ rtrid_t hello_neighbor[1]; /* may repeat */
+};
+
+/* Database Description packet */
+struct dd6 {
+ uint32_t db_options;
+ uint16_t db_mtu;
+ uint8_t db_mbz;
+ uint8_t db_flags;
+ uint32_t db_seq;
+ struct lsa6_hdr db_lshdr[1]; /* may repeat */
+};
+
+/* Link State Request */
+struct lsr6 {
+ uint16_t ls_mbz;
+ uint16_t ls_type;
+ rtrid_t ls_stateid;
+ rtrid_t ls_router;
+};
+
+/* Link State Update */
+struct lsu6 {
+ uint32_t lsu_count;
+ struct lsa6 lsu_lsa[1]; /* may repeat */
+};
+
+static const char tstr[] = " [|ospf3]";
static const struct tok ospf6_option_values[] = {
{ OSPF6_OPTION_V6, "V6" },
{ OSPF6_OPTION_E, "External" },
- { OSPF6_OPTION_MC, "Multicast" },
+ { OSPF6_OPTION_MC, "Deprecated" },
{ OSPF6_OPTION_N, "NSSA" },
{ OSPF6_OPTION_R, "Router" },
{ OSPF6_OPTION_DC, "Demand Circuit" },
+ { OSPF6_OPTION_AF, "AFs Support" },
+ { OSPF6_OPTION_L, "LLS" },
+ { OSPF6_OPTION_AT, "Authentication Trailer" },
{ 0, NULL }
};
@@ -63,12 +309,12 @@ static const struct tok ospf6_rla_flag_values[] = {
static const struct tok ospf6_asla_flag_values[] = {
{ ASLA_FLAG_EXTERNAL, "External Type 2" },
- { ASLA_FLAG_FWDADDR, "Fforwarding" },
+ { ASLA_FLAG_FWDADDR, "Forwarding" },
{ ASLA_FLAG_ROUTETAG, "Tag" },
{ 0, NULL }
};
-static struct tok ospf6_type_values[] = {
+static const struct tok ospf6_type_values[] = {
{ OSPF_TYPE_HELLO, "Hello" },
{ OSPF_TYPE_DD, "Database Description" },
{ OSPF_TYPE_LS_REQ, "LS-Request" },
@@ -77,82 +323,81 @@ static struct tok ospf6_type_values[] = {
{ 0, NULL }
};
-static struct tok ospf6_lsa_values[] = {
+static const 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_GROUP, "Deprecated" },
{ 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" },
+ { LS_TYPE_RI, "Router Information" },
+ { LS_TYPE_INTER_ASTE, "Inter-AS-TE" },
+ { LS_TYPE_L1VPN, "Layer 1 VPN" },
{ 0, NULL }
};
-static struct tok ospf6_ls_scope_values[] = {
+static const 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[] = {
+static const struct tok ospf6_dd_flag_values[] = {
{ OSPF6_DB_INIT, "Init" },
{ OSPF6_DB_MORE, "More" },
{ OSPF6_DB_MASTER, "Master" },
+ { OSPF6_DB_M6, "IPv6 MTU" },
{ 0, NULL }
};
-static struct tok ospf6_lsa_prefix_option_values[] = {
+static const 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_MC, "Deprecated" },
{ 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 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 const struct tok ospf6_auth_type_str[] = {
+ { OSPF6_AUTH_TYPE_HMAC, "HMAC" },
+ { 0, NULL }
+};
static void
-ospf6_print_ls_type(register u_int ls_type, register const rtrid_t *ls_stateid)
+ospf6_print_ls_type(netdissect_options *ndo,
+ register u_int ls_type, register const rtrid_t *ls_stateid)
{
- printf("\n\t %s LSA (%d), %s Scope%s, LSA-ID %s",
+ ND_PRINT((ndo, "\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));
+ ipaddr_string(ndo, ls_stateid)));
}
static int
-ospf6_print_lshdr(register const struct lsa6_hdr *lshp)
+ospf6_print_lshdr(netdissect_options *ndo,
+ register const struct lsa6_hdr *lshp, const u_char *dataend)
{
+ if ((u_char *)(lshp + 1) > dataend)
+ goto trunc;
+ ND_TCHECK(lshp->ls_type);
+ ND_TCHECK(lshp->ls_seq);
- TCHECK(lshp->ls_type);
- TCHECK(lshp->ls_seq);
-
- printf("\n\t Advertising Router %s, seq 0x%08x, age %us, length %u",
- ipaddr_string(&lshp->ls_router),
+ ND_PRINT((ndo, "\n\t Advertising Router %s, seq 0x%08x, age %us, length %u",
+ ipaddr_string(ndo, &lshp->ls_router),
EXTRACT_32BITS(&lshp->ls_seq),
EXTRACT_16BITS(&lshp->ls_age),
- EXTRACT_16BITS(&lshp->ls_length)-(u_int)sizeof(struct lsa6_hdr));
+ EXTRACT_16BITS(&lshp->ls_length)-(u_int)sizeof(struct lsa6_hdr)));
- ospf6_print_ls_type(EXTRACT_16BITS(&lshp->ls_type), &lshp->ls_stateid);
+ ospf6_print_ls_type(ndo, EXTRACT_16BITS(&lshp->ls_type), &lshp->ls_stateid);
return (0);
trunc:
@@ -160,36 +405,37 @@ trunc:
}
static int
-ospf6_print_lsaprefix(const u_int8_t *tptr, u_int lsa_length)
+ospf6_print_lsaprefix(netdissect_options *ndo,
+ const uint8_t *tptr, u_int lsa_length)
{
const struct lsa6_prefix *lsapp = (struct lsa6_prefix *)tptr;
u_int wordlen;
struct in6_addr prefix;
- if (lsa_length < sizeof (*lsapp) - 4)
+ if (lsa_length < sizeof (*lsapp) - IPV6_ADDR_LEN_BYTES)
goto trunc;
- lsa_length -= sizeof (*lsapp) - 4;
- TCHECK2(*lsapp, sizeof (*lsapp) - 4);
+ lsa_length -= sizeof (*lsapp) - IPV6_ADDR_LEN_BYTES;
+ ND_TCHECK2(*lsapp, sizeof (*lsapp) - IPV6_ADDR_LEN_BYTES);
wordlen = (lsapp->lsa_p_len + 31) / 32;
if (wordlen * 4 > sizeof(struct in6_addr)) {
- printf(" bogus prefixlen /%d", lsapp->lsa_p_len);
+ ND_PRINT((ndo, " bogus prefixlen /%d", lsapp->lsa_p_len));
goto trunc;
}
if (lsa_length < wordlen * 4)
goto trunc;
lsa_length -= wordlen * 4;
- TCHECK2(lsapp->lsa_p_prefix, wordlen * 4);
+ ND_TCHECK2(lsapp->lsa_p_prefix, wordlen * 4);
memset(&prefix, 0, sizeof(prefix));
memcpy(&prefix, lsapp->lsa_p_prefix, wordlen * 4);
- printf("\n\t\t%s/%d", ip6addr_string(&prefix),
- lsapp->lsa_p_len);
+ ND_PRINT((ndo, "\n\t\t%s/%d", ip6addr_string(ndo, &prefix),
+ lsapp->lsa_p_len));
if (lsapp->lsa_p_opt) {
- printf(", Options [%s]",
+ ND_PRINT((ndo, ", Options [%s]",
bittok2str(ospf6_lsa_prefix_option_values,
- "none", lsapp->lsa_p_opt));
+ "none", lsapp->lsa_p_opt)));
}
- printf(", metric %u", EXTRACT_16BITS(&lsapp->lsa_p_metric));
- return sizeof(*lsapp) - 4 + wordlen * 4;
+ ND_PRINT((ndo, ", metric %u", EXTRACT_16BITS(&lsapp->lsa_p_metric)));
+ return sizeof(*lsapp) - IPV6_ADDR_LEN_BYTES + wordlen * 4;
trunc:
return -1;
@@ -200,7 +446,8 @@ trunc:
* Print a single link state advertisement. If truncated return 1, else 0.
*/
static int
-ospf6_print_lsa(register const struct lsa6 *lsap)
+ospf6_print_lsa(netdissect_options *ndo,
+ register const struct lsa6 *lsap, const u_char *dataend)
{
register const struct rlalink6 *rlp;
#if 0
@@ -214,17 +461,17 @@ ospf6_print_lsa(register const struct lsa6 *lsap)
register const struct llsa *llsap;
register const struct lsa6_prefix *lsapp;
#if 0
- register const u_int32_t *lp;
+ register const uint32_t *lp;
#endif
register u_int prefixes;
register int bytelen;
register u_int length, lsa_length;
- u_int32_t flags32;
- const u_int8_t *tptr;
+ uint32_t flags32;
+ const uint8_t *tptr;
- if (ospf6_print_lshdr(&lsap->ls_hdr))
+ if (ospf6_print_lshdr(ndo, &lsap->ls_hdr, dataend))
return (1);
- TCHECK(lsap->ls_hdr.ls_length);
+ ND_TCHECK(lsap->ls_hdr.ls_length);
length = EXTRACT_16BITS(&lsap->ls_hdr.ls_length);
/*
@@ -233,62 +480,62 @@ ospf6_print_lsa(register const struct lsa6 *lsap)
* If it does, find the length of what follows the
* header.
*/
- if (length < sizeof(struct lsa6_hdr))
+ if (length < sizeof(struct lsa6_hdr) || (u_char *)lsap + length > dataend)
return (1);
lsa_length = length - sizeof(struct lsa6_hdr);
- tptr = (u_int8_t *)lsap+sizeof(struct lsa6_hdr);
+ tptr = (uint8_t *)lsap+sizeof(struct lsa6_hdr);
switch (EXTRACT_16BITS(&lsap->ls_hdr.ls_type)) {
case LS_TYPE_ROUTER | LS_SCOPE_AREA:
if (lsa_length < sizeof (lsap->lsa_un.un_rla.rla_options))
return (1);
lsa_length -= sizeof (lsap->lsa_un.un_rla.rla_options);
- TCHECK(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)));
- printf(", RLA-Flags [%s]",
- bittok2str(ospf6_rla_flag_values, "none",
- lsap->lsa_un.un_rla.rla_flags));
+ ND_TCHECK(lsap->lsa_un.un_rla.rla_options);
+ ND_PRINT((ndo, "\n\t Options [%s]",
+ bittok2str(ospf6_option_values, "none",
+ EXTRACT_32BITS(&lsap->lsa_un.un_rla.rla_options))));
+ ND_PRINT((ndo, ", RLA-Flags [%s]",
+ bittok2str(ospf6_rla_flag_values, "none",
+ lsap->lsa_un.un_rla.rla_flags)));
rlp = lsap->lsa_un.un_rla.rla_link;
while (lsa_length != 0) {
if (lsa_length < sizeof (*rlp))
return (1);
lsa_length -= sizeof (*rlp);
- TCHECK(*rlp);
+ ND_TCHECK(*rlp);
switch (rlp->link_type) {
case RLA_TYPE_VIRTUAL:
- printf("\n\t Virtual Link: Neighbor Router-ID %s"
+ ND_PRINT((ndo, "\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));
+ ipaddr_string(ndo, &rlp->link_nrtid),
+ ipaddr_string(ndo, &rlp->link_nifid),
+ ipaddr_string(ndo, &rlp->link_ifid)));
break;
case RLA_TYPE_ROUTER:
- printf("\n\t Neighbor Router-ID %s"
+ ND_PRINT((ndo, "\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));
+ ipaddr_string(ndo, &rlp->link_nrtid),
+ ipaddr_string(ndo, &rlp->link_nifid),
+ ipaddr_string(ndo, &rlp->link_ifid)));
break;
case RLA_TYPE_TRANSIT:
- printf("\n\t Neighbor Network-ID %s"
+ ND_PRINT((ndo, "\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));
+ ipaddr_string(ndo, &rlp->link_nrtid),
+ ipaddr_string(ndo, &rlp->link_nifid),
+ ipaddr_string(ndo, &rlp->link_ifid)));
break;
default:
- printf("\n\t Unknown Router Links Type 0x%02x",
- rlp->link_type);
+ ND_PRINT((ndo, "\n\t Unknown Router Links Type 0x%02x",
+ rlp->link_type));
return (0);
}
- printf(", metric %d", EXTRACT_16BITS(&rlp->link_metric));
+ ND_PRINT((ndo, ", metric %d", EXTRACT_16BITS(&rlp->link_metric)));
rlp++;
}
break;
@@ -297,19 +544,19 @@ ospf6_print_lsa(register const struct lsa6 *lsap)
if (lsa_length < sizeof (lsap->lsa_un.un_nla.nla_options))
return (1);
lsa_length -= sizeof (lsap->lsa_un.un_nla.nla_options);
- TCHECK(lsap->lsa_un.un_nla.nla_options);
- printf("\n\t Options [%s]",
- bittok2str(ospf6_option_values, "none",
- EXTRACT_32BITS(&lsap->lsa_un.un_nla.nla_options)));
+ ND_TCHECK(lsap->lsa_un.un_nla.nla_options);
+ ND_PRINT((ndo, "\n\t Options [%s]",
+ bittok2str(ospf6_option_values, "none",
+ EXTRACT_32BITS(&lsap->lsa_un.un_nla.nla_options))));
- printf("\n\t Connected Routers:");
+ ND_PRINT((ndo, "\n\t Connected Routers:"));
ap = lsap->lsa_un.un_nla.nla_router;
while (lsa_length != 0) {
if (lsa_length < sizeof (*ap))
return (1);
lsa_length -= sizeof (*ap);
- TCHECK(*ap);
- printf("\n\t\t%s", ipaddr_string(ap));
+ ND_TCHECK(*ap);
+ ND_PRINT((ndo, "\n\t\t%s", ipaddr_string(ndo, ap)));
++ap;
}
break;
@@ -318,13 +565,13 @@ ospf6_print_lsa(register const struct lsa6 *lsap)
if (lsa_length < sizeof (lsap->lsa_un.un_inter_ap.inter_ap_metric))
return (1);
lsa_length -= sizeof (lsap->lsa_un.un_inter_ap.inter_ap_metric);
- TCHECK(lsap->lsa_un.un_inter_ap.inter_ap_metric);
- printf(", metric %u",
- EXTRACT_32BITS(&lsap->lsa_un.un_inter_ap.inter_ap_metric) & SLA_MASK_METRIC);
+ ND_TCHECK(lsap->lsa_un.un_inter_ap.inter_ap_metric);
+ ND_PRINT((ndo, ", metric %u",
+ EXTRACT_32BITS(&lsap->lsa_un.un_inter_ap.inter_ap_metric) & SLA_MASK_METRIC));
- tptr = (u_int8_t *)lsap->lsa_un.un_inter_ap.inter_ap_prefix;
+ tptr = (uint8_t *)lsap->lsa_un.un_inter_ap.inter_ap_prefix;
while (lsa_length != 0) {
- bytelen = ospf6_print_lsaprefix(tptr, lsa_length);
+ bytelen = ospf6_print_lsaprefix(ndo, tptr, lsa_length);
if (bytelen < 0)
goto trunc;
lsa_length -= bytelen;
@@ -336,17 +583,17 @@ ospf6_print_lsa(register const struct lsa6 *lsap)
if (lsa_length < sizeof (lsap->lsa_un.un_asla.asla_metric))
return (1);
lsa_length -= sizeof (lsap->lsa_un.un_asla.asla_metric);
- TCHECK(lsap->lsa_un.un_asla.asla_metric);
+ ND_TCHECK(lsap->lsa_un.un_asla.asla_metric);
flags32 = EXTRACT_32BITS(&lsap->lsa_un.un_asla.asla_metric);
- printf("\n\t Flags [%s]",
- bittok2str(ospf6_asla_flag_values, "none", flags32));
- printf(" metric %u",
+ ND_PRINT((ndo, "\n\t Flags [%s]",
+ bittok2str(ospf6_asla_flag_values, "none", flags32)));
+ ND_PRINT((ndo, " metric %u",
EXTRACT_32BITS(&lsap->lsa_un.un_asla.asla_metric) &
- ASLA_MASK_METRIC);
+ ASLA_MASK_METRIC));
- tptr = (u_int8_t *)lsap->lsa_un.un_asla.asla_prefix;
+ tptr = (uint8_t *)lsap->lsa_un.un_asla.asla_prefix;
lsapp = (struct lsa6_prefix *)tptr;
- bytelen = ospf6_print_lsaprefix(tptr, lsa_length);
+ bytelen = ospf6_print_lsaprefix(ndo, tptr, lsa_length);
if (bytelen < 0)
goto trunc;
lsa_length -= bytelen;
@@ -359,30 +606,30 @@ ospf6_print_lsa(register const struct lsa6 *lsap)
if (lsa_length < sizeof (*fwdaddr6))
return (1);
lsa_length -= sizeof (*fwdaddr6);
- TCHECK(*fwdaddr6);
- printf(" forward %s",
- ip6addr_string(fwdaddr6));
+ ND_TCHECK(*fwdaddr6);
+ ND_PRINT((ndo, " forward %s",
+ ip6addr_string(ndo, fwdaddr6)));
tptr += sizeof(*fwdaddr6);
}
if ((flags32 & ASLA_FLAG_ROUTETAG) != 0) {
- if (lsa_length < sizeof (u_int32_t))
+ if (lsa_length < sizeof (uint32_t))
return (1);
- lsa_length -= sizeof (u_int32_t);
- TCHECK(*(u_int32_t *)tptr);
- printf(" tag %s",
- ipaddr_string((u_int32_t *)tptr));
- tptr += sizeof(u_int32_t);
+ lsa_length -= sizeof (uint32_t);
+ ND_TCHECK(*(uint32_t *)tptr);
+ ND_PRINT((ndo, " tag %s",
+ ipaddr_string(ndo, (uint32_t *)tptr)));
+ tptr += sizeof(uint32_t);
}
if (lsapp->lsa_p_metric) {
- if (lsa_length < sizeof (u_int32_t))
+ if (lsa_length < sizeof (uint32_t))
return (1);
- lsa_length -= sizeof (u_int32_t);
- TCHECK(*(u_int32_t *)tptr);
- printf(" RefLSID: %s",
- ipaddr_string((u_int32_t *)tptr));
- tptr += sizeof(u_int32_t);
+ lsa_length -= sizeof (uint32_t);
+ ND_TCHECK(*(uint32_t *)tptr);
+ ND_PRINT((ndo, " RefLSID: %s",
+ ipaddr_string(ndo, (uint32_t *)tptr)));
+ tptr += sizeof(uint32_t);
}
break;
@@ -392,23 +639,23 @@ ospf6_print_lsa(register const struct lsa6 *lsap)
if (lsa_length < sizeof (llsap->llsa_priandopt))
return (1);
lsa_length -= sizeof (llsap->llsa_priandopt);
- TCHECK(llsap->llsa_priandopt);
- printf("\n\t Options [%s]",
- bittok2str(ospf6_option_values, "none",
- EXTRACT_32BITS(&llsap->llsa_options)));
+ ND_TCHECK(llsap->llsa_priandopt);
+ ND_PRINT((ndo, "\n\t Options [%s]",
+ bittok2str(ospf6_option_values, "none",
+ EXTRACT_32BITS(&llsap->llsa_options))));
if (lsa_length < sizeof (llsap->llsa_lladdr) + sizeof (llsap->llsa_nprefix))
return (1);
lsa_length -= sizeof (llsap->llsa_lladdr) + sizeof (llsap->llsa_nprefix);
prefixes = EXTRACT_32BITS(&llsap->llsa_nprefix);
- printf("\n\t Priority %d, Link-local address %s, Prefixes %d:",
+ ND_PRINT((ndo, "\n\t Priority %d, Link-local address %s, Prefixes %d:",
llsap->llsa_priority,
- ip6addr_string(&llsap->llsa_lladdr),
- prefixes);
+ ip6addr_string(ndo, &llsap->llsa_lladdr),
+ prefixes));
- tptr = (u_int8_t *)llsap->llsa_prefix;
+ tptr = (uint8_t *)llsap->llsa_prefix;
while (prefixes > 0) {
- bytelen = ospf6_print_lsaprefix(tptr, lsa_length);
+ bytelen = ospf6_print_lsaprefix(ndo, tptr, lsa_length);
if (bytelen < 0)
goto trunc;
prefixes--;
@@ -422,21 +669,21 @@ ospf6_print_lsa(register const struct lsa6 *lsap)
if (lsa_length < sizeof (lsap->lsa_un.un_intra_ap.intra_ap_rtid))
return (1);
lsa_length -= sizeof (lsap->lsa_un.un_intra_ap.intra_ap_rtid);
- TCHECK(lsap->lsa_un.un_intra_ap.intra_ap_rtid);
- ospf6_print_ls_type(
+ ND_TCHECK(lsap->lsa_un.un_intra_ap.intra_ap_rtid);
+ ospf6_print_ls_type(ndo,
EXTRACT_16BITS(&lsap->lsa_un.un_intra_ap.intra_ap_lstype),
&lsap->lsa_un.un_intra_ap.intra_ap_lsid);
if (lsa_length < sizeof (lsap->lsa_un.un_intra_ap.intra_ap_nprefix))
return (1);
lsa_length -= sizeof (lsap->lsa_un.un_intra_ap.intra_ap_nprefix);
- TCHECK(lsap->lsa_un.un_intra_ap.intra_ap_nprefix);
+ ND_TCHECK(lsap->lsa_un.un_intra_ap.intra_ap_nprefix);
prefixes = EXTRACT_16BITS(&lsap->lsa_un.un_intra_ap.intra_ap_nprefix);
- printf("\n\t Prefixes %d:", prefixes);
+ ND_PRINT((ndo, "\n\t Prefixes %d:", prefixes));
- tptr = (u_int8_t *)lsap->lsa_un.un_intra_ap.intra_ap_prefix;
+ tptr = (uint8_t *)lsap->lsa_un.un_intra_ap.intra_ap_prefix;
while (prefixes > 0) {
- bytelen = ospf6_print_lsaprefix(tptr, lsa_length);
+ bytelen = ospf6_print_lsaprefix(ndo, tptr, lsa_length);
if (bytelen < 0)
goto trunc;
prefixes--;
@@ -446,19 +693,19 @@ ospf6_print_lsa(register const struct lsa6 *lsap)
break;
case LS_TYPE_GRACE | LS_SCOPE_LINKLOCAL:
- if (ospf_print_grace_lsa(tptr, lsa_length) == -1) {
+ if (ospf_print_grace_lsa(ndo, tptr, lsa_length) == -1) {
return 1;
}
break;
case LS_TYPE_INTRA_ATE | LS_SCOPE_LINKLOCAL:
- if (ospf_print_te_lsa(tptr, lsa_length) == -1) {
+ if (ospf_print_te_lsa(ndo, tptr, lsa_length) == -1) {
return 1;
}
break;
default:
- if(!print_unknown_data(tptr,
+ if(!print_unknown_data(ndo,tptr,
"\n\t ",
lsa_length)) {
return (1);
@@ -472,8 +719,9 @@ trunc:
}
static int
-ospf6_decode_v3(register const struct ospf6hdr *op,
- register const u_char *dataend)
+ospf6_decode_v3(netdissect_options *ndo,
+ register const struct ospf6hdr *op,
+ register const u_char *dataend)
{
register const rtrid_t *ap;
register const struct lsr6 *lsrp;
@@ -483,66 +731,74 @@ ospf6_decode_v3(register const struct ospf6hdr *op,
switch (op->ospf6_type) {
- case OSPF_TYPE_HELLO:
- 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("\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(", Backup Designated Router %s",
- ipaddr_string(&op->ospf6_hello.hello_bdr));
- if (vflag) {
- printf("\n\t Neighbor List:");
- ap = op->ospf6_hello.hello_neighbor;
+ case OSPF_TYPE_HELLO: {
+ register const struct hello6 *hellop = (const struct hello6 *)((uint8_t *)op + OSPF6HDR_LEN);
+
+ ND_PRINT((ndo, "\n\tOptions [%s]",
+ bittok2str(ospf6_option_values, "none",
+ EXTRACT_32BITS(&hellop->hello_options))));
+
+ ND_TCHECK(hellop->hello_deadint);
+ ND_PRINT((ndo, "\n\t Hello Timer %us, Dead Timer %us, Interface-ID %s, Priority %u",
+ EXTRACT_16BITS(&hellop->hello_helloint),
+ EXTRACT_16BITS(&hellop->hello_deadint),
+ ipaddr_string(ndo, &hellop->hello_ifid),
+ hellop->hello_priority));
+
+ ND_TCHECK(hellop->hello_dr);
+ if (EXTRACT_32BITS(&hellop->hello_dr) != 0)
+ ND_PRINT((ndo, "\n\t Designated Router %s",
+ ipaddr_string(ndo, &hellop->hello_dr)));
+ ND_TCHECK(hellop->hello_bdr);
+ if (EXTRACT_32BITS(&hellop->hello_bdr) != 0)
+ ND_PRINT((ndo, ", Backup Designated Router %s",
+ ipaddr_string(ndo, &hellop->hello_bdr)));
+ if (ndo->ndo_vflag > 1) {
+ ND_PRINT((ndo, "\n\t Neighbor List:"));
+ ap = hellop->hello_neighbor;
while ((u_char *)ap < dataend) {
- TCHECK(*ap);
- printf("\n\t %s", ipaddr_string(ap));
+ ND_TCHECK(*ap);
+ ND_PRINT((ndo, "\n\t %s", ipaddr_string(ndo, ap)));
++ap;
}
}
break; /* HELLO */
+ }
- case OSPF_TYPE_DD:
- TCHECK(op->ospf6_db.db_options);
- printf("\n\tOptions [%s]",
- bittok2str(ospf6_option_values, "none",
- EXTRACT_32BITS(&op->ospf6_db.db_options)));
- TCHECK(op->ospf6_db.db_flags);
- printf(", DD Flags [%s]",
- bittok2str(ospf6_dd_flag_values,"none",op->ospf6_db.db_flags));
-
- 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;
- }
+ case OSPF_TYPE_DD: {
+ register const struct dd6 *ddp = (const struct dd6 *)((uint8_t *)op + OSPF6HDR_LEN);
+
+ ND_TCHECK(ddp->db_options);
+ ND_PRINT((ndo, "\n\tOptions [%s]",
+ bittok2str(ospf6_option_values, "none",
+ EXTRACT_32BITS(&ddp->db_options))));
+ ND_TCHECK(ddp->db_flags);
+ ND_PRINT((ndo, ", DD Flags [%s]",
+ bittok2str(ospf6_dd_flag_values,"none",ddp->db_flags)));
+
+ ND_TCHECK(ddp->db_seq);
+ ND_PRINT((ndo, ", MTU %u, DD-Sequence 0x%08x",
+ EXTRACT_16BITS(&ddp->db_mtu),
+ EXTRACT_32BITS(&ddp->db_seq)));
+ if (ndo->ndo_vflag > 1) {
+ /* Print all the LS adv's */
+ lshp = ddp->db_lshdr;
+ while ((u_char *)lshp < dataend) {
+ if (ospf6_print_lshdr(ndo, lshp++, dataend))
+ goto trunc;
+ }
+ }
break;
+ }
case OSPF_TYPE_LS_REQ:
- if (vflag) {
- lsrp = op->ospf6_lsr;
+ if (ndo->ndo_vflag > 1) {
+ lsrp = (const struct lsr6 *)((uint8_t *)op + OSPF6HDR_LEN);
while ((u_char *)lsrp < dataend) {
- TCHECK(*lsrp);
- printf("\n\t Advertising Router %s",
- ipaddr_string(&lsrp->ls_router));
- ospf6_print_ls_type(EXTRACT_16BITS(&lsrp->ls_type),
+ ND_TCHECK(*lsrp);
+ ND_PRINT((ndo, "\n\t Advertising Router %s",
+ ipaddr_string(ndo, &lsrp->ls_router)));
+ ospf6_print_ls_type(ndo, EXTRACT_16BITS(&lsrp->ls_type),
&lsrp->ls_stateid);
++lsrp;
}
@@ -550,12 +806,14 @@ ospf6_decode_v3(register const struct ospf6hdr *op,
break;
case OSPF_TYPE_LS_UPDATE:
- if (vflag) {
- lsap = op->ospf6_lsu.lsu_lsa;
- TCHECK(op->ospf6_lsu.lsu_count);
- i = EXTRACT_32BITS(&op->ospf6_lsu.lsu_count);
- while (i--) {
- if (ospf6_print_lsa(lsap))
+ if (ndo->ndo_vflag > 1) {
+ register const struct lsu6 *lsup = (const struct lsu6 *)((uint8_t *)op + OSPF6HDR_LEN);
+
+ ND_TCHECK(lsup->lsu_count);
+ i = EXTRACT_32BITS(&lsup->lsu_count);
+ lsap = lsup->lsu_lsa;
+ while ((u_char *)lsap < dataend && i--) {
+ if (ospf6_print_lsa(ndo, lsap, dataend))
goto trunc;
lsap = (struct lsa6 *)((u_char *)lsap +
EXTRACT_16BITS(&lsap->ls_hdr.ls_length));
@@ -563,13 +821,12 @@ ospf6_decode_v3(register const struct ospf6hdr *op,
}
break;
-
case OSPF_TYPE_LS_ACK:
- if (vflag) {
- lshp = op->ospf6_lsa.lsa_lshdr;
-
- while (!ospf6_print_lshdr(lshp)) {
- ++lshp;
+ if (ndo->ndo_vflag > 1) {
+ lshp = (const struct lsa6_hdr *)((uint8_t *)op + OSPF6HDR_LEN);
+ while ((u_char *)lshp < dataend) {
+ if (ospf6_print_lshdr(ndo, lshp++, dataend))
+ goto trunc;
}
}
break;
@@ -582,63 +839,171 @@ trunc:
return (1);
}
+/* RFC5613 Section 2.2 (w/o the TLVs) */
+static int
+ospf6_print_lls(netdissect_options *ndo,
+ const u_char *cp, const u_int len)
+{
+ uint16_t llsdatalen;
+
+ if (len == 0)
+ return 0;
+ if (len < OSPF_LLS_HDRLEN)
+ goto trunc;
+ /* Checksum */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, "\n\tLLS Checksum 0x%04x", EXTRACT_16BITS(cp)));
+ cp += 2;
+ /* LLS Data Length */
+ ND_TCHECK2(*cp, 2);
+ llsdatalen = EXTRACT_16BITS(cp);
+ ND_PRINT((ndo, ", Data Length %u", llsdatalen));
+ if (llsdatalen < OSPF_LLS_HDRLEN || llsdatalen > len)
+ goto trunc;
+ cp += 2;
+ /* LLS TLVs */
+ ND_TCHECK2(*cp, llsdatalen - OSPF_LLS_HDRLEN);
+ /* FIXME: code in print-ospf.c can be reused to decode the TLVs */
+
+ return llsdatalen;
+trunc:
+ return -1;
+}
+
+/* RFC6506 Section 4.1 */
+static int
+ospf6_decode_at(netdissect_options *ndo,
+ const u_char *cp, const u_int len)
+{
+ uint16_t authdatalen;
+
+ if (len == 0)
+ return 0;
+ if (len < OSPF6_AT_HDRLEN)
+ goto trunc;
+ /* Authentication Type */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, "\n\tAuthentication Type %s", tok2str(ospf6_auth_type_str, "unknown (0x%04x)", EXTRACT_16BITS(cp))));
+ cp += 2;
+ /* Auth Data Len */
+ ND_TCHECK2(*cp, 2);
+ authdatalen = EXTRACT_16BITS(cp);
+ ND_PRINT((ndo, ", Length %u", authdatalen));
+ if (authdatalen < OSPF6_AT_HDRLEN || authdatalen > len)
+ goto trunc;
+ cp += 2;
+ /* Reserved */
+ ND_TCHECK2(*cp, 2);
+ cp += 2;
+ /* Security Association ID */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, ", SAID %u", EXTRACT_16BITS(cp)));
+ cp += 2;
+ /* Cryptographic Sequence Number (High-Order 32 Bits) */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, ", CSN 0x%08x", EXTRACT_32BITS(cp)));
+ cp += 4;
+ /* Cryptographic Sequence Number (Low-Order 32 Bits) */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, ":%08x", EXTRACT_32BITS(cp)));
+ cp += 4;
+ /* Authentication Data */
+ ND_TCHECK2(*cp, authdatalen - OSPF6_AT_HDRLEN);
+ if (ndo->ndo_vflag > 1)
+ print_unknown_data(ndo,cp, "\n\tAuthentication Data ", authdatalen - OSPF6_AT_HDRLEN);
+ return 0;
+
+trunc:
+ return 1;
+}
+
+/* The trailing data may include LLS and/or AT data (in this specific order).
+ * LLS data may be present only in Hello and DBDesc packets with the L-bit set.
+ * AT data may be present in Hello and DBDesc packets with the AT-bit set or in
+ * any other packet type, thus decode the AT data regardless of the AT-bit.
+ */
+static int
+ospf6_decode_v3_trailer(netdissect_options *ndo,
+ const struct ospf6hdr *op, const u_char *cp, const unsigned len)
+{
+ int llslen = 0;
+ int lls_hello = 0;
+ int lls_dd = 0;
+
+ if (op->ospf6_type == OSPF_TYPE_HELLO) {
+ const struct hello6 *hellop = (const struct hello6 *)((uint8_t *)op + OSPF6HDR_LEN);
+ if (EXTRACT_32BITS(&hellop->hello_options) & OSPF6_OPTION_L)
+ lls_hello = 1;
+ } else if (op->ospf6_type == OSPF_TYPE_DD) {
+ const struct dd6 *ddp = (const struct dd6 *)((uint8_t *)op + OSPF6HDR_LEN);
+ if (EXTRACT_32BITS(&ddp->db_options) & OSPF6_OPTION_L)
+ lls_dd = 1;
+ }
+ if ((lls_hello || lls_dd) && (llslen = ospf6_print_lls(ndo, cp, len)) < 0)
+ goto trunc;
+ return ospf6_decode_at(ndo, cp + llslen, len - llslen);
+
+trunc:
+ return 1;
+}
+
void
-ospf6_print(register const u_char *bp, register u_int length)
+ospf6_print(netdissect_options *ndo,
+ register const u_char *bp, register u_int length)
{
register const struct ospf6hdr *op;
register const u_char *dataend;
register const char *cp;
+ uint16_t datalen;
op = (struct ospf6hdr *)bp;
/* 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(ospf6_type_values, "unknown LS-type", op->ospf6_type);
- printf("OSPFv%u, %s, length %d", op->ospf6_version, cp, length);
+ ND_TCHECK(op->ospf6_type);
+ cp = tok2str(ospf6_type_values, "unknown packet type (%u)", op->ospf6_type);
+ ND_PRINT((ndo, "OSPFv%u, %s, length %d", op->ospf6_version, cp, length));
if (*cp == 'u') {
return;
- }
+ }
- if(!vflag) { /* non verbose - so lets bail out here */
- return;
- }
+ if(!ndo->ndo_vflag) { /* non verbose - so lets bail out here */
+ return;
+ }
- TCHECK(op->ospf6_len);
- if (length != EXTRACT_16BITS(&op->ospf6_len)) {
- printf(" [len %d]", EXTRACT_16BITS(&op->ospf6_len));
+ /* OSPFv3 data always comes first and optional trailing data may follow. */
+ ND_TCHECK(op->ospf6_len);
+ datalen = EXTRACT_16BITS(&op->ospf6_len);
+ if (datalen > length) {
+ ND_PRINT((ndo, " [len %d]", datalen));
return;
}
- dataend = bp + length;
+ dataend = bp + datalen;
- /* Print the routerid if it is not the same as the source */
- TCHECK(op->ospf6_routerid);
- printf("\n\tRouter-ID %s", ipaddr_string(&op->ospf6_routerid));
+ ND_TCHECK(op->ospf6_routerid);
+ ND_PRINT((ndo, "\n\tRouter-ID %s", ipaddr_string(ndo, &op->ospf6_routerid)));
- TCHECK(op->ospf6_areaid);
- if (op->ospf6_areaid != 0)
- printf(", Area %s", ipaddr_string(&op->ospf6_areaid));
+ ND_TCHECK(op->ospf6_areaid);
+ if (EXTRACT_32BITS(&op->ospf6_areaid) != 0)
+ ND_PRINT((ndo, ", Area %s", ipaddr_string(ndo, &op->ospf6_areaid)));
else
- printf(", Backbone Area");
- TCHECK(op->ospf6_instanceid);
+ ND_PRINT((ndo, ", Backbone Area"));
+ ND_TCHECK(op->ospf6_instanceid);
if (op->ospf6_instanceid)
- printf(", Instance %u", op->ospf6_instanceid);
+ ND_PRINT((ndo, ", Instance %u", op->ospf6_instanceid));
/* Do rest according to version. */
switch (op->ospf6_version) {
case 3:
/* ospf version 3 */
- if (ospf6_decode_v3(op, dataend))
+ if (ospf6_decode_v3(ndo, op, dataend) ||
+ ospf6_decode_v3_trailer(ndo, op, dataend, length - datalen))
goto trunc;
break;
-
- default:
- printf(" ospf [version %d]", op->ospf6_version);
- break;
} /* end switch on version */
return;
trunc:
- fputs(tstr, stdout);
+ ND_PRINT((ndo, "%s", tstr));
}
diff --git a/contrib/tcpdump/print-otv.c b/contrib/tcpdump/print-otv.c
index cd5395742129..53a79dea5db1 100644
--- a/contrib/tcpdump/print-otv.c
+++ b/contrib/tcpdump/print-otv.c
@@ -13,20 +13,15 @@
* Original code by Francesco Fondelli (francesco dot fondelli, gmail dot com)
*/
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <stdlib.h>
-
#include "interface.h"
#include "extract.h"
-#include "addrtoname.h"
-
-#include "udp.h"
/*
* OTV header, draft-hasmit-otv-04
@@ -41,14 +36,14 @@
*/
void
-otv_print(const u_char *bp, u_int len)
+otv_print(netdissect_options *ndo, const u_char *bp, u_int len)
{
- u_int8_t flags;
- u_int32_t overlay_id;
- u_int32_t instance_id;
-
+ uint8_t flags;
+ uint32_t overlay_id;
+ uint32_t instance_id;
+
if (len < 8) {
- printf("[|OTV]");
+ ND_PRINT((ndo, "[|OTV]"));
return;
}
@@ -61,19 +56,10 @@ otv_print(const u_char *bp, u_int len)
instance_id = EXTRACT_24BITS(bp);
bp += 4;
- printf("OTV, ");
-
- fputs("flags [", stdout);
- if (flags & 0x08)
- fputs("I", stdout);
- else
- fputs(".", stdout);
- fputs("] ", stdout);
-
- printf("(0x%02x), ", flags);
- printf("overlay %u, ", overlay_id);
- printf("instance %u\n", instance_id);
+ ND_PRINT((ndo, "OTV, "));
+ ND_PRINT((ndo, "flags [%s] (0x%02x), ", flags & 0x08 ? "I" : ".", flags));
+ ND_PRINT((ndo, "overlay %u, ", overlay_id));
+ ND_PRINT((ndo, "instance %u\n", instance_id));
- ether_print(gndo, bp, len - 8, len - 8, NULL, NULL);
- return;
+ ether_print(ndo, bp, len - 8, len - 8, NULL, NULL);
}
diff --git a/contrib/tcpdump/print-pflog.c b/contrib/tcpdump/print-pflog.c
index ac325f4b0e63..4263a469b527 100644
--- a/contrib/tcpdump/print-pflog.c
+++ b/contrib/tcpdump/print-pflog.c
@@ -19,11 +19,7 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-pflog.c,v 1.16 2007-09-12 19:36:18 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -39,14 +35,12 @@ static const char rcsid[] _U_ =
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <pcap.h>
-
-#include "extract.h"
#include "interface.h"
-#include "addrtoname.h"
+#include "extract.h"
+
+static const char tstr[] = "[|pflog]";
-static struct tok pf_reasons[] = {
+static const struct tok pf_reasons[] = {
{ 0, "0(match)" },
{ 1, "1(bad-offset)" },
{ 2, "2(fragment)" },
@@ -65,7 +59,7 @@ static struct tok pf_reasons[] = {
{ 0, NULL }
};
-static struct tok pf_actions[] = {
+static const struct tok pf_actions[] = {
{ PF_PASS, "pass" },
{ PF_DROP, "block" },
{ PF_SCRUB, "scrub" },
@@ -79,7 +73,7 @@ static struct tok pf_actions[] = {
{ 0, NULL }
};
-static struct tok pf_directions[] = {
+static const struct tok pf_directions[] = {
{ PF_INOUT, "in/out" },
{ PF_IN, "in" },
{ PF_OUT, "out" },
@@ -91,58 +85,59 @@ static struct tok pf_directions[] = {
#define OPENBSD_AF_INET6 24
static void
-pflog_print(const struct pfloghdr *hdr)
+pflog_print(netdissect_options *ndo, const struct pfloghdr *hdr)
{
- u_int32_t rulenr, subrulenr;
+ uint32_t rulenr, subrulenr;
rulenr = EXTRACT_32BITS(&hdr->rulenr);
subrulenr = EXTRACT_32BITS(&hdr->subrulenr);
- if (subrulenr == (u_int32_t)-1)
- printf("rule %u/", rulenr);
+ if (subrulenr == (uint32_t)-1)
+ ND_PRINT((ndo, "rule %u/", rulenr));
else
- printf("rule %u.%s.%u/", rulenr, hdr->ruleset, subrulenr);
+ ND_PRINT((ndo, "rule %u.%s.%u/", rulenr, hdr->ruleset, subrulenr));
- printf("%s: %s %s on %s: ",
+ ND_PRINT((ndo, "%s: %s %s on %s: ",
tok2str(pf_reasons, "unkn(%u)", hdr->reason),
tok2str(pf_actions, "unkn(%u)", hdr->action),
tok2str(pf_directions, "unkn(%u)", hdr->dir),
- hdr->ifname);
+ hdr->ifname));
}
u_int
-pflog_if_print(const struct pcap_pkthdr *h, register const u_char *p)
+pflog_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
+ register const u_char *p)
{
u_int length = h->len;
u_int hdrlen;
u_int caplen = h->caplen;
const struct pfloghdr *hdr;
- u_int8_t af;
+ uint8_t af;
/* check length */
- if (caplen < sizeof(u_int8_t)) {
- printf("[|pflog]");
+ if (caplen < sizeof(uint8_t)) {
+ ND_PRINT((ndo, "%s", tstr));
return (caplen);
}
#define MIN_PFLOG_HDRLEN 45
hdr = (struct pfloghdr *)p;
if (hdr->length < MIN_PFLOG_HDRLEN) {
- printf("[pflog: invalid header length!]");
+ ND_PRINT((ndo, "[pflog: invalid header length!]"));
return (hdr->length); /* XXX: not really */
}
hdrlen = BPF_WORDALIGN(hdr->length);
if (caplen < hdrlen) {
- printf("[|pflog]");
+ ND_PRINT((ndo, "%s", tstr));
return (hdrlen); /* XXX: true? */
}
/* print what we know */
hdr = (struct pfloghdr *)p;
- TCHECK(*hdr);
- if (eflag)
- pflog_print(hdr);
-
+ ND_TCHECK(*hdr);
+ if (ndo->ndo_eflag)
+ pflog_print(ndo, hdr);
+
/* skip to the real packet */
af = hdr->af;
length -= hdrlen;
@@ -154,7 +149,7 @@ pflog_if_print(const struct pcap_pkthdr *h, register const u_char *p)
#if OPENBSD_AF_INET != AF_INET
case OPENBSD_AF_INET: /* XXX: read pcap files */
#endif
- ip_print(gndo, p, length);
+ ip_print(ndo, p, length);
break;
#ifdef INET6
@@ -162,21 +157,21 @@ pflog_if_print(const struct pcap_pkthdr *h, register const u_char *p)
#if OPENBSD_AF_INET6 != AF_INET6
case OPENBSD_AF_INET6: /* XXX: read pcap files */
#endif
- ip6_print(gndo, p, length);
+ ip6_print(ndo, p, length);
break;
#endif
default:
/* address family not handled, print raw packet */
- if (!eflag)
- pflog_print(hdr);
- if (!suppress_default_print)
- default_print(p, caplen);
+ if (!ndo->ndo_eflag)
+ pflog_print(ndo, hdr);
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
}
-
+
return (hdrlen);
trunc:
- printf("[|pflog]");
+ ND_PRINT((ndo, "%s", tstr));
return (hdrlen);
}
diff --git a/contrib/tcpdump/print-pfsync.c b/contrib/tcpdump/print-pfsync.c
index 7a6da89cba3c..ed7f8dd56a40 100644
--- a/contrib/tcpdump/print-pfsync.c
+++ b/contrib/tcpdump/print-pfsync.c
@@ -39,7 +39,6 @@
#include <net/if.h>
#include <net/pfvar.h> /* XXX */
#include <net/if_pfsync.h>
-#include <netinet/ip.h>
#define TCPSTATES
#include <netinet/tcp_fsm.h>
diff --git a/contrib/tcpdump/print-pgm.c b/contrib/tcpdump/print-pgm.c
index 2d4d7449c91b..6a8342539f47 100644
--- a/contrib/tcpdump/print-pgm.c
+++ b/contrib/tcpdump/print-pgm.c
@@ -13,21 +13,13 @@
* Original code by Andy Heffernan (ahh@juniper.net)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-pgm.c,v 1.5 2005-06-07 22:05:58 guy Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
#include "interface.h"
#include "extract.h"
#include "addrtoname.h"
@@ -37,67 +29,68 @@ static const char rcsid[] _U_ =
#include "ip6.h"
#endif
#include "ipproto.h"
+#include "af.h"
/*
* PGM header (RFC 3208)
*/
struct pgm_header {
- u_int16_t pgm_sport;
- u_int16_t pgm_dport;
- u_int8_t pgm_type;
- u_int8_t pgm_options;
- u_int16_t pgm_sum;
- u_int8_t pgm_gsid[6];
- u_int16_t pgm_length;
+ uint16_t pgm_sport;
+ uint16_t pgm_dport;
+ uint8_t pgm_type;
+ uint8_t pgm_options;
+ uint16_t pgm_sum;
+ uint8_t pgm_gsid[6];
+ uint16_t pgm_length;
};
struct pgm_spm {
- u_int32_t pgms_seq;
- u_int32_t pgms_trailseq;
- u_int32_t pgms_leadseq;
- u_int16_t pgms_nla_afi;
- u_int16_t pgms_reserved;
- /* ... u_int8_t pgms_nla[0]; */
+ uint32_t pgms_seq;
+ uint32_t pgms_trailseq;
+ uint32_t pgms_leadseq;
+ uint16_t pgms_nla_afi;
+ uint16_t pgms_reserved;
+ /* ... uint8_t pgms_nla[0]; */
/* ... options */
};
struct pgm_nak {
- u_int32_t pgmn_seq;
- u_int16_t pgmn_source_afi;
- u_int16_t pgmn_reserved;
- /* ... u_int8_t pgmn_source[0]; */
- /* ... u_int16_t pgmn_group_afi */
- /* ... u_int16_t pgmn_reserved2; */
- /* ... u_int8_t pgmn_group[0]; */
+ uint32_t pgmn_seq;
+ uint16_t pgmn_source_afi;
+ uint16_t pgmn_reserved;
+ /* ... uint8_t pgmn_source[0]; */
+ /* ... uint16_t pgmn_group_afi */
+ /* ... uint16_t pgmn_reserved2; */
+ /* ... uint8_t pgmn_group[0]; */
/* ... options */
};
struct pgm_ack {
- u_int32_t pgma_rx_max_seq;
- u_int32_t pgma_bitmap;
+ uint32_t pgma_rx_max_seq;
+ uint32_t pgma_bitmap;
/* ... options */
};
struct pgm_poll {
- u_int32_t pgmp_seq;
- u_int16_t pgmp_round;
- u_int16_t pgmp_reserved;
+ uint32_t pgmp_seq;
+ uint16_t pgmp_round;
+ uint16_t pgmp_reserved;
/* ... options */
};
struct pgm_polr {
- u_int32_t pgmp_seq;
- u_int16_t pgmp_round;
- u_int16_t pgmp_subtype;
- u_int16_t pgmp_nla_afi;
- u_int16_t pgmp_reserved;
- /* ... u_int8_t pgmp_nla[0]; */
+ uint32_t pgmp_seq;
+ uint16_t pgmp_round;
+ uint16_t pgmp_subtype;
+ uint16_t pgmp_nla_afi;
+ uint16_t pgmp_reserved;
+ /* ... uint8_t pgmp_nla[0]; */
/* ... options */
};
struct pgm_data {
- u_int32_t pgmd_seq;
- u_int32_t pgmd_trailseq;
+ uint32_t pgmd_seq;
+ uint32_t pgmd_trailseq;
/* ... options */
};
@@ -142,26 +135,22 @@ typedef enum _pgm_type {
#define PGM_OPT_PGMCC_DATA 0x12
#define PGM_OPT_PGMCC_FEEDBACK 0x13
-
+
#define PGM_OPT_MASK 0x7f
#define PGM_OPT_END 0x80 /* end of options marker */
#define PGM_MIN_OPT_LEN 4
-#ifndef AFI_IP
-#define AFI_IP 1
-#define AFI_IP6 2
-#endif
-
void
-pgm_print(register const u_char *bp, register u_int length,
- register const u_char *bp2)
+pgm_print(netdissect_options *ndo,
+ register const u_char *bp, register u_int length,
+ register const u_char *bp2)
{
register const struct pgm_header *pgm;
register const struct ip *ip;
register char ch;
- u_int16_t sport, dport;
+ uint16_t sport, dport;
int addr_size;
const void *nla;
int nla_af;
@@ -171,8 +160,8 @@ pgm_print(register const u_char *bp, register u_int length,
#else
char nla_buf[INET_ADDRSTRLEN];
#endif
- u_int8_t opt_type, opt_len, flags1, flags2;
- u_int32_t seq, opts_len, len, offset;
+ uint8_t opt_type, opt_len;
+ uint32_t seq, opts_len, len, offset;
pgm = (struct pgm_header *)bp;
ip = (struct ip *)bp2;
@@ -183,24 +172,24 @@ pgm_print(register const u_char *bp, register u_int length,
ip6 = NULL;
#else /* INET6 */
if (IP_V(ip) == 6) {
- (void)printf("Can't handle IPv6");
+ ND_PRINT((ndo, "Can't handle IPv6"));
return;
}
#endif /* INET6 */
ch = '\0';
- if (!TTEST(pgm->pgm_dport)) {
+ if (!ND_TTEST(pgm->pgm_dport)) {
#ifdef INET6
if (ip6) {
- (void)printf("%s > %s: [|pgm]",
- ip6addr_string(&ip6->ip6_src),
- ip6addr_string(&ip6->ip6_dst));
+ ND_PRINT((ndo, "%s > %s: [|pgm]",
+ ip6addr_string(ndo, &ip6->ip6_src),
+ ip6addr_string(ndo, &ip6->ip6_dst)));
return;
} else
#endif /* INET6 */
{
- (void)printf("%s > %s: [|pgm]",
- ipaddr_string(&ip->ip_src),
- ipaddr_string(&ip->ip_dst));
+ ND_PRINT((ndo, "%s > %s: [|pgm]",
+ ipaddr_string(ndo, &ip->ip_src),
+ ipaddr_string(ndo, &ip->ip_dst)));
return;
}
}
@@ -211,61 +200,58 @@ pgm_print(register const u_char *bp, register u_int length,
#ifdef INET6
if (ip6) {
if (ip6->ip6_nxt == IPPROTO_PGM) {
- (void)printf("%s.%s > %s.%s: ",
- ip6addr_string(&ip6->ip6_src),
+ ND_PRINT((ndo, "%s.%s > %s.%s: ",
+ ip6addr_string(ndo, &ip6->ip6_src),
tcpport_string(sport),
- ip6addr_string(&ip6->ip6_dst),
- tcpport_string(dport));
+ ip6addr_string(ndo, &ip6->ip6_dst),
+ tcpport_string(dport)));
} else {
- (void)printf("%s > %s: ",
- tcpport_string(sport), tcpport_string(dport));
+ ND_PRINT((ndo, "%s > %s: ",
+ tcpport_string(sport), tcpport_string(dport)));
}
} else
#endif /*INET6*/
{
if (ip->ip_p == IPPROTO_PGM) {
- (void)printf("%s.%s > %s.%s: ",
- ipaddr_string(&ip->ip_src),
+ ND_PRINT((ndo, "%s.%s > %s.%s: ",
+ ipaddr_string(ndo, &ip->ip_src),
tcpport_string(sport),
- ipaddr_string(&ip->ip_dst),
- tcpport_string(dport));
+ ipaddr_string(ndo, &ip->ip_dst),
+ tcpport_string(dport)));
} else {
- (void)printf("%s > %s: ",
- tcpport_string(sport), tcpport_string(dport));
+ ND_PRINT((ndo, "%s > %s: ",
+ tcpport_string(sport), tcpport_string(dport)));
}
}
- TCHECK(*pgm);
+ ND_TCHECK(*pgm);
- (void)printf("PGM, length %u", pgm->pgm_length);
+ ND_PRINT((ndo, "PGM, length %u", EXTRACT_16BITS(&pgm->pgm_length)));
- if (!vflag)
+ if (!ndo->ndo_vflag)
return;
- if (length > pgm->pgm_length)
- length = pgm->pgm_length;
-
- (void)printf(" 0x%02x%02x%02x%02x%02x%02x ",
+ ND_PRINT((ndo, " 0x%02x%02x%02x%02x%02x%02x ",
pgm->pgm_gsid[0],
pgm->pgm_gsid[1],
pgm->pgm_gsid[2],
pgm->pgm_gsid[3],
pgm->pgm_gsid[4],
- pgm->pgm_gsid[5]);
+ pgm->pgm_gsid[5]));
switch (pgm->pgm_type) {
case PGM_SPM: {
struct pgm_spm *spm;
spm = (struct pgm_spm *)(pgm + 1);
- TCHECK(*spm);
+ ND_TCHECK(*spm);
switch (EXTRACT_16BITS(&spm->pgms_nla_afi)) {
- case AFI_IP:
+ case AFNUM_INET:
addr_size = sizeof(struct in_addr);
nla_af = AF_INET;
break;
#ifdef INET6
- case AFI_IP6:
+ case AFNUM_INET6:
addr_size = sizeof(struct in6_addr);
nla_af = AF_INET6;
break;
@@ -275,16 +261,16 @@ pgm_print(register const u_char *bp, register u_int length,
break;
}
bp = (u_char *) (spm + 1);
- TCHECK2(*bp, addr_size);
+ ND_TCHECK2(*bp, addr_size);
nla = bp;
bp += addr_size;
inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf));
- (void)printf("SPM seq %u trail %u lead %u nla %s",
+ ND_PRINT((ndo, "SPM seq %u trail %u lead %u nla %s",
EXTRACT_32BITS(&spm->pgms_seq),
EXTRACT_32BITS(&spm->pgms_trailseq),
EXTRACT_32BITS(&spm->pgms_leadseq),
- nla_buf);
+ nla_buf));
break;
}
@@ -292,27 +278,27 @@ pgm_print(register const u_char *bp, register u_int length,
struct pgm_poll *poll;
poll = (struct pgm_poll *)(pgm + 1);
- TCHECK(*poll);
- (void)printf("POLL seq %u round %u",
+ ND_TCHECK(*poll);
+ ND_PRINT((ndo, "POLL seq %u round %u",
EXTRACT_32BITS(&poll->pgmp_seq),
- EXTRACT_16BITS(&poll->pgmp_round));
+ EXTRACT_16BITS(&poll->pgmp_round)));
bp = (u_char *) (poll + 1);
break;
}
case PGM_POLR: {
struct pgm_polr *polr;
- u_int32_t ivl, rnd, mask;
+ uint32_t ivl, rnd, mask;
polr = (struct pgm_polr *)(pgm + 1);
- TCHECK(*polr);
+ ND_TCHECK(*polr);
switch (EXTRACT_16BITS(&polr->pgmp_nla_afi)) {
- case AFI_IP:
+ case AFNUM_INET:
addr_size = sizeof(struct in_addr);
nla_af = AF_INET;
break;
#ifdef INET6
- case AFI_IP6:
+ case AFNUM_INET6:
addr_size = sizeof(struct in6_addr);
nla_af = AF_INET6;
break;
@@ -322,37 +308,37 @@ pgm_print(register const u_char *bp, register u_int length,
break;
}
bp = (u_char *) (polr + 1);
- TCHECK2(*bp, addr_size);
+ ND_TCHECK2(*bp, addr_size);
nla = bp;
bp += addr_size;
inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf));
- TCHECK2(*bp, sizeof(u_int32_t));
+ ND_TCHECK2(*bp, sizeof(uint32_t));
ivl = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
+ bp += sizeof(uint32_t);
- TCHECK2(*bp, sizeof(u_int32_t));
+ ND_TCHECK2(*bp, sizeof(uint32_t));
rnd = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
+ bp += sizeof(uint32_t);
- TCHECK2(*bp, sizeof(u_int32_t));
+ ND_TCHECK2(*bp, sizeof(uint32_t));
mask = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
+ bp += sizeof(uint32_t);
- (void)printf("POLR seq %u round %u nla %s ivl %u rnd 0x%08x "
+ ND_PRINT((ndo, "POLR seq %u round %u nla %s ivl %u rnd 0x%08x "
"mask 0x%08x", EXTRACT_32BITS(&polr->pgmp_seq),
- EXTRACT_16BITS(&polr->pgmp_round), nla_buf, ivl, rnd, mask);
+ EXTRACT_16BITS(&polr->pgmp_round), nla_buf, ivl, rnd, mask));
break;
}
case PGM_ODATA: {
struct pgm_data *odata;
odata = (struct pgm_data *)(pgm + 1);
- TCHECK(*odata);
- (void)printf("ODATA trail %u seq %u",
+ ND_TCHECK(*odata);
+ ND_PRINT((ndo, "ODATA trail %u seq %u",
EXTRACT_32BITS(&odata->pgmd_trailseq),
- EXTRACT_32BITS(&odata->pgmd_seq));
+ EXTRACT_32BITS(&odata->pgmd_seq)));
bp = (u_char *) (odata + 1);
break;
}
@@ -361,10 +347,10 @@ pgm_print(register const u_char *bp, register u_int length,
struct pgm_data *rdata;
rdata = (struct pgm_data *)(pgm + 1);
- TCHECK(*rdata);
- (void)printf("RDATA trail %u seq %u",
+ ND_TCHECK(*rdata);
+ ND_PRINT((ndo, "RDATA trail %u seq %u",
EXTRACT_32BITS(&rdata->pgmd_trailseq),
- EXTRACT_32BITS(&rdata->pgmd_seq));
+ EXTRACT_32BITS(&rdata->pgmd_seq)));
bp = (u_char *) (rdata + 1);
break;
}
@@ -382,19 +368,19 @@ pgm_print(register const u_char *bp, register u_int length,
#endif
nak = (struct pgm_nak *)(pgm + 1);
- TCHECK(*nak);
+ ND_TCHECK(*nak);
/*
* Skip past the source, saving info along the way
* and stopping if we don't have enough.
*/
switch (EXTRACT_16BITS(&nak->pgmn_source_afi)) {
- case AFI_IP:
+ case AFNUM_INET:
addr_size = sizeof(struct in_addr);
source_af = AF_INET;
break;
#ifdef INET6
- case AFI_IP6:
+ case AFNUM_INET6:
addr_size = sizeof(struct in6_addr);
source_af = AF_INET6;
break;
@@ -404,7 +390,7 @@ pgm_print(register const u_char *bp, register u_int length,
break;
}
bp = (u_char *) (nak + 1);
- TCHECK2(*bp, addr_size);
+ ND_TCHECK2(*bp, addr_size);
source = bp;
bp += addr_size;
@@ -413,12 +399,12 @@ pgm_print(register const u_char *bp, register u_int length,
* and stopping if we don't have enough.
*/
switch (EXTRACT_16BITS(bp)) {
- case AFI_IP:
+ case AFNUM_INET:
addr_size = sizeof(struct in_addr);
group_af = AF_INET;
break;
#ifdef INET6
- case AFI_IP6:
+ case AFNUM_INET6:
addr_size = sizeof(struct in6_addr);
group_af = AF_INET6;
break;
@@ -427,8 +413,8 @@ pgm_print(register const u_char *bp, register u_int length,
goto trunc;
break;
}
- bp += (2 * sizeof(u_int16_t));
- TCHECK2(*bp, addr_size);
+ bp += (2 * sizeof(uint16_t));
+ ND_TCHECK2(*bp, addr_size);
group = bp;
bp += addr_size;
@@ -439,19 +425,19 @@ pgm_print(register const u_char *bp, register u_int length,
inet_ntop(group_af, group, group_buf, sizeof(group_buf));
switch (pgm->pgm_type) {
case PGM_NAK:
- (void)printf("NAK ");
+ ND_PRINT((ndo, "NAK "));
break;
case PGM_NULLNAK:
- (void)printf("NNAK ");
+ ND_PRINT((ndo, "NNAK "));
break;
case PGM_NCF:
- (void)printf("NCF ");
+ ND_PRINT((ndo, "NCF "));
break;
default:
break;
}
- (void)printf("(%s -> %s), seq %u",
- source_buf, group_buf, EXTRACT_32BITS(&nak->pgmn_seq));
+ ND_PRINT((ndo, "(%s -> %s), seq %u",
+ source_buf, group_buf, EXTRACT_32BITS(&nak->pgmn_seq)));
break;
}
@@ -459,31 +445,31 @@ pgm_print(register const u_char *bp, register u_int length,
struct pgm_ack *ack;
ack = (struct pgm_ack *)(pgm + 1);
- TCHECK(*ack);
- (void)printf("ACK seq %u",
- EXTRACT_32BITS(&ack->pgma_rx_max_seq));
+ ND_TCHECK(*ack);
+ ND_PRINT((ndo, "ACK seq %u",
+ EXTRACT_32BITS(&ack->pgma_rx_max_seq)));
bp = (u_char *) (ack + 1);
break;
}
case PGM_SPMR:
- (void)printf("SPMR");
+ ND_PRINT((ndo, "SPMR"));
break;
default:
- (void)printf("UNKNOWN type %0x02x", pgm->pgm_type);
+ ND_PRINT((ndo, "UNKNOWN type 0x%02x", pgm->pgm_type));
break;
}
- if (pgm->pgm_options & PGM_OPT_BIT_PRESENT) {
+ if (pgm->pgm_options & PGM_OPT_BIT_PRESENT) {
/*
* make sure there's enough for the first option header
*/
- if (!TTEST2(*bp, PGM_MIN_OPT_LEN)) {
- (void)printf("[|OPT]");
+ if (!ND_TTEST2(*bp, PGM_MIN_OPT_LEN)) {
+ ND_PRINT((ndo, "[|OPT]"));
return;
- }
+ }
/*
* That option header MUST be an OPT_LENGTH option
@@ -491,143 +477,137 @@ pgm_print(register const u_char *bp, register u_int length,
*/
opt_type = *bp++;
if ((opt_type & PGM_OPT_MASK) != PGM_OPT_LENGTH) {
- (void)printf("[First option bad, should be PGM_OPT_LENGTH, is %u]", opt_type & PGM_OPT_MASK);
+ ND_PRINT((ndo, "[First option bad, should be PGM_OPT_LENGTH, is %u]", opt_type & PGM_OPT_MASK));
return;
}
opt_len = *bp++;
if (opt_len != 4) {
- (void)printf("[Bad OPT_LENGTH option, length %u != 4]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_LENGTH option, length %u != 4]", opt_len));
return;
}
opts_len = EXTRACT_16BITS(bp);
if (opts_len < 4) {
- (void)printf("[Bad total option length %u < 4]", opts_len);
+ ND_PRINT((ndo, "[Bad total option length %u < 4]", opts_len));
return;
}
- bp += sizeof(u_int16_t);
- (void)printf(" OPTS LEN %d", opts_len);
+ bp += sizeof(uint16_t);
+ ND_PRINT((ndo, " OPTS LEN %d", opts_len));
opts_len -= 4;
while (opts_len) {
if (opts_len < PGM_MIN_OPT_LEN) {
- (void)printf("[Total option length leaves no room for final option]");
+ ND_PRINT((ndo, "[Total option length leaves no room for final option]"));
return;
}
opt_type = *bp++;
opt_len = *bp++;
if (opt_len < PGM_MIN_OPT_LEN) {
- (void)printf("[Bad option, length %u < %u]", opt_len,
- PGM_MIN_OPT_LEN);
+ ND_PRINT((ndo, "[Bad option, length %u < %u]", opt_len,
+ PGM_MIN_OPT_LEN));
break;
}
if (opts_len < opt_len) {
- (void)printf("[Total option length leaves no room for final option]");
+ ND_PRINT((ndo, "[Total option length leaves no room for final option]"));
return;
}
- if (!TTEST2(*bp, opt_len - 2)) {
- (void)printf(" [|OPT]");
+ if (!ND_TTEST2(*bp, opt_len - 2)) {
+ ND_PRINT((ndo, " [|OPT]"));
return;
- }
+ }
switch (opt_type & PGM_OPT_MASK) {
case PGM_OPT_LENGTH:
if (opt_len != 4) {
- (void)printf("[Bad OPT_LENGTH option, length %u != 4]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_LENGTH option, length %u != 4]", opt_len));
return;
}
- (void)printf(" OPTS LEN (extra?) %d", EXTRACT_16BITS(bp));
- bp += sizeof(u_int16_t);
+ ND_PRINT((ndo, " OPTS LEN (extra?) %d", EXTRACT_16BITS(bp)));
+ bp += sizeof(uint16_t);
opts_len -= 4;
break;
case PGM_OPT_FRAGMENT:
if (opt_len != 16) {
- (void)printf("[Bad OPT_FRAGMENT option, length %u != 16]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_FRAGMENT option, length %u != 16]", opt_len));
return;
}
- flags1 = *bp++;
- flags2 = *bp++;
+ bp += 2;
seq = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
+ bp += sizeof(uint32_t);
offset = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
+ bp += sizeof(uint32_t);
len = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
- (void)printf(" FRAG seq %u off %u len %u", seq, offset, len);
+ bp += sizeof(uint32_t);
+ ND_PRINT((ndo, " FRAG seq %u off %u len %u", seq, offset, len));
opts_len -= 16;
break;
case PGM_OPT_NAK_LIST:
- flags1 = *bp++;
- flags2 = *bp++;
- opt_len -= sizeof(u_int32_t); /* option header */
- (void)printf(" NAK LIST");
+ bp += 2;
+ opt_len -= sizeof(uint32_t); /* option header */
+ ND_PRINT((ndo, " NAK LIST"));
while (opt_len) {
- if (opt_len < sizeof(u_int32_t)) {
- (void)printf("[Option length not a multiple of 4]");
+ if (opt_len < sizeof(uint32_t)) {
+ ND_PRINT((ndo, "[Option length not a multiple of 4]"));
return;
}
- TCHECK2(*bp, sizeof(u_int32_t));
- (void)printf(" %u", EXTRACT_32BITS(bp));
- bp += sizeof(u_int32_t);
- opt_len -= sizeof(u_int32_t);
- opts_len -= sizeof(u_int32_t);
+ ND_TCHECK2(*bp, sizeof(uint32_t));
+ ND_PRINT((ndo, " %u", EXTRACT_32BITS(bp)));
+ bp += sizeof(uint32_t);
+ opt_len -= sizeof(uint32_t);
+ opts_len -= sizeof(uint32_t);
}
break;
case PGM_OPT_JOIN:
if (opt_len != 8) {
- (void)printf("[Bad OPT_JOIN option, length %u != 8]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_JOIN option, length %u != 8]", opt_len));
return;
}
- flags1 = *bp++;
- flags2 = *bp++;
+ bp += 2;
seq = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
- (void)printf(" JOIN %u", seq);
+ bp += sizeof(uint32_t);
+ ND_PRINT((ndo, " JOIN %u", seq));
opts_len -= 8;
break;
case PGM_OPT_NAK_BO_IVL:
if (opt_len != 12) {
- (void)printf("[Bad OPT_NAK_BO_IVL option, length %u != 12]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_NAK_BO_IVL option, length %u != 12]", opt_len));
return;
}
- flags1 = *bp++;
- flags2 = *bp++;
+ bp += 2;
offset = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
+ bp += sizeof(uint32_t);
seq = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
- (void)printf(" BACKOFF ivl %u ivlseq %u", offset, seq);
+ bp += sizeof(uint32_t);
+ ND_PRINT((ndo, " BACKOFF ivl %u ivlseq %u", offset, seq));
opts_len -= 12;
break;
case PGM_OPT_NAK_BO_RNG:
if (opt_len != 12) {
- (void)printf("[Bad OPT_NAK_BO_RNG option, length %u != 12]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_NAK_BO_RNG option, length %u != 12]", opt_len));
return;
}
- flags1 = *bp++;
- flags2 = *bp++;
+ bp += 2;
offset = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
+ bp += sizeof(uint32_t);
seq = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
- (void)printf(" BACKOFF max %u min %u", offset, seq);
+ bp += sizeof(uint32_t);
+ ND_PRINT((ndo, " BACKOFF max %u min %u", offset, seq));
opts_len -= 12;
break;
case PGM_OPT_REDIRECT:
- flags1 = *bp++;
- flags2 = *bp++;
+ bp += 2;
switch (EXTRACT_16BITS(bp)) {
- case AFI_IP:
+ case AFNUM_INET:
addr_size = sizeof(struct in_addr);
nla_af = AF_INET;
break;
#ifdef INET6
- case AFI_IP6:
+ case AFNUM_INET6:
addr_size = sizeof(struct in6_addr);
nla_af = AF_INET6;
break;
@@ -636,138 +616,129 @@ pgm_print(register const u_char *bp, register u_int length,
goto trunc;
break;
}
- bp += (2 * sizeof(u_int16_t));
+ bp += (2 * sizeof(uint16_t));
if (opt_len != 4 + addr_size) {
- (void)printf("[Bad OPT_REDIRECT option, length %u != 4 + address size]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_REDIRECT option, length %u != 4 + address size]", opt_len));
return;
}
- TCHECK2(*bp, addr_size);
+ ND_TCHECK2(*bp, addr_size);
nla = bp;
bp += addr_size;
inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf));
- (void)printf(" REDIRECT %s", (char *)nla);
+ ND_PRINT((ndo, " REDIRECT %s", (char *)nla));
opts_len -= 4 + addr_size;
break;
case PGM_OPT_PARITY_PRM:
if (opt_len != 8) {
- (void)printf("[Bad OPT_PARITY_PRM option, length %u != 8]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_PARITY_PRM option, length %u != 8]", opt_len));
return;
}
- flags1 = *bp++;
- flags2 = *bp++;
+ bp += 2;
len = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
- (void)printf(" PARITY MAXTGS %u", len);
+ bp += sizeof(uint32_t);
+ ND_PRINT((ndo, " PARITY MAXTGS %u", len));
opts_len -= 8;
break;
case PGM_OPT_PARITY_GRP:
if (opt_len != 8) {
- (void)printf("[Bad OPT_PARITY_GRP option, length %u != 8]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_PARITY_GRP option, length %u != 8]", opt_len));
return;
}
- flags1 = *bp++;
- flags2 = *bp++;
+ bp += 2;
seq = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
- (void)printf(" PARITY GROUP %u", seq);
+ bp += sizeof(uint32_t);
+ ND_PRINT((ndo, " PARITY GROUP %u", seq));
opts_len -= 8;
break;
case PGM_OPT_CURR_TGSIZE:
if (opt_len != 8) {
- (void)printf("[Bad OPT_CURR_TGSIZE option, length %u != 8]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_CURR_TGSIZE option, length %u != 8]", opt_len));
return;
}
- flags1 = *bp++;
- flags2 = *bp++;
+ bp += 2;
len = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
- (void)printf(" PARITY ATGS %u", len);
+ bp += sizeof(uint32_t);
+ ND_PRINT((ndo, " PARITY ATGS %u", len));
opts_len -= 8;
break;
case PGM_OPT_NBR_UNREACH:
if (opt_len != 4) {
- (void)printf("[Bad OPT_NBR_UNREACH option, length %u != 4]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_NBR_UNREACH option, length %u != 4]", opt_len));
return;
}
- flags1 = *bp++;
- flags2 = *bp++;
- (void)printf(" NBR_UNREACH");
+ bp += 2;
+ ND_PRINT((ndo, " NBR_UNREACH"));
opts_len -= 4;
break;
case PGM_OPT_PATH_NLA:
- (void)printf(" PATH_NLA [%d]", opt_len);
+ ND_PRINT((ndo, " PATH_NLA [%d]", opt_len));
bp += opt_len;
opts_len -= opt_len;
break;
case PGM_OPT_SYN:
if (opt_len != 4) {
- (void)printf("[Bad OPT_SYN option, length %u != 4]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_SYN option, length %u != 4]", opt_len));
return;
}
- flags1 = *bp++;
- flags2 = *bp++;
- (void)printf(" SYN");
+ bp += 2;
+ ND_PRINT((ndo, " SYN"));
opts_len -= 4;
break;
case PGM_OPT_FIN:
if (opt_len != 4) {
- (void)printf("[Bad OPT_FIN option, length %u != 4]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_FIN option, length %u != 4]", opt_len));
return;
}
- flags1 = *bp++;
- flags2 = *bp++;
- (void)printf(" FIN");
+ bp += 2;
+ ND_PRINT((ndo, " FIN"));
opts_len -= 4;
break;
case PGM_OPT_RST:
if (opt_len != 4) {
- (void)printf("[Bad OPT_RST option, length %u != 4]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_RST option, length %u != 4]", opt_len));
return;
}
- flags1 = *bp++;
- flags2 = *bp++;
- (void)printf(" RST");
+ bp += 2;
+ ND_PRINT((ndo, " RST"));
opts_len -= 4;
break;
case PGM_OPT_CR:
- (void)printf(" CR");
+ ND_PRINT((ndo, " CR"));
bp += opt_len;
opts_len -= opt_len;
break;
case PGM_OPT_CRQST:
if (opt_len != 4) {
- (void)printf("[Bad OPT_CRQST option, length %u != 4]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_CRQST option, length %u != 4]", opt_len));
return;
}
- flags1 = *bp++;
- flags2 = *bp++;
- (void)printf(" CRQST");
+ bp += 2;
+ ND_PRINT((ndo, " CRQST"));
opts_len -= 4;
break;
case PGM_OPT_PGMCC_DATA:
- flags1 = *bp++;
- flags2 = *bp++;
+ bp += 2;
offset = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
+ bp += sizeof(uint32_t);
switch (EXTRACT_16BITS(bp)) {
- case AFI_IP:
+ case AFNUM_INET:
addr_size = sizeof(struct in_addr);
nla_af = AF_INET;
break;
#ifdef INET6
- case AFI_IP6:
+ case AFNUM_INET6:
addr_size = sizeof(struct in6_addr);
nla_af = AF_INET6;
break;
@@ -776,32 +747,31 @@ pgm_print(register const u_char *bp, register u_int length,
goto trunc;
break;
}
- bp += (2 * sizeof(u_int16_t));
+ bp += (2 * sizeof(uint16_t));
if (opt_len != 12 + addr_size) {
- (void)printf("[Bad OPT_PGMCC_DATA option, length %u != 12 + address size]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_PGMCC_DATA option, length %u != 12 + address size]", opt_len));
return;
}
- TCHECK2(*bp, addr_size);
+ ND_TCHECK2(*bp, addr_size);
nla = bp;
bp += addr_size;
inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf));
- (void)printf(" PGMCC DATA %u %s", offset, (char*)nla);
+ ND_PRINT((ndo, " PGMCC DATA %u %s", offset, (char*)nla));
opts_len -= 16;
break;
case PGM_OPT_PGMCC_FEEDBACK:
- flags1 = *bp++;
- flags2 = *bp++;
+ bp += 2;
offset = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
+ bp += sizeof(uint32_t);
switch (EXTRACT_16BITS(bp)) {
- case AFI_IP:
+ case AFNUM_INET:
addr_size = sizeof(struct in_addr);
nla_af = AF_INET;
break;
#ifdef INET6
- case AFI_IP6:
+ case AFNUM_INET6:
addr_size = sizeof(struct in6_addr);
nla_af = AF_INET6;
break;
@@ -810,22 +780,22 @@ pgm_print(register const u_char *bp, register u_int length,
goto trunc;
break;
}
- bp += (2 * sizeof(u_int16_t));
+ bp += (2 * sizeof(uint16_t));
if (opt_len != 12 + addr_size) {
- (void)printf("[Bad OPT_PGMCC_FEEDBACK option, length %u != 12 + address size]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_PGMCC_FEEDBACK option, length %u != 12 + address size]", opt_len));
return;
}
- TCHECK2(*bp, addr_size);
+ ND_TCHECK2(*bp, addr_size);
nla = bp;
bp += addr_size;
inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf));
- (void)printf(" PGMCC FEEDBACK %u %s", offset, (char*)nla);
+ ND_PRINT((ndo, " PGMCC FEEDBACK %u %s", offset, (char*)nla));
opts_len -= 16;
break;
default:
- (void)printf(" OPT_%02X [%d] ", opt_type, opt_len);
+ ND_PRINT((ndo, " OPT_%02X [%d] ", opt_type, opt_len));
bp += opt_len;
opts_len -= opt_len;
break;
@@ -836,12 +806,15 @@ pgm_print(register const u_char *bp, register u_int length,
}
}
- (void)printf(" [%u]", EXTRACT_16BITS(&pgm->pgm_length));
+ ND_PRINT((ndo, " [%u]", length));
+ if (ndo->ndo_packettype == PT_PGM_ZMTP1 &&
+ (pgm->pgm_type == PGM_ODATA || pgm->pgm_type == PGM_RDATA))
+ zmtp1_print_datagram(ndo, bp, EXTRACT_16BITS(&pgm->pgm_length));
return;
trunc:
- fputs("[|pgm]", stdout);
+ ND_PRINT((ndo, "[|pgm]"));
if (ch != '\0')
- putchar('>');
+ ND_PRINT((ndo, ">"));
}
diff --git a/contrib/tcpdump/print-pim.c b/contrib/tcpdump/print-pim.c
index c3915b468bbc..d6d6f10bb335 100644
--- a/contrib/tcpdump/print-pim.c
+++ b/contrib/tcpdump/print-pim.c
@@ -21,26 +21,40 @@
* $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.49 2006-02-13 01:31:35 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <stdlib.h>
-
#include "interface.h"
#include "addrtoname.h"
#include "extract.h"
#include "ip.h"
+#define PIMV1_TYPE_QUERY 0
+#define PIMV1_TYPE_REGISTER 1
+#define PIMV1_TYPE_REGISTER_STOP 2
+#define PIMV1_TYPE_JOIN_PRUNE 3
+#define PIMV1_TYPE_RP_REACHABILITY 4
+#define PIMV1_TYPE_ASSERT 5
+#define PIMV1_TYPE_GRAFT 6
+#define PIMV1_TYPE_GRAFT_ACK 7
+
+static const struct tok pimv1_type_str[] = {
+ { PIMV1_TYPE_QUERY, "Query" },
+ { PIMV1_TYPE_REGISTER, "Register" },
+ { PIMV1_TYPE_REGISTER_STOP, "Register-Stop" },
+ { PIMV1_TYPE_JOIN_PRUNE, "Join/Prune" },
+ { PIMV1_TYPE_RP_REACHABILITY, "RP-reachable" },
+ { PIMV1_TYPE_ASSERT, "Assert" },
+ { PIMV1_TYPE_GRAFT, "Graft" },
+ { PIMV1_TYPE_GRAFT_ACK, "Graft-ACK" },
+ { 0, NULL }
+};
+
#define PIMV2_TYPE_HELLO 0
#define PIMV2_TYPE_REGISTER 1
#define PIMV2_TYPE_REGISTER_STOP 2
@@ -51,8 +65,10 @@ static const char rcsid[] _U_ =
#define PIMV2_TYPE_GRAFT_ACK 7
#define PIMV2_TYPE_CANDIDATE_RP 8
#define PIMV2_TYPE_PRUNE_REFRESH 9
+#define PIMV2_TYPE_DF_ELECTION 10
+#define PIMV2_TYPE_ECMP_REDIRECT 11
-static struct tok pimv2_type_values[] = {
+static const struct tok pimv2_type_values[] = {
{ PIMV2_TYPE_HELLO, "Hello" },
{ PIMV2_TYPE_REGISTER, "Register" },
{ PIMV2_TYPE_REGISTER_STOP, "Register Stop" },
@@ -63,6 +79,8 @@ static struct tok pimv2_type_values[] = {
{ PIMV2_TYPE_GRAFT_ACK, "Graft Acknowledgement" },
{ PIMV2_TYPE_CANDIDATE_RP, "Candidate RP Advertisement" },
{ PIMV2_TYPE_PRUNE_REFRESH, "Prune Refresh" },
+ { PIMV2_TYPE_DF_ELECTION, "DF Election" },
+ { PIMV2_TYPE_ECMP_REDIRECT, "ECMP Redirect" },
{ 0, NULL}
};
@@ -76,7 +94,7 @@ static struct tok pimv2_type_values[] = {
#define PIMV2_HELLO_OPTION_ADDRESS_LIST 24
#define PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD 65001
-static struct tok pimv2_hello_option_values[] = {
+static const struct tok pimv2_hello_option_values[] = {
{ PIMV2_HELLO_OPTION_HOLDTIME, "Hold Time" },
{ PIMV2_HELLO_OPTION_LANPRUNEDELAY, "LAN Prune Delay" },
{ PIMV2_HELLO_OPTION_DR_PRIORITY_OLD, "DR Priority (Old)" },
@@ -93,11 +111,11 @@ static struct tok pimv2_hello_option_values[] = {
#define PIMV2_REGISTER_FLAG_BORDER 0x80000000
#define PIMV2_REGISTER_FLAG_NULL 0x40000000
-static struct tok pimv2_register_flag_values[] = {
+static const struct tok pimv2_register_flag_values[] = {
{ PIMV2_REGISTER_FLAG_BORDER, "Border" },
{ PIMV2_REGISTER_FLAG_NULL, "Null" },
{ 0, NULL}
-};
+};
/*
* XXX: We consider a case where IPv6 is not ready yet for portability,
@@ -105,7 +123,7 @@ static struct tok pimv2_register_flag_values[] = {
*/
struct pim {
- u_int8_t pim_typever;
+ uint8_t pim_typever;
/* upper 4bit: PIM version number; 2 for PIMv2 */
/* lower 4bit: the PIM message type, currently they are:
* Hello, Register, Register-Stop, Join/Prune,
@@ -118,54 +136,53 @@ struct pim {
u_short pim_cksum; /* IP style check sum */
};
-static void pimv2_print(register const u_char *bp, register u_int len, u_int cksum);
+static void pimv2_print(netdissect_options *, register const u_char *bp, register u_int len, u_int cksum);
static void
-pimv1_join_prune_print(register const u_char *bp, register u_int len)
+pimv1_join_prune_print(netdissect_options *ndo,
+ register const u_char *bp, register u_int len)
{
- int maddrlen, addrlen, ngroups, njoin, nprune;
+ int ngroups, njoin, nprune;
int njp;
/* If it's a single group and a single source, use 1-line output. */
- if (TTEST2(bp[0], 30) && bp[11] == 1 &&
+ if (ND_TTEST2(bp[0], 30) && bp[11] == 1 &&
((njoin = EXTRACT_16BITS(&bp[20])) + EXTRACT_16BITS(&bp[22])) == 1) {
int hold;
- (void)printf(" RPF %s ", ipaddr_string(bp));
+ ND_PRINT((ndo, " RPF %s ", ipaddr_string(ndo, bp)));
hold = EXTRACT_16BITS(&bp[6]);
if (hold != 180) {
- (void)printf("Hold ");
- relts_print(hold);
+ ND_PRINT((ndo, "Hold "));
+ relts_print(ndo, hold);
}
- (void)printf("%s (%s/%d, %s", njoin ? "Join" : "Prune",
- ipaddr_string(&bp[26]), bp[25] & 0x3f,
- ipaddr_string(&bp[12]));
+ ND_PRINT((ndo, "%s (%s/%d, %s", njoin ? "Join" : "Prune",
+ ipaddr_string(ndo, &bp[26]), bp[25] & 0x3f,
+ ipaddr_string(ndo, &bp[12])));
if (EXTRACT_32BITS(&bp[16]) != 0xffffffff)
- (void)printf("/%s", ipaddr_string(&bp[16]));
- (void)printf(") %s%s %s",
+ ND_PRINT((ndo, "/%s", ipaddr_string(ndo, &bp[16])));
+ ND_PRINT((ndo, ") %s%s %s",
(bp[24] & 0x01) ? "Sparse" : "Dense",
(bp[25] & 0x80) ? " WC" : "",
- (bp[25] & 0x40) ? "RP" : "SPT");
+ (bp[25] & 0x40) ? "RP" : "SPT"));
return;
}
- TCHECK2(bp[0], sizeof(struct in_addr));
- if (vflag > 1)
- (void)printf("\n");
- (void)printf(" Upstream Nbr: %s", ipaddr_string(bp));
- TCHECK2(bp[6], 2);
- if (vflag > 1)
- (void)printf("\n");
- (void)printf(" Hold time: ");
- relts_print(EXTRACT_16BITS(&bp[6]));
- if (vflag < 2)
+ ND_TCHECK2(bp[0], sizeof(struct in_addr));
+ if (ndo->ndo_vflag > 1)
+ ND_PRINT((ndo, "\n"));
+ ND_PRINT((ndo, " Upstream Nbr: %s", ipaddr_string(ndo, bp)));
+ ND_TCHECK2(bp[6], 2);
+ if (ndo->ndo_vflag > 1)
+ ND_PRINT((ndo, "\n"));
+ ND_PRINT((ndo, " Hold time: "));
+ relts_print(ndo, EXTRACT_16BITS(&bp[6]));
+ if (ndo->ndo_vflag < 2)
return;
bp += 8;
len -= 8;
- TCHECK2(bp[0], 4);
- maddrlen = bp[1];
- addrlen = bp[2];
+ ND_TCHECK2(bp[0], 4);
ngroups = bp[3];
bp += 4;
len -= 4;
@@ -174,15 +191,15 @@ pimv1_join_prune_print(register const u_char *bp, register u_int len)
* XXX - does the address have length "addrlen" and the
* mask length "maddrlen"?
*/
- TCHECK2(bp[0], sizeof(struct in_addr));
- (void)printf("\n\tGroup: %s", ipaddr_string(bp));
- TCHECK2(bp[4], sizeof(struct in_addr));
+ ND_TCHECK2(bp[0], sizeof(struct in_addr));
+ ND_PRINT((ndo, "\n\tGroup: %s", ipaddr_string(ndo, bp)));
+ ND_TCHECK2(bp[4], sizeof(struct in_addr));
if (EXTRACT_32BITS(&bp[4]) != 0xffffffff)
- (void)printf("/%s", ipaddr_string(&bp[4]));
- TCHECK2(bp[8], 4);
+ ND_PRINT((ndo, "/%s", ipaddr_string(ndo, &bp[4])));
+ ND_TCHECK2(bp[8], 4);
njoin = EXTRACT_16BITS(&bp[8]);
nprune = EXTRACT_16BITS(&bp[10]);
- (void)printf(" joined: %d pruned: %d", njoin, nprune);
+ ND_PRINT((ndo, " joined: %d pruned: %d", njoin, nprune));
bp += 12;
len -= 12;
for (njp = 0; njp < (njoin + nprune); njp++) {
@@ -192,127 +209,108 @@ pimv1_join_prune_print(register const u_char *bp, register u_int len)
type = "Join ";
else
type = "Prune";
- TCHECK2(bp[0], 6);
- (void)printf("\n\t%s %s%s%s%s/%d", type,
+ ND_TCHECK2(bp[0], 6);
+ ND_PRINT((ndo, "\n\t%s %s%s%s%s/%d", type,
(bp[0] & 0x01) ? "Sparse " : "Dense ",
(bp[1] & 0x80) ? "WC " : "",
(bp[1] & 0x40) ? "RP " : "SPT ",
- ipaddr_string(&bp[2]), bp[1] & 0x3f);
+ ipaddr_string(ndo, &bp[2]), bp[1] & 0x3f));
bp += 6;
len -= 6;
}
}
return;
trunc:
- (void)printf("[|pim]");
+ ND_PRINT((ndo, "[|pim]"));
return;
}
void
-pimv1_print(register const u_char *bp, register u_int len)
+pimv1_print(netdissect_options *ndo,
+ register const u_char *bp, register u_int len)
{
register const u_char *ep;
register u_char type;
- ep = (const u_char *)snapend;
+ ep = (const u_char *)ndo->ndo_snapend;
if (bp >= ep)
return;
- TCHECK(bp[1]);
+ ND_TCHECK(bp[1]);
type = bp[1];
+ ND_PRINT((ndo, " %s", tok2str(pimv1_type_str, "[type %u]", type)));
switch (type) {
- case 0:
- (void)printf(" Query");
- if (TTEST(bp[8])) {
+ case PIMV1_TYPE_QUERY:
+ if (ND_TTEST(bp[8])) {
switch (bp[8] >> 4) {
case 0:
- (void)printf(" Dense-mode");
+ ND_PRINT((ndo, " Dense-mode"));
break;
case 1:
- (void)printf(" Sparse-mode");
+ ND_PRINT((ndo, " Sparse-mode"));
break;
case 2:
- (void)printf(" Sparse-Dense-mode");
+ ND_PRINT((ndo, " Sparse-Dense-mode"));
break;
default:
- (void)printf(" mode-%d", bp[8] >> 4);
+ ND_PRINT((ndo, " mode-%d", bp[8] >> 4));
break;
}
}
- if (vflag) {
- TCHECK2(bp[10],2);
- (void)printf(" (Hold-time ");
- relts_print(EXTRACT_16BITS(&bp[10]));
- (void)printf(")");
+ if (ndo->ndo_vflag) {
+ ND_TCHECK2(bp[10],2);
+ ND_PRINT((ndo, " (Hold-time "));
+ relts_print(ndo, EXTRACT_16BITS(&bp[10]));
+ ND_PRINT((ndo, ")"));
}
break;
- case 1:
- (void)printf(" Register");
- TCHECK2(bp[8], 20); /* ip header */
- (void)printf(" for %s > %s", ipaddr_string(&bp[20]),
- ipaddr_string(&bp[24]));
+ case PIMV1_TYPE_REGISTER:
+ ND_TCHECK2(bp[8], 20); /* ip header */
+ ND_PRINT((ndo, " for %s > %s", ipaddr_string(ndo, &bp[20]),
+ ipaddr_string(ndo, &bp[24])));
break;
- case 2:
- (void)printf(" Register-Stop");
- TCHECK2(bp[12], sizeof(struct in_addr));
- (void)printf(" for %s > %s", ipaddr_string(&bp[8]),
- ipaddr_string(&bp[12]));
- break;
- case 3:
- (void)printf(" Join/Prune");
- if (vflag)
- pimv1_join_prune_print(&bp[8], len - 8);
+ case PIMV1_TYPE_REGISTER_STOP:
+ ND_TCHECK2(bp[12], sizeof(struct in_addr));
+ ND_PRINT((ndo, " for %s > %s", ipaddr_string(ndo, &bp[8]),
+ ipaddr_string(ndo, &bp[12])));
break;
- case 4:
- (void)printf(" RP-reachable");
- if (vflag) {
- TCHECK2(bp[22], 2);
- (void)printf(" group %s",
- ipaddr_string(&bp[8]));
+ case PIMV1_TYPE_RP_REACHABILITY:
+ if (ndo->ndo_vflag) {
+ ND_TCHECK2(bp[22], 2);
+ ND_PRINT((ndo, " group %s", ipaddr_string(ndo, &bp[8])));
if (EXTRACT_32BITS(&bp[12]) != 0xffffffff)
- (void)printf("/%s", ipaddr_string(&bp[12]));
- (void)printf(" RP %s hold ", ipaddr_string(&bp[16]));
- relts_print(EXTRACT_16BITS(&bp[22]));
+ ND_PRINT((ndo, "/%s", ipaddr_string(ndo, &bp[12])));
+ ND_PRINT((ndo, " RP %s hold ", ipaddr_string(ndo, &bp[16])));
+ relts_print(ndo, EXTRACT_16BITS(&bp[22]));
}
break;
- case 5:
- (void)printf(" Assert");
- TCHECK2(bp[16], sizeof(struct in_addr));
- (void)printf(" for %s > %s", ipaddr_string(&bp[16]),
- ipaddr_string(&bp[8]));
+ case PIMV1_TYPE_ASSERT:
+ ND_TCHECK2(bp[16], sizeof(struct in_addr));
+ ND_PRINT((ndo, " for %s > %s", ipaddr_string(ndo, &bp[16]),
+ ipaddr_string(ndo, &bp[8])));
if (EXTRACT_32BITS(&bp[12]) != 0xffffffff)
- (void)printf("/%s", ipaddr_string(&bp[12]));
- TCHECK2(bp[24], 4);
- (void)printf(" %s pref %d metric %d",
+ ND_PRINT((ndo, "/%s", ipaddr_string(ndo, &bp[12])));
+ ND_TCHECK2(bp[24], 4);
+ ND_PRINT((ndo, " %s pref %d metric %d",
(bp[20] & 0x80) ? "RP-tree" : "SPT",
EXTRACT_32BITS(&bp[20]) & 0x7fffffff,
- EXTRACT_32BITS(&bp[24]));
- break;
- case 6:
- (void)printf(" Graft");
- if (vflag)
- pimv1_join_prune_print(&bp[8], len - 8);
+ EXTRACT_32BITS(&bp[24])));
break;
- case 7:
- (void)printf(" Graft-ACK");
- if (vflag)
- pimv1_join_prune_print(&bp[8], len - 8);
- break;
- case 8:
- (void)printf(" Mode");
- break;
- default:
- (void)printf(" [type %d]", type);
+ case PIMV1_TYPE_JOIN_PRUNE:
+ case PIMV1_TYPE_GRAFT:
+ case PIMV1_TYPE_GRAFT_ACK:
+ if (ndo->ndo_vflag)
+ pimv1_join_prune_print(ndo, &bp[8], len - 8);
break;
}
if ((bp[4] >> 4) != 1)
- (void)printf(" [v%d]", bp[4] >> 4);
+ ND_PRINT((ndo, " [v%d]", bp[4] >> 4));
return;
trunc:
- (void)printf("[|pim]");
+ ND_PRINT((ndo, "[|pim]"));
return;
}
@@ -323,37 +321,38 @@ trunc:
* This implements version 1+, dated Sept 9, 1998.
*/
void
-cisco_autorp_print(register const u_char *bp, register u_int len)
+cisco_autorp_print(netdissect_options *ndo,
+ register const u_char *bp, register u_int len)
{
int type;
int numrps;
int hold;
- TCHECK(bp[0]);
- (void)printf(" auto-rp ");
+ ND_TCHECK(bp[0]);
+ ND_PRINT((ndo, " auto-rp "));
type = bp[0];
switch (type) {
case 0x11:
- (void)printf("candidate-advert");
+ ND_PRINT((ndo, "candidate-advert"));
break;
case 0x12:
- (void)printf("mapping");
+ ND_PRINT((ndo, "mapping"));
break;
default:
- (void)printf("type-0x%02x", type);
+ ND_PRINT((ndo, "type-0x%02x", type));
break;
}
- TCHECK(bp[1]);
+ ND_TCHECK(bp[1]);
numrps = bp[1];
- TCHECK2(bp[2], 2);
- (void)printf(" Hold ");
+ ND_TCHECK2(bp[2], 2);
+ ND_PRINT((ndo, " Hold "));
hold = EXTRACT_16BITS(&bp[2]);
if (hold)
- relts_print(EXTRACT_16BITS(&bp[2]));
+ relts_print(ndo, EXTRACT_16BITS(&bp[2]));
else
- printf("FOREVER");
+ ND_PRINT((ndo, "FOREVER"));
/* Next 4 bytes are reserved. */
@@ -376,34 +375,34 @@ cisco_autorp_print(register const u_char *bp, register u_int len)
int nentries;
char s;
- TCHECK2(bp[0], 4);
- (void)printf(" RP %s", ipaddr_string(bp));
- TCHECK(bp[4]);
+ ND_TCHECK2(bp[0], 4);
+ ND_PRINT((ndo, " RP %s", ipaddr_string(ndo, bp)));
+ ND_TCHECK(bp[4]);
switch (bp[4] & 0x3) {
- case 0: printf(" PIMv?");
+ case 0: ND_PRINT((ndo, " PIMv?"));
break;
- case 1: printf(" PIMv1");
+ case 1: ND_PRINT((ndo, " PIMv1"));
break;
- case 2: printf(" PIMv2");
+ case 2: ND_PRINT((ndo, " PIMv2"));
break;
- case 3: printf(" PIMv1+2");
+ case 3: ND_PRINT((ndo, " PIMv1+2"));
break;
}
if (bp[4] & 0xfc)
- (void)printf(" [rsvd=0x%02x]", bp[4] & 0xfc);
- TCHECK(bp[5]);
+ ND_PRINT((ndo, " [rsvd=0x%02x]", bp[4] & 0xfc));
+ ND_TCHECK(bp[5]);
nentries = bp[5];
bp += 6; len -= 6;
s = ' ';
for (; nentries; nentries--) {
- TCHECK2(bp[0], 6);
- (void)printf("%c%s%s/%d", s, bp[0] & 1 ? "!" : "",
- ipaddr_string(&bp[2]), bp[1]);
+ ND_TCHECK2(bp[0], 6);
+ ND_PRINT((ndo, "%c%s%s/%d", s, bp[0] & 1 ? "!" : "",
+ ipaddr_string(ndo, &bp[2]), bp[1]));
if (bp[0] & 0x02) {
- (void)printf(" bidir");
+ ND_PRINT((ndo, " bidir"));
}
if (bp[0] & 0xfc) {
- (void)printf("[rsvd=0x%02x]", bp[0] & 0xfc);
+ ND_PRINT((ndo, "[rsvd=0x%02x]", bp[0] & 0xfc));
}
s = ',';
bp += 6; len -= 6;
@@ -412,43 +411,44 @@ cisco_autorp_print(register const u_char *bp, register u_int len)
return;
trunc:
- (void)printf("[|autorp]");
+ ND_PRINT((ndo, "[|autorp]"));
return;
}
void
-pim_print(register const u_char *bp, register u_int len, u_int cksum)
+pim_print(netdissect_options *ndo,
+ register const u_char *bp, register u_int len, u_int cksum)
{
register const u_char *ep;
register struct pim *pim = (struct pim *)bp;
- ep = (const u_char *)snapend;
+ ep = (const u_char *)ndo->ndo_snapend;
if (bp >= ep)
return;
#ifdef notyet /* currently we see only version and type */
- TCHECK(pim->pim_rsv);
+ ND_TCHECK(pim->pim_rsv);
#endif
switch (PIM_VER(pim->pim_typever)) {
case 2:
- if (!vflag) {
- printf("PIMv%u, %s, length %u",
- PIM_VER(pim->pim_typever),
- tok2str(pimv2_type_values,"Unknown Type",PIM_TYPE(pim->pim_typever)),
- len);
- return;
- } else {
- printf("PIMv%u, length %u\n\t%s",
- PIM_VER(pim->pim_typever),
- len,
- tok2str(pimv2_type_values,"Unknown Type",PIM_TYPE(pim->pim_typever)));
- pimv2_print(bp, len, cksum);
- }
- break;
+ if (!ndo->ndo_vflag) {
+ ND_PRINT((ndo, "PIMv%u, %s, length %u",
+ PIM_VER(pim->pim_typever),
+ tok2str(pimv2_type_values,"Unknown Type",PIM_TYPE(pim->pim_typever)),
+ len));
+ return;
+ } else {
+ ND_PRINT((ndo, "PIMv%u, length %u\n\t%s",
+ PIM_VER(pim->pim_typever),
+ len,
+ tok2str(pimv2_type_values,"Unknown Type",PIM_TYPE(pim->pim_typever))));
+ pimv2_print(ndo, bp, len, cksum);
+ }
+ break;
default:
- printf("PIMv%u, length %u",
- PIM_VER(pim->pim_typever),
- len);
+ ND_PRINT((ndo, "PIMv%u, length %u",
+ PIM_VER(pim->pim_typever),
+ len));
break;
}
return;
@@ -521,15 +521,16 @@ enum pimv2_addrtype {
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
static int
-pimv2_addr_print(const u_char *bp, enum pimv2_addrtype at, int silent)
+pimv2_addr_print(netdissect_options *ndo,
+ const u_char *bp, enum pimv2_addrtype at, int silent)
{
int af;
int len, hdrlen;
- TCHECK(bp[0]);
+ ND_TCHECK(bp[0]);
if (pimv2_addr_len == 0) {
- TCHECK(bp[1]);
+ ND_TCHECK(bp[1]);
switch (bp[0]) {
case 1:
af = AF_INET;
@@ -568,49 +569,49 @@ pimv2_addr_print(const u_char *bp, enum pimv2_addrtype at, int silent)
bp += hdrlen;
switch (at) {
case pimv2_unicast:
- TCHECK2(bp[0], len);
+ ND_TCHECK2(bp[0], len);
if (af == AF_INET) {
if (!silent)
- (void)printf("%s", ipaddr_string(bp));
+ ND_PRINT((ndo, "%s", ipaddr_string(ndo, bp)));
}
#ifdef INET6
else if (af == AF_INET6) {
if (!silent)
- (void)printf("%s", ip6addr_string(bp));
+ ND_PRINT((ndo, "%s", ip6addr_string(ndo, bp)));
}
#endif
return hdrlen + len;
case pimv2_group:
case pimv2_source:
- TCHECK2(bp[0], len + 2);
+ ND_TCHECK2(bp[0], len + 2);
if (af == AF_INET) {
if (!silent) {
- (void)printf("%s", ipaddr_string(bp + 2));
+ ND_PRINT((ndo, "%s", ipaddr_string(ndo, bp + 2)));
if (bp[1] != 32)
- (void)printf("/%u", bp[1]);
+ ND_PRINT((ndo, "/%u", bp[1]));
}
}
#ifdef INET6
else if (af == AF_INET6) {
if (!silent) {
- (void)printf("%s", ip6addr_string(bp + 2));
+ ND_PRINT((ndo, "%s", ip6addr_string(ndo, bp + 2)));
if (bp[1] != 128)
- (void)printf("/%u", bp[1]);
+ ND_PRINT((ndo, "/%u", bp[1]));
}
}
#endif
if (bp[0] && !silent) {
if (at == pimv2_group) {
- (void)printf("(0x%02x)", bp[0]);
+ ND_PRINT((ndo, "(0x%02x)", bp[0]));
} else {
- (void)printf("(%s%s%s",
+ ND_PRINT((ndo, "(%s%s%s",
bp[0] & 0x04 ? "S" : "",
bp[0] & 0x02 ? "W" : "",
- bp[0] & 0x01 ? "R" : "");
+ bp[0] & 0x01 ? "R" : ""));
if (bp[0] & 0xf8) {
- (void) printf("+0x%02x", bp[0] & 0xf8);
+ ND_PRINT((ndo, "+0x%02x", bp[0] & 0xf8));
}
- (void)printf(")");
+ ND_PRINT((ndo, ")"));
}
}
return hdrlen + 2 + len;
@@ -622,110 +623,110 @@ trunc:
}
static void
-pimv2_print(register const u_char *bp, register u_int len, u_int cksum)
+pimv2_print(netdissect_options *ndo,
+ register const u_char *bp, register u_int len, u_int cksum)
{
register const u_char *ep;
register struct pim *pim = (struct pim *)bp;
int advance;
- ep = (const u_char *)snapend;
+ ep = (const u_char *)ndo->ndo_snapend;
if (bp >= ep)
return;
if (ep > bp + len)
ep = bp + len;
- TCHECK(pim->pim_rsv);
+ ND_TCHECK(pim->pim_rsv);
pimv2_addr_len = pim->pim_rsv;
if (pimv2_addr_len != 0)
- (void)printf(", RFC2117-encoding");
+ ND_PRINT((ndo, ", RFC2117-encoding"));
- printf(", cksum 0x%04x ", EXTRACT_16BITS(&pim->pim_cksum));
- if (EXTRACT_16BITS(&pim->pim_cksum) == 0) {
- printf("(unverified)");
- } else {
- printf("(%scorrect)", TTEST2(bp[0], len) && cksum ? "in" : "" );
- }
+ ND_PRINT((ndo, ", cksum 0x%04x ", EXTRACT_16BITS(&pim->pim_cksum)));
+ if (EXTRACT_16BITS(&pim->pim_cksum) == 0) {
+ ND_PRINT((ndo, "(unverified)"));
+ } else {
+ ND_PRINT((ndo, "(%scorrect)", ND_TTEST2(bp[0], len) && cksum ? "in" : "" ));
+ }
switch (PIM_TYPE(pim->pim_typever)) {
case PIMV2_TYPE_HELLO:
{
- u_int16_t otype, olen;
+ uint16_t otype, olen;
bp += 4;
while (bp < ep) {
- TCHECK2(bp[0], 4);
+ ND_TCHECK2(bp[0], 4);
otype = EXTRACT_16BITS(&bp[0]);
olen = EXTRACT_16BITS(&bp[2]);
- TCHECK2(bp[0], 4 + olen);
-
- printf("\n\t %s Option (%u), length %u, Value: ",
- tok2str( pimv2_hello_option_values,"Unknown",otype),
- otype,
- olen);
+ ND_TCHECK2(bp[0], 4 + olen);
+ ND_PRINT((ndo, "\n\t %s Option (%u), length %u, Value: ",
+ tok2str(pimv2_hello_option_values, "Unknown", otype),
+ otype,
+ olen));
bp += 4;
switch (otype) {
case PIMV2_HELLO_OPTION_HOLDTIME:
- relts_print(EXTRACT_16BITS(bp));
- break;
+ relts_print(ndo, EXTRACT_16BITS(bp));
+ break;
case PIMV2_HELLO_OPTION_LANPRUNEDELAY:
if (olen != 4) {
- (void)printf("ERROR: Option Length != 4 Bytes (%u)", olen);
+ ND_PRINT((ndo, "ERROR: Option Length != 4 Bytes (%u)", olen));
} else {
char t_bit;
- u_int16_t lan_delay, override_interval;
+ uint16_t lan_delay, override_interval;
lan_delay = EXTRACT_16BITS(bp);
override_interval = EXTRACT_16BITS(bp+2);
t_bit = (lan_delay & 0x8000)? 1 : 0;
lan_delay &= ~0x8000;
- (void)printf("\n\t T-bit=%d, LAN delay %dms, Override interval %dms",
- t_bit, lan_delay, override_interval);
+ ND_PRINT((ndo, "\n\t T-bit=%d, LAN delay %dms, Override interval %dms",
+ t_bit, lan_delay, override_interval));
}
break;
case PIMV2_HELLO_OPTION_DR_PRIORITY_OLD:
case PIMV2_HELLO_OPTION_DR_PRIORITY:
- switch (olen) {
- case 0:
- printf("Bi-Directional Capability (Old)");
- break;
- case 4:
- printf("%u", EXTRACT_32BITS(bp));
- break;
- default:
- printf("ERROR: Option Length != 4 Bytes (%u)", olen);
- break;
- }
- break;
+ switch (olen) {
+ case 0:
+ ND_PRINT((ndo, "Bi-Directional Capability (Old)"));
+ break;
+ case 4:
+ ND_PRINT((ndo, "%u", EXTRACT_32BITS(bp)));
+ break;
+ default:
+ ND_PRINT((ndo, "ERROR: Option Length != 4 Bytes (%u)", olen));
+ break;
+ }
+ break;
case PIMV2_HELLO_OPTION_GENID:
- (void)printf("0x%08x", EXTRACT_32BITS(bp));
+ ND_PRINT((ndo, "0x%08x", EXTRACT_32BITS(bp)));
break;
case PIMV2_HELLO_OPTION_REFRESH_CAP:
- (void)printf("v%d", *bp);
+ ND_PRINT((ndo, "v%d", *bp));
if (*(bp+1) != 0) {
- (void)printf(", interval ");
- relts_print(*(bp+1));
+ ND_PRINT((ndo, ", interval "));
+ relts_print(ndo, *(bp+1));
}
if (EXTRACT_16BITS(bp+2) != 0) {
- (void)printf(" ?0x%04x?", EXTRACT_16BITS(bp+2));
+ ND_PRINT((ndo, " ?0x%04x?", EXTRACT_16BITS(bp+2)));
}
break;
case PIMV2_HELLO_OPTION_BIDIR_CAP:
break;
- case PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD:
- case PIMV2_HELLO_OPTION_ADDRESS_LIST:
- if (vflag > 1) {
+ case PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD:
+ case PIMV2_HELLO_OPTION_ADDRESS_LIST:
+ if (ndo->ndo_vflag > 1) {
const u_char *ptr = bp;
while (ptr < (bp+olen)) {
int advance;
- printf("\n\t ");
- advance = pimv2_addr_print(ptr, pimv2_unicast, 0);
+ ND_PRINT((ndo, "\n\t "));
+ advance = pimv2_addr_print(ndo, ptr, pimv2_unicast, 0);
if (advance < 0) {
- printf("...");
+ ND_PRINT((ndo, "..."));
break;
}
ptr += advance;
@@ -733,13 +734,13 @@ pimv2_print(register const u_char *bp, register u_int len, u_int cksum)
}
break;
default:
- if (vflag <= 1)
- print_unknown_data(bp,"\n\t ",olen);
- break;
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo, bp, "\n\t ", olen);
+ break;
}
- /* do we want to see an additionally hexdump ? */
- if (vflag> 1)
- print_unknown_data(bp,"\n\t ",olen);
+ /* do we want to see an additionally hexdump ? */
+ if (ndo->ndo_vflag> 1)
+ print_unknown_data(ndo, bp, "\n\t ", olen);
bp += olen;
}
break;
@@ -749,35 +750,34 @@ pimv2_print(register const u_char *bp, register u_int len, u_int cksum)
{
struct ip *ip;
- if (!TTEST2(*(bp+4), PIMV2_REGISTER_FLAG_LEN))
- goto trunc;
+ ND_TCHECK2(*(bp + 4), PIMV2_REGISTER_FLAG_LEN);
- printf(", Flags [ %s ]\n\t",
- tok2str(pimv2_register_flag_values,
- "none",
- EXTRACT_32BITS(bp+4)));
+ ND_PRINT((ndo, ", Flags [ %s ]\n\t",
+ tok2str(pimv2_register_flag_values,
+ "none",
+ EXTRACT_32BITS(bp+4))));
bp += 8; len -= 8;
/* encapsulated multicast packet */
ip = (struct ip *)bp;
switch (IP_V(ip)) {
case 0: /* Null header */
- (void)printf("IP-Null-header %s > %s",
- ipaddr_string(&ip->ip_src),
- ipaddr_string(&ip->ip_dst));
+ ND_PRINT((ndo, "IP-Null-header %s > %s",
+ ipaddr_string(ndo, &ip->ip_src),
+ ipaddr_string(ndo, &ip->ip_dst)));
break;
case 4: /* IPv4 */
- ip_print(gndo, bp, len);
+ ip_print(ndo, bp, len);
break;
#ifdef INET6
case 6: /* IPv6 */
- ip6_print(gndo, bp, len);
+ ip6_print(ndo, bp, len);
break;
#endif
- default:
- (void)printf("IP ver %d", IP_V(ip));
- break;
+ default:
+ ND_PRINT((ndo, "IP ver %d", IP_V(ip)));
+ break;
}
break;
}
@@ -786,17 +786,17 @@ pimv2_print(register const u_char *bp, register u_int len, u_int cksum)
bp += 4; len -= 4;
if (bp >= ep)
break;
- (void)printf(" group=");
- if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) < 0) {
- (void)printf("...");
+ ND_PRINT((ndo, " group="));
+ if ((advance = pimv2_addr_print(ndo, bp, pimv2_group, 0)) < 0) {
+ ND_PRINT((ndo, "..."));
break;
}
bp += advance; len -= advance;
if (bp >= ep)
break;
- (void)printf(" source=");
- if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
- (void)printf("...");
+ ND_PRINT((ndo, " source="));
+ if ((advance = pimv2_addr_print(ndo, bp, pimv2_unicast, 0)) < 0) {
+ ND_PRINT((ndo, "..."));
break;
}
bp += advance; len -= advance;
@@ -843,19 +843,19 @@ pimv2_print(register const u_char *bp, register u_int len, u_int cksum)
*/
{
- u_int8_t ngroup;
- u_int16_t holdtime;
- u_int16_t njoin;
- u_int16_t nprune;
+ uint8_t ngroup;
+ uint16_t holdtime;
+ uint16_t njoin;
+ uint16_t nprune;
int i, j;
bp += 4; len -= 4;
if (PIM_TYPE(pim->pim_typever) != 7) { /*not for Graft-ACK*/
if (bp >= ep)
break;
- (void)printf(", upstream-neighbor: ");
- if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
- (void)printf("...");
+ ND_PRINT((ndo, ", upstream-neighbor: "));
+ if ((advance = pimv2_addr_print(ndo, bp, pimv2_unicast, 0)) < 0) {
+ ND_PRINT((ndo, "..."));
break;
}
bp += advance; len -= advance;
@@ -864,44 +864,44 @@ pimv2_print(register const u_char *bp, register u_int len, u_int cksum)
break;
ngroup = bp[1];
holdtime = EXTRACT_16BITS(&bp[2]);
- (void)printf("\n\t %u group(s)", ngroup);
+ ND_PRINT((ndo, "\n\t %u group(s)", ngroup));
if (PIM_TYPE(pim->pim_typever) != 7) { /*not for Graft-ACK*/
- (void)printf(", holdtime: ");
+ ND_PRINT((ndo, ", holdtime: "));
if (holdtime == 0xffff)
- (void)printf("infinite");
+ ND_PRINT((ndo, "infinite"));
else
- relts_print(holdtime);
+ relts_print(ndo, holdtime);
}
bp += 4; len -= 4;
for (i = 0; i < ngroup; i++) {
if (bp >= ep)
goto jp_done;
- (void)printf("\n\t group #%u: ", i+1);
- if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) < 0) {
- (void)printf("...)");
+ ND_PRINT((ndo, "\n\t group #%u: ", i+1));
+ if ((advance = pimv2_addr_print(ndo, bp, pimv2_group, 0)) < 0) {
+ ND_PRINT((ndo, "...)"));
goto jp_done;
}
bp += advance; len -= advance;
if (bp + 4 > ep) {
- (void)printf("...)");
+ ND_PRINT((ndo, "...)"));
goto jp_done;
}
njoin = EXTRACT_16BITS(&bp[0]);
nprune = EXTRACT_16BITS(&bp[2]);
- (void)printf(", joined sources: %u, pruned sources: %u", njoin,nprune);
+ ND_PRINT((ndo, ", joined sources: %u, pruned sources: %u", njoin, nprune));
bp += 4; len -= 4;
for (j = 0; j < njoin; j++) {
- (void)printf("\n\t joined source #%u: ",j+1);
- if ((advance = pimv2_addr_print(bp, pimv2_source, 0)) < 0) {
- (void)printf("...)");
+ ND_PRINT((ndo, "\n\t joined source #%u: ", j+1));
+ if ((advance = pimv2_addr_print(ndo, bp, pimv2_source, 0)) < 0) {
+ ND_PRINT((ndo, "...)"));
goto jp_done;
}
bp += advance; len -= advance;
}
for (j = 0; j < nprune; j++) {
- (void)printf("\n\t pruned source #%u: ",j+1);
- if ((advance = pimv2_addr_print(bp, pimv2_source, 0)) < 0) {
- (void)printf("...)");
+ ND_PRINT((ndo, "\n\t pruned source #%u: ", j+1));
+ if ((advance = pimv2_addr_print(ndo, bp, pimv2_source, 0)) < 0) {
+ ND_PRINT((ndo, "...)"));
goto jp_done;
}
bp += advance; len -= advance;
@@ -917,72 +917,72 @@ pimv2_print(register const u_char *bp, register u_int len, u_int cksum)
bp += 4;
/* Fragment Tag, Hash Mask len, and BSR-priority */
- if (bp + sizeof(u_int16_t) >= ep) break;
- (void)printf(" tag=%x", EXTRACT_16BITS(bp));
- bp += sizeof(u_int16_t);
+ if (bp + sizeof(uint16_t) >= ep) break;
+ ND_PRINT((ndo, " tag=%x", EXTRACT_16BITS(bp)));
+ bp += sizeof(uint16_t);
if (bp >= ep) break;
- (void)printf(" hashmlen=%d", bp[0]);
+ ND_PRINT((ndo, " hashmlen=%d", bp[0]));
if (bp + 1 >= ep) break;
- (void)printf(" BSRprio=%d", bp[1]);
+ ND_PRINT((ndo, " BSRprio=%d", bp[1]));
bp += 2;
/* Encoded-Unicast-BSR-Address */
if (bp >= ep) break;
- (void)printf(" BSR=");
- if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
- (void)printf("...");
+ ND_PRINT((ndo, " BSR="));
+ if ((advance = pimv2_addr_print(ndo, bp, pimv2_unicast, 0)) < 0) {
+ ND_PRINT((ndo, "..."));
break;
}
bp += advance;
for (i = 0; bp < ep; i++) {
/* Encoded-Group Address */
- (void)printf(" (group%d: ", i);
- if ((advance = pimv2_addr_print(bp, pimv2_group, 0))
+ ND_PRINT((ndo, " (group%d: ", i));
+ if ((advance = pimv2_addr_print(ndo, bp, pimv2_group, 0))
< 0) {
- (void)printf("...)");
+ ND_PRINT((ndo, "...)"));
goto bs_done;
}
bp += advance;
/* RP-Count, Frag RP-Cnt, and rsvd */
if (bp >= ep) {
- (void)printf("...)");
+ ND_PRINT((ndo, "...)"));
goto bs_done;
}
- (void)printf(" RPcnt=%d", bp[0]);
+ ND_PRINT((ndo, " RPcnt=%d", bp[0]));
if (bp + 1 >= ep) {
- (void)printf("...)");
+ ND_PRINT((ndo, "...)"));
goto bs_done;
}
- (void)printf(" FRPcnt=%d", frpcnt = bp[1]);
+ ND_PRINT((ndo, " FRPcnt=%d", frpcnt = bp[1]));
bp += 4;
for (j = 0; j < frpcnt && bp < ep; j++) {
/* each RP info */
- (void)printf(" RP%d=", j);
- if ((advance = pimv2_addr_print(bp,
+ ND_PRINT((ndo, " RP%d=", j));
+ if ((advance = pimv2_addr_print(ndo, bp,
pimv2_unicast,
0)) < 0) {
- (void)printf("...)");
+ ND_PRINT((ndo, "...)"));
goto bs_done;
}
bp += advance;
if (bp + 1 >= ep) {
- (void)printf("...)");
+ ND_PRINT((ndo, "...)"));
goto bs_done;
}
- (void)printf(",holdtime=");
- relts_print(EXTRACT_16BITS(bp));
+ ND_PRINT((ndo, ",holdtime="));
+ relts_print(ndo, EXTRACT_16BITS(bp));
if (bp + 2 >= ep) {
- (void)printf("...)");
+ ND_PRINT((ndo, "...)"));
goto bs_done;
}
- (void)printf(",prio=%d", bp[2]);
+ ND_PRINT((ndo, ",prio=%d", bp[2]));
bp += 4;
}
- (void)printf(")");
+ ND_PRINT((ndo, ")"));
}
bs_done:
break;
@@ -991,26 +991,26 @@ pimv2_print(register const u_char *bp, register u_int len, u_int cksum)
bp += 4; len -= 4;
if (bp >= ep)
break;
- (void)printf(" group=");
- if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) < 0) {
- (void)printf("...");
+ ND_PRINT((ndo, " group="));
+ if ((advance = pimv2_addr_print(ndo, bp, pimv2_group, 0)) < 0) {
+ ND_PRINT((ndo, "..."));
break;
}
bp += advance; len -= advance;
if (bp >= ep)
break;
- (void)printf(" src=");
- if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
- (void)printf("...");
+ ND_PRINT((ndo, " src="));
+ if ((advance = pimv2_addr_print(ndo, bp, pimv2_unicast, 0)) < 0) {
+ ND_PRINT((ndo, "..."));
break;
}
bp += advance; len -= advance;
if (bp + 8 > ep)
break;
if (bp[0] & 0x80)
- (void)printf(" RPT");
- (void)printf(" pref=%u", EXTRACT_32BITS(&bp[0]) & 0x7fffffff);
- (void)printf(" metric=%u", EXTRACT_32BITS(&bp[4]));
+ ND_PRINT((ndo, " RPT"));
+ ND_PRINT((ndo, " pref=%u", EXTRACT_32BITS(&bp[0]) & 0x7fffffff));
+ ND_PRINT((ndo, " metric=%u", EXTRACT_32BITS(&bp[4])));
break;
case PIMV2_TYPE_CANDIDATE_RP:
@@ -1020,30 +1020,30 @@ pimv2_print(register const u_char *bp, register u_int len, u_int cksum)
/* Prefix-Cnt, Priority, and Holdtime */
if (bp >= ep) break;
- (void)printf(" prefix-cnt=%d", bp[0]);
+ ND_PRINT((ndo, " prefix-cnt=%d", bp[0]));
pfxcnt = bp[0];
if (bp + 1 >= ep) break;
- (void)printf(" prio=%d", bp[1]);
+ ND_PRINT((ndo, " prio=%d", bp[1]));
if (bp + 3 >= ep) break;
- (void)printf(" holdtime=");
- relts_print(EXTRACT_16BITS(&bp[2]));
+ ND_PRINT((ndo, " holdtime="));
+ relts_print(ndo, EXTRACT_16BITS(&bp[2]));
bp += 4;
/* Encoded-Unicast-RP-Address */
if (bp >= ep) break;
- (void)printf(" RP=");
- if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
- (void)printf("...");
+ ND_PRINT((ndo, " RP="));
+ if ((advance = pimv2_addr_print(ndo, bp, pimv2_unicast, 0)) < 0) {
+ ND_PRINT((ndo, "..."));
break;
}
bp += advance;
/* Encoded-Group Addresses */
for (i = 0; i < pfxcnt && bp < ep; i++) {
- (void)printf(" Group%d=", i);
- if ((advance = pimv2_addr_print(bp, pimv2_group, 0))
+ ND_PRINT((ndo, " Group%d=", i));
+ if ((advance = pimv2_addr_print(ndo, bp, pimv2_group, 0))
< 0) {
- (void)printf("...");
+ ND_PRINT((ndo, "..."));
break;
}
bp += advance;
@@ -1052,39 +1052,39 @@ pimv2_print(register const u_char *bp, register u_int len, u_int cksum)
}
case PIMV2_TYPE_PRUNE_REFRESH:
- (void)printf(" src=");
- if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
- (void)printf("...");
+ ND_PRINT((ndo, " src="));
+ if ((advance = pimv2_addr_print(ndo, bp, pimv2_unicast, 0)) < 0) {
+ ND_PRINT((ndo, "..."));
break;
}
bp += advance;
- (void)printf(" grp=");
- if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) < 0) {
- (void)printf("...");
+ ND_PRINT((ndo, " grp="));
+ if ((advance = pimv2_addr_print(ndo, bp, pimv2_group, 0)) < 0) {
+ ND_PRINT((ndo, "..."));
break;
}
bp += advance;
- (void)printf(" forwarder=");
- if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
- (void)printf("...");
+ ND_PRINT((ndo, " forwarder="));
+ if ((advance = pimv2_addr_print(ndo, bp, pimv2_unicast, 0)) < 0) {
+ ND_PRINT((ndo, "..."));
break;
}
bp += advance;
- TCHECK2(bp[0], 2);
- (void)printf(" TUNR ");
- relts_print(EXTRACT_16BITS(bp));
+ ND_TCHECK2(bp[0], 2);
+ ND_PRINT((ndo, " TUNR "));
+ relts_print(ndo, EXTRACT_16BITS(bp));
break;
default:
- (void)printf(" [type %d]", PIM_TYPE(pim->pim_typever));
+ ND_PRINT((ndo, " [type %d]", PIM_TYPE(pim->pim_typever)));
break;
}
return;
trunc:
- (void)printf("[|pim]");
+ ND_PRINT((ndo, "[|pim]"));
}
/*
diff --git a/contrib/tcpdump/print-pktap.c b/contrib/tcpdump/print-pktap.c
new file mode 100644
index 000000000000..46a187de2f33
--- /dev/null
+++ b/contrib/tcpdump/print-pktap.c
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#define NETDISSECT_REWORKED
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tcpdump-stdinc.h>
+
+#include "interface.h"
+#include "extract.h"
+
+#ifdef DLT_PKTAP
+
+/*
+ * XXX - these are little-endian in the captures I've seen, but Apple
+ * no longer make any big-endian machines (Macs use x86, iOS machines
+ * use ARM and run it little-endian), so that might be by definition
+ * or they might be host-endian.
+ *
+ * If a big-endian PKTAP file ever shows up, and it comes from a
+ * big-endian machine, presumably these are host-endian, and we need
+ * to just fetch the fields directly in tcpdump but byte-swap them
+ * to host byte order in libpcap.
+ */
+typedef struct pktap_header {
+ uint32_t pkt_len; /* length of pktap header */
+ uint32_t pkt_rectype; /* type of record */
+ uint32_t pkt_dlt; /* DLT type of this packet */
+ char pkt_ifname[24]; /* interface name */
+ uint32_t pkt_flags;
+ uint32_t pkt_pfamily; /* "protocol family" */
+ uint32_t pkt_llhdrlen; /* link-layer header length? */
+ uint32_t pkt_lltrlrlen; /* link-layer trailer length? */
+ uint32_t pkt_pid; /* process ID */
+ char pkt_cmdname[20]; /* command name */
+ uint32_t pkt_svc_class; /* "service class" */
+ uint16_t pkt_iftype; /* "interface type" */
+ uint16_t pkt_ifunit; /* unit number of interface? */
+ uint32_t pkt_epid; /* "effective process ID" */
+ char pkt_ecmdname[20]; /* "effective command name" */
+} pktap_header_t;
+
+/*
+ * Record types.
+ */
+#define PKT_REC_NONE 0 /* nothing follows the header */
+#define PKT_REC_PACKET 1 /* a packet follows the header */
+
+static inline void
+pktap_header_print(netdissect_options *ndo, const u_char *bp, u_int length)
+{
+ const pktap_header_t *hdr;
+ uint32_t dlt, hdrlen;
+
+ hdr = (const pktap_header_t *)bp;
+
+ dlt = EXTRACT_LE_32BITS(&hdr->pkt_dlt);
+ hdrlen = EXTRACT_LE_32BITS(&hdr->pkt_len);
+ if (!ndo->ndo_qflag) {
+ ND_PRINT((ndo,", DLT %s (%d) len %d",
+ pcap_datalink_val_to_name(dlt), dlt, hdrlen));
+ } else {
+ ND_PRINT((ndo,", %s", pcap_datalink_val_to_name(dlt)));
+ }
+
+ ND_PRINT((ndo, ", length %u: ", length));
+}
+
+/*
+ * This is the top level routine of the printer. 'p' points
+ * to the ether header of the packet, 'h->ts' is the timestamp,
+ * 'h->len' is the length of the packet off the wire, and 'h->caplen'
+ * is the number of bytes actually captured.
+ */
+u_int
+pktap_if_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, const u_char *p)
+{
+ uint32_t dlt, hdrlen, rectype;
+ u_int caplen = h->caplen;
+ u_int length = h->len;
+ if_ndo_printer ndo_printer;
+ if_printer printer;
+ pktap_header_t *hdr;
+
+ if (caplen < sizeof(pktap_header_t) || length < sizeof(pktap_header_t)) {
+ ND_PRINT((ndo, "[|pktap]"));
+ return (0);
+ }
+ hdr = (pktap_header_t *)p;
+ dlt = EXTRACT_LE_32BITS(&hdr->pkt_dlt);
+ hdrlen = EXTRACT_LE_32BITS(&hdr->pkt_len);
+ if (hdrlen < sizeof(pktap_header_t)) {
+ /*
+ * Claimed header length < structure length.
+ * XXX - does this just mean some fields aren't
+ * being supplied, or is it truly an error (i.e.,
+ * is the length supplied so that the header can
+ * be expanded in the future)?
+ */
+ ND_PRINT((ndo, "[|pktap]"));
+ return (0);
+ }
+ if (caplen < hdrlen || length < hdrlen) {
+ ND_PRINT((ndo, "[|pktap]"));
+ return (hdrlen);
+ }
+
+ if (ndo->ndo_eflag)
+ pktap_header_print(ndo, p, length);
+
+ length -= hdrlen;
+ caplen -= hdrlen;
+ p += hdrlen;
+
+ rectype = EXTRACT_LE_32BITS(&hdr->pkt_rectype);
+ switch (rectype) {
+
+ case PKT_REC_NONE:
+ ND_PRINT((ndo, "no data"));
+ break;
+
+ case PKT_REC_PACKET:
+ if ((printer = lookup_printer(dlt)) != NULL) {
+ printer(h, p);
+ } else if ((ndo_printer = lookup_ndo_printer(dlt)) != NULL) {
+ ndo_printer(ndo, h, p);
+ } else {
+ if (!ndo->ndo_eflag)
+ pktap_header_print(ndo, (u_char *)hdr,
+ length + hdrlen);
+
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
+ }
+ break;
+ }
+
+ return (hdrlen);
+}
+
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
+
+#endif /* DLT_PKTAP */
diff --git a/contrib/tcpdump/print-ppi.c b/contrib/tcpdump/print-ppi.c
index 38873c84c5ae..2cff56c8144b 100644
--- a/contrib/tcpdump/print-ppi.c
+++ b/contrib/tcpdump/print-ppi.c
@@ -1,33 +1,38 @@
/*
* Oracle
*/
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <pcap.h>
-
-#include "netdissect.h"
#include "interface.h"
#include "extract.h"
-#include "ppi.h"
+
+typedef struct ppi_header {
+ uint8_t ppi_ver;
+ uint8_t ppi_flags;
+ uint16_t ppi_len;
+ uint32_t ppi_dlt;
+} ppi_header_t;
+
+#define PPI_HDRLEN 8
#ifdef DLT_PPI
static inline void
-ppi_header_print(struct netdissect_options *ndo, const u_char *bp, u_int length)
+ppi_header_print(netdissect_options *ndo, const u_char *bp, u_int length)
{
const ppi_header_t *hdr;
- u_int32_t dlt;
- u_int16_t len;
+ uint32_t dlt;
+ uint16_t len;
hdr = (const ppi_header_t *)bp;
- len = EXTRACT_16BITS(&hdr->ppi_len);
- dlt = EXTRACT_32BITS(&hdr->ppi_dlt);
+ len = EXTRACT_LE_16BITS(&hdr->ppi_len);
+ dlt = EXTRACT_LE_32BITS(&hdr->ppi_dlt);
if (!ndo->ndo_qflag) {
ND_PRINT((ndo,", V.%d DLT %s (%d) len %d", hdr->ppi_ver,
@@ -41,7 +46,7 @@ ppi_header_print(struct netdissect_options *ndo, const u_char *bp, u_int length)
}
static void
-ppi_print(struct netdissect_options *ndo,
+ppi_print(netdissect_options *ndo,
const struct pcap_pkthdr *h, const u_char *p)
{
if_ndo_printer ndo_printer;
@@ -49,14 +54,14 @@ ppi_print(struct netdissect_options *ndo,
ppi_header_t *hdr;
u_int caplen = h->caplen;
u_int length = h->len;
- u_int32_t dlt;
+ uint32_t dlt;
if (caplen < sizeof(ppi_header_t)) {
ND_PRINT((ndo, "[|ppi]"));
return;
}
hdr = (ppi_header_t *)p;
- dlt = EXTRACT_32BITS(&hdr->ppi_dlt);
+ dlt = EXTRACT_LE_32BITS(&hdr->ppi_dlt);
if (ndo->ndo_eflag)
ppi_header_print(ndo, p, length);
@@ -75,7 +80,7 @@ ppi_print(struct netdissect_options *ndo,
length + sizeof(ppi_header_t));
if (!ndo->ndo_suppress_default_print)
- ndo->ndo_default_print(ndo, p, caplen);
+ ND_DEFAULTPRINT(p, caplen);
}
}
@@ -86,7 +91,7 @@ ppi_print(struct netdissect_options *ndo,
* is the number of bytes actually captured.
*/
u_int
-ppi_if_print(struct netdissect_options *ndo,
+ppi_if_print(netdissect_options *ndo,
const struct pcap_pkthdr *h, const u_char *p)
{
ppi_print(ndo, h, p);
diff --git a/contrib/tcpdump/print-ppp.c b/contrib/tcpdump/print-ppp.c
index 4bae64aeb077..b1a4729d9357 100644
--- a/contrib/tcpdump/print-ppp.c
+++ b/contrib/tcpdump/print-ppp.c
@@ -31,11 +31,7 @@
* o BAP support
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.114 2005-12-05 11:35:58 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -47,8 +43,6 @@ static const char rcsid[] _U_ =
#include <net/if_ppp.h>
#endif
-#include <pcap.h>
-#include <stdio.h>
#include <stdlib.h>
#include "interface.h"
@@ -67,7 +61,7 @@ static const char rcsid[] _U_ =
/* Protocol Codes defined in ppp.h */
-struct tok ppptype2str[] = {
+static const struct tok ppptype2str[] = {
{ PPP_IP, "IP" },
{ PPP_OSI, "OSI" },
{ PPP_NS, "NS" },
@@ -109,6 +103,7 @@ struct tok ppptype2str[] = {
{ PPP_BACP, "BACP" },
{ PPP_BAP, "BAP" },
{ PPP_MPCP, "MLPPP-CP" },
+ { PPP_CCP, "CCP" },
{ 0, NULL }
};
@@ -131,7 +126,7 @@ struct tok ppptype2str[] = {
#define CPCODES_RESET_REQ 14 /* Reset-Request (CCP only) RFC1962 */
#define CPCODES_RESET_REP 15 /* Reset-Reply (CCP only) */
-struct tok cpcodes[] = {
+static const struct tok cpcodes[] = {
{CPCODES_VEXT, "Vendor-Extension"}, /* RFC2153 */
{CPCODES_CONF_REQ, "Conf-Request"},
{CPCODES_CONF_ACK, "Conf-Ack"},
@@ -245,7 +240,7 @@ static const char *lcpconfopts[] = {
/* 27-254 unassigned */
#define CCPOPT_RESV 255 /* RFC1962 */
-const struct tok ccpconfopts_values[] = {
+static const struct tok ccpconfopts_values[] = {
{ CCPOPT_OUI, "OUI" },
{ CCPOPT_PRED1, "Pred-1" },
{ CCPOPT_PRED2, "Pred-2" },
@@ -268,7 +263,7 @@ const struct tok ccpconfopts_values[] = {
#define BACPOPT_FPEER 1 /* RFC2125 */
-const struct tok bacconfopts_values[] = {
+static const struct tok bacconfopts_values[] = {
{ BACPOPT_FPEER, "Favored-Peer" },
{0, NULL}
};
@@ -286,7 +281,7 @@ const struct tok bacconfopts_values[] = {
#define IPCPOPT_SECDNS 131 /* RFC1877 */
#define IPCPOPT_SECNBNS 132 /* RFC1877 */
-struct tok ipcpopt_values[] = {
+static const struct tok ipcpopt_values[] = {
{ IPCPOPT_2ADDR, "IP-Addrs" },
{ IPCPOPT_IPCOMP, "IP-Comp" },
{ IPCPOPT_ADDR, "IP-Addr" },
@@ -301,13 +296,13 @@ struct tok ipcpopt_values[] = {
#define IPCPOPT_IPCOMP_HDRCOMP 0x61 /* rfc3544 */
#define IPCPOPT_IPCOMP_MINLEN 14
-struct tok ipcpopt_compproto_values[] = {
+static const struct tok ipcpopt_compproto_values[] = {
{ PPP_VJC, "VJ-Comp" },
{ IPCPOPT_IPCOMP_HDRCOMP, "IP Header Compression" },
{ 0, NULL }
};
-struct tok ipcpopt_compproto_subopt_values[] = {
+static const struct tok ipcpopt_compproto_subopt_values[] = {
{ 1, "RTP-Compression" },
{ 2, "Enhanced RTP-Compression" },
{ 0, NULL }
@@ -316,7 +311,7 @@ struct tok ipcpopt_compproto_subopt_values[] = {
/* IP6CP Config Options */
#define IP6CP_IFID 1
-struct tok ip6cpopt_values[] = {
+static const struct tok ip6cpopt_values[] = {
{ IP6CP_IFID, "Interface-ID" },
{ 0, NULL }
};
@@ -335,7 +330,7 @@ struct tok ip6cpopt_values[] = {
#define AUTHALG_MSCHAP1 128 /* RFC2433 */
#define AUTHALG_MSCHAP2 129 /* RFC2795 */
-struct tok authalg_values[] = {
+static const struct tok authalg_values[] = {
{ AUTHALG_CHAPMD5, "MD5" },
{ AUTHALG_MSCHAP1, "MS-CHAPv1" },
{ AUTHALG_MSCHAP2, "MS-CHAPv2" },
@@ -360,7 +355,7 @@ struct tok authalg_values[] = {
#define CALLBACK_X500 4 /* X.500 distinguished name */
#define CALLBACK_CBCP 6 /* Location is determined during CBCP nego */
-struct tok ppp_callback_values[] = {
+static const struct tok ppp_callback_values[] = {
{ CALLBACK_AUTH, "UserAuth" },
{ CALLBACK_DSTR, "DialString" },
{ CALLBACK_LID, "LocalID" },
@@ -377,7 +372,7 @@ struct tok ppp_callback_values[] = {
#define CHAP_SUCC 3
#define CHAP_FAIL 4
-struct tok chapcode_values[] = {
+static const struct tok chapcode_values[] = {
{ CHAP_CHAL, "Challenge" },
{ CHAP_RESP, "Response" },
{ CHAP_SUCC, "Success" },
@@ -391,7 +386,7 @@ struct tok chapcode_values[] = {
#define PAP_AACK 2
#define PAP_ANAK 3
-struct tok papcode_values[] = {
+static const struct tok papcode_values[] = {
{ PAP_AREQ, "Auth-Req" },
{ PAP_AACK, "Auth-ACK" },
{ PAP_ANAK, "Auth-NACK" },
@@ -408,73 +403,68 @@ struct tok papcode_values[] = {
#define BAP_CSIND 7
#define BAP_CSRES 8
-static void handle_ctrl_proto (u_int proto,const u_char *p, int length);
-static void handle_chap (const u_char *p, int length);
-static void handle_pap (const u_char *p, int length);
-static void handle_bap (const u_char *p, int length);
-static void handle_mlppp(const u_char *p, int length);
-static int print_lcp_config_options (const u_char *p, int);
-static int print_ipcp_config_options (const u_char *p, int);
-static int print_ip6cp_config_options (const u_char *p, int);
-static int print_ccp_config_options (const u_char *p, int);
-static int print_bacp_config_options (const u_char *p, int);
-static void handle_ppp (u_int proto, const u_char *p, int length);
-static void ppp_hdlc(const u_char *p, int length);
+static int print_lcp_config_options(netdissect_options *, const u_char *p, int);
+static int print_ipcp_config_options(netdissect_options *, const u_char *p, int);
+static int print_ip6cp_config_options(netdissect_options *, const u_char *p, int);
+static int print_ccp_config_options(netdissect_options *, const u_char *p, int);
+static int print_bacp_config_options(netdissect_options *, const u_char *p, int);
+static void handle_ppp(netdissect_options *, u_int proto, const u_char *p, int length);
/* generic Control Protocol (e.g. LCP, IPCP, CCP, etc.) handler */
static void
-handle_ctrl_proto(u_int proto, const u_char *pptr, int length)
+handle_ctrl_proto(netdissect_options *ndo,
+ u_int proto, const u_char *pptr, int length)
{
const char *typestr;
u_int code, len;
- int (*pfunc)(const u_char *, int);
+ int (*pfunc)(netdissect_options *, const u_char *, int);
int x, j;
const u_char *tptr;
tptr=pptr;
typestr = tok2str(ppptype2str, "unknown ctrl-proto (0x%04x)", proto);
- printf("%s, ",typestr);
+ ND_PRINT((ndo, "%s, ", typestr));
if (length < 4) /* FIXME weak boundary checking */
goto trunc;
- TCHECK2(*tptr, 2);
+ ND_TCHECK2(*tptr, 2);
code = *tptr++;
-
- printf("%s (0x%02x), id %u, length %u",
- tok2str(cpcodes, "Unknown Opcode",code),
- code,
- *tptr++, /* ID */
- length+2);
-
- if (!vflag)
- return;
+
+ ND_PRINT((ndo, "%s (0x%02x), id %u, length %u",
+ tok2str(cpcodes, "Unknown Opcode",code),
+ code,
+ *tptr++, /* ID */
+ length + 2));
+
+ if (!ndo->ndo_vflag)
+ return;
if (length <= 4)
return; /* there may be a NULL confreq etc. */
- TCHECK2(*tptr, 2);
+ ND_TCHECK2(*tptr, 2);
len = EXTRACT_16BITS(tptr);
tptr += 2;
- printf("\n\tencoded length %u (=Option(s) length %u)",len,len-4);
+ ND_PRINT((ndo, "\n\tencoded length %u (=Option(s) length %u)", len, len - 4));
- if (vflag>1)
- print_unknown_data(pptr-2,"\n\t",6);
+ if (ndo->ndo_vflag > 1)
+ print_unknown_data(ndo, pptr - 2, "\n\t", 6);
switch (code) {
case CPCODES_VEXT:
if (length < 11)
break;
- TCHECK2(*tptr, 4);
- printf("\n\t Magic-Num 0x%08x", EXTRACT_32BITS(tptr));
+ ND_TCHECK2(*tptr, 4);
+ ND_PRINT((ndo, "\n\t Magic-Num 0x%08x", EXTRACT_32BITS(tptr)));
tptr += 4;
- TCHECK2(*tptr, 3);
- printf(" Vendor: %s (%u)",
+ ND_TCHECK2(*tptr, 3);
+ ND_PRINT((ndo, " Vendor: %s (%u)",
tok2str(oui_values,"Unknown",EXTRACT_24BITS(tptr)),
- EXTRACT_24BITS(tptr));
+ EXTRACT_24BITS(tptr)));
/* XXX: need to decode Kind and Value(s)? */
break;
case CPCODES_CONF_REQ:
@@ -510,8 +500,8 @@ handle_ctrl_proto(u_int proto, const u_char *pptr, int length)
if (pfunc == NULL) /* catch the above null pointer if unknown CP */
break;
-
- if ((j = (*pfunc)(tptr, len)) == 0)
+
+ if ((j = (*pfunc)(ndo, tptr, len)) == 0)
break;
x -= j;
tptr += j;
@@ -528,209 +518,239 @@ handle_ctrl_proto(u_int proto, const u_char *pptr, int length)
case CPCODES_PROT_REJ:
if (length < 6)
break;
- TCHECK2(*tptr, 2);
- printf("\n\t Rejected %s Protocol (0x%04x)",
+ ND_TCHECK2(*tptr, 2);
+ ND_PRINT((ndo, "\n\t Rejected %s Protocol (0x%04x)",
tok2str(ppptype2str,"unknown", EXTRACT_16BITS(tptr)),
- EXTRACT_16BITS(tptr));
+ EXTRACT_16BITS(tptr)));
/* XXX: need to decode Rejected-Information? - hexdump for now */
- if (len > 6) {
- printf("\n\t Rejected Packet");
- print_unknown_data(tptr+2,"\n\t ",len-2);
- }
+ if (len > 6) {
+ ND_PRINT((ndo, "\n\t Rejected Packet"));
+ print_unknown_data(ndo, tptr + 2, "\n\t ", len - 2);
+ }
break;
case CPCODES_ECHO_REQ:
case CPCODES_ECHO_RPL:
case CPCODES_DISC_REQ:
if (length < 8)
break;
- TCHECK2(*tptr, 4);
- printf("\n\t Magic-Num 0x%08x", EXTRACT_32BITS(tptr));
+ ND_TCHECK2(*tptr, 4);
+ ND_PRINT((ndo, "\n\t Magic-Num 0x%08x", EXTRACT_32BITS(tptr)));
/* XXX: need to decode Data? - hexdump for now */
- if (len > 8) {
- printf("\n\t -----trailing data-----");
- TCHECK2(tptr[4], len-8);
- print_unknown_data(tptr+4,"\n\t ",len-8);
- }
+ if (len > 8) {
+ ND_PRINT((ndo, "\n\t -----trailing data-----"));
+ ND_TCHECK2(tptr[4], len - 8);
+ print_unknown_data(ndo, tptr + 4, "\n\t ", len - 8);
+ }
break;
case CPCODES_ID:
if (length < 8)
break;
- TCHECK2(*tptr, 4);
- printf("\n\t Magic-Num 0x%08x", EXTRACT_32BITS(tptr));
+ ND_TCHECK2(*tptr, 4);
+ ND_PRINT((ndo, "\n\t Magic-Num 0x%08x", EXTRACT_32BITS(tptr)));
/* RFC 1661 says this is intended to be human readable */
- if (len > 8) {
- printf("\n\t Message\n\t ");
- fn_printn(tptr+4,len-4,snapend);
- }
+ if (len > 8) {
+ ND_PRINT((ndo, "\n\t Message\n\t "));
+ if (fn_printn(ndo, tptr + 4, len - 4, ndo->ndo_snapend))
+ goto trunc;
+ }
break;
case CPCODES_TIME_REM:
if (length < 12)
break;
- TCHECK2(*tptr, 4);
- printf("\n\t Magic-Num 0x%08x", EXTRACT_32BITS(tptr));
- TCHECK2(*(tptr + 4), 4);
- printf(", Seconds-Remaining %us", EXTRACT_32BITS(tptr + 4));
+ ND_TCHECK2(*tptr, 4);
+ ND_PRINT((ndo, "\n\t Magic-Num 0x%08x", EXTRACT_32BITS(tptr)));
+ ND_TCHECK2(*(tptr + 4), 4);
+ ND_PRINT((ndo, ", Seconds-Remaining %us", EXTRACT_32BITS(tptr + 4)));
/* XXX: need to decode Message? */
break;
default:
- /* XXX this is dirty but we do not get the
- * original pointer passed to the begin
- * the PPP packet */
- if (vflag <= 1)
- print_unknown_data(pptr-2,"\n\t ",length+2);
+ /* XXX this is dirty but we do not get the
+ * original pointer passed to the begin
+ * the PPP packet */
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo, pptr - 2, "\n\t ", length + 2);
break;
}
return;
trunc:
- printf("[|%s]", typestr);
+ ND_PRINT((ndo, "[|%s]", typestr));
}
/* LCP config options */
static int
-print_lcp_config_options(const u_char *p, int length)
+print_lcp_config_options(netdissect_options *ndo,
+ const u_char *p, int length)
{
int len, opt;
if (length < 2)
return 0;
- TCHECK2(*p, 2);
+ ND_TCHECK2(*p, 2);
len = p[1];
opt = p[0];
if (length < len)
return 0;
if (len < 2) {
if ((opt >= LCPOPT_MIN) && (opt <= LCPOPT_MAX))
- printf("\n\t %s Option (0x%02x), length %u (bogus, should be >= 2)", lcpconfopts[opt],opt,len);
+ ND_PRINT((ndo, "\n\t %s Option (0x%02x), length %u (length bogus, should be >= 2)",
+ lcpconfopts[opt], opt, len));
else
- printf("\n\tunknown LCP option 0x%02x", opt);
+ ND_PRINT((ndo, "\n\tunknown LCP option 0x%02x", opt));
return 0;
}
if ((opt >= LCPOPT_MIN) && (opt <= LCPOPT_MAX))
- printf("\n\t %s Option (0x%02x), length %u: ", lcpconfopts[opt],opt,len);
+ ND_PRINT((ndo, "\n\t %s Option (0x%02x), length %u", lcpconfopts[opt], opt, len));
else {
- printf("\n\tunknown LCP option 0x%02x", opt);
+ ND_PRINT((ndo, "\n\tunknown LCP option 0x%02x", opt));
return len;
}
switch (opt) {
case LCPOPT_VEXT:
- if (len >= 6) {
- TCHECK2(*(p + 2), 3);
- printf("Vendor: %s (%u)",
- tok2str(oui_values,"Unknown",EXTRACT_24BITS(p+2)),
- EXTRACT_24BITS(p+2));
+ if (len < 6) {
+ ND_PRINT((ndo, " (length bogus, should be >= 6)"));
+ return len;
+ }
+ ND_TCHECK2(*(p + 2), 3);
+ ND_PRINT((ndo, ": Vendor: %s (%u)",
+ tok2str(oui_values,"Unknown",EXTRACT_24BITS(p+2)),
+ EXTRACT_24BITS(p + 2)));
#if 0
- TCHECK(p[5]);
- printf(", kind: 0x%02x", p[5]);
- printf(", Value: 0x")
- for (i = 0; i < len - 6; i++) {
- TCHECK(p[6 + i]);
- printf("%02x", p[6 + i]);
- }
-#endif
+ ND_TCHECK(p[5]);
+ ND_PRINT((ndo, ", kind: 0x%02x", p[5]));
+ ND_PRINT((ndo, ", Value: 0x"));
+ for (i = 0; i < len - 6; i++) {
+ ND_TCHECK(p[6 + i]);
+ ND_PRINT((ndo, "%02x", p[6 + i]));
}
+#endif
break;
case LCPOPT_MRU:
- if (len == 4) {
- TCHECK2(*(p + 2), 2);
- printf("%u", EXTRACT_16BITS(p + 2));
+ if (len != 4) {
+ ND_PRINT((ndo, " (length bogus, should be = 4)"));
+ return len;
}
+ ND_TCHECK2(*(p + 2), 2);
+ ND_PRINT((ndo, ": %u", EXTRACT_16BITS(p + 2)));
break;
case LCPOPT_ACCM:
- if (len == 6) {
- TCHECK2(*(p + 2), 4);
- printf("0x%08x", EXTRACT_32BITS(p + 2));
+ if (len != 6) {
+ ND_PRINT((ndo, " (length bogus, should be = 6)"));
+ return len;
}
+ ND_TCHECK2(*(p + 2), 4);
+ ND_PRINT((ndo, ": 0x%08x", EXTRACT_32BITS(p + 2)));
break;
case LCPOPT_AP:
- if (len >= 4) {
- TCHECK2(*(p + 2), 2);
- printf("%s", tok2str(ppptype2str,"Unknown Auth Proto (0x04x)",EXTRACT_16BITS(p+2)));
-
- switch (EXTRACT_16BITS(p+2)) {
- case PPP_CHAP:
- TCHECK(p[4]);
- printf(", %s",tok2str(authalg_values,"Unknown Auth Alg %u",p[4]));
+ if (len < 4) {
+ ND_PRINT((ndo, " (length bogus, should be >= 4)"));
+ return len;
+ }
+ ND_TCHECK2(*(p + 2), 2);
+ ND_PRINT((ndo, ": %s", tok2str(ppptype2str, "Unknown Auth Proto (0x04x)", EXTRACT_16BITS(p + 2))));
+
+ switch (EXTRACT_16BITS(p+2)) {
+ case PPP_CHAP:
+ ND_TCHECK(p[4]);
+ ND_PRINT((ndo, ", %s", tok2str(authalg_values, "Unknown Auth Alg %u", p[4])));
break;
- case PPP_PAP: /* fall through */
- case PPP_EAP:
- case PPP_SPAP:
- case PPP_SPAP_OLD:
+ case PPP_PAP: /* fall through */
+ case PPP_EAP:
+ case PPP_SPAP:
+ case PPP_SPAP_OLD:
break;
- default:
- print_unknown_data(p,"\n\t",len);
- }
+ default:
+ print_unknown_data(ndo, p, "\n\t", len);
}
break;
case LCPOPT_QP:
- if (len >= 4) {
- TCHECK2(*(p + 2), 2);
- if (EXTRACT_16BITS(p+2) == PPP_LQM)
- printf(" LQR");
- else
- printf(" unknown");
+ if (len < 4) {
+ ND_PRINT((ndo, " (length bogus, should be >= 4)"));
+ return 0;
}
+ ND_TCHECK2(*(p + 2), 2);
+ if (EXTRACT_16BITS(p+2) == PPP_LQM)
+ ND_PRINT((ndo, ": LQR"));
+ else
+ ND_PRINT((ndo, ": unknown"));
break;
case LCPOPT_MN:
- if (len == 6) {
- TCHECK2(*(p + 2), 4);
- printf("0x%08x", EXTRACT_32BITS(p + 2));
+ if (len != 6) {
+ ND_PRINT((ndo, " (length bogus, should be = 6)"));
+ return 0;
}
+ ND_TCHECK2(*(p + 2), 4);
+ ND_PRINT((ndo, ": 0x%08x", EXTRACT_32BITS(p + 2)));
break;
case LCPOPT_PFC:
break;
case LCPOPT_ACFC:
break;
case LCPOPT_LD:
- if (len == 4) {
- TCHECK2(*(p + 2), 2);
- printf("0x%04x", EXTRACT_16BITS(p + 2));
+ if (len != 4) {
+ ND_PRINT((ndo, " (length bogus, should be = 4)"));
+ return 0;
}
+ ND_TCHECK2(*(p + 2), 2);
+ ND_PRINT((ndo, ": 0x%04x", EXTRACT_16BITS(p + 2)));
break;
case LCPOPT_CBACK:
- if (len < 3)
- break;
- TCHECK(p[2]);
- printf("Callback Operation %s (%u)",
- tok2str(ppp_callback_values,"Unknown",p[2]),
- p[2]);
+ if (len < 3) {
+ ND_PRINT((ndo, " (length bogus, should be >= 3)"));
+ return 0;
+ }
+ ND_PRINT((ndo, ": "));
+ ND_TCHECK(p[2]);
+ ND_PRINT((ndo, ": Callback Operation %s (%u)",
+ tok2str(ppp_callback_values, "Unknown", p[2]),
+ p[2]));
break;
case LCPOPT_MLMRRU:
- if (len == 4) {
- TCHECK2(*(p + 2), 2);
- printf("%u", EXTRACT_16BITS(p + 2));
+ if (len != 4) {
+ ND_PRINT((ndo, " (length bogus, should be = 4)"));
+ return 0;
}
+ ND_TCHECK2(*(p + 2), 2);
+ ND_PRINT((ndo, ": %u", EXTRACT_16BITS(p + 2)));
break;
case LCPOPT_MLED:
- if (len < 3)
- break;
- TCHECK(p[2]);
+ if (len < 3) {
+ ND_PRINT((ndo, " (length bogus, should be >= 3)"));
+ return 0;
+ }
+ ND_TCHECK(p[2]);
switch (p[2]) { /* class */
case MEDCLASS_NULL:
- printf("Null");
+ ND_PRINT((ndo, ": Null"));
break;
case MEDCLASS_LOCAL:
- printf("Local"); /* XXX */
+ ND_PRINT((ndo, ": Local")); /* XXX */
break;
case MEDCLASS_IPV4:
- if (len != 7)
- break;
- TCHECK2(*(p + 3), 4);
- printf("IPv4 %s", ipaddr_string(p + 3));
+ if (len != 7) {
+ ND_PRINT((ndo, " (length bogus, should be = 7)"));
+ return 0;
+ }
+ ND_TCHECK2(*(p + 3), 4);
+ ND_PRINT((ndo, ": IPv4 %s", ipaddr_string(ndo, p + 3)));
break;
case MEDCLASS_MAC:
- if (len != 9)
- break;
- TCHECK(p[8]);
- printf("MAC %02x:%02x:%02x:%02x:%02x:%02x",
- p[3], p[4], p[5], p[6], p[7], p[8]);
+ if (len != 9) {
+ ND_PRINT((ndo, " (length bogus, should be = 9)"));
+ return 0;
+ }
+ ND_TCHECK2(*(p + 3), 6);
+ ND_PRINT((ndo, ": MAC %s", etheraddr_string(ndo, p + 3)));
break;
case MEDCLASS_MNB:
- printf("Magic-Num-Block"); /* XXX */
+ ND_PRINT((ndo, ": Magic-Num-Block")); /* XXX */
break;
case MEDCLASS_PSNDN:
- printf("PSNDN"); /* XXX */
+ ND_PRINT((ndo, ": PSNDN")); /* XXX */
+ break;
+ default:
+ ND_PRINT((ndo, ": Unknown class %u", p[2]));
break;
}
break;
@@ -758,46 +778,50 @@ print_lcp_config_options(const u_char *p, int length)
case LCPOPT_PPPMUX:
break;
#endif
- default:
- if(vflag<2)
- print_unknown_data(&p[2],"\n\t ",len-2);
- break;
+ default:
+ /*
+ * Unknown option; dump it as raw bytes now if we're
+ * not going to do so below.
+ */
+ if (ndo->ndo_vflag < 2)
+ print_unknown_data(ndo, &p[2], "\n\t ", len - 2);
+ break;
}
-
- if (vflag>1)
- print_unknown_data(&p[2],"\n\t ",len-2); /* exclude TLV header */
+
+ if (ndo->ndo_vflag > 1)
+ print_unknown_data(ndo, &p[2], "\n\t ", len - 2); /* exclude TLV header */
return len;
trunc:
- printf("[|lcp]");
+ ND_PRINT((ndo, "[|lcp]"));
return 0;
}
/* ML-PPP*/
-struct tok ppp_ml_flag_values[] = {
+static const struct tok ppp_ml_flag_values[] = {
{ 0x80, "begin" },
{ 0x40, "end" },
{ 0, NULL }
};
static void
-handle_mlppp(const u_char *p, int length) {
+handle_mlppp(netdissect_options *ndo,
+ const u_char *p, int length) {
- if (!eflag)
- printf("MLPPP, ");
+ if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, "MLPPP, "));
- printf("seq 0x%03x, Flags [%s], length %u",
+ ND_PRINT((ndo, "seq 0x%03x, Flags [%s], length %u",
(EXTRACT_16BITS(p))&0x0fff, /* only support 12-Bit sequence space for now */
bittok2str(ppp_ml_flag_values, "none", *p & 0xc0),
- length);
-
- return;
+ length));
}
/* CHAP */
static void
-handle_chap(const u_char *p, int length)
+handle_chap(netdissect_options *ndo,
+ const u_char *p, int length)
{
u_int code, len;
int val_size, name_size, msg_size;
@@ -806,26 +830,26 @@ handle_chap(const u_char *p, int length)
p0 = p;
if (length < 1) {
- printf("[|chap]");
+ ND_PRINT((ndo, "[|chap]"));
return;
} else if (length < 4) {
- TCHECK(*p);
- printf("[|chap 0x%02x]", *p);
+ ND_TCHECK(*p);
+ ND_PRINT((ndo, "[|chap 0x%02x]", *p));
return;
}
- TCHECK(*p);
+ ND_TCHECK(*p);
code = *p;
- printf("CHAP, %s (0x%02x)",
+ ND_PRINT((ndo, "CHAP, %s (0x%02x)",
tok2str(chapcode_values,"unknown",code),
- code);
+ code));
p++;
- TCHECK(*p);
- printf(", id %u", *p); /* ID */
+ ND_TCHECK(*p);
+ ND_PRINT((ndo, ", id %u", *p)); /* ID */
p++;
- TCHECK2(*p, 2);
+ ND_TCHECK2(*p, 2);
len = EXTRACT_16BITS(p);
p += 2;
@@ -841,42 +865,43 @@ handle_chap(const u_char *p, int length)
case CHAP_RESP:
if (length - (p - p0) < 1)
return;
- TCHECK(*p);
+ ND_TCHECK(*p);
val_size = *p; /* value size */
p++;
if (length - (p - p0) < val_size)
return;
- printf(", Value ");
+ ND_PRINT((ndo, ", Value "));
for (i = 0; i < val_size; i++) {
- TCHECK(*p);
- printf("%02x", *p++);
+ ND_TCHECK(*p);
+ ND_PRINT((ndo, "%02x", *p++));
}
name_size = len - (p - p0);
- printf(", Name ");
+ ND_PRINT((ndo, ", Name "));
for (i = 0; i < name_size; i++) {
- TCHECK(*p);
- safeputchar(*p++);
+ ND_TCHECK(*p);
+ safeputchar(ndo, *p++);
}
break;
case CHAP_SUCC:
case CHAP_FAIL:
msg_size = len - (p - p0);
- printf(", Msg ");
+ ND_PRINT((ndo, ", Msg "));
for (i = 0; i< msg_size; i++) {
- TCHECK(*p);
- safeputchar(*p++);
+ ND_TCHECK(*p);
+ safeputchar(ndo, *p++);
}
break;
}
return;
trunc:
- printf("[|chap]");
+ ND_PRINT((ndo, "[|chap]"));
}
/* PAP (see RFC 1334) */
static void
-handle_pap(const u_char *p, int length)
+handle_pap(netdissect_options *ndo,
+ const u_char *p, int length)
{
u_int code, len;
int peerid_len, passwd_len, msg_len;
@@ -885,36 +910,36 @@ handle_pap(const u_char *p, int length)
p0 = p;
if (length < 1) {
- printf("[|pap]");
+ ND_PRINT((ndo, "[|pap]"));
return;
} else if (length < 4) {
- TCHECK(*p);
- printf("[|pap 0x%02x]", *p);
+ ND_TCHECK(*p);
+ ND_PRINT((ndo, "[|pap 0x%02x]", *p));
return;
}
- TCHECK(*p);
+ ND_TCHECK(*p);
code = *p;
- printf("PAP, %s (0x%02x)",
- tok2str(papcode_values,"unknown",code),
- code);
+ ND_PRINT((ndo, "PAP, %s (0x%02x)",
+ tok2str(papcode_values, "unknown", code),
+ code));
p++;
- TCHECK(*p);
- printf(", id %u", *p); /* ID */
+ ND_TCHECK(*p);
+ ND_PRINT((ndo, ", id %u", *p)); /* ID */
p++;
- TCHECK2(*p, 2);
+ ND_TCHECK2(*p, 2);
len = EXTRACT_16BITS(p);
p += 2;
if ((int)len > length) {
- printf(", length %u > packet size", len);
+ ND_PRINT((ndo, ", length %u > packet size", len));
return;
}
length = len;
if (length < (p - p0)) {
- printf(", length %u < PAP header length", length);
+ ND_PRINT((ndo, ", length %u < PAP header length", length));
return;
}
@@ -922,55 +947,56 @@ handle_pap(const u_char *p, int length)
case PAP_AREQ:
if (length - (p - p0) < 1)
return;
- TCHECK(*p);
+ ND_TCHECK(*p);
peerid_len = *p; /* Peer-ID Length */
p++;
if (length - (p - p0) < peerid_len)
return;
- printf(", Peer ");
+ ND_PRINT((ndo, ", Peer "));
for (i = 0; i < peerid_len; i++) {
- TCHECK(*p);
- safeputchar(*p++);
+ ND_TCHECK(*p);
+ safeputchar(ndo, *p++);
}
if (length - (p - p0) < 1)
return;
- TCHECK(*p);
+ ND_TCHECK(*p);
passwd_len = *p; /* Password Length */
p++;
if (length - (p - p0) < passwd_len)
return;
- printf(", Name ");
+ ND_PRINT((ndo, ", Name "));
for (i = 0; i < passwd_len; i++) {
- TCHECK(*p);
- safeputchar(*p++);
+ ND_TCHECK(*p);
+ safeputchar(ndo, *p++);
}
break;
case PAP_AACK:
case PAP_ANAK:
if (length - (p - p0) < 1)
return;
- TCHECK(*p);
+ ND_TCHECK(*p);
msg_len = *p; /* Msg-Length */
p++;
if (length - (p - p0) < msg_len)
return;
- printf(", Msg ");
+ ND_PRINT((ndo, ", Msg "));
for (i = 0; i< msg_len; i++) {
- TCHECK(*p);
- safeputchar(*p++);
+ ND_TCHECK(*p);
+ safeputchar(ndo, *p++);
}
break;
}
return;
trunc:
- printf("[|pap]");
+ ND_PRINT((ndo, "[|pap]"));
}
/* BAP */
static void
-handle_bap(const u_char *p _U_, int length _U_)
+handle_bap(netdissect_options *ndo _U_,
+ const u_char *p _U_, int length _U_)
{
/* XXX: to be supported!! */
}
@@ -978,91 +1004,99 @@ handle_bap(const u_char *p _U_, int length _U_)
/* IPCP config options */
static int
-print_ipcp_config_options(const u_char *p, int length)
+print_ipcp_config_options(netdissect_options *ndo,
+ const u_char *p, int length)
{
int len, opt;
u_int compproto, ipcomp_subopttotallen, ipcomp_subopt, ipcomp_suboptlen;
if (length < 2)
return 0;
- TCHECK2(*p, 2);
+ ND_TCHECK2(*p, 2);
len = p[1];
opt = p[0];
if (length < len)
return 0;
if (len < 2) {
- printf("\n\t %s Option (0x%02x), length %u (bogus, should be >= 2)",
+ ND_PRINT((ndo, "\n\t %s Option (0x%02x), length %u (length bogus, should be >= 2)",
tok2str(ipcpopt_values,"unknown",opt),
opt,
- len);
+ len));
return 0;
}
- printf("\n\t %s Option (0x%02x), length %u: ",
+ ND_PRINT((ndo, "\n\t %s Option (0x%02x), length %u",
tok2str(ipcpopt_values,"unknown",opt),
opt,
- len);
+ len));
switch (opt) {
case IPCPOPT_2ADDR: /* deprecated */
- if (len != 10)
- goto invlen;
- TCHECK2(*(p + 6), 4);
- printf("src %s, dst %s",
- ipaddr_string(p + 2),
- ipaddr_string(p + 6));
+ if (len != 10) {
+ ND_PRINT((ndo, " (length bogus, should be = 10)"));
+ return len;
+ }
+ ND_TCHECK2(*(p + 6), 4);
+ ND_PRINT((ndo, ": src %s, dst %s",
+ ipaddr_string(ndo, p + 2),
+ ipaddr_string(ndo, p + 6)));
break;
case IPCPOPT_IPCOMP:
- if (len < 4)
- goto invlen;
- TCHECK2(*(p + 2), 2);
- compproto = EXTRACT_16BITS(p+2);
+ if (len < 4) {
+ ND_PRINT((ndo, " (length bogus, should be >= 4)"));
+ return 0;
+ }
+ ND_TCHECK2(*(p + 2), 2);
+ compproto = EXTRACT_16BITS(p+2);
- printf("%s (0x%02x):",
- tok2str(ipcpopt_compproto_values,"Unknown",compproto),
- compproto);
+ ND_PRINT((ndo, ": %s (0x%02x):",
+ tok2str(ipcpopt_compproto_values, "Unknown", compproto),
+ compproto));
switch (compproto) {
case PPP_VJC:
/* XXX: VJ-Comp parameters should be decoded */
break;
case IPCPOPT_IPCOMP_HDRCOMP:
- if (len < IPCPOPT_IPCOMP_MINLEN)
- goto invlen;
+ if (len < IPCPOPT_IPCOMP_MINLEN) {
+ ND_PRINT((ndo, " (length bogus, should be >= %u)",
+ IPCPOPT_IPCOMP_MINLEN));
+ return 0;
+ }
- TCHECK2(*(p + 2), IPCPOPT_IPCOMP_MINLEN);
- printf("\n\t TCP Space %u, non-TCP Space %u" \
+ ND_TCHECK2(*(p + 2), IPCPOPT_IPCOMP_MINLEN);
+ ND_PRINT((ndo, "\n\t TCP Space %u, non-TCP Space %u" \
", maxPeriod %u, maxTime %u, maxHdr %u",
EXTRACT_16BITS(p+4),
EXTRACT_16BITS(p+6),
EXTRACT_16BITS(p+8),
EXTRACT_16BITS(p+10),
- EXTRACT_16BITS(p+12));
+ EXTRACT_16BITS(p+12)));
/* suboptions present ? */
if (len > IPCPOPT_IPCOMP_MINLEN) {
ipcomp_subopttotallen = len - IPCPOPT_IPCOMP_MINLEN;
p += IPCPOPT_IPCOMP_MINLEN;
-
- printf("\n\t Suboptions, length %u", ipcomp_subopttotallen);
+
+ ND_PRINT((ndo, "\n\t Suboptions, length %u", ipcomp_subopttotallen));
while (ipcomp_subopttotallen >= 2) {
- TCHECK2(*p, 2);
+ ND_TCHECK2(*p, 2);
ipcomp_subopt = *p;
ipcomp_suboptlen = *(p+1);
-
+
/* sanity check */
if (ipcomp_subopt == 0 ||
ipcomp_suboptlen == 0 )
break;
/* XXX: just display the suboptions for now */
- printf("\n\t\t%s Suboption #%u, length %u",
+ ND_PRINT((ndo, "\n\t\t%s Suboption #%u, length %u",
tok2str(ipcpopt_compproto_subopt_values,
"Unknown",
ipcomp_subopt),
ipcomp_subopt,
- ipcomp_suboptlen);
+ ipcomp_suboptlen));
ipcomp_subopttotallen -= ipcomp_suboptlen;
p += ipcomp_suboptlen;
@@ -1080,114 +1114,153 @@ print_ipcp_config_options(const u_char *p, int length)
case IPCPOPT_PRINBNS:
case IPCPOPT_SECDNS:
case IPCPOPT_SECNBNS:
- if (len != 6)
- goto invlen;
- TCHECK2(*(p + 2), 4);
- printf("%s", ipaddr_string(p + 2));
+ if (len != 6) {
+ ND_PRINT((ndo, " (length bogus, should be = 6)"));
+ return 0;
+ }
+ ND_TCHECK2(*(p + 2), 4);
+ ND_PRINT((ndo, ": %s", ipaddr_string(ndo, p + 2)));
break;
default:
- if(vflag<2)
- print_unknown_data(&p[2],"\n\t ",len-2);
+ /*
+ * Unknown option; dump it as raw bytes now if we're
+ * not going to do so below.
+ */
+ if (ndo->ndo_vflag < 2)
+ print_unknown_data(ndo, &p[2], "\n\t ", len - 2);
break;
}
- if (vflag>1)
- print_unknown_data(&p[2],"\n\t ",len-2); /* exclude TLV header */
+ if (ndo->ndo_vflag > 1)
+ print_unknown_data(ndo, &p[2], "\n\t ", len - 2); /* exclude TLV header */
return len;
-invlen:
- printf(", invalid-length-%d", opt);
- return 0;
-
trunc:
- printf("[|ipcp]");
+ ND_PRINT((ndo, "[|ipcp]"));
return 0;
}
/* IP6CP config options */
static int
-print_ip6cp_config_options(const u_char *p, int length)
+print_ip6cp_config_options(netdissect_options *ndo,
+ const u_char *p, int length)
{
int len, opt;
if (length < 2)
return 0;
- TCHECK2(*p, 2);
+ ND_TCHECK2(*p, 2);
len = p[1];
opt = p[0];
if (length < len)
return 0;
if (len < 2) {
- printf("\n\t %s Option (0x%02x), length %u (bogus, should be >= 2)",
+ ND_PRINT((ndo, "\n\t %s Option (0x%02x), length %u (length bogus, should be >= 2)",
tok2str(ip6cpopt_values,"unknown",opt),
opt,
- len);
- return 0;
+ len));
+ return 0;
}
- printf("\n\t %s Option (0x%02x), length %u: ",
+ ND_PRINT((ndo, "\n\t %s Option (0x%02x), length %u",
tok2str(ip6cpopt_values,"unknown",opt),
opt,
- len);
+ len));
switch (opt) {
case IP6CP_IFID:
- if (len != 10)
- goto invlen;
- TCHECK2(*(p + 2), 8);
- printf("%04x:%04x:%04x:%04x",
+ if (len != 10) {
+ ND_PRINT((ndo, " (length bogus, should be = 10)"));
+ return len;
+ }
+ ND_TCHECK2(*(p + 2), 8);
+ ND_PRINT((ndo, ": %04x:%04x:%04x:%04x",
EXTRACT_16BITS(p + 2),
EXTRACT_16BITS(p + 4),
EXTRACT_16BITS(p + 6),
- EXTRACT_16BITS(p + 8));
+ EXTRACT_16BITS(p + 8)));
break;
default:
- if(vflag<2)
- print_unknown_data(&p[2],"\n\t ",len-2);
+ /*
+ * Unknown option; dump it as raw bytes now if we're
+ * not going to do so below.
+ */
+ if (ndo->ndo_vflag < 2)
+ print_unknown_data(ndo, &p[2], "\n\t ", len - 2);
break;
}
- if (vflag>1)
- print_unknown_data(&p[2],"\n\t ",len-2); /* exclude TLV header */
+ if (ndo->ndo_vflag > 1)
+ print_unknown_data(ndo, &p[2], "\n\t ", len - 2); /* exclude TLV header */
return len;
-invlen:
- printf(", invalid-length-%d", opt);
- return 0;
-
trunc:
- printf("[|ip6cp]");
+ ND_PRINT((ndo, "[|ip6cp]"));
return 0;
}
/* CCP config options */
static int
-print_ccp_config_options(const u_char *p, int length)
+print_ccp_config_options(netdissect_options *ndo,
+ const u_char *p, int length)
{
int len, opt;
if (length < 2)
return 0;
- TCHECK2(*p, 2);
+ ND_TCHECK2(*p, 2);
len = p[1];
opt = p[0];
if (length < len)
return 0;
if (len < 2) {
- printf("\n\t %s Option (0x%02x), length %u (bogus, should be >= 2)",
- tok2str(ccpconfopts_values, "Unknown", opt),
- opt,
- len);
- return 0;
- }
+ ND_PRINT((ndo, "\n\t %s Option (0x%02x), length %u (length bogus, should be >= 2)",
+ tok2str(ccpconfopts_values, "Unknown", opt),
+ opt,
+ len));
+ return 0;
+ }
- printf("\n\t %s Option (0x%02x), length %u:",
- tok2str(ccpconfopts_values, "Unknown", opt),
- opt,
- len);
+ ND_PRINT((ndo, "\n\t %s Option (0x%02x), length %u",
+ tok2str(ccpconfopts_values, "Unknown", opt),
+ opt,
+ len));
switch (opt) {
- /* fall through --> default: nothing supported yet */
+ case CCPOPT_BSDCOMP:
+ if (len < 3) {
+ ND_PRINT((ndo, " (length bogus, should be >= 3)"));
+ return len;
+ }
+ ND_TCHECK2(*(p + 2), 1);
+ ND_PRINT((ndo, ": Version: %u, Dictionary Bits: %u",
+ p[2] >> 5, p[2] & 0x1f));
+ break;
+ case CCPOPT_MVRCA:
+ if (len < 4) {
+ ND_PRINT((ndo, " (length bogus, should be >= 4)"));
+ return len;
+ }
+ ND_TCHECK2(*(p + 2), 1);
+ ND_PRINT((ndo, ": Features: %u, PxP: %s, History: %u, #CTX-ID: %u",
+ (p[2] & 0xc0) >> 6,
+ (p[2] & 0x20) ? "Enabled" : "Disabled",
+ p[2] & 0x1f, p[3]));
+ break;
+ case CCPOPT_DEFLATE:
+ if (len < 4) {
+ ND_PRINT((ndo, " (length bogus, should be >= 4)"));
+ return len;
+ }
+ ND_TCHECK2(*(p + 2), 1);
+ ND_PRINT((ndo, ": Window: %uK, Method: %s (0x%x), MBZ: %u, CHK: %u",
+ (p[2] & 0xf0) >> 4,
+ ((p[2] & 0x0f) == 8) ? "zlib" : "unkown",
+ p[2] & 0x0f, (p[3] & 0xfc) >> 2, p[3] & 0x03));
+ break;
+
+/* XXX: to be supported */
+#if 0
case CCPOPT_OUI:
case CCPOPT_PRED1:
case CCPOPT_PRED2:
@@ -1197,82 +1270,97 @@ print_ccp_config_options(const u_char *p, int length)
case CCPOPT_MPPC:
case CCPOPT_GFZA:
case CCPOPT_V42BIS:
- case CCPOPT_BSDCOMP:
case CCPOPT_LZSDCP:
- case CCPOPT_MVRCA:
case CCPOPT_DEC:
- case CCPOPT_DEFLATE:
case CCPOPT_RESV:
+ break;
+#endif
default:
- if(vflag<2)
- print_unknown_data(&p[2],"\n\t ",len-2);
+ /*
+ * Unknown option; dump it as raw bytes now if we're
+ * not going to do so below.
+ */
+ if (ndo->ndo_vflag < 2)
+ print_unknown_data(ndo, &p[2], "\n\t ", len - 2);
break;
}
- if (vflag>1)
- print_unknown_data(&p[2],"\n\t ",len-2); /* exclude TLV header */
+ if (ndo->ndo_vflag > 1)
+ print_unknown_data(ndo, &p[2], "\n\t ", len - 2); /* exclude TLV header */
return len;
trunc:
- printf("[|ccp]");
+ ND_PRINT((ndo, "[|ccp]"));
return 0;
}
/* BACP config options */
static int
-print_bacp_config_options(const u_char *p, int length)
+print_bacp_config_options(netdissect_options *ndo,
+ const u_char *p, int length)
{
int len, opt;
if (length < 2)
return 0;
- TCHECK2(*p, 2);
+ ND_TCHECK2(*p, 2);
len = p[1];
opt = p[0];
if (length < len)
return 0;
if (len < 2) {
- printf("\n\t %s Option (0x%02x), length %u (bogus, should be >= 2)",
- tok2str(bacconfopts_values, "Unknown", opt),
- opt,
- len);
- return 0;
- }
+ ND_PRINT((ndo, "\n\t %s Option (0x%02x), length %u (length bogus, should be >= 2)",
+ tok2str(bacconfopts_values, "Unknown", opt),
+ opt,
+ len));
+ return 0;
+ }
- printf("\n\t %s Option (0x%02x), length %u:",
- tok2str(bacconfopts_values, "Unknown", opt),
- opt,
- len);
+ ND_PRINT((ndo, "\n\t %s Option (0x%02x), length %u",
+ tok2str(bacconfopts_values, "Unknown", opt),
+ opt,
+ len));
switch (opt) {
case BACPOPT_FPEER:
- TCHECK2(*(p + 2), 4);
- printf(", Magic-Num 0x%08x", EXTRACT_32BITS(p + 2));
- break;
+ if (len != 6) {
+ ND_PRINT((ndo, " (length bogus, should be = 6)"));
+ return len;
+ }
+ ND_TCHECK2(*(p + 2), 4);
+ ND_PRINT((ndo, ": Magic-Num 0x%08x", EXTRACT_32BITS(p + 2)));
+ break;
default:
- if(vflag<2)
- print_unknown_data(&p[2],"\n\t ",len-2);
+ /*
+ * Unknown option; dump it as raw bytes now if we're
+ * not going to do so below.
+ */
+ if (ndo->ndo_vflag < 2)
+ print_unknown_data(ndo, &p[2], "\n\t ", len - 2);
break;
}
- if (vflag>1)
- print_unknown_data(&p[2],"\n\t ",len-2); /* exclude TLV header */
+ if (ndo->ndo_vflag > 1)
+ print_unknown_data(ndo, &p[2], "\n\t ", len - 2); /* exclude TLV header */
return len;
trunc:
- printf("[|bacp]");
+ ND_PRINT((ndo, "[|bacp]"));
return 0;
}
-
static void
-ppp_hdlc(const u_char *p, int length)
+ppp_hdlc(netdissect_options *ndo,
+ const u_char *p, int length)
{
u_char *b, *s, *t, c;
int i, proto;
const void *se;
- b = (u_int8_t *)malloc(length);
+ if (length <= 0)
+ return;
+
+ b = (uint8_t *)malloc(length);
if (b == NULL)
return;
@@ -1293,52 +1381,65 @@ ppp_hdlc(const u_char *p, int length)
*t++ = c;
}
- se = snapend;
- snapend = t;
+ se = ndo->ndo_snapend;
+ ndo->ndo_snapend = t;
+ length = t - b;
/* now lets guess about the payload codepoint format */
+ if (length < 1)
+ goto trunc;
proto = *b; /* start with a one-octet codepoint guess */
-
+
switch (proto) {
case PPP_IP:
- ip_print(gndo, b+1, t - b - 1);
+ ip_print(ndo, b + 1, length - 1);
goto cleanup;
#ifdef INET6
case PPP_IPV6:
- ip6_print(gndo, b+1, t - b - 1);
+ ip6_print(ndo, b + 1, length - 1);
goto cleanup;
#endif
default: /* no luck - try next guess */
break;
}
+ if (length < 2)
+ goto trunc;
proto = EXTRACT_16BITS(b); /* next guess - load two octets */
switch (proto) {
case (PPP_ADDRESS << 8 | PPP_CONTROL): /* looks like a PPP frame */
+ if (length < 4)
+ goto trunc;
proto = EXTRACT_16BITS(b+2); /* load the PPP proto-id */
- handle_ppp(proto, b+4, t - b - 4);
+ handle_ppp(ndo, proto, b + 4, length - 4);
break;
default: /* last guess - proto must be a PPP proto-id */
- handle_ppp(proto, b+2, t - b - 2);
+ handle_ppp(ndo, proto, b + 2, length - 2);
break;
}
cleanup:
- snapend = se;
+ ndo->ndo_snapend = se;
free(b);
return;
+
+trunc:
+ ndo->ndo_snapend = se;
+ free(b);
+ ND_PRINT((ndo, "[|ppp]"));
}
/* PPP */
static void
-handle_ppp(u_int proto, const u_char *p, int length)
+handle_ppp(netdissect_options *ndo,
+ u_int proto, const u_char *p, int length)
{
- if ((proto & 0xff00) == 0x7e00) {/* is this an escape code ? */
- ppp_hdlc(p-1, length);
- return;
- }
+ if ((proto & 0xff00) == 0x7e00) { /* is this an escape code ? */
+ ppp_hdlc(ndo, p - 1, length);
+ return;
+ }
switch (proto) {
case PPP_LCP: /* fall through */
@@ -1348,55 +1449,56 @@ handle_ppp(u_int proto, const u_char *p, int length)
case PPP_IPV6CP:
case PPP_CCP:
case PPP_BACP:
- handle_ctrl_proto(proto, p, length);
+ handle_ctrl_proto(ndo, proto, p, length);
+ break;
+ case PPP_ML:
+ handle_mlppp(ndo, p, length);
break;
- case PPP_ML:
- handle_mlppp(p, length);
- break;
case PPP_CHAP:
- handle_chap(p, length);
+ handle_chap(ndo, p, length);
break;
case PPP_PAP:
- handle_pap(p, length);
+ handle_pap(ndo, p, length);
break;
case PPP_BAP: /* XXX: not yet completed */
- handle_bap(p, length);
+ handle_bap(ndo, p, length);
break;
case ETHERTYPE_IP: /*XXX*/
case PPP_VJNC:
case PPP_IP:
- ip_print(gndo, p, length);
+ ip_print(ndo, p, length);
break;
#ifdef INET6
case ETHERTYPE_IPV6: /*XXX*/
case PPP_IPV6:
- ip6_print(gndo, p, length);
+ ip6_print(ndo, p, length);
break;
#endif
case ETHERTYPE_IPX: /*XXX*/
case PPP_IPX:
- ipx_print(p, length);
+ ipx_print(ndo, p, length);
break;
case PPP_OSI:
- isoclns_print(p, length, length);
- break;
+ isoclns_print(ndo, p, length, length);
+ break;
case PPP_MPLS_UCAST:
case PPP_MPLS_MCAST:
- mpls_print(p, length);
+ mpls_print(ndo, p, length);
break;
case PPP_COMP:
- printf("compressed PPP data");
+ ND_PRINT((ndo, "compressed PPP data"));
break;
default:
- printf("%s ", tok2str(ppptype2str, "unknown PPP protocol (0x%04x)", proto));
- print_unknown_data(p,"\n\t",length);
+ ND_PRINT((ndo, "%s ", tok2str(ppptype2str, "unknown PPP protocol (0x%04x)", proto)));
+ print_unknown_data(ndo, p, "\n\t", length);
break;
}
}
/* Standard PPP printer */
u_int
-ppp_print(register const u_char *p, u_int length)
+ppp_print(netdissect_options *ndo,
+ register const u_char *p, u_int length)
{
u_int proto,ppp_header;
u_int olen = length; /* _o_riginal length */
@@ -1408,18 +1510,18 @@ ppp_print(register const u_char *p, u_int length)
*/
if (length < 2)
goto trunc;
- TCHECK2(*p, 2);
+ ND_TCHECK2(*p, 2);
ppp_header = EXTRACT_16BITS(p);
switch(ppp_header) {
case (PPP_WITHDIRECTION_IN << 8 | PPP_CONTROL):
- if (eflag) printf("In ");
+ if (ndo->ndo_eflag) ND_PRINT((ndo, "In "));
p += 2;
length -= 2;
hdr_len += 2;
break;
case (PPP_WITHDIRECTION_OUT << 8 | PPP_CONTROL):
- if (eflag) printf("Out ");
+ if (ndo->ndo_eflag) ND_PRINT((ndo, "Out "));
p += 2;
length -= 2;
hdr_len += 2;
@@ -1436,43 +1538,44 @@ ppp_print(register const u_char *p, u_int length)
if (length < 2)
goto trunc;
- TCHECK(*p);
+ ND_TCHECK(*p);
if (*p % 2) {
proto = *p; /* PFC is used */
p++;
length--;
hdr_len++;
} else {
- TCHECK2(*p, 2);
+ ND_TCHECK2(*p, 2);
proto = EXTRACT_16BITS(p);
p += 2;
length -= 2;
hdr_len += 2;
}
- if (eflag)
- printf("%s (0x%04x), length %u: ",
- tok2str(ppptype2str, "unknown", proto),
- proto,
- olen);
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "%s (0x%04x), length %u: ",
+ tok2str(ppptype2str, "unknown", proto),
+ proto,
+ olen));
- handle_ppp(proto, p, length);
+ handle_ppp(ndo, proto, p, length);
return (hdr_len);
trunc:
- printf("[|ppp]");
+ ND_PRINT((ndo, "[|ppp]"));
return (0);
}
/* PPP I/F printer */
u_int
-ppp_if_print(const struct pcap_pkthdr *h, register const u_char *p)
+ppp_if_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, register const u_char *p)
{
register u_int length = h->len;
register u_int caplen = h->caplen;
if (caplen < PPP_HDRLEN) {
- printf("[|ppp]");
+ ND_PRINT((ndo, "[|ppp]"));
return (caplen);
}
@@ -1513,11 +1616,11 @@ ppp_if_print(const struct pcap_pkthdr *h, register const u_char *p)
* (Is the Cisco framing in question what DLT_C_HDLC, in
* BSD/OS, is?)
*/
- if (eflag)
- printf("%c %4d %02x ", p[0] ? 'O' : 'I', length, p[1]);
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "%c %4d %02x ", p[0] ? 'O' : 'I', length, p[1]));
#endif
- ppp_print(p, length);
+ ppp_print(ndo, p, length);
return (0);
}
@@ -1532,7 +1635,8 @@ ppp_if_print(const struct pcap_pkthdr *h, register const u_char *p)
* This handles, for example, DLT_PPP_SERIAL in NetBSD.
*/
u_int
-ppp_hdlc_if_print(const struct pcap_pkthdr *h, register const u_char *p)
+ppp_hdlc_if_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, register const u_char *p)
{
register u_int length = h->len;
register u_int caplen = h->caplen;
@@ -1540,7 +1644,7 @@ ppp_hdlc_if_print(const struct pcap_pkthdr *h, register const u_char *p)
u_int hdrlen = 0;
if (caplen < 2) {
- printf("[|ppp]");
+ ND_PRINT((ndo, "[|ppp]"));
return (caplen);
}
@@ -1548,12 +1652,12 @@ ppp_hdlc_if_print(const struct pcap_pkthdr *h, register const u_char *p)
case PPP_ADDRESS:
if (caplen < 4) {
- printf("[|ppp]");
+ ND_PRINT((ndo, "[|ppp]"));
return (caplen);
}
- if (eflag)
- printf("%02x %02x %d ", p[0], p[1], length);
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "%02x %02x %d ", p[0], p[1], length));
p += 2;
length -= 2;
hdrlen += 2;
@@ -1562,20 +1666,19 @@ ppp_hdlc_if_print(const struct pcap_pkthdr *h, register const u_char *p)
p += 2;
length -= 2;
hdrlen += 2;
- printf("%s: ", tok2str(ppptype2str, "unknown PPP protocol (0x%04x)", proto));
+ ND_PRINT((ndo, "%s: ", tok2str(ppptype2str, "unknown PPP protocol (0x%04x)", proto)));
- handle_ppp(proto, p, length);
+ handle_ppp(ndo, proto, p, length);
break;
case CHDLC_UNICAST:
case CHDLC_BCAST:
- return (chdlc_if_print(h, p));
+ return (chdlc_if_print(ndo, h, p));
default:
- if (eflag)
- printf("%02x %02x %d ", p[0], p[1], length);
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "%02x %02x %d ", p[0], p[1], length));
p += 2;
- length -= 2;
hdrlen += 2;
/*
@@ -1583,7 +1686,7 @@ ppp_hdlc_if_print(const struct pcap_pkthdr *h, register const u_char *p)
* the next two octets as an Ethernet type; does that
* ever happen?
*/
- printf("unknown addr %02x; ctrl %02x", p[0], p[1]);
+ ND_PRINT((ndo, "unknown addr %02x; ctrl %02x", p[0], p[1]));
break;
}
@@ -1594,18 +1697,19 @@ ppp_hdlc_if_print(const struct pcap_pkthdr *h, register const u_char *p)
/* BSD/OS specific PPP printer */
u_int
-ppp_bsdos_if_print(const struct pcap_pkthdr *h _U_, register const u_char *p _U_)
+ppp_bsdos_if_print(netdissect_options *ndo _U_,
+ const struct pcap_pkthdr *h _U_, register const u_char *p _U_)
{
register int hdrlength;
#ifdef __bsdi__
register u_int length = h->len;
register u_int caplen = h->caplen;
- u_int16_t ptype;
+ uint16_t ptype;
const u_char *q;
int i;
if (caplen < PPP_BSDI_HDRLEN) {
- printf("[|ppp]");
+ ND_PRINT((ndo, "[|ppp]"));
return (caplen)
}
@@ -1613,34 +1717,34 @@ ppp_bsdos_if_print(const struct pcap_pkthdr *h _U_, register const u_char *p _U_
#if 0
if (p[0] == PPP_ADDRESS && p[1] == PPP_CONTROL) {
- if (eflag)
- printf("%02x %02x ", p[0], p[1]);
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "%02x %02x ", p[0], p[1]));
p += 2;
hdrlength = 2;
}
- if (eflag)
- printf("%d ", length);
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "%d ", length));
/* Retrieve the protocol type */
if (*p & 01) {
/* Compressed protocol field */
ptype = *p;
- if (eflag)
- printf("%02x ", ptype);
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "%02x ", ptype));
p++;
hdrlength += 1;
} else {
/* Un-compressed protocol field */
ptype = EXTRACT_16BITS(p);
- if (eflag)
- printf("%04x ", ptype);
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "%04x ", ptype));
p += 2;
hdrlength += 2;
}
#else
ptype = 0; /*XXX*/
- if (eflag)
- printf("%c ", p[SLC_DIR] ? 'O' : 'I');
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "%c ", p[SLC_DIR] ? 'O' : 'I'));
if (p[SLC_LLHL]) {
/* link level header */
struct ppp_header *ph;
@@ -1649,72 +1753,72 @@ ppp_bsdos_if_print(const struct pcap_pkthdr *h _U_, register const u_char *p _U_
ph = (struct ppp_header *)q;
if (ph->phdr_addr == PPP_ADDRESS
&& ph->phdr_ctl == PPP_CONTROL) {
- if (eflag)
- printf("%02x %02x ", q[0], q[1]);
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "%02x %02x ", q[0], q[1]));
ptype = EXTRACT_16BITS(&ph->phdr_type);
- if (eflag && (ptype == PPP_VJC || ptype == PPP_VJNC)) {
- printf("%s ", tok2str(ppptype2str,
- "proto-#%d", ptype));
+ if (ndo->ndo_eflag && (ptype == PPP_VJC || ptype == PPP_VJNC)) {
+ ND_PRINT((ndo, "%s ", tok2str(ppptype2str,
+ "proto-#%d", ptype)));
}
} else {
- if (eflag) {
- printf("LLH=[");
+ if (ndo->ndo_eflag) {
+ ND_PRINT((ndo, "LLH=["));
for (i = 0; i < p[SLC_LLHL]; i++)
- printf("%02x", q[i]);
- printf("] ");
+ ND_PRINT((ndo, "%02x", q[i]));
+ ND_PRINT((ndo, "] "));
}
}
}
- if (eflag)
- printf("%d ", length);
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "%d ", length));
if (p[SLC_CHL]) {
q = p + SLC_BPFHDRLEN + p[SLC_LLHL];
switch (ptype) {
case PPP_VJC:
- ptype = vjc_print(q, ptype);
+ ptype = vjc_print(ndo, q, ptype);
hdrlength = PPP_BSDI_HDRLEN;
p += hdrlength;
switch (ptype) {
case PPP_IP:
- ip_print(gndo, p, length);
+ ip_print(ndo, p, length);
break;
#ifdef INET6
case PPP_IPV6:
- ip6_print(gndo, p, length);
+ ip6_print(ndo, p, length);
break;
#endif
case PPP_MPLS_UCAST:
case PPP_MPLS_MCAST:
- mpls_print(p, length);
+ mpls_print(ndo, p, length);
break;
}
goto printx;
case PPP_VJNC:
- ptype = vjc_print(q, ptype);
+ ptype = vjc_print(ndo, q, ptype);
hdrlength = PPP_BSDI_HDRLEN;
p += hdrlength;
switch (ptype) {
case PPP_IP:
- ip_print(gndo, p, length);
+ ip_print(ndo, p, length);
break;
#ifdef INET6
case PPP_IPV6:
- ip6_print(gndo, p, length);
+ ip6_print(ndo, p, length);
break;
#endif
case PPP_MPLS_UCAST:
case PPP_MPLS_MCAST:
- mpls_print(p, length);
+ mpls_print(ndo, p, length);
break;
}
goto printx;
default:
- if (eflag) {
- printf("CH=[");
+ if (ndo->ndo_eflag) {
+ ND_PRINT((ndo, "CH=["));
for (i = 0; i < p[SLC_LLHL]; i++)
- printf("%02x", q[i]);
- printf("] ");
+ ND_PRINT((ndo, "%02x", q[i]));
+ ND_PRINT((ndo, "] "));
}
break;
}
@@ -1732,15 +1836,15 @@ ppp_bsdos_if_print(const struct pcap_pkthdr *h _U_, register const u_char *p _U_
break;
#ifdef INET6
case PPP_IPV6:
- ip6_print(gndo, p, length);
+ ip6_print(ndo, p, length);
break;
#endif
- case PPP_MPLS_UCAST:
- case PPP_MPLS_MCAST:
- mpls_print(gndo, p, length);
- break;
+ case PPP_MPLS_UCAST:
+ case PPP_MPLS_MCAST:
+ mpls_print(ndo, p, length);
+ break;
default:
- printf("%s ", tok2str(ppptype2str, "unknown PPP protocol (0x%04x)", ptype));
+ ND_PRINT((ndo, "%s ", tok2str(ppptype2str, "unknown PPP protocol (0x%04x)", ptype)));
}
printx:
diff --git a/contrib/tcpdump/print-pppoe.c b/contrib/tcpdump/print-pppoe.c
index 8040c7ae09c2..1624c5e50f3b 100644
--- a/contrib/tcpdump/print-pppoe.c
+++ b/contrib/tcpdump/print-pppoe.c
@@ -17,29 +17,18 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Original code by Greg Stark <gsstark@mit.edu>
+ *
+ * Original code by Greg Stark <gsstark@mit.edu>
*/
-#ifndef lint
-static const char rcsid[] _U_ =
-"@(#) $Header: /tcpdump/master/tcpdump/print-pppoe.c,v 1.31 2005-04-26 19:48:38 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <string.h>
-
#include "interface.h"
-#include "addrtoname.h"
-#include "ppp.h"
-#include "ethertype.h"
-#include "ether.h"
#include "extract.h" /* must come after interface.h */
/* Codes */
@@ -51,7 +40,7 @@ enum {
PPPOE_PADT = 0xa7
};
-static struct tok pppoecode2str[] = {
+static const struct tok pppoecode2str[] = {
{ PPPOE_PADI, "PADI" },
{ PPPOE_PADO, "PADO" },
{ PPPOE_PADR, "PADR" },
@@ -76,7 +65,7 @@ enum {
PPPOE_GENERIC_ERROR = 0x0203
};
-static struct tok pppoetag2str[] = {
+static const struct tok pppoetag2str[] = {
{ PPPOE_EOL, "EOL" },
{ PPPOE_SERVICE_NAME, "Service-Name" },
{ PPPOE_AC_NAME, "AC-Name" },
@@ -95,25 +84,25 @@ static struct tok pppoetag2str[] = {
#define MAXTAGPRINT 80
u_int
-pppoe_if_print(const struct pcap_pkthdr *h, register const u_char *p)
+pppoe_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p)
{
- return (pppoe_print(p, h->len));
+ return (pppoe_print(ndo, p, h->len));
}
u_int
-pppoe_print(register const u_char *bp, u_int length)
+pppoe_print(netdissect_options *ndo, register const u_char *bp, u_int length)
{
- u_int16_t pppoe_ver, pppoe_type, pppoe_code, pppoe_sessionid;
+ uint16_t pppoe_ver, pppoe_type, pppoe_code, pppoe_sessionid;
u_int pppoe_length;
const u_char *pppoe_packet, *pppoe_payload;
if (length < PPPOE_HDRLEN) {
- (void)printf("truncated-pppoe %u", length);
+ ND_PRINT((ndo, "truncated-pppoe %u", length));
return (length);
}
length -= PPPOE_HDRLEN;
pppoe_packet = bp;
- TCHECK2(*pppoe_packet, PPPOE_HDRLEN);
+ ND_TCHECK2(*pppoe_packet, PPPOE_HDRLEN);
pppoe_ver = (pppoe_packet[0] & 0xF0) >> 4;
pppoe_type = (pppoe_packet[0] & 0x0F);
pppoe_code = pppoe_packet[1];
@@ -122,22 +111,22 @@ pppoe_print(register const u_char *bp, u_int length)
pppoe_payload = pppoe_packet + PPPOE_HDRLEN;
if (pppoe_ver != 1) {
- printf(" [ver %d]",pppoe_ver);
+ ND_PRINT((ndo, " [ver %d]",pppoe_ver));
}
if (pppoe_type != 1) {
- printf(" [type %d]",pppoe_type);
+ ND_PRINT((ndo, " [type %d]",pppoe_type));
}
- printf("PPPoE %s", tok2str(pppoecode2str, "PAD-%x", pppoe_code));
+ ND_PRINT((ndo, "PPPoE %s", tok2str(pppoecode2str, "PAD-%x", pppoe_code)));
if (pppoe_code == PPPOE_PADI && pppoe_length > 1484 - PPPOE_HDRLEN) {
- printf(" [len %u!]",pppoe_length);
+ ND_PRINT((ndo, " [len %u!]",pppoe_length));
}
if (pppoe_length > length) {
- printf(" [len %u > %u!]", pppoe_length, length);
+ ND_PRINT((ndo, " [len %u > %u!]", pppoe_length, length));
pppoe_length = length;
}
if (pppoe_sessionid) {
- printf(" [ses 0x%x]", pppoe_sessionid);
+ ND_PRINT((ndo, " [ses 0x%x]", pppoe_sessionid));
}
if (pppoe_code) {
@@ -151,7 +140,7 @@ pppoe_print(register const u_char *bp, u_int length)
* tag_type is previous tag or 0xffff for first iteration
*/
while (tag_type && p < pppoe_payload + pppoe_length) {
- TCHECK2(*p, 4);
+ ND_TCHECK2(*p, 4);
tag_type = EXTRACT_16BITS(p);
tag_len = EXTRACT_16BITS(p + 2);
p += 4;
@@ -164,7 +153,7 @@ pppoe_print(register const u_char *bp, u_int length)
unsigned tag_str_len = 0;
/* TODO print UTF-8 decoded text */
- TCHECK2(*p, tag_len);
+ ND_TCHECK2(*p, tag_len);
for (v = p; v < p + tag_len && tag_str_len < MAXTAGPRINT-1; v++)
if (*v >= 32 && *v < 127) {
tag_str[tag_str_len++] = *v;
@@ -176,24 +165,24 @@ pppoe_print(register const u_char *bp, u_int length)
tag_str[tag_str_len] = 0;
if (isascii > isgarbage) {
- printf(" [%s \"%*.*s\"]",
+ ND_PRINT((ndo, " [%s \"%*.*s\"]",
tok2str(pppoetag2str, "TAG-0x%x", tag_type),
(int)tag_str_len,
(int)tag_str_len,
- tag_str);
+ tag_str));
} else {
/* Print hex, not fast to abuse printf but this doesn't get used much */
- printf(" [%s 0x", tok2str(pppoetag2str, "TAG-0x%x", tag_type));
+ ND_PRINT((ndo, " [%s 0x", tok2str(pppoetag2str, "TAG-0x%x", tag_type)));
for (v=p; v<p+tag_len; v++) {
- printf("%02X", *v);
+ ND_PRINT((ndo, "%02X", *v));
}
- printf("]");
+ ND_PRINT((ndo, "]"));
}
-
+
} else
- printf(" [%s]", tok2str(pppoetag2str,
- "TAG-0x%x", tag_type));
+ ND_PRINT((ndo, " [%s]", tok2str(pppoetag2str,
+ "TAG-0x%x", tag_type)));
p += tag_len;
/* p points to next tag */
@@ -201,11 +190,11 @@ pppoe_print(register const u_char *bp, u_int length)
return (0);
} else {
/* PPPoE data */
- printf(" ");
- return (PPPOE_HDRLEN + ppp_print(pppoe_payload, pppoe_length));
+ ND_PRINT((ndo, " "));
+ return (PPPOE_HDRLEN + ppp_print(ndo, pppoe_payload, pppoe_length));
}
trunc:
- printf("[|pppoe]");
+ ND_PRINT((ndo, "[|pppoe]"));
return (PPPOE_HDRLEN);
}
diff --git a/contrib/tcpdump/print-pptp.c b/contrib/tcpdump/print-pptp.c
index 2fbba6211e24..c77868d46256 100644
--- a/contrib/tcpdump/print-pptp.c
+++ b/contrib/tcpdump/print-pptp.c
@@ -21,24 +21,17 @@
* PPTP support contributed by Motonori Shindo (mshindo@mshindo.net)
*/
-
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-pptp.c,v 1.12 2006-06-23 02:03:09 hannes Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-
#include "interface.h"
#include "extract.h"
-static char tstr[] = " [|pptp]";
+static const char tstr[] = " [|pptp]";
#define PPTP_MSG_TYPE_CTRL 1 /* Control Message */
#define PPTP_MSG_TYPE_MGMT 2 /* Management Message (currently not used */
@@ -91,147 +84,147 @@ static const char *pptp_message_type_string[] = {
/* common for all PPTP control messages */
struct pptp_hdr {
- u_int16_t length;
- u_int16_t msg_type;
- u_int32_t magic_cookie;
- u_int16_t ctrl_msg_type;
- u_int16_t reserved0;
+ uint16_t length;
+ uint16_t msg_type;
+ uint32_t magic_cookie;
+ uint16_t ctrl_msg_type;
+ uint16_t reserved0;
};
struct pptp_msg_sccrq {
- u_int16_t proto_ver;
- u_int16_t reserved1;
- u_int32_t framing_cap;
- u_int32_t bearer_cap;
- u_int16_t max_channel;
- u_int16_t firm_rev;
+ uint16_t proto_ver;
+ uint16_t reserved1;
+ uint32_t framing_cap;
+ uint32_t bearer_cap;
+ uint16_t max_channel;
+ uint16_t firm_rev;
u_char hostname[64];
u_char vendor[64];
};
struct pptp_msg_sccrp {
- u_int16_t proto_ver;
- u_int8_t result_code;
- u_int8_t err_code;
- u_int32_t framing_cap;
- u_int32_t bearer_cap;
- u_int16_t max_channel;
- u_int16_t firm_rev;
+ uint16_t proto_ver;
+ uint8_t result_code;
+ uint8_t err_code;
+ uint32_t framing_cap;
+ uint32_t bearer_cap;
+ uint16_t max_channel;
+ uint16_t firm_rev;
u_char hostname[64];
u_char vendor[64];
};
struct pptp_msg_stopccrq {
- u_int8_t reason;
- u_int8_t reserved1;
- u_int16_t reserved2;
+ uint8_t reason;
+ uint8_t reserved1;
+ uint16_t reserved2;
};
struct pptp_msg_stopccrp {
- u_int8_t result_code;
- u_int8_t err_code;
- u_int16_t reserved1;
+ uint8_t result_code;
+ uint8_t err_code;
+ uint16_t reserved1;
};
struct pptp_msg_echorq {
- u_int32_t id;
+ uint32_t id;
};
struct pptp_msg_echorp {
- u_int32_t id;
- u_int8_t result_code;
- u_int8_t err_code;
- u_int16_t reserved1;
+ uint32_t id;
+ uint8_t result_code;
+ uint8_t err_code;
+ uint16_t reserved1;
};
struct pptp_msg_ocrq {
- u_int16_t call_id;
- u_int16_t call_ser;
- u_int32_t min_bps;
- u_int32_t max_bps;
- u_int32_t bearer_type;
- u_int32_t framing_type;
- u_int16_t recv_winsiz;
- u_int16_t pkt_proc_delay;
- u_int16_t phone_no_len;
- u_int16_t reserved1;
+ uint16_t call_id;
+ uint16_t call_ser;
+ uint32_t min_bps;
+ uint32_t max_bps;
+ uint32_t bearer_type;
+ uint32_t framing_type;
+ uint16_t recv_winsiz;
+ uint16_t pkt_proc_delay;
+ uint16_t phone_no_len;
+ uint16_t reserved1;
u_char phone_no[64];
u_char subaddr[64];
};
struct pptp_msg_ocrp {
- u_int16_t call_id;
- u_int16_t peer_call_id;
- u_int8_t result_code;
- u_int8_t err_code;
- u_int16_t cause_code;
- u_int32_t conn_speed;
- u_int16_t recv_winsiz;
- u_int16_t pkt_proc_delay;
- u_int32_t phy_chan_id;
+ uint16_t call_id;
+ uint16_t peer_call_id;
+ uint8_t result_code;
+ uint8_t err_code;
+ uint16_t cause_code;
+ uint32_t conn_speed;
+ uint16_t recv_winsiz;
+ uint16_t pkt_proc_delay;
+ uint32_t phy_chan_id;
};
struct pptp_msg_icrq {
- u_int16_t call_id;
- u_int16_t call_ser;
- u_int32_t bearer_type;
- u_int32_t phy_chan_id;
- u_int16_t dialed_no_len;
- u_int16_t dialing_no_len;
+ uint16_t call_id;
+ uint16_t call_ser;
+ uint32_t bearer_type;
+ uint32_t phy_chan_id;
+ uint16_t dialed_no_len;
+ uint16_t dialing_no_len;
u_char dialed_no[64]; /* DNIS */
u_char dialing_no[64]; /* CLID */
u_char subaddr[64];
};
struct pptp_msg_icrp {
- u_int16_t call_id;
- u_int16_t peer_call_id;
- u_int8_t result_code;
- u_int8_t err_code;
- u_int16_t recv_winsiz;
- u_int16_t pkt_proc_delay;
- u_int16_t reserved1;
+ uint16_t call_id;
+ uint16_t peer_call_id;
+ uint8_t result_code;
+ uint8_t err_code;
+ uint16_t recv_winsiz;
+ uint16_t pkt_proc_delay;
+ uint16_t reserved1;
};
struct pptp_msg_iccn {
- u_int16_t peer_call_id;
- u_int16_t reserved1;
- u_int32_t conn_speed;
- u_int16_t recv_winsiz;
- u_int16_t pkt_proc_delay;
- u_int32_t framing_type;
+ uint16_t peer_call_id;
+ uint16_t reserved1;
+ uint32_t conn_speed;
+ uint16_t recv_winsiz;
+ uint16_t pkt_proc_delay;
+ uint32_t framing_type;
};
struct pptp_msg_ccrq {
- u_int16_t call_id;
- u_int16_t reserved1;
+ uint16_t call_id;
+ uint16_t reserved1;
};
struct pptp_msg_cdn {
- u_int16_t call_id;
- u_int8_t result_code;
- u_int8_t err_code;
- u_int16_t cause_code;
- u_int16_t reserved1;
+ uint16_t call_id;
+ uint8_t result_code;
+ uint8_t err_code;
+ uint16_t cause_code;
+ uint16_t reserved1;
u_char call_stats[128];
};
struct pptp_msg_wen {
- u_int16_t peer_call_id;
- u_int16_t reserved1;
- u_int32_t crc_err;
- u_int32_t framing_err;
- u_int32_t hardware_overrun;
- u_int32_t buffer_overrun;
- u_int32_t timeout_err;
- u_int32_t align_err;
+ uint16_t peer_call_id;
+ uint16_t reserved1;
+ uint32_t crc_err;
+ uint32_t framing_err;
+ uint32_t hardware_overrun;
+ uint32_t buffer_overrun;
+ uint32_t timeout_err;
+ uint32_t align_err;
};
struct pptp_msg_sli {
- u_int16_t peer_call_id;
- u_int16_t reserved1;
- u_int32_t send_accm;
- u_int32_t recv_accm;
+ uint16_t peer_call_id;
+ uint16_t reserved1;
+ uint32_t send_accm;
+ uint32_t recv_accm;
};
/* attributes that appear more than once in above messages:
@@ -239,27 +232,27 @@ struct pptp_msg_sli {
Number of
occurence attributes
--------------------------------------
- 2 u_int32_t bearer_cap;
- 2 u_int32_t bearer_type;
- 6 u_int16_t call_id;
- 2 u_int16_t call_ser;
- 2 u_int16_t cause_code;
- 2 u_int32_t conn_speed;
- 6 u_int8_t err_code;
- 2 u_int16_t firm_rev;
- 2 u_int32_t framing_cap;
- 2 u_int32_t framing_type;
+ 2 uint32_t bearer_cap;
+ 2 uint32_t bearer_type;
+ 6 uint16_t call_id;
+ 2 uint16_t call_ser;
+ 2 uint16_t cause_code;
+ 2 uint32_t conn_speed;
+ 6 uint8_t err_code;
+ 2 uint16_t firm_rev;
+ 2 uint32_t framing_cap;
+ 2 uint32_t framing_type;
2 u_char hostname[64];
- 2 u_int32_t id;
- 2 u_int16_t max_channel;
- 5 u_int16_t peer_call_id;
- 2 u_int32_t phy_chan_id;
- 4 u_int16_t pkt_proc_delay;
- 2 u_int16_t proto_ver;
- 4 u_int16_t recv_winsiz;
- 2 u_int8_t reserved1;
- 9 u_int16_t reserved1;
- 6 u_int8_t result_code;
+ 2 uint32_t id;
+ 2 uint16_t max_channel;
+ 5 uint16_t peer_call_id;
+ 2 uint32_t phy_chan_id;
+ 4 uint16_t pkt_proc_delay;
+ 2 uint16_t proto_ver;
+ 4 uint16_t recv_winsiz;
+ 2 uint8_t reserved1;
+ 9 uint16_t reserved1;
+ 6 uint8_t result_code;
2 u_char subaddr[64];
2 u_char vendor[64];
@@ -272,781 +265,733 @@ struct pptp_msg_sli {
/******************************************/
/* In these attribute-specific print-out functions, it't not necessary
- to do TCHECK because they are already checked in the caller of
+ to do ND_TCHECK because they are already checked in the caller of
these functions. */
static void
-pptp_bearer_cap_print(const u_int32_t *bearer_cap)
+pptp_bearer_cap_print(netdissect_options *ndo,
+ const uint32_t *bearer_cap)
{
- printf(" BEARER_CAP(");
- if (EXTRACT_32BITS(bearer_cap) & PPTP_BEARER_CAP_DIGITAL_MASK) {
- printf("D");
- }
- if (EXTRACT_32BITS(bearer_cap) & PPTP_BEARER_CAP_ANALOG_MASK) {
- printf("A");
- }
- printf(")");
+ ND_PRINT((ndo, " BEARER_CAP(%s%s)",
+ EXTRACT_32BITS(bearer_cap) & PPTP_BEARER_CAP_DIGITAL_MASK ? "D" : "",
+ EXTRACT_32BITS(bearer_cap) & PPTP_BEARER_CAP_ANALOG_MASK ? "A" : ""));
}
+static const struct tok pptp_btype_str[] = {
+ { 1, "A" }, /* Analog */
+ { 2, "D" }, /* Digital */
+ { 3, "Any" },
+ { 0, NULL }
+};
+
static void
-pptp_bearer_type_print(const u_int32_t *bearer_type)
+pptp_bearer_type_print(netdissect_options *ndo,
+ const uint32_t *bearer_type)
{
- printf(" BEARER_TYPE(");
- switch (EXTRACT_32BITS(bearer_type)) {
- case 1:
- printf("A"); /* Analog */
- break;
- case 2:
- printf("D"); /* Digital */
- break;
- case 3:
- printf("Any");
- break;
- default:
- printf("?");
- break;
- }
- printf(")");
+ ND_PRINT((ndo, " BEARER_TYPE(%s)",
+ tok2str(pptp_btype_str, "?", EXTRACT_32BITS(bearer_type))));
}
static void
-pptp_call_id_print(const u_int16_t *call_id)
+pptp_call_id_print(netdissect_options *ndo,
+ const uint16_t *call_id)
{
- printf(" CALL_ID(%u)", EXTRACT_16BITS(call_id));
+ ND_PRINT((ndo, " CALL_ID(%u)", EXTRACT_16BITS(call_id)));
}
static void
-pptp_call_ser_print(const u_int16_t *call_ser)
+pptp_call_ser_print(netdissect_options *ndo,
+ const uint16_t *call_ser)
{
- printf(" CALL_SER_NUM(%u)", EXTRACT_16BITS(call_ser));
+ ND_PRINT((ndo, " CALL_SER_NUM(%u)", EXTRACT_16BITS(call_ser)));
}
static void
-pptp_cause_code_print(const u_int16_t *cause_code)
+pptp_cause_code_print(netdissect_options *ndo,
+ const uint16_t *cause_code)
{
- printf(" CAUSE_CODE(%u)", EXTRACT_16BITS(cause_code));
+ ND_PRINT((ndo, " CAUSE_CODE(%u)", EXTRACT_16BITS(cause_code)));
}
static void
-pptp_conn_speed_print(const u_int32_t *conn_speed)
+pptp_conn_speed_print(netdissect_options *ndo,
+ const uint32_t *conn_speed)
{
- printf(" CONN_SPEED(%u)", EXTRACT_32BITS(conn_speed));
+ ND_PRINT((ndo, " CONN_SPEED(%u)", EXTRACT_32BITS(conn_speed)));
}
+static const struct tok pptp_errcode_str[] = {
+ { 0, "None" },
+ { 1, "Not-Connected" },
+ { 2, "Bad-Format" },
+ { 3, "Bad-Value" },
+ { 4, "No-Resource" },
+ { 5, "Bad-Call-ID" },
+ { 6, "PAC-Error" },
+ { 0, NULL }
+};
+
static void
-pptp_err_code_print(const u_int8_t *err_code)
+pptp_err_code_print(netdissect_options *ndo,
+ const uint8_t *err_code)
{
- printf(" ERR_CODE(%u", *err_code);
- if (vflag) {
- switch (*err_code) {
- case 0:
- printf(":None");
- break;
- case 1:
- printf(":Not-Connected");
- break;
- case 2:
- printf(":Bad-Format");
- break;
- case 3:
- printf(":Bad-Valude");
- break;
- case 4:
- printf(":No-Resource");
- break;
- case 5:
- printf(":Bad-Call-ID");
- break;
- case 6:
- printf(":PAC-Error");
- break;
- default:
- printf(":?");
- break;
- }
+ ND_PRINT((ndo, " ERR_CODE(%u", *err_code));
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, ":%s", tok2str(pptp_errcode_str, "?", *err_code)));
}
- printf(")");
+ ND_PRINT((ndo, ")"));
}
static void
-pptp_firm_rev_print(const u_int16_t *firm_rev)
+pptp_firm_rev_print(netdissect_options *ndo,
+ const uint16_t *firm_rev)
{
- printf(" FIRM_REV(%u)", EXTRACT_16BITS(firm_rev));
+ ND_PRINT((ndo, " FIRM_REV(%u)", EXTRACT_16BITS(firm_rev)));
}
static void
-pptp_framing_cap_print(const u_int32_t *framing_cap)
+pptp_framing_cap_print(netdissect_options *ndo,
+ const uint32_t *framing_cap)
{
- printf(" FRAME_CAP(");
+ ND_PRINT((ndo, " FRAME_CAP("));
if (EXTRACT_32BITS(framing_cap) & PPTP_FRAMING_CAP_ASYNC_MASK) {
- printf("A"); /* Async */
+ ND_PRINT((ndo, "A")); /* Async */
}
if (EXTRACT_32BITS(framing_cap) & PPTP_FRAMING_CAP_SYNC_MASK) {
- printf("S"); /* Sync */
+ ND_PRINT((ndo, "S")); /* Sync */
}
- printf(")");
+ ND_PRINT((ndo, ")"));
}
+static const struct tok pptp_ftype_str[] = {
+ { 1, "A" }, /* Async */
+ { 2, "S" }, /* Sync */
+ { 3, "E" }, /* Either */
+ { 0, NULL }
+};
+
static void
-pptp_framing_type_print(const u_int32_t *framing_type)
+pptp_framing_type_print(netdissect_options *ndo,
+ const uint32_t *framing_type)
{
- printf(" FRAME_TYPE(");
- switch (EXTRACT_32BITS(framing_type)) {
- case 1:
- printf("A"); /* Async */
- break;
- case 2:
- printf("S"); /* Sync */
- break;
- case 3:
- printf("E"); /* Either */
- break;
- default:
- printf("?");
- break;
- }
- printf(")");
+ ND_PRINT((ndo, " FRAME_TYPE(%s)",
+ tok2str(pptp_ftype_str, "?", EXTRACT_32BITS(framing_type))));
}
static void
-pptp_hostname_print(const u_char *hostname)
+pptp_hostname_print(netdissect_options *ndo,
+ const u_char *hostname)
{
- printf(" HOSTNAME(%.64s)", hostname);
+ ND_PRINT((ndo, " HOSTNAME(%.64s)", hostname));
}
static void
-pptp_id_print(const u_int32_t *id)
+pptp_id_print(netdissect_options *ndo,
+ const uint32_t *id)
{
- printf(" ID(%u)", EXTRACT_32BITS(id));
+ ND_PRINT((ndo, " ID(%u)", EXTRACT_32BITS(id)));
}
static void
-pptp_max_channel_print(const u_int16_t *max_channel)
+pptp_max_channel_print(netdissect_options *ndo,
+ const uint16_t *max_channel)
{
- printf(" MAX_CHAN(%u)", EXTRACT_16BITS(max_channel));
+ ND_PRINT((ndo, " MAX_CHAN(%u)", EXTRACT_16BITS(max_channel)));
}
static void
-pptp_peer_call_id_print(const u_int16_t *peer_call_id)
+pptp_peer_call_id_print(netdissect_options *ndo,
+ const uint16_t *peer_call_id)
{
- printf(" PEER_CALL_ID(%u)", EXTRACT_16BITS(peer_call_id));
+ ND_PRINT((ndo, " PEER_CALL_ID(%u)", EXTRACT_16BITS(peer_call_id)));
}
static void
-pptp_phy_chan_id_print(const u_int32_t *phy_chan_id)
+pptp_phy_chan_id_print(netdissect_options *ndo,
+ const uint32_t *phy_chan_id)
{
- printf(" PHY_CHAN_ID(%u)", EXTRACT_32BITS(phy_chan_id));
+ ND_PRINT((ndo, " PHY_CHAN_ID(%u)", EXTRACT_32BITS(phy_chan_id)));
}
static void
-pptp_pkt_proc_delay_print(const u_int16_t *pkt_proc_delay)
+pptp_pkt_proc_delay_print(netdissect_options *ndo,
+ const uint16_t *pkt_proc_delay)
{
- printf(" PROC_DELAY(%u)", EXTRACT_16BITS(pkt_proc_delay));
+ ND_PRINT((ndo, " PROC_DELAY(%u)", EXTRACT_16BITS(pkt_proc_delay)));
}
static void
-pptp_proto_ver_print(const u_int16_t *proto_ver)
+pptp_proto_ver_print(netdissect_options *ndo,
+ const uint16_t *proto_ver)
{
- printf(" PROTO_VER(%u.%u)", /* Version.Revision */
+ ND_PRINT((ndo, " PROTO_VER(%u.%u)", /* Version.Revision */
EXTRACT_16BITS(proto_ver) >> 8,
- EXTRACT_16BITS(proto_ver) & 0xff);
+ EXTRACT_16BITS(proto_ver) & 0xff));
}
static void
-pptp_recv_winsiz_print(const u_int16_t *recv_winsiz)
+pptp_recv_winsiz_print(netdissect_options *ndo,
+ const uint16_t *recv_winsiz)
{
- printf(" RECV_WIN(%u)", EXTRACT_16BITS(recv_winsiz));
+ ND_PRINT((ndo, " RECV_WIN(%u)", EXTRACT_16BITS(recv_winsiz)));
}
+static const struct tok pptp_scrrp_str[] = {
+ { 1, "Successful channel establishment" },
+ { 2, "General error" },
+ { 3, "Command channel already exists" },
+ { 4, "Requester is not authorized to establish a command channel" },
+ { 5, "The protocol version of the requester is not supported" },
+ { 0, NULL }
+};
+
+static const struct tok pptp_echorp_str[] = {
+ { 1, "OK" },
+ { 2, "General Error" },
+ { 0, NULL }
+};
+
+static const struct tok pptp_ocrp_str[] = {
+ { 1, "Connected" },
+ { 2, "General Error" },
+ { 3, "No Carrier" },
+ { 4, "Busy" },
+ { 5, "No Dial Tone" },
+ { 6, "Time-out" },
+ { 7, "Do Not Accept" },
+ { 0, NULL }
+};
+
+static const struct tok pptp_icrp_str[] = {
+ { 1, "Connect" },
+ { 2, "General Error" },
+ { 3, "Do Not Accept" },
+ { 0, NULL }
+};
+
+static const struct tok pptp_cdn_str[] = {
+ { 1, "Lost Carrier" },
+ { 2, "General Error" },
+ { 3, "Admin Shutdown" },
+ { 4, "Request" },
+ { 0, NULL }
+};
+
static void
-pptp_result_code_print(const u_int8_t *result_code, int ctrl_msg_type)
-{
- printf(" RESULT_CODE(%u", *result_code);
- if (vflag) {
- switch (ctrl_msg_type) {
- case PPTP_CTRL_MSG_TYPE_SCCRP:
- switch (*result_code) {
- case 1:
- printf(":Successful channel establishment");
- break;
- case 2:
- printf(":General error");
- break;
- case 3:
- printf(":Command channel already exists");
- break;
- case 4:
- printf(":Requester is not authorized to establish a command channel");
- break;
- case 5:
- printf(":The protocol version of the requester is not supported");
- break;
- default:
- printf(":?");
- break;
- }
- break;
- case PPTP_CTRL_MSG_TYPE_StopCCRP:
- case PPTP_CTRL_MSG_TYPE_ECHORP:
- switch (*result_code) {
- case 1:
- printf(":OK");
- break;
- case 2:
- printf(":General Error");
- break;
- default:
- printf(":?");
- break;
- }
- break;
- case PPTP_CTRL_MSG_TYPE_OCRP:
- switch (*result_code) {
- case 1:
- printf(":Connected");
- break;
- case 2:
- printf(":General Error");
- break;
- case 3:
- printf(":No Carrier");
- break;
- case 4:
- printf(":Busy");
- break;
- case 5:
- printf(":No Dial Tone");
- break;
- case 6:
- printf(":Time-out");
- break;
- case 7:
- printf(":Do Not Accept");
- break;
- default:
- printf(":?");
- break;
- }
- break;
- case PPTP_CTRL_MSG_TYPE_ICRP:
- switch (*result_code) {
- case 1:
- printf(":Connect");
- break;
- case 2:
- printf(":General Error");
- break;
- case 3:
- printf(":Do Not Accept");
- break;
- default:
- printf(":?");
- break;
- }
- break;
- case PPTP_CTRL_MSG_TYPE_CDN:
- switch (*result_code) {
- case 1:
- printf(":Lost Carrier");
- break;
- case 2:
- printf(":General Error");
- break;
- case 3:
- printf(":Admin Shutdown");
- break;
- case 4:
- printf(":Request");
- default:
- printf(":?");
- break;
- break;
- }
- default:
- /* assertion error */
- break;
- }
+pptp_result_code_print(netdissect_options *ndo,
+ const uint8_t *result_code, int ctrl_msg_type)
+{
+ ND_PRINT((ndo, " RESULT_CODE(%u", *result_code));
+ if (ndo->ndo_vflag) {
+ const struct tok *dict =
+ ctrl_msg_type == PPTP_CTRL_MSG_TYPE_SCCRP ? pptp_scrrp_str :
+ ctrl_msg_type == PPTP_CTRL_MSG_TYPE_StopCCRP ? pptp_echorp_str :
+ ctrl_msg_type == PPTP_CTRL_MSG_TYPE_ECHORP ? pptp_echorp_str :
+ ctrl_msg_type == PPTP_CTRL_MSG_TYPE_OCRP ? pptp_ocrp_str :
+ ctrl_msg_type == PPTP_CTRL_MSG_TYPE_ICRP ? pptp_icrp_str :
+ ctrl_msg_type == PPTP_CTRL_MSG_TYPE_CDN ? pptp_cdn_str :
+ NULL; /* assertion error */
+ if (dict != NULL)
+ ND_PRINT((ndo, ":%s", tok2str(dict, "?", *result_code)));
}
- printf(")");
+ ND_PRINT((ndo, ")"));
}
static void
-pptp_subaddr_print(const u_char *subaddr)
+pptp_subaddr_print(netdissect_options *ndo,
+ const u_char *subaddr)
{
- printf(" SUB_ADDR(%.64s)", subaddr);
+ ND_PRINT((ndo, " SUB_ADDR(%.64s)", subaddr));
}
static void
-pptp_vendor_print(const u_char *vendor)
+pptp_vendor_print(netdissect_options *ndo,
+ const u_char *vendor)
{
- printf(" VENDOR(%.64s)", vendor);
+ ND_PRINT((ndo, " VENDOR(%.64s)", vendor));
}
/************************************/
/* PPTP message print out functions */
/************************************/
static void
-pptp_sccrq_print(const u_char *dat)
+pptp_sccrq_print(netdissect_options *ndo,
+ const u_char *dat)
{
struct pptp_msg_sccrq *ptr = (struct pptp_msg_sccrq *)dat;
- TCHECK(ptr->proto_ver);
- pptp_proto_ver_print(&ptr->proto_ver);
- TCHECK(ptr->reserved1);
- TCHECK(ptr->framing_cap);
- pptp_framing_cap_print(&ptr->framing_cap);
- TCHECK(ptr->bearer_cap);
- pptp_bearer_cap_print(&ptr->bearer_cap);
- TCHECK(ptr->max_channel);
- pptp_max_channel_print(&ptr->max_channel);
- TCHECK(ptr->firm_rev);
- pptp_firm_rev_print(&ptr->firm_rev);
- TCHECK(ptr->hostname);
- pptp_hostname_print(&ptr->hostname[0]);
- TCHECK(ptr->vendor);
- pptp_vendor_print(&ptr->vendor[0]);
+ ND_TCHECK(ptr->proto_ver);
+ pptp_proto_ver_print(ndo, &ptr->proto_ver);
+ ND_TCHECK(ptr->reserved1);
+ ND_TCHECK(ptr->framing_cap);
+ pptp_framing_cap_print(ndo, &ptr->framing_cap);
+ ND_TCHECK(ptr->bearer_cap);
+ pptp_bearer_cap_print(ndo, &ptr->bearer_cap);
+ ND_TCHECK(ptr->max_channel);
+ pptp_max_channel_print(ndo, &ptr->max_channel);
+ ND_TCHECK(ptr->firm_rev);
+ pptp_firm_rev_print(ndo, &ptr->firm_rev);
+ ND_TCHECK(ptr->hostname);
+ pptp_hostname_print(ndo, &ptr->hostname[0]);
+ ND_TCHECK(ptr->vendor);
+ pptp_vendor_print(ndo, &ptr->vendor[0]);
return;
trunc:
- printf("%s", tstr);
+ ND_PRINT((ndo, "%s", tstr));
}
static void
-pptp_sccrp_print(const u_char *dat)
+pptp_sccrp_print(netdissect_options *ndo,
+ const u_char *dat)
{
struct pptp_msg_sccrp *ptr = (struct pptp_msg_sccrp *)dat;
- TCHECK(ptr->proto_ver);
- pptp_proto_ver_print(&ptr->proto_ver);
- TCHECK(ptr->result_code);
- pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_SCCRP);
- TCHECK(ptr->err_code);
- pptp_err_code_print(&ptr->err_code);
- TCHECK(ptr->framing_cap);
- pptp_framing_cap_print(&ptr->framing_cap);
- TCHECK(ptr->bearer_cap);
- pptp_bearer_cap_print(&ptr->bearer_cap);
- TCHECK(ptr->max_channel);
- pptp_max_channel_print(&ptr->max_channel);
- TCHECK(ptr->firm_rev);
- pptp_firm_rev_print(&ptr->firm_rev);
- TCHECK(ptr->hostname);
- pptp_hostname_print(&ptr->hostname[0]);
- TCHECK(ptr->vendor);
- pptp_vendor_print(&ptr->vendor[0]);
+ ND_TCHECK(ptr->proto_ver);
+ pptp_proto_ver_print(ndo, &ptr->proto_ver);
+ ND_TCHECK(ptr->result_code);
+ pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_SCCRP);
+ ND_TCHECK(ptr->err_code);
+ pptp_err_code_print(ndo, &ptr->err_code);
+ ND_TCHECK(ptr->framing_cap);
+ pptp_framing_cap_print(ndo, &ptr->framing_cap);
+ ND_TCHECK(ptr->bearer_cap);
+ pptp_bearer_cap_print(ndo, &ptr->bearer_cap);
+ ND_TCHECK(ptr->max_channel);
+ pptp_max_channel_print(ndo, &ptr->max_channel);
+ ND_TCHECK(ptr->firm_rev);
+ pptp_firm_rev_print(ndo, &ptr->firm_rev);
+ ND_TCHECK(ptr->hostname);
+ pptp_hostname_print(ndo, &ptr->hostname[0]);
+ ND_TCHECK(ptr->vendor);
+ pptp_vendor_print(ndo, &ptr->vendor[0]);
return;
trunc:
- printf("%s", tstr);
+ ND_PRINT((ndo, "%s", tstr));
}
static void
-pptp_stopccrq_print(const u_char *dat)
+pptp_stopccrq_print(netdissect_options *ndo,
+ const u_char *dat)
{
struct pptp_msg_stopccrq *ptr = (struct pptp_msg_stopccrq *)dat;
- TCHECK(ptr->reason);
- printf(" REASON(%u", ptr->reason);
- if (vflag) {
+ ND_TCHECK(ptr->reason);
+ ND_PRINT((ndo, " REASON(%u", ptr->reason));
+ if (ndo->ndo_vflag) {
switch (ptr->reason) {
case 1:
- printf(":None");
+ ND_PRINT((ndo, ":None"));
break;
case 2:
- printf(":Stop-Protocol");
+ ND_PRINT((ndo, ":Stop-Protocol"));
break;
case 3:
- printf(":Stop-Local-Shutdown");
+ ND_PRINT((ndo, ":Stop-Local-Shutdown"));
break;
default:
- printf(":?");
+ ND_PRINT((ndo, ":?"));
break;
}
}
- printf(")");
- TCHECK(ptr->reserved1);
- TCHECK(ptr->reserved2);
+ ND_PRINT((ndo, ")"));
+ ND_TCHECK(ptr->reserved1);
+ ND_TCHECK(ptr->reserved2);
return;
trunc:
- printf("%s", tstr);
+ ND_PRINT((ndo, "%s", tstr));
}
static void
-pptp_stopccrp_print(const u_char *dat)
+pptp_stopccrp_print(netdissect_options *ndo,
+ const u_char *dat)
{
struct pptp_msg_stopccrp *ptr = (struct pptp_msg_stopccrp *)dat;
- TCHECK(ptr->result_code);
- pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_StopCCRP);
- TCHECK(ptr->err_code);
- pptp_err_code_print(&ptr->err_code);
- TCHECK(ptr->reserved1);
+ ND_TCHECK(ptr->result_code);
+ pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_StopCCRP);
+ ND_TCHECK(ptr->err_code);
+ pptp_err_code_print(ndo, &ptr->err_code);
+ ND_TCHECK(ptr->reserved1);
return;
trunc:
- printf("%s", tstr);
+ ND_PRINT((ndo, "%s", tstr));
}
static void
-pptp_echorq_print(const u_char *dat)
+pptp_echorq_print(netdissect_options *ndo,
+ const u_char *dat)
{
struct pptp_msg_echorq *ptr = (struct pptp_msg_echorq *)dat;
- TCHECK(ptr->id);
- pptp_id_print(&ptr->id);
+ ND_TCHECK(ptr->id);
+ pptp_id_print(ndo, &ptr->id);
return;
trunc:
- printf("%s", tstr);
+ ND_PRINT((ndo, "%s", tstr));
}
static void
-pptp_echorp_print(const u_char *dat)
+pptp_echorp_print(netdissect_options *ndo,
+ const u_char *dat)
{
struct pptp_msg_echorp *ptr = (struct pptp_msg_echorp *)dat;
- TCHECK(ptr->id);
- pptp_id_print(&ptr->id);
- TCHECK(ptr->result_code);
- pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_ECHORP);
- TCHECK(ptr->err_code);
- pptp_err_code_print(&ptr->err_code);
- TCHECK(ptr->reserved1);
+ ND_TCHECK(ptr->id);
+ pptp_id_print(ndo, &ptr->id);
+ ND_TCHECK(ptr->result_code);
+ pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_ECHORP);
+ ND_TCHECK(ptr->err_code);
+ pptp_err_code_print(ndo, &ptr->err_code);
+ ND_TCHECK(ptr->reserved1);
return;
trunc:
- printf("%s", tstr);
+ ND_PRINT((ndo, "%s", tstr));
}
static void
-pptp_ocrq_print(const u_char *dat)
+pptp_ocrq_print(netdissect_options *ndo,
+ const u_char *dat)
{
struct pptp_msg_ocrq *ptr = (struct pptp_msg_ocrq *)dat;
- TCHECK(ptr->call_id);
- pptp_call_id_print(&ptr->call_id);
- TCHECK(ptr->call_ser);
- pptp_call_ser_print(&ptr->call_ser);
- TCHECK(ptr->min_bps);
- printf(" MIN_BPS(%u)", EXTRACT_32BITS(&ptr->min_bps));
- TCHECK(ptr->max_bps);
- printf(" MAX_BPS(%u)", EXTRACT_32BITS(&ptr->max_bps));
- TCHECK(ptr->bearer_type);
- pptp_bearer_type_print(&ptr->bearer_type);
- TCHECK(ptr->framing_type);
- pptp_framing_type_print(&ptr->framing_type);
- TCHECK(ptr->recv_winsiz);
- pptp_recv_winsiz_print(&ptr->recv_winsiz);
- TCHECK(ptr->pkt_proc_delay);
- pptp_pkt_proc_delay_print(&ptr->pkt_proc_delay);
- TCHECK(ptr->phone_no_len);
- printf(" PHONE_NO_LEN(%u)", EXTRACT_16BITS(&ptr->phone_no_len));
- TCHECK(ptr->reserved1);
- TCHECK(ptr->phone_no);
- printf(" PHONE_NO(%.64s)", ptr->phone_no);
- TCHECK(ptr->subaddr);
- pptp_subaddr_print(&ptr->subaddr[0]);
+ ND_TCHECK(ptr->call_id);
+ pptp_call_id_print(ndo, &ptr->call_id);
+ ND_TCHECK(ptr->call_ser);
+ pptp_call_ser_print(ndo, &ptr->call_ser);
+ ND_TCHECK(ptr->min_bps);
+ ND_PRINT((ndo, " MIN_BPS(%u)", EXTRACT_32BITS(&ptr->min_bps)));
+ ND_TCHECK(ptr->max_bps);
+ ND_PRINT((ndo, " MAX_BPS(%u)", EXTRACT_32BITS(&ptr->max_bps)));
+ ND_TCHECK(ptr->bearer_type);
+ pptp_bearer_type_print(ndo, &ptr->bearer_type);
+ ND_TCHECK(ptr->framing_type);
+ pptp_framing_type_print(ndo, &ptr->framing_type);
+ ND_TCHECK(ptr->recv_winsiz);
+ pptp_recv_winsiz_print(ndo, &ptr->recv_winsiz);
+ ND_TCHECK(ptr->pkt_proc_delay);
+ pptp_pkt_proc_delay_print(ndo, &ptr->pkt_proc_delay);
+ ND_TCHECK(ptr->phone_no_len);
+ ND_PRINT((ndo, " PHONE_NO_LEN(%u)", EXTRACT_16BITS(&ptr->phone_no_len)));
+ ND_TCHECK(ptr->reserved1);
+ ND_TCHECK(ptr->phone_no);
+ ND_PRINT((ndo, " PHONE_NO(%.64s)", ptr->phone_no));
+ ND_TCHECK(ptr->subaddr);
+ pptp_subaddr_print(ndo, &ptr->subaddr[0]);
return;
trunc:
- printf("%s", tstr);
+ ND_PRINT((ndo, "%s", tstr));
}
static void
-pptp_ocrp_print(const u_char *dat)
+pptp_ocrp_print(netdissect_options *ndo,
+ const u_char *dat)
{
struct pptp_msg_ocrp *ptr = (struct pptp_msg_ocrp *)dat;
- TCHECK(ptr->call_id);
- pptp_call_id_print(&ptr->call_id);
- TCHECK(ptr->peer_call_id);
- pptp_peer_call_id_print(&ptr->peer_call_id);
- TCHECK(ptr->result_code);
- pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_OCRP);
- TCHECK(ptr->err_code);
- pptp_err_code_print(&ptr->err_code);
- TCHECK(ptr->cause_code);
- pptp_cause_code_print(&ptr->cause_code);
- TCHECK(ptr->conn_speed);
- pptp_conn_speed_print(&ptr->conn_speed);
- TCHECK(ptr->recv_winsiz);
- pptp_recv_winsiz_print(&ptr->recv_winsiz);
- TCHECK(ptr->pkt_proc_delay);
- pptp_pkt_proc_delay_print(&ptr->pkt_proc_delay);
- TCHECK(ptr->phy_chan_id);
- pptp_phy_chan_id_print(&ptr->phy_chan_id);
+ ND_TCHECK(ptr->call_id);
+ pptp_call_id_print(ndo, &ptr->call_id);
+ ND_TCHECK(ptr->peer_call_id);
+ pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
+ ND_TCHECK(ptr->result_code);
+ pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_OCRP);
+ ND_TCHECK(ptr->err_code);
+ pptp_err_code_print(ndo, &ptr->err_code);
+ ND_TCHECK(ptr->cause_code);
+ pptp_cause_code_print(ndo, &ptr->cause_code);
+ ND_TCHECK(ptr->conn_speed);
+ pptp_conn_speed_print(ndo, &ptr->conn_speed);
+ ND_TCHECK(ptr->recv_winsiz);
+ pptp_recv_winsiz_print(ndo, &ptr->recv_winsiz);
+ ND_TCHECK(ptr->pkt_proc_delay);
+ pptp_pkt_proc_delay_print(ndo, &ptr->pkt_proc_delay);
+ ND_TCHECK(ptr->phy_chan_id);
+ pptp_phy_chan_id_print(ndo, &ptr->phy_chan_id);
return;
trunc:
- printf("%s", tstr);
+ ND_PRINT((ndo, "%s", tstr));
}
static void
-pptp_icrq_print(const u_char *dat)
+pptp_icrq_print(netdissect_options *ndo,
+ const u_char *dat)
{
struct pptp_msg_icrq *ptr = (struct pptp_msg_icrq *)dat;
- TCHECK(ptr->call_id);
- pptp_call_id_print(&ptr->call_id);
- TCHECK(ptr->call_ser);
- pptp_call_ser_print(&ptr->call_ser);
- TCHECK(ptr->bearer_type);
- pptp_bearer_type_print(&ptr->bearer_type);
- TCHECK(ptr->phy_chan_id);
- pptp_phy_chan_id_print(&ptr->phy_chan_id);
- TCHECK(ptr->dialed_no_len);
- printf(" DIALED_NO_LEN(%u)", EXTRACT_16BITS(&ptr->dialed_no_len));
- TCHECK(ptr->dialing_no_len);
- printf(" DIALING_NO_LEN(%u)", EXTRACT_16BITS(&ptr->dialing_no_len));
- TCHECK(ptr->dialed_no);
- printf(" DIALED_NO(%.64s)", ptr->dialed_no);
- TCHECK(ptr->dialing_no);
- printf(" DIALING_NO(%.64s)", ptr->dialing_no);
- TCHECK(ptr->subaddr);
- pptp_subaddr_print(&ptr->subaddr[0]);
+ ND_TCHECK(ptr->call_id);
+ pptp_call_id_print(ndo, &ptr->call_id);
+ ND_TCHECK(ptr->call_ser);
+ pptp_call_ser_print(ndo, &ptr->call_ser);
+ ND_TCHECK(ptr->bearer_type);
+ pptp_bearer_type_print(ndo, &ptr->bearer_type);
+ ND_TCHECK(ptr->phy_chan_id);
+ pptp_phy_chan_id_print(ndo, &ptr->phy_chan_id);
+ ND_TCHECK(ptr->dialed_no_len);
+ ND_PRINT((ndo, " DIALED_NO_LEN(%u)", EXTRACT_16BITS(&ptr->dialed_no_len)));
+ ND_TCHECK(ptr->dialing_no_len);
+ ND_PRINT((ndo, " DIALING_NO_LEN(%u)", EXTRACT_16BITS(&ptr->dialing_no_len)));
+ ND_TCHECK(ptr->dialed_no);
+ ND_PRINT((ndo, " DIALED_NO(%.64s)", ptr->dialed_no));
+ ND_TCHECK(ptr->dialing_no);
+ ND_PRINT((ndo, " DIALING_NO(%.64s)", ptr->dialing_no));
+ ND_TCHECK(ptr->subaddr);
+ pptp_subaddr_print(ndo, &ptr->subaddr[0]);
return;
trunc:
- printf("%s", tstr);
+ ND_PRINT((ndo, "%s", tstr));
}
static void
-pptp_icrp_print(const u_char *dat)
+pptp_icrp_print(netdissect_options *ndo,
+ const u_char *dat)
{
struct pptp_msg_icrp *ptr = (struct pptp_msg_icrp *)dat;
- TCHECK(ptr->call_id);
- pptp_call_id_print(&ptr->call_id);
- TCHECK(ptr->peer_call_id);
- pptp_peer_call_id_print(&ptr->peer_call_id);
- TCHECK(ptr->result_code);
- pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_ICRP);
- TCHECK(ptr->err_code);
- pptp_err_code_print(&ptr->err_code);
- TCHECK(ptr->recv_winsiz);
- pptp_recv_winsiz_print(&ptr->recv_winsiz);
- TCHECK(ptr->pkt_proc_delay);
- pptp_pkt_proc_delay_print(&ptr->pkt_proc_delay);
- TCHECK(ptr->reserved1);
+ ND_TCHECK(ptr->call_id);
+ pptp_call_id_print(ndo, &ptr->call_id);
+ ND_TCHECK(ptr->peer_call_id);
+ pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
+ ND_TCHECK(ptr->result_code);
+ pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_ICRP);
+ ND_TCHECK(ptr->err_code);
+ pptp_err_code_print(ndo, &ptr->err_code);
+ ND_TCHECK(ptr->recv_winsiz);
+ pptp_recv_winsiz_print(ndo, &ptr->recv_winsiz);
+ ND_TCHECK(ptr->pkt_proc_delay);
+ pptp_pkt_proc_delay_print(ndo, &ptr->pkt_proc_delay);
+ ND_TCHECK(ptr->reserved1);
return;
trunc:
- printf("%s", tstr);
+ ND_PRINT((ndo, "%s", tstr));
}
static void
-pptp_iccn_print(const u_char *dat)
+pptp_iccn_print(netdissect_options *ndo,
+ const u_char *dat)
{
struct pptp_msg_iccn *ptr = (struct pptp_msg_iccn *)dat;
- TCHECK(ptr->peer_call_id);
- pptp_peer_call_id_print(&ptr->peer_call_id);
- TCHECK(ptr->reserved1);
- TCHECK(ptr->conn_speed);
- pptp_conn_speed_print(&ptr->conn_speed);
- TCHECK(ptr->recv_winsiz);
- pptp_recv_winsiz_print(&ptr->recv_winsiz);
- TCHECK(ptr->pkt_proc_delay);
- pptp_pkt_proc_delay_print(&ptr->pkt_proc_delay);
- TCHECK(ptr->framing_type);
- pptp_framing_type_print(&ptr->framing_type);
+ ND_TCHECK(ptr->peer_call_id);
+ pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
+ ND_TCHECK(ptr->reserved1);
+ ND_TCHECK(ptr->conn_speed);
+ pptp_conn_speed_print(ndo, &ptr->conn_speed);
+ ND_TCHECK(ptr->recv_winsiz);
+ pptp_recv_winsiz_print(ndo, &ptr->recv_winsiz);
+ ND_TCHECK(ptr->pkt_proc_delay);
+ pptp_pkt_proc_delay_print(ndo, &ptr->pkt_proc_delay);
+ ND_TCHECK(ptr->framing_type);
+ pptp_framing_type_print(ndo, &ptr->framing_type);
return;
trunc:
- printf("%s", tstr);
+ ND_PRINT((ndo, "%s", tstr));
}
static void
-pptp_ccrq_print(const u_char *dat)
+pptp_ccrq_print(netdissect_options *ndo,
+ const u_char *dat)
{
struct pptp_msg_ccrq *ptr = (struct pptp_msg_ccrq *)dat;
- TCHECK(ptr->call_id);
- pptp_call_id_print(&ptr->call_id);
- TCHECK(ptr->reserved1);
+ ND_TCHECK(ptr->call_id);
+ pptp_call_id_print(ndo, &ptr->call_id);
+ ND_TCHECK(ptr->reserved1);
return;
trunc:
- printf("%s", tstr);
+ ND_PRINT((ndo, "%s", tstr));
}
static void
-pptp_cdn_print(const u_char *dat)
+pptp_cdn_print(netdissect_options *ndo,
+ const u_char *dat)
{
struct pptp_msg_cdn *ptr = (struct pptp_msg_cdn *)dat;
- TCHECK(ptr->call_id);
- pptp_call_id_print(&ptr->call_id);
- TCHECK(ptr->result_code);
- pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_CDN);
- TCHECK(ptr->err_code);
- pptp_err_code_print(&ptr->err_code);
- TCHECK(ptr->cause_code);
- pptp_cause_code_print(&ptr->cause_code);
- TCHECK(ptr->reserved1);
- TCHECK(ptr->call_stats);
- printf(" CALL_STATS(%.128s)", ptr->call_stats);
+ ND_TCHECK(ptr->call_id);
+ pptp_call_id_print(ndo, &ptr->call_id);
+ ND_TCHECK(ptr->result_code);
+ pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_CDN);
+ ND_TCHECK(ptr->err_code);
+ pptp_err_code_print(ndo, &ptr->err_code);
+ ND_TCHECK(ptr->cause_code);
+ pptp_cause_code_print(ndo, &ptr->cause_code);
+ ND_TCHECK(ptr->reserved1);
+ ND_TCHECK(ptr->call_stats);
+ ND_PRINT((ndo, " CALL_STATS(%.128s)", ptr->call_stats));
return;
trunc:
- printf("%s", tstr);
+ ND_PRINT((ndo, "%s", tstr));
}
static void
-pptp_wen_print(const u_char *dat)
+pptp_wen_print(netdissect_options *ndo,
+ const u_char *dat)
{
struct pptp_msg_wen *ptr = (struct pptp_msg_wen *)dat;
- TCHECK(ptr->peer_call_id);
- pptp_peer_call_id_print(&ptr->peer_call_id);
- TCHECK(ptr->reserved1);
- TCHECK(ptr->crc_err);
- printf(" CRC_ERR(%u)", EXTRACT_32BITS(&ptr->crc_err));
- TCHECK(ptr->framing_err);
- printf(" FRAMING_ERR(%u)", EXTRACT_32BITS(&ptr->framing_err));
- TCHECK(ptr->hardware_overrun);
- printf(" HARDWARE_OVERRUN(%u)", EXTRACT_32BITS(&ptr->hardware_overrun));
- TCHECK(ptr->buffer_overrun);
- printf(" BUFFER_OVERRUN(%u)", EXTRACT_32BITS(&ptr->buffer_overrun));
- TCHECK(ptr->timeout_err);
- printf(" TIMEOUT_ERR(%u)", EXTRACT_32BITS(&ptr->timeout_err));
- TCHECK(ptr->align_err);
- printf(" ALIGN_ERR(%u)", EXTRACT_32BITS(&ptr->align_err));
+ ND_TCHECK(ptr->peer_call_id);
+ pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
+ ND_TCHECK(ptr->reserved1);
+ ND_TCHECK(ptr->crc_err);
+ ND_PRINT((ndo, " CRC_ERR(%u)", EXTRACT_32BITS(&ptr->crc_err)));
+ ND_TCHECK(ptr->framing_err);
+ ND_PRINT((ndo, " FRAMING_ERR(%u)", EXTRACT_32BITS(&ptr->framing_err)));
+ ND_TCHECK(ptr->hardware_overrun);
+ ND_PRINT((ndo, " HARDWARE_OVERRUN(%u)", EXTRACT_32BITS(&ptr->hardware_overrun)));
+ ND_TCHECK(ptr->buffer_overrun);
+ ND_PRINT((ndo, " BUFFER_OVERRUN(%u)", EXTRACT_32BITS(&ptr->buffer_overrun)));
+ ND_TCHECK(ptr->timeout_err);
+ ND_PRINT((ndo, " TIMEOUT_ERR(%u)", EXTRACT_32BITS(&ptr->timeout_err)));
+ ND_TCHECK(ptr->align_err);
+ ND_PRINT((ndo, " ALIGN_ERR(%u)", EXTRACT_32BITS(&ptr->align_err)));
return;
trunc:
- printf("%s", tstr);
+ ND_PRINT((ndo, "%s", tstr));
}
static void
-pptp_sli_print(const u_char *dat)
+pptp_sli_print(netdissect_options *ndo,
+ const u_char *dat)
{
struct pptp_msg_sli *ptr = (struct pptp_msg_sli *)dat;
- TCHECK(ptr->peer_call_id);
- pptp_peer_call_id_print(&ptr->peer_call_id);
- TCHECK(ptr->reserved1);
- TCHECK(ptr->send_accm);
- printf(" SEND_ACCM(0x%08x)", EXTRACT_32BITS(&ptr->send_accm));
- TCHECK(ptr->recv_accm);
- printf(" RECV_ACCM(0x%08x)", EXTRACT_32BITS(&ptr->recv_accm));
+ ND_TCHECK(ptr->peer_call_id);
+ pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
+ ND_TCHECK(ptr->reserved1);
+ ND_TCHECK(ptr->send_accm);
+ ND_PRINT((ndo, " SEND_ACCM(0x%08x)", EXTRACT_32BITS(&ptr->send_accm)));
+ ND_TCHECK(ptr->recv_accm);
+ ND_PRINT((ndo, " RECV_ACCM(0x%08x)", EXTRACT_32BITS(&ptr->recv_accm)));
return;
trunc:
- printf("%s", tstr);
+ ND_PRINT((ndo, "%s", tstr));
}
void
-pptp_print(const u_char *dat)
+pptp_print(netdissect_options *ndo,
+ const u_char *dat)
{
const struct pptp_hdr *hdr;
- u_int32_t mc;
- u_int16_t ctrl_msg_type;
+ uint32_t mc;
+ uint16_t ctrl_msg_type;
- printf(": pptp");
+ ND_PRINT((ndo, ": pptp"));
hdr = (struct pptp_hdr *)dat;
- TCHECK(hdr->length);
- if (vflag) {
- printf(" Length=%u", EXTRACT_16BITS(&hdr->length));
+ ND_TCHECK(hdr->length);
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, " Length=%u", EXTRACT_16BITS(&hdr->length)));
}
- TCHECK(hdr->msg_type);
- if (vflag) {
+ ND_TCHECK(hdr->msg_type);
+ if (ndo->ndo_vflag) {
switch(EXTRACT_16BITS(&hdr->msg_type)) {
case PPTP_MSG_TYPE_CTRL:
- printf(" CTRL-MSG");
+ ND_PRINT((ndo, " CTRL-MSG"));
break;
case PPTP_MSG_TYPE_MGMT:
- printf(" MGMT-MSG");
+ ND_PRINT((ndo, " MGMT-MSG"));
break;
default:
- printf(" UNKNOWN-MSG-TYPE");
+ ND_PRINT((ndo, " UNKNOWN-MSG-TYPE"));
break;
}
}
- TCHECK(hdr->magic_cookie);
+ ND_TCHECK(hdr->magic_cookie);
mc = EXTRACT_32BITS(&hdr->magic_cookie);
if (mc != PPTP_MAGIC_COOKIE) {
- printf(" UNEXPECTED Magic-Cookie!!(%08x)", mc);
+ ND_PRINT((ndo, " UNEXPECTED Magic-Cookie!!(%08x)", mc));
}
- if (vflag || mc != PPTP_MAGIC_COOKIE) {
- printf(" Magic-Cookie=%08x", mc);
+ if (ndo->ndo_vflag || mc != PPTP_MAGIC_COOKIE) {
+ ND_PRINT((ndo, " Magic-Cookie=%08x", mc));
}
- TCHECK(hdr->ctrl_msg_type);
+ ND_TCHECK(hdr->ctrl_msg_type);
ctrl_msg_type = EXTRACT_16BITS(&hdr->ctrl_msg_type);
if (ctrl_msg_type < PPTP_MAX_MSGTYPE_INDEX) {
- printf(" CTRL_MSGTYPE=%s",
- pptp_message_type_string[ctrl_msg_type]);
+ ND_PRINT((ndo, " CTRL_MSGTYPE=%s",
+ pptp_message_type_string[ctrl_msg_type]));
} else {
- printf(" UNKNOWN_CTRL_MSGTYPE(%u)", ctrl_msg_type);
+ ND_PRINT((ndo, " UNKNOWN_CTRL_MSGTYPE(%u)", ctrl_msg_type));
}
- TCHECK(hdr->reserved0);
+ ND_TCHECK(hdr->reserved0);
dat += 12;
switch(ctrl_msg_type) {
case PPTP_CTRL_MSG_TYPE_SCCRQ:
- pptp_sccrq_print(dat);
+ pptp_sccrq_print(ndo, dat);
break;
case PPTP_CTRL_MSG_TYPE_SCCRP:
- pptp_sccrp_print(dat);
+ pptp_sccrp_print(ndo, dat);
break;
case PPTP_CTRL_MSG_TYPE_StopCCRQ:
- pptp_stopccrq_print(dat);
+ pptp_stopccrq_print(ndo, dat);
break;
case PPTP_CTRL_MSG_TYPE_StopCCRP:
- pptp_stopccrp_print(dat);
+ pptp_stopccrp_print(ndo, dat);
break;
case PPTP_CTRL_MSG_TYPE_ECHORQ:
- pptp_echorq_print(dat);
+ pptp_echorq_print(ndo, dat);
break;
case PPTP_CTRL_MSG_TYPE_ECHORP:
- pptp_echorp_print(dat);
+ pptp_echorp_print(ndo, dat);
break;
case PPTP_CTRL_MSG_TYPE_OCRQ:
- pptp_ocrq_print(dat);
+ pptp_ocrq_print(ndo, dat);
break;
case PPTP_CTRL_MSG_TYPE_OCRP:
- pptp_ocrp_print(dat);
+ pptp_ocrp_print(ndo, dat);
break;
case PPTP_CTRL_MSG_TYPE_ICRQ:
- pptp_icrq_print(dat);
+ pptp_icrq_print(ndo, dat);
break;
case PPTP_CTRL_MSG_TYPE_ICRP:
- pptp_icrp_print(dat);
+ pptp_icrp_print(ndo, dat);
break;
case PPTP_CTRL_MSG_TYPE_ICCN:
- pptp_iccn_print(dat);
+ pptp_iccn_print(ndo, dat);
break;
case PPTP_CTRL_MSG_TYPE_CCRQ:
- pptp_ccrq_print(dat);
+ pptp_ccrq_print(ndo, dat);
break;
case PPTP_CTRL_MSG_TYPE_CDN:
- pptp_cdn_print(dat);
+ pptp_cdn_print(ndo, dat);
break;
case PPTP_CTRL_MSG_TYPE_WEN:
- pptp_wen_print(dat);
+ pptp_wen_print(ndo, dat);
break;
case PPTP_CTRL_MSG_TYPE_SLI:
- pptp_sli_print(dat);
+ pptp_sli_print(ndo, dat);
break;
default:
/* do nothing */
@@ -1056,5 +1001,5 @@ pptp_print(const u_char *dat)
return;
trunc:
- printf("%s", tstr);
+ ND_PRINT((ndo, "%s", tstr));
}
diff --git a/contrib/tcpdump/print-radius.c b/contrib/tcpdump/print-radius.c
index 44f0c7fce9ce..7855fa269c1e 100644
--- a/contrib/tcpdump/print-radius.c
+++ b/contrib/tcpdump/print-radius.c
@@ -42,11 +42,7 @@
* TODO: Among other things to print ok MacIntosh and Vendor values
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "$Id: print-radius.c,v 1.28 2005-09-26 01:01:55 guy Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -55,19 +51,19 @@ static const char rcsid[] _U_ =
#include <string.h>
-#include <stdio.h>
-
#include "interface.h"
#include "addrtoname.h"
#include "extract.h"
#include "oui.h"
+static const char tstr[] = " [|radius]";
+
#define TAM_SIZE(x) (sizeof(x)/sizeof(x[0]) )
#define PRINT_HEX(bytes_len, ptr_data) \
while(bytes_len) \
{ \
- printf("%02X", *ptr_data ); \
+ ND_PRINT((ndo, "%02X", *ptr_data )); \
ptr_data++; \
bytes_len--; \
}
@@ -84,7 +80,7 @@ static const char rcsid[] _U_ =
#define RADCMD_STATUS_CLI 13 /* Status-Client */
#define RADCMD_RESERVED 255 /* Reserved */
-static struct tok radius_command_values[] = {
+static const struct tok radius_command_values[] = {
{ RADCMD_ACCESS_REQ, "Access Request" },
{ RADCMD_ACCESS_ACC, "Access Accept" },
{ RADCMD_ACCESS_REJ, "Access Reject" },
@@ -136,24 +132,24 @@ static struct tok radius_command_values[] = {
/********************************/
-static void print_attr_string(register u_char *, u_int, u_short );
-static void print_attr_num(register u_char *, u_int, u_short );
-static void print_vendor_attr(register u_char *, u_int, u_short );
-static void print_attr_address(register u_char *, u_int, u_short);
-static void print_attr_time(register u_char *, u_int, u_short);
-static void print_attr_strange(register u_char *, u_int, u_short);
+static void print_attr_string(netdissect_options *, register u_char *, u_int, u_short );
+static void print_attr_num(netdissect_options *, register u_char *, u_int, u_short );
+static void print_vendor_attr(netdissect_options *, register u_char *, u_int, u_short );
+static void print_attr_address(netdissect_options *, register u_char *, u_int, u_short);
+static void print_attr_time(netdissect_options *, register u_char *, u_int, u_short);
+static void print_attr_strange(netdissect_options *, register u_char *, u_int, u_short);
-struct radius_hdr { u_int8_t code; /* Radius packet code */
- u_int8_t id; /* Radius packet id */
- u_int16_t len; /* Radius total length */
- u_int8_t auth[16]; /* Authenticator */
+struct radius_hdr { uint8_t code; /* Radius packet code */
+ uint8_t id; /* Radius packet id */
+ uint16_t len; /* Radius total length */
+ uint8_t auth[16]; /* Authenticator */
};
#define MIN_RADIUS_LEN 20
-struct radius_attr { u_int8_t type; /* Attribute type */
- u_int8_t len; /* Attribute length */
+struct radius_attr { uint8_t type; /* Attribute type */
+ uint8_t len; /* Attribute length */
};
@@ -337,7 +333,7 @@ struct attrtype { const char *name; /* Attribute name */
const char **subtypes; /* Standard Values (if any) */
u_char siz_subtypes; /* Size of total standard values */
u_char first_subtype; /* First standard value is 0 or 1 */
- void (*print_func)(register u_char *, u_int, u_short );
+ void (*print_func)(netdissect_options *, register u_char *, u_int, u_short);
} attr_type[]=
{
{ NULL, NULL, 0, 0, NULL },
@@ -429,7 +425,7 @@ struct attrtype { const char *name; /* Attribute name */
{ "Accounting Tunnel packets lost", NULL, 0, 0, print_attr_num }, /*86*/
{ "NAS Port ID", NULL, 0, 0, print_attr_string },
{ "Framed Pool", NULL, 0, 0, print_attr_string },
- { "Unassigned", NULL, 0, 0, NULL },
+ { "Chargeable User Identity", NULL, 0, 0, print_attr_string },
{ "Tunnel Client Authentication ID", NULL, 0, 0, print_attr_string },
{ "Tunnel Server Authentication ID", NULL, 0, 0, print_attr_string },
{ "Unassigned", NULL, 0, 0, NULL }, /*92*/
@@ -445,25 +441,26 @@ struct attrtype { const char *name; /* Attribute name */
/* Returns nothing. */
/*****************************/
static void
-print_attr_string(register u_char *data, u_int length, u_short attr_code )
+print_attr_string(netdissect_options *ndo,
+ register u_char *data, u_int length, u_short attr_code)
{
register u_int i;
- TCHECK2(data[0],length);
+ ND_TCHECK2(data[0],length);
switch(attr_code)
{
case TUNNEL_PASS:
if (length < 3)
{
- printf(" [|radius]");
+ ND_PRINT((ndo, "%s", tstr));
return;
}
if (*data && (*data <=0x1F) )
- printf("Tag %u, ",*data);
+ ND_PRINT((ndo, "Tag %u, ",*data));
data++;
length--;
- printf("Salt %u ",EXTRACT_16BITS(data) );
+ ND_PRINT((ndo, "Salt %u ", EXTRACT_16BITS(data)));
data+=2;
length-=2;
break;
@@ -477,10 +474,10 @@ print_attr_string(register u_char *data, u_int length, u_short attr_code )
{
if (length < 1)
{
- printf(" [|radius]");
+ ND_PRINT((ndo, "%s", tstr));
return;
}
- printf("Tag %u",*data);
+ ND_PRINT((ndo, "Tag %u", *data));
data++;
length--;
}
@@ -488,20 +485,20 @@ print_attr_string(register u_char *data, u_int length, u_short attr_code )
}
for (i=0; *data && i < length ; i++, data++)
- printf("%c",(*data < 32 || *data > 128) ? '.' : *data );
+ ND_PRINT((ndo, "%c", (*data < 32 || *data > 128) ? '.' : *data));
return;
trunc:
- printf(" [|radius]");
+ ND_PRINT((ndo, "%s", tstr));
}
/*
* print vendor specific attributes
*/
-
static void
-print_vendor_attr(register u_char *data, u_int length, u_short attr_code _U_)
+print_vendor_attr(netdissect_options *ndo,
+ register u_char *data, u_int length, u_short attr_code _U_)
{
u_int idx;
u_int vendor_id;
@@ -510,55 +507,53 @@ print_vendor_attr(register u_char *data, u_int length, u_short attr_code _U_)
if (length < 4)
goto trunc;
- TCHECK2(*data, 4);
+ ND_TCHECK2(*data, 4);
vendor_id = EXTRACT_32BITS(data);
data+=4;
length-=4;
- printf("Vendor: %s (%u)",
+ ND_PRINT((ndo, "Vendor: %s (%u)",
tok2str(smi_values,"Unknown",vendor_id),
- vendor_id);
+ vendor_id));
while (length >= 2) {
- TCHECK2(*data, 2);
+ ND_TCHECK2(*data, 2);
vendor_type = *(data);
vendor_length = *(data+1);
if (vendor_length < 2)
{
- printf("\n\t Vendor Attribute: %u, Length: %u (bogus, must be >= 2)",
+ ND_PRINT((ndo, "\n\t Vendor Attribute: %u, Length: %u (bogus, must be >= 2)",
vendor_type,
- vendor_length);
+ vendor_length));
return;
}
if (vendor_length > length)
{
- printf("\n\t Vendor Attribute: %u, Length: %u (bogus, goes past end of vendor-specific attribute)",
+ ND_PRINT((ndo, "\n\t Vendor Attribute: %u, Length: %u (bogus, goes past end of vendor-specific attribute)",
vendor_type,
- vendor_length);
+ vendor_length));
return;
}
data+=2;
vendor_length-=2;
length-=2;
- TCHECK2(*data, vendor_length);
+ ND_TCHECK2(*data, vendor_length);
- printf("\n\t Vendor Attribute: %u, Length: %u, Value: ",
+ ND_PRINT((ndo, "\n\t Vendor Attribute: %u, Length: %u, Value: ",
vendor_type,
- vendor_length);
+ vendor_length));
for (idx = 0; idx < vendor_length ; idx++, data++)
- printf("%c",(*data < 32 || *data > 128) ? '.' : *data );
+ ND_PRINT((ndo, "%c", (*data < 32 || *data > 128) ? '.' : *data));
length-=vendor_length;
}
return;
trunc:
- printf(" [|radius]");
+ ND_PRINT((ndo, "%s", tstr));
}
-
-
/******************************/
/* Print an attribute numeric */
/* value pointed by 'data' */
@@ -567,31 +562,32 @@ print_vendor_attr(register u_char *data, u_int length, u_short attr_code _U_)
/* Returns nothing. */
/******************************/
static void
-print_attr_num(register u_char *data, u_int length, u_short attr_code )
+print_attr_num(netdissect_options *ndo,
+ register u_char *data, u_int length, u_short attr_code)
{
- u_int8_t tag;
- u_int32_t timeout;
+ uint8_t tag;
+ uint32_t timeout;
if (length != 4)
{
- printf("ERROR: length %u != 4", length);
+ ND_PRINT((ndo, "ERROR: length %u != 4", length));
return;
}
- TCHECK2(data[0],4);
+ ND_TCHECK2(data[0],4);
/* This attribute has standard values */
if (attr_type[attr_code].siz_subtypes)
{
static const char **table;
- u_int32_t data_value;
+ uint32_t data_value;
table = attr_type[attr_code].subtypes;
if ( (attr_code == TUNNEL_TYPE) || (attr_code == TUNNEL_MEDIUM) )
{
if (!*data)
- printf("Tag[Unused]");
+ ND_PRINT((ndo, "Tag[Unused]"));
else
- printf("Tag[%d]", *data);
+ ND_PRINT((ndo, "Tag[%d]", *data));
data++;
data_value = EXTRACT_24BITS(data);
}
@@ -599,12 +595,12 @@ print_attr_num(register u_char *data, u_int length, u_short attr_code )
{
data_value = EXTRACT_32BITS(data);
}
- if ( data_value <= (u_int32_t)(attr_type[attr_code].siz_subtypes - 1 +
+ if ( data_value <= (uint32_t)(attr_type[attr_code].siz_subtypes - 1 +
attr_type[attr_code].first_subtype) &&
data_value >= attr_type[attr_code].first_subtype )
- printf("%s",table[data_value]);
+ ND_PRINT((ndo, "%s", table[data_value]));
else
- printf("#%u",data_value);
+ ND_PRINT((ndo, "#%u", data_value));
}
else
{
@@ -612,9 +608,9 @@ print_attr_num(register u_char *data, u_int length, u_short attr_code )
{
case FRM_IPX:
if (EXTRACT_32BITS( data) == 0xFFFFFFFE )
- printf("NAS Select");
+ ND_PRINT((ndo, "NAS Select"));
else
- printf("%d",EXTRACT_32BITS( data) );
+ ND_PRINT((ndo, "%d", EXTRACT_32BITS(data)));
break;
case SESSION_TIMEOUT:
@@ -624,44 +620,44 @@ print_attr_num(register u_char *data, u_int length, u_short attr_code )
case ACCT_INT_INTERVAL:
timeout = EXTRACT_32BITS( data);
if ( timeout < 60 )
- printf( "%02d secs", timeout);
+ ND_PRINT((ndo, "%02d secs", timeout));
else
{
if ( timeout < 3600 )
- printf( "%02d:%02d min",
- timeout / 60, timeout % 60);
+ ND_PRINT((ndo, "%02d:%02d min",
+ timeout / 60, timeout % 60));
else
- printf( "%02d:%02d:%02d hours",
+ ND_PRINT((ndo, "%02d:%02d:%02d hours",
timeout / 3600, (timeout % 3600) / 60,
- timeout % 60);
+ timeout % 60));
}
break;
case FRM_ATALK_LINK:
if (EXTRACT_32BITS(data) )
- printf("%d",EXTRACT_32BITS(data) );
+ ND_PRINT((ndo, "%d", EXTRACT_32BITS(data)));
else
- printf("Unnumbered" );
+ ND_PRINT((ndo, "Unnumbered"));
break;
case FRM_ATALK_NETWORK:
if (EXTRACT_32BITS(data) )
- printf("%d",EXTRACT_32BITS(data) );
+ ND_PRINT((ndo, "%d", EXTRACT_32BITS(data)));
else
- printf("NAS assigned" );
+ ND_PRINT((ndo, "NAS assigned"));
break;
case TUNNEL_PREFERENCE:
tag = *data;
data++;
if (tag == 0)
- printf("Tag (Unused) %d",EXTRACT_24BITS(data) );
+ ND_PRINT((ndo, "Tag (Unused) %d", EXTRACT_24BITS(data)));
else
- printf("Tag (%d) %d", tag, EXTRACT_24BITS(data) );
+ ND_PRINT((ndo, "Tag (%d) %d", tag, EXTRACT_24BITS(data)));
break;
default:
- printf("%d",EXTRACT_32BITS( data) );
+ ND_PRINT((ndo, "%d", EXTRACT_32BITS(data)));
break;
} /* switch */
@@ -671,10 +667,9 @@ print_attr_num(register u_char *data, u_int length, u_short attr_code )
return;
trunc:
- printf(" [|radius]");
+ ND_PRINT((ndo, "%s", tstr));
}
-
/*****************************/
/* Print an attribute IPv4 */
/* address value pointed by */
@@ -683,41 +678,41 @@ print_attr_num(register u_char *data, u_int length, u_short attr_code )
/* Returns nothing. */
/*****************************/
static void
-print_attr_address(register u_char *data, u_int length, u_short attr_code )
+print_attr_address(netdissect_options *ndo,
+ register u_char *data, u_int length, u_short attr_code)
{
if (length != 4)
{
- printf("ERROR: length %u != 4", length);
+ ND_PRINT((ndo, "ERROR: length %u != 4", length));
return;
}
- TCHECK2(data[0],4);
+ ND_TCHECK2(data[0],4);
switch(attr_code)
{
case FRM_IPADDR:
case LOG_IPHOST:
if (EXTRACT_32BITS(data) == 0xFFFFFFFF )
- printf("User Selected");
+ ND_PRINT((ndo, "User Selected"));
else
if (EXTRACT_32BITS(data) == 0xFFFFFFFE )
- printf("NAS Select");
+ ND_PRINT((ndo, "NAS Select"));
else
- printf("%s",ipaddr_string(data));
+ ND_PRINT((ndo, "%s",ipaddr_string(ndo, data)));
break;
default:
- printf("%s",ipaddr_string(data) );
+ ND_PRINT((ndo, "%s", ipaddr_string(ndo, data)));
break;
}
return;
trunc:
- printf(" [|radius]");
+ ND_PRINT((ndo, "%s", tstr));
}
-
/*************************************/
/* Print an attribute of 'secs since */
/* January 1, 1970 00:00 UTC' value */
@@ -726,31 +721,32 @@ print_attr_address(register u_char *data, u_int length, u_short attr_code )
/*************************************/
/* Returns nothing. */
/*************************************/
-static void print_attr_time(register u_char *data, u_int length, u_short attr_code _U_)
+static void
+print_attr_time(netdissect_options *ndo,
+ register u_char *data, u_int length, u_short attr_code _U_)
{
time_t attr_time;
char string[26];
if (length != 4)
{
- printf("ERROR: length %u != 4", length);
+ ND_PRINT((ndo, "ERROR: length %u != 4", length));
return;
}
- TCHECK2(data[0],4);
+ ND_TCHECK2(data[0],4);
attr_time = EXTRACT_32BITS(data);
strlcpy(string, ctime(&attr_time), sizeof(string));
/* Get rid of the newline */
string[24] = '\0';
- printf("%.24s", string);
+ ND_PRINT((ndo, "%.24s", string));
return;
trunc:
- printf(" [|radius]");
+ ND_PRINT((ndo, "%s", tstr));
}
-
/***********************************/
/* Print an attribute of 'strange' */
/* data format pointed by 'data' */
@@ -758,7 +754,9 @@ static void print_attr_time(register u_char *data, u_int length, u_short attr_co
/***********************************/
/* Returns nothing. */
/***********************************/
-static void print_attr_strange(register u_char *data, u_int length, u_short attr_code)
+static void
+print_attr_strange(netdissect_options *ndo,
+ register u_char *data, u_int length, u_short attr_code)
{
u_short len_data;
@@ -767,45 +765,45 @@ static void print_attr_strange(register u_char *data, u_int length, u_short attr
case ARAP_PASS:
if (length != 16)
{
- printf("ERROR: length %u != 16", length);
+ ND_PRINT((ndo, "ERROR: length %u != 16", length));
return;
}
- printf("User_challenge (");
- TCHECK2(data[0],8);
+ ND_PRINT((ndo, "User_challenge ("));
+ ND_TCHECK2(data[0],8);
len_data = 8;
PRINT_HEX(len_data, data);
- printf(") User_resp(");
- TCHECK2(data[0],8);
+ ND_PRINT((ndo, ") User_resp("));
+ ND_TCHECK2(data[0],8);
len_data = 8;
PRINT_HEX(len_data, data);
- printf(")");
+ ND_PRINT((ndo, ")"));
break;
case ARAP_FEATURES:
if (length != 14)
{
- printf("ERROR: length %u != 14", length);
+ ND_PRINT((ndo, "ERROR: length %u != 14", length));
return;
}
- TCHECK2(data[0],1);
+ ND_TCHECK2(data[0],1);
if (*data)
- printf("User can change password");
+ ND_PRINT((ndo, "User can change password"));
else
- printf("User cannot change password");
+ ND_PRINT((ndo, "User cannot change password"));
data++;
- TCHECK2(data[0],1);
- printf(", Min password length: %d",*data);
+ ND_TCHECK2(data[0],1);
+ ND_PRINT((ndo, ", Min password length: %d", *data));
data++;
- printf(", created at: ");
- TCHECK2(data[0],4);
+ ND_PRINT((ndo, ", created at: "));
+ ND_TCHECK2(data[0],4);
len_data = 4;
PRINT_HEX(len_data, data);
- printf(", expires in: ");
- TCHECK2(data[0],4);
+ ND_PRINT((ndo, ", expires in: "));
+ ND_TCHECK2(data[0],4);
len_data = 4;
PRINT_HEX(len_data, data);
- printf(", Current Time: ");
- TCHECK2(data[0],4);
+ ND_PRINT((ndo, ", Current Time: "));
+ ND_TCHECK2(data[0],4);
len_data = 4;
PRINT_HEX(len_data, data);
break;
@@ -813,10 +811,10 @@ static void print_attr_strange(register u_char *data, u_int length, u_short attr
case ARAP_CHALLENGE_RESP:
if (length < 8)
{
- printf("ERROR: length %u != 8", length);
+ ND_PRINT((ndo, "ERROR: length %u != 8", length));
return;
}
- TCHECK2(data[0],8);
+ ND_TCHECK2(data[0],8);
len_data = 8;
PRINT_HEX(len_data, data);
break;
@@ -824,13 +822,12 @@ static void print_attr_strange(register u_char *data, u_int length, u_short attr
return;
trunc:
- printf(" [|radius]");
+ ND_PRINT((ndo, "%s", tstr));
}
-
-
static void
-radius_attrs_print(register const u_char *attr, u_int length)
+radius_attrs_print(netdissect_options *ndo,
+ register const u_char *attr, u_int length)
{
register const struct radius_attr *rad_attr = (struct radius_attr *)attr;
const char *attr_string;
@@ -839,32 +836,32 @@ radius_attrs_print(register const u_char *attr, u_int length)
{
if (length < 2)
goto trunc;
- TCHECK(*rad_attr);
-
+ ND_TCHECK(*rad_attr);
+
if (rad_attr->type > 0 && rad_attr->type < TAM_SIZE(attr_type))
attr_string = attr_type[rad_attr->type].name;
else
attr_string = "Unknown";
if (rad_attr->len < 2)
{
- printf("\n\t %s Attribute (%u), length: %u (bogus, must be >= 2)",
+ ND_PRINT((ndo, "\n\t %s Attribute (%u), length: %u (bogus, must be >= 2)",
attr_string,
rad_attr->type,
- rad_attr->len);
+ rad_attr->len));
return;
}
if (rad_attr->len > length)
{
- printf("\n\t %s Attribute (%u), length: %u (bogus, goes past end of packet)",
+ ND_PRINT((ndo, "\n\t %s Attribute (%u), length: %u (bogus, goes past end of packet)",
attr_string,
rad_attr->type,
- rad_attr->len);
+ rad_attr->len));
return;
}
- printf("\n\t %s Attribute (%u), length: %u, Value: ",
+ ND_PRINT((ndo, "\n\t %s Attribute (%u), length: %u, Value: ",
attr_string,
rad_attr->type,
- rad_attr->len);
+ rad_attr->len));
if (rad_attr->type < TAM_SIZE(attr_type))
{
@@ -872,13 +869,13 @@ radius_attrs_print(register const u_char *attr, u_int length)
{
if ( attr_type[rad_attr->type].print_func )
(*attr_type[rad_attr->type].print_func)(
- ((u_char *)(rad_attr+1)),
+ ndo, ((u_char *)(rad_attr+1)),
rad_attr->len - 2, rad_attr->type);
}
}
/* do we also want to see a hex dump ? */
- if (vflag> 1)
- print_unknown_data((u_char *)rad_attr+2,"\n\t ",(rad_attr->len)-2);
+ if (ndo->ndo_vflag> 1)
+ print_unknown_data(ndo, (u_char *)rad_attr+2, "\n\t ", (rad_attr->len)-2);
length-=(rad_attr->len);
rad_attr = (struct radius_attr *)( ((char *)(rad_attr))+rad_attr->len);
@@ -886,52 +883,52 @@ radius_attrs_print(register const u_char *attr, u_int length)
return;
trunc:
- printf(" [|radius]");
+ ND_PRINT((ndo, "%s", tstr));
}
-
void
-radius_print(const u_char *dat, u_int length)
+radius_print(netdissect_options *ndo,
+ const u_char *dat, u_int length)
{
register const struct radius_hdr *rad;
u_int len, auth_idx;
- TCHECK2(*dat, MIN_RADIUS_LEN);
+ ND_TCHECK2(*dat, MIN_RADIUS_LEN);
rad = (struct radius_hdr *)dat;
len = EXTRACT_16BITS(&rad->len);
if (len < MIN_RADIUS_LEN)
{
- printf(" [|radius]");
+ ND_PRINT((ndo, "%s", tstr));
return;
}
if (len > length)
len = length;
- if (vflag < 1) {
- printf("RADIUS, %s (%u), id: 0x%02x length: %u",
+ if (ndo->ndo_vflag < 1) {
+ ND_PRINT((ndo, "RADIUS, %s (%u), id: 0x%02x length: %u",
tok2str(radius_command_values,"Unknown Command",rad->code),
rad->code,
rad->id,
- len);
+ len));
return;
}
else {
- printf("RADIUS, length: %u\n\t%s (%u), id: 0x%02x, Authenticator: ",
+ ND_PRINT((ndo, "RADIUS, length: %u\n\t%s (%u), id: 0x%02x, Authenticator: ",
len,
tok2str(radius_command_values,"Unknown Command",rad->code),
rad->code,
- rad->id);
+ rad->id));
for(auth_idx=0; auth_idx < 16; auth_idx++)
- printf("%02x", rad->auth[auth_idx] );
+ ND_PRINT((ndo, "%02x", rad->auth[auth_idx]));
}
if (len > MIN_RADIUS_LEN)
- radius_attrs_print( dat + MIN_RADIUS_LEN, len - MIN_RADIUS_LEN);
+ radius_attrs_print(ndo, dat + MIN_RADIUS_LEN, len - MIN_RADIUS_LEN);
return;
trunc:
- printf(" [|radius]");
+ ND_PRINT((ndo, "%s", tstr));
}
diff --git a/contrib/tcpdump/print-raw.c b/contrib/tcpdump/print-raw.c
index 8e376ce52ccc..d20387c644c9 100644
--- a/contrib/tcpdump/print-raw.c
+++ b/contrib/tcpdump/print-raw.c
@@ -19,22 +19,13 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#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)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <pcap.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "addrtoname.h"
#include "interface.h"
/*
@@ -42,12 +33,12 @@ static const char rcsid[] _U_ =
*/
u_int
-raw_if_print(const struct pcap_pkthdr *h, const u_char *p)
+raw_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
{
- if (eflag)
- printf("ip: ");
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "ip: "));
- ipN_print(p, h->len);
+ ipN_print(ndo, p, h->len);
return (0);
}
diff --git a/contrib/tcpdump/print-rip.c b/contrib/tcpdump/print-rip.c
index e941947dd37c..c1b036e442f3 100644
--- a/contrib/tcpdump/print-rip.c
+++ b/contrib/tcpdump/print-rip.c
@@ -19,11 +19,7 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-rip.c,v 1.59 2006-03-23 14:58:44 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -31,7 +27,6 @@ static const char rcsid[] _U_ =
#include <tcpdump-stdinc.h>
#include <stdio.h>
-#include <string.h>
#include "interface.h"
#include "addrtoname.h"
@@ -39,10 +34,12 @@ static const char rcsid[] _U_ =
#include "af.h"
+static const char tstr[] = "[|rip]";
+
struct rip {
- u_int8_t rip_cmd; /* request/response */
- u_int8_t rip_vers; /* protocol version # */
- u_int8_t unused[2]; /* unused */
+ uint8_t rip_cmd; /* request/response */
+ uint8_t rip_vers; /* protocol version # */
+ uint8_t unused[2]; /* unused */
};
#define RIPCMD_REQUEST 1 /* want info */
@@ -67,7 +64,7 @@ static const struct tok rip_cmd_values[] = {
/*
* rfc 1723
- *
+ *
* 0 1 2 3 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -87,118 +84,121 @@ static const struct tok rip_cmd_values[] = {
*/
struct rip_netinfo {
- u_int16_t rip_family;
- u_int16_t rip_tag;
- u_int32_t rip_dest;
- u_int32_t rip_dest_mask;
- u_int32_t rip_router;
- u_int32_t rip_metric; /* cost of route */
+ uint16_t rip_family;
+ uint16_t rip_tag;
+ uint32_t rip_dest;
+ uint32_t rip_dest_mask;
+ uint32_t rip_router;
+ uint32_t rip_metric; /* cost of route */
};
static void
-rip_entry_print_v1(register const struct rip_netinfo *ni)
+rip_entry_print_v1(netdissect_options *ndo,
+ register const struct rip_netinfo *ni)
{
register u_short family;
/* RFC 1058 */
family = EXTRACT_16BITS(&ni->rip_family);
if (family != BSD_AFNUM_INET && family != 0) {
- 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);
+ ND_PRINT((ndo, "\n\t AFI %s, ", tok2str(bsd_af_values, "Unknown (%u)", family)));
+ print_unknown_data(ndo, (uint8_t *)&ni->rip_family, "\n\t ", RIP_ROUTELEN);
return;
}
if (EXTRACT_16BITS(&ni->rip_tag) ||
EXTRACT_32BITS(&ni->rip_dest_mask) ||
EXTRACT_32BITS(&ni->rip_router)) {
/* MBZ fields not zero */
- print_unknown_data((u_int8_t *)&ni->rip_family,"\n\t ",RIP_ROUTELEN);
+ print_unknown_data(ndo, (uint8_t *)&ni->rip_family, "\n\t ", RIP_ROUTELEN);
return;
}
if (family == 0) {
- printf("\n\t AFI 0, %s, metric: %u",
- ipaddr_string(&ni->rip_dest),
- EXTRACT_32BITS(&ni->rip_metric));
+ ND_PRINT((ndo, "\n\t AFI 0, %s, metric: %u",
+ ipaddr_string(ndo, &ni->rip_dest),
+ EXTRACT_32BITS(&ni->rip_metric)));
return;
} /* BSD_AFNUM_INET */
- printf("\n\t %s, metric: %u",
- ipaddr_string(&ni->rip_dest),
- EXTRACT_32BITS(&ni->rip_metric));
+ ND_PRINT((ndo, "\n\t %s, metric: %u",
+ ipaddr_string(ndo, &ni->rip_dest),
+ EXTRACT_32BITS(&ni->rip_metric)));
}
static unsigned
-rip_entry_print_v2(register const struct rip_netinfo *ni, const unsigned remaining)
+rip_entry_print_v2(netdissect_options *ndo,
+ register const struct rip_netinfo *ni, const unsigned remaining)
{
register u_short family;
family = EXTRACT_16BITS(&ni->rip_family);
if (family == 0xFFFF) { /* variable-sized authentication structures */
- u_int16_t auth_type = EXTRACT_16BITS(&ni->rip_tag);
+ uint16_t auth_type = EXTRACT_16BITS(&ni->rip_tag);
if (auth_type == 2) {
register u_char *p = (u_char *)&ni->rip_dest;
u_int i = 0;
- printf("\n\t Simple Text Authentication data: ");
+ ND_PRINT((ndo, "\n\t Simple Text Authentication data: "));
for (; i < RIP_AUTHLEN; p++, i++)
- putchar (isprint(*p) ? *p : '.');
+ ND_PRINT((ndo, "%c", ND_ISPRINT(*p) ? *p : '.'));
} else if (auth_type == 3) {
- printf("\n\t Auth header:");
- printf(" Packet Len %u,", EXTRACT_16BITS((u_int8_t *)ni + 4));
- printf(" Key-ID %u,", *((u_int8_t *)ni + 6));
- printf(" Auth Data Len %u,", *((u_int8_t *)ni + 7));
- printf(" SeqNo %u,", EXTRACT_32BITS(&ni->rip_dest_mask));
- printf(" MBZ %u,", EXTRACT_32BITS(&ni->rip_router));
- printf(" MBZ %u", EXTRACT_32BITS(&ni->rip_metric));
+ ND_PRINT((ndo, "\n\t Auth header:"));
+ ND_PRINT((ndo, " Packet Len %u,", EXTRACT_16BITS((uint8_t *)ni + 4)));
+ ND_PRINT((ndo, " Key-ID %u,", *((uint8_t *)ni + 6)));
+ ND_PRINT((ndo, " Auth Data Len %u,", *((uint8_t *)ni + 7)));
+ ND_PRINT((ndo, " SeqNo %u,", EXTRACT_32BITS(&ni->rip_dest_mask)));
+ ND_PRINT((ndo, " MBZ %u,", EXTRACT_32BITS(&ni->rip_router)));
+ ND_PRINT((ndo, " MBZ %u", EXTRACT_32BITS(&ni->rip_metric)));
} else if (auth_type == 1) {
- printf("\n\t Auth trailer:");
- print_unknown_data((u_int8_t *)&ni->rip_dest,"\n\t ",remaining);
+ ND_PRINT((ndo, "\n\t Auth trailer:"));
+ print_unknown_data(ndo, (uint8_t *)&ni->rip_dest, "\n\t ", remaining);
return remaining; /* AT spans till the packet end */
- } else {
- printf("\n\t Unknown (%u) Authentication data:",
- EXTRACT_16BITS(&ni->rip_tag));
- print_unknown_data((u_int8_t *)&ni->rip_dest,"\n\t ",remaining);
+ } else {
+ ND_PRINT((ndo, "\n\t Unknown (%u) Authentication data:",
+ EXTRACT_16BITS(&ni->rip_tag)));
+ print_unknown_data(ndo, (uint8_t *)&ni->rip_dest, "\n\t ", remaining);
}
} else if (family != BSD_AFNUM_INET && family != 0) {
- 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);
+ ND_PRINT((ndo, "\n\t AFI %s", tok2str(bsd_af_values, "Unknown (%u)", family)));
+ print_unknown_data(ndo, (uint8_t *)&ni->rip_tag, "\n\t ", RIP_ROUTELEN-2);
} else { /* BSD_AFNUM_INET or AFI 0 */
- printf("\n\t AFI %s, %15s/%-2d, tag 0x%04x, metric: %u, next-hop: ",
+ ND_PRINT((ndo, "\n\t AFI %s, %15s/%-2d, tag 0x%04x, metric: %u, next-hop: ",
tok2str(bsd_af_values, "%u", family),
- ipaddr_string(&ni->rip_dest),
+ ipaddr_string(ndo, &ni->rip_dest),
mask2plen(EXTRACT_32BITS(&ni->rip_dest_mask)),
EXTRACT_16BITS(&ni->rip_tag),
- EXTRACT_32BITS(&ni->rip_metric));
+ EXTRACT_32BITS(&ni->rip_metric)));
if (EXTRACT_32BITS(&ni->rip_router))
- printf("%s", ipaddr_string(&ni->rip_router));
- else
- printf("self");
+ ND_PRINT((ndo, "%s", ipaddr_string(ndo, &ni->rip_router)));
+ else
+ ND_PRINT((ndo, "self"));
}
return sizeof (*ni);
}
void
-rip_print(const u_char *dat, u_int length)
+rip_print(netdissect_options *ndo,
+ const u_char *dat, u_int length)
{
register const struct rip *rp;
register const struct rip_netinfo *ni;
register u_int i, j;
- if (snapend < dat) {
- printf(" [|rip]");
+ if (ndo->ndo_snapend < dat) {
+ ND_PRINT((ndo, " %s", tstr));
return;
}
- i = snapend - dat;
+ i = ndo->ndo_snapend - dat;
if (i > length)
i = length;
if (i < sizeof(*rp)) {
- printf(" [|rip]");
+ ND_PRINT((ndo, " %s", tstr));
return;
}
i -= sizeof(*rp);
rp = (struct rip *)dat;
- printf("%sRIPv%u",
- (vflag >= 1) ? "\n\t" : "",
- rp->rip_vers);
+ ND_PRINT((ndo, "%sRIPv%u",
+ (ndo->ndo_vflag >= 1) ? "\n\t" : "",
+ rp->rip_vers));
switch (rp->rip_vers) {
case 0:
@@ -213,38 +213,38 @@ rip_print(const u_char *dat, u_int length)
*
* so perhaps we should just dump the packet, in hex.
*/
- print_unknown_data((u_int8_t *)&rp->rip_cmd,"\n\t",length);
+ print_unknown_data(ndo, (uint8_t *)&rp->rip_cmd, "\n\t", length);
break;
default:
/* dump version and lets see if we know the commands name*/
- printf(", %s, length: %u",
+ ND_PRINT((ndo, ", %s, length: %u",
tok2str(rip_cmd_values,
"unknown command (%u)",
rp->rip_cmd),
- length);
+ length));
- if (vflag < 1)
+ if (ndo->ndo_vflag < 1)
return;
switch (rp->rip_cmd) {
case RIPCMD_REQUEST:
case RIPCMD_RESPONSE:
j = length / sizeof(*ni);
- printf(", routes: %u%s", j, rp->rip_vers == 2 ? " or less" : "");
+ ND_PRINT((ndo, ", routes: %u%s", j, rp->rip_vers == 2 ? " or less" : ""));
ni = (struct rip_netinfo *)(rp + 1);
for (; i >= sizeof(*ni); ++ni) {
if (rp->rip_vers == 1)
{
- rip_entry_print_v1(ni);
+ rip_entry_print_v1(ndo, ni);
i -= sizeof(*ni);
}
else if (rp->rip_vers == 2)
- i -= rip_entry_print_v2(ni, i);
+ i -= rip_entry_print_v2(ndo, ni, i);
else
break;
}
if (i)
- printf("[|rip]");
+ ND_PRINT((ndo, "%s", tstr));
break;
case RIPCMD_TRACEOFF:
@@ -255,15 +255,15 @@ rip_print(const u_char *dat, u_int length)
case RIPCMD_TRACEON:
/* fall through */
default:
- if (vflag <= 1) {
- if(!print_unknown_data((u_int8_t *)rp,"\n\t",length))
+ if (ndo->ndo_vflag <= 1) {
+ if(!print_unknown_data(ndo, (uint8_t *)rp, "\n\t", length))
return;
}
break;
}
/* do we want to see an additionally hexdump ? */
- if (vflag> 1) {
- if(!print_unknown_data((u_int8_t *)rp,"\n\t",length))
+ if (ndo->ndo_vflag> 1) {
+ if(!print_unknown_data(ndo, (uint8_t *)rp, "\n\t", length))
return;
}
}
diff --git a/contrib/tcpdump/print-ripng.c b/contrib/tcpdump/print-ripng.c
index cef39daf1e0c..4bc900d105ac 100644
--- a/contrib/tcpdump/print-ripng.c
+++ b/contrib/tcpdump/print-ripng.c
@@ -19,11 +19,7 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#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 $";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -31,13 +27,65 @@ static const char rcsid[] _U_ =
#ifdef INET6
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include "route6d.h"
#include "interface.h"
#include "addrtoname.h"
#include "extract.h"
+/*
+ * Copyright (C) 1995, 1996, 1997 and 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#define RIP6_VERSION 1
+
+#define RIP6_REQUEST 1
+#define RIP6_RESPONSE 2
+
+struct netinfo6 {
+ struct in6_addr rip6_dest;
+ uint16_t rip6_tag;
+ uint8_t rip6_plen;
+ uint8_t rip6_metric;
+};
+
+struct rip6 {
+ uint8_t rip6_cmd;
+ uint8_t rip6_vers;
+ uint8_t rip6_res1[2];
+ union {
+ struct netinfo6 ru6_nets[1];
+ char ru6_tracefile[1];
+ } rip6un;
+#define rip6_nets rip6un.ru6_nets
+#define rip6_tracefile rip6un.ru6_tracefile
+};
+
+#define HOPCNT_INFINITY6 16
+
#if !defined(IN6_IS_ADDR_UNSPECIFIED) && !defined(_MSC_VER) /* MSVC inline */
static int IN6_IS_ADDR_UNSPECIFIED(const struct in6_addr *addr)
{
@@ -47,19 +95,19 @@ static int IN6_IS_ADDR_UNSPECIFIED(const struct in6_addr *addr)
#endif
static int
-rip6_entry_print(register const struct netinfo6 *ni, int metric)
+rip6_entry_print(netdissect_options *ndo, register const struct netinfo6 *ni, int metric)
{
int l;
- l = printf("%s/%d", ip6addr_string(&ni->rip6_dest), ni->rip6_plen);
+ l = ND_PRINT((ndo, "%s/%d", ip6addr_string(ndo, &ni->rip6_dest), ni->rip6_plen));
if (ni->rip6_tag)
- l += printf(" [%d]", EXTRACT_16BITS(&ni->rip6_tag));
+ l += ND_PRINT((ndo, " [%d]", EXTRACT_16BITS(&ni->rip6_tag)));
if (metric)
- l += printf(" (%d)", ni->rip6_metric);
+ l += ND_PRINT((ndo, " (%d)", ni->rip6_metric));
return l;
}
void
-ripng_print(const u_char *dat, unsigned int length)
+ripng_print(netdissect_options *ndo, const u_char *dat, unsigned int length)
{
register const struct rip6 *rp = (struct rip6 *)dat;
register const struct netinfo6 *ni;
@@ -68,9 +116,9 @@ ripng_print(const u_char *dat, unsigned int length)
int j;
int trunc;
- if (snapend < dat)
+ if (ndo->ndo_snapend < dat)
return;
- amt = snapend - dat;
+ amt = ndo->ndo_snapend - dat;
i = min(length, amt);
if (i < (sizeof(struct rip6) - sizeof(struct netinfo6)))
return;
@@ -83,46 +131,46 @@ ripng_print(const u_char *dat, unsigned int length)
if (j == 1
&& rp->rip6_nets->rip6_metric == HOPCNT_INFINITY6
&& IN6_IS_ADDR_UNSPECIFIED(&rp->rip6_nets->rip6_dest)) {
- printf(" ripng-req dump");
+ ND_PRINT((ndo, " ripng-req dump"));
break;
}
if (j * sizeof(*ni) != length - 4)
- printf(" ripng-req %d[%u]:", j, length);
+ ND_PRINT((ndo, " ripng-req %d[%u]:", j, length));
else
- printf(" ripng-req %d:", j);
+ ND_PRINT((ndo, " ripng-req %d:", j));
trunc = ((i / sizeof(*ni)) * sizeof(*ni) != i);
for (ni = rp->rip6_nets; i >= sizeof(*ni);
i -= sizeof(*ni), ++ni) {
- if (vflag > 1)
- printf("\n\t");
+ if (ndo->ndo_vflag > 1)
+ ND_PRINT((ndo, "\n\t"));
else
- printf(" ");
- rip6_entry_print(ni, 0);
+ ND_PRINT((ndo, " "));
+ rip6_entry_print(ndo, ni, 0);
}
break;
case RIP6_RESPONSE:
j = length / sizeof(*ni);
if (j * sizeof(*ni) != length - 4)
- printf(" ripng-resp %d[%u]:", j, length);
+ ND_PRINT((ndo, " ripng-resp %d[%u]:", j, length));
else
- printf(" ripng-resp %d:", j);
+ ND_PRINT((ndo, " ripng-resp %d:", j));
trunc = ((i / sizeof(*ni)) * sizeof(*ni) != i);
for (ni = rp->rip6_nets; i >= sizeof(*ni);
i -= sizeof(*ni), ++ni) {
- if (vflag > 1)
- printf("\n\t");
+ if (ndo->ndo_vflag > 1)
+ ND_PRINT((ndo, "\n\t"));
else
- printf(" ");
- rip6_entry_print(ni, ni->rip6_metric);
+ ND_PRINT((ndo, " "));
+ rip6_entry_print(ndo, ni, ni->rip6_metric);
}
if (trunc)
- printf("[|ripng]");
+ ND_PRINT((ndo, "[|ripng]"));
break;
default:
- printf(" ripng-%d ?? %u", rp->rip6_cmd, length);
+ ND_PRINT((ndo, " ripng-%d ?? %u", rp->rip6_cmd, length));
break;
}
if (rp->rip6_vers != RIP6_VERSION)
- printf(" [vers %d]", rp->rip6_vers);
+ ND_PRINT((ndo, " [vers %d]", rp->rip6_vers));
}
#endif /* INET6 */
diff --git a/contrib/tcpdump/print-rpki-rtr.c b/contrib/tcpdump/print-rpki-rtr.c
index c705c0506d8d..5bb5df7b0541 100644
--- a/contrib/tcpdump/print-rpki-rtr.c
+++ b/contrib/tcpdump/print-rpki-rtr.c
@@ -17,19 +17,13 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
-"@(#) $Header: /tcpdump/master/tcpdump/print-rpki_rtr.c,v 1.10 2008-03-20 09:30:56 hannes Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
#include "interface.h"
@@ -175,7 +169,7 @@ indent_string (u_int indent)
* Print a single PDU.
*/
static void
-rpki_rtr_pdu_print (const u_char *tptr, u_int indent)
+rpki_rtr_pdu_print (netdissect_options *ndo, const u_char *tptr, u_int indent)
{
const rpki_rtr_pdu *pdu_header;
u_int pdu_type, pdu_len, hexdump;
@@ -186,11 +180,11 @@ rpki_rtr_pdu_print (const u_char *tptr, u_int indent)
pdu_len = EXTRACT_32BITS(pdu_header->length);
hexdump = FALSE;
- printf("%sRPKI-RTRv%u, %s PDU (%u), length: %u",
+ ND_PRINT((ndo, "%sRPKI-RTRv%u, %s PDU (%u), length: %u",
indent_string(8),
pdu_header->version,
tok2str(rpki_rtr_pdu_values, "Unknown", pdu_type),
- pdu_type, pdu_len);
+ pdu_type, pdu_len));
switch (pdu_type) {
@@ -201,10 +195,10 @@ rpki_rtr_pdu_print (const u_char *tptr, u_int indent)
case RPKI_RTR_SERIAL_QUERY_PDU:
case RPKI_RTR_END_OF_DATA_PDU:
msg = (const u_char *)(pdu_header + 1);
- printf("%sSession ID: 0x%04x, Serial: %u",
+ ND_PRINT((ndo, "%sSession ID: 0x%04x, Serial: %u",
indent_string(indent+2),
EXTRACT_16BITS(pdu_header->u.session_id),
- EXTRACT_32BITS(msg));
+ EXTRACT_32BITS(msg)));
break;
/*
@@ -219,9 +213,9 @@ rpki_rtr_pdu_print (const u_char *tptr, u_int indent)
break;
case RPKI_RTR_CACHE_RESPONSE_PDU:
- printf("%sSession ID: 0x%04x",
+ ND_PRINT((ndo, "%sSession ID: 0x%04x",
indent_string(indent+2),
- EXTRACT_16BITS(pdu_header->u.session_id));
+ EXTRACT_16BITS(pdu_header->u.session_id)));
break;
case RPKI_RTR_IPV4_PREFIX_PDU:
@@ -229,11 +223,11 @@ rpki_rtr_pdu_print (const u_char *tptr, u_int indent)
rpki_rtr_pdu_ipv4_prefix *pdu;
pdu = (rpki_rtr_pdu_ipv4_prefix *)tptr;
- printf("%sIPv4 Prefix %s/%u-%u, origin-as %u, flags 0x%02x",
+ ND_PRINT((ndo, "%sIPv4 Prefix %s/%u-%u, origin-as %u, flags 0x%02x",
indent_string(indent+2),
- ipaddr_string(pdu->prefix),
+ ipaddr_string(ndo, pdu->prefix),
pdu->prefix_length, pdu->max_length,
- EXTRACT_32BITS(pdu->as), pdu->flags);
+ EXTRACT_32BITS(pdu->as), pdu->flags));
}
break;
@@ -243,11 +237,11 @@ rpki_rtr_pdu_print (const u_char *tptr, u_int indent)
rpki_rtr_pdu_ipv6_prefix *pdu;
pdu = (rpki_rtr_pdu_ipv6_prefix *)tptr;
- printf("%sIPv6 Prefix %s/%u-%u, origin-as %u, flags 0x%02x",
+ ND_PRINT((ndo, "%sIPv6 Prefix %s/%u-%u, origin-as %u, flags 0x%02x",
indent_string(indent+2),
- ip6addr_string(pdu->prefix),
+ ip6addr_string(ndo, pdu->prefix),
pdu->prefix_length, pdu->max_length,
- EXTRACT_32BITS(pdu->as), pdu->flags);
+ EXTRACT_32BITS(pdu->as), pdu->flags));
}
break;
#endif
@@ -263,10 +257,10 @@ rpki_rtr_pdu_print (const u_char *tptr, u_int indent)
tlen = pdu_len;
error_code = EXTRACT_16BITS(pdu->pdu_header.u.error_code);
- printf("%sError code: %s (%u), Encapsulated PDU length: %u",
+ ND_PRINT((ndo, "%sError code: %s (%u), Encapsulated PDU length: %u",
indent_string(indent+2),
tok2str(rpki_rtr_error_codes, "Unknown", error_code),
- error_code, encapsulated_pdu_length);
+ error_code, encapsulated_pdu_length));
tptr += sizeof(*pdu);
tlen -= sizeof(*pdu);
@@ -276,8 +270,8 @@ rpki_rtr_pdu_print (const u_char *tptr, u_int indent)
*/
if (encapsulated_pdu_length &&
(encapsulated_pdu_length <= tlen)) {
- printf("%s-----encapsulated PDU-----", indent_string(indent+4));
- rpki_rtr_pdu_print(tptr, indent+2);
+ ND_PRINT((ndo, "%s-----encapsulated PDU-----", indent_string(indent+4)));
+ rpki_rtr_pdu_print(ndo, tptr, indent+2);
}
tptr += encapsulated_pdu_length;
@@ -285,7 +279,7 @@ rpki_rtr_pdu_print (const u_char *tptr, u_int indent)
/*
* Extract, trail-zero and print the Error message.
- */
+ */
text_length = 0;
if (tlen > 4) {
text_length = EXTRACT_32BITS(tptr);
@@ -293,9 +287,9 @@ rpki_rtr_pdu_print (const u_char *tptr, u_int indent)
tlen -= 4;
}
if (text_length && (text_length <= tlen )) {
- memcpy(buf, tptr, MIN(sizeof(buf)-1, text_length));
+ memcpy(buf, tptr, min(sizeof(buf)-1, text_length));
buf[text_length] = '\0';
- printf("%sError text: %s", indent_string(indent+2), buf);
+ ND_PRINT((ndo, "%sError text: %s", indent_string(indent+2), buf));
}
}
break;
@@ -304,18 +298,18 @@ rpki_rtr_pdu_print (const u_char *tptr, u_int indent)
/*
* Unknown data, please hexdump.
- */
+ */
hexdump = TRUE;
}
/* do we also want to see a hex dump ? */
- if (vflag > 1 || (vflag && hexdump)) {
- print_unknown_data(tptr,"\n\t ", pdu_len);
+ if (ndo->ndo_vflag > 1 || (ndo->ndo_vflag && hexdump)) {
+ print_unknown_data(ndo,tptr,"\n\t ", pdu_len);
}
}
void
-rpki_rtr_print(register const u_char *pptr, register u_int len) {
+rpki_rtr_print(netdissect_options *ndo, register const u_char *pptr, register u_int len) {
u_int tlen, pdu_type, pdu_len;
const u_char *tptr;
@@ -324,14 +318,14 @@ rpki_rtr_print(register const u_char *pptr, register u_int len) {
tptr = pptr;
tlen = len;
- if (!vflag) {
- printf(", RPKI-RTR");
+ if (!ndo->ndo_vflag) {
+ ND_PRINT((ndo, ", RPKI-RTR"));
return;
}
while (tlen >= sizeof(rpki_rtr_pdu)) {
- TCHECK2(*tptr, sizeof(rpki_rtr_pdu));
+ ND_TCHECK2(*tptr, sizeof(rpki_rtr_pdu));
pdu_header = (rpki_rtr_pdu *)tptr;
pdu_type = pdu_header->pdu_type;
@@ -342,7 +336,7 @@ rpki_rtr_print(register const u_char *pptr, register u_int len) {
break;
}
- TCHECK2(*tptr, pdu_len);
+ ND_TCHECK2(*tptr, pdu_len);
if (tlen < pdu_len) {
goto trunc;
}
@@ -350,14 +344,14 @@ rpki_rtr_print(register const u_char *pptr, register u_int len) {
/*
* Print the PDU.
*/
- rpki_rtr_pdu_print(tptr, 8);
+ rpki_rtr_pdu_print(ndo, tptr, 8);
tlen -= pdu_len;
tptr += pdu_len;
}
return;
trunc:
- printf("\n\t[|RPKI-RTR]");
+ ND_PRINT((ndo, "\n\t[|RPKI-RTR]"));
}
/*
diff --git a/contrib/tcpdump/print-rrcp.c b/contrib/tcpdump/print-rrcp.c
index c5b1fdd96a20..2370d9c20e25 100644
--- a/contrib/tcpdump/print-rrcp.c
+++ b/contrib/tcpdump/print-rrcp.c
@@ -21,29 +21,18 @@
* and Realtek Echo Protocol (RRCP-REP) packets.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-rrcp.c,v 1.2 2008-04-11 17:21:34 gianluca Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "netdissect.h"
+#include "interface.h"
#include "addrtoname.h"
#include "extract.h"
#include "ether.h"
-#ifndef ETH_ALEN
-#define ETH_ALEN 6
-#endif
-
#define RRCP_OPCODE_MASK 0x7F /* 0x00 = hello, 0x01 = get, 0x02 = set */
#define RRCP_ISREPLY 0x80 /* 0 = request to switch, 0x80 = reply from switch */
@@ -86,8 +75,8 @@ rrcp_print(netdissect_options *ndo,
u_int length _U_)
{
const u_char *rrcp;
- u_int8_t rrcp_proto;
- u_int8_t rrcp_opcode;
+ uint8_t rrcp_proto;
+ uint8_t rrcp_opcode;
register const struct ether_header *ep;
char proto_str[16];
char opcode_str[32];
@@ -100,8 +89,8 @@ rrcp_print(netdissect_options *ndo,
ND_TCHECK(*(rrcp + RRCP_OPCODE_ISREPLY_OFFSET));
rrcp_opcode = (*(rrcp + RRCP_OPCODE_ISREPLY_OFFSET)) & RRCP_OPCODE_MASK;
ND_PRINT((ndo, "%s > %s, %s %s",
- etheraddr_string(ESRC(ep)),
- etheraddr_string(EDST(ep)),
+ etheraddr_string(ndo, ESRC(ep)),
+ etheraddr_string(ndo, EDST(ep)),
tok2strbuf(proto_values,"RRCP-0x%02x",rrcp_proto,proto_str,sizeof(proto_str)),
((*(rrcp + RRCP_OPCODE_ISREPLY_OFFSET)) & RRCP_ISREPLY) ? "reply" : "query"));
if (rrcp_proto==1){
@@ -125,7 +114,7 @@ rrcp_print(netdissect_options *ndo,
ND_PRINT((ndo, " downlink_port=%d, uplink_port=%d, uplink_mac=%s, vendor_id=%08x ,chip_id=%04x ",
*(rrcp + RRCP_DOWNLINK_PORT_OFFSET),
*(rrcp + RRCP_UPLINK_PORT_OFFSET),
- etheraddr_string(rrcp + RRCP_UPLINK_MAC_OFFSET),
+ etheraddr_string(ndo, rrcp + RRCP_UPLINK_MAC_OFFSET),
EXTRACT_32BITS(rrcp + RRCP_VENDOR_ID_OFFSET),
EXTRACT_16BITS(rrcp + RRCP_CHIP_ID_OFFSET)));
}else if (rrcp_opcode==1 || rrcp_opcode==2 || rrcp_proto==2){
@@ -134,8 +123,6 @@ rrcp_print(netdissect_options *ndo,
EXTRACT_32BITS(rrcp + RRCP_COOKIE2_OFFSET),
EXTRACT_32BITS(rrcp + RRCP_COOKIE1_OFFSET)));
}
- if (!ndo->ndo_vflag)
- return;
return;
trunc:
diff --git a/contrib/tcpdump/print-rsvp.c b/contrib/tcpdump/print-rsvp.c
index 1c76dcbbf6a9..51ab9f8ad104 100644
--- a/contrib/tcpdump/print-rsvp.c
+++ b/contrib/tcpdump/print-rsvp.c
@@ -15,21 +15,13 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-rsvp.c,v 1.50 2008-08-16 11:36:20 hannes Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
#include "interface.h"
#include "extract.h"
#include "addrtoname.h"
@@ -51,18 +43,18 @@ static const char rcsid[] _U_ =
*/
struct rsvp_common_header {
- u_int8_t version_flags;
- u_int8_t msg_type;
- u_int8_t checksum[2];
- u_int8_t ttl;
- u_int8_t reserved;
- u_int8_t length[2];
+ uint8_t version_flags;
+ uint8_t msg_type;
+ uint8_t checksum[2];
+ uint8_t ttl;
+ uint8_t reserved;
+ uint8_t length[2];
};
-/*
+/*
* RFC2205 object header
*
- *
+ *
* 0 1 2 3
* +-------------+-------------+-------------+-------------+
* | Length (bytes) | Class-Num | C-Type |
@@ -74,13 +66,13 @@ struct rsvp_common_header {
*/
struct rsvp_object_header {
- u_int8_t length[2];
- u_int8_t class_num;
- u_int8_t ctype;
+ uint8_t length[2];
+ uint8_t class_num;
+ uint8_t ctype;
};
#define RSVP_VERSION 1
-#define RSVP_EXTRACT_VERSION(x) (((x)&0xf0)>>4)
+#define RSVP_EXTRACT_VERSION(x) (((x)&0xf0)>>4)
#define RSVP_EXTRACT_FLAGS(x) ((x)&0x0f)
#define RSVP_MSGTYPE_PATH 1
@@ -121,7 +113,7 @@ static const struct tok rsvp_header_flag_values[] = {
#define RSVP_OBJ_RSVP_HOP 3 /* rfc2205, rfc3473 */
#define RSVP_OBJ_INTEGRITY 4 /* rfc2747 */
#define RSVP_OBJ_TIME_VALUES 5 /* rfc2205 */
-#define RSVP_OBJ_ERROR_SPEC 6
+#define RSVP_OBJ_ERROR_SPEC 6
#define RSVP_OBJ_SCOPE 7
#define RSVP_OBJ_STYLE 8 /* rfc2205 */
#define RSVP_OBJ_FLOWSPEC 9 /* rfc2215 */
@@ -300,11 +292,11 @@ static const struct tok rsvp_ctype_values[] = {
};
struct rsvp_obj_integrity_t {
- u_int8_t flags;
- u_int8_t res;
- u_int8_t key_id[6];
- u_int8_t sequence[8];
- u_int8_t digest[16];
+ uint8_t flags;
+ uint8_t res;
+ uint8_t key_id[6];
+ uint8_t sequence[8];
+ uint8_t digest[16];
};
static const struct tok rsvp_obj_integrity_flag_values[] = {
@@ -313,14 +305,14 @@ static const struct tok rsvp_obj_integrity_flag_values[] = {
};
struct rsvp_obj_frr_t {
- u_int8_t setup_prio;
- u_int8_t hold_prio;
- u_int8_t hop_limit;
- u_int8_t flags;
- u_int8_t bandwidth[4];
- u_int8_t include_any[4];
- u_int8_t exclude_any[4];
- u_int8_t include_all[4];
+ uint8_t setup_prio;
+ uint8_t hold_prio;
+ uint8_t hop_limit;
+ uint8_t flags;
+ uint8_t bandwidth[4];
+ uint8_t include_any[4];
+ uint8_t exclude_any[4];
+ uint8_t include_all[4];
};
@@ -390,7 +382,7 @@ static const struct tok rsvp_intserv_parameter_id_values[] = {
{ 0, NULL}
};
-static struct tok rsvp_session_attribute_flag_values[] = {
+static const struct tok rsvp_session_attribute_flag_values[] = {
{ 0x01, "Local Protection" },
{ 0x02, "Label Recording" },
{ 0x04, "SE Style" },
@@ -399,7 +391,7 @@ static struct tok rsvp_session_attribute_flag_values[] = {
{ 0, NULL}
};
-static struct tok rsvp_obj_prop_tlv_values[] = {
+static const struct tok rsvp_obj_prop_tlv_values[] = {
{ 0x01, "Cos" },
{ 0x02, "Metric 1" },
{ 0x04, "Metric 2" },
@@ -413,7 +405,7 @@ static struct tok rsvp_obj_prop_tlv_values[] = {
#define RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE 28
#define RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE_OLD 125
-static struct tok rsvp_obj_error_code_values[] = {
+static const struct tok rsvp_obj_error_code_values[] = {
{ RSVP_OBJ_ERROR_SPEC_CODE_ROUTING, "Routing Problem" },
{ RSVP_OBJ_ERROR_SPEC_CODE_NOTIFY, "Notify Error" },
{ RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE, "Diffserv TE Error" },
@@ -421,7 +413,7 @@ static struct tok rsvp_obj_error_code_values[] = {
{ 0, NULL}
};
-static struct tok rsvp_obj_error_code_routing_values[] = {
+static const struct tok rsvp_obj_error_code_routing_values[] = {
{ 1, "Bad EXPLICIT_ROUTE object" },
{ 2, "Bad strict node" },
{ 3, "Bad loose node" },
@@ -435,14 +427,14 @@ static struct tok rsvp_obj_error_code_routing_values[] = {
{ 0, NULL}
};
-static struct tok rsvp_obj_error_code_diffserv_te_values[] = {
+static const struct tok rsvp_obj_error_code_diffserv_te_values[] = {
{ 1, "Unexpected CT object" },
{ 2, "Unsupported CT" },
{ 3, "Invalid CT value" },
{ 4, "CT/setup priority do not form a configured TE-Class" },
{ 5, "CT/holding priority do not form a configured TE-Class" },
{ 6, "CT/setup priority and CT/holding priority do not form a configured TE-Class" },
- { 7, "Inconsistency between signaled PSC and signaled CT" },
+ { 7, "Inconsistency between signaled PSC and signaled CT" },
{ 8, "Inconsistency between signaled PHBs and signaled CT" },
{ 0, NULL}
};
@@ -486,21 +478,20 @@ static const struct tok rsvp_obj_generalized_uni_values[] = {
{ 0, NULL}
};
-static int rsvp_intserv_print(const u_char *, u_short);
-
-/*
+/*
* this is a dissector for all the intserv defined
* specs as defined per rfc2215
* it is called from various rsvp objects;
* returns the amount of bytes being processed
*/
static int
-rsvp_intserv_print(const u_char *tptr, u_short obj_tlen) {
+rsvp_intserv_print(netdissect_options *ndo,
+ const u_char *tptr, u_short obj_tlen) {
int parameter_id,parameter_length;
union {
float f;
- u_int32_t i;
+ uint32_t i;
} bw;
if (obj_tlen < 4)
@@ -508,11 +499,11 @@ rsvp_intserv_print(const u_char *tptr, u_short obj_tlen) {
parameter_id = *(tptr);
parameter_length = EXTRACT_16BITS(tptr+2)<<2; /* convert wordcount to bytecount */
- printf("\n\t Parameter ID: %s (%u), length: %u, Flags: [0x%02x]",
+ ND_PRINT((ndo, "\n\t Parameter ID: %s (%u), length: %u, Flags: [0x%02x]",
tok2str(rsvp_intserv_parameter_id_values,"unknown",parameter_id),
parameter_id,
parameter_length,
- *(tptr+1));
+ *(tptr + 1)));
if (obj_tlen < parameter_length+4)
return 0;
@@ -527,7 +518,7 @@ rsvp_intserv_print(const u_char *tptr, u_short obj_tlen) {
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
if (parameter_length == 4)
- printf("\n\t\tIS hop count: %u", EXTRACT_32BITS(tptr+4));
+ ND_PRINT((ndo, "\n\t\tIS hop count: %u", EXTRACT_32BITS(tptr + 4)));
break;
case 6:
@@ -540,7 +531,7 @@ rsvp_intserv_print(const u_char *tptr, u_short obj_tlen) {
*/
if (parameter_length == 4) {
bw.i = EXTRACT_32BITS(tptr+4);
- printf("\n\t\tPath b/w estimate: %.10g Mbps", bw.f/125000);
+ ND_PRINT((ndo, "\n\t\tPath b/w estimate: %.10g Mbps", bw.f / 125000));
}
break;
@@ -553,11 +544,11 @@ rsvp_intserv_print(const u_char *tptr, u_short obj_tlen) {
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
if (parameter_length == 4) {
- printf("\n\t\tMinimum path latency: ");
+ ND_PRINT((ndo, "\n\t\tMinimum path latency: "));
if (EXTRACT_32BITS(tptr+4) == 0xffffffff)
- printf("don't care");
+ ND_PRINT((ndo, "don't care"));
else
- printf("%u", EXTRACT_32BITS(tptr+4));
+ ND_PRINT((ndo, "%u", EXTRACT_32BITS(tptr + 4)));
}
break;
@@ -571,10 +562,10 @@ rsvp_intserv_print(const u_char *tptr, u_short obj_tlen) {
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
if (parameter_length == 4)
- printf("\n\t\tComposed MTU: %u bytes", EXTRACT_32BITS(tptr+4));
+ ND_PRINT((ndo, "\n\t\tComposed MTU: %u bytes", EXTRACT_32BITS(tptr + 4)));
break;
case 127:
- /*
+ /*
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | 127 (e) | 0 (f) | 5 (g) |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -592,18 +583,18 @@ rsvp_intserv_print(const u_char *tptr, u_short obj_tlen) {
if (parameter_length == 20) {
bw.i = EXTRACT_32BITS(tptr+4);
- printf("\n\t\tToken Bucket Rate: %.10g Mbps", bw.f/125000);
+ ND_PRINT((ndo, "\n\t\tToken Bucket Rate: %.10g Mbps", bw.f / 125000));
bw.i = EXTRACT_32BITS(tptr+8);
- printf("\n\t\tToken Bucket Size: %.10g bytes", bw.f);
+ ND_PRINT((ndo, "\n\t\tToken Bucket Size: %.10g bytes", bw.f));
bw.i = EXTRACT_32BITS(tptr+12);
- printf("\n\t\tPeak Data Rate: %.10g Mbps", bw.f/125000);
- printf("\n\t\tMinimum Policed Unit: %u bytes", EXTRACT_32BITS(tptr+16));
- printf("\n\t\tMaximum Packet Size: %u bytes", EXTRACT_32BITS(tptr+20));
+ ND_PRINT((ndo, "\n\t\tPeak Data Rate: %.10g Mbps", bw.f / 125000));
+ ND_PRINT((ndo, "\n\t\tMinimum Policed Unit: %u bytes", EXTRACT_32BITS(tptr + 16)));
+ ND_PRINT((ndo, "\n\t\tMaximum Packet Size: %u bytes", EXTRACT_32BITS(tptr + 20)));
}
break;
case 130:
- /*
+ /*
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | 130 (h) | 0 (i) | 2 (j) |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -615,8 +606,8 @@ rsvp_intserv_print(const u_char *tptr, u_short obj_tlen) {
if (parameter_length == 8) {
bw.i = EXTRACT_32BITS(tptr+4);
- printf("\n\t\tRate: %.10g Mbps", bw.f/125000);
- printf("\n\t\tSlack Term: %u", EXTRACT_32BITS(tptr+8));
+ ND_PRINT((ndo, "\n\t\tRate: %.10g Mbps", bw.f / 125000));
+ ND_PRINT((ndo, "\n\t\tSlack Term: %u", EXTRACT_32BITS(tptr + 8)));
}
break;
@@ -625,18 +616,19 @@ rsvp_intserv_print(const u_char *tptr, u_short obj_tlen) {
case 135:
case 136:
if (parameter_length == 4)
- printf("\n\t\tValue: %u", EXTRACT_32BITS(tptr+4));
+ ND_PRINT((ndo, "\n\t\tValue: %u", EXTRACT_32BITS(tptr + 4)));
break;
default:
- if (vflag <= 1)
- print_unknown_data(tptr+4,"\n\t\t",parameter_length);
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo, tptr + 4, "\n\t\t", parameter_length);
}
return (parameter_length+4); /* header length 4 bytes */
}
static int
-rsvp_obj_print (const u_char *pptr
+rsvp_obj_print(netdissect_options *ndo,
+ const u_char *pptr
#ifndef HAVE_LIBCRYPTO
_U_
#endif
@@ -658,52 +650,51 @@ _U_
int hexdump,processed,padbytes,error_code,error_value,i,sigcheck;
union {
float f;
- u_int32_t i;
+ uint32_t i;
} bw;
- u_int8_t namelen;
+ uint8_t namelen;
u_int action, subchannel;
while(tlen>=sizeof(struct rsvp_object_header)) {
/* did we capture enough for fully decoding the object header ? */
- if (!TTEST2(*tptr, sizeof(struct rsvp_object_header)))
- goto trunc;
+ ND_TCHECK2(*tptr, sizeof(struct rsvp_object_header));
rsvp_obj_header = (const struct rsvp_object_header *)tptr;
rsvp_obj_len=EXTRACT_16BITS(rsvp_obj_header->length);
rsvp_obj_ctype=rsvp_obj_header->ctype;
if(rsvp_obj_len % 4) {
- printf("%sERROR: object header size %u not a multiple of 4", ident, rsvp_obj_len);
+ ND_PRINT((ndo, "%sERROR: object header size %u not a multiple of 4", ident, rsvp_obj_len));
return -1;
}
if(rsvp_obj_len < sizeof(struct rsvp_object_header)) {
- printf("%sERROR: object header too short %u < %lu", ident, rsvp_obj_len,
- (unsigned long)sizeof(const struct rsvp_object_header));
+ ND_PRINT((ndo, "%sERROR: object header too short %u < %lu", ident, rsvp_obj_len,
+ (unsigned long)sizeof(const struct rsvp_object_header)));
return -1;
}
- printf("%s%s Object (%u) Flags: [%s",
+ ND_PRINT((ndo, "%s%s Object (%u) Flags: [%s",
ident,
tok2str(rsvp_obj_values,
"Unknown",
rsvp_obj_header->class_num),
rsvp_obj_header->class_num,
- ((rsvp_obj_header->class_num)&0x80) ? "ignore" : "reject");
+ ((rsvp_obj_header->class_num) & 0x80) ? "ignore" : "reject"));
if (rsvp_obj_header->class_num > 128)
- printf(" %s",
- ((rsvp_obj_header->class_num)&0x40) ? "and forward" : "silently");
+ ND_PRINT((ndo, " %s",
+ ((rsvp_obj_header->class_num) & 0x40) ? "and forward" : "silently"));
- printf(" if unknown], Class-Type: %s (%u), length: %u",
+ ND_PRINT((ndo, " if unknown], Class-Type: %s (%u), length: %u",
tok2str(rsvp_ctype_values,
"Unknown",
((rsvp_obj_header->class_num)<<8)+rsvp_obj_ctype),
rsvp_obj_ctype,
- rsvp_obj_len);
-
+ rsvp_obj_len));
+
if(tlen < rsvp_obj_len) {
- printf("%sERROR: object goes past end of objects TLV", ident);
+ ND_PRINT((ndo, "%sERROR: object goes past end of objects TLV", ident));
return -1;
}
@@ -711,7 +702,7 @@ _U_
obj_tlen=rsvp_obj_len-sizeof(struct rsvp_object_header);
/* did we capture enough for fully decoding the object ? */
- if (!TTEST2(*tptr, rsvp_obj_len))
+ if (!ND_TTEST2(*tptr, rsvp_obj_len))
return -1;
hexdump=FALSE;
@@ -721,79 +712,79 @@ _U_
case RSVP_CTYPE_IPV4:
if (obj_tlen < 8)
return -1;
- printf("%s IPv4 DestAddress: %s, Protocol ID: 0x%02x",
+ ND_PRINT((ndo, "%s IPv4 DestAddress: %s, Protocol ID: 0x%02x",
ident,
- ipaddr_string(obj_tptr),
- *(obj_tptr+sizeof(struct in_addr)));
- printf("%s Flags: [0x%02x], DestPort %u",
+ ipaddr_string(ndo, obj_tptr),
+ *(obj_tptr + sizeof(struct in_addr))));
+ ND_PRINT((ndo, "%s Flags: [0x%02x], DestPort %u",
ident,
*(obj_tptr+5),
- EXTRACT_16BITS(obj_tptr+6));
+ EXTRACT_16BITS(obj_tptr + 6)));
obj_tlen-=8;
- obj_tptr+=8;
+ obj_tptr+=8;
break;
#ifdef INET6
case RSVP_CTYPE_IPV6:
if (obj_tlen < 20)
return -1;
- printf("%s IPv6 DestAddress: %s, Protocol ID: 0x%02x",
+ ND_PRINT((ndo, "%s IPv6 DestAddress: %s, Protocol ID: 0x%02x",
ident,
- ip6addr_string(obj_tptr),
- *(obj_tptr+sizeof(struct in6_addr)));
- printf("%s Flags: [0x%02x], DestPort %u",
+ ip6addr_string(ndo, obj_tptr),
+ *(obj_tptr + sizeof(struct in6_addr))));
+ ND_PRINT((ndo, "%s Flags: [0x%02x], DestPort %u",
ident,
*(obj_tptr+sizeof(struct in6_addr)+1),
- EXTRACT_16BITS(obj_tptr+sizeof(struct in6_addr)+2));
+ EXTRACT_16BITS(obj_tptr + sizeof(struct in6_addr) + 2)));
obj_tlen-=20;
- obj_tptr+=20;
+ obj_tptr+=20;
break;
case RSVP_CTYPE_TUNNEL_IPV6:
if (obj_tlen < 36)
return -1;
- printf("%s IPv6 Tunnel EndPoint: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
+ ND_PRINT((ndo, "%s IPv6 Tunnel EndPoint: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
ident,
- ip6addr_string(obj_tptr),
+ ip6addr_string(ndo, obj_tptr),
EXTRACT_16BITS(obj_tptr+18),
- ip6addr_string(obj_tptr+20));
+ ip6addr_string(ndo, obj_tptr + 20)));
obj_tlen-=36;
- obj_tptr+=36;
+ obj_tptr+=36;
break;
case RSVP_CTYPE_14: /* IPv6 p2mp LSP Tunnel */
if (obj_tlen < 26)
return -1;
- printf("%s IPv6 P2MP LSP ID: 0x%08x, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
+ ND_PRINT((ndo, "%s IPv6 P2MP LSP ID: 0x%08x, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
ident,
EXTRACT_32BITS(obj_tptr),
EXTRACT_16BITS(obj_tptr+6),
- ip6addr_string(obj_tptr+8));
+ ip6addr_string(ndo, obj_tptr + 8)));
obj_tlen-=26;
- obj_tptr+=26;
+ obj_tptr+=26;
break;
#endif
case RSVP_CTYPE_13: /* IPv4 p2mp LSP Tunnel */
if (obj_tlen < 12)
return -1;
- printf("%s IPv4 P2MP LSP ID: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
+ ND_PRINT((ndo, "%s IPv4 P2MP LSP ID: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
ident,
- ipaddr_string(obj_tptr),
+ ipaddr_string(ndo, obj_tptr),
EXTRACT_16BITS(obj_tptr+6),
- ipaddr_string(obj_tptr+8));
+ ipaddr_string(ndo, obj_tptr + 8)));
obj_tlen-=12;
- obj_tptr+=12;
+ obj_tptr+=12;
break;
case RSVP_CTYPE_TUNNEL_IPV4:
case RSVP_CTYPE_UNI_IPV4:
if (obj_tlen < 12)
return -1;
- printf("%s IPv4 Tunnel EndPoint: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
+ ND_PRINT((ndo, "%s IPv4 Tunnel EndPoint: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
ident,
- ipaddr_string(obj_tptr),
+ ipaddr_string(ndo, obj_tptr),
EXTRACT_16BITS(obj_tptr+6),
- ipaddr_string(obj_tptr+8));
+ ipaddr_string(ndo, obj_tptr + 8)));
obj_tlen-=12;
- obj_tptr+=12;
+ obj_tptr+=12;
break;
default:
hexdump=TRUE;
@@ -805,21 +796,21 @@ _U_
case RSVP_CTYPE_IPV4:
if (obj_tlen < sizeof(struct in_addr))
return -1;
- printf("%s IPv4 Receiver Address: %s",
+ ND_PRINT((ndo, "%s IPv4 Receiver Address: %s",
ident,
- ipaddr_string(obj_tptr));
+ ipaddr_string(ndo, obj_tptr)));
obj_tlen-=sizeof(struct in_addr);
- obj_tptr+=sizeof(struct in_addr);
+ obj_tptr+=sizeof(struct in_addr);
break;
#ifdef INET6
case RSVP_CTYPE_IPV6:
if (obj_tlen < sizeof(struct in6_addr))
return -1;
- printf("%s IPv6 Receiver Address: %s",
+ ND_PRINT((ndo, "%s IPv6 Receiver Address: %s",
ident,
- ip6addr_string(obj_tptr));
+ ip6addr_string(ndo, obj_tptr)));
obj_tlen-=sizeof(struct in6_addr);
- obj_tptr+=sizeof(struct in6_addr);
+ obj_tptr+=sizeof(struct in6_addr);
break;
#endif
default:
@@ -832,21 +823,21 @@ _U_
case RSVP_CTYPE_IPV4:
if (obj_tlen < sizeof(struct in_addr))
return -1;
- printf("%s IPv4 Notify Node Address: %s",
+ ND_PRINT((ndo, "%s IPv4 Notify Node Address: %s",
ident,
- ipaddr_string(obj_tptr));
+ ipaddr_string(ndo, obj_tptr)));
obj_tlen-=sizeof(struct in_addr);
- obj_tptr+=sizeof(struct in_addr);
+ obj_tptr+=sizeof(struct in_addr);
break;
#ifdef INET6
case RSVP_CTYPE_IPV6:
if (obj_tlen < sizeof(struct in6_addr))
return-1;
- printf("%s IPv6 Notify Node Address: %s",
+ ND_PRINT((ndo, "%s IPv6 Notify Node Address: %s",
ident,
- ip6addr_string(obj_tptr));
+ ip6addr_string(ndo, obj_tptr)));
obj_tlen-=sizeof(struct in6_addr);
- obj_tptr+=sizeof(struct in6_addr);
+ obj_tptr+=sizeof(struct in6_addr);
break;
#endif
default:
@@ -861,7 +852,7 @@ _U_
switch(rsvp_obj_ctype) {
case RSVP_CTYPE_1:
while(obj_tlen >= 4 ) {
- printf("%s Label: %u", ident, EXTRACT_32BITS(obj_tptr));
+ ND_PRINT((ndo, "%s Label: %u", ident, EXTRACT_32BITS(obj_tptr)));
obj_tlen-=4;
obj_tptr+=4;
}
@@ -869,21 +860,21 @@ _U_
case RSVP_CTYPE_2:
if (obj_tlen < 4)
return-1;
- printf("%s Generalized Label: %u",
+ ND_PRINT((ndo, "%s Generalized Label: %u",
ident,
- EXTRACT_32BITS(obj_tptr));
+ EXTRACT_32BITS(obj_tptr)));
obj_tlen-=4;
obj_tptr+=4;
break;
case RSVP_CTYPE_3:
if (obj_tlen < 12)
return-1;
- printf("%s Waveband ID: %u%s Start Label: %u, Stop Label: %u",
+ ND_PRINT((ndo, "%s Waveband ID: %u%s Start Label: %u, Stop Label: %u",
ident,
EXTRACT_32BITS(obj_tptr),
ident,
EXTRACT_32BITS(obj_tptr+4),
- EXTRACT_32BITS(obj_tptr+8));
+ EXTRACT_32BITS(obj_tptr + 8)));
obj_tlen-=12;
obj_tptr+=12;
break;
@@ -897,12 +888,12 @@ _U_
case RSVP_CTYPE_1:
if (obj_tlen < 4)
return-1;
- printf("%s Reservation Style: %s, Flags: [0x%02x]",
+ ND_PRINT((ndo, "%s Reservation Style: %s, Flags: [0x%02x]",
ident,
tok2str(rsvp_resstyle_values,
"Unknown",
EXTRACT_24BITS(obj_tptr+1)),
- *(obj_tptr));
+ *(obj_tptr)));
obj_tlen-=4;
obj_tptr+=4;
break;
@@ -916,10 +907,10 @@ _U_
case RSVP_CTYPE_IPV4:
if (obj_tlen < 8)
return-1;
- printf("%s Source Address: %s, Source Port: %u",
+ ND_PRINT((ndo, "%s Source Address: %s, Source Port: %u",
ident,
- ipaddr_string(obj_tptr),
- EXTRACT_16BITS(obj_tptr+6));
+ ipaddr_string(ndo, obj_tptr),
+ EXTRACT_16BITS(obj_tptr + 6)));
obj_tlen-=8;
obj_tptr+=8;
break;
@@ -927,24 +918,24 @@ _U_
case RSVP_CTYPE_IPV6:
if (obj_tlen < 20)
return-1;
- printf("%s Source Address: %s, Source Port: %u",
+ ND_PRINT((ndo, "%s Source Address: %s, Source Port: %u",
ident,
- ip6addr_string(obj_tptr),
- EXTRACT_16BITS(obj_tptr+18));
+ ip6addr_string(ndo, obj_tptr),
+ EXTRACT_16BITS(obj_tptr + 18)));
obj_tlen-=20;
obj_tptr+=20;
break;
case RSVP_CTYPE_13: /* IPv6 p2mp LSP tunnel */
if (obj_tlen < 40)
return-1;
- printf("%s IPv6 Tunnel Sender Address: %s, LSP ID: 0x%04x"
+ ND_PRINT((ndo, "%s IPv6 Tunnel Sender Address: %s, LSP ID: 0x%04x"
"%s Sub-Group Originator ID: %s, Sub-Group ID: 0x%04x",
ident,
- ip6addr_string(obj_tptr),
+ ip6addr_string(ndo, obj_tptr),
EXTRACT_16BITS(obj_tptr+18),
ident,
- ip6addr_string(obj_tptr+20),
- EXTRACT_16BITS(obj_tptr+38));
+ ip6addr_string(ndo, obj_tptr+20),
+ EXTRACT_16BITS(obj_tptr + 38)));
obj_tlen-=40;
obj_tptr+=40;
break;
@@ -952,24 +943,24 @@ _U_
case RSVP_CTYPE_TUNNEL_IPV4:
if (obj_tlen < 8)
return-1;
- printf("%s IPv4 Tunnel Sender Address: %s, LSP-ID: 0x%04x",
+ ND_PRINT((ndo, "%s IPv4 Tunnel Sender Address: %s, LSP-ID: 0x%04x",
ident,
- ipaddr_string(obj_tptr),
- EXTRACT_16BITS(obj_tptr+6));
+ ipaddr_string(ndo, obj_tptr),
+ EXTRACT_16BITS(obj_tptr + 6)));
obj_tlen-=8;
obj_tptr+=8;
break;
case RSVP_CTYPE_12: /* IPv4 p2mp LSP tunnel */
if (obj_tlen < 16)
return-1;
- printf("%s IPv4 Tunnel Sender Address: %s, LSP ID: 0x%04x"
+ ND_PRINT((ndo, "%s IPv4 Tunnel Sender Address: %s, LSP ID: 0x%04x"
"%s Sub-Group Originator ID: %s, Sub-Group ID: 0x%04x",
ident,
- ipaddr_string(obj_tptr),
+ ipaddr_string(ndo, obj_tptr),
EXTRACT_16BITS(obj_tptr+6),
ident,
- ipaddr_string(obj_tptr+8),
- EXTRACT_16BITS(obj_tptr+12));
+ ipaddr_string(ndo, obj_tptr+8),
+ EXTRACT_16BITS(obj_tptr + 12)));
obj_tlen-=16;
obj_tptr+=16;
break;
@@ -982,11 +973,11 @@ _U_
switch(rsvp_obj_ctype) {
case RSVP_CTYPE_1:
while(obj_tlen >= 4 ) {
- printf("%s L3 Protocol ID: %s",
+ ND_PRINT((ndo, "%s L3 Protocol ID: %s",
ident,
tok2str(ethertype_values,
"Unknown Protocol (0x%04x)",
- EXTRACT_16BITS(obj_tptr+2)));
+ EXTRACT_16BITS(obj_tptr + 2))));
obj_tlen-=4;
obj_tptr+=4;
}
@@ -994,50 +985,50 @@ _U_
case RSVP_CTYPE_2:
if (obj_tlen < 12)
return-1;
- printf("%s L3 Protocol ID: %s",
+ ND_PRINT((ndo, "%s L3 Protocol ID: %s",
ident,
tok2str(ethertype_values,
"Unknown Protocol (0x%04x)",
- EXTRACT_16BITS(obj_tptr+2)));
- printf(",%s merge capability",((*(obj_tptr+4))&0x80) ? "no" : "" );
- printf("%s Minimum VPI/VCI: %u/%u",
+ EXTRACT_16BITS(obj_tptr + 2))));
+ ND_PRINT((ndo, ",%s merge capability",((*(obj_tptr + 4)) & 0x80) ? "no" : "" ));
+ ND_PRINT((ndo, "%s Minimum VPI/VCI: %u/%u",
ident,
(EXTRACT_16BITS(obj_tptr+4))&0xfff,
- (EXTRACT_16BITS(obj_tptr+6))&0xfff);
- printf("%s Maximum VPI/VCI: %u/%u",
+ (EXTRACT_16BITS(obj_tptr + 6)) & 0xfff));
+ ND_PRINT((ndo, "%s Maximum VPI/VCI: %u/%u",
ident,
(EXTRACT_16BITS(obj_tptr+8))&0xfff,
- (EXTRACT_16BITS(obj_tptr+10))&0xfff);
+ (EXTRACT_16BITS(obj_tptr + 10)) & 0xfff));
obj_tlen-=12;
obj_tptr+=12;
break;
case RSVP_CTYPE_3:
if (obj_tlen < 12)
return-1;
- printf("%s L3 Protocol ID: %s",
+ ND_PRINT((ndo, "%s L3 Protocol ID: %s",
ident,
tok2str(ethertype_values,
"Unknown Protocol (0x%04x)",
- EXTRACT_16BITS(obj_tptr+2)));
- printf("%s Minimum/Maximum DLCI: %u/%u, %s%s bit DLCI",
+ EXTRACT_16BITS(obj_tptr + 2))));
+ ND_PRINT((ndo, "%s Minimum/Maximum DLCI: %u/%u, %s%s bit DLCI",
ident,
(EXTRACT_32BITS(obj_tptr+4))&0x7fffff,
(EXTRACT_32BITS(obj_tptr+8))&0x7fffff,
(((EXTRACT_16BITS(obj_tptr+4)>>7)&3) == 0 ) ? "10" : "",
- (((EXTRACT_16BITS(obj_tptr+4)>>7)&3) == 2 ) ? "23" : "");
+ (((EXTRACT_16BITS(obj_tptr + 4) >> 7) & 3) == 2 ) ? "23" : ""));
obj_tlen-=12;
obj_tptr+=12;
break;
case RSVP_CTYPE_4:
if (obj_tlen < 4)
return-1;
- printf("%s LSP Encoding Type: %s (%u)",
+ ND_PRINT((ndo, "%s LSP Encoding Type: %s (%u)",
ident,
tok2str(gmpls_encoding_values,
"Unknown",
*obj_tptr),
- *obj_tptr);
- printf("%s Switching Type: %s (%u), Payload ID: %s (0x%04x)",
+ *obj_tptr));
+ ND_PRINT((ndo, "%s Switching Type: %s (%u), Payload ID: %s (0x%04x)",
ident,
tok2str(gmpls_switch_cap_values,
"Unknown",
@@ -1046,7 +1037,7 @@ _U_
tok2str(gmpls_payload_values,
"Unknown",
EXTRACT_16BITS(obj_tptr+2)),
- EXTRACT_16BITS(obj_tptr+2));
+ EXTRACT_16BITS(obj_tptr + 2)));
obj_tlen-=4;
obj_tptr+=4;
break;
@@ -1060,30 +1051,30 @@ _U_
switch(rsvp_obj_ctype) {
case RSVP_CTYPE_IPV4:
while(obj_tlen >= 4 ) {
- printf("%s Subobject Type: %s, length %u",
+ ND_PRINT((ndo, "%s Subobject Type: %s, length %u",
ident,
tok2str(rsvp_obj_xro_values,
"Unknown %u",
RSVP_OBJ_XRO_MASK_SUBOBJ(*obj_tptr)),
- *(obj_tptr+1));
+ *(obj_tptr + 1)));
if (*(obj_tptr+1) == 0) { /* prevent infinite loops */
- printf("%s ERROR: zero length ERO subtype",ident);
+ ND_PRINT((ndo, "%s ERROR: zero length ERO subtype", ident));
break;
}
switch(RSVP_OBJ_XRO_MASK_SUBOBJ(*obj_tptr)) {
case RSVP_OBJ_XRO_IPV4:
- printf(", %s, %s/%u, Flags: [%s]",
+ ND_PRINT((ndo, ", %s, %s/%u, Flags: [%s]",
RSVP_OBJ_XRO_MASK_LOOSE(*obj_tptr) ? "Loose" : "Strict",
- ipaddr_string(obj_tptr+2),
+ ipaddr_string(ndo, obj_tptr+2),
*(obj_tptr+6),
bittok2str(rsvp_obj_rro_flag_values,
"none",
- *(obj_tptr+7))); /* rfc3209 says that this field is rsvd. */
+ *(obj_tptr + 7)))); /* rfc3209 says that this field is rsvd. */
break;
case RSVP_OBJ_XRO_LABEL:
- printf(", Flags: [%s] (%#x), Class-Type: %s (%u), %u",
+ ND_PRINT((ndo, ", Flags: [%s] (%#x), Class-Type: %s (%u), %u",
bittok2str(rsvp_obj_rro_label_flag_values,
"none",
*(obj_tptr+2)),
@@ -1092,7 +1083,7 @@ _U_
"Unknown",
*(obj_tptr+3) + 256*RSVP_OBJ_RRO),
*(obj_tptr+3),
- EXTRACT_32BITS(obj_tptr+4));
+ EXTRACT_32BITS(obj_tptr + 4)));
}
obj_tlen-=*(obj_tptr+1);
obj_tptr+=*(obj_tptr+1);
@@ -1109,10 +1100,10 @@ _U_
case RSVP_CTYPE_2:
if (obj_tlen < 8)
return-1;
- printf("%s Source Instance: 0x%08x, Destination Instance: 0x%08x",
+ ND_PRINT((ndo, "%s Source Instance: 0x%08x, Destination Instance: 0x%08x",
ident,
EXTRACT_32BITS(obj_tptr),
- EXTRACT_32BITS(obj_tptr+4));
+ EXTRACT_32BITS(obj_tptr + 4)));
obj_tlen-=8;
obj_tptr+=8;
break;
@@ -1126,10 +1117,10 @@ _U_
case RSVP_CTYPE_1:
if (obj_tlen < 8)
return-1;
- printf("%s Restart Time: %ums, Recovery Time: %ums",
+ ND_PRINT((ndo, "%s Restart Time: %ums, Recovery Time: %ums",
ident,
EXTRACT_32BITS(obj_tptr),
- EXTRACT_32BITS(obj_tptr+4));
+ EXTRACT_32BITS(obj_tptr + 4)));
obj_tlen-=8;
obj_tptr+=8;
break;
@@ -1146,17 +1137,17 @@ _U_
namelen = *(obj_tptr+3);
if (obj_tlen < 4+namelen)
return-1;
- printf("%s Session Name: ", ident);
+ ND_PRINT((ndo, "%s Session Name: ", ident));
for (i = 0; i < namelen; i++)
- safeputchar(*(obj_tptr+4+i));
- printf("%s Setup Priority: %u, Holding Priority: %u, Flags: [%s] (%#x)",
+ safeputchar(ndo, *(obj_tptr + 4 + i));
+ ND_PRINT((ndo, "%s Setup Priority: %u, Holding Priority: %u, Flags: [%s] (%#x)",
ident,
(int)*obj_tptr,
(int)*(obj_tptr+1),
bittok2str(rsvp_session_attribute_flag_values,
"none",
*(obj_tptr+2)),
- *(obj_tptr+2));
+ *(obj_tptr + 2)));
obj_tlen-=4+*(obj_tptr+3);
obj_tptr+=4+*(obj_tptr+3);
break;
@@ -1169,7 +1160,7 @@ _U_
switch(rsvp_obj_ctype) {
int subobj_type,af,subobj_len,total_subobj_len;
- case RSVP_CTYPE_1:
+ case RSVP_CTYPE_1:
if (obj_tlen < 4)
return-1;
@@ -1181,12 +1172,12 @@ _U_
subobj_type = (EXTRACT_16BITS(obj_tptr+2))>>8;
af = (EXTRACT_16BITS(obj_tptr+2))&0x00FF;
- printf("%s Subobject Type: %s (%u), AF: %s (%u), length: %u",
+ ND_PRINT((ndo, "%s Subobject Type: %s (%u), AF: %s (%u), length: %u",
ident,
tok2str(rsvp_obj_generalized_uni_values, "Unknown", subobj_type),
subobj_type,
tok2str(af_values, "Unknown", af), af,
- subobj_len);
+ subobj_len));
switch(subobj_type) {
case RSVP_GEN_UNI_SUBOBJ_SOURCE_TNA_ADDRESS:
@@ -1196,15 +1187,15 @@ _U_
case AFNUM_INET:
if (subobj_len < 8)
return -1;
- printf("%s UNI IPv4 TNA address: %s",
- ident, ipaddr_string(obj_tptr+4));
+ ND_PRINT((ndo, "%s UNI IPv4 TNA address: %s",
+ ident, ipaddr_string(ndo, obj_tptr + 4)));
break;
#ifdef INET6
case AFNUM_INET6:
if (subobj_len < 20)
return -1;
- printf("%s UNI IPv6 TNA address: %s",
- ident, ip6addr_string(obj_tptr+4));
+ ND_PRINT((ndo, "%s UNI IPv6 TNA address: %s",
+ ident, ip6addr_string(ndo, obj_tptr + 4)));
break;
#endif
case AFNUM_NSAP:
@@ -1228,12 +1219,12 @@ _U_
return -1;
}
- printf("%s U-bit: %x, Label type: %u, Logical port id: %u, Label: %u",
+ ND_PRINT((ndo, "%s U-bit: %x, Label type: %u, Logical port id: %u, Label: %u",
ident,
((EXTRACT_32BITS(obj_tptr+4))>>31),
((EXTRACT_32BITS(obj_tptr+4))&0xFF),
EXTRACT_32BITS(obj_tptr+8),
- EXTRACT_32BITS(obj_tptr+12));
+ EXTRACT_32BITS(obj_tptr + 12)));
break;
case RSVP_GEN_UNI_SUBOBJ_SERVICE_LEVEL:
@@ -1241,8 +1232,8 @@ _U_
return -1;
}
- printf("%s Service level: %u",
- ident, (EXTRACT_32BITS(obj_tptr+4))>>24);
+ ND_PRINT((ndo, "%s Service level: %u",
+ ident, (EXTRACT_32BITS(obj_tptr + 4)) >> 24));
break;
default:
@@ -1271,10 +1262,10 @@ _U_
case RSVP_CTYPE_IPV4:
if (obj_tlen < 8)
return-1;
- printf("%s Previous/Next Interface: %s, Logical Interface Handle: 0x%08x",
+ ND_PRINT((ndo, "%s Previous/Next Interface: %s, Logical Interface Handle: 0x%08x",
ident,
- ipaddr_string(obj_tptr),
- EXTRACT_32BITS(obj_tptr+4));
+ ipaddr_string(ndo, obj_tptr),
+ EXTRACT_32BITS(obj_tptr + 4)));
obj_tlen-=8;
obj_tptr+=8;
if (obj_tlen)
@@ -1285,10 +1276,10 @@ _U_
case RSVP_CTYPE_IPV6:
if (obj_tlen < 20)
return-1;
- printf("%s Previous/Next Interface: %s, Logical Interface Handle: 0x%08x",
+ ND_PRINT((ndo, "%s Previous/Next Interface: %s, Logical Interface Handle: 0x%08x",
ident,
- ip6addr_string(obj_tptr),
- EXTRACT_32BITS(obj_tptr+16));
+ ip6addr_string(ndo, obj_tptr),
+ EXTRACT_32BITS(obj_tptr + 16)));
obj_tlen-=20;
obj_tptr+=20;
hexdump=TRUE; /* unless we have a TLV parser lets just hexdump */
@@ -1304,9 +1295,9 @@ _U_
case RSVP_CTYPE_1:
if (obj_tlen < 4)
return-1;
- printf("%s Refresh Period: %ums",
+ ND_PRINT((ndo, "%s Refresh Period: %ums",
ident,
- EXTRACT_32BITS(obj_tptr));
+ EXTRACT_32BITS(obj_tptr)));
obj_tlen-=4;
obj_tptr+=4;
break;
@@ -1323,27 +1314,27 @@ _U_
case RSVP_CTYPE_2:
if (obj_tlen < 4)
return-1;
- printf("%s Msg-Version: %u, length: %u",
+ ND_PRINT((ndo, "%s Msg-Version: %u, length: %u",
ident,
(*obj_tptr & 0xf0) >> 4,
- EXTRACT_16BITS(obj_tptr+2)<<2);
+ EXTRACT_16BITS(obj_tptr + 2) << 2));
obj_tptr+=4; /* get to the start of the service header */
obj_tlen-=4;
while (obj_tlen >= 4) {
intserv_serv_tlen=EXTRACT_16BITS(obj_tptr+2)<<2;
- printf("%s Service Type: %s (%u), break bit %s set, Service length: %u",
+ ND_PRINT((ndo, "%s Service Type: %s (%u), break bit %s set, Service length: %u",
ident,
tok2str(rsvp_intserv_service_type_values,"unknown",*(obj_tptr)),
*(obj_tptr),
(*(obj_tptr+1)&0x80) ? "" : "not",
- intserv_serv_tlen);
-
+ intserv_serv_tlen));
+
obj_tptr+=4; /* get to the start of the parameter list */
obj_tlen-=4;
while (intserv_serv_tlen>=4) {
- processed = rsvp_intserv_print(obj_tptr, obj_tlen);
+ processed = rsvp_intserv_print(ndo, obj_tptr, obj_tlen);
if (processed == 0)
break;
obj_tlen-=processed;
@@ -1362,10 +1353,10 @@ _U_
case RSVP_CTYPE_IPV4:
if (obj_tlen < 8)
return-1;
- printf("%s Source Address: %s, Source Port: %u",
+ ND_PRINT((ndo, "%s Source Address: %s, Source Port: %u",
ident,
- ipaddr_string(obj_tptr),
- EXTRACT_16BITS(obj_tptr+6));
+ ipaddr_string(ndo, obj_tptr),
+ EXTRACT_16BITS(obj_tptr + 6)));
obj_tlen-=8;
obj_tptr+=8;
break;
@@ -1373,44 +1364,44 @@ _U_
case RSVP_CTYPE_IPV6:
if (obj_tlen < 20)
return-1;
- printf("%s Source Address: %s, Source Port: %u",
+ ND_PRINT((ndo, "%s Source Address: %s, Source Port: %u",
ident,
- ip6addr_string(obj_tptr),
- EXTRACT_16BITS(obj_tptr+18));
+ ip6addr_string(ndo, obj_tptr),
+ EXTRACT_16BITS(obj_tptr + 18)));
obj_tlen-=20;
obj_tptr+=20;
break;
case RSVP_CTYPE_3:
if (obj_tlen < 20)
return-1;
- printf("%s Source Address: %s, Flow Label: %u",
+ ND_PRINT((ndo, "%s Source Address: %s, Flow Label: %u",
ident,
- ip6addr_string(obj_tptr),
- EXTRACT_24BITS(obj_tptr+17));
+ ip6addr_string(ndo, obj_tptr),
+ EXTRACT_24BITS(obj_tptr + 17)));
obj_tlen-=20;
obj_tptr+=20;
break;
case RSVP_CTYPE_TUNNEL_IPV6:
if (obj_tlen < 20)
return-1;
- printf("%s Source Address: %s, LSP-ID: 0x%04x",
+ ND_PRINT((ndo, "%s Source Address: %s, LSP-ID: 0x%04x",
ident,
- ipaddr_string(obj_tptr),
- EXTRACT_16BITS(obj_tptr+18));
+ ipaddr_string(ndo, obj_tptr),
+ EXTRACT_16BITS(obj_tptr + 18)));
obj_tlen-=20;
obj_tptr+=20;
break;
case RSVP_CTYPE_13: /* IPv6 p2mp LSP tunnel */
if (obj_tlen < 40)
return-1;
- printf("%s IPv6 Tunnel Sender Address: %s, LSP ID: 0x%04x"
+ ND_PRINT((ndo, "%s IPv6 Tunnel Sender Address: %s, LSP ID: 0x%04x"
"%s Sub-Group Originator ID: %s, Sub-Group ID: 0x%04x",
ident,
- ip6addr_string(obj_tptr),
+ ip6addr_string(ndo, obj_tptr),
EXTRACT_16BITS(obj_tptr+18),
ident,
- ip6addr_string(obj_tptr+20),
- EXTRACT_16BITS(obj_tptr+38));
+ ip6addr_string(ndo, obj_tptr+20),
+ EXTRACT_16BITS(obj_tptr + 38)));
obj_tlen-=40;
obj_tptr+=40;
break;
@@ -1418,24 +1409,24 @@ _U_
case RSVP_CTYPE_TUNNEL_IPV4:
if (obj_tlen < 8)
return-1;
- printf("%s Source Address: %s, LSP-ID: 0x%04x",
+ ND_PRINT((ndo, "%s Source Address: %s, LSP-ID: 0x%04x",
ident,
- ipaddr_string(obj_tptr),
- EXTRACT_16BITS(obj_tptr+6));
+ ipaddr_string(ndo, obj_tptr),
+ EXTRACT_16BITS(obj_tptr + 6)));
obj_tlen-=8;
obj_tptr+=8;
break;
case RSVP_CTYPE_12: /* IPv4 p2mp LSP tunnel */
if (obj_tlen < 16)
return-1;
- printf("%s IPv4 Tunnel Sender Address: %s, LSP ID: 0x%04x"
+ ND_PRINT((ndo, "%s IPv4 Tunnel Sender Address: %s, LSP ID: 0x%04x"
"%s Sub-Group Originator ID: %s, Sub-Group ID: 0x%04x",
ident,
- ipaddr_string(obj_tptr),
+ ipaddr_string(ndo, obj_tptr),
EXTRACT_16BITS(obj_tptr+6),
ident,
- ipaddr_string(obj_tptr+8),
- EXTRACT_16BITS(obj_tptr+12));
+ ipaddr_string(ndo, obj_tptr+8),
+ EXTRACT_16BITS(obj_tptr + 12)));
obj_tlen-=16;
obj_tptr+=16;
break;
@@ -1453,17 +1444,17 @@ _U_
case RSVP_CTYPE_1: /* new style */
if (obj_tlen < sizeof(struct rsvp_obj_frr_t))
return-1;
- printf("%s Setup Priority: %u, Holding Priority: %u, Hop-limit: %u, Bandwidth: %.10g Mbps",
+ ND_PRINT((ndo, "%s Setup Priority: %u, Holding Priority: %u, Hop-limit: %u, Bandwidth: %.10g Mbps",
ident,
(int)obj_ptr.rsvp_obj_frr->setup_prio,
(int)obj_ptr.rsvp_obj_frr->hold_prio,
(int)obj_ptr.rsvp_obj_frr->hop_limit,
- bw.f*8/1000000);
- printf("%s Include-any: 0x%08x, Exclude-any: 0x%08x, Include-all: 0x%08x",
+ bw.f * 8 / 1000000));
+ ND_PRINT((ndo, "%s Include-any: 0x%08x, Exclude-any: 0x%08x, Include-all: 0x%08x",
ident,
EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->include_any),
EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->exclude_any),
- EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->include_all));
+ EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->include_all)));
obj_tlen-=sizeof(struct rsvp_obj_frr_t);
obj_tptr+=sizeof(struct rsvp_obj_frr_t);
break;
@@ -1471,16 +1462,16 @@ _U_
case RSVP_CTYPE_TUNNEL_IPV4: /* old style */
if (obj_tlen < 16)
return-1;
- printf("%s Setup Priority: %u, Holding Priority: %u, Hop-limit: %u, Bandwidth: %.10g Mbps",
+ ND_PRINT((ndo, "%s Setup Priority: %u, Holding Priority: %u, Hop-limit: %u, Bandwidth: %.10g Mbps",
ident,
(int)obj_ptr.rsvp_obj_frr->setup_prio,
(int)obj_ptr.rsvp_obj_frr->hold_prio,
(int)obj_ptr.rsvp_obj_frr->hop_limit,
- bw.f*8/1000000);
- printf("%s Include Colors: 0x%08x, Exclude Colors: 0x%08x",
+ bw.f * 8 / 1000000));
+ ND_PRINT((ndo, "%s Include Colors: 0x%08x, Exclude Colors: 0x%08x",
ident,
EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->include_any),
- EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->exclude_any));
+ EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->exclude_any)));
obj_tlen-=16;
obj_tptr+=16;
break;
@@ -1494,10 +1485,10 @@ _U_
switch(rsvp_obj_ctype) {
case RSVP_CTYPE_TUNNEL_IPV4:
while(obj_tlen >= 8) {
- printf("%s PLR-ID: %s, Avoid-Node-ID: %s",
+ ND_PRINT((ndo, "%s PLR-ID: %s, Avoid-Node-ID: %s",
ident,
- ipaddr_string(obj_tptr),
- ipaddr_string(obj_tptr+4));
+ ipaddr_string(ndo, obj_tptr),
+ ipaddr_string(ndo, obj_tptr + 4)));
obj_tlen-=8;
obj_tptr+=8;
}
@@ -1511,9 +1502,9 @@ _U_
case RSVP_OBJ_CLASSTYPE_OLD: /* fall through */
switch(rsvp_obj_ctype) {
case RSVP_CTYPE_1:
- printf("%s CT: %u",
+ ND_PRINT((ndo, "%s CT: %u",
ident,
- EXTRACT_32BITS(obj_tptr)&0x7);
+ EXTRACT_32BITS(obj_tptr) & 0x7));
obj_tlen-=4;
obj_tptr+=4;
break;
@@ -1530,27 +1521,27 @@ _U_
return-1;
error_code=*(obj_tptr+5);
error_value=EXTRACT_16BITS(obj_tptr+6);
- printf("%s Error Node Address: %s, Flags: [0x%02x]%s Error Code: %s (%u)",
+ ND_PRINT((ndo, "%s Error Node Address: %s, Flags: [0x%02x]%s Error Code: %s (%u)",
ident,
- ipaddr_string(obj_tptr),
+ ipaddr_string(ndo, obj_tptr),
*(obj_tptr+4),
ident,
tok2str(rsvp_obj_error_code_values,"unknown",error_code),
- error_code);
+ error_code));
switch (error_code) {
case RSVP_OBJ_ERROR_SPEC_CODE_ROUTING:
- printf(", Error Value: %s (%u)",
+ ND_PRINT((ndo, ", Error Value: %s (%u)",
tok2str(rsvp_obj_error_code_routing_values,"unknown",error_value),
- error_value);
+ error_value));
break;
case RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE: /* fall through */
case RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE_OLD:
- printf(", Error Value: %s (%u)",
+ ND_PRINT((ndo, ", Error Value: %s (%u)",
tok2str(rsvp_obj_error_code_diffserv_te_values,"unknown",error_value),
- error_value);
+ error_value));
break;
default:
- printf(", Unknown Error Value (%u)", error_value);
+ ND_PRINT((ndo, ", Unknown Error Value (%u)", error_value));
break;
}
obj_tlen-=8;
@@ -1563,19 +1554,19 @@ _U_
return-1;
error_code=*(obj_tptr+17);
error_value=EXTRACT_16BITS(obj_tptr+18);
- printf("%s Error Node Address: %s, Flags: [0x%02x]%s Error Code: %s (%u)",
+ ND_PRINT((ndo, "%s Error Node Address: %s, Flags: [0x%02x]%s Error Code: %s (%u)",
ident,
- ip6addr_string(obj_tptr),
+ ip6addr_string(ndo, obj_tptr),
*(obj_tptr+16),
ident,
tok2str(rsvp_obj_error_code_values,"unknown",error_code),
- error_code);
+ error_code));
switch (error_code) {
case RSVP_OBJ_ERROR_SPEC_CODE_ROUTING:
- printf(", Error Value: %s (%u)",
+ ND_PRINT((ndo, ", Error Value: %s (%u)",
tok2str(rsvp_obj_error_code_routing_values,"unknown",error_value),
- error_value);
+ error_value));
break;
default:
break;
@@ -1595,24 +1586,24 @@ _U_
if (obj_tlen < 4)
return-1;
padbytes = EXTRACT_16BITS(obj_tptr+2);
- printf("%s TLV count: %u, padding bytes: %u",
+ ND_PRINT((ndo, "%s TLV count: %u, padding bytes: %u",
ident,
EXTRACT_16BITS(obj_tptr),
- padbytes);
+ padbytes));
obj_tlen-=4;
obj_tptr+=4;
/* loop through as long there is anything longer than the TLV header (2) */
while(obj_tlen >= 2 + padbytes) {
- printf("%s %s TLV (0x%02x), length: %u", /* length includes header */
+ ND_PRINT((ndo, "%s %s TLV (0x%02x), length: %u", /* length includes header */
ident,
tok2str(rsvp_obj_prop_tlv_values,"unknown",*obj_tptr),
*obj_tptr,
- *(obj_tptr+1));
+ *(obj_tptr + 1)));
if (obj_tlen < *(obj_tptr+1))
return-1;
if (*(obj_tptr+1) < 2)
return -1;
- print_unknown_data(obj_tptr+2,"\n\t\t",*(obj_tptr+1)-2);
+ print_unknown_data(ndo, obj_tptr + 2, "\n\t\t", *(obj_tptr + 1) - 2);
obj_tlen-=*(obj_tptr+1);
obj_tptr+=*(obj_tptr+1);
}
@@ -1630,18 +1621,18 @@ _U_
case RSVP_CTYPE_2:
if (obj_tlen < 8)
return-1;
- printf("%s Flags [0x%02x], epoch: %u",
+ ND_PRINT((ndo, "%s Flags [0x%02x], epoch: %u",
ident,
*obj_tptr,
- EXTRACT_24BITS(obj_tptr+1));
+ EXTRACT_24BITS(obj_tptr + 1)));
obj_tlen-=4;
obj_tptr+=4;
/* loop through as long there are no messages left */
while(obj_tlen >= 4) {
- printf("%s Message-ID 0x%08x (%u)",
+ ND_PRINT((ndo, "%s Message-ID 0x%08x (%u)",
ident,
EXTRACT_32BITS(obj_tptr),
- EXTRACT_32BITS(obj_tptr));
+ EXTRACT_32BITS(obj_tptr)));
obj_tlen-=4;
obj_tptr+=4;
}
@@ -1657,7 +1648,7 @@ _U_
if (obj_tlen < sizeof(struct rsvp_obj_integrity_t))
return-1;
obj_ptr.rsvp_obj_integrity = (const struct rsvp_obj_integrity_t *)obj_tptr;
- printf("%s Key-ID 0x%04x%08x, Sequence 0x%08x%08x, Flags [%s]",
+ ND_PRINT((ndo, "%s Key-ID 0x%04x%08x, Sequence 0x%08x%08x, Flags [%s]",
ident,
EXTRACT_16BITS(obj_ptr.rsvp_obj_integrity->key_id),
EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->key_id+2),
@@ -1665,21 +1656,21 @@ _U_
EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->sequence+4),
bittok2str(rsvp_obj_integrity_flag_values,
"none",
- obj_ptr.rsvp_obj_integrity->flags));
- printf("%s MD5-sum 0x%08x%08x%08x%08x ",
+ obj_ptr.rsvp_obj_integrity->flags)));
+ ND_PRINT((ndo, "%s MD5-sum 0x%08x%08x%08x%08x ",
ident,
EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest),
EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest+4),
EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest+8),
- EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest+12));
+ EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest + 12)));
#ifdef HAVE_LIBCRYPTO
- sigcheck = signature_verify(pptr, plen, (unsigned char *)obj_ptr.\
+ sigcheck = signature_verify(ndo, pptr, plen, (unsigned char *)obj_ptr.\
rsvp_obj_integrity->digest);
#else
sigcheck = CANT_CHECK_SIGNATURE;
#endif
- printf(" (%s)", tok2str(signature_check_values, "Unknown", sigcheck));
+ ND_PRINT((ndo, " (%s)", tok2str(signature_check_values, "Unknown", sigcheck)));
obj_tlen+=sizeof(struct rsvp_obj_integrity_t);
obj_tptr+=sizeof(struct rsvp_obj_integrity_t);
@@ -1687,16 +1678,16 @@ _U_
default:
hexdump=TRUE;
}
- break;
+ break;
case RSVP_OBJ_ADMIN_STATUS:
switch(rsvp_obj_ctype) {
- case RSVP_CTYPE_1:
+ case RSVP_CTYPE_1:
if (obj_tlen < 4)
return-1;
- printf("%s Flags [%s]", ident,
+ ND_PRINT((ndo, "%s Flags [%s]", ident,
bittok2str(rsvp_obj_admin_status_flag_values, "none",
- EXTRACT_32BITS(obj_tptr)));
+ EXTRACT_32BITS(obj_tptr))));
obj_tlen-=4;
obj_tptr+=4;
break;
@@ -1707,14 +1698,14 @@ _U_
case RSVP_OBJ_LABEL_SET:
switch(rsvp_obj_ctype) {
- case RSVP_CTYPE_1:
+ case RSVP_CTYPE_1:
if (obj_tlen < 4)
return-1;
action = (EXTRACT_16BITS(obj_tptr)>>8);
- printf("%s Action: %s (%u), Label type: %u", ident,
+ ND_PRINT((ndo, "%s Action: %s (%u), Label type: %u", ident,
tok2str(rsvp_obj_label_set_action_values, "Unknown", action),
- action, ((EXTRACT_32BITS(obj_tptr) & 0x7F)));
+ action, ((EXTRACT_32BITS(obj_tptr) & 0x7F))));
switch (action) {
case LABEL_SET_INCLUSIVE_RANGE:
@@ -1723,9 +1714,9 @@ _U_
/* only a couple of subchannels are expected */
if (obj_tlen < 12)
return -1;
- printf("%s Start range: %u, End range: %u", ident,
+ ND_PRINT((ndo, "%s Start range: %u, End range: %u", ident,
EXTRACT_32BITS(obj_tptr+4),
- EXTRACT_32BITS(obj_tptr+8));
+ EXTRACT_32BITS(obj_tptr + 8)));
obj_tlen-=12;
obj_tptr+=12;
break;
@@ -1735,8 +1726,8 @@ _U_
obj_tptr+=4;
subchannel = 1;
while(obj_tlen >= 4 ) {
- printf("%s Subchannel #%u: %u", ident, subchannel,
- EXTRACT_32BITS(obj_tptr));
+ ND_PRINT((ndo, "%s Subchannel #%u: %u", ident, subchannel,
+ EXTRACT_32BITS(obj_tptr)));
obj_tptr+=4;
obj_tlen-=4;
subchannel++;
@@ -1750,21 +1741,21 @@ _U_
case RSVP_OBJ_S2L:
switch (rsvp_obj_ctype) {
- case RSVP_CTYPE_IPV4:
+ case RSVP_CTYPE_IPV4:
if (obj_tlen < 4)
return-1;
- printf("%s Sub-LSP destination address: %s",
- ident, ipaddr_string(obj_tptr));
+ ND_PRINT((ndo, "%s Sub-LSP destination address: %s",
+ ident, ipaddr_string(ndo, obj_tptr)));
obj_tlen-=4;
obj_tptr+=4;
break;
#ifdef INET6
- case RSVP_CTYPE_IPV6:
+ case RSVP_CTYPE_IPV6:
if (obj_tlen < 16)
return-1;
- printf("%s Sub-LSP destination address: %s",
- ident, ip6addr_string(obj_tptr));
+ ND_PRINT((ndo, "%s Sub-LSP destination address: %s",
+ ident, ip6addr_string(ndo, obj_tptr)));
obj_tlen-=16;
obj_tptr+=16;
@@ -1784,27 +1775,27 @@ _U_
case RSVP_OBJ_ACCEPT_LABEL_SET:
case RSVP_OBJ_PROTECTION:
default:
- if (vflag <= 1)
- print_unknown_data(obj_tptr,"\n\t ",obj_tlen); /* FIXME indentation */
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo, obj_tptr, "\n\t ", obj_tlen); /* FIXME indentation */
break;
}
/* do we also want to see a hex dump ? */
- if (vflag > 1 || hexdump==TRUE)
- print_unknown_data(tptr+sizeof(struct rsvp_object_header),"\n\t ", /* FIXME indentation */
- rsvp_obj_len-sizeof(struct rsvp_object_header));
+ if (ndo->ndo_vflag > 1 || hexdump == TRUE)
+ print_unknown_data(ndo, tptr + sizeof(struct rsvp_object_header), "\n\t ", /* FIXME indentation */
+ rsvp_obj_len - sizeof(struct rsvp_object_header));
tptr+=rsvp_obj_len;
tlen-=rsvp_obj_len;
}
return 0;
trunc:
- printf("\n\t\t packet exceeded snapshot");
+ ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
return -1;
}
-
void
-rsvp_print(register const u_char *pptr, register u_int len) {
+rsvp_print(netdissect_options *ndo,
+ register const u_char *pptr, register u_int len) {
struct rsvp_common_header *rsvp_com_header;
const u_char *tptr,*subtptr;
@@ -1813,23 +1804,23 @@ rsvp_print(register const u_char *pptr, register u_int len) {
tptr=pptr;
rsvp_com_header = (struct rsvp_common_header *)pptr;
- TCHECK(*rsvp_com_header);
+ ND_TCHECK(*rsvp_com_header);
/*
* Sanity checking of the header.
*/
if (RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags) != RSVP_VERSION) {
- printf("ERROR: RSVP version %u packet not supported",
- RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags));
+ ND_PRINT((ndo, "ERROR: RSVP version %u packet not supported",
+ RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags)));
return;
}
/* in non-verbose mode just lets print the basic Message Type*/
- if (vflag < 1) {
- printf("RSVPv%u %s Message, length: %u",
+ if (ndo->ndo_vflag < 1) {
+ ND_PRINT((ndo, "RSVPv%u %s Message, length: %u",
RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags),
tok2str(rsvp_msg_type_values, "unknown (%u)",rsvp_com_header->msg_type),
- len);
+ len));
return;
}
@@ -1837,14 +1828,14 @@ rsvp_print(register const u_char *pptr, register u_int len) {
plen = tlen = EXTRACT_16BITS(rsvp_com_header->length);
- printf("\n\tRSVPv%u %s Message (%u), Flags: [%s], length: %u, ttl: %u, checksum: 0x%04x",
+ ND_PRINT((ndo, "\n\tRSVPv%u %s Message (%u), Flags: [%s], length: %u, ttl: %u, checksum: 0x%04x",
RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags),
tok2str(rsvp_msg_type_values, "unknown, type: %u",rsvp_com_header->msg_type),
rsvp_com_header->msg_type,
bittok2str(rsvp_header_flag_values,"none",RSVP_EXTRACT_FLAGS(rsvp_com_header->version_flags)),
tlen,
rsvp_com_header->ttl,
- EXTRACT_16BITS(rsvp_com_header->checksum));
+ EXTRACT_16BITS(rsvp_com_header->checksum)));
/*
* Clear checksum prior to signature verification.
@@ -1853,8 +1844,8 @@ rsvp_print(register const u_char *pptr, register u_int len) {
rsvp_com_header->checksum[1] = 0;
if (tlen < sizeof(const struct rsvp_common_header)) {
- printf("ERROR: common header too short %u < %lu", tlen,
- (unsigned long)sizeof(const struct rsvp_common_header));
+ ND_PRINT((ndo, "ERROR: common header too short %u < %lu", tlen,
+ (unsigned long)sizeof(const struct rsvp_common_header)));
return;
}
@@ -1867,49 +1858,49 @@ rsvp_print(register const u_char *pptr, register u_int len) {
while(tlen > 0) {
subtptr=tptr;
rsvp_com_header = (struct rsvp_common_header *)subtptr;
- TCHECK(*rsvp_com_header);
+ ND_TCHECK(*rsvp_com_header);
/*
* Sanity checking of the header.
*/
if (RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags) != RSVP_VERSION) {
- printf("ERROR: RSVP version %u packet not supported",
- RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags));
+ ND_PRINT((ndo, "ERROR: RSVP version %u packet not supported",
+ RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags)));
return;
}
subtlen=EXTRACT_16BITS(rsvp_com_header->length);
-
- printf("\n\t RSVPv%u %s Message (%u), Flags: [%s], length: %u, ttl: %u, checksum: 0x%04x",
+
+ ND_PRINT((ndo, "\n\t RSVPv%u %s Message (%u), Flags: [%s], length: %u, ttl: %u, checksum: 0x%04x",
RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags),
tok2str(rsvp_msg_type_values, "unknown, type: %u",rsvp_com_header->msg_type),
rsvp_com_header->msg_type,
bittok2str(rsvp_header_flag_values,"none",RSVP_EXTRACT_FLAGS(rsvp_com_header->version_flags)),
subtlen,
rsvp_com_header->ttl,
- EXTRACT_16BITS(rsvp_com_header->checksum));
+ EXTRACT_16BITS(rsvp_com_header->checksum)));
/*
* Clear checksum prior to signature verification.
*/
rsvp_com_header->checksum[0] = 0;
rsvp_com_header->checksum[1] = 0;
-
+
if (subtlen < sizeof(const struct rsvp_common_header)) {
- printf("ERROR: common header too short %u < %lu", subtlen,
- (unsigned long)sizeof(const struct rsvp_common_header));
+ ND_PRINT((ndo, "ERROR: common header too short %u < %lu", subtlen,
+ (unsigned long)sizeof(const struct rsvp_common_header)));
return;
}
if (tlen < subtlen) {
- printf("ERROR: common header too large %u > %u", subtlen,
- tlen);
+ ND_PRINT((ndo, "ERROR: common header too large %u > %u", subtlen,
+ tlen));
return;
}
subtptr+=sizeof(const struct rsvp_common_header);
subtlen-=sizeof(const struct rsvp_common_header);
- if (rsvp_obj_print(pptr, plen, subtptr,"\n\t ", subtlen) == -1)
+ if (rsvp_obj_print(ndo, pptr, plen, subtptr, "\n\t ", subtlen) == -1)
return;
tptr+=subtlen+sizeof(const struct rsvp_common_header);
@@ -1929,16 +1920,16 @@ rsvp_print(register const u_char *pptr, register u_int len) {
case RSVP_MSGTYPE_HELLO:
case RSVP_MSGTYPE_ACK:
case RSVP_MSGTYPE_SREFRESH:
- if (rsvp_obj_print(pptr, plen, tptr,"\n\t ", tlen) == -1)
+ if (rsvp_obj_print(ndo, pptr, plen, tptr, "\n\t ", tlen) == -1)
return;
break;
- default:
- print_unknown_data(tptr,"\n\t ",tlen);
+ default:
+ print_unknown_data(ndo, tptr, "\n\t ", tlen);
break;
}
return;
trunc:
- printf("\n\t\t packet exceeded snapshot");
+ ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
}
diff --git a/contrib/tcpdump/print-rt6.c b/contrib/tcpdump/print-rt6.c
index dc196b4e766a..3d5f9e3721a1 100644
--- a/contrib/tcpdump/print-rt6.c
+++ b/contrib/tcpdump/print-rt6.c
@@ -19,11 +19,7 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-rt6.c,v 1.27 2005-04-20 22:34:57 guy Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -32,7 +28,7 @@ static const char rcsid[] _U_ =
#include <tcpdump-stdinc.h>
-#include <stdio.h>
+#include <string.h>
#include "ip6.h"
@@ -41,25 +37,26 @@ static const char rcsid[] _U_ =
#include "extract.h"
int
-rt6_print(register const u_char *bp, const u_char *bp2 _U_)
+rt6_print(netdissect_options *ndo, register const u_char *bp, const u_char *bp2 _U_)
{
register const struct ip6_rthdr *dp;
register const struct ip6_rthdr0 *dp0;
register const u_char *ep;
int i, len;
register const struct in6_addr *addr;
+ const struct in6_addr *last_addr = NULL;
dp = (struct ip6_rthdr *)bp;
len = dp->ip6r_len;
/* 'ep' points to the end of available data. */
- ep = snapend;
+ ep = ndo->ndo_snapend;
- TCHECK(dp->ip6r_segleft);
+ ND_TCHECK(dp->ip6r_segleft);
- printf("srcrt (len=%d", dp->ip6r_len); /*)*/
- printf(", type=%d", dp->ip6r_type);
- printf(", segleft=%d", dp->ip6r_segleft);
+ ND_PRINT((ndo, "srcrt (len=%d", dp->ip6r_len)); /*)*/
+ ND_PRINT((ndo, ", type=%d", dp->ip6r_type));
+ ND_PRINT((ndo, ", segleft=%d", dp->ip6r_segleft));
switch (dp->ip6r_type) {
#ifndef IPV6_RTHDR_TYPE_0
@@ -72,10 +69,10 @@ rt6_print(register const u_char *bp, const u_char *bp2 _U_)
case IPV6_RTHDR_TYPE_2: /* Mobile IPv6 ID-20 */
dp0 = (struct ip6_rthdr0 *)dp;
- TCHECK(dp0->ip6r0_reserved);
- if (dp0->ip6r0_reserved || vflag) {
- printf(", rsv=0x%0x",
- EXTRACT_32BITS(&dp0->ip6r0_reserved));
+ ND_TCHECK(dp0->ip6r0_reserved);
+ if (dp0->ip6r0_reserved || ndo->ndo_vflag) {
+ ND_PRINT((ndo, ", rsv=0x%0x",
+ EXTRACT_32BITS(&dp0->ip6r0_reserved)));
}
if (len % 2 == 1)
@@ -86,11 +83,20 @@ rt6_print(register const u_char *bp, const u_char *bp2 _U_)
if ((u_char *)(addr + 1) > ep)
goto trunc;
- printf(", [%d]%s", i, ip6addr_string(addr));
+ ND_PRINT((ndo, ", [%d]%s", i, ip6addr_string(ndo, addr)));
+ last_addr = addr;
addr++;
}
+ /*
+ * the destination address used in the pseudo-header is that of the final
+ * destination : the last address of the routing header
+ */
+ if (last_addr != NULL) {
+ struct ip6_hdr *ip6 = (struct ip6_hdr *)bp2;
+ UNALIGNED_MEMCPY(&ip6->ip6_dst, last_addr, sizeof (struct in6_addr));
+ }
/*(*/
- printf(") ");
+ ND_PRINT((ndo, ") "));
return((dp0->ip6r0_len + 1) << 3);
break;
default:
@@ -99,7 +105,7 @@ rt6_print(register const u_char *bp, const u_char *bp2 _U_)
}
trunc:
- fputs("[|srcrt]", stdout);
+ ND_PRINT((ndo, "[|srcrt]"));
return -1;
}
#endif /* INET6 */
diff --git a/contrib/tcpdump/print-rx.c b/contrib/tcpdump/print-rx.c
index 70393ea5cbbe..8a9babbc1f0f 100644
--- a/contrib/tcpdump/print-rx.c
+++ b/contrib/tcpdump/print-rx.c
@@ -32,11 +32,7 @@
* Ken Hornstein <kenh@cmf.nrl.navy.mil>
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-rx.c,v 1.42 2008-07-01 07:44:50 guy Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -50,11 +46,89 @@ static const char rcsid[] _U_ =
#include "addrtoname.h"
#include "extract.h"
-#include "rx.h"
-
#include "ip.h"
-static struct tok rx_types[] = {
+#define FS_RX_PORT 7000
+#define CB_RX_PORT 7001
+#define PROT_RX_PORT 7002
+#define VLDB_RX_PORT 7003
+#define KAUTH_RX_PORT 7004
+#define VOL_RX_PORT 7005
+#define ERROR_RX_PORT 7006 /* Doesn't seem to be used */
+#define BOS_RX_PORT 7007
+
+#define AFSNAMEMAX 256
+#define AFSOPAQUEMAX 1024
+#define PRNAMEMAX 64
+#define VLNAMEMAX 65
+#define KANAMEMAX 64
+#define BOSNAMEMAX 256
+
+#define PRSFS_READ 1 /* Read files */
+#define PRSFS_WRITE 2 /* Write files */
+#define PRSFS_INSERT 4 /* Insert files into a directory */
+#define PRSFS_LOOKUP 8 /* Lookup files into a directory */
+#define PRSFS_DELETE 16 /* Delete files */
+#define PRSFS_LOCK 32 /* Lock files */
+#define PRSFS_ADMINISTER 64 /* Change ACL's */
+
+struct rx_header {
+ uint32_t epoch;
+ uint32_t cid;
+ uint32_t callNumber;
+ uint32_t seq;
+ uint32_t serial;
+ uint8_t type;
+#define RX_PACKET_TYPE_DATA 1
+#define RX_PACKET_TYPE_ACK 2
+#define RX_PACKET_TYPE_BUSY 3
+#define RX_PACKET_TYPE_ABORT 4
+#define RX_PACKET_TYPE_ACKALL 5
+#define RX_PACKET_TYPE_CHALLENGE 6
+#define RX_PACKET_TYPE_RESPONSE 7
+#define RX_PACKET_TYPE_DEBUG 8
+#define RX_PACKET_TYPE_PARAMS 9
+#define RX_PACKET_TYPE_VERSION 13
+ uint8_t flags;
+#define RX_CLIENT_INITIATED 1
+#define RX_REQUEST_ACK 2
+#define RX_LAST_PACKET 4
+#define RX_MORE_PACKETS 8
+#define RX_FREE_PACKET 16
+#define RX_SLOW_START_OK 32
+#define RX_JUMBO_PACKET 32
+ uint8_t userStatus;
+ uint8_t securityIndex;
+ uint16_t spare; /* How clever: even though the AFS */
+ uint16_t serviceId; /* header files indicate that the */
+}; /* serviceId is first, it's really */
+ /* encoded _after_ the spare field */
+ /* I wasted a day figuring that out! */
+
+#define NUM_RX_FLAGS 7
+
+#define RX_MAXACKS 255
+
+struct rx_ackPacket {
+ uint16_t bufferSpace; /* Number of packet buffers available */
+ uint16_t maxSkew; /* Max diff between ack'd packet and */
+ /* highest packet received */
+ uint32_t firstPacket; /* The first packet in ack list */
+ uint32_t previousPacket; /* Previous packet recv'd (obsolete) */
+ uint32_t serial; /* # of packet that prompted the ack */
+ uint8_t reason; /* Reason for acknowledgement */
+ uint8_t nAcks; /* Number of acknowledgements */
+ uint8_t acks[RX_MAXACKS]; /* Up to RX_MAXACKS acknowledgements */
+};
+
+/*
+ * Values for the acks array
+ */
+
+#define RX_ACK_TYPE_NACK 0 /* Don't have this packet */
+#define RX_ACK_TYPE_ACK 1 /* I have this packet */
+
+static const struct tok rx_types[] = {
{ RX_PACKET_TYPE_DATA, "data" },
{ RX_PACKET_TYPE_ACK, "ack" },
{ RX_PACKET_TYPE_BUSY, "busy" },
@@ -68,7 +142,7 @@ static struct tok rx_types[] = {
{ 0, NULL },
};
-static struct double_tok {
+static const struct double_tok {
int flag; /* Rx flag */
int packetType; /* Packet type */
const char *s; /* Flag string */
@@ -82,7 +156,7 @@ static struct double_tok {
{ RX_JUMBO_PACKET, RX_PACKET_TYPE_DATA, "jumbogram" }
};
-static struct tok fs_req[] = {
+static const struct tok fs_req[] = {
{ 130, "fetch-data" },
{ 131, "fetch-acl" },
{ 132, "fetch-status" },
@@ -127,7 +201,7 @@ static struct tok fs_req[] = {
{ 0, NULL },
};
-static struct tok cb_req[] = {
+static const struct tok cb_req[] = {
{ 204, "callback" },
{ 205, "initcb" },
{ 206, "probe" },
@@ -149,7 +223,7 @@ static struct tok cb_req[] = {
{ 0, NULL },
};
-static struct tok pt_req[] = {
+static const struct tok pt_req[] = {
{ 500, "new-user" },
{ 501, "where-is-it" },
{ 502, "dump-entry" },
@@ -176,7 +250,7 @@ static struct tok pt_req[] = {
{ 0, NULL },
};
-static struct tok vldb_req[] = {
+static const struct tok vldb_req[] = {
{ 501, "create-entry" },
{ 502, "delete-entry" },
{ 503, "get-entry-by-id" },
@@ -214,7 +288,7 @@ static struct tok vldb_req[] = {
{ 0, NULL },
};
-static struct tok kauth_req[] = {
+static const struct tok kauth_req[] = {
{ 1, "auth-old" },
{ 21, "authenticate" },
{ 22, "authenticate-v2" },
@@ -236,7 +310,7 @@ static struct tok kauth_req[] = {
{ 0, NULL },
};
-static struct tok vol_req[] = {
+static const struct tok vol_req[] = {
{ 100, "create-volume" },
{ 101, "delete-volume" },
{ 102, "restore" },
@@ -272,7 +346,7 @@ static struct tok vol_req[] = {
{ 0, NULL },
};
-static struct tok bos_req[] = {
+static const struct tok bos_req[] = {
{ 80, "create-bnode" },
{ 81, "delete-bnode" },
{ 82, "set-status" },
@@ -313,7 +387,7 @@ static struct tok bos_req[] = {
{ 0, NULL },
};
-static struct tok ubik_req[] = {
+static const struct tok ubik_req[] = {
{ 10000, "vote-beacon" },
{ 10001, "vote-debug-old" },
{ 10002, "vote-sdebug-old" },
@@ -344,14 +418,14 @@ static struct tok ubik_req[] = {
#define DISK_LOW 20000
#define DISK_HIGH 20013
-static struct tok cb_types[] = {
+static const struct tok cb_types[] = {
{ 1, "exclusive" },
{ 2, "shared" },
{ 3, "dropped" },
{ 0, NULL },
};
-static struct tok ubik_lock_types[] = {
+static const struct tok ubik_lock_types[] = {
{ 1, "read" },
{ 2, "write" },
{ 3, "wait" },
@@ -360,7 +434,7 @@ static struct tok ubik_lock_types[] = {
static const char *voltype[] = { "read-write", "read-only", "backup" };
-static struct tok afs_fs_errors[] = {
+static const struct tok afs_fs_errors[] = {
{ 101, "salvage volume" },
{ 102, "no such vnode" },
{ 103, "no such volume" },
@@ -373,7 +447,7 @@ static struct tok afs_fs_errors[] = {
{ 110, "volume busy" },
{ 111, "volume moved" },
{ 112, "AFS IO error" },
- { -100, "restarting fileserver" },
+ { 0xffffff9c, "restarting fileserver" }, /* -100, sic! */
{ 0, NULL }
};
@@ -381,7 +455,7 @@ static struct tok afs_fs_errors[] = {
* Reasons for acknowledging a packet
*/
-static struct tok rx_ack_reasons[] = {
+static const struct tok rx_ack_reasons[] = {
{ 1, "ack requested" },
{ 2, "duplicate packet" },
{ 3, "out of sequence" },
@@ -400,12 +474,12 @@ static struct tok rx_ack_reasons[] = {
*/
struct rx_cache_entry {
- u_int32_t callnum; /* Call number (net order) */
+ uint32_t callnum; /* Call number (net order) */
struct in_addr client; /* client IP address (net order) */
struct in_addr server; /* server IP address (net order) */
int dport; /* server port (host order) */
u_short serviceId; /* Service identifier (net order) */
- u_int32_t opcode; /* RX opcode (host order) */
+ uint32_t opcode; /* RX opcode (host order) */
};
#define RX_CACHE_SIZE 64
@@ -414,31 +488,31 @@ static struct rx_cache_entry rx_cache[RX_CACHE_SIZE];
static int rx_cache_next = 0;
static int rx_cache_hint = 0;
-static void rx_cache_insert(const u_char *, const struct ip *, int);
+static void rx_cache_insert(netdissect_options *, const u_char *, const struct ip *, int);
static int rx_cache_find(const struct rx_header *, const struct ip *,
int, int32_t *);
-static void fs_print(const u_char *, int);
-static void fs_reply_print(const u_char *, int, int32_t);
-static void acl_print(u_char *, int, u_char *);
-static void cb_print(const u_char *, int);
-static void cb_reply_print(const u_char *, int, int32_t);
-static void prot_print(const u_char *, int);
-static void prot_reply_print(const u_char *, int, int32_t);
-static void vldb_print(const u_char *, int);
-static void vldb_reply_print(const u_char *, int, int32_t);
-static void kauth_print(const u_char *, int);
-static void kauth_reply_print(const u_char *, int, int32_t);
-static void vol_print(const u_char *, int);
-static void vol_reply_print(const u_char *, int, int32_t);
-static void bos_print(const u_char *, int);
-static void bos_reply_print(const u_char *, int, int32_t);
-static void ubik_print(const u_char *);
-static void ubik_reply_print(const u_char *, int, int32_t);
-
-static void rx_ack_print(const u_char *, int);
-
-static int is_ubik(u_int32_t);
+static void fs_print(netdissect_options *, const u_char *, int);
+static void fs_reply_print(netdissect_options *, const u_char *, int, int32_t);
+static void acl_print(netdissect_options *, u_char *, int, u_char *);
+static void cb_print(netdissect_options *, const u_char *, int);
+static void cb_reply_print(netdissect_options *, const u_char *, int, int32_t);
+static void prot_print(netdissect_options *, const u_char *, int);
+static void prot_reply_print(netdissect_options *, const u_char *, int, int32_t);
+static void vldb_print(netdissect_options *, const u_char *, int);
+static void vldb_reply_print(netdissect_options *, const u_char *, int, int32_t);
+static void kauth_print(netdissect_options *, const u_char *, int);
+static void kauth_reply_print(netdissect_options *, const u_char *, int, int32_t);
+static void vol_print(netdissect_options *, const u_char *, int);
+static void vol_reply_print(netdissect_options *, const u_char *, int, int32_t);
+static void bos_print(netdissect_options *, const u_char *, int);
+static void bos_reply_print(netdissect_options *, const u_char *, int, int32_t);
+static void ubik_print(netdissect_options *, const u_char *);
+static void ubik_reply_print(netdissect_options *, const u_char *, int, int32_t);
+
+static void rx_ack_print(netdissect_options *, const u_char *, int);
+
+static int is_ubik(uint32_t);
/*
* Handle the rx-level packet. See if we know what port it's going to so
@@ -446,51 +520,52 @@ static int is_ubik(u_int32_t);
*/
void
-rx_print(register const u_char *bp, int length, int sport, int dport,
- u_char *bp2)
+rx_print(netdissect_options *ndo,
+ register const u_char *bp, int length, int sport, int dport,
+ u_char *bp2)
{
register struct rx_header *rxh;
int i;
int32_t opcode;
- if (snapend - bp < (int)sizeof (struct rx_header)) {
- printf(" [|rx] (%d)", length);
+ if (ndo->ndo_snapend - bp < (int)sizeof (struct rx_header)) {
+ ND_PRINT((ndo, " [|rx] (%d)", length));
return;
}
rxh = (struct rx_header *) bp;
- printf(" rx %s", tok2str(rx_types, "type %d", rxh->type));
+ ND_PRINT((ndo, " rx %s", tok2str(rx_types, "type %d", rxh->type)));
- if (vflag) {
+ if (ndo->ndo_vflag) {
int firstflag = 0;
- if (vflag > 1)
- printf(" cid %08x call# %d",
+ if (ndo->ndo_vflag > 1)
+ ND_PRINT((ndo, " cid %08x call# %d",
(int) EXTRACT_32BITS(&rxh->cid),
- (int) EXTRACT_32BITS(&rxh->callNumber));
+ (int) EXTRACT_32BITS(&rxh->callNumber)));
- printf(" seq %d ser %d",
+ ND_PRINT((ndo, " seq %d ser %d",
(int) EXTRACT_32BITS(&rxh->seq),
- (int) EXTRACT_32BITS(&rxh->serial));
+ (int) EXTRACT_32BITS(&rxh->serial)));
- if (vflag > 2)
- printf(" secindex %d serviceid %hu",
+ if (ndo->ndo_vflag > 2)
+ ND_PRINT((ndo, " secindex %d serviceid %hu",
(int) rxh->securityIndex,
- EXTRACT_16BITS(&rxh->serviceId));
+ EXTRACT_16BITS(&rxh->serviceId)));
- if (vflag > 1)
+ if (ndo->ndo_vflag > 1)
for (i = 0; i < NUM_RX_FLAGS; i++) {
if (rxh->flags & rx_flags[i].flag &&
(!rx_flags[i].packetType ||
rxh->type == rx_flags[i].packetType)) {
if (!firstflag) {
firstflag = 1;
- printf(" ");
+ ND_PRINT((ndo, " "));
} else {
- printf(",");
+ ND_PRINT((ndo, ","));
}
- printf("<%s>", rx_flags[i].s);
+ ND_PRINT((ndo, "<%s>", rx_flags[i].s));
}
}
}
@@ -513,29 +588,29 @@ rx_print(register const u_char *bp, int length, int sport, int dport,
* have a chance to print out replies
*/
- rx_cache_insert(bp, (const struct ip *) bp2, dport);
+ rx_cache_insert(ndo, bp, (const struct ip *) bp2, dport);
switch (dport) {
case FS_RX_PORT: /* AFS file service */
- fs_print(bp, length);
+ fs_print(ndo, bp, length);
break;
case CB_RX_PORT: /* AFS callback service */
- cb_print(bp, length);
+ cb_print(ndo, bp, length);
break;
case PROT_RX_PORT: /* AFS protection service */
- prot_print(bp, length);
+ prot_print(ndo, bp, length);
break;
case VLDB_RX_PORT: /* AFS VLDB service */
- vldb_print(bp, length);
+ vldb_print(ndo, bp, length);
break;
case KAUTH_RX_PORT: /* AFS Kerberos auth service */
- kauth_print(bp, length);
+ kauth_print(ndo, bp, length);
break;
case VOL_RX_PORT: /* AFS Volume service */
- vol_print(bp, length);
+ vol_print(ndo, bp, length);
break;
case BOS_RX_PORT: /* AFS BOS service */
- bos_print(bp, length);
+ bos_print(ndo, bp, length);
break;
default:
;
@@ -557,25 +632,25 @@ rx_print(register const u_char *bp, int length, int sport, int dport,
switch (sport) {
case FS_RX_PORT: /* AFS file service */
- fs_reply_print(bp, length, opcode);
+ fs_reply_print(ndo, bp, length, opcode);
break;
case CB_RX_PORT: /* AFS callback service */
- cb_reply_print(bp, length, opcode);
+ cb_reply_print(ndo, bp, length, opcode);
break;
case PROT_RX_PORT: /* AFS PT service */
- prot_reply_print(bp, length, opcode);
+ prot_reply_print(ndo, bp, length, opcode);
break;
case VLDB_RX_PORT: /* AFS VLDB service */
- vldb_reply_print(bp, length, opcode);
+ vldb_reply_print(ndo, bp, length, opcode);
break;
case KAUTH_RX_PORT: /* AFS Kerberos auth service */
- kauth_reply_print(bp, length, opcode);
+ kauth_reply_print(ndo, bp, length, opcode);
break;
case VOL_RX_PORT: /* AFS Volume service */
- vol_reply_print(bp, length, opcode);
+ vol_reply_print(ndo, bp, length, opcode);
break;
case BOS_RX_PORT: /* AFS BOS service */
- bos_reply_print(bp, length, opcode);
+ bos_reply_print(ndo, bp, length, opcode);
break;
default:
;
@@ -588,10 +663,10 @@ rx_print(register const u_char *bp, int length, int sport, int dport,
*/
} else if (rxh->type == RX_PACKET_TYPE_ACK)
- rx_ack_print(bp, length);
+ rx_ack_print(ndo, bp, length);
- printf(" (%d)", length);
+ ND_PRINT((ndo, " (%d)", length));
}
/*
@@ -599,12 +674,13 @@ rx_print(register const u_char *bp, int length, int sport, int dport,
*/
static void
-rx_cache_insert(const u_char *bp, const struct ip *ip, int dport)
+rx_cache_insert(netdissect_options *ndo,
+ const u_char *bp, const struct ip *ip, int dport)
{
struct rx_cache_entry *rxent;
const struct rx_header *rxh = (const struct rx_header *) bp;
- if (snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t)))
+ if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t)))
return;
rxent = &rx_cache[rx_cache_next];
@@ -633,8 +709,8 @@ rx_cache_find(const struct rx_header *rxh, const struct ip *ip, int sport,
{
int i;
struct rx_cache_entry *rxent;
- u_int32_t clip = ip->ip_dst.s_addr;
- u_int32_t sip = ip->ip_src.s_addr;
+ uint32_t clip = ip->ip_dst.s_addr;
+ uint32_t sip = ip->ip_src.s_addr;
/* Start the search where we last left off */
@@ -653,7 +729,7 @@ rx_cache_find(const struct rx_header *rxh, const struct ip *ip, int sport,
*opcode = rxent->opcode;
return(1);
}
- if (++i > RX_CACHE_SIZE)
+ if (++i >= RX_CACHE_SIZE)
i = 0;
} while (i != rx_cache_hint);
@@ -666,101 +742,101 @@ rx_cache_find(const struct rx_header *rxh, const struct ip *ip, int sport,
*/
#define FIDOUT() { unsigned long n1, n2, n3; \
- TCHECK2(bp[0], sizeof(int32_t) * 3); \
+ ND_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(" fid %d/%d/%d", (int) n1, (int) n2, (int) n3); \
+ ND_PRINT((ndo, " fid %d/%d/%d", (int) n1, (int) n2, (int) n3)); \
}
#define STROUT(MAX) { unsigned int i; \
- TCHECK2(bp[0], sizeof(int32_t)); \
+ ND_TCHECK2(bp[0], sizeof(int32_t)); \
i = EXTRACT_32BITS(bp); \
if (i > (MAX)) \
goto trunc; \
bp += sizeof(int32_t); \
- printf(" \""); \
- if (fn_printn(bp, i, snapend)) \
+ ND_PRINT((ndo, " \"")); \
+ if (fn_printn(ndo, bp, i, ndo->ndo_snapend)) \
goto trunc; \
- printf("\""); \
+ ND_PRINT((ndo, "\"")); \
bp += ((i + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t); \
}
#define INTOUT() { int i; \
- TCHECK2(bp[0], sizeof(int32_t)); \
+ ND_TCHECK2(bp[0], sizeof(int32_t)); \
i = (int) EXTRACT_32BITS(bp); \
bp += sizeof(int32_t); \
- printf(" %d", i); \
+ ND_PRINT((ndo, " %d", i)); \
}
#define UINTOUT() { unsigned long i; \
- TCHECK2(bp[0], sizeof(int32_t)); \
+ ND_TCHECK2(bp[0], sizeof(int32_t)); \
i = EXTRACT_32BITS(bp); \
bp += sizeof(int32_t); \
- printf(" %lu", i); \
+ ND_PRINT((ndo, " %lu", i)); \
}
-#define UINT64OUT() { u_int64_t i; \
- TCHECK2(bp[0], sizeof(u_int64_t)); \
+#define UINT64OUT() { uint64_t i; \
+ ND_TCHECK2(bp[0], sizeof(uint64_t)); \
i = EXTRACT_64BITS(bp); \
- bp += sizeof(u_int64_t); \
- printf(" %" PRIu64, i); \
+ bp += sizeof(uint64_t); \
+ ND_PRINT((ndo, " %" PRIu64, i)); \
}
#define DATEOUT() { time_t t; struct tm *tm; char str[256]; \
- TCHECK2(bp[0], sizeof(int32_t)); \
+ ND_TCHECK2(bp[0], sizeof(int32_t)); \
t = (time_t) EXTRACT_32BITS(bp); \
bp += sizeof(int32_t); \
tm = localtime(&t); \
strftime(str, 256, "%Y/%m/%d %T", tm); \
- printf(" %s", str); \
+ ND_PRINT((ndo, " %s", str)); \
}
#define STOREATTROUT() { unsigned long mask, i; \
- TCHECK2(bp[0], (sizeof(int32_t)*6)); \
+ ND_TCHECK2(bp[0], (sizeof(int32_t)*6)); \
mask = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
- if (mask) printf (" StoreStatus"); \
- if (mask & 1) { printf(" date"); DATEOUT(); } \
+ if (mask) ND_PRINT((ndo, " StoreStatus")); \
+ if (mask & 1) { ND_PRINT((ndo, " date")); DATEOUT(); } \
else bp += sizeof(int32_t); \
i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
- if (mask & 2) printf(" owner %lu", i); \
+ if (mask & 2) ND_PRINT((ndo, " owner %lu", i)); \
i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
- if (mask & 4) printf(" group %lu", i); \
+ if (mask & 4) ND_PRINT((ndo, " group %lu", i)); \
i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
- if (mask & 8) printf(" mode %lo", i & 07777); \
+ if (mask & 8) ND_PRINT((ndo, " mode %lo", i & 07777)); \
i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
- if (mask & 16) printf(" segsize %lu", i); \
+ if (mask & 16) ND_PRINT((ndo, " segsize %lu", i)); \
/* undocumented in 3.3 docu */ \
- if (mask & 1024) printf(" fsync"); \
+ if (mask & 1024) ND_PRINT((ndo, " fsync")); \
}
#define UBIK_VERSIONOUT() {int32_t epoch; int32_t counter; \
- TCHECK2(bp[0], sizeof(int32_t) * 2); \
+ ND_TCHECK2(bp[0], sizeof(int32_t) * 2); \
epoch = EXTRACT_32BITS(bp); \
bp += sizeof(int32_t); \
counter = EXTRACT_32BITS(bp); \
bp += sizeof(int32_t); \
- printf(" %d.%d", epoch, counter); \
+ ND_PRINT((ndo, " %d.%d", epoch, counter)); \
}
-#define AFSUUIDOUT() {u_int32_t temp; int i; \
- TCHECK2(bp[0], 11*sizeof(u_int32_t)); \
+#define AFSUUIDOUT() {uint32_t temp; int i; \
+ ND_TCHECK2(bp[0], 11*sizeof(uint32_t)); \
temp = EXTRACT_32BITS(bp); \
- bp += sizeof(u_int32_t); \
- printf(" %08x", temp); \
+ bp += sizeof(uint32_t); \
+ ND_PRINT((ndo, " %08x", temp)); \
temp = EXTRACT_32BITS(bp); \
- bp += sizeof(u_int32_t); \
- printf("%04x", temp); \
+ bp += sizeof(uint32_t); \
+ ND_PRINT((ndo, "%04x", temp)); \
temp = EXTRACT_32BITS(bp); \
- bp += sizeof(u_int32_t); \
- printf("%04x", temp); \
+ bp += sizeof(uint32_t); \
+ ND_PRINT((ndo, "%04x", temp)); \
for (i = 0; i < 8; i++) { \
temp = EXTRACT_32BITS(bp); \
- bp += sizeof(u_int32_t); \
- printf("%02x", (unsigned char) temp); \
+ bp += sizeof(uint32_t); \
+ ND_PRINT((ndo, "%02x", (unsigned char) temp)); \
} \
}
@@ -773,27 +849,27 @@ rx_cache_find(const struct rx_header *rxh, const struct ip *ip, int sport,
int k; \
if ((MAX) + 1 > sizeof(s)) \
goto trunc; \
- TCHECK2(bp[0], (MAX) * sizeof(int32_t)); \
+ ND_TCHECK2(bp[0], (MAX) * sizeof(int32_t)); \
sp = s; \
for (k = 0; k < (MAX); k++) { \
*sp++ = (u_char) EXTRACT_32BITS(bp); \
bp += sizeof(int32_t); \
} \
s[(MAX)] = '\0'; \
- printf(" \""); \
- fn_print(s, NULL); \
- printf("\""); \
+ ND_PRINT((ndo, " \"")); \
+ fn_print(ndo, s, NULL); \
+ ND_PRINT((ndo, "\"")); \
}
#define DESTSERVEROUT() { unsigned long n1, n2, n3; \
- TCHECK2(bp[0], sizeof(int32_t) * 3); \
+ ND_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); \
+ ND_PRINT((ndo, " server %d:%d:%d", (int) n1, (int) n2, (int) n3)); \
}
/*
@@ -801,7 +877,8 @@ rx_cache_find(const struct rx_header *rxh, const struct ip *ip, int sport,
*/
static void
-fs_print(register const u_char *bp, int length)
+fs_print(netdissect_options *ndo,
+ register const u_char *bp, int length)
{
int fs_op;
unsigned long i;
@@ -809,7 +886,7 @@ fs_print(register const u_char *bp, int length)
if (length <= (int)sizeof(struct rx_header))
return;
- if (snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
+ if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
goto trunc;
}
@@ -820,7 +897,7 @@ fs_print(register const u_char *bp, int length)
fs_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
- printf(" fs call %s", tok2str(fs_req, "op#%d", fs_op));
+ ND_PRINT((ndo, " fs call %s", tok2str(fs_req, "op#%d", fs_op)));
/*
* Print out arguments to some of the AFS calls. This stuff is
@@ -836,9 +913,9 @@ fs_print(register const u_char *bp, int length)
switch (fs_op) {
case 130: /* Fetch data */
FIDOUT();
- printf(" offset");
+ ND_PRINT((ndo, " offset"));
UINTOUT();
- printf(" length");
+ ND_PRINT((ndo, " length"));
UINTOUT();
break;
case 131: /* Fetch ACL */
@@ -858,25 +935,25 @@ fs_print(register const u_char *bp, int length)
case 133: /* Store data */
FIDOUT();
STOREATTROUT();
- printf(" offset");
+ ND_PRINT((ndo, " offset"));
UINTOUT();
- printf(" length");
+ ND_PRINT((ndo, " length"));
UINTOUT();
- printf(" flen");
+ ND_PRINT((ndo, " flen"));
UINTOUT();
break;
case 134: /* Store ACL */
{
char a[AFSOPAQUEMAX+1];
FIDOUT();
- TCHECK2(bp[0], 4);
+ ND_TCHECK2(bp[0], 4);
i = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
- TCHECK2(bp[0], i);
+ ND_TCHECK2(bp[0], i);
i = min(AFSOPAQUEMAX, i);
strncpy(a, (char *) bp, i);
a[i] = '\0';
- acl_print((u_char *) a, sizeof(a), (u_char *) a + i);
+ acl_print(ndo, (u_char *) a, sizeof(a), (u_char *) a + i);
break;
}
case 137: /* Create file */
@@ -891,23 +968,23 @@ fs_print(register const u_char *bp, int length)
STROUT(AFSNAMEMAX);
break;
case 138: /* Rename file */
- printf(" old");
+ ND_PRINT((ndo, " old"));
FIDOUT();
STROUT(AFSNAMEMAX);
- printf(" new");
+ ND_PRINT((ndo, " new"));
FIDOUT();
STROUT(AFSNAMEMAX);
break;
case 139: /* Symlink */
FIDOUT();
STROUT(AFSNAMEMAX);
- printf(" link to");
+ ND_PRINT((ndo, " link to"));
STROUT(AFSNAMEMAX);
break;
case 140: /* Link */
FIDOUT();
STROUT(AFSNAMEMAX);
- printf(" link to");
+ ND_PRINT((ndo, " link to"));
FIDOUT();
break;
case 148: /* Get volume info */
@@ -915,48 +992,48 @@ fs_print(register const u_char *bp, int length)
break;
case 149: /* Get volume stats */
case 150: /* Set volume stats */
- printf(" volid");
+ ND_PRINT((ndo, " volid"));
UINTOUT();
break;
case 154: /* New get volume info */
- printf(" volname");
+ ND_PRINT((ndo, " volname"));
STROUT(AFSNAMEMAX);
break;
case 155: /* Bulk stat */
case 65536: /* Inline bulk stat */
{
unsigned long j;
- TCHECK2(bp[0], 4);
+ ND_TCHECK2(bp[0], 4);
j = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
for (i = 0; i < j; i++) {
FIDOUT();
if (i != j - 1)
- printf(",");
+ ND_PRINT((ndo, ","));
}
if (j == 0)
- printf(" <none!>");
+ ND_PRINT((ndo, " <none!>"));
}
case 65537: /* Fetch data 64 */
FIDOUT();
- printf(" offset");
+ ND_PRINT((ndo, " offset"));
UINT64OUT();
- printf(" length");
+ ND_PRINT((ndo, " length"));
UINT64OUT();
break;
case 65538: /* Store data 64 */
FIDOUT();
STOREATTROUT();
- printf(" offset");
+ ND_PRINT((ndo, " offset"));
UINT64OUT();
- printf(" length");
+ ND_PRINT((ndo, " length"));
UINT64OUT();
- printf(" flen");
+ ND_PRINT((ndo, " flen"));
UINT64OUT();
break;
case 65541: /* CallBack rx conn address */
- printf(" addr");
+ ND_PRINT((ndo, " addr"));
UINTOUT();
default:
;
@@ -965,7 +1042,7 @@ fs_print(register const u_char *bp, int length)
return;
trunc:
- printf(" [|fs]");
+ ND_PRINT((ndo, " [|fs]"));
}
/*
@@ -973,7 +1050,8 @@ trunc:
*/
static void
-fs_reply_print(register const u_char *bp, int length, int32_t opcode)
+fs_reply_print(netdissect_options *ndo,
+ register const u_char *bp, int length, int32_t opcode)
{
unsigned long i;
struct rx_header *rxh;
@@ -988,7 +1066,7 @@ fs_reply_print(register const u_char *bp, int length, int32_t opcode)
* gleaned from fsint/afsint.xg
*/
- printf(" fs reply %s", tok2str(fs_req, "op#%d", opcode));
+ ND_PRINT((ndo, " fs reply %s", tok2str(fs_req, "op#%d", opcode)));
bp += sizeof(struct rx_header);
@@ -1001,23 +1079,23 @@ fs_reply_print(register const u_char *bp, int length, int32_t opcode)
case 131: /* Fetch ACL */
{
char a[AFSOPAQUEMAX+1];
- TCHECK2(bp[0], 4);
+ ND_TCHECK2(bp[0], 4);
i = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
- TCHECK2(bp[0], i);
+ ND_TCHECK2(bp[0], i);
i = min(AFSOPAQUEMAX, i);
strncpy(a, (char *) bp, i);
a[i] = '\0';
- acl_print((u_char *) a, sizeof(a), (u_char *) a + i);
+ acl_print(ndo, (u_char *) a, sizeof(a), (u_char *) a + i);
break;
}
case 137: /* Create file */
case 141: /* MakeDir */
- printf(" new");
+ ND_PRINT((ndo, " new"));
FIDOUT();
break;
case 151: /* Get root volume */
- printf(" root volume");
+ ND_PRINT((ndo, " root volume"));
STROUT(AFSNAMEMAX);
break;
case 153: /* Get time */
@@ -1032,19 +1110,19 @@ fs_reply_print(register const u_char *bp, int length, int32_t opcode)
/*
* Otherwise, just print out the return code
*/
- TCHECK2(bp[0], sizeof(int32_t));
+ ND_TCHECK2(bp[0], sizeof(int32_t));
i = (int) EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
- printf(" error %s", tok2str(afs_fs_errors, "#%d", i));
+ ND_PRINT((ndo, " error %s", tok2str(afs_fs_errors, "#%d", i)));
} else {
- printf(" strange fs reply of type %d", rxh->type);
+ ND_PRINT((ndo, " strange fs reply of type %d", rxh->type));
}
return;
trunc:
- printf(" [|fs]");
+ ND_PRINT((ndo, " [|fs]"));
}
/*
@@ -1062,7 +1140,8 @@ trunc:
*/
static void
-acl_print(u_char *s, int maxsize, u_char *end)
+acl_print(netdissect_options *ndo,
+ u_char *s, int maxsize, u_char *end)
{
int pos, neg, acl;
int n, i;
@@ -1085,31 +1164,25 @@ acl_print(u_char *s, int maxsize, u_char *end)
*/
#define ACLOUT(acl) \
- if (acl & PRSFS_READ) \
- printf("r"); \
- if (acl & PRSFS_LOOKUP) \
- printf("l"); \
- if (acl & PRSFS_INSERT) \
- printf("i"); \
- if (acl & PRSFS_DELETE) \
- printf("d"); \
- if (acl & PRSFS_WRITE) \
- printf("w"); \
- if (acl & PRSFS_LOCK) \
- printf("k"); \
- if (acl & PRSFS_ADMINISTER) \
- printf("a");
+ ND_PRINT((ndo, "%s%s%s%s%s%s%s", \
+ acl & PRSFS_READ ? "r" : "", \
+ acl & PRSFS_LOOKUP ? "l" : "", \
+ acl & PRSFS_INSERT ? "i" : "", \
+ acl & PRSFS_DELETE ? "d" : "", \
+ acl & PRSFS_WRITE ? "w" : "", \
+ acl & PRSFS_LOCK ? "k" : "", \
+ acl & PRSFS_ADMINISTER ? "a" : ""));
for (i = 0; i < pos; i++) {
snprintf(fmt, sizeof(fmt), "%%%ds %%d\n%%n", maxsize - 1);
if (sscanf((char *) s, fmt, user, &acl, &n) != 2)
goto finish;
s += n;
- printf(" +{");
- fn_print((u_char *)user, NULL);
- printf(" ");
+ ND_PRINT((ndo, " +{"));
+ fn_print(ndo, (u_char *)user, NULL);
+ ND_PRINT((ndo, " "));
ACLOUT(acl);
- printf("}");
+ ND_PRINT((ndo, "}"));
if (s > end)
goto finish;
}
@@ -1119,11 +1192,11 @@ acl_print(u_char *s, int maxsize, u_char *end)
if (sscanf((char *) s, fmt, user, &acl, &n) != 2)
goto finish;
s += n;
- printf(" -{");
- fn_print((u_char *)user, NULL);
- printf(" ");
+ ND_PRINT((ndo, " -{"));
+ fn_print(ndo, (u_char *)user, NULL);
+ ND_PRINT((ndo, " "));
ACLOUT(acl);
- printf("}");
+ ND_PRINT((ndo, "}"));
if (s > end)
goto finish;
}
@@ -1140,7 +1213,8 @@ finish:
*/
static void
-cb_print(register const u_char *bp, int length)
+cb_print(netdissect_options *ndo,
+ register const u_char *bp, int length)
{
int cb_op;
unsigned long i;
@@ -1148,7 +1222,7 @@ cb_print(register const u_char *bp, int length)
if (length <= (int)sizeof(struct rx_header))
return;
- if (snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
+ if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
goto trunc;
}
@@ -1159,7 +1233,7 @@ cb_print(register const u_char *bp, int length)
cb_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
- printf(" cb call %s", tok2str(cb_req, "op#%d", cb_op));
+ ND_PRINT((ndo, " cb call %s", tok2str(cb_req, "op#%d", cb_op)));
bp += sizeof(struct rx_header) + 4;
@@ -1172,38 +1246,38 @@ cb_print(register const u_char *bp, int length)
case 204: /* Callback */
{
unsigned long j, t;
- TCHECK2(bp[0], 4);
+ ND_TCHECK2(bp[0], 4);
j = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
for (i = 0; i < j; i++) {
FIDOUT();
if (i != j - 1)
- printf(",");
+ ND_PRINT((ndo, ","));
}
if (j == 0)
- printf(" <none!>");
+ ND_PRINT((ndo, " <none!>"));
j = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
if (j != 0)
- printf(";");
+ ND_PRINT((ndo, ";"));
for (i = 0; i < j; i++) {
- printf(" ver");
+ ND_PRINT((ndo, " ver"));
INTOUT();
- printf(" expires");
+ ND_PRINT((ndo, " expires"));
DATEOUT();
- TCHECK2(bp[0], 4);
+ ND_TCHECK2(bp[0], 4);
t = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
tok2str(cb_types, "type %d", t);
}
}
case 214: {
- printf(" afsuuid");
+ ND_PRINT((ndo, " afsuuid"));
AFSUUIDOUT();
break;
}
@@ -1214,7 +1288,7 @@ cb_print(register const u_char *bp, int length)
return;
trunc:
- printf(" [|cb]");
+ ND_PRINT((ndo, " [|cb]"));
}
/*
@@ -1222,7 +1296,8 @@ trunc:
*/
static void
-cb_reply_print(register const u_char *bp, int length, int32_t opcode)
+cb_reply_print(netdissect_options *ndo,
+ register const u_char *bp, int length, int32_t opcode)
{
struct rx_header *rxh;
@@ -1236,7 +1311,7 @@ cb_reply_print(register const u_char *bp, int length, int32_t opcode)
* gleaned from fsint/afscbint.xg
*/
- printf(" cb reply %s", tok2str(cb_req, "op#%d", opcode));
+ ND_PRINT((ndo, " cb reply %s", tok2str(cb_req, "op#%d", opcode)));
bp += sizeof(struct rx_header);
@@ -1256,14 +1331,14 @@ cb_reply_print(register const u_char *bp, int length, int32_t opcode)
/*
* Otherwise, just print out the return code
*/
- printf(" errcode");
+ ND_PRINT((ndo, " errcode"));
INTOUT();
}
return;
trunc:
- printf(" [|cb]");
+ ND_PRINT((ndo, " [|cb]"));
}
/*
@@ -1271,7 +1346,8 @@ trunc:
*/
static void
-prot_print(register const u_char *bp, int length)
+prot_print(netdissect_options *ndo,
+ register const u_char *bp, int length)
{
unsigned long i;
int pt_op;
@@ -1279,7 +1355,7 @@ prot_print(register const u_char *bp, int length)
if (length <= (int)sizeof(struct rx_header))
return;
- if (snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
+ if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
goto trunc;
}
@@ -1290,14 +1366,14 @@ prot_print(register const u_char *bp, int length)
pt_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
- printf(" pt");
+ ND_PRINT((ndo, " pt"));
if (is_ubik(pt_op)) {
- ubik_print(bp);
+ ubik_print(ndo, bp);
return;
}
- printf(" call %s", tok2str(pt_req, "op#%d", pt_op));
+ ND_PRINT((ndo, " call %s", tok2str(pt_req, "op#%d", pt_op)));
/*
* Decode some of the arguments to the PT calls
@@ -1308,9 +1384,9 @@ prot_print(register const u_char *bp, int length)
switch (pt_op) {
case 500: /* I New User */
STROUT(PRNAMEMAX);
- printf(" id");
+ ND_PRINT((ndo, " id"));
INTOUT();
- printf(" oldid");
+ ND_PRINT((ndo, " oldid"));
INTOUT();
break;
case 501: /* Where is it */
@@ -1322,25 +1398,25 @@ prot_print(register const u_char *bp, int length)
case 518: /* Get CPS2 */
case 519: /* Get host CPS */
case 530: /* List super groups */
- printf(" id");
+ ND_PRINT((ndo, " id"));
INTOUT();
break;
case 502: /* Dump entry */
- printf(" pos");
+ ND_PRINT((ndo, " pos"));
INTOUT();
break;
case 503: /* Add to group */
case 507: /* Remove from group */
case 515: /* Is a member of? */
- printf(" uid");
+ ND_PRINT((ndo, " uid"));
INTOUT();
- printf(" gid");
+ ND_PRINT((ndo, " gid"));
INTOUT();
break;
case 504: /* Name to ID */
{
unsigned long j;
- TCHECK2(bp[0], 4);
+ ND_TCHECK2(bp[0], 4);
j = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
@@ -1355,46 +1431,46 @@ prot_print(register const u_char *bp, int length)
VECOUT(PRNAMEMAX);
}
if (j == 0)
- printf(" <none!>");
+ ND_PRINT((ndo, " <none!>"));
}
break;
case 505: /* Id to name */
{
unsigned long j;
- printf(" ids:");
- TCHECK2(bp[0], 4);
+ ND_PRINT((ndo, " ids:"));
+ ND_TCHECK2(bp[0], 4);
i = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
for (j = 0; j < i; j++)
INTOUT();
if (j == 0)
- printf(" <none!>");
+ ND_PRINT((ndo, " <none!>"));
}
break;
case 509: /* New entry */
STROUT(PRNAMEMAX);
- printf(" flag");
+ ND_PRINT((ndo, " flag"));
INTOUT();
- printf(" oid");
+ ND_PRINT((ndo, " oid"));
INTOUT();
break;
case 511: /* Set max */
- printf(" id");
+ ND_PRINT((ndo, " id"));
INTOUT();
- printf(" gflag");
+ ND_PRINT((ndo, " gflag"));
INTOUT();
break;
case 513: /* Change entry */
- printf(" id");
+ ND_PRINT((ndo, " id"));
INTOUT();
STROUT(PRNAMEMAX);
- printf(" oldid");
+ ND_PRINT((ndo, " oldid"));
INTOUT();
- printf(" newid");
+ ND_PRINT((ndo, " newid"));
INTOUT();
break;
case 520: /* Update entry */
- printf(" id");
+ ND_PRINT((ndo, " id"));
INTOUT();
STROUT(PRNAMEMAX);
break;
@@ -1406,7 +1482,7 @@ prot_print(register const u_char *bp, int length)
return;
trunc:
- printf(" [|pt]");
+ ND_PRINT((ndo, " [|pt]"));
}
/*
@@ -1414,7 +1490,8 @@ trunc:
*/
static void
-prot_reply_print(register const u_char *bp, int length, int32_t opcode)
+prot_reply_print(netdissect_options *ndo,
+ register const u_char *bp, int length, int32_t opcode)
{
struct rx_header *rxh;
unsigned long i;
@@ -1430,14 +1507,14 @@ prot_reply_print(register const u_char *bp, int length, int32_t opcode)
* Ubik call, however.
*/
- printf(" pt");
+ ND_PRINT((ndo, " pt"));
if (is_ubik(opcode)) {
- ubik_reply_print(bp, length, opcode);
+ ubik_reply_print(ndo, bp, length, opcode);
return;
}
- printf(" reply %s", tok2str(pt_req, "op#%d", opcode));
+ ND_PRINT((ndo, " reply %s", tok2str(pt_req, "op#%d", opcode)));
bp += sizeof(struct rx_header);
@@ -1450,20 +1527,20 @@ prot_reply_print(register const u_char *bp, int length, int32_t opcode)
case 504: /* Name to ID */
{
unsigned long j;
- printf(" ids:");
- TCHECK2(bp[0], 4);
+ ND_PRINT((ndo, " ids:"));
+ ND_TCHECK2(bp[0], 4);
i = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
for (j = 0; j < i; j++)
INTOUT();
if (j == 0)
- printf(" <none!>");
+ ND_PRINT((ndo, " <none!>"));
}
break;
case 505: /* ID to name */
{
unsigned long j;
- TCHECK2(bp[0], 4);
+ ND_TCHECK2(bp[0], 4);
j = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
@@ -1478,7 +1555,7 @@ prot_reply_print(register const u_char *bp, int length, int32_t opcode)
VECOUT(PRNAMEMAX);
}
if (j == 0)
- printf(" <none!>");
+ ND_PRINT((ndo, " <none!>"));
}
break;
case 508: /* Get CPS */
@@ -1488,20 +1565,20 @@ prot_reply_print(register const u_char *bp, int length, int32_t opcode)
case 519: /* Get host CPS */
{
unsigned long j;
- TCHECK2(bp[0], 4);
+ ND_TCHECK2(bp[0], 4);
j = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
for (i = 0; i < j; i++) {
INTOUT();
}
if (j == 0)
- printf(" <none!>");
+ ND_PRINT((ndo, " <none!>"));
}
break;
case 510: /* List max */
- printf(" maxuid");
+ ND_PRINT((ndo, " maxuid"));
INTOUT();
- printf(" maxgid");
+ ND_PRINT((ndo, " maxgid"));
INTOUT();
break;
default:
@@ -1511,14 +1588,14 @@ prot_reply_print(register const u_char *bp, int length, int32_t opcode)
/*
* Otherwise, just print out the return code
*/
- printf(" errcode");
+ ND_PRINT((ndo, " errcode"));
INTOUT();
}
return;
trunc:
- printf(" [|pt]");
+ ND_PRINT((ndo, " [|pt]"));
}
/*
@@ -1526,7 +1603,8 @@ trunc:
*/
static void
-vldb_print(register const u_char *bp, int length)
+vldb_print(netdissect_options *ndo,
+ register const u_char *bp, int length)
{
int vldb_op;
unsigned long i;
@@ -1534,7 +1612,7 @@ vldb_print(register const u_char *bp, int length)
if (length <= (int)sizeof(struct rx_header))
return;
- if (snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
+ if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
goto trunc;
}
@@ -1545,13 +1623,13 @@ vldb_print(register const u_char *bp, int length)
vldb_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
- printf(" vldb");
+ ND_PRINT((ndo, " vldb"));
if (is_ubik(vldb_op)) {
- ubik_print(bp);
+ ubik_print(ndo, bp);
return;
}
- printf(" call %s", tok2str(vldb_req, "op#%d", vldb_op));
+ ND_PRINT((ndo, " call %s", tok2str(vldb_req, "op#%d", vldb_op)));
/*
* Decode some of the arguments to the VLDB calls
@@ -1570,13 +1648,13 @@ vldb_print(register const u_char *bp, int length)
case 508: /* Set lock */
case 509: /* Release lock */
case 518: /* Get entry by ID N */
- printf(" volid");
+ ND_PRINT((ndo, " volid"));
INTOUT();
- TCHECK2(bp[0], sizeof(int32_t));
+ ND_TCHECK2(bp[0], sizeof(int32_t));
i = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
if (i <= 2)
- printf(" type %s", voltype[i]);
+ ND_PRINT((ndo, " type %s", voltype[i]));
break;
case 504: /* Get entry by name */
case 519: /* Get entry by name N */
@@ -1585,23 +1663,23 @@ vldb_print(register const u_char *bp, int length)
STROUT(VLNAMEMAX);
break;
case 505: /* Get new vol id */
- printf(" bump");
+ ND_PRINT((ndo, " bump"));
INTOUT();
break;
case 506: /* Replace entry */
case 520: /* Replace entry N */
- printf(" volid");
+ ND_PRINT((ndo, " volid"));
INTOUT();
- TCHECK2(bp[0], sizeof(int32_t));
+ ND_TCHECK2(bp[0], sizeof(int32_t));
i = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
if (i <= 2)
- printf(" type %s", voltype[i]);
+ ND_PRINT((ndo, " type %s", voltype[i]));
VECOUT(VLNAMEMAX);
break;
case 510: /* List entry */
case 521: /* List entry N */
- printf(" index");
+ ND_PRINT((ndo, " index"));
INTOUT();
break;
default:
@@ -1611,7 +1689,7 @@ vldb_print(register const u_char *bp, int length)
return;
trunc:
- printf(" [|vldb]");
+ ND_PRINT((ndo, " [|vldb]"));
}
/*
@@ -1619,7 +1697,8 @@ trunc:
*/
static void
-vldb_reply_print(register const u_char *bp, int length, int32_t opcode)
+vldb_reply_print(netdissect_options *ndo,
+ register const u_char *bp, int length, int32_t opcode)
{
struct rx_header *rxh;
unsigned long i;
@@ -1635,14 +1714,14 @@ vldb_reply_print(register const u_char *bp, int length, int32_t opcode)
* Ubik call, however.
*/
- printf(" vldb");
+ ND_PRINT((ndo, " vldb"));
if (is_ubik(opcode)) {
- ubik_reply_print(bp, length, opcode);
+ ubik_reply_print(ndo, bp, length, opcode);
return;
}
- printf(" reply %s", tok2str(vldb_req, "op#%d", opcode));
+ ND_PRINT((ndo, " reply %s", tok2str(vldb_req, "op#%d", opcode)));
bp += sizeof(struct rx_header);
@@ -1653,93 +1732,93 @@ vldb_reply_print(register const u_char *bp, int length, int32_t opcode)
if (rxh->type == RX_PACKET_TYPE_DATA)
switch (opcode) {
case 510: /* List entry */
- printf(" count");
+ ND_PRINT((ndo, " count"));
INTOUT();
- printf(" nextindex");
+ ND_PRINT((ndo, " nextindex"));
INTOUT();
case 503: /* Get entry by id */
case 504: /* Get entry by name */
{ unsigned long nservers, j;
VECOUT(VLNAMEMAX);
- TCHECK2(bp[0], sizeof(int32_t));
+ ND_TCHECK2(bp[0], sizeof(int32_t));
bp += sizeof(int32_t);
- printf(" numservers");
- TCHECK2(bp[0], sizeof(int32_t));
+ ND_PRINT((ndo, " numservers"));
+ ND_TCHECK2(bp[0], sizeof(int32_t));
nservers = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
- printf(" %lu", nservers);
- printf(" servers");
+ ND_PRINT((ndo, " %lu", nservers));
+ ND_PRINT((ndo, " servers"));
for (i = 0; i < 8; i++) {
- TCHECK2(bp[0], sizeof(int32_t));
+ ND_TCHECK2(bp[0], sizeof(int32_t));
if (i < nservers)
- printf(" %s",
- intoa(((struct in_addr *) bp)->s_addr));
+ ND_PRINT((ndo, " %s",
+ intoa(((struct in_addr *) bp)->s_addr)));
bp += sizeof(int32_t);
}
- printf(" partitions");
+ ND_PRINT((ndo, " partitions"));
for (i = 0; i < 8; i++) {
- TCHECK2(bp[0], sizeof(int32_t));
+ ND_TCHECK2(bp[0], sizeof(int32_t));
j = EXTRACT_32BITS(bp);
if (i < nservers && j <= 26)
- printf(" %c", 'a' + (int)j);
+ ND_PRINT((ndo, " %c", 'a' + (int)j));
else if (i < nservers)
- printf(" %lu", j);
+ ND_PRINT((ndo, " %lu", j));
bp += sizeof(int32_t);
}
- TCHECK2(bp[0], 8 * sizeof(int32_t));
+ ND_TCHECK2(bp[0], 8 * sizeof(int32_t));
bp += 8 * sizeof(int32_t);
- printf(" rwvol");
+ ND_PRINT((ndo, " rwvol"));
UINTOUT();
- printf(" rovol");
+ ND_PRINT((ndo, " rovol"));
UINTOUT();
- printf(" backup");
+ ND_PRINT((ndo, " backup"));
UINTOUT();
}
break;
case 505: /* Get new volume ID */
- printf(" newvol");
+ ND_PRINT((ndo, " newvol"));
UINTOUT();
break;
case 521: /* List entry */
case 529: /* List entry U */
- printf(" count");
+ ND_PRINT((ndo, " count"));
INTOUT();
- printf(" nextindex");
+ ND_PRINT((ndo, " nextindex"));
INTOUT();
case 518: /* Get entry by ID N */
case 519: /* Get entry by name N */
{ unsigned long nservers, j;
VECOUT(VLNAMEMAX);
- printf(" numservers");
- TCHECK2(bp[0], sizeof(int32_t));
+ ND_PRINT((ndo, " numservers"));
+ ND_TCHECK2(bp[0], sizeof(int32_t));
nservers = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
- printf(" %lu", nservers);
- printf(" servers");
+ ND_PRINT((ndo, " %lu", nservers));
+ ND_PRINT((ndo, " servers"));
for (i = 0; i < 13; i++) {
- TCHECK2(bp[0], sizeof(int32_t));
+ ND_TCHECK2(bp[0], sizeof(int32_t));
if (i < nservers)
- printf(" %s",
- intoa(((struct in_addr *) bp)->s_addr));
+ ND_PRINT((ndo, " %s",
+ intoa(((struct in_addr *) bp)->s_addr)));
bp += sizeof(int32_t);
}
- printf(" partitions");
+ ND_PRINT((ndo, " partitions"));
for (i = 0; i < 13; i++) {
- TCHECK2(bp[0], sizeof(int32_t));
+ ND_TCHECK2(bp[0], sizeof(int32_t));
j = EXTRACT_32BITS(bp);
if (i < nservers && j <= 26)
- printf(" %c", 'a' + (int)j);
+ ND_PRINT((ndo, " %c", 'a' + (int)j));
else if (i < nservers)
- printf(" %lu", j);
+ ND_PRINT((ndo, " %lu", j));
bp += sizeof(int32_t);
}
- TCHECK2(bp[0], 13 * sizeof(int32_t));
+ ND_TCHECK2(bp[0], 13 * sizeof(int32_t));
bp += 13 * sizeof(int32_t);
- printf(" rwvol");
+ ND_PRINT((ndo, " rwvol"));
UINTOUT();
- printf(" rovol");
+ ND_PRINT((ndo, " rovol"));
UINTOUT();
- printf(" backup");
+ ND_PRINT((ndo, " backup"));
UINTOUT();
}
break;
@@ -1747,40 +1826,40 @@ vldb_reply_print(register const u_char *bp, int length, int32_t opcode)
case 527: /* Get entry by name U */
{ unsigned long nservers, j;
VECOUT(VLNAMEMAX);
- printf(" numservers");
- TCHECK2(bp[0], sizeof(int32_t));
+ ND_PRINT((ndo, " numservers"));
+ ND_TCHECK2(bp[0], sizeof(int32_t));
nservers = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
- printf(" %lu", nservers);
- printf(" servers");
+ ND_PRINT((ndo, " %lu", nservers));
+ ND_PRINT((ndo, " servers"));
for (i = 0; i < 13; i++) {
if (i < nservers) {
- printf(" afsuuid");
+ ND_PRINT((ndo, " afsuuid"));
AFSUUIDOUT();
} else {
- TCHECK2(bp[0], 44);
+ ND_TCHECK2(bp[0], 44);
bp += 44;
}
}
- TCHECK2(bp[0], 4 * 13);
+ ND_TCHECK2(bp[0], 4 * 13);
bp += 4 * 13;
- printf(" partitions");
+ ND_PRINT((ndo, " partitions"));
for (i = 0; i < 13; i++) {
- TCHECK2(bp[0], sizeof(int32_t));
+ ND_TCHECK2(bp[0], sizeof(int32_t));
j = EXTRACT_32BITS(bp);
if (i < nservers && j <= 26)
- printf(" %c", 'a' + (int)j);
+ ND_PRINT((ndo, " %c", 'a' + (int)j));
else if (i < nservers)
- printf(" %lu", j);
+ ND_PRINT((ndo, " %lu", j));
bp += sizeof(int32_t);
}
- TCHECK2(bp[0], 13 * sizeof(int32_t));
+ ND_TCHECK2(bp[0], 13 * sizeof(int32_t));
bp += 13 * sizeof(int32_t);
- printf(" rwvol");
+ ND_PRINT((ndo, " rwvol"));
UINTOUT();
- printf(" rovol");
+ ND_PRINT((ndo, " rovol"));
UINTOUT();
- printf(" backup");
+ ND_PRINT((ndo, " backup"));
UINTOUT();
}
default:
@@ -1791,14 +1870,14 @@ vldb_reply_print(register const u_char *bp, int length, int32_t opcode)
/*
* Otherwise, just print out the return code
*/
- printf(" errcode");
+ ND_PRINT((ndo, " errcode"));
INTOUT();
}
return;
trunc:
- printf(" [|vldb]");
+ ND_PRINT((ndo, " [|vldb]"));
}
/*
@@ -1806,14 +1885,15 @@ trunc:
*/
static void
-kauth_print(register const u_char *bp, int length)
+kauth_print(netdissect_options *ndo,
+ register const u_char *bp, int length)
{
int kauth_op;
if (length <= (int)sizeof(struct rx_header))
return;
- if (snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
+ if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
goto trunc;
}
@@ -1824,15 +1904,15 @@ kauth_print(register const u_char *bp, int length)
kauth_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
- printf(" kauth");
+ ND_PRINT((ndo, " kauth"));
if (is_ubik(kauth_op)) {
- ubik_print(bp);
+ ubik_print(ndo, bp);
return;
}
- printf(" call %s", tok2str(kauth_req, "op#%d", kauth_op));
+ ND_PRINT((ndo, " call %s", tok2str(kauth_req, "op#%d", kauth_op)));
/*
* Decode some of the arguments to the KA calls
@@ -1851,7 +1931,7 @@ kauth_print(register const u_char *bp, int length)
case 8: /* Get entry */
case 14: /* Unlock */
case 15: /* Lock status */
- printf(" principal");
+ ND_PRINT((ndo, " principal"));
STROUT(KANAMEMAX);
STROUT(KANAMEMAX);
break;
@@ -1859,29 +1939,29 @@ kauth_print(register const u_char *bp, int length)
case 23: /* GetTicket */
{
int i;
- printf(" kvno");
+ ND_PRINT((ndo, " kvno"));
INTOUT();
- printf(" domain");
+ ND_PRINT((ndo, " domain"));
STROUT(KANAMEMAX);
- TCHECK2(bp[0], sizeof(int32_t));
+ ND_TCHECK2(bp[0], sizeof(int32_t));
i = (int) EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
- TCHECK2(bp[0], i);
+ ND_TCHECK2(bp[0], i);
bp += i;
- printf(" principal");
+ ND_PRINT((ndo, " principal"));
STROUT(KANAMEMAX);
STROUT(KANAMEMAX);
break;
}
case 4: /* Set Password */
- printf(" principal");
+ ND_PRINT((ndo, " principal"));
STROUT(KANAMEMAX);
STROUT(KANAMEMAX);
- printf(" kvno");
+ ND_PRINT((ndo, " kvno"));
INTOUT();
break;
case 12: /* Get password */
- printf(" name");
+ ND_PRINT((ndo, " name"));
STROUT(KANAMEMAX);
break;
default:
@@ -1891,7 +1971,7 @@ kauth_print(register const u_char *bp, int length)
return;
trunc:
- printf(" [|kauth]");
+ ND_PRINT((ndo, " [|kauth]"));
}
/*
@@ -1899,7 +1979,8 @@ trunc:
*/
static void
-kauth_reply_print(register const u_char *bp, int length, int32_t opcode)
+kauth_reply_print(netdissect_options *ndo,
+ register const u_char *bp, int length, int32_t opcode)
{
struct rx_header *rxh;
@@ -1913,14 +1994,14 @@ kauth_reply_print(register const u_char *bp, int length, int32_t opcode)
* gleaned from kauth/kauth.rg
*/
- printf(" kauth");
+ ND_PRINT((ndo, " kauth"));
if (is_ubik(opcode)) {
- ubik_reply_print(bp, length, opcode);
+ ubik_reply_print(ndo, bp, length, opcode);
return;
}
- printf(" reply %s", tok2str(kauth_req, "op#%d", opcode));
+ ND_PRINT((ndo, " reply %s", tok2str(kauth_req, "op#%d", opcode)));
bp += sizeof(struct rx_header);
@@ -1935,14 +2016,14 @@ kauth_reply_print(register const u_char *bp, int length, int32_t opcode)
/*
* Otherwise, just print out the return code
*/
- printf(" errcode");
+ ND_PRINT((ndo, " errcode"));
INTOUT();
}
return;
trunc:
- printf(" [|kauth]");
+ ND_PRINT((ndo, " [|kauth]"));
}
/*
@@ -1950,14 +2031,15 @@ trunc:
*/
static void
-vol_print(register const u_char *bp, int length)
+vol_print(netdissect_options *ndo,
+ register const u_char *bp, int length)
{
int vol_op;
if (length <= (int)sizeof(struct rx_header))
return;
- if (snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
+ if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
goto trunc;
}
@@ -1968,126 +2050,126 @@ vol_print(register const u_char *bp, int length)
vol_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
- printf(" vol call %s", tok2str(vol_req, "op#%d", vol_op));
+ ND_PRINT((ndo, " vol call %s", tok2str(vol_req, "op#%d", vol_op)));
bp += sizeof(struct rx_header) + 4;
switch (vol_op) {
case 100: /* Create volume */
- printf(" partition");
+ ND_PRINT((ndo, " partition"));
UINTOUT();
- printf(" name");
+ ND_PRINT((ndo, " name"));
STROUT(AFSNAMEMAX);
- printf(" type");
+ ND_PRINT((ndo, " type"));
UINTOUT();
- printf(" parent");
+ ND_PRINT((ndo, " parent"));
UINTOUT();
break;
case 101: /* Delete volume */
case 107: /* Get flags */
- printf(" trans");
+ ND_PRINT((ndo, " trans"));
UINTOUT();
break;
case 102: /* Restore */
- printf(" totrans");
+ ND_PRINT((ndo, " totrans"));
UINTOUT();
- printf(" flags");
+ ND_PRINT((ndo, " flags"));
UINTOUT();
break;
case 103: /* Forward */
- printf(" fromtrans");
+ ND_PRINT((ndo, " fromtrans"));
UINTOUT();
- printf(" fromdate");
+ ND_PRINT((ndo, " fromdate"));
DATEOUT();
DESTSERVEROUT();
- printf(" desttrans");
+ ND_PRINT((ndo, " desttrans"));
INTOUT();
break;
case 104: /* End trans */
- printf(" trans");
+ ND_PRINT((ndo, " trans"));
UINTOUT();
break;
case 105: /* Clone */
- printf(" trans");
+ ND_PRINT((ndo, " trans"));
UINTOUT();
- printf(" purgevol");
+ ND_PRINT((ndo, " purgevol"));
UINTOUT();
- printf(" newtype");
+ ND_PRINT((ndo, " newtype"));
UINTOUT();
- printf(" newname");
+ ND_PRINT((ndo, " newname"));
STROUT(AFSNAMEMAX);
break;
case 106: /* Set flags */
- printf(" trans");
+ ND_PRINT((ndo, " trans"));
UINTOUT();
- printf(" flags");
+ ND_PRINT((ndo, " flags"));
UINTOUT();
break;
case 108: /* Trans create */
- printf(" vol");
+ ND_PRINT((ndo, " vol"));
UINTOUT();
- printf(" partition");
+ ND_PRINT((ndo, " partition"));
UINTOUT();
- printf(" flags");
+ ND_PRINT((ndo, " flags"));
UINTOUT();
break;
case 109: /* Dump */
case 655537: /* Get size */
- printf(" fromtrans");
+ ND_PRINT((ndo, " fromtrans"));
UINTOUT();
- printf(" fromdate");
+ ND_PRINT((ndo, " fromdate"));
DATEOUT();
break;
case 110: /* Get n-th volume */
- printf(" index");
+ ND_PRINT((ndo, " index"));
UINTOUT();
break;
case 111: /* Set forwarding */
- printf(" tid");
+ ND_PRINT((ndo, " tid"));
UINTOUT();
- printf(" newsite");
+ ND_PRINT((ndo, " newsite"));
UINTOUT();
break;
case 112: /* Get name */
case 113: /* Get status */
- printf(" tid");
+ ND_PRINT((ndo, " tid"));
break;
case 114: /* Signal restore */
- printf(" name");
+ ND_PRINT((ndo, " name"));
STROUT(AFSNAMEMAX);
- printf(" type");
+ ND_PRINT((ndo, " type"));
UINTOUT();
- printf(" pid");
+ ND_PRINT((ndo, " pid"));
UINTOUT();
- printf(" cloneid");
+ ND_PRINT((ndo, " cloneid"));
UINTOUT();
break;
case 116: /* List volumes */
- printf(" partition");
+ ND_PRINT((ndo, " partition"));
UINTOUT();
- printf(" flags");
+ ND_PRINT((ndo, " flags"));
UINTOUT();
break;
case 117: /* Set id types */
- printf(" tid");
+ ND_PRINT((ndo, " tid"));
UINTOUT();
- printf(" name");
+ ND_PRINT((ndo, " name"));
STROUT(AFSNAMEMAX);
- printf(" type");
+ ND_PRINT((ndo, " type"));
UINTOUT();
- printf(" pid");
+ ND_PRINT((ndo, " pid"));
UINTOUT();
- printf(" clone");
+ ND_PRINT((ndo, " clone"));
UINTOUT();
- printf(" backup");
+ ND_PRINT((ndo, " backup"));
UINTOUT();
break;
case 119: /* Partition info */
- printf(" name");
+ ND_PRINT((ndo, " name"));
STROUT(AFSNAMEMAX);
break;
case 120: /* Reclone */
- printf(" tid");
+ ND_PRINT((ndo, " tid"));
UINTOUT();
break;
case 121: /* List one volume */
@@ -2095,46 +2177,46 @@ vol_print(register const u_char *bp, int length)
case 124: /* Extended List volumes */
case 125: /* Extended List one volume */
case 65536: /* Convert RO to RW volume */
- printf(" partid");
+ ND_PRINT((ndo, " partid"));
UINTOUT();
- printf(" volid");
+ ND_PRINT((ndo, " volid"));
UINTOUT();
break;
case 123: /* Set date */
- printf(" tid");
+ ND_PRINT((ndo, " tid"));
UINTOUT();
- printf(" date");
+ ND_PRINT((ndo, " date"));
DATEOUT();
break;
case 126: /* Set info */
- printf(" tid");
+ ND_PRINT((ndo, " tid"));
UINTOUT();
break;
case 128: /* Forward multiple */
- printf(" fromtrans");
+ ND_PRINT((ndo, " fromtrans"));
UINTOUT();
- printf(" fromdate");
+ ND_PRINT((ndo, " fromdate"));
DATEOUT();
{
unsigned long i, j;
- TCHECK2(bp[0], 4);
+ ND_TCHECK2(bp[0], 4);
j = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
for (i = 0; i < j; i++) {
DESTSERVEROUT();
if (i != j - 1)
- printf(",");
+ ND_PRINT((ndo, ","));
}
if (j == 0)
- printf(" <none!>");
+ ND_PRINT((ndo, " <none!>"));
}
break;
case 65538: /* Dump version 2 */
- printf(" fromtrans");
+ ND_PRINT((ndo, " fromtrans"));
UINTOUT();
- printf(" fromdate");
+ ND_PRINT((ndo, " fromdate"));
DATEOUT();
- printf(" flags");
+ ND_PRINT((ndo, " flags"));
UINTOUT();
break;
default:
@@ -2143,7 +2225,7 @@ vol_print(register const u_char *bp, int length)
return;
trunc:
- printf(" [|vol]");
+ ND_PRINT((ndo, " [|vol]"));
}
/*
@@ -2151,7 +2233,8 @@ trunc:
*/
static void
-vol_reply_print(register const u_char *bp, int length, int32_t opcode)
+vol_reply_print(netdissect_options *ndo,
+ register const u_char *bp, int length, int32_t opcode)
{
struct rx_header *rxh;
@@ -2165,7 +2248,7 @@ vol_reply_print(register const u_char *bp, int length, int32_t opcode)
* gleaned from volser/volint.xg
*/
- printf(" vol reply %s", tok2str(vol_req, "op#%d", opcode));
+ ND_PRINT((ndo, " vol reply %s", tok2str(vol_req, "op#%d", opcode)));
bp += sizeof(struct rx_header);
@@ -2176,66 +2259,66 @@ vol_reply_print(register const u_char *bp, int length, int32_t opcode)
if (rxh->type == RX_PACKET_TYPE_DATA) {
switch (opcode) {
case 100: /* Create volume */
- printf(" volid");
+ ND_PRINT((ndo, " volid"));
UINTOUT();
- printf(" trans");
+ ND_PRINT((ndo, " trans"));
UINTOUT();
break;
case 104: /* End transaction */
UINTOUT();
break;
case 105: /* Clone */
- printf(" newvol");
+ ND_PRINT((ndo, " newvol"));
UINTOUT();
break;
case 107: /* Get flags */
UINTOUT();
break;
case 108: /* Transaction create */
- printf(" trans");
+ ND_PRINT((ndo, " trans"));
UINTOUT();
break;
case 110: /* Get n-th volume */
- printf(" volume");
+ ND_PRINT((ndo, " volume"));
UINTOUT();
- printf(" partition");
+ ND_PRINT((ndo, " partition"));
UINTOUT();
break;
case 112: /* Get name */
STROUT(AFSNAMEMAX);
break;
case 113: /* Get status */
- printf(" volid");
+ ND_PRINT((ndo, " volid"));
UINTOUT();
- printf(" nextuniq");
+ ND_PRINT((ndo, " nextuniq"));
UINTOUT();
- printf(" type");
+ ND_PRINT((ndo, " type"));
UINTOUT();
- printf(" parentid");
+ ND_PRINT((ndo, " parentid"));
UINTOUT();
- printf(" clone");
+ ND_PRINT((ndo, " clone"));
UINTOUT();
- printf(" backup");
+ ND_PRINT((ndo, " backup"));
UINTOUT();
- printf(" restore");
+ ND_PRINT((ndo, " restore"));
UINTOUT();
- printf(" maxquota");
+ ND_PRINT((ndo, " maxquota"));
UINTOUT();
- printf(" minquota");
+ ND_PRINT((ndo, " minquota"));
UINTOUT();
- printf(" owner");
+ ND_PRINT((ndo, " owner"));
UINTOUT();
- printf(" create");
+ ND_PRINT((ndo, " create"));
DATEOUT();
- printf(" access");
+ ND_PRINT((ndo, " access"));
DATEOUT();
- printf(" update");
+ ND_PRINT((ndo, " update"));
DATEOUT();
- printf(" expire");
+ ND_PRINT((ndo, " expire"));
DATEOUT();
- printf(" backup");
+ ND_PRINT((ndo, " backup"));
DATEOUT();
- printf(" copy");
+ ND_PRINT((ndo, " copy"));
DATEOUT();
break;
case 115: /* Old list partitions */
@@ -2244,24 +2327,24 @@ vol_reply_print(register const u_char *bp, int length, int32_t opcode)
case 121: /* List one volume */
{
unsigned long i, j;
- TCHECK2(bp[0], 4);
+ ND_TCHECK2(bp[0], 4);
j = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
for (i = 0; i < j; i++) {
- printf(" name");
+ ND_PRINT((ndo, " name"));
VECOUT(32);
- printf(" volid");
+ ND_PRINT((ndo, " volid"));
UINTOUT();
- printf(" type");
+ ND_PRINT((ndo, " type"));
bp += sizeof(int32_t) * 21;
if (i != j - 1)
- printf(",");
+ ND_PRINT((ndo, ","));
}
if (j == 0)
- printf(" <none!>");
+ ND_PRINT((ndo, " <none!>"));
}
break;
-
+
default:
;
@@ -2270,14 +2353,14 @@ vol_reply_print(register const u_char *bp, int length, int32_t opcode)
/*
* Otherwise, just print out the return code
*/
- printf(" errcode");
+ ND_PRINT((ndo, " errcode"));
INTOUT();
}
return;
trunc:
- printf(" [|vol]");
+ ND_PRINT((ndo, " [|vol]"));
}
/*
@@ -2285,14 +2368,15 @@ trunc:
*/
static void
-bos_print(register const u_char *bp, int length)
+bos_print(netdissect_options *ndo,
+ register const u_char *bp, int length)
{
int bos_op;
if (length <= (int)sizeof(struct rx_header))
return;
- if (snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
+ if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
goto trunc;
}
@@ -2303,7 +2387,7 @@ bos_print(register const u_char *bp, int length)
bos_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
- printf(" bos call %s", tok2str(bos_req, "op#%d", bos_op));
+ ND_PRINT((ndo, " bos call %s", tok2str(bos_req, "op#%d", bos_op)));
/*
* Decode some of the arguments to the BOS calls
@@ -2313,9 +2397,9 @@ bos_print(register const u_char *bp, int length)
switch (bos_op) {
case 80: /* Create B node */
- printf(" type");
+ ND_PRINT((ndo, " type"));
STROUT(BOSNAMEMAX);
- printf(" instance");
+ ND_PRINT((ndo, " instance"));
STROUT(BOSNAMEMAX);
break;
case 81: /* Delete B node */
@@ -2336,12 +2420,12 @@ bos_print(register const u_char *bp, int length)
case 82: /* Set status */
case 98: /* Set T status */
STROUT(BOSNAMEMAX);
- printf(" status");
+ ND_PRINT((ndo, " status"));
INTOUT();
break;
case 86: /* Get instance parm */
STROUT(BOSNAMEMAX);
- printf(" num");
+ ND_PRINT((ndo, " num"));
INTOUT();
break;
case 84: /* Enumerate instance */
@@ -2354,11 +2438,11 @@ bos_print(register const u_char *bp, int length)
break;
case 105: /* Install */
STROUT(BOSNAMEMAX);
- printf(" size");
+ ND_PRINT((ndo, " size"));
INTOUT();
- printf(" flags");
+ ND_PRINT((ndo, " flags"));
INTOUT();
- printf(" date");
+ ND_PRINT((ndo, " date"));
INTOUT();
break;
default:
@@ -2368,7 +2452,7 @@ bos_print(register const u_char *bp, int length)
return;
trunc:
- printf(" [|bos]");
+ ND_PRINT((ndo, " [|bos]"));
}
/*
@@ -2376,7 +2460,8 @@ trunc:
*/
static void
-bos_reply_print(register const u_char *bp, int length, int32_t opcode)
+bos_reply_print(netdissect_options *ndo,
+ register const u_char *bp, int length, int32_t opcode)
{
struct rx_header *rxh;
@@ -2390,7 +2475,7 @@ bos_reply_print(register const u_char *bp, int length, int32_t opcode)
* gleaned from volser/volint.xg
*/
- printf(" bos reply %s", tok2str(bos_req, "op#%d", opcode));
+ ND_PRINT((ndo, " bos reply %s", tok2str(bos_req, "op#%d", opcode)));
bp += sizeof(struct rx_header);
@@ -2405,14 +2490,14 @@ bos_reply_print(register const u_char *bp, int length, int32_t opcode)
/*
* Otherwise, just print out the return code
*/
- printf(" errcode");
+ ND_PRINT((ndo, " errcode"));
INTOUT();
}
return;
trunc:
- printf(" [|bos]");
+ ND_PRINT((ndo, " [|bos]"));
}
/*
@@ -2420,7 +2505,7 @@ trunc:
*/
static int
-is_ubik(u_int32_t opcode)
+is_ubik(uint32_t opcode)
{
if ((opcode >= VOTE_LOW && opcode <= VOTE_HIGH) ||
(opcode >= DISK_LOW && opcode <= DISK_HIGH))
@@ -2434,7 +2519,8 @@ is_ubik(u_int32_t opcode)
*/
static void
-ubik_print(register const u_char *bp)
+ubik_print(netdissect_options *ndo,
+ register const u_char *bp)
{
int ubik_op;
int32_t temp;
@@ -2446,7 +2532,7 @@ ubik_print(register const u_char *bp)
ubik_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
- printf(" ubik call %s", tok2str(ubik_req, "op#%d", ubik_op));
+ ND_PRINT((ndo, " ubik call %s", tok2str(ubik_req, "op#%d", ubik_op)));
/*
* Decode some of the arguments to the Ubik calls
@@ -2456,19 +2542,19 @@ ubik_print(register const u_char *bp)
switch (ubik_op) {
case 10000: /* Beacon */
- TCHECK2(bp[0], 4);
+ ND_TCHECK2(bp[0], 4);
temp = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
- printf(" syncsite %s", temp ? "yes" : "no");
- printf(" votestart");
+ ND_PRINT((ndo, " syncsite %s", temp ? "yes" : "no"));
+ ND_PRINT((ndo, " votestart"));
DATEOUT();
- printf(" dbversion");
+ ND_PRINT((ndo, " dbversion"));
UBIK_VERSIONOUT();
- printf(" tid");
+ ND_PRINT((ndo, " tid"));
UBIK_VERSIONOUT();
break;
case 10003: /* Get sync site */
- printf(" site");
+ ND_PRINT((ndo, " site"));
UINTOUT();
break;
case 20000: /* Begin */
@@ -2476,56 +2562,56 @@ ubik_print(register const u_char *bp)
case 20007: /* Abort */
case 20008: /* Release locks */
case 20010: /* Writev */
- printf(" tid");
+ ND_PRINT((ndo, " tid"));
UBIK_VERSIONOUT();
break;
case 20002: /* Lock */
- printf(" tid");
+ ND_PRINT((ndo, " tid"));
UBIK_VERSIONOUT();
- printf(" file");
+ ND_PRINT((ndo, " file"));
INTOUT();
- printf(" pos");
+ ND_PRINT((ndo, " pos"));
INTOUT();
- printf(" length");
+ ND_PRINT((ndo, " length"));
INTOUT();
temp = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
tok2str(ubik_lock_types, "type %d", temp);
break;
case 20003: /* Write */
- printf(" tid");
+ ND_PRINT((ndo, " tid"));
UBIK_VERSIONOUT();
- printf(" file");
+ ND_PRINT((ndo, " file"));
INTOUT();
- printf(" pos");
+ ND_PRINT((ndo, " pos"));
INTOUT();
break;
case 20005: /* Get file */
- printf(" file");
+ ND_PRINT((ndo, " file"));
INTOUT();
break;
case 20006: /* Send file */
- printf(" file");
+ ND_PRINT((ndo, " file"));
INTOUT();
- printf(" length");
+ ND_PRINT((ndo, " length"));
INTOUT();
- printf(" dbversion");
+ ND_PRINT((ndo, " dbversion"));
UBIK_VERSIONOUT();
break;
case 20009: /* Truncate */
- printf(" tid");
+ ND_PRINT((ndo, " tid"));
UBIK_VERSIONOUT();
- printf(" file");
+ ND_PRINT((ndo, " file"));
INTOUT();
- printf(" length");
+ ND_PRINT((ndo, " length"));
INTOUT();
break;
case 20012: /* Set version */
- printf(" tid");
+ ND_PRINT((ndo, " tid"));
UBIK_VERSIONOUT();
- printf(" oldversion");
+ ND_PRINT((ndo, " oldversion"));
UBIK_VERSIONOUT();
- printf(" newversion");
+ ND_PRINT((ndo, " newversion"));
UBIK_VERSIONOUT();
break;
default:
@@ -2535,7 +2621,7 @@ ubik_print(register const u_char *bp)
return;
trunc:
- printf(" [|ubik]");
+ ND_PRINT((ndo, " [|ubik]"));
}
/*
@@ -2543,7 +2629,8 @@ trunc:
*/
static void
-ubik_reply_print(register const u_char *bp, int length, int32_t opcode)
+ubik_reply_print(netdissect_options *ndo,
+ register const u_char *bp, int length, int32_t opcode)
{
struct rx_header *rxh;
@@ -2557,7 +2644,7 @@ ubik_reply_print(register const u_char *bp, int length, int32_t opcode)
* from ubik/ubik_int.xg
*/
- printf(" ubik reply %s", tok2str(ubik_req, "op#%d", opcode));
+ ND_PRINT((ndo, " ubik reply %s", tok2str(ubik_req, "op#%d", opcode)));
bp += sizeof(struct rx_header);
@@ -2568,10 +2655,10 @@ ubik_reply_print(register const u_char *bp, int length, int32_t opcode)
if (rxh->type == RX_PACKET_TYPE_DATA)
switch (opcode) {
case 10000: /* Beacon */
- printf(" vote no");
+ ND_PRINT((ndo, " vote no"));
break;
case 20004: /* Get version */
- printf(" dbversion");
+ ND_PRINT((ndo, " dbversion"));
UBIK_VERSIONOUT();
break;
default:
@@ -2587,18 +2674,18 @@ ubik_reply_print(register const u_char *bp, int length, int32_t opcode)
else
switch (opcode) {
case 10000: /* Beacon */
- printf(" vote yes until");
+ ND_PRINT((ndo, " vote yes until"));
DATEOUT();
break;
default:
- printf(" errcode");
+ ND_PRINT((ndo, " errcode"));
INTOUT();
}
return;
trunc:
- printf(" [|ubik]");
+ ND_PRINT((ndo, " [|ubik]"));
}
/*
@@ -2606,11 +2693,12 @@ trunc:
*/
static void
-rx_ack_print(register const u_char *bp, int length)
+rx_ack_print(netdissect_options *ndo,
+ register const u_char *bp, int length)
{
struct rx_ackPacket *rxa;
int i, start, last;
- u_int32_t firstPacket;
+ uint32_t firstPacket;
if (length < (int)sizeof(struct rx_header))
return;
@@ -2625,7 +2713,7 @@ rx_ack_print(register const u_char *bp, int length)
* rx_ackPacket structure.
*/
- TCHECK2(bp[0], sizeof(struct rx_ackPacket) - RX_MAXACKS);
+ ND_TCHECK2(bp[0], sizeof(struct rx_ackPacket) - RX_MAXACKS);
rxa = (struct rx_ackPacket *) bp;
bp += (sizeof(struct rx_ackPacket) - RX_MAXACKS);
@@ -2634,15 +2722,15 @@ rx_ack_print(register const u_char *bp, int length)
* Print out a few useful things from the ack packet structure
*/
- if (vflag > 2)
- printf(" bufspace %d maxskew %d",
+ if (ndo->ndo_vflag > 2)
+ ND_PRINT((ndo, " bufspace %d maxskew %d",
(int) EXTRACT_16BITS(&rxa->bufferSpace),
- (int) EXTRACT_16BITS(&rxa->maxSkew));
+ (int) EXTRACT_16BITS(&rxa->maxSkew)));
firstPacket = EXTRACT_32BITS(&rxa->firstPacket);
- printf(" first %d serial %d reason %s",
+ ND_PRINT((ndo, " first %d serial %d reason %s",
firstPacket, EXTRACT_32BITS(&rxa->serial),
- tok2str(rx_ack_reasons, "#%d", (int) rxa->reason));
+ tok2str(rx_ack_reasons, "#%d", (int) rxa->reason)));
/*
* Okay, now we print out the ack array. The way _this_ works
@@ -2665,7 +2753,7 @@ rx_ack_print(register const u_char *bp, int length)
if (rxa->nAcks != 0) {
- TCHECK2(bp[0], rxa->nAcks);
+ ND_TCHECK2(bp[0], rxa->nAcks);
/*
* Sigh, this is gross, but it seems to work to collapse
@@ -2683,13 +2771,12 @@ rx_ack_print(register const u_char *bp, int length)
*/
if (last == -2) {
- printf(" acked %d",
- firstPacket + i);
+ ND_PRINT((ndo, " acked %d", firstPacket + i));
start = i;
}
/*
- * Otherwise, if the there is a skip in
+ * Otherwise, if there is a skip in
* the range (such as an nacked packet in
* the middle of some acked packets),
* then print the current packet number
@@ -2698,7 +2785,7 @@ rx_ack_print(register const u_char *bp, int length)
*/
else if (last != i - 1) {
- printf(",%d", firstPacket + i);
+ ND_PRINT((ndo, ",%d", firstPacket + i));
start = i;
}
@@ -2724,7 +2811,7 @@ rx_ack_print(register const u_char *bp, int length)
* range.
*/
} else if (last == i - 1 && start != last)
- printf("-%d", firstPacket + i - 1);
+ ND_PRINT((ndo, "-%d", firstPacket + i - 1));
/*
* So, what's going on here? We ran off the end of the
@@ -2738,7 +2825,7 @@ rx_ack_print(register const u_char *bp, int length)
*/
if (last == i - 1 && start != last)
- printf("-%d", firstPacket + i - 1);
+ ND_PRINT((ndo, "-%d", firstPacket + i - 1));
/*
* Same as above, just without comments
@@ -2747,19 +2834,18 @@ rx_ack_print(register const u_char *bp, int length)
for (i = 0, start = last = -2; i < rxa->nAcks; i++)
if (rxa->acks[i] == RX_ACK_TYPE_NACK) {
if (last == -2) {
- printf(" nacked %d",
- firstPacket + i);
+ ND_PRINT((ndo, " nacked %d", firstPacket + i));
start = i;
} else if (last != i - 1) {
- printf(",%d", firstPacket + i);
+ ND_PRINT((ndo, ",%d", firstPacket + i));
start = i;
}
last = i;
} else if (last == i - 1 && start != last)
- printf("-%d", firstPacket + i - 1);
+ ND_PRINT((ndo, "-%d", firstPacket + i - 1));
if (last == i - 1 && start != last)
- printf("-%d", firstPacket + i - 1);
+ ND_PRINT((ndo, "-%d", firstPacket + i - 1));
bp += rxa->nAcks;
}
@@ -2770,29 +2856,29 @@ rx_ack_print(register const u_char *bp, int length)
* you may or may not see them
*/
-#define TRUNCRET(n) if (snapend - bp + 1 <= n) return;
+#define TRUNCRET(n) if (ndo->ndo_snapend - bp + 1 <= n) return;
- if (vflag > 1) {
+ if (ndo->ndo_vflag > 1) {
TRUNCRET(4);
- printf(" ifmtu");
+ ND_PRINT((ndo, " ifmtu"));
INTOUT();
TRUNCRET(4);
- printf(" maxmtu");
+ ND_PRINT((ndo, " maxmtu"));
INTOUT();
TRUNCRET(4);
- printf(" rwind");
+ ND_PRINT((ndo, " rwind"));
INTOUT();
TRUNCRET(4);
- printf(" maxpackets");
+ ND_PRINT((ndo, " maxpackets"));
INTOUT();
}
return;
trunc:
- printf(" [|ack]");
+ ND_PRINT((ndo, " [|ack]"));
}
#undef TRUNCRET
diff --git a/contrib/tcpdump/print-sctp.c b/contrib/tcpdump/print-sctp.c
index a8990a9ae005..4b595f2e825e 100644
--- a/contrib/tcpdump/print-sctp.c
+++ b/contrib/tcpdump/print-sctp.c
@@ -33,24 +33,13 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
-"@(#) $Header: /tcpdump/master/tcpdump/print-sctp.c,v 1.21 2007-09-13 18:03:49 guy Exp $ (NETLAB/PEL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include "sctpHeader.h"
-#include "sctpConstants.h"
-#include <assert.h>
-
-#include <stdio.h>
-#include <string.h>
-
#include "interface.h"
#include "addrtoname.h"
#include "extract.h" /* must come after interface.h */
@@ -59,17 +48,437 @@ static const char rcsid[] _U_ =
#include "ip6.h"
#endif
+/* Definitions from:
+ *
+ * SCTP reference Implementation Copyright (C) 1999 Cisco And Motorola
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Cisco nor of Motorola may be used
+ * to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the SCTP reference Implementation
+ *
+ *
+ * Please send any bug reports or fixes you make to one of the following email
+ * addresses:
+ *
+ * rstewar1@email.mot.com
+ * kmorneau@cisco.com
+ * qxie1@email.mot.com
+ *
+ * Any bugs reported given to us we will try to fix... any fixes shared will
+ * be incorperated into the next SCTP release.
+ */
+
+/* The valid defines for all message
+ * types know to SCTP. 0 is reserved
+ */
+#define SCTP_DATA 0x00
+#define SCTP_INITIATION 0x01
+#define SCTP_INITIATION_ACK 0x02
+#define SCTP_SELECTIVE_ACK 0x03
+#define SCTP_HEARTBEAT_REQUEST 0x04
+#define SCTP_HEARTBEAT_ACK 0x05
+#define SCTP_ABORT_ASSOCIATION 0x06
+#define SCTP_SHUTDOWN 0x07
+#define SCTP_SHUTDOWN_ACK 0x08
+#define SCTP_OPERATION_ERR 0x09
+#define SCTP_COOKIE_ECHO 0x0a
+#define SCTP_COOKIE_ACK 0x0b
+#define SCTP_ECN_ECHO 0x0c
+#define SCTP_ECN_CWR 0x0d
+#define SCTP_SHUTDOWN_COMPLETE 0x0e
+#define SCTP_FORWARD_CUM_TSN 0xc0
+#define SCTP_RELIABLE_CNTL 0xc1
+#define SCTP_RELIABLE_CNTL_ACK 0xc2
+
+static const struct tok sctp_chunkid_str[] = {
+ { SCTP_DATA, "DATA" },
+ { SCTP_INITIATION, "INIT" },
+ { SCTP_INITIATION_ACK, "INIT ACK" },
+ { SCTP_SELECTIVE_ACK, "SACK" },
+ { SCTP_HEARTBEAT_REQUEST, "HB REQ" },
+ { SCTP_HEARTBEAT_ACK, "HB ACK" },
+ { SCTP_ABORT_ASSOCIATION, "ABORT" },
+ { SCTP_SHUTDOWN, "SHUTDOWN" },
+ { SCTP_SHUTDOWN_ACK, "SHUTDOWN ACK" },
+ { SCTP_OPERATION_ERR, "OP ERR" },
+ { SCTP_COOKIE_ECHO, "COOKIE ECHO" },
+ { SCTP_COOKIE_ACK, "COOKIE ACK" },
+ { SCTP_ECN_ECHO, "ECN ECHO" },
+ { SCTP_ECN_CWR, "ECN CWR" },
+ { SCTP_SHUTDOWN_COMPLETE, "SHUTDOWN COMPLETE" },
+ { SCTP_FORWARD_CUM_TSN, "FOR CUM TSN" },
+ { SCTP_RELIABLE_CNTL, "REL CTRL" },
+ { SCTP_RELIABLE_CNTL_ACK, "REL CTRL ACK" },
+ { 0, NULL }
+};
+
+/* Data Chuck Specific Flags */
+#define SCTP_DATA_FRAG_MASK 0x03
+#define SCTP_DATA_MIDDLE_FRAG 0x00
+#define SCTP_DATA_LAST_FRAG 0x01
+#define SCTP_DATA_FIRST_FRAG 0x02
+#define SCTP_DATA_NOT_FRAG 0x03
+#define SCTP_DATA_UNORDERED 0x04
+
+#define SCTP_ADDRMAX 60
+
#define CHAN_HP 6704
#define CHAN_MP 6705
#define CHAN_LP 6706
-struct tok ForCES_channels[] = {
+/* the sctp common header */
+
+struct sctpHeader{
+ uint16_t source;
+ uint16_t destination;
+ uint32_t verificationTag;
+ uint32_t adler32;
+};
+
+/* various descriptor parsers */
+
+struct sctpChunkDesc{
+ uint8_t chunkID;
+ uint8_t chunkFlg;
+ uint16_t chunkLength;
+};
+
+struct sctpParamDesc{
+ uint16_t paramType;
+ uint16_t paramLength;
+};
+
+
+struct sctpRelChunkDesc{
+ struct sctpChunkDesc chk;
+ uint32_t serialNumber;
+};
+
+struct sctpVendorSpecificParam {
+ struct sctpParamDesc p; /* type must be 0xfffe */
+ uint32_t vendorId; /* vendor ID from RFC 1700 */
+ uint16_t vendorSpecificType;
+ uint16_t vendorSpecificLen;
+};
+
+
+/* Structures for the control parts */
+
+
+
+/* Sctp association init request/ack */
+
+/* this is used for init ack, too */
+struct sctpInitiation{
+ uint32_t initTag; /* tag of mine */
+ uint32_t rcvWindowCredit; /* rwnd */
+ uint16_t NumPreopenStreams; /* OS */
+ uint16_t MaxInboundStreams; /* MIS */
+ uint32_t initialTSN;
+ /* optional param's follow in sctpParamDesc form */
+};
+
+struct sctpV4IpAddress{
+ struct sctpParamDesc p; /* type is set to SCTP_IPV4_PARAM_TYPE, len=10 */
+ uint32_t ipAddress;
+};
+
+
+struct sctpV6IpAddress{
+ struct sctpParamDesc p; /* type is set to SCTP_IPV6_PARAM_TYPE, len=22 */
+ uint8_t ipAddress[16];
+};
+
+struct sctpDNSName{
+ struct sctpParamDesc param;
+ uint8_t name[1];
+};
+
+
+struct sctpCookiePreserve{
+ struct sctpParamDesc p; /* type is set to SCTP_COOKIE_PRESERVE, len=8 */
+ uint32_t extraTime;
+};
+
+
+struct sctpTimeStamp{
+ uint32_t ts_sec;
+ uint32_t ts_usec;
+};
+
+/* wire structure of my cookie */
+struct cookieMessage{
+ uint32_t TieTag_curTag; /* copied from assoc if present */
+ uint32_t TieTag_hisTag; /* copied from assoc if present */
+ int32_t cookieLife; /* life I will award this cookie */
+ struct sctpTimeStamp timeEnteringState; /* the time I built cookie */
+ struct sctpInitiation initAckISent; /* the INIT-ACK that I sent to my peer */
+ uint32_t addressWhereISent[4]; /* I make this 4 ints so I get 128bits for future */
+ int32_t addrtype; /* address type */
+ uint16_t locScope; /* V6 local scope flag */
+ uint16_t siteScope; /* V6 site scope flag */
+ /* at the end is tacked on the INIT chunk sent in
+ * its entirety and of course our
+ * signature.
+ */
+};
+
+
+/* this guy is for use when
+ * I have a initiate message gloming the
+ * things together.
+
+ */
+struct sctpUnifiedInit{
+ struct sctpChunkDesc uh;
+ struct sctpInitiation initm;
+};
+
+struct sctpSendableInit{
+ struct sctpHeader mh;
+ struct sctpUnifiedInit msg;
+};
+
+
+/* Selective Acknowledgement
+ * has the following structure with
+ * a optional ammount of trailing int's
+ * on the last part (based on the numberOfDesc
+ * field).
+ */
+
+struct sctpSelectiveAck{
+ uint32_t highestConseqTSN;
+ uint32_t updatedRwnd;
+ uint16_t numberOfdesc;
+ uint16_t numDupTsns;
+};
+
+struct sctpSelectiveFrag{
+ uint16_t fragmentStart;
+ uint16_t fragmentEnd;
+};
+
+
+struct sctpUnifiedSack{
+ struct sctpChunkDesc uh;
+ struct sctpSelectiveAck sack;
+};
+
+/* for both RTT request/response the
+ * following is sent
+ */
+
+struct sctpHBrequest {
+ uint32_t time_value_1;
+ uint32_t time_value_2;
+};
+
+/* here is what I read and respond with to. */
+struct sctpHBunified{
+ struct sctpChunkDesc hdr;
+ struct sctpParamDesc hb;
+};
+
+
+/* here is what I send */
+struct sctpHBsender{
+ struct sctpChunkDesc hdr;
+ struct sctpParamDesc hb;
+ struct sctpHBrequest rtt;
+ int8_t addrFmt[SCTP_ADDRMAX];
+ uint16_t userreq;
+};
+
+
+
+/* for the abort and shutdown ACK
+ * we must carry the init tag in the common header. Just the
+ * common header is all that is needed with a chunk descriptor.
+ */
+struct sctpUnifiedAbort{
+ struct sctpChunkDesc uh;
+};
+
+struct sctpUnifiedAbortLight{
+ struct sctpHeader mh;
+ struct sctpChunkDesc uh;
+};
+
+struct sctpUnifiedAbortHeavy{
+ struct sctpHeader mh;
+ struct sctpChunkDesc uh;
+ uint16_t causeCode;
+ uint16_t causeLen;
+};
+
+/* For the graceful shutdown we must carry
+ * the tag (in common header) and the highest consequitive acking value
+ */
+struct sctpShutdown {
+ uint32_t TSN_Seen;
+};
+
+struct sctpUnifiedShutdown{
+ struct sctpChunkDesc uh;
+ struct sctpShutdown shut;
+};
+
+/* in the unified message we add the trailing
+ * stream id since it is the only message
+ * that is defined as a operation error.
+ */
+struct sctpOpErrorCause{
+ uint16_t cause;
+ uint16_t causeLen;
+};
+
+struct sctpUnifiedOpError{
+ struct sctpChunkDesc uh;
+ struct sctpOpErrorCause c;
+};
+
+struct sctpUnifiedStreamError{
+ struct sctpHeader mh;
+ struct sctpChunkDesc uh;
+ struct sctpOpErrorCause c;
+ uint16_t strmNum;
+ uint16_t reserved;
+};
+
+struct staleCookieMsg{
+ struct sctpHeader mh;
+ struct sctpChunkDesc uh;
+ struct sctpOpErrorCause c;
+ uint32_t moretime;
+};
+
+/* the following is used in all sends
+ * where nothing is needed except the
+ * chunk/type i.e. shutdownAck Abort */
+
+struct sctpUnifiedSingleMsg{
+ struct sctpHeader mh;
+ struct sctpChunkDesc uh;
+};
+
+struct sctpDataPart{
+ uint32_t TSN;
+ uint16_t streamId;
+ uint16_t sequence;
+ uint32_t payloadtype;
+};
+
+struct sctpUnifiedDatagram{
+ struct sctpChunkDesc uh;
+ struct sctpDataPart dp;
+};
+
+struct sctpECN_echo{
+ struct sctpChunkDesc uh;
+ uint32_t Lowest_TSN;
+};
+
+
+struct sctpCWR{
+ struct sctpChunkDesc uh;
+ uint32_t TSN_reduced_at;
+};
+
+static const struct tok ForCES_channels[] = {
{ CHAN_HP, "ForCES HP" },
{ CHAN_MP, "ForCES MP" },
{ CHAN_LP, "ForCES LP" },
{ 0, NULL }
};
+/* data chunk's payload protocol identifiers */
+
+#define SCTP_PPID_IUA 1
+#define SCTP_PPID_M2UA 2
+#define SCTP_PPID_M3UA 3
+#define SCTP_PPID_SUA 4
+#define SCTP_PPID_M2PA 5
+#define SCTP_PPID_V5UA 6
+#define SCTP_PPID_H248 7
+#define SCTP_PPID_BICC 8
+#define SCTP_PPID_TALI 9
+#define SCTP_PPID_DUA 10
+#define SCTP_PPID_ASAP 11
+#define SCTP_PPID_ENRP 12
+#define SCTP_PPID_H323 13
+#define SCTP_PPID_QIPC 14
+#define SCTP_PPID_SIMCO 15
+#define SCTP_PPID_DDPSC 16
+#define SCTP_PPID_DDPSSC 17
+#define SCTP_PPID_S1AP 18
+#define SCTP_PPID_RUA 19
+#define SCTP_PPID_HNBAP 20
+#define SCTP_PPID_FORCES_HP 21
+#define SCTP_PPID_FORCES_MP 22
+#define SCTP_PPID_FORCES_LP 23
+#define SCTP_PPID_SBC_AP 24
+#define SCTP_PPID_NBAP 25
+/* 26 */
+#define SCTP_PPID_X2AP 27
+
+static const struct tok PayloadProto_idents[] = {
+ { SCTP_PPID_IUA, "ISDN Q.921" },
+ { SCTP_PPID_M2UA, "M2UA" },
+ { SCTP_PPID_M3UA, "M3UA" },
+ { SCTP_PPID_SUA, "SUA" },
+ { SCTP_PPID_M2PA, "M2PA" },
+ { SCTP_PPID_V5UA, "V5.2" },
+ { SCTP_PPID_H248, "H.248" },
+ { SCTP_PPID_BICC, "BICC" },
+ { SCTP_PPID_TALI, "TALI" },
+ { SCTP_PPID_DUA, "DUA" },
+ { SCTP_PPID_ASAP, "ASAP" },
+ { SCTP_PPID_ENRP, "ENRP" },
+ { SCTP_PPID_H323, "H.323" },
+ { SCTP_PPID_QIPC, "Q.IPC" },
+ { SCTP_PPID_SIMCO, "SIMCO" },
+ { SCTP_PPID_DDPSC, "DDPSC" },
+ { SCTP_PPID_DDPSSC, "DDPSSC" },
+ { SCTP_PPID_S1AP, "S1AP" },
+ { SCTP_PPID_RUA, "RUA" },
+ { SCTP_PPID_HNBAP, "HNBAP" },
+ { SCTP_PPID_FORCES_HP, "ForCES HP" },
+ { SCTP_PPID_FORCES_MP, "ForCES MP" },
+ { SCTP_PPID_FORCES_LP, "ForCES LP" },
+ { SCTP_PPID_SBC_AP, "SBc-AP" },
+ { SCTP_PPID_NBAP, "NBAP" },
+ /* 26 */
+ { SCTP_PPID_X2AP, "X2AP" },
+ { 0, NULL }
+};
+
+
static inline int isForCES_port(u_short Port)
{
if (Port == CHAN_HP)
@@ -82,9 +491,10 @@ static inline int isForCES_port(u_short Port)
return 0;
}
-void sctp_print(const u_char *bp, /* beginning of sctp packet */
- const u_char *bp2, /* beginning of enclosing */
- u_int sctpPacketLength) /* ip packet */
+void sctp_print(netdissect_options *ndo,
+ const u_char *bp, /* beginning of sctp packet */
+ const u_char *bp2, /* beginning of enclosing */
+ u_int sctpPacketLength) /* ip packet */
{
const struct sctpHeader *sctpPktHdr;
const struct ip *ip;
@@ -103,8 +513,8 @@ void sctp_print(const u_char *bp, /* beginning of sctp packet */
sctpPktHdr = (const struct sctpHeader*) bp;
endPacketPtr = (const u_char*)sctpPktHdr+sctpPacketLength;
- if( (u_long) endPacketPtr > (u_long) snapend)
- endPacketPtr = (const void *) snapend;
+ if( (u_long) endPacketPtr > (u_long) ndo->ndo_snapend)
+ endPacketPtr = (const void *) ndo->ndo_snapend;
ip = (struct ip *)bp2;
#ifdef INET6
if (IP_V(ip) == 6)
@@ -112,12 +522,12 @@ void sctp_print(const u_char *bp, /* beginning of sctp packet */
else
ip6 = NULL;
#endif /*INET6*/
- TCHECK(*sctpPktHdr);
+ ND_TCHECK(*sctpPktHdr);
if (sctpPacketLength < sizeof(struct sctpHeader))
{
- (void)printf("truncated-sctp - %ld bytes missing!",
- (long)sctpPacketLength-sizeof(struct sctpHeader));
+ ND_PRINT((ndo, "truncated-sctp - %ld bytes missing!",
+ (long)sctpPacketLength-sizeof(struct sctpHeader)));
return;
}
@@ -129,32 +539,31 @@ void sctp_print(const u_char *bp, /* beginning of sctp packet */
#ifdef INET6
if (ip6) {
- (void)printf("%s.%d > %s.%d: sctp",
- ip6addr_string(&ip6->ip6_src),
+ ND_PRINT((ndo, "%s.%d > %s.%d: sctp",
+ ip6addr_string(ndo, &ip6->ip6_src),
sourcePort,
- ip6addr_string(&ip6->ip6_dst),
- destPort);
+ ip6addr_string(ndo, &ip6->ip6_dst),
+ destPort));
} else
#endif /*INET6*/
{
- (void)printf("%s.%d > %s.%d: sctp",
- ipaddr_string(&ip->ip_src),
+ ND_PRINT((ndo, "%s.%d > %s.%d: sctp",
+ ipaddr_string(ndo, &ip->ip_src),
sourcePort,
- ipaddr_string(&ip->ip_dst),
- destPort);
+ ipaddr_string(ndo, &ip->ip_dst),
+ destPort));
}
- fflush(stdout);
if (isForCES_port(sourcePort)) {
- printf("[%s]", tok2str(ForCES_channels, NULL, sourcePort));
+ ND_PRINT((ndo, "[%s]", tok2str(ForCES_channels, NULL, sourcePort)));
isforces = 1;
}
if (isForCES_port(destPort)) {
- printf("[%s]", tok2str(ForCES_channels, NULL, destPort));
+ ND_PRINT((ndo, "[%s]", tok2str(ForCES_channels, NULL, destPort)));
isforces = 1;
}
- if (vflag >= 2)
+ if (ndo->ndo_vflag >= 2)
sep = "\n\t";
else
sep = " (";
@@ -169,18 +578,18 @@ void sctp_print(const u_char *bp, /* beginning of sctp packet */
chunkDescPtr = (const struct sctpChunkDesc *) nextChunk, chunkCount++)
{
- u_int16_t chunkLength;
+ uint16_t chunkLength;
const u_char *chunkEnd;
- u_int16_t align;
+ uint16_t align;
- TCHECK(*chunkDescPtr);
+ ND_TCHECK(*chunkDescPtr);
chunkLength = EXTRACT_16BITS(&chunkDescPtr->chunkLength);
if (chunkLength < sizeof(*chunkDescPtr)) {
- printf("%s%d) [Bad chunk length %u]", sep, chunkCount+1, chunkLength);
- break;
+ ND_PRINT((ndo, "%s%d) [Bad chunk length %u]", sep, chunkCount+1, chunkLength));
+ break;
}
- TCHECK2(*((u_int8_t *)chunkDescPtr), chunkLength);
+ ND_TCHECK2(*((uint8_t *)chunkDescPtr), chunkLength);
chunkEnd = ((const u_char*)chunkDescPtr + chunkLength);
align=chunkLength % 4;
@@ -189,26 +598,29 @@ void sctp_print(const u_char *bp, /* beginning of sctp packet */
nextChunk = (const void *) (chunkEnd + align);
- printf("%s%d) ", sep, chunkCount+1);
+ ND_PRINT((ndo, "%s%d) ", sep, chunkCount+1));
+ ND_PRINT((ndo, "[%s] ", tok2str(sctp_chunkid_str, "Unknown chunk type: 0x%x",
+ chunkDescPtr->chunkID)));
switch (chunkDescPtr->chunkID)
{
case SCTP_DATA :
{
const struct sctpDataPart *dataHdrPtr;
-
- printf("[DATA] ");
+ uint32_t ppid;
+ const u_char *payloadPtr;
+ u_int payload_size;
if ((chunkDescPtr->chunkFlg & SCTP_DATA_UNORDERED)
== SCTP_DATA_UNORDERED)
- printf("(U)");
+ ND_PRINT((ndo, "(U)"));
if ((chunkDescPtr->chunkFlg & SCTP_DATA_FIRST_FRAG)
== SCTP_DATA_FIRST_FRAG)
- printf("(B)");
+ ND_PRINT((ndo, "(B)"));
if ((chunkDescPtr->chunkFlg & SCTP_DATA_LAST_FRAG)
== SCTP_DATA_LAST_FRAG)
- printf("(E)");
+ ND_PRINT((ndo, "(E)"));
if( ((chunkDescPtr->chunkFlg & SCTP_DATA_UNORDERED)
== SCTP_DATA_UNORDERED)
@@ -218,72 +630,68 @@ void sctp_print(const u_char *bp, /* beginning of sctp packet */
||
((chunkDescPtr->chunkFlg & SCTP_DATA_LAST_FRAG)
== SCTP_DATA_LAST_FRAG) )
- printf(" ");
+ ND_PRINT((ndo, " "));
dataHdrPtr=(const struct sctpDataPart*)(chunkDescPtr+1);
- printf("[TSN: %u] ", EXTRACT_32BITS(&dataHdrPtr->TSN));
- printf("[SID: %u] ", EXTRACT_16BITS(&dataHdrPtr->streamId));
- printf("[SSEQ %u] ", EXTRACT_16BITS(&dataHdrPtr->sequence));
- printf("[PPID 0x%x] ", EXTRACT_32BITS(&dataHdrPtr->payloadtype));
- fflush(stdout);
- if (isforces) {
- const u_char *payloadPtr;
- u_int chunksize = sizeof(struct sctpDataPart)+
- sizeof(struct sctpChunkDesc);
- payloadPtr = (const u_char *) (dataHdrPtr + 1);
- if (EXTRACT_16BITS(&chunkDescPtr->chunkLength) <
- sizeof(struct sctpDataPart)+
- sizeof(struct sctpChunkDesc)+1) {
- /* Less than 1 byte of chunk payload */
- printf("bogus ForCES chunk length %u]",
- EXTRACT_16BITS(&chunkDescPtr->chunkLength));
- return;
- }
+ ppid = EXTRACT_32BITS(&dataHdrPtr->payloadtype);
+ ND_PRINT((ndo, "[TSN: %u] ", EXTRACT_32BITS(&dataHdrPtr->TSN)));
+ ND_PRINT((ndo, "[SID: %u] ", EXTRACT_16BITS(&dataHdrPtr->streamId)));
+ ND_PRINT((ndo, "[SSEQ %u] ", EXTRACT_16BITS(&dataHdrPtr->sequence)));
+ ND_PRINT((ndo, "[PPID %s] ",
+ tok2str(PayloadProto_idents, "0x%x", ppid)));
+
+ if (!isforces) {
+ isforces = (ppid == SCTP_PPID_FORCES_HP) ||
+ (ppid == SCTP_PPID_FORCES_MP) ||
+ (ppid == SCTP_PPID_FORCES_LP);
+ }
+
+ payloadPtr = (const u_char *) (dataHdrPtr + 1);
+ if (EXTRACT_16BITS(&chunkDescPtr->chunkLength) <
+ sizeof(struct sctpDataPart) + sizeof(struct sctpChunkDesc) + 1) {
+ ND_PRINT((ndo, "bogus chunk length %u]", EXTRACT_16BITS(&chunkDescPtr->chunkLength)));
+ return;
+ }
+
+ payload_size = EXTRACT_16BITS(&chunkDescPtr->chunkLength) -
+ (sizeof(struct sctpDataPart) + sizeof(struct sctpChunkDesc));
- forces_print(payloadPtr, EXTRACT_16BITS(&chunkDescPtr->chunkLength)- chunksize);
- } else if (vflag >= 2) { /* if verbose output is specified */
+ if (isforces) {
+ forces_print(ndo, payloadPtr, payload_size);
+ } else if (ndo->ndo_vflag >= 2) { /* if verbose output is specified */
/* at the command line */
- const u_char *payloadPtr;
-
- printf("[Payload");
-
- if (!suppress_default_print) {
- payloadPtr = (const u_char *) (++dataHdrPtr);
- printf(":");
- if (EXTRACT_16BITS(&chunkDescPtr->chunkLength) <
- sizeof(struct sctpDataPart)+
- sizeof(struct sctpChunkDesc)+1) {
- /* Less than 1 byte of chunk payload */
- printf("bogus chunk length %u]",
- EXTRACT_16BITS(&chunkDescPtr->chunkLength));
- return;
+ switch (ppid) {
+ case SCTP_PPID_M3UA :
+ m3ua_print(ndo, payloadPtr, payload_size);
+ break;
+ default:
+ ND_PRINT((ndo, "[Payload"));
+ if (!ndo->ndo_suppress_default_print) {
+ ND_PRINT((ndo, ":"));
+ ND_DEFAULTPRINT(payloadPtr, payload_size);
}
- default_print(payloadPtr,
- EXTRACT_16BITS(&chunkDescPtr->chunkLength) -
- (sizeof(struct sctpDataPart)+
- sizeof(struct sctpChunkDesc)));
- } else
- printf("]");
- }
+ ND_PRINT((ndo, "]"));
+ break;
+ }
+ }
break;
}
case SCTP_INITIATION :
{
const struct sctpInitiation *init;
- printf("[INIT] ");
init=(const struct sctpInitiation*)(chunkDescPtr+1);
- printf("[init tag: %u] ", EXTRACT_32BITS(&init->initTag));
- printf("[rwnd: %u] ", EXTRACT_32BITS(&init->rcvWindowCredit));
- printf("[OS: %u] ", EXTRACT_16BITS(&init->NumPreopenStreams));
- printf("[MIS: %u] ", EXTRACT_16BITS(&init->MaxInboundStreams));
- printf("[init TSN: %u] ", EXTRACT_32BITS(&init->initialTSN));
+ ND_PRINT((ndo, "[init tag: %u] ", EXTRACT_32BITS(&init->initTag)));
+ ND_PRINT((ndo, "[rwnd: %u] ", EXTRACT_32BITS(&init->rcvWindowCredit)));
+ ND_PRINT((ndo, "[OS: %u] ", EXTRACT_16BITS(&init->NumPreopenStreams)));
+ ND_PRINT((ndo, "[MIS: %u] ", EXTRACT_16BITS(&init->MaxInboundStreams)));
+ ND_PRINT((ndo, "[init TSN: %u] ", EXTRACT_32BITS(&init->initialTSN)));
#if(0) /* ALC you can add code for optional params here */
if( (init+1) < chunkEnd )
- printf(" @@@@@ UNFINISHED @@@@@@%s\n",
- "Optional params present, but not printed.");
+ ND_PRINT((ndo, " @@@@@ UNFINISHED @@@@@@%s\n",
+ "Optional params present, but not printed."));
#endif
break;
}
@@ -291,18 +699,17 @@ void sctp_print(const u_char *bp, /* beginning of sctp packet */
{
const struct sctpInitiation *init;
- printf("[INIT ACK] ");
init=(const struct sctpInitiation*)(chunkDescPtr+1);
- printf("[init tag: %u] ", EXTRACT_32BITS(&init->initTag));
- printf("[rwnd: %u] ", EXTRACT_32BITS(&init->rcvWindowCredit));
- printf("[OS: %u] ", EXTRACT_16BITS(&init->NumPreopenStreams));
- printf("[MIS: %u] ", EXTRACT_16BITS(&init->MaxInboundStreams));
- printf("[init TSN: %u] ", EXTRACT_32BITS(&init->initialTSN));
+ ND_PRINT((ndo, "[init tag: %u] ", EXTRACT_32BITS(&init->initTag)));
+ ND_PRINT((ndo, "[rwnd: %u] ", EXTRACT_32BITS(&init->rcvWindowCredit)));
+ ND_PRINT((ndo, "[OS: %u] ", EXTRACT_16BITS(&init->NumPreopenStreams)));
+ ND_PRINT((ndo, "[MIS: %u] ", EXTRACT_16BITS(&init->MaxInboundStreams)));
+ ND_PRINT((ndo, "[init TSN: %u] ", EXTRACT_32BITS(&init->initialTSN)));
#if(0) /* ALC you can add code for optional params here */
if( (init+1) < chunkEnd )
- printf(" @@@@@ UNFINISHED @@@@@@%s\n",
- "Optional params present, but not printed.");
+ ND_PRINT((ndo, " @@@@@ UNFINISHED @@@@@@%s\n",
+ "Optional params present, but not printed."));
#endif
break;
}
@@ -313,12 +720,11 @@ void sctp_print(const u_char *bp, /* beginning of sctp packet */
int fragNo, tsnNo;
const u_char *dupTSN;
- printf("[SACK] ");
sack=(const struct sctpSelectiveAck*)(chunkDescPtr+1);
- printf("[cum ack %u] ", EXTRACT_32BITS(&sack->highestConseqTSN));
- printf("[a_rwnd %u] ", EXTRACT_32BITS(&sack->updatedRwnd));
- printf("[#gap acks %u] ", EXTRACT_16BITS(&sack->numberOfdesc));
- printf("[#dup tsns %u] ", EXTRACT_16BITS(&sack->numDupTsns));
+ ND_PRINT((ndo, "[cum ack %u] ", EXTRACT_32BITS(&sack->highestConseqTSN)));
+ ND_PRINT((ndo, "[a_rwnd %u] ", EXTRACT_32BITS(&sack->updatedRwnd)));
+ ND_PRINT((ndo, "[#gap acks %u] ", EXTRACT_16BITS(&sack->numberOfdesc)));
+ ND_PRINT((ndo, "[#dup tsns %u] ", EXTRACT_16BITS(&sack->numDupTsns)));
/* print gaps */
@@ -327,81 +733,28 @@ void sctp_print(const u_char *bp, /* beginning of sctp packet */
fragNo=0;
(const void *)frag < nextChunk && fragNo < EXTRACT_16BITS(&sack->numberOfdesc);
frag++, fragNo++)
- printf("\n\t\t[gap ack block #%d: start = %u, end = %u] ",
+ ND_PRINT((ndo, "\n\t\t[gap ack block #%d: start = %u, end = %u] ",
fragNo+1,
EXTRACT_32BITS(&sack->highestConseqTSN) + EXTRACT_16BITS(&frag->fragmentStart),
- EXTRACT_32BITS(&sack->highestConseqTSN) + EXTRACT_16BITS(&frag->fragmentEnd));
+ EXTRACT_32BITS(&sack->highestConseqTSN) + EXTRACT_16BITS(&frag->fragmentEnd)));
/* print duplicate TSNs */
for (dupTSN = (const u_char *)frag, tsnNo=0;
(const void *) dupTSN < nextChunk && tsnNo<EXTRACT_16BITS(&sack->numDupTsns);
dupTSN += 4, tsnNo++)
- printf("\n\t\t[dup TSN #%u: %u] ", tsnNo+1,
- EXTRACT_32BITS(dupTSN));
+ ND_PRINT((ndo, "\n\t\t[dup TSN #%u: %u] ", tsnNo+1,
+ EXTRACT_32BITS(dupTSN)));
break;
}
- case SCTP_HEARTBEAT_REQUEST :
- {
- const struct sctpHBsender *hb;
-
- hb=(const struct sctpHBsender*)chunkDescPtr;
-
- printf("[HB REQ] ");
-
- break;
- }
- case SCTP_HEARTBEAT_ACK :
- printf("[HB ACK] ");
- break;
- case SCTP_ABORT_ASSOCIATION :
- printf("[ABORT] ");
- break;
- case SCTP_SHUTDOWN :
- printf("[SHUTDOWN] ");
- break;
- case SCTP_SHUTDOWN_ACK :
- printf("[SHUTDOWN ACK] ");
- break;
- case SCTP_OPERATION_ERR :
- printf("[OP ERR] ");
- break;
- case SCTP_COOKIE_ECHO :
- printf("[COOKIE ECHO] ");
- break;
- case SCTP_COOKIE_ACK :
- printf("[COOKIE ACK] ");
- break;
- case SCTP_ECN_ECHO :
- printf("[ECN ECHO] ");
- break;
- case SCTP_ECN_CWR :
- printf("[ECN CWR] ");
- break;
- case SCTP_SHUTDOWN_COMPLETE :
- printf("[SHUTDOWN COMPLETE] ");
- break;
- case SCTP_FORWARD_CUM_TSN :
- printf("[FOR CUM TSN] ");
- break;
- case SCTP_RELIABLE_CNTL :
- printf("[REL CTRL] ");
- break;
- case SCTP_RELIABLE_CNTL_ACK :
- printf("[REL CTRL ACK] ");
- break;
- default :
- printf("[Unknown chunk type: 0x%x]", chunkDescPtr->chunkID);
- return;
}
- if (vflag < 2)
+ if (ndo->ndo_vflag < 2)
sep = ", (";
}
return;
trunc:
- printf("[|sctp]");
- return;
+ ND_PRINT((ndo, "[|sctp]"));
}
diff --git a/contrib/tcpdump/print-sflow.c b/contrib/tcpdump/print-sflow.c
index 79a3fdf1d9c7..da72848d15f7 100644
--- a/contrib/tcpdump/print-sflow.c
+++ b/contrib/tcpdump/print-sflow.c
@@ -19,28 +19,20 @@
* Expansion and refactoring by Rick Jones <rick.jones2@hp.com>
*/
-#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
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
#include "interface.h"
#include "extract.h"
#include "addrtoname.h"
-/*
+/*
* 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
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -58,22 +50,22 @@ static const char rcsid[] _U_ =
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | 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];
+ uint8_t version[4];
+ uint8_t ip_version[4];
+ uint8_t agent[4];
+ uint8_t agent_id[4];
+ uint8_t seqnum[4];
+ uint8_t uptime[4];
+ uint8_t samples[4];
};
struct sflow_sample_header {
- u_int8_t format[4];
- u_int8_t len[4];
+ uint8_t format[4];
+ uint8_t len[4];
};
#define SFLOW_FLOW_SAMPLE 1
@@ -90,29 +82,29 @@ static const struct tok sflow_format_values[] = {
};
struct sflow_flow_sample_t {
- u_int8_t seqnum[4];
- u_int8_t typesource[4];
- u_int8_t rate[4];
- u_int8_t pool[4];
- u_int8_t drops[4];
- u_int8_t in_interface[4];
- u_int8_t out_interface[4];
- u_int8_t records[4];
+ uint8_t seqnum[4];
+ uint8_t typesource[4];
+ uint8_t rate[4];
+ uint8_t pool[4];
+ uint8_t drops[4];
+ uint8_t in_interface[4];
+ uint8_t out_interface[4];
+ uint8_t records[4];
};
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];
+ uint8_t seqnum[4];
+ uint8_t type[4];
+ uint8_t index[4];
+ uint8_t rate[4];
+ uint8_t pool[4];
+ uint8_t drops[4];
+ uint8_t in_interface_format[4];
+ uint8_t in_interface_value[4];
+ uint8_t out_interface_format[4];
+ uint8_t out_interface_value[4];
+ uint8_t records[4];
};
#define SFLOW_FLOW_RAW_PACKET 1
@@ -162,49 +154,49 @@ static const struct tok sflow_flow_raw_protocol_values[] = {
{ 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];
+ uint8_t protocol[4];
+ uint8_t length[4];
+ uint8_t stripped_bytes[4];
+ uint8_t header_size[4];
};
struct sflow_ethernet_frame_t {
- u_int8_t length[4];
- u_int8_t src_mac[8];
- u_int8_t dst_mac[8];
- u_int8_t type[4];
+ uint8_t length[4];
+ uint8_t src_mac[8];
+ uint8_t dst_mac[8];
+ uint8_t type[4];
};
struct sflow_extended_switch_data_t {
- u_int8_t src_vlan[4];
- u_int8_t src_pri[4];
- u_int8_t dst_vlan[4];
- u_int8_t dst_pri[4];
+ uint8_t src_vlan[4];
+ uint8_t src_pri[4];
+ uint8_t dst_vlan[4];
+ uint8_t dst_pri[4];
};
struct sflow_counter_record_t {
- u_int8_t format[4];
- u_int8_t length[4];
+ uint8_t format[4];
+ uint8_t length[4];
};
struct sflow_flow_record_t {
- u_int8_t format[4];
- u_int8_t length[4];
+ uint8_t format[4];
+ uint8_t length[4];
};
struct sflow_counter_sample_t {
- u_int8_t seqnum[4];
- u_int8_t typesource[4];
- u_int8_t records[4];
+ uint8_t seqnum[4];
+ uint8_t typesource[4];
+ uint8_t records[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];
+ uint8_t seqnum[4];
+ uint8_t type[4];
+ uint8_t index[4];
+ uint8_t records[4];
};
#define SFLOW_COUNTER_GENERIC 1
@@ -237,74 +229,75 @@ static const struct tok sflow_iface_direction_values[] = {
{ 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];
+ uint8_t ifindex[4];
+ uint8_t iftype[4];
+ uint8_t ifspeed[8];
+ uint8_t ifdirection[4];
+ uint8_t ifstatus[4];
+ uint8_t ifinoctets[8];
+ uint8_t ifinunicastpkts[4];
+ uint8_t ifinmulticastpkts[4];
+ uint8_t ifinbroadcastpkts[4];
+ uint8_t ifindiscards[4];
+ uint8_t ifinerrors[4];
+ uint8_t ifinunkownprotos[4];
+ uint8_t ifoutoctets[8];
+ uint8_t ifoutunicastpkts[4];
+ uint8_t ifoutmulticastpkts[4];
+ uint8_t ifoutbroadcastpkts[4];
+ uint8_t ifoutdiscards[4];
+ uint8_t ifouterrors[4];
+ uint8_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];
+ uint8_t alignerrors[4];
+ uint8_t fcserrors[4];
+ uint8_t single_collision_frames[4];
+ uint8_t multiple_collision_frames[4];
+ uint8_t test_errors[4];
+ uint8_t deferred_transmissions[4];
+ uint8_t late_collisions[4];
+ uint8_t excessive_collisions[4];
+ uint8_t mac_transmit_errors[4];
+ uint8_t carrier_sense_errors[4];
+ uint8_t frame_too_longs[4];
+ uint8_t mac_receive_errors[4];
+ uint8_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];
+ uint8_t in_highpriority_frames[4];
+ uint8_t in_highpriority_octets[8];
+ uint8_t in_normpriority_frames[4];
+ uint8_t in_normpriority_octets[8];
+ uint8_t in_ipmerrors[4];
+ uint8_t in_oversized[4];
+ uint8_t in_data_errors[4];
+ uint8_t in_null_addressed_frames[4];
+ uint8_t out_highpriority_frames[4];
+ uint8_t out_highpriority_octets[8];
+ uint8_t transitioninto_frames[4];
+ uint8_t hc_in_highpriority_octets[8];
+ uint8_t hc_in_normpriority_octets[8];
+ uint8_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];
+ uint8_t vlan_id[4];
+ uint8_t octets[8];
+ uint8_t unicast_pkt[4];
+ uint8_t multicast_pkt[4];
+ uint8_t broadcast_pkt[4];
+ uint8_t discards[4];
};
static int
-print_sflow_counter_generic(const u_char *pointer, u_int len) {
+print_sflow_counter_generic(netdissect_options *ndo,
+ const u_char *pointer, u_int len) {
const struct sflow_generic_counter_t *sflow_gen_counter;
@@ -313,43 +306,44 @@ print_sflow_counter_generic(const u_char *pointer, u_int len) {
sflow_gen_counter = (const struct sflow_generic_counter_t *)pointer;
- printf("\n\t ifindex %u, iftype %u, ifspeed %" PRIu64 ", ifdirection %u (%s)",
+ ND_PRINT((ndo, "\n\t ifindex %u, iftype %u, ifspeed %" PRIu64 ", ifdirection %u (%s)",
EXTRACT_32BITS(sflow_gen_counter->ifindex),
EXTRACT_32BITS(sflow_gen_counter->iftype),
EXTRACT_64BITS(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->ifdirection))));
+ ND_PRINT((ndo, "\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
+ (EXTRACT_32BITS(sflow_gen_counter->ifstatus)>>1)&1 ? "up" : "down"));
+ ND_PRINT((ndo, "\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->ifindiscards)));
+ ND_PRINT((ndo, "\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
+ EXTRACT_32BITS(sflow_gen_counter->ifinunkownprotos)));
+ ND_PRINT((ndo, "\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->ifoutdiscards)));
+ ND_PRINT((ndo, "\n\t Out errors %u, promisc mode %u",
EXTRACT_32BITS(sflow_gen_counter->ifouterrors),
- EXTRACT_32BITS(sflow_gen_counter->ifpromiscmode));
+ EXTRACT_32BITS(sflow_gen_counter->ifpromiscmode)));
return 0;
}
static int
-print_sflow_counter_ethernet(const u_char *pointer, u_int len){
+print_sflow_counter_ethernet(netdissect_options *ndo,
+ const u_char *pointer, u_int len){
const struct sflow_ethernet_counter_t *sflow_eth_counter;
@@ -357,34 +351,36 @@ print_sflow_counter_ethernet(const u_char *pointer, u_int len){
return 1;
sflow_eth_counter = (const struct sflow_ethernet_counter_t *)pointer;
- printf("\n\t align errors %u, fcs errors %u, single collision %u, multiple collision %u, test error %u",
+ ND_PRINT((ndo, "\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->test_errors)));
+ ND_PRINT((ndo, "\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->mac_transmit_errors)));
+ ND_PRINT((ndo, "\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));
+ EXTRACT_32BITS(sflow_eth_counter->symbol_errors)));
return 0;
}
static int
-print_sflow_counter_token_ring(const u_char *pointer _U_, u_int len _U_) {
+print_sflow_counter_token_ring(netdissect_options *ndo _U_,
+ const u_char *pointer _U_, u_int len _U_) {
return 0;
}
static int
-print_sflow_counter_basevg(const u_char *pointer, u_int len) {
+print_sflow_counter_basevg(netdissect_options *ndo,
+ const u_char *pointer, u_int len) {
const struct sflow_100basevg_counter_t *sflow_100basevg_counter;
@@ -392,63 +388,65 @@ print_sflow_counter_basevg(const u_char *pointer, u_int len) {
return 1;
sflow_100basevg_counter = (const struct sflow_100basevg_counter_t *)pointer;
- printf("\n\t in high prio frames %u, in high prio octets %" PRIu64,
+ ND_PRINT((ndo, "\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_64BITS(sflow_100basevg_counter->in_highpriority_octets)));
+ ND_PRINT((ndo, "\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_64BITS(sflow_100basevg_counter->in_normpriority_octets)));
+ ND_PRINT((ndo, "\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
+ EXTRACT_32BITS(sflow_100basevg_counter->in_null_addressed_frames)));
+ ND_PRINT((ndo, "\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
+ EXTRACT_32BITS(sflow_100basevg_counter->transitioninto_frames)));
+ ND_PRINT((ndo, "\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));
+ EXTRACT_64BITS(sflow_100basevg_counter->hc_out_highpriority_octets)));
return 0;
}
static int
-print_sflow_counter_vlan(const u_char *pointer, u_int len) {
+print_sflow_counter_vlan(netdissect_options *ndo,
+ const u_char *pointer, u_int len) {
const struct sflow_vlan_counter_t *sflow_vlan_counter;
-
+
if (len < sizeof(struct sflow_vlan_counter_t))
return 1;
sflow_vlan_counter = (const struct sflow_vlan_counter_t *)pointer;
- printf("\n\t vlan_id %u, octets %" PRIu64
+ ND_PRINT((ndo, "\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));
+ EXTRACT_32BITS(sflow_vlan_counter->discards)));
return 0;
}
struct sflow_processor_counter_t {
- u_int8_t five_sec_util[4];
- u_int8_t one_min_util[4];
- u_int8_t five_min_util[4];
- u_int8_t total_memory[8];
- u_int8_t free_memory[8];
+ uint8_t five_sec_util[4];
+ uint8_t one_min_util[4];
+ uint8_t five_min_util[4];
+ uint8_t total_memory[8];
+ uint8_t free_memory[8];
};
static int
-print_sflow_counter_processor(const u_char *pointer, u_int len) {
+print_sflow_counter_processor(netdissect_options *ndo,
+ const u_char *pointer, u_int len) {
const struct sflow_processor_counter_t *sflow_processor_counter;
@@ -456,19 +454,20 @@ print_sflow_counter_processor(const u_char *pointer, u_int len) {
return 1;
sflow_processor_counter = (const struct sflow_processor_counter_t *)pointer;
- printf("\n\t 5sec %u, 1min %u, 5min %u, total_mem %" PRIu64
+ ND_PRINT((ndo, "\n\t 5sec %u, 1min %u, 5min %u, total_mem %" PRIu64
", total_mem %" PRIu64,
EXTRACT_32BITS(sflow_processor_counter->five_sec_util),
EXTRACT_32BITS(sflow_processor_counter->one_min_util),
EXTRACT_32BITS(sflow_processor_counter->five_min_util),
EXTRACT_64BITS(sflow_processor_counter->total_memory),
- EXTRACT_64BITS(sflow_processor_counter->free_memory));
+ EXTRACT_64BITS(sflow_processor_counter->free_memory)));
return 0;
}
static int
-sflow_print_counter_records(const u_char *pointer, u_int len, u_int records) {
+sflow_print_counter_records(netdissect_options *ndo,
+ const u_char *pointer, u_int len, u_int records) {
u_int nrecords;
const u_char *tptr;
@@ -492,11 +491,11 @@ sflow_print_counter_records(const u_char *pointer, u_int len, u_int records) {
counter_type = enterprise & 0x0FFF;
enterprise = enterprise >> 20;
counter_len = EXTRACT_32BITS(sflow_counter_record->length);
- printf("\n\t enterprise %u, %s (%u) length %u",
+ ND_PRINT((ndo, "\n\t enterprise %u, %s (%u) length %u",
enterprise,
(enterprise == 0) ? tok2str(sflow_counter_type_values,"Unknown",counter_type) : "Unknown",
counter_type,
- counter_len);
+ counter_len));
tptr += sizeof(struct sflow_counter_record_t);
tlen -= sizeof(struct sflow_counter_record_t);
@@ -506,39 +505,39 @@ sflow_print_counter_records(const u_char *pointer, u_int len, u_int records) {
if (enterprise == 0) {
switch (counter_type) {
case SFLOW_COUNTER_GENERIC:
- if (print_sflow_counter_generic(tptr,tlen))
+ if (print_sflow_counter_generic(ndo, tptr, tlen))
return 1;
break;
case SFLOW_COUNTER_ETHERNET:
- if (print_sflow_counter_ethernet(tptr,tlen))
+ if (print_sflow_counter_ethernet(ndo, tptr, tlen))
return 1;
break;
case SFLOW_COUNTER_TOKEN_RING:
- if (print_sflow_counter_token_ring(tptr,tlen))
+ if (print_sflow_counter_token_ring(ndo, tptr,tlen))
return 1;
break;
case SFLOW_COUNTER_BASEVG:
- if (print_sflow_counter_basevg(tptr,tlen))
+ if (print_sflow_counter_basevg(ndo, tptr, tlen))
return 1;
break;
case SFLOW_COUNTER_VLAN:
- if (print_sflow_counter_vlan(tptr,tlen))
+ if (print_sflow_counter_vlan(ndo, tptr, tlen))
return 1;
break;
case SFLOW_COUNTER_PROCESSOR:
- if (print_sflow_counter_processor(tptr,tlen))
+ if (print_sflow_counter_processor(ndo, tptr, tlen))
return 1;
break;
default:
- if (vflag <= 1)
- print_unknown_data(tptr, "\n\t\t", counter_len);
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo, tptr, "\n\t\t", counter_len);
break;
}
}
tptr += counter_len;
tlen -= counter_len;
nrecords--;
-
+
}
return 0;
@@ -546,7 +545,8 @@ sflow_print_counter_records(const u_char *pointer, u_int len, u_int records) {
static int
-sflow_print_counter_sample(const u_char *pointer, u_int len) {
+sflow_print_counter_sample(netdissect_options *ndo,
+ const u_char *pointer, u_int len) {
const struct sflow_counter_sample_t *sflow_counter_sample;
u_int nrecords;
@@ -564,21 +564,22 @@ sflow_print_counter_sample(const u_char *pointer, u_int len) {
nrecords = EXTRACT_32BITS(sflow_counter_sample->records);
type = typesource >> 24;
index = typesource & 0x0FFF;
-
- printf(" seqnum %u, type %u, idx %u, records %u",
+
+ ND_PRINT((ndo, " seqnum %u, type %u, idx %u, records %u",
EXTRACT_32BITS(sflow_counter_sample->seqnum),
type,
index,
- nrecords);
+ nrecords));
- return sflow_print_counter_records(pointer + sizeof(struct sflow_counter_sample_t),
+ return sflow_print_counter_records(ndo, pointer + sizeof(struct sflow_counter_sample_t),
len - sizeof(struct sflow_counter_sample_t),
nrecords);
}
static int
-sflow_print_expanded_counter_sample(const u_char *pointer, u_int len) {
+sflow_print_expanded_counter_sample(netdissect_options *ndo,
+ const u_char *pointer, u_int len) {
const struct sflow_expanded_counter_sample_t *sflow_expanded_counter_sample;
u_int nrecords;
@@ -591,20 +592,21 @@ sflow_print_expanded_counter_sample(const u_char *pointer, u_int len) {
nrecords = EXTRACT_32BITS(sflow_expanded_counter_sample->records);
- printf(" seqnum %u, type %u, idx %u, records %u",
+ ND_PRINT((ndo, " 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);
-
- return sflow_print_counter_records(pointer + sizeof(struct sflow_expanded_counter_sample_t),
+ nrecords));
+
+ return sflow_print_counter_records(ndo, pointer + sizeof(struct sflow_expanded_counter_sample_t),
len - sizeof(struct sflow_expanded_counter_sample_t),
nrecords);
}
static int
-print_sflow_raw_packet(const u_char *pointer, u_int len) {
+print_sflow_raw_packet(netdissect_options *ndo,
+ const u_char *pointer, u_int len) {
const struct sflow_expanded_flow_raw_t *sflow_flow_raw;
@@ -612,12 +614,12 @@ print_sflow_raw_packet(const u_char *pointer, u_int len) {
return 1;
sflow_flow_raw = (const struct sflow_expanded_flow_raw_t *)pointer;
- printf("\n\t protocol %s (%u), length %u, stripped bytes %u, header_size %u",
+ ND_PRINT((ndo, "\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));
+ EXTRACT_32BITS(sflow_flow_raw->header_size)));
/* QUESTION - should we attempt to print the raw header itself?
assuming of course there is wnough data present to do so... */
@@ -626,7 +628,8 @@ print_sflow_raw_packet(const u_char *pointer, u_int len) {
}
static int
-print_sflow_ethernet_frame(const u_char *pointer, u_int len) {
+print_sflow_ethernet_frame(netdissect_options *ndo,
+ const u_char *pointer, u_int len) {
const struct sflow_ethernet_frame_t *sflow_ethernet_frame;
@@ -635,15 +638,16 @@ print_sflow_ethernet_frame(const u_char *pointer, u_int len) {
sflow_ethernet_frame = (const struct sflow_ethernet_frame_t *)pointer;
- printf("\n\t frame len %u, type %u",
+ ND_PRINT((ndo, "\n\t frame len %u, type %u",
EXTRACT_32BITS(sflow_ethernet_frame->length),
- EXTRACT_32BITS(sflow_ethernet_frame->type));
+ EXTRACT_32BITS(sflow_ethernet_frame->type)));
return 0;
}
static int
-print_sflow_extended_switch_data(const u_char *pointer, u_int len) {
+print_sflow_extended_switch_data(netdissect_options *ndo,
+ const u_char *pointer, u_int len) {
const struct sflow_extended_switch_data_t *sflow_extended_sw_data;
@@ -651,17 +655,18 @@ print_sflow_extended_switch_data(const u_char *pointer, u_int len) {
return 1;
sflow_extended_sw_data = (const struct sflow_extended_switch_data_t *)pointer;
- printf("\n\t src vlan %u, src pri %u, dst vlan %u, dst pri %u",
+ ND_PRINT((ndo, "\n\t src vlan %u, src pri %u, dst vlan %u, dst pri %u",
EXTRACT_32BITS(sflow_extended_sw_data->src_vlan),
EXTRACT_32BITS(sflow_extended_sw_data->src_pri),
EXTRACT_32BITS(sflow_extended_sw_data->dst_vlan),
- EXTRACT_32BITS(sflow_extended_sw_data->dst_pri));
+ EXTRACT_32BITS(sflow_extended_sw_data->dst_pri)));
return 0;
}
static int
-sflow_print_flow_records(const u_char *pointer, u_int len, u_int records) {
+sflow_print_flow_records(netdissect_options *ndo,
+ const u_char *pointer, u_int len, u_int records) {
u_int nrecords;
const u_char *tptr;
@@ -684,16 +689,16 @@ sflow_print_flow_records(const u_char *pointer, u_int len, u_int records) {
/* so, the funky encoding means we cannot blythly mask-off
bits, we must also check the enterprise. */
-
+
enterprise = EXTRACT_32BITS(sflow_flow_record->format);
flow_type = enterprise & 0x0FFF;
enterprise = enterprise >> 12;
flow_len = EXTRACT_32BITS(sflow_flow_record->length);
- printf("\n\t enterprise %u %s (%u) length %u",
+ ND_PRINT((ndo, "\n\t enterprise %u %s (%u) length %u",
enterprise,
(enterprise == 0) ? tok2str(sflow_flow_type_values,"Unknown",flow_type) : "Unknown",
flow_type,
- flow_len);
+ flow_len));
tptr += sizeof(struct sflow_flow_record_t);
tlen -= sizeof(struct sflow_flow_record_t);
@@ -704,15 +709,15 @@ sflow_print_flow_records(const u_char *pointer, u_int len, u_int records) {
if (enterprise == 0) {
switch (flow_type) {
case SFLOW_FLOW_RAW_PACKET:
- if (print_sflow_raw_packet(tptr,tlen))
+ if (print_sflow_raw_packet(ndo, tptr, tlen))
return 1;
break;
case SFLOW_FLOW_EXTENDED_SWITCH_DATA:
- if (print_sflow_extended_switch_data(tptr,tlen))
+ if (print_sflow_extended_switch_data(ndo, tptr, tlen))
return 1;
break;
case SFLOW_FLOW_ETHERNET_FRAME:
- if (print_sflow_ethernet_frame(tptr,tlen))
+ if (print_sflow_ethernet_frame(ndo, tptr, tlen))
return 1;
break;
/* FIXME these need a decoder */
@@ -731,8 +736,8 @@ sflow_print_flow_records(const u_char *pointer, u_int len, u_int records) {
case SFLOW_FLOW_EXTENDED_VLAN_TUNNEL:
break;
default:
- if (vflag <= 1)
- print_unknown_data(tptr, "\n\t\t", flow_len);
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo, tptr, "\n\t\t", flow_len);
break;
}
}
@@ -746,7 +751,8 @@ sflow_print_flow_records(const u_char *pointer, u_int len, u_int records) {
}
static int
-sflow_print_flow_sample(const u_char *pointer, u_int len) {
+sflow_print_flow_sample(netdissect_options *ndo,
+ const u_char *pointer, u_int len) {
const struct sflow_flow_sample_t *sflow_flow_sample;
u_int nrecords;
@@ -764,7 +770,7 @@ sflow_print_flow_sample(const u_char *pointer, u_int len) {
type = typesource >> 24;
index = typesource & 0x0FFF;
- printf(" seqnum %u, type %u, idx %u, rate %u, pool %u, drops %u, input %u output %u records %u",
+ ND_PRINT((ndo, " seqnum %u, type %u, idx %u, rate %u, pool %u, drops %u, input %u output %u records %u",
EXTRACT_32BITS(sflow_flow_sample->seqnum),
type,
index,
@@ -773,16 +779,17 @@ sflow_print_flow_sample(const u_char *pointer, u_int len) {
EXTRACT_32BITS(sflow_flow_sample->drops),
EXTRACT_32BITS(sflow_flow_sample->in_interface),
EXTRACT_32BITS(sflow_flow_sample->out_interface),
- nrecords);
+ nrecords));
- return sflow_print_flow_records(pointer + sizeof(struct sflow_flow_sample_t),
+ return sflow_print_flow_records(ndo, pointer + sizeof(struct sflow_flow_sample_t),
len - sizeof(struct sflow_flow_sample_t),
nrecords);
}
static int
-sflow_print_expanded_flow_sample(const u_char *pointer, u_int len) {
+sflow_print_expanded_flow_sample(netdissect_options *ndo,
+ const u_char *pointer, u_int len) {
const struct sflow_expanded_flow_sample_t *sflow_expanded_flow_sample;
u_int nrecords;
@@ -794,68 +801,69 @@ sflow_print_expanded_flow_sample(const u_char *pointer, u_int len) {
nrecords = EXTRACT_32BITS(sflow_expanded_flow_sample->records);
- printf(" seqnum %u, type %u, idx %u, rate %u, pool %u, drops %u, records %u",
+ ND_PRINT((ndo, " 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));
-
- return sflow_print_flow_records(pointer + sizeof(struct sflow_expanded_flow_sample_t),
+ EXTRACT_32BITS(sflow_expanded_flow_sample->records)));
+
+ return sflow_print_flow_records(ndo, pointer + sizeof(struct sflow_expanded_flow_sample_t),
len - sizeof(struct sflow_expanded_flow_sample_t),
nrecords);
}
void
-sflow_print(const u_char *pptr, u_int len) {
+sflow_print(netdissect_options *ndo,
+ const u_char *pptr, u_int len) {
const struct sflow_datagram_t *sflow_datagram;
const struct sflow_sample_header *sflow_sample;
const u_char *tptr;
u_int tlen;
- u_int32_t sflow_sample_type, sflow_sample_len;
- u_int32_t nsamples;
+ uint32_t sflow_sample_type, sflow_sample_len;
+ uint32_t nsamples;
tptr = pptr;
tlen = len;
sflow_datagram = (const struct sflow_datagram_t *)pptr;
- TCHECK(*sflow_datagram);
+ ND_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));
+ ND_PRINT((ndo, "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",
+ if (ndo->ndo_vflag < 1) {
+ ND_PRINT((ndo, "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);
+ ipaddr_string(ndo, sflow_datagram->agent),
+ EXTRACT_32BITS(sflow_datagram->agent_id),
+ 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",
+ ND_PRINT((ndo, "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),
+ ipaddr_string(ndo, sflow_datagram->agent),
EXTRACT_32BITS(sflow_datagram->agent_id),
EXTRACT_32BITS(sflow_datagram->seqnum),
EXTRACT_32BITS(sflow_datagram->uptime),
nsamples,
- len);
+ len));
/* skip Common header */
tptr += sizeof(const struct sflow_datagram_t);
@@ -863,7 +871,7 @@ sflow_print(const u_char *pptr, u_int len) {
while (nsamples > 0 && tlen > 0) {
sflow_sample = (const struct sflow_sample_header *)tptr;
- TCHECK(*sflow_sample);
+ ND_TCHECK(*sflow_sample);
sflow_sample_type = (EXTRACT_32BITS(sflow_sample->format)&0x0FFF);
sflow_sample_len = EXTRACT_32BITS(sflow_sample->len);
@@ -873,11 +881,11 @@ sflow_print(const u_char *pptr, u_int len) {
tptr += sizeof(struct sflow_sample_header);
tlen -= sizeof(struct sflow_sample_header);
-
- printf("\n\t%s (%u), length %u,",
+
+ ND_PRINT((ndo, "\n\t%s (%u), length %u,",
tok2str(sflow_format_values, "Unknown", sflow_sample_type),
sflow_sample_type,
- sflow_sample_len);
+ sflow_sample_len));
/* basic sanity check */
if (sflow_sample_type == 0 || sflow_sample_len ==0) {
@@ -888,32 +896,32 @@ sflow_print(const u_char *pptr, u_int len) {
goto trunc;
/* did we capture enough for fully decoding the sample ? */
- TCHECK2(*tptr, sflow_sample_len);
+ ND_TCHECK2(*tptr, sflow_sample_len);
switch(sflow_sample_type) {
case SFLOW_FLOW_SAMPLE:
- if (sflow_print_flow_sample(tptr,tlen))
+ if (sflow_print_flow_sample(ndo, tptr, tlen))
goto trunc;
break;
case SFLOW_COUNTER_SAMPLE:
- if (sflow_print_counter_sample(tptr,tlen))
+ if (sflow_print_counter_sample(ndo, tptr,tlen))
goto trunc;
break;
case SFLOW_EXPANDED_FLOW_SAMPLE:
- if (sflow_print_expanded_flow_sample(tptr,tlen))
+ if (sflow_print_expanded_flow_sample(ndo, tptr, tlen))
goto trunc;
break;
case SFLOW_EXPANDED_COUNTER_SAMPLE:
- if (sflow_print_expanded_counter_sample(tptr,tlen))
+ if (sflow_print_expanded_counter_sample(ndo, tptr,tlen))
goto trunc;
break;
default:
- if (vflag <= 1)
- print_unknown_data(tptr, "\n\t ", sflow_sample_len);
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo, tptr, "\n\t ", sflow_sample_len);
break;
}
tptr += sflow_sample_len;
@@ -923,7 +931,7 @@ sflow_print(const u_char *pptr, u_int len) {
return;
trunc:
- printf("[|SFLOW]");
+ ND_PRINT((ndo, "[|SFLOW]"));
}
/*
diff --git a/contrib/tcpdump/print-sip.c b/contrib/tcpdump/print-sip.c
index c5bc8534daaa..540cbf424267 100644
--- a/contrib/tcpdump/print-sip.c
+++ b/contrib/tcpdump/print-sip.c
@@ -13,52 +13,44 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#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 $";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <stdlib.h>
-
#include "interface.h"
#include "extract.h"
-#include "udp.h"
-
void
-sip_print(register const u_char *pptr, register u_int len)
+sip_print(netdissect_options *ndo,
+ register const u_char *pptr, register u_int len)
{
u_int idx;
- printf("SIP, length: %u%s", len, vflag ? "\n\t" : "");
+ ND_PRINT((ndo, "SIP, length: %u%s", len, ndo->ndo_vflag ? "\n\t" : ""));
/* in non-verbose mode just lets print the protocol and length */
- if (vflag < 1)
+ if (ndo->ndo_vflag < 1)
return;
for (idx = 0; idx < len; idx++) {
- TCHECK2(*(pptr+idx), 2);
+ ND_TCHECK2(*(pptr+idx), 2);
if (EXTRACT_16BITS(pptr+idx) != 0x0d0a) { /* linefeed ? */
- safeputchar(*(pptr+idx));
+ safeputchar(ndo, *(pptr + idx));
} else {
- printf("\n\t");
+ ND_PRINT((ndo, "\n\t"));
idx+=1;
}
}
/* do we want to see an additionally hexdump ? */
- if (vflag> 1)
- print_unknown_data(pptr,"\n\t",len);
+ if (ndo->ndo_vflag > 1)
+ print_unknown_data(ndo, pptr, "\n\t", len);
return;
trunc:
- printf("[|sip]");
+ ND_PRINT((ndo, "[|sip]"));
}
diff --git a/contrib/tcpdump/print-sl.c b/contrib/tcpdump/print-sl.c
index 3d649a665367..40a1ed5daeac 100644
--- a/contrib/tcpdump/print-sl.c
+++ b/contrib/tcpdump/print-sl.c
@@ -21,44 +21,51 @@
* $FreeBSD$
*/
-#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)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <pcap.h>
-#include <stdio.h>
-
#include "interface.h"
-#include "addrtoname.h"
#include "extract.h" /* must come after interface.h */
#include "ip.h"
#include "tcp.h"
-#include "slip.h"
#include "slcompress.h"
+/*
+ * definitions of the pseudo- link-level header attached to slip
+ * packets grabbed by the packet filter (bpf) traffic monitor.
+ */
+#define SLIP_HDRLEN 16
+
+#define SLX_DIR 0
+#define SLX_CHDR 1
+#define CHDR_LEN 15
+
+#define SLIPDIR_IN 0
+#define SLIPDIR_OUT 1
+
+static const char tstr[] = "[|slip]";
+
static u_int lastlen[2][256];
static u_int lastconn = 255;
-static void sliplink_print(const u_char *, const struct ip *, u_int);
-static void compressed_sl_print(const u_char *, const struct ip *, u_int, int);
+static void sliplink_print(netdissect_options *, const u_char *, const struct ip *, u_int);
+static void compressed_sl_print(netdissect_options *, const u_char *, const struct ip *, u_int, int);
u_int
-sl_if_print(const struct pcap_pkthdr *h, const u_char *p)
+sl_if_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, const u_char *p)
{
register u_int caplen = h->caplen;
register u_int length = h->len;
register const struct ip *ip;
if (caplen < SLIP_HDRLEN) {
- printf("[|slip]");
+ ND_PRINT((ndo, "%s", tstr));
return (caplen);
}
@@ -66,34 +73,35 @@ sl_if_print(const struct pcap_pkthdr *h, const u_char *p)
ip = (struct ip *)(p + SLIP_HDRLEN);
- if (eflag)
- sliplink_print(p, ip, length);
+ if (ndo->ndo_eflag)
+ sliplink_print(ndo, p, ip, length);
switch (IP_V(ip)) {
case 4:
- ip_print(gndo, (u_char *)ip, length);
+ ip_print(ndo, (u_char *)ip, length);
break;
#ifdef INET6
case 6:
- ip6_print(gndo, (u_char *)ip, length);
+ ip6_print(ndo, (u_char *)ip, length);
break;
#endif
default:
- printf ("ip v%d", IP_V(ip));
+ ND_PRINT((ndo, "ip v%d", IP_V(ip)));
}
return (SLIP_HDRLEN);
}
u_int
-sl_bsdos_if_print(const struct pcap_pkthdr *h, const u_char *p)
+sl_bsdos_if_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, const u_char *p)
{
register u_int caplen = h->caplen;
register u_int length = h->len;
register const struct ip *ip;
if (caplen < SLIP_HDRLEN) {
- printf("[|slip]");
+ ND_PRINT((ndo, "%s", tstr));
return (caplen);
}
@@ -102,39 +110,39 @@ sl_bsdos_if_print(const struct pcap_pkthdr *h, const u_char *p)
ip = (struct ip *)(p + SLIP_HDRLEN);
#ifdef notdef
- if (eflag)
- sliplink_print(p, ip, length);
+ if (ndo->ndo_eflag)
+ sliplink_print(ndo, p, ip, length);
#endif
- ip_print(gndo, (u_char *)ip, length);
+ ip_print(ndo, (u_char *)ip, length);
return (SLIP_HDRLEN);
}
static void
-sliplink_print(register const u_char *p, register const struct ip *ip,
- register u_int length)
+sliplink_print(netdissect_options *ndo,
+ register const u_char *p, register const struct ip *ip,
+ register u_int length)
{
int dir;
u_int hlen;
dir = p[SLX_DIR];
- putchar(dir == SLIPDIR_IN ? 'I' : 'O');
- putchar(' ');
+ ND_PRINT((ndo, dir == SLIPDIR_IN ? "I " : "O "));
- if (nflag) {
+ if (ndo->ndo_nflag) {
/* XXX just dump the header */
register int i;
for (i = SLX_CHDR; i < SLX_CHDR + CHDR_LEN - 1; ++i)
- printf("%02x.", p[i]);
- printf("%02x: ", p[SLX_CHDR + CHDR_LEN - 1]);
+ ND_PRINT((ndo, "%02x.", p[i]));
+ ND_PRINT((ndo, "%02x: ", p[SLX_CHDR + CHDR_LEN - 1]));
return;
}
switch (p[SLX_CHDR] & 0xf0) {
case TYPE_IP:
- printf("ip %d: ", length + SLIP_HDRLEN);
+ ND_PRINT((ndo, "ip %d: ", length + SLIP_HDRLEN));
break;
case TYPE_UNCOMPRESSED_TCP:
@@ -147,21 +155,22 @@ sliplink_print(register const u_char *p, register const struct ip *ip,
hlen = IP_HL(ip);
hlen += TH_OFF((struct tcphdr *)&((int *)ip)[hlen]);
lastlen[dir][lastconn] = length - (hlen << 2);
- printf("utcp %d: ", lastconn);
+ ND_PRINT((ndo, "utcp %d: ", lastconn));
break;
default:
if (p[SLX_CHDR] & TYPE_COMPRESSED_TCP) {
- compressed_sl_print(&p[SLX_CHDR], ip,
+ compressed_sl_print(ndo, &p[SLX_CHDR], ip,
length, dir);
- printf(": ");
+ ND_PRINT((ndo, ": "));
} else
- printf("slip-%d!: ", p[SLX_CHDR]);
+ ND_PRINT((ndo, "slip-%d!: ", p[SLX_CHDR]));
}
}
static const u_char *
-print_sl_change(const char *str, register const u_char *cp)
+print_sl_change(netdissect_options *ndo,
+ const char *str, register const u_char *cp)
{
register u_int i;
@@ -169,12 +178,13 @@ print_sl_change(const char *str, register const u_char *cp)
i = EXTRACT_16BITS(cp);
cp += 2;
}
- printf(" %s%d", str, i);
+ ND_PRINT((ndo, " %s%d", str, i));
return (cp);
}
static const u_char *
-print_sl_winchange(register const u_char *cp)
+print_sl_winchange(netdissect_options *ndo,
+ register const u_char *cp)
{
register short i;
@@ -183,15 +193,16 @@ print_sl_winchange(register const u_char *cp)
cp += 2;
}
if (i >= 0)
- printf(" W+%d", i);
+ ND_PRINT((ndo, " W+%d", i));
else
- printf(" W%d", i);
+ ND_PRINT((ndo, " W%d", i));
return (cp);
}
static void
-compressed_sl_print(const u_char *chdr, const struct ip *ip,
- u_int length, int dir)
+compressed_sl_print(netdissect_options *ndo,
+ const u_char *chdr, const struct ip *ip,
+ u_int length, int dir)
{
register const u_char *cp = chdr;
register u_int flags, hlen;
@@ -199,35 +210,35 @@ compressed_sl_print(const u_char *chdr, const struct ip *ip,
flags = *cp++;
if (flags & NEW_C) {
lastconn = *cp++;
- printf("ctcp %d", lastconn);
+ ND_PRINT((ndo, "ctcp %d", lastconn));
} else
- printf("ctcp *");
+ ND_PRINT((ndo, "ctcp *"));
/* skip tcp checksum */
cp += 2;
switch (flags & SPECIALS_MASK) {
case SPECIAL_I:
- printf(" *SA+%d", lastlen[dir][lastconn]);
+ ND_PRINT((ndo, " *SA+%d", lastlen[dir][lastconn]));
break;
case SPECIAL_D:
- printf(" *S+%d", lastlen[dir][lastconn]);
+ ND_PRINT((ndo, " *S+%d", lastlen[dir][lastconn]));
break;
default:
if (flags & NEW_U)
- cp = print_sl_change("U=", cp);
+ cp = print_sl_change(ndo, "U=", cp);
if (flags & NEW_W)
- cp = print_sl_winchange(cp);
+ cp = print_sl_winchange(ndo, cp);
if (flags & NEW_A)
- cp = print_sl_change("A+", cp);
+ cp = print_sl_change(ndo, "A+", cp);
if (flags & NEW_S)
- cp = print_sl_change("S+", cp);
+ cp = print_sl_change(ndo, "S+", cp);
break;
}
if (flags & NEW_I)
- cp = print_sl_change("I+", cp);
+ cp = print_sl_change(ndo, "I+", cp);
/*
* 'hlen' is the length of the uncompressed TCP/IP header (in words).
@@ -237,5 +248,5 @@ compressed_sl_print(const u_char *chdr, const struct ip *ip,
hlen = IP_HL(ip);
hlen += TH_OFF((struct tcphdr *)&((int32_t *)ip)[hlen]);
lastlen[dir][lastconn] = length - (hlen << 2);
- printf(" %d (%ld)", lastlen[dir][lastconn], (long)(cp - chdr));
+ ND_PRINT((ndo, " %d (%ld)", lastlen[dir][lastconn], (long)(cp - chdr)));
}
diff --git a/contrib/tcpdump/print-sll.c b/contrib/tcpdump/print-sll.c
index a044de6709fb..0ca36f53e46b 100644
--- a/contrib/tcpdump/print-sll.c
+++ b/contrib/tcpdump/print-sll.c
@@ -18,30 +18,110 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.19 2005-11-13 12:12:43 guy Exp $ (LBL)";
-#endif
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <string.h>
-#include <pcap.h>
-
#include "interface.h"
#include "addrtoname.h"
#include "ethertype.h"
#include "extract.h"
#include "ether.h"
-#include "sll.h"
-const struct tok sll_pkttype_values[] = {
+/*
+ * For captures on Linux cooked sockets, we construct a fake header
+ * that includes:
+ *
+ * a 2-byte "packet type" which is one of:
+ *
+ * LINUX_SLL_HOST packet was sent to us
+ * LINUX_SLL_BROADCAST packet was broadcast
+ * LINUX_SLL_MULTICAST packet was multicast
+ * LINUX_SLL_OTHERHOST packet was sent to somebody else
+ * LINUX_SLL_OUTGOING packet was sent *by* us;
+ *
+ * a 2-byte Ethernet protocol field;
+ *
+ * a 2-byte link-layer type;
+ *
+ * a 2-byte link-layer address length;
+ *
+ * an 8-byte source link-layer address, whose actual length is
+ * specified by the previous value.
+ *
+ * All fields except for the link-layer address are in network byte order.
+ *
+ * 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@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
+ * can be told apart and programs that read them can dissect the
+ * packets in them.
+ *
+ * This structure, and the #defines below, must be the same in the
+ * libpcap and tcpdump versions of "sll.h".
+ */
+
+/*
+ * A DLT_LINUX_SLL fake link-layer header.
+ */
+#define SLL_HDR_LEN 16 /* total header length */
+#define SLL_ADDRLEN 8 /* length of address field */
+
+struct sll_header {
+ uint16_t sll_pkttype; /* packet type */
+ uint16_t sll_hatype; /* link-layer address type */
+ uint16_t sll_halen; /* link-layer address length */
+ uint8_t sll_addr[SLL_ADDRLEN]; /* link-layer address */
+ uint16_t sll_protocol; /* protocol */
+};
+
+/*
+ * The LINUX_SLL_ values for "sll_pkttype"; these correspond to the
+ * PACKET_ values on Linux, but are defined here so that they're
+ * available even on systems other than Linux, and so that they
+ * don't change even if the PACKET_ values change.
+ */
+#define LINUX_SLL_HOST 0
+#define LINUX_SLL_BROADCAST 1
+#define LINUX_SLL_MULTICAST 2
+#define LINUX_SLL_OTHERHOST 3
+#define LINUX_SLL_OUTGOING 4
+
+/*
+ * The LINUX_SLL_ values for "sll_protocol"; these correspond to the
+ * ETH_P_ values on Linux, but are defined here so that they're
+ * available even on systems other than Linux. We assume, for now,
+ * that the ETH_P_ values won't change in Linux; if they do, then:
+ *
+ * if we don't translate them in "pcap-linux.c", capture files
+ * won't necessarily be readable if captured on a system that
+ * defines ETH_P_ values that don't match these values;
+ *
+ * if we do translate them in "pcap-linux.c", that makes life
+ * unpleasant for the BPF code generator, as the values you test
+ * for in the kernel aren't the values that you test for when
+ * reading a capture file, so the fixup code run on BPF programs
+ * handed to the kernel ends up having to do more work.
+ *
+ * Add other values here as necessary, for handling packet types that
+ * might show up on non-Ethernet, non-802.x networks. (Not all the ones
+ * in the Linux "if_ether.h" will, I suspect, actually show up in
+ * captures.)
+ */
+#define LINUX_SLL_P_802_3 0x0001 /* Novell 802.3 frames without 802.2 LLC header */
+#define LINUX_SLL_P_802_2 0x0004 /* 802.2 frames (not D/I/X Ethernet) */
+
+static const struct tok sll_pkttype_values[] = {
{ LINUX_SLL_HOST, "In" },
{ LINUX_SLL_BROADCAST, "B" },
{ LINUX_SLL_MULTICAST, "M" },
@@ -51,11 +131,11 @@ const struct tok sll_pkttype_values[] = {
};
static inline void
-sll_print(register const struct sll_header *sllp, u_int length)
+sll_print(netdissect_options *ndo, register const struct sll_header *sllp, u_int length)
{
u_short ether_type;
- printf("%3s ",tok2str(sll_pkttype_values,"?",EXTRACT_16BITS(&sllp->sll_pkttype)));
+ ND_PRINT((ndo, "%3s ",tok2str(sll_pkttype_values,"?",EXTRACT_16BITS(&sllp->sll_pkttype))));
/*
* XXX - check the link-layer address type value?
@@ -63,11 +143,11 @@ sll_print(register const struct sll_header *sllp, u_int length)
* XXX - print others as strings of hex?
*/
if (EXTRACT_16BITS(&sllp->sll_halen) == 6)
- (void)printf("%s ", etheraddr_string(sllp->sll_addr));
+ ND_PRINT((ndo, "%s ", etheraddr_string(ndo, sllp->sll_addr)));
- if (!qflag) {
+ if (!ndo->ndo_qflag) {
ether_type = EXTRACT_16BITS(&sllp->sll_protocol);
-
+
if (ether_type <= ETHERMTU) {
/*
* Not an Ethernet type; what type is it?
@@ -78,30 +158,30 @@ sll_print(register const struct sll_header *sllp, u_int length)
/*
* Ethernet_802.3 IPX frame.
*/
- (void)printf("802.3");
+ ND_PRINT((ndo, "802.3"));
break;
case LINUX_SLL_P_802_2:
/*
* 802.2.
*/
- (void)printf("802.2");
+ ND_PRINT((ndo, "802.2"));
break;
default:
/*
* What is it?
*/
- (void)printf("ethertype Unknown (0x%04x)",
- ether_type);
+ ND_PRINT((ndo, "ethertype Unknown (0x%04x)",
+ ether_type));
break;
}
} else {
- (void)printf("ethertype %s (0x%04x)",
+ ND_PRINT((ndo, "ethertype %s (0x%04x)",
tok2str(ethertype_values, "Unknown", ether_type),
- ether_type);
+ ether_type));
}
- (void)printf(", length %u: ", length);
+ ND_PRINT((ndo, ", length %u: ", length));
}
}
@@ -112,7 +192,7 @@ sll_print(register const struct sll_header *sllp, u_int length)
* is the number of bytes actually captured.
*/
u_int
-sll_if_print(const struct pcap_pkthdr *h, const u_char *p)
+sll_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
{
u_int caplen = h->caplen;
u_int length = h->len;
@@ -126,14 +206,14 @@ sll_if_print(const struct pcap_pkthdr *h, const u_char *p)
* adds this many bytes of header to every packet in a
* cooked socket capture.
*/
- printf("[|sll]");
+ ND_PRINT((ndo, "[|sll]"));
return (caplen);
}
sllp = (const struct sll_header *)p;
- if (eflag)
- sll_print(sllp, length);
+ if (ndo->ndo_eflag)
+ sll_print(ndo, sllp, length);
/*
* Go past the cooked-mode header.
@@ -159,7 +239,7 @@ recurse:
/*
* Ethernet_802.3 IPX frame.
*/
- ipx_print(p, length);
+ ipx_print(ndo, p, length);
break;
case LINUX_SLL_P_802_2:
@@ -167,7 +247,7 @@ recurse:
* 802.2.
* Try to print the LLC-layer header & higher layers.
*/
- if (llc_print(p, length, caplen, NULL, NULL,
+ if (llc_print(ndo, p, length, caplen, NULL, NULL,
&extracted_ethertype) == 0)
goto unknown; /* unknown LLC type */
break;
@@ -178,14 +258,14 @@ recurse:
unknown:
/* ether_type not known, print raw packet */
- if (!eflag)
- sll_print(sllp, length + SLL_HDR_LEN);
+ if (!ndo->ndo_eflag)
+ sll_print(ndo, sllp, length + SLL_HDR_LEN);
if (extracted_ethertype) {
- printf("(LLC %s) ",
- etherproto_string(htons(extracted_ethertype)));
+ ND_PRINT((ndo, "(LLC %s) ",
+ etherproto_string(htons(extracted_ethertype))));
}
- if (!suppress_default_print)
- default_print(p, caplen);
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
break;
}
} else if (ether_type == ETHERTYPE_8021Q) {
@@ -194,36 +274,36 @@ recurse:
* the enclosed type field.
*/
if (caplen < 4 || length < 4) {
- printf("[|vlan]");
+ ND_PRINT((ndo, "[|vlan]"));
return (SLL_HDR_LEN);
}
- if (eflag) {
- u_int16_t tag = EXTRACT_16BITS(p);
+ if (ndo->ndo_eflag) {
+ uint16_t tag = EXTRACT_16BITS(p);
- printf("vlan %u, p %u%s, ",
+ ND_PRINT((ndo, "vlan %u, p %u%s, ",
tag & 0xfff,
tag >> 13,
- (tag & 0x1000) ? ", CFI" : "");
+ (tag & 0x1000) ? ", CFI" : ""));
}
ether_type = EXTRACT_16BITS(p + 2);
if (ether_type <= ETHERMTU)
ether_type = LINUX_SLL_P_802_2;
- if (!qflag) {
- (void)printf("ethertype %s, ",
- tok2str(ethertype_values, "Unknown", ether_type));
+ if (!ndo->ndo_qflag) {
+ ND_PRINT((ndo, "ethertype %s, ",
+ tok2str(ethertype_values, "Unknown", ether_type)));
}
p += 4;
length -= 4;
caplen -= 4;
goto recurse;
} else {
- if (ethertype_print(gndo, ether_type, p, length, caplen) == 0) {
+ if (ethertype_print(ndo, ether_type, p, length, caplen) == 0) {
/* ether_type not known, print raw packet */
- if (!eflag)
- sll_print(sllp, length + SLL_HDR_LEN);
- if (!suppress_default_print)
- default_print(p, caplen);
+ if (!ndo->ndo_eflag)
+ sll_print(ndo, sllp, length + SLL_HDR_LEN);
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
}
}
diff --git a/contrib/tcpdump/print-slow.c b/contrib/tcpdump/print-slow.c
index fdfefccf386a..fec76cab3ff2 100644
--- a/contrib/tcpdump/print-slow.c
+++ b/contrib/tcpdump/print-slow.c
@@ -18,21 +18,13 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-slow.c,v 1.8 2006-10-12 05:44:33 hannes Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
#include "interface.h"
#include "extract.h"
#include "addrtoname.h"
@@ -40,8 +32,8 @@ static const char rcsid[] _U_ =
#include "oui.h"
struct slow_common_header_t {
- u_int8_t proto_subtype;
- u_int8_t version;
+ uint8_t proto_subtype;
+ uint8_t version;
};
#define SLOW_PROTO_LACP 1
@@ -67,7 +59,7 @@ static const struct tok slow_oam_flag_values[] = {
{ 0x0020, "Remote Evaluating" },
{ 0x0040, "Remote Stable" },
{ 0, NULL}
-};
+};
#define SLOW_OAM_CODE_INFO 0x00
#define SLOW_OAM_CODE_EVENT_NOTIF 0x01
@@ -87,15 +79,15 @@ static const struct tok slow_oam_code_values[] = {
};
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];
+ uint8_t info_type;
+ uint8_t info_length;
+ uint8_t oam_version;
+ uint8_t revision[2];
+ uint8_t state;
+ uint8_t oam_config;
+ uint8_t oam_pdu_config[2];
+ uint8_t oui[3];
+ uint8_t vendor_private[4];
};
#define SLOW_OAM_INFO_TYPE_END_OF_TLV 0x00
@@ -157,29 +149,29 @@ static const struct tok slow_oam_link_event_values[] = {
};
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];
+ uint8_t event_type;
+ uint8_t event_length;
+ uint8_t time_stamp[2];
+ uint8_t window[8];
+ uint8_t threshold[8];
+ uint8_t errors[8];
+ uint8_t errors_running_total[8];
+ uint8_t event_running_total[4];
};
struct slow_oam_variablerequest_t {
- u_int8_t branch;
- u_int8_t leaf[2];
+ uint8_t branch;
+ uint8_t leaf[2];
};
struct slow_oam_variableresponse_t {
- u_int8_t branch;
- u_int8_t leaf[2];
- u_int8_t length;
+ uint8_t branch;
+ uint8_t leaf[2];
+ uint8_t length;
};
struct slow_oam_loopbackctrl_t {
- u_int8_t command;
+ uint8_t command;
};
static const struct tok slow_oam_loopbackctrl_cmd_values[] = {
@@ -189,8 +181,8 @@ static const struct tok slow_oam_loopbackctrl_cmd_values[] = {
};
struct tlv_header_t {
- u_int8_t type;
- u_int8_t length;
+ uint8_t type;
+ uint8_t length;
};
#define LACP_TLV_TERMINATOR 0x00
@@ -213,14 +205,14 @@ static const struct tok slow_tlv_values[] = {
};
struct lacp_tlv_actor_partner_info_t {
- u_int8_t sys_pri[2];
- u_int8_t sys[ETHER_ADDR_LEN];
- u_int8_t key[2];
- u_int8_t port_pri[2];
- u_int8_t port[2];
- u_int8_t state;
- u_int8_t pad[3];
-};
+ uint8_t sys_pri[2];
+ uint8_t sys[ETHER_ADDR_LEN];
+ uint8_t key[2];
+ uint8_t port_pri[2];
+ uint8_t port[2];
+ uint8_t state;
+ uint8_t pad[3];
+};
static const struct tok lacp_tlv_actor_partner_info_state_values[] = {
{ 0x01, "Activity"},
@@ -235,33 +227,34 @@ static const struct tok lacp_tlv_actor_partner_info_state_values[] = {
};
struct lacp_tlv_collector_info_t {
- u_int8_t max_delay[2];
- u_int8_t pad[12];
-};
+ uint8_t max_delay[2];
+ uint8_t pad[12];
+};
struct marker_tlv_marker_info_t {
- u_int8_t req_port[2];
- u_int8_t req_sys[ETHER_ADDR_LEN];
- u_int8_t req_trans_id[4];
- u_int8_t pad[2];
-};
+ uint8_t req_port[2];
+ uint8_t req_sys[ETHER_ADDR_LEN];
+ uint8_t req_trans_id[4];
+ uint8_t pad[2];
+};
struct lacp_marker_tlv_terminator_t {
- u_int8_t pad[50];
-};
+ uint8_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);
+static void slow_marker_lacp_print(netdissect_options *, register const u_char *, register u_int);
+static void slow_oam_print(netdissect_options *, 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) {
+slow_print(netdissect_options *ndo,
+ register const u_char *pptr, register u_int len) {
int print_version;
slow_com_header = (const struct slow_common_header_t *)pptr;
- TCHECK(*slow_com_header);
+ ND_TCHECK(*slow_com_header);
/*
* Sanity checking of the header.
@@ -269,7 +262,7 @@ slow_print(register const u_char *pptr, register u_int len) {
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);
+ ND_PRINT((ndo, "LACP version %u packet not supported",slow_com_header->version));
return;
}
print_version = 1;
@@ -277,7 +270,7 @@ slow_print(register const u_char *pptr, register u_int len) {
case SLOW_PROTO_MARKER:
if (slow_com_header->version != MARKER_VERSION) {
- printf("MARKER version %u packet not supported",slow_com_header->version);
+ ND_PRINT((ndo, "MARKER version %u packet not supported",slow_com_header->version));
return;
}
print_version = 1;
@@ -294,24 +287,24 @@ slow_print(register const u_char *pptr, register u_int len) {
}
if (print_version) {
- printf("%sv%u, length %u",
+ ND_PRINT((ndo, "%sv%u, length %u",
tok2str(slow_proto_values, "unknown (%u)",slow_com_header->proto_subtype),
slow_com_header->version,
- len);
+ len));
} else {
/* some slow protos don't have a version number in the header */
- printf("%s, length %u",
+ ND_PRINT((ndo, "%s, length %u",
tok2str(slow_proto_values, "unknown (%u)",slow_com_header->proto_subtype),
- len);
+ len));
}
/* unrecognized subtype */
if (print_version == -1) {
- print_unknown_data(pptr, "\n\t", len);
+ print_unknown_data(ndo, pptr, "\n\t", len);
return;
}
- if (!vflag)
+ if (!ndo->ndo_vflag)
return;
switch (slow_com_header->proto_subtype) {
@@ -320,7 +313,7 @@ slow_print(register const u_char *pptr, register u_int len) {
case SLOW_PROTO_OAM:
/* skip proto_subtype */
- slow_oam_print(pptr+1, len-1);
+ slow_oam_print(ndo, pptr+1, len-1);
break;
case SLOW_PROTO_LACP: /* LACP and MARKER share the same semantics */
@@ -328,16 +321,18 @@ slow_print(register const u_char *pptr, register u_int len) {
/* 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);
+ slow_marker_lacp_print(ndo, pptr, len);
break;
}
return;
trunc:
- printf("\n\t\t packet exceeded snapshot");
+ ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
}
-void slow_marker_lacp_print(register const u_char *tptr, register u_int tlen) {
+static void
+slow_marker_lacp_print(netdissect_options *ndo,
+ register const u_char *tptr, register u_int tlen) {
const struct tlv_header_t *tlv_header;
const u_char *tlv_tptr;
@@ -349,26 +344,26 @@ void slow_marker_lacp_print(register const u_char *tptr, register u_int tlen) {
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));
+ ND_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",
+ ND_PRINT((ndo, "\n\t%s TLV (0x%02x), length %u",
tok2str(slow_tlv_values,
"Unknown",
(slow_com_header->proto_subtype << 8) + tlv_header->type),
tlv_header->type,
- tlv_len);
+ tlv_len));
if ((tlv_len < sizeof(struct tlv_header_t) ||
tlv_len > tlen) &&
tlv_header->type != LACP_TLV_TERMINATOR &&
tlv_header->type != MARKER_TLV_TERMINATOR) {
- printf("\n\t-----trailing data-----");
- print_unknown_data(tptr+sizeof(struct tlv_header_t),"\n\t ",tlen);
+ ND_PRINT((ndo, "\n\t-----trailing data-----"));
+ print_unknown_data(ndo, tptr+sizeof(struct tlv_header_t), "\n\t ", tlen);
return;
}
@@ -376,7 +371,7 @@ void slow_marker_lacp_print(register const u_char *tptr, register u_int tlen) {
tlv_tlen=tlv_len-sizeof(struct tlv_header_t);
/* did we capture enough for fully decoding the tlv ? */
- TCHECK2(*tptr, tlv_len);
+ ND_TCHECK2(*tptr, tlv_len);
switch((slow_com_header->proto_subtype << 8) + tlv_header->type) {
@@ -385,34 +380,34 @@ void slow_marker_lacp_print(register const u_char *tptr, register u_int tlen) {
case ((SLOW_PROTO_LACP << 8) + LACP_TLV_PARTNER_INFO):
tlv_ptr.lacp_tlv_actor_partner_info = (const struct lacp_tlv_actor_partner_info_t *)tlv_tptr;
- printf("\n\t System %s, System Priority %u, Key %u" \
+ ND_PRINT((ndo, "\n\t System %s, System Priority %u, Key %u" \
", Port %u, Port Priority %u\n\t State Flags [%s]",
- etheraddr_string(tlv_ptr.lacp_tlv_actor_partner_info->sys),
+ etheraddr_string(ndo, tlv_ptr.lacp_tlv_actor_partner_info->sys),
EXTRACT_16BITS(tlv_ptr.lacp_tlv_actor_partner_info->sys_pri),
EXTRACT_16BITS(tlv_ptr.lacp_tlv_actor_partner_info->key),
EXTRACT_16BITS(tlv_ptr.lacp_tlv_actor_partner_info->port),
EXTRACT_16BITS(tlv_ptr.lacp_tlv_actor_partner_info->port_pri),
bittok2str(lacp_tlv_actor_partner_info_state_values,
"none",
- tlv_ptr.lacp_tlv_actor_partner_info->state));
+ tlv_ptr.lacp_tlv_actor_partner_info->state)));
break;
case ((SLOW_PROTO_LACP << 8) + LACP_TLV_COLLECTOR_INFO):
tlv_ptr.lacp_tlv_collector_info = (const struct lacp_tlv_collector_info_t *)tlv_tptr;
- printf("\n\t Max Delay %u",
- EXTRACT_16BITS(tlv_ptr.lacp_tlv_collector_info->max_delay));
+ ND_PRINT((ndo, "\n\t Max Delay %u",
+ EXTRACT_16BITS(tlv_ptr.lacp_tlv_collector_info->max_delay)));
break;
case ((SLOW_PROTO_MARKER << 8) + MARKER_TLV_MARKER_INFO):
tlv_ptr.marker_tlv_marker_info = (const struct marker_tlv_marker_info_t *)tlv_tptr;
- printf("\n\t Request System %s, Request Port %u, Request Transaction ID 0x%08x",
- etheraddr_string(tlv_ptr.marker_tlv_marker_info->req_sys),
+ ND_PRINT((ndo, "\n\t Request System %s, Request Port %u, Request Transaction ID 0x%08x",
+ etheraddr_string(ndo, tlv_ptr.marker_tlv_marker_info->req_sys),
EXTRACT_16BITS(tlv_ptr.marker_tlv_marker_info->req_port),
- EXTRACT_32BITS(tlv_ptr.marker_tlv_marker_info->req_trans_id));
+ EXTRACT_32BITS(tlv_ptr.marker_tlv_marker_info->req_trans_id)));
break;
@@ -424,24 +419,24 @@ void slow_marker_lacp_print(register const u_char *tptr, register u_int tlen) {
tlv_len = sizeof(tlv_ptr.lacp_marker_tlv_terminator->pad) +
sizeof(struct tlv_header_t);
/* tell the user that we modified the length field */
- if (vflag>1)
- printf(" (=%u)",tlv_len);
+ if (ndo->ndo_vflag>1)
+ ND_PRINT((ndo, " (=%u)", tlv_len));
/* we have messed around with the length field - now we need to check
* again if there are enough bytes on the wire for the hexdump */
- TCHECK2(tlv_ptr.lacp_marker_tlv_terminator->pad[0],
+ ND_TCHECK2(tlv_ptr.lacp_marker_tlv_terminator->pad[0],
sizeof(tlv_ptr.lacp_marker_tlv_terminator->pad));
}
break;
default:
- if (vflag <= 1)
- print_unknown_data(tlv_tptr,"\n\t ",tlv_tlen);
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo, tlv_tptr, "\n\t ", tlv_tlen);
break;
}
/* do we want to see an additional hexdump ? */
- if (vflag > 1) {
- print_unknown_data(tptr+sizeof(struct tlv_header_t),"\n\t ",
+ if (ndo->ndo_vflag > 1) {
+ print_unknown_data(ndo, tptr+sizeof(struct tlv_header_t), "\n\t ",
tlv_len-sizeof(struct tlv_header_t));
}
@@ -450,21 +445,23 @@ void slow_marker_lacp_print(register const u_char *tptr, register u_int tlen) {
}
return;
trunc:
- printf("\n\t\t packet exceeded snapshot");
+ ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
}
-void slow_oam_print(register const u_char *tptr, register u_int tlen) {
+static void
+slow_oam_print(netdissect_options *ndo,
+ 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;
+ uint8_t flags[2];
+ uint8_t code;
};
struct slow_oam_tlv_header_t {
- u_int8_t type;
- u_int8_t length;
+ uint8_t type;
+ uint8_t length;
};
union {
@@ -479,71 +476,71 @@ void slow_oam_print(register const u_char *tptr, register u_int tlen) {
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]",
+ ND_PRINT((ndo, "\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)));
+ 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",
+ ND_PRINT((ndo, "\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);
+ 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");
+ ND_PRINT((ndo, "\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));
+ ND_PRINT((ndo, "\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",
+ ND_PRINT((ndo, "\n\t OAM-Version %u, Revision %u",
tlv.slow_oam_info->oam_version,
- EXTRACT_16BITS(&tlv.slow_oam_info->revision));
+ EXTRACT_16BITS(&tlv.slow_oam_info->revision)));
- printf("\n\t State-Parser-Action %s, State-MUX-Action %s",
+ ND_PRINT((ndo, "\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",
+ tlv.slow_oam_info->state & OAM_INFO_TYPE_MUX_MASK)));
+ ND_PRINT((ndo, "\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",
+ OAM_INFO_TYPE_PDU_SIZE_MASK));
+ ND_PRINT((ndo, "\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));
+ EXTRACT_32BITS(&tlv.slow_oam_info->vendor_private)));
break;
-
+
case SLOW_OAM_INFO_TYPE_ORG_SPECIFIC:
hexdump = TRUE;
break;
-
+
default:
hexdump = TRUE;
break;
@@ -555,8 +552,8 @@ void slow_oam_print(register const u_char *tptr, register u_int tlen) {
}
/* do we also want to see a hex dump ? */
- if (vflag > 1 || hexdump==TRUE) {
- print_unknown_data(tptr,"\n\t ",
+ if (ndo->ndo_vflag > 1 || hexdump==TRUE) {
+ print_unknown_data(ndo, tptr, "\n\t ",
ptr.slow_oam_tlv_header->length);
}
@@ -568,34 +565,34 @@ void slow_oam_print(register const u_char *tptr, register u_int tlen) {
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",
+ ND_PRINT((ndo, "\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);
+ 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");
+ ND_PRINT((ndo, "\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));
+ ND_PRINT((ndo, "\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
+ ND_PRINT((ndo, "\n\t Timestamp %u ms, Errored Window %" PRIu64
"\n\t Errored Threshold %" PRIu64
"\n\t Errors %" PRIu64
"\n\t Error Running Total %" PRIu64
@@ -605,13 +602,13 @@ void slow_oam_print(register const u_char *tptr, register u_int tlen) {
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));
+ 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;
@@ -623,8 +620,8 @@ void slow_oam_print(register const u_char *tptr, register u_int tlen) {
}
/* do we also want to see a hex dump ? */
- if (vflag > 1 || hexdump==TRUE) {
- print_unknown_data(tptr,"\n\t ",
+ if (ndo->ndo_vflag > 1 || hexdump==TRUE) {
+ print_unknown_data(ndo, tptr, "\n\t ",
ptr.slow_oam_tlv_header->length);
}
@@ -632,14 +629,14 @@ void slow_oam_print(register const u_char *tptr, register u_int tlen) {
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)",
+ ND_PRINT((ndo, "\n\t Command %s (%u)",
tok2str(slow_oam_loopbackctrl_cmd_values,
"Unknown",
tlv.slow_oam_loopbackctrl->command),
- tlv.slow_oam_loopbackctrl->command);
+ tlv.slow_oam_loopbackctrl->command));
tptr ++;
tlen --;
break;
@@ -652,8 +649,8 @@ void slow_oam_print(register const u_char *tptr, register u_int tlen) {
case SLOW_OAM_CODE_VAR_RESPONSE:
case SLOW_OAM_CODE_PRIVATE:
default:
- if (vflag <= 1) {
- print_unknown_data(tptr,"\n\t ", tlen);
+ if (ndo->ndo_vflag <= 1) {
+ print_unknown_data(ndo, tptr, "\n\t ", tlen);
}
break;
}
diff --git a/contrib/tcpdump/print-smb.c b/contrib/tcpdump/print-smb.c
index 68c73659f84f..6bffa7cb33ff 100644
--- a/contrib/tcpdump/print-smb.c
+++ b/contrib/tcpdump/print-smb.c
@@ -6,24 +6,21 @@
* or later
*/
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-smb.c,v 1.47 2007-12-09 00:30:47 guy Exp $";
-#endif
-
#include <tcpdump-stdinc.h>
-#include <stdio.h>
#include <string.h>
#include "interface.h"
#include "extract.h"
#include "smb.h"
+static const char tstr[] = "[|SMB]";
+
static int request = 0;
static int unicodestr = 0;
@@ -34,7 +31,7 @@ struct smbdescript {
const char *req_f2;
const char *rep_f1;
const char *rep_f2;
- void (*fn)(const u_char *, const u_char *, const u_char *, const u_char *);
+ void (*fn)(netdissect_options *, const u_char *, const u_char *, const u_char *, const u_char *);
};
struct smbdescriptint {
@@ -42,7 +39,7 @@ struct smbdescriptint {
const char *req_f2;
const char *rep_f1;
const char *rep_f2;
- void (*fn)(const u_char *, const u_char *, int, int);
+ void (*fn)(netdissect_options *, const u_char *, const u_char *, int, int);
};
struct smbfns
@@ -65,8 +62,8 @@ struct smbfnsint
#define FLG_CHAIN (1 << 0)
-static struct smbfns *
-smbfind(int id, struct smbfns *list)
+static const struct smbfns *
+smbfind(int id, const struct smbfns *list)
{
int sindex;
@@ -77,8 +74,8 @@ smbfind(int id, struct smbfns *list)
return(&list[0]);
}
-static struct smbfnsint *
-smbfindint(int id, struct smbfnsint *list)
+static const struct smbfnsint *
+smbfindint(int id, const struct smbfnsint *list)
{
int sindex;
@@ -90,7 +87,8 @@ smbfindint(int id, struct smbfnsint *list)
}
static void
-trans2_findfirst(const u_char *param, const u_char *data, int pcnt, int dcnt)
+trans2_findfirst(netdissect_options *ndo,
+ const u_char *param, const u_char *data, int pcnt, int dcnt)
{
const char *fmt;
@@ -99,24 +97,25 @@ trans2_findfirst(const u_char *param, const u_char *data, int pcnt, int dcnt)
else
fmt = "Handle=[w]\nCount=[d]\nEOS=[w]\nEoffset=[d]\nLastNameOfs=[w]\n";
- smb_fdata(param, fmt, param + pcnt, unicodestr);
+ smb_fdata(ndo, param, fmt, param + pcnt, unicodestr);
if (dcnt) {
- printf("data:\n");
- print_data(data, dcnt);
+ ND_PRINT((ndo, "data:\n"));
+ print_data(ndo, data, dcnt);
}
}
static void
-trans2_qfsinfo(const u_char *param, const u_char *data, int pcnt, int dcnt)
+trans2_qfsinfo(netdissect_options *ndo,
+ const u_char *param, const u_char *data, int pcnt, int dcnt)
{
static int level = 0;
const char *fmt="";
if (request) {
- TCHECK2(*param, 2);
+ ND_TCHECK2(*param, 2);
level = EXTRACT_LE_16BITS(param);
fmt = "InfoLevel=[d]\n";
- smb_fdata(param, fmt, param + pcnt, unicodestr);
+ smb_fdata(ndo, param, fmt, param + pcnt, unicodestr);
} else {
switch (level) {
case 1:
@@ -132,19 +131,18 @@ trans2_qfsinfo(const u_char *param, const u_char *data, int pcnt, int dcnt)
fmt = "UnknownLevel\n";
break;
}
- smb_fdata(data, fmt, data + dcnt, unicodestr);
+ smb_fdata(ndo, data, fmt, data + dcnt, unicodestr);
}
if (dcnt) {
- printf("data:\n");
- print_data(data, dcnt);
+ ND_PRINT((ndo, "data:\n"));
+ print_data(ndo, data, dcnt);
}
return;
trunc:
- printf("[|SMB]");
- return;
+ ND_PRINT((ndo, "%s", tstr));
}
-struct smbfnsint trans2_fns[] = {
+static const struct smbfnsint trans2_fns[] = {
{ 0, "TRANSACT2_OPEN", 0,
{ "Flags2=[w]\nMode=[w]\nSearchAttrib=[A]\nAttrib=[A]\nTime=[T2]\nOFun=[w]\nSize=[D]\nRes=([w, w, w, w, w])\nPath=[S]",
NULL,
@@ -170,18 +168,19 @@ struct smbfnsint trans2_fns[] = {
static void
-print_trans2(const u_char *words, const u_char *dat, const u_char *buf, const u_char *maxbuf)
+print_trans2(netdissect_options *ndo,
+ const u_char *words, const u_char *dat, const u_char *buf, const u_char *maxbuf)
{
u_int bcc;
- static struct smbfnsint *fn = &trans2_fns[0];
+ static const struct smbfnsint *fn = &trans2_fns[0];
const u_char *data, *param;
const u_char *w = words + 1;
const char *f1 = NULL, *f2 = NULL;
int pcnt, dcnt;
- TCHECK(words[0]);
+ ND_TCHECK(words[0]);
if (request) {
- TCHECK2(w[14 * 2], 2);
+ ND_TCHECK2(w[14 * 2], 2);
pcnt = EXTRACT_LE_16BITS(w + 9 * 2);
param = buf + EXTRACT_LE_16BITS(w + 10 * 2);
dcnt = EXTRACT_LE_16BITS(w + 11 * 2);
@@ -189,151 +188,151 @@ print_trans2(const u_char *words, const u_char *dat, const u_char *buf, const u_
fn = smbfindint(EXTRACT_LE_16BITS(w + 14 * 2), trans2_fns);
} else {
if (words[0] == 0) {
- printf("%s\n", fn->name);
- printf("Trans2Interim\n");
+ ND_PRINT((ndo, "%s\n", fn->name));
+ ND_PRINT((ndo, "Trans2Interim\n"));
return;
}
- TCHECK2(w[7 * 2], 2);
+ ND_TCHECK2(w[7 * 2], 2);
pcnt = EXTRACT_LE_16BITS(w + 3 * 2);
param = buf + EXTRACT_LE_16BITS(w + 4 * 2);
dcnt = EXTRACT_LE_16BITS(w + 6 * 2);
data = buf + EXTRACT_LE_16BITS(w + 7 * 2);
}
- printf("%s param_length=%d data_length=%d\n", fn->name, pcnt, dcnt);
+ ND_PRINT((ndo, "%s param_length=%d data_length=%d\n", fn->name, pcnt, dcnt));
if (request) {
if (words[0] == 8) {
- smb_fdata(words + 1,
+ smb_fdata(ndo, words + 1,
"Trans2Secondary\nTotParam=[d]\nTotData=[d]\nParamCnt=[d]\nParamOff=[d]\nParamDisp=[d]\nDataCnt=[d]\nDataOff=[d]\nDataDisp=[d]\nHandle=[d]\n",
maxbuf, unicodestr);
return;
} else {
- smb_fdata(words + 1,
+ smb_fdata(ndo, words + 1,
"TotParam=[d]\nTotData=[d]\nMaxParam=[d]\nMaxData=[d]\nMaxSetup=[b][P1]\nFlags=[w]\nTimeOut=[D]\nRes1=[w]\nParamCnt=[d]\nParamOff=[d]\nDataCnt=[d]\nDataOff=[d]\nSetupCnt=[b][P1]\n",
words + 1 + 14 * 2, unicodestr);
}
f1 = fn->descript.req_f1;
f2 = fn->descript.req_f2;
} else {
- smb_fdata(words + 1,
+ smb_fdata(ndo, words + 1,
"TotParam=[d]\nTotData=[d]\nRes1=[w]\nParamCnt=[d]\nParamOff=[d]\nParamDisp[d]\nDataCnt=[d]\nDataOff=[d]\nDataDisp=[d]\nSetupCnt=[b][P1]\n",
words + 1 + 10 * 2, unicodestr);
f1 = fn->descript.rep_f1;
f2 = fn->descript.rep_f2;
}
- TCHECK2(*dat, 2);
+ ND_TCHECK2(*dat, 2);
bcc = EXTRACT_LE_16BITS(dat);
- printf("smb_bcc=%u\n", bcc);
+ ND_PRINT((ndo, "smb_bcc=%u\n", bcc));
if (fn->descript.fn)
- (*fn->descript.fn)(param, data, pcnt, dcnt);
+ (*fn->descript.fn)(ndo, param, data, pcnt, dcnt);
else {
- smb_fdata(param, f1 ? f1 : "Parameters=\n", param + pcnt, unicodestr);
- smb_fdata(data, f2 ? f2 : "Data=\n", data + dcnt, unicodestr);
+ smb_fdata(ndo, param, f1 ? f1 : "Parameters=\n", param + pcnt, unicodestr);
+ smb_fdata(ndo, data, f2 ? f2 : "Data=\n", data + dcnt, unicodestr);
}
return;
trunc:
- printf("[|SMB]");
- return;
+ ND_PRINT((ndo, "%s", tstr));
}
-
static void
-print_browse(const u_char *param, int paramlen, const u_char *data, int datalen)
+print_browse(netdissect_options *ndo,
+ const u_char *param, int paramlen, const u_char *data, int datalen)
{
const u_char *maxbuf = data + datalen;
int command;
- TCHECK(data[0]);
+ ND_TCHECK(data[0]);
command = data[0];
- smb_fdata(param, "BROWSE PACKET\n|Param ", param+paramlen, unicodestr);
+ smb_fdata(ndo, param, "BROWSE PACKET\n|Param ", param+paramlen, unicodestr);
switch (command) {
case 0xF:
- data = smb_fdata(data,
+ data = smb_fdata(ndo, data,
"BROWSE PACKET:\nType=[B] (LocalMasterAnnouncement)\nUpdateCount=[w]\nRes1=[B]\nAnnounceInterval=[d]\nName=[n2]\nMajorVersion=[B]\nMinorVersion=[B]\nServerType=[W]\nElectionVersion=[w]\nBrowserConstant=[w]\n",
maxbuf, unicodestr);
break;
case 0x1:
- data = smb_fdata(data,
+ data = smb_fdata(ndo, data,
"BROWSE PACKET:\nType=[B] (HostAnnouncement)\nUpdateCount=[w]\nRes1=[B]\nAnnounceInterval=[d]\nName=[n2]\nMajorVersion=[B]\nMinorVersion=[B]\nServerType=[W]\nElectionVersion=[w]\nBrowserConstant=[w]\n",
maxbuf, unicodestr);
break;
case 0x2:
- data = smb_fdata(data,
+ data = smb_fdata(ndo, data,
"BROWSE PACKET:\nType=[B] (AnnouncementRequest)\nFlags=[B]\nReplySystemName=[S]\n",
maxbuf, unicodestr);
break;
case 0xc:
- data = smb_fdata(data,
+ data = smb_fdata(ndo, data,
"BROWSE PACKET:\nType=[B] (WorkgroupAnnouncement)\nUpdateCount=[w]\nRes1=[B]\nAnnounceInterval=[d]\nName=[n2]\nMajorVersion=[B]\nMinorVersion=[B]\nServerType=[W]\nCommentPointer=[W]\nServerName=[S]\n",
maxbuf, unicodestr);
break;
case 0x8:
- data = smb_fdata(data,
+ data = smb_fdata(ndo, data,
"BROWSE PACKET:\nType=[B] (ElectionFrame)\nElectionVersion=[B]\nOSSummary=[W]\nUptime=[(W, W)]\nServerName=[S]\n",
maxbuf, unicodestr);
break;
case 0xb:
- data = smb_fdata(data,
+ data = smb_fdata(ndo, data,
"BROWSE PACKET:\nType=[B] (BecomeBackupBrowser)\nName=[S]\n",
maxbuf, unicodestr);
break;
case 0x9:
- data = smb_fdata(data,
+ data = smb_fdata(ndo, data,
"BROWSE PACKET:\nType=[B] (GetBackupList)\nListCount?=[B]\nToken=[W]\n",
maxbuf, unicodestr);
break;
case 0xa:
- data = smb_fdata(data,
+ data = smb_fdata(ndo, data,
"BROWSE PACKET:\nType=[B] (BackupListResponse)\nServerCount?=[B]\nToken=[W]\n*Name=[S]\n",
maxbuf, unicodestr);
break;
case 0xd:
- data = smb_fdata(data,
+ data = smb_fdata(ndo, data,
"BROWSE PACKET:\nType=[B] (MasterAnnouncement)\nMasterName=[S]\n",
maxbuf, unicodestr);
break;
case 0xe:
- data = smb_fdata(data,
+ data = smb_fdata(ndo, data,
"BROWSE PACKET:\nType=[B] (ResetBrowser)\nOptions=[B]\n", maxbuf, unicodestr);
break;
default:
- data = smb_fdata(data, "Unknown Browser Frame ", maxbuf, unicodestr);
+ data = smb_fdata(ndo, data, "Unknown Browser Frame ", maxbuf, unicodestr);
break;
}
return;
trunc:
- printf("[|SMB]");
- return;
+ ND_PRINT((ndo, "%s", tstr));
}
static void
-print_ipc(const u_char *param, int paramlen, const u_char *data, int datalen)
+print_ipc(netdissect_options *ndo,
+ const u_char *param, int paramlen, const u_char *data, int datalen)
{
if (paramlen)
- smb_fdata(param, "Command=[w]\nStr1=[S]\nStr2=[S]\n", param + paramlen,
+ smb_fdata(ndo, param, "Command=[w]\nStr1=[S]\nStr2=[S]\n", param + paramlen,
unicodestr);
if (datalen)
- smb_fdata(data, "IPC ", data + datalen, unicodestr);
+ smb_fdata(ndo, data, "IPC ", data + datalen, unicodestr);
}
static void
-print_trans(const u_char *words, const u_char *data1, const u_char *buf, const u_char *maxbuf)
+print_trans(netdissect_options *ndo,
+ const u_char *words, const u_char *data1, const u_char *buf, const u_char *maxbuf)
{
u_int bcc;
const char *f1, *f2, *f3, *f4;
@@ -342,7 +341,7 @@ print_trans(const u_char *words, const u_char *data1, const u_char *buf, const u
int datalen, paramlen;
if (request) {
- TCHECK2(w[12 * 2], 2);
+ ND_TCHECK2(w[12 * 2], 2);
paramlen = EXTRACT_LE_16BITS(w + 9 * 2);
param = buf + EXTRACT_LE_16BITS(w + 10 * 2);
datalen = EXTRACT_LE_16BITS(w + 11 * 2);
@@ -352,7 +351,7 @@ print_trans(const u_char *words, const u_char *data1, const u_char *buf, const u
f3 = "|Param ";
f4 = "|Data ";
} else {
- TCHECK2(w[7 * 2], 2);
+ ND_TCHECK2(w[7 * 2], 2);
paramlen = EXTRACT_LE_16BITS(w + 3 * 2);
param = buf + EXTRACT_LE_16BITS(w + 4 * 2);
datalen = EXTRACT_LE_16BITS(w + 6 * 2);
@@ -363,44 +362,44 @@ print_trans(const u_char *words, const u_char *data1, const u_char *buf, const u
f4 = "|Data ";
}
- smb_fdata(words + 1, f1, SMBMIN(words + 1 + 2 * words[0], maxbuf),
+ smb_fdata(ndo, words + 1, f1, min(words + 1 + 2 * words[0], maxbuf),
unicodestr);
- TCHECK2(*data1, 2);
+ ND_TCHECK2(*data1, 2);
bcc = EXTRACT_LE_16BITS(data1);
- printf("smb_bcc=%u\n", bcc);
+ ND_PRINT((ndo, "smb_bcc=%u\n", bcc));
if (bcc > 0) {
- smb_fdata(data1 + 2, f2, maxbuf - (paramlen + datalen), unicodestr);
+ smb_fdata(ndo, data1 + 2, f2, maxbuf - (paramlen + datalen), unicodestr);
if (strcmp((const char *)(data1 + 2), "\\MAILSLOT\\BROWSE") == 0) {
- print_browse(param, paramlen, data, datalen);
+ print_browse(ndo, param, paramlen, data, datalen);
return;
}
if (strcmp((const char *)(data1 + 2), "\\PIPE\\LANMAN") == 0) {
- print_ipc(param, paramlen, data, datalen);
+ print_ipc(ndo, param, paramlen, data, datalen);
return;
}
if (paramlen)
- smb_fdata(param, f3, SMBMIN(param + paramlen, maxbuf), unicodestr);
+ smb_fdata(ndo, param, f3, min(param + paramlen, maxbuf), unicodestr);
if (datalen)
- smb_fdata(data, f4, SMBMIN(data + datalen, maxbuf), unicodestr);
+ smb_fdata(ndo, data, f4, min(data + datalen, maxbuf), unicodestr);
}
return;
trunc:
- printf("[|SMB]");
- return;
+ ND_PRINT((ndo, "%s", tstr));
}
static void
-print_negprot(const u_char *words, const u_char *data, const u_char *buf _U_, const u_char *maxbuf)
+print_negprot(netdissect_options *ndo,
+ const u_char *words, const u_char *data, const u_char *buf _U_, const u_char *maxbuf)
{
u_int wct, bcc;
const char *f1 = NULL, *f2 = NULL;
- TCHECK(words[0]);
+ ND_TCHECK(words[0]);
wct = words[0];
if (request)
f2 = "*|Dialect=[Y]\n";
@@ -414,34 +413,34 @@ print_negprot(const u_char *words, const u_char *data, const u_char *buf _U_, co
}
if (f1)
- smb_fdata(words + 1, f1, SMBMIN(words + 1 + wct * 2, maxbuf),
+ smb_fdata(ndo, words + 1, f1, min(words + 1 + wct * 2, maxbuf),
unicodestr);
else
- print_data(words + 1, SMBMIN(wct * 2, PTR_DIFF(maxbuf, words + 1)));
+ print_data(ndo, words + 1, min(wct * 2, PTR_DIFF(maxbuf, words + 1)));
- TCHECK2(*data, 2);
+ ND_TCHECK2(*data, 2);
bcc = EXTRACT_LE_16BITS(data);
- printf("smb_bcc=%u\n", bcc);
+ ND_PRINT((ndo, "smb_bcc=%u\n", bcc));
if (bcc > 0) {
if (f2)
- smb_fdata(data + 2, f2, SMBMIN(data + 2 + EXTRACT_LE_16BITS(data),
+ smb_fdata(ndo, data + 2, f2, min(data + 2 + EXTRACT_LE_16BITS(data),
maxbuf), unicodestr);
else
- print_data(data + 2, SMBMIN(EXTRACT_LE_16BITS(data), PTR_DIFF(maxbuf, data + 2)));
+ print_data(ndo, data + 2, min(EXTRACT_LE_16BITS(data), PTR_DIFF(maxbuf, data + 2)));
}
return;
trunc:
- printf("[|SMB]");
- return;
+ ND_PRINT((ndo, "%s", tstr));
}
static void
-print_sesssetup(const u_char *words, const u_char *data, const u_char *buf _U_, const u_char *maxbuf)
+print_sesssetup(netdissect_options *ndo,
+ const u_char *words, const u_char *data, const u_char *buf _U_, const u_char *maxbuf)
{
u_int wct, bcc;
const char *f1 = NULL, *f2 = NULL;
- TCHECK(words[0]);
+ ND_TCHECK(words[0]);
wct = words[0];
if (request) {
if (wct == 10)
@@ -458,39 +457,39 @@ print_sesssetup(const u_char *words, const u_char *data, const u_char *buf _U_,
}
if (f1)
- smb_fdata(words + 1, f1, SMBMIN(words + 1 + wct * 2, maxbuf),
+ smb_fdata(ndo, words + 1, f1, min(words + 1 + wct * 2, maxbuf),
unicodestr);
else
- print_data(words + 1, SMBMIN(wct * 2, PTR_DIFF(maxbuf, words + 1)));
+ print_data(ndo, words + 1, min(wct * 2, PTR_DIFF(maxbuf, words + 1)));
- TCHECK2(*data, 2);
+ ND_TCHECK2(*data, 2);
bcc = EXTRACT_LE_16BITS(data);
- printf("smb_bcc=%u\n", bcc);
+ ND_PRINT((ndo, "smb_bcc=%u\n", bcc));
if (bcc > 0) {
if (f2)
- smb_fdata(data + 2, f2, SMBMIN(data + 2 + EXTRACT_LE_16BITS(data),
+ smb_fdata(ndo, data + 2, f2, min(data + 2 + EXTRACT_LE_16BITS(data),
maxbuf), unicodestr);
else
- print_data(data + 2, SMBMIN(EXTRACT_LE_16BITS(data), PTR_DIFF(maxbuf, data + 2)));
+ print_data(ndo, data + 2, min(EXTRACT_LE_16BITS(data), PTR_DIFF(maxbuf, data + 2)));
}
return;
trunc:
- printf("[|SMB]");
- return;
+ ND_PRINT((ndo, "%s", tstr));
}
static void
-print_lockingandx(const u_char *words, const u_char *data, const u_char *buf _U_, const u_char *maxbuf)
+print_lockingandx(netdissect_options *ndo,
+ const u_char *words, const u_char *data, const u_char *buf _U_, const u_char *maxbuf)
{
u_int wct, bcc;
const u_char *maxwords;
const char *f1 = NULL, *f2 = NULL;
- TCHECK(words[0]);
+ ND_TCHECK(words[0]);
wct = words[0];
if (request) {
f1 = "Com2=[w]\nOff2=[d]\nHandle=[d]\nLockType=[w]\nTimeOut=[D]\nUnlockCount=[d]\nLockCount=[d]\n";
- TCHECK(words[7]);
+ ND_TCHECK(words[7]);
if (words[7] & 0x10)
f2 = "*Process=[d]\n[P2]Offset=[M]\nLength=[M]\n";
else
@@ -499,28 +498,27 @@ print_lockingandx(const u_char *words, const u_char *data, const u_char *buf _U_
f1 = "Com2=[w]\nOff2=[d]\n";
}
- maxwords = SMBMIN(words + 1 + wct * 2, maxbuf);
+ maxwords = min(words + 1 + wct * 2, maxbuf);
if (wct)
- smb_fdata(words + 1, f1, maxwords, unicodestr);
+ smb_fdata(ndo, words + 1, f1, maxwords, unicodestr);
- TCHECK2(*data, 2);
+ ND_TCHECK2(*data, 2);
bcc = EXTRACT_LE_16BITS(data);
- printf("smb_bcc=%u\n", bcc);
+ ND_PRINT((ndo, "smb_bcc=%u\n", bcc));
if (bcc > 0) {
if (f2)
- smb_fdata(data + 2, f2, SMBMIN(data + 2 + EXTRACT_LE_16BITS(data),
+ smb_fdata(ndo, data + 2, f2, min(data + 2 + EXTRACT_LE_16BITS(data),
maxbuf), unicodestr);
else
- print_data(data + 2, SMBMIN(EXTRACT_LE_16BITS(data), PTR_DIFF(maxbuf, data + 2)));
+ print_data(ndo, data + 2, min(EXTRACT_LE_16BITS(data), PTR_DIFF(maxbuf, data + 2)));
}
return;
trunc:
- printf("[|SMB]");
- return;
+ ND_PRINT((ndo, "%s", tstr));
}
-static struct smbfns smb_fns[] = {
+static const struct smbfns smb_fns[] = {
{ -1, "SMBunknown", 0, DEFDESCRIPT },
{ SMBtcon, "SMBtcon", 0,
@@ -792,19 +790,20 @@ static struct smbfns smb_fns[] = {
* print a SMB message
*/
static void
-print_smb(const u_char *buf, const u_char *maxbuf)
+print_smb(netdissect_options *ndo,
+ const u_char *buf, const u_char *maxbuf)
{
- u_int16_t flags2;
+ uint16_t flags2;
int nterrcodes;
int command;
- u_int32_t nterror;
+ uint32_t nterror;
const u_char *words, *maxwords, *data;
- struct smbfns *fn;
+ const struct smbfns *fn;
const char *fmt_smbheader =
"[P4]SMB Command = [B]\nError class = [BP1]\nError code = [d]\nFlags1 = [B]\nFlags2 = [B][P13]\nTree ID = [d]\nProc ID = [d]\nUID = [d]\nMID = [d]\nWord Count = [b]\n";
int smboffset;
- TCHECK(buf[9]);
+ ND_TCHECK(buf[9]);
request = (buf[9] & 0x80) ? 0 : 1;
flags2 = EXTRACT_LE_16BITS(&buf[10]);
unicodestr = flags2 & 0x8000;
@@ -815,24 +814,24 @@ print_smb(const u_char *buf, const u_char *maxbuf)
fn = smbfind(command, smb_fns);
- if (vflag > 1)
- printf("\n");
+ if (ndo->ndo_vflag > 1)
+ ND_PRINT((ndo, "\n"));
- printf("SMB PACKET: %s (%s)\n", fn->name, request ? "REQUEST" : "REPLY");
+ ND_PRINT((ndo, "SMB PACKET: %s (%s)\n", fn->name, request ? "REQUEST" : "REPLY"));
- if (vflag < 2)
+ if (ndo->ndo_vflag < 2)
return;
/* print out the header */
- smb_fdata(buf, fmt_smbheader, buf + 33, unicodestr);
+ smb_fdata(ndo, buf, fmt_smbheader, buf + 33, unicodestr);
if (nterrcodes) {
nterror = EXTRACT_LE_32BITS(&buf[5]);
if (nterror)
- printf("NTError = %s\n", nt_errstr(nterror));
+ ND_PRINT((ndo, "NTError = %s\n", nt_errstr(nterror)));
} else {
if (buf[5])
- printf("SMBError = %s\n", smb_errstr(buf[5], EXTRACT_LE_16BITS(&buf[7])));
+ ND_PRINT((ndo, "SMBError = %s\n", smb_errstr(buf[5], EXTRACT_LE_16BITS(&buf[7]))));
}
smboffset = 32;
@@ -844,10 +843,10 @@ print_smb(const u_char *buf, const u_char *maxbuf)
int newsmboffset;
words = buf + smboffset;
- TCHECK(words[0]);
+ ND_TCHECK(words[0]);
wct = words[0];
data = words + 1 + wct * 2;
- maxwords = SMBMIN(data, maxbuf);
+ maxwords = min(data, maxbuf);
if (request) {
f1 = fn->descript.req_f1;
@@ -858,33 +857,33 @@ print_smb(const u_char *buf, const u_char *maxbuf)
}
if (fn->descript.fn)
- (*fn->descript.fn)(words, data, buf, maxbuf);
+ (*fn->descript.fn)(ndo, words, data, buf, maxbuf);
else {
if (wct) {
if (f1)
- smb_fdata(words + 1, f1, words + 1 + wct * 2, unicodestr);
+ smb_fdata(ndo, words + 1, f1, words + 1 + wct * 2, unicodestr);
else {
int i;
int v;
for (i = 0; &words[1 + 2 * i] < maxwords; i++) {
- TCHECK2(words[1 + 2 * i], 2);
+ ND_TCHECK2(words[1 + 2 * i], 2);
v = EXTRACT_LE_16BITS(words + 1 + 2 * i);
- printf("smb_vwv[%d]=%d (0x%X)\n", i, v, v);
+ ND_PRINT((ndo, "smb_vwv[%d]=%d (0x%X)\n", i, v, v));
}
}
}
- TCHECK2(*data, 2);
+ ND_TCHECK2(*data, 2);
bcc = EXTRACT_LE_16BITS(data);
- printf("smb_bcc=%u\n", bcc);
+ ND_PRINT((ndo, "smb_bcc=%u\n", bcc));
if (f2) {
if (bcc > 0)
- smb_fdata(data + 2, f2, data + 2 + bcc, unicodestr);
+ smb_fdata(ndo, data + 2, f2, data + 2 + bcc, unicodestr);
} else {
if (bcc > 0) {
- printf("smb_buf[]=\n");
- print_data(data + 2, SMBMIN(bcc, PTR_DIFF(maxbuf, data + 2)));
+ ND_PRINT((ndo, "smb_buf[]=\n"));
+ print_data(ndo, data + 2, min(bcc, PTR_DIFF(maxbuf, data + 2)));
}
}
}
@@ -893,29 +892,28 @@ print_smb(const u_char *buf, const u_char *maxbuf)
break;
if (wct == 0)
break;
- TCHECK(words[1]);
+ ND_TCHECK(words[1]);
command = words[1];
if (command == 0xFF)
break;
- TCHECK2(words[3], 2);
- newsmboffset = EXTRACT_LE_16BITS(words + 3);
+ ND_TCHECK2(words[3], 2);
+ newsmboffset = EXTRACT_LE_16BITS(words + 3);
fn = smbfind(command, smb_fns);
- printf("\nSMB PACKET: %s (%s) (CHAINED)\n",
- fn->name, request ? "REQUEST" : "REPLY");
+ ND_PRINT((ndo, "\nSMB PACKET: %s (%s) (CHAINED)\n",
+ fn->name, request ? "REQUEST" : "REPLY"));
if (newsmboffset <= smboffset) {
- printf("Bad andX offset: %u <= %u\n", newsmboffset, smboffset);
+ ND_PRINT((ndo, "Bad andX offset: %u <= %u\n", newsmboffset, smboffset));
break;
}
smboffset = newsmboffset;
}
- printf("\n");
+ ND_PRINT((ndo, "\n"));
return;
trunc:
- printf("[|SMB]");
- return;
+ ND_PRINT((ndo, "%s", tstr));
}
@@ -923,7 +921,8 @@ trunc:
* print a NBT packet received across tcp on port 139
*/
void
-nbt_tcp_print(const u_char *data, int length)
+nbt_tcp_print(netdissect_options *ndo,
+ const u_char *data, int length)
{
int caplen;
int type;
@@ -932,9 +931,9 @@ nbt_tcp_print(const u_char *data, int length)
if (length < 4)
goto trunc;
- if (snapend < data)
+ if (ndo->ndo_snapend < data)
goto trunc;
- caplen = snapend - data;
+ caplen = ndo->ndo_snapend - data;
if (caplen < 4)
goto trunc;
maxbuf = data + caplen;
@@ -945,19 +944,19 @@ nbt_tcp_print(const u_char *data, int length)
startbuf = data;
- if (vflag < 2) {
- printf(" NBT Session Packet: ");
+ if (ndo->ndo_vflag < 2) {
+ ND_PRINT((ndo, " NBT Session Packet: "));
switch (type) {
case 0x00:
- printf("Session Message");
+ ND_PRINT((ndo, "Session Message"));
break;
case 0x81:
- printf("Session Request");
+ ND_PRINT((ndo, "Session Request"));
break;
case 0x82:
- printf("Session Granted");
+ ND_PRINT((ndo, "Session Granted"));
break;
case 0x83:
@@ -972,64 +971,64 @@ nbt_tcp_print(const u_char *data, int length)
goto trunc;
ecode = data[4];
- printf("Session Reject, ");
+ ND_PRINT((ndo, "Session Reject, "));
switch (ecode) {
case 0x80:
- printf("Not listening on called name");
+ ND_PRINT((ndo, "Not listening on called name"));
break;
case 0x81:
- printf("Not listening for calling name");
+ ND_PRINT((ndo, "Not listening for calling name"));
break;
case 0x82:
- printf("Called name not present");
+ ND_PRINT((ndo, "Called name not present"));
break;
case 0x83:
- printf("Called name present, but insufficient resources");
+ ND_PRINT((ndo, "Called name present, but insufficient resources"));
break;
default:
- printf("Unspecified error 0x%X", ecode);
+ ND_PRINT((ndo, "Unspecified error 0x%X", ecode));
break;
}
}
break;
case 0x85:
- printf("Session Keepalive");
+ ND_PRINT((ndo, "Session Keepalive"));
break;
default:
- data = smb_fdata(data, "Unknown packet type [rB]", maxbuf, 0);
+ data = smb_fdata(ndo, data, "Unknown packet type [rB]", maxbuf, 0);
break;
}
} else {
- printf ("\n>>> NBT Session Packet\n");
+ ND_PRINT((ndo, "\n>>> NBT Session Packet\n"));
switch (type) {
case 0x00:
- data = smb_fdata(data, "[P1]NBT Session Message\nFlags=[B]\nLength=[rd]\n",
+ data = smb_fdata(ndo, data, "[P1]NBT Session Message\nFlags=[B]\nLength=[rd]\n",
data + 4, 0);
if (data == NULL)
break;
if (nbt_len >= 4 && caplen >= 4 && memcmp(data,"\377SMB",4) == 0) {
if ((int)nbt_len > caplen) {
if ((int)nbt_len > length)
- printf("WARNING: Packet is continued in later TCP segments\n");
+ ND_PRINT((ndo, "WARNING: Packet is continued in later TCP segments\n"));
else
- printf("WARNING: Short packet. Try increasing the snap length by %d\n",
- nbt_len - caplen);
+ ND_PRINT((ndo, "WARNING: Short packet. Try increasing the snap length by %d\n",
+ nbt_len - caplen));
}
- print_smb(data, maxbuf > data + nbt_len ? data + nbt_len : maxbuf);
+ print_smb(ndo, data, maxbuf > data + nbt_len ? data + nbt_len : maxbuf);
} else
- printf("Session packet:(raw data or continuation?)\n");
+ ND_PRINT((ndo, "Session packet:(raw data or continuation?)\n"));
break;
case 0x81:
- data = smb_fdata(data,
+ data = smb_fdata(ndo, data,
"[P1]NBT Session Request\nFlags=[B]\nLength=[rd]\nDestination=[n1]\nSource=[n1]\n",
maxbuf, 0);
break;
case 0x82:
- data = smb_fdata(data, "[P1]NBT Session Granted\nFlags=[B]\nLength=[rd]\n", maxbuf, 0);
+ data = smb_fdata(ndo, data, "[P1]NBT Session Granted\nFlags=[B]\nLength=[rd]\n", maxbuf, 0);
break;
case 0x83:
@@ -1038,7 +1037,7 @@ nbt_tcp_print(const u_char *data, int length)
int ecode;
origdata = data;
- data = smb_fdata(data, "[P1]NBT SessionReject\nFlags=[B]\nLength=[rd]\nReason=[B]\n",
+ data = smb_fdata(ndo, data, "[P1]NBT SessionReject\nFlags=[B]\nLength=[rd]\nReason=[B]\n",
maxbuf, 0);
if (data == NULL)
break;
@@ -1046,19 +1045,19 @@ nbt_tcp_print(const u_char *data, int length)
ecode = origdata[4];
switch (ecode) {
case 0x80:
- printf("Not listening on called name\n");
+ ND_PRINT((ndo, "Not listening on called name\n"));
break;
case 0x81:
- printf("Not listening for calling name\n");
+ ND_PRINT((ndo, "Not listening for calling name\n"));
break;
case 0x82:
- printf("Called name not present\n");
+ ND_PRINT((ndo, "Called name not present\n"));
break;
case 0x83:
- printf("Called name present, but insufficient resources\n");
+ ND_PRINT((ndo, "Called name present, but insufficient resources\n"));
break;
default:
- printf("Unspecified error 0x%X\n", ecode);
+ ND_PRINT((ndo, "Unspecified error 0x%X\n", ecode));
break;
}
}
@@ -1066,37 +1065,45 @@ nbt_tcp_print(const u_char *data, int length)
break;
case 0x85:
- data = smb_fdata(data, "[P1]NBT Session Keepalive\nFlags=[B]\nLength=[rd]\n", maxbuf, 0);
+ data = smb_fdata(ndo, data, "[P1]NBT Session Keepalive\nFlags=[B]\nLength=[rd]\n", maxbuf, 0);
break;
default:
- data = smb_fdata(data, "NBT - Unknown packet type\nType=[B]\n", maxbuf, 0);
+ data = smb_fdata(ndo, data, "NBT - Unknown packet type\nType=[B]\n", maxbuf, 0);
break;
}
- printf("\n");
- fflush(stdout);
+ ND_PRINT((ndo, "\n"));
}
return;
trunc:
- printf("[|SMB]");
- return;
+ ND_PRINT((ndo, "%s", tstr));
}
+static const struct tok opcode_str[] = {
+ { 0, "QUERY" },
+ { 5, "REGISTRATION" },
+ { 6, "RELEASE" },
+ { 7, "WACK" },
+ { 8, "REFRESH(8)" },
+ { 9, "REFRESH" },
+ { 15, "MULTIHOMED REGISTRATION" },
+ { 0, NULL }
+};
/*
* print a NBT packet received across udp on port 137
*/
void
-nbt_udp137_print(const u_char *data, int length)
+nbt_udp137_print(netdissect_options *ndo,
+ const u_char *data, int length)
{
const u_char *maxbuf = data + length;
int name_trn_id, response, opcode, nm_flags, rcode;
int qdcount, ancount, nscount, arcount;
- const char *opcodestr;
const u_char *p;
int total, i;
- TCHECK2(data[10], 2);
+ ND_TCHECK2(data[10], 2);
name_trn_id = EXTRACT_16BITS(data);
response = (data[2] >> 7);
opcode = (data[2] >> 3) & 0xF;
@@ -1111,59 +1118,36 @@ nbt_udp137_print(const u_char *data, int length)
if (maxbuf <= data)
return;
- if (vflag > 1)
- printf("\n>>> ");
-
- printf("NBT UDP PACKET(137): ");
+ if (ndo->ndo_vflag > 1)
+ ND_PRINT((ndo, "\n>>> "));
- switch (opcode) {
- case 0: opcodestr = "QUERY"; break;
- case 5: opcodestr = "REGISTRATION"; break;
- case 6: opcodestr = "RELEASE"; break;
- case 7: opcodestr = "WACK"; break;
- case 8: opcodestr = "REFRESH(8)"; break;
- case 9: opcodestr = "REFRESH"; break;
- case 15: opcodestr = "MULTIHOMED REGISTRATION"; break;
- default: opcodestr = "OPUNKNOWN"; break;
- }
- printf("%s", opcodestr);
+ ND_PRINT((ndo, "NBT UDP PACKET(137): %s", tok2str(opcode_str, "OPUNKNOWN", opcode)));
if (response) {
- if (rcode)
- printf("; NEGATIVE");
- else
- printf("; POSITIVE");
+ ND_PRINT((ndo, "; %s", rcode ? "NEGATIVE" : "POSITIVE"));
}
+ ND_PRINT((ndo, "; %s; %s", response ? "RESPONSE" : "REQUEST",
+ (nm_flags & 1) ? "BROADCAST" : "UNICAST"));
- if (response)
- printf("; RESPONSE");
- else
- printf("; REQUEST");
-
- if (nm_flags & 1)
- printf("; BROADCAST");
- else
- printf("; UNICAST");
-
- if (vflag < 2)
+ if (ndo->ndo_vflag < 2)
return;
- printf("\nTrnID=0x%X\nOpCode=%d\nNmFlags=0x%X\nRcode=%d\nQueryCount=%d\nAnswerCount=%d\nAuthorityCount=%d\nAddressRecCount=%d\n",
+ ND_PRINT((ndo, "\nTrnID=0x%X\nOpCode=%d\nNmFlags=0x%X\nRcode=%d\nQueryCount=%d\nAnswerCount=%d\nAuthorityCount=%d\nAddressRecCount=%d\n",
name_trn_id, opcode, nm_flags, rcode, qdcount, ancount, nscount,
- arcount);
+ arcount));
p = data + 12;
total = ancount + nscount + arcount;
if (qdcount > 100 || total > 100) {
- printf("Corrupt packet??\n");
+ ND_PRINT((ndo, "Corrupt packet??\n"));
return;
}
if (qdcount) {
- printf("QuestionRecords:\n");
+ ND_PRINT((ndo, "QuestionRecords:\n"));
for (i = 0; i < qdcount; i++) {
- p = smb_fdata(p,
+ p = smb_fdata(ndo, p,
"|Name=[n1]\nQuestionType=[rw]\nQuestionClass=[rw]\n#",
maxbuf, 0);
if (p == NULL)
@@ -1172,60 +1156,60 @@ nbt_udp137_print(const u_char *data, int length)
}
if (total) {
- printf("\nResourceRecords:\n");
+ ND_PRINT((ndo, "\nResourceRecords:\n"));
for (i = 0; i < total; i++) {
int rdlen;
int restype;
- p = smb_fdata(p, "Name=[n1]\n#", maxbuf, 0);
+ p = smb_fdata(ndo, p, "Name=[n1]\n#", maxbuf, 0);
if (p == NULL)
goto out;
restype = EXTRACT_16BITS(p);
- p = smb_fdata(p, "ResType=[rw]\nResClass=[rw]\nTTL=[rD]\n", p + 8, 0);
+ p = smb_fdata(ndo, p, "ResType=[rw]\nResClass=[rw]\nTTL=[rD]\n", p + 8, 0);
if (p == NULL)
goto out;
rdlen = EXTRACT_16BITS(p);
- printf("ResourceLength=%d\nResourceData=\n", rdlen);
+ ND_PRINT((ndo, "ResourceLength=%d\nResourceData=\n", rdlen));
p += 2;
if (rdlen == 6) {
- p = smb_fdata(p, "AddrType=[rw]\nAddress=[b.b.b.b]\n", p + rdlen, 0);
+ p = smb_fdata(ndo, p, "AddrType=[rw]\nAddress=[b.b.b.b]\n", p + rdlen, 0);
if (p == NULL)
goto out;
} else {
if (restype == 0x21) {
int numnames;
- TCHECK(*p);
+ ND_TCHECK(*p);
numnames = p[0];
- p = smb_fdata(p, "NumNames=[B]\n", p + 1, 0);
+ p = smb_fdata(ndo, p, "NumNames=[B]\n", p + 1, 0);
if (p == NULL)
goto out;
while (numnames--) {
- p = smb_fdata(p, "Name=[n2]\t#", maxbuf, 0);
+ p = smb_fdata(ndo, p, "Name=[n2]\t#", maxbuf, 0);
if (p == NULL)
goto out;
- TCHECK(*p);
+ ND_TCHECK(*p);
if (p[0] & 0x80)
- printf("<GROUP> ");
+ ND_PRINT((ndo, "<GROUP> "));
switch (p[0] & 0x60) {
- case 0x00: printf("B "); break;
- case 0x20: printf("P "); break;
- case 0x40: printf("M "); break;
- case 0x60: printf("_ "); break;
+ case 0x00: ND_PRINT((ndo, "B ")); break;
+ case 0x20: ND_PRINT((ndo, "P ")); break;
+ case 0x40: ND_PRINT((ndo, "M ")); break;
+ case 0x60: ND_PRINT((ndo, "_ ")); break;
}
if (p[0] & 0x10)
- printf("<DEREGISTERING> ");
+ ND_PRINT((ndo, "<DEREGISTERING> "));
if (p[0] & 0x08)
- printf("<CONFLICT> ");
+ ND_PRINT((ndo, "<CONFLICT> "));
if (p[0] & 0x04)
- printf("<ACTIVE> ");
+ ND_PRINT((ndo, "<ACTIVE> "));
if (p[0] & 0x02)
- printf("<PERMANENT> ");
- printf("\n");
+ ND_PRINT((ndo, "<PERMANENT> "));
+ ND_PRINT((ndo, "\n"));
p += 2;
}
} else {
- print_data(p, min(rdlen, length - (p - data)));
+ print_data(ndo, p, min(rdlen, length - (p - data)));
p += rdlen;
}
}
@@ -1233,22 +1217,21 @@ nbt_udp137_print(const u_char *data, int length)
}
if (p < maxbuf)
- smb_fdata(p, "AdditionalData:\n", maxbuf, 0);
+ smb_fdata(ndo, p, "AdditionalData:\n", maxbuf, 0);
out:
- printf("\n");
- fflush(stdout);
+ ND_PRINT((ndo, "\n"));
return;
trunc:
- printf("[|SMB]");
- return;
+ ND_PRINT((ndo, "%s", tstr));
}
/*
* Print an SMB-over-TCP packet received across tcp on port 445
*/
void
-smb_tcp_print (const u_char * data, int length)
+smb_tcp_print(netdissect_options *ndo,
+ const u_char * data, int length)
{
int caplen;
u_int smb_len;
@@ -1256,9 +1239,9 @@ smb_tcp_print (const u_char * data, int length)
if (length < 4)
goto trunc;
- if (snapend < data)
+ if (ndo->ndo_snapend < data)
goto trunc;
- caplen = snapend - data;
+ caplen = ndo->ndo_snapend - data;
if (caplen < 4)
goto trunc;
maxbuf = data + caplen;
@@ -1272,40 +1255,40 @@ smb_tcp_print (const u_char * data, int length)
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");
+ ND_PRINT((ndo, "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);
+ ND_PRINT((ndo, "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);
+ print_smb(ndo, data, maxbuf > data + smb_len ? data + smb_len : maxbuf);
} else
- printf("SMB-over-TCP packet:(raw data or continuation?)\n");
+ ND_PRINT((ndo, "SMB-over-TCP packet:(raw data or continuation?)\n"));
return;
trunc:
- printf("[|SMB]");
- return;
+ ND_PRINT((ndo, "%s", tstr));
}
/*
* print a NBT packet received across udp on port 138
*/
void
-nbt_udp138_print(const u_char *data, int length)
+nbt_udp138_print(netdissect_options *ndo,
+ const u_char *data, int length)
{
const u_char *maxbuf = data + length;
- if (maxbuf > snapend)
- maxbuf = snapend;
+ if (maxbuf > ndo->ndo_snapend)
+ maxbuf = ndo->ndo_snapend;
if (maxbuf <= data)
return;
startbuf = data;
- if (vflag < 2) {
- printf("NBT UDP PACKET(138)");
+ if (ndo->ndo_vflag < 2) {
+ ND_PRINT((ndo, "NBT UDP PACKET(138)"));
return;
}
- data = smb_fdata(data,
+ data = smb_fdata(ndo, data,
"\n>>> NBT UDP PACKET(138) Res=[rw] ID=[rw] IP=[b.b.b.b] Port=[rd] Length=[rd] Res2=[rw]\nSourceName=[n1]\nDestName=[n1]\n#",
maxbuf, 0);
@@ -1315,11 +1298,10 @@ nbt_udp138_print(const u_char *data, int length)
goto out;
if (memcmp(data, "\377SMB",4) == 0)
- print_smb(data, maxbuf);
+ print_smb(ndo, data, maxbuf);
}
out:
- printf("\n");
- fflush(stdout);
+ ND_PRINT((ndo, "\n"));
}
@@ -1382,7 +1364,8 @@ struct nbf_strings {
};
void
-netbeui_print(u_short control, const u_char *data, int length)
+netbeui_print(netdissect_options *ndo,
+ u_short control, const u_char *data, int length)
{
const u_char *maxbuf = data + length;
int len;
@@ -1390,9 +1373,9 @@ netbeui_print(u_short control, const u_char *data, int length)
const u_char *data2;
int is_truncated = 0;
- if (maxbuf > snapend)
- maxbuf = snapend;
- TCHECK(data[4]);
+ if (maxbuf > ndo->ndo_snapend)
+ maxbuf = ndo->ndo_snapend;
+ ND_TCHECK(data[4]);
len = EXTRACT_LE_16BITS(data);
command = data[4];
data2 = data + len;
@@ -1403,36 +1386,36 @@ netbeui_print(u_short control, const u_char *data, int length)
startbuf = data;
- if (vflag < 2) {
- printf("NBF Packet: ");
- data = smb_fdata(data, "[P5]#", maxbuf, 0);
+ if (ndo->ndo_vflag < 2) {
+ ND_PRINT((ndo, "NBF Packet: "));
+ data = smb_fdata(ndo, data, "[P5]#", maxbuf, 0);
} else {
- printf("\n>>> NBF Packet\nType=0x%X ", control);
- data = smb_fdata(data, "Length=[d] Signature=[w] Command=[B]\n#", maxbuf, 0);
+ ND_PRINT((ndo, "\n>>> NBF Packet\nType=0x%X ", control));
+ data = smb_fdata(ndo, data, "Length=[d] Signature=[w] Command=[B]\n#", maxbuf, 0);
}
if (data == NULL)
goto out;
if (command > 0x1f || nbf_strings[command].name == NULL) {
- if (vflag < 2)
- data = smb_fdata(data, "Unknown NBF Command#", data2, 0);
+ if (ndo->ndo_vflag < 2)
+ data = smb_fdata(ndo, data, "Unknown NBF Command#", data2, 0);
else
- data = smb_fdata(data, "Unknown NBF Command\n", data2, 0);
+ data = smb_fdata(ndo, data, "Unknown NBF Command\n", data2, 0);
} else {
- if (vflag < 2) {
- printf("%s", nbf_strings[command].name);
+ if (ndo->ndo_vflag < 2) {
+ ND_PRINT((ndo, "%s", nbf_strings[command].name));
if (nbf_strings[command].nonverbose != NULL)
- data = smb_fdata(data, nbf_strings[command].nonverbose, data2, 0);
+ data = smb_fdata(ndo, data, nbf_strings[command].nonverbose, data2, 0);
} else {
- printf("%s:\n", nbf_strings[command].name);
+ ND_PRINT((ndo, "%s:\n", nbf_strings[command].name));
if (nbf_strings[command].verbose != NULL)
- data = smb_fdata(data, nbf_strings[command].verbose, data2, 0);
+ data = smb_fdata(ndo, data, nbf_strings[command].verbose, data2, 0);
else
- printf("\n");
+ ND_PRINT((ndo, "\n"));
}
}
- if (vflag < 2)
+ if (ndo->ndo_vflag < 2)
return;
if (data == NULL)
@@ -1453,26 +1436,25 @@ netbeui_print(u_short control, const u_char *data, int length)
goto out;
if (memcmp(data2, "\377SMB",4) == 0)
- print_smb(data2, maxbuf);
+ print_smb(ndo, data2, maxbuf);
else {
int i;
for (i = 0; i < 128; i++) {
if (&data2[i + 3] >= maxbuf)
break;
if (memcmp(&data2[i], "\377SMB", 4) == 0) {
- printf("found SMB packet at %d\n", i);
- print_smb(&data2[i], maxbuf);
+ ND_PRINT((ndo, "found SMB packet at %d\n", i));
+ print_smb(ndo, &data2[i], maxbuf);
break;
}
}
}
out:
- printf("\n");
+ ND_PRINT((ndo, "\n"));
return;
trunc:
- printf("[|SMB]");
- return;
+ ND_PRINT((ndo, "%s", tstr));
}
@@ -1480,7 +1462,8 @@ trunc:
* print IPX-Netbios frames
*/
void
-ipx_netbios_print(const u_char *data, u_int length)
+ipx_netbios_print(netdissect_options *ndo,
+ const u_char *data, u_int length)
{
/*
* this is a hack till I work out how to parse the rest of the
@@ -1491,20 +1474,19 @@ ipx_netbios_print(const u_char *data, u_int length)
maxbuf = data + length;
/* Don't go past the end of the captured data in the packet. */
- if (maxbuf > snapend)
- maxbuf = snapend;
+ if (maxbuf > ndo->ndo_snapend)
+ maxbuf = ndo->ndo_snapend;
startbuf = data;
for (i = 0; i < 128; i++) {
if (&data[i + 4] > maxbuf)
break;
if (memcmp(&data[i], "\377SMB", 4) == 0) {
- smb_fdata(data, "\n>>> IPX transport ", &data[i], 0);
- print_smb(&data[i], maxbuf);
- printf("\n");
- fflush(stdout);
+ smb_fdata(ndo, data, "\n>>> IPX transport ", &data[i], 0);
+ print_smb(ndo, &data[i], maxbuf);
+ ND_PRINT((ndo, "\n"));
break;
}
}
if (i == 128)
- smb_fdata(data, "\n>>> Unknown IPX ", maxbuf, 0);
+ smb_fdata(ndo, data, "\n>>> Unknown IPX ", maxbuf, 0);
}
diff --git a/contrib/tcpdump/print-snmp.c b/contrib/tcpdump/print-snmp.c
index 728da6beb79e..f5501582ba7a 100644
--- a/contrib/tcpdump/print-snmp.c
+++ b/contrib/tcpdump/print-snmp.c
@@ -56,11 +56,7 @@
# @(#)snmp.awk.x 1.1 (LANL) 1/15/90
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-snmp.c,v 1.64 2005-05-06 07:56:53 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -70,20 +66,21 @@ static const char rcsid[] _U_ =
#include <stdio.h>
#include <string.h>
-#ifdef HAVE_SMI_H
+#ifdef USE_LIBSMI
#include <smi.h>
#endif
#include "interface.h"
-#include "addrtoname.h"
#undef OPAQUE /* defined in <wingdi.h> */
+static const char tstr[] = "[|snmp]";
+
/*
* Universal ASN.1 types
* (we only care about the tag values for those allowed in the Internet SMI)
*/
-const char *Universal[] = {
+static const char *Universal[] = {
"U-0",
"Boolean",
"Integer",
@@ -106,7 +103,7 @@ const char *Universal[] = {
/*
* Application-wide ASN.1 types from the Internet SMI and their tags
*/
-const char *Application[] = {
+static const char *Application[] = {
"IpAddress",
#define IPADDR 0
"Counter",
@@ -125,7 +122,7 @@ const char *Application[] = {
/*
* Context-specific ASN.1 types for the SNMP PDUs and their tags
*/
-const char *Context[] = {
+static const char *Context[] = {
"GetRequest",
#define GETREQ 0
"GetNextRequest",
@@ -155,7 +152,7 @@ const char *Context[] = {
/*
* Context-specific ASN.1 types for the SNMP Exceptions and their tags
*/
-const char *Exceptions[] = {
+static const char *Exceptions[] = {
"noSuchObject",
#define NOSUCHOBJECT 0
"noSuchInstance",
@@ -168,14 +165,14 @@ const char *Exceptions[] = {
* Private ASN.1 types
* The Internet SMI does not specify any
*/
-const char *Private[] = {
+static const char *Private[] = {
"P-0"
};
/*
* error-status values for any SNMP PDU
*/
-const char *ErrorStatus[] = {
+static const char *ErrorStatus[] = {
"noError",
"tooBig",
"noSuchName",
@@ -204,7 +201,7 @@ const char *ErrorStatus[] = {
/*
* generic-trap values in the SNMP Trap-PDU
*/
-const char *GenericTrap[] = {
+static const char *GenericTrap[] = {
"coldStart",
"warmStart",
"linkDown",
@@ -225,7 +222,7 @@ const char *GenericTrap[] = {
* type definitions.
*/
#define defineCLASS(x) { "x", x, sizeof(x)/sizeof(x[0]) } /* not ANSI-C */
-struct {
+static const struct {
const char *name;
const char **Id;
int numIDs;
@@ -245,7 +242,7 @@ struct {
/*
* defined forms for ASN.1 types
*/
-const char *Form[] = {
+static const char *Form[] = {
"Primitive",
#define PRIMITIVE 0
"Constructed",
@@ -278,7 +275,7 @@ struct obj {
* Currently, this includes the prefixes for the Internet MIB, the
* private enterprises tree, and the experimental tree.
*/
-struct obj_abrev {
+static const struct obj_abrev {
const char *prefix; /* prefix for this abrev */
struct obj *node; /* pointer into object table */
const char *oid; /* ASN.1 encoded OID */
@@ -315,10 +312,10 @@ struct obj_abrev {
} while ((objp = objp->next) != NULL); \
} \
if (objp) { \
- printf(suppressdot?"%s":".%s", objp->desc); \
+ ND_PRINT((ndo, suppressdot?"%s":".%s", objp->desc)); \
objp = objp->child; \
} else \
- printf(suppressdot?"%u":".%u", (o)); \
+ ND_PRINT((ndo, suppressdot?"%u":".%u", (o))); \
}
/*
@@ -326,15 +323,15 @@ struct obj_abrev {
* temporary internal representation while decoding an ASN.1 data stream.
*/
struct be {
- u_int32_t asnlen;
+ uint32_t asnlen;
union {
caddr_t raw;
int32_t integer;
- u_int32_t uns;
+ uint32_t uns;
const u_char *str;
struct {
- u_int32_t high;
- u_int32_t low;
+ uint32_t high;
+ uint32_t low;
} uns64;
} data;
u_short id;
@@ -360,7 +357,7 @@ struct be {
/*
* SNMP versions recognized by this module
*/
-const char *SnmpVersion[] = {
+static const char *SnmpVersion[] = {
"SNMPv1",
#define SNMP_VERSION_1 0
"SNMPv2c",
@@ -403,7 +400,8 @@ const char *SnmpVersion[] = {
* O/w, this returns the number of bytes parsed from "p".
*/
static int
-asn1_parse(register const u_char *p, u_int len, struct be *elem)
+asn1_parse(netdissect_options *ndo,
+ register const u_char *p, u_int len, struct be *elem)
{
u_char form, class, id;
int i, hdr;
@@ -411,10 +409,10 @@ asn1_parse(register const u_char *p, u_int len, struct be *elem)
elem->asnlen = 0;
elem->type = BE_ANY;
if (len < 1) {
- fputs("[nothing to parse]", stdout);
+ ND_PRINT((ndo, "[nothing to parse]"));
return -1;
}
- TCHECK(*p);
+ ND_TCHECK(*p);
/*
* it would be nice to use a bit field, but you can't depend on them.
@@ -450,54 +448,54 @@ asn1_parse(register const u_char *p, u_int len, struct be *elem)
*/
for (id = 0; *p & ASN_BIT8; len--, hdr++, p++) {
if (len < 1) {
- fputs("[Xtagfield?]", stdout);
+ ND_PRINT((ndo, "[Xtagfield?]"));
return -1;
}
- TCHECK(*p);
+ ND_TCHECK(*p);
id = (id << 7) | (*p & ~ASN_BIT8);
}
if (len < 1) {
- fputs("[Xtagfield?]", stdout);
+ ND_PRINT((ndo, "[Xtagfield?]"));
return -1;
}
- TCHECK(*p);
+ ND_TCHECK(*p);
elem->id = id = (id << 7) | *p;
--len;
++hdr;
++p;
}
if (len < 1) {
- fputs("[no asnlen]", stdout);
+ ND_PRINT((ndo, "[no asnlen]"));
return -1;
}
- TCHECK(*p);
+ ND_TCHECK(*p);
elem->asnlen = *p;
p++; len--; hdr++;
if (elem->asnlen & ASN_BIT8) {
- u_int32_t noct = elem->asnlen % ASN_BIT8;
+ uint32_t noct = elem->asnlen % ASN_BIT8;
elem->asnlen = 0;
if (len < noct) {
- printf("[asnlen? %d<%d]", len, noct);
+ ND_PRINT((ndo, "[asnlen? %d<%d]", len, noct));
return -1;
}
- TCHECK2(*p, noct);
+ ND_TCHECK2(*p, noct);
for (; noct-- > 0; len--, hdr++)
elem->asnlen = (elem->asnlen << ASN_SHIFT8) | *p++;
}
if (len < elem->asnlen) {
- printf("[len%d<asnlen%u]", len, elem->asnlen);
+ ND_PRINT((ndo, "[len%d<asnlen%u]", len, elem->asnlen));
return -1;
}
if (form >= sizeof(Form)/sizeof(Form[0])) {
- printf("[form?%d]", form);
+ ND_PRINT((ndo, "[form?%d]", form));
return -1;
}
if (class >= sizeof(Class)/sizeof(Class[0])) {
- printf("[class?%c/%d]", *Form[form], class);
+ ND_PRINT((ndo, "[class?%c/%d]", *Form[form], class));
return -1;
}
if ((int)id >= Class[class].numIDs) {
- printf("[id?%c/%s/%d]", *Form[form], Class[class].name, id);
+ ND_PRINT((ndo, "[id?%c/%s/%d]", *Form[form], Class[class].name, id));
return -1;
}
@@ -516,7 +514,7 @@ asn1_parse(register const u_char *p, u_int len, struct be *elem)
elem->type = BE_INT;
data = 0;
- TCHECK2(*p, elem->asnlen);
+ ND_TCHECK2(*p, elem->asnlen);
if (*p & ASN_BIT8) /* negative */
data = -1;
for (i = elem->asnlen; i-- > 0; p++)
@@ -538,8 +536,7 @@ asn1_parse(register const u_char *p, u_int len, struct be *elem)
default:
elem->type = BE_OCTET;
elem->data.raw = (caddr_t)p;
- printf("[P/U/%s]",
- Class[class].Id[id]);
+ ND_PRINT((ndo, "[P/U/%s]", Class[class].Id[id]));
break;
}
break;
@@ -554,8 +551,8 @@ asn1_parse(register const u_char *p, u_int len, struct be *elem)
case COUNTER:
case GAUGE:
case TIMETICKS: {
- register u_int32_t data;
- TCHECK2(*p, elem->asnlen);
+ register uint32_t data;
+ ND_TCHECK2(*p, elem->asnlen);
elem->type = BE_UNS;
data = 0;
for (i = elem->asnlen; i-- > 0; p++)
@@ -565,8 +562,8 @@ asn1_parse(register const u_char *p, u_int len, struct be *elem)
}
case COUNTER64: {
- register u_int32_t high, low;
- TCHECK2(*p, elem->asnlen);
+ register uint32_t high, low;
+ ND_TCHECK2(*p, elem->asnlen);
elem->type = BE_UNS64;
high = 0, low = 0;
for (i = elem->asnlen; i-- > 0; p++) {
@@ -582,8 +579,8 @@ asn1_parse(register const u_char *p, u_int len, struct be *elem)
default:
elem->type = BE_OCTET;
elem->data.raw = (caddr_t)p;
- printf("[P/A/%s]",
- Class[class].Id[id]);
+ ND_PRINT((ndo, "[P/A/%s]",
+ Class[class].Id[id]));
break;
}
break;
@@ -608,9 +605,8 @@ asn1_parse(register const u_char *p, u_int len, struct be *elem)
break;
default:
- printf("[P/%s/%s]",
- Class[class].name, Class[class].Id[id]);
- TCHECK2(*p, elem->asnlen);
+ ND_PRINT((ndo, "[P/%s/%s]", Class[class].name, Class[class].Id[id]));
+ ND_TCHECK2(*p, elem->asnlen);
elem->type = BE_OCTET;
elem->data.raw = (caddr_t)p;
break;
@@ -629,7 +625,7 @@ asn1_parse(register const u_char *p, u_int len, struct be *elem)
default:
elem->type = BE_OCTET;
elem->data.raw = (caddr_t)p;
- printf("C/U/%s", Class[class].Id[id]);
+ ND_PRINT((ndo, "C/U/%s", Class[class].Id[id]));
break;
}
break;
@@ -642,8 +638,7 @@ asn1_parse(register const u_char *p, u_int len, struct be *elem)
default:
elem->type = BE_OCTET;
elem->data.raw = (caddr_t)p;
- printf("C/%s/%s",
- Class[class].name, Class[class].Id[id]);
+ ND_PRINT((ndo, "C/%s/%s", Class[class].name, Class[class].Id[id]));
break;
}
break;
@@ -653,7 +648,7 @@ asn1_parse(register const u_char *p, u_int len, struct be *elem)
return elem->asnlen + hdr;
trunc:
- fputs("[|snmp]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
@@ -663,18 +658,19 @@ trunc:
* BE form was added.
*/
static int
-asn1_print(struct be *elem)
+asn1_print(netdissect_options *ndo,
+ struct be *elem)
{
u_char *p = (u_char *)elem->data.raw;
- u_int32_t asnlen = elem->asnlen;
- u_int32_t i;
+ uint32_t asnlen = elem->asnlen;
+ uint32_t i;
switch (elem->type) {
case BE_OCTET:
- TCHECK2(*p, asnlen);
+ ND_TCHECK2(*p, asnlen);
for (i = asnlen; i-- > 0; p++)
- printf("_%.2x", *p);
+ ND_PRINT((ndo, "_%.2x", *p));
break;
case BE_NULL:
@@ -683,24 +679,24 @@ asn1_print(struct be *elem)
case BE_OID: {
int o = 0, first = -1, i = asnlen;
- if (!sflag && !nflag && asnlen > 2) {
- struct obj_abrev *a = &obj_abrev_list[0];
+ if (!ndo->ndo_sflag && !ndo->ndo_nflag && asnlen > 2) {
+ const struct obj_abrev *a = &obj_abrev_list[0];
size_t a_len = strlen(a->oid);
for (; a->node; a++) {
- TCHECK2(*p, a_len);
+ ND_TCHECK2(*p, a_len);
if (memcmp(a->oid, (char *)p, a_len) == 0) {
objp = a->node->child;
i -= strlen(a->oid);
p += strlen(a->oid);
- fputs(a->prefix, stdout);
+ ND_PRINT((ndo, "%s", a->prefix));
first = 1;
break;
}
}
}
- for (; !sflag && i-- > 0; p++) {
- TCHECK(*p);
+ for (; !ndo->ndo_sflag && i-- > 0; p++) {
+ ND_TCHECK(*p);
o = (o << ASN_SHIFT7) + (*p & ~ASN_BIT8);
if (*p & ASN_LONGLEN)
continue;
@@ -711,7 +707,7 @@ asn1_print(struct be *elem)
*/
if (first < 0) {
int s;
- if (!nflag)
+ if (!ndo->ndo_nflag)
objp = mibroot;
first = 0;
s = o / OIDMUX;
@@ -728,11 +724,11 @@ asn1_print(struct be *elem)
}
case BE_INT:
- printf("%d", elem->data.integer);
+ ND_PRINT((ndo, "%d", elem->data.integer));
break;
case BE_UNS:
- printf("%u", elem->data.uns);
+ ND_PRINT((ndo, "%u", elem->data.uns));
break;
case BE_UNS64: { /* idea borrowed from by Marshall Rose */
@@ -740,16 +736,16 @@ asn1_print(struct be *elem)
int j, carry;
char *cpf, *cpl, last[6], first[30];
if (elem->data.uns64.high == 0) {
- printf("%u", elem->data.uns64.low);
- break;
+ ND_PRINT((ndo, "%u", elem->data.uns64.low));
+ break;
}
d = elem->data.uns64.high * 4294967296.0; /* 2^32 */
if (elem->data.uns64.high <= 0x1fffff) {
d += elem->data.uns64.low;
#if 0 /*is looks illegal, but what is the intention?*/
- printf("%.f", d);
+ ND_PRINT((ndo, "%.f", d));
#else
- printf("%f", d);
+ ND_PRINT((ndo, "%f", d));
#endif
break;
}
@@ -773,68 +769,67 @@ asn1_print(struct be *elem)
}
*cpf = j + '0';
}
- fputs(first, stdout);
+ ND_PRINT((ndo, "%s", first));
break;
}
case BE_STR: {
register int printable = 1, first = 1;
const u_char *p = elem->data.str;
- TCHECK2(*p, asnlen);
+ ND_TCHECK2(*p, asnlen);
for (i = asnlen; printable && i-- > 0; p++)
- printable = isprint(*p) || isspace(*p);
+ printable = ND_ISPRINT(*p);
p = elem->data.str;
if (printable) {
- putchar('"');
- if (fn_printn(p, asnlen, snapend)) {
- putchar('"');
+ ND_PRINT((ndo, "\""));
+ if (fn_printn(ndo, p, asnlen, ndo->ndo_snapend)) {
+ ND_PRINT((ndo, "\""));
goto trunc;
}
- putchar('"');
+ ND_PRINT((ndo, "\""));
} else
for (i = asnlen; i-- > 0; p++) {
- printf(first ? "%.2x" : "_%.2x", *p);
+ ND_PRINT((ndo, first ? "%.2x" : "_%.2x", *p));
first = 0;
}
break;
}
case BE_SEQ:
- printf("Seq(%u)", elem->asnlen);
+ ND_PRINT((ndo, "Seq(%u)", elem->asnlen));
break;
case BE_INETADDR:
if (asnlen != ASNLEN_INETADDR)
- printf("[inetaddr len!=%d]", ASNLEN_INETADDR);
- TCHECK2(*p, asnlen);
+ ND_PRINT((ndo, "[inetaddr len!=%d]", ASNLEN_INETADDR));
+ ND_TCHECK2(*p, asnlen);
for (i = asnlen; i-- != 0; p++) {
- printf((i == asnlen-1) ? "%u" : ".%u", *p);
+ ND_PRINT((ndo, (i == asnlen-1) ? "%u" : ".%u", *p));
}
break;
case BE_NOSUCHOBJECT:
case BE_NOSUCHINST:
case BE_ENDOFMIBVIEW:
- printf("[%s]", Class[EXCEPTIONS].Id[elem->id]);
+ ND_PRINT((ndo, "[%s]", Class[EXCEPTIONS].Id[elem->id]));
break;
case BE_PDU:
- printf("%s(%u)",
- Class[CONTEXT].Id[elem->id], elem->asnlen);
+ ND_PRINT((ndo, "%s(%u)", Class[CONTEXT].Id[elem->id], elem->asnlen));
break;
case BE_ANY:
- fputs("[BE_ANY!?]", stdout);
+ ND_PRINT((ndo, "[BE_ANY!?]"));
break;
default:
- fputs("[be!?]", stdout);
+ ND_PRINT((ndo, "[be!?]"));
break;
}
return 0;
trunc:
- fputs("[|snmp]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
@@ -855,15 +850,15 @@ asn1_decode(u_char *p, u_int length)
int i = 0;
while (i >= 0 && length > 0) {
- i = asn1_parse(p, length, &elem);
+ i = asn1_parse(ndo, p, length, &elem);
if (i >= 0) {
- fputs(" ", stdout);
- if (asn1_print(&elem) < 0)
+ ND_PRINT((ndo, " "));
+ if (asn1_print(ndo, &elem) < 0)
return;
if (elem.type == BE_SEQ || elem.type == BE_PDU) {
- fputs(" {", stdout);
+ ND_PRINT((ndo, " {"));
asn1_decode(elem.data.raw, elem.asnlen);
- fputs(" }", stdout);
+ ND_PRINT((ndo, " }"));
}
length -= i;
p += i;
@@ -872,14 +867,14 @@ asn1_decode(u_char *p, u_int length)
}
#endif
-#ifdef LIBSMI
+#ifdef USE_LIBSMI
struct smi2be {
SmiBasetype basetype;
int be;
};
-static struct smi2be smi2betab[] = {
+static const struct smi2be smi2betab[] = {
{ SMI_BASETYPE_INTEGER32, BE_INT },
{ SMI_BASETYPE_OCTETSTRING, BE_STR },
{ SMI_BASETYPE_OCTETSTRING, BE_INETADDR },
@@ -896,15 +891,17 @@ static struct smi2be smi2betab[] = {
};
static int
-smi_decode_oid(struct be *elem, unsigned int *oid,
- unsigned int oidsize, unsigned int *oidlen)
+smi_decode_oid(netdissect_options *ndo,
+ struct be *elem, unsigned int *oid,
+ unsigned int oidsize, unsigned int *oidlen)
{
u_char *p = (u_char *)elem->data.raw;
- u_int32_t asnlen = elem->asnlen;
+ uint32_t asnlen = elem->asnlen;
int o = 0, first = -1, i = asnlen;
+ unsigned int firstval;
- for (*oidlen = 0; sflag && i-- > 0; p++) {
- TCHECK(*p);
+ for (*oidlen = 0; ndo->ndo_sflag && i-- > 0; p++) {
+ ND_TCHECK(*p);
o = (o << ASN_SHIFT7) + (*p & ~ASN_BIT8);
if (*p & ASN_LONGLEN)
continue;
@@ -915,12 +912,12 @@ smi_decode_oid(struct be *elem, unsigned int *oid,
*/
if (first < 0) {
first = 0;
+ firstval = o / OIDMUX;
+ if (firstval > 2) firstval = 2;
+ o -= firstval * OIDMUX;
if (*oidlen < oidsize) {
- oid[*oidlen] = o / OIDMUX;
- if (oid[*oidlen] > 2) oid[*oidlen] = 2;
+ oid[(*oidlen)++] = firstval;
}
- o -= oid[*oidlen] * OIDMUX;
- if (*oidlen < oidsize) (*oidlen)++;
}
if (*oidlen < oidsize) {
oid[(*oidlen)++] = o;
@@ -930,7 +927,7 @@ smi_decode_oid(struct be *elem, unsigned int *oid,
return 0;
trunc:
- fputs("[|snmp]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
@@ -1024,29 +1021,30 @@ static int smi_check_range(SmiType *smiType, struct be *elem)
return ok;
}
-static SmiNode *smi_print_variable(struct be *elem, int *status)
+static SmiNode *
+smi_print_variable(netdissect_options *ndo,
+ struct be *elem, int *status)
{
unsigned int oid[128], oidlen;
SmiNode *smiNode = NULL;
unsigned int i;
- *status = smi_decode_oid(elem, oid, sizeof(oid)/sizeof(unsigned int),
+ *status = smi_decode_oid(ndo, elem, oid, sizeof(oid) / sizeof(unsigned int),
&oidlen);
if (*status < 0)
return NULL;
smiNode = smiGetNodeByOID(oidlen, oid);
if (! smiNode) {
- *status = asn1_print(elem);
+ *status = asn1_print(ndo, elem);
return NULL;
}
- if (vflag) {
- fputs(smiGetNodeModule(smiNode)->name, stdout);
- fputs("::", stdout);
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "%s::", smiGetNodeModule(smiNode)->name));
}
- fputs(smiNode->name, stdout);
+ ND_PRINT((ndo, "%s", smiNode->name));
if (smiNode->oidlen < oidlen) {
- for (i = smiNode->oidlen; i < oidlen; i++) {
- printf(".%u", oid[i]);
+ for (i = smiNode->oidlen; i < oidlen; i++) {
+ ND_PRINT((ndo, ".%u", oid[i]));
}
}
*status = 0;
@@ -1054,7 +1052,8 @@ static SmiNode *smi_print_variable(struct be *elem, int *status)
}
static int
-smi_print_value(SmiNode *smiNode, u_char pduid, struct be *elem)
+smi_print_value(netdissect_options *ndo,
+ SmiNode *smiNode, u_char pduid, struct be *elem)
{
unsigned int i, oid[128], oidlen;
SmiType *smiType;
@@ -1063,43 +1062,43 @@ smi_print_value(SmiNode *smiNode, u_char pduid, struct be *elem)
if (! smiNode || ! (smiNode->nodekind
& (SMI_NODEKIND_SCALAR | SMI_NODEKIND_COLUMN))) {
- return asn1_print(elem);
+ return asn1_print(ndo, elem);
}
if (elem->type == BE_NOSUCHOBJECT
|| elem->type == BE_NOSUCHINST
|| elem->type == BE_ENDOFMIBVIEW) {
- return asn1_print(elem);
+ return asn1_print(ndo, elem);
}
if (NOTIFY_CLASS(pduid) && smiNode->access < SMI_ACCESS_NOTIFY) {
- fputs("[notNotifyable]", stdout);
+ ND_PRINT((ndo, "[notNotifyable]"));
}
if (READ_CLASS(pduid) && smiNode->access < SMI_ACCESS_READ_ONLY) {
- fputs("[notReadable]", stdout);
+ ND_PRINT((ndo, "[notReadable]"));
}
if (WRITE_CLASS(pduid) && smiNode->access < SMI_ACCESS_READ_WRITE) {
- fputs("[notWritable]", stdout);
+ ND_PRINT((ndo, "[notWritable]"));
}
if (RESPONSE_CLASS(pduid)
&& smiNode->access == SMI_ACCESS_NOT_ACCESSIBLE) {
- fputs("[noAccess]", stdout);
+ ND_PRINT((ndo, "[noAccess]"));
}
smiType = smiGetNodeType(smiNode);
if (! smiType) {
- return asn1_print(elem);
+ return asn1_print(ndo, elem);
}
if (! smi_check_type(smiType->basetype, elem->type)) {
- fputs("[wrongType]", stdout);
+ ND_PRINT((ndo, "[wrongType]"));
}
if (! smi_check_range(smiType, elem)) {
- fputs("[outOfRange]", stdout);
+ ND_PRINT((ndo, "[outOfRange]"));
}
/* resolve bits to named bits */
@@ -1115,20 +1114,19 @@ smi_print_value(SmiNode *smiNode, u_char pduid, struct be *elem)
if (smiType->basetype == SMI_BASETYPE_BITS) {
/* print bit labels */
} else {
- smi_decode_oid(elem, oid,
+ smi_decode_oid(ndo, elem, oid,
sizeof(oid)/sizeof(unsigned int),
&oidlen);
smiNode = smiGetNodeByOID(oidlen, oid);
if (smiNode) {
- if (vflag) {
- fputs(smiGetNodeModule(smiNode)->name, stdout);
- fputs("::", stdout);
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "%s::", smiGetNodeModule(smiNode)->name));
}
- fputs(smiNode->name, stdout);
+ ND_PRINT((ndo, "%s", smiNode->name));
if (smiNode->oidlen < oidlen) {
for (i = smiNode->oidlen;
i < oidlen; i++) {
- printf(".%u", oid[i]);
+ ND_PRINT((ndo, ".%u", oid[i]));
}
}
done++;
@@ -1143,8 +1141,8 @@ smi_print_value(SmiNode *smiNode, u_char pduid, struct be *elem)
nn = smiGetNextNamedNumber(nn)) {
if (nn->value.value.integer32
== elem->data.integer) {
- fputs(nn->name, stdout);
- printf("(%d)", elem->data.integer);
+ ND_PRINT((ndo, "%s", nn->name));
+ ND_PRINT((ndo, "(%d)", elem->data.integer));
done++;
break;
}
@@ -1154,7 +1152,7 @@ smi_print_value(SmiNode *smiNode, u_char pduid, struct be *elem)
}
if (! done) {
- return asn1_print(elem);
+ return asn1_print(ndo, elem);
}
return 0;
}
@@ -1197,25 +1195,26 @@ smi_print_value(SmiNode *smiNode, u_char pduid, struct be *elem)
* Decode SNMP varBind
*/
static void
-varbind_print(u_char pduid, const u_char *np, u_int length)
+varbind_print(netdissect_options *ndo,
+ u_char pduid, const u_char *np, u_int length)
{
struct be elem;
int count = 0, ind;
-#ifdef LIBSMI
+#ifdef USE_LIBSMI
SmiNode *smiNode = NULL;
#endif
int status;
/* Sequence of varBind */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_SEQ) {
- fputs("[!SEQ of varbind]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[!SEQ of varbind]"));
+ asn1_print(ndo, &elem);
return;
}
if ((u_int)count < length)
- printf("[%d extra after SEQ of varbind]", length - count);
+ ND_PRINT((ndo, "[%d extra after SEQ of varbind]", length - count));
/* descend */
length = elem.asnlen;
np = (u_char *)elem.data.raw;
@@ -1224,14 +1223,14 @@ varbind_print(u_char pduid, const u_char *np, u_int length)
const u_char *vbend;
u_int vblength;
- fputs(" ", stdout);
+ ND_PRINT((ndo, " "));
/* Sequence */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_SEQ) {
- fputs("[!varbind]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[!varbind]"));
+ asn1_print(ndo, &elem);
return;
}
vbend = np + count;
@@ -1241,17 +1240,17 @@ varbind_print(u_char pduid, const u_char *np, u_int length)
np = (u_char *)elem.data.raw;
/* objName (OID) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_OID) {
- fputs("[objName!=OID]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[objName!=OID]"));
+ asn1_print(ndo, &elem);
return;
}
-#ifdef LIBSMI
- smiNode = smi_print_variable(&elem, &status);
+#ifdef USE_LIBSMI
+ smiNode = smi_print_variable(ndo, &elem, &status);
#else
- status = asn1_print(&elem);
+ status = asn1_print(ndo, &elem);
#endif
if (status < 0)
return;
@@ -1260,24 +1259,24 @@ varbind_print(u_char pduid, const u_char *np, u_int length)
if (pduid != GETREQ && pduid != GETNEXTREQ
&& pduid != GETBULKREQ)
- fputs("=", stdout);
+ ND_PRINT((ndo, "="));
/* objVal (ANY) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (pduid == GETREQ || pduid == GETNEXTREQ
|| pduid == GETBULKREQ) {
if (elem.type != BE_NULL) {
- fputs("[objVal!=NULL]", stdout);
- if (asn1_print(&elem) < 0)
+ ND_PRINT((ndo, "[objVal!=NULL]"));
+ if (asn1_print(ndo, &elem) < 0)
return;
}
} else {
if (elem.type != BE_NULL) {
-#ifdef LIBSMI
- status = smi_print_value(smiNode, pduid, &elem);
+#ifdef USE_LIBSMI
+ status = smi_print_value(ndo, smiNode, pduid, &elem);
#else
- status = asn1_print(&elem);
+ status = asn1_print(ndo, &elem);
#endif
}
if (status < 0)
@@ -1293,30 +1292,31 @@ varbind_print(u_char pduid, const u_char *np, u_int length)
* GetBulk, Inform, V2Trap, and Report
*/
static void
-snmppdu_print(u_short pduid, const u_char *np, u_int length)
+snmppdu_print(netdissect_options *ndo,
+ u_short pduid, const u_char *np, u_int length)
{
struct be elem;
int count = 0, error;
/* reqId (Integer) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_INT) {
- fputs("[reqId!=INT]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[reqId!=INT]"));
+ asn1_print(ndo, &elem);
return;
}
- if (vflag)
- printf("R=%d ", elem.data.integer);
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, "R=%d ", elem.data.integer));
length -= count;
np += count;
/* errorStatus (Integer) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_INT) {
- fputs("[errorStatus!=INT]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[errorStatus!=INT]"));
+ asn1_print(ndo, &elem);
return;
}
error = 0;
@@ -1324,48 +1324,47 @@ snmppdu_print(u_short pduid, const u_char *np, u_int length)
|| pduid == INFORMREQ || pduid == V2TRAP || pduid == REPORT)
&& elem.data.integer != 0) {
char errbuf[20];
- printf("[errorStatus(%s)!=0]",
- DECODE_ErrorStatus(elem.data.integer));
+ ND_PRINT((ndo, "[errorStatus(%s)!=0]",
+ DECODE_ErrorStatus(elem.data.integer)));
} else if (pduid == GETBULKREQ) {
- printf(" N=%d", elem.data.integer);
+ ND_PRINT((ndo, " N=%d", elem.data.integer));
} else if (elem.data.integer != 0) {
char errbuf[20];
- printf(" %s", DECODE_ErrorStatus(elem.data.integer));
+ ND_PRINT((ndo, " %s", DECODE_ErrorStatus(elem.data.integer)));
error = elem.data.integer;
}
length -= count;
np += count;
/* errorIndex (Integer) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_INT) {
- fputs("[errorIndex!=INT]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[errorIndex!=INT]"));
+ asn1_print(ndo, &elem);
return;
}
if ((pduid == GETREQ || pduid == GETNEXTREQ || pduid == SETREQ
|| pduid == INFORMREQ || pduid == V2TRAP || pduid == REPORT)
&& elem.data.integer != 0)
- printf("[errorIndex(%d)!=0]", elem.data.integer);
+ ND_PRINT((ndo, "[errorIndex(%d)!=0]", elem.data.integer));
else if (pduid == GETBULKREQ)
- printf(" M=%d", elem.data.integer);
+ ND_PRINT((ndo, " M=%d", elem.data.integer));
else if (elem.data.integer != 0) {
if (!error)
- printf("[errorIndex(%d) w/o errorStatus]",
- elem.data.integer);
+ ND_PRINT((ndo, "[errorIndex(%d) w/o errorStatus]", elem.data.integer));
else {
- printf("@%d", elem.data.integer);
+ ND_PRINT((ndo, "@%d", elem.data.integer));
error = elem.data.integer;
}
} else if (error) {
- fputs("[errorIndex==0]", stdout);
+ ND_PRINT((ndo, "[errorIndex==0]"));
error = 0;
}
length -= count;
np += count;
- varbind_print(pduid, np, length);
+ varbind_print(ndo, pduid, np, length);
return;
}
@@ -1373,89 +1372,90 @@ snmppdu_print(u_short pduid, const u_char *np, u_int length)
* Decode SNMP Trap PDU
*/
static void
-trappdu_print(const u_char *np, u_int length)
+trappdu_print(netdissect_options *ndo,
+ const u_char *np, u_int length)
{
struct be elem;
int count = 0, generic;
- putchar(' ');
+ ND_PRINT((ndo, " "));
/* enterprise (oid) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_OID) {
- fputs("[enterprise!=OID]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[enterprise!=OID]"));
+ asn1_print(ndo, &elem);
return;
}
- if (asn1_print(&elem) < 0)
+ if (asn1_print(ndo, &elem) < 0)
return;
length -= count;
np += count;
- putchar(' ');
+ ND_PRINT((ndo, " "));
/* agent-addr (inetaddr) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_INETADDR) {
- fputs("[agent-addr!=INETADDR]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[agent-addr!=INETADDR]"));
+ asn1_print(ndo, &elem);
return;
}
- if (asn1_print(&elem) < 0)
+ if (asn1_print(ndo, &elem) < 0)
return;
length -= count;
np += count;
/* generic-trap (Integer) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_INT) {
- fputs("[generic-trap!=INT]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[generic-trap!=INT]"));
+ asn1_print(ndo, &elem);
return;
}
generic = elem.data.integer;
{
char buf[20];
- printf(" %s", DECODE_GenericTrap(generic));
+ ND_PRINT((ndo, " %s", DECODE_GenericTrap(generic)));
}
length -= count;
np += count;
/* specific-trap (Integer) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_INT) {
- fputs("[specific-trap!=INT]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[specific-trap!=INT]"));
+ asn1_print(ndo, &elem);
return;
}
if (generic != GT_ENTERPRISE) {
if (elem.data.integer != 0)
- printf("[specific-trap(%d)!=0]", elem.data.integer);
+ ND_PRINT((ndo, "[specific-trap(%d)!=0]", elem.data.integer));
} else
- printf(" s=%d", elem.data.integer);
+ ND_PRINT((ndo, " s=%d", elem.data.integer));
length -= count;
np += count;
- putchar(' ');
+ ND_PRINT((ndo, " "));
/* time-stamp (TimeTicks) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_UNS) { /* XXX */
- fputs("[time-stamp!=TIMETICKS]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[time-stamp!=TIMETICKS]"));
+ asn1_print(ndo, &elem);
return;
}
- if (asn1_print(&elem) < 0)
+ if (asn1_print(ndo, &elem) < 0)
return;
length -= count;
np += count;
- varbind_print (TRAP, np, length);
+ varbind_print(ndo, TRAP, np, length);
return;
}
@@ -1463,26 +1463,27 @@ trappdu_print(const u_char *np, u_int length)
* Decode arbitrary SNMP PDUs.
*/
static void
-pdu_print(const u_char *np, u_int length, int version)
+pdu_print(netdissect_options *ndo,
+ const u_char *np, u_int length, int version)
{
struct be pdu;
int count = 0;
/* PDU (Context) */
- if ((count = asn1_parse(np, length, &pdu)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &pdu)) < 0)
return;
if (pdu.type != BE_PDU) {
- fputs("[no PDU]", stdout);
+ ND_PRINT((ndo, "[no PDU]"));
return;
}
if ((u_int)count < length)
- printf("[%d extra after PDU]", length - count);
- if (vflag) {
- fputs("{ ", stdout);
+ ND_PRINT((ndo, "[%d extra after PDU]", length - count));
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "{ "));
}
- if (asn1_print(&pdu) < 0)
+ if (asn1_print(ndo, &pdu) < 0)
return;
- fputs(" ", stdout);
+ ND_PRINT((ndo, " "));
/* descend into PDU */
length = pdu.asnlen;
np = (u_char *)pdu.data.raw;
@@ -1490,18 +1491,18 @@ pdu_print(const u_char *np, u_int length, int version)
if (version == SNMP_VERSION_1 &&
(pdu.id == GETBULKREQ || pdu.id == INFORMREQ ||
pdu.id == V2TRAP || pdu.id == REPORT)) {
- printf("[v2 PDU in v1 message]");
+ ND_PRINT((ndo, "[v2 PDU in v1 message]"));
return;
}
if (version == SNMP_VERSION_2 && pdu.id == TRAP) {
- printf("[v1 PDU in v2 message]");
+ ND_PRINT((ndo, "[v1 PDU in v2 message]"));
return;
}
switch (pdu.id) {
case TRAP:
- trappdu_print(np, length);
+ trappdu_print(ndo, np, length);
break;
case GETREQ:
case GETNEXTREQ:
@@ -1511,12 +1512,12 @@ pdu_print(const u_char *np, u_int length, int version)
case INFORMREQ:
case V2TRAP:
case REPORT:
- snmppdu_print(pdu.id, np, length);
+ snmppdu_print(ndo, pdu.id, np, length);
break;
}
- if (vflag) {
- fputs(" } ", stdout);
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, " } "));
}
}
@@ -1524,70 +1525,72 @@ pdu_print(const u_char *np, u_int length, int version)
* Decode a scoped SNMP PDU.
*/
static void
-scopedpdu_print(const u_char *np, u_int length, int version)
+scopedpdu_print(netdissect_options *ndo,
+ const u_char *np, u_int length, int version)
{
struct be elem;
int i, count = 0;
/* Sequence */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_SEQ) {
- fputs("[!scoped PDU]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[!scoped PDU]"));
+ asn1_print(ndo, &elem);
return;
}
length = elem.asnlen;
np = (u_char *)elem.data.raw;
/* contextEngineID (OCTET STRING) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_STR) {
- fputs("[contextEngineID!=STR]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[contextEngineID!=STR]"));
+ asn1_print(ndo, &elem);
return;
}
length -= count;
np += count;
- fputs("E= ", stdout);
+ ND_PRINT((ndo, "E= "));
for (i = 0; i < (int)elem.asnlen; i++) {
- printf("0x%02X", elem.data.str[i]);
- }
- fputs(" ", stdout);
+ ND_PRINT((ndo, "0x%02X", elem.data.str[i]));
+ }
+ ND_PRINT((ndo, " "));
/* contextName (OCTET STRING) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_STR) {
- fputs("[contextName!=STR]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[contextName!=STR]"));
+ asn1_print(ndo, &elem);
return;
}
length -= count;
np += count;
- printf("C=%.*s ", (int)elem.asnlen, elem.data.str);
+ ND_PRINT((ndo, "C=%.*s ", (int)elem.asnlen, elem.data.str));
- pdu_print(np, length, version);
+ pdu_print(ndo, np, length, version);
}
/*
* Decode SNMP Community Header (SNMPv1 and SNMPv2c)
*/
static void
-community_print(const u_char *np, u_int length, int version)
+community_print(netdissect_options *ndo,
+ const u_char *np, u_int length, int version)
{
struct be elem;
int count = 0;
/* Community (String) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_STR) {
- fputs("[comm!=STR]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[comm!=STR]"));
+ asn1_print(ndo, &elem);
return;
}
/* default community */
@@ -1595,114 +1598,116 @@ community_print(const u_char *np, u_int length, int version)
strncmp((char *)elem.data.str, DEF_COMMUNITY,
sizeof(DEF_COMMUNITY) - 1) == 0))
/* ! "public" */
- printf("C=%.*s ", (int)elem.asnlen, elem.data.str);
+ ND_PRINT((ndo, "C=%.*s ", (int)elem.asnlen, elem.data.str));
length -= count;
np += count;
- pdu_print(np, length, version);
+ pdu_print(ndo, np, length, version);
}
/*
* Decode SNMPv3 User-based Security Message Header (SNMPv3)
*/
static void
-usm_print(const u_char *np, u_int length)
+usm_print(netdissect_options *ndo,
+ const u_char *np, u_int length)
{
struct be elem;
int count = 0;
/* Sequence */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_SEQ) {
- fputs("[!usm]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[!usm]"));
+ asn1_print(ndo, &elem);
return;
}
length = elem.asnlen;
np = (u_char *)elem.data.raw;
/* msgAuthoritativeEngineID (OCTET STRING) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_STR) {
- fputs("[msgAuthoritativeEngineID!=STR]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[msgAuthoritativeEngineID!=STR]"));
+ asn1_print(ndo, &elem);
return;
}
length -= count;
np += count;
/* msgAuthoritativeEngineBoots (INTEGER) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_INT) {
- fputs("[msgAuthoritativeEngineBoots!=INT]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[msgAuthoritativeEngineBoots!=INT]"));
+ asn1_print(ndo, &elem);
return;
}
- if (vflag)
- printf("B=%d ", elem.data.integer);
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, "B=%d ", elem.data.integer));
length -= count;
np += count;
/* msgAuthoritativeEngineTime (INTEGER) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_INT) {
- fputs("[msgAuthoritativeEngineTime!=INT]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[msgAuthoritativeEngineTime!=INT]"));
+ asn1_print(ndo, &elem);
return;
}
- if (vflag)
- printf("T=%d ", elem.data.integer);
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, "T=%d ", elem.data.integer));
length -= count;
np += count;
/* msgUserName (OCTET STRING) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_STR) {
- fputs("[msgUserName!=STR]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[msgUserName!=STR]"));
+ asn1_print(ndo, &elem);
return;
}
length -= count;
np += count;
- printf("U=%.*s ", (int)elem.asnlen, elem.data.str);
+ ND_PRINT((ndo, "U=%.*s ", (int)elem.asnlen, elem.data.str));
/* msgAuthenticationParameters (OCTET STRING) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_STR) {
- fputs("[msgAuthenticationParameters!=STR]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[msgAuthenticationParameters!=STR]"));
+ asn1_print(ndo, &elem);
return;
}
length -= count;
np += count;
/* msgPrivacyParameters (OCTET STRING) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_STR) {
- fputs("[msgPrivacyParameters!=STR]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[msgPrivacyParameters!=STR]"));
+ asn1_print(ndo, &elem);
return;
}
length -= count;
np += count;
if ((u_int)count < length)
- printf("[%d extra after usm SEQ]", length - count);
+ ND_PRINT((ndo, "[%d extra after usm SEQ]", length - count));
}
/*
* Decode SNMPv3 Message Header (SNMPv3)
*/
static void
-v3msg_print(const u_char *np, u_int length)
+v3msg_print(netdissect_options *ndo,
+ const u_char *np, u_int length)
{
struct be elem;
int count = 0;
@@ -1712,75 +1717,74 @@ v3msg_print(const u_char *np, u_int length)
int xlength = length;
/* Sequence */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_SEQ) {
- fputs("[!message]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[!message]"));
+ asn1_print(ndo, &elem);
return;
}
length = elem.asnlen;
np = (u_char *)elem.data.raw;
- if (vflag) {
- fputs("{ ", stdout);
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "{ "));
}
/* msgID (INTEGER) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_INT) {
- fputs("[msgID!=INT]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[msgID!=INT]"));
+ asn1_print(ndo, &elem);
return;
}
length -= count;
np += count;
/* msgMaxSize (INTEGER) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_INT) {
- fputs("[msgMaxSize!=INT]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[msgMaxSize!=INT]"));
+ asn1_print(ndo, &elem);
return;
}
length -= count;
np += count;
/* msgFlags (OCTET STRING) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_STR) {
- fputs("[msgFlags!=STR]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[msgFlags!=STR]"));
+ asn1_print(ndo, &elem);
return;
}
if (elem.asnlen != 1) {
- printf("[msgFlags size %d]", elem.asnlen);
+ ND_PRINT((ndo, "[msgFlags size %d]", elem.asnlen));
return;
}
flags = elem.data.str[0];
if (flags != 0x00 && flags != 0x01 && flags != 0x03
&& flags != 0x04 && flags != 0x05 && flags != 0x07) {
- printf("[msgFlags=0x%02X]", flags);
+ ND_PRINT((ndo, "[msgFlags=0x%02X]", flags));
return;
}
length -= count;
np += count;
- fputs("F=", stdout);
- if (flags & 0x01) fputs("a", stdout);
- if (flags & 0x02) fputs("p", stdout);
- if (flags & 0x04) fputs("r", stdout);
- fputs(" ", stdout);
+ ND_PRINT((ndo, "F=%s%s%s ",
+ flags & 0x01 ? "a" : "",
+ flags & 0x02 ? "p" : "",
+ flags & 0x04 ? "r" : ""));
/* msgSecurityModel (INTEGER) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_INT) {
- fputs("[msgSecurityModel!=INT]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[msgSecurityModel!=INT]"));
+ asn1_print(ndo, &elem);
return;
}
model = elem.data.integer;
@@ -1788,18 +1792,18 @@ v3msg_print(const u_char *np, u_int length)
np += count;
if ((u_int)count < length)
- printf("[%d extra after message SEQ]", length - count);
+ ND_PRINT((ndo, "[%d extra after message SEQ]", length - count));
- if (vflag) {
- fputs("} ", stdout);
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "} "));
}
if (model == 3) {
- if (vflag) {
- fputs("{ USM ", stdout);
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "{ USM "));
}
} else {
- printf("[security model %d]", model);
+ ND_PRINT((ndo, "[security model %d]", model));
return;
}
@@ -1807,31 +1811,31 @@ v3msg_print(const u_char *np, u_int length)
length = xlength - (np - xnp);
/* msgSecurityParameters (OCTET STRING) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_STR) {
- fputs("[msgSecurityParameters!=STR]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[msgSecurityParameters!=STR]"));
+ asn1_print(ndo, &elem);
return;
}
length -= count;
np += count;
if (model == 3) {
- usm_print(elem.data.str, elem.asnlen);
- if (vflag) {
- fputs("} ", stdout);
+ usm_print(ndo, elem.data.str, elem.asnlen);
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "} "));
}
}
- if (vflag) {
- fputs("{ ScopedPDU ", stdout);
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "{ ScopedPDU "));
}
- scopedpdu_print(np, length, 3);
+ scopedpdu_print(ndo, np, length, 3);
- if (vflag) {
- fputs("} ", stdout);
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "} "));
}
}
@@ -1839,34 +1843,35 @@ v3msg_print(const u_char *np, u_int length)
* Decode SNMP header and pass on to PDU printing routines
*/
void
-snmp_print(const u_char *np, u_int length)
+snmp_print(netdissect_options *ndo,
+ const u_char *np, u_int length)
{
struct be elem;
int count = 0;
int version = 0;
- putchar(' ');
+ ND_PRINT((ndo, " "));
/* initial Sequence */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_SEQ) {
- fputs("[!init SEQ]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[!init SEQ]"));
+ asn1_print(ndo, &elem);
return;
}
if ((u_int)count < length)
- printf("[%d extra after iSEQ]", length - count);
+ ND_PRINT((ndo, "[%d extra after iSEQ]", length - count));
/* descend */
length = elem.asnlen;
np = (u_char *)elem.data.raw;
/* Version (INTEGER) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_INT) {
- fputs("[version!=INT]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[version!=INT]"));
+ asn1_print(ndo, &elem);
return;
}
@@ -1874,11 +1879,11 @@ snmp_print(const u_char *np, u_int length)
case SNMP_VERSION_1:
case SNMP_VERSION_2:
case SNMP_VERSION_3:
- if (vflag)
- printf("{ %s ", SnmpVersion[elem.data.integer]);
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, "{ %s ", SnmpVersion[elem.data.integer]));
break;
default:
- printf("[version = %d]", elem.data.integer);
+ ND_PRINT((ndo, "[version = %d]", elem.data.integer));
return;
}
version = elem.data.integer;
@@ -1888,17 +1893,17 @@ snmp_print(const u_char *np, u_int length)
switch (version) {
case SNMP_VERSION_1:
case SNMP_VERSION_2:
- community_print(np, length, version);
+ community_print(ndo, np, length, version);
break;
case SNMP_VERSION_3:
- v3msg_print(np, length);
+ v3msg_print(ndo, np, length);
break;
default:
- printf("[version = %d]", elem.data.integer);
+ ND_PRINT((ndo, "[version = %d]", elem.data.integer));
break;
}
- if (vflag) {
- fputs("} ", stdout);
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "} "));
}
}
diff --git a/contrib/tcpdump/print-stp.c b/contrib/tcpdump/print-stp.c
index 7880268acee5..93bb60002858 100644
--- a/contrib/tcpdump/print-stp.c
+++ b/contrib/tcpdump/print-stp.c
@@ -9,44 +9,37 @@
* Contributed by Lennert Buytenhek <buytenh@gnu.org>
*/
-#ifndef lint
-static const char rcsid[] _U_ =
-"@(#) $Header: /tcpdump/master/tcpdump/print-stp.c,v 1.20 2007-03-18 17:11:46 hannes Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdlib.h>
#include <stdio.h>
-#include <string.h>
#include "interface.h"
-#include "addrtoname.h"
#include "extract.h"
-#define RSTP_EXTRACT_PORT_ROLE(x) (((x)&0x0C)>>2)
+#define RSTP_EXTRACT_PORT_ROLE(x) (((x)&0x0C)>>2)
/* STP timers are expressed in multiples of 1/256th second */
#define STP_TIME_BASE 256
#define STP_BPDU_MSTP_MIN_LEN 102
struct stp_bpdu_ {
- u_int8_t protocol_id[2];
- u_int8_t protocol_version;
- u_int8_t bpdu_type;
- u_int8_t flags;
- u_int8_t root_id[8];
- u_int8_t root_path_cost[4];
- u_int8_t bridge_id[8];
- u_int8_t port_id[2];
- u_int8_t message_age[2];
- u_int8_t max_age[2];
- u_int8_t hello_time[2];
- u_int8_t forward_delay[2];
- u_int8_t v1_length;
+ uint8_t protocol_id[2];
+ uint8_t protocol_version;
+ uint8_t bpdu_type;
+ uint8_t flags;
+ uint8_t root_id[8];
+ uint8_t root_path_cost[4];
+ uint8_t bridge_id[8];
+ uint8_t port_id[2];
+ uint8_t message_age[2];
+ uint8_t max_age[2];
+ uint8_t hello_time[2];
+ uint8_t forward_delay[2];
+ uint8_t v1_length;
};
#define STP_PROTO_REGULAR 0x00
@@ -54,7 +47,7 @@ struct stp_bpdu_ {
#define STP_PROTO_MSTP 0x03
#define STP_PROTO_SPB 0x04
-struct tok stp_proto_values[] = {
+static const struct tok stp_proto_values[] = {
{ STP_PROTO_REGULAR, "802.1d" },
{ STP_PROTO_RAPID, "802.1w" },
{ STP_PROTO_MSTP, "802.1s" },
@@ -66,7 +59,7 @@ struct tok stp_proto_values[] = {
#define STP_BPDU_TYPE_RSTP 0x02
#define STP_BPDU_TYPE_TOPO_CHANGE 0x80
-struct tok stp_bpdu_flag_values[] = {
+static const struct tok stp_bpdu_flag_values[] = {
{ 0x01, "Topology change" },
{ 0x02, "Proposal" },
{ 0x10, "Learn" },
@@ -76,14 +69,14 @@ struct tok stp_bpdu_flag_values[] = {
{ 0, NULL}
};
-struct tok stp_bpdu_type_values[] = {
+static const struct tok stp_bpdu_type_values[] = {
{ STP_BPDU_TYPE_CONFIG, "Config" },
{ STP_BPDU_TYPE_RSTP, "Rapid STP" },
{ STP_BPDU_TYPE_TOPO_CHANGE, "Topology Change" },
{ 0, NULL}
};
-struct tok rstp_obj_port_role_values[] = {
+static const struct tok rstp_obj_port_role_values[] = {
{ 0x00, "Unknown" },
{ 0x01, "Alternate" },
{ 0x02, "Root" },
@@ -104,36 +97,37 @@ stp_print_bridge_id(const u_char *p)
}
static void
-stp_print_config_bpdu(const struct stp_bpdu_ *stp_bpdu, u_int length)
+stp_print_config_bpdu(netdissect_options *ndo, const struct stp_bpdu_ *stp_bpdu,
+ u_int length)
{
- printf(", Flags [%s]",
- bittok2str(stp_bpdu_flag_values, "none", stp_bpdu->flags));
+ ND_PRINT((ndo, ", Flags [%s]",
+ bittok2str(stp_bpdu_flag_values, "none", stp_bpdu->flags)));
- printf(", bridge-id %s.%04x, length %u",
+ ND_PRINT((ndo, ", bridge-id %s.%04x, length %u",
stp_print_bridge_id((const u_char *)&stp_bpdu->bridge_id),
- EXTRACT_16BITS(&stp_bpdu->port_id), length);
+ EXTRACT_16BITS(&stp_bpdu->port_id), length));
/* in non-verbose mode just print the bridge-id */
- if (!vflag) {
+ if (!ndo->ndo_vflag) {
return;
}
- printf("\n\tmessage-age %.2fs, max-age %.2fs"
+ ND_PRINT((ndo, "\n\tmessage-age %.2fs, max-age %.2fs"
", hello-time %.2fs, forwarding-delay %.2fs",
(float)EXTRACT_16BITS(&stp_bpdu->message_age) / STP_TIME_BASE,
(float)EXTRACT_16BITS(&stp_bpdu->max_age) / STP_TIME_BASE,
(float)EXTRACT_16BITS(&stp_bpdu->hello_time) / STP_TIME_BASE,
- (float)EXTRACT_16BITS(&stp_bpdu->forward_delay) / STP_TIME_BASE);
+ (float)EXTRACT_16BITS(&stp_bpdu->forward_delay) / STP_TIME_BASE));
- printf("\n\troot-id %s, root-pathcost %u",
+ ND_PRINT((ndo, "\n\troot-id %s, root-pathcost %u",
stp_print_bridge_id((const u_char *)&stp_bpdu->root_id),
- EXTRACT_32BITS(&stp_bpdu->root_path_cost));
+ EXTRACT_32BITS(&stp_bpdu->root_path_cost)));
/* Port role is only valid for 802.1w */
if (stp_bpdu->protocol_version == STP_PROTO_RAPID) {
- printf(", port-role %s",
+ ND_PRINT((ndo, ", port-role %s",
tok2str(rstp_obj_port_role_values, "Unknown",
- RSTP_EXTRACT_PORT_ROLE(stp_bpdu->flags)));
+ RSTP_EXTRACT_PORT_ROLE(stp_bpdu->flags))));
}
}
@@ -144,7 +138,7 @@ stp_print_config_bpdu(const struct stp_bpdu_ *stp_bpdu, u_int length)
* MSTP BPDU
*
* 2 - bytes Protocol Id
- * 1 - byte Protocol Ver.
+ * 1 - byte Protocol Ver.
* 1 - byte BPDU tye
* 1 - byte Flags
* 8 - bytes CIST Root Identifier
@@ -171,11 +165,11 @@ stp_print_config_bpdu(const struct stp_bpdu_ *stp_bpdu, u_int length)
* Ref. IEEE 802.1aq. Section 14
*
* 2 - bytes Version 4 length
- * 1 - byte Aux Config Identifier
+ * 1 - byte Aux Config Identifier
* 32 - bytes Aux Config Name
* 2 - bytes Aux Revision level
* 16 - bytes Aux Config Digest [MD5]
- * 1 - byte (1 - 2) Agreement Number
+ * 1 - byte (1 - 2) Agreement Number
* (3 - 4) Discarded Agreement Number
* (5) Agreement Valid Flag
* (6) Restricted Role Flag
@@ -234,63 +228,63 @@ stp_print_config_bpdu(const struct stp_bpdu_ *stp_bpdu, u_int length)
static void
-stp_print_mstp_bpdu(const struct stp_bpdu_ *stp_bpdu, u_int length)
+stp_print_mstp_bpdu(netdissect_options *ndo, const struct stp_bpdu_ *stp_bpdu,
+ u_int length)
{
const u_char *ptr;
- u_int16_t v3len;
- u_int16_t len;
- u_int16_t msti;
- u_int16_t offset;
+ uint16_t v3len;
+ uint16_t len;
+ uint16_t msti;
+ u_int offset;
ptr = (const u_char *)stp_bpdu;
- printf(", CIST Flags [%s], length %u",
- bittok2str(stp_bpdu_flag_values, "none", stp_bpdu->flags), length);
+ ND_PRINT((ndo, ", CIST Flags [%s], length %u",
+ bittok2str(stp_bpdu_flag_values, "none", stp_bpdu->flags), length));
/*
- * in non-verbose mode just print the flags. We dont read that much
- * of the packet (DEFAULT_SNAPLEN) to print out cist bridge-id
+ * in non-verbose mode just print the flags.
*/
- if (!vflag) {
+ if (!ndo->ndo_vflag) {
return;
}
- printf("\n\tport-role %s, ",
+ ND_PRINT((ndo, "\n\tport-role %s, ",
tok2str(rstp_obj_port_role_values, "Unknown",
- RSTP_EXTRACT_PORT_ROLE(stp_bpdu->flags)));
+ RSTP_EXTRACT_PORT_ROLE(stp_bpdu->flags))));
- printf("CIST root-id %s, CIST ext-pathcost %u ",
+ ND_PRINT((ndo, "CIST root-id %s, CIST ext-pathcost %u ",
stp_print_bridge_id((const u_char *)&stp_bpdu->root_id),
- EXTRACT_32BITS(&stp_bpdu->root_path_cost));
+ EXTRACT_32BITS(&stp_bpdu->root_path_cost)));
- printf("\n\tCIST regional-root-id %s, ",
- stp_print_bridge_id((const u_char *)&stp_bpdu->bridge_id));
+ ND_PRINT((ndo, "\n\tCIST regional-root-id %s, ",
+ stp_print_bridge_id((const u_char *)&stp_bpdu->bridge_id)));
- printf("CIST port-id %04x, ", EXTRACT_16BITS(&stp_bpdu->port_id));
+ ND_PRINT((ndo, "CIST port-id %04x, ", EXTRACT_16BITS(&stp_bpdu->port_id)));
- printf("\n\tmessage-age %.2fs, max-age %.2fs"
+ ND_PRINT((ndo, "\n\tmessage-age %.2fs, max-age %.2fs"
", hello-time %.2fs, forwarding-delay %.2fs",
(float)EXTRACT_16BITS(&stp_bpdu->message_age) / STP_TIME_BASE,
(float)EXTRACT_16BITS(&stp_bpdu->max_age) / STP_TIME_BASE,
(float)EXTRACT_16BITS(&stp_bpdu->hello_time) / STP_TIME_BASE,
- (float)EXTRACT_16BITS(&stp_bpdu->forward_delay) / STP_TIME_BASE);
+ (float)EXTRACT_16BITS(&stp_bpdu->forward_delay) / STP_TIME_BASE));
- printf ("\n\tv3len %d, ", EXTRACT_16BITS(ptr + MST_BPDU_VER3_LEN_OFFSET));
- printf("MCID Name %s, rev %u, "
+ ND_PRINT((ndo, "\n\tv3len %d, ", EXTRACT_16BITS(ptr + MST_BPDU_VER3_LEN_OFFSET)));
+ ND_PRINT((ndo, "MCID Name %s, rev %u, "
"\n\t\tdigest %08x%08x%08x%08x, ",
ptr + MST_BPDU_CONFIG_NAME_OFFSET,
EXTRACT_16BITS(ptr + MST_BPDU_CONFIG_NAME_OFFSET + 32),
EXTRACT_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET),
EXTRACT_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET + 4),
EXTRACT_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET + 8),
- EXTRACT_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET + 12));
+ EXTRACT_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET + 12)));
- printf ("CIST int-root-pathcost %u, ",
- EXTRACT_32BITS(ptr + MST_BPDU_CIST_INT_PATH_COST_OFFSET));
+ ND_PRINT((ndo, "CIST int-root-pathcost %u, ",
+ EXTRACT_32BITS(ptr + MST_BPDU_CIST_INT_PATH_COST_OFFSET)));
- printf("\n\tCIST bridge-id %s, ",
- stp_print_bridge_id(ptr + MST_BPDU_CIST_BRIDGE_ID_OFFSET));
+ ND_PRINT((ndo, "\n\tCIST bridge-id %s, ",
+ stp_print_bridge_id(ptr + MST_BPDU_CIST_BRIDGE_ID_OFFSET)));
- printf("CIST remaining-hops %d", ptr[MST_BPDU_CIST_REMAIN_HOPS_OFFSET]);
+ ND_PRINT((ndo, "CIST remaining-hops %d", ptr[MST_BPDU_CIST_REMAIN_HOPS_OFFSET]));
/* Dump all MSTI's */
v3len = EXTRACT_16BITS(ptr + MST_BPDU_VER3_LEN_OFFSET);
@@ -302,80 +296,92 @@ stp_print_mstp_bpdu(const struct stp_bpdu_ *stp_bpdu, u_int length)
MST_BPDU_MSTI_ROOT_PRIO_OFFSET);
msti = msti & 0x0FFF;
- printf("\n\tMSTI %d, Flags [%s], port-role %s",
+ ND_PRINT((ndo, "\n\tMSTI %d, Flags [%s], port-role %s",
msti, bittok2str(stp_bpdu_flag_values, "none", ptr[offset]),
tok2str(rstp_obj_port_role_values, "Unknown",
- RSTP_EXTRACT_PORT_ROLE(ptr[offset])));
- printf("\n\t\tMSTI regional-root-id %s, pathcost %u",
+ RSTP_EXTRACT_PORT_ROLE(ptr[offset]))));
+ ND_PRINT((ndo, "\n\t\tMSTI regional-root-id %s, pathcost %u",
stp_print_bridge_id(ptr + offset +
MST_BPDU_MSTI_ROOT_PRIO_OFFSET),
EXTRACT_32BITS(ptr + offset +
- MST_BPDU_MSTI_ROOT_PATH_COST_OFFSET));
- printf("\n\t\tMSTI bridge-prio %d, port-prio %d, hops %d",
+ MST_BPDU_MSTI_ROOT_PATH_COST_OFFSET)));
+ ND_PRINT((ndo, "\n\t\tMSTI bridge-prio %d, port-prio %d, hops %d",
ptr[offset + MST_BPDU_MSTI_BRIDGE_PRIO_OFFSET] >> 4,
ptr[offset + MST_BPDU_MSTI_PORT_PRIO_OFFSET] >> 4,
- ptr[offset + MST_BPDU_MSTI_REMAIN_HOPS_OFFSET]);
+ ptr[offset + MST_BPDU_MSTI_REMAIN_HOPS_OFFSET]));
len -= MST_BPDU_MSTI_LENGTH;
offset += MST_BPDU_MSTI_LENGTH;
}
}
+}
+
+static void
+stp_print_spb_bpdu(netdissect_options *ndo, const struct stp_bpdu_ *stp_bpdu,
+ u_int offset)
+{
+ const u_char *ptr;
+
+ /*
+ * in non-verbose mode don't print anything.
+ */
+ if (!ndo->ndo_vflag) {
+ return;
+ }
- if ((length-offset) >= SPB_BPDU_MIN_LEN)
- {
- printf("\n\tv4len %d AUXMCID Name %s, Rev %u, \n\t\tdigest %08x%08x%08x%08x",
- EXTRACT_16BITS (ptr + offset),
- ptr + offset + SPB_BPDU_CONFIG_NAME_OFFSET,
- EXTRACT_16BITS(ptr + offset + SPB_BPDU_CONFIG_REV_OFFSET),
- EXTRACT_32BITS(ptr + offset + SPB_BPDU_CONFIG_DIGEST_OFFSET),
- EXTRACT_32BITS(ptr + offset + SPB_BPDU_CONFIG_DIGEST_OFFSET + 4),
- EXTRACT_32BITS(ptr + offset + SPB_BPDU_CONFIG_DIGEST_OFFSET + 8),
- EXTRACT_32BITS(ptr + offset + SPB_BPDU_CONFIG_DIGEST_OFFSET + 12));
-
- printf("\n\tAgreement num %d, Discarded Agreement num %d, Agreement valid-"
- "flag %d, \n\tRestricted role-flag: %d, Format id %d cap %d, "
- "Convention id %d cap %d, \n\tEdge count %d, "
- "Agreement digest %08x%08x%08x%08x%08x\n",
- ptr[offset + SPB_BPDU_AGREEMENT_OFFSET]>>6,
- ptr[offset + SPB_BPDU_AGREEMENT_OFFSET]>>4 & 0x3,
- ptr[offset + SPB_BPDU_AGREEMENT_OFFSET]>>3 & 0x1,
- ptr[offset + SPB_BPDU_AGREEMENT_OFFSET]>>2 & 0x1,
- ptr[offset + SPB_BPDU_AGREEMENT_FORMAT_OFFSET]>>4,
- ptr[offset + SPB_BPDU_AGREEMENT_FORMAT_OFFSET]&0x00ff,
- ptr[offset + SPB_BPDU_AGREEMENT_CON_OFFSET]>>4,
- ptr[offset + SPB_BPDU_AGREEMENT_CON_OFFSET]&0x00ff,
- EXTRACT_16BITS(ptr + offset + SPB_BPDU_AGREEMENT_EDGE_OFFSET),
- EXTRACT_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET),
- EXTRACT_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET)+4,
- EXTRACT_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET)+8,
- EXTRACT_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET)+12,
- EXTRACT_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET)+16);
- }
+ ptr = (const u_char *)stp_bpdu;
+ ND_PRINT((ndo, "\n\tv4len %d AUXMCID Name %s, Rev %u, \n\t\tdigest %08x%08x%08x%08x",
+ EXTRACT_16BITS (ptr + offset),
+ ptr + offset + SPB_BPDU_CONFIG_NAME_OFFSET,
+ EXTRACT_16BITS(ptr + offset + SPB_BPDU_CONFIG_REV_OFFSET),
+ EXTRACT_32BITS(ptr + offset + SPB_BPDU_CONFIG_DIGEST_OFFSET),
+ EXTRACT_32BITS(ptr + offset + SPB_BPDU_CONFIG_DIGEST_OFFSET + 4),
+ EXTRACT_32BITS(ptr + offset + SPB_BPDU_CONFIG_DIGEST_OFFSET + 8),
+ EXTRACT_32BITS(ptr + offset + SPB_BPDU_CONFIG_DIGEST_OFFSET + 12)));
+
+ ND_PRINT((ndo, "\n\tAgreement num %d, Discarded Agreement num %d, Agreement valid-"
+ "flag %d, \n\tRestricted role-flag: %d, Format id %d cap %d, "
+ "Convention id %d cap %d, \n\tEdge count %d, "
+ "Agreement digest %08x%08x%08x%08x%08x\n",
+ ptr[offset + SPB_BPDU_AGREEMENT_OFFSET]>>6,
+ ptr[offset + SPB_BPDU_AGREEMENT_OFFSET]>>4 & 0x3,
+ ptr[offset + SPB_BPDU_AGREEMENT_OFFSET]>>3 & 0x1,
+ ptr[offset + SPB_BPDU_AGREEMENT_OFFSET]>>2 & 0x1,
+ ptr[offset + SPB_BPDU_AGREEMENT_FORMAT_OFFSET]>>4,
+ ptr[offset + SPB_BPDU_AGREEMENT_FORMAT_OFFSET]&0x00ff,
+ ptr[offset + SPB_BPDU_AGREEMENT_CON_OFFSET]>>4,
+ ptr[offset + SPB_BPDU_AGREEMENT_CON_OFFSET]&0x00ff,
+ EXTRACT_16BITS(ptr + offset + SPB_BPDU_AGREEMENT_EDGE_OFFSET),
+ EXTRACT_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET),
+ EXTRACT_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET)+4,
+ EXTRACT_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET)+8,
+ EXTRACT_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET)+12,
+ EXTRACT_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET)+16));
}
/*
* Print 802.1d / 802.1w / 802.1q (mstp) / 802.1aq (spb) packets.
*/
void
-stp_print(const u_char *p, u_int length)
+stp_print(netdissect_options *ndo, const u_char *p, u_int length)
{
const struct stp_bpdu_ *stp_bpdu;
- u_int16_t mstp_len;
- u_int16_t spb_len;
-
+ u_int mstp_len;
+ u_int spb_len;
+
stp_bpdu = (struct stp_bpdu_*)p;
/* Minimum STP Frame size. */
if (length < 4)
goto trunc;
-
+
if (EXTRACT_16BITS(&stp_bpdu->protocol_id)) {
- printf("unknown STP version, length %u", length);
+ ND_PRINT((ndo, "unknown STP version, length %u", length));
return;
}
- printf("STP %s", tok2str(stp_proto_values, "Unknown STP protocol (0x%02x)",
- stp_bpdu->protocol_version));
+ ND_PRINT((ndo, "STP %s", tok2str(stp_proto_values, "Unknown STP protocol (0x%02x)",
+ stp_bpdu->protocol_version)));
switch (stp_bpdu->protocol_version) {
case STP_PROTO_REGULAR:
@@ -387,15 +393,15 @@ stp_print(const u_char *p, u_int length)
return;
}
- printf(", %s", tok2str(stp_bpdu_type_values, "Unknown BPDU Type (0x%02x)",
- stp_bpdu->bpdu_type));
+ ND_PRINT((ndo, ", %s", tok2str(stp_bpdu_type_values, "Unknown BPDU Type (0x%02x)",
+ stp_bpdu->bpdu_type)));
switch (stp_bpdu->bpdu_type) {
case STP_BPDU_TYPE_CONFIG:
if (length < sizeof(struct stp_bpdu_) - 1) {
goto trunc;
}
- stp_print_config_bpdu(stp_bpdu, length);
+ stp_print_config_bpdu(ndo, stp_bpdu, length);
break;
case STP_BPDU_TYPE_RSTP:
@@ -403,7 +409,7 @@ stp_print(const u_char *p, u_int length)
if (length < sizeof(struct stp_bpdu_)) {
goto trunc;
}
- stp_print_config_bpdu(stp_bpdu, length);
+ stp_print_config_bpdu(ndo, stp_bpdu, length);
} else if (stp_bpdu->protocol_version == STP_PROTO_MSTP ||
stp_bpdu->protocol_version == STP_PROTO_SPB) {
if (length < STP_BPDU_MSTP_MIN_LEN) {
@@ -421,6 +427,7 @@ stp_print(const u_char *p, u_int length)
if (length < (sizeof(struct stp_bpdu_) + mstp_len)) {
goto trunc;
}
+ stp_print_mstp_bpdu(ndo, stp_bpdu, length);
if (stp_bpdu->protocol_version == STP_PROTO_SPB)
{
@@ -431,9 +438,8 @@ stp_print(const u_char *p, u_int length)
spb_len < SPB_BPDU_MIN_LEN) {
goto trunc;
}
+ stp_print_spb_bpdu(ndo, stp_bpdu, (sizeof(struct stp_bpdu_) + mstp_len));
}
-
- stp_print_mstp_bpdu(stp_bpdu, length);
}
break;
@@ -447,7 +453,7 @@ stp_print(const u_char *p, u_int length)
return;
trunc:
- printf("[|stp %d]", length);
+ ND_PRINT((ndo, "[|stp %d]", length));
}
/*
diff --git a/contrib/tcpdump/print-sunatm.c b/contrib/tcpdump/print-sunatm.c
index e6f19e8586f1..fc03d42a4702 100644
--- a/contrib/tcpdump/print-sunatm.c
+++ b/contrib/tcpdump/print-sunatm.c
@@ -29,29 +29,21 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-sunatm.c,v 1.8 2004-03-17 23:24:38 guy Exp $ (LBL)";
-#endif
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-
+
struct mbuf;
struct rtentry;
-
-#include <stdio.h>
-#include <pcap.h>
#include "interface.h"
#include "extract.h"
-#include "addrtoname.h"
#include "atm.h"
-#include "atmuni31.h"
/* SunATM header for ATM packet */
#define DIR_POS 0 /* Direction (0x80 = transmit, 0x00 = receive) */
@@ -70,7 +62,8 @@ struct rtentry;
* is the number of bytes actually captured.
*/
u_int
-sunatm_if_print(const struct pcap_pkthdr *h, const u_char *p)
+sunatm_if_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, const u_char *p)
{
u_int caplen = h->caplen;
u_int length = h->len;
@@ -79,15 +72,12 @@ sunatm_if_print(const struct pcap_pkthdr *h, const u_char *p)
u_int traftype;
if (caplen < PKT_BEGIN_POS) {
- printf("[|atm]");
+ ND_PRINT((ndo, "[|atm]"));
return (caplen);
}
- if (eflag) {
- if (p[DIR_POS] & 0x80)
- printf("Tx: ");
- else
- printf("Rx: ");
+ if (ndo->ndo_eflag) {
+ ND_PRINT((ndo, p[DIR_POS] & 0x80 ? "Tx: " : "Rx: "));
}
switch (p[DIR_POS] & 0x0f) {
@@ -111,7 +101,7 @@ sunatm_if_print(const struct pcap_pkthdr *h, const u_char *p)
p += PKT_BEGIN_POS;
caplen -= PKT_BEGIN_POS;
length -= PKT_BEGIN_POS;
- atm_print(vpi, vci, traftype, p, length, caplen);
+ atm_print(ndo, vpi, vci, traftype, p, length, caplen);
return (PKT_BEGIN_POS);
}
diff --git a/contrib/tcpdump/print-sunrpc.c b/contrib/tcpdump/print-sunrpc.c
index 3a1fce749803..6d982826c560 100644
--- a/contrib/tcpdump/print-sunrpc.c
+++ b/contrib/tcpdump/print-sunrpc.c
@@ -21,11 +21,7 @@
* $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-sunrpc.c,v 1.47 2005-04-27 21:43:48 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -68,9 +64,97 @@ static const char rcsid[] _U_ =
#include "rpc_auth.h"
#include "rpc_msg.h"
-#include "pmap_prot.h"
-static struct tok proc2str[] = {
+/*
+ * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
+ * unrestricted use provided that this legend is included on all tape
+ * media and as a part of the software program in whole or part. Users
+ * may copy or modify Sun RPC without charge, but are not authorized
+ * to license or distribute it to anyone else except as part of a product or
+ * program developed by the user.
+ *
+ * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
+ * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
+ *
+ * Sun RPC is provided with no support and without any obligation on the
+ * part of Sun Microsystems, Inc. to assist in its use, correction,
+ * modification or enhancement.
+ *
+ * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
+ * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
+ * OR ANY PART THEREOF.
+ *
+ * In no event will Sun Microsystems, Inc. be liable for any lost revenue
+ * or profits or other special, indirect and consequential damages, even if
+ * Sun has been advised of the possibility of such damages.
+ *
+ * Sun Microsystems, Inc.
+ * 2550 Garcia Avenue
+ * Mountain View, California 94043
+ *
+ * from: @(#)pmap_prot.h 1.14 88/02/08 SMI
+ * from: @(#)pmap_prot.h 2.1 88/07/29 4.0 RPCSRC
+ * $FreeBSD$
+ */
+
+/*
+ * pmap_prot.h
+ * Protocol for the local binder service, or pmap.
+ *
+ * Copyright (C) 1984, Sun Microsystems, Inc.
+ *
+ * The following procedures are supported by the protocol:
+ *
+ * PMAPPROC_NULL() returns ()
+ * takes nothing, returns nothing
+ *
+ * PMAPPROC_SET(struct pmap) returns (bool_t)
+ * TRUE is success, FALSE is failure. Registers the tuple
+ * [prog, vers, prot, port].
+ *
+ * PMAPPROC_UNSET(struct pmap) returns (bool_t)
+ * TRUE is success, FALSE is failure. Un-registers pair
+ * [prog, vers]. prot and port are ignored.
+ *
+ * PMAPPROC_GETPORT(struct pmap) returns (long unsigned).
+ * 0 is failure. Otherwise returns the port number where the pair
+ * [prog, vers] is registered. It may lie!
+ *
+ * PMAPPROC_DUMP() RETURNS (struct pmaplist *)
+ *
+ * PMAPPROC_CALLIT(unsigned, unsigned, unsigned, string<>)
+ * RETURNS (port, string<>);
+ * usage: encapsulatedresults = PMAPPROC_CALLIT(prog, vers, proc, encapsulatedargs);
+ * Calls the procedure on the local machine. If it is not registered,
+ * this procedure is quite; ie it does not return error information!!!
+ * This procedure only is supported on rpc/udp and calls via
+ * rpc/udp. This routine only passes null authentication parameters.
+ * This file has no interface to xdr routines for PMAPPROC_CALLIT.
+ *
+ * The service supports remote procedure calls on udp/ip or tcp/ip socket 111.
+ */
+
+#define SUNRPC_PMAPPORT ((uint16_t)111)
+#define SUNRPC_PMAPPROG ((uint32_t)100000)
+#define SUNRPC_PMAPVERS ((uint32_t)2)
+#define SUNRPC_PMAPVERS_PROTO ((uint32_t)2)
+#define SUNRPC_PMAPVERS_ORIG ((uint32_t)1)
+#define SUNRPC_PMAPPROC_NULL ((uint32_t)0)
+#define SUNRPC_PMAPPROC_SET ((uint32_t)1)
+#define SUNRPC_PMAPPROC_UNSET ((uint32_t)2)
+#define SUNRPC_PMAPPROC_GETPORT ((uint32_t)3)
+#define SUNRPC_PMAPPROC_DUMP ((uint32_t)4)
+#define SUNRPC_PMAPPROC_CALLIT ((uint32_t)5)
+
+struct sunrpc_pmap {
+ uint32_t pm_prog;
+ uint32_t pm_vers;
+ uint32_t pm_prot;
+ uint32_t pm_port;
+};
+
+static const struct tok proc2str[] = {
{ SUNRPC_PMAPPROC_NULL, "null" },
{ SUNRPC_PMAPPROC_SET, "set" },
{ SUNRPC_PMAPPROC_UNSET, "unset" },
@@ -81,23 +165,23 @@ static struct tok proc2str[] = {
};
/* Forwards */
-static char *progstr(u_int32_t);
+static char *progstr(uint32_t);
void
-sunrpcrequest_print(register const u_char *bp, register u_int length,
- register const u_char *bp2)
+sunrpcrequest_print(netdissect_options *ndo, register const u_char *bp,
+ register u_int length, register const u_char *bp2)
{
register const struct sunrpc_msg *rp;
register const struct ip *ip;
#ifdef INET6
register const struct ip6_hdr *ip6;
#endif
- u_int32_t x;
+ uint32_t x;
char srcid[20], dstid[20]; /*fits 32bit*/
rp = (struct sunrpc_msg *)bp;
- if (!nflag) {
+ if (!ndo->ndo_nflag) {
snprintf(srcid, sizeof(srcid), "0x%x",
EXTRACT_32BITS(&rp->rm_xid));
strlcpy(dstid, "sunrpc", sizeof(dstid));
@@ -110,28 +194,28 @@ sunrpcrequest_print(register const u_char *bp, register u_int length,
switch (IP_V((struct ip *)bp2)) {
case 4:
ip = (struct ip *)bp2;
- printf("%s.%s > %s.%s: %d",
- ipaddr_string(&ip->ip_src), srcid,
- ipaddr_string(&ip->ip_dst), dstid, length);
+ ND_PRINT((ndo, "%s.%s > %s.%s: %d",
+ ipaddr_string(ndo, &ip->ip_src), srcid,
+ ipaddr_string(ndo, &ip->ip_dst), dstid, length));
break;
#ifdef INET6
case 6:
ip6 = (struct ip6_hdr *)bp2;
- printf("%s.%s > %s.%s: %d",
- ip6addr_string(&ip6->ip6_src), srcid,
- ip6addr_string(&ip6->ip6_dst), dstid, length);
+ ND_PRINT((ndo, "%s.%s > %s.%s: %d",
+ ip6addr_string(ndo, &ip6->ip6_src), srcid,
+ ip6addr_string(ndo, &ip6->ip6_dst), dstid, length));
break;
#endif
default:
- printf("%s.%s > %s.%s: %d", "?", srcid, "?", dstid, length);
+ ND_PRINT((ndo, "%s.%s > %s.%s: %d", "?", srcid, "?", dstid, length));
break;
}
- printf(" %s", tok2str(proc2str, " proc #%u",
- EXTRACT_32BITS(&rp->rm_call.cb_proc)));
+ ND_PRINT((ndo, " %s", tok2str(proc2str, " proc #%u",
+ EXTRACT_32BITS(&rp->rm_call.cb_proc))));
x = EXTRACT_32BITS(&rp->rm_call.cb_rpcvers);
if (x != 2)
- printf(" [rpcver %u]", x);
+ ND_PRINT((ndo, " [rpcver %u]", x));
switch (EXTRACT_32BITS(&rp->rm_call.cb_proc)) {
@@ -140,24 +224,23 @@ sunrpcrequest_print(register const u_char *bp, register u_int length,
case SUNRPC_PMAPPROC_GETPORT:
case SUNRPC_PMAPPROC_CALLIT:
x = EXTRACT_32BITS(&rp->rm_call.cb_prog);
- if (!nflag)
- printf(" %s", progstr(x));
+ if (!ndo->ndo_nflag)
+ ND_PRINT((ndo, " %s", progstr(x)));
else
- printf(" %u", x);
- printf(".%u", EXTRACT_32BITS(&rp->rm_call.cb_vers));
+ ND_PRINT((ndo, " %u", x));
+ ND_PRINT((ndo, ".%u", EXTRACT_32BITS(&rp->rm_call.cb_vers)));
break;
}
}
static char *
-progstr(prog)
- u_int32_t prog;
+progstr(uint32_t prog)
{
#if defined(HAVE_GETRPCBYNUMBER) && defined(HAVE_RPC_RPC_H)
register struct rpcent *rp;
#endif
static char buf[32];
- static u_int32_t lastprog = 0;
+ static uint32_t lastprog = 0;
if (lastprog != 0 && prog == lastprog)
return (buf);
diff --git a/contrib/tcpdump/print-symantec.c b/contrib/tcpdump/print-symantec.c
index 8b4ee38c4093..dcff2a66bf05 100644
--- a/contrib/tcpdump/print-symantec.c
+++ b/contrib/tcpdump/print-symantec.c
@@ -18,57 +18,50 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-symantec.c,v 1.5 2005-07-07 01:22:21 guy Exp $ (LBL)";
-#endif
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <pcap.h>
-
#include "interface.h"
#include "extract.h"
-#include "addrtoname.h"
#include "ethertype.h"
#include "ether.h"
struct symantec_header {
- u_int8_t stuff1[6];
- u_int16_t ether_type;
- u_int8_t stuff2[36];
+ uint8_t stuff1[6];
+ uint16_t ether_type;
+ uint8_t stuff2[36];
};
static inline void
-symantec_hdr_print(register const u_char *bp, u_int length)
+symantec_hdr_print(netdissect_options *ndo, register const u_char *bp, u_int length)
{
register const struct symantec_header *sp;
- u_int16_t etype;
+ uint16_t etype;
sp = (const struct symantec_header *)bp;
etype = EXTRACT_16BITS(&sp->ether_type);
- if (!qflag) {
+ if (!ndo->ndo_qflag) {
if (etype <= ETHERMTU)
- (void)printf("invalid ethertype %u", etype);
- else
- (void)printf("ethertype %s (0x%04x)",
+ ND_PRINT((ndo, "invalid ethertype %u", etype));
+ else
+ ND_PRINT((ndo, "ethertype %s (0x%04x)",
tok2str(ethertype_values,"Unknown", etype),
- etype);
+ etype));
} else {
if (etype <= ETHERMTU)
- (void)printf("invalid ethertype %u", etype);
- else
- (void)printf("%s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", etype));
+ ND_PRINT((ndo, "invalid ethertype %u", etype));
+ else
+ ND_PRINT((ndo, "%s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", etype)));
}
- (void)printf(", length %u: ", length);
+ ND_PRINT((ndo, ", length %u: ", length));
}
/*
@@ -78,7 +71,7 @@ symantec_hdr_print(register const u_char *bp, u_int length)
* is the number of bytes actually captured.
*/
u_int
-symantec_if_print(const struct pcap_pkthdr *h, const u_char *p)
+symantec_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
{
u_int length = h->len;
u_int caplen = h->caplen;
@@ -86,12 +79,12 @@ symantec_if_print(const struct pcap_pkthdr *h, const u_char *p)
u_short ether_type;
if (caplen < sizeof (struct symantec_header)) {
- printf("[|symantec]");
+ ND_PRINT((ndo, "[|symantec]"));
return caplen;
}
- if (eflag)
- symantec_hdr_print(p, length);
+ if (ndo->ndo_eflag)
+ symantec_hdr_print(ndo, p, length);
length -= sizeof (struct symantec_header);
caplen -= sizeof (struct symantec_header);
@@ -102,19 +95,19 @@ symantec_if_print(const struct pcap_pkthdr *h, const u_char *p)
if (ether_type <= ETHERMTU) {
/* ether_type not known, print raw packet */
- if (!eflag)
- symantec_hdr_print((u_char *)sp, length + sizeof (struct symantec_header));
+ if (!ndo->ndo_eflag)
+ symantec_hdr_print(ndo, (u_char *)sp, length + sizeof (struct symantec_header));
- if (!suppress_default_print)
- default_print(p, caplen);
- } else if (ethertype_print(gndo, ether_type, p, length, caplen) == 0) {
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
+ } else if (ethertype_print(ndo, ether_type, p, length, caplen) == 0) {
/* ether_type not known, print raw packet */
- if (!eflag)
- symantec_hdr_print((u_char *)sp, length + sizeof (struct symantec_header));
+ if (!ndo->ndo_eflag)
+ symantec_hdr_print(ndo, (u_char *)sp, length + sizeof (struct symantec_header));
- if (!suppress_default_print)
- default_print(p, caplen);
- }
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
+ }
return (sizeof (struct symantec_header));
}
diff --git a/contrib/tcpdump/print-syslog.c b/contrib/tcpdump/print-syslog.c
index 3685d62042a0..5e3cd4f70fe0 100644
--- a/contrib/tcpdump/print-syslog.c
+++ b/contrib/tcpdump/print-syslog.c
@@ -14,25 +14,19 @@
* FOR A PARTICULAR PURPOSE.
*/
-#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 $";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <stdlib.h>
-
#include "interface.h"
#include "extract.h"
-#include "addrtoname.h"
-/*
+static const char tstr[] = "[|syslog]";
+
+/*
* tokenlists and #defines taken from Ethereal - Network traffic analyzer
* by Gerald Combs <gerald@ethereal.com>
*/
@@ -82,11 +76,12 @@ static const struct tok syslog_facility_values[] = {
};
void
-syslog_print(register const u_char *pptr, register u_int len)
+syslog_print(netdissect_options *ndo,
+ register const u_char *pptr, register u_int len)
{
- u_int16_t msg_off = 0;
- u_int16_t pri = 0;
- u_int16_t facility,severity;
+ uint16_t msg_off = 0;
+ uint16_t pri = 0;
+ uint16_t facility,severity;
/* extract decimal figures that are
* encapsulated within < > tags
@@ -94,70 +89,57 @@ syslog_print(register const u_char *pptr, register u_int len)
* severity and facility values
*/
- if (!TTEST2(*pptr, 1))
- goto trunc;
-
+ ND_TCHECK2(*pptr, 1);
if (*(pptr+msg_off) == '<') {
msg_off++;
-
- if (!TTEST2(*(pptr+msg_off), 1))
- goto trunc;
-
+ ND_TCHECK2(*(pptr + msg_off), 1);
while ( *(pptr+msg_off) >= '0' &&
*(pptr+msg_off) <= '9' &&
msg_off <= SYSLOG_MAX_DIGITS) {
-
- if (!TTEST2(*(pptr+msg_off), 1))
- goto trunc;
-
pri = pri * 10 + (*(pptr+msg_off) - '0');
msg_off++;
-
- if (!TTEST2(*(pptr+msg_off), 1))
- goto trunc;
-
- if (*(pptr+msg_off) == '>')
- msg_off++;
+ ND_TCHECK2(*(pptr + msg_off), 1);
+ }
+ if (*(pptr+msg_off) != '>') {
+ ND_PRINT((ndo, "%s", tstr));
+ return;
}
+ msg_off++;
} else {
- printf("[|syslog]");
+ ND_PRINT((ndo, "%s", tstr));
return;
}
facility = (pri & SYSLOG_FACILITY_MASK) >> 3;
severity = pri & SYSLOG_SEVERITY_MASK;
-
- if (vflag < 1 )
+ if (ndo->ndo_vflag < 1 )
{
- printf("SYSLOG %s.%s, length: %u",
+ ND_PRINT((ndo, "SYSLOG %s.%s, length: %u",
tok2str(syslog_facility_values, "unknown (%u)", facility),
tok2str(syslog_severity_values, "unknown (%u)", severity),
- len);
+ len));
return;
}
-
- printf("SYSLOG, length: %u\n\tFacility %s (%u), Severity %s (%u)\n\tMsg: ",
+
+ ND_PRINT((ndo, "SYSLOG, length: %u\n\tFacility %s (%u), Severity %s (%u)\n\tMsg: ",
len,
tok2str(syslog_facility_values, "unknown (%u)", facility),
facility,
tok2str(syslog_severity_values, "unknown (%u)", severity),
- severity);
+ severity));
/* print the syslog text in verbose mode */
for (; msg_off < len; msg_off++) {
- if (!TTEST2(*(pptr+msg_off), 1))
- goto trunc;
- safeputchar(*(pptr+msg_off));
+ ND_TCHECK2(*(pptr + msg_off), 1);
+ safeputchar(ndo, *(pptr + msg_off));
}
- if (vflag > 1) {
- if(!print_unknown_data(pptr,"\n\t",len))
- return;
- }
-
+ if (ndo->ndo_vflag > 1)
+ print_unknown_data(ndo, pptr, "\n\t", len);
+
return;
trunc:
- printf("[|syslog]");
+ ND_PRINT((ndo, "%s", tstr));
}
diff --git a/contrib/tcpdump/print-tcp.c b/contrib/tcpdump/print-tcp.c
index 3b0a13541afc..5b1133a6c30a 100644
--- a/contrib/tcpdump/print-tcp.c
+++ b/contrib/tcpdump/print-tcp.c
@@ -24,19 +24,17 @@
*/
#ifndef lint
-static const char rcsid[] _U_ =
-"@(#) $Header: /tcpdump/master/tcpdump/print-tcp.c,v 1.135 2008-11-09 23:35:03 mcr Exp $ (LBL)";
#else
__RCSID("$NetBSD: print-tcp.c,v 1.8 2007/07/24 11:53:48 drochner Exp $");
#endif
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -60,23 +58,19 @@ __RCSID("$NetBSD: print-tcp.c,v 1.8 2007/07/24 11:53:48 drochner Exp $");
#include <openssl/md5.h>
#include <signature.h>
-static int tcp_verify_signature(const struct ip *ip, const struct tcphdr *tp,
+static int tcp_verify_signature(netdissect_options *ndo,
+ const struct ip *ip, const struct tcphdr *tp,
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);
+static void print_tcp_rst_data(netdissect_options *, register const u_char *sp, u_int length);
#define MAX_RST_DATA_LEN 30
struct tha {
-#ifndef INET6
struct in_addr src;
struct in_addr dst;
-#else
- struct in6_addr src;
- struct in6_addr dst;
-#endif /*INET6*/
u_int port;
};
@@ -87,14 +81,32 @@ struct tcp_seq_hash {
tcp_seq ack;
};
+#ifdef INET6
+struct tha6 {
+ struct in6_addr src;
+ struct in6_addr dst;
+ u_int port;
+};
+
+struct tcp_seq_hash6 {
+ struct tcp_seq_hash6 *nxt;
+ struct tha6 addr;
+ tcp_seq seq;
+ tcp_seq ack;
+};
+#endif
+
#define TSEQ_HASHSIZE 919
/* These tcp optinos do not have the size octet */
#define ZEROLENOPT(o) ((o) == TCPOPT_EOL || (o) == TCPOPT_NOP)
-static struct tcp_seq_hash tcp_seq_hash[TSEQ_HASHSIZE];
+static struct tcp_seq_hash tcp_seq_hash4[TSEQ_HASHSIZE];
+#ifdef INET6
+static struct tcp_seq_hash6 tcp_seq_hash6[TSEQ_HASHSIZE];
+#endif
-struct tok tcp_flag_values[] = {
+static const struct tok tcp_flag_values[] = {
{ TH_FIN, "F" },
{ TH_SYN, "S" },
{ TH_RST, "R" },
@@ -106,7 +118,7 @@ struct tok tcp_flag_values[] = {
{ 0, NULL }
};
-struct tok tcp_option_values[] = {
+static const struct tok tcp_option_values[] = {
{ TCPOPT_EOL, "eol" },
{ TCPOPT_NOP, "nop" },
{ TCPOPT_MAXSEG, "mss" },
@@ -122,30 +134,36 @@ struct tok tcp_option_values[] = {
{ TCPOPT_SIGNATURE, "md5" },
{ TCPOPT_AUTH, "enhanced auth" },
{ TCPOPT_UTO, "uto" },
+ { TCPOPT_MPTCP, "mptcp" },
+ { TCPOPT_EXPERIMENT2, "exp" },
{ 0, NULL }
};
-static int tcp_cksum(register const struct ip *ip,
- register const struct tcphdr *tp,
- register u_int len)
+static int
+tcp_cksum(netdissect_options *ndo,
+ register const struct ip *ip,
+ register const struct tcphdr *tp,
+ register u_int len)
{
- return (nextproto4_cksum(ip, (const u_int8_t *)tp, len,
- IPPROTO_TCP));
+ return nextproto4_cksum(ndo, ip, (const uint8_t *)tp, len, len,
+ IPPROTO_TCP);
}
void
-tcp_print(register const u_char *bp, register u_int length,
- register const u_char *bp2, int fragmented)
+tcp_print(netdissect_options *ndo,
+ 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;
+ uint16_t sport, dport, win, urp;
+ uint32_t seq, ack, thseq, thack;
u_int utoval;
- int threv;
+ uint16_t magic;
+ register int rev;
#ifdef INET6
register const struct ip6_hdr *ip6;
#endif
@@ -159,10 +177,10 @@ tcp_print(register const u_char *bp, register u_int length,
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));
+ if (!ND_TTEST(tp->th_dport)) {
+ ND_PRINT((ndo, "%s > %s: [|tcp]",
+ ipaddr_string(ndo, &ip->ip_src),
+ ipaddr_string(ndo, &ip->ip_dst)));
return;
}
@@ -171,254 +189,217 @@ tcp_print(register const u_char *bp, register u_int length,
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 &&
- (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),
+ ND_PRINT((ndo, "%s.%s > %s.%s: ",
+ ip6addr_string(ndo, &ip6->ip6_src),
tcpport_string(sport),
- ip6addr_string(&ip6->ip6_dst),
- tcpport_string(dport));
+ ip6addr_string(ndo, &ip6->ip6_dst),
+ tcpport_string(dport)));
} else {
- (void)printf("%s > %s: ",
- tcpport_string(sport), tcpport_string(dport));
+ ND_PRINT((ndo, "%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),
+ ND_PRINT((ndo, "%s.%s > %s.%s: ",
+ ipaddr_string(ndo, &ip->ip_src),
tcpport_string(sport),
- ipaddr_string(&ip->ip_dst),
- tcpport_string(dport));
+ ipaddr_string(ndo, &ip->ip_dst),
+ tcpport_string(dport)));
} else {
- (void)printf("%s > %s: ",
- tcpport_string(sport), tcpport_string(dport));
+ ND_PRINT((ndo, "%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));
+ ND_PRINT((ndo, " tcp %d [bad hdr length %u - too short, < %lu]",
+ length - hlen, hlen, (unsigned long)sizeof(*tp)));
return;
}
- TCHECK(*tp);
+ ND_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 (ndo->ndo_qflag) {
+ ND_PRINT((ndo, "tcp %d", length - hlen));
if (hlen > length) {
- (void)printf(" [bad hdr length %u - too long, > %u]",
- hlen, length);
+ ND_PRINT((ndo, " [bad hdr length %u - too long, > %u]",
+ hlen, length));
}
return;
}
flags = tp->th_flags;
- printf("Flags [%s]", bittok2str_nosep(tcp_flag_values, "none", flags));
+ ND_PRINT((ndo, "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;
+ if (!ndo->ndo_Sflag && (flags & TH_ACK)) {
/*
* 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
rev = 0;
+#ifdef INET6
if (ip6) {
+ register struct tcp_seq_hash6 *th;
+ struct tcp_seq_hash6 *tcp_seq_hash;
+ const struct in6_addr *src, *dst;
+ struct tha6 tha;
+
+ tcp_seq_hash = tcp_seq_hash6;
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)
+ if (UNALIGNED_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);
+ UNALIGNED_MEMCPY(&tha.src, dst, sizeof ip6->ip6_dst);
+ UNALIGNED_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);
+ UNALIGNED_MEMCPY(&tha.dst, dst, sizeof ip6->ip6_dst);
+ UNALIGNED_MEMCPY(&tha.src, src, sizeof ip6->ip6_src);
tha.port = sport << 16 | dport;
}
+
+ 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_hash6 *)
+ 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 {
- /*
- * Zero out the tha structure; the src and dst
- * fields are big enough to hold an IPv6
- * address, but we only have IPv4 addresses
- * and thus must clear out the remaining 124
- * bits.
- *
- * XXX - should we just clear those bytes after
- * copying the IPv4 addresses, rather than
- * zeroing out the entire structure and then
- * overwriting some of the zeroes?
- *
- * XXX - this could fail if we see TCP packets
- * with an IPv6 address with the lower 124 bits
- * all zero and also see TCP packes with an
- * IPv4 address with the same 32 bits as the
- * upper 32 bits of the IPv6 address in question.
- * Can that happen? Is it likely enough to be
- * an issue?
- */
- memset(&tha, 0, sizeof(tha));
+#else /*INET6*/
+ {
+#endif /*INET6*/
+ register struct tcp_seq_hash *th;
+ struct tcp_seq_hash *tcp_seq_hash;
+ const struct in_addr *src, *dst;
+ struct tha tha;
+
+ tcp_seq_hash = tcp_seq_hash4;
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)
+ if (UNALIGNED_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);
+ UNALIGNED_MEMCPY(&tha.src, dst, sizeof ip->ip_dst);
+ UNALIGNED_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);
+ UNALIGNED_MEMCPY(&tha.dst, dst, sizeof ip->ip_dst);
+ UNALIGNED_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;
- }
-#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;
+ 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");
+ 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;
}
- 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;
+ thseq = th->seq;
+ thack = th->ack;
+ }
} else {
/*fool gcc*/
- thseq = thack = threv = 0;
+ thseq = thack = rev = 0;
}
if (hlen > length) {
- (void)printf(" [bad hdr length %u - too long, > %u]",
- hlen, length);
+ ND_PRINT((ndo, " [bad hdr length %u - too long, > %u]",
+ hlen, length));
return;
}
- if (vflag && !Kflag && !fragmented) {
+ if (ndo->ndo_vflag && !ndo->ndo_Kflag && !fragmented) {
/* Check the checksum, if possible. */
- u_int16_t sum, tcp_sum;
+ uint16_t sum, tcp_sum;
if (IP_V(ip) == 4) {
- if (TTEST2(tp->th_sport, length)) {
- sum = tcp_cksum(ip, tp, length);
+ if (ND_TTEST2(tp->th_sport, length)) {
+ sum = tcp_cksum(ndo, ip, tp, length);
tcp_sum = EXTRACT_16BITS(&tp->th_sum);
- (void)printf(", cksum 0x%04x", tcp_sum);
+ ND_PRINT((ndo, ", cksum 0x%04x", tcp_sum));
if (sum != 0)
- (void)printf(" (incorrect -> 0x%04x)",
- in_cksum_shouldbe(tcp_sum, sum));
+ ND_PRINT((ndo, " (incorrect -> 0x%04x)",
+ in_cksum_shouldbe(tcp_sum, sum)));
else
- (void)printf(" (correct)");
+ ND_PRINT((ndo, " (correct)"));
}
}
#ifdef INET6
else if (IP_V(ip) == 6 && ip6->ip6_plen) {
- if (TTEST2(tp->th_sport, length)) {
- sum = nextproto6_cksum(ip6, (const u_int8_t *)tp, length, IPPROTO_TCP);
+ if (ND_TTEST2(tp->th_sport, length)) {
+ sum = nextproto6_cksum(ip6, (const uint8_t *)tp,
+ length, length, IPPROTO_TCP);
tcp_sum = EXTRACT_16BITS(&tp->th_sum);
- (void)printf(", cksum 0x%04x", tcp_sum);
+ ND_PRINT((ndo, ", cksum 0x%04x", tcp_sum));
if (sum != 0)
- (void)printf(" (incorrect -> 0x%04x)",
- in_cksum_shouldbe(tcp_sum, sum));
+ ND_PRINT((ndo, " (incorrect -> 0x%04x)",
+ in_cksum_shouldbe(tcp_sum, sum)));
else
- (void)printf(" (correct)");
+ ND_PRINT((ndo, " (correct)"));
}
}
@@ -426,22 +407,22 @@ tcp_print(register const u_char *bp, register u_int length,
}
length -= hlen;
- if (vflag > 1 || length > 0 || flags & (TH_SYN | TH_FIN | TH_RST)) {
- (void)printf(", seq %u", seq);
+ if (ndo->ndo_vflag > 1 || length > 0 || flags & (TH_SYN | TH_FIN | TH_RST)) {
+ ND_PRINT((ndo, ", seq %u", seq));
if (length > 0) {
- (void)printf(":%u", seq + length);
+ ND_PRINT((ndo, ":%u", seq + length));
}
}
if (flags & TH_ACK) {
- (void)printf(", ack %u", ack);
+ ND_PRINT((ndo, ", ack %u", ack));
}
- (void)printf(", win %d", win);
+ ND_PRINT((ndo, ", win %d", win));
if (flags & TH_URG)
- (void)printf(", urg %d", urp);
+ ND_PRINT((ndo, ", urg %d", urp));
/*
* Handle any options.
*/
@@ -452,16 +433,16 @@ tcp_print(register const u_char *bp, register u_int length,
hlen -= sizeof(*tp);
cp = (const u_char *)tp + sizeof(*tp);
- printf(", options [");
+ ND_PRINT((ndo, ", options ["));
while (hlen > 0) {
if (ch != '\0')
- putchar(ch);
- TCHECK(*cp);
+ ND_PRINT((ndo, "%c", ch));
+ ND_TCHECK(*cp);
opt = *cp++;
if (ZEROLENOPT(opt))
len = 1;
else {
- TCHECK(*cp);
+ ND_TCHECK(*cp);
len = *cp++; /* total including type, len */
if (len < 2 || len > hlen)
goto bad;
@@ -471,46 +452,46 @@ tcp_print(register const u_char *bp, register u_int length,
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); }
+#define LENCHECK(l) { if ((l) > hlen) goto bad; ND_TCHECK2(*cp, l); }
- printf("%s", tok2str(tcp_option_values, "Unknown Option %u", opt));
+ ND_PRINT((ndo, "%s", tok2str(tcp_option_values, "unknown-%u", opt)));
switch (opt) {
case TCPOPT_MAXSEG:
datalen = 2;
LENCHECK(datalen);
- (void)printf(" %u", EXTRACT_16BITS(cp));
+ ND_PRINT((ndo, " %u", EXTRACT_16BITS(cp)));
break;
case TCPOPT_WSCALE:
datalen = 1;
LENCHECK(datalen);
- (void)printf(" %u", *cp);
+ ND_PRINT((ndo, " %u", *cp));
break;
case TCPOPT_SACK:
datalen = len - 2;
if (datalen % 8 != 0) {
- (void)printf("malformed sack");
+ ND_PRINT((ndo, "malformed sack"));
} else {
- u_int32_t s, e;
+ uint32_t s, e;
- (void)printf(" %d ", datalen / 8);
+ ND_PRINT((ndo, " %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) {
+ if (rev) {
s -= thseq;
e -= thseq;
} else {
s -= thack;
e -= thack;
}
- (void)printf("{%u:%u}", s, e);
+ ND_PRINT((ndo, "{%u:%u}", s, e));
}
}
break;
@@ -527,50 +508,50 @@ tcp_print(register const u_char *bp, register u_int length,
*/
datalen = 4;
LENCHECK(datalen);
- (void)printf(" %u", EXTRACT_32BITS(cp));
+ ND_PRINT((ndo, " %u", EXTRACT_32BITS(cp)));
break;
case TCPOPT_TIMESTAMP:
datalen = 8;
LENCHECK(datalen);
- (void)printf(" val %u ecr %u",
+ ND_PRINT((ndo, " val %u ecr %u",
EXTRACT_32BITS(cp),
- EXTRACT_32BITS(cp + 4));
+ EXTRACT_32BITS(cp + 4)));
break;
case TCPOPT_SIGNATURE:
datalen = TCP_SIGLEN;
LENCHECK(datalen);
#ifdef HAVE_LIBCRYPTO
- switch (tcp_verify_signature(ip, tp,
+ switch (tcp_verify_signature(ndo, ip, tp,
bp + TH_OFF(tp) * 4, length, cp)) {
case SIGNATURE_VALID:
- (void)printf("valid");
+ ND_PRINT((ndo, "valid"));
break;
case SIGNATURE_INVALID:
- (void)printf("invalid");
+ ND_PRINT((ndo, "invalid"));
break;
case CANT_CHECK_SIGNATURE:
- (void)printf("can't check - ");
+ ND_PRINT((ndo, "can't check - "));
for (i = 0; i < TCP_SIGLEN; ++i)
- (void)printf("%02x", cp[i]);
+ ND_PRINT((ndo, "%02x", cp[i]));
break;
}
#else
for (i = 0; i < TCP_SIGLEN; ++i)
- (void)printf("%02x", cp[i]);
+ ND_PRINT((ndo, "%02x", cp[i]));
#endif
break;
case TCPOPT_AUTH:
- (void)printf("keyid %d", *cp++);
+ ND_PRINT((ndo, "keyid %d", *cp++));
datalen = len - 3;
for (i = 0; i < datalen; ++i) {
LENCHECK(i);
- (void)printf("%02x", cp[i]);
+ ND_PRINT((ndo, "%02x", cp[i]));
}
break;
@@ -588,19 +569,63 @@ tcp_print(register const u_char *bp, register u_int length,
datalen = 2;
LENCHECK(datalen);
utoval = EXTRACT_16BITS(cp);
- (void)printf("0x%x", utoval);
+ ND_PRINT((ndo, "0x%x", utoval));
if (utoval & 0x0001)
utoval = (utoval >> 1) * 60;
else
utoval >>= 1;
- (void)printf(" %u", utoval);
+ ND_PRINT((ndo, " %u", utoval));
+ break;
+
+ case TCPOPT_MPTCP:
+ datalen = len - 2;
+ LENCHECK(datalen);
+ if (!mptcp_print(ndo, cp-2, len, flags))
+ goto bad;
+ break;
+
+ case TCPOPT_EXPERIMENT2:
+ datalen = len - 2;
+ LENCHECK(datalen);
+ if (datalen < 2)
+ goto bad;
+ /* RFC6994 */
+ magic = EXTRACT_16BITS(cp);
+ ND_PRINT((ndo, "-"));
+
+ switch(magic) {
+
+ case 0xf989:
+ /* TCP Fast Open: draft-ietf-tcpm-fastopen-04 */
+ if (datalen == 2) {
+ /* Fast Open Cookie Request */
+ ND_PRINT((ndo, "tfo cookiereq"));
+ } else {
+ /* Fast Open Cookie */
+ if (datalen % 2 != 0 || datalen < 6 || datalen > 18) {
+ ND_PRINT((ndo, "tfo malformed"));
+ } else {
+ ND_PRINT((ndo, "tfo cookie "));
+ for (i = 2; i < datalen; ++i)
+ ND_PRINT((ndo, "%02x", cp[i]));
+ }
+ }
+ break;
+
+ default:
+ /* Unknown magic number */
+ ND_PRINT((ndo, "%04x", magic));
+ break;
+ }
break;
default:
datalen = len - 2;
+ if (datalen)
+ ND_PRINT((ndo, " 0x"));
for (i = 0; i < datalen; ++i) {
LENCHECK(i);
- (void)printf("%02x", cp[i]);
+ ND_PRINT((ndo, "%02x", cp[i]));
}
break;
}
@@ -614,18 +639,18 @@ tcp_print(register const u_char *bp, register u_int length,
if (!ZEROLENOPT(opt))
++datalen; /* size octet */
if (datalen != len)
- (void)printf("[len %d]", len);
+ ND_PRINT((ndo, "[len %d]", len));
ch = ',';
if (opt == TCPOPT_EOL)
break;
}
- putchar(']');
+ ND_PRINT((ndo, "]"));
}
/*
* Print length field before crawling down the stack.
*/
- printf(", length %u", length);
+ ND_PRINT((ndo, ", length %u", length));
if (length <= 0)
return;
@@ -634,35 +659,38 @@ tcp_print(register const u_char *bp, register u_int length,
* Decode payload if necessary.
*/
bp += TH_OFF(tp) * 4;
- if ((flags & TH_RST) && vflag) {
- print_tcp_rst_data(bp, length);
+ if ((flags & TH_RST) && ndo->ndo_vflag) {
+ print_tcp_rst_data(ndo, bp, length);
return;
- }
+ }
- if (packettype) {
- switch (packettype) {
+ if (ndo->ndo_packettype) {
+ switch (ndo->ndo_packettype) {
case PT_ZMTP1:
- zmtp1_print(bp, length);
+ zmtp1_print(ndo, bp, length);
break;
}
return;
}
if (sport == TELNET_PORT || dport == TELNET_PORT) {
- if (!qflag && vflag)
- telnet_print(bp, length);
+ if (!ndo->ndo_qflag && ndo->ndo_vflag)
+ telnet_print(ndo, bp, length);
} else if (sport == BGP_PORT || dport == BGP_PORT)
- bgp_print(bp, length);
+ bgp_print(ndo, bp, length);
else if (sport == PPTP_PORT || dport == PPTP_PORT)
- pptp_print(bp);
+ pptp_print(ndo, bp);
#ifdef TCPDUMP_DO_SMB
else if (sport == NETBIOS_SSN_PORT || dport == NETBIOS_SSN_PORT)
- nbt_tcp_print(bp, length);
+ nbt_tcp_print(ndo, bp, length);
else if (sport == SMB_PORT || dport == SMB_PORT)
- smb_tcp_print(bp, length);
+ smb_tcp_print(ndo, bp, length);
#endif
else if (sport == BEEP_PORT || dport == BEEP_PORT)
- beep_print(bp, length);
+ beep_print(ndo, bp, length);
+ else if (sport == OPENFLOW_PORT_OLD || dport == OPENFLOW_PORT_OLD ||
+ sport == OPENFLOW_PORT_IANA || dport == OPENFLOW_PORT_IANA)
+ openflow_print(ndo, bp, length);
else if (length > 2 &&
(sport == NAMESERVER_PORT || dport == NAMESERVER_PORT ||
sport == MULTICASTDNS_PORT || dport == MULTICASTDNS_PORT)) {
@@ -670,26 +698,56 @@ tcp_print(register const u_char *bp, register u_int length,
* 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);
+ ns_print(ndo, bp + 2, length - 2, 0);
} else if (sport == MSDP_PORT || dport == MSDP_PORT) {
- msdp_print(bp, length);
+ msdp_print(ndo, bp, length);
} else if (sport == RPKI_RTR_PORT || dport == RPKI_RTR_PORT) {
- rpki_rtr_print(bp, length);
+ rpki_rtr_print(ndo, bp, length);
}
else if (length > 0 && (sport == LDP_PORT || dport == LDP_PORT)) {
- ldp_print(bp, length);
+ ldp_print(ndo, bp, length);
+ }
+ else if ((sport == NFS_PORT || dport == NFS_PORT) &&
+ length >= 4 && ND_TTEST2(*bp, 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.
+ */
+ uint32_t fraglen;
+ register struct sunrpc_msg *rp;
+ enum sunrpc_msg_type direction;
+
+ fraglen = EXTRACT_32BITS(bp) & 0x7FFFFFFF;
+ if (fraglen > (length) - 4)
+ fraglen = (length) - 4;
+ rp = (struct sunrpc_msg *)(bp + 4);
+ if (ND_TTEST(rp->rm_direction)) {
+ direction = (enum sunrpc_msg_type)EXTRACT_32BITS(&rp->rm_direction);
+ if (dport == NFS_PORT && direction == SUNRPC_CALL) {
+ ND_PRINT((ndo, ": NFS request xid %u ", EXTRACT_32BITS(&rp->rm_xid)));
+ nfsreq_print_noaddr(ndo, (u_char *)rp, fraglen, (u_char *)ip);
+ return;
+ }
+ if (sport == NFS_PORT && direction == SUNRPC_REPLY) {
+ ND_PRINT((ndo, ": NFS reply xid %u ", EXTRACT_32BITS(&rp->rm_xid)));
+ nfsreply_print_noaddr(ndo, (u_char *)rp, fraglen, (u_char *)ip);
+ return;
+ }
+ }
}
return;
bad:
- fputs("[bad opt]", stdout);
+ ND_PRINT((ndo, "[bad opt]"));
if (ch != '\0')
- putchar('>');
+ ND_PRINT((ndo, ">"));
return;
trunc:
- fputs("[|tcp]", stdout);
+ ND_PRINT((ndo, "[|tcp]"));
if (ch != '\0')
- putchar('>');
+ ND_PRINT((ndo, ">"));
}
/*
@@ -708,51 +766,51 @@ tcp_print(register const u_char *bp, register u_int length,
*/
static void
-print_tcp_rst_data(register const u_char *sp, u_int length)
+print_tcp_rst_data(netdissect_options *ndo,
+ register const u_char *sp, u_int length)
{
int c;
- if (TTEST2(*sp, length))
- printf(" [RST");
- else
- printf(" [!RST");
+ ND_PRINT((ndo, ND_TTEST2(*sp, length) ? " [RST" : " [!RST"));
if (length > MAX_RST_DATA_LEN) {
length = MAX_RST_DATA_LEN; /* can use -X for longer */
- putchar('+'); /* indicate we truncate */
+ ND_PRINT((ndo, "+")); /* indicate we truncate */
}
- putchar(' ');
- while (length-- && sp <= snapend) {
+ ND_PRINT((ndo, " "));
+ while (length-- && sp <= ndo->ndo_snapend) {
c = *sp++;
- safeputchar(c);
+ safeputchar(ndo, c);
}
- putchar(']');
+ ND_PRINT((ndo, "]"));
}
#ifdef HAVE_LIBCRYPTO
+USES_APPLE_DEPRECATED_API
static int
-tcp_verify_signature(const struct ip *ip, const struct tcphdr *tp,
+tcp_verify_signature(netdissect_options *ndo,
+ const struct ip *ip, const struct tcphdr *tp,
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;
+ uint16_t savecsum, tlen;
#ifdef INET6
struct ip6_hdr *ip6;
- u_int32_t len32;
- u_int8_t nxt;
+ uint32_t len32;
+ uint8_t nxt;
#endif
- if (data + length > snapend) {
- printf("snaplen too short, ");
+ if (data + length > ndo->ndo_snapend) {
+ ND_PRINT((ndo, "snaplen too short, "));
return (CANT_CHECK_SIGNATURE);
}
tp1 = *tp;
- if (sigsecret == NULL) {
- printf("shared secret not supplied with -M, ");
+ if (ndo->ndo_sigsecret == NULL) {
+ ND_PRINT((ndo, "shared secret not supplied with -M, "));
return (CANT_CHECK_SIGNATURE);
}
@@ -784,9 +842,9 @@ tcp_verify_signature(const struct ip *ip, const struct tcphdr *tp,
#endif
} else {
#ifdef INET6
- printf("IP version not 4 or 6, ");
+ ND_PRINT((ndo, "IP version not 4 or 6, "));
#else
- printf("IP version not 4, ");
+ ND_PRINT((ndo, "IP version not 4, "));
#endif
return (CANT_CHECK_SIGNATURE);
}
@@ -807,7 +865,7 @@ tcp_verify_signature(const struct ip *ip, const struct tcphdr *tp,
/*
* Step 4: Update MD5 hash with shared secret.
*/
- MD5_Update(&ctx, sigsecret, strlen(sigsecret));
+ MD5_Update(&ctx, ndo->ndo_sigsecret, strlen(ndo->ndo_sigsecret));
MD5_Final(sig, &ctx);
if (memcmp(rcvsig, sig, TCP_SIGLEN) == 0)
@@ -815,6 +873,7 @@ tcp_verify_signature(const struct ip *ip, const struct tcphdr *tp,
else
return (SIGNATURE_INVALID);
}
+USES_APPLE_RST
#endif /* HAVE_LIBCRYPTO */
/*
diff --git a/contrib/tcpdump/print-telnet.c b/contrib/tcpdump/print-telnet.c
index 4911e5caf238..6a2680b413c8 100644
--- a/contrib/tcpdump/print-telnet.c
+++ b/contrib/tcpdump/print-telnet.c
@@ -45,27 +45,304 @@
* are preserved in all copies.
*/
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#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 $";
-#endif
-
#include <tcpdump-stdinc.h>
#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include "interface.h"
-#include "addrtoname.h"
#define TELCMDS
#define TELOPTS
-#include "telnet.h"
+
+/* NetBSD: telnet.h,v 1.9 2001/06/11 01:50:50 wiz Exp */
+
+/*
+ * Definitions for the TELNET protocol.
+ */
+#define IAC 255 /* interpret as command: */
+#define DONT 254 /* you are not to use option */
+#define DO 253 /* please, you use option */
+#define WONT 252 /* I won't use option */
+#define WILL 251 /* I will use option */
+#define SB 250 /* interpret as subnegotiation */
+#define GA 249 /* you may reverse the line */
+#define EL 248 /* erase the current line */
+#define EC 247 /* erase the current character */
+#define AYT 246 /* are you there */
+#define AO 245 /* abort output--but let prog finish */
+#define IP 244 /* interrupt process--permanently */
+#define BREAK 243 /* break */
+#define DM 242 /* data mark--for connect. cleaning */
+#define NOP 241 /* nop */
+#define SE 240 /* end sub negotiation */
+#define EOR 239 /* end of record (transparent mode) */
+#define ABORT 238 /* Abort process */
+#define SUSP 237 /* Suspend process */
+#define xEOF 236 /* End of file: EOF is already used... */
+
+#define SYNCH 242 /* for telfunc calls */
+
+#ifdef TELCMDS
+const char *telcmds[] = {
+ "EOF", "SUSP", "ABORT", "EOR",
+ "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC",
+ "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0,
+};
+#else
+extern char *telcmds[];
+#endif
+
+#define TELCMD_FIRST xEOF
+#define TELCMD_LAST IAC
+#define TELCMD_OK(x) ((unsigned int)(x) <= TELCMD_LAST && \
+ (unsigned int)(x) >= TELCMD_FIRST)
+#define TELCMD(x) telcmds[(x)-TELCMD_FIRST]
+
+/* telnet options */
+#define TELOPT_BINARY 0 /* 8-bit data path */
+#define TELOPT_ECHO 1 /* echo */
+#define TELOPT_RCP 2 /* prepare to reconnect */
+#define TELOPT_SGA 3 /* suppress go ahead */
+#define TELOPT_NAMS 4 /* approximate message size */
+#define TELOPT_STATUS 5 /* give status */
+#define TELOPT_TM 6 /* timing mark */
+#define TELOPT_RCTE 7 /* remote controlled transmission and echo */
+#define TELOPT_NAOL 8 /* negotiate about output line width */
+#define TELOPT_NAOP 9 /* negotiate about output page size */
+#define TELOPT_NAOCRD 10 /* negotiate about CR disposition */
+#define TELOPT_NAOHTS 11 /* negotiate about horizontal tabstops */
+#define TELOPT_NAOHTD 12 /* negotiate about horizontal tab disposition */
+#define TELOPT_NAOFFD 13 /* negotiate about formfeed disposition */
+#define TELOPT_NAOVTS 14 /* negotiate about vertical tab stops */
+#define TELOPT_NAOVTD 15 /* negotiate about vertical tab disposition */
+#define TELOPT_NAOLFD 16 /* negotiate about output LF disposition */
+#define TELOPT_XASCII 17 /* extended ascic character set */
+#define TELOPT_LOGOUT 18 /* force logout */
+#define TELOPT_BM 19 /* byte macro */
+#define TELOPT_DET 20 /* data entry terminal */
+#define TELOPT_SUPDUP 21 /* supdup protocol */
+#define TELOPT_SUPDUPOUTPUT 22 /* supdup output */
+#define TELOPT_SNDLOC 23 /* send location */
+#define TELOPT_TTYPE 24 /* terminal type */
+#define TELOPT_EOR 25 /* end or record */
+#define TELOPT_TUID 26 /* TACACS user identification */
+#define TELOPT_OUTMRK 27 /* output marking */
+#define TELOPT_TTYLOC 28 /* terminal location number */
+#define TELOPT_3270REGIME 29 /* 3270 regime */
+#define TELOPT_X3PAD 30 /* X.3 PAD */
+#define TELOPT_NAWS 31 /* window size */
+#define TELOPT_TSPEED 32 /* terminal speed */
+#define TELOPT_LFLOW 33 /* remote flow control */
+#define TELOPT_LINEMODE 34 /* Linemode option */
+#define TELOPT_XDISPLOC 35 /* X Display Location */
+#define TELOPT_OLD_ENVIRON 36 /* Old - Environment variables */
+#define TELOPT_AUTHENTICATION 37/* Authenticate */
+#define TELOPT_ENCRYPT 38 /* Encryption option */
+#define TELOPT_NEW_ENVIRON 39 /* New - Environment variables */
+#define TELOPT_EXOPL 255 /* extended-options-list */
+
+
+#define NTELOPTS (1+TELOPT_NEW_ENVIRON)
+#ifdef TELOPTS
+const char *telopts[NTELOPTS+1] = {
+ "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME",
+ "STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP",
+ "NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS",
+ "NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO",
+ "DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT",
+ "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD",
+ "TACACS UID", "OUTPUT MARKING", "TTYLOC",
+ "3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW",
+ "LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION",
+ "ENCRYPT", "NEW-ENVIRON",
+ 0,
+};
+#define TELOPT_FIRST TELOPT_BINARY
+#define TELOPT_LAST TELOPT_NEW_ENVIRON
+#define TELOPT_OK(x) ((unsigned int)(x) <= TELOPT_LAST)
+#define TELOPT(x) telopts[(x)-TELOPT_FIRST]
+#endif
+
+/* sub-option qualifiers */
+#define TELQUAL_IS 0 /* option is... */
+#define TELQUAL_SEND 1 /* send option */
+#define TELQUAL_INFO 2 /* ENVIRON: informational version of IS */
+#define TELQUAL_REPLY 2 /* AUTHENTICATION: client version of IS */
+#define TELQUAL_NAME 3 /* AUTHENTICATION: client version of IS */
+
+#define LFLOW_OFF 0 /* Disable remote flow control */
+#define LFLOW_ON 1 /* Enable remote flow control */
+#define LFLOW_RESTART_ANY 2 /* Restart output on any char */
+#define LFLOW_RESTART_XON 3 /* Restart output only on XON */
+
+/*
+ * LINEMODE suboptions
+ */
+
+#define LM_MODE 1
+#define LM_FORWARDMASK 2
+#define LM_SLC 3
+
+#define MODE_EDIT 0x01
+#define MODE_TRAPSIG 0x02
+#define MODE_ACK 0x04
+#define MODE_SOFT_TAB 0x08
+#define MODE_LIT_ECHO 0x10
+
+#define MODE_MASK 0x1f
+
+#define SLC_SYNCH 1
+#define SLC_BRK 2
+#define SLC_IP 3
+#define SLC_AO 4
+#define SLC_AYT 5
+#define SLC_EOR 6
+#define SLC_ABORT 7
+#define SLC_EOF 8
+#define SLC_SUSP 9
+#define SLC_EC 10
+#define SLC_EL 11
+#define SLC_EW 12
+#define SLC_RP 13
+#define SLC_LNEXT 14
+#define SLC_XON 15
+#define SLC_XOFF 16
+#define SLC_FORW1 17
+#define SLC_FORW2 18
+#define SLC_MCL 19
+#define SLC_MCR 20
+#define SLC_MCWL 21
+#define SLC_MCWR 22
+#define SLC_MCBOL 23
+#define SLC_MCEOL 24
+#define SLC_INSRT 25
+#define SLC_OVER 26
+#define SLC_ECR 27
+#define SLC_EWR 28
+#define SLC_EBOL 29
+#define SLC_EEOL 30
+
+#define NSLC 30
+
+/*
+ * For backwards compatibility, we define SLC_NAMES to be the
+ * list of names if SLC_NAMES is not defined.
+ */
+#define SLC_NAMELIST "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \
+ "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \
+ "LNEXT", "XON", "XOFF", "FORW1", "FORW2", \
+ "MCL", "MCR", "MCWL", "MCWR", "MCBOL", \
+ "MCEOL", "INSRT", "OVER", "ECR", "EWR", \
+ "EBOL", "EEOL", \
+ 0,
+
+#ifdef SLC_NAMES
+const char *slc_names[] = {
+ SLC_NAMELIST
+};
+#else
+extern char *slc_names[];
+#define SLC_NAMES SLC_NAMELIST
+#endif
+
+#define SLC_NAME_OK(x) ((unsigned int)(x) <= NSLC)
+#define SLC_NAME(x) slc_names[x]
+
+#define SLC_NOSUPPORT 0
+#define SLC_CANTCHANGE 1
+#define SLC_VARIABLE 2
+#define SLC_DEFAULT 3
+#define SLC_LEVELBITS 0x03
+
+#define SLC_FUNC 0
+#define SLC_FLAGS 1
+#define SLC_VALUE 2
+
+#define SLC_ACK 0x80
+#define SLC_FLUSHIN 0x40
+#define SLC_FLUSHOUT 0x20
+
+#define OLD_ENV_VAR 1
+#define OLD_ENV_VALUE 0
+#define NEW_ENV_VAR 0
+#define NEW_ENV_VALUE 1
+#define ENV_ESC 2
+#define ENV_USERVAR 3
+
+/*
+ * AUTHENTICATION suboptions
+ */
+
+/*
+ * Who is authenticating who ...
+ */
+#define AUTH_WHO_CLIENT 0 /* Client authenticating server */
+#define AUTH_WHO_SERVER 1 /* Server authenticating client */
+#define AUTH_WHO_MASK 1
+
+#define AUTHTYPE_NULL 0
+#define AUTHTYPE_KERBEROS_V4 1
+#define AUTHTYPE_KERBEROS_V5 2
+#define AUTHTYPE_SPX 3
+#define AUTHTYPE_MINK 4
+#define AUTHTYPE_CNT 5
+
+#define AUTHTYPE_TEST 99
+
+#ifdef AUTH_NAMES
+const char *authtype_names[] = {
+ "NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", 0,
+};
+#else
+extern char *authtype_names[];
+#endif
+
+#define AUTHTYPE_NAME_OK(x) ((unsigned int)(x) < AUTHTYPE_CNT)
+#define AUTHTYPE_NAME(x) authtype_names[x]
+
+/*
+ * ENCRYPTion suboptions
+ */
+#define ENCRYPT_IS 0 /* I pick encryption type ... */
+#define ENCRYPT_SUPPORT 1 /* I support encryption types ... */
+#define ENCRYPT_REPLY 2 /* Initial setup response */
+#define ENCRYPT_START 3 /* Am starting to send encrypted */
+#define ENCRYPT_END 4 /* Am ending encrypted */
+#define ENCRYPT_REQSTART 5 /* Request you start encrypting */
+#define ENCRYPT_REQEND 6 /* Request you send encrypting */
+#define ENCRYPT_ENC_KEYID 7
+#define ENCRYPT_DEC_KEYID 8
+#define ENCRYPT_CNT 9
+
+#define ENCTYPE_ANY 0
+#define ENCTYPE_DES_CFB64 1
+#define ENCTYPE_DES_OFB64 2
+#define ENCTYPE_CNT 3
+
+#ifdef ENCRYPT_NAMES
+const char *encrypt_names[] = {
+ "IS", "SUPPORT", "REPLY", "START", "END",
+ "REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID",
+ 0,
+};
+const char *enctype_names[] = {
+ "ANY", "DES_CFB64", "DES_OFB64", 0,
+};
+#else
+extern char *encrypt_names[];
+extern char *enctype_names[];
+#endif
+
+#define ENCRYPT_NAME_OK(x) ((unsigned int)(x) < ENCRYPT_CNT)
+#define ENCRYPT_NAME(x) encrypt_names[x]
+
+#define ENCTYPE_NAME_OK(x) ((unsigned int)(x) < ENCTYPE_CNT)
+#define ENCTYPE_NAME(x) enctype_names[x]
/* normal */
static const char *cmds[] = {
@@ -107,7 +384,7 @@ numstr(int x)
/* sp points to IAC byte */
static int
-telnet_parse(const u_char *sp, u_int length, int print)
+telnet_parse(netdissect_options *ndo, const u_char *sp, u_int length, int print)
{
int i, x;
u_int c;
@@ -116,7 +393,7 @@ telnet_parse(const u_char *sp, u_int length, int print)
do { \
if (length < 1) \
goto pktend; \
- TCHECK(*sp); \
+ ND_TCHECK(*sp); \
c = *sp++; \
length--; \
} while (0)
@@ -129,7 +406,7 @@ telnet_parse(const u_char *sp, u_int length, int print)
FETCH(c, sp, length);
if (c == IAC) { /* <IAC><IAC>! */
if (print)
- printf("IAC IAC");
+ ND_PRINT((ndo, "IAC IAC"));
goto done;
}
@@ -147,10 +424,10 @@ telnet_parse(const u_char *sp, u_int length, int print)
FETCH(x, sp, length);
if (x >= 0 && x < NTELOPTS) {
if (print)
- (void)printf("%s %s", telcmds[i], telopts[x]);
+ ND_PRINT((ndo, "%s %s", telcmds[i], telopts[x]));
} else {
if (print)
- (void)printf("%s %#x", telcmds[i], x);
+ ND_PRINT((ndo, "%s %#x", telcmds[i], x));
}
if (c != SB)
break;
@@ -170,47 +447,46 @@ telnet_parse(const u_char *sp, u_int length, int print)
break;
FETCH(c, sp, length);
if (print)
- (void)printf(" %s", STR_OR_ID(c, authcmd));
+ ND_PRINT((ndo, " %s", STR_OR_ID(c, authcmd)));
if (p <= sp)
break;
FETCH(c, sp, length);
if (print)
- (void)printf(" %s", STR_OR_ID(c, authtype));
+ ND_PRINT((ndo, " %s", STR_OR_ID(c, authtype)));
break;
case TELOPT_ENCRYPT:
if (p <= sp)
break;
FETCH(c, sp, length);
if (print)
- (void)printf(" %s", STR_OR_ID(c, enccmd));
+ ND_PRINT((ndo, " %s", STR_OR_ID(c, enccmd)));
if (p <= sp)
break;
FETCH(c, sp, length);
if (print)
- (void)printf(" %s", STR_OR_ID(c, enctype));
+ ND_PRINT((ndo, " %s", STR_OR_ID(c, enctype)));
break;
default:
if (p <= sp)
break;
FETCH(c, sp, length);
if (print)
- (void)printf(" %s", STR_OR_ID(c, cmds));
+ ND_PRINT((ndo, " %s", STR_OR_ID(c, cmds)));
break;
}
while (p > sp) {
FETCH(x, sp, length);
if (print)
- (void)printf(" %#x", x);
+ ND_PRINT((ndo, " %#x", x));
}
/* terminating IAC SE */
if (print)
- (void)printf(" SE");
+ ND_PRINT((ndo, " SE"));
sp += 2;
- length -= 2;
break;
default:
if (print)
- (void)printf("%s", telcmds[i]);
+ ND_PRINT((ndo, "%s", telcmds[i]));
goto done;
}
@@ -218,14 +494,14 @@ done:
return sp - osp;
trunc:
- (void)printf("[|telnet]");
+ ND_PRINT((ndo, "[|telnet]"));
pktend:
return -1;
#undef FETCH
}
void
-telnet_print(const u_char *sp, u_int length)
+telnet_print(netdissect_options *ndo, const u_char *sp, u_int length)
{
int first = 1;
const u_char *osp;
@@ -234,34 +510,34 @@ telnet_print(const u_char *sp, u_int length)
osp = sp;
while (length > 0 && *sp == IAC) {
- l = telnet_parse(sp, length, 0);
+ l = telnet_parse(ndo, sp, length, 0);
if (l < 0)
break;
/*
* now print it
*/
- if (Xflag && 2 < vflag) {
+ if (ndo->ndo_Xflag && 2 < ndo->ndo_vflag) {
if (first)
- printf("\nTelnet:");
- hex_print_with_offset("\n", sp, l, sp - osp);
+ ND_PRINT((ndo, "\nTelnet:"));
+ hex_print_with_offset(ndo, "\n", sp, l, sp - osp);
if (l > 8)
- printf("\n\t\t\t\t");
+ ND_PRINT((ndo, "\n\t\t\t\t"));
else
- printf("%*s\t", (8 - l) * 3, "");
+ ND_PRINT((ndo, "%*s\t", (8 - l) * 3, ""));
} else
- printf("%s", (first) ? " [telnet " : ", ");
+ ND_PRINT((ndo, "%s", (first) ? " [telnet " : ", "));
- (void)telnet_parse(sp, length, 1);
+ (void)telnet_parse(ndo, sp, length, 1);
first = 0;
sp += l;
length -= l;
}
if (!first) {
- if (Xflag && 2 < vflag)
- printf("\n");
+ if (ndo->ndo_Xflag && 2 < ndo->ndo_vflag)
+ ND_PRINT((ndo, "\n"));
else
- printf("]");
+ ND_PRINT((ndo, "]"));
}
}
diff --git a/contrib/tcpdump/print-tftp.c b/contrib/tcpdump/print-tftp.c
index 84cde3969d08..9b88e74f1022 100644
--- a/contrib/tcpdump/print-tftp.c
+++ b/contrib/tcpdump/print-tftp.c
@@ -21,31 +21,63 @@
* Format and print trivial file transfer protocol packets.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-tftp.c,v 1.39 2008-04-11 16:47:38 gianluca Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#ifdef SEGSIZE
-#undef SEGSIZE /* SINIX sucks */
-#endif
-
-#include <stdio.h>
#include <string.h>
#include "interface.h"
-#include "addrtoname.h"
#include "extract.h"
-#include "tftp.h"
+
+/*
+ * Trivial File Transfer Protocol (IEN-133)
+ */
+
+/*
+ * Packet types.
+ */
+#define RRQ 01 /* read request */
+#define WRQ 02 /* write request */
+#define DATA 03 /* data packet */
+#define ACK 04 /* acknowledgement */
+#define TFTP_ERROR 05 /* error code */
+#define OACK 06 /* option acknowledgement */
+
+struct tftphdr {
+ unsigned short th_opcode; /* packet type */
+ union {
+ unsigned short tu_block; /* block # */
+ unsigned short tu_code; /* error code */
+ char tu_stuff[1]; /* request packet stuff */
+ } th_u;
+ char th_data[1]; /* data or error string */
+};
+
+#define th_block th_u.tu_block
+#define th_code th_u.tu_code
+#define th_stuff th_u.tu_stuff
+#define th_msg th_data
+
+/*
+ * Error codes.
+ */
+#define EUNDEF 0 /* not defined */
+#define ENOTFOUND 1 /* file not found */
+#define EACCESS 2 /* access violation */
+#define ENOSPACE 3 /* disk full or allocation exceeded */
+#define EBADOP 4 /* illegal TFTP operation */
+#define EBADID 5 /* unknown transfer ID */
+#define EEXISTS 6 /* file already exists */
+#define ENOUSER 7 /* no such user */
+
+static const char tstr[] = " [|tftp]";
/* op code to string mapping */
-static struct tok op2str[] = {
+static const struct tok op2str[] = {
{ RRQ, "RRQ" }, /* read request */
{ WRQ, "WRQ" }, /* write request */
{ DATA, "DATA" }, /* data packet */
@@ -56,7 +88,7 @@ static struct tok op2str[] = {
};
/* error code to string mapping */
-static struct tok err2str[] = {
+static const struct tok err2str[] = {
{ EUNDEF, "EUNDEF" }, /* not defined */
{ ENOTFOUND, "ENOTFOUND" }, /* file not found */
{ EACCESS, "EACCESS" }, /* access violation */
@@ -72,24 +104,24 @@ static struct tok err2str[] = {
* Print trivial file transfer program requests
*/
void
-tftp_print(register const u_char *bp, u_int length)
+tftp_print(netdissect_options *ndo,
+ register const u_char *bp, u_int length)
{
register const struct tftphdr *tp;
register const char *cp;
register const u_char *p;
register int opcode, i;
- static char tstr[] = " [|tftp]";
tp = (const struct tftphdr *)bp;
/* Print length */
- printf(" %d", length);
+ ND_PRINT((ndo, " %d", length));
/* Print tftp request type */
- TCHECK(tp->th_opcode);
+ ND_TCHECK(tp->th_opcode);
opcode = EXTRACT_16BITS(&tp->th_opcode);
cp = tok2str(op2str, "tftp-#%d", opcode);
- printf(" %s", cp);
+ ND_PRINT((ndo, " %s", cp));
/* Bail if bogus opcode */
if (*cp == 't')
return;
@@ -100,13 +132,13 @@ tftp_print(register const u_char *bp, u_int length)
case WRQ:
case OACK:
p = (u_char *)tp->th_stuff;
- putchar(' ');
+ ND_PRINT((ndo, " "));
/* Print filename or first option */
if (opcode != OACK)
- putchar('"');
- i = fn_print(p, snapend);
+ ND_PRINT((ndo, "\""));
+ i = fn_print(ndo, p, ndo->ndo_snapend);
if (opcode != OACK)
- putchar('"');
+ ND_PRINT((ndo, "\""));
/* Print the mode (RRQ and WRQ only) and any options */
while ((p = (const u_char *)strchr((const char *)p, '\0')) != NULL) {
@@ -114,40 +146,40 @@ tftp_print(register const u_char *bp, u_int length)
break;
p++;
if (*p != '\0') {
- putchar(' ');
- fn_print(p, snapend);
+ ND_PRINT((ndo, " "));
+ fn_print(ndo, p, ndo->ndo_snapend);
}
}
-
+
if (i)
goto trunc;
break;
case ACK:
case DATA:
- TCHECK(tp->th_block);
- printf(" block %d", EXTRACT_16BITS(&tp->th_block));
+ ND_TCHECK(tp->th_block);
+ ND_PRINT((ndo, " block %d", EXTRACT_16BITS(&tp->th_block)));
break;
case TFTP_ERROR:
/* Print error code string */
- TCHECK(tp->th_code);
- printf(" %s \"", tok2str(err2str, "tftp-err-#%d \"",
- EXTRACT_16BITS(&tp->th_code)));
+ ND_TCHECK(tp->th_code);
+ ND_PRINT((ndo, " %s \"", tok2str(err2str, "tftp-err-#%d \"",
+ EXTRACT_16BITS(&tp->th_code))));
/* Print error message string */
- i = fn_print((const u_char *)tp->th_data, snapend);
- putchar('"');
+ i = fn_print(ndo, (const u_char *)tp->th_data, ndo->ndo_snapend);
+ ND_PRINT((ndo, "\""));
if (i)
goto trunc;
break;
default:
/* We shouldn't get here */
- printf("(unknown #%d)", opcode);
+ ND_PRINT((ndo, "(unknown #%d)", opcode));
break;
}
return;
trunc:
- fputs(tstr, stdout);
+ ND_PRINT((ndo, "%s", tstr));
return;
}
diff --git a/contrib/tcpdump/print-timed.c b/contrib/tcpdump/print-timed.c
index 55fbb39eaed7..5830bc7be077 100644
--- a/contrib/tcpdump/print-timed.c
+++ b/contrib/tcpdump/print-timed.c
@@ -19,24 +19,72 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#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 $";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "timed.h"
#include "interface.h"
#include "extract.h"
+/*
+ * Time Synchronization Protocol
+ */
+
+struct tsp_timeval {
+ uint32_t tv_sec;
+ uint32_t tv_usec;
+};
+
+struct tsp {
+ uint8_t tsp_type;
+ uint8_t tsp_vers;
+ uint16_t tsp_seq;
+ union {
+ struct tsp_timeval tspu_time;
+ int8_t tspu_hopcnt;
+ } tsp_u;
+ int8_t tsp_name[256];
+};
+
+#define tsp_time tsp_u.tspu_time
+#define tsp_hopcnt tsp_u.tspu_hopcnt
+
+/*
+ * Command types.
+ */
+#define TSP_ANY 0 /* match any types */
+#define TSP_ADJTIME 1 /* send adjtime */
+#define TSP_ACK 2 /* generic acknowledgement */
+#define TSP_MASTERREQ 3 /* ask for master's name */
+#define TSP_MASTERACK 4 /* acknowledge master request */
+#define TSP_SETTIME 5 /* send network time */
+#define TSP_MASTERUP 6 /* inform slaves that master is up */
+#define TSP_SLAVEUP 7 /* slave is up but not polled */
+#define TSP_ELECTION 8 /* advance candidature for master */
+#define TSP_ACCEPT 9 /* support candidature of master */
+#define TSP_REFUSE 10 /* reject candidature of master */
+#define TSP_CONFLICT 11 /* two or more masters present */
+#define TSP_RESOLVE 12 /* masters' conflict resolution */
+#define TSP_QUIT 13 /* reject candidature if master is up */
+#define TSP_DATE 14 /* reset the time (date command) */
+#define TSP_DATEREQ 15 /* remote request to reset the time */
+#define TSP_DATEACK 16 /* acknowledge time setting */
+#define TSP_TRACEON 17 /* turn tracing on */
+#define TSP_TRACEOFF 18 /* turn tracing off */
+#define TSP_MSITE 19 /* find out master's site */
+#define TSP_MSITEREQ 20 /* remote master's site request */
+#define TSP_TEST 21 /* for testing election algo */
+#define TSP_SETDATE 22 /* New from date command */
+#define TSP_SETDATEREQ 23 /* New remote for above */
+#define TSP_LOOP 24 /* loop detection packet */
+
+#define TSPTYPENUMBER 25
+
+static const char tstr[] = "[|timed]";
+
static const char *tsptype[TSPTYPENUMBER] =
{ "ANY", "ADJTIME", "ACK", "MASTERREQ", "MASTERACK", "SETTIME", "MASTERUP",
"SLAVEUP", "ELECTION", "ACCEPT", "REFUSE", "CONFLICT", "RESOLVE", "QUIT",
@@ -44,68 +92,56 @@ static const char *tsptype[TSPTYPENUMBER] =
"TEST", "SETDATE", "SETDATEREQ", "LOOP" };
void
-timed_print(register const u_char *bp)
+timed_print(netdissect_options *ndo,
+ register const u_char *bp)
{
-#define endof(x) ((u_char *)&(x) + sizeof (x))
struct tsp *tsp = (struct tsp *)bp;
long sec, usec;
- const u_char *end;
- if (endof(tsp->tsp_type) > snapend) {
- fputs("[|timed]", stdout);
- return;
- }
+ ND_TCHECK(tsp->tsp_type);
if (tsp->tsp_type < TSPTYPENUMBER)
- printf("TSP_%s", tsptype[tsp->tsp_type]);
+ ND_PRINT((ndo, "TSP_%s", tsptype[tsp->tsp_type]));
else
- printf("(tsp_type %#x)", tsp->tsp_type);
+ ND_PRINT((ndo, "(tsp_type %#x)", tsp->tsp_type));
- if (endof(tsp->tsp_vers) > snapend) {
- fputs(" [|timed]", stdout);
- return;
- }
- printf(" vers %d", tsp->tsp_vers);
+ ND_TCHECK(tsp->tsp_vers);
+ ND_PRINT((ndo, " vers %u", tsp->tsp_vers));
- if (endof(tsp->tsp_seq) > snapend) {
- fputs(" [|timed]", stdout);
- return;
- }
- printf(" seq %d", tsp->tsp_seq);
+ ND_TCHECK(tsp->tsp_seq);
+ ND_PRINT((ndo, " seq %u", tsp->tsp_seq));
- if (tsp->tsp_type == TSP_LOOP) {
- if (endof(tsp->tsp_hopcnt) > snapend) {
- fputs(" [|timed]", stdout);
- return;
- }
- printf(" hopcnt %d", tsp->tsp_hopcnt);
- } else if (tsp->tsp_type == TSP_SETTIME ||
- tsp->tsp_type == TSP_ADJTIME ||
- tsp->tsp_type == TSP_SETDATE ||
- tsp->tsp_type == TSP_SETDATEREQ) {
- if (endof(tsp->tsp_time) > snapend) {
- fputs(" [|timed]", stdout);
- return;
- }
+ switch (tsp->tsp_type) {
+ case TSP_LOOP:
+ ND_TCHECK(tsp->tsp_hopcnt);
+ ND_PRINT((ndo, " hopcnt %u", tsp->tsp_hopcnt));
+ break;
+ case TSP_SETTIME:
+ case TSP_ADJTIME:
+ case TSP_SETDATE:
+ case TSP_SETDATEREQ:
+ ND_TCHECK(tsp->tsp_time);
sec = EXTRACT_32BITS(&tsp->tsp_time.tv_sec);
usec = EXTRACT_32BITS(&tsp->tsp_time.tv_usec);
+ /* XXX The comparison below is always false? */
if (usec < 0)
/* corrupt, skip the rest of the packet */
return;
- fputs(" time ", stdout);
+ ND_PRINT((ndo, " time "));
if (sec < 0 && usec != 0) {
sec++;
if (sec == 0)
- fputc('-', stdout);
+ ND_PRINT((ndo, "-"));
usec = 1000000 - usec;
}
- printf("%ld.%06ld", sec, usec);
+ ND_PRINT((ndo, "%ld.%06ld", sec, usec));
+ break;
}
+ ND_TCHECK(tsp->tsp_name);
+ ND_PRINT((ndo, " name "));
+ if (fn_print(ndo, (u_char *)tsp->tsp_name, (u_char *)tsp->tsp_name + sizeof(tsp->tsp_name)))
+ goto trunc;
+ return;
- end = memchr(tsp->tsp_name, '\0', snapend - (u_char *)tsp->tsp_name);
- if (end == NULL)
- fputs(" [|timed]", stdout);
- else {
- fputs(" name ", stdout);
- fwrite(tsp->tsp_name, end - (u_char *)tsp->tsp_name, 1, stdout);
- }
+trunc:
+ ND_PRINT((ndo, " %s", tstr));
}
diff --git a/contrib/tcpdump/print-tipc.c b/contrib/tcpdump/print-tipc.c
index 8f2f76914522..b883fba9fed6 100644
--- a/contrib/tcpdump/print-tipc.c
+++ b/contrib/tcpdump/print-tipc.c
@@ -19,26 +19,20 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-arp.c,v 1.66 2006-03-03 22:53:21 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "netdissect.h"
-#include "addrtoname.h"
+#include "interface.h"
#include "ether.h"
#include "ethertype.h"
#include "extract.h" /* must come after interface.h */
+static const char tstr[] = "[|TIPC]";
+
/*
* Transparent Inter-Process Communication (TIPC) protocol.
*
@@ -69,8 +63,8 @@ static const char rcsid[] _U_ =
#define TIPC_NODE(addr) (((addr) >> 0) & 0xFFF)
struct tipc_pkthdr {
- u_int32_t w0;
- u_int32_t w1;
+ uint32_t w0;
+ uint32_t w1;
};
#define TIPC_VER(w0) (((w0) >> 29) & 0x07)
@@ -113,30 +107,30 @@ static const struct tok tipc_linkconf_mtype_values[] = {
};
struct payload_tipc_pkthdr {
- u_int32_t w0;
- u_int32_t w1;
- u_int32_t w2;
- u_int32_t prev_node;
- u_int32_t orig_port;
- u_int32_t dest_port;
- u_int32_t orig_node;
- u_int32_t dest_node;
- u_int32_t name_type;
- u_int32_t w9;
- u_int32_t wA;
+ uint32_t w0;
+ uint32_t w1;
+ uint32_t w2;
+ uint32_t prev_node;
+ uint32_t orig_port;
+ uint32_t dest_port;
+ uint32_t orig_node;
+ uint32_t dest_node;
+ uint32_t name_type;
+ uint32_t w9;
+ uint32_t wA;
};
struct internal_tipc_pkthdr {
- u_int32_t w0;
- u_int32_t w1;
- u_int32_t w2;
- u_int32_t prev_node;
- u_int32_t w4;
- u_int32_t w5;
- u_int32_t orig_node;
- u_int32_t dest_node;
- u_int32_t trans_seq;
- u_int32_t w9;
+ uint32_t w0;
+ uint32_t w1;
+ uint32_t w2;
+ uint32_t prev_node;
+ uint32_t w4;
+ uint32_t w5;
+ uint32_t orig_node;
+ uint32_t dest_node;
+ uint32_t trans_seq;
+ uint32_t w9;
};
#define TIPC_SEQ_GAP(w1) (((w1) >> 16) & 0x1FFF)
@@ -149,13 +143,13 @@ struct internal_tipc_pkthdr {
#define TIPC_LINK_TOL(w9) (((w9) >> 0) & 0xFFFF)
struct link_conf_tipc_pkthdr {
- u_int32_t w0;
- u_int32_t w1;
- u_int32_t dest_domain;
- u_int32_t prev_node;
- u_int32_t ntwrk_id;
- u_int32_t w5;
- u_int8_t media_address[16];
+ uint32_t w0;
+ uint32_t w1;
+ uint32_t dest_domain;
+ uint32_t prev_node;
+ uint32_t ntwrk_id;
+ uint32_t w5;
+ uint8_t media_address[16];
};
#define TIPC_NODE_SIG(w1) (((w1) >> 0) & 0xFFFF)
@@ -164,7 +158,7 @@ struct link_conf_tipc_pkthdr {
static void
print_payload(netdissect_options *ndo, const struct payload_tipc_pkthdr *ap)
{
- u_int32_t w0, w1, w2;
+ uint32_t w0, w1, w2;
u_int user;
u_int hsize;
u_int msize;
@@ -223,13 +217,13 @@ print_payload(netdissect_options *ndo, const struct payload_tipc_pkthdr *ap)
return;
trunc:
- ND_PRINT((ndo, "[|TIPC]"));
+ ND_PRINT((ndo, "%s", tstr));
}
-
+
static void
print_internal(netdissect_options *ndo, const struct internal_tipc_pkthdr *ap)
{
- u_int32_t w0, w1, w2, w4, w5, w9;
+ uint32_t w0, w1, w2, w4, w5, w9;
u_int user;
u_int hsize;
u_int msize;
@@ -291,13 +285,13 @@ print_internal(netdissect_options *ndo, const struct internal_tipc_pkthdr *ap)
return;
trunc:
- ND_PRINT((ndo, "[|TIPC]"));
+ ND_PRINT((ndo, "%s", tstr));
}
static void
print_link_conf(netdissect_options *ndo, const struct link_conf_tipc_pkthdr *ap)
{
- u_int32_t w0, w1, w5;
+ uint32_t w0, w1, w5;
u_int user;
u_int hsize;
u_int msize;
@@ -315,7 +309,6 @@ print_link_conf(netdissect_options *ndo, const struct link_conf_tipc_pkthdr *ap)
msize = TIPC_MSIZE(w0);
w1 = EXTRACT_32BITS(&ap->w1);
mtype = TIPC_MTYPE(w1);
- prev_node = EXTRACT_32BITS(&ap->prev_node);
dest_domain = EXTRACT_32BITS(&ap->dest_domain);
prev_node = EXTRACT_32BITS(&ap->prev_node);
@@ -338,7 +331,7 @@ print_link_conf(netdissect_options *ndo, const struct link_conf_tipc_pkthdr *ap)
return;
trunc:
- ND_PRINT((ndo, "[|TIPC]"));
+ ND_PRINT((ndo, "%s", tstr));
}
void
@@ -346,7 +339,7 @@ tipc_print(netdissect_options *ndo, const u_char *bp, u_int length _U_,
u_int caplen _U_)
{
const struct tipc_pkthdr *ap;
- u_int32_t w0;
+ uint32_t w0;
u_int user;
ap = (struct tipc_pkthdr *)bp;
@@ -363,7 +356,7 @@ tipc_print(netdissect_options *ndo, const u_char *bp, u_int length _U_,
case TIPC_USER_NAME_DISTRIBUTOR:
case TIPC_USER_CONN_MANAGER:
print_payload(ndo, (struct payload_tipc_pkthdr *)bp);
- break;
+ break;
case TIPC_USER_LINK_CONFIG:
print_link_conf(ndo, (struct link_conf_tipc_pkthdr *)bp);
@@ -381,7 +374,7 @@ tipc_print(netdissect_options *ndo, const u_char *bp, u_int length _U_,
return;
trunc:
- ND_PRINT((ndo, "[|TIPC]"));
+ ND_PRINT((ndo, "%s", tstr));
}
/*
diff --git a/contrib/tcpdump/print-token.c b/contrib/tcpdump/print-token.c
index 0f99354e4737..af4780c1c85d 100644
--- a/contrib/tcpdump/print-token.c
+++ b/contrib/tcpdump/print-token.c
@@ -25,28 +25,74 @@
*
* $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.27 2005-11-13 12:12:43 guy Exp $";
-#endif
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <pcap.h>
-#include <stdio.h>
#include <string.h>
#include "interface.h"
#include "extract.h"
#include "addrtoname.h"
-#include "ethertype.h"
-
#include "ether.h"
-#include "token.h"
+
+/*
+ * Copyright (c) 1998, Larry Lile
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice unmodified, this list of conditions, and the following
+ * disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#define TOKEN_HDRLEN 14
+#define TOKEN_RING_MAC_LEN 6
+#define ROUTING_SEGMENT_MAX 16
+#define IS_SOURCE_ROUTED(trp) ((trp)->token_shost[0] & 0x80)
+#define FRAME_TYPE(trp) (((trp)->token_fc & 0xC0) >> 6)
+#define TOKEN_FC_LLC 1
+
+#define BROADCAST(trp) ((EXTRACT_16BITS(&(trp)->token_rcf) & 0xE000) >> 13)
+#define RIF_LENGTH(trp) ((EXTRACT_16BITS(&(trp)->token_rcf) & 0x1f00) >> 8)
+#define DIRECTION(trp) ((EXTRACT_16BITS(&(trp)->token_rcf) & 0x0080) >> 7)
+#define LARGEST_FRAME(trp) ((EXTRACT_16BITS(&(trp)->token_rcf) & 0x0070) >> 4)
+#define RING_NUMBER(trp, x) ((EXTRACT_16BITS(&(trp)->token_rseg[x]) & 0xfff0) >> 4)
+#define BRIDGE_NUMBER(trp, x) ((EXTRACT_16BITS(&(trp)->token_rseg[x]) & 0x000f))
+#define SEGMENT_COUNT(trp) ((int)((RIF_LENGTH(trp) - 2) / 2))
+
+struct token_header {
+ uint8_t token_ac;
+ uint8_t token_fc;
+ uint8_t token_dhost[TOKEN_RING_MAC_LEN];
+ uint8_t token_shost[TOKEN_RING_MAC_LEN];
+ uint16_t token_rcf;
+ uint16_t token_rseg[ROUTING_SEGMENT_MAX];
+};
+
+static const char tstr[] = "[|token-ring]";
/* Extract src, dst addresses */
static inline void
@@ -60,22 +106,23 @@ extract_token_addrs(const struct token_header *trp, char *fsrc, char *fdst)
* Print the TR MAC header
*/
static inline void
-token_hdr_print(register const struct token_header *trp, register u_int length,
- register const u_char *fsrc, register const u_char *fdst)
+token_hdr_print(netdissect_options *ndo,
+ register const struct token_header *trp, register u_int length,
+ register const u_char *fsrc, register const u_char *fdst)
{
const char *srcname, *dstname;
- srcname = etheraddr_string(fsrc);
- dstname = etheraddr_string(fdst);
+ srcname = etheraddr_string(ndo, fsrc);
+ dstname = etheraddr_string(ndo, fdst);
- if (vflag)
- (void) printf("%02x %02x %s %s %d: ",
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, "%02x %02x %s %s %d: ",
trp->token_ac,
trp->token_fc,
srcname, dstname,
- length);
+ length));
else
- printf("%s %s %d: ", srcname, dstname, length);
+ ND_PRINT((ndo, "%s %s %d: ", srcname, dstname, length));
}
static const char *broadcast_indicator[] = {
@@ -101,7 +148,7 @@ static const char *largest_frame[] = {
};
u_int
-token_print(const u_char *p, u_int length, u_int caplen)
+token_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
{
const struct token_header *trp;
u_short extracted_ethertype;
@@ -112,7 +159,7 @@ token_print(const u_char *p, u_int length, u_int caplen)
trp = (const struct token_header *)p;
if (caplen < TOKEN_HDRLEN) {
- printf("[|token-ring]");
+ ND_PRINT((ndo, "%s", tstr));
return hdr_len;
}
@@ -126,36 +173,36 @@ token_print(const u_char *p, u_int length, u_int caplen)
/* Clear source-routed bit */
*ESRC(&ehdr) &= 0x7f;
- if (eflag)
- token_hdr_print(trp, length, ESRC(&ehdr), EDST(&ehdr));
+ if (ndo->ndo_eflag)
+ token_hdr_print(ndo, trp, length, ESRC(&ehdr), EDST(&ehdr));
if (caplen < TOKEN_HDRLEN + 2) {
- printf("[|token-ring]");
+ ND_PRINT((ndo, "%s", tstr));
return hdr_len;
}
route_len = RIF_LENGTH(trp);
hdr_len += route_len;
if (caplen < hdr_len) {
- printf("[|token-ring]");
+ ND_PRINT((ndo, "%s", tstr));
return hdr_len;
}
- if (vflag) {
- printf("%s ", broadcast_indicator[BROADCAST(trp)]);
- printf("%s", direction[DIRECTION(trp)]);
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "%s ", broadcast_indicator[BROADCAST(trp)]));
+ ND_PRINT((ndo, "%s", direction[DIRECTION(trp)]));
for (seg = 0; seg < SEGMENT_COUNT(trp); seg++)
- printf(" [%d:%d]", RING_NUMBER(trp, seg),
- BRIDGE_NUMBER(trp, seg));
+ ND_PRINT((ndo, " [%d:%d]", RING_NUMBER(trp, seg),
+ BRIDGE_NUMBER(trp, seg)));
} else {
- printf("rt = %x", EXTRACT_16BITS(&trp->token_rcf));
+ ND_PRINT((ndo, "rt = %x", EXTRACT_16BITS(&trp->token_rcf)));
for (seg = 0; seg < SEGMENT_COUNT(trp); seg++)
- printf(":%x", EXTRACT_16BITS(&trp->token_rseg[seg]));
+ ND_PRINT((ndo, ":%x", EXTRACT_16BITS(&trp->token_rseg[seg])));
}
- printf(" (%s) ", largest_frame[LARGEST_FRAME(trp)]);
+ ND_PRINT((ndo, " (%s) ", largest_frame[LARGEST_FRAME(trp)]));
} else {
- if (eflag)
- token_hdr_print(trp, length, ESRC(&ehdr), EDST(&ehdr));
+ if (ndo->ndo_eflag)
+ token_hdr_print(ndo, trp, length, ESRC(&ehdr), EDST(&ehdr));
}
/* Skip over token ring MAC header and routing information */
@@ -166,28 +213,28 @@ token_print(const u_char *p, u_int length, u_int caplen)
/* Frame Control field determines interpretation of packet */
if (FRAME_TYPE(trp) == TOKEN_FC_LLC) {
/* Try to print the LLC-layer header & higher layers */
- if (llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr),
+ if (llc_print(ndo, p, length, caplen, ESRC(&ehdr), EDST(&ehdr),
&extracted_ethertype) == 0) {
/* ether_type not known, print raw packet */
- if (!eflag)
- token_hdr_print(trp,
+ if (!ndo->ndo_eflag)
+ token_hdr_print(ndo, trp,
length + TOKEN_HDRLEN + route_len,
ESRC(&ehdr), EDST(&ehdr));
if (extracted_ethertype) {
- printf("(LLC %s) ",
- etherproto_string(htons(extracted_ethertype)));
+ ND_PRINT((ndo, "(LLC %s) ",
+ etherproto_string(htons(extracted_ethertype))));
}
- if (!suppress_default_print)
- default_print(p, caplen);
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
}
} else {
/* Some kinds of TR packet we cannot handle intelligently */
/* XXX - dissect MAC packets if frame type is 0 */
- if (!eflag)
- token_hdr_print(trp, length + TOKEN_HDRLEN + route_len,
+ if (!ndo->ndo_eflag)
+ token_hdr_print(ndo, trp, length + TOKEN_HDRLEN + route_len,
ESRC(&ehdr), EDST(&ehdr));
- if (!suppress_default_print)
- default_print(p, caplen);
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
}
return (hdr_len);
}
@@ -199,7 +246,7 @@ token_print(const u_char *p, u_int length, u_int caplen)
* is the number of bytes actually captured.
*/
u_int
-token_if_print(const struct pcap_pkthdr *h, const u_char *p)
+token_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
{
- return (token_print(p, h->len, h->caplen));
+ return (token_print(ndo, p, h->len, h->caplen));
}
diff --git a/contrib/tcpdump/print-udld.c b/contrib/tcpdump/print-udld.c
index a5488dda451f..15e2bf6fae49 100644
--- a/contrib/tcpdump/print-udld.c
+++ b/contrib/tcpdump/print-udld.c
@@ -12,25 +12,21 @@
* LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE.
*
- * UNIDIRECTIONAL LINK DETECTION (UDLD) as per
+ * UNIDIRECTIONAL LINK DETECTION (UDLD) as per
* http://www.ietf.org/internet-drafts/draft-foschiano-udld-02.txt
*
* Original code by Carles Kishimoto <carles.kishimoto@gmail.com>
*/
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <string.h>
-
#include "interface.h"
-#include "addrtoname.h"
-#include "extract.h"
-#include "nlpid.h"
+#include "extract.h"
#define UDLD_HEADER_LEN 4
#define UDLD_DEVICE_ID_TLV 0x0001
@@ -41,7 +37,7 @@
#define UDLD_DEVICE_NAME_TLV 0x0006
#define UDLD_SEQ_NUMBER_TLV 0x0007
-static struct tok udld_tlv_values[] = {
+static const struct tok udld_tlv_values[] = {
{ UDLD_DEVICE_ID_TLV, "Device-ID TLV"},
{ UDLD_PORT_ID_TLV, "Port-ID TLV"},
{ UDLD_ECHO_TLV, "Echo TLV"},
@@ -52,7 +48,7 @@ static struct tok udld_tlv_values[] = {
{ 0, NULL}
};
-static struct tok udld_code_values[] = {
+static const struct tok udld_code_values[] = {
{ 0x00, "Reserved"},
{ 0x01, "Probe message"},
{ 0x02, "Echo message"},
@@ -60,7 +56,7 @@ static struct tok udld_code_values[] = {
{ 0, NULL}
};
-static struct tok udld_flags_values[] = {
+static const struct tok udld_flags_values[] = {
{ 0x00, "RT"},
{ 0x01, "RSY"},
{ 0, NULL}
@@ -68,22 +64,22 @@ static struct tok udld_flags_values[] = {
/*
*
- * 0 1 2 3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Ver | Opcode | Flags | Checksum |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | List of TLVs (variable length list) |
- * | ... |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * 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)
+#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)
+udld_print (netdissect_options *ndo, const u_char *pptr, u_int length)
{
int code, type, len;
const u_char *tptr;
@@ -91,39 +87,37 @@ udld_print (const u_char *pptr, u_int length)
if (length < UDLD_HEADER_LEN)
goto trunc;
- tptr = pptr;
+ tptr = pptr;
- if (!TTEST2(*tptr, UDLD_HEADER_LEN))
- goto trunc;
+ ND_TCHECK2(*tptr, UDLD_HEADER_LEN);
code = UDLD_EXTRACT_OPCODE(*tptr);
- printf("UDLDv%u, Code %s (%x), Flags [%s] (0x%02x), length %u",
+ ND_PRINT((ndo, "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);
+ length));
/*
* In non-verbose mode, just print version and opcode type
*/
- if (vflag < 1) {
+ if (ndo->ndo_vflag < 1) {
return;
}
- printf("\n\tChecksum 0x%04x (unverified)", EXTRACT_16BITS(tptr+2));
+ ND_PRINT((ndo, "\n\tChecksum 0x%04x (unverified)", EXTRACT_16BITS(tptr+2)));
tptr += UDLD_HEADER_LEN;
while (tptr < (pptr+length)) {
- if (!TTEST2(*tptr, 4))
- goto trunc;
+ ND_TCHECK2(*tptr, 4);
type = EXTRACT_16BITS(tptr);
- len = EXTRACT_16BITS(tptr+2);
+ len = EXTRACT_16BITS(tptr+2);
len -= 4;
tptr += 4;
@@ -132,37 +126,37 @@ udld_print (const u_char *pptr, u_int length)
return;
}
- printf("\n\t%s (0x%04x) TLV, length %u",
+ ND_PRINT((ndo, "\n\t%s (0x%04x) TLV, length %u",
tok2str(udld_tlv_values, "Unknown", type),
- type, len);
+ 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);
+ case UDLD_DEVICE_NAME_TLV:
+ ND_PRINT((ndo, ", %s", tptr));
break;
- case UDLD_MESSAGE_INTERVAL_TLV:
+ case UDLD_MESSAGE_INTERVAL_TLV:
case UDLD_TIMEOUT_INTERVAL_TLV:
- printf(", %us", (*tptr));
+ ND_PRINT((ndo, ", %us", (*tptr)));
break;
case UDLD_SEQ_NUMBER_TLV:
- printf(", %u", EXTRACT_32BITS(tptr));
+ ND_PRINT((ndo, ", %u", EXTRACT_32BITS(tptr)));
break;
default:
break;
- }
+ }
tptr += len;
}
return;
trunc:
- printf("[|udld]");
+ ND_PRINT((ndo, "[|udld]"));
}
/*
diff --git a/contrib/tcpdump/print-udp.c b/contrib/tcpdump/print-udp.c
index bfc3d8c963e3..58be945684c5 100644
--- a/contrib/tcpdump/print-udp.c
+++ b/contrib/tcpdump/print-udp.c
@@ -21,24 +21,13 @@
* $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.142 2007-08-08 17:20:58 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#ifdef SEGSIZE
-#undef SEGSIZE
-#endif
-
-#include <stdio.h>
-#include <string.h>
-
#include "interface.h"
#include "addrtoname.h"
#include "extract.h"
@@ -59,14 +48,14 @@ static const char rcsid[] _U_ =
#include "bootp.h"
struct rtcphdr {
- u_int16_t rh_flags; /* T:2 P:1 CNT:5 PT:8 */
- u_int16_t rh_len; /* length of message (in words) */
- u_int32_t rh_ssrc; /* synchronization src id */
+ uint16_t rh_flags; /* T:2 P:1 CNT:5 PT:8 */
+ uint16_t rh_len; /* length of message (in words) */
+ uint32_t rh_ssrc; /* synchronization src id */
};
typedef struct {
- u_int32_t upper; /* more significant 32 bits */
- u_int32_t lower; /* less significant 32 bits */
+ uint32_t upper; /* more significant 32 bits */
+ uint32_t lower; /* less significant 32 bits */
} ntp64;
/*
@@ -74,9 +63,9 @@ typedef struct {
*/
struct rtcp_sr {
ntp64 sr_ntp; /* 64-bit ntp timestamp */
- u_int32_t sr_ts; /* reference media timestamp */
- u_int32_t sr_np; /* no. packets sent */
- u_int32_t sr_nb; /* no. bytes sent */
+ uint32_t sr_ts; /* reference media timestamp */
+ uint32_t sr_np; /* no. packets sent */
+ uint32_t sr_nb; /* no. bytes sent */
};
/*
@@ -84,12 +73,12 @@ struct rtcp_sr {
* Time stamps are middle 32-bits of ntp timestamp.
*/
struct rtcp_rr {
- u_int32_t rr_srcid; /* sender being reported */
- u_int32_t rr_nl; /* no. packets lost */
- u_int32_t rr_ls; /* extended last seq number received */
- u_int32_t rr_dv; /* jitter (delay variance) */
- u_int32_t rr_lsr; /* orig. ts from last rr from this src */
- u_int32_t rr_dlsr; /* time from recpt of last rr to xmit time */
+ uint32_t rr_srcid; /* sender being reported */
+ uint32_t rr_nl; /* no. packets lost */
+ uint32_t rr_ls; /* extended last seq number received */
+ uint32_t rr_dv; /* jitter (delay variance) */
+ uint32_t rr_lsr; /* orig. ts from last rr from this src */
+ uint32_t rr_dlsr; /* time from recpt of last rr to xmit time */
};
/*XXX*/
@@ -108,39 +97,40 @@ struct rtcp_rr {
#define RTCP_PT_APP 204
static void
-vat_print(const void *hdr, register const struct udphdr *up)
+vat_print(netdissect_options *ndo, const void *hdr, register const struct udphdr *up)
{
/* vat/vt audio */
- u_int ts = *(u_int16_t *)hdr;
+ u_int ts = *(uint16_t *)hdr;
if ((ts & 0xf060) != 0) {
/* probably vt */
- (void)printf("udp/vt %u %d / %d",
- (u_int32_t)(EXTRACT_16BITS(&up->uh_ulen) - sizeof(*up)),
- ts & 0x3ff, ts >> 10);
+ ND_PRINT((ndo, "udp/vt %u %d / %d",
+ (uint32_t)(EXTRACT_16BITS(&up->uh_ulen) - sizeof(*up)),
+ ts & 0x3ff, ts >> 10));
} else {
/* probably vat */
- u_int32_t i0 = EXTRACT_32BITS(&((u_int *)hdr)[0]);
- u_int32_t i1 = EXTRACT_32BITS(&((u_int *)hdr)[1]);
- printf("udp/vat %u c%d %u%s",
- (u_int32_t)(EXTRACT_16BITS(&up->uh_ulen) - sizeof(*up) - 8),
+ uint32_t i0 = EXTRACT_32BITS(&((u_int *)hdr)[0]);
+ uint32_t i1 = EXTRACT_32BITS(&((u_int *)hdr)[1]);
+ ND_PRINT((ndo, "udp/vat %u c%d %u%s",
+ (uint32_t)(EXTRACT_16BITS(&up->uh_ulen) - sizeof(*up) - 8),
i0 & 0xffff,
- i1, i0 & 0x800000? "*" : "");
+ i1, i0 & 0x800000? "*" : ""));
/* audio format */
if (i0 & 0x1f0000)
- printf(" f%d", (i0 >> 16) & 0x1f);
+ ND_PRINT((ndo, " f%d", (i0 >> 16) & 0x1f));
if (i0 & 0x3f000000)
- printf(" s%d", (i0 >> 24) & 0x3f);
+ ND_PRINT((ndo, " s%d", (i0 >> 24) & 0x3f));
}
}
static void
-rtp_print(const void *hdr, u_int len, register const struct udphdr *up)
+rtp_print(netdissect_options *ndo, const void *hdr, u_int len,
+ register const struct udphdr *up)
{
/* rtp v1 or v2 */
u_int *ip = (u_int *)hdr;
u_int hasopt, hasext, contype, hasmarker;
- u_int32_t i0 = EXTRACT_32BITS(&((u_int *)hdr)[0]);
- u_int32_t i1 = EXTRACT_32BITS(&((u_int *)hdr)[1]);
+ uint32_t i0 = EXTRACT_32BITS(&((u_int *)hdr)[0]);
+ uint32_t i1 = EXTRACT_32BITS(&((u_int *)hdr)[1]);
u_int dlen = EXTRACT_16BITS(&up->uh_ulen) - sizeof(*up) - 8;
const char * ptype;
@@ -165,23 +155,23 @@ rtp_print(const void *hdr, u_int len, register const struct udphdr *up)
ip += 1;
len -= 1;
}
- printf("udp/%s %d c%d %s%s %d %u",
+ ND_PRINT((ndo, "udp/%s %d c%d %s%s %d %u",
ptype,
dlen,
contype,
(hasopt || hasext)? "+" : "",
hasmarker? "*" : "",
i0 & 0xffff,
- i1);
- if (vflag) {
- printf(" %u", EXTRACT_32BITS(&((u_int *)hdr)[2]));
+ i1));
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, " %u", EXTRACT_32BITS(&((u_int *)hdr)[2])));
if (hasopt) {
u_int i2, optlen;
do {
i2 = ip[0];
optlen = (i2 >> 16) & 0xff;
if (optlen == 0 || optlen > len) {
- printf(" !opt");
+ ND_PRINT((ndo, " !opt"));
return;
}
ip += optlen;
@@ -193,29 +183,29 @@ rtp_print(const void *hdr, u_int len, register const struct udphdr *up)
i2 = ip[0];
extlen = (i2 & 0xffff) + 1;
if (extlen > len) {
- printf(" !ext");
+ ND_PRINT((ndo, " !ext"));
return;
}
ip += extlen;
}
if (contype == 0x1f) /*XXX H.261 */
- printf(" 0x%04x", ip[0] >> 16);
+ ND_PRINT((ndo, " 0x%04x", ip[0] >> 16));
}
}
static const u_char *
-rtcp_print(const u_char *hdr, const u_char *ep)
+rtcp_print(netdissect_options *ndo, const u_char *hdr, const u_char *ep)
{
/* rtp v2 control (rtcp) */
struct rtcp_rr *rr = 0;
struct rtcp_sr *sr;
struct rtcphdr *rh = (struct rtcphdr *)hdr;
u_int len;
- u_int16_t flags;
+ uint16_t flags;
int cnt;
double ts, dts;
if ((u_char *)(rh + 1) > ep) {
- printf(" [|rtcp]");
+ ND_PRINT((ndo, " [|rtcp]"));
return (ep);
}
len = (EXTRACT_16BITS(&rh->rh_len) + 1) * 4;
@@ -224,85 +214,85 @@ rtcp_print(const u_char *hdr, const u_char *ep)
switch (flags & 0xff) {
case RTCP_PT_SR:
sr = (struct rtcp_sr *)(rh + 1);
- printf(" sr");
+ ND_PRINT((ndo, " sr"));
if (len != cnt * sizeof(*rr) + sizeof(*sr) + sizeof(*rh))
- printf(" [%d]", len);
- if (vflag)
- printf(" %u", EXTRACT_32BITS(&rh->rh_ssrc));
+ ND_PRINT((ndo, " [%d]", len));
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, " %u", EXTRACT_32BITS(&rh->rh_ssrc)));
if ((u_char *)(sr + 1) > ep) {
- printf(" [|rtcp]");
+ ND_PRINT((ndo, " [|rtcp]"));
return (ep);
}
ts = (double)(EXTRACT_32BITS(&sr->sr_ntp.upper)) +
((double)(EXTRACT_32BITS(&sr->sr_ntp.lower)) /
4294967296.0);
- printf(" @%.2f %u %up %ub", ts, EXTRACT_32BITS(&sr->sr_ts),
- EXTRACT_32BITS(&sr->sr_np), EXTRACT_32BITS(&sr->sr_nb));
+ ND_PRINT((ndo, " @%.2f %u %up %ub", ts, EXTRACT_32BITS(&sr->sr_ts),
+ EXTRACT_32BITS(&sr->sr_np), EXTRACT_32BITS(&sr->sr_nb)));
rr = (struct rtcp_rr *)(sr + 1);
break;
case RTCP_PT_RR:
- printf(" rr");
+ ND_PRINT((ndo, " rr"));
if (len != cnt * sizeof(*rr) + sizeof(*rh))
- printf(" [%d]", len);
+ ND_PRINT((ndo, " [%d]", len));
rr = (struct rtcp_rr *)(rh + 1);
- if (vflag)
- printf(" %u", EXTRACT_32BITS(&rh->rh_ssrc));
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, " %u", EXTRACT_32BITS(&rh->rh_ssrc)));
break;
case RTCP_PT_SDES:
- printf(" sdes %d", len);
- if (vflag)
- printf(" %u", EXTRACT_32BITS(&rh->rh_ssrc));
+ ND_PRINT((ndo, " sdes %d", len));
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, " %u", EXTRACT_32BITS(&rh->rh_ssrc)));
cnt = 0;
break;
case RTCP_PT_BYE:
- printf(" bye %d", len);
- if (vflag)
- printf(" %u", EXTRACT_32BITS(&rh->rh_ssrc));
+ ND_PRINT((ndo, " bye %d", len));
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, " %u", EXTRACT_32BITS(&rh->rh_ssrc)));
cnt = 0;
break;
default:
- printf(" type-0x%x %d", flags & 0xff, len);
+ ND_PRINT((ndo, " type-0x%x %d", flags & 0xff, len));
cnt = 0;
break;
}
if (cnt > 1)
- printf(" c%d", cnt);
+ ND_PRINT((ndo, " c%d", cnt));
while (--cnt >= 0) {
if ((u_char *)(rr + 1) > ep) {
- printf(" [|rtcp]");
+ ND_PRINT((ndo, " [|rtcp]"));
return (ep);
}
- if (vflag)
- printf(" %u", EXTRACT_32BITS(&rr->rr_srcid));
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, " %u", EXTRACT_32BITS(&rr->rr_srcid)));
ts = (double)(EXTRACT_32BITS(&rr->rr_lsr)) / 65536.;
dts = (double)(EXTRACT_32BITS(&rr->rr_dlsr)) / 65536.;
- printf(" %ul %us %uj @%.2f+%.2f",
+ ND_PRINT((ndo, " %ul %us %uj @%.2f+%.2f",
EXTRACT_32BITS(&rr->rr_nl) & 0x00ffffff,
EXTRACT_32BITS(&rr->rr_ls),
- EXTRACT_32BITS(&rr->rr_dv), ts, dts);
+ EXTRACT_32BITS(&rr->rr_dv), ts, dts));
}
return (hdr + len);
}
-static int udp_cksum(register const struct ip *ip,
+static int udp_cksum(netdissect_options *ndo, register const struct ip *ip,
register const struct udphdr *up,
register u_int len)
{
- return (nextproto4_cksum(ip, (const u_int8_t *)(void *)up, len,
- IPPROTO_UDP));
+ return nextproto4_cksum(ndo, ip, (const uint8_t *)(void *)up, len, len,
+ IPPROTO_UDP);
}
#ifdef INET6
static int udp6_cksum(const struct ip6_hdr *ip6, const struct udphdr *up,
u_int len)
{
- return (nextproto6_cksum(ip6, (const u_int8_t *)(void *)up, len,
- IPPROTO_UDP));
+ return nextproto6_cksum(ip6, (const uint8_t *)(void *)up, len, len,
+ IPPROTO_UDP);
}
#endif
static void
-udpipaddr_print(const struct ip *ip, int sport, int dport)
+udpipaddr_print(netdissect_options *ndo, const struct ip *ip, int sport, int dport)
{
#ifdef INET6
const struct ip6_hdr *ip6;
@@ -315,21 +305,21 @@ udpipaddr_print(const struct ip *ip, int sport, int dport)
if (ip6) {
if (ip6->ip6_nxt == IPPROTO_UDP) {
if (sport == -1) {
- (void)printf("%s > %s: ",
- ip6addr_string(&ip6->ip6_src),
- ip6addr_string(&ip6->ip6_dst));
+ ND_PRINT((ndo, "%s > %s: ",
+ ip6addr_string(ndo, &ip6->ip6_src),
+ ip6addr_string(ndo, &ip6->ip6_dst)));
} else {
- (void)printf("%s.%s > %s.%s: ",
- ip6addr_string(&ip6->ip6_src),
+ ND_PRINT((ndo, "%s.%s > %s.%s: ",
+ ip6addr_string(ndo, &ip6->ip6_src),
udpport_string(sport),
- ip6addr_string(&ip6->ip6_dst),
- udpport_string(dport));
+ ip6addr_string(ndo, &ip6->ip6_dst),
+ udpport_string(dport)));
}
} else {
if (sport != -1) {
- (void)printf("%s > %s: ",
+ ND_PRINT((ndo, "%s > %s: ",
udpport_string(sport),
- udpport_string(dport));
+ udpport_string(dport)));
}
}
} else
@@ -337,41 +327,41 @@ udpipaddr_print(const struct ip *ip, int sport, int dport)
{
if (ip->ip_p == IPPROTO_UDP) {
if (sport == -1) {
- (void)printf("%s > %s: ",
- ipaddr_string(&ip->ip_src),
- ipaddr_string(&ip->ip_dst));
+ ND_PRINT((ndo, "%s > %s: ",
+ ipaddr_string(ndo, &ip->ip_src),
+ ipaddr_string(ndo, &ip->ip_dst)));
} else {
- (void)printf("%s.%s > %s.%s: ",
- ipaddr_string(&ip->ip_src),
+ ND_PRINT((ndo, "%s.%s > %s.%s: ",
+ ipaddr_string(ndo, &ip->ip_src),
udpport_string(sport),
- ipaddr_string(&ip->ip_dst),
- udpport_string(dport));
+ ipaddr_string(ndo, &ip->ip_dst),
+ udpport_string(dport)));
}
} else {
if (sport != -1) {
- (void)printf("%s > %s: ",
+ ND_PRINT((ndo, "%s > %s: ",
udpport_string(sport),
- udpport_string(dport));
+ udpport_string(dport)));
}
}
}
}
void
-udp_print(register const u_char *bp, u_int length,
+udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
register const u_char *bp2, int fragmented)
{
register const struct udphdr *up;
register const struct ip *ip;
register const u_char *cp;
register const u_char *ep = bp + length;
- u_int16_t sport, dport, ulen;
+ uint16_t sport, dport, ulen;
#ifdef INET6
register const struct ip6_hdr *ip6;
#endif
- if (ep > snapend)
- ep = snapend;
+ if (ep > ndo->ndo_snapend)
+ ep = ndo->ndo_snapend;
up = (struct udphdr *)bp;
ip = (struct ip *)bp2;
#ifdef INET6
@@ -381,9 +371,9 @@ udp_print(register const u_char *bp, u_int length,
ip6 = NULL;
#endif /*INET6*/
cp = (u_char *)(up + 1);
- if (!TTEST(up->uh_dport)) {
- udpipaddr_print(ip, -1, -1);
- (void)printf("[|udp]");
+ if (!ND_TTEST(up->uh_dport)) {
+ udpipaddr_print(ndo, ip, -1, -1);
+ ND_PRINT((ndo, "[|udp]"));
return;
}
@@ -391,80 +381,80 @@ udp_print(register const u_char *bp, u_int length,
dport = EXTRACT_16BITS(&up->uh_dport);
if (length < sizeof(struct udphdr)) {
- udpipaddr_print(ip, sport, dport);
- (void)printf("truncated-udp %d", length);
+ udpipaddr_print(ndo, ip, sport, dport);
+ ND_PRINT((ndo, "truncated-udp %d", length));
return;
}
length -= sizeof(struct udphdr);
- if (cp > snapend) {
- udpipaddr_print(ip, sport, dport);
- (void)printf("[|udp]");
+ if (cp > ndo->ndo_snapend) {
+ udpipaddr_print(ndo, ip, sport, dport);
+ ND_PRINT((ndo, "[|udp]"));
return;
}
ulen = EXTRACT_16BITS(&up->uh_ulen);
if (ulen < 8) {
- udpipaddr_print(ip, sport, dport);
- (void)printf("truncated-udplength %d", ulen);
+ udpipaddr_print(ndo, ip, sport, dport);
+ ND_PRINT((ndo, "truncated-udplength %d", ulen));
return;
}
- if (packettype) {
+ if (ndo->ndo_packettype) {
register struct sunrpc_msg *rp;
enum sunrpc_msg_type direction;
- switch (packettype) {
+ switch (ndo->ndo_packettype) {
case PT_VAT:
- udpipaddr_print(ip, sport, dport);
- vat_print((void *)(up + 1), up);
+ udpipaddr_print(ndo, ip, sport, dport);
+ vat_print(ndo, (void *)(up + 1), up);
break;
case PT_WB:
- udpipaddr_print(ip, sport, dport);
- wb_print((void *)(up + 1), length);
+ udpipaddr_print(ndo, ip, sport, dport);
+ wb_print(ndo, (void *)(up + 1), length);
break;
case PT_RPC:
rp = (struct sunrpc_msg *)(up + 1);
direction = (enum sunrpc_msg_type)EXTRACT_32BITS(&rp->rm_direction);
if (direction == SUNRPC_CALL)
- sunrpcrequest_print((u_char *)rp, length,
+ sunrpcrequest_print(ndo, (u_char *)rp, length,
(u_char *)ip);
else
- nfsreply_print((u_char *)rp, length,
+ nfsreply_print(ndo, (u_char *)rp, length,
(u_char *)ip); /*XXX*/
break;
case PT_RTP:
- udpipaddr_print(ip, sport, dport);
- rtp_print((void *)(up + 1), length, up);
+ udpipaddr_print(ndo, ip, sport, dport);
+ rtp_print(ndo, (void *)(up + 1), length, up);
break;
case PT_RTCP:
- udpipaddr_print(ip, sport, dport);
+ udpipaddr_print(ndo, ip, sport, dport);
while (cp < ep)
- cp = rtcp_print(cp, ep);
+ cp = rtcp_print(ndo, cp, ep);
break;
case PT_SNMP:
- udpipaddr_print(ip, sport, dport);
- snmp_print((const u_char *)(up + 1), length);
+ udpipaddr_print(ndo, ip, sport, dport);
+ snmp_print(ndo, (const u_char *)(up + 1), length);
break;
case PT_CNFP:
- udpipaddr_print(ip, sport, dport);
- cnfp_print(cp, (const u_char *)ip);
+ udpipaddr_print(ndo, ip, sport, dport);
+ cnfp_print(ndo, cp, (const u_char *)ip);
break;
case PT_TFTP:
- udpipaddr_print(ip, sport, dport);
- tftp_print(cp, length);
+ udpipaddr_print(ndo, ip, sport, dport);
+ tftp_print(ndo, cp, length);
break;
case PT_AODV:
- udpipaddr_print(ip, sport, dport);
- aodv_print((const u_char *)(up + 1), length,
+ udpipaddr_print(ndo, ip, sport, dport);
+ aodv_print(ndo, (const u_char *)(up + 1), length,
#ifdef INET6
ip6 != NULL);
#else
@@ -473,32 +463,45 @@ udp_print(register const u_char *bp, u_int length,
break;
case PT_RADIUS:
- udpipaddr_print(ip, sport, dport);
- radius_print(cp, length);
+ udpipaddr_print(ndo, ip, sport, dport);
+ radius_print(ndo, cp, length);
break;
case PT_VXLAN:
- udpipaddr_print(ip, sport, dport);
- vxlan_print((const u_char *)(up + 1), length);
+ udpipaddr_print(ndo, ip, sport, dport);
+ vxlan_print(ndo, (const u_char *)(up + 1), length);
+ break;
+
+ case PT_PGM:
+ case PT_PGM_ZMTP1:
+ udpipaddr_print(ndo, ip, sport, dport);
+ pgm_print(ndo, cp, length, bp2);
+ break;
+ case PT_LMP:
+ udpipaddr_print(ndo, ip, sport, dport);
+ lmp_print(ndo, cp, length);
break;
}
return;
}
- if (!qflag) {
+ udpipaddr_print(ndo, ip, sport, dport);
+ if (!ndo->ndo_qflag) {
register struct sunrpc_msg *rp;
enum sunrpc_msg_type direction;
rp = (struct sunrpc_msg *)(up + 1);
- if (TTEST(rp->rm_direction)) {
+ if (ND_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, length,
+ ND_PRINT((ndo, "NFS request xid %u ", EXTRACT_32BITS(&rp->rm_xid)));
+ nfsreq_print_noaddr(ndo, (u_char *)rp, length,
(u_char *)ip);
return;
}
if (sport == NFS_PORT && direction == SUNRPC_REPLY) {
- nfsreply_print((u_char *)rp, length,
+ ND_PRINT((ndo, "NFS reply xid %u ", EXTRACT_32BITS(&rp->rm_xid)));
+ nfsreply_print_noaddr(ndo, (u_char *)rp, length,
(u_char *)ip);
return;
}
@@ -509,175 +512,178 @@ udp_print(register const u_char *bp, u_int length,
}
#endif
}
- if (TTEST(((struct LAP *)cp)->type) &&
+ if (ND_TTEST(((struct LAP *)cp)->type) &&
((struct LAP *)cp)->type == lapDDP &&
(atalk_port(sport) || atalk_port(dport))) {
- if (vflag)
- fputs("kip ", stdout);
- llap_print(cp, length);
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, "kip "));
+ llap_print(ndo, cp, length);
return;
}
}
- udpipaddr_print(ip, sport, dport);
- if (vflag && !Kflag && !fragmented) {
+ if (ndo->ndo_vflag && !ndo->ndo_Kflag && !fragmented) {
/* Check the checksum, if possible. */
- u_int16_t sum, udp_sum;
+ uint16_t sum, udp_sum;
/*
* XXX - do this even if vflag == 1?
* TCP does, and we do so for UDP-over-IPv6.
*/
- if (IP_V(ip) == 4 && (vflag > 1)) {
+ if (IP_V(ip) == 4 && (ndo->ndo_vflag > 1)) {
udp_sum = EXTRACT_16BITS(&up->uh_sum);
if (udp_sum == 0) {
- (void)printf("[no cksum] ");
- } else if (TTEST2(cp[0], length)) {
- sum = udp_cksum(ip, up, length + sizeof(struct udphdr));
+ ND_PRINT((ndo, "[no cksum] "));
+ } else if (ND_TTEST2(cp[0], length)) {
+ sum = udp_cksum(ndo, ip, up, length + sizeof(struct udphdr));
if (sum != 0) {
- (void)printf("[bad udp cksum 0x%04x -> 0x%04x!] ",
+ ND_PRINT((ndo, "[bad udp cksum 0x%04x -> 0x%04x!] ",
udp_sum,
- in_cksum_shouldbe(udp_sum, sum));
+ in_cksum_shouldbe(udp_sum, sum)));
} else
- (void)printf("[udp sum ok] ");
+ ND_PRINT((ndo, "[udp sum ok] "));
}
}
#ifdef INET6
else if (IP_V(ip) == 6 && ip6->ip6_plen) {
/* for IPv6, UDP checksum is mandatory */
- if (TTEST2(cp[0], length)) {
+ if (ND_TTEST2(cp[0], length)) {
sum = udp6_cksum(ip6, up, length + sizeof(struct udphdr));
udp_sum = EXTRACT_16BITS(&up->uh_sum);
if (sum != 0) {
- (void)printf("[bad udp cksum 0x%04x -> 0x%04x!] ",
+ ND_PRINT((ndo, "[bad udp cksum 0x%04x -> 0x%04x!] ",
udp_sum,
- in_cksum_shouldbe(udp_sum, sum));
+ in_cksum_shouldbe(udp_sum, sum)));
} else
- (void)printf("[udp sum ok] ");
+ ND_PRINT((ndo, "[udp sum ok] "));
}
}
#endif
}
- if (!qflag) {
+ if (!ndo->ndo_qflag) {
#define ISPORT(p) (dport == (p) || sport == (p))
if (ISPORT(NAMESERVER_PORT))
- ns_print((const u_char *)(up + 1), length, 0);
+ ns_print(ndo, (const u_char *)(up + 1), length, 0);
else if (ISPORT(MULTICASTDNS_PORT))
- ns_print((const u_char *)(up + 1), length, 1);
+ ns_print(ndo, (const u_char *)(up + 1), length, 1);
else if (ISPORT(TIMED_PORT))
- timed_print((const u_char *)(up + 1));
+ timed_print(ndo, (const u_char *)(up + 1));
else if (ISPORT(TFTP_PORT))
- tftp_print((const u_char *)(up + 1), length);
+ tftp_print(ndo, (const u_char *)(up + 1), length);
else if (ISPORT(IPPORT_BOOTPC) || ISPORT(IPPORT_BOOTPS))
- bootp_print((const u_char *)(up + 1), length);
+ bootp_print(ndo, (const u_char *)(up + 1), length);
else if (ISPORT(RIP_PORT))
- rip_print((const u_char *)(up + 1), length);
+ rip_print(ndo, (const u_char *)(up + 1), length);
else if (ISPORT(AODV_PORT))
- aodv_print((const u_char *)(up + 1), length,
+ aodv_print(ndo, (const u_char *)(up + 1), length,
#ifdef INET6
ip6 != NULL);
#else
0);
#endif
else if (ISPORT(ISAKMP_PORT))
- isakmp_print(gndo, (const u_char *)(up + 1), length, bp2);
+ isakmp_print(ndo, (const u_char *)(up + 1), length, bp2);
else if (ISPORT(ISAKMP_PORT_NATT))
- isakmp_rfc3948_print(gndo, (const u_char *)(up + 1), length, bp2);
+ isakmp_rfc3948_print(ndo, (const u_char *)(up + 1), length, bp2);
#if 1 /*???*/
else if (ISPORT(ISAKMP_PORT_USER1) || ISPORT(ISAKMP_PORT_USER2))
- isakmp_print(gndo, (const u_char *)(up + 1), length, bp2);
+ isakmp_print(ndo, (const u_char *)(up + 1), length, bp2);
#endif
else if (ISPORT(SNMP_PORT) || ISPORT(SNMPTRAP_PORT))
- snmp_print((const u_char *)(up + 1), length);
+ snmp_print(ndo, (const u_char *)(up + 1), length);
else if (ISPORT(NTP_PORT))
- ntp_print((const u_char *)(up + 1), length);
+ ntp_print(ndo, (const u_char *)(up + 1), length);
else if (ISPORT(KERBEROS_PORT) || ISPORT(KERBEROS_SEC_PORT))
- krb_print((const void *)(up + 1));
+ krb_print(ndo, (const void *)(up + 1));
else if (ISPORT(L2TP_PORT))
- l2tp_print((const u_char *)(up + 1), length);
+ l2tp_print(ndo, (const u_char *)(up + 1), length);
#ifdef TCPDUMP_DO_SMB
else if (ISPORT(NETBIOS_NS_PORT))
- nbt_udp137_print((const u_char *)(up + 1), length);
+ nbt_udp137_print(ndo, (const u_char *)(up + 1), length);
else if (ISPORT(NETBIOS_DGRAM_PORT))
- nbt_udp138_print((const u_char *)(up + 1), length);
+ nbt_udp138_print(ndo, (const u_char *)(up + 1), length);
#endif
- else if (dport == 3456)
- vat_print((const void *)(up + 1), up);
+ else if (dport == VAT_PORT)
+ vat_print(ndo, (const void *)(up + 1), up);
else if (ISPORT(ZEPHYR_SRV_PORT) || ISPORT(ZEPHYR_CLT_PORT))
- zephyr_print((const void *)(up + 1), length);
+ zephyr_print(ndo, (const void *)(up + 1), length);
/*
* Since there are 10 possible ports to check, I think
* a <> test would be more efficient
*/
else if ((sport >= RX_PORT_LOW && sport <= RX_PORT_HIGH) ||
(dport >= RX_PORT_LOW && dport <= RX_PORT_HIGH))
- rx_print((const void *)(up + 1), length, sport, dport,
+ rx_print(ndo, (const void *)(up + 1), length, sport, dport,
(u_char *) ip);
#ifdef INET6
else if (ISPORT(RIPNG_PORT))
- ripng_print((const u_char *)(up + 1), length);
+ ripng_print(ndo, (const u_char *)(up + 1), length);
else if (ISPORT(DHCP6_SERV_PORT) || ISPORT(DHCP6_CLI_PORT))
- dhcp6_print((const u_char *)(up + 1), length);
+ dhcp6_print(ndo, (const u_char *)(up + 1), length);
+ else if (ISPORT(AHCP_PORT))
+ ahcp_print(ndo, (const u_char *)(up + 1), length);
else if (ISPORT(BABEL_PORT) || ISPORT(BABEL_PORT_OLD))
- babel_print((const u_char *)(up + 1), length);
+ babel_print(ndo, (const u_char *)(up + 1), length);
#endif /*INET6*/
/*
* Kludge in test for whiteboard packets.
*/
- else if (dport == 4567)
- wb_print((const void *)(up + 1), length);
+ else if (dport == WB_PORT)
+ wb_print(ndo, (const void *)(up + 1), length);
else if (ISPORT(CISCO_AUTORP_PORT))
- cisco_autorp_print((const void *)(up + 1), length);
+ cisco_autorp_print(ndo, (const void *)(up + 1), length);
else if (ISPORT(RADIUS_PORT) ||
ISPORT(RADIUS_NEW_PORT) ||
ISPORT(RADIUS_ACCOUNTING_PORT) ||
ISPORT(RADIUS_NEW_ACCOUNTING_PORT) )
- radius_print((const u_char *)(up+1), length);
+ radius_print(ndo, (const u_char *)(up+1), length);
else if (dport == HSRP_PORT)
- hsrp_print((const u_char *)(up + 1), length);
+ hsrp_print(ndo, (const u_char *)(up + 1), length);
else if (ISPORT(LWRES_PORT))
- lwres_print((const u_char *)(up + 1), length);
+ lwres_print(ndo, (const u_char *)(up + 1), length);
else if (ISPORT(LDP_PORT))
- ldp_print((const u_char *)(up + 1), length);
+ ldp_print(ndo, (const u_char *)(up + 1), length);
else if (ISPORT(OLSR_PORT))
- olsr_print((const u_char *)(up + 1), length,
+ olsr_print(ndo, (const u_char *)(up + 1), length,
#if INET6
(IP_V(ip) == 6) ? 1 : 0);
#else
0);
#endif
else if (ISPORT(MPLS_LSP_PING_PORT))
- lspping_print((const u_char *)(up + 1), length);
+ lspping_print(ndo, (const u_char *)(up + 1), length);
else if (dport == BFD_CONTROL_PORT ||
dport == BFD_ECHO_PORT )
- bfd_print((const u_char *)(up+1), length, dport);
+ bfd_print(ndo, (const u_char *)(up+1), length, dport);
else if (ISPORT(LMP_PORT))
- lmp_print((const u_char *)(up + 1), length);
+ lmp_print(ndo, (const u_char *)(up + 1), length);
else if (ISPORT(VQP_PORT))
- vqp_print((const u_char *)(up + 1), length);
+ vqp_print(ndo, (const u_char *)(up + 1), length);
else if (ISPORT(SFLOW_PORT))
- sflow_print((const u_char *)(up + 1), length);
+ sflow_print(ndo, (const u_char *)(up + 1), length);
else if (dport == LWAPP_CONTROL_PORT)
- lwapp_control_print((const u_char *)(up + 1), length, 1);
+ lwapp_control_print(ndo, (const u_char *)(up + 1), length, 1);
else if (sport == LWAPP_CONTROL_PORT)
- lwapp_control_print((const u_char *)(up + 1), length, 0);
+ lwapp_control_print(ndo, (const u_char *)(up + 1), length, 0);
else if (ISPORT(LWAPP_DATA_PORT))
- lwapp_data_print((const u_char *)(up + 1), length);
+ lwapp_data_print(ndo, (const u_char *)(up + 1), length);
else if (ISPORT(SIP_PORT))
- sip_print((const u_char *)(up + 1), length);
+ sip_print(ndo, (const u_char *)(up + 1), length);
else if (ISPORT(SYSLOG_PORT))
- syslog_print((const u_char *)(up + 1), length);
+ syslog_print(ndo, (const u_char *)(up + 1), length);
else if (ISPORT(OTV_PORT))
- otv_print((const u_char *)(up + 1), length);
+ otv_print(ndo, (const u_char *)(up + 1), length);
+ else if (ISPORT(VXLAN_PORT))
+ vxlan_print(ndo, (const u_char *)(up + 1), length);
else
- (void)printf("UDP, length %u",
- (u_int32_t)(ulen - sizeof(*up)));
+ ND_PRINT((ndo, "UDP, length %u",
+ (uint32_t)(ulen - sizeof(*up))));
#undef ISPORT
} else
- (void)printf("UDP, length %u", (u_int32_t)(ulen - sizeof(*up)));
+ ND_PRINT((ndo, "UDP, length %u", (uint32_t)(ulen - sizeof(*up))));
}
diff --git a/contrib/tcpdump/print-usb.c b/contrib/tcpdump/print-usb.c
index 8e15e7bf39d1..75f78fc9025a 100644
--- a/contrib/tcpdump/print-usb.c
+++ b/contrib/tcpdump/print-usb.c
@@ -19,22 +19,21 @@
*
*/
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <pcap.h>
-#include <stdio.h>
-#include <string.h>
-
#include "interface.h"
#if defined(HAVE_PCAP_USB_H) && defined(DLT_USB_LINUX)
#include <pcap/usb.h>
+static const char tstr[] = "[|usb]";
+
/* returns direction: 1=inbound 2=outbound -1=invalid */
static int
get_direction(int transfer_type, int event_type)
@@ -81,49 +80,49 @@ get_direction(int transfer_type, int event_type)
}
static void
-usb_header_print(const pcap_usb_header *uh)
+usb_header_print(netdissect_options *ndo, const pcap_usb_header *uh)
{
int direction;
switch(uh->transfer_type)
{
case URB_ISOCHRONOUS:
- printf("ISOCHRONOUS");
+ ND_PRINT((ndo, "ISOCHRONOUS"));
break;
case URB_INTERRUPT:
- printf("INTERRUPT");
+ ND_PRINT((ndo, "INTERRUPT"));
break;
case URB_CONTROL:
- printf("CONTROL");
+ ND_PRINT((ndo, "CONTROL"));
break;
case URB_BULK:
- printf("BULK");
+ ND_PRINT((ndo, "BULK"));
break;
default:
- printf(" ?");
+ ND_PRINT((ndo, " ?"));
}
switch(uh->event_type)
{
case URB_SUBMIT:
- printf(" SUBMIT");
+ ND_PRINT((ndo, " SUBMIT"));
break;
case URB_COMPLETE:
- printf(" COMPLETE");
+ ND_PRINT((ndo, " COMPLETE"));
break;
case URB_ERROR:
- printf(" ERROR");
+ ND_PRINT((ndo, " ERROR"));
break;
default:
- printf(" ?");
+ ND_PRINT((ndo, " ?"));
}
direction = get_direction(uh->transfer_type, uh->event_type);
if(direction == 1)
- printf(" from");
+ ND_PRINT((ndo, " from"));
else if(direction == 2)
- printf(" to");
- printf(" %d:%d:%d", uh->bus_id, uh->device_address, uh->endpoint_number & 0x7f);
+ ND_PRINT((ndo, " to"));
+ ND_PRINT((ndo, " %d:%d:%d", uh->bus_id, uh->device_address, uh->endpoint_number & 0x7f));
}
/*
@@ -135,14 +134,15 @@ usb_header_print(const pcap_usb_header *uh)
* is the number of bytes actually captured.
*/
u_int
-usb_linux_48_byte_print(const struct pcap_pkthdr *h, register const u_char *p)
+usb_linux_48_byte_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
+ register const u_char *p)
{
if (h->caplen < sizeof(pcap_usb_header)) {
- printf("[|usb]");
+ ND_PRINT((ndo, "%s", tstr));
return(sizeof(pcap_usb_header));
}
- usb_header_print((const pcap_usb_header *) p);
+ usb_header_print(ndo, (const pcap_usb_header *) p);
return(sizeof(pcap_usb_header));
}
@@ -157,14 +157,15 @@ usb_linux_48_byte_print(const struct pcap_pkthdr *h, register const u_char *p)
* is the number of bytes actually captured.
*/
u_int
-usb_linux_64_byte_print(const struct pcap_pkthdr *h, register const u_char *p)
+usb_linux_64_byte_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
+ register const u_char *p)
{
if (h->caplen < sizeof(pcap_usb_header_mmapped)) {
- printf("[|usb]");
+ ND_PRINT((ndo, "%s", tstr));
return(sizeof(pcap_usb_header_mmapped));
}
- usb_header_print((const pcap_usb_header *) p);
+ usb_header_print(ndo, (const pcap_usb_header *) p);
return(sizeof(pcap_usb_header_mmapped));
}
diff --git a/contrib/tcpdump/print-vjc.c b/contrib/tcpdump/print-vjc.c
index 2dc89aa5f989..24f8a122c09b 100644
--- a/contrib/tcpdump/print-vjc.c
+++ b/contrib/tcpdump/print-vjc.c
@@ -19,23 +19,14 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#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)";
-#endif
-
#include <tcpdump-stdinc.h>
-#include <pcap.h>
-#include <stdio.h>
-
#include "interface.h"
-#include "addrtoname.h"
-
#include "slcompress.h"
#include "ppp.h"
@@ -82,38 +73,38 @@ static const char rcsid[] _U_ =
* unused argument remind us that we should fix this some day.
*/
int
-vjc_print(register const char *bp, u_short proto _U_)
+vjc_print(netdissect_options *ndo, register const char *bp, u_short proto _U_)
{
int i;
switch (bp[0] & 0xf0) {
case TYPE_IP:
- if (eflag)
- printf("(vjc type=IP) ");
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "(vjc type=IP) "));
return PPP_IP;
case TYPE_UNCOMPRESSED_TCP:
- if (eflag)
- printf("(vjc type=raw TCP) ");
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "(vjc type=raw TCP) "));
return PPP_IP;
case TYPE_COMPRESSED_TCP:
- if (eflag)
- printf("(vjc type=compressed TCP) ");
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "(vjc type=compressed TCP) "));
for (i = 0; i < 8; i++) {
if (bp[1] & (0x80 >> i))
- printf("%c", "?CI?SAWU"[i]);
+ ND_PRINT((ndo, "%c", "?CI?SAWU"[i]));
}
if (bp[1])
- printf(" ");
- printf("C=0x%02x ", bp[2]);
- printf("sum=0x%04x ", *(u_short *)&bp[3]);
+ ND_PRINT((ndo, " "));
+ ND_PRINT((ndo, "C=0x%02x ", bp[2]));
+ ND_PRINT((ndo, "sum=0x%04x ", *(u_short *)&bp[3]));
return -1;
case TYPE_ERROR:
- if (eflag)
- printf("(vjc type=error) ");
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "(vjc type=error) "));
return -1;
default:
- if (eflag)
- printf("(vjc type=0x%02x) ", bp[0] & 0xf0);
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "(vjc type=0x%02x) ", bp[0] & 0xf0));
return -1;
}
}
diff --git a/contrib/tcpdump/print-vqp.c b/contrib/tcpdump/print-vqp.c
index 2d9e8e1f969b..ce3572ac5208 100644
--- a/contrib/tcpdump/print-vqp.c
+++ b/contrib/tcpdump/print-vqp.c
@@ -12,26 +12,18 @@
* LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE.
*
- * support for the Cisco prop. VQP Protocol
+ * support for the Cisco prop. VQP Protocol
*
* Original code by Carles Kishimoto <Carles.Kishimoto@bsc.es>
*/
-#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
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
#include "interface.h"
#include "extract.h"
#include "addrtoname.h"
@@ -52,16 +44,16 @@ static const char rcsid[] _U_ =
*/
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];
+ uint8_t version;
+ uint8_t msg_type;
+ uint8_t error_code;
+ uint8_t nitems;
+ uint8_t sequence[4];
};
struct vqp_obj_tlv_t {
- u_int8_t obj_type[4];
- u_int8_t obj_length[2];
+ uint8_t obj_type[4];
+ uint8_t obj_length[2];
};
#define VQP_OBJ_REQ_JOIN_PORT 0x01
@@ -106,52 +98,52 @@ static const struct tok vqp_obj_values[] = {
};
void
-vqp_print(register const u_char *pptr, register u_int len)
+vqp_print(netdissect_options *ndo, 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;
+ uint16_t vqp_obj_len;
+ uint32_t vqp_obj_type;
int tlen;
- u_int8_t nitems;
+ uint8_t nitems;
tptr=pptr;
tlen = len;
vqp_common_header = (const struct vqp_common_header_t *)pptr;
- TCHECK(*vqp_common_header);
+ ND_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));
+ ND_PRINT((ndo, "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",
+ if (ndo->ndo_vflag < 1) {
+ ND_PRINT((ndo, "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);
+ 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",
+ ND_PRINT((ndo, "\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);
+ len));
/* skip VQP Common header */
tptr+=sizeof(const struct vqp_common_header_t);
@@ -165,9 +157,9 @@ vqp_print(register const u_char *pptr, register u_int len)
tptr+=sizeof(struct vqp_obj_tlv_t);
tlen-=sizeof(struct vqp_obj_tlv_t);
- printf("\n\t %s Object (0x%08x), length %u, value: ",
+ ND_PRINT((ndo, "\n\t %s Object (0x%08x), length %u, value: ",
tok2str(vqp_obj_values, "Unknown", vqp_obj_type),
- vqp_obj_type, vqp_obj_len);
+ vqp_obj_type, vqp_obj_len));
/* basic sanity check */
if (vqp_obj_type == 0 || vqp_obj_len ==0) {
@@ -175,28 +167,27 @@ vqp_print(register const u_char *pptr, register u_int len)
}
/* did we capture enough for fully decoding the object ? */
- if (!TTEST2(*tptr, vqp_obj_len))
- goto trunc;
+ ND_TCHECK2(*tptr, vqp_obj_len);
switch(vqp_obj_type) {
case VQP_OBJ_IP_ADDRESS:
- printf("%s (0x%08x)", ipaddr_string(tptr), EXTRACT_32BITS(tptr));
+ ND_PRINT((ndo, "%s (0x%08x)", ipaddr_string(ndo, 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);
+ safeputs(ndo, 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));
+ ND_PRINT((ndo, "%s", etheraddr_string(ndo, tptr)));
break;
default:
- if (vflag <= 1)
- print_unknown_data(tptr, "\n\t ", vqp_obj_len);
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo,tptr, "\n\t ", vqp_obj_len);
break;
}
tptr += vqp_obj_len;
@@ -205,5 +196,5 @@ vqp_print(register const u_char *pptr, register u_int len)
}
return;
trunc:
- printf("\n\t[|VQP]");
+ ND_PRINT((ndo, "\n\t[|VQP]"));
}
diff --git a/contrib/tcpdump/print-vrrp.c b/contrib/tcpdump/print-vrrp.c
index 8b733d228c3c..f739d1ed7165 100644
--- a/contrib/tcpdump/print-vrrp.c
+++ b/contrib/tcpdump/print-vrrp.c
@@ -23,26 +23,22 @@
* FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-vrrp.c,v 1.10 2005-05-06 07:56:54 guy Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <stdlib.h>
-
#include "interface.h"
#include "extract.h"
#include "addrtoname.h"
+#include "ip.h"
+#include "ipproto.h"
/*
- * RFC 2338:
+ * RFC 2338 (VRRP v2):
+ *
* 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
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -62,6 +58,27 @@ static const char rcsid[] _U_ =
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Authentication Data (2) |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *
+ *
+ * RFC 5798 (VRRP v3):
+ *
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | IPv4 Fields or IPv6 Fields |
+ * ... ...
+ * | |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |Version| Type | Virtual Rtr ID| Priority |Count IPvX Addr|
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |(rsvd) | Max Adver Int | Checksum |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | |
+ * + +
+ * | IPvX Address(es) |
+ * + +
+ * | |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
/* Type */
@@ -85,63 +102,81 @@ static const struct tok auth2str[] = {
};
void
-vrrp_print(register const u_char *bp, register u_int len, int ttl)
+vrrp_print(netdissect_options *ndo,
+ register const u_char *bp, register u_int len,
+ register const u_char *bp2, int ttl)
{
- int version, type, auth_type;
+ int version, type, auth_type = VRRP_AUTH_NONE; /* keep compiler happy */
const char *type_s;
- TCHECK(bp[0]);
+ ND_TCHECK(bp[0]);
version = (bp[0] & 0xf0) >> 4;
type = bp[0] & 0x0f;
type_s = tok2str(type2str, "unknown type (%u)", type);
- printf("VRRPv%u, %s", version, type_s);
+ ND_PRINT((ndo, "VRRPv%u, %s", version, type_s));
if (ttl != 255)
- printf(", (ttl %u)", ttl);
- if (version != 2 || type != VRRP_TYPE_ADVERTISEMENT)
+ ND_PRINT((ndo, ", (ttl %u)", ttl));
+ if (version < 2 || version > 3 || type != VRRP_TYPE_ADVERTISEMENT)
return;
- TCHECK(bp[2]);
- printf(", vrid %u, prio %u", bp[1], bp[2]);
- TCHECK(bp[5]);
- auth_type = bp[4];
- printf(", authtype %s", tok2str(auth2str, NULL, auth_type));
- printf(", intvl %us, length %u", bp[5],len);
- if (vflag) {
+ ND_TCHECK(bp[2]);
+ ND_PRINT((ndo, ", vrid %u, prio %u", bp[1], bp[2]));
+ ND_TCHECK(bp[5]);
+
+ if (version == 2) {
+ auth_type = bp[4];
+ ND_PRINT((ndo, ", authtype %s", tok2str(auth2str, NULL, auth_type)));
+ ND_PRINT((ndo, ", intvl %us, length %u", bp[5], len));
+ } else { /* version == 3 */
+ uint16_t intvl = (bp[4] & 0x0f) << 8 | bp[5];
+ ND_PRINT((ndo, ", intvl %ucs, length %u", intvl, len));
+ }
+
+ if (ndo->ndo_vflag) {
int naddrs = bp[3];
int i;
char c;
- if (TTEST2(bp[0], len)) {
+ if (version == 2 && ND_TTEST2(bp[0], len)) {
struct cksum_vec vec[1];
vec[0].ptr = bp;
vec[0].len = len;
if (in_cksum(vec, 1))
- printf(", (bad vrrp cksum %x)",
- EXTRACT_16BITS(&bp[6]));
+ ND_PRINT((ndo, ", (bad vrrp cksum %x)",
+ EXTRACT_16BITS(&bp[6])));
+ }
+
+ if (version == 3 && ND_TTEST2(bp[0], len)) {
+ uint16_t cksum = nextproto4_cksum(ndo, (struct ip *)bp2, bp,
+ len, len, IPPROTO_VRRP);
+ if (cksum)
+ ND_PRINT((ndo, ", (bad vrrp cksum %x)",
+ EXTRACT_16BITS(&bp[6])));
}
- printf(", addrs");
+
+ ND_PRINT((ndo, ", addrs"));
if (naddrs > 1)
- printf("(%d)", naddrs);
- printf(":");
+ ND_PRINT((ndo, "(%d)", naddrs));
+ ND_PRINT((ndo, ":"));
c = ' ';
bp += 8;
for (i = 0; i < naddrs; i++) {
- TCHECK(bp[3]);
- printf("%c%s", c, ipaddr_string(bp));
+ ND_TCHECK(bp[3]);
+ ND_PRINT((ndo, "%c%s", c, ipaddr_string(ndo, bp)));
c = ',';
bp += 4;
}
- if (auth_type == VRRP_AUTH_SIMPLE) { /* simple text password */
- TCHECK(bp[7]);
- printf(" auth \"");
- if (fn_printn(bp, 8, snapend)) {
- printf("\"");
+ if (version == 2 && auth_type == VRRP_AUTH_SIMPLE) { /* simple text password */
+ ND_TCHECK(bp[7]);
+ ND_PRINT((ndo, " auth \""));
+ if (fn_printn(ndo, bp, 8, ndo->ndo_snapend)) {
+ ND_PRINT((ndo, "\""));
goto trunc;
}
- printf("\"");
+ ND_PRINT((ndo, "\""));
}
}
return;
trunc:
- printf("[|vrrp]");
+ ND_PRINT((ndo, "[|vrrp]"));
}
diff --git a/contrib/tcpdump/print-vtp.c b/contrib/tcpdump/print-vtp.c
index 7631c6f61842..9fe86e3c4bb6 100644
--- a/contrib/tcpdump/print-vtp.c
+++ b/contrib/tcpdump/print-vtp.c
@@ -15,26 +15,23 @@
* 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/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 <carles.kishimoto@gmail.com>
*/
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <string.h>
-
#include "interface.h"
#include "addrtoname.h"
-#include "extract.h"
-#include "nlpid.h"
+#include "extract.h"
#define VTP_HEADER_LEN 36
#define VTP_DOMAIN_NAME_LEN 32
@@ -48,16 +45,16 @@
#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;
+ uint8_t len;
+ uint8_t status;
+ uint8_t type;
+ uint8_t name_len;
+ uint16_t vlanid;
+ uint16_t mtu;
+ uint32_t index;
};
-static struct tok vtp_message_type_values[] = {
+static const struct tok vtp_message_type_values[] = {
{ VTP_SUMMARY_ADV, "Summary advertisement"},
{ VTP_SUBSET_ADV, "Subset advertisement"},
{ VTP_ADV_REQUEST, "Advertisement request"},
@@ -65,7 +62,7 @@ static struct tok vtp_message_type_values[] = {
{ 0, NULL }
};
-static struct tok vtp_header_values[] = {
+static const 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 */
@@ -73,7 +70,7 @@ static struct tok vtp_header_values[] = {
{ 0, NULL }
};
-static struct tok vtp_vlan_type_values[] = {
+static const struct tok vtp_vlan_type_values[] = {
{ 0x01, "Ethernet"},
{ 0x02, "FDDI"},
{ 0x03, "TrCRF"},
@@ -82,7 +79,7 @@ static struct tok vtp_vlan_type_values[] = {
{ 0, NULL }
};
-static struct tok vtp_vlan_status[] = {
+static const struct tok vtp_vlan_status[] = {
{ 0x00, "Operational"},
{ 0x01, "Suspended"},
{ 0, NULL }
@@ -99,7 +96,7 @@ static struct tok vtp_vlan_status[] = {
#define VTP_VLAN_STE_HOP_COUNT 0x09
#define VTP_VLAN_BACKUP_CRF_MODE 0x0A
-static struct tok vtp_vlan_tlv_values[] = {
+static const 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"},
@@ -113,7 +110,7 @@ static struct tok vtp_vlan_tlv_values[] = {
{ 0, NULL }
};
-static struct tok vtp_stp_type_values[] = {
+static const struct tok vtp_stp_type_values[] = {
{ 1, "SRT"},
{ 2, "SRB"},
{ 3, "Auto"},
@@ -121,7 +118,8 @@ static struct tok vtp_stp_type_values[] = {
};
void
-vtp_print (const u_char *pptr, u_int length)
+vtp_print (netdissect_options *ndo,
+ const u_char *pptr, u_int length)
{
int type, len, tlv_len, tlv_value;
const u_char *tptr;
@@ -130,28 +128,27 @@ vtp_print (const u_char *pptr, u_int length)
if (length < VTP_HEADER_LEN)
goto trunc;
- tptr = pptr;
+ tptr = pptr;
- if (!TTEST2(*tptr, VTP_HEADER_LEN))
- goto trunc;
+ ND_TCHECK2(*tptr, VTP_HEADER_LEN);
type = *(tptr+1);
- printf("VTPv%u, Message %s (0x%02x), length %u",
- *tptr,
+ ND_PRINT((ndo, "VTPv%u, Message %s (0x%02x), length %u",
+ *tptr,
tok2str(vtp_message_type_values,"Unknown message type", type),
*(tptr+1),
- length);
+ length));
/* In non-verbose mode, just print version and message type */
- if (vflag < 1) {
+ if (ndo->ndo_vflag < 1) {
return;
}
/* verbose mode print all fields */
- printf("\n\tDomain name: %s, %s: %u",
+ ND_PRINT((ndo, "\n\tDomain name: %s, %s: %u",
(tptr+4),
tok2str(vtp_header_values,"Unknown",*(tptr+1)),
- *(tptr+2));
+ *(tptr+2)));
tptr += VTP_HEADER_LEN;
@@ -176,23 +173,23 @@ vtp_print (const u_char *pptr, u_int length)
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | MD5 digest (16 bytes) |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *
+ *
*/
- printf("\n\t Config Rev %x, Updater %s",
+ ND_PRINT((ndo, "\n\t Config Rev %x, Updater %s",
EXTRACT_32BITS(tptr),
- ipaddr_string(tptr+4));
- tptr += 8;
- printf(", Timestamp 0x%08x 0x%08x 0x%08x",
+ ipaddr_string(ndo, tptr+4)));
+ tptr += 8;
+ ND_PRINT((ndo, ", Timestamp 0x%08x 0x%08x 0x%08x",
EXTRACT_32BITS(tptr),
EXTRACT_32BITS(tptr + 4),
- EXTRACT_32BITS(tptr + 8));
+ EXTRACT_32BITS(tptr + 8)));
tptr += VTP_UPDATE_TIMESTAMP_LEN;
- printf(", MD5 digest: %08x%08x%08x%08x",
+ ND_PRINT((ndo, ", MD5 digest: %08x%08x%08x%08x",
EXTRACT_32BITS(tptr),
EXTRACT_32BITS(tptr + 4),
EXTRACT_32BITS(tptr + 8),
- EXTRACT_32BITS(tptr + 12));
+ EXTRACT_32BITS(tptr + 12)));
tptr += VTP_MD5_DIGEST_LEN;
break;
@@ -215,12 +212,12 @@ vtp_print (const u_char *pptr, u_int length)
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | VLAN info field N |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *
+ *
*/
- printf(", Config Rev %x", EXTRACT_32BITS(tptr));
+ ND_PRINT((ndo, ", 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
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -242,17 +239,16 @@ vtp_print (const u_char *pptr, u_int length)
if (len == 0)
break;
- if (!TTEST2(*tptr, len))
- goto trunc;
+ ND_TCHECK2(*tptr, len);
vtp_vlan = (struct vtp_vlan_*)tptr;
- printf("\n\tVLAN info status %s, type %s, VLAN-id %u, MTU %u, SAID 0x%08x, Name %s",
+ ND_PRINT((ndo, "\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));
+ (tptr + VTP_VLAN_INFO_OFFSET)));
/*
* Vlan names are aligned to 32-bit boundaries.
@@ -264,16 +260,16 @@ vtp_print (const u_char *pptr, u_int length)
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
+ * 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",
+ ND_PRINT((ndo, "\n\t\t%s (0x%04x) TLV",
tok2str(vtp_vlan_tlv_values, "Unknown", type),
- type);
+ type));
/*
* infinite loop check
@@ -282,38 +278,37 @@ vtp_print (const u_char *pptr, u_int length)
return;
}
- if (!TTEST2(*tptr, tlv_len*2 +2))
- goto trunc;
+ ND_TCHECK2(*tptr, tlv_len * 2 +2);
tlv_value = EXTRACT_16BITS(tptr+2);
switch (type) {
case VTP_VLAN_STE_HOP_COUNT:
- printf(", %u", tlv_value);
+ ND_PRINT((ndo, ", %u", tlv_value));
break;
case VTP_VLAN_PRUNING:
- printf(", %s (%u)",
+ ND_PRINT((ndo, ", %s (%u)",
tlv_value == 1 ? "Enabled" : "Disabled",
- tlv_value);
+ tlv_value));
break;
case VTP_VLAN_STP_TYPE:
- printf(", %s (%u)",
+ ND_PRINT((ndo, ", %s (%u)",
tok2str(vtp_stp_type_values, "Unknown", tlv_value),
- tlv_value);
+ tlv_value));
break;
case VTP_VLAN_BRIDGE_TYPE:
- printf(", %s (%u)",
+ ND_PRINT((ndo, ", %s (%u)",
tlv_value == 1 ? "SRB" : "SRT",
- tlv_value);
+ tlv_value));
break;
case VTP_VLAN_BACKUP_CRF_MODE:
- printf(", %s (%u)",
+ ND_PRINT((ndo, ", %s (%u)",
tlv_value == 1 ? "Backup" : "Not backup",
- tlv_value);
+ tlv_value));
break;
/*
@@ -327,7 +322,7 @@ vtp_print (const u_char *pptr, u_int length)
case VTP_VLAN_TRANS_BRIDGED_VLAN:
case VTP_VLAN_ARP_HOP_COUNT:
default:
- print_unknown_data(tptr, "\n\t\t ", 2 + tlv_len*2);
+ print_unknown_data(ndo, tptr, "\n\t\t ", 2 + tlv_len*2);
break;
}
len -= 2 + tlv_len*2;
@@ -352,7 +347,7 @@ vtp_print (const u_char *pptr, u_int length)
*
*/
- printf("\n\tStart value: %u", EXTRACT_32BITS(tptr));
+ ND_PRINT((ndo, "\n\tStart value: %u", EXTRACT_32BITS(tptr)));
break;
case VTP_JOIN_MESSAGE:
@@ -367,7 +362,7 @@ vtp_print (const u_char *pptr, u_int length)
return;
trunc:
- printf("[|vtp]");
+ ND_PRINT((ndo, "[|vtp]"));
}
/*
diff --git a/contrib/tcpdump/print-vxlan.c b/contrib/tcpdump/print-vxlan.c
index 80344634d1a3..62b4b2ba0b1a 100644
--- a/contrib/tcpdump/print-vxlan.c
+++ b/contrib/tcpdump/print-vxlan.c
@@ -13,20 +13,15 @@
* Original code by Francesco Fondelli (francesco dot fondelli, gmail dot com)
*/
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <stdlib.h>
-
#include "interface.h"
#include "extract.h"
-#include "addrtoname.h"
-
-#include "udp.h"
/*
* VXLAN header, draft-mahalingam-dutt-dcops-vxlan-03
@@ -37,17 +32,17 @@
* |R|R|R|R|I|R|R|R| Reserved |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | VXLAN Network Identifier (VNI) | Reserved |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
void
-vxlan_print(const u_char *bp, u_int len)
+vxlan_print(netdissect_options *ndo, const u_char *bp, u_int len)
{
- u_int8_t flags;
- u_int32_t vni;
-
+ uint8_t flags;
+ uint32_t vni;
+
if (len < 8) {
- printf("[|VXLAN]");
+ ND_PRINT((ndo, "[|VXLAN]"));
return;
}
@@ -57,18 +52,9 @@ vxlan_print(const u_char *bp, u_int len)
vni = EXTRACT_24BITS(bp);
bp += 4;
- printf("VXLAN, ");
-
- fputs("flags [", stdout);
- if (flags & 0x08)
- fputs("I", stdout);
- else
- fputs(".", stdout);
- fputs("] ", stdout);
-
- printf("(0x%02x), ", flags);
- printf("vni %u\n", vni);
+ ND_PRINT((ndo, "VXLAN, "));
+ ND_PRINT((ndo, "flags [%s] (0x%02x), ", flags & 0x08 ? "I" : ".", flags));
+ ND_PRINT((ndo, "vni %u\n", vni));
- ether_print(gndo, bp, len - 8, len - 8, NULL, NULL);
- return;
+ ether_print(ndo, bp, len - 8, len - 8, NULL, NULL);
}
diff --git a/contrib/tcpdump/print-wb.c b/contrib/tcpdump/print-wb.c
index 3ae604ffed0b..49100fa48f4f 100644
--- a/contrib/tcpdump/print-wb.c
+++ b/contrib/tcpdump/print-wb.c
@@ -19,23 +19,19 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#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)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-
#include "interface.h"
#include "addrtoname.h"
#include "extract.h"
+static const char tstr[] = "[|wb]";
+
/* XXX need to add byte-swapping macros! */
/* XXX - you mean like the ones in "extract.h"? */
@@ -60,9 +56,9 @@ static const char rcsid[] _U_ =
* The transport level header.
*/
struct pkt_hdr {
- u_int32_t ph_src; /* site id of source */
- u_int32_t ph_ts; /* time stamp (for skew computation) */
- u_int16_t ph_version; /* version number */
+ uint32_t ph_src; /* site id of source */
+ uint32_t ph_ts; /* time stamp (for skew computation) */
+ uint16_t ph_version; /* version number */
u_char ph_type; /* message type */
u_char ph_flags; /* message flags */
};
@@ -85,13 +81,13 @@ struct pkt_hdr {
#define PF_VIS 0x02 /* only visible ops wanted */
struct PageID {
- u_int32_t p_sid; /* session id of initiator */
- u_int32_t p_uid; /* page number */
+ uint32_t p_sid; /* session id of initiator */
+ uint32_t p_uid; /* page number */
};
struct dophdr {
- u_int32_t dh_ts; /* sender's timestamp */
- u_int16_t dh_len; /* body length */
+ uint32_t dh_ts; /* sender's timestamp */
+ uint16_t dh_len; /* body length */
u_char dh_flags;
u_char dh_type; /* body type */
/* body follows */
@@ -120,8 +116,8 @@ struct dophdr {
*/
struct pkt_dop {
struct PageID pd_page; /* page that operations apply to */
- u_int32_t pd_sseq; /* start sequence number */
- u_int32_t pd_eseq; /* end sequence number */
+ uint32_t pd_sseq; /* start sequence number */
+ uint32_t pd_eseq; /* end sequence number */
/* drawing ops follow */
};
@@ -129,31 +125,31 @@ struct pkt_dop {
* A repair request.
*/
struct pkt_rreq {
- u_int32_t pr_id; /* source id of drawops to be repaired */
+ uint32_t pr_id; /* source id of drawops to be repaired */
struct PageID pr_page; /* page of drawops */
- u_int32_t pr_sseq; /* start seqno */
- u_int32_t pr_eseq; /* end seqno */
+ uint32_t pr_sseq; /* start seqno */
+ uint32_t pr_eseq; /* end seqno */
};
/*
* A repair reply.
*/
struct pkt_rrep {
- u_int32_t pr_id; /* original site id of ops */
+ uint32_t pr_id; /* original site id of ops */
struct pkt_dop pr_dop;
/* drawing ops follow */
};
struct id_off {
- u_int32_t id;
- u_int32_t off;
+ uint32_t id;
+ uint32_t off;
};
struct pgstate {
- u_int32_t slot;
+ uint32_t slot;
struct PageID page;
- u_int16_t nid;
- u_int16_t rsvd;
+ uint16_t nid;
+ uint16_t rsvd;
/* seqptr's */
};
@@ -161,7 +157,7 @@ struct pgstate {
* An announcement packet.
*/
struct pkt_id {
- u_int32_t pi_mslot;
+ uint32_t pi_mslot;
struct PageID pi_mpage; /* current page */
struct pgstate pi_ps;
/* seqptr's */
@@ -170,17 +166,18 @@ struct pkt_id {
struct pkt_preq {
struct PageID pp_page;
- u_int32_t pp_low;
- u_int32_t pp_high;
+ uint32_t pp_low;
+ uint32_t pp_high;
};
struct pkt_prep {
- u_int32_t pp_n; /* size of pageid array */
+ uint32_t pp_n; /* size of pageid array */
/* pgstate's follow */
};
static int
-wb_id(const struct pkt_id *id, u_int len)
+wb_id(netdissect_options *ndo,
+ const struct pkt_id *id, u_int len)
{
int i;
const char *cp;
@@ -188,80 +185,83 @@ wb_id(const struct pkt_id *id, u_int len)
char c;
int nid;
- printf(" wb-id:");
- if (len < sizeof(*id) || (u_char *)(id + 1) > snapend)
+ ND_PRINT((ndo, " wb-id:"));
+ if (len < sizeof(*id) || (u_char *)(id + 1) > ndo->ndo_snapend)
return (-1);
len -= sizeof(*id);
- printf(" %u/%s:%u (max %u/%s:%u) ",
+ ND_PRINT((ndo, " %u/%s:%u (max %u/%s:%u) ",
EXTRACT_32BITS(&id->pi_ps.slot),
- ipaddr_string(&id->pi_ps.page.p_sid),
+ ipaddr_string(ndo, &id->pi_ps.page.p_sid),
EXTRACT_32BITS(&id->pi_ps.page.p_uid),
EXTRACT_32BITS(&id->pi_mslot),
- ipaddr_string(&id->pi_mpage.p_sid),
- EXTRACT_32BITS(&id->pi_mpage.p_uid));
+ ipaddr_string(ndo, &id->pi_mpage.p_sid),
+ EXTRACT_32BITS(&id->pi_mpage.p_uid)));
nid = EXTRACT_16BITS(&id->pi_ps.nid);
len -= sizeof(*io) * nid;
io = (struct id_off *)(id + 1);
cp = (char *)(io + nid);
- if ((u_char *)cp + len <= snapend) {
- putchar('"');
- (void)fn_print((u_char *)cp, (u_char *)cp + len);
- putchar('"');
+ if ((u_char *)cp + len <= ndo->ndo_snapend) {
+ ND_PRINT((ndo, "\""));
+ fn_print(ndo, (u_char *)cp, (u_char *)cp + len);
+ ND_PRINT((ndo, "\""));
}
c = '<';
- for (i = 0; i < nid && (u_char *)(io + 1) <= snapend; ++io, ++i) {
- printf("%c%s:%u",
- c, ipaddr_string(&io->id), EXTRACT_32BITS(&io->off));
+ for (i = 0; i < nid && (u_char *)(io + 1) <= ndo->ndo_snapend; ++io, ++i) {
+ ND_PRINT((ndo, "%c%s:%u",
+ c, ipaddr_string(ndo, &io->id), EXTRACT_32BITS(&io->off)));
c = ',';
}
if (i >= nid) {
- printf(">");
+ ND_PRINT((ndo, ">"));
return (0);
}
return (-1);
}
static int
-wb_rreq(const struct pkt_rreq *rreq, u_int len)
+wb_rreq(netdissect_options *ndo,
+ const struct pkt_rreq *rreq, u_int len)
{
- printf(" wb-rreq:");
- if (len < sizeof(*rreq) || (u_char *)(rreq + 1) > snapend)
+ ND_PRINT((ndo, " wb-rreq:"));
+ if (len < sizeof(*rreq) || (u_char *)(rreq + 1) > ndo->ndo_snapend)
return (-1);
- printf(" please repair %s %s:%u<%u:%u>",
- ipaddr_string(&rreq->pr_id),
- ipaddr_string(&rreq->pr_page.p_sid),
+ ND_PRINT((ndo, " please repair %s %s:%u<%u:%u>",
+ ipaddr_string(ndo, &rreq->pr_id),
+ ipaddr_string(ndo, &rreq->pr_page.p_sid),
EXTRACT_32BITS(&rreq->pr_page.p_uid),
EXTRACT_32BITS(&rreq->pr_sseq),
- EXTRACT_32BITS(&rreq->pr_eseq));
+ EXTRACT_32BITS(&rreq->pr_eseq)));
return (0);
}
static int
-wb_preq(const struct pkt_preq *preq, u_int len)
+wb_preq(netdissect_options *ndo,
+ const struct pkt_preq *preq, u_int len)
{
- printf(" wb-preq:");
- if (len < sizeof(*preq) || (u_char *)(preq + 1) > snapend)
+ ND_PRINT((ndo, " wb-preq:"));
+ if (len < sizeof(*preq) || (u_char *)(preq + 1) > ndo->ndo_snapend)
return (-1);
- printf(" need %u/%s:%u",
+ ND_PRINT((ndo, " need %u/%s:%u",
EXTRACT_32BITS(&preq->pp_low),
- ipaddr_string(&preq->pp_page.p_sid),
- EXTRACT_32BITS(&preq->pp_page.p_uid));
+ ipaddr_string(ndo, &preq->pp_page.p_sid),
+ EXTRACT_32BITS(&preq->pp_page.p_uid)));
return (0);
}
static int
-wb_prep(const struct pkt_prep *prep, u_int len)
+wb_prep(netdissect_options *ndo,
+ const struct pkt_prep *prep, u_int len)
{
int n;
const struct pgstate *ps;
- const u_char *ep = snapend;
+ const u_char *ep = ndo->ndo_snapend;
- printf(" wb-prep:");
+ ND_PRINT((ndo, " wb-prep:"));
if (len < sizeof(*prep)) {
return (-1);
}
@@ -271,24 +271,24 @@ wb_prep(const struct pkt_prep *prep, u_int len)
const struct id_off *io, *ie;
char c = '<';
- printf(" %u/%s:%u",
+ ND_PRINT((ndo, " %u/%s:%u",
EXTRACT_32BITS(&ps->slot),
- ipaddr_string(&ps->page.p_sid),
- EXTRACT_32BITS(&ps->page.p_uid));
+ ipaddr_string(ndo, &ps->page.p_sid),
+ EXTRACT_32BITS(&ps->page.p_uid)));
io = (struct id_off *)(ps + 1);
for (ie = io + ps->nid; io < ie && (u_char *)(io + 1) <= ep; ++io) {
- printf("%c%s:%u", c, ipaddr_string(&io->id),
- EXTRACT_32BITS(&io->off));
+ ND_PRINT((ndo, "%c%s:%u", c, ipaddr_string(ndo, &io->id),
+ EXTRACT_32BITS(&io->off)));
c = ',';
}
- printf(">");
+ ND_PRINT((ndo, ">"));
ps = (struct pgstate *)io;
}
return ((u_char *)ps <= ep? 0 : -1);
}
-const char *dopstr[] = {
+static const char *dopstr[] = {
"dop-0!",
"dop-1!",
"RECT",
@@ -308,21 +308,22 @@ const char *dopstr[] = {
};
static int
-wb_dops(const struct dophdr *dh, u_int32_t ss, u_int32_t es)
+wb_dops(netdissect_options *ndo,
+ const struct dophdr *dh, uint32_t ss, uint32_t es)
{
- printf(" <");
+ ND_PRINT((ndo, " <"));
for ( ; ss <= es; ++ss) {
register int t = dh->dh_type;
if (t > DT_MAXTYPE)
- printf(" dop-%d!", t);
+ ND_PRINT((ndo, " dop-%d!", t));
else {
- printf(" %s", dopstr[t]);
+ ND_PRINT((ndo, " %s", dopstr[t]));
if (t == DT_SKIP || t == DT_HOLE) {
- u_int32_t ts = EXTRACT_32BITS(&dh->dh_ts);
- printf("%d", ts - ss + 1);
+ uint32_t ts = EXTRACT_32BITS(&dh->dh_ts);
+ ND_PRINT((ndo, "%d", ts - ss + 1));
if (ss > ts || ts > es) {
- printf("[|]");
+ ND_PRINT((ndo, "[|]"));
if (ts < ss)
return (0);
}
@@ -330,55 +331,57 @@ wb_dops(const struct dophdr *dh, u_int32_t ss, u_int32_t es)
}
}
dh = DOP_NEXT(dh);
- if ((u_char *)dh > snapend) {
- printf("[|wb]");
+ if ((u_char *)dh > ndo->ndo_snapend) {
+ ND_PRINT((ndo, "%s", tstr));
break;
}
}
- printf(" >");
+ ND_PRINT((ndo, " >"));
return (0);
}
static int
-wb_rrep(const struct pkt_rrep *rrep, u_int len)
+wb_rrep(netdissect_options *ndo,
+ const struct pkt_rrep *rrep, u_int len)
{
const struct pkt_dop *dop = &rrep->pr_dop;
- printf(" wb-rrep:");
- if (len < sizeof(*rrep) || (u_char *)(rrep + 1) > snapend)
+ ND_PRINT((ndo, " wb-rrep:"));
+ if (len < sizeof(*rrep) || (u_char *)(rrep + 1) > ndo->ndo_snapend)
return (-1);
len -= sizeof(*rrep);
- printf(" for %s %s:%u<%u:%u>",
- ipaddr_string(&rrep->pr_id),
- ipaddr_string(&dop->pd_page.p_sid),
+ ND_PRINT((ndo, " for %s %s:%u<%u:%u>",
+ ipaddr_string(ndo, &rrep->pr_id),
+ ipaddr_string(ndo, &dop->pd_page.p_sid),
EXTRACT_32BITS(&dop->pd_page.p_uid),
EXTRACT_32BITS(&dop->pd_sseq),
- EXTRACT_32BITS(&dop->pd_eseq));
+ EXTRACT_32BITS(&dop->pd_eseq)));
- if (vflag)
- return (wb_dops((const struct dophdr *)(dop + 1),
+ if (ndo->ndo_vflag)
+ return (wb_dops(ndo, (const struct dophdr *)(dop + 1),
EXTRACT_32BITS(&dop->pd_sseq),
EXTRACT_32BITS(&dop->pd_eseq)));
return (0);
}
static int
-wb_drawop(const struct pkt_dop *dop, u_int len)
+wb_drawop(netdissect_options *ndo,
+ const struct pkt_dop *dop, u_int len)
{
- printf(" wb-dop:");
- if (len < sizeof(*dop) || (u_char *)(dop + 1) > snapend)
+ ND_PRINT((ndo, " wb-dop:"));
+ if (len < sizeof(*dop) || (u_char *)(dop + 1) > ndo->ndo_snapend)
return (-1);
len -= sizeof(*dop);
- printf(" %s:%u<%u:%u>",
- ipaddr_string(&dop->pd_page.p_sid),
+ ND_PRINT((ndo, " %s:%u<%u:%u>",
+ ipaddr_string(ndo, &dop->pd_page.p_sid),
EXTRACT_32BITS(&dop->pd_page.p_uid),
EXTRACT_32BITS(&dop->pd_sseq),
- EXTRACT_32BITS(&dop->pd_eseq));
+ EXTRACT_32BITS(&dop->pd_eseq)));
- if (vflag)
- return (wb_dops((const struct dophdr *)(dop + 1),
+ if (ndo->ndo_vflag)
+ return (wb_dops(ndo, (const struct dophdr *)(dop + 1),
EXTRACT_32BITS(&dop->pd_sseq),
EXTRACT_32BITS(&dop->pd_eseq)));
return (0);
@@ -388,57 +391,58 @@ wb_drawop(const struct pkt_dop *dop, u_int len)
* Print whiteboard multicast packets.
*/
void
-wb_print(register const void *hdr, register u_int len)
+wb_print(netdissect_options *ndo,
+ register const void *hdr, register u_int len)
{
register const struct pkt_hdr *ph;
ph = (const struct pkt_hdr *)hdr;
- if (len < sizeof(*ph) || (u_char *)(ph + 1) > snapend) {
- printf("[|wb]");
+ if (len < sizeof(*ph) || (u_char *)(ph + 1) > ndo->ndo_snapend) {
+ ND_PRINT((ndo, "%s", tstr));
return;
}
len -= sizeof(*ph);
if (ph->ph_flags)
- printf("*");
+ ND_PRINT((ndo, "*"));
switch (ph->ph_type) {
case PT_KILL:
- printf(" wb-kill");
+ ND_PRINT((ndo, " wb-kill"));
return;
case PT_ID:
- if (wb_id((struct pkt_id *)(ph + 1), len) >= 0)
+ if (wb_id(ndo, (struct pkt_id *)(ph + 1), len) >= 0)
return;
break;
case PT_RREQ:
- if (wb_rreq((struct pkt_rreq *)(ph + 1), len) >= 0)
+ if (wb_rreq(ndo, (struct pkt_rreq *)(ph + 1), len) >= 0)
return;
break;
case PT_RREP:
- if (wb_rrep((struct pkt_rrep *)(ph + 1), len) >= 0)
+ if (wb_rrep(ndo, (struct pkt_rrep *)(ph + 1), len) >= 0)
return;
break;
case PT_DRAWOP:
- if (wb_drawop((struct pkt_dop *)(ph + 1), len) >= 0)
+ if (wb_drawop(ndo, (struct pkt_dop *)(ph + 1), len) >= 0)
return;
break;
case PT_PREQ:
- if (wb_preq((struct pkt_preq *)(ph + 1), len) >= 0)
+ if (wb_preq(ndo, (struct pkt_preq *)(ph + 1), len) >= 0)
return;
break;
case PT_PREP:
- if (wb_prep((struct pkt_prep *)(ph + 1), len) >= 0)
+ if (wb_prep(ndo, (struct pkt_prep *)(ph + 1), len) >= 0)
return;
break;
default:
- printf(" wb-%d!", ph->ph_type);
+ ND_PRINT((ndo, " wb-%d!", ph->ph_type));
return;
}
}
diff --git a/contrib/tcpdump/print-zephyr.c b/contrib/tcpdump/print-zephyr.c
index 7c52e6540658..8132c49af7a1 100644
--- a/contrib/tcpdump/print-zephyr.c
+++ b/contrib/tcpdump/print-zephyr.c
@@ -20,11 +20,7 @@
* PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-zephyr.c,v 1.10 2007-08-09 18:47:27 hannes Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -70,7 +66,7 @@ enum z_packet_type {
Z_PACKET_STAT
};
-static struct tok z_types[] = {
+static const struct tok z_types[] = {
{ Z_PACKET_UNSAFE, "unsafe" },
{ Z_PACKET_UNACKED, "unacked" },
{ Z_PACKET_ACKED, "acked" },
@@ -82,26 +78,26 @@ static struct tok z_types[] = {
{ Z_PACKET_STAT, "stat" }
};
-char z_buf[256];
+static char z_buf[256];
static char *
-parse_field(char **pptr, int *len)
+parse_field(netdissect_options *ndo, char **pptr, int *len)
{
char *s;
if (*len <= 0 || !pptr || !*pptr)
return NULL;
- if (*pptr > (char *) snapend)
+ if (*pptr > (char *) ndo->ndo_snapend)
return NULL;
s = *pptr;
- while (*pptr <= (char *) snapend && *len >= 0 && **pptr) {
+ while (*pptr <= (char *) ndo->ndo_snapend && *len >= 0 && **pptr) {
(*pptr)++;
(*len)--;
}
(*pptr)++;
(*len)--;
- if (*len < 0 || *pptr > (char *) snapend)
+ if (*len < 0 || *pptr > (char *) ndo->ndo_snapend)
return NULL;
return s;
}
@@ -132,7 +128,7 @@ str_to_lower(char *string)
}
void
-zephyr_print(const u_char *cp, int length)
+zephyr_print(netdissect_options *ndo, const u_char *cp, int length)
{
struct z_packet z;
char *parse = (char *) cp;
@@ -150,7 +146,7 @@ zephyr_print(const u_char *cp, int length)
z.recipient = 0;
#define PARSE_STRING \
- s = parse_field(&parse, &parselen); \
+ s = parse_field(ndo, &parse, &parselen); \
if (!s) lose = 1;
#define PARSE_FIELD_INT(field) \
@@ -184,38 +180,38 @@ zephyr_print(const u_char *cp, int length)
PARSE_FIELD_STR(z.multi_uid);
if (lose) {
- printf(" [|zephyr] (%d)", length);
+ ND_PRINT((ndo, " [|zephyr] (%d)", length));
return;
}
- printf(" zephyr");
+ ND_PRINT((ndo, " zephyr"));
if (strncmp(z.version+4, "0.2", 3)) {
- printf(" v%s", z.version+4);
+ ND_PRINT((ndo, " v%s", z.version+4));
return;
}
- printf(" %s", tok2str(z_types, "type %d", z.kind));
+ ND_PRINT((ndo, " %s", tok2str(z_types, "type %d", z.kind)));
if (z.kind == Z_PACKET_SERVACK) {
/* Initialization to silence warnings */
char *ackdata = NULL;
PARSE_FIELD_STR(ackdata);
if (!lose && strcmp(ackdata, "SENT"))
- printf("/%s", str_to_lower(ackdata));
+ ND_PRINT((ndo, "/%s", str_to_lower(ackdata)));
}
- if (*z.sender) printf(" %s", z.sender);
+ if (*z.sender) ND_PRINT((ndo, " %s", z.sender));
if (!strcmp(z.class, "USER_LOCATE")) {
if (!strcmp(z.opcode, "USER_HIDE"))
- printf(" hide");
+ ND_PRINT((ndo, " hide"));
else if (!strcmp(z.opcode, "USER_UNHIDE"))
- printf(" unhide");
+ ND_PRINT((ndo, " unhide"));
else
- printf(" locate %s", z.inst);
+ ND_PRINT((ndo, " locate %s", z.inst));
return;
}
if (!strcmp(z.class, "ZEPHYR_ADMIN")) {
- printf(" zephyr-admin %s", str_to_lower(z.opcode));
+ ND_PRINT((ndo, " zephyr-admin %s", str_to_lower(z.opcode)));
return;
}
@@ -225,79 +221,79 @@ zephyr_print(const u_char *cp, int length)
!strcmp(z.opcode, "SUBSCRIBE_NODEFS") ||
!strcmp(z.opcode, "UNSUBSCRIBE")) {
- printf(" %ssub%s", strcmp(z.opcode, "SUBSCRIBE") ? "un" : "",
+ ND_PRINT((ndo, " %ssub%s", strcmp(z.opcode, "SUBSCRIBE") ? "un" : "",
strcmp(z.opcode, "SUBSCRIBE_NODEFS") ? "" :
- "-nodefs");
+ "-nodefs"));
if (z.kind != Z_PACKET_SERVACK) {
/* Initialization to silence warnings */
char *c = NULL, *i = NULL, *r = NULL;
PARSE_FIELD_STR(c);
PARSE_FIELD_STR(i);
PARSE_FIELD_STR(r);
- if (!lose) printf(" %s", z_triple(c, i, r));
+ if (!lose) ND_PRINT((ndo, " %s", z_triple(c, i, r)));
}
return;
}
if (!strcmp(z.opcode, "GIMME")) {
- printf(" ret");
+ ND_PRINT((ndo, " ret"));
return;
}
if (!strcmp(z.opcode, "GIMMEDEFS")) {
- printf(" gimme-defs");
+ ND_PRINT((ndo, " gimme-defs"));
return;
}
if (!strcmp(z.opcode, "CLEARSUB")) {
- printf(" clear-subs");
+ ND_PRINT((ndo, " clear-subs"));
return;
}
- printf(" %s", str_to_lower(z.opcode));
+ ND_PRINT((ndo, " %s", str_to_lower(z.opcode)));
return;
}
if (!strcmp(z.inst, "HM")) {
- printf(" %s", str_to_lower(z.opcode));
+ ND_PRINT((ndo, " %s", str_to_lower(z.opcode)));
return;
}
if (!strcmp(z.inst, "REALM")) {
if (!strcmp(z.opcode, "ADD_SUBSCRIBE"))
- printf(" realm add-subs");
+ ND_PRINT((ndo, " realm add-subs"));
if (!strcmp(z.opcode, "REQ_SUBSCRIBE"))
- printf(" realm req-subs");
+ ND_PRINT((ndo, " realm req-subs"));
if (!strcmp(z.opcode, "RLM_SUBSCRIBE"))
- printf(" realm rlm-sub");
+ ND_PRINT((ndo, " realm rlm-sub"));
if (!strcmp(z.opcode, "RLM_UNSUBSCRIBE"))
- printf(" realm rlm-unsub");
+ ND_PRINT((ndo, " realm rlm-unsub"));
return;
}
}
if (!strcmp(z.class, "HM_CTL")) {
- printf(" hm_ctl %s", str_to_lower(z.inst));
- printf(" %s", str_to_lower(z.opcode));
+ ND_PRINT((ndo, " hm_ctl %s", str_to_lower(z.inst)));
+ ND_PRINT((ndo, " %s", str_to_lower(z.opcode)));
return;
}
if (!strcmp(z.class, "HM_STAT")) {
if (!strcmp(z.inst, "HMST_CLIENT") && !strcmp(z.opcode, "GIMMESTATS")) {
- printf(" get-client-stats");
+ ND_PRINT((ndo, " get-client-stats"));
return;
}
}
if (!strcmp(z.class, "WG_CTL")) {
- printf(" wg_ctl %s", str_to_lower(z.inst));
- printf(" %s", str_to_lower(z.opcode));
+ ND_PRINT((ndo, " wg_ctl %s", str_to_lower(z.inst)));
+ ND_PRINT((ndo, " %s", str_to_lower(z.opcode)));
return;
}
if (!strcmp(z.class, "LOGIN")) {
if (!strcmp(z.opcode, "USER_FLUSH")) {
- printf(" flush_locs");
+ ND_PRINT((ndo, " flush_locs"));
return;
}
@@ -307,7 +303,7 @@ zephyr_print(const u_char *cp, int length)
!strcmp(z.opcode, "REALM-ANNOUNCED") ||
!strcmp(z.opcode, "NET-VISIBLE") ||
!strcmp(z.opcode, "NET-ANNOUNCED")) {
- printf(" set-exposure %s", str_to_lower(z.opcode));
+ ND_PRINT((ndo, " set-exposure %s", str_to_lower(z.opcode)));
return;
}
}
@@ -315,8 +311,7 @@ zephyr_print(const u_char *cp, int length)
if (!*z.recipient)
z.recipient = "*";
- printf(" to %s", z_triple(z.class, z.inst, z.recipient));
+ ND_PRINT((ndo, " to %s", z_triple(z.class, z.inst, z.recipient)));
if (*z.opcode)
- printf(" op %s", z.opcode);
- return;
+ ND_PRINT((ndo, " op %s", z.opcode));
}
diff --git a/contrib/tcpdump/print-zeromq.c b/contrib/tcpdump/print-zeromq.c
index d5ac4bd3b448..0ef30517bd7c 100644
--- a/contrib/tcpdump/print-zeromq.c
+++ b/contrib/tcpdump/print-zeromq.c
@@ -28,17 +28,18 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-
#include "interface.h"
#include "extract.h"
+static const char tstr[] = " [|zmtp1]";
+
/* Maximum number of ZMTP/1.0 frame body bytes (without the flags) to dump in
* hex and ASCII under a single "-v" flag.
*/
@@ -75,42 +76,42 @@
*/
static const u_char *
-zmtp1_print_frame(const u_char *cp, const u_char *ep) {
- u_int64_t body_len_declared, body_len_captured, header_len;
- u_int8_t flags;
+zmtp1_print_frame(netdissect_options *ndo, const u_char *cp, const u_char *ep) {
+ uint64_t body_len_declared, body_len_captured, header_len;
+ uint8_t flags;
- printf("\n\t");
- TCHECK2(*cp, 1); /* length/0xFF */
+ ND_PRINT((ndo, "\n\t"));
+ ND_TCHECK2(*cp, 1); /* length/0xFF */
if (cp[0] != 0xFF) {
header_len = 1; /* length */
body_len_declared = cp[0];
if (body_len_declared == 0)
return cp + header_len; /* skip to next frame */
- printf(" frame flags+body (8-bit) length %"PRIu8"", cp[0]);
- TCHECK2(*cp, header_len + 1); /* length, flags */
+ ND_PRINT((ndo, " frame flags+body (8-bit) length %u", cp[0]));
+ ND_TCHECK2(*cp, header_len + 1); /* length, flags */
flags = cp[1];
} else {
header_len = 1 + 8; /* 0xFF, length */
- printf(" frame flags+body (64-bit) length");
- TCHECK2(*cp, header_len); /* 0xFF, length */
+ ND_PRINT((ndo, " frame flags+body (64-bit) length"));
+ ND_TCHECK2(*cp, header_len); /* 0xFF, length */
body_len_declared = EXTRACT_64BITS(cp + 1);
if (body_len_declared == 0)
return cp + header_len; /* skip to next frame */
- printf(" %"PRIu64"", body_len_declared);
- TCHECK2(*cp, header_len + 1); /* 0xFF, length, flags */
+ ND_PRINT((ndo, " %" PRIu64, body_len_declared));
+ ND_TCHECK2(*cp, header_len + 1); /* 0xFF, length, flags */
flags = cp[9];
}
body_len_captured = ep - cp - header_len;
if (body_len_declared > body_len_captured)
- printf(" (%"PRIu64" captured)", body_len_captured);
- printf(", flags 0x%02"PRIx8"", flags);
+ ND_PRINT((ndo, " (%" PRIu64 " captured)", body_len_captured));
+ ND_PRINT((ndo, ", flags 0x%02x", flags));
- if (vflag) {
- u_int64_t body_len_printed = MIN(body_len_captured, body_len_declared);
+ if (ndo->ndo_vflag) {
+ uint64_t body_len_printed = min(body_len_captured, body_len_declared);
- printf(" (%s|%s|%s|%s|%s|%s|%s|%s)",
+ ND_PRINT((ndo, " (%s|%s|%s|%s|%s|%s|%s|%s)",
flags & 0x80 ? "MBZ" : "-",
flags & 0x40 ? "MBZ" : "-",
flags & 0x20 ? "MBZ" : "-",
@@ -118,31 +119,97 @@ zmtp1_print_frame(const u_char *cp, const u_char *ep) {
flags & 0x08 ? "MBZ" : "-",
flags & 0x04 ? "MBZ" : "-",
flags & 0x02 ? "MBZ" : "-",
- flags & 0x01 ? "MORE" : "-");
+ flags & 0x01 ? "MORE" : "-"));
- if (vflag == 1)
- body_len_printed = MIN(VBYTES + 1, body_len_printed);
+ if (ndo->ndo_vflag == 1)
+ body_len_printed = min(VBYTES + 1, body_len_printed);
if (body_len_printed > 1) {
- printf(", first %"PRIu64" byte(s) of body:", body_len_printed - 1);
- hex_and_ascii_print("\n\t ", cp + header_len + 1, body_len_printed - 1);
- printf("\n");
+ ND_PRINT((ndo, ", first %" PRIu64 " byte(s) of body:", body_len_printed - 1));
+ hex_and_ascii_print(ndo, "\n\t ", cp + header_len + 1, body_len_printed - 1);
+ ND_PRINT((ndo, "\n"));
}
}
- TCHECK2(*cp, header_len + body_len_declared); /* Next frame within the buffer ? */
+ ND_TCHECK2(*cp, header_len + body_len_declared); /* Next frame within the buffer ? */
return cp + header_len + body_len_declared;
trunc:
- printf(" [|zmtp1]");
+ ND_PRINT((ndo, "%s", tstr));
return ep;
}
void
-zmtp1_print(const u_char *cp, u_int len) {
- const u_char *ep = MIN(snapend, cp + len);
+zmtp1_print(netdissect_options *ndo, const u_char *cp, u_int len) {
+ const u_char *ep = min(ndo->ndo_snapend, cp + len);
- printf(": ZMTP/1.0");
+ ND_PRINT((ndo, ": ZMTP/1.0"));
while (cp < ep)
- cp = zmtp1_print_frame(cp, ep);
+ cp = zmtp1_print_frame(ndo, cp, ep);
}
+/* The functions below decode a ZeroMQ datagram, supposedly stored in the "Data"
+ * field of an ODATA/RDATA [E]PGM packet. An excerpt from zmq_pgm(7) man page
+ * follows.
+ *
+ * In order for late joining consumers to be able to identify message
+ * boundaries, each PGM datagram payload starts with a 16-bit unsigned integer
+ * in network byte order specifying either the offset of the first message frame
+ * in the datagram or containing the value 0xFFFF if the datagram contains
+ * solely an intermediate part of a larger message.
+ *
+ * Note that offset specifies where the first message begins rather than the
+ * first message part. Thus, if there are trailing message parts at the
+ * beginning of the packet the offset ignores them and points to first initial
+ * message part in the packet.
+ */
+
+static const u_char *
+zmtp1_print_intermediate_part(netdissect_options *ndo, const u_char *cp, const u_int len) {
+ u_int frame_offset;
+ uint64_t remaining_len;
+
+ ND_TCHECK2(*cp, 2);
+ frame_offset = EXTRACT_16BITS(cp);
+ ND_PRINT((ndo, "\n\t frame offset 0x%04x", frame_offset));
+ cp += 2;
+ remaining_len = ndo->ndo_snapend - cp; /* without the frame length */
+
+ if (frame_offset == 0xFFFF)
+ frame_offset = len - 2; /* always within the declared length */
+ else if (2 + frame_offset > len) {
+ ND_PRINT((ndo, " (exceeds datagram declared length)"));
+ goto trunc;
+ }
+
+ /* offset within declared length of the datagram */
+ if (frame_offset) {
+ ND_PRINT((ndo, "\n\t frame intermediate part, %u bytes", frame_offset));
+ if (frame_offset > remaining_len)
+ ND_PRINT((ndo, " (%"PRIu64" captured)", remaining_len));
+ if (ndo->ndo_vflag) {
+ uint64_t len_printed = min(frame_offset, remaining_len);
+
+ if (ndo->ndo_vflag == 1)
+ len_printed = min(VBYTES, len_printed);
+ if (len_printed > 1) {
+ ND_PRINT((ndo, ", first %"PRIu64" byte(s):", len_printed));
+ hex_and_ascii_print(ndo, "\n\t ", cp, len_printed);
+ ND_PRINT((ndo, "\n"));
+ }
+ }
+ }
+ return cp + frame_offset;
+
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return cp + len;
+}
+
+void
+zmtp1_print_datagram(netdissect_options *ndo, const u_char *cp, const u_int len) {
+ const u_char *ep = min(ndo->ndo_snapend, cp + len);
+
+ cp = zmtp1_print_intermediate_part(ndo, cp, len);
+ while (cp < ep)
+ cp = zmtp1_print_frame(ndo, cp, ep);
+}
diff --git a/contrib/tcpdump/route6d.h b/contrib/tcpdump/route6d.h
deleted file mode 100644
index 53953fdb6d31..000000000000
--- a/contrib/tcpdump/route6d.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 1995, 1996, 1997 and 1998 WIDE Project.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-/*
- * $Header: /tcpdump/master/tcpdump/route6d.h,v 1.5 2002-12-11 07:14:10 guy Exp $
- */
-
-#define RIP6_VERSION 1
-
-#define RIP6_REQUEST 1
-#define RIP6_RESPONSE 2
-
-struct netinfo6 {
- struct in6_addr rip6_dest;
- u_int16_t rip6_tag;
- u_int8_t rip6_plen;
- u_int8_t rip6_metric;
-};
-
-struct rip6 {
- u_int8_t rip6_cmd;
- u_int8_t rip6_vers;
- u_int8_t rip6_res1[2];
- union {
- struct netinfo6 ru6_nets[1];
- char ru6_tracefile[1];
- } rip6un;
-#define rip6_nets rip6un.ru6_nets
-#define rip6_tracefile rip6un.ru6_tracefile
-};
-
-#define HOPCNT_INFINITY6 16
-#define MAXRTE 24
-#define NEXTHOP_METRIC 0xff
-
-#ifndef DEBUG
-#define SUPPLY_INTERVAL6 30
-#define RIP_LIFETIME 180
-#define RIP_HOLDDOWN 120
-#define RIP_TRIG_INTERVAL6 5
-#define RIP_TRIG_INTERVAL6_MIN 1
-#else
-/* only for debugging; can not wait for 30sec to appear a bug */
-#define SUPPLY_INTERVAL6 10
-#define RIP_LIFETIME 60
-#define RIP_HOLDDOWN 40
-#define RIP_TRIG_INTERVAL6 5
-#define RIP_TRIG_INTERVAL6_MIN 1
-#endif
-
-#define RIP6_PORT 521
-#define RIP6_DEST "ff02::9"
diff --git a/contrib/tcpdump/rpc_auth.h b/contrib/tcpdump/rpc_auth.h
index 0e5a1c1294bb..6dabb49673b4 100644
--- a/contrib/tcpdump/rpc_auth.h
+++ b/contrib/tcpdump/rpc_auth.h
@@ -1,4 +1,3 @@
-/* @(#) $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
@@ -67,8 +66,8 @@ enum sunrpc_auth_stat {
* Authentication info. Opaque to client.
*/
struct sunrpc_opaque_auth {
- u_int32_t oa_flavor; /* flavor of auth */
- u_int32_t oa_len; /* length of opaque body */
+ uint32_t oa_flavor; /* flavor of auth */
+ uint32_t oa_len; /* length of opaque body */
/* zero or more bytes of body */
};
diff --git a/contrib/tcpdump/rpc_msg.h b/contrib/tcpdump/rpc_msg.h
index 9c2770c2b035..35a191c89bc0 100644
--- a/contrib/tcpdump/rpc_msg.h
+++ b/contrib/tcpdump/rpc_msg.h
@@ -1,4 +1,3 @@
-/* @(#) $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
@@ -40,7 +39,7 @@
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
-#define SUNRPC_MSG_VERSION ((u_int32_t) 2)
+#define SUNRPC_MSG_VERSION ((uint32_t) 2)
/*
* Bottom up definition of an rpc message.
@@ -80,13 +79,13 @@ enum sunrpc_reject_stat {
* Reply to an rpc request that was rejected by the server.
*/
struct sunrpc_rejected_reply {
- u_int32_t rj_stat; /* enum reject_stat */
+ uint32_t rj_stat; /* enum reject_stat */
union {
struct {
- u_int32_t low;
- u_int32_t high;
+ uint32_t low;
+ uint32_t high;
} RJ_versions;
- u_int32_t RJ_why; /* enum auth_stat - why authentication did not work */
+ uint32_t RJ_why; /* enum auth_stat - why authentication did not work */
} ru;
#define rj_vers ru.RJ_versions
#define rj_why ru.RJ_why
@@ -96,7 +95,7 @@ struct sunrpc_rejected_reply {
* Body of a reply to an rpc request.
*/
struct sunrpc_reply_body {
- u_int32_t rp_stat; /* enum reply_stat */
+ uint32_t rp_stat; /* enum reply_stat */
struct sunrpc_rejected_reply rp_reject; /* if rejected */
};
@@ -104,10 +103,10 @@ struct sunrpc_reply_body {
* Body of an rpc request call.
*/
struct sunrpc_call_body {
- u_int32_t cb_rpcvers; /* must be equal to two */
- u_int32_t cb_prog;
- u_int32_t cb_vers;
- u_int32_t cb_proc;
+ uint32_t cb_rpcvers; /* must be equal to two */
+ uint32_t cb_prog;
+ uint32_t cb_vers;
+ uint32_t cb_proc;
struct sunrpc_opaque_auth cb_cred;
/* followed by opaque verifier */
};
@@ -116,8 +115,8 @@ struct sunrpc_call_body {
* The rpc message
*/
struct sunrpc_msg {
- u_int32_t rm_xid;
- u_int32_t rm_direction; /* enum msg_type */
+ uint32_t rm_xid;
+ uint32_t rm_direction; /* enum msg_type */
union {
struct sunrpc_call_body RM_cmb;
struct sunrpc_reply_body RM_rmb;
diff --git a/contrib/tcpdump/rpl.h b/contrib/tcpdump/rpl.h
new file mode 100644
index 000000000000..c48784baa43e
--- /dev/null
+++ b/contrib/tcpdump/rpl.h
@@ -0,0 +1,174 @@
+#ifndef _RPL_H_
+
+/*
+ * NOTE: the contents of this file are an interpretation of RFC6550.
+ * no copyright is asserted on this file, as it transcribes
+ * a public specification.
+ *
+ */
+
+/*
+ * DIO: Updated to RFC6550, as published in 2012: section 6. (page 30)
+ */
+
+#define ND_RPL_MESSAGE 155 /* 0x9B */
+
+enum ND_RPL_CODE {
+ ND_RPL_DAG_IS=0x00,
+ ND_RPL_DAG_IO=0x01,
+ ND_RPL_DAO =0x02,
+ ND_RPL_DAO_ACK=0x03,
+ ND_RPL_SEC_DAG_IS = 0x80,
+ ND_RPL_SEC_DAG_IO = 0x81,
+ ND_RPL_SEC_DAG = 0x82,
+ ND_RPL_SEC_DAG_ACK= 0x83,
+ ND_RPL_SEC_CONSIST= 0x84,
+};
+
+enum ND_RPL_DIO_FLAGS {
+ ND_RPL_DIO_GROUNDED = 0x80,
+ ND_RPL_DIO_DATRIG = 0x40,
+ ND_RPL_DIO_DASUPPORT= 0x20,
+ ND_RPL_DIO_RES4 = 0x10,
+ ND_RPL_DIO_RES3 = 0x08,
+ ND_RPL_DIO_PRF_MASK = 0x07, /* 3-bit preference */
+};
+
+#define DAGID_LEN 16
+
+/* section 6 of draft-ietf-roll-rpl-19 */
+struct nd_rpl_security {
+ uint8_t rpl_sec_t_reserved; /* bit 7 is T-bit */
+ uint8_t rpl_sec_algo;
+ uint16_t rpl_sec_kim_lvl_flags; /* bit 15/14, KIM */
+ /* bit 10-8, LVL, bit 7-0 flags */
+ uint32_t rpl_sec_counter;
+#if 0
+ uint8_t rpl_sec_ki[0]; /* depends upon kim */
+#endif
+};
+
+/* section 6.2.1, DODAG Information Solication (DIS_IS) */
+struct nd_rpl_dis_is {
+ uint8_t rpl_dis_flags;
+ uint8_t rpl_dis_reserved;
+#if 0
+ uint8_t rpl_dis_options[0];
+#endif
+};
+
+/* section 6.3.1, DODAG Information Object (DIO) */
+struct nd_rpl_dio {
+ uint8_t rpl_instanceid;
+ uint8_t rpl_version;
+ uint16_t rpl_dagrank;
+ uint8_t rpl_mopprf; /* bit 7=G, 5-3=MOP, 2-0=PRF */
+ uint8_t rpl_dtsn; /* Dest. Advertisement Trigger Sequence Number */
+ uint8_t rpl_flags; /* no flags defined yet */
+ uint8_t rpl_resv1;
+ uint8_t rpl_dagid[DAGID_LEN];
+};
+#define RPL_DIO_GROUND_FLAG 0x80
+#define RPL_DIO_MOP_SHIFT 3
+#define RPL_DIO_MOP_MASK (7 << RPL_DIO_MOP_SHIFT)
+#define RPL_DIO_PRF_SHIFT 0
+#define RPL_DIO_PRF_MASK (7 << RPL_DIO_PRF_SHIFT)
+#define RPL_DIO_GROUNDED(X) ((X)&RPL_DIO_GROUND_FLAG)
+#define RPL_DIO_MOP(X) (enum RPL_DIO_MOP)(((X)&RPL_DIO_MOP_MASK) >> RPL_DIO_MOP_SHIFT)
+#define RPL_DIO_PRF(X) (((X)&RPL_DIO_PRF_MASK) >> RPL_DIO_PRF_SHIFT)
+
+enum RPL_DIO_MOP {
+ RPL_DIO_NONSTORING= 0x0,
+ RPL_DIO_STORING = 0x1,
+ RPL_DIO_NONSTORING_MULTICAST = 0x2,
+ RPL_DIO_STORING_MULTICAST = 0x3,
+};
+
+enum RPL_SUBOPT {
+ RPL_OPT_PAD0 = 0,
+ RPL_OPT_PADN = 1,
+ RPL_DIO_METRICS = 2,
+ RPL_DIO_ROUTINGINFO = 3,
+ RPL_DIO_CONFIG = 4,
+ RPL_DAO_RPLTARGET = 5,
+ RPL_DAO_TRANSITINFO = 6,
+ RPL_DIO_DESTPREFIX = 8,
+ RPL_DAO_RPLTARGET_DESC=9,
+};
+
+struct rpl_dio_genoption {
+ uint8_t rpl_dio_type;
+ uint8_t rpl_dio_len; /* suboption length, not including type/len */
+};
+#define RPL_DIO_GENOPTION_LEN 2
+
+#define RPL_DIO_LIFETIME_INFINITE 0xffffffff
+#define RPL_DIO_LIFETIME_DISCONNECT 0
+
+struct rpl_dio_destprefix {
+ uint8_t rpl_dio_type;
+ uint8_t rpl_dio_len;
+ uint8_t rpl_dio_prefixlen; /* in bits */
+ uint8_t rpl_dio_prf; /* flags, including Route Preference */
+ uint32_t rpl_dio_prefixlifetime; /* in seconds */
+#if 0
+ uint8_t rpl_dio_prefix[0]; /* variable number of bytes */
+#endif
+};
+
+/* section 6.4.1, DODAG Information Object (DIO) */
+struct nd_rpl_dao {
+ uint8_t rpl_instanceid;
+ uint8_t rpl_flags; /* bit 7=K, 6=D */
+ uint8_t rpl_resv;
+ uint8_t rpl_daoseq;
+ uint8_t rpl_dagid[DAGID_LEN]; /* present when D set. */
+};
+#define ND_RPL_DAO_MIN_LEN 4 /* length without DAGID */
+
+/* indicates if this DAO is to be acK'ed */
+#define RPL_DAO_K_SHIFT 7
+#define RPL_DAO_K_MASK (1 << RPL_DAO_K_SHIFT)
+#define RPL_DAO_K(X) (((X)&RPL_DAO_K_MASK) >> RPL_DAO_K_SHIFT)
+
+/* indicates if the DAGID is present */
+#define RPL_DAO_D_SHIFT 6
+#define RPL_DAO_D_MASK (1 << RPL_DAO_D_SHIFT)
+#define RPL_DAO_D(X) (((X)&RPL_DAO_D_MASK) >> RPL_DAO_D_SHIFT)
+
+struct rpl_dao_target {
+ uint8_t rpl_dao_type;
+ uint8_t rpl_dao_len;
+ uint8_t rpl_dao_flags; /* unused */
+ uint8_t rpl_dao_prefixlen; /* in bits */
+#if 0
+ uint8_t rpl_dao_prefix[0]; /* variable number of bytes */
+#endif
+};
+
+/* section 6.5.1, Destination Advertisement Object Acknowledgement (DAO-ACK) */
+struct nd_rpl_daoack {
+ uint8_t rpl_instanceid;
+ uint8_t rpl_flags; /* bit 7=D */
+ uint8_t rpl_daoseq;
+ uint8_t rpl_status;
+ uint8_t rpl_dagid[DAGID_LEN]; /* present when D set. */
+};
+#define ND_RPL_DAOACK_MIN_LEN 4 /* length without DAGID */
+/* indicates if the DAGID is present */
+#define RPL_DAOACK_D_SHIFT 7
+#define RPL_DAOACK_D_MASK (1 << RPL_DAOACK_D_SHIFT)
+#define RPL_DAOACK_D(X) (((X)&RPL_DAOACK_D_MASK) >> RPL_DAOACK_D_SHIFT)
+
+
+
+#define _RPL_H_
+#endif /* _RPL_H_ */
+
+/*
+ * Local Variables:
+ * c-basic-offset:4
+ * c-style: whitesmith
+ * End:
+ */
+
diff --git a/contrib/tcpdump/rx.h b/contrib/tcpdump/rx.h
deleted file mode 100644
index b79dd30cde0d..000000000000
--- a/contrib/tcpdump/rx.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright: (c) 2000 United States Government as represented by the
- * Secretary of the Navy. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. The names of the authors may not be used to endorse or promote
- * products derived from this software without specific prior
- * written permission.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-/*
- * Rx protocol format
- *
- * $Id: rx.h,v 1.8 2002-12-11 07:14:11 guy Exp $
- */
-
-#define FS_RX_PORT 7000
-#define CB_RX_PORT 7001
-#define PROT_RX_PORT 7002
-#define VLDB_RX_PORT 7003
-#define KAUTH_RX_PORT 7004
-#define VOL_RX_PORT 7005
-#define ERROR_RX_PORT 7006 /* Doesn't seem to be used */
-#define BOS_RX_PORT 7007
-
-#ifndef AFSNAMEMAX
-#define AFSNAMEMAX 256
-#endif
-
-#ifndef AFSOPAQUEMAX
-#define AFSOPAQUEMAX 1024
-#endif
-
-#define PRNAMEMAX 64
-#define VLNAMEMAX 65
-#define KANAMEMAX 64
-#define BOSNAMEMAX 256
-
-#define PRSFS_READ 1 /* Read files */
-#define PRSFS_WRITE 2 /* Write files */
-#define PRSFS_INSERT 4 /* Insert files into a directory */
-#define PRSFS_LOOKUP 8 /* Lookup files into a directory */
-#define PRSFS_DELETE 16 /* Delete files */
-#define PRSFS_LOCK 32 /* Lock files */
-#define PRSFS_ADMINISTER 64 /* Change ACL's */
-
-struct rx_header {
- u_int32_t epoch;
- u_int32_t cid;
- u_int32_t callNumber;
- u_int32_t seq;
- u_int32_t serial;
- u_int8_t type;
-#define RX_PACKET_TYPE_DATA 1
-#define RX_PACKET_TYPE_ACK 2
-#define RX_PACKET_TYPE_BUSY 3
-#define RX_PACKET_TYPE_ABORT 4
-#define RX_PACKET_TYPE_ACKALL 5
-#define RX_PACKET_TYPE_CHALLENGE 6
-#define RX_PACKET_TYPE_RESPONSE 7
-#define RX_PACKET_TYPE_DEBUG 8
-#define RX_PACKET_TYPE_PARAMS 9
-#define RX_PACKET_TYPE_VERSION 13
- u_int8_t flags;
-#define RX_CLIENT_INITIATED 1
-#define RX_REQUEST_ACK 2
-#define RX_LAST_PACKET 4
-#define RX_MORE_PACKETS 8
-#define RX_FREE_PACKET 16
-#define RX_SLOW_START_OK 32
-#define RX_JUMBO_PACKET 32
- u_int8_t userStatus;
- u_int8_t securityIndex;
- u_int16_t spare; /* How clever: even though the AFS */
- u_int16_t serviceId; /* header files indicate that the */
-}; /* serviceId is first, it's really */
- /* encoded _after_ the spare field */
- /* I wasted a day figuring that out! */
-
-#define NUM_RX_FLAGS 7
-
-#define RX_MAXACKS 255
-
-struct rx_ackPacket {
- u_int16_t bufferSpace; /* Number of packet buffers available */
- u_int16_t maxSkew; /* Max diff between ack'd packet and */
- /* highest packet received */
- u_int32_t firstPacket; /* The first packet in ack list */
- u_int32_t previousPacket; /* Previous packet recv'd (obsolete) */
- u_int32_t serial; /* # of packet that prompted the ack */
- u_int8_t reason; /* Reason for acknowledgement */
- u_int8_t nAcks; /* Number of acknowledgements */
- u_int8_t acks[RX_MAXACKS]; /* Up to RX_MAXACKS acknowledgements */
-};
-
-/*
- * Values for the acks array
- */
-
-#define RX_ACK_TYPE_NACK 0 /* Don't have this packet */
-#define RX_ACK_TYPE_ACK 1 /* I have this packet */
diff --git a/contrib/tcpdump/sctpConstants.h b/contrib/tcpdump/sctpConstants.h
deleted file mode 100644
index ac28a151d0e8..000000000000
--- a/contrib/tcpdump/sctpConstants.h
+++ /dev/null
@@ -1,571 +0,0 @@
-/* @(#) $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
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of Cisco nor of Motorola may be used
- * to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This file is part of the SCTP reference Implementation
- *
- *
- * Please send any bug reports or fixes you make to one of the following email
- * addresses:
- *
- * rstewar1@email.mot.com
- * kmorneau@cisco.com
- * qxie1@email.mot.com
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorperated into the next SCTP release.
- */
-
-
-#ifndef __sctpConstants_h__
-#define __sctpConstants_h__
-
-
- /* If you wish to use MD5 instead of SLA uncomment the line
- * below. Why you would like to do this:
- * a) There may be IPR on SHA-1, or so the FIP-180-1 page says,
- * b) MD5 is 3 times faster (has coded here).
- *
- * The disadvantage is, it is thought that MD5 has been
- * cracked... see RFC2104.
- */
-/*#define USE_MD5 1*/
-
-/* the SCTP protocol signature
- * this includes the version number
- * encoded in the last 4 bits of the
- * signature.
- */
-#define PROTO_SIGNATURE_A 0x30000000
-
-#define SCTP_VERSION_NUMBER 0x3
-
-#define MAX_TSN 0xffffffff
-#define MAX_SEQ 0xffff
-
-/* option:
- * If you comment out the following you will
- * receive the old behavior of obeying cwnd for
- * the fast retransmit algorithm. With this defined
- * a FR happens right away with-out waiting for the
- * flightsize to drop below the cwnd value (which
- * is reduced by the FR to 1/2 the inflight packets).
- */
-#define SCTP_IGNORE_CWND_ON_FR 1
-/* default max I can burst out after a fast retransmit */
-#define SCTP_DEF_MAX_BURST 4
-
-/* Packet transmit states in the sent
- * field in the SCTP_transmitOnQueue struct
- */
-#define SCTP_DATAGRAM_UNSENT 0
-#define SCTP_DATAGRAM_SENT 1
-#define SCTP_DATAGRAM_RESEND1 2 /* not used */
-#define SCTP_DATAGRAM_RESEND2 3 /* not used */
-#define SCTP_DATAGRAM_RESEND3 4 /* not used */
-#define SCTP_DATAGRAM_RESEND 5
-#define SCTP_DATAGRAM_ACKED 10010
-#define SCTP_DATAGRAM_INBOUND 10011
-#define SCTP_READY_TO_TRANSMIT 10012
-#define SCTP_DATAGRAM_MARKED 20010
-
-#define MAX_FSID 64 /* debug 5 ints used for cc dynamic tracking */
-
-/* The valid defines for all message
- * types know to SCTP. 0 is reserved
- */
-#define SCTP_MSGTYPE_MASK 0xff
-
-#define SCTP_DATA 0x00
-#define SCTP_INITIATION 0x01
-#define SCTP_INITIATION_ACK 0x02
-#define SCTP_SELECTIVE_ACK 0x03
-#define SCTP_HEARTBEAT_REQUEST 0x04
-#define SCTP_HEARTBEAT_ACK 0x05
-#define SCTP_ABORT_ASSOCIATION 0x06
-#define SCTP_SHUTDOWN 0x07
-#define SCTP_SHUTDOWN_ACK 0x08
-#define SCTP_OPERATION_ERR 0x09
-#define SCTP_COOKIE_ECHO 0x0a
-#define SCTP_COOKIE_ACK 0x0b
-#define SCTP_ECN_ECHO 0x0c
-#define SCTP_ECN_CWR 0x0d
-#define SCTP_SHUTDOWN_COMPLETE 0x0e
-#define SCTP_FORWARD_CUM_TSN 0xc0
-#define SCTP_RELIABLE_CNTL 0xc1
-#define SCTP_RELIABLE_CNTL_ACK 0xc2
-
-/* ABORT and SHUTDOWN COMPLETE FLAG */
-#define SCTP_HAD_NO_TCB 0x01
-
-/* Data Chuck Specific Flags */
-#define SCTP_DATA_FRAG_MASK 0x03
-#define SCTP_DATA_MIDDLE_FRAG 0x00
-#define SCTP_DATA_LAST_FRAG 0x01
-#define SCTP_DATA_FIRST_FRAG 0x02
-#define SCTP_DATA_NOT_FRAG 0x03
-#define SCTP_DATA_UNORDERED 0x04
-
-#define SCTP_CRC_ENABLE_BIT 0x01 /* lower bit of reserved */
-
-#define isSCTPControl(a) (a->chunkID != SCTP_DATA)
-#define isSCTPData(a) (a->chunkID == SCTP_DATA)
-
-/* sctp parameter types for init/init-ack */
-
-#define SCTP_IPV4_PARAM_TYPE 0x0005
-#define SCTP_IPV6_PARAM_TYPE 0x0006
-#define SCTP_RESPONDER_COOKIE 0x0007
-#define SCTP_UNRECOG_PARAM 0x0008
-#define SCTP_COOKIE_PRESERVE 0x0009
-#define SCTP_HOSTNAME_VIA_DNS 0x000b
-#define SCTP_RESTRICT_ADDR_TO 0x000c
-
-#define SCTP_ECN_I_CAN_DO_ECN 0x8000
-#define SCTP_OPERATION_SUCCEED 0x4001
-#define SCTP_ERROR_NOT_EXECUTED 0x4002
-
-#define SCTP_UNRELIABLE_STRM 0xc000
-#define SCTP_ADD_IP_ADDRESS 0xc001
-#define SCTP_DEL_IP_ADDRESS 0xc002
-#define SCTP_STRM_FLOW_LIMIT 0xc003
-#define SCTP_PARTIAL_CSUM 0xc004
-#define SCTP_ERROR_CAUSE_TLV 0xc005
-#define SCTP_MIT_STACK_NAME 0xc006
-#define SCTP_SETADDRESS_PRIMARY 0xc007
-
-/* bits for TOS field */
-#define SCTP_ECT_BIT 0x02
-#define SCTP_CE_BIT 0x01
-
-/* error codes */
-#define SCTP_OP_ERROR_NO_ERROR 0x0000
-#define SCTP_OP_ERROR_INV_STRM 0x0001
-#define SCTP_OP_ERROR_MISS_PARAM 0x0002
-#define SCTP_OP_ERROR_STALE_COOKIE 0x0003
-#define SCTP_OP_ERROR_NO_RESOURCE 0x0004
-#define SCTP_OP_ERROR_DNS_FAILED 0x0005
-#define SCTP_OP_ERROR_UNK_CHUNK 0x0006
-#define SCTP_OP_ERROR_INV_PARAM 0x0007
-#define SCTP_OP_ERROR_UNK_PARAM 0x0008
-#define SCTP_OP_ERROR_NO_USERD 0x0009
-#define SCTP_OP_ERROR_COOKIE_SHUT 0x000a
-#define SCTP_OP_ERROR_DELETE_LAST 0x000b
-#define SCTP_OP_ERROR_RESOURCE_SHORT 0x000c
-
-#define SCTP_MAX_ERROR_CAUSE 12
-
-/* empty error causes i.e. nothing but the cause
- * are SCTP_OP_ERROR_NO_RESOURCE, SCTP_OP_ERROR_INV_PARAM,
- * SCTP_OP_ERROR_COOKIE_SHUT.
- */
-
-/* parameter for Heart Beat */
-#define HEART_BEAT_PARAM 0x0001
-
-
-
-/* send options for SCTP
- */
-#define SCTP_ORDERED_DELIVERY 0x01
-#define SCTP_NON_ORDERED_DELIVERY 0x02
-#define SCTP_DO_CRC16 0x08
-#define SCTP_MY_ADDRESS_ONLY 0x10
-
-/* below turns off above */
-#define SCTP_FLEXIBLE_ADDRESS 0x20
-#define SCTP_NO_HEARTBEAT 0x40
-
-/* mask to get sticky */
-#define SCTP_STICKY_OPTIONS_MASK 0x0c
-
-/* MTU discovery flags */
-#define SCTP_DONT_FRAGMENT 0x0100
-#define SCTP_FRAGMENT_OK 0x0200
-
-
-/* SCTP state defines for internal state machine */
-#define SCTP_STATE_EMPTY 0x0000
-#define SCTP_STATE_INUSE 0x0001
-#define SCTP_STATE_COOKIE_WAIT 0x0002
-#define SCTP_STATE_COOKIE_SENT 0x0004
-#define SCTP_STATE_OPEN 0x0008
-#define SCTP_STATE_SHUTDOWN 0x0010
-#define SCTP_STATE_SHUTDOWN_RECV 0x0020
-#define SCTP_STATE_SHUTDOWN_ACK_SENT 0x0040
-#define SCTP_STATE_SHUTDOWN_PEND 0x0080
-#define SCTP_STATE_MASK 0x007f
-/* SCTP reachability state for each address */
-#define SCTP_ADDR_NOT_REACHABLE 1
-#define SCTP_ADDR_REACHABLE 2
-#define SCTP_ADDR_NOHB 4
-#define SCTP_ADDR_BEING_DELETED 8
-
-/* How long a cookie lives */
-#define SCTP_DEFAULT_COOKIE_LIFE 60 /* seconds */
-
-/* resource limit of streams */
-#define MAX_SCTP_STREAMS 2048
-
-
-/* guess at how big to make the TSN mapping array */
-#define SCTP_STARTING_MAPARRAY 10000
-
-/* Here we define the timer types used
- * by the implementation has
- * arguments in the set/get timer type calls.
- */
-#define SCTP_TIMER_INIT 0
-#define SCTP_TIMER_RECV 1
-#define SCTP_TIMER_SEND 2
-#define SCTP_TIMER_SHUTDOWN 3
-#define SCTP_TIMER_HEARTBEAT 4
-#define SCTP_TIMER_PMTU 5
-/* number of timer types in the base SCTP
- * structure used in the set/get and has
- * the base default.
- */
-#define SCTP_NUM_TMRS 6
-
-
-
-#define SCTP_IPV4_ADDRESS 2
-#define SCTP_IPV6_ADDRESS 4
-
-/* timer types */
-#define SctpTimerTypeNone 0
-#define SctpTimerTypeSend 1
-#define SctpTimerTypeInit 2
-#define SctpTimerTypeRecv 3
-#define SctpTimerTypeShutdown 4
-#define SctpTimerTypeHeartbeat 5
-#define SctpTimerTypeCookie 6
-#define SctpTimerTypeNewCookie 7
-#define SctpTimerTypePathMtuRaise 8
-#define SctpTimerTypeShutdownAck 9
-#define SctpTimerTypeRelReq 10
-
-/* Here are the timer directives given to the
- * user provided function
- */
-#define SCTP_TIMER_START 1
-#define SCTP_TIMER_STOP 2
-
-/* running flag states in timer structure */
-#define SCTP_TIMER_IDLE 0x0
-#define SCTP_TIMER_EXPIRED 0x1
-#define SCTP_TIMER_RUNNING 0x2
-
-
-/* number of simultaneous timers running */
-#define SCTP_MAX_NET_TIMERS 6 /* base of where net timers start */
-#define SCTP_NUMBER_TIMERS 12 /* allows up to 6 destinations */
-
-
-/* Of course we really don't collect stale cookies, being
- * folks of decerning taste. However we do count them, if
- * we get to many before the association comes up.. we
- * give up. Below is the constant that dictates when
- * we give it up...this is a implemenation dependant
- * treatment. In ours we do not ask for a extension of
- * time, but just retry this many times...
- */
-#define SCTP_MAX_STALE_COOKIES_I_COLLECT 10
-
-/* max number of TSN's dup'd that I will hold */
-#define SCTP_MAX_DUP_TSNS 20
-
-/* Here we define the types used when
- * setting the retry ammounts.
- */
-/* constants for type of set */
-#define SCTP_MAXATTEMPT_INIT 2
-#define SCTP_MAXATTEMPT_SEND 3
-
-/* Here we define the default timers and the
- * default number of attemts we make for
- * each respective side (send/init).
- */
-
-/* init timer def = 3sec */
-#define SCTP_INIT_SEC 3
-#define SCTP_INIT_NSEC 0
-
-/* send timer def = 3 seconds */
-#define SCTP_SEND_SEC 1
-#define SCTP_SEND_NSEC 0
-
-/* recv timer def = 200ms (in nsec) */
-#define SCTP_RECV_SEC 0
-#define SCTP_RECV_NSEC 200000000
-
-/* 30 seconds + RTO */
-#define SCTP_HB_SEC 30
-#define SCTP_HB_NSEC 0
-
-
-/* 300 ms */
-#define SCTP_SHUTDOWN_SEC 0
-#define SCTP_SHUTDOWN_NSEC 300000000
-
-#define SCTP_RTO_UPPER_BOUND 60000000 /* 60 sec in micro-second's */
-#define SCTP_RTO_UPPER_BOUND_SEC 60 /* for the init timer */
-#define SCTP_RTO_LOWER_BOUND 1000000 /* 1 sec in micro-sec's */
-
-#define SCTP_DEF_MAX_INIT 8
-#define SCTP_DEF_MAX_SEND 10
-
-#define SCTP_DEF_PMTU_RAISE 600 /* 10 Minutes between raise attempts */
-#define SCTP_DEF_PMTU_MIN 600
-
-#define SCTP_MSEC_IN_A_SEC 1000
-#define SCTP_USEC_IN_A_SEC 1000000
-#define SCTP_NSEC_IN_A_SEC 1000000000
-
-
-/* Events that SCTP will look for, these
- * are or'd together to declare what SCTP
- * wants. Each select mask/poll list should be
- * set for the fd, if the bit is on.
- */
-#define SCTP_EVENT_READ 0x000001
-#define SCTP_EVENT_WRITE 0x000002
-#define SCTP_EVENT_EXCEPT 0x000004
-
-/* The following constant is a value for this
- * particular implemenation. It is quite arbitrary and
- * is used to limit how much data will be queued up to
- * a sender, waiting for cwnd to be larger than flightSize.
- * All implementations will need this protection is some
- * way due to buffer size constraints.
- */
-
-#define SCTP_MAX_OUTSTANDING_DG 10000
-
-
-
-/* This constant (SCTP_MAX_READBUFFER) define
- * how big the read/write buffer is
- * when we enter the fd event notification
- * the buffer is put on the stack, so the bigger
- * it is the more stack you chew up, however it
- * has got to be big enough to handle the bigest
- * message this O/S will send you. In solaris
- * with sockets (not TLI) we end up at a value
- * of 64k. In TLI we could do partial reads to
- * get it all in with less hassel.. but we
- * write to sockets for generality.
- */
-#define SCTP_MAX_READBUFFER 65536
-#define SCTP_ADDRMAX 60
-
-/* amount peer is obligated to have in rwnd or
- * I will abort
- */
-#define SCTP_MIN_RWND 1500
-
-#define SCTP_WINDOW_MIN 1500 /* smallest rwnd can be */
-#define SCTP_WINDOW_MAX 1048576 /* biggest I can grow rwnd to
- * My playing around suggests a
- * value greater than 64k does not
- * do much, I guess via the kernel
- * limitations on the stream/socket.
- */
-
-#define SCTP_MAX_BUNDLE_UP 256 /* max number of chunks I can bundle */
-
-/* I can handle a 1meg re-assembly */
-#define SCTP_DEFAULT_MAXMSGREASM 1048576
-
-
-#define SCTP_DEFAULT_MAXWINDOW 32768 /* default rwnd size */
-#define SCTP_DEFAULT_MAXSEGMENT 1500 /* MTU size, this is the default
- * to which we set the smallestMTU
- * size to. This governs what is the
- * largest size we will use, of course
- * PMTU will raise this up to
- * the largest interface MTU or the
- * ceiling below if there is no
- * SIOCGIFMTU.
- */
-#ifdef LYNX
-#define DEFAULT_MTU_CEILING 1500 /* Since Lynx O/S is brain dead
- * in the way it handles the
- * raw IP socket, insisting
- * on makeing its own IP
- * header, we limit the growth
- * to that of the e-net size
- */
-#else
-#define DEFAULT_MTU_CEILING 2048 /* If no SIOCGIFMTU, highest value
- * to raise the PMTU to, i.e.
- * don't try to raise above this
- * value. Tune this per your
- * largest MTU interface if your
- * system does not support the
- * SIOCGIFMTU ioctl.
- */
-#endif
-#define SCTP_DEFAULT_MINSEGMENT 512 /* MTU size ... if no mtu disc */
-#define SCTP_HOW_MANY_SECRETS 2 /* how many secrets I keep */
-/* This is how long a secret lives, NOT how long a cookie lives */
-#define SCTP_HOW_LONG_COOKIE_LIVE 3600 /* how many seconds the current secret will live */
-
-#define SCTP_NUMBER_OF_SECRETS 8 /* or 8 * 4 = 32 octets */
-#define SCTP_SECRET_SIZE 32 /* number of octets in a 256 bits */
-
-#ifdef USE_MD5
-#define SCTP_SIGNATURE_SIZE 16 /* size of a MD5 signature */
-#else
-#define SCTP_SIGNATURE_SIZE 20 /* size of a SLA-1 signature */
-#endif
-/* Here are the notification constants
- * that the code and upper layer will get
- */
-
-/* association is up */
-#define SCTP_NOTIFY_ASSOC_UP 1
-
-/* association is down */
-#define SCTP_NOTIFY_ASSOC_DOWN 2
-
-/* interface on a association is down
- * and out of consideration for selection.
- */
-#define SCTP_NOTIFY_INTF_DOWN 3
-
-/* interface on a association is up
- * and now back in consideration for selection.
- */
-#define SCTP_NOTIFY_INTF_UP 4
-
-/* The given datagram cannot be delivered
- * to the peer, this will probably be followed
- * by a SCTP_NOTFIY_ASSOC_DOWN.
- */
-#define SCTP_NOTIFY_DG_FAIL 5
-
-/* Sent dg on non-open stream extreme code error!
- */
-#define SCTP_NOTIFY_STRDATA_ERR 6
-
-#define SCTP_NOTIFY_ASSOC_ABORTED 7
-
-/* The stream ones are not used yet, but could
- * be when a association opens.
- */
-#define SCTP_NOTIFY_PEER_OPENED_STR 8
-#define SCTP_NOTIFY_STREAM_OPENED_OK 9
-
-/* association sees a restart event */
-#define SCTP_NOTIFY_ASSOC_RESTART 10
-
-/* a user requested HB returned */
-#define SCTP_NOTIFY_HB_RESP 11
-
-/* a result from a REL-REQ */
-#define SCTP_NOTIFY_RELREQ_RESULT_OK 12
-#define SCTP_NOTIFY_RELREQ_RESULT_FAILED 13
-
-/* clock variance is 10ms or 10,000 us's */
-#define SCTP_CLOCK_GRAINULARITY 10000
-
-#define IP_HDR_SIZE 40 /* we use the size of a IP6 header here
- * this detracts a small amount for ipv4
- * but it simplifies the ipv6 addition
- */
-
-#define SCTP_NUM_FDS 3
-
-/* raw IP filedescriptor */
-#define SCTP_FD_IP 0
-/* raw ICMP filedescriptor */
-#define SCTP_FD_ICMP 1
-/* processes contact me for requests here */
-#define SCTP_REQUEST 2
-
-
-#define SCTP_DEAMON_PORT 9899
-
-/* Deamon registration message types/responses */
-#define DEAMON_REGISTER 0x01
-#define DEAMON_REGISTER_ACK 0x02
-#define DEAMON_DEREGISTER 0x03
-#define DEAMON_DEREGISTER_ACK 0x04
-#define DEAMON_CHECKADDR_LIST 0x05
-
-#define DEAMON_MAGIC_VER_LEN 0xff
-
-/* max times I will attempt to send a message to deamon */
-#define SCTP_MAX_ATTEMPTS_AT_DEAMON 5
-#define SCTP_TIMEOUT_IN_POLL_FOR_DEAMON 1500 /* 1.5 seconds */
-
-/* modular comparison */
-/* True if a > b (mod = M) */
-#define compare_with_wrap(a, b, M) ((a > b) && ((a - b) < (M >> 1))) || \
- ((b > a) && ((b - a) > (M >> 1)))
-
-#ifndef TIMEVAL_TO_TIMESPEC
-#define TIMEVAL_TO_TIMESPEC(tv, ts) \
-{ \
- (ts)->tv_sec = (tv)->tv_sec; \
- (ts)->tv_nsec = (tv)->tv_usec * 1000; \
-}
-#endif
-
-/* pegs */
-#define SCTP_NUMBER_OF_PEGS 21
-/* peg index's */
-#define SCTP_PEG_SACKS_SEEN 0
-#define SCTP_PEG_SACKS_SENT 1
-#define SCTP_PEG_TSNS_SENT 2
-#define SCTP_PEG_TSNS_RCVD 3
-#define SCTP_DATAGRAMS_SENT 4
-#define SCTP_DATAGRAMS_RCVD 5
-#define SCTP_RETRANTSN_SENT 6
-#define SCTP_DUPTSN_RECVD 7
-#define SCTP_HBR_RECV 8
-#define SCTP_HBA_RECV 9
-#define SCTP_HB_SENT 10
-#define SCTP_DATA_DG_SENT 11
-#define SCTP_DATA_DG_RECV 12
-#define SCTP_TMIT_TIMER 13
-#define SCTP_RECV_TIMER 14
-#define SCTP_HB_TIMER 15
-#define SCTP_FAST_RETRAN 16
-#define SCTP_PEG_TSNS_READ 17
-#define SCTP_NONE_LFT_TO 18
-#define SCTP_NONE_LFT_RWND 19
-#define SCTP_NONE_LFT_CWND 20
-
-
-
-#endif
-
diff --git a/contrib/tcpdump/sctpHeader.h b/contrib/tcpdump/sctpHeader.h
deleted file mode 100644
index 63f30b5d834a..000000000000
--- a/contrib/tcpdump/sctpHeader.h
+++ /dev/null
@@ -1,323 +0,0 @@
-/* @(#) $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
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 4. Neither the name of Cisco nor of Motorola may be used
- * to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This file is part of the SCTP reference Implementation
- *
- *
- * Please send any bug reports or fixes you make to one of the following email
- * addresses:
- *
- * rstewar1@email.mot.com
- * kmorneau@cisco.com
- * qxie1@email.mot.com
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorperated into the next SCTP release.
- */
-
-
-#ifndef __sctpHeader_h__
-#define __sctpHeader_h__
-
-#include <sctpConstants.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* the sctp common header */
-
-#ifdef TRU64
- #define _64BITS 1
-#endif
-
-struct sctpHeader{
- u_int16_t source;
- u_int16_t destination;
- u_int32_t verificationTag;
- u_int32_t adler32;
-};
-
-/* various descriptor parsers */
-
-struct sctpChunkDesc{
- u_int8_t chunkID;
- u_int8_t chunkFlg;
- u_int16_t chunkLength;
-};
-
-struct sctpParamDesc{
- u_int16_t paramType;
- u_int16_t paramLength;
-};
-
-
-struct sctpRelChunkDesc{
- struct sctpChunkDesc chk;
- u_int32_t serialNumber;
-};
-
-struct sctpVendorSpecificParam {
- struct sctpParamDesc p; /* type must be 0xfffe */
- u_int32_t vendorId; /* vendor ID from RFC 1700 */
- u_int16_t vendorSpecificType;
- u_int16_t vendorSpecificLen;
-};
-
-
-/* Structures for the control parts */
-
-
-
-/* Sctp association init request/ack */
-
-/* this is used for init ack, too */
-struct sctpInitiation{
- u_int32_t initTag; /* tag of mine */
- u_int32_t rcvWindowCredit; /* rwnd */
- u_int16_t NumPreopenStreams; /* OS */
- u_int16_t MaxInboundStreams; /* MIS */
- u_int32_t initialTSN;
- /* optional param's follow in sctpParamDesc form */
-};
-
-struct sctpV4IpAddress{
- struct sctpParamDesc p; /* type is set to SCTP_IPV4_PARAM_TYPE, len=10 */
- u_int32_t ipAddress;
-};
-
-
-struct sctpV6IpAddress{
- struct sctpParamDesc p; /* type is set to SCTP_IPV6_PARAM_TYPE, len=22 */
- u_int8_t ipAddress[16];
-};
-
-struct sctpDNSName{
- struct sctpParamDesc param;
- u_int8_t name[1];
-};
-
-
-struct sctpCookiePreserve{
- struct sctpParamDesc p; /* type is set to SCTP_COOKIE_PRESERVE, len=8 */
- u_int32_t extraTime;
-};
-
-
-struct sctpTimeStamp{
- u_int32_t ts_sec;
- u_int32_t ts_usec;
-};
-
-/* wire structure of my cookie */
-struct cookieMessage{
- u_int32_t TieTag_curTag; /* copied from assoc if present */
- u_int32_t TieTag_hisTag; /* copied from assoc if present */
- int32_t cookieLife; /* life I will award this cookie */
- struct sctpTimeStamp timeEnteringState; /* the time I built cookie */
- struct sctpInitiation initAckISent; /* the INIT-ACK that I sent to my peer */
- u_int32_t addressWhereISent[4]; /* I make this 4 ints so I get 128bits for future */
- int32_t addrtype; /* address type */
- u_int16_t locScope; /* V6 local scope flag */
- u_int16_t siteScope; /* V6 site scope flag */
- /* at the end is tacked on the INIT chunk sent in
- * its entirety and of course our
- * signature.
- */
-};
-
-
-/* this guy is for use when
- * I have a initiate message gloming the
- * things together.
-
- */
-struct sctpUnifiedInit{
- struct sctpChunkDesc uh;
- struct sctpInitiation initm;
-};
-
-struct sctpSendableInit{
- struct sctpHeader mh;
- struct sctpUnifiedInit msg;
-};
-
-
-/* Selective Acknowledgement
- * has the following structure with
- * a optional ammount of trailing int's
- * on the last part (based on the numberOfDesc
- * field).
- */
-
-struct sctpSelectiveAck{
- u_int32_t highestConseqTSN;
- u_int32_t updatedRwnd;
- u_int16_t numberOfdesc;
- u_int16_t numDupTsns;
-};
-
-struct sctpSelectiveFrag{
- u_int16_t fragmentStart;
- u_int16_t fragmentEnd;
-};
-
-
-struct sctpUnifiedSack{
- struct sctpChunkDesc uh;
- struct sctpSelectiveAck sack;
-};
-
-/* for both RTT request/response the
- * following is sent
- */
-
-struct sctpHBrequest {
- u_int32_t time_value_1;
- u_int32_t time_value_2;
-};
-
-/* here is what I read and respond with to. */
-struct sctpHBunified{
- struct sctpChunkDesc hdr;
- struct sctpParamDesc hb;
-};
-
-
-/* here is what I send */
-struct sctpHBsender{
- struct sctpChunkDesc hdr;
- struct sctpParamDesc hb;
- struct sctpHBrequest rtt;
- int8_t addrFmt[SCTP_ADDRMAX];
- u_int16_t userreq;
-};
-
-
-
-/* for the abort and shutdown ACK
- * we must carry the init tag in the common header. Just the
- * common header is all that is needed with a chunk descriptor.
- */
-struct sctpUnifiedAbort{
- struct sctpChunkDesc uh;
-};
-
-struct sctpUnifiedAbortLight{
- struct sctpHeader mh;
- struct sctpChunkDesc uh;
-};
-
-struct sctpUnifiedAbortHeavy{
- struct sctpHeader mh;
- struct sctpChunkDesc uh;
- u_int16_t causeCode;
- u_int16_t causeLen;
-};
-
-/* For the graceful shutdown we must carry
- * the tag (in common header) and the highest consequitive acking value
- */
-struct sctpShutdown {
- u_int32_t TSN_Seen;
-};
-
-struct sctpUnifiedShutdown{
- struct sctpChunkDesc uh;
- struct sctpShutdown shut;
-};
-
-/* in the unified message we add the trailing
- * stream id since it is the only message
- * that is defined as a operation error.
- */
-struct sctpOpErrorCause{
- u_int16_t cause;
- u_int16_t causeLen;
-};
-
-struct sctpUnifiedOpError{
- struct sctpChunkDesc uh;
- struct sctpOpErrorCause c;
-};
-
-struct sctpUnifiedStreamError{
- struct sctpHeader mh;
- struct sctpChunkDesc uh;
- struct sctpOpErrorCause c;
- u_int16_t strmNum;
- u_int16_t reserved;
-};
-
-struct staleCookieMsg{
- struct sctpHeader mh;
- struct sctpChunkDesc uh;
- struct sctpOpErrorCause c;
- u_int32_t moretime;
-};
-
-/* the following is used in all sends
- * where nothing is needed except the
- * chunk/type i.e. shutdownAck Abort */
-
-struct sctpUnifiedSingleMsg{
- struct sctpHeader mh;
- struct sctpChunkDesc uh;
-};
-
-struct sctpDataPart{
- u_int32_t TSN;
- u_int16_t streamId;
- u_int16_t sequence;
- u_int32_t payloadtype;
-};
-
-struct sctpUnifiedDatagram{
- struct sctpChunkDesc uh;
- struct sctpDataPart dp;
-};
-
-struct sctpECN_echo{
- struct sctpChunkDesc uh;
- u_int32_t Lowest_TSN;
-};
-
-
-struct sctpCWR{
- struct sctpChunkDesc uh;
- u_int32_t TSN_reduced_at;
-};
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/contrib/tcpdump/setsignal.c b/contrib/tcpdump/setsignal.c
index a4b59cefe1bb..1bcc032ed22e 100644
--- a/contrib/tcpdump/setsignal.c
+++ b/contrib/tcpdump/setsignal.c
@@ -19,11 +19,6 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#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)";
-#endif
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -78,6 +73,8 @@ RETSIGTYPE
memset(&new, 0, sizeof(new));
new.sa_handler = func;
+ if (sig == SIGCHLD)
+ new.sa_flags = SA_RESTART;
if (sigaction(sig, &new, &old) < 0)
return (SIG_ERR);
return (old.sa_handler);
diff --git a/contrib/tcpdump/setsignal.h b/contrib/tcpdump/setsignal.h
index 984c34073072..91a2048a1622 100644
--- a/contrib/tcpdump/setsignal.h
+++ b/contrib/tcpdump/setsignal.h
@@ -17,8 +17,6 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/setsignal.h,v 1.2 1999-10-07 23:47:13 mcr Exp $ (LBL)
*/
#ifndef setsignal_h
#define setsignal_h
diff --git a/contrib/tcpdump/signature.c b/contrib/tcpdump/signature.c
index c55645fe2bdf..324035fb8b3c 100644
--- a/contrib/tcpdump/signature.c
+++ b/contrib/tcpdump/signature.c
@@ -1,4 +1,4 @@
-/*
+/*
* 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
@@ -11,15 +11,11 @@
* FOR A PARTICULAR PURPOSE.
*
* Functions for signature and digest verification.
- *
+ *
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/signature.c,v 1.2 2008-09-22 20:22:10 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -48,9 +44,10 @@ const struct tok signature_check_values[] = {
* Compute a HMAC MD5 sum.
* Taken from rfc2104, Appendix.
*/
+USES_APPLE_DEPRECATED_API
static void
-signature_compute_hmac_md5(const u_int8_t *text, int text_len, unsigned char *key,
- unsigned int key_len, u_int8_t *digest)
+signature_compute_hmac_md5(const uint8_t *text, int text_len, unsigned char *key,
+ unsigned int key_len, uint8_t *digest)
{
MD5_CTX context;
unsigned char k_ipad[65]; /* inner padding - key XORd with ipad */
@@ -110,6 +107,7 @@ signature_compute_hmac_md5(const u_int8_t *text, int text_len, unsigned char *ke
MD5_Update(&context, digest, 16); /* then results of 1st hash */
MD5_Final(digest, &context); /* finish up 2nd pass */
}
+USES_APPLE_RST
#endif
#ifdef HAVE_LIBCRYPTO
@@ -118,10 +116,11 @@ signature_compute_hmac_md5(const u_int8_t *text, int text_len, unsigned char *ke
* Currently only MD5 is supported.
*/
int
-signature_verify (const u_char *pptr, u_int plen, u_char *sig_ptr)
+signature_verify(netdissect_options *ndo,
+ const u_char *pptr, u_int plen, u_char *sig_ptr)
{
- u_int8_t rcvsig[16];
- u_int8_t sig[16];
+ uint8_t rcvsig[16];
+ uint8_t sig[16];
unsigned int i;
/*
@@ -130,12 +129,12 @@ signature_verify (const u_char *pptr, u_int plen, u_char *sig_ptr)
memcpy(rcvsig, sig_ptr, sizeof(rcvsig));
memset(sig_ptr, 0, sizeof(rcvsig));
- if (!sigsecret) {
+ if (!ndo->ndo_sigsecret) {
return (CANT_CHECK_SIGNATURE);
}
- signature_compute_hmac_md5(pptr, plen, (unsigned char *)sigsecret,
- strlen(sigsecret), sig);
+ signature_compute_hmac_md5(pptr, plen, (unsigned char *)ndo->ndo_sigsecret,
+ strlen(ndo->ndo_sigsecret), sig);
if (memcmp(rcvsig, sig, sizeof(sig)) == 0) {
return (SIGNATURE_VALID);
@@ -143,7 +142,7 @@ signature_verify (const u_char *pptr, u_int plen, u_char *sig_ptr)
} else {
for (i = 0; i < sizeof(sig); ++i) {
- (void)printf("%02x", sig[i]);
+ ND_PRINT((ndo, "%02x", sig[i]));
}
return (SIGNATURE_INVALID);
diff --git a/contrib/tcpdump/signature.h b/contrib/tcpdump/signature.h
index e48b722988aa..a052df866fb8 100644
--- a/contrib/tcpdump/signature.h
+++ b/contrib/tcpdump/signature.h
@@ -1,4 +1,4 @@
-/*
+/*
* 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
@@ -15,7 +15,8 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-/* @(#) $Header: /tcpdump/master/tcpdump/signature.h,v 1.1 2008-08-16 11:36:20 hannes Exp $ (LBL) */
+/* for netdissect_options */
+#include "netdissect.h"
/* signature checking result codes */
#define SIGNATURE_VALID 0
@@ -23,4 +24,4 @@
#define CANT_CHECK_SIGNATURE 2
extern const struct tok signature_check_values[];
-extern int signature_verify (const u_char *, u_int, u_char *);
+extern int signature_verify(netdissect_options *, const u_char *, u_int, u_char *);
diff --git a/contrib/tcpdump/slcompress.h b/contrib/tcpdump/slcompress.h
index d10243a9fd78..644c7559e4a6 100644
--- a/contrib/tcpdump/slcompress.h
+++ b/contrib/tcpdump/slcompress.h
@@ -1,8 +1,6 @@
/*
* Definitions for tcp compression routines.
*
- * @(#) $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
deleted file mode 100644
index aa6402c3b109..000000000000
--- a/contrib/tcpdump/slip.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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 $
- *
- * Copyright (c) 1990 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-/*
- * definitions of the pseudo- link-level header attached to slip
- * packets grabbed by the packet filter (bpf) traffic monitor.
- */
-#define SLIP_HDRLEN 16
-
-#define SLX_DIR 0
-#define SLX_CHDR 1
-#define CHDR_LEN 15
-
-#define SLIPDIR_IN 0
-#define SLIPDIR_OUT 1
diff --git a/contrib/tcpdump/sll.h b/contrib/tcpdump/sll.h
deleted file mode 100644
index 0a34963a5300..000000000000
--- a/contrib/tcpdump/sll.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/*-
- * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from the Stanford/CMU enet packet filter,
- * (net/enet.c) distributed as part of 4.3BSD, and code contributed
- * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
- * Berkeley Laboratory.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/sll.h,v 1.8 2008-05-30 01:37:41 guy Exp $ (LBL)
- */
-
-/*
- * For captures on Linux cooked sockets, we construct a fake header
- * that includes:
- *
- * a 2-byte "packet type" which is one of:
- *
- * LINUX_SLL_HOST packet was sent to us
- * LINUX_SLL_BROADCAST packet was broadcast
- * LINUX_SLL_MULTICAST packet was multicast
- * LINUX_SLL_OTHERHOST packet was sent to somebody else
- * LINUX_SLL_OUTGOING packet was sent *by* us;
- *
- * a 2-byte Ethernet protocol field;
- *
- * a 2-byte link-layer type;
- *
- * a 2-byte link-layer address length;
- *
- * an 8-byte source link-layer address, whose actual length is
- * specified by the previous value.
- *
- * All fields except for the link-layer address are in network byte order.
- *
- * 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@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
- * can be told apart and programs that read them can dissect the
- * packets in them.
- *
- * This structure, and the #defines below, must be the same in the
- * libpcap and tcpdump versions of "sll.h".
- */
-
-/*
- * A DLT_LINUX_SLL fake link-layer header.
- */
-#define SLL_HDR_LEN 16 /* total header length */
-#define SLL_ADDRLEN 8 /* length of address field */
-
-struct sll_header {
- u_int16_t sll_pkttype; /* packet type */
- u_int16_t sll_hatype; /* link-layer address type */
- u_int16_t sll_halen; /* link-layer address length */
- u_int8_t sll_addr[SLL_ADDRLEN]; /* link-layer address */
- u_int16_t sll_protocol; /* protocol */
-};
-
-/*
- * The LINUX_SLL_ values for "sll_pkttype"; these correspond to the
- * PACKET_ values on Linux, but are defined here so that they're
- * available even on systems other than Linux, and so that they
- * don't change even if the PACKET_ values change.
- */
-#define LINUX_SLL_HOST 0
-#define LINUX_SLL_BROADCAST 1
-#define LINUX_SLL_MULTICAST 2
-#define LINUX_SLL_OTHERHOST 3
-#define LINUX_SLL_OUTGOING 4
-
-/*
- * The LINUX_SLL_ values for "sll_protocol"; these correspond to the
- * ETH_P_ values on Linux, but are defined here so that they're
- * available even on systems other than Linux. We assume, for now,
- * that the ETH_P_ values won't change in Linux; if they do, then:
- *
- * if we don't translate them in "pcap-linux.c", capture files
- * won't necessarily be readable if captured on a system that
- * defines ETH_P_ values that don't match these values;
- *
- * if we do translate them in "pcap-linux.c", that makes life
- * unpleasant for the BPF code generator, as the values you test
- * for in the kernel aren't the values that you test for when
- * reading a capture file, so the fixup code run on BPF programs
- * handed to the kernel ends up having to do more work.
- *
- * Add other values here as necessary, for handling packet types that
- * might show up on non-Ethernet, non-802.x networks. (Not all the ones
- * in the Linux "if_ether.h" will, I suspect, actually show up in
- * captures.)
- */
-#define LINUX_SLL_P_802_3 0x0001 /* Novell 802.3 frames without 802.2 LLC header */
-#define LINUX_SLL_P_802_2 0x0004 /* 802.2 frames (not D/I/X Ethernet) */
diff --git a/contrib/tcpdump/smb.h b/contrib/tcpdump/smb.h
index 8eeb303f91a0..88eaa0696422 100644
--- a/contrib/tcpdump/smb.h
+++ b/contrib/tcpdump/smb.h
@@ -1,4 +1,3 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/smb.h,v 1.9 2004-12-28 22:29:44 guy Exp $ (LBL) */
/*
* Copyright (C) Andrew Tridgell 1995-1999
*
@@ -7,7 +6,8 @@
* or later
*/
-#define SMBMIN(a,b) ((a)<(b)?(a):(b))
+/* for netdissect_options */
+#include "netdissect.h"
/* the complete */
#define SMBmkdir 0x00 /* create directory */
@@ -119,4 +119,4 @@
#define PTR_DIFF(p1, p2) ((size_t)(((char *)(p1)) - (char *)(p2)))
/* some protos */
-const u_char *smb_fdata(const u_char *, const char *, const u_char *, int);
+const u_char *smb_fdata(netdissect_options *, const u_char *, const char *, const u_char *, int);
diff --git a/contrib/tcpdump/smbutil.c b/contrib/tcpdump/smbutil.c
index 5eadb4fdb564..1c1742c26dd3 100644
--- a/contrib/tcpdump/smbutil.c
+++ b/contrib/tcpdump/smbutil.c
@@ -6,15 +6,11 @@
* or later
*/
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/smbutil.c,v 1.39 2007-07-15 19:07:39 guy Exp $";
-#endif
-
#include <tcpdump-stdinc.h>
#include <stdio.h>
@@ -25,16 +21,16 @@ static const char rcsid[] _U_ =
#include "extract.h"
#include "smb.h"
-static u_int32_t stringlen;
+static uint32_t stringlen;
extern const u_char *startbuf;
/*
* interpret a 32 bit dos packed date/time to some parameters
*/
static void
-interpret_dos_date(u_int32_t date, struct tm *tp)
+interpret_dos_date(uint32_t date, struct tm *tp)
{
- u_int32_t p0, p1, p2, p3;
+ uint32_t p0, p1, p2, p3;
p0 = date & 0xFF;
p1 = ((date & 0xFF00) >> 8) & 0xFF;
@@ -54,7 +50,7 @@ interpret_dos_date(u_int32_t date, struct tm *tp)
* create a unix date from a dos date
*/
static time_t
-int_unix_date(u_int32_t dos_date)
+int_unix_date(uint32_t dos_date)
{
struct tm t;
@@ -76,7 +72,7 @@ int_unix_date(u_int32_t dos_date)
static time_t
make_unix_date(const u_char *date_ptr)
{
- u_int32_t dos_date = 0;
+ uint32_t dos_date = 0;
dos_date = EXTRACT_LE_32BITS(date_ptr);
@@ -90,7 +86,7 @@ make_unix_date(const u_char *date_ptr)
static time_t
make_unix_date2(const u_char *date_ptr)
{
- u_int32_t x, x2;
+ uint32_t x, x2;
x = EXTRACT_LE_32BITS(date_ptr);
x2 = ((x & 0xFFFF) << 16) | ((x & 0xFFFF0000) >> 16);
@@ -129,14 +125,15 @@ interpret_long_date(const u_char *p)
* we run past the end of the buffer
*/
static int
-name_interpret(const u_char *in, const u_char *maxbuf, char *out)
+name_interpret(netdissect_options *ndo,
+ const u_char *in, const u_char *maxbuf, char *out)
{
int ret;
int len;
if (in >= maxbuf)
return(-1); /* name goes past the end of the buffer */
- TCHECK2(*in, 1);
+ ND_TCHECK2(*in, 1);
len = (*in++) / 2;
*out=0;
@@ -145,7 +142,7 @@ name_interpret(const u_char *in, const u_char *maxbuf, char *out)
return(0);
while (len--) {
- TCHECK2(*in, 2);
+ ND_TCHECK2(*in, 2);
if (in + 1 >= maxbuf)
return(-1); /* name goes past the end of the buffer */
if (in[0] < 'A' || in[0] > 'P' || in[1] < 'A' || in[1] > 'P') {
@@ -169,7 +166,8 @@ trunc:
* find a pointer to a netbios name
*/
static const u_char *
-name_ptr(const u_char *buf, int ofs, const u_char *maxbuf)
+name_ptr(netdissect_options *ndo,
+ const u_char *buf, int ofs, const u_char *maxbuf)
{
const u_char *p;
u_char c;
@@ -177,15 +175,15 @@ name_ptr(const u_char *buf, int ofs, const u_char *maxbuf)
p = buf + ofs;
if (p >= maxbuf)
return(NULL); /* name goes past the end of the buffer */
- TCHECK2(*p, 1);
+ ND_TCHECK2(*p, 1);
c = *p;
/* XXX - this should use the same code that the DNS dissector does */
if ((c & 0xC0) == 0xC0) {
- u_int16_t l;
+ uint16_t l;
- TCHECK2(*p, 2);
+ ND_TCHECK2(*p, 2);
if ((p + 1) >= maxbuf)
return(NULL); /* name goes past the end of the buffer */
l = EXTRACT_16BITS(p) & 0x3FFF;
@@ -196,7 +194,7 @@ name_ptr(const u_char *buf, int ofs, const u_char *maxbuf)
p = buf + l;
if (p >= maxbuf)
return(NULL); /* name goes past the end of the buffer */
- TCHECK2(*p, 1);
+ ND_TCHECK2(*p, 1);
}
return(p);
@@ -208,13 +206,14 @@ trunc:
* extract a netbios name from a buf
*/
static int
-name_extract(const u_char *buf, int ofs, const u_char *maxbuf, char *name)
+name_extract(netdissect_options *ndo,
+ const u_char *buf, int ofs, const u_char *maxbuf, char *name)
{
- const u_char *p = name_ptr(buf, ofs, maxbuf);
+ const u_char *p = name_ptr(ndo, buf, ofs, maxbuf);
if (p == NULL)
return(-1); /* error (probably name going past end of buffer) */
name[0] = '\0';
- return(name_interpret(p, maxbuf, name));
+ return(name_interpret(ndo, p, maxbuf, name));
}
@@ -222,21 +221,22 @@ name_extract(const u_char *buf, int ofs, const u_char *maxbuf, char *name)
* return the total storage length of a mangled name
*/
static int
-name_len(const unsigned char *s, const unsigned char *maxbuf)
+name_len(netdissect_options *ndo,
+ const unsigned char *s, const unsigned char *maxbuf)
{
const unsigned char *s0 = s;
unsigned char c;
if (s >= maxbuf)
return(-1); /* name goes past the end of the buffer */
- TCHECK2(*s, 1);
+ ND_TCHECK2(*s, 1);
c = *s;
if ((c & 0xC0) == 0xC0)
return(2);
while (*s) {
if (s >= maxbuf)
return(-1); /* name goes past the end of the buffer */
- TCHECK2(*s, 1);
+ ND_TCHECK2(*s, 1);
s += (*s) + 1;
}
return(PTR_DIFF(s, s0) + 1);
@@ -246,11 +246,12 @@ trunc:
}
static void
-print_asc(const unsigned char *buf, int len)
+print_asc(netdissect_options *ndo,
+ const unsigned char *buf, int len)
{
int i;
for (i = 0; i < len; i++)
- safeputchar(buf[i]);
+ safeputchar(ndo, buf[i]);
}
static const char *
@@ -271,56 +272,58 @@ name_type_str(int name_type)
}
void
-print_data(const unsigned char *buf, int len)
+print_data(netdissect_options *ndo,
+ const unsigned char *buf, int len)
{
int i = 0;
if (len <= 0)
return;
- printf("[%03X] ", i);
+ ND_PRINT((ndo, "[%03X] ", i));
for (i = 0; i < len; /*nothing*/) {
- TCHECK(buf[i]);
- printf("%02X ", buf[i] & 0xff);
+ ND_TCHECK(buf[i]);
+ ND_PRINT((ndo, "%02X ", buf[i] & 0xff));
i++;
if (i%8 == 0)
- printf(" ");
+ ND_PRINT((ndo, " "));
if (i % 16 == 0) {
- print_asc(&buf[i - 16], 8);
- printf(" ");
- print_asc(&buf[i - 8], 8);
- printf("\n");
+ print_asc(ndo, &buf[i - 16], 8);
+ ND_PRINT((ndo, " "));
+ print_asc(ndo, &buf[i - 8], 8);
+ ND_PRINT((ndo, "\n"));
if (i < len)
- printf("[%03X] ", i);
+ ND_PRINT((ndo, "[%03X] ", i));
}
}
if (i % 16) {
int n;
n = 16 - (i % 16);
- printf(" ");
+ ND_PRINT((ndo, " "));
if (n>8)
- printf(" ");
+ ND_PRINT((ndo, " "));
while (n--)
- printf(" ");
+ ND_PRINT((ndo, " "));
- n = SMBMIN(8, i % 16);
- print_asc(&buf[i - (i % 16)], n);
- printf(" ");
+ n = min(8, i % 16);
+ print_asc(ndo, &buf[i - (i % 16)], n);
+ ND_PRINT((ndo, " "));
n = (i % 16) - n;
if (n > 0)
- print_asc(&buf[i - n], n);
- printf("\n");
+ print_asc(ndo, &buf[i - n], n);
+ ND_PRINT((ndo, "\n"));
}
return;
trunc:
- printf("\n");
- printf("WARNING: Short packet. Try increasing the snap length\n");
+ ND_PRINT((ndo, "\n"));
+ ND_PRINT((ndo, "WARNING: Short packet. Try increasing the snap length\n"));
}
static void
-write_bits(unsigned int val, const char *fmt)
+write_bits(netdissect_options *ndo,
+ unsigned int val, const char *fmt)
{
const char *p = fmt;
int i = 0;
@@ -328,20 +331,21 @@ write_bits(unsigned int val, const char *fmt)
while ((p = strchr(fmt, '|'))) {
size_t l = PTR_DIFF(p, fmt);
if (l && (val & (1 << i)))
- printf("%.*s ", (int)l, fmt);
+ ND_PRINT((ndo, "%.*s ", (int)l, fmt));
fmt = p + 1;
i++;
}
}
-/* convert a UCS2 string into iso-8859-1 string */
+/* convert a UCS-2 string into an ASCII string */
#define MAX_UNISTR_SIZE 1000
static const char *
-unistr(const u_char *s, u_int32_t *len, int use_unicode)
+unistr(netdissect_options *ndo,
+ const u_char *s, uint32_t *len, int use_unicode)
{
static char buf[MAX_UNISTR_SIZE+1];
size_t l = 0;
- u_int32_t strsize;
+ uint32_t strsize;
const u_char *sp;
if (use_unicode) {
@@ -349,7 +353,7 @@ unistr(const u_char *s, u_int32_t *len, int use_unicode)
* Skip padding that puts the string on an even boundary.
*/
if (((s - startbuf) % 2) != 0) {
- TCHECK(s[0]);
+ ND_TCHECK(s[0]);
s++;
}
}
@@ -361,7 +365,7 @@ unistr(const u_char *s, u_int32_t *len, int use_unicode)
sp = s;
if (!use_unicode) {
for (;;) {
- TCHECK(sp[0]);
+ ND_TCHECK(sp[0]);
*len += 1;
if (sp[0] == 0)
break;
@@ -370,7 +374,7 @@ unistr(const u_char *s, u_int32_t *len, int use_unicode)
strsize = *len - 1;
} else {
for (;;) {
- TCHECK2(sp[0], 2);
+ ND_TCHECK2(sp[0], 2);
*len += 2;
if (sp[0] == 0 && sp[1] == 0)
break;
@@ -386,10 +390,10 @@ unistr(const u_char *s, u_int32_t *len, int use_unicode)
}
if (!use_unicode) {
while (strsize != 0) {
- TCHECK(s[0]);
+ ND_TCHECK(s[0]);
if (l >= MAX_UNISTR_SIZE)
break;
- if (isprint(s[0]))
+ if (ND_ISPRINT(s[0]))
buf[l] = s[0];
else {
if (s[0] == 0)
@@ -402,10 +406,10 @@ unistr(const u_char *s, u_int32_t *len, int use_unicode)
}
} else {
while (strsize != 0) {
- TCHECK2(s[0], 2);
+ ND_TCHECK2(s[0], 2);
if (l >= MAX_UNISTR_SIZE)
break;
- if (s[1] == 0 && isprint(s[0])) {
+ if (s[1] == 0 && ND_ISPRINT(s[0])) {
/* It's a printable ASCII character */
buf[l] = s[0];
} else {
@@ -429,8 +433,9 @@ trunc:
}
static const u_char *
-smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
- int unicodestr)
+smb_fdata1(netdissect_options *ndo,
+ const u_char *buf, const char *fmt, const u_char *maxbuf,
+ int unicodestr)
{
int reverse = 0;
const char *attrib_fmt = "READONLY|HIDDEN|SYSTEM|VOLUME|DIR|ARCHIVE|";
@@ -438,15 +443,15 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
while (*fmt && buf<maxbuf) {
switch (*fmt) {
case 'a':
- TCHECK(buf[0]);
- write_bits(buf[0], attrib_fmt);
+ ND_TCHECK(buf[0]);
+ write_bits(ndo, buf[0], attrib_fmt);
buf++;
fmt++;
break;
case 'A':
- TCHECK2(buf[0], 2);
- write_bits(EXTRACT_LE_16BITS(buf), attrib_fmt);
+ ND_TCHECK2(buf[0], 2);
+ write_bits(ndo, EXTRACT_LE_16BITS(buf), attrib_fmt);
buf += 2;
fmt++;
break;
@@ -466,8 +471,8 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
strncpy(bitfmt, fmt, l);
bitfmt[l] = '\0';
fmt = p + 1;
- TCHECK(buf[0]);
- write_bits(buf[0], bitfmt);
+ ND_TCHECK(buf[0]);
+ write_bits(ndo, buf[0], bitfmt);
buf++;
break;
}
@@ -475,7 +480,7 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
case 'P':
{
int l = atoi(fmt + 1);
- TCHECK2(buf[0], l);
+ ND_TCHECK2(buf[0], l);
buf += l;
fmt++;
while (isdigit((unsigned char)*fmt))
@@ -489,9 +494,9 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
case 'b':
{
unsigned int x;
- TCHECK(buf[0]);
+ ND_TCHECK(buf[0]);
x = buf[0];
- printf("%u (0x%x)", x, x);
+ ND_PRINT((ndo, "%u (0x%x)", x, x));
buf += 1;
fmt++;
break;
@@ -499,10 +504,10 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
case 'd':
{
unsigned int x;
- TCHECK2(buf[0], 2);
+ ND_TCHECK2(buf[0], 2);
x = reverse ? EXTRACT_16BITS(buf) :
EXTRACT_LE_16BITS(buf);
- printf("%d (0x%x)", x, x);
+ ND_PRINT((ndo, "%d (0x%x)", x, x));
buf += 2;
fmt++;
break;
@@ -510,21 +515,21 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
case 'D':
{
unsigned int x;
- TCHECK2(buf[0], 4);
+ ND_TCHECK2(buf[0], 4);
x = reverse ? EXTRACT_32BITS(buf) :
EXTRACT_LE_32BITS(buf);
- printf("%d (0x%x)", x, x);
+ ND_PRINT((ndo, "%d (0x%x)", x, x));
buf += 4;
fmt++;
break;
}
case 'L':
{
- u_int64_t x;
- TCHECK2(buf[0], 8);
+ uint64_t x;
+ ND_TCHECK2(buf[0], 8);
x = reverse ? EXTRACT_64BITS(buf) :
EXTRACT_LE_64BITS(buf);
- printf("%" PRIu64 " (0x%" PRIx64 ")", x, x);
+ ND_PRINT((ndo, "%" PRIu64 " (0x%" PRIx64 ")", x, x));
buf += 8;
fmt++;
break;
@@ -532,15 +537,15 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
case 'M':
{
/* Weird mixed-endian length values in 64-bit locks */
- u_int32_t x1, x2;
- u_int64_t x;
- TCHECK2(buf[0], 8);
+ uint32_t x1, x2;
+ uint64_t x;
+ ND_TCHECK2(buf[0], 8);
x1 = reverse ? EXTRACT_32BITS(buf) :
EXTRACT_LE_32BITS(buf);
x2 = reverse ? EXTRACT_32BITS(buf + 4) :
EXTRACT_LE_32BITS(buf + 4);
- x = (((u_int64_t)x1) << 32) | x2;
- printf("%" PRIu64 " (0x%" PRIx64 ")", x, x);
+ x = (((uint64_t)x1) << 32) | x2;
+ ND_PRINT((ndo, "%" PRIu64 " (0x%" PRIx64 ")", x, x));
buf += 8;
fmt++;
break;
@@ -548,9 +553,9 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
case 'B':
{
unsigned int x;
- TCHECK(buf[0]);
+ ND_TCHECK(buf[0]);
x = buf[0];
- printf("0x%X", x);
+ ND_PRINT((ndo, "0x%X", x));
buf += 1;
fmt++;
break;
@@ -558,10 +563,10 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
case 'w':
{
unsigned int x;
- TCHECK2(buf[0], 2);
+ ND_TCHECK2(buf[0], 2);
x = reverse ? EXTRACT_16BITS(buf) :
EXTRACT_LE_16BITS(buf);
- printf("0x%X", x);
+ ND_PRINT((ndo, "0x%X", x));
buf += 2;
fmt++;
break;
@@ -569,10 +574,10 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
case 'W':
{
unsigned int x;
- TCHECK2(buf[0], 4);
+ ND_TCHECK2(buf[0], 4);
x = reverse ? EXTRACT_32BITS(buf) :
EXTRACT_LE_32BITS(buf);
- printf("0x%X", x);
+ ND_PRINT((ndo, "0x%X", x));
buf += 4;
fmt++;
break;
@@ -583,25 +588,25 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
switch (*fmt) {
case 'b':
- TCHECK(buf[0]);
+ ND_TCHECK(buf[0]);
stringlen = buf[0];
- printf("%u", stringlen);
+ ND_PRINT((ndo, "%u", stringlen));
buf += 1;
break;
case 'd':
- TCHECK2(buf[0], 2);
+ ND_TCHECK2(buf[0], 2);
stringlen = reverse ? EXTRACT_16BITS(buf) :
EXTRACT_LE_16BITS(buf);
- printf("%u", stringlen);
+ ND_PRINT((ndo, "%u", stringlen));
buf += 2;
break;
case 'D':
- TCHECK2(buf[0], 4);
+ ND_TCHECK2(buf[0], 4);
stringlen = reverse ? EXTRACT_32BITS(buf) :
EXTRACT_LE_32BITS(buf);
- printf("%u", stringlen);
+ ND_PRINT((ndo, "%u", stringlen));
buf += 4;
break;
}
@@ -613,13 +618,13 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
{
/*XXX unistr() */
const char *s;
- u_int32_t len;
+ uint32_t len;
len = 0;
- s = unistr(buf, &len, (*fmt == 'R') ? 0 : unicodestr);
+ s = unistr(ndo, buf, &len, (*fmt == 'R') ? 0 : unicodestr);
if (s == NULL)
goto trunc;
- printf("%s", s);
+ ND_PRINT((ndo, "%s", s));
buf += len;
fmt++;
break;
@@ -628,18 +633,18 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
case 'Y': /* like 'Z', but always ASCII */
{
const char *s;
- u_int32_t len;
+ uint32_t len;
- TCHECK(*buf);
+ ND_TCHECK(*buf);
if (*buf != 4 && *buf != 2) {
- printf("Error! ASCIIZ buffer of type %u", *buf);
+ ND_PRINT((ndo, "Error! ASCIIZ buffer of type %u", *buf));
return maxbuf; /* give up */
}
len = 0;
- s = unistr(buf + 1, &len, (*fmt == 'Y') ? 0 : unicodestr);
+ s = unistr(ndo, buf + 1, &len, (*fmt == 'Y') ? 0 : unicodestr);
if (s == NULL)
goto trunc;
- printf("%s", s);
+ ND_PRINT((ndo, "%s", s));
buf += len + 1;
fmt++;
break;
@@ -647,8 +652,8 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
case 's':
{
int l = atoi(fmt + 1);
- TCHECK2(*buf, l);
- printf("%-*.*s", l, l, buf);
+ ND_TCHECK2(*buf, l);
+ ND_PRINT((ndo, "%-*.*s", l, l, buf));
buf += l;
fmt++;
while (isdigit((unsigned char)*fmt))
@@ -657,8 +662,8 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
}
case 'c':
{
- TCHECK2(*buf, stringlen);
- printf("%-*.*s", (int)stringlen, (int)stringlen, buf);
+ ND_TCHECK2(*buf, stringlen);
+ ND_PRINT((ndo, "%-*.*s", (int)stringlen, (int)stringlen, buf));
buf += stringlen;
fmt++;
while (isdigit((unsigned char)*fmt))
@@ -668,10 +673,10 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
case 'C':
{
const char *s;
- s = unistr(buf, &stringlen, unicodestr);
+ s = unistr(ndo, buf, &stringlen, unicodestr);
if (s == NULL)
goto trunc;
- printf("%s", s);
+ ND_PRINT((ndo, "%s", s));
buf += stringlen;
fmt++;
break;
@@ -679,9 +684,9 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
case 'h':
{
int l = atoi(fmt + 1);
- TCHECK2(*buf, l);
+ ND_TCHECK2(*buf, l);
while (l--)
- printf("%02x", *buf++);
+ ND_PRINT((ndo, "%02x", *buf++));
fmt++;
while (isdigit((unsigned char)*fmt))
fmt++;
@@ -696,22 +701,22 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
switch (t) {
case 1:
- name_type = name_extract(startbuf, PTR_DIFF(buf, startbuf),
+ name_type = name_extract(ndo, startbuf, PTR_DIFF(buf, startbuf),
maxbuf, nbuf);
if (name_type < 0)
goto trunc;
- len = name_len(buf, maxbuf);
+ len = name_len(ndo, buf, maxbuf);
if (len < 0)
goto trunc;
buf += len;
- printf("%-15.15s NameType=0x%02X (%s)", nbuf, name_type,
- name_type_str(name_type));
+ ND_PRINT((ndo, "%-15.15s NameType=0x%02X (%s)", nbuf, name_type,
+ name_type_str(name_type)));
break;
case 2:
- TCHECK(buf[15]);
+ ND_TCHECK(buf[15]);
name_type = buf[15];
- printf("%-15.15s NameType=0x%02X (%s)", buf, name_type,
- name_type_str(name_type));
+ ND_PRINT((ndo, "%-15.15s NameType=0x%02X (%s)", buf, name_type,
+ name_type_str(name_type)));
buf += 16;
break;
}
@@ -725,11 +730,11 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
time_t t;
struct tm *lt;
const char *tstring;
- u_int32_t x;
+ uint32_t x;
switch (atoi(fmt + 1)) {
case 1:
- TCHECK2(buf[0], 4);
+ ND_TCHECK2(buf[0], 4);
x = EXTRACT_LE_32BITS(buf);
if (x == 0 || x == 0xFFFFFFFF)
t = 0;
@@ -738,7 +743,7 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
buf += 4;
break;
case 2:
- TCHECK2(buf[0], 4);
+ ND_TCHECK2(buf[0], 4);
x = EXTRACT_LE_32BITS(buf);
if (x == 0 || x == 0xFFFFFFFF)
t = 0;
@@ -747,7 +752,7 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
buf += 4;
break;
case 3:
- TCHECK2(buf[0], 8);
+ ND_TCHECK2(buf[0], 8);
t = interpret_long_date(buf);
buf += 8;
break;
@@ -763,33 +768,34 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
tstring = "(Can't convert time)\n";
} else
tstring = "NULL\n";
- printf("%s", tstring);
+ ND_PRINT((ndo, "%s", tstring));
fmt++;
while (isdigit((unsigned char)*fmt))
fmt++;
break;
}
default:
- putchar(*fmt);
+ ND_PRINT((ndo, "%c", *fmt));
fmt++;
break;
}
}
if (buf >= maxbuf && *fmt)
- printf("END OF BUFFER\n");
+ ND_PRINT((ndo, "END OF BUFFER\n"));
return(buf);
trunc:
- printf("\n");
- printf("WARNING: Short packet. Try increasing the snap length\n");
+ ND_PRINT((ndo, "\n"));
+ ND_PRINT((ndo, "WARNING: Short packet. Try increasing the snap length\n"));
return(NULL);
}
const u_char *
-smb_fdata(const u_char *buf, const char *fmt, const u_char *maxbuf,
- int unicodestr)
+smb_fdata(netdissect_options *ndo,
+ const u_char *buf, const char *fmt, const u_char *maxbuf,
+ int unicodestr)
{
static int depth = 0;
char s[128];
@@ -802,7 +808,7 @@ smb_fdata(const u_char *buf, const char *fmt, const u_char *maxbuf,
while (buf < maxbuf) {
const u_char *buf2;
depth++;
- buf2 = smb_fdata(buf, fmt, maxbuf, unicodestr);
+ buf2 = smb_fdata(ndo, buf, fmt, maxbuf, unicodestr);
depth--;
if (buf2 == NULL)
return(NULL);
@@ -841,22 +847,21 @@ smb_fdata(const u_char *buf, const char *fmt, const u_char *maxbuf,
strncpy(s, fmt, p - fmt);
s[p - fmt] = '\0';
fmt = p + 1;
- buf = smb_fdata1(buf, s, maxbuf, unicodestr);
+ buf = smb_fdata1(ndo, buf, s, maxbuf, unicodestr);
if (buf == NULL)
return(NULL);
break;
default:
- putchar(*fmt);
+ ND_PRINT((ndo, "%c", *fmt));
fmt++;
- fflush(stdout);
break;
}
}
if (!depth && buf < maxbuf) {
size_t len = PTR_DIFF(maxbuf, buf);
- printf("Data: (%lu bytes)\n", (unsigned long)len);
- print_data(buf, len);
+ ND_PRINT((ndo, "Data: (%lu bytes)\n", (unsigned long)len));
+ print_data(ndo, buf, len);
return(buf + len);
}
return(buf);
@@ -1008,7 +1013,7 @@ smb_errstr(int class, int num)
}
typedef struct {
- u_int32_t code;
+ uint32_t code;
const char *name;
} nt_err_code_struct;
@@ -1872,7 +1877,7 @@ static const nt_err_code_struct nt_errors[] = {
* return an NT error string from a SMB buffer
*/
const char *
-nt_errstr(u_int32_t err)
+nt_errstr(uint32_t err)
{
static char ret[128];
int i;
diff --git a/contrib/tcpdump/strcasecmp.c b/contrib/tcpdump/strcasecmp.c
index 5504e0aff5a7..7ee4e383deca 100644
--- a/contrib/tcpdump/strcasecmp.c
+++ b/contrib/tcpdump/strcasecmp.c
@@ -14,11 +14,6 @@
#include "config.h"
#endif
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/strcasecmp.c,v 1.6 2003-11-16 09:36:43 guy Exp $";
-#endif
-
#include <tcpdump-stdinc.h>
#include "interface.h"
diff --git a/contrib/tcpdump/tcp.h b/contrib/tcpdump/tcp.h
index 92d505ae1404..3645486099cc 100644
--- a/contrib/tcpdump/tcp.h
+++ b/contrib/tcpdump/tcp.h
@@ -1,4 +1,3 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/tcp.h,v 1.14 2007-12-09 00:30:47 guy Exp $ (LBL) */
/*
* Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved.
@@ -34,22 +33,22 @@
* @(#)tcp.h 8.1 (Berkeley) 6/10/93
*/
-typedef u_int32_t tcp_seq;
+typedef uint32_t tcp_seq;
/*
* TCP header.
* Per RFC 793, September, 1981.
*/
struct tcphdr {
- u_int16_t th_sport; /* source port */
- u_int16_t th_dport; /* destination port */
+ uint16_t th_sport; /* source port */
+ uint16_t th_dport; /* destination port */
tcp_seq th_seq; /* sequence number */
tcp_seq th_ack; /* acknowledgement number */
- u_int8_t th_offx2; /* data offset, rsvd */
- u_int8_t th_flags;
- u_int16_t th_win; /* window */
- u_int16_t th_sum; /* checksum */
- u_int16_t th_urp; /* urgent pointer */
-};
+ uint8_t th_offx2; /* data offset, rsvd */
+ uint8_t th_flags;
+ uint16_t th_win; /* window */
+ uint16_t th_sum; /* checksum */
+ uint16_t th_urp; /* urgent pointer */
+} UNALIGNED;
#define TH_OFF(th) (((th)->th_offx2 & 0xf0) >> 4)
@@ -85,7 +84,8 @@ struct tcphdr {
#define TCPOPT_AUTH 20 /* Enhanced AUTH option */
#define TCPOPT_UTO 28 /* tcp user timeout (rfc5482) */
#define TCPOLEN_UTO 4
-
+#define TCPOPT_MPTCP 30 /* MPTCP options */
+#define TCPOPT_EXPERIMENT2 254 /* experimental headers (rfc4727) */
#define TCPOPT_TSTAMP_HDR \
(TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP)
@@ -97,6 +97,12 @@ struct tcphdr {
#define BGP_PORT 179
#endif
#define NETBIOS_SSN_PORT 139
+#ifndef OPENFLOW_PORT_OLD
+#define OPENFLOW_PORT_OLD 6633
+#endif
+#ifndef OPENFLOW_PORT_IANA
+#define OPENFLOW_PORT_IANA 6653
+#endif
#ifndef PPTP_PORT
#define PPTP_PORT 1723
#endif
diff --git a/contrib/tcpdump/tcpdump-stdinc.h b/contrib/tcpdump/tcpdump-stdinc.h
index d350d1be126b..32f8fc920b01 100644
--- a/contrib/tcpdump/tcpdump-stdinc.h
+++ b/contrib/tcpdump/tcpdump-stdinc.h
@@ -27,27 +27,27 @@
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *
- * @(#) $Header: /tcpdump/master/tcpdump/tcpdump-stdinc.h,v 1.18 2007-11-24 18:13:33 mcr Exp $ (LBL)
*/
/*
* Include the appropriate OS header files on Windows and various flavors
- * of UNIX, and also define some additional items and include various
- * non-OS header files on Windows, and; this isolates most of the platform
+ * of UNIX, include various non-OS header files on Windows, and define
+ * various items as needed, to isolate most of tcpdump's platform
* differences to this one file.
*/
#ifndef tcpdump_stdinc_h
#define tcpdump_stdinc_h
+#include <errno.h>
+
#ifdef WIN32
+#include <stdint.h>
#include <stdio.h>
#include <winsock2.h>
-#include <Ws2tcpip.h>
-#include "bittypes.h"
+#include <ws2tcpip.h>
+#include "bittypes.h" /* in wpcap's Win32/include */
#include <ctype.h>
#include <time.h>
#include <io.h>
@@ -55,27 +55,92 @@
#include <sys/types.h>
#include <net/netdb.h> /* in wpcap's Win32/include */
-#ifndef NBBY
-#define NBBY 8
+#ifndef uint8_t
+#define uint8_t unsigned char
+#endif
+
+#ifndef int8_t
+#define int8_t signed char
+#endif
+
+#ifndef uint16_t
+#define uint16_t unsigned short
+#endif
+
+#ifndef int16_t
+#define int16_t signed short
+#endif
+
+#ifndef uint32_t
+#define uint32_t unsigned int
+#endif
+
+#ifndef int32_t
+#define int32_t signed int
+#endif
+
+#ifdef _MSC_EXTENSIONS
+
+#ifndef uint64_t
+#define uint64_t unsigned _int64
+#endif
+
+#ifndef int64_t
+#define int64_t _int64
+#endif
+
+#ifndef PRId64
+#define PRId64 "I64d"
+#endif
+
+#ifndef PRIo64
+#define PRIo64 "I64o"
+#endif
+
+#ifndef PRIu64
+#define PRIu64 "I64u"
+#endif
+
+#ifndef PRIx64
+#define PRIx64 "I64x"
+#endif
+
+#else /* _MSC_EXTENSIONS */
+
+#ifndef uint64_t
+#define uint64_t unsigned long long
+#endif
+
+#ifndef int64_t
+#define int64_t long long
+#endif
+
+#ifndef PRId64
+#define PRId64 "lld"
+#endif
+
+#ifndef PRIo64
+#define PRIo64 "llo"
+#endif
+
+#ifndef PRIu64
+#define PRIu64 "llu"
#endif
-#if !defined(__MINGW32__) && !defined(__WATCOMC__)
-#undef toascii
-#define isascii __isascii
-#define toascii __toascii
+#ifndef PRIx64
+#define PRIx64 "llx"
+#endif
+
+#endif /* _MSC_EXTENSIONS */
+
+#ifdef _MSC_VER
#define stat _stat
#define open _open
#define fstat _fstat
#define read _read
#define close _close
#define O_RDONLY _O_RDONLY
-
-typedef short ino_t;
-#endif /* __MINGW32__ */
-
-#ifdef __MINGW32__
-#include <stdint.h>
-#endif
+#endif /* _MSC_VER */
/* Protos for missing/x.c functions (ideally <missing/addrinfo.h>
* should be used, but it clashes with <ws2tcpip.h>).
@@ -84,12 +149,21 @@ extern const char *inet_ntop (int, const void *, char *, size_t);
extern int inet_pton (int, const char *, void *);
extern int inet_aton (const char *cp, struct in_addr *addr);
+/*
+ * With MSVC, for C, __inline is used to make a function an inline.
+ */
+#ifdef _MSC_VER
+#define inline __inline
+#endif
+
#ifndef INET6_ADDRSTRLEN
#define INET6_ADDRSTRLEN 46
#endif
-#ifndef toascii
-#define toascii(c) ((c) & 0x7f)
+/* It is in MSVC's <errno.h>, but not defined in MingW+Watcom.
+ */
+#ifndef EAFNOSUPPORT
+#define EAFNOSUPPORT WSAEAFNOSUPPORT
#endif
#ifndef caddr_t
@@ -109,14 +183,9 @@ typedef char* caddr_t;
#include <netdb.h>
#if HAVE_INTTYPES_H
#include <inttypes.h>
-#else
-#if HAVE_STDINT_H
+#elif HAVE_STDINT_H
#include <stdint.h>
#endif
-#endif
-#ifdef HAVE_SYS_BITYPES_H
-#include <sys/bitypes.h>
-#endif
#include <sys/param.h>
#include <sys/types.h> /* concession to AIX */
#include <sys/time.h>
@@ -166,7 +235,11 @@ typedef char* caddr_t;
* Note: this also requires that padding be put into the structure,
* at least for compilers where it's implemented as __attribute__((packed)).
*/
+#if !(defined(_MSC_VER) && defined(UNALIGNED))
+/* MSVC may have its own macro defined with the same name and purpose. */
+#undef UNALIGNED
#define UNALIGNED __attribute__((packed))
+#endif
#if defined(WIN32) || defined(MSDOS)
#define FOPEN_READ_TXT "rt"
@@ -180,7 +253,7 @@ typedef char* caddr_t;
#define FOPEN_WRITE_BIN FOPEN_WRITE_TXT
#endif
-#if defined(__GNUC__) && defined(__i386__) && !defined(__APPLE__) && !defined(__ntohl)
+#if defined(__GNUC__) && defined(__i386__) && !defined(__APPLE__) && !defined(__ntohl)
#undef ntohl
#undef ntohs
#undef htonl
@@ -223,4 +296,57 @@ typedef char* caddr_t;
#define FALSE 0
#endif
+/*
+ * The Apple deprecation workaround macros below were adopted from the
+ * FreeRADIUS server code under permission of Alan DeKok and Arran Cudbard-Bell.
+ */
+
+#define XSTRINGIFY(x) #x
+
+/*
+ * Macros for controlling warnings in GCC >= 4.2 and clang >= 2.8
+ */
+#define DIAG_JOINSTR(x,y) XSTRINGIFY(x ## y)
+#define DIAG_DO_PRAGMA(x) _Pragma (#x)
+
+#if defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 402
+# define DIAG_PRAGMA(x) DIAG_DO_PRAGMA(GCC diagnostic x)
+# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406
+# define DIAG_OFF(x) DIAG_PRAGMA(push) DIAG_PRAGMA(ignored DIAG_JOINSTR(-W,x))
+# define DIAG_ON(x) DIAG_PRAGMA(pop)
+# else
+# define DIAG_OFF(x) DIAG_PRAGMA(ignored DIAG_JOINSTR(-W,x))
+# define DIAG_ON(x) DIAG_PRAGMA(warning DIAG_JOINSTR(-W,x))
+# endif
+#elif defined(__clang__) && ((__clang_major__ * 100) + __clang_minor__ >= 208)
+# define DIAG_PRAGMA(x) DIAG_DO_PRAGMA(clang diagnostic x)
+# define DIAG_OFF(x) DIAG_PRAGMA(push) DIAG_PRAGMA(ignored DIAG_JOINSTR(-W,x))
+# define DIAG_ON(x) DIAG_PRAGMA(pop)
+#else
+# define DIAG_OFF(x)
+# define DIAG_ON(x)
+#endif
+
+/*
+ * For dealing with APIs which are only deprecated in OSX (like the OpenSSL API)
+ */
+#ifdef __APPLE__
+# define USES_APPLE_DEPRECATED_API DIAG_OFF(deprecated-declarations)
+# define USES_APPLE_RST DIAG_ON(deprecated-declarations)
+#else
+# define USES_APPLE_DEPRECATED_API
+# define USES_APPLE_RST
+#endif
+
+/*
+ * end of Apple deprecation workaround macros
+ */
+
+#ifndef min
+#define min(a,b) ((a)>(b)?(b):(a))
+#endif
+#ifndef max
+#define max(a,b) ((b)>(a)?(b):(a))
+#endif
+
#endif /* tcpdump_stdinc_h */
diff --git a/contrib/tcpdump/tcpdump.1.in b/contrib/tcpdump/tcpdump.1.in
index cb2fbdd378e9..a96646928b09 100644
--- a/contrib/tcpdump/tcpdump.1.in
+++ b/contrib/tcpdump/tcpdump.1.in
@@ -1,5 +1,3 @@
-.\" @(#) $Header: /tcpdump/master/tcpdump/tcpdump.1.in,v 1.2 2008-11-09 23:35:03 mcr Exp $ (LBL)
-.\"
.\" $NetBSD: tcpdump.8,v 1.9 2003/03/31 00:18:17 perry Exp $
.\"
.\" Copyright (c) 1987, 1988, 1989, 1990, 1991, 1992, 1994, 1995, 1996, 1997
@@ -22,18 +20,21 @@
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
.\"
-.TH TCPDUMP 1 "12 July 2012"
+.TH TCPDUMP 1 "11 July 2014"
.SH NAME
tcpdump \- dump traffic on a network
.SH SYNOPSIS
.na
.B tcpdump
[
-.B \-AbdDefhHIJKlLnNOpqRStuUvxX
+.B \-AbdDefhHIJKlLnNOpqRStuUvxX#
] [
.B \-B
.I buffer_size
-] [
+]
+.br
+.ti +8
+[
.B \-c
.I count
]
@@ -70,6 +71,14 @@ tcpdump \- dump traffic on a network
.br
.ti +8
[
+.B \-\-number
+]
+[
+.B \-Q
+.I in|out|inout
+]
+.ti +8
+[
.B \-r
.I file
]
@@ -117,6 +126,13 @@ tcpdump \- dump traffic on a network
]
.ti +8
[
+.BI \-\-time\-stamp\-precision= tstamp_precision
+]
+[
+.B \-\-version
+]
+.ti +8
+[
.I expression
]
.br
@@ -205,14 +221,18 @@ capturing web pages.
Print the AS number in BGP packets in ASDOT notation rather than ASPLAIN
notation.
.TP
-.B \-B
+.BI \-B " buffer_size"
+.PD 0
+.TP
+.BI \-\-buffer\-size= buffer_size
+.PD
Set the operating system capture buffer size to \fIbuffer_size\fP, in
units of KiB (1024 bytes).
.TP
-.B \-c
+.BI \-c " count"
Exit after receiving \fIcount\fP packets.
.TP
-.B \-C
+.BI \-C " file_size"
Before writing a raw packet to a savefile, check whether the file is
currently larger than \fIfile_size\fP and, if so, close the current
savefile and open a new one. Savefiles after the first savefile will
@@ -235,6 +255,10 @@ program fragment.
Dump packet-matching code as decimal numbers (preceded with a count).
.TP
.B \-D
+.PD 0
+.TP
+.B \-\-list\-interfaces
+.PD
Print the list of the network interfaces available on the system and on
which
.I tcpdump
@@ -314,11 +338,11 @@ because the capture is being done on the Linux "any" interface, which
can capture on more than one interface, this option will not work
correctly.
.TP
-.B \-F
+.BI \-F " file"
Use \fIfile\fP as input for the filter expression.
An additional expression given on the command line is ignored.
.TP
-.B \-G
+.BI \-G " rotate_seconds"
If specified, rotates the dump file specified with the
.B \-w
option every \fIrotate_seconds\fP seconds.
@@ -333,17 +357,29 @@ If used in conjunction with the
option, filenames will take the form of `\fIfile\fP<count>'.
.TP
.B \-h
+.PD 0
+.TP
+.B \-\-help
+.PD
Print the tcpdump and libpcap version strings, print a usage message,
and exit.
.TP
+.B \-\-version
+.PD
+Print the tcpdump and libpcap version strings and exit.
+.TP
.B \-H
Attempt to detect 802.11s draft mesh headers.
.TP
-.B \-i
+.BI \-i " interface"
+.PD 0
+.TP
+.BI \-\-interface= interface
+.PD
Listen on \fIinterface\fP.
If unspecified, \fItcpdump\fP searches the system interface list for the
-lowest numbered, configured up interface (excluding loopback).
-Ties are broken by choosing the earliest match.
+lowest numbered, configured up interface (excluding loopback), which may turn
+out to be, for example, ``eth0''.
.IP
On Linux systems with 2.2 or later kernels, an
.I interface
@@ -359,6 +395,10 @@ used as the
argument.
.TP
.B \-I
+.PD 0
+.TP
+.B \-\-monitor\-mode
+.PD
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
@@ -379,19 +419,50 @@ monitor mode will be shown; if
is specified, only those link-layer types available when in monitor mode
will be shown.
.TP
-.B \-j
+.BI \-j " tstamp_type"
+.PD 0
+.TP
+.BI \-\-time\-stamp\-type= tstamp_type
+.PD
Set the time stamp type for the capture to \fItstamp_type\fP. The names
to use for the time stamp types are given in
-.BR pcap-tstamp-type (@MAN_MISC_INFO@);
+.BR pcap-tstamp (@MAN_MISC_INFO@);
not all the types listed there will necessarily be valid for any given
interface.
.TP
.B \-J
+.PD 0
+.TP
+.B \-\-list\-time\-stamp\-types
+.PD
List the supported time stamp types for the interface and exit. If the
time stamp type cannot be set for the interface, no time stamp types are
listed.
.TP
+.BI \-\-time\-stamp\-precision= tstamp_precision
+When capturing, set the time stamp precision for the capture to
+\fItstamp_precision\fP. Note that availability of high precision time
+stamps (nanoseconds) and their actual accuracy is platform and hardware
+dependent. Also note that when writing captures made with nanosecond
+accuracy to a savefile, the time stamps are written with nanosecond
+resolution, and the file is written with a different magic number, to
+indicate that the time stamps are in seconds and nanoseconds; not all
+programs that read pcap savefiles will be able to read those captures.
+.LP
+When reading a savefile, convert time stamps to the precision specified
+by \fItimestamp_precision\fP, and display them with that resolution. If
+the precision specified is less than the precision of time stamps in the
+file, the conversion will lose precision.
+.LP
+The supported values for \fItimestamp_precision\fP are \fBmicro\fP for
+microsecond resolution and \fBnano\fP for nanosecond resolution. The
+default is microsecond resolution.
+.TP
.B \-K
+.PD 0
+.TP
+.B \-\-dont\-verify\-checksums
+.PD
Don't attempt to verify IP, TCP, or UDP checksums. This is useful for
interfaces that perform some or all of those checksum calculation in
hardware; otherwise, all outgoing TCP checksums will be flagged as bad.
@@ -434,6 +505,10 @@ than at the end of each line; this is buffered on all platforms,
including Windows.
.TP
.B \-L
+.PD 0
+.TP
+.B \-\-list\-data\-link\-types
+.PD
List the known data link types for the interface, in the specified mode,
and exit. The list of known data link types may be dependent on the
specified mode; for example, on some platforms, a Wi-Fi interface might
@@ -444,12 +519,12 @@ and another set of data link types when in monitor mode (for example, it
might support 802.11 headers, or 802.11 headers with radio information,
only in monitor mode).
.TP
-.B \-m
+.BI \-m " module"
Load SMI MIB module definitions from file \fImodule\fR.
This option
can be used several times to load several MIB modules into \fItcpdump\fP.
.TP
-.B \-M
+.BI \-M " secret"
Use \fIsecret\fP as a shared secret for validating the digests found in
TCP segments with the TCP-MD5 option (RFC 2385), if present.
.TP
@@ -462,18 +537,42 @@ E.g.,
if you give this flag then \fItcpdump\fP will print ``nic''
instead of ``nic.ddn.mil''.
.TP
+.B \-#
+.PD 0
+.TP
+.B \-\-number
+.PD
+Print an optional packet number at the beginning of the line.
+.TP
.B \-O
+.PD 0
+.TP
+.B \-\-no\-optimize
+.PD
Do not run the packet-matching code optimizer.
This is useful only
if you suspect a bug in the optimizer.
.TP
.B \-p
+.PD 0
+.TP
+.B \-\-no\-promiscuous\-mode
+.PD
\fIDon't\fP put the interface
into promiscuous mode.
Note that the interface might be in promiscuous
mode for some other reason; hence, `-p' cannot be used as an abbreviation for
`ether host {local-hw-addr} or ether broadcast'.
.TP
+.BI \-Q " direction"
+.PD 0
+.TP
+.BI \-\-direction= direction
+.PD
+Choose send/receive direction \fIdirection\fR for which packets should be
+captured. Possible values are `in', `out' and `inout'. Not available
+on all platforms.
+.TP
.B \-q
Quick (quiet?) output.
Print less protocol information so output
@@ -485,16 +584,24 @@ If specified, \fItcpdump\fP will not print replay prevention field.
Since there is no protocol version field in ESP/AH specification,
\fItcpdump\fP cannot deduce the version of ESP/AH protocol.
.TP
-.B \-r
+.BI \-r " file"
Read packets from \fIfile\fR (which was created with the
.B \-w
-option).
+option or by other tools that write pcap or pcap-ng files).
Standard input is used if \fIfile\fR is ``-''.
.TP
.B \-S
+.PD 0
+.TP
+.B \-\-absolute\-tcp\-sequence\-numbers
+.PD
Print absolute, rather than relative, TCP sequence numbers.
.TP
-.B \-s
+.BI \-s " snaplen"
+.PD 0
+.TP
+.BI \-\-snapshot\-length= snaplen
+.PD
Snarf \fIsnaplen\fP bytes of data from each packet rather than the
default of 65535 bytes.
Packets truncated because of a limited snapshot
@@ -512,13 +619,16 @@ Setting
for backwards compatibility with recent older versions of
.IR tcpdump .
.TP
-.B \-T
+.BI \-T " type"
Force packets selected by "\fIexpression\fP" to be interpreted the
specified \fItype\fR.
Currently known types are
\fBaodv\fR (Ad-hoc On-demand Distance Vector protocol),
\fBcarp\fR (Common Address Redundancy Protocol),
\fBcnfp\fR (Cisco NetFlow protocol),
+\fBlmp\fR (Link Management Protocol),
+\fBpgm\fR (Pragmatic General Multicast),
+\fBpgm_zmtp1\fR (ZMTP/1.0 inside PGM/EPGM),
\fBradius\fR (RADIUS),
\fBrpc\fR (Remote Procedure Call),
\fBrtp\fR (Real-Time Applications protocol),
@@ -530,6 +640,16 @@ Currently known types are
\fBzmtp1\fR (ZeroMQ Message Transport Protocol 1.0)
and
\fBvxlan\fR (Virtual eXtensible Local Area Network).
+.IP
+Note that the \fBpgm\fR type above affects UDP interpretation only, the native
+PGM is always recognised as IP protocol 113 regardless. UDP-encapsulated PGM is
+often called "EPGM" or "PGM/UDP".
+.IP
+Note that the \fBpgm_zmtp1\fR type above affects interpretation of both native
+PGM and UDP at once. During the native PGM decoding the application data of an
+ODATA/RDATA packet would be decoded as a ZeroMQ datagram with ZMTP/1.0 frames.
+During the UDP decoding in addition to that any UDP packet would be treated as
+an encapsulated PGM packet.
.TP
.B \-t
\fIDon't\fP print a timestamp on each dump line.
@@ -552,6 +672,10 @@ on each dump line.
Print undecoded NFS handles.
.TP
.B \-U
+.PD 0
+.TP
+.B \-\-packet\-buffered
+.PD
If the
.B \-w
option is not specified, make the printed packet output
@@ -602,11 +726,11 @@ With
.B \-X
Telnet options are printed in hex as well.
.TP
-.B \-V
+.BI \-V " file"
Read a list of filenames from \fIfile\fR. Standard input is used
if \fIfile\fR is ``-''.
.TP
-.B \-w
+.BI \-w " file"
Write the raw packets to \fIfile\fR rather than parsing and printing
them out.
They can later be printed with the \-r option.
@@ -679,10 +803,14 @@ each packet,
.I including
its link level header, in hex and ASCII.
.TP
-.B \-y
+.BI \-y " datalinktype"
+.PD 0
+.TP
+.BI \-\-linktype= datalinktype
+.PD
Set the data link type to use while capturing packets to \fIdatalinktype\fP.
.TP
-.B \-z
+.BI \-z " postrotate-command"
Used in conjunction with the
.B -C
or
@@ -690,7 +818,7 @@ or
options, this will make
.I tcpdump
run "
-.I command file
+.I postrotate-command file
" where
.I file
is the savefile being closed after each rotation. For example, specifying
@@ -707,7 +835,11 @@ 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
+.BI \-Z " user"
+.PD 0
+.TP
+.BI \-\-relinquish\-privileges= user
+.PD
If
.I tcpdump
is running as root, after opening the capture device or input savefile,
@@ -728,8 +860,8 @@ only packets for which \fIexpression\fP is `true' will be dumped.
For the \fIexpression\fP syntax, see
.BR pcap-filter (@MAN_MISC_INFO@).
.LP
-Expression arguments can be passed to \fItcpdump\fP as either a single
-argument or as multiple arguments, whichever is more convenient.
+The \fIexpression\fP argument can be passed to \fItcpdump\fP as either a single
+Shell argument, or as multiple Shell arguments, whichever is more convenient.
Generally, if the expression contains Shell metacharacters, such as
backslashes used to escape protocol names, it is easier to pass it as
a single, quoted argument rather than to escape the Shell
@@ -1389,39 +1521,45 @@ Sun NFS (Network File System) requests and replies are printed as:
.RS
.nf
.sp .5
-\fIsrc.xid > dst.nfs: len op args\fP
-\fIsrc.nfs > dst.xid: reply stat len op results\fP
+\fIsrc.sport > dst.nfs: NFS request xid xid len op args\fP
+\fIsrc.nfs > dst.dport: NFS reply xid xid reply stat len op results\fP
.sp .5
\f(CW
-sushi.6709 > wrl.nfs: 112 readlink fh 21,24/10.73165
-wrl.nfs > sushi.6709: reply ok 40 readlink "../var"
-sushi.201b > wrl.nfs:
+sushi.1023 > wrl.nfs: NFS request xid 26377
+ 112 readlink fh 21,24/10.73165
+wrl.nfs > sushi.1023: NFS reply xid 26377
+ reply ok 40 readlink "../var"
+sushi.1022 > wrl.nfs: NFS request xid 8219
144 lookup fh 9,74/4096.6878 "xcolors"
-wrl.nfs > sushi.201b:
+wrl.nfs > sushi.1022: NFS reply xid 8219
reply ok 128 lookup fh 9,74/4134.3150
\fR
.sp .5
.fi
.RE
-In the first line, host \fIsushi\fP sends a transaction with id \fI6709\fP
-to \fIwrl\fP (note that the number following the src host is a
-transaction id, \fInot\fP the source port).
+In the first line, host \fIsushi\fP sends a transaction with id \fI26377\fP
+to \fIwrl\fP.
The request was 112 bytes,
excluding the UDP and IP headers.
The operation was a \fIreadlink\fP
(read symbolic link) on file handle (\fIfh\fP) 21,24/10.731657119.
(If one is lucky, as in this case, the file handle can be interpreted
as a major,minor device number pair, followed by the inode number and
-generation number.)
-\fIWrl\fP replies `ok' with the contents of the link.
+generation number.) In the second line, \fIwrl\fP replies `ok' with
+the same transaction id and the contents of the link.
+.LP
+In the third line, \fIsushi\fP asks (using a new transaction id) \fIwrl\fP
+to lookup the name `\fIxcolors\fP' in directory file 9,74/4096.6878. In
+the fourth line, \fIwrl\fP sends a reply with the respective transaction id.
.LP
-In the third line, \fIsushi\fP asks \fIwrl\fP to lookup the name
-`\fIxcolors\fP' in directory file 9,74/4096.6878.
Note that the data printed
depends on the operation type.
The format is intended to be self
explanatory if read in conjunction with
an NFS protocol spec.
+Also note that older versions of tcpdump printed NFS packets in a
+slightly different format: the transaction id (xid) would be printed
+instead of the non-NFS port number of the packet.
.LP
If the \-v (verbose) flag is given, additional information is printed.
For example:
@@ -1429,9 +1567,9 @@ For example:
.nf
.sp .5
\f(CW
-sushi.1372a > wrl.nfs:
+sushi.1023 > wrl.nfs: NFS request xid 79658
148 read fh 21,11/12.195 8192 bytes @ 24576
-wrl.nfs > sushi.1372a:
+wrl.nfs > sushi.1023: NFS reply xid 79658
reply ok 1472 read REG 100664 ids 417/0 sz 29388
\fP
.sp .5
@@ -1734,7 +1872,7 @@ Ethernet interface removed the packet from the wire and when the kernel
serviced the `new packet' interrupt.
.SH "SEE ALSO"
stty(1), pcap(3PCAP), bpf(4), nit(4P), pcap-savefile(@MAN_FILE_FORMATS@),
-pcap-filter(@MAN_MISC_INFO@), pcap-tstamp-type(@MAN_MISC_INFO@)
+pcap-filter(@MAN_MISC_INFO@), pcap-tstamp(@MAN_MISC_INFO@)
.LP
.RS
.I http://www.iana.org/assignments/media-types/application/vnd.tcpdump.pcap
diff --git a/contrib/tcpdump/tcpdump.c b/contrib/tcpdump/tcpdump.c
index 7ca2cfe1fe00..9c9609b93257 100644
--- a/contrib/tcpdump/tcpdump.c
+++ b/contrib/tcpdump/tcpdump.c
@@ -29,8 +29,6 @@
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.283 2008-09-25 21:45:50 guy Exp $ (LBL)";
#endif
/* $FreeBSD$ */
@@ -50,7 +48,6 @@ static const char rcsid[] _U_ =
#include <tcpdump-stdinc.h>
#ifdef WIN32
-#include "getopt.h"
#include "w32_fzs.h"
extern int strcasecmp (const char *__s1, const char *__s2);
extern int SIZE_BUF;
@@ -58,10 +55,19 @@ extern int SIZE_BUF;
#define uint UINT
#endif /* WIN32 */
-#ifdef HAVE_SMI_H
+#ifdef USE_LIBSMI
#include <smi.h>
#endif
+#ifdef HAVE_LIBCRYPTO
+#include <openssl/crypto.h>
+#endif
+
+#ifdef HAVE_GETOPT_LONG
+#include <getopt.h>
+#else
+#include "getopt_long.h"
+#endif
#include <pcap.h>
#include <signal.h>
#include <stdio.h>
@@ -70,25 +76,24 @@ extern int SIZE_BUF;
#include <limits.h>
#ifdef __FreeBSD__
#include <sys/capsicum.h>
-#include <sys/ioccom.h>
-#include <sys/types.h>
#include <sys/sysctl.h>
-#include <net/bpf.h>
-#include <fcntl.h>
-#include <libgen.h>
-#ifdef HAVE_LIBCAPSICUM
#include <libcapsicum.h>
#include <libcapsicum_dns.h>
#include <libcapsicum_service.h>
#include <nv.h>
-#endif /* HAVE_LIBCAPSICUM */
-#endif /* __FreeBSD__ */
+#endif /* __FreeBSD__ */
+#ifdef HAVE_CAPSICUM
+#include <sys/capability.h>
+#include <sys/ioccom.h>
+#include <net/bpf.h>
+#include <fcntl.h>
+#include <libgen.h>
+#endif /* HAVE_CAPSICUM */
#ifndef WIN32
#include <sys/wait.h>
#include <sys/resource.h>
#include <pwd.h>
#include <grp.h>
-#include <errno.h>
#endif /* WIN32 */
/* capabilities convinience library */
@@ -117,11 +122,15 @@ extern int SIZE_BUF;
netdissect_options Gndo;
netdissect_options *gndo = &Gndo;
+static int Dflag; /* list available devices and exit */
static int dflag; /* print filter code */
static int Lflag; /* list available data link types and exit */
#ifdef HAVE_PCAP_SET_TSTAMP_TYPE
static int Jflag; /* list available time stamp types */
#endif
+#ifdef HAVE_PCAP_SETDIRECTION
+int Qflag = -1; /* restrict captured packet by send/receive direction */
+#endif
static char *zflag = NULL; /* compress each savefile using a specified command (like gzip or bzip2) */
static int infodelay;
@@ -129,7 +138,7 @@ static int infoprint;
char *program_name;
-#ifdef HAVE_LIBCAPSICUM
+#ifdef HAVE_CAPSICUM
cap_channel_t *capdns;
#endif
@@ -138,7 +147,8 @@ 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 print_version(void);
+static void print_usage(void);
static void show_dlts_and_exit(const char *device, pcap_t *pd) __attribute__((noreturn));
static void print_packet(u_char *, const struct pcap_pkthdr *, const u_char *);
@@ -147,8 +157,16 @@ static void dump_packet_and_trunc(u_char *, const struct pcap_pkthdr *, const u_
static void dump_packet(u_char *, const struct pcap_pkthdr *, const u_char *);
static void droproot(const char *, const char *);
static void ndo_error(netdissect_options *ndo, const char *fmt, ...)
- __attribute__ ((noreturn, format (printf, 2, 3)));
-static void ndo_warning(netdissect_options *ndo, const char *fmt, ...);
+ __attribute__((noreturn))
+#ifdef __ATTRIBUTE___FORMAT_OK
+ __attribute__((format (printf, 2, 3)))
+#endif /* __ATTRIBUTE___FORMAT_OK */
+ ;
+static void ndo_warning(netdissect_options *ndo, const char *fmt, ...)
+#ifdef __ATTRIBUTE___FORMAT_OK
+ __attribute__((format (printf, 2, 3)))
+#endif /* __ATTRIBUTE___FORMAT_OK */
+ ;
#ifdef SIGNAL_REQ_INFO
RETSIGTYPE requestinfo(int);
@@ -177,14 +195,32 @@ struct ndo_printer {
};
-static struct printer printers[] = {
- { arcnet_if_print, DLT_ARCNET },
-#ifdef DLT_ARCNET_LINUX
- { arcnet_linux_if_print, DLT_ARCNET_LINUX },
+static const struct printer printers[] = {
+ { NULL, 0 },
+};
+
+static const struct ndo_printer ndo_printers[] = {
+ { ether_if_print, DLT_EN10MB },
+#ifdef DLT_IPNET
+ { ipnet_if_print, DLT_IPNET },
#endif
- { token_if_print, DLT_IEEE802 },
-#ifdef DLT_LANE8023
- { lane_if_print, DLT_LANE8023 },
+#ifdef DLT_IEEE802_15_4
+ { ieee802_15_4_if_print, DLT_IEEE802_15_4 },
+#endif
+#ifdef DLT_IEEE802_15_4_NOFCS
+ { ieee802_15_4_if_print, DLT_IEEE802_15_4_NOFCS },
+#endif
+#ifdef DLT_PPI
+ { ppi_if_print, DLT_PPI },
+#endif
+#ifdef DLT_NETANALYZER
+ { netanalyzer_if_print, DLT_NETANALYZER },
+#endif
+#ifdef DLT_NETANALYZER_TRANSPARENT
+ { netanalyzer_transparent_if_print, DLT_NETANALYZER_TRANSPARENT },
+#endif
+#if defined(DLT_NFLOG) && defined(HAVE_PCAP_NFLOG_H)
+ { nflog_if_print, DLT_NFLOG},
#endif
#ifdef DLT_CIP
{ cip_if_print, DLT_CIP },
@@ -192,77 +228,83 @@ static struct printer printers[] = {
#ifdef DLT_ATM_CLIP
{ cip_if_print, DLT_ATM_CLIP },
#endif
- { sl_if_print, DLT_SLIP },
-#ifdef DLT_SLIP_BSDOS
- { sl_bsdos_if_print, DLT_SLIP_BSDOS },
-#endif
- { ppp_if_print, DLT_PPP },
-#ifdef DLT_PPP_WITHDIRECTION
- { ppp_if_print, DLT_PPP_WITHDIRECTION },
-#endif
-#ifdef DLT_PPP_BSDOS
- { ppp_bsdos_if_print, DLT_PPP_BSDOS },
+#ifdef DLT_IP_OVER_FC
+ { ipfc_if_print, DLT_IP_OVER_FC },
#endif
- { fddi_if_print, DLT_FDDI },
{ null_if_print, DLT_NULL },
#ifdef DLT_LOOP
{ null_if_print, DLT_LOOP },
#endif
+#ifdef DLT_APPLE_IP_OVER_IEEE1394
+ { ap1394_if_print, DLT_APPLE_IP_OVER_IEEE1394 },
+#endif
+#if defined(DLT_BLUETOOTH_HCI_H4_WITH_PHDR) && defined(HAVE_PCAP_BLUETOOTH_H)
+ { bt_if_print, DLT_BLUETOOTH_HCI_H4_WITH_PHDR},
+#endif
+#ifdef DLT_LANE8023
+ { lane_if_print, DLT_LANE8023 },
+#endif
+ { arcnet_if_print, DLT_ARCNET },
+#ifdef DLT_ARCNET_LINUX
+ { arcnet_linux_if_print, DLT_ARCNET_LINUX },
+#endif
{ raw_if_print, DLT_RAW },
- { atm_if_print, DLT_ATM_RFC1483 },
+#ifdef DLT_IPV4
+ { raw_if_print, DLT_IPV4 },
+#endif
+#ifdef DLT_IPV6
+ { raw_if_print, DLT_IPV6 },
+#endif
+#ifdef HAVE_PCAP_USB_H
+#ifdef DLT_USB_LINUX
+ { usb_linux_48_byte_print, DLT_USB_LINUX},
+#endif /* DLT_USB_LINUX */
+#ifdef DLT_USB_LINUX_MMAPPED
+ { usb_linux_64_byte_print, DLT_USB_LINUX_MMAPPED},
+#endif /* DLT_USB_LINUX_MMAPPED */
+#endif /* HAVE_PCAP_USB_H */
+#ifdef DLT_SYMANTEC_FIREWALL
+ { symantec_if_print, DLT_SYMANTEC_FIREWALL },
+#endif
#ifdef DLT_C_HDLC
{ chdlc_if_print, DLT_C_HDLC },
#endif
#ifdef DLT_HDLC
{ chdlc_if_print, DLT_HDLC },
#endif
-#ifdef DLT_PPP_SERIAL
- { ppp_hdlc_if_print, DLT_PPP_SERIAL },
-#endif
#ifdef DLT_PPP_ETHER
{ pppoe_if_print, DLT_PPP_ETHER },
#endif
-#ifdef DLT_LINUX_SLL
- { sll_if_print, DLT_LINUX_SLL },
-#endif
-#ifdef DLT_IEEE802_11
- { ieee802_11_if_print, DLT_IEEE802_11},
-#endif
-#ifdef DLT_LTALK
- { ltalk_if_print, DLT_LTALK },
-#endif
#if defined(DLT_PFLOG) && defined(HAVE_NET_PFVAR_H)
{ pflog_if_print, DLT_PFLOG },
#endif
+ { token_if_print, DLT_IEEE802 },
+ { fddi_if_print, DLT_FDDI },
+#ifdef DLT_LINUX_SLL
+ { sll_if_print, DLT_LINUX_SLL },
+#endif
#ifdef DLT_FR
{ fr_if_print, DLT_FR },
#endif
#ifdef DLT_FRELAY
{ fr_if_print, DLT_FRELAY },
#endif
+#ifdef DLT_MFR
+ { mfr_if_print, DLT_MFR },
+#endif
+ { atm_if_print, DLT_ATM_RFC1483 },
#ifdef DLT_SUNATM
{ sunatm_if_print, DLT_SUNATM },
#endif
-#ifdef DLT_IP_OVER_FC
- { ipfc_if_print, DLT_IP_OVER_FC },
-#endif
-#ifdef DLT_PRISM_HEADER
- { prism_if_print, DLT_PRISM_HEADER },
-#endif
-#ifdef DLT_IEEE802_11_RADIO
- { ieee802_11_radio_if_print, DLT_IEEE802_11_RADIO },
-#endif
#ifdef DLT_ENC
{ enc_if_print, DLT_ENC },
#endif
-#ifdef DLT_SYMANTEC_FIREWALL
- { symantec_if_print, DLT_SYMANTEC_FIREWALL },
-#endif
-#ifdef DLT_APPLE_IP_OVER_IEEE1394
- { ap1394_if_print, DLT_APPLE_IP_OVER_IEEE1394 },
+ { sl_if_print, DLT_SLIP },
+#ifdef DLT_SLIP_BSDOS
+ { sl_bsdos_if_print, DLT_SLIP_BSDOS },
#endif
-#ifdef DLT_IEEE802_11_RADIO_AVS
- { ieee802_11_radio_avs_if_print, DLT_IEEE802_11_RADIO_AVS },
+#ifdef DLT_LTALK
+ { ltalk_if_print, DLT_LTALK },
#endif
#ifdef DLT_JUNIPER_ATM1
{ juniper_atm1_print, DLT_JUNIPER_ATM1 },
@@ -309,56 +351,49 @@ static struct printer printers[] = {
#ifdef DLT_JUNIPER_CHDLC
{ juniper_chdlc_print, DLT_JUNIPER_CHDLC },
#endif
-#ifdef DLT_MFR
- { mfr_if_print, DLT_MFR },
+#ifdef DLT_PKTAP
+ { pktap_if_print, DLT_PKTAP },
#endif
-#if defined(DLT_BLUETOOTH_HCI_H4_WITH_PHDR) && defined(HAVE_PCAP_BLUETOOTH_H)
- { bt_if_print, DLT_BLUETOOTH_HCI_H4_WITH_PHDR},
+#ifdef DLT_IEEE802_11_RADIO
+ { ieee802_11_radio_if_print, DLT_IEEE802_11_RADIO },
#endif
-#ifdef HAVE_PCAP_USB_H
-#ifdef DLT_USB_LINUX
- { usb_linux_48_byte_print, DLT_USB_LINUX},
-#endif /* DLT_USB_LINUX */
-#ifdef DLT_USB_LINUX_MMAPPED
- { usb_linux_64_byte_print, DLT_USB_LINUX_MMAPPED},
-#endif /* DLT_USB_LINUX_MMAPPED */
-#endif /* HAVE_PCAP_USB_H */
-#ifdef DLT_IPV4
- { raw_if_print, DLT_IPV4 },
+#ifdef DLT_IEEE802_11
+ { ieee802_11_if_print, DLT_IEEE802_11},
#endif
-#ifdef DLT_IPV6
- { raw_if_print, DLT_IPV6 },
+#ifdef DLT_IEEE802_11_RADIO_AVS
+ { ieee802_11_radio_avs_if_print, DLT_IEEE802_11_RADIO_AVS },
#endif
- { NULL, 0 },
-};
-
-static struct ndo_printer ndo_printers[] = {
- { ether_if_print, DLT_EN10MB },
-#ifdef DLT_IPNET
- { ipnet_if_print, DLT_IPNET },
+#ifdef DLT_PRISM_HEADER
+ { prism_if_print, DLT_PRISM_HEADER },
#endif
-#ifdef DLT_IEEE802_15_4
- { ieee802_15_4_if_print, DLT_IEEE802_15_4 },
+ { ppp_if_print, DLT_PPP },
+#ifdef DLT_PPP_WITHDIRECTION
+ { ppp_if_print, DLT_PPP_WITHDIRECTION },
#endif
-#ifdef DLT_IEEE802_15_4_NOFCS
- { ieee802_15_4_if_print, DLT_IEEE802_15_4_NOFCS },
+#ifdef DLT_PPP_BSDOS
+ { ppp_bsdos_if_print, DLT_PPP_BSDOS },
#endif
-#ifdef DLT_PPI
- { ppi_if_print, DLT_PPI },
+#ifdef DLT_PPP_SERIAL
+ { ppp_hdlc_if_print, DLT_PPP_SERIAL },
#endif
-#ifdef DLT_NETANALYZER
- { netanalyzer_if_print, DLT_NETANALYZER },
+ { NULL, 0 },
+};
+
+static const struct tok status_flags[] = {
+#ifdef PCAP_IF_UP
+ { PCAP_IF_UP, "Up" },
#endif
-#ifdef DLT_NETANALYZER_TRANSPARENT
- { netanalyzer_transparent_if_print, DLT_NETANALYZER_TRANSPARENT },
+#ifdef PCAP_IF_RUNNING
+ { PCAP_IF_RUNNING, "Running" },
#endif
- { NULL, 0 },
+ { PCAP_IF_LOOPBACK, "Loopback" },
+ { 0, NULL }
};
if_printer
lookup_printer(int type)
{
- struct printer *p;
+ const struct printer *p;
for (p = printers; p->f; ++p)
if (type == p->type)
@@ -371,12 +406,36 @@ lookup_printer(int type)
if_ndo_printer
lookup_ndo_printer(int type)
{
- struct ndo_printer *p;
+ const struct ndo_printer *p;
for (p = ndo_printers; p->f; ++p)
if (type == p->type)
return p->f;
+#if defined(DLT_USER2) && defined(DLT_PKTAP)
+ /*
+ * Apple incorrectly chose to use DLT_USER2 for their PKTAP
+ * header.
+ *
+ * We map DLT_PKTAP, whether it's DLT_USER2 as it is on Darwin-
+ * based OSes or the same value as LINKTYPE_PKTAP as it is on
+ * other OSes, to LINKTYPE_PKTAP, so files written with
+ * this version of libpcap for a DLT_PKTAP capture have a link-
+ * layer header type of LINKTYPE_PKTAP.
+ *
+ * However, files written on OS X Mavericks for a DLT_PKTAP
+ * capture have a link-layer header type of LINKTYPE_USER2.
+ * If we don't have a printer for DLT_USER2, and type is
+ * DLT_USER2, we look up the printer for DLT_PKTAP and use
+ * that.
+ */
+ if (type == DLT_USER2) {
+ for (p = ndo_printers; p->f; ++p)
+ if (DLT_PKTAP == p->type)
+ return p->f;
+ }
+#endif
+
return NULL;
/* NOTREACHED */
}
@@ -403,7 +462,7 @@ struct dump_info {
char *CurrentFileName;
pcap_t *pd;
pcap_dumper_t *p;
-#ifdef __FreeBSD__
+#ifdef HAVE_CAPSICUM
int dirfd;
#endif
};
@@ -495,6 +554,52 @@ show_dlts_and_exit(const char *device, pcap_t *pd)
exit(0);
}
+#ifdef HAVE_PCAP_FINDALLDEVS
+static void
+show_devices_and_exit (void)
+{
+ pcap_if_t *devpointer;
+ char ebuf[PCAP_ERRBUF_SIZE];
+ int i;
+
+ if (pcap_findalldevs(&devpointer, ebuf) < 0)
+ error("%s", ebuf);
+ else {
+ for (i = 0; devpointer != NULL; i++) {
+ printf("%d.%s", i+1, devpointer->name);
+ if (devpointer->description != NULL)
+ printf(" (%s)", devpointer->description);
+ if (devpointer->flags != 0)
+ printf(" [%s]", bittok2str(status_flags, "none", devpointer->flags));
+ printf("\n");
+ devpointer = devpointer->next;
+ }
+ }
+ exit(0);
+}
+#endif /* HAVE_PCAP_FINDALLDEVS */
+
+/*
+ * Short options.
+ *
+ * Note that there we use all letters for short options except for g, k,
+ * o, and P, and those are used by other versions of tcpdump, and we should
+ * only use them for the same purposes that the other versions of tcpdump
+ * use them:
+ *
+ * OS X tcpdump uses -g to force non--v output for IP to be on one
+ * line, making it more "g"repable;
+ *
+ * OS X tcpdump uses -k tospecify that packet comments in pcap-ng files
+ * should be printed;
+ *
+ * OpenBSD tcpdump uses -o to indicate that OS fingerprinting should be done
+ * for hosts sending TCP SYN packets;
+ *
+ * OS X tcpdump uses -P to indicate that -w should write pcap-ng rather
+ * than pcap files.
+ */
+
/*
* Set up flags that might or might not be supported depending on the
* version of libpcap we're using.
@@ -541,6 +646,74 @@ show_dlts_and_exit(const char *device, pcap_t *pd)
#define U_FLAG
#endif
+#ifdef HAVE_PCAP_SETDIRECTION
+#define Q_FLAG "Q:"
+#else
+#define Q_FLAG
+#endif
+
+/*
+ * Long options.
+ *
+ * We do not currently have long options corresponding to all short
+ * options; we should probably pick appropriate option names for them.
+ *
+ * However, the short options where the number of times the option is
+ * specified matters, such as -v and -d and -t, should probably not
+ * just map to a long option, as saying
+ *
+ * tcpdump --verbose --verbose
+ *
+ * doesn't make sense; it should be --verbosity={N} or something such
+ * as that.
+ *
+ * For long options with no corresponding short options, we define values
+ * outside the range of ASCII graphic characters, make that the last
+ * component of the entry for the long option, and have a case for that
+ * option in the switch statement.
+ */
+#define OPTION_VERSION 128
+#define OPTION_TSTAMP_PRECISION 129
+
+static const struct option longopts[] = {
+#if defined(HAVE_PCAP_CREATE) || defined(WIN32)
+ { "buffer-size", required_argument, NULL, 'B' },
+#endif
+ { "list-interfaces", no_argument, NULL, 'D' },
+ { "help", no_argument, NULL, 'h' },
+ { "interface", required_argument, NULL, 'i' },
+#ifdef HAVE_PCAP_CREATE
+ { "monitor-mode", no_argument, NULL, 'I' },
+#endif
+#ifdef HAVE_PCAP_SET_TSTAMP_TYPE
+ { "time-stamp-type", required_argument, NULL, 'j' },
+ { "list-time-stamp-types", no_argument, NULL, 'J' },
+#endif
+#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
+ { "time-stamp-precision", required_argument, NULL, OPTION_TSTAMP_PRECISION},
+#endif
+ { "dont-verify-checksums", no_argument, NULL, 'K' },
+ { "list-data-link-types", no_argument, NULL, 'L' },
+ { "no-optimize", no_argument, NULL, 'O' },
+ { "no-promiscuous-mode", no_argument, NULL, 'p' },
+#ifdef HAVE_PCAP_SETDIRECTION
+ { "direction", required_argument, NULL, 'Q' },
+#endif
+ { "snapshot-length", required_argument, NULL, 's' },
+ { "absolute-tcp-sequence-numbers", no_argument, NULL, 'S' },
+#ifdef HAVE_PCAP_DUMP_FLUSH
+ { "packet-buffered", no_argument, NULL, 'U' },
+#endif
+ { "linktype", required_argument, NULL, 'y' },
+#if defined(HAVE_PCAP_DEBUG) || defined(HAVE_YYDEBUG)
+ { "debug-filter-parser", no_argument, NULL, 'Y' },
+#endif
+ { "relinquish-privileges", required_argument, NULL, 'Z' },
+ { "number", no_argument, NULL, '#' },
+ { "version", no_argument, NULL, OPTION_VERSION },
+ { NULL, 0, NULL, 0 }
+};
+
#ifndef WIN32
/* Drop root privileges and chroot if necessary */
static void
@@ -552,7 +725,7 @@ droproot(const char *username, const char *chroot_dir)
fprintf(stderr, "tcpdump: Chroot without dropping root is insecure\n");
exit(1);
}
-
+
pw = getpwnam(username);
if (pw) {
if (chroot_dir) {
@@ -565,7 +738,10 @@ droproot(const char *username, const char *chroot_dir)
#ifdef HAVE_CAP_NG_H
int ret = capng_change_id(pw->pw_uid, pw->pw_gid, CAPNG_NO_FLAG);
if (ret < 0) {
- printf("error : ret %d\n", ret);
+ fprintf(stderr, "error : ret %d\n", ret);
+ }
+ else {
+ printf("dropped privs to %s\n", username);
}
/* We don't need CAP_SETUID and CAP_SETGID */
capng_update(CAPNG_DROP, CAPNG_EFFECTIVE, CAP_SETUID);
@@ -578,12 +754,15 @@ droproot(const char *username, const char *chroot_dir)
if (initgroups(pw->pw_name, pw->pw_gid) != 0 ||
setgid(pw->pw_gid) != 0 || setuid(pw->pw_uid) != 0) {
fprintf(stderr, "tcpdump: Couldn't change to '%.32s' uid=%lu gid=%lu: %s\n",
- username,
+ username,
(unsigned long)pw->pw_uid,
(unsigned long)pw->pw_gid,
pcap_strerror(errno));
exit(1);
}
+ else {
+ printf("dropped privs to %s\n", username);
+ }
#endif /* HAVE_CAP_NG_H */
}
else {
@@ -645,7 +824,7 @@ MakeFilename(char *buffer, char *orig_name, int cnt, int max_chars)
static int tcpdump_printf(netdissect_options *ndo _U_,
const char *fmt, ...)
{
-
+
va_list args;
int ret;
@@ -694,7 +873,7 @@ get_next_file(FILE *VFile, char *ptr)
return ret;
}
-#ifdef HAVE_LIBCAPSICUM
+#ifdef HAVE_CAPSICUM
static cap_channel_t *
capdns_setup(void)
{
@@ -723,13 +902,43 @@ capdns_setup(void)
return (capdnsloc);
}
-#endif /* HAVE_LIBCAPSICUM */
+#endif /* HAVE_CAPSICUM */
+
+#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
+static int
+tstamp_precision_from_string(const char *precision)
+{
+ if (strncmp(precision, "nano", strlen("nano")) == 0)
+ return PCAP_TSTAMP_PRECISION_NANO;
+
+ if (strncmp(precision, "micro", strlen("micro")) == 0)
+ return PCAP_TSTAMP_PRECISION_MICRO;
+
+ return -EINVAL;
+}
+
+static const char *
+tstamp_precision_to_string(int precision)
+{
+ switch (precision) {
+
+ case PCAP_TSTAMP_PRECISION_MICRO:
+ return "micro";
+
+ case PCAP_TSTAMP_PRECISION_NANO:
+ return "nano";
+
+ default:
+ return "unknown";
+ }
+}
+#endif
int
main(int argc, char **argv)
{
register int cnt, op, i;
- bpf_u_int32 localnet, netmask;
+ bpf_u_int32 localnet =0 , netmask = 0;
register char *cp, *infile, *cmdbuf, *device, *RFileName, *VFileName, *WFileName;
pcap_handler callback;
int type;
@@ -755,10 +964,10 @@ main(int argc, char **argv)
#endif
int status;
FILE *VFile;
-#ifdef __FreeBSD__
+#ifdef HAVE_CAPSICUM
cap_rights_t rights;
int cansandbox;
-#endif /* __FreeBSD__ */
+#endif /* HAVE_CAPSICUM */
#ifdef WIN32
if(wsockinit() != 0) return 1;
@@ -773,7 +982,7 @@ main(int argc, char **argv)
gndo->ndo_error=ndo_error;
gndo->ndo_warning=ndo_warning;
gndo->ndo_snaplen = DEFAULT_SNAPLEN;
-
+
cnt = -1;
device = NULL;
infile = NULL;
@@ -790,12 +999,12 @@ main(int argc, char **argv)
if (abort_on_misalignment(ebuf, sizeof(ebuf)) < 0)
error("%s", ebuf);
-#ifdef LIBSMI
+#ifdef USE_LIBSMI
smiInit("tcpdump");
#endif
while (
- (op = getopt(argc, argv, "aAb" B_FLAG "c:C:d" D_FLAG "eE:fF:G:hHi:" I_FLAG j_FLAG J_FLAG "KlLm:M:nNOpqr:Rs:StT:u" U_FLAG "V:vw:W:xXy:Yz:Z:")) != -1)
+ (op = getopt_long(argc, argv, "aAb" B_FLAG "c:C:d" D_FLAG "eE:fF:G:hHi:" I_FLAG j_FLAG J_FLAG "KlLm:M:nNOpq" Q_FLAG "r:Rs:StT:u" U_FLAG "vV:w:W:xXy:Yz:Z:#", longopts, NULL)) != -1)
switch (op) {
case 'a':
@@ -834,21 +1043,9 @@ main(int argc, char **argv)
++dflag;
break;
-#ifdef HAVE_PCAP_FINDALLDEVS
case 'D':
- if (pcap_findalldevs(&devpointer, ebuf) < 0)
- error("%s", ebuf);
- else {
- for (i = 0; devpointer != 0; i++) {
- printf("%d.%s", i+1, devpointer->name);
- if (devpointer->description != NULL)
- printf(" (%s)", devpointer->description);
- printf("\n");
- devpointer = devpointer->next;
- }
- }
- return 0;
-#endif /* HAVE_PCAP_FINDALLDEVS */
+ Dflag++;
+ break;
case 'L':
Lflag++;
@@ -889,7 +1086,8 @@ main(int argc, char **argv)
break;
case 'h':
- usage();
+ print_usage();
+ exit(0);
break;
case 'H':
@@ -899,7 +1097,7 @@ main(int argc, char **argv)
case 'i':
if (optarg[0] == '0' && optarg[1] == 0)
error("Invalid adapter index");
-
+
#ifdef HAVE_PCAP_FINDALLDEVS
/*
* If the argument is a number, treat it as
@@ -982,7 +1180,7 @@ main(int argc, char **argv)
break;
case 'm':
-#ifdef LIBSMI
+#ifdef USE_LIBSMI
if (smiLoadModule(optarg) == 0) {
error("could not load MIB module %s", optarg);
}
@@ -1023,6 +1221,19 @@ main(int argc, char **argv)
++suppress_default_print;
break;
+#ifdef HAVE_PCAP_SETDIRECTION
+ case 'Q':
+ if (strcasecmp(optarg, "in") == 0)
+ Qflag = PCAP_D_IN;
+ else if (strcasecmp(optarg, "out") == 0)
+ Qflag = PCAP_D_OUT;
+ else if (strcasecmp(optarg, "inout") == 0)
+ Qflag = PCAP_D_INOUT;
+ else
+ error("unknown capture direction `%s'", optarg);
+ break;
+#endif /* HAVE_PCAP_SETDIRECTION */
+
case 'r':
RFileName = optarg;
break;
@@ -1075,6 +1286,12 @@ main(int argc, char **argv)
packettype = PT_ZMTP1;
else if (strcasecmp(optarg, "vxlan") == 0)
packettype = PT_VXLAN;
+ else if (strcasecmp(optarg, "pgm") == 0)
+ packettype = PT_PGM;
+ else if (strcasecmp(optarg, "pgm_zmtp1") == 0)
+ packettype = PT_PGM_ZMTP1;
+ else if (strcasecmp(optarg, "lmp") == 0)
+ packettype = PT_LMP;
else
error("unknown packet type `%s'", optarg);
break;
@@ -1103,7 +1320,7 @@ main(int argc, char **argv)
case 'W':
Wflag = atoi(optarg);
- if (Wflag < 0)
+ if (Wflag < 0)
error("invalid number of output files %s", optarg);
WflagChars = getWflagChars(Wflag);
break;
@@ -1141,29 +1358,41 @@ main(int argc, char **argv)
break;
#endif
case 'z':
- if (optarg) {
- zflag = strdup(optarg);
- } else {
- usage();
- /* NOTREACHED */
- }
+ zflag = strdup(optarg);
break;
case 'Z':
- if (optarg) {
- username = strdup(optarg);
- }
- else {
- usage();
- /* NOTREACHED */
- }
+ username = strdup(optarg);
+ break;
+
+ case '#':
+ gndo->ndo_packet_number = 1;
break;
+ case OPTION_VERSION:
+ print_version();
+ exit(0);
+ break;
+
+#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
+ case OPTION_TSTAMP_PRECISION:
+ gndo->ndo_tstamp_precision = tstamp_precision_from_string(optarg);
+ if (gndo->ndo_tstamp_precision < 0)
+ error("unsupported time stamp precision");
+ break;
+#endif
+
default:
- usage();
+ print_usage();
+ exit(1);
/* NOTREACHED */
}
+#ifdef HAVE_PCAP_FINDALLDEVS
+ if (Dflag)
+ show_devices_and_exit();
+#endif
+
switch (tflag) {
case 0: /* Default */
@@ -1200,7 +1429,7 @@ main(int argc, char **argv)
#ifdef WITH_USER
/* if run as root, prepare for dropping root privileges */
if (getuid() == 0 || geteuid() == 0) {
- /* Run with '-Z root' to restore old behaviour */
+ /* Run with '-Z root' to restore old behaviour */
if (!username)
username = WITH_USER;
}
@@ -1244,10 +1473,16 @@ main(int argc, char **argv)
RFileName = VFileLine;
}
+#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
+ pd = pcap_open_offline_with_tstamp_precision(RFileName,
+ gndo->ndo_tstamp_precision, ebuf);
+#else
pd = pcap_open_offline(RFileName, ebuf);
+#endif
+
if (pd == NULL)
error("%s", ebuf);
-#ifdef __FreeBSD__
+#ifdef HAVE_CAPSICUM
cap_rights_init(&rights, CAP_READ);
if (cap_rights_limit(fileno(pcap_file(pd)), &rights) < 0 &&
errno != ENOSYS) {
@@ -1265,8 +1500,6 @@ main(int argc, char **argv)
RFileName, dlt_name,
pcap_datalink_val_to_description(dlt));
}
- localnet = 0;
- netmask = 0;
} else {
/*
* We're doing a live capture.
@@ -1281,8 +1514,8 @@ main(int argc, char **argv)
* Print a message to the standard error on Windows.
* XXX - why do it here, with a different message?
*/
- if(strlen(device) == 1) //we assume that an ASCII string is always longer than 1 char
- { //a Unicode string has a \0 as second byte (so strlen() is 1)
+ if(strlen(device) == 1) /* we assume that an ASCII string is always longer than 1 char */
+ { /* a Unicode string has a \0 as second byte (so strlen() is 1) */
fprintf(stderr, "%s: listening on %ws\n", program_name, device);
}
else
@@ -1290,7 +1523,7 @@ main(int argc, char **argv)
fprintf(stderr, "%s: listening on %s\n", program_name, device);
}
- fflush(stderr);
+ fflush(stderr);
#endif /* WIN32 */
#ifdef HAVE_PCAP_CREATE
pd = pcap_create(device, ebuf);
@@ -1300,6 +1533,15 @@ main(int argc, char **argv)
if (Jflag)
show_tstamp_types_and_exit(device, pd);
#endif
+#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
+ status = pcap_set_tstamp_precision(pd, gndo->ndo_tstamp_precision);
+ if (status != 0)
+ error("%s: Can't set %ssecond time stamp precision: %s",
+ device,
+ tstamp_precision_to_string(gndo->ndo_tstamp_precision),
+ pcap_statustostr(status));
+#endif
+
/*
* Is this an interface that supports monitor mode?
*/
@@ -1392,6 +1634,14 @@ main(int argc, char **argv)
warning("%s: %s", device,
pcap_statustostr(status));
}
+#ifdef HAVE_PCAP_SETDIRECTION
+ if (Qflag != -1) {
+ status = pcap_setdirection(pd, Qflag);
+ if (status != 0)
+ error("%s: pcap_setdirection() failed: %s",
+ device, pcap_geterr(pd));
+ }
+#endif /* HAVE_PCAP_SETDIRECTION */
#else
*ebuf = '\0';
pd = pcap_open_live(device, snaplen, !pflag, 1000, ebuf);
@@ -1439,11 +1689,12 @@ main(int argc, char **argv)
warning("snaplen raised from %d to %d", snaplen, i);
snaplen = i;
}
- if (pcap_lookupnet(device, &localnet, &netmask, ebuf) < 0) {
- localnet = 0;
- netmask = 0;
- warning("%s", ebuf);
- }
+ if(fflag != 0) {
+ if (pcap_lookupnet(device, &localnet, &netmask, ebuf) < 0) {
+ warning("foreign (-f) flag used but: %s", ebuf);
+ }
+ }
+
}
if (infile)
cmdbuf = read_infile(infile);
@@ -1459,15 +1710,15 @@ main(int argc, char **argv)
exit(0);
}
-#ifdef HAVE_LIBCAPSICUM
+#ifdef HAVE_CAPSICUM
if (!nflag)
capdns = capdns_setup();
-#endif /* HAVE_LIBCAPSICUM */
+#endif /* HAVE_CAPSICUM */
- init_addrtoname(localnet, netmask);
+ init_addrtoname(gndo, localnet, netmask);
init_checksum();
-#ifndef WIN32
+#ifndef WIN32
(void)setsignal(SIGPIPE, cleanup);
(void)setsignal(SIGTERM, cleanup);
(void)setsignal(SIGINT, cleanup);
@@ -1476,7 +1727,7 @@ main(int argc, char **argv)
(void)setsignal(SIGCHLD, child_cleanup);
#endif
/* Cooperate with nohup(1) */
-#ifndef WIN32
+#ifndef WIN32
if ((oldhandler = setsignal(SIGHUP, cleanup)) != SIG_DFL)
(void)setsignal(SIGHUP, oldhandler);
#endif /* WIN32 */
@@ -1529,16 +1780,11 @@ main(int argc, char **argv)
if (pcap_setfilter(pd, &fcode) < 0)
error("%s", pcap_geterr(pd));
-#ifdef __FreeBSD__
+#ifdef HAVE_CAPSICUM
if (RFileName == NULL && VFileName == NULL) {
static const unsigned long cmds[] = { BIOCGSTATS };
- /*
- * The various libpcap devices use a combination of
- * read (bpf), ioctl (bpf, netmap), poll (netmap).
- * Grant the relevant access rights, sorted by name.
- */
- cap_rights_init(&rights, CAP_EVENT, CAP_IOCTL, CAP_READ);
+ cap_rights_init(&rights, CAP_IOCTL, CAP_READ);
if (cap_rights_limit(pcap_fileno(pd), &rights) < 0 &&
errno != ENOSYS) {
error("unable to limit pcap descriptor");
@@ -1570,7 +1816,7 @@ main(int argc, char **argv)
#endif
if (p == NULL)
error("%s", pcap_geterr(pd));
-#ifdef __FreeBSD__
+#ifdef HAVE_CAPSICUM
cap_rights_init(&rights, CAP_SEEK, CAP_WRITE);
if (cap_rights_limit(fileno(pcap_dump_file(p)), &rights) < 0 &&
errno != ENOSYS) {
@@ -1578,7 +1824,7 @@ main(int argc, char **argv)
}
#endif
if (Cflag != 0 || Gflag != 0) {
-#ifdef __FreeBSD__
+#ifdef HAVE_CAPSICUM
dumpinfo.WFileName = strdup(basename(WFileName));
dumpinfo.dirfd = open(dirname(WFileName),
O_DIRECTORY | O_RDONLY);
@@ -1592,7 +1838,7 @@ main(int argc, char **argv)
errno != ENOSYS) {
error("unable to limit directory rights");
}
-#else /* !__FreeBSD__ */
+#else /* !HAVE_CAPSICUM */
dumpinfo.WFileName = WFileName;
#endif
callback = dump_packet_and_trunc;
@@ -1668,7 +1914,7 @@ main(int argc, char **argv)
#ifdef __FreeBSD__
cansandbox = (VFileName == NULL && zflag == NULL);
-#ifdef HAVE_LIBCAPSICUM
+#ifdef HAVE_CAPSICUM
cansandbox = (cansandbox && (nflag || capdns != NULL));
#else
cansandbox = (cansandbox && nflag);
@@ -1696,6 +1942,14 @@ main(int argc, char **argv)
}
(void)fflush(stdout);
}
+ if (status == -2) {
+ /*
+ * We got interrupted. If we are reading multiple
+ * files (via -V) set these so that we stop.
+ */
+ VFileName = NULL;
+ ret = NULL;
+ }
if (status == -1) {
/*
* Error. Report it.
@@ -1718,7 +1972,7 @@ main(int argc, char **argv)
pd = pcap_open_offline(RFileName, ebuf);
if (pd == NULL)
error("%s", ebuf);
-#ifdef __FreeBSD__
+#ifdef HAVE_CAPSICUM
cap_rights_init(&rights, CAP_READ);
if (cap_rights_limit(fileno(pcap_file(pd)),
&rights) < 0 && errno != ENOSYS) {
@@ -1893,7 +2147,7 @@ static void
dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
{
struct dump_info *dump_info;
-#ifdef __FreeBSD__
+#ifdef HAVE_CAPSICUM
cap_rights_t rights;
#endif
@@ -1924,7 +2178,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
/* If the time is greater than the specified window, rotate */
if (t - Gflag_time >= Gflag) {
-#ifdef __FreeBSD__
+#ifdef HAVE_CAPSICUM
FILE *fp;
int fd;
#endif
@@ -1961,6 +2215,13 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
if (dump_info->CurrentFileName == NULL)
error("dump_packet_and_trunc: malloc");
/*
+ * Gflag was set otherwise we wouldn't be here. Reset the count
+ * so multiple files would end with 1,2,3 in the filename.
+ * The counting is handled with the -C flow after this.
+ */
+ Cflag_count = 0;
+
+ /*
* This is always the first file in the Cflag
* rotation: e.g. 0
* We also don't need numbering if Cflag is not set.
@@ -1975,7 +2236,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
capng_update(CAPNG_ADD, CAPNG_EFFECTIVE, CAP_DAC_OVERRIDE);
capng_apply(CAPNG_EFFECTIVE);
#endif /* HAVE_CAP_NG_H */
-#ifdef __FreeBSD__
+#ifdef HAVE_CAPSICUM
fd = openat(dump_info->dirfd,
dump_info->CurrentFileName,
O_CREAT | O_WRONLY | O_TRUNC, 0644);
@@ -1989,7 +2250,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
dump_info->CurrentFileName);
}
dump_info->p = pcap_dump_fopen(dump_info->pd, fp);
-#else /* !__FreeBSD__ */
+#else /* !HAVE_CAPSICUM */
dump_info->p = pcap_dump_open(dump_info->pd, dump_info->CurrentFileName);
#endif
#ifdef HAVE_CAP_NG_H
@@ -1998,7 +2259,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
#endif /* HAVE_CAP_NG_H */
if (dump_info->p == NULL)
error("%s", pcap_geterr(pd));
-#ifdef __FreeBSD__
+#ifdef HAVE_CAPSICUM
cap_rights_init(&rights, CAP_SEEK, CAP_WRITE);
if (cap_rights_limit(fileno(pcap_dump_file(dump_info->p)),
&rights) < 0 && errno != ENOSYS) {
@@ -2014,7 +2275,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
* file could put it over Cflag.
*/
if (Cflag != 0 && pcap_dump_ftell(dump_info->p) > Cflag) {
-#ifdef __FreeBSD__
+#ifdef HAVE_CAPSICUM
FILE *fp;
int fd;
#endif
@@ -2041,7 +2302,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
if (dump_info->CurrentFileName == NULL)
error("dump_packet_and_trunc: malloc");
MakeFilename(dump_info->CurrentFileName, dump_info->WFileName, Cflag_count, WflagChars);
-#ifdef __FreeBSD__
+#ifdef HAVE_CAPSICUM
fd = openat(dump_info->dirfd, dump_info->CurrentFileName,
O_CREAT | O_WRONLY | O_TRUNC, 0644);
if (fd < 0) {
@@ -2054,12 +2315,12 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
dump_info->CurrentFileName);
}
dump_info->p = pcap_dump_fopen(dump_info->pd, fp);
-#else /* !__FreeBSD__ */
+#else /* !HAVE_CAPSICUM */
dump_info->p = pcap_dump_open(dump_info->pd, dump_info->CurrentFileName);
#endif
if (dump_info->p == NULL)
error("%s", pcap_geterr(pd));
-#ifdef __FreeBSD__
+#ifdef HAVE_CAPSICUM
cap_rights_init(&rights, CAP_SEEK, CAP_WRITE);
if (cap_rights_limit(fileno(pcap_dump_file(dump_info->p)),
&rights) < 0 && errno != ENOSYS) {
@@ -2102,36 +2363,42 @@ print_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
{
struct print_info *print_info;
u_int hdrlen;
+ netdissect_options *ndo;
++packets_captured;
++infodelay;
- ts_print(&h->ts);
print_info = (struct print_info *)user;
+ ndo = print_info->ndo;
+
+ if(ndo->ndo_packet_number)
+ ND_PRINT((ndo, "%5u ", packets_captured));
+
+ ts_print(ndo, &h->ts);
/*
* Some printers want to check that they're not walking off the
* end of the packet.
* Rather than pass it all the way down, we set this global.
*/
- snapend = sp + h->caplen;
+ ndo->ndo_snapend = sp + h->caplen;
if(print_info->ndo_type) {
hdrlen = (*print_info->p.ndo_printer)(print_info->ndo, h, sp);
} else {
hdrlen = (*print_info->p.printer)(h, sp);
}
-
- if (Xflag) {
+
+ if (ndo->ndo_Xflag) {
/*
* Print the raw packet data in hex and ASCII.
*/
- if (Xflag > 1) {
+ if (ndo->ndo_Xflag > 1) {
/*
* Include the link-layer header.
*/
- hex_and_ascii_print("\n\t", sp, h->caplen);
+ hex_and_ascii_print(ndo, "\n\t", sp, h->caplen);
} else {
/*
* Don't include the link-layer header - and if
@@ -2139,18 +2406,18 @@ print_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
* print nothing.
*/
if (h->caplen > hdrlen)
- hex_and_ascii_print("\n\t", sp + hdrlen,
+ hex_and_ascii_print(ndo, "\n\t", sp + hdrlen,
h->caplen - hdrlen);
}
- } else if (xflag) {
+ } else if (ndo->ndo_xflag) {
/*
* Print the raw packet data in hex.
*/
- if (xflag > 1) {
+ if (ndo->ndo_xflag > 1) {
/*
* Include the link-layer header.
*/
- hex_print("\n\t", sp, h->caplen);
+ hex_print(ndo, "\n\t", sp, h->caplen);
} else {
/*
* Don't include the link-layer header - and if
@@ -2158,18 +2425,18 @@ print_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
* print nothing.
*/
if (h->caplen > hdrlen)
- hex_print("\n\t", sp + hdrlen,
- h->caplen - hdrlen);
+ hex_print(ndo, "\n\t", sp + hdrlen,
+ h->caplen - hdrlen);
}
- } else if (Aflag) {
+ } else if (ndo->ndo_Aflag) {
/*
* Print the raw packet data in ASCII.
*/
- if (Aflag > 1) {
+ if (ndo->ndo_Aflag > 1) {
/*
* Include the link-layer header.
*/
- ascii_print(sp, h->caplen);
+ ascii_print(ndo, sp, h->caplen);
} else {
/*
* Don't include the link-layer header - and if
@@ -2177,7 +2444,7 @@ print_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
* print nothing.
*/
if (h->caplen > hdrlen)
- ascii_print(sp + hdrlen, h->caplen - hdrlen);
+ ascii_print(ndo, sp + hdrlen, h->caplen - hdrlen);
}
}
@@ -2207,11 +2474,11 @@ print_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
* version number of the Packet.dll code, to supply the
* "Wpcap_version" information on Windows.
*/
- char WDversion[]="current-cvs.tcpdump.org";
+ char WDversion[]="current-git.tcpdump.org";
#if !defined(HAVE_GENERATED_VERSION)
- char version[]="current-cvs.tcpdump.org";
+ char version[]="current-git.tcpdump.org";
#endif
- char pcap_version[]="current-cvs.tcpdump.org";
+ char pcap_version[]="current-git.tcpdump.org";
char Wpcap_version[]="3.1";
#endif
@@ -2219,9 +2486,9 @@ print_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
* By default, print the specified data out in hex and ASCII.
*/
static void
-ndo_default_print(netdissect_options *ndo _U_, const u_char *bp, u_int length)
+ndo_default_print(netdissect_options *ndo, const u_char *bp, u_int length)
{
- hex_and_ascii_print("\n\t", bp, length); /* pass on lf and identation string */
+ hex_and_ascii_print(ndo, "\n\t", bp, length); /* pass on lf and identation string */
}
void
@@ -2263,8 +2530,9 @@ static void verbose_stats_dump(int sig _U_)
}
#endif
+USES_APPLE_DEPRECATED_API
static void
-usage(void)
+print_version(void)
{
extern char version[];
#ifndef HAVE_PCAP_LIB_VERSION
@@ -2291,19 +2559,43 @@ usage(void)
(void)fprintf(stderr, "libpcap version %s\n", pcap_version);
#endif /* WIN32 */
#endif /* HAVE_PCAP_LIB_VERSION */
+
+#if defined(HAVE_LIBCRYPTO) && defined(SSLEAY_VERSION)
+ (void)fprintf (stderr, "%s\n", SSLeay_version(SSLEAY_VERSION));
+#endif
+
+#ifdef USE_LIBSMI
+ (void)fprintf (stderr, "SMI-library: %s\n", smi_version_string);
+#endif
+}
+USES_APPLE_RST
+
+static void
+print_usage(void)
+{
+ print_version();
(void)fprintf(stderr,
-"Usage: %s [-aAbd" D_FLAG "efhH" I_FLAG J_FLAG "KlLnNOpqRStu" U_FLAG "vxX]" B_FLAG_USAGE " [ -c count ]\n", program_name);
+"Usage: %s [-aAbd" D_FLAG "efhH" I_FLAG J_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[ -i interface ]" j_FLAG_USAGE " [ -M secret ]\n");
+"\t\t[ -i interface ]" j_FLAG_USAGE " [ -M secret ] [ --number ]\n");
+#ifdef HAVE_PCAP_SETDIRECTION
+ (void)fprintf(stderr,
+"\t\t[ -Q in|out|inout ]\n");
+#endif
+ (void)fprintf(stderr,
+"\t\t[ -r file ] [ -s snaplen ] ");
+#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
+ (void)fprintf(stderr, "[ --time-stamp-precision precision ]\n");
(void)fprintf(stderr,
-"\t\t[ -r file ] [ -s snaplen ] [ -T type ] [ -V file ] [ -w file ]\n");
+"\t\t");
+#endif
+ (void)fprintf(stderr, "[ -T type ] [ --version ] [ -V file ]\n");
(void)fprintf(stderr,
-"\t\t[ -W filecount ] [ -y datalinktype ] [ -z command ]\n");
+"\t\t[ -w file ] [ -W filecount ] [ -y datalinktype ] [ -z command ]\n");
(void)fprintf(stderr,
"\t\t[ -Z user ] [ expression ]\n");
- exit(1);
}
@@ -2343,3 +2635,9 @@ ndo_warning(netdissect_options *ndo _U_, const char *fmt, ...)
(void)fputc('\n', stderr);
}
}
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
diff --git a/contrib/tcpdump/telnet.h b/contrib/tcpdump/telnet.h
deleted file mode 100644
index 33a07be9482e..000000000000
--- a/contrib/tcpdump/telnet.h
+++ /dev/null
@@ -1,348 +0,0 @@
-/* @(#) $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 */
-
-/*
- * Copyright (c) 1983, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)telnet.h 8.2 (Berkeley) 12/15/93
- */
-
-#ifndef _ARPA_TELNET_H_
-#define _ARPA_TELNET_H_
-
-/*
- * Definitions for the TELNET protocol.
- */
-#define IAC 255 /* interpret as command: */
-#define DONT 254 /* you are not to use option */
-#define DO 253 /* please, you use option */
-#define WONT 252 /* I won't use option */
-#define WILL 251 /* I will use option */
-#define SB 250 /* interpret as subnegotiation */
-#define GA 249 /* you may reverse the line */
-#define EL 248 /* erase the current line */
-#define EC 247 /* erase the current character */
-#define AYT 246 /* are you there */
-#define AO 245 /* abort output--but let prog finish */
-#define IP 244 /* interrupt process--permanently */
-#define BREAK 243 /* break */
-#define DM 242 /* data mark--for connect. cleaning */
-#define NOP 241 /* nop */
-#define SE 240 /* end sub negotiation */
-#define EOR 239 /* end of record (transparent mode) */
-#define ABORT 238 /* Abort process */
-#define SUSP 237 /* Suspend process */
-#define xEOF 236 /* End of file: EOF is already used... */
-
-#define SYNCH 242 /* for telfunc calls */
-
-#ifdef TELCMDS
-const char *telcmds[] = {
- "EOF", "SUSP", "ABORT", "EOR",
- "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC",
- "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0,
-};
-#else
-extern char *telcmds[];
-#endif
-
-#define TELCMD_FIRST xEOF
-#define TELCMD_LAST IAC
-#define TELCMD_OK(x) ((unsigned int)(x) <= TELCMD_LAST && \
- (unsigned int)(x) >= TELCMD_FIRST)
-#define TELCMD(x) telcmds[(x)-TELCMD_FIRST]
-
-/* telnet options */
-#define TELOPT_BINARY 0 /* 8-bit data path */
-#define TELOPT_ECHO 1 /* echo */
-#define TELOPT_RCP 2 /* prepare to reconnect */
-#define TELOPT_SGA 3 /* suppress go ahead */
-#define TELOPT_NAMS 4 /* approximate message size */
-#define TELOPT_STATUS 5 /* give status */
-#define TELOPT_TM 6 /* timing mark */
-#define TELOPT_RCTE 7 /* remote controlled transmission and echo */
-#define TELOPT_NAOL 8 /* negotiate about output line width */
-#define TELOPT_NAOP 9 /* negotiate about output page size */
-#define TELOPT_NAOCRD 10 /* negotiate about CR disposition */
-#define TELOPT_NAOHTS 11 /* negotiate about horizontal tabstops */
-#define TELOPT_NAOHTD 12 /* negotiate about horizontal tab disposition */
-#define TELOPT_NAOFFD 13 /* negotiate about formfeed disposition */
-#define TELOPT_NAOVTS 14 /* negotiate about vertical tab stops */
-#define TELOPT_NAOVTD 15 /* negotiate about vertical tab disposition */
-#define TELOPT_NAOLFD 16 /* negotiate about output LF disposition */
-#define TELOPT_XASCII 17 /* extended ascic character set */
-#define TELOPT_LOGOUT 18 /* force logout */
-#define TELOPT_BM 19 /* byte macro */
-#define TELOPT_DET 20 /* data entry terminal */
-#define TELOPT_SUPDUP 21 /* supdup protocol */
-#define TELOPT_SUPDUPOUTPUT 22 /* supdup output */
-#define TELOPT_SNDLOC 23 /* send location */
-#define TELOPT_TTYPE 24 /* terminal type */
-#define TELOPT_EOR 25 /* end or record */
-#define TELOPT_TUID 26 /* TACACS user identification */
-#define TELOPT_OUTMRK 27 /* output marking */
-#define TELOPT_TTYLOC 28 /* terminal location number */
-#define TELOPT_3270REGIME 29 /* 3270 regime */
-#define TELOPT_X3PAD 30 /* X.3 PAD */
-#define TELOPT_NAWS 31 /* window size */
-#define TELOPT_TSPEED 32 /* terminal speed */
-#define TELOPT_LFLOW 33 /* remote flow control */
-#define TELOPT_LINEMODE 34 /* Linemode option */
-#define TELOPT_XDISPLOC 35 /* X Display Location */
-#define TELOPT_OLD_ENVIRON 36 /* Old - Environment variables */
-#define TELOPT_AUTHENTICATION 37/* Authenticate */
-#define TELOPT_ENCRYPT 38 /* Encryption option */
-#define TELOPT_NEW_ENVIRON 39 /* New - Environment variables */
-#define TELOPT_EXOPL 255 /* extended-options-list */
-
-
-#define NTELOPTS (1+TELOPT_NEW_ENVIRON)
-#ifdef TELOPTS
-const char *telopts[NTELOPTS+1] = {
- "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME",
- "STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP",
- "NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS",
- "NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO",
- "DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT",
- "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD",
- "TACACS UID", "OUTPUT MARKING", "TTYLOC",
- "3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW",
- "LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION",
- "ENCRYPT", "NEW-ENVIRON",
- 0,
-};
-#define TELOPT_FIRST TELOPT_BINARY
-#define TELOPT_LAST TELOPT_NEW_ENVIRON
-#define TELOPT_OK(x) ((unsigned int)(x) <= TELOPT_LAST)
-#define TELOPT(x) telopts[(x)-TELOPT_FIRST]
-#endif
-
-/* sub-option qualifiers */
-#define TELQUAL_IS 0 /* option is... */
-#define TELQUAL_SEND 1 /* send option */
-#define TELQUAL_INFO 2 /* ENVIRON: informational version of IS */
-#define TELQUAL_REPLY 2 /* AUTHENTICATION: client version of IS */
-#define TELQUAL_NAME 3 /* AUTHENTICATION: client version of IS */
-
-#define LFLOW_OFF 0 /* Disable remote flow control */
-#define LFLOW_ON 1 /* Enable remote flow control */
-#define LFLOW_RESTART_ANY 2 /* Restart output on any char */
-#define LFLOW_RESTART_XON 3 /* Restart output only on XON */
-
-/*
- * LINEMODE suboptions
- */
-
-#define LM_MODE 1
-#define LM_FORWARDMASK 2
-#define LM_SLC 3
-
-#define MODE_EDIT 0x01
-#define MODE_TRAPSIG 0x02
-#define MODE_ACK 0x04
-#define MODE_SOFT_TAB 0x08
-#define MODE_LIT_ECHO 0x10
-
-#define MODE_MASK 0x1f
-
-/* Not part of protocol, but needed to simplify things... */
-#define MODE_FLOW 0x0100
-#define MODE_ECHO 0x0200
-#define MODE_INBIN 0x0400
-#define MODE_OUTBIN 0x0800
-#define MODE_FORCE 0x1000
-
-#define SLC_SYNCH 1
-#define SLC_BRK 2
-#define SLC_IP 3
-#define SLC_AO 4
-#define SLC_AYT 5
-#define SLC_EOR 6
-#define SLC_ABORT 7
-#define SLC_EOF 8
-#define SLC_SUSP 9
-#define SLC_EC 10
-#define SLC_EL 11
-#define SLC_EW 12
-#define SLC_RP 13
-#define SLC_LNEXT 14
-#define SLC_XON 15
-#define SLC_XOFF 16
-#define SLC_FORW1 17
-#define SLC_FORW2 18
-#define SLC_MCL 19
-#define SLC_MCR 20
-#define SLC_MCWL 21
-#define SLC_MCWR 22
-#define SLC_MCBOL 23
-#define SLC_MCEOL 24
-#define SLC_INSRT 25
-#define SLC_OVER 26
-#define SLC_ECR 27
-#define SLC_EWR 28
-#define SLC_EBOL 29
-#define SLC_EEOL 30
-
-#define NSLC 30
-
-/*
- * For backwards compatibility, we define SLC_NAMES to be the
- * list of names if SLC_NAMES is not defined.
- */
-#define SLC_NAMELIST "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \
- "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \
- "LNEXT", "XON", "XOFF", "FORW1", "FORW2", \
- "MCL", "MCR", "MCWL", "MCWR", "MCBOL", \
- "MCEOL", "INSRT", "OVER", "ECR", "EWR", \
- "EBOL", "EEOL", \
- 0,
-
-#ifdef SLC_NAMES
-const char *slc_names[] = {
- SLC_NAMELIST
-};
-#else
-extern char *slc_names[];
-#define SLC_NAMES SLC_NAMELIST
-#endif
-
-#define SLC_NAME_OK(x) ((unsigned int)(x) <= NSLC)
-#define SLC_NAME(x) slc_names[x]
-
-#define SLC_NOSUPPORT 0
-#define SLC_CANTCHANGE 1
-#define SLC_VARIABLE 2
-#define SLC_DEFAULT 3
-#define SLC_LEVELBITS 0x03
-
-#define SLC_FUNC 0
-#define SLC_FLAGS 1
-#define SLC_VALUE 2
-
-#define SLC_ACK 0x80
-#define SLC_FLUSHIN 0x40
-#define SLC_FLUSHOUT 0x20
-
-#define OLD_ENV_VAR 1
-#define OLD_ENV_VALUE 0
-#define NEW_ENV_VAR 0
-#define NEW_ENV_VALUE 1
-#define ENV_ESC 2
-#define ENV_USERVAR 3
-
-/*
- * AUTHENTICATION suboptions
- */
-
-/*
- * Who is authenticating who ...
- */
-#define AUTH_WHO_CLIENT 0 /* Client authenticating server */
-#define AUTH_WHO_SERVER 1 /* Server authenticating client */
-#define AUTH_WHO_MASK 1
-
-/*
- * amount of authentication done
- */
-#define AUTH_HOW_ONE_WAY 0
-#define AUTH_HOW_MUTUAL 2
-#define AUTH_HOW_MASK 2
-
-/*
- * should we be encrypting? (not yet formally standardized)
- */
-#define AUTH_ENCRYPT_OFF 0
-#define AUTH_ENCRYPT_ON 4
-#define AUTH_ENCRYPT_MASK 4
-
-#define AUTHTYPE_NULL 0
-#define AUTHTYPE_KERBEROS_V4 1
-#define AUTHTYPE_KERBEROS_V5 2
-#define AUTHTYPE_SPX 3
-#define AUTHTYPE_MINK 4
-#define AUTHTYPE_CNT 5
-
-#define AUTHTYPE_TEST 99
-
-#ifdef AUTH_NAMES
-const char *authtype_names[] = {
- "NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", 0,
-};
-#else
-extern char *authtype_names[];
-#endif
-
-#define AUTHTYPE_NAME_OK(x) ((unsigned int)(x) < AUTHTYPE_CNT)
-#define AUTHTYPE_NAME(x) authtype_names[x]
-
-/*
- * ENCRYPTion suboptions
- */
-#define ENCRYPT_IS 0 /* I pick encryption type ... */
-#define ENCRYPT_SUPPORT 1 /* I support encryption types ... */
-#define ENCRYPT_REPLY 2 /* Initial setup response */
-#define ENCRYPT_START 3 /* Am starting to send encrypted */
-#define ENCRYPT_END 4 /* Am ending encrypted */
-#define ENCRYPT_REQSTART 5 /* Request you start encrypting */
-#define ENCRYPT_REQEND 6 /* Request you send encrypting */
-#define ENCRYPT_ENC_KEYID 7
-#define ENCRYPT_DEC_KEYID 8
-#define ENCRYPT_CNT 9
-
-#define ENCTYPE_ANY 0
-#define ENCTYPE_DES_CFB64 1
-#define ENCTYPE_DES_OFB64 2
-#define ENCTYPE_CNT 3
-
-#ifdef ENCRYPT_NAMES
-const char *encrypt_names[] = {
- "IS", "SUPPORT", "REPLY", "START", "END",
- "REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID",
- 0,
-};
-const char *enctype_names[] = {
- "ANY", "DES_CFB64", "DES_OFB64", 0,
-};
-#else
-extern char *encrypt_names[];
-extern char *enctype_names[];
-#endif
-
-
-#define ENCRYPT_NAME_OK(x) ((unsigned int)(x) < ENCRYPT_CNT)
-#define ENCRYPT_NAME(x) encrypt_names[x]
-
-#define ENCTYPE_NAME_OK(x) ((unsigned int)(x) < ENCTYPE_CNT)
-#define ENCTYPE_NAME(x) enctype_names[x]
-
-#endif /* _ARPA_TELNET_H_ */
diff --git a/contrib/tcpdump/tftp.h b/contrib/tcpdump/tftp.h
deleted file mode 100644
index 6a092e0af528..000000000000
--- a/contrib/tcpdump/tftp.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/tftp.h,v 1.2 2008-04-11 16:47:38 gianluca Exp $ (LBL) */
-/*
- * Copyright (c) 1983, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)tftp.h 8.1 (Berkeley) 6/2/93
- */
-
-#ifndef _TFTP_H_
-#define _TFTP_H_
-
-/*
- * Trivial File Transfer Protocol (IEN-133)
- */
-#define SEGSIZE 512 /* data segment size */
-
-/*
- * Packet types.
- */
-#define RRQ 01 /* read request */
-#define WRQ 02 /* write request */
-#define DATA 03 /* data packet */
-#define ACK 04 /* acknowledgement */
-#define TFTP_ERROR 05 /* error code */
-#define OACK 06 /* option acknowledgement */
-
-struct tftphdr {
- unsigned short th_opcode; /* packet type */
- union {
- unsigned short tu_block; /* block # */
- unsigned short tu_code; /* error code */
- char tu_stuff[1]; /* request packet stuff */
- } th_u;
- char th_data[1]; /* data or error string */
-};
-
-#define th_block th_u.tu_block
-#define th_code th_u.tu_code
-#define th_stuff th_u.tu_stuff
-#define th_msg th_data
-
-/*
- * Error codes.
- */
-#define EUNDEF 0 /* not defined */
-#define ENOTFOUND 1 /* file not found */
-#define EACCESS 2 /* access violation */
-#define ENOSPACE 3 /* disk full or allocation exceeded */
-#define EBADOP 4 /* illegal TFTP operation */
-#define EBADID 5 /* unknown transfer ID */
-#define EEXISTS 6 /* file already exists */
-#define ENOUSER 7 /* no such user */
-
-#endif /* !_TFTP_H_ */
diff --git a/contrib/tcpdump/timed.h b/contrib/tcpdump/timed.h
deleted file mode 100644
index f8d5a113684f..000000000000
--- a/contrib/tcpdump/timed.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/timed.h,v 1.6 2008-02-05 19:46:19 guy Exp $ (LBL) */
-/*
- * Copyright (c) 1983, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)timed.h 8.1 (Berkeley) 6/2/93
- */
-
-#ifndef _PROTOCOLS_TIMED_H_
-#define _PROTOCOLS_TIMED_H_
-
-/*
- * Time Synchronization Protocol
- */
-
-#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 tsp_timeval tspu_time;
- int8_t tspu_hopcnt;
- } tsp_u;
- int8_t tsp_name[256];
-};
-
-#define tsp_time tsp_u.tspu_time
-#define tsp_hopcnt tsp_u.tspu_hopcnt
-
-/*
- * Command types.
- */
-#define TSP_ANY 0 /* match any types */
-#define TSP_ADJTIME 1 /* send adjtime */
-#define TSP_ACK 2 /* generic acknowledgement */
-#define TSP_MASTERREQ 3 /* ask for master's name */
-#define TSP_MASTERACK 4 /* acknowledge master request */
-#define TSP_SETTIME 5 /* send network time */
-#define TSP_MASTERUP 6 /* inform slaves that master is up */
-#define TSP_SLAVEUP 7 /* slave is up but not polled */
-#define TSP_ELECTION 8 /* advance candidature for master */
-#define TSP_ACCEPT 9 /* support candidature of master */
-#define TSP_REFUSE 10 /* reject candidature of master */
-#define TSP_CONFLICT 11 /* two or more masters present */
-#define TSP_RESOLVE 12 /* masters' conflict resolution */
-#define TSP_QUIT 13 /* reject candidature if master is up */
-#define TSP_DATE 14 /* reset the time (date command) */
-#define TSP_DATEREQ 15 /* remote request to reset the time */
-#define TSP_DATEACK 16 /* acknowledge time setting */
-#define TSP_TRACEON 17 /* turn tracing on */
-#define TSP_TRACEOFF 18 /* turn tracing off */
-#define TSP_MSITE 19 /* find out master's site */
-#define TSP_MSITEREQ 20 /* remote master's site request */
-#define TSP_TEST 21 /* for testing election algo */
-#define TSP_SETDATE 22 /* New from date command */
-#define TSP_SETDATEREQ 23 /* New remote for above */
-#define TSP_LOOP 24 /* loop detection packet */
-
-#define TSPTYPENUMBER 25
-
-#endif /* !_TIMED_H_ */
diff --git a/contrib/tcpdump/token.h b/contrib/tcpdump/token.h
deleted file mode 100644
index 19524c6c04f7..000000000000
--- a/contrib/tcpdump/token.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* @(#) $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.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice unmodified, this list of conditions, and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#define TOKEN_HDRLEN 14
-#define TOKEN_RING_MAC_LEN 6
-#define ROUTING_SEGMENT_MAX 16
-#define IS_SOURCE_ROUTED(trp) ((trp)->token_shost[0] & 0x80)
-#define FRAME_TYPE(trp) (((trp)->token_fc & 0xC0) >> 6)
-#define TOKEN_FC_LLC 1
-
-#define BROADCAST(trp) ((EXTRACT_16BITS(&(trp)->token_rcf) & 0xE000) >> 13)
-#define RIF_LENGTH(trp) ((EXTRACT_16BITS(&(trp)->token_rcf) & 0x1f00) >> 8)
-#define DIRECTION(trp) ((EXTRACT_16BITS(&(trp)->token_rcf) & 0x0080) >> 7)
-#define LARGEST_FRAME(trp) ((EXTRACT_16BITS(&(trp)->token_rcf) & 0x0070) >> 4)
-#define RING_NUMBER(trp, x) ((EXTRACT_16BITS(&(trp)->token_rseg[x]) & 0xfff0) >> 4)
-#define BRIDGE_NUMBER(trp, x) ((EXTRACT_16BITS(&(trp)->token_rseg[x]) & 0x000f))
-#define SEGMENT_COUNT(trp) ((int)((RIF_LENGTH(trp) - 2) / 2))
-
-struct token_header {
- u_int8_t token_ac;
- u_int8_t token_fc;
- u_int8_t token_dhost[TOKEN_RING_MAC_LEN];
- u_int8_t token_shost[TOKEN_RING_MAC_LEN];
- u_int16_t token_rcf;
- u_int16_t token_rseg[ROUTING_SEGMENT_MAX];
-};
diff --git a/contrib/tcpdump/udp.h b/contrib/tcpdump/udp.h
index b07cdd4331f6..4bc90a790c51 100644
--- a/contrib/tcpdump/udp.h
+++ b/contrib/tcpdump/udp.h
@@ -1,4 +1,3 @@
-/* @(#) $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.
@@ -39,10 +38,10 @@
* Per RFC 768, September, 1981.
*/
struct udphdr {
- u_int16_t uh_sport; /* source port */
- u_int16_t uh_dport; /* destination port */
- u_int16_t uh_ulen; /* udp length */
- u_int16_t uh_sum; /* udp checksum */
+ uint16_t uh_sport; /* source port */
+ uint16_t uh_dport; /* destination port */
+ uint16_t uh_ulen; /* udp length */
+ uint16_t uh_sum; /* udp checksum */
};
#define TFTP_PORT 69 /*XXX*/
@@ -79,18 +78,22 @@ struct udphdr {
#define VQP_PORT 1589
#define ZEPHYR_SRV_PORT 2103
#define ZEPHYR_CLT_PORT 2104
+#define VAT_PORT 3456
#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 WB_PORT 4567
#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 */
#define OTV_PORT 8472 /* draft-hasmit-otv-04 */
+#define VXLAN_PORT 4789 /* draft-mahalingam-dutt-dcops-vxlan-04 */
#ifdef INET6
#define RIPNG_PORT 521 /*XXX*/
#define DHCP6_SERV_PORT 546 /*XXX*/
#define DHCP6_CLI_PORT 547 /*XXX*/
+#define AHCP_PORT 5359 /* draft-chroboczek-ahcp-00 */
#define BABEL_PORT 6696
#define BABEL_PORT_OLD 6697
#endif
diff --git a/contrib/tcpdump/util.c b/contrib/tcpdump/util.c
index a2ef36d70b78..5731ca7b376a 100644
--- a/contrib/tcpdump/util.c
+++ b/contrib/tcpdump/util.c
@@ -19,11 +19,7 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/util.c,v 1.109 2007-01-29 09:59:42 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -32,11 +28,9 @@ static const char rcsid[] _U_ =
#include <sys/stat.h>
-#include <errno.h>
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
-#include <pcap.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
@@ -44,15 +38,14 @@ 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.
* Return true if truncated.
*/
int
-fn_print(register const u_char *s, register const u_char *ep)
+fn_print(netdissect_options *ndo,
+ register const u_char *s, register const u_char *ep)
{
register int ret;
register u_char c;
@@ -64,16 +57,15 @@ fn_print(register const u_char *s, register const u_char *ep)
ret = 0;
break;
}
- if (!isascii(c)) {
- c = toascii(c);
- putchar('M');
- putchar('-');
+ if (!ND_ISASCII(c)) {
+ c = ND_TOASCII(c);
+ ND_PRINT((ndo, "M-"));
}
- if (!isprint(c)) {
+ if (!ND_ISPRINT(c)) {
c ^= 0x40; /* DEL to ?, others to alpha */
- putchar('^');
+ ND_PRINT((ndo, "^"));
}
- putchar(c);
+ ND_PRINT((ndo, "%c", c));
}
return(ret);
}
@@ -84,24 +76,23 @@ fn_print(register const u_char *s, register const u_char *ep)
* Return true if truncated.
*/
int
-fn_printn(register const u_char *s, register u_int n,
- register const u_char *ep)
+fn_printn(netdissect_options *ndo,
+ register const u_char *s, register u_int n, register const u_char *ep)
{
register u_char c;
while (n > 0 && (ep == NULL || s < ep)) {
n--;
c = *s++;
- if (!isascii(c)) {
- c = toascii(c);
- putchar('M');
- putchar('-');
+ if (!ND_ISASCII(c)) {
+ c = ND_TOASCII(c);
+ ND_PRINT((ndo, "M-"));
}
- if (!isprint(c)) {
+ if (!ND_ISPRINT(c)) {
c ^= 0x40; /* DEL to ?, others to alpha */
- putchar('^');
+ ND_PRINT((ndo, "^"));
}
- putchar(c);
+ ND_PRINT((ndo, "%c", c));
}
return (n == 0) ? 0 : 1;
}
@@ -112,8 +103,9 @@ fn_printn(register const u_char *s, register u_int n,
* Return true if truncated.
*/
int
-fn_printzp(register const u_char *s, register u_int n,
- register const u_char *ep)
+fn_printzp(netdissect_options *ndo,
+ register const u_char *s, register u_int n,
+ register const u_char *ep)
{
register int ret;
register u_char c;
@@ -126,16 +118,15 @@ fn_printzp(register const u_char *s, register u_int n,
ret = 0;
break;
}
- if (!isascii(c)) {
- c = toascii(c);
- putchar('M');
- putchar('-');
+ if (!ND_ISASCII(c)) {
+ c = ND_TOASCII(c);
+ ND_PRINT((ndo, "M-"));
}
- if (!isprint(c)) {
+ if (!ND_ISPRINT(c)) {
c ^= 0x40; /* DEL to ?, others to alpha */
- putchar('^');
+ ND_PRINT((ndo, "^"));
}
- putchar(c);
+ ND_PRINT((ndo, "%c", c));
}
return (n == 0) ? 0 : ret;
}
@@ -143,12 +134,33 @@ fn_printzp(register const u_char *s, register u_int n,
/*
* Format the timestamp
*/
-char *
-ts_format(register int sec, register int usec)
+static char *
+ts_format(netdissect_options *ndo, int sec, 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);
+ static char buf[sizeof("00:00:00.000000000")];
+ const char *format;
+
+#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
+ switch (ndo->ndo_tstamp_precision) {
+
+ case PCAP_TSTAMP_PRECISION_MICRO:
+ format = "%02d:%02d:%02d.%06u";
+ break;
+
+ case PCAP_TSTAMP_PRECISION_NANO:
+ format = "%02d:%02d:%02d.%09u";
+ break;
+
+ default:
+ format = "%02d:%02d:%02d.{unknown precision}";
+ break;
+ }
+#else
+ format = "%02d:%02d:%02d.%06u";
+#endif
+
+ snprintf(buf, sizeof(buf), format,
+ sec / 3600, (sec % 3600) / 60, sec % 60, usec);
return buf;
}
@@ -157,7 +169,8 @@ ts_format(register int sec, register int usec)
* Print the timestamp
*/
void
-ts_print(register const struct timeval *tvp)
+ts_print(netdissect_options *ndo,
+ register const struct timeval *tvp)
{
register int s;
struct tm *tm;
@@ -167,20 +180,20 @@ ts_print(register const struct timeval *tvp)
int d_usec;
int d_sec;
- switch (tflag) {
+ switch (ndo->ndo_tflag) {
case 0: /* Default */
s = (tvp->tv_sec + thiszone) % 86400;
- (void)printf("%s ", ts_format(s, tvp->tv_usec));
+ ND_PRINT((ndo, "%s ", ts_format(ndo, s, tvp->tv_usec)));
break;
case 1: /* No time stamp */
break;
case 2: /* Unix timeval style */
- (void)printf("%u.%06u ",
+ ND_PRINT((ndo, "%u.%06u ",
(unsigned)tvp->tv_sec,
- (unsigned)tvp->tv_usec);
+ (unsigned)tvp->tv_usec));
break;
case 3: /* Microseconds since previous packet */
@@ -188,20 +201,20 @@ ts_print(register const struct timeval *tvp)
if (b_sec == 0) {
/* init timestamp for first packet */
b_usec = tvp->tv_usec;
- b_sec = tvp->tv_sec;
+ 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));
+ ND_PRINT((ndo, "%s ", ts_format(ndo, d_sec, d_usec)));
- if (tflag == 3) { /* set timestamp for last packet */
+ if (ndo->ndo_tflag == 3) { /* set timestamp for last packet */
b_sec = tvp->tv_sec;
b_usec = tvp->tv_usec;
}
@@ -212,11 +225,11 @@ ts_print(register const struct timeval *tvp)
Time = (tvp->tv_sec + thiszone) - s;
tm = gmtime (&Time);
if (!tm)
- printf("Date fail ");
+ ND_PRINT((ndo, "Date fail "));
else
- printf("%04d-%02d-%02d %s ",
+ ND_PRINT((ndo, "%04d-%02d-%02d %s ",
tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
- ts_format(s, tvp->tv_usec));
+ ts_format(ndo, s, tvp->tv_usec)));
break;
}
}
@@ -227,7 +240,8 @@ ts_print(register const struct timeval *tvp)
* is represented as 1y1w1d1h1m1s.
*/
void
-relts_print(int secs)
+relts_print(netdissect_options *ndo,
+ int secs)
{
static const char *lengths[] = {"y", "w", "d", "h", "m", "s"};
static const int seconds[] = {31536000, 604800, 86400, 3600, 60, 1};
@@ -235,16 +249,16 @@ relts_print(int secs)
const int *s = seconds;
if (secs == 0) {
- (void)printf("0s");
+ ND_PRINT((ndo, "0s"));
return;
}
if (secs < 0) {
- (void)printf("-");
+ ND_PRINT((ndo, "-"));
secs = -secs;
}
while (secs > 0) {
if (secs >= *s) {
- (void)printf("%d%s", secs / *s, *l);
+ ND_PRINT((ndo, "%d%s", secs / *s, *l));
secs -= (secs / *s) * *s;
}
s++;
@@ -259,21 +273,21 @@ relts_print(int secs)
*/
int
-print_unknown_data(const u_char *cp,const char *ident,int len)
+print_unknown_data(netdissect_options *ndo, const u_char *cp,const char *ident,int len)
{
if (len < 0) {
- printf("%sDissector error: print_unknown_data called with negative length",
- ident);
+ ND_PRINT((ndo,"%sDissector error: print_unknown_data called with negative length",
+ ident));
return(0);
}
- if (snapend - cp < len)
- len = snapend - cp;
+ if (ndo->ndo_snapend - cp < len)
+ len = ndo->ndo_snapend - cp;
if (len < 0) {
- printf("%sDissector error: print_unknown_data called with pointer past end of packet",
- ident);
+ ND_PRINT((ndo,"%sDissector error: print_unknown_data called with pointer past end of packet",
+ ident));
return(0);
}
- hex_print(ident,cp,len);
+ hex_print(ndo, ident,cp,len);
return(1); /* everything is ok */
}
@@ -282,7 +296,7 @@ print_unknown_data(const u_char *cp,const char *ident,int len)
*/
const char *
tok2strbuf(register const struct tok *lp, register const char *fmt,
- register int v, char *buf, size_t bufsize)
+ register u_int v, char *buf, size_t bufsize)
{
if (lp != NULL) {
while (lp->s != NULL) {
@@ -327,6 +341,7 @@ bittok2str_internal(register const struct tok *lp, register const char *fmt,
int buflen=0;
register int rotbit; /* this is the bit we rotate through all bitpositions */
register int tokval;
+ const char * sepstr = "";
while (lp != NULL && lp->s != NULL) {
tokval=lp->v; /* load our first value */
@@ -339,7 +354,8 @@ bittok2str_internal(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%s",
- lp->s, sep ? ", " : "");
+ sepstr, lp->s);
+ sepstr = sep ? ", " : "";
break;
}
rotbit=rotbit<<1; /* no match - lets shift and try again */
@@ -347,23 +363,10 @@ bittok2str_internal(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';
- return (buf);
- }
- else {
+ if (buflen == 0)
/* bummer - lets print the "unknown" message as advised in the fmt string if we got one */
- if (fmt == NULL)
- fmt = "#%d";
- (void)snprintf(buf, sizeof(buf), fmt, v);
- return (buf);
- }
+ (void)snprintf(buf, sizeof(buf), fmt == NULL ? "#%d" : fmt, v);
+ return (buf);
}
/*
@@ -415,9 +418,9 @@ tok2strary_internal(register const char **lp, int n, register const char *fmt,
*/
int
-mask2plen(u_int32_t mask)
+mask2plen(uint32_t mask)
{
- u_int32_t bitmasks[33] = {
+ uint32_t bitmasks[33] = {
0x00000000,
0x80000000, 0xc0000000, 0xe0000000, 0xf0000000,
0xf8000000, 0xfc000000, 0xfe000000, 0xff000000,
@@ -584,25 +587,41 @@ read_infile(char *fname)
}
void
-safeputs(const char *s, int maxlen)
+safeputs(netdissect_options *ndo,
+ const u_char *s, const u_int maxlen)
{
- int idx = 0;
+ u_int idx = 0;
while (*s && idx < maxlen) {
- safeputchar(*s);
- idx++;
+ safeputchar(ndo, *s);
+ idx++;
s++;
}
}
void
-safeputchar(int c)
+safeputchar(netdissect_options *ndo,
+ const u_char c)
{
- unsigned char ch;
+ ND_PRINT((ndo, (c < 0x80 && ND_ISPRINT(c)) ? "%c" : "\\0x%02x", c));
+}
- ch = (unsigned char)(c & 0xff);
- if (ch < 0x80 && isprint(ch))
- printf("%c", ch);
- else
- printf("\\0x%02x", ch);
+#ifdef LBL_ALIGN
+/*
+ * Some compilers try to optimize memcpy(), using the alignment constraint
+ * on the argument pointer type. by using this function, we try to avoid the
+ * optimization.
+ */
+void
+unaligned_memcpy(void *p, const void *q, size_t l)
+{
+ memcpy(p, q, l);
+}
+
+/* As with memcpy(), so with memcmp(). */
+int
+unaligned_memcmp(const void *p, const void *q, size_t l)
+{
+ return (memcmp(p, q, l));
}
+#endif
diff --git a/contrib/tcpdump/vfprintf.c b/contrib/tcpdump/vfprintf.c
index 6f8407af6960..6f3e15f71289 100644
--- a/contrib/tcpdump/vfprintf.c
+++ b/contrib/tcpdump/vfprintf.c
@@ -19,11 +19,6 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#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)";
-#endif
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif