aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGleb Smirnoff <glebius@FreeBSD.org>2017-01-31 19:17:06 +0000
committerGleb Smirnoff <glebius@FreeBSD.org>2017-01-31 19:17:06 +0000
commitd79b843cb78484ea27f877f1541055e1a6a5a4d3 (patch)
tree57b11b7f3aa68244815f4469b548fcab0c5c3e78
parent1bf4ba1024df1c302debe8156a60a9dfafb149ee (diff)
downloadsrc-d79b843cb78484ea27f877f1541055e1a6a5a4d3.tar.gz
src-d79b843cb78484ea27f877f1541055e1a6a5a4d3.zip
Import tcpdump-4.9.0 into dist.
Notes
Notes: svn path=/vendor/tcpdump/dist/; revision=313024
-rw-r--r--CHANGES190
-rw-r--r--CONTRIBUTING103
-rw-r--r--CREDITS7
-rw-r--r--INSTALL.txt103
-rw-r--r--Makefile.in66
-rw-r--r--PLATFORMS9
l---------README1
-rw-r--r--VERSION2
-rw-r--r--aclocal.m4175
-rw-r--r--addrtoname.c240
-rw-r--r--addrtoname.h32
-rw-r--r--addrtostr.c (renamed from missing/inet_ntop.c)96
-rw-r--r--addrtostr.h (renamed from missing/inet_pton.c)17
-rw-r--r--af.c5
-rw-r--r--af.h6
-rw-r--r--ascii_strcasecmp.c105
-rw-r--r--ascii_strcasecmp.h33
-rw-r--r--atmuni31.h85
-rw-r--r--bpf_dump.c5
-rw-r--r--checksum.c13
-rw-r--r--config.h.in37
-rwxr-xr-xconfigure1167
-rwxr-xr-xconfigure.in417
-rw-r--r--cpack.c19
-rw-r--r--cpack.h10
-rw-r--r--ether.h11
-rw-r--r--ethertype.h3
-rw-r--r--extract.h31
-rw-r--r--gmpls.c5
-rw-r--r--gmt2local.c3
-rw-r--r--in_cksum.c13
-rw-r--r--interface.h150
-rw-r--r--ip.h44
-rw-r--r--ip6.h7
-rwxr-xr-xipproto.c5
-rwxr-xr-xl2vpn.c101
-rwxr-xr-xl2vpn.h1
-rw-r--r--lbl/os-solaris2.h1
-rw-r--r--lbl/os-sunos4.h2
-rw-r--r--lbl/os-ultrix4.h1
-rw-r--r--machdep.c2
-rw-r--r--machdep.h4
-rw-r--r--mib.h2
-rw-r--r--missing/addrinfo.h117
-rw-r--r--missing/datalinks.c2
-rw-r--r--missing/dlnames.c5
-rw-r--r--missing/getnameinfo.c276
-rw-r--r--missing/inet_aton.c53
-rw-r--r--missing/snprintf.c2
-rw-r--r--missing/strdup.c2
-rw-r--r--missing/strlcat.c6
-rw-r--r--missing/strlcpy.c6
-rw-r--r--missing/strsep.c6
-rw-r--r--nameser.h14
-rw-r--r--netdissect-stdinc.h (renamed from tcpdump-stdinc.h)88
-rw-r--r--netdissect.c146
-rw-r--r--netdissect.h596
-rw-r--r--nfsfh.h2
-rwxr-xr-xnlpid.c5
-rw-r--r--oui.c6
-rw-r--r--oui.h47
-rw-r--r--parsenfsfh.c241
-rw-r--r--pcap-missing.h15
-rw-r--r--print-802_11.c1773
-rw-r--r--print-802_15_4.c13
-rw-r--r--print-ah.c20
-rw-r--r--print-ahcp.c84
-rw-r--r--print-aodv.c69
-rw-r--r--print-aoe.c56
-rw-r--r--print-ap1394.c30
-rw-r--r--print-arcnet.c7
-rw-r--r--print-arp.c23
-rw-r--r--print-ascii.c7
-rw-r--r--print-atalk.c61
-rw-r--r--print-atm.c150
-rw-r--r--print-babel.c187
-rw-r--r--print-beep.c9
-rw-r--r--print-bfd.c186
-rw-r--r--print-bgp.c499
-rw-r--r--print-bootp.c29
-rw-r--r--print-bt.c7
-rw-r--r--print-calm-fast.c29
-rw-r--r--print-carp.c7
-rw-r--r--print-cdp.c21
-rw-r--r--print-cfm.c340
-rw-r--r--print-chdlc.c11
-rw-r--r--print-cip.c47
-rw-r--r--print-cnfp.c7
-rw-r--r--print-dccp.c48
-rw-r--r--print-decnet.c134
-rw-r--r--print-dhcp6.c126
-rw-r--r--print-domain.c24
-rw-r--r--print-dtp.c36
-rw-r--r--print-dvmrp.c9
-rw-r--r--print-eap.c12
-rw-r--r--print-egp.c36
-rw-r--r--print-eigrp.c7
-rw-r--r--print-enc.c9
-rw-r--r--print-esp.c151
-rw-r--r--print-ether.c178
-rw-r--r--print-fddi.c60
-rw-r--r--print-forces.c126
-rw-r--r--print-fr.c445
-rw-r--r--print-frag6.c10
-rw-r--r--print-ftp.c7
-rw-r--r--print-geneve.c48
-rw-r--r--print-geonet.c29
-rw-r--r--print-gre.c102
-rw-r--r--print-hncp.c855
-rw-r--r--print-hsrp.c13
-rw-r--r--print-http.c9
-rw-r--r--print-icmp.c41
-rw-r--r--print-icmp6.c203
-rw-r--r--print-igmp.c15
-rw-r--r--print-igrp.c25
-rw-r--r--print-ip.c136
-rw-r--r--print-ip6.c187
-rw-r--r--print-ip6opts.c13
-rw-r--r--print-ipcomp.c60
-rw-r--r--print-ipfc.c58
-rw-r--r--print-ipnet.c13
-rw-r--r--print-ipx.c26
-rw-r--r--print-isakmp.c464
-rw-r--r--print-isoclns.c504
-rw-r--r--print-juniper.c39
-rw-r--r--print-krb.c11
-rw-r--r--print-l2tp.c73
-rw-r--r--print-lane.c11
-rw-r--r--print-ldp.c27
-rw-r--r--print-lisp.c449
-rw-r--r--print-llc.c244
-rw-r--r--print-lldp.c58
-rw-r--r--print-lmp.c23
-rw-r--r--print-loopback.c36
-rw-r--r--print-lspping.c641
-rw-r--r--print-lwapp.c11
-rw-r--r--print-lwres.c41
-rw-r--r--print-m3ua.c32
-rw-r--r--print-medsa.c196
-rw-r--r--print-mobile.c11
-rw-r--r--print-mobility.c62
-rw-r--r--print-mpcp.c9
-rw-r--r--print-mpls.c27
-rw-r--r--print-mptcp.c31
-rw-r--r--print-msdp.c7
-rw-r--r--print-msnlb.c9
-rw-r--r--print-nflog.c13
-rw-r--r--print-nfs.c134
-rw-r--r--print-nsh.c185
-rw-r--r--print-ntp.c30
-rw-r--r--print-null.c9
-rw-r--r--print-olsr.c184
-rw-r--r--print-openflow-1.0.c178
-rw-r--r--print-openflow.c16
-rw-r--r--print-ospf.c148
-rw-r--r--print-ospf6.c65
-rw-r--r--print-otv.c41
-rw-r--r--print-pflog.c10
-rw-r--r--print-pgm.c288
-rw-r--r--print-pim.c130
-rw-r--r--print-pktap.c28
-rw-r--r--print-ppi.c54
-rw-r--r--print-ppp.c22
-rw-r--r--print-pppoe.c17
-rw-r--r--print-pptp.c39
-rw-r--r--print-radius.c56
-rw-r--r--print-raw.c7
-rw-r--r--print-resp.c538
-rw-r--r--print-rip.c37
-rw-r--r--print-ripng.c12
-rw-r--r--print-rpki-rtr.c53
-rw-r--r--print-rrcp.c71
-rw-r--r--print-rsvp.c173
-rw-r--r--print-rt6.c32
-rw-r--r--print-rtsp.c9
-rw-r--r--print-rx.c131
-rw-r--r--print-sctp.c217
-rw-r--r--print-sflow.c68
-rw-r--r--print-sip.c7
-rw-r--r--print-sl.c31
-rw-r--r--print-sll.c38
-rw-r--r--print-slow.c274
-rw-r--r--print-smb.c37
-rw-r--r--print-smtp.c4
-rw-r--r--print-snmp.c346
-rw-r--r--print-stp.c110
-rw-r--r--print-sunatm.c7
-rw-r--r--print-sunrpc.c21
-rw-r--r--print-symantec.c17
-rwxr-xr-xprint-syslog.c7
-rw-r--r--print-tcp.c279
-rw-r--r--print-telnet.c21
-rw-r--r--print-tftp.c93
-rw-r--r--print-timed.c15
-rw-r--r--print-tipc.c30
-rw-r--r--print-token.c44
-rw-r--r--print-udld.c71
-rw-r--r--print-udp.c322
-rw-r--r--print-usb.c7
-rw-r--r--print-vjc.c18
-rw-r--r--print-vqp.c9
-rw-r--r--print-vrrp.c9
-rw-r--r--print-vtp.c50
-rw-r--r--print-vxlan-gpe.c113
-rw-r--r--print-vxlan.c28
-rw-r--r--print-wb.c35
-rw-r--r--print-zephyr.c59
-rw-r--r--print-zeromq.c35
-rw-r--r--print.c484
-rw-r--r--print.h44
-rw-r--r--rpl.h8
-rw-r--r--setsignal.c2
-rw-r--r--signature.c88
-rw-r--r--signature.h6
-rw-r--r--smb.h2
-rw-r--r--smbutil.c10
-rw-r--r--strcasecmp.c88
-rw-r--r--strtoaddr.c239
-rw-r--r--strtoaddr.h23
-rw-r--r--tcp.h70
-rw-r--r--tcpdump.1.in31
-rw-r--r--tcpdump.c1739
-rw-r--r--tests/OLSRv1_HNA_sgw_1.out13
-rw-r--r--tests/OLSRv1_HNA_sgw_1.pcapbin0 -> 158 bytes
-rw-r--r--tests/RADIUS-port1700.pcapbin0 -> 107 bytes
-rw-r--r--tests/TESTLIST188
-rwxr-xr-xtests/TESTonce6
-rw-r--r--tests/aarp-heapoverflow-1.out1
-rw-r--r--tests/aarp-heapoverflow-1.pcapbin0 -> 329 bytes
-rw-r--r--tests/aarp-heapoverflow-2.out1
-rw-r--r--tests/aarp-heapoverflow-2.pcapbin0 -> 329 bytes
-rw-r--r--tests/arp-too-long-tha.out1
-rw-r--r--tests/arp-too-long-tha.pcapbin0 -> 180 bytes
-rw-r--r--tests/atm-heapoverflow.out1
-rw-r--r--tests/atm-heapoverflow.pcapbin0 -> 124 bytes
-rw-r--r--tests/atm-oam-heapoverflow.out1
-rw-r--r--tests/atm-oam-heapoverflow.pcapbin0 -> 88 bytes
-rw-r--r--tests/bad-ipv4-version-pgm-heapoverflow.out1
-rw-r--r--tests/bad-ipv4-version-pgm-heapoverflow.pcapbin0 -> 329 bytes
-rw-r--r--tests/bfd-raw-auth-md5-v.out341
-rw-r--r--tests/bfd-raw-auth-md5.out31
-rw-r--r--tests/bfd-raw-auth-md5.pcapbin0 -> 3434 bytes
-rw-r--r--tests/bfd-raw-auth-sha1-v.out275
-rw-r--r--tests/bfd-raw-auth-sha1.out25
-rw-r--r--tests/bfd-raw-auth-sha1.pcapbin0 -> 2874 bytes
-rw-r--r--tests/bfd-raw-auth-simple-v.out150
-rw-r--r--tests/bfd-raw-auth-simple.out15
-rw-r--r--tests/bfd-raw-auth-simple.pcapbin0 -> 1449 bytes
-rw-r--r--tests/bgp-aigp.out20
-rw-r--r--tests/bgp-aigp.pcapbin0 -> 258 bytes
-rw-r--r--tests/bgp-large-community.out42
-rw-r--r--tests/bgp-large-community.pcapbin0 -> 481 bytes
-rw-r--r--tests/calm-fast-mac-lookup-heapoverflow.out5
-rw-r--r--tests/calm-fast-mac-lookup-heapoverflow.pcapbin0 -> 202 bytes
-rwxr-xr-xtests/crypto.sh4
-rw-r--r--tests/cve-2014-8767-OLSR.out4
-rw-r--r--tests/cve-2014-8767-OLSR.pcapbin0 -> 115 bytes
-rw-r--r--tests/cve-2014-8768-Geonet.out1
-rw-r--r--tests/cve-2014-8768-Geonet.pcapbin0 -> 115 bytes
-rw-r--r--tests/cve-2014-8769-AODV.out2
-rw-r--r--tests/cve-2014-8769-AODV.pcapbin0 -> 115 bytes
-rw-r--r--tests/cve2015-0261-crash.pcapbin201 -> 201 bytes
-rw-r--r--tests/cve2015-0261-ipv6.out2
-rw-r--r--tests/dhcp-mud.out36
-rw-r--r--tests/dhcp-mud.pcapbin0 -> 844 bytes
-rw-r--r--tests/dhcpv6-mud.out5
-rw-r--r--tests/dhcpv6-mud.pcapbin0 -> 1634 bytes
-rw-r--r--tests/dnssec-vv.out12
-rw-r--r--tests/dnssec.pcapbin0 -> 3936 bytes
-rw-r--r--tests/dtp-v.out35
-rw-r--r--tests/evb.out120
-rw-r--r--tests/failure-outputs.txt0
-rw-r--r--tests/frf15-heapoverflow.out1
-rw-r--r--tests/frf15-heapoverflow.pcapbin0 -> 88 bytes
-rw-r--r--tests/geonet-mac-lookup-heapoverflow.out1
-rw-r--r--tests/geonet-mac-lookup-heapoverflow.pcapbin0 -> 74 bytes
-rw-r--r--tests/gre-heapoverflow-1.out8
-rw-r--r--tests/gre-heapoverflow-1.pcapbin0 -> 202 bytes
-rw-r--r--tests/gre-heapoverflow-2.out6
-rw-r--r--tests/gre-heapoverflow-2.pcapbin0 -> 202 bytes
-rw-r--r--tests/heap-overflow-1.out1
-rw-r--r--tests/heap-overflow-1.pcapbin0 -> 88 bytes
-rw-r--r--tests/heap-overflow-2.out1
-rw-r--r--tests/heap-overflow-2.pcapbin0 -> 88 bytes
-rw-r--r--tests/heapoverflow-EXTRACT_16BITS.out1
-rw-r--r--tests/heapoverflow-EXTRACT_16BITS.pcapbin0 -> 88 bytes
-rw-r--r--tests/heapoverflow-atalk_print.out1
-rw-r--r--tests/heapoverflow-atalk_print.pcapbin0 -> 88 bytes
-rw-r--r--tests/heapoverflow-in_checksum.out3
-rw-r--r--tests/heapoverflow-in_checksum.pcapbin0 -> 88 bytes
-rw-r--r--tests/heapoverflow-ip_print_demux.out6
-rw-r--r--tests/heapoverflow-ip_print_demux.pcapbin0 -> 202 bytes
-rw-r--r--tests/heapoverflow-ppp_hdlc_if_print.out1
-rw-r--r--tests/heapoverflow-ppp_hdlc_if_print.pcapbin0 -> 88 bytes
-rw-r--r--tests/heapoverflow-q933_printq.out2
-rw-r--r--tests/heapoverflow-q933_printq.pcapbin0 -> 88 bytes
-rw-r--r--tests/heapoverflow-sl_if_print.out1
-rw-r--r--tests/heapoverflow-sl_if_print.pcapbin0 -> 88 bytes
-rw-r--r--tests/heapoverflow-tcp_print.out2
-rw-r--r--tests/heapoverflow-tcp_print.pcapbin0 -> 112 bytes
-rw-r--r--tests/hncp.out53
-rw-r--r--tests/hncp.pcapbin0 -> 1566 bytes
-rw-r--r--tests/ieee802.11_exthdr.out52
-rw-r--r--tests/ieee802.11_rx-stbc.out6
-rw-r--r--tests/ikev2pI2-segfault-v.out8
-rw-r--r--tests/ikev2pI2-segfault.out1
-rw-r--r--tests/ikev2pI2-segfault.pcapbin0 -> 656 bytes
-rw-r--r--tests/ipcomp-heapoverflow.out2
-rw-r--r--tests/ipcomp-heapoverflow.pcapbin0 -> 329 bytes
-rw-r--r--tests/ipv6hdr-heapoverflow-v.out1
-rw-r--r--tests/ipv6hdr-heapoverflow.out1
-rw-r--r--tests/ipv6hdr-heapoverflow.pcapbin0 -> 88 bytes
-rw-r--r--tests/isis-seg-fault-1-v.out301
-rwxr-xr-xtests/isis-seg-fault-1-v.sh17
-rw-r--r--tests/isis-seg-fault-1.pcapbin0 -> 1632 bytes
-rw-r--r--tests/isis-seg-fault-2-v.out222
-rw-r--r--tests/isis-seg-fault-2.pcapbin0 -> 1632 bytes
-rw-r--r--tests/isis-seg-fault-3-v.out4
-rw-r--r--tests/isis-seg-fault-3.pcapbin0 -> 196 bytes
-rw-r--r--tests/isis_poi.out8
-rw-r--r--tests/isis_poi.pcapbin0 -> 122 bytes
-rw-r--r--tests/isis_poi2.out9
-rw-r--r--tests/isis_poi2.pcapbin0 -> 128 bytes
-rw-r--r--tests/isoclns-heapoverflow-2.out1
-rw-r--r--tests/isoclns-heapoverflow-2.pcapbin0 -> 152 bytes
-rw-r--r--tests/isoclns-heapoverflow-3.out1
-rw-r--r--tests/isoclns-heapoverflow-3.pcapbin0 -> 152 bytes
-rw-r--r--tests/isoclns-heapoverflow.out1
-rw-r--r--tests/isoclns-heapoverflow.pcapbin0 -> 329 bytes
-rw-r--r--tests/juniper_header-heapoverflow.out1
-rw-r--r--tests/juniper_header-heapoverflow.pcapbin0 -> 200 bytes
-rw-r--r--tests/kday1.out15
-rw-r--r--tests/kday2.out9
-rw-r--r--tests/kday3.out13
-rw-r--r--tests/kday4.out16
-rw-r--r--tests/kday5.out7
-rw-r--r--tests/kday6.out20
-rw-r--r--tests/kday7.out17
-rw-r--r--tests/kday8.out9
-rw-r--r--tests/lisp_eid_notify.out63
-rw-r--r--tests/lisp_eid_notify.pcapbin0 -> 776 bytes
-rw-r--r--tests/lisp_eid_register.out28
-rw-r--r--tests/lisp_eid_register.pcapbin0 -> 384 bytes
-rw-r--r--tests/lisp_ipv6.out24
-rw-r--r--tests/lisp_ipv6.pcapbin0 -> 396 bytes
-rw-r--r--tests/llc-xid-heapoverflow.out1
-rw-r--r--tests/llc-xid-heapoverflow.pcapbin0 -> 329 bytes
-rw-r--r--tests/lldp_cdp-ev.out8
-rw-r--r--tests/lldp_mudurl-v.out62
-rw-r--r--tests/lldp_mudurl-vv.out106
-rw-r--r--tests/lldp_mudurl.pcapbin0 -> 660 bytes
-rwxr-xr-xtests/lmp-v.sh4
-rw-r--r--tests/lspping-fec-ldp-v.out111
-rw-r--r--tests/lspping-fec-ldp-vv.out121
-rw-r--r--tests/lspping-fec-ldp.out13
-rw-r--r--tests/lspping-fec-rsvp-v.out105
-rw-r--r--tests/lspping-fec-rsvp-vv.out125
-rw-r--r--tests/lspping-fec-rsvp.out10
-rw-r--r--tests/medsa-e.out20
-rw-r--r--tests/medsa.out20
-rw-r--r--tests/medsa.pcapbin0 -> 2568 bytes
-rw-r--r--tests/mpls-label-heapoverflow.out2
-rw-r--r--tests/mpls-label-heapoverflow.pcapbin0 -> 329 bytes
-rw-r--r--tests/mpls-traceroute-v.out81
-rw-r--r--tests/mpls-traceroute.out18
-rw-r--r--tests/mstp-v.out80
-rwxr-xr-xtests/nflog-e.sh2
-rw-r--r--tests/nfs-seg-fault-1.out1
-rw-r--r--tests/nfs-seg-fault-1.pcapbin0 -> 8120 bytes
-rw-r--r--tests/nsh-over-vxlan-gpe-v.out5
-rw-r--r--tests/nsh-over-vxlan-gpe-vv.out5
-rw-r--r--tests/nsh-over-vxlan-gpe-vvv.out9
-rw-r--r--tests/nsh-over-vxlan-gpe.out1
-rw-r--r--tests/nsh-over-vxlan-gpe.pcapbin0 -> 146 bytes
-rw-r--r--tests/of10_p3295-vv.out4
-rw-r--r--tests/of10_s4810-vvvv.out24
-rw-r--r--tests/ospf2-seg-fault-1-v.out9
-rw-r--r--tests/ospf2-seg-fault-1.pcapbin0 -> 292 bytes
-rw-r--r--tests/otv-heapoverflow-1.out10
-rw-r--r--tests/otv-heapoverflow-1.pcapbin0 -> 896 bytes
-rw-r--r--tests/otv-heapoverflow-2.out11
-rw-r--r--tests/otv-heapoverflow-2.pcapbin0 -> 896 bytes
-rw-r--r--tests/pcap-invalid-version-1.out1
-rw-r--r--tests/pcap-invalid-version-1.pcapbin0 -> 530 bytes
-rw-r--r--tests/pcap-invalid-version-2.out1
-rw-r--r--tests/pcap-invalid-version-2.pcapbin0 -> 530 bytes
-rw-r--r--tests/pcap-ng-invalid-vers-1.out1
-rw-r--r--tests/pcap-ng-invalid-vers-1.pcapbin0 -> 260 bytes
-rw-r--r--tests/pcap-ng-invalid-vers-2.out1
-rw-r--r--tests/pcap-ng-invalid-vers-2.pcapbin0 -> 260 bytes
-rw-r--r--tests/q933-heapoverflow-2.out24
-rw-r--r--tests/q933-heapoverflow-2.pcapbin0 -> 1483 bytes
-rw-r--r--tests/radiotap-heapoverflow.out1
-rw-r--r--tests/radiotap-heapoverflow.pcapbin0 -> 296 bytes
-rw-r--r--tests/radius-port1700-v.out4
-rw-r--r--tests/radius-rfc4675-v.out2
-rw-r--r--tests/relts-0x80000000.out2
-rw-r--r--tests/relts-0x80000000.pcapbin0 -> 440 bytes
-rw-r--r--tests/resp_1.out150
-rw-r--r--tests/resp_1_benchmark.pcapbin0 -> 26858 bytes
-rw-r--r--tests/resp_2.out14
-rw-r--r--tests/resp_2_inline.pcapbin0 -> 2671 bytes
-rw-r--r--tests/resp_3.out163
-rw-r--r--tests/resp_3_malicious.pcapbin0 -> 14724 bytes
-rw-r--r--tests/rpl-14-daovvv.out2
-rw-r--r--tests/rpl-19-pickdag.out2
-rw-r--r--tests/rpl-19-pickdagvvv.out2
-rw-r--r--tests/rpl-26-senddaovv.out2
-rw-r--r--tests/rsvp-inf-loop-2-v.out12
-rw-r--r--tests/rsvp-inf-loop-2.pcapbin0 -> 400 bytes
-rw-r--r--tests/rtp-seg-fault-1.out2
-rw-r--r--tests/rtp-seg-fault-1.pcapbin0 -> 2360 bytes
-rw-r--r--tests/rtp-seg-fault-2.out2
-rw-r--r--tests/rtp-seg-fault-2.pcapbin0 -> 1192 bytes
-rw-r--r--tests/scps_invalid.out2
-rw-r--r--tests/scps_invalid.pcapbin0 -> 264 bytes
-rw-r--r--tests/snmp-heapoverflow-1.out21
-rw-r--r--tests/snmp-heapoverflow-1.pcapbin0 -> 2804 bytes
-rw-r--r--tests/snmp-heapoverflow-2.out1
-rw-r--r--tests/snmp-heapoverflow-2.pcapbin0 -> 173 bytes
-rw-r--r--tests/spb_bpduv4-v.out400
-rw-r--r--tests/stp-heapoverflow-1.out27
-rw-r--r--tests/stp-heapoverflow-1.pcapbin0 -> 1076 bytes
-rw-r--r--tests/stp-heapoverflow-2.out27
-rw-r--r--tests/stp-heapoverflow-2.pcapbin0 -> 1076 bytes
-rw-r--r--tests/stp-heapoverflow-3.out27
-rw-r--r--tests/stp-heapoverflow-3.pcapbin0 -> 1076 bytes
-rw-r--r--tests/stp-heapoverflow-4.out27
-rw-r--r--tests/stp-heapoverflow-4.pcapbin0 -> 1076 bytes
-rw-r--r--tests/stp-heapoverflow-5.out27
-rw-r--r--tests/stp-heapoverflow-5.pcapbin0 -> 1076 bytes
-rw-r--r--tests/tcp-auth-heapoverflow.out2
-rw-r--r--tests/tcp-auth-heapoverflow.pcapbin0 -> 138 bytes
-rw-r--r--tests/tcp_header_heapoverflow.out2
-rw-r--r--tests/tcp_header_heapoverflow.pcapbin0 -> 329 bytes
-rw-r--r--tests/tftp-heapoverflow.out2
-rw-r--r--tests/tftp-heapoverflow.pcapbin0 -> 180 bytes
-rw-r--r--tests/trunc_aack.out1
-rw-r--r--tests/truncated-aack.pcapbin0 -> 50 bytes
-rw-r--r--tests/udld-inf-loop-1-v.out9
-rw-r--r--tests/udld-inf-loop-1.pcapbin0 -> 220 bytes
-rw-r--r--tests/udld-v.out406
-rw-r--r--tests/udp-length-heapoverflow.out2
-rw-r--r--tests/udp-length-heapoverflow.pcapbin0 -> 329 bytes
-rw-r--r--tests/unaligned-nfs-1.out2
-rw-r--r--tests/unaligned-nfs-1.pcapbin0 -> 222 bytes
-rw-r--r--tests/vxlan.out20
-rw-r--r--tests/vxlan.pcapbin0 -> 1552 bytes
-rw-r--r--tests/zmtp1-inf-loop-1.out2
-rw-r--r--tests/zmtp1-inf-loop-1.pcapbin0 -> 208 bytes
-rw-r--r--timeval-operations.h78
-rw-r--r--udp.h325
-rw-r--r--util-print.c (renamed from util.c)380
-rw-r--r--vfprintf.c2
-rw-r--r--win32/Include/w32_fzs.h48
-rw-r--r--win32/prj/WinDump.dsp166
-rw-r--r--win32/prj/WinDump.sln20
-rw-r--r--win32/prj/WinDump.vcproj3950
-rw-r--r--win32/src/ether_ntohost.c219
459 files changed, 23030 insertions, 9673 deletions
diff --git a/CHANGES b/CHANGES
index 38769f2c4ea7..7c4be177173d 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,187 @@
+Wednesday January 18, 2017 devel.fx.lebail@orange.fr
+ Summary for 4.9.0 tcpdump release
+ General updates:
+ Improve separation frontend/backend (tcpdump/libnetdissect)
+ Don't require IPv6 library support in order to support IPv6 addresses
+ Introduce data types to use for integral values in packet structures
+ Fix display of timestamps with -tt, -ttt and -ttttt options
+ Fix some heap overflows found with American Fuzzy Lop by Hanno Boeck and others
+ (More information in the log with CVE-2016-* and CVE-2017-*)
+ Change the way protocols print link-layer addresses (Fix heap overflows
+ in CALM-FAST and GeoNetworking printers)
+ Pass correct caplen value to ether_print() and some other functions
+ Fix lookup_nsap() to match what isonsap_string() expects
+ Clean up relative time stamp printing (Fix an array overflow)
+ Fix some alignment issues with GCC on Solaris 10 SPARC
+ Add some ND_TTEST_/ND_TCHECK_ macros to simplify writing bounds checks
+ Add a fn_printztn() which returns the number of bytes processed
+ Add nd_init() and nd_cleanup() functions. Improve libsmi support
+ Add CONTRIBUTING file
+ Add a summary comment in all printers
+ Compile with more warning options in devel mode if supported (-Wcast-qual, ...)
+ Fix some leaks found by Valgrind/Memcheck
+ Fix a bunch of de-constifications
+ Squelch some Coverity warnings and some compiler warnings
+ Update Coverity and Travis-CI setup
+ Update Visual Studio files
+
+ Frontend:
+ Fix capsicum support to work with zerocopy buffers in bpf
+ Try opening interfaces by name first, then by name-as-index
+ Work around pcap_create() failures fetching time stamp type lists
+ Fix a segmentation fault with 'tcpdump -J'
+ Improve addrtostr6() bounds checking
+ Add exit_tcpdump() function
+ Don't drop CAP_SYS_CHROOT before chrooting
+ Fixes issue where statistics not reported when -G and -W options used
+
+ New printers supporting:
+ Generic Protocol Extension for VXLAN (VXLAN-GPE)
+ Home Networking Control Protocol (HNCP), RFCs 7787 and 7788
+ Locator/Identifier Separation Protocol (LISP), type 3 and type 4 packets
+ Marvell Extended Distributed Switch Architecture header (MEDSA)
+ Network Service Header (NSH)
+ REdis Serialization Protocol (RESP)
+
+ Updated printers:
+ 802.11: Beginnings of 11ac radiotap support
+ 802.11: Check the Protected bit for management frames
+ 802.11: Do bounds checking on last_presentp before dereferencing it (Fix a heap overflow)
+ 802.11: Fix the radiotap printer to handle the special bits correctly
+ 802.11: If we have the MCS field, it's 11n
+ 802.11: Only print unknown frame type or subtype messages once
+ 802.11: Radiotap dBm values get printed as dB; Update a test output accordingly
+ 802.11: Source and destination addresses were backwards
+ AH: Add a bounds check
+ AH: Report to our caller that dissection failed if a bounds check fails
+ AP1394: Print src > dst, not dst > src
+ ARP: Don't assume the target hardware address is <= 6 octets long (Fix a heap overflow)
+ ATALK: Add bounds and length checks (Fix heap overflows)
+ ATM: Add some bounds checks (Fix a heap overflow)
+ ATM: Fix an incorrect bounds check
+ BFD: Update specification from draft to RFC 5880
+ BFD: Update to print optional authentication field
+ BGP: Add decoding of ADD-PATH capability
+ BGP: Add support for the AIGP attribute (RFC7311)
+ BGP: Print LARGE_COMMUNITY Path Attribute
+ BGP: Update BGP numbers from IANA; Print minor values for FSM notification
+ BOOTP: Add a bounds check
+ Babel: Add decoder for source-specific extension
+ CDP: Filter out non-printable characters
+ CFM: Fixes to match the IEEE standard, additional bounds and length checks
+ CSLIP: Add more bounds checks (Fix a heap overflow)
+ ClassicalIPoATM: Add a bounds check on LLC+SNAP header (Fix a heap overflow)
+ DHCP: Fix MUDURL and TZ options
+ DHCPv6: Process MUDURL and TZ options
+ DHCPv6: Update Status Codes with RFCs/IANA names
+ DNS: Represent the "DNSSEC OK" bit as "DO" instead of "OK". Add a test case
+ DTP: Improve packet integrity checks
+ EGP: Fix bounds checks
+ ESP: Don't use OpenSSL_add_all_algorithms() in OpenSSL 1.1.0 or later
+ ESP: Handle OpenSSL 1.1.x
+ Ethernet: Add some bounds checking before calling isoclns_print (Fix a heap overflow)
+ Ethernet: Print the Length/Type field as length when needed
+ FDDI: Fix -e output for FDDI
+ FR: Add some packet-length checks and improve Q.933 printing (Fix heap overflows)
+ GRE: Add some bounds checks (Fix heap overflows)
+ Geneve: Fix error message with invalid option length; Update list option classes
+ HNCP: Fix incorrect time interval format. Fix handling of IPv4 prefixes
+ ICMP6: Fetch a 32-bit big-endian quantity with EXTRACT_32BITS()
+ ICMP6: dagid is always an IPv6 address, not an opaque 128-bit string
+ IGMP: Add a length check
+ IP: Add a bounds check (Fix a heap overflow)
+ IP: Check before fetching the protocol version (Fix a heap overflow)
+ IP: Don't try to dissect if IP version != 4 (Fix a heap overflow)
+ IP: Stop processing IPPROTO_ values once we hit IPPROTO_IPCOMP
+ IPComp: Check whether we have the CPI before we fetch it (Fix a heap overflow)
+ IPoFC: Fix -e output (IP-over-Fibre Channel)
+ IPv6: Don't overwrite the destination IPv6 address for routing headers
+ IPv6: Fix header printing
+ IPv6: Stop processing IPPROTO_ values once we hit IPPROTO_IPCOMP
+ ISAKMP: Clean up parsing of IKEv2 Security Associations
+ ISOCLNS/IS-IS: Add support for Purge Originator Identifier (RFC6232) and test cases
+ ISOCLNS/IS-IS: Don't overwrite packet data when checking the signature
+ ISOCLNS/IS-IS: Filter out non-printable characters
+ ISOCLNS/IS-IS: Fix segmentation faults
+ ISOCLNS/IS-IS: Have signature_verify() do the copying and clearing
+ ISOCLNS: Add some bounds checks
+ Juniper: Make sure a Juniper header TLV isn't bigger than what's left in the packet (Fix a heap overflow)
+ LLC/SNAP: With -e, print the LLC header before the SNAP header; without it, cut the SNAP header
+ LLC: Add a bounds check (Fix a heap overflow)
+ LLC: Clean up printing of LLC packets
+ LLC: Fix the printing of RFC 948-style IP packets
+ LLC: Skip the LLC and SNAP headers with -x for 802.11 and some other protocols
+ LLDP: Implement IANA OUI and LLDP MUD option
+ MPLS LSP ping: Update printing for RFC 4379, bug fixes, more bounds checks
+ MPLS: "length" is now the *remaining* packet length
+ MPLS: Add bounds and length checks (Fix a heap overflow)
+ NFS: Add a test that makes unaligned accesses
+ NFS: Don't assume the ONC RPC header is nicely aligned
+ NFS: Don't overflow the Opaque_Handle buffer (Fix a segmentation fault)
+ NFS: Don't run past the end of an NFSv3 file handle
+ OLSR: Add a test to cover a HNA sgw case
+ OLSR: Fix 'Advertised networks' count
+ OLSR: Fix printing of smart-gateway HNAs in IPv4
+ OSPF: Add a bounds check for the Hello packet options
+ OSPF: Do more bounds checking
+ OSPF: Fix a segmentation fault
+ OSPF: Fix printing 'ospf_topology_values' default
+ OTV: Add missing bounds checks
+ PGM: Print the formatted IP address, not the raw binary address, as a string
+ PIM: Add some bounds checking (Fix a heap overflow)
+ PIMv2: Fix checksumming of Register messages
+ PPI: Pass an adjusted struct pcap_pkthdr to the sub-printer
+ PPP: Add some bounds checks (Fix a heap overflow)
+ PPP: Report invalid PAP AACK/ANAK packets
+ Q.933: Add a missing bounds check
+ RADIUS: Add Value 13 "VLAN" to Tunnel-Type attribute
+ RADIUS: Filter out non-printable characters
+ RADIUS: Translate UDP/1700 as RADIUS
+ RESP: Do better checking of RESP packets
+ RPKI-RTR: Add a return value check for "fn_printn" call
+ RPKI-RTR: Remove printing when truncated condition already detected
+ RPL: Fix 'Consistency Check' control code
+ RPL: Fix suboption print
+ RSVP: An INTEGRITY object in a submessage covers only the submessage
+ RSVP: Fix an infinite loop; Add bounds and length checks
+ RSVP: Fix some if statements missing brackets
+ RSVP: Have signature_verify() do the copying and clearing
+ RTCP: Add some bounds checks
+ RTP: Add some bounds checks, fix two segmentation faults
+ SCTP: Do more bounds checking
+ SFLOW: Fix bounds checking
+ SLOW: Fix bugs, add checks
+ SMB: Before fetching the flags2 field, make sure we have it
+ SMB: Do bounds checks on NBNS resource types and resource data lengths
+ SNMP: Clean up the "have libsmi but no modules loaded" case
+ SNMP: Clean up the object abbreviation list and fix the code to match them
+ SNMP: Do bounds checks when printing character and octet strings
+ SNMP: Improve ASN.1 bounds checks
+ SNMP: More bounds and length checks
+ STP: Add a bunch of bounds checks, and fix some printing (Fix heap overflows)
+ STP: Filter out non-printable characters
+ TCP: Add bounds and length checks for packets with TCP option 20
+ TCP: Correct TCP option Kind value for TCP Auth and add SCPS-TP
+ TCP: Fix two bounds checks (Fix heap overflows)
+ TCP: Make sure we have the data offset field before fetching it (Fix a heap overflow)
+ TCP: Put TCP-AO option decoding right
+ TFTP: Don't use strchr() to scan packet data (Fix a heap overflow)
+ Telnet: Add some bounds checks
+ TokenRing: Fix -e output
+ UDLD: Fix an infinite loop
+ UDP: Add a bounds check (Fix a heap overflow)
+ UDP: Check against the packet length first
+ UDP: Don't do the DDP-over-UDP heuristic check up front
+ VAT: Add some bounds checks
+ VTP: Add a test on Mgmt Domain Name length
+ VTP: Add bounds checks and filter out non-printable characters
+ VXLAN: Add a bound check and a test case
+ ZeroMQ: Fix an infinite loop
+
+Tuesday April 14, 2015 guy@alum.mit.edu
+ Summary for 4.8.0 tcpdump release
+ Fix "-x" for Apple PKTAP and PPI packets
+
Friday April 10, 2015 guy@alum.mit.edu
Summary for 4.7.4 tcpdump release
RPKI to Router Protocol: Fix Segmentation Faults and other problems
@@ -464,10 +648,10 @@ Wed. November 12, 2003. mcr@sandelman.ottawa.on.ca. Summary for 3.8 release
Tuesday, February 25, 2003. fenner@research.att.com. 3.7.2 release
- Fixed infinite loop when parsing malformed isakmp packets.
+ Fixed infinite loop when parsing invalid isakmp packets.
(reported by iDefense; already fixed in CVS)
- Fixed infinite loop when parsing malformed BGP packets.
- Fixed buffer overflow with certain malformed NFS packets.
+ Fixed infinite loop when parsing invalid BGP packets.
+ Fixed buffer overflow with certain invalid NFS packets.
Pretty-print unprintable network names in 802.11 printer.
Handle truncated nbp (appletalk) packets.
Updated DHCPv6 printer to match draft-ietf-dhc-dhcpv6-22.txt
diff --git a/CONTRIBUTING b/CONTRIBUTING
new file mode 100644
index 000000000000..5d3b46e0e5fd
--- /dev/null
+++ b/CONTRIBUTING
@@ -0,0 +1,103 @@
+Some Information for Contributors
+---------------------------------
+You want to contribute to Tcpdump, Thanks!
+Please, read these lines.
+
+1) Fork the Tcpdump repository on GitHub from
+ https://github.com/the-tcpdump-group/tcpdump
+ (See https://help.github.com/articles/fork-a-repo/)
+
+2) Setup an optional Travis-CI build
+ You can setup a travis build for your fork. So, you can test your changes
+ on Linux and OSX before sending pull requests.
+ (See http://docs.travis-ci.com/user/getting-started/)
+
+3) Clone your repository
+ git clone https://github.com/<username>/tcpdump.git
+
+4) Do a 'touch .devel' in your working directory.
+ Currently, the effect is
+ a) add (via configure, in Makefile) some warnings options ( -Wall
+ -Wmissing-prototypes -Wstrict-prototypes, ...) to the compiler if it
+ supports these options,
+ b) have the Makefile support "make depend" and the configure script run it.
+
+5) Configure and build
+ ./configure && make -s && make check
+
+6) Add/update sample.pcap files
+ We use tests directory to do regression tests on the dissection of captured
+ packets, by running tcpdump against a savefile sample.pcap, created with -w
+ option and comparing the results with a text file sample.out giving the
+ expected results.
+
+ Any new/updated fields in a dissector must be present in a sample.pcap file
+ and the corresponding output file.
+
+ Configuration is set in tests/TESTLIST.
+ Each line in this file has the following format:
+ test-name sample.pcap sample.out tcpdump-options
+
+ the sample.out file can be build by:
+ (cd tests && ../tcpdump -n -r sample.pcap tcpdump-options > sample.out)
+
+ It is often useful to have test outputs with different verbosity levels
+ (none, -v, -vv, -vvv, etc.) depending on the code.
+
+7) Test with 'make check'
+ Don't send a pull request if 'make check' gives failed tests.
+
+8) Rebase your commits against upstream/master
+ (To keep linearity)
+
+9) Initiate and send a pull request
+ (See https://help.github.com/articles/using-pull-requests/)
+
+Some remarks
+------------
+a) A thorough reading of some other printers code is useful.
+
+b) Put the normative reference if any as comments (RFC, etc.).
+
+c) Put the format of packets/headers/options as comments.
+
+d) The printer may receive incomplete packet in the buffer, truncated at any
+ random position, for example by capturing with '-s size' option.
+ Thus use ND_TTEST, ND_TTEST2, ND_TCHECK or ND_TCHECK2 for bound checking.
+ For ND_TCHECK2:
+ Define : static const char tstr[] = " [|protocol]";
+ Define a label: trunc
+ Print with: ND_PRINT((ndo, "%s", tstr));
+ You can test the code via:
+ sudo ./tcpdump -s snaplen [-v][v][...] -i lo # in a terminal
+ sudo tcpreplay -i lo sample.pcap # in another terminal
+ You should try several values for snaplen to do various truncation.
+
+e) Do invalid packet checks in code: Think that your code can receive in input
+ not only a valid packet but any arbitrary random sequence of octets (packet
+ - built malformed originally by the sender or by a fuzz tester,
+ - became corrupted in transit).
+ Print with: ND_PRINT((ndo, "%s", istr)); /* to print " (invalid)" */
+
+f) Use 'struct tok' for indexed strings and print them with
+ tok2str() or bittok2str() (for flags).
+
+g) Avoid empty lines in output of printers.
+
+h) A commit message must have:
+ First line: Capitalized short summary in the imperative (70 chars or less)
+
+ Body: Detailed explanatory text, if necessary. Fold it to approximately
+ 72 characters. There must be an empty line separating the summary from
+ the body.
+
+i) Avoid non-ASCII characters in code and commit messages.
+
+j) Use the style of the modified sources.
+
+k) Don't mix declarations and code
+
+l) Don't use // for comments
+ Not all C compilers accept C++/C99 comments by default.
+
+m) Avoid trailing tabs/spaces
diff --git a/CREDITS b/CREDITS
index a21311abc48d..52429671f75f 100644
--- a/CREDITS
+++ b/CREDITS
@@ -20,11 +20,13 @@ Additional people who have contributed patches:
Andrea Bittau <a dot bittau at cs dot ucl dot ac dot uk>
Andrew Brown <atatat at atatdot dot net>
Andrew Church <andrew at users dot sourceforge dot net>
+ Andrew Darqui <andrew dot darqui at gmail dot com>
Andrew Hintz <adhintz at users dot sourceforge dot net>
Andrew Nording <andrew at nording dot ru>
Andrew Tridgell <tridge at linuxcare dot com>
Andy Heffernan <ahh at juniper dot net>
Anton Bernal <anton at juniper dot net>
+ Antonin Décimo <antonin dot decimo at gmail dot com>
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>
@@ -33,6 +35,7 @@ Additional people who have contributed patches:
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>
+ Bill Parker <wp02855 at gmail 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>
@@ -95,6 +98,7 @@ Additional people who have contributed patches:
Jason R. Thorpe <thorpej at netbsd dot org>
Jefferson Ogata <jogata at nodc dot noaa dot gov>
Jeffrey Hutzelman <jhutz at cmu dot edu>
+ Jean-Raphaël Gaglione <jr dot gaglione at yahoo dot fr>
Jesper Peterson <jesper at endace dot com>
Jesse Gross <jesse at nicira dot com>
Jim Hutchins <jim at ca dot sandia dot gov>
@@ -119,7 +123,7 @@ Additional people who have contributed patches:
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>
+ Daniel Lee <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>
@@ -134,6 +138,7 @@ Additional people who have contributed patches:
Markus Schöpflin <schoepflin at sourceforge dot net>
Marshall Rose <mrose at dbc dot mtview dot ca dot us>
Martin Husemann <martin at netbsd dot org>
+ Matthieu Boutier <boutier at pps dot univ-paris-diderot dot fr>
Max Laier <max at love2party dot net>
Michael A. Meffie III <meffie at sourceforge dot net>
Michael Madore <mmadore at turbolinux dot com>
diff --git a/INSTALL.txt b/INSTALL.txt
index dcb52b86894b..f91d004a85b4 100644
--- a/INSTALL.txt
+++ b/INSTALL.txt
@@ -49,9 +49,10 @@ addrtoname.c - address to hostname routines
addrtoname.h - address to hostname definitions
ah.h - IPSEC Authentication Header definitions
appletalk.h - AppleTalk definitions
+ascii_strcasecmp.c - locale-independent case-independent string comparison
+ routines
atime.awk - TCP ack awk script
atm.h - ATM traffic type definitions
-atmuni31.h - ATM Q.2931 definitions
bpf_dump.c - BPF program printing routines, in case libpcap doesn't
have them
chdlc.h - Cisco HDLC definitions
@@ -100,100 +101,8 @@ 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
ppp.h - Point to Point Protocol definitions
-print-802_11.c - IEEE 802.11 printer routines
-print-ap1394.c - Apple IP-over-IEEE 1394 printer routines
-print-ah.c - IPSEC Authentication Header printer routines
-print-aodv.c - AODV printer routines
-print-arcnet.c - ARCNET printer routines
-print-arp.c - Address Resolution Protocol printer routines
-print-ascii.c - ASCII packet dump routines
-print-atalk.c - AppleTalk printer routines
-print-atm.c - ATM printer routines
-print-beep.c - BEEP printer routines
-print-bgp.c - Border Gateway Protocol printer routines
-print-bootp.c - BOOTP and IPv4 DHCP printer routines
-print-bt.c - Bluetooth printer routines
-print-cdp.c - Cisco Discovery Protocol printer routines
-print-chdlc.c - Cisco HDLC printer routines
-print-cip.c - Classical-IP over ATM routines
-print-cnfp.c - Cisco NetFlow printer routines
-print-dccp.c - DCCP printer routines
-print-decnet.c - DECnet printer routines
-print-dhcp6.c - IPv6 DHCP printer routines
-print-domain.c - Domain Name System printer routines
-print-dvmrp.c - Distance Vector Multicast Routing Protocol printer routines
-print-eap.c - EAP printer routines
-print-enc.c - OpenBSD IPsec encapsulation BPF layer printer routines
-print-egp.c - External Gateway Protocol printer routines
-print-esp.c - IPSEC Encapsulating Security Payload printer routines
-print-ether.c - Ethernet printer routines
-print-fddi.c - Fiber Distributed Data Interface printer routines
-print-fr.c - Frame Relay printer routines
-print-frag6.c - IPv6 fragmentation header printer routines
-print-gre.c - Generic Routing Encapsulation printer routines
-print-hsrp.c - Cisco Hot Standby Router Protocol printer routines
-print-icmp.c - Internet Control Message Protocol printer routines
-print-icmp6.c - IPv6 Internet Control Message Protocol printer routines
-print-igmp.c - Internet Group Management Protocol printer routines
-print-igrp.c - Interior Gateway Routing Protocol printer routines
-print-ip.c - IP printer routines
-print-ip6.c - IPv6 printer routines
-print-ip6opts.c - IPv6 header option printer routines
-print-ipcomp.c - IP Payload Compression Protocol printer routines
-print-ipx.c - IPX printer routines
-print-isakmp.c - Internet Security Association and Key Management Protocol
-print-isoclns.c - ISO CLNS, ESIS, and ISIS printer routines
-print-krb.c - Kerberos printer routines
-print-l2tp.c - Layer Two Tunneling Protocol printer routines
-print-lane.c - ATM LANE printer routines
-print-llc.c - IEEE 802.2 LLC printer routines
-print-lspping.c - LSPPING printer routines
-print-lwres.c - Lightweight Resolver protocol printer routines
-print-mobile.c - IPv4 mobility printer routines
-print-mobility.c - IPv6 mobility printer routines
-print-mpls.c - Multi-Protocol Label Switching printer routines
-print-msdp.c - Multicast Source Discovery Protocol printer routines
-print-nfs.c - Network File System printer routines
-print-ntp.c - Network Time Protocol printer routines
-print-null.c - BSD loopback device printer routines
-print-ospf.c - Open Shortest Path First printer routines
-print-ospf6.c - IPv6 Open Shortest Path First printer routines
-print-pflog.c - OpenBSD packet filter log file printer routines
-print-pgm.c - Pragmatic General Multicast printer routines
-print-pim.c - Protocol Independent Multicast printer routines
-print-ppp.c - Point to Point Protocol printer routines
-print-pppoe.c - PPP-over-Ethernet printer routines
-print-pptp.c - Point-to-Point Tunnelling Protocol printer routines
-print-radius.c - Radius protocol printer routines
-print-raw.c - Raw IP printer routines
-print-rip.c - Routing Information Protocol printer routines
-print-ripng.c - IPv6 Routing Information Protocol printer routines
-print-rrcp.c - Realtek Remote Control Protocol routines
-print-rsvp.c - Resource reSerVation Protocol (RSVP) printer routines
-print-rt6.c - IPv6 routing header printer routines
-print-rx.c - AFS RX printer routines
-print-sctp.c - Stream Control Transmission Protocol printer routines
-print-sip.c - SIP printer routines
-print-sl.c - Compressed Serial Line Internet Protocol printer routines
-print-sll.c - Linux "cooked" capture printer routines
-print-slow.c - IEEE "slow protocol" (802.3ad) printer routines
-print-smb.c - SMB/CIFS printer routines
-print-snmp.c - Simple Network Management Protocol printer routines
-print-stp.c - IEEE 802.1d spanning tree protocol printer routines
-print-sunatm.c - SunATM DLPI capture printer routines
-print-sunrpc.c - Sun Remote Procedure Call printer routines
-print-symantec.c - Symantec Enterprise Firewall printer routines
-print-tcp.c - TCP printer routines
-print-telnet.c - Telnet option printer routines
-print-tftp.c - Trivial File Transfer Protocol printer routines
-print-timed.c - BSD time daemon protocol printer routines
-print-token.c - Token Ring printer routines
-print-udp.c - UDP printer routines
-print-usb.c - USB printer routines
-print-vjc.c - PPP Van Jacobson compression (RFC1144) printer routines
-print-vrrp.c - Virtual Router Redundancy Protocol
-print-wb.c - White Board printer routines
-print-zephyr.c - Zephyr printer routines
+print.c - Top-level routines for protocol printing
+print-*.c - The netdissect printers
rpc_auth.h - definitions for ONC RPC authentication
rpc_msg.h - definitions for ONC RPC messages
send-ack.awk - unidirectional tcp send/ack awk script
@@ -203,11 +112,11 @@ slcompress.h - SLIP/PPP Van Jacobson compression (RFC1144) definitions
smb.h - SMB/CIFS definitions
smbutil.c - SMB/CIFS utility routines
stime.awk - TCP send awk script
-strcasecmp.c - missing routine
tcp.h - TCP definitions
tcpdump.1 - manual entry
tcpdump.c - main program
+timeval-operations.h - timeval operations macros
udp.h - UDP definitions
-util.c - utility routines
+util-print.c - utility routines for protocol printers
vfprintf.c - emulation routine
win32 - headers and routines for building on Win32 systems
diff --git a/Makefile.in b/Makefile.in
index a0dc559ada69..c18d5ed91656 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -74,7 +74,9 @@ CSRC = setsignal.c tcpdump.c
LIBNETDISSECT_SRC=\
addrtoname.c \
+ addrtostr.c \
af.c \
+ ascii_strcasecmp.c \
checksum.c \
cpack.c \
gmpls.c \
@@ -86,6 +88,7 @@ LIBNETDISSECT_SRC=\
nlpid.c \
oui.c \
parsenfsfh.c \
+ print.c \
print-802_11.c \
print-802_15_4.c \
print-ah.c \
@@ -98,6 +101,7 @@ LIBNETDISSECT_SRC=\
print-ascii.c \
print-atalk.c \
print-atm.c \
+ print-babel.c \
print-beep.c \
print-bfd.c \
print-bgp.c \
@@ -112,6 +116,7 @@ LIBNETDISSECT_SRC=\
print-cnfp.c \
print-dccp.c \
print-decnet.c \
+ print-dhcp6.c \
print-domain.c \
print-dtp.c \
print-dvmrp.c \
@@ -124,17 +129,21 @@ LIBNETDISSECT_SRC=\
print-fddi.c \
print-forces.c \
print-fr.c \
+ print-frag6.c \
print-ftp.c \
print-geneve.c \
print-geonet.c \
print-gre.c \
+ print-hncp.c \
print-hsrp.c \
print-http.c \
print-icmp.c \
+ print-icmp6.c \
print-igmp.c \
print-igrp.c \
print-ip.c \
print-ip6.c \
+ print-ip6opts.c \
print-ipcomp.c \
print-ipfc.c \
print-ipnet.c \
@@ -146,6 +155,7 @@ LIBNETDISSECT_SRC=\
print-l2tp.c \
print-lane.c \
print-ldp.c \
+ print-lisp.c \
print-llc.c \
print-lldp.c \
print-lmp.c \
@@ -154,7 +164,9 @@ LIBNETDISSECT_SRC=\
print-lwapp.c \
print-lwres.c \
print-m3ua.c \
+ print-medsa.c \
print-mobile.c \
+ print-mobility.c \
print-mpcp.c \
print-mpls.c \
print-mptcp.c \
@@ -162,12 +174,14 @@ LIBNETDISSECT_SRC=\
print-msnlb.c \
print-nflog.c \
print-nfs.c \
+ print-nsh.c \
print-ntp.c \
print-null.c \
print-olsr.c \
print-openflow-1.0.c \
print-openflow.c \
print-ospf.c \
+ print-ospf6.c \
print-otv.c \
print-pgm.c \
print-pim.c \
@@ -178,10 +192,13 @@ LIBNETDISSECT_SRC=\
print-pptp.c \
print-radius.c \
print-raw.c \
+ print-resp.c \
print-rip.c \
+ print-ripng.c \
print-rpki-rtr.c \
print-rrcp.c \
print-rsvp.c \
+ print-rt6.c \
print-rtsp.c \
print-rx.c \
print-sctp.c \
@@ -211,11 +228,14 @@ LIBNETDISSECT_SRC=\
print-vrrp.c \
print-vtp.c \
print-vxlan.c \
+ print-vxlan-gpe.c \
print-wb.c \
print-zephyr.c \
print-zeromq.c \
+ netdissect.c \
signature.c \
- util.c
+ strtoaddr.c \
+ util-print.c
LOCALSRC = @LOCALSRC@
GENSRC = version.c
@@ -232,11 +252,12 @@ SRC = $(CSRC) $(GENSRC) $(LOCALSRC) $(LIBNETDISSECT_SRC)
OBJ = $(CSRC:.c=.o) $(GENSRC:.c=.o) $(LIBNETDISSECT_OBJ)
HDR = \
addrtoname.h \
+ addrtostr.h \
af.h \
ah.h \
appletalk.h \
+ ascii_strcasecmp.h \
atm.h \
- atmuni31.h \
chdlc.h \
cpack.h \
ether.h \
@@ -264,6 +285,7 @@ HDR = \
oui.h \
pcap-missing.h \
ppp.h \
+ print.h \
rpc_auth.h \
rpc_msg.h \
rpl.h \
@@ -271,14 +293,15 @@ HDR = \
signature.h \
slcompress.h \
smb.h \
+ strtoaddr.h \
tcp.h \
- tcpdump-stdinc.h \
+ netdissect-stdinc.h \
+ timeval-operations.h \
udp.h
TAGHDR = \
/usr/include/arpa/tftp.h \
/usr/include/net/if_arp.h \
- /usr/include/net/slip.h \
/usr/include/netinet/if_ether.h \
/usr/include/netinet/in.h \
/usr/include/netinet/ip_icmp.h \
@@ -292,11 +315,14 @@ CLEANFILES = $(PROG) $(OBJ) $(GENSRC)
EXTRA_DIST = \
CHANGES \
+ CONTRIBUTING \
CREDITS \
INSTALL.txt \
LICENSE \
Makefile.in \
Makefile-devel-adds \
+ PLATFORMS \
+ README \
README.md \
Readme.Win32 \
VERSION \
@@ -314,14 +340,9 @@ EXTRA_DIST = \
lbl/os-sunos4.h \
lbl/os-ultrix4.h \
makemib \
- missing/addrinfo.h \
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/strdup.c \
missing/strlcat.c \
@@ -330,27 +351,19 @@ EXTRA_DIST = \
mkdep \
packetdat.awk \
pcap_dump_ftell.c \
- print-babel.c \
- print-dhcp6.c \
- print-frag6.c \
- print-icmp6.c \
- print-ip6opts.c \
- print-mobility.c \
- print-ospf6.c \
print-pflog.c \
- print-ripng.c \
- print-rt6.c \
print-smb.c \
send-ack.awk \
smbutil.c \
stime.awk \
- strcasecmp.c \
tcpdump.1.in \
vfprintf.c \
- win32/Include/w32_fzs.h \
win32/prj/GNUmakefile \
win32/prj/WinDump.dsp \
- win32/prj/WinDump.dsw
+ win32/prj/WinDump.dsw \
+ win32/prj/WinDump.sln \
+ win32/prj/WinDump.vcproj \
+ win32/src/ether_ntohost.c
TEST_DIST= `find tests \( -name 'DIFF' -prune \) -o \( -name NEW -prune \) -o -type f \! -name '.*' \! -name '*~' -print`
@@ -369,16 +382,8 @@ datalinks.o: $(srcdir)/missing/datalinks.c
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/datalinks.c
dlnames.o: $(srcdir)/missing/dlnames.c
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/dlnames.c
-getnameinfo.o: $(srcdir)/missing/getnameinfo.c
- $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/getnameinfo.c
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
- $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/inet_ntop.c
-inet_aton.o: $(srcdir)/missing/inet_aton.c
- $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/inet_aton.c
snprintf.o: $(srcdir)/missing/snprintf.c
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c
strdup.o: $(srcdir)/missing/strdup.c
@@ -434,6 +439,9 @@ distclean:
check: tcpdump
(cd tests && ./TESTrun.sh)
+extags: $(TAGFILES)
+ ctags $(TAGFILES)
+
tags: $(TAGFILES)
ctags -wtd $(TAGFILES)
diff --git a/PLATFORMS b/PLATFORMS
new file mode 100644
index 000000000000..ec85e59be6d0
--- /dev/null
+++ b/PLATFORMS
@@ -0,0 +1,9 @@
+== Tested platforms ==
+NetBSD 5.1/i386 (mcr - 2012/4/1)
+Debian Linux (squeeze/i386) (mcr - 2012/4/1)
+
+---
+RedHat Linux 6.1/i386 (assar)
+FreeBSD 2.2.8/i386 (itojun)
+
+
diff --git a/README b/README
new file mode 120000
index 000000000000..42061c01a1c7
--- /dev/null
+++ b/README
@@ -0,0 +1 @@
+README.md \ No newline at end of file
diff --git a/VERSION b/VERSION
index b48b2de9d963..6ed7776bf321 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-4.7.4
+4.9.0
diff --git a/aclocal.m4 b/aclocal.m4
index 285000d902cd..ea0f6241c967 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -219,6 +219,36 @@ AC_DEFUN(AC_LBL_C_INIT,
])
dnl
+dnl Check whether, if you pass an unknown warning option to the
+dnl compiler, it fails or just prints a warning message and succeeds.
+dnl Set ac_lbl_unknown_warning_option_error to the appropriate flag
+dnl to force an error if it would otherwise just print a warning message
+dnl and succeed.
+dnl
+AC_DEFUN(AC_LBL_CHECK_UNKNOWN_WARNING_OPTION_ERROR,
+ [
+ AC_MSG_CHECKING([whether the compiler fails when given an unknown warning option])
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -Wxyzzy-this-will-never-succeed-xyzzy"
+ AC_TRY_COMPILE(
+ [],
+ [return 0],
+ [
+ AC_MSG_RESULT([no])
+ #
+ # We're assuming this is clang, where
+ # -Werror=unknown-warning-option is the appropriate
+ # option to force the compiler to fail.
+ #
+ ac_lbl_unknown_warning_option_error="-Werror=unknown-warning-option"
+ ],
+ [
+ AC_MSG_RESULT([yes])
+ ])
+ CFLAGS="$save_CFLAGS"
+ ])
+
+dnl
dnl Check whether the compiler option specified as the second argument
dnl is supported by the compiler and, if so, add it to the macro
dnl specified as the first argument
@@ -227,7 +257,18 @@ AC_DEFUN(AC_LBL_CHECK_COMPILER_OPT,
[
AC_MSG_CHECKING([whether the compiler supports the $2 option])
save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors $2"
+ if expr "x$2" : "x-W.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error $2"
+ elif expr "x$2" : "x-f.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror $2"
+ elif expr "x$2" : "x-m.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror $2"
+ else
+ CFLAGS="$CFLAGS $2"
+ fi
AC_TRY_COMPILE(
[],
[return 0],
@@ -942,11 +983,18 @@ AC_DEFUN(AC_LBL_DEVEL,
# Skip all the warning option stuff on some compilers.
#
if test "$ac_lbl_cc_dont_try_gcc_dashW" != yes; then
+ AC_LBL_CHECK_UNKNOWN_WARNING_OPTION_ERROR()
AC_LBL_CHECK_COMPILER_OPT($1, -Wall)
AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-prototypes)
AC_LBL_CHECK_COMPILER_OPT($1, -Wstrict-prototypes)
AC_LBL_CHECK_COMPILER_OPT($1, -Wwrite-strings)
AC_LBL_CHECK_COMPILER_OPT($1, -Wpointer-arith)
+ AC_LBL_CHECK_COMPILER_OPT($1, -Wcast-qual)
+ AC_LBL_CHECK_COMPILER_OPT($1, -Wshadow)
+ AC_LBL_CHECK_COMPILER_OPT($1, -Wdeclaration-after-statement)
+ AC_LBL_CHECK_COMPILER_OPT($1, -Wpedantic)
+ AC_LBL_CHECK_COMPILER_OPT($1, -Wold-style-definition)
+ AC_LBL_CHECK_COMPILER_OPT($1, -Wused-but-marked-unused)
AC_LBL_CHECK_COMPILER_OPT($1, -W)
fi
AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT()
@@ -1114,131 +1162,6 @@ dnl OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
dnl SUCH DAMAGE.
dnl
-dnl Checks to see if AF_INET6 is defined
-AC_DEFUN(AC_CHECK_AF_INET6, [
- AC_MSG_CHECKING(for AF_INET6)
- AC_CACHE_VAL($1,
- AC_TRY_COMPILE([
-# include <sys/types.h>
-# include <sys/socket.h>],
- [int a = AF_INET6],
- $1=yes,
- $1=no))
- AC_MSG_RESULT($$1)
- if test $$1 = yes ; then
- AC_DEFINE(HAVE_AF_INET6)
- fi
-])
-
-dnl
-dnl Checks to see if the sockaddr struct has the 4.4 BSD sa_len member
-dnl borrowed from LBL libpcap
-AC_DEFUN(AC_CHECK_SA_LEN, [
- AC_MSG_CHECKING(if sockaddr struct has sa_len member)
- AC_CACHE_VAL($1,
- AC_TRY_COMPILE([
-# include <sys/types.h>
-# include <sys/socket.h>],
- [u_int i = sizeof(((struct sockaddr *)0)->sa_len)],
- $1=yes,
- $1=no))
- AC_MSG_RESULT($$1)
- if test $$1 = yes ; then
- AC_DEFINE(HAVE_SOCKADDR_SA_LEN)
- fi
-])
-
-dnl
-dnl Checks for addrinfo structure
-AC_DEFUN(AC_STRUCT_ADDRINFO, [
- AC_MSG_CHECKING(for addrinfo)
- AC_CACHE_VAL($1,
- AC_TRY_COMPILE([
-# include <netdb.h>],
- [struct addrinfo a],
- $1=yes,
- $1=no))
- AC_MSG_RESULT($$1)
- if test $$1 = yes; then
- AC_DEFINE(HAVE_ADDRINFO, 1,
- [define if you have the addrinfo function])
- else
- AC_DEFINE(NEED_ADDRINFO_H, 1,
- [define if you need to include missing/addrinfo.h])
- fi
-])
-
-dnl
-dnl Checks for NI_MAXSERV
-AC_DEFUN(AC_NI_MAXSERV, [
- AC_MSG_CHECKING(for NI_MAXSERV)
- AC_CACHE_VAL($1,
- AC_EGREP_CPP(yes, [#include <netdb.h>
-#ifdef NI_MAXSERV
-yes
-#endif],
- $1=yes,
- $1=no))
- AC_MSG_RESULT($$1)
- if test $$1 != yes; then
- AC_DEFINE(NEED_ADDRINFO_H)
- fi
-])
-
-dnl
-dnl Checks for NI_NAMEREQD
-AC_DEFUN(AC_NI_NAMEREQD, [
- AC_MSG_CHECKING(for NI_NAMEREQD)
- AC_CACHE_VAL($1,
- AC_EGREP_CPP(yes, [#include <netdb.h>
-#ifdef NI_NOFQDN
-yes
-#endif],
- $1=yes,
- $1=no))
- AC_MSG_RESULT($$1)
- if test $$1 != yes; then
- AC_DEFINE(NEED_ADDRINFO_H)
- fi
-])
-
-dnl
-dnl Checks for sockaddr_storage structure
-AC_DEFUN(AC_STRUCT_SA_STORAGE, [
- AC_MSG_CHECKING(for sockaddr_storage)
- AC_CACHE_VAL($1,
- AC_TRY_COMPILE([
-# include <sys/types.h>
-# include <sys/socket.h>],
- [struct sockaddr_storage s],
- $1=yes,
- $1=no))
- AC_MSG_RESULT($$1)
- if test $$1 = yes; then
- AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1,
- [define if you have struct sockaddr_storage])
- fi
-])
-
-dnl
-dnl check for h_errno
-AC_DEFUN(AC_VAR_H_ERRNO, [
- AC_MSG_CHECKING(for h_errno)
- AC_CACHE_VAL(ac_cv_var_h_errno,
- AC_TRY_COMPILE([
-# include <sys/types.h>
-# include <netdb.h>],
- [int foo = h_errno;],
- ac_cv_var_h_errno=yes,
- ac_cv_var_h_errno=no))
- AC_MSG_RESULT($ac_cv_var_h_errno)
- if test "$ac_cv_var_h_errno" = "yes"; then
- AC_DEFINE(HAVE_H_ERRNO, 1,
- [define if you have the h_errno variable])
- fi
-])
-
-dnl
dnl Test for __attribute__
dnl
diff --git a/addrtoname.c b/addrtoname.c
index d0437fe490a3..6975b7134e23 100644
--- a/addrtoname.c
+++ b/addrtoname.c
@@ -22,12 +22,11 @@
* and address to string conversion routines
*/
-#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#ifdef USE_ETHER_NTOHOST
#ifdef HAVE_NETINET_IF_ETHER_H
@@ -58,8 +57,10 @@ extern int ether_ntohost(char *, const struct ether_addr *);
#include <string.h>
#include <stdlib.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
+#include "addrtostr.h"
+#include "ethertype.h"
#include "llc.h"
#include "setsignal.h"
#include "extract.h"
@@ -72,7 +73,7 @@ extern int ether_ntohost(char *, const struct ether_addr *);
/*
* hash tables for whatever-to-name translations
*
- * XXX there has to be error checks against strdup(3) failure
+ * ndo_error() called on strdup(3) failure
*/
#define HASHNAMESIZE 4096
@@ -90,7 +91,7 @@ static struct hnamemem eprototable[HASHNAMESIZE];
static struct hnamemem dnaddrtable[HASHNAMESIZE];
static struct hnamemem ipxsaptable[HASHNAMESIZE];
-#if defined(INET6) && defined(WIN32)
+#ifdef _WIN32
/*
* fake gethostbyaddr for Win2k/XP
* gethostbyaddr() returns incorrect value when AF_INET6 is passed
@@ -128,9 +129,8 @@ win32_gethostbyaddr(const char *addr, int len, int type)
}
}
#define gethostbyaddr win32_gethostbyaddr
-#endif /* INET6 & WIN32 */
+#endif /* _WIN32 */
-#ifdef INET6
struct h6namemem {
struct in6_addr addr;
char *name;
@@ -138,7 +138,6 @@ struct h6namemem {
};
static struct h6namemem h6nametable[HASHNAMESIZE];
-#endif /* INET6 */
struct enamemem {
u_short e_addr0;
@@ -205,7 +204,7 @@ static uint32_t f_localnet;
*
* NOTE: ap is *NOT* necessarily part of the packet data (not even if
* this is being called with the "ipaddr_string()" macro), so you
- * *CANNOT* use the TCHECK{2}/TTEST{2} macros on it. Furthermore,
+ * *CANNOT* use the ND_TCHECK{2}/ND_TTEST{2} macros on it. Furthermore,
* even in cases where it *is* part of the packet data, the caller
* would still have to check for a null return value, even if it's
* just printing the return value with "%s" - not all versions of
@@ -223,7 +222,7 @@ getname(netdissect_options *ndo, const u_char *ap)
{
register struct hostent *hp;
uint32_t addr;
- static struct hnamemem *p; /* static for longjmp() */
+ struct hnamemem *p;
memcpy(&addr, ap, sizeof(addr));
p = &hnametable[addr & (HASHNAMESIZE-1)];
@@ -232,7 +231,7 @@ getname(netdissect_options *ndo, const u_char *ap)
return (p->name);
}
p->addr = addr;
- p->nxt = newhnamemem();
+ p->nxt = newhnamemem(ndo);
/*
* Print names unless:
@@ -248,6 +247,9 @@ getname(netdissect_options *ndo, const u_char *ap)
char *dotp;
p->name = strdup(hp->h_name);
+ if (p->name == NULL)
+ (*ndo->ndo_error)(ndo,
+ "getname: strdup(hp->h_name)");
if (ndo->ndo_Nflag) {
/* Remove domain qualifications */
dotp = strchr(p->name, '.');
@@ -258,10 +260,11 @@ getname(netdissect_options *ndo, const u_char *ap)
}
}
p->name = strdup(intoa(addr));
+ if (p->name == NULL)
+ (*ndo->ndo_error)(ndo, "getname: strdup(intoa(addr))");
return (p->name);
}
-#ifdef INET6
/*
* Return a name for the IP6 address pointed to by ap. This address
* is assumed to be in network byte order.
@@ -277,7 +280,7 @@ getname6(netdissect_options *ndo, const u_char *ap)
uint16_t d;
} addra;
} addr;
- static struct h6namemem *p; /* static for longjmp() */
+ struct h6namemem *p;
register const char *cp;
char ntop_buf[INET6_ADDRSTRLEN];
@@ -288,7 +291,7 @@ getname6(netdissect_options *ndo, const u_char *ap)
return (p->name);
}
p->addr = addr.addr;
- p->nxt = newh6namemem();
+ p->nxt = newh6namemem(ndo);
/*
* Do not print names if -n was given.
@@ -299,6 +302,9 @@ getname6(netdissect_options *ndo, const u_char *ap)
char *dotp;
p->name = strdup(hp->h_name);
+ if (p->name == NULL)
+ (*ndo->ndo_error)(ndo,
+ "getname6: strdup(hp->h_name)");
if (ndo->ndo_Nflag) {
/* Remove domain qualifications */
dotp = strchr(p->name, '.');
@@ -308,11 +314,12 @@ getname6(netdissect_options *ndo, const u_char *ap)
return (p->name);
}
}
- cp = inet_ntop(AF_INET6, &addr, ntop_buf, sizeof(ntop_buf));
+ cp = addrtostr6(ap, ntop_buf, sizeof(ntop_buf));
p->name = strdup(cp);
+ if (p->name == NULL)
+ (*ndo->ndo_error)(ndo, "getname6: strdup(cp)");
return (p->name);
}
-#endif /* INET6 */
static const char hex[] = "0123456789abcdef";
@@ -320,7 +327,7 @@ static const char hex[] = "0123456789abcdef";
/* Find the hash node that corresponds the ether address 'ep' */
static inline struct enamemem *
-lookup_emem(const u_char *ep)
+lookup_emem(netdissect_options *ndo, const u_char *ep)
{
register u_int i, j, k;
struct enamemem *tp;
@@ -342,7 +349,7 @@ lookup_emem(const u_char *ep)
tp->e_addr2 = k;
tp->e_nxt = (struct enamemem *)calloc(1, sizeof(*tp));
if (tp->e_nxt == NULL)
- error("lookup_emem: calloc");
+ (*ndo->ndo_error)(ndo, "lookup_emem: calloc");
return tp;
}
@@ -353,7 +360,8 @@ lookup_emem(const u_char *ep)
*/
static inline struct enamemem *
-lookup_bytestring(register const u_char *bs, const unsigned int nlen)
+lookup_bytestring(netdissect_options *ndo, register const u_char *bs,
+ const unsigned int nlen)
{
struct enamemem *tp;
register u_int i, j, k;
@@ -385,12 +393,12 @@ lookup_bytestring(register const u_char *bs, const unsigned int nlen)
tp->e_bs = (u_char *) calloc(1, nlen + 1);
if (tp->e_bs == NULL)
- error("lookup_bytestring: calloc");
+ (*ndo->ndo_error)(ndo, "lookup_bytestring: calloc");
memcpy(tp->e_bs, bs, nlen);
tp->e_nxt = (struct enamemem *)calloc(1, sizeof(*tp));
if (tp->e_nxt == NULL)
- error("lookup_bytestring: calloc");
+ (*ndo->ndo_error)(ndo, "lookup_bytestring: calloc");
return tp;
}
@@ -398,14 +406,15 @@ lookup_bytestring(register const u_char *bs, const unsigned int nlen)
/* Find the hash node that corresponds the NSAP 'nsap' */
static inline struct enamemem *
-lookup_nsap(register const u_char *nsap)
+lookup_nsap(netdissect_options *ndo, register const u_char *nsap,
+ register u_int nsap_length)
{
register u_int i, j, k;
- unsigned int nlen = *nsap;
struct enamemem *tp;
- const u_char *ensap = nsap + nlen - 6;
+ const u_char *ensap;
- if (nlen > 6) {
+ if (nsap_length > 6) {
+ ensap = nsap + nsap_length - 6;
k = (ensap[0] << 8) | ensap[1];
j = (ensap[2] << 8) | ensap[3];
i = (ensap[4] << 8) | ensap[5];
@@ -418,22 +427,23 @@ lookup_nsap(register const u_char *nsap)
if (tp->e_addr0 == i &&
tp->e_addr1 == j &&
tp->e_addr2 == k &&
- tp->e_nsap[0] == nlen &&
+ tp->e_nsap[0] == nsap_length &&
memcmp((const char *)&(nsap[1]),
- (char *)&(tp->e_nsap[1]), nlen) == 0)
+ (char *)&(tp->e_nsap[1]), nsap_length) == 0)
return tp;
else
tp = tp->e_nxt;
tp->e_addr0 = i;
tp->e_addr1 = j;
tp->e_addr2 = k;
- tp->e_nsap = (u_char *)malloc(nlen + 1);
+ tp->e_nsap = (u_char *)malloc(nsap_length + 1);
if (tp->e_nsap == NULL)
- error("lookup_nsap: malloc");
- memcpy((char *)tp->e_nsap, (const char *)nsap, nlen + 1);
+ (*ndo->ndo_error)(ndo, "lookup_nsap: malloc");
+ tp->e_nsap[0] = (u_char)nsap_length; /* guaranteed < ISONSAP_MAX_LENGTH */
+ memcpy((char *)&tp->e_nsap[1], (const char *)nsap, nsap_length);
tp->e_nxt = (struct enamemem *)calloc(1, sizeof(*tp));
if (tp->e_nxt == NULL)
- error("lookup_nsap: calloc");
+ (*ndo->ndo_error)(ndo, "lookup_nsap: calloc");
return tp;
}
@@ -441,7 +451,7 @@ lookup_nsap(register const u_char *nsap)
/* Find the hash node that corresponds the protoid 'pi'. */
static inline struct protoidmem *
-lookup_protoid(const u_char *pi)
+lookup_protoid(netdissect_options *ndo, const u_char *pi)
{
register u_int i, j;
struct protoidmem *tp;
@@ -461,7 +471,7 @@ lookup_protoid(const u_char *pi)
tp->p_proto = j;
tp->p_nxt = (struct protoidmem *)calloc(1, sizeof(*tp));
if (tp->p_nxt == NULL)
- error("lookup_protoid: calloc");
+ (*ndo->ndo_error)(ndo, "lookup_protoid: calloc");
return tp;
}
@@ -475,21 +485,18 @@ etheraddr_string(netdissect_options *ndo, register const u_char *ep)
int oui;
char buf[BUFSIZE];
- tp = lookup_emem(ep);
+ tp = lookup_emem(ndo, ep);
if (tp->e_name)
return (tp->e_name);
#ifdef USE_ETHER_NTOHOST
if (!ndo->ndo_nflag) {
char buf2[BUFSIZE];
- /*
- * We don't cast it to "const struct ether_addr *"
- * because some systems fail to declare the second
- * argument as a "const" pointer, even though they
- * don't modify what it points to.
- */
- if (ether_ntohost(buf2, (struct ether_addr *)ep) == 0) {
+ if (ether_ntohost(buf2, (const struct ether_addr *)ep) == 0) {
tp->e_name = strdup(buf2);
+ if (tp->e_name == NULL)
+ (*ndo->ndo_error)(ndo,
+ "etheraddr_string: strdup(buf2)");
return (tp->e_name);
}
}
@@ -510,11 +517,13 @@ etheraddr_string(netdissect_options *ndo, register const u_char *ep)
} else
*cp = '\0';
tp->e_name = strdup(buf);
+ if (tp->e_name == NULL)
+ (*ndo->ndo_error)(ndo, "etheraddr_string: strdup(buf)");
return (tp->e_name);
}
const char *
-le64addr_string(const u_char *ep)
+le64addr_string(netdissect_options *ndo, const u_char *ep)
{
const unsigned int len = 8;
register u_int i;
@@ -522,7 +531,7 @@ le64addr_string(const u_char *ep)
register struct enamemem *tp;
char buf[BUFSIZE];
- tp = lookup_bytestring(ep, len);
+ tp = lookup_bytestring(ndo, ep, len);
if (tp->e_name)
return (tp->e_name);
@@ -537,12 +546,15 @@ le64addr_string(const u_char *ep)
*cp = '\0';
tp->e_name = strdup(buf);
+ if (tp->e_name == NULL)
+ (*ndo->ndo_error)(ndo, "le64addr_string: strdup(buf)");
return (tp->e_name);
}
const char *
-linkaddr_string(netdissect_options *ndo, 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;
@@ -557,13 +569,13 @@ linkaddr_string(netdissect_options *ndo, const u_char *ep, const unsigned int ty
if (type == LINKADDR_FRELAY)
return (q922_string(ndo, ep, len));
- tp = lookup_bytestring(ep, len);
+ tp = lookup_bytestring(ndo, ep, len);
if (tp->e_name)
return (tp->e_name);
tp->e_name = cp = (char *)malloc(len*3);
if (tp->e_name == NULL)
- error("linkaddr_string: malloc");
+ (*ndo->ndo_error)(ndo, "linkaddr_string: malloc");
*cp++ = hex[*ep >> 4];
*cp++ = hex[*ep++ & 0xf];
for (i = len-1; i > 0 ; --i) {
@@ -576,7 +588,7 @@ linkaddr_string(netdissect_options *ndo, const u_char *ep, const unsigned int ty
}
const char *
-etherproto_string(u_short port)
+etherproto_string(netdissect_options *ndo, u_short port)
{
register char *cp;
register struct hnamemem *tp;
@@ -588,7 +600,7 @@ etherproto_string(u_short port)
return (tp->name);
tp->addr = i;
- tp->nxt = newhnamemem();
+ tp->nxt = newhnamemem(ndo);
cp = buf;
NTOHS(port);
@@ -598,18 +610,20 @@ etherproto_string(u_short port)
*cp++ = hex[port & 0xf];
*cp++ = '\0';
tp->name = strdup(buf);
+ if (tp->name == NULL)
+ (*ndo->ndo_error)(ndo, "etherproto_string: strdup(buf)");
return (tp->name);
}
const char *
-protoid_string(register const u_char *pi)
+protoid_string(netdissect_options *ndo, register const u_char *pi)
{
register u_int i, j;
register char *cp;
register struct protoidmem *tp;
char buf[sizeof("00:00:00:00:00")];
- tp = lookup_protoid(pi);
+ tp = lookup_protoid(ndo, pi);
if (tp->p_name)
return tp->p_name;
@@ -625,12 +639,15 @@ protoid_string(register const u_char *pi)
}
*cp = '\0';
tp->p_name = strdup(buf);
+ if (tp->p_name == NULL)
+ (*ndo->ndo_error)(ndo, "protoid_string: strdup(buf)");
return (tp->p_name);
}
#define ISONSAP_MAX_LENGTH 20
const char *
-isonsap_string(const u_char *nsap, register u_int nsap_length)
+isonsap_string(netdissect_options *ndo, const u_char *nsap,
+ register u_int nsap_length)
{
register u_int nsap_idx;
register char *cp;
@@ -639,13 +656,13 @@ isonsap_string(const u_char *nsap, register u_int nsap_length)
if (nsap_length < 1 || nsap_length > ISONSAP_MAX_LENGTH)
return ("isonsap_string: illegal length");
- tp = lookup_nsap(nsap);
+ tp = lookup_nsap(ndo, nsap, nsap_length);
if (tp->e_name)
return tp->e_name;
tp->e_name = cp = (char *)malloc(sizeof("xx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xx"));
if (cp == NULL)
- error("isonsap_string: malloc");
+ (*ndo->ndo_error)(ndo, "isonsap_string: malloc");
for (nsap_idx = 0; nsap_idx < nsap_length; nsap_idx++) {
*cp++ = hex[*nsap >> 4];
@@ -660,7 +677,7 @@ isonsap_string(const u_char *nsap, register u_int nsap_length)
}
const char *
-tcpport_string(u_short port)
+tcpport_string(netdissect_options *ndo, u_short port)
{
register struct hnamemem *tp;
register uint32_t i = port;
@@ -671,15 +688,17 @@ tcpport_string(u_short port)
return (tp->name);
tp->addr = i;
- tp->nxt = newhnamemem();
+ tp->nxt = newhnamemem(ndo);
(void)snprintf(buf, sizeof(buf), "%u", i);
tp->name = strdup(buf);
+ if (tp->name == NULL)
+ (*ndo->ndo_error)(ndo, "tcpport_string: strdup(buf)");
return (tp->name);
}
const char *
-udpport_string(register u_short port)
+udpport_string(netdissect_options *ndo, register u_short port)
{
register struct hnamemem *tp;
register uint32_t i = port;
@@ -690,15 +709,17 @@ udpport_string(register u_short port)
return (tp->name);
tp->addr = i;
- tp->nxt = newhnamemem();
+ tp->nxt = newhnamemem(ndo);
(void)snprintf(buf, sizeof(buf), "%u", i);
tp->name = strdup(buf);
+ if (tp->name == NULL)
+ (*ndo->ndo_error)(ndo, "udpport_string: strdup(buf)");
return (tp->name);
}
const char *
-ipxsap_string(u_short port)
+ipxsap_string(netdissect_options *ndo, u_short port)
{
register char *cp;
register struct hnamemem *tp;
@@ -710,7 +731,7 @@ ipxsap_string(u_short port)
return (tp->name);
tp->addr = i;
- tp->nxt = newhnamemem();
+ tp->nxt = newhnamemem(ndo);
cp = buf;
NTOHS(port);
@@ -720,6 +741,8 @@ ipxsap_string(u_short port)
*cp++ = hex[port & 0xf];
*cp++ = '\0';
tp->name = strdup(buf);
+ if (tp->name == NULL)
+ (*ndo->ndo_error)(ndo, "ipxsap_string: strdup(buf)");
return (tp->name);
}
@@ -748,25 +771,44 @@ init_servarray(netdissect_options *ndo)
table->name = strdup(buf);
} else
table->name = strdup(sv->s_name);
+ if (table->name == NULL)
+ (*ndo->ndo_error)(ndo, "init_servarray: strdup");
+
table->addr = port;
- table->nxt = newhnamemem();
+ table->nxt = newhnamemem(ndo);
}
endservent();
}
-/* in libpcap.a (nametoaddr.c) */
-#if defined(WIN32) && !defined(USE_STATIC_LIBPCAP)
-extern __declspec(dllimport)
-#else
-extern
-#endif
-const struct eproto {
+static const struct eproto {
const char *s;
u_short p;
-} eproto_db[];
+} eproto_db[] = {
+ { "pup", ETHERTYPE_PUP },
+ { "xns", ETHERTYPE_NS },
+ { "ip", ETHERTYPE_IP },
+ { "ip6", ETHERTYPE_IPV6 },
+ { "arp", ETHERTYPE_ARP },
+ { "rarp", ETHERTYPE_REVARP },
+ { "sprite", ETHERTYPE_SPRITE },
+ { "mopdl", ETHERTYPE_MOPDL },
+ { "moprc", ETHERTYPE_MOPRC },
+ { "decnet", ETHERTYPE_DN },
+ { "lat", ETHERTYPE_LAT },
+ { "sca", ETHERTYPE_SCA },
+ { "lanbridge", ETHERTYPE_LANBRIDGE },
+ { "vexp", ETHERTYPE_VEXP },
+ { "vprod", ETHERTYPE_VPROD },
+ { "atalk", ETHERTYPE_ATALK },
+ { "atalkarp", ETHERTYPE_AARP },
+ { "loopback", ETHERTYPE_LOOPBACK },
+ { "decdts", ETHERTYPE_DECDTS },
+ { "decdns", ETHERTYPE_DECDNS },
+ { (char *)0, 0 }
+};
static void
-init_eprotoarray(void)
+init_eprotoarray(netdissect_options *ndo)
{
register int i;
register struct hnamemem *table;
@@ -778,7 +820,7 @@ init_eprotoarray(void)
table = table->nxt;
table->name = eproto_db[i].s;
table->addr = htons(eproto_db[i].p);
- table->nxt = newhnamemem();
+ table->nxt = newhnamemem(ndo);
}
}
@@ -799,7 +841,7 @@ static const struct protoidlist {
* types.
*/
static void
-init_protoidarray(void)
+init_protoidarray(netdissect_options *ndo)
{
register int i;
register struct protoidmem *tp;
@@ -813,12 +855,15 @@ init_protoidarray(void)
u_short etype = htons(eproto_db[i].p);
memcpy((char *)&protoid[3], (char *)&etype, 2);
- tp = lookup_protoid(protoid);
+ tp = lookup_protoid(ndo, protoid);
tp->p_name = strdup(eproto_db[i].s);
+ if (tp->p_name == NULL)
+ (*ndo->ndo_error)(ndo,
+ "init_protoidarray: strdup(eproto_db[i].s)");
}
/* Hardwire some SNAP proto ID names */
for (pl = protoidlist; pl->name != NULL; ++pl) {
- tp = lookup_protoid(pl->protoid);
+ tp = lookup_protoid(ndo, pl->protoid);
/* Don't override existing name */
if (tp->p_name != NULL)
continue;
@@ -850,7 +895,7 @@ static const struct etherlist {
* translation, so we just pcap_next_etherent as a convenience.
*/
static void
-init_etherarray(void)
+init_etherarray(netdissect_options *ndo)
{
register const struct etherlist *el;
register struct enamemem *tp;
@@ -864,8 +909,11 @@ init_etherarray(void)
fp = fopen(PCAP_ETHERS_FILE, "r");
if (fp != NULL) {
while ((ep = pcap_next_etherent(fp)) != NULL) {
- tp = lookup_emem(ep->addr);
+ tp = lookup_emem(ndo, ep->addr);
tp->e_name = strdup(ep->name);
+ if (tp->e_name == NULL)
+ (*ndo->ndo_error)(ndo,
+ "init_etherarray: strdup(ep->addr)");
}
(void)fclose(fp);
}
@@ -873,7 +921,7 @@ init_etherarray(void)
/* Hardwire some ethernet names */
for (el = etherlist; el->name != NULL; ++el) {
- tp = lookup_emem(el->addr);
+ tp = lookup_emem(ndo, el->addr);
/* Don't override existing name */
if (tp->e_name != NULL)
continue;
@@ -881,14 +929,12 @@ init_etherarray(void)
#ifdef USE_ETHER_NTOHOST
/*
* Use YP/NIS version of name if available.
- *
- * We don't cast it to "const struct ether_addr *"
- * because some systems don't modify the Ethernet
- * address but fail to declare the second argument
- * as a "const" pointer.
*/
- if (ether_ntohost(name, (struct ether_addr *)el->addr) == 0) {
+ if (ether_ntohost(name, (const struct ether_addr *)el->addr) == 0) {
tp->e_name = strdup(name);
+ if (tp->e_name == NULL)
+ (*ndo->ndo_error)(ndo,
+ "init_etherarray: strdup(name)");
continue;
}
#endif
@@ -1114,7 +1160,7 @@ static const struct tok ipxsap_db[] = {
};
static void
-init_ipxsaparray(void)
+init_ipxsaparray(netdissect_options *ndo)
{
register int i;
register struct hnamemem *table;
@@ -1126,7 +1172,7 @@ init_ipxsaparray(void)
table = table->nxt;
table->name = ipxsap_db[i].s;
table->addr = htons(ipxsap_db[i].v);
- table->nxt = newhnamemem();
+ table->nxt = newhnamemem(ndo);
}
}
@@ -1149,11 +1195,11 @@ init_addrtoname(netdissect_options *ndo, uint32_t localnet, uint32_t mask)
*/
return;
- init_etherarray();
+ init_etherarray(ndo);
init_servarray(ndo);
- init_eprotoarray();
- init_protoidarray();
- init_ipxsaparray();
+ init_eprotoarray(ndo);
+ init_protoidarray(ndo);
+ init_ipxsaparray(ndo);
}
const char *
@@ -1161,24 +1207,24 @@ dnaddr_string(netdissect_options *ndo, u_short dnaddr)
{
register struct hnamemem *tp;
- for (tp = &dnaddrtable[dnaddr & (HASHNAMESIZE-1)]; tp->nxt != 0;
+ for (tp = &dnaddrtable[dnaddr & (HASHNAMESIZE-1)]; tp->nxt != NULL;
tp = tp->nxt)
if (tp->addr == dnaddr)
return (tp->name);
tp->addr = dnaddr;
- tp->nxt = newhnamemem();
+ tp->nxt = newhnamemem(ndo);
if (ndo->ndo_nflag)
- tp->name = dnnum_string(dnaddr);
+ tp->name = dnnum_string(ndo, dnaddr);
else
- tp->name = dnname_string(dnaddr);
+ tp->name = dnname_string(ndo, dnaddr);
return(tp->name);
}
/* Return a zero'ed hnamemem struct and cuts down on calloc() overhead */
struct hnamemem *
-newhnamemem(void)
+newhnamemem(netdissect_options *ndo)
{
register struct hnamemem *p;
static struct hnamemem *ptr = NULL;
@@ -1188,17 +1234,16 @@ newhnamemem(void)
num = 64;
ptr = (struct hnamemem *)calloc(num, sizeof (*ptr));
if (ptr == NULL)
- error("newhnamemem: calloc");
+ (*ndo->ndo_error)(ndo, "newhnamemem: calloc");
}
--num;
p = ptr++;
return (p);
}
-#ifdef INET6
/* Return a zero'ed h6namemem struct and cuts down on calloc() overhead */
struct h6namemem *
-newh6namemem(void)
+newh6namemem(netdissect_options *ndo)
{
register struct h6namemem *p;
static struct h6namemem *ptr = NULL;
@@ -1208,13 +1253,12 @@ newh6namemem(void)
num = 64;
ptr = (struct h6namemem *)calloc(num, sizeof (*ptr));
if (ptr == NULL)
- error("newh6namemem: calloc");
+ (*ndo->ndo_error)(ndo, "newh6namemem: calloc");
}
--num;
p = ptr++;
return (p);
}
-#endif /* INET6 */
/* Represent TCI part of the 802.1Q 4-octet tag as text. */
const char *
diff --git a/addrtoname.h b/addrtoname.h
index b07d8b29e4cf..72e5ef19d549 100644
--- a/addrtoname.h
+++ b/addrtoname.h
@@ -19,6 +19,14 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
+/*
+ * Definitions to let us compile most of the IPv6 code even on systems
+ * without IPv6 support.
+ */
+#ifndef INET6_ADDRSTRLEN
+#define INET6_ADDRSTRLEN 46
+#endif
+
/* Name to address translation routines. */
enum {
@@ -32,28 +40,22 @@ enum {
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 *isonsap_string(const u_char *, register u_int);
+extern const char *le64addr_string(netdissect_options *, const u_char *);
+extern const char *etherproto_string(netdissect_options *, u_short);
+extern const char *tcpport_string(netdissect_options *, u_short);
+extern const char *udpport_string(netdissect_options *, u_short);
+extern const char *isonsap_string(netdissect_options *, 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 *protoid_string(netdissect_options *, const u_char *);
+extern const char *ipxsap_string(netdissect_options *, u_short);
extern const char *getname(netdissect_options *, const u_char *);
-#ifdef INET6
extern const char *getname6(netdissect_options *, const u_char *);
-#endif
extern const char *intoa(uint32_t);
extern void init_addrtoname(netdissect_options *, uint32_t, uint32_t);
-extern struct hnamemem *newhnamemem(void);
-#ifdef INET6
-extern struct h6namemem *newh6namemem(void);
-#endif
+extern struct hnamemem *newhnamemem(netdissect_options *);
+extern struct h6namemem *newh6namemem(netdissect_options *);
extern const char * ieee8021q_tci_string(const uint16_t);
#define ipaddr_string(ndo, p) getname(ndo, (const u_char *)(p))
-#ifdef INET6
#define ip6addr_string(ndo, p) getname6(ndo, (const u_char *)(p))
-#endif
diff --git a/missing/inet_ntop.c b/addrtostr.c
index 8c6f7eb8c7eb..92875622e361 100644
--- a/missing/inet_ntop.c
+++ b/addrtostr.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999 Kungliga Tekniska Hgskolan
+ * 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
- * Hgskolan 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
@@ -40,9 +40,11 @@
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
+#include "addrtostr.h"
#include <stdio.h>
+#include <string.h>
/*
*
@@ -56,13 +58,12 @@
#define INT16SZ 2 /* word size */
#endif
-static const char *
-inet_ntop_v4 (const void *src, char *dst, size_t size)
+const char *
+addrtostr (const void *src, char *dst, size_t size)
{
+ const u_char *srcaddr = (const u_char *)src;
const char digits[] = "0123456789";
int i;
- struct in_addr *addr = (struct in_addr *)src;
- u_long a = ntohl(addr->s_addr);
const char *orig_dst = dst;
if (size < INET_ADDRSTRLEN) {
@@ -70,7 +71,7 @@ inet_ntop_v4 (const void *src, char *dst, size_t size)
return NULL;
}
for (i = 0; i < 4; ++i) {
- int n = (a >> (24 - i * 8)) & 0xFF;
+ int n = *srcaddr++;
int non_zerop = 0;
if (non_zerop || n / 100 > 0) {
@@ -91,12 +92,11 @@ inet_ntop_v4 (const void *src, char *dst, size_t size)
return orig_dst;
}
-#ifdef INET6
/*
* Convert IPv6 binary address into presentation (printable) format.
*/
-static const char *
-inet_ntop_v6 (const u_char *src, char *dst, size_t size)
+const char *
+addrtostr6 (const void *src, char *dst, size_t size)
{
/*
* Note that int32_t and int16_t need only be "at least" large enough
@@ -105,14 +105,16 @@ inet_ntop_v6 (const u_char *src, char *dst, size_t size)
* Keep this in mind if you think this function should have been coded
* to use pointer overlays. All the world's not a VAX.
*/
- char tmp [INET6_ADDRSTRLEN+1];
- char *tp;
+ const u_char *srcaddr = (const u_char *)src;
+ char *dp;
+ size_t space_left, added_space;
+ int snprintfed;
struct {
long base;
long len;
} best, cur;
u_long words [IN6ADDRSZ / INT16SZ];
- int i;
+ u_int i;
/* Preprocess:
* Copy the input (bytewise) array into a wordwise array.
@@ -120,7 +122,7 @@ inet_ntop_v6 (const u_char *src, char *dst, size_t size)
*/
memset (words, 0, sizeof(words));
for (i = 0; i < IN6ADDRSZ; i++)
- words[i/2] |= (src[i] << ((1 - (i % 2)) << 3));
+ words[i/2] |= (srcaddr[i] << ((1 - (i % 2)) << 3));
best.len = 0;
best.base = -1;
@@ -148,7 +150,17 @@ inet_ntop_v6 (const u_char *src, char *dst, size_t size)
/* Format the result.
*/
- tp = tmp;
+ dp = dst;
+ space_left = size;
+#define APPEND_CHAR(c) \
+ { \
+ if (space_left == 0) { \
+ errno = ENOSPC; \
+ return (NULL); \
+ } \
+ *dp++ = c; \
+ space_left--; \
+ }
for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++)
{
/* Are we inside the best run of 0x00's?
@@ -156,61 +168,47 @@ inet_ntop_v6 (const u_char *src, char *dst, size_t size)
if (best.base != -1 && i >= best.base && i < (best.base + best.len))
{
if (i == best.base)
- *tp++ = ':';
+ APPEND_CHAR(':');
continue;
}
/* Are we following an initial run of 0x00s or any real hex?
*/
if (i != 0)
- *tp++ = ':';
+ APPEND_CHAR(':');
/* Is this address an encapsulated IPv4?
*/
if (i == 6 && best.base == 0 &&
(best.len == 6 || (best.len == 5 && words[5] == 0xffff)))
{
- if (!inet_ntop_v4(src+12, tp, sizeof(tmp) - (tp - tmp)))
+ if (!addrtostr(srcaddr+12, dp, space_left))
{
errno = ENOSPC;
return (NULL);
}
- tp += strlen(tp);
+ added_space = strlen(dp);
+ dp += added_space;
+ space_left -= added_space;
break;
}
- tp += sprintf (tp, "%lx", words[i]);
+ snprintfed = snprintf (dp, space_left, "%lx", words[i]);
+ if (snprintfed < 0)
+ return (NULL);
+ if ((size_t) snprintfed >= space_left)
+ {
+ errno = ENOSPC;
+ return (NULL);
+ }
+ dp += snprintfed;
+ space_left -= snprintfed;
}
/* Was it a trailing run of 0x00's?
*/
if (best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ))
- *tp++ = ':';
- *tp++ = '\0';
+ APPEND_CHAR(':');
+ APPEND_CHAR('\0');
- /* Check for overflow, copy, and we're done.
- */
- if ((size_t)(tp - tmp) > size)
- {
- errno = ENOSPC;
- return (NULL);
- }
- return strcpy (dst, tmp);
-}
-#endif /* INET6 */
-
-
-const char *
-inet_ntop(int af, const void *src, char *dst, size_t size)
-{
- switch (af) {
- case AF_INET :
- return inet_ntop_v4 (src, dst, size);
-#ifdef INET6
- case AF_INET6:
- return inet_ntop_v6 ((const u_char*)src, dst, size);
-#endif
- default :
- errno = EAFNOSUPPORT;
- return NULL;
- }
+ return (dst);
}
diff --git a/missing/inet_pton.c b/addrtostr.h
index 3466f42b7cb5..2b95a1625573 100644
--- a/missing/inet_pton.c
+++ b/addrtostr.h
@@ -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,14 +36,7 @@
* SUCH DAMAGE.
*/
-#include <tcpdump-stdinc.h>
+/* Address to printable string translation routines. */
-int
-inet_pton(int af, const char *src, void *dst)
-{
- if (af != AF_INET) {
- errno = EAFNOSUPPORT;
- return -1;
- }
- return inet_aton (src, dst);
-}
+extern const char *addrtostr(const void *src, char *dst, size_t size);
+extern const char *addrtostr6(const void *src, char *dst, size_t size);
diff --git a/af.c b/af.c
index bea6d977763f..539ede5251e2 100644
--- a/af.c
+++ b/af.c
@@ -15,13 +15,12 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-#include "interface.h"
+#include <netdissect-stdinc.h>
+#include "netdissect.h"
#include "af.h"
const struct tok af_values[] = {
diff --git a/af.h b/af.h
index bbe1a16f4f94..1bde577e4220 100644
--- a/af.h
+++ b/af.h
@@ -50,6 +50,6 @@ extern const struct tok bsd_af_values[];
#define BSD_AFNUM_ISO 7
#define BSD_AFNUM_APPLETALK 16
#define BSD_AFNUM_IPX 23
-#define BSD_AFNUM_INET6_BSD 24 /* OpenBSD (and probably NetBSD), BSD/OS */
-#define BSD_AFNUM_INET6_FREEBSD 28
-#define BSD_AFNUM_INET6_DARWIN 30
+#define BSD_AFNUM_INET6_BSD 24 /* NetBSD, OpenBSD, BSD/OS, Npcap */
+#define BSD_AFNUM_INET6_FREEBSD 28 /* FreeBSD */
+#define BSD_AFNUM_INET6_DARWIN 30 /* OS X, iOS, other Darwin-based OSes */
diff --git a/ascii_strcasecmp.c b/ascii_strcasecmp.c
new file mode 100644
index 000000000000..b8decf141b05
--- /dev/null
+++ b/ascii_strcasecmp.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 1987 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that this notice is preserved and that due credit is given
+ * to the University of California at Berkeley. The name of the University
+ * may not be used to endorse or promote products derived from this
+ * software without specific written prior permission. This software
+ * is provided ``as is'' without express or implied warranty.
+ */
+
+#include "ascii_strcasecmp.h"
+
+/*
+ * This array maps upper-case ASCII letters to their lower-case
+ * equivalents; all other byte values are mapped to themselves,
+ * so this is locale-independent and intended to be locale-independent,
+ * to avoid issues with, for example, "i" and "I" not being lower-case
+ * and upper-case versions of the same letter in Turkish, where
+ * there are separate "i with dot" and "i without dot" letters.
+ */
+static const unsigned char charmap[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
+ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ 0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
+ 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
+ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
+ 0x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
+ 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
+ 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
+ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
+ 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
+ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
+ 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
+ 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
+ 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
+ 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
+ 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
+ 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
+ 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
+ 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
+ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
+ 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
+ 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
+ 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
+ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
+ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
+ 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
+};
+
+int
+ascii_strcasecmp(const char *s1, const char *s2)
+{
+ register const unsigned char *cm = charmap,
+ *us1 = (const unsigned char *)s1,
+ *us2 = (const unsigned char *)s2;
+
+ while (cm[*us1] == cm[*us2++])
+ if (*us1++ == '\0')
+ return(0);
+ return(cm[*us1] - cm[*--us2]);
+}
+
+int
+ascii_strncasecmp(const char *s1, const char *s2, register size_t n)
+{
+ register const unsigned char *cm = charmap,
+ *us1 = (const unsigned char *)s1,
+ *us2 = (const unsigned char *)s2;
+
+ for (;;) {
+ if (n == 0) {
+ /*
+ * We've run out of characters that we should
+ * compare, and they've all been equal; return
+ * 0, to indicate that the prefixes are the
+ * same.
+ */
+ return(0);
+ }
+ if (cm[*us1] != cm[*us2++]) {
+ /*
+ * We've found a mismatch.
+ */
+ break;
+ }
+ if (*us1++ == '\0') {
+ /*
+ * We've run out of characters *to* compare,
+ * and they've all been equal; return 0, to
+ * indicate that the strings are the same.
+ */
+ return(0);
+ }
+ n--;
+ }
+ return(cm[*us1] - cm[*--us2]);
+}
diff --git a/ascii_strcasecmp.h b/ascii_strcasecmp.h
new file mode 100644
index 000000000000..7f8ddb9aaa3f
--- /dev/null
+++ b/ascii_strcasecmp.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 1988-1997
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Copyright (c) 1998-2012 Michael Richardson <mcr@tcpdump.org>
+ * The TCPDUMP project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef netdissect_ascii_strcasecmp_h
+#define netdissect_ascii_strcasecmp_h
+
+#include <stddef.h>
+
+extern int ascii_strcasecmp(const char *, const char *);
+extern int ascii_strncasecmp(const char *, const char *, size_t);
+
+#endif /* netdissect_ascii_strcasecmp_h */
diff --git a/atmuni31.h b/atmuni31.h
deleted file mode 100644
index 0f85430098ce..000000000000
--- a/atmuni31.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 1997 Yen Yen Lim and North Dakota State University
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Yen Yen Lim and
- North Dakota State University
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/* Based on UNI3.1 standard by ATM Forum */
-
-/* ATM traffic types based on VPI=0 and (the following VCI */
-#define VCI_PPC 0x05 /* Point-to-point signal msg */
-#define VCI_BCC 0x02 /* Broadcast signal msg */
-#define VCI_OAMF4SC 0x03 /* Segment OAM F4 flow cell */
-#define VCI_OAMF4EC 0x04 /* End-to-end OAM F4 flow cell */
-#define VCI_METAC 0x01 /* Meta signal msg */
-#define VCI_ILMIC 0x10 /* ILMI msg */
-
-/* Q.2931 signalling messages */
-#define CALL_PROCEED 0x02 /* call proceeding */
-#define CONNECT 0x07 /* connect */
-#define CONNECT_ACK 0x0f /* connect_ack */
-#define SETUP 0x05 /* setup */
-#define RELEASE 0x4d /* release */
-#define RELEASE_DONE 0x5a /* release_done */
-#define RESTART 0x46 /* restart */
-#define RESTART_ACK 0x4e /* restart ack */
-#define STATUS 0x7d /* status */
-#define STATUS_ENQ 0x75 /* status ack */
-#define ADD_PARTY 0x80 /* add party */
-#define ADD_PARTY_ACK 0x81 /* add party ack */
-#define ADD_PARTY_REJ 0x82 /* add party rej */
-#define DROP_PARTY 0x83 /* drop party */
-#define DROP_PARTY_ACK 0x84 /* drop party ack */
-
-/* Information Element Parameters in the signalling messages */
-#define CAUSE 0x08 /* cause */
-#define ENDPT_REF 0x54 /* endpoint reference */
-#define AAL_PARA 0x58 /* ATM adaptation layer parameters */
-#define TRAFF_DESCRIP 0x59 /* atm traffic descriptors */
-#define CONNECT_ID 0x5a /* connection identifier */
-#define QOS_PARA 0x5c /* quality of service parameters */
-#define B_HIGHER 0x5d /* broadband higher layer information */
-#define B_BEARER 0x5e /* broadband bearer capability */
-#define B_LOWER 0x5f /* broadband lower information */
-#define CALLING_PARTY 0x6c /* calling party number */
-#define CALLED_PARTY 0x70 /* called party nmber */
-
-#define Q2931 0x09
-
-/* Q.2931 signalling general messages format */
-#define PROTO_POS 0 /* offset of protocol discriminator */
-#define CALL_REF_POS 2 /* offset of call reference value */
-#define MSG_TYPE_POS 5 /* offset of message type */
-#define MSG_LEN_POS 7 /* offset of mesage length */
-#define IE_BEGIN_POS 9 /* offset of first information element */
-
-/* format of signalling messages */
-#define TYPE_POS 0
-#define LEN_POS 2
-#define FIELD_BEGIN_POS 4
diff --git a/bpf_dump.c b/bpf_dump.c
index 2ef852834085..9bad38d387e0 100644
--- a/bpf_dump.c
+++ b/bpf_dump.c
@@ -19,16 +19,15 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <stdio.h>
-#include "interface.h"
+#include "netdissect.h"
void
bpf_dump(const struct bpf_program *p, int option)
diff --git a/checksum.c b/checksum.c
index d8263c7a244a..0829fbe6f039 100644
--- a/checksum.c
+++ b/checksum.c
@@ -17,19 +17,18 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
-#include "interface.h"
+#include "netdissect.h"
/*
* CRC-10 table generated using the following Python snippet:
@@ -146,17 +145,17 @@ create_osi_cksum (const uint8_t *pptr, int checksum_offset, int length)
uint32_t c0;
uint32_t c1;
uint16_t checksum;
- int index;
+ int idx;
c0 = 0;
c1 = 0;
- for (index = 0; index < length; index++) {
+ for (idx = 0; idx < length; idx++) {
/*
* Ignore the contents of the checksum field.
*/
- if (index == checksum_offset ||
- index == checksum_offset+1) {
+ if (idx == checksum_offset ||
+ idx == checksum_offset+1) {
c1 += c0;
pptr++;
} else {
diff --git a/config.h.in b/config.h.in
index 914289a8f9fc..27ba4b10d7a0 100644
--- a/config.h.in
+++ b/config.h.in
@@ -1,7 +1,7 @@
/* config.h.in. Generated from configure.in by autoheader. */
-/* define if you have the addrinfo function */
-#undef HAVE_ADDRINFO
+/* define if you want to build the possibly-buggy SMB printer */
+#undef ENABLE_SMB
/* Define to 1 if you have the `alarm' function. */
#undef HAVE_ALARM
@@ -34,24 +34,21 @@
/* Define to 1 if you have the `ether_ntohost' function. */
#undef HAVE_ETHER_NTOHOST
+/* Define to 1 if you have the `EVP_CIPHER_CTX_new' function. */
+#undef HAVE_EVP_CIPHER_CTX_NEW
+
/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
/* Define to 1 if you have the `fork' function. */
#undef HAVE_FORK
-/* Define to 1 if you have the `getnameinfo' function. */
-#undef HAVE_GETNAMEINFO
-
/* Define to 1 if you have the `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
@@ -79,6 +76,9 @@
/* Define to 1 if you have the <netinet/if_ether.h> header file. */
#undef HAVE_NETINET_IF_ETHER_H
+/* Define to 1 if you have the <net/if_pflog.h> header file. */
+#undef HAVE_NET_IF_PFLOG_H
+
/* Define to 1 if you have the <net/pfvar.h> header file. */
#undef HAVE_NET_PFVAR_H
@@ -88,6 +88,9 @@
/* Define to 1 if you have the <openssl/evp.h> header file. */
#undef HAVE_OPENSSL_EVP_H
+/* define if the OS provides AF_INET6 and struct in6_addr */
+#undef HAVE_OS_IPV6_SUPPORT
+
/* if there's an os_proto.h for this platform, to use additional prototypes */
#undef HAVE_OS_PROTO_H
@@ -142,6 +145,12 @@
/* Define to 1 if you have the `pcap_set_immediate_mode' function. */
#undef HAVE_PCAP_SET_IMMEDIATE_MODE
+/* Define to 1 if you have the `pcap_set_optimizer_debug' function. */
+#undef HAVE_PCAP_SET_OPTIMIZER_DEBUG
+
+/* Define to 1 if you have the `pcap_set_parser_debug' function. */
+#undef HAVE_PCAP_SET_PARSER_DEBUG
+
/* Define to 1 if you have the `pcap_set_tstamp_precision' function. */
#undef HAVE_PCAP_SET_TSTAMP_PRECISION
@@ -184,9 +193,6 @@
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
-/* Define to 1 if you have the `strcasecmp' function. */
-#undef HAVE_STRCASECMP
-
/* Define to 1 if you have the `strdup' function. */
#undef HAVE_STRDUP
@@ -238,15 +244,9 @@
/* 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
@@ -292,9 +292,6 @@
/* 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
diff --git a/configure b/configure
index 43b3068aab43..03c69c582cab 100755
--- a/configure
+++ b/configure
@@ -704,7 +704,6 @@ enable_smb
with_user
with_chroot
with_sandbox_capsicum
-enable_ipv6
with_system_libpcap
with_crypto
with_cap_ng
@@ -1332,8 +1331,6 @@ Optional Features:
--disable-universal don't build universal on OS X
--enable-smb enable possibly-buggy SMB printer default=yes
--disable-smb disable possibly-buggy SMB printer
- --enable-ipv6 enable ipv6 (with ipv4) support
- --disable-ipv6 disable ipv6 support
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@@ -1346,7 +1343,8 @@ Optional Packages:
--with-sandbox-capsicum use Capsicum security functions [default=yes, if
available]
--with-system-libpcap don't use local pcap library
- --with-crypto use OpenSSL libcrypto [default=yes, if available]
+ --with-crypto[=DIR] use OpenSSL/libressl libcrypto (located in directory
+ DIR, if specified) [default=yes, if available]
--with-cap-ng use libcap-ng [default=yes, if available]
Some influential environment variables:
@@ -3352,7 +3350,18 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
{ $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"
+ if expr "x-ffloat-store" : "x-W.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -ffloat-store"
+ elif expr "x-ffloat-store" : "x-f.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -ffloat-store"
+ elif expr "x-ffloat-store" : "x-m.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -ffloat-store"
+ else
+ CFLAGS="$CFLAGS -ffloat-store"
+ fi
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@@ -4213,7 +4222,25 @@ fi
done
if test "$ac_cv_header_net_pfvar_h" = yes; then
- LOCALSRC="print-pflog.c $LOCALSRC"
+ for ac_header in net/if_pflog.h
+do :
+ ac_fn_c_check_header_compile "$LINENO" "net/if_pflog.h" "ac_cv_header_net_if_pflog_h" "#include <sys/types.h>
+ #include <sys/socket.h>
+ #include <net/if.h>
+ #include <net/pfvar.h>
+"
+if test "x$ac_cv_header_net_if_pflog_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_NET_IF_PFLOG_H 1
+_ACEOF
+
+fi
+
+done
+
+ if test "$ac_cv_header_net_if_pflog_h" = yes; then
+ LOCALSRC="print-pflog.c $LOCALSRC"
+ fi
fi
for ac_header in netinet/if_ether.h
do :
@@ -4474,7 +4501,7 @@ $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 ENABLE_SMB 1" >>confdefs.h
LOCALSRC="print-smb.c smbutil.c $LOCALSRC"
;;
@@ -4576,9 +4603,9 @@ $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.
+# We must check this before checking whether to check the OS's IPv6,
+# support 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
@@ -4842,30 +4869,19 @@ 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.
-if test "${enable_ipv6+set}" = set; then :
- enableval=$enable_ipv6; case "$enableval" in
-yes) { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
- LOCALSRC="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
-
- ipv6=yes
- ;;
-*)
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
- ipv6=no
- ;;
- esac
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+#
+# Check whether AF_INET6 and struct in6_addr are defined.
+# If they aren't both defined, we don't have sufficient OS
+# support for IPv6, so we don't look for IPv6 support libraries,
+# and we define AF_INET6 and struct in6_addr ourselves.
+#
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the operating system supports IPv6" >&5
+$as_echo_n "checking whether the operating system supports IPv6... " >&6; }
+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>
#include <netinet/in.h>
@@ -4882,21 +4898,23 @@ foo(struct in6_addr *addr)
_ACEOF
if ac_fn_c_try_compile "$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; }
- LOCALSRC="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 HAVE_OS_IPV6_SUPPORT 1" >>confdefs.h
+
+ ipv6=yes
- ipv6=yes
else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
- ipv6=no
+ ipv6=no
+
+
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-
ipv6type=unknown
ipv6lib=none
@@ -4917,8 +4935,7 @@ yes
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "yes" >/dev/null 2>&1; then :
- ipv6type=$i;
- CFLAGS="-DINET6 $CFLAGS"
+ ipv6type=$i
fi
rm -f conftest*
@@ -4936,8 +4953,7 @@ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
ipv6type=$i;
ipv6lib=inet6;
ipv6libdir=/usr/local/v6/lib;
- ipv6trylibc=yes;
- CFLAGS="-DINET6 $CFLAGS"
+ ipv6trylibc=yes
fi
rm -f conftest*
@@ -4952,8 +4968,7 @@ yes
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "yes" >/dev/null 2>&1; then :
- ipv6type=$i;
- CFLAGS="-DINET6 $CFLAGS"
+ ipv6type=$i
fi
rm -f conftest*
@@ -4964,7 +4979,7 @@ rm -f conftest*
ipv6lib=inet6
ipv6libdir=/usr/inet6/lib
ipv6trylibc=yes;
- CFLAGS="-DINET6 -I/usr/inet6/include $CFLAGS"
+ CFLAGS="-I/usr/inet6/include $CFLAGS"
fi
;;
toshiba)
@@ -4979,8 +4994,7 @@ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "yes" >/dev/null 2>&1; then :
ipv6type=$i;
ipv6lib=inet6;
- ipv6libdir=/usr/local/v6/lib;
- CFLAGS="-DINET6 $CFLAGS"
+ ipv6libdir=/usr/local/v6/lib
fi
rm -f conftest*
@@ -5015,8 +5029,7 @@ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "yes" >/dev/null 2>&1; then :
ipv6type=$i;
ipv6lib=inet6;
- ipv6libdir=/usr/local/v6/lib;
- CFLAGS="-DINET6 $CFLAGS"
+ ipv6libdir=/usr/local/v6/lib
fi
rm -f conftest*
@@ -5046,239 +5059,6 @@ if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
fi
fi
-
-if test "$ipv6" = "yes"; then
- #
- # XXX - on Tru64 UNIX 5.1, there is no "getaddrinfo()"
- # function in libc; there are "ngetaddrinfo()" and
- # "ogetaddrinfo()" functions, and <netdb.h> #defines
- # "getaddrinfo" to be either "ngetaddrinfo" or
- # "ogetaddrinfo", depending on whether _SOCKADDR_LEN
- # or _XOPEN_SOURCE_EXTENDED are defined or not.
- #
- # So this test doesn't work on Tru64 5.1, and possibly
- # on other 5.x releases. This causes the configure
- # script to become confused, and results in libpcap
- # being unbuildable.
- #
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing getaddrinfo" >&5
-$as_echo_n "checking for library containing getaddrinfo... " >&6; }
-if ${ac_cv_search_getaddrinfo+:} 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 getaddrinfo ();
-int
-main ()
-{
-return getaddrinfo ();
- ;
- return 0;
-}
-_ACEOF
-for ac_lib in '' socket; do
- if test -z "$ac_lib"; then
- ac_res="none required"
- else
- ac_res=-l$ac_lib
- LIBS="-l$ac_lib $ac_func_search_save_LIBS"
- fi
- if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_search_getaddrinfo=$ac_res
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext
- if ${ac_cv_search_getaddrinfo+:} false; then :
- break
-fi
-done
-if ${ac_cv_search_getaddrinfo+:} false; then :
-
-else
- ac_cv_search_getaddrinfo=no
-fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_getaddrinfo" >&5
-$as_echo "$ac_cv_search_getaddrinfo" >&6; }
-ac_res=$ac_cv_search_getaddrinfo
-if test "$ac_res" != no; then :
- test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking getaddrinfo bug" >&5
-$as_echo_n "checking getaddrinfo bug... " >&6; }
- if ${td_cv_buggygetaddrinfo+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test "$cross_compiling" = yes; then :
- td_cv_buggygetaddrinfo=unknown
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-#include <sys/types.h>
-#include <netdb.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-
-main()
-{
- int passive, gaierr, inet4 = 0, inet6 = 0;
- struct addrinfo hints, *ai, *aitop;
- char straddr[INET6_ADDRSTRLEN], strport[16];
-
- for (passive = 0; passive <= 1; passive++) {
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = AF_UNSPEC;
- hints.ai_flags = passive ? AI_PASSIVE : 0;
- hints.ai_socktype = SOCK_STREAM;
- hints.ai_protocol = IPPROTO_TCP;
- if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
- (void)gai_strerror(gaierr);
- goto bad;
- }
- for (ai = aitop; ai; ai = ai->ai_next) {
- if (ai->ai_addr == NULL ||
- ai->ai_addrlen == 0 ||
- getnameinfo(ai->ai_addr, ai->ai_addrlen,
- straddr, sizeof(straddr), strport, sizeof(strport),
- NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
- goto bad;
- }
- switch (ai->ai_family) {
- case AF_INET:
- if (strcmp(strport, "54321") != 0) {
- goto bad;
- }
- if (passive) {
- if (strcmp(straddr, "0.0.0.0") != 0) {
- goto bad;
- }
- } else {
- if (strcmp(straddr, "127.0.0.1") != 0) {
- goto bad;
- }
- }
- inet4++;
- break;
- case AF_INET6:
- if (strcmp(strport, "54321") != 0) {
- goto bad;
- }
- if (passive) {
- if (strcmp(straddr, "::") != 0) {
- goto bad;
- }
- } else {
- if (strcmp(straddr, "::1") != 0) {
- goto bad;
- }
- }
- inet6++;
- break;
- case AF_UNSPEC:
- goto bad;
- break;
-#ifdef AF_UNIX
- case AF_UNIX:
-#else
-#ifdef AF_LOCAL
- case AF_LOCAL:
-#endif
-#endif
- default:
- /* another family support? */
- break;
- }
- }
- }
-
- /* supported family should be 2, unsupported family should be 0 */
- if (!(inet4 == 0 || inet4 == 2))
- goto bad;
- if (!(inet6 == 0 || inet6 == 2))
- goto bad;
-
- if (aitop)
- freeaddrinfo(aitop);
- exit(0);
-
- bad:
- if (aitop)
- freeaddrinfo(aitop);
- exit(1);
-}
-
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
- td_cv_buggygetaddrinfo=no
-else
- td_cv_buggygetaddrinfo=yes
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
- conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-fi
-
- if test "$td_cv_buggygetaddrinfo" = no; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: good" >&5
-$as_echo "good" >&6; }
- elif test "$td_cv_buggygetaddrinfo" = unknown; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: unknown (cross-compiling)" >&5
-$as_echo "unknown (cross-compiling)" >&6; }
- else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: buggy" >&5
-$as_echo "buggy" >&6; }
- fi
-
- if test "$td_cv_buggygetaddrinfo" = "yes"; then
- #
- # XXX - it doesn't appear that "ipv6type" can ever be
- # set to "linux". Should this be testing for
- # "linux-glibc", or for that *or* "linux-libinet6"?
- # If the latter, note that "linux-libinet6" is also
- # the type given to some non-Linux OSes.
- #
- if test "$ipv6type" != "linux"; then
- echo 'Fatal: You must get working getaddrinfo() function.'
- echo ' or you can specify "--disable-ipv6"'.
- exit 1
- else
- echo 'Warning: getaddrinfo() implementation on your system seems be buggy.'
- echo ' Better upgrade your system library to newest version'
- echo ' of GNU C library (aka glibc).'
- fi
- fi
-
-fi
-
- ac_fn_c_check_func "$LINENO" "getnameinfo" "ac_cv_func_getnameinfo"
-if test "x$ac_cv_func_getnameinfo" = xyes; then :
- $as_echo "#define HAVE_GETNAMEINFO 1" >>confdefs.h
-
-else
- case " $LIBOBJS " in
- *" getnameinfo.$ac_objext "* ) ;;
- *) LIBOBJS="$LIBOBJS getnameinfo.$ac_objext"
- ;;
-esac
-
-fi
-
-
-fi
-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dnet_htoa declaration in netdnet/dnetdb.h" >&5
$as_echo_n "checking for dnet_htoa declaration in netdnet/dnetdb.h... " >&6; }
if ${td_cv_decl_netdnet_dnetdb_h_dnet_htoa+:} false; then :
@@ -5306,116 +5086,6 @@ $as_echo "#define HAVE_NETDNET_DNETDB_H_DNET_HTOA 1" >>confdefs.h
fi
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for addrinfo" >&5
-$as_echo_n "checking for addrinfo... " >&6; }
- if ${ac_cv_addrinfo+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-# include <netdb.h>
-int
-main ()
-{
-struct addrinfo a
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_addrinfo=yes
-else
- ac_cv_addrinfo=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-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
-
- else
-
-$as_echo "#define NEED_ADDRINFO_H 1" >>confdefs.h
-
- fi
-
-if test "$ac_cv_addrinfo" = no; then
- missing_includes=yes
-fi
-
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for NI_MAXSERV" >&5
-$as_echo_n "checking for NI_MAXSERV... " >&6; }
- if ${ac_cv_maxserv+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <netdb.h>
-#ifdef NI_MAXSERV
-yes
-#endif
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "yes" >/dev/null 2>&1; then :
- ac_cv_maxserv=yes
-else
- ac_cv_maxserv=no
-fi
-rm -f conftest*
-
-fi
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_maxserv" >&5
-$as_echo "$ac_cv_maxserv" >&6; }
- if test $ac_cv_maxserv != yes; then
- $as_echo "#define NEED_ADDRINFO_H 1" >>confdefs.h
-
- fi
-
-if test "$ac_cv_maxserv" = no; then
- missing_includes=yes
-fi
-
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for NI_NAMEREQD" >&5
-$as_echo_n "checking for NI_NAMEREQD... " >&6; }
- if ${ac_cv_namereqd+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <netdb.h>
-#ifdef NI_NOFQDN
-yes
-#endif
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "yes" >/dev/null 2>&1; then :
- ac_cv_namereqd=yes
-else
- ac_cv_namereqd=no
-fi
-rm -f conftest*
-
-fi
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_namereqd" >&5
-$as_echo "$ac_cv_namereqd" >&6; }
- if test $ac_cv_namereqd != yes; then
- $as_echo "#define NEED_ADDRINFO_H 1" >>confdefs.h
-
- fi
-
-if test "$ac_cv_namereqd" = 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
@@ -5429,19 +5099,6 @@ esac
fi
-ac_fn_c_check_func "$LINENO" "strcasecmp" "ac_cv_func_strcasecmp"
-if test "x$ac_cv_func_strcasecmp" = xyes; then :
- $as_echo "#define HAVE_STRCASECMP 1" >>confdefs.h
-
-else
- case " $LIBOBJS " in
- *" strcasecmp.$ac_objext "* ) ;;
- *) LIBOBJS="$LIBOBJS strcasecmp.$ac_objext"
- ;;
-esac
-
-fi
-
ac_fn_c_check_func "$LINENO" "strlcat" "ac_cv_func_strlcat"
if test "x$ac_cv_func_strlcat" = xyes; then :
$as_echo "#define HAVE_STRLCAT 1" >>confdefs.h
@@ -5794,7 +5451,6 @@ fi
-
LBL_LIBS="$LIBS"
pfopen=/usr/examples/packetfilter/pfopen.c
if test -f $pfopen ; then
@@ -6163,114 +5819,6 @@ fi
# Check for these after AC_LBL_LIBPCAP, so we link with the appropriate
# libraries (e.g., "-lsocket -lnsl" on Solaris).
#
-# We don't use AC_REPLACE_FUNCS because that uses AC_CHECK_FUNCS which
-# use AC_CHECK_FUNC which doesn't let us specify the right #includes
-# to make this work on BSD/OS 4.x. BSD/OS 4.x ships with the BIND8
-# resolver, and the way it defines inet_{ntop,pton} is rather strange;
-# it does not ship with a libc symbol "inet_ntop()", it ships with
-# "_inet_ntop()", and has a #define macro in one of the system headers
-# to rename it.
-#
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inet_ntop" >&5
-$as_echo_n "checking for inet_ntop... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-int
-main ()
-{
-char src[4], dst[128];
-inet_ntop(AF_INET, src, dst, sizeof(dst));
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- { $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; }
- case " $LIBOBJS " in
- *" inet_ntop.$ac_objext "* ) ;;
- *) LIBOBJS="$LIBOBJS inet_ntop.$ac_objext"
- ;;
-esac
-
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inet_pton" >&5
-$as_echo_n "checking for inet_pton... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-int
-main ()
-{
-char src[128], dst[4];
-inet_pton(AF_INET, src, dst);
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- { $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; }
- case " $LIBOBJS " in
- *" inet_pton.$ac_objext "* ) ;;
- *) LIBOBJS="$LIBOBJS inet_pton.$ac_objext"
- ;;
-esac
-
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inet_aton" >&5
-$as_echo_n "checking for inet_aton... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-int
-main ()
-{
-char src[128];
-struct in_addr dst;
-inet_aton(src, &dst);
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- { $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; }
- case " $LIBOBJS " in
- *" inet_aton.$ac_objext "* ) ;;
- *) LIBOBJS="$LIBOBJS inet_aton.$ac_objext"
- ;;
-esac
-
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-
-#
-# Check for these after AC_LBL_LIBPCAP, for the same reason.
-#
# You are in a twisty little maze of UN*Xes, all different.
# Some might not have ether_ntohost().
# Some might have it, but not declare it in any header file.
@@ -6488,44 +6036,6 @@ if test "x$ac_cv_lib_dlpi_dlpi_walk" = xyes; then :
fi
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking if sockaddr struct has sa_len member" >&5
-$as_echo_n "checking if sockaddr struct has sa_len member... " >&6; }
- if ${ac_cv_sockaddr_has_sa_len+:} 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 ()
-{
-u_int i = sizeof(((struct sockaddr *)0)->sa_len)
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_sockaddr_has_sa_len=yes
-else
- ac_cv_sockaddr_has_sa_len=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sockaddr_has_sa_len" >&5
-$as_echo "$ac_cv_sockaddr_has_sa_len" >&6; }
- if test $ac_cv_sockaddr_has_sa_len = yes ; then
- $as_echo "#define HAVE_SOCKADDR_SA_LEN 1" >>confdefs.h
-
- fi
-
-if test "$ac_cv_sockaddr_has_sa_len" = no; then
- missing_includes=yes
-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 :
@@ -6748,18 +6258,38 @@ $as_echo "#define HAVE_PCAP_VERSION 1" >>confdefs.h
$as_echo "no" >&6; }
fi
fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pcap_debug is defined by libpcap" >&5
+
+#
+# Check for special debugging functions
+#
+for ac_func in pcap_set_parser_debug
+do :
+ ac_fn_c_check_func "$LINENO" "pcap_set_parser_debug" "ac_cv_func_pcap_set_parser_debug"
+if test "x$ac_cv_func_pcap_set_parser_debug" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_PCAP_SET_PARSER_DEBUG 1
+_ACEOF
+
+fi
+done
+
+if test "$ac_cv_func_pcap_set_parser_debug" = "no" ; then
+ #
+ # OK, we don't have pcap_set_parser_debug() to set the libpcap
+ # filter expression parser debug flag; can we directly set the
+ # flag?
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pcap_debug is defined by libpcap" >&5
$as_echo_n "checking whether pcap_debug is defined by libpcap... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
- extern int pcap_debug;
+ extern int pcap_debug;
- return pcap_debug;
+ return pcap_debug;
;
return 0;
@@ -6772,30 +6302,30 @@ else
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
-if test "$ac_lbl_cv_pcap_debug_defined" = yes ; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+ 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
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
- #
- # OK, what about "yydebug"?
- #
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether yydebug is defined by libpcap" >&5
+ #
+ # OK, what about "yydebug"?
+ #
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether yydebug is defined by libpcap" >&5
$as_echo_n "checking whether yydebug is defined by libpcap... " >&6; }
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
- extern int yydebug;
+ extern int yydebug;
- return yydebug;
+ return yydebug;
;
return 0;
@@ -6808,17 +6338,29 @@ else
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
- if test "$ac_lbl_cv_yydebug_defined" = yes ; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+ 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
- else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
+ fi
fi
fi
+for ac_func in pcap_set_optimizer_debug
+do :
+ ac_fn_c_check_func "$LINENO" "pcap_set_optimizer_debug" "ac_cv_func_pcap_set_optimizer_debug"
+if test "x$ac_cv_func_pcap_set_optimizer_debug" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_PCAP_SET_OPTIMIZER_DEBUG 1
+_ACEOF
+
+fi
+done
+
ac_fn_c_check_func "$LINENO" "bpf_dump" "ac_cv_func_bpf_dump"
if test "x$ac_cv_func_bpf_dump" = xyes; then :
$as_echo "#define HAVE_BPF_DUMP 1" >>confdefs.h
@@ -7417,7 +6959,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 \"netdissect-stdinc.h\"
"
if test "x$ac_cv_header_pcap_bluetooth_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
@@ -7430,7 +6972,7 @@ 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\"
+ ac_fn_c_check_header_compile "$LINENO" "pcap/nflog.h" "ac_cv_header_pcap_nflog_h" "#include \"netdissect-stdinc.h\"
"
if test "x$ac_cv_header_pcap_nflog_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
@@ -7443,7 +6985,7 @@ 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 \"netdissect-stdinc.h\"
"
if test "x$ac_cv_header_pcap_usb_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
@@ -7651,10 +7193,57 @@ rm -f os-proto.h
#
if test "$ac_lbl_cc_dont_try_gcc_dashW" != yes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler fails when given an unknown warning option" >&5
+$as_echo_n "checking whether the compiler fails when given an unknown warning option... " >&6; }
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -Wxyzzy-this-will-never-succeed-xyzzy"
+ 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: no" >&5
+$as_echo "no" >&6; }
+ #
+ # We're assuming this is clang, where
+ # -Werror=unknown-warning-option is the appropriate
+ # option to force the compiler to fail.
+ #
+ ac_lbl_unknown_warning_option_error="-Werror=unknown-warning-option"
+
+else
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ CFLAGS="$save_CFLAGS"
+
+
{ $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"
+ if expr "x-Wall" : "x-W.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wall"
+ elif expr "x-Wall" : "x-f.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wall"
+ elif expr "x-Wall" : "x-m.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wall"
+ else
+ CFLAGS="$CFLAGS -Wall"
+ fi
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@@ -7686,7 +7275,18 @@ 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"
+ if expr "x-Wmissing-prototypes" : "x-W.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wmissing-prototypes"
+ elif expr "x-Wmissing-prototypes" : "x-f.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wmissing-prototypes"
+ elif expr "x-Wmissing-prototypes" : "x-m.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wmissing-prototypes"
+ else
+ CFLAGS="$CFLAGS -Wmissing-prototypes"
+ fi
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@@ -7718,7 +7318,18 @@ 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"
+ if expr "x-Wstrict-prototypes" : "x-W.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wstrict-prototypes"
+ elif expr "x-Wstrict-prototypes" : "x-f.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wstrict-prototypes"
+ elif expr "x-Wstrict-prototypes" : "x-m.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wstrict-prototypes"
+ else
+ CFLAGS="$CFLAGS -Wstrict-prototypes"
+ fi
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@@ -7750,7 +7361,18 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $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"
+ if expr "x-Wwrite-strings" : "x-W.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wwrite-strings"
+ elif expr "x-Wwrite-strings" : "x-f.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wwrite-strings"
+ elif expr "x-Wwrite-strings" : "x-m.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wwrite-strings"
+ else
+ CFLAGS="$CFLAGS -Wwrite-strings"
+ fi
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@@ -7782,7 +7404,18 @@ 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"
+ if expr "x-Wpointer-arith" : "x-W.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wpointer-arith"
+ elif expr "x-Wpointer-arith" : "x-f.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wpointer-arith"
+ elif expr "x-Wpointer-arith" : "x-m.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wpointer-arith"
+ else
+ CFLAGS="$CFLAGS -Wpointer-arith"
+ fi
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@@ -7811,10 +7444,279 @@ 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 -Wcast-qual option" >&5
+$as_echo_n "checking whether the compiler supports the -Wcast-qual option... " >&6; }
+ save_CFLAGS="$CFLAGS"
+ if expr "x-Wcast-qual" : "x-W.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wcast-qual"
+ elif expr "x-Wcast-qual" : "x-f.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wcast-qual"
+ elif expr "x-Wcast-qual" : "x-m.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wcast-qual"
+ else
+ CFLAGS="$CFLAGS -Wcast-qual"
+ fi
+ 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 -Wcast-qual"
+
+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 -Wshadow option" >&5
+$as_echo_n "checking whether the compiler supports the -Wshadow option... " >&6; }
+ save_CFLAGS="$CFLAGS"
+ if expr "x-Wshadow" : "x-W.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wshadow"
+ elif expr "x-Wshadow" : "x-f.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wshadow"
+ elif expr "x-Wshadow" : "x-m.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wshadow"
+ else
+ CFLAGS="$CFLAGS -Wshadow"
+ fi
+ 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 -Wshadow"
+
+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 -Wdeclaration-after-statement option" >&5
+$as_echo_n "checking whether the compiler supports the -Wdeclaration-after-statement option... " >&6; }
+ save_CFLAGS="$CFLAGS"
+ if expr "x-Wdeclaration-after-statement" : "x-W.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wdeclaration-after-statement"
+ elif expr "x-Wdeclaration-after-statement" : "x-f.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wdeclaration-after-statement"
+ elif expr "x-Wdeclaration-after-statement" : "x-m.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wdeclaration-after-statement"
+ else
+ CFLAGS="$CFLAGS -Wdeclaration-after-statement"
+ fi
+ 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 -Wdeclaration-after-statement"
+
+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 -Wpedantic option" >&5
+$as_echo_n "checking whether the compiler supports the -Wpedantic option... " >&6; }
+ save_CFLAGS="$CFLAGS"
+ if expr "x-Wpedantic" : "x-W.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wpedantic"
+ elif expr "x-Wpedantic" : "x-f.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wpedantic"
+ elif expr "x-Wpedantic" : "x-m.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wpedantic"
+ else
+ CFLAGS="$CFLAGS -Wpedantic"
+ fi
+ 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 -Wpedantic"
+
+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 -Wold-style-definition option" >&5
+$as_echo_n "checking whether the compiler supports the -Wold-style-definition option... " >&6; }
+ save_CFLAGS="$CFLAGS"
+ if expr "x-Wold-style-definition" : "x-W.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wold-style-definition"
+ elif expr "x-Wold-style-definition" : "x-f.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wold-style-definition"
+ elif expr "x-Wold-style-definition" : "x-m.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wold-style-definition"
+ else
+ CFLAGS="$CFLAGS -Wold-style-definition"
+ fi
+ 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 -Wold-style-definition"
+
+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 -Wused-but-marked-unused option" >&5
+$as_echo_n "checking whether the compiler supports the -Wused-but-marked-unused option... " >&6; }
+ save_CFLAGS="$CFLAGS"
+ if expr "x-Wused-but-marked-unused" : "x-W.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wused-but-marked-unused"
+ elif expr "x-Wused-but-marked-unused" : "x-f.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wused-but-marked-unused"
+ elif expr "x-Wused-but-marked-unused" : "x-m.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wused-but-marked-unused"
+ else
+ CFLAGS="$CFLAGS -Wused-but-marked-unused"
+ fi
+ 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 -Wused-but-marked-unused"
+
+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"
+ if expr "x-W" : "x-W.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -W"
+ elif expr "x-W" : "x-f.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -W"
+ elif expr "x-W" : "x-m.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -W"
+ else
+ CFLAGS="$CFLAGS -W"
+ fi
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@@ -8092,45 +7994,9 @@ $as_echo "#define LBL_ALIGN 1" >>confdefs.h
fi
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for h_errno" >&5
-$as_echo_n "checking for h_errno... " >&6; }
- if ${ac_cv_var_h_errno+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-# include <sys/types.h>
-# include <netdb.h>
-int
-main ()
-{
-int foo = h_errno;
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_var_h_errno=yes
-else
- ac_cv_var_h_errno=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-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
-
- fi
-
-
-# Check for OpenSSL libcrypto
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use OpenSSL libcrypto" >&5
-$as_echo_n "checking whether to use OpenSSL libcrypto... " >&6; }
+# Check for OpenSSL/libressl libcrypto
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use OpenSSL/libressl libcrypto" >&5
+$as_echo_n "checking whether to use OpenSSL/libressl libcrypto... " >&6; }
# Specify location for both includes and libraries.
want_libcrypto=ifavailable
@@ -8139,20 +8005,38 @@ if test "${with_crypto+set}" = set; then :
withval=$with_crypto;
if test $withval = no
then
+ # User doesn't want to link with libcrypto.
want_libcrypto=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
elif test $withval = yes
then
+ # User wants to link with libcrypto but hasn't specified
+ # a directory.
want_libcrypto=yes
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
+ else
+ # User wants to link with libcrypto and has specified
+ # a directory, so use the provided value.
+ want_libcrypto=yes
+ libcrypto_root=$withval
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, using the version installed in $withval" >&5
+$as_echo "yes, using the version installed in $withval" >&6; }
+
+ #
+ # Put the subdirectories of the libcrypto root directory
+ # at the front of the header and library search path.
+ #
+ CFLAGS="-I$withval/include $CFLAGS"
+ LIBS="-L$withval/lib $LIBS"
fi
else
#
- # Use libcrypto if it's present, otherwise don't.
+ # Use libcrypto if it's present, otherwise don't; no directory
+ # was specified.
#
want_libcrypto=ifavailable
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, if available" >&5
@@ -8161,7 +8045,19 @@ $as_echo "yes, if available" >&6; }
fi
if test "$want_libcrypto" != "no"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for DES_cbc_encrypt in -lcrypto" >&5
+ #
+ # Don't check for libcrypto unless we have its headers;
+ # Apple, bless their pointy little heads, apparently ship
+ # libcrypto as a library, but not the header files, in
+ # El Capitan, probably because they don't want you writing
+ # nasty portable code that could run on other UN*Xes, they
+ # want you writing code that uses their Shiny New Crypto
+ # Library and that only runs on OS X.
+ #
+ ac_fn_c_check_header_mongrel "$LINENO" "openssl/crypto.h" "ac_cv_header_openssl_crypto_h" "$ac_includes_default"
+if test "x$ac_cv_header_openssl_crypto_h" = xyes; then :
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for DES_cbc_encrypt in -lcrypto" >&5
$as_echo_n "checking for DES_cbc_encrypt in -lcrypto... " >&6; }
if ${ac_cv_lib_crypto_DES_cbc_encrypt+:} false; then :
$as_echo_n "(cached) " >&6
@@ -8206,7 +8102,8 @@ _ACEOF
fi
- for ac_header in openssl/evp.h
+ if test "$ac_cv_lib_crypto_DES_cbc_encrypt" = "yes"; then
+ for ac_header in openssl/evp.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "openssl/evp.h" "ac_cv_header_openssl_evp_h" "$ac_includes_default"
if test "x$ac_cv_header_openssl_evp_h" = xyes; then :
@@ -8218,6 +8115,28 @@ fi
done
+ #
+ # OK, do we have EVP_CIPHER_CTX_new?
+ # If so, we use it to allocate an
+ # EVP_CIPHER_CTX, as EVP_CIPHER_CTX may be
+ # opaque; otherwise, we allocate it ourselves.
+ #
+ for ac_func in EVP_CIPHER_CTX_new
+do :
+ ac_fn_c_check_func "$LINENO" "EVP_CIPHER_CTX_new" "ac_cv_func_EVP_CIPHER_CTX_new"
+if test "x$ac_cv_func_EVP_CIPHER_CTX_new" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_EVP_CIPHER_CTX_NEW 1
+_ACEOF
+
+fi
+done
+
+ fi
+
+fi
+
+
fi
# Check for libcap-ng
diff --git a/configure.in b/configure.in
index a629559ed1cb..a78a12666347 100755
--- a/configure.in
+++ b/configure.in
@@ -37,7 +37,13 @@ AC_CHECK_HEADERS(net/pfvar.h, , , [#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>])
if test "$ac_cv_header_net_pfvar_h" = yes; then
- LOCALSRC="print-pflog.c $LOCALSRC"
+ AC_CHECK_HEADERS(net/if_pflog.h, , , [#include <sys/types.h>
+ #include <sys/socket.h>
+ #include <net/if.h>
+ #include <net/pfvar.h>])
+ if test "$ac_cv_header_net_if_pflog_h" = yes; then
+ LOCALSRC="print-pflog.c $LOCALSRC"
+ fi
fi
AC_CHECK_HEADERS(netinet/if_ether.h, , , [#include <sys/types.h>
#include <sys/socket.h>])
@@ -169,7 +175,7 @@ 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, 1,
+ AC_DEFINE(ENABLE_SMB, 1,
[define if you want to build the possibly-buggy SMB printer])
LOCALSRC="print-smb.c smbutil.c $LOCALSRC"
;;
@@ -229,32 +235,24 @@ else
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.
+# We must check this before checking whether to check the OS's IPv6,
+# support 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
- --disable-ipv6 disable ipv6 support],
-[ case "$enableval" in
-yes) AC_MSG_RESULT(yes)
- LOCALSRC="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, 1, [Define if you enable IPv6 support])
- ipv6=yes
- ;;
-*)
- AC_MSG_RESULT(no)
- ipv6=no
- ;;
- esac ],
-
- AC_COMPILE_IFELSE(
+#
+# Check whether AF_INET6 and struct in6_addr are defined.
+# If they aren't both defined, we don't have sufficient OS
+# support for IPv6, so we don't look for IPv6 support libraries,
+# and we define AF_INET6 and struct in6_addr ourselves.
+#
+AC_MSG_CHECKING([whether the operating system supports IPv6])
+AC_COMPILE_IFELSE(
[
AC_LANG_SOURCE(
- [[/* AF_INET6 available check */
+ [[
+/* AF_INET6 available check */
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
@@ -267,17 +265,19 @@ foo(struct in6_addr *addr)
#else
#error "AF_INET6 not defined"
#endif
- ]])
+ ]])
+ ],
+ [
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_OS_IPV6_SUPPORT, 1,
+ [define if the OS provides AF_INET6 and struct in6_addr])
+ ipv6=yes
],
-[ AC_MSG_RESULT(yes)
- LOCALSRC="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, 1, [Define if you enable IPv6 support])
- ipv6=yes],
-[ AC_MSG_RESULT(no)
- ipv6=no],
-[ AC_MSG_RESULT(no)
- ipv6=no]
-))
+ [
+ AC_MSG_RESULT(no)
+ ipv6=no
+ ]
+)
ipv6type=unknown
ipv6lib=none
@@ -294,8 +294,7 @@ if test "$ipv6" = "yes"; then
#ifdef IPV6_INRIA_VERSION
yes
#endif],
- [ipv6type=$i;
- CFLAGS="-DINET6 $CFLAGS"])
+ [ipv6type=$i])
;;
kame)
dnl http://www.kame.net/
@@ -307,8 +306,7 @@ yes
[ipv6type=$i;
ipv6lib=inet6;
ipv6libdir=/usr/local/v6/lib;
- ipv6trylibc=yes;
- CFLAGS="-DINET6 $CFLAGS"])
+ ipv6trylibc=yes])
;;
linux-glibc)
dnl http://www.v6.linux.or.jp/
@@ -317,8 +315,7 @@ yes
#if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
yes
#endif],
- [ipv6type=$i;
- CFLAGS="-DINET6 $CFLAGS"])
+ [ipv6type=$i])
;;
linux-libinet6)
dnl http://www.v6.linux.or.jp/
@@ -331,7 +328,7 @@ yes
ipv6lib=inet6
ipv6libdir=/usr/inet6/lib
ipv6trylibc=yes;
- CFLAGS="-DINET6 -I/usr/inet6/include $CFLAGS"
+ CFLAGS="-I/usr/inet6/include $CFLAGS"
fi
;;
toshiba)
@@ -342,8 +339,7 @@ yes
#endif],
[ipv6type=$i;
ipv6lib=inet6;
- ipv6libdir=/usr/local/v6/lib;
- CFLAGS="-DINET6 $CFLAGS"])
+ ipv6libdir=/usr/local/v6/lib])
;;
v6d)
AC_EGREP_CPP(yes,
@@ -364,8 +360,7 @@ yes
#endif],
[ipv6type=$i;
ipv6lib=inet6;
- ipv6libdir=/usr/local/v6/lib;
- CFLAGS="-DINET6 $CFLAGS"])
+ ipv6libdir=/usr/local/v6/lib])
;;
esac
if test "$ipv6type" != "unknown"; then
@@ -391,151 +386,6 @@ if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
fi
fi
-
-if test "$ipv6" = "yes"; then
- #
- # XXX - on Tru64 UNIX 5.1, there is no "getaddrinfo()"
- # function in libc; there are "ngetaddrinfo()" and
- # "ogetaddrinfo()" functions, and <netdb.h> #defines
- # "getaddrinfo" to be either "ngetaddrinfo" or
- # "ogetaddrinfo", depending on whether _SOCKADDR_LEN
- # or _XOPEN_SOURCE_EXTENDED are defined or not.
- #
- # So this test doesn't work on Tru64 5.1, and possibly
- # on other 5.x releases. This causes the configure
- # script to become confused, and results in libpcap
- # being unbuildable.
- #
- AC_SEARCH_LIBS(getaddrinfo, socket, [dnl
- AC_MSG_CHECKING(getaddrinfo bug)
- AC_CACHE_VAL(td_cv_buggygetaddrinfo, [AC_TRY_RUN([
-#include <sys/types.h>
-#include <netdb.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-
-main()
-{
- int passive, gaierr, inet4 = 0, inet6 = 0;
- struct addrinfo hints, *ai, *aitop;
- char straddr[INET6_ADDRSTRLEN], strport[16];
-
- for (passive = 0; passive <= 1; passive++) {
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = AF_UNSPEC;
- hints.ai_flags = passive ? AI_PASSIVE : 0;
- hints.ai_socktype = SOCK_STREAM;
- hints.ai_protocol = IPPROTO_TCP;
- if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
- (void)gai_strerror(gaierr);
- goto bad;
- }
- for (ai = aitop; ai; ai = ai->ai_next) {
- if (ai->ai_addr == NULL ||
- ai->ai_addrlen == 0 ||
- getnameinfo(ai->ai_addr, ai->ai_addrlen,
- straddr, sizeof(straddr), strport, sizeof(strport),
- NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
- goto bad;
- }
- switch (ai->ai_family) {
- case AF_INET:
- if (strcmp(strport, "54321") != 0) {
- goto bad;
- }
- if (passive) {
- if (strcmp(straddr, "0.0.0.0") != 0) {
- goto bad;
- }
- } else {
- if (strcmp(straddr, "127.0.0.1") != 0) {
- goto bad;
- }
- }
- inet4++;
- break;
- case AF_INET6:
- if (strcmp(strport, "54321") != 0) {
- goto bad;
- }
- if (passive) {
- if (strcmp(straddr, "::") != 0) {
- goto bad;
- }
- } else {
- if (strcmp(straddr, "::1") != 0) {
- goto bad;
- }
- }
- inet6++;
- break;
- case AF_UNSPEC:
- goto bad;
- break;
-#ifdef AF_UNIX
- case AF_UNIX:
-#else
-#ifdef AF_LOCAL
- case AF_LOCAL:
-#endif
-#endif
- default:
- /* another family support? */
- break;
- }
- }
- }
-
- /* supported family should be 2, unsupported family should be 0 */
- if (!(inet4 == 0 || inet4 == 2))
- goto bad;
- if (!(inet6 == 0 || inet6 == 2))
- goto bad;
-
- if (aitop)
- freeaddrinfo(aitop);
- exit(0);
-
- bad:
- if (aitop)
- freeaddrinfo(aitop);
- exit(1);
-}
-],
- td_cv_buggygetaddrinfo=no,
- td_cv_buggygetaddrinfo=yes,
- td_cv_buggygetaddrinfo=unknown)])
- if test "$td_cv_buggygetaddrinfo" = no; then
- AC_MSG_RESULT(good)
- elif test "$td_cv_buggygetaddrinfo" = unknown; then
- AC_MSG_RESULT([unknown (cross-compiling)])
- else
- AC_MSG_RESULT(buggy)
- fi
-
- if test "$td_cv_buggygetaddrinfo" = "yes"; then
- #
- # XXX - it doesn't appear that "ipv6type" can ever be
- # set to "linux". Should this be testing for
- # "linux-glibc", or for that *or* "linux-libinet6"?
- # If the latter, note that "linux-libinet6" is also
- # the type given to some non-Linux OSes.
- #
- if test "$ipv6type" != "linux"; then
- echo 'Fatal: You must get working getaddrinfo() function.'
- echo ' or you can specify "--disable-ipv6"'.
- exit 1
- else
- echo 'Warning: getaddrinfo() implementation on your system seems be buggy.'
- echo ' Better upgrade your system library to newest version'
- echo ' of GNU C library (aka glibc).'
- fi
- fi
- ])
- AC_REPLACE_FUNCS(getnameinfo)
-fi
-
AC_CACHE_CHECK([for dnet_htoa declaration in netdnet/dnetdb.h],
[td_cv_decl_netdnet_dnetdb_h_dnet_htoa],
[AC_EGREP_HEADER(dnet_htoa, netdnet/dnetdb.h,
@@ -546,28 +396,7 @@ if test "$td_cv_decl_netdnet_dnetdb_h_dnet_htoa" = yes; then
[define if you have a dnet_htoa declaration in <netdnet/dnetdb.h>])
fi
-dnl
-dnl Checks for addrinfo structure
-AC_STRUCT_ADDRINFO(ac_cv_addrinfo)
-if test "$ac_cv_addrinfo" = no; then
- missing_includes=yes
-fi
-
-dnl
-dnl Checks for NI_MAXSERV
-AC_NI_MAXSERV(ac_cv_maxserv)
-if test "$ac_cv_maxserv" = no; then
- missing_includes=yes
-fi
-
-dnl
-dnl Checks for NI_NAMEREQD
-AC_NI_NAMEREQD(ac_cv_namereqd)
-if test "$ac_cv_namereqd" = no; then
- missing_includes=yes
-fi
-
-AC_REPLACE_FUNCS(vfprintf strcasecmp strlcat strlcpy strdup strsep getopt_long)
+AC_REPLACE_FUNCS(vfprintf strlcat strlcpy strdup strsep getopt_long)
AC_CHECK_FUNCS(fork vfork strftime)
AC_CHECK_FUNCS(setlinebuf alarm)
@@ -589,52 +418,12 @@ dnl Some platforms may need -lnsl for 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)
-
AC_LBL_LIBPCAP(V_PCAPDEP, V_INCLS)
#
# Check for these after AC_LBL_LIBPCAP, so we link with the appropriate
# libraries (e.g., "-lsocket -lnsl" on Solaris).
#
-# We don't use AC_REPLACE_FUNCS because that uses AC_CHECK_FUNCS which
-# use AC_CHECK_FUNC which doesn't let us specify the right #includes
-# to make this work on BSD/OS 4.x. BSD/OS 4.x ships with the BIND8
-# resolver, and the way it defines inet_{ntop,pton} is rather strange;
-# it does not ship with a libc symbol "inet_ntop()", it ships with
-# "_inet_ntop()", and has a #define macro in one of the system headers
-# to rename it.
-#
-dnl AC_TRY_COMPILE(inet_ntop inet_pton inet_aton)
-AC_MSG_CHECKING(for inet_ntop)
-AC_TRY_LINK([#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>], [char src[4], dst[128];
-inet_ntop(AF_INET, src, dst, sizeof(dst));],
- [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
- AC_LIBOBJ(inet_ntop)])
-AC_MSG_CHECKING(for inet_pton)
-AC_TRY_LINK([#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>], [char src[128], dst[4];
-inet_pton(AF_INET, src, dst);],
- [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
- AC_LIBOBJ(inet_pton)])
-AC_MSG_CHECKING(for inet_aton)
-AC_TRY_LINK([#include <sys/types.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>], [char src[128];
-struct in_addr dst;
-inet_aton(src, &dst);],
- [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
- AC_LIBOBJ(inet_aton)])
-
-#
-# Check for these after AC_LBL_LIBPCAP, for the same reason.
-#
# You are in a twisty little maze of UN*Xes, all different.
# Some might not have ether_ntohost().
# Some might have it, but not declare it in any header file.
@@ -753,14 +542,6 @@ fi
# libdlpi is needed for Solaris 11 and later.
AC_CHECK_LIB(dlpi, dlpi_walk, LIBS="$LIBS -ldlpi" LDFLAGS="-L/lib $LDFLAGS", ,-L/lib)
-dnl portability macros for getaddrinfo/getnameinfo
-dnl
-dnl Check for sa_len
-AC_CHECK_SA_LEN(ac_cv_sockaddr_has_sa_len)
-if test "$ac_cv_sockaddr_has_sa_len" = no; then
- missing_includes=yes
-fi
-
dnl
dnl Check for "pcap_list_datalinks()", "pcap_set_datalink()",
dnl and "pcap_datalink_name_to_val()", and use substitute versions
@@ -860,39 +641,51 @@ if test $ac_cv_func_pcap_lib_version = "no" ; then
AC_MSG_RESULT(no)
fi
fi
-AC_MSG_CHECKING(whether pcap_debug is defined by libpcap)
-AC_TRY_LINK([],
- [
- extern int pcap_debug;
-
- return pcap_debug;
- ],
- ac_lbl_cv_pcap_debug_defined=yes,
- ac_lbl_cv_pcap_debug_defined=no)
-if test "$ac_lbl_cv_pcap_debug_defined" = yes ; then
- AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_PCAP_DEBUG, 1, [define if libpcap has pcap_debug])
-else
- AC_MSG_RESULT(no)
- #
- # OK, what about "yydebug"?
+
+#
+# Check for special debugging functions
+#
+AC_CHECK_FUNCS(pcap_set_parser_debug)
+if test "$ac_cv_func_pcap_set_parser_debug" = "no" ; then
#
- AC_MSG_CHECKING(whether yydebug is defined by libpcap)
+ # OK, we don't have pcap_set_parser_debug() to set the libpcap
+ # filter expression parser debug flag; can we directly set the
+ # flag?
+ AC_MSG_CHECKING(whether pcap_debug is defined by libpcap)
AC_TRY_LINK([],
[
- extern int yydebug;
+ extern int pcap_debug;
- return yydebug;
+ return pcap_debug;
],
- ac_lbl_cv_yydebug_defined=yes,
- ac_lbl_cv_yydebug_defined=no)
- if test "$ac_lbl_cv_yydebug_defined" = yes ; then
+ ac_lbl_cv_pcap_debug_defined=yes,
+ ac_lbl_cv_pcap_debug_defined=no)
+ if test "$ac_lbl_cv_pcap_debug_defined" = yes ; then
AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_YYDEBUG, 1, [define if libpcap has yydebug])
+ AC_DEFINE(HAVE_PCAP_DEBUG, 1, [define if libpcap has pcap_debug])
else
AC_MSG_RESULT(no)
+ #
+ # OK, what about "yydebug"?
+ #
+ AC_MSG_CHECKING(whether yydebug is defined by libpcap)
+ AC_TRY_LINK([],
+ [
+ extern int yydebug;
+
+ return yydebug;
+ ],
+ ac_lbl_cv_yydebug_defined=yes,
+ ac_lbl_cv_yydebug_defined=no)
+ if test "$ac_lbl_cv_yydebug_defined" = yes ; then
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_YYDEBUG, 1, [define if libpcap has yydebug])
+ else
+ AC_MSG_RESULT(no)
+ fi
fi
fi
+AC_CHECK_FUNCS(pcap_set_optimizer_debug)
AC_REPLACE_FUNCS(bpf_dump) dnl moved to libpcap in 0.6
V_GROUP=0
@@ -1071,9 +864,9 @@ fi
#
savedcppflags="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $V_INCLS"
-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"])
+AC_CHECK_HEADERS(pcap/bluetooth.h,,,[#include "netdissect-stdinc.h"])
+AC_CHECK_HEADERS(pcap/nflog.h,,,[#include "netdissect-stdinc.h"])
+AC_CHECK_HEADERS(pcap/usb.h,,,[#include "netdissect-stdinc.h"])
CPPFLAGS="$savedcppflags"
AC_PROG_RANLIB
@@ -1085,35 +878,71 @@ AC_LBL_SOCKADDR_SA_LEN
AC_LBL_UNALIGNED_ACCESS
-AC_VAR_H_ERRNO
-
-# Check for OpenSSL libcrypto
-AC_MSG_CHECKING(whether to use OpenSSL libcrypto)
+# Check for OpenSSL/libressl libcrypto
+AC_MSG_CHECKING(whether to use OpenSSL/libressl libcrypto)
# Specify location for both includes and libraries.
want_libcrypto=ifavailable
AC_ARG_WITH(crypto,
- AS_HELP_STRING([--with-crypto],
- [use OpenSSL libcrypto @<:@default=yes, if available@:>@]),
+ AS_HELP_STRING([--with-crypto]@<:@=DIR@:>@,
+ [use OpenSSL/libressl libcrypto (located in directory DIR, if specified) @<:@default=yes, if available@:>@]),
[
if test $withval = no
then
+ # User doesn't want to link with libcrypto.
want_libcrypto=no
AC_MSG_RESULT(no)
elif test $withval = yes
then
+ # User wants to link with libcrypto but hasn't specified
+ # a directory.
want_libcrypto=yes
AC_MSG_RESULT(yes)
+ else
+ # User wants to link with libcrypto and has specified
+ # a directory, so use the provided value.
+ want_libcrypto=yes
+ libcrypto_root=$withval
+ AC_MSG_RESULT([yes, using the version installed in $withval])
+
+ #
+ # Put the subdirectories of the libcrypto root directory
+ # at the front of the header and library search path.
+ #
+ CFLAGS="-I$withval/include $CFLAGS"
+ LIBS="-L$withval/lib $LIBS"
fi
],[
#
- # Use libcrypto if it's present, otherwise don't.
+ # Use libcrypto if it's present, otherwise don't; no directory
+ # was specified.
#
want_libcrypto=ifavailable
AC_MSG_RESULT([yes, if available])
])
if test "$want_libcrypto" != "no"; then
- AC_CHECK_LIB(crypto, DES_cbc_encrypt)
- AC_CHECK_HEADERS(openssl/evp.h)
+ #
+ # Don't check for libcrypto unless we have its headers;
+ # Apple, bless their pointy little heads, apparently ship
+ # libcrypto as a library, but not the header files, in
+ # El Capitan, probably because they don't want you writing
+ # nasty portable code that could run on other UN*Xes, they
+ # want you writing code that uses their Shiny New Crypto
+ # Library and that only runs on OS X.
+ #
+ AC_CHECK_HEADER(openssl/crypto.h,
+ [
+ AC_CHECK_LIB(crypto, DES_cbc_encrypt)
+ if test "$ac_cv_lib_crypto_DES_cbc_encrypt" = "yes"; then
+ AC_CHECK_HEADERS(openssl/evp.h)
+ #
+ # OK, do we have EVP_CIPHER_CTX_new?
+ # If so, we use it to allocate an
+ # EVP_CIPHER_CTX, as EVP_CIPHER_CTX may be
+ # opaque; otherwise, we allocate it ourselves.
+ #
+ AC_CHECK_FUNCS(EVP_CIPHER_CTX_new)
+ fi
+ ])
fi
# Check for libcap-ng
diff --git a/cpack.c b/cpack.c
index 16bfd151698e..e37d813d39fb 100644
--- a/cpack.c
+++ b/cpack.c
@@ -27,20 +27,19 @@
* OF SUCH DAMAGE.
*/
-#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include "cpack.h"
#include "extract.h"
-uint8_t *
-cpack_next_boundary(uint8_t *buf, uint8_t *p, size_t alignment)
+const uint8_t *
+cpack_next_boundary(const uint8_t *buf, const uint8_t *p, size_t alignment)
{
size_t misalignment = (size_t)(p - buf) % alignment;
@@ -54,10 +53,10 @@ cpack_next_boundary(uint8_t *buf, uint8_t *p, size_t alignment)
* wordsize bytes remain in the buffer after the boundary. Otherwise,
* return a pointer to the boundary.
*/
-uint8_t *
+const uint8_t *
cpack_align_and_reserve(struct cpack_state *cs, size_t wordsize)
{
- uint8_t *next;
+ const uint8_t *next;
/* Ensure alignment. */
next = cpack_next_boundary(cs->c_buf, cs->c_next, wordsize);
@@ -81,7 +80,7 @@ cpack_advance(struct cpack_state *cs, const size_t toskip)
}
int
-cpack_init(struct cpack_state *cs, uint8_t *buf, size_t buflen)
+cpack_init(struct cpack_state *cs, const uint8_t *buf, size_t buflen)
{
memset(cs, 0, sizeof(*cs));
@@ -96,7 +95,7 @@ cpack_init(struct cpack_state *cs, uint8_t *buf, size_t buflen)
int
cpack_uint64(struct cpack_state *cs, uint64_t *u)
{
- uint8_t *next;
+ const uint8_t *next;
if ((next = cpack_align_and_reserve(cs, sizeof(*u))) == NULL)
return -1;
@@ -112,7 +111,7 @@ cpack_uint64(struct cpack_state *cs, uint64_t *u)
int
cpack_uint32(struct cpack_state *cs, uint32_t *u)
{
- uint8_t *next;
+ const uint8_t *next;
if ((next = cpack_align_and_reserve(cs, sizeof(*u))) == NULL)
return -1;
@@ -128,7 +127,7 @@ cpack_uint32(struct cpack_state *cs, uint32_t *u)
int
cpack_uint16(struct cpack_state *cs, uint16_t *u)
{
- uint8_t *next;
+ const uint8_t *next;
if ((next = cpack_align_and_reserve(cs, sizeof(*u))) == NULL)
return -1;
diff --git a/cpack.h b/cpack.h
index a7eb6d611d6b..3072e0c37411 100644
--- a/cpack.h
+++ b/cpack.h
@@ -31,20 +31,20 @@
#define _CPACK_H
struct cpack_state {
- uint8_t *c_buf;
- uint8_t *c_next;
+ const uint8_t *c_buf;
+ const uint8_t *c_next;
size_t c_len;
};
-int cpack_init(struct cpack_state *, uint8_t *, size_t);
+int cpack_init(struct cpack_state *, const uint8_t *, size_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 *);
-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);
+const uint8_t *cpack_next_boundary(const uint8_t *buf, const uint8_t *p, size_t alignment);
+const uint8_t *cpack_align_and_reserve(struct cpack_state *cs, size_t wordsize);
#define cpack_int8(__s, __p) cpack_uint8((__s), (uint8_t*)(__p))
#define cpack_int16(__s, __p) cpack_uint16((__s), (uint16_t*)(__p))
diff --git a/ether.h b/ether.h
index 58b92de52a03..64916789782d 100644
--- a/ether.h
+++ b/ether.h
@@ -41,18 +41,17 @@
#define ETHER_ADDR_LEN 6
/*
- * Structure of a DEC/Intel/Xerox or 802.3 Ethernet header.
+ * Structure of an Ethernet header.
*/
struct ether_header {
uint8_t ether_dhost[ETHER_ADDR_LEN];
uint8_t ether_shost[ETHER_ADDR_LEN];
- uint16_t ether_type;
+ uint16_t ether_length_type;
};
/*
- * Length of a DEC/Intel/Xerox or 802.3 Ethernet header; note that some
- * compilers may pad "struct ether_header" to a multiple of 4 bytes,
- * for example, so "sizeof (struct ether_header)" may not give the right
- * answer.
+ * Length of an Ethernet header; note that some compilers may pad
+ * "struct ether_header" to a multiple of 4 bytes, for example, so
+ * "sizeof (struct ether_header)" may not give the right answer.
*/
#define ETHER_HDRLEN 14
diff --git a/ethertype.h b/ethertype.h
index 803991735eb2..2aa53a08823d 100644
--- a/ethertype.h
+++ b/ethertype.h
@@ -196,5 +196,8 @@
#ifndef ETHERTYPE_GEONET
#define ETHERTYPE_GEONET 0x8947 /* ETSI GeoNetworking (Official IEEE registration from Jan 2013) */
#endif
+#ifndef ETHERTYPE_MEDSA
+#define ETHERTYPE_MEDSA 0xdada /* Marvel Distributed Switch Architecture */
+#endif
extern const struct tok ethertype_values[];
diff --git a/extract.h b/extract.h
index cb62ebddb61e..23623c289cb3 100644
--- a/extract.h
+++ b/extract.h
@@ -103,7 +103,7 @@ EXTRACT_32BITS(const void *p)
static inline uint64_t
EXTRACT_64BITS(const void *p)
{
- return ((uint64_t)(((uint64_t)ntohl(((const unaligned_uint32_t *)(p) + 0)->val)) << 32 | \
+ 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));
}
@@ -153,7 +153,7 @@ EXTRACT_32BITS(const void *p)
static inline uint64_t
EXTRACT_64BITS(const void *p)
{
- return ((uint64_t)(((uint64_t)ntohl(*((const uint32_t *)(p) + 0))) << 32 | \
+ return ((uint64_t)(((uint64_t)ntohl(*((const uint32_t *)(p) + 0))) << 32 |
((uint64_t)ntohl(*((const uint32_t *)(p) + 1))) << 0));
}
@@ -215,3 +215,30 @@ EXTRACT_64BITS(const void *p)
((uint64_t)(*((const uint8_t *)(p) + 2)) << 16) | \
((uint64_t)(*((const uint8_t *)(p) + 1)) << 8) | \
((uint64_t)(*((const uint8_t *)(p) + 0)) << 0)))
+
+/*
+ * Macros to check the presence of the values in question.
+ */
+#define ND_TTEST_8BITS(p) ND_TTEST2(*(p), 1)
+#define ND_TCHECK_8BITS(p) ND_TCHECK2(*(p), 1)
+
+#define ND_TTEST_16BITS(p) ND_TTEST2(*(p), 2)
+#define ND_TCHECK_16BITS(p) ND_TCHECK2(*(p), 2)
+
+#define ND_TTEST_24BITS(p) ND_TTEST2(*(p), 3)
+#define ND_TCHECK_24BITS(p) ND_TCHECK2(*(p), 3)
+
+#define ND_TTEST_32BITS(p) ND_TTEST2(*(p), 4)
+#define ND_TCHECK_32BITS(p) ND_TCHECK2(*(p), 4)
+
+#define ND_TTEST_40BITS(p) ND_TTEST2(*(p), 5)
+#define ND_TCHECK_40BITS(p) ND_TCHECK2(*(p), 5)
+
+#define ND_TTEST_48BITS(p) ND_TTEST2(*(p), 6)
+#define ND_TCHECK_48BITS(p) ND_TCHECK2(*(p), 6)
+
+#define ND_TTEST_56BITS(p) ND_TTEST2(*(p), 7)
+#define ND_TCHECK_56BITS(p) ND_TCHECK2(*(p), 7)
+
+#define ND_TTEST_64BITS(p) ND_TTEST2(*(p), 8)
+#define ND_TCHECK_64BITS(p) ND_TCHECK2(*(p), 8)
diff --git a/gmpls.c b/gmpls.c
index c9fd9bb8ac6c..23515e98c757 100644
--- a/gmpls.c
+++ b/gmpls.c
@@ -13,14 +13,13 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "gmpls.h"
/* rfc3471 */
diff --git a/gmt2local.c b/gmt2local.c
index 6958f66a4640..d6cd93b8532b 100644
--- a/gmt2local.c
+++ b/gmt2local.c
@@ -19,12 +19,11 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <stdio.h>
diff --git a/in_cksum.c b/in_cksum.c
index 171728a88ceb..e9bed2287ae6 100644
--- a/in_cksum.c
+++ b/in_cksum.c
@@ -35,14 +35,13 @@
* @(#)in_cksum.c 8.1 (Berkeley) 6/10/93
*/
-#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
/*
* Checksum routine for Internet Protocol family headers (Portable Version).
@@ -74,7 +73,7 @@ in_cksum(const struct cksum_vec *vec, int veclen)
for (; veclen != 0; vec++, veclen--) {
if (vec->len == 0)
continue;
- w = (const uint16_t *)(void *)vec->ptr;
+ w = (const uint16_t *)(const void *)vec->ptr;
if (mlen == -1) {
/*
* The first byte of this chunk is the continuation
@@ -86,18 +85,18 @@ in_cksum(const struct cksum_vec *vec, int veclen)
*/
s_util.c[1] = *(const uint8_t *)w;
sum += s_util.s;
- w = (const uint16_t *)(void *)((const uint8_t *)w + 1);
+ w = (const uint16_t *)(const void *)((const uint8_t *)w + 1);
mlen = vec->len - 1;
} else
mlen = vec->len;
/*
* Force to even boundary.
*/
- if ((1 & (unsigned long) w) && (mlen > 0)) {
+ if ((1 & (uintptr_t) w) && (mlen > 0)) {
REDUCE;
sum <<= 8;
s_util.c[0] = *(const uint8_t *)w;
- w = (const uint16_t *)(void *)((const uint8_t *)w + 1);
+ w = (const uint16_t *)(const void *)((const uint8_t *)w + 1);
mlen--;
byte_swapped = 1;
}
diff --git a/interface.h b/interface.h
index 59c1eefdb790..46d338b4af24 100644
--- a/interface.h
+++ b/interface.h
@@ -65,165 +65,15 @@ extern char *strdup(const char *);
extern char *strsep(char **, const char *);
#endif
-#define PT_VAT 1 /* Visual Audio Tool */
-#define PT_WB 2 /* distributed White Board */
-#define PT_RPC 3 /* Remote Procedure Call */
-#define PT_RTP 4 /* Real-Time Applications protocol */
-#define PT_RTCP 5 /* Real-Time Applications control protocol */
-#define PT_SNMP 6 /* Simple Network Management Protocol */
-#define PT_CNFP 7 /* Cisco NetFlow protocol */
-#define PT_TFTP 8 /* trivial file transfer protocol */
-#define PT_AODV 9 /* Ad-hoc On-demand Distance Vector Protocol */
-#define PT_CARP 10 /* Common Address Redundancy Protocol */
-#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 */
-
-#define ESRC(ep) ((ep)->ether_shost)
-#define EDST(ep) ((ep)->ether_dhost)
-
-#ifndef NTOHL
-#define NTOHL(x) (x) = ntohl(x)
-#define NTOHS(x) (x) = ntohs(x)
-#define HTONL(x) (x) = htonl(x)
-#define HTONS(x) (x) = htons(x)
-#endif
#endif
extern char *program_name; /* used to generate self-identifying messages */
-extern int32_t thiszone; /* seconds offset from gmt to local time */
-
-/*
- * True if "l" bytes of "var" were captured.
- *
- * The "snapend - (l) <= snapend" checks to make sure "l" isn't so large
- * that "snapend - (l)" underflows.
- *
- * The check is for <= rather than < because "l" might be 0.
- *
- * We cast the pointers to uintptr_t to make sure that the compiler
- * doesn't optimize away any of these tests (which it is allowed to
- * do, as adding an integer to, or subtracting an integer from, a
- * pointer assumes that the pointer is a pointer to an element of an
- * array and that the result of the addition or subtraction yields a
- * pointer to another member of the array, so that, for example, if
- * you subtract a positive integer from a pointer, the result is
- * guaranteed to be less than the original pointer value). See
- *
- * http://www.kb.cert.org/vuls/id/162289
- */
-#define TTEST2(var, l) \
- ((uintptr_t)snapend - (l) <= (uintptr_t)snapend && \
- (uintptr_t)&(var) <= (uintptr_t)snapend - (l))
-
-/* True if "var" was captured */
-#define TTEST(var) TTEST2(var, sizeof(var))
-
-/* Bail if "l" bytes of "var" were not captured */
-#define TCHECK2(var, l) if (!TTEST2(var, l)) goto trunc
-
-/* Bail if "var" was not captured */
-#define TCHECK(var) TCHECK2(var, sizeof(var))
-
-extern 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 void error(const char *, ...)
- __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 const char *dnname_string(u_short);
-extern const char *dnnum_string(u_short);
-
-/* checksum routines */
-extern void init_checksum(void);
-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 char *smb_errstr(int, int);
-extern const char *nt_errstr(uint32_t);
-
-#ifdef INET6
-extern int mask62plen(const u_char *);
-#endif /*INET6*/
-
-struct cksum_vec {
- const uint8_t *ptr;
- int len;
-};
-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;
extern void bpf_dump(const struct bpf_program *, int);
#endif
-
-#include "netdissect.h"
-
-/* forward compatibility */
-
-#ifndef NETDISSECT_REWORKED
-extern netdissect_options *gndo;
-
-#define bflag gndo->ndo_bflag
-#define eflag gndo->ndo_eflag
-#define fflag gndo->ndo_fflag
-#define jflag gndo->ndo_jflag
-#define Kflag gndo->ndo_Kflag
-#define nflag gndo->ndo_nflag
-#define Nflag gndo->ndo_Nflag
-#define Oflag gndo->ndo_Oflag
-#define pflag gndo->ndo_pflag
-#define qflag gndo->ndo_qflag
-#define Rflag gndo->ndo_Rflag
-#define sflag gndo->ndo_sflag
-#define Sflag gndo->ndo_Sflag
-#define tflag gndo->ndo_tflag
-#define Uflag gndo->ndo_Uflag
-#define uflag gndo->ndo_uflag
-#define vflag gndo->ndo_vflag
-#define xflag gndo->ndo_xflag
-#define Xflag gndo->ndo_Xflag
-#define Cflag gndo->ndo_Cflag
-#define Gflag gndo->ndo_Gflag
-#define Aflag gndo->ndo_Aflag
-#define Bflag gndo->ndo_Bflag
-#define Iflag gndo->ndo_Iflag
-#define suppress_default_print gndo->ndo_suppress_default_print
-#define packettype gndo->ndo_packettype
-#define sigsecret gndo->ndo_sigsecret
-#define Wflag gndo->ndo_Wflag
-#define WflagChars gndo->ndo_WflagChars
-#define Cflag_count gndo->ndo_Cflag_count
-#define Gflag_count gndo->ndo_Gflag_count
-#define Gflag_time gndo->ndo_Gflag_time
-#define Hflag gndo->ndo_Hflag
-#define snaplen gndo->ndo_snaplen
-#define snapend gndo->ndo_snapend
-
-extern void default_print(const u_char *, u_int);
-
-#endif
diff --git a/ip.h b/ip.h
index 72c8972680a3..8179061ef131 100644
--- a/ip.h
+++ b/ip.h
@@ -33,10 +33,8 @@
* @(#)ip.h 8.2 (Berkeley) 6/1/94
*/
-#ifndef TCPDUMP_IP_H
-#define TCPDUMP_IP_H
-
-#include "tcpdump-stdinc.h"
+#ifndef netdissect_ip_h
+#define netdissect_ip_h
/*
* Definitions for internet protocol version 4.
@@ -52,21 +50,21 @@
* against negative integers quite easily, and fail in subtle ways.
*/
struct ip {
- uint8_t ip_vhl; /* header length, version */
+ nd_uint8_t ip_vhl; /* header length, version */
#define IP_V(ip) (((ip)->ip_vhl & 0xf0) >> 4)
#define IP_HL(ip) ((ip)->ip_vhl & 0x0f)
- 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 */
+ nd_uint8_t ip_tos; /* type of service */
+ nd_uint16_t ip_len; /* total length */
+ nd_uint16_t ip_id; /* identification */
+ nd_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 */
- 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;
+ nd_uint8_t ip_ttl; /* time to live */
+ nd_uint8_t ip_p; /* protocol */
+ nd_uint16_t ip_sum; /* checksum */
+ nd_ipv4 ip_src,ip_dst; /* source and dest address */
+};
#define IP_MAXPACKET 65535 /* maximum packet size */
@@ -125,20 +123,20 @@ struct ip {
* Time stamp option structure.
*/
struct ip_timestamp {
- 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 */
+ nd_uint8_t ipt_code; /* IPOPT_TS */
+ nd_uint8_t ipt_len; /* size of structure (variable) */
+ nd_uint8_t ipt_ptr; /* index of current entry */
+ nd_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 {
- uint32_t ipt_time[1];
+ nd_uint32_t ipt_time[1];
struct ipt_ta {
- struct in_addr ipt_addr;
- uint32_t ipt_time;
+ nd_ipv4 ipt_addr;
+ nd_uint32_t ipt_time;
} ipt_ta[1];
} ipt_timestamp;
-} UNALIGNED;
+};
/* flag bits for ipt_flg */
#define IPOPT_TS_TSONLY 0 /* timestamps only */
@@ -163,4 +161,4 @@ struct ip_timestamp {
#define IPTTLDEC 1 /* subtracted when forwarding */
#define IP_MSS 576 /* default maximum segment size */
-#endif /* TCPDUMP_IP_H */
+#endif /* netdissect_ip_h */
diff --git a/ip6.h b/ip6.h
index 1ad914985b62..2ea1d0abe8ec 100644
--- a/ip6.h
+++ b/ip6.h
@@ -172,7 +172,11 @@ struct ip6_rthdr {
/* followed by routing type specific data */
} UNALIGNED;
+#define IPV6_RTHDR_TYPE_0 0
+#define IPV6_RTHDR_TYPE_2 2
+
/* Type 0 Routing header */
+/* Also used for Type 2 */
struct ip6_rthdr0 {
uint8_t ip6r0_nxt; /* next header */
uint8_t ip6r0_len; /* length in units of 8 octets */
@@ -195,7 +199,4 @@ struct ip6_frag {
#define IP6F_RESERVED_MASK 0x0006 /* reserved bits in ip6f_offlg */
#define IP6F_MORE_FRAG 0x0001 /* more-fragments flag */
-/* in print-ip6.c */
-extern int nextproto6_cksum(const struct ip6_hdr *, const uint8_t *, u_int, u_int, u_int);
-
#endif /* not _NETINET_IP6_H_ */
diff --git a/ipproto.c b/ipproto.c
index e44b74814bb4..bcf2cedc2cc4 100755
--- a/ipproto.c
+++ b/ipproto.c
@@ -13,14 +13,13 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "ipproto.h"
const struct tok ipproto_values[] = {
diff --git a/l2vpn.c b/l2vpn.c
index 54037aa19bc3..3f3639fd3eec 100755
--- a/l2vpn.c
+++ b/l2vpn.c
@@ -13,42 +13,83 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-#include "interface.h"
+#include <netdissect-stdinc.h>
+#include "netdissect.h"
#include "l2vpn.h"
-/* draft-ietf-pwe3-iana-allocation-04 */
+/*
+ * BGP Layer 2 Encapsulation Types
+ *
+ * RFC 6624
+ *
+ * http://www.iana.org/assignments/bgp-parameters/bgp-parameters.xhtml#bgp-l2-encapsulation-types-registry
+ */
const struct tok l2vpn_encaps_values[] = {
- { 0x00, "Reserved"},
- { 0x01, "Frame Relay"},
- { 0x02, "ATM AAL5 VCC transport"},
- { 0x03, "ATM transparent cell transport"},
- { 0x04, "Ethernet VLAN"},
- { 0x05, "Ethernet"},
- { 0x06, "Cisco-HDLC"},
- { 0x07, "PPP"},
- { 0x08, "SONET/SDH Circuit Emulation Service over MPLS"},
- { 0x09, "ATM n-to-one VCC cell transport"},
- { 0x0a, "ATM n-to-one VPC cell transport"},
- { 0x0b, "IP Layer2 Transport"},
- { 0x0c, "ATM one-to-one VCC Cell Mode"},
- { 0x0d, "ATM one-to-one VPC Cell Mode"},
- { 0x0e, "ATM AAL5 PDU VCC transport"},
- { 0x0f, "Frame-Relay Port mode"},
- { 0x10, "SONET/SDH Circuit Emulation over Packet"},
- { 0x11, "Structure-agnostic E1 over Packet"},
- { 0x12, "Structure-agnostic T1 (DS1) over Packet"},
- { 0x13, "Structure-agnostic E3 over Packet"},
- { 0x14, "Structure-agnostic T3 (DS3) over Packet"},
- { 0x15, "CESoPSN basic mode"},
- { 0x16, "TDMoIP basic mode"},
- { 0x17, "CESoPSN TDM with CAS"},
- { 0x18, "TDMoIP TDM with CAS"},
- { 0x40, "IP-interworking"},
+ { 0, "Reserved"},
+ { 1, "Frame Relay"},
+ { 2, "ATM AAL5 SDU VCC transport"},
+ { 3, "ATM transparent cell transport"},
+ { 4, "Ethernet (VLAN) Tagged Mode"},
+ { 5, "Ethernet Raw Mode"},
+ { 6, "Cisco HDLC"},
+ { 7, "PPP"},
+ { 8, "SONET/SDH Circuit Emulation Service over MPLS"},
+ { 9, "ATM n-to-one VCC cell transport"},
+ { 10, "ATM n-to-one VPC cell transport"},
+ { 11, "IP layer 2 transport"},
+ { 15, "Frame Relay Port mode"},
+ { 17, "Structure-agnostic E1 over packet"},
+ { 18, "Structure-agnostic T1 (DS1) over packet"},
+ { 19, "VPLS"},
+ { 20, "Structure-agnostic T3 (DS3) over packet"},
+ { 21, "Nx64kbit/s Basic Service using Structure-aware"},
+ { 25, "Frame Relay DLCI"},
+ { 40, "Structure-agnostic E3 over packet"},
+ { 41, "Octet-aligned playload for Structure-agnostic DS1 circuits"},
+ { 42, "E1 Nx64kbit/s with CAS using Structure-aware"},
+ { 43, "DS1 (ESF) Nx64kbit/s with CAS using Structure-aware"},
+ { 44, "DS1 (SF) Nx64kbit/s with CAS using Structure-aware"},
+ { 0, NULL}
+};
+
+/*
+ * MPLS Pseudowire Types
+ *
+ * RFC 4446
+ *
+ * http://www.iana.org/assignments/pwe3-parameters/pwe3-parameters.xhtml#pwe3-parameters-2
+ */
+const struct tok mpls_pw_types_values[] = {
+ { 0x0000, "Reserved"},
+ { 0x0001, "Frame Relay DLCI (Martini Mode)"},
+ { 0x0002, "ATM AAL5 SDU VCC transport"},
+ { 0x0003, "ATM transparent cell transport"},
+ { 0x0004, "Ethernet VLAN"},
+ { 0x0005, "Ethernet"},
+ { 0x0006, "Cisco-HDLC"},
+ { 0x0007, "PPP"},
+ { 0x0008, "SONET/SDH Circuit Emulation Service over MPLS"},
+ { 0x0009, "ATM n-to-one VCC cell transport"},
+ { 0x000a, "ATM n-to-one VPC cell transport"},
+ { 0x000b, "IP Layer2 Transport"},
+ { 0x000c, "ATM one-to-one VCC Cell Mode"},
+ { 0x000d, "ATM one-to-one VPC Cell Mode"},
+ { 0x000e, "ATM AAL5 PDU VCC transport"},
+ { 0x000f, "Frame-Relay Port mode"},
+ { 0x0010, "SONET/SDH Circuit Emulation over Packet"},
+ { 0x0011, "Structure-agnostic E1 over Packet"},
+ { 0x0012, "Structure-agnostic T1 (DS1) over Packet"},
+ { 0x0013, "Structure-agnostic E3 over Packet"},
+ { 0x0014, "Structure-agnostic T3 (DS3) over Packet"},
+ { 0x0015, "CESoPSN basic mode"},
+ { 0x0016, "TDMoIP basic mode"},
+ { 0x0017, "CESoPSN TDM with CAS"},
+ { 0x0018, "TDMoIP TDM with CAS"},
+ { 0x0019, "Frame Relay DLCI"},
+ { 0x0040, "IP-interworking"},
{ 0, NULL}
};
diff --git a/l2vpn.h b/l2vpn.h
index 151228fc697b..d93abf15b8b3 100755
--- a/l2vpn.h
+++ b/l2vpn.h
@@ -14,3 +14,4 @@
*/
extern const struct tok l2vpn_encaps_values[];
+extern const struct tok mpls_pw_types_values[];
diff --git a/lbl/os-solaris2.h b/lbl/os-solaris2.h
index 9f94da97658f..aedba4ef3c7a 100644
--- a/lbl/os-solaris2.h
+++ b/lbl/os-solaris2.h
@@ -25,4 +25,3 @@ int setlinebuf(FILE *);
#endif
char *strerror(int);
int snprintf(char *, size_t, const char *, ...);
-int strcasecmp(const char *, const char *);
diff --git a/lbl/os-sunos4.h b/lbl/os-sunos4.h
index b73585706cd5..0e63270b789b 100644
--- a/lbl/os-sunos4.h
+++ b/lbl/os-sunos4.h
@@ -166,12 +166,10 @@ int sscanf(char *, const char *, ...);
int stat(const char *, struct stat *);
int statfs(char *, struct statfs *);
char *strerror(int);
-int strcasecmp(const char *, const char *);
#ifdef __STDC__
struct tm;
#endif
int strftime(char *, int, char *, struct tm *);
-int strncasecmp(const char *, const char *, int);
long strtol(const char *, char **, int);
void sync(void);
void syslog(int, const char *, ...);
diff --git a/lbl/os-ultrix4.h b/lbl/os-ultrix4.h
index fa1f770f8d44..891def2b39f6 100644
--- a/lbl/os-ultrix4.h
+++ b/lbl/os-ultrix4.h
@@ -34,4 +34,3 @@ int ioctl(int, int, caddr_t);
int pfopen(char *, int);
int setlinebuf(FILE *);
int socket(int, int, int);
-int strcasecmp(const char *, const char *);
diff --git a/machdep.c b/machdep.c
index 7b259ae1c432..1f0861611326 100644
--- a/machdep.c
+++ b/machdep.c
@@ -29,7 +29,7 @@
* need to do to get it defined? This is clearly wrong, as we shouldn't
* have to include UNIX or Windows system header files to get it.
*/
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#ifndef HAVE___ATTRIBUTE__
#define __attribute__(x)
diff --git a/machdep.h b/machdep.h
index d1c7d4b5c55b..ba8ed389693b 100644
--- a/machdep.h
+++ b/machdep.h
@@ -18,8 +18,8 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef tcpdump_machdep_h
-#define tcpdump_machdep_h
+#ifndef netdissect_machdep_h
+#define netdissect_machdep_h
int abort_on_misalignment(char *, size_t);
#endif
diff --git a/mib.h b/mib.h
index 92c6c2c58f00..6c8e63c978b5 100644
--- a/mib.h
+++ b/mib.h
@@ -8,7 +8,7 @@
/* parse problem: new name "mib" for mgmt.mib(1) ignored */
/* parse problem: no parent for 0.nullSpecific(0) */
-struct obj
+static struct obj
_proteon_obj = {
"proteon", 1, 0,
NULL, NULL
diff --git a/missing/addrinfo.h b/missing/addrinfo.h
deleted file mode 100644
index bf4bbf6ed6d0..000000000000
--- a/missing/addrinfo.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef HAVE_ADDRINFO
-
-/*
- * Error return codes from getaddrinfo()
- */
-#define EAI_ADDRFAMILY 1 /* address family for hostname not supported */
-#define EAI_AGAIN 2 /* temporary failure in name resolution */
-#define EAI_BADFLAGS 3 /* invalid value for ai_flags */
-#define EAI_FAIL 4 /* non-recoverable failure in name resolution */
-#define EAI_FAMILY 5 /* ai_family not supported */
-#define EAI_MEMORY 6 /* memory allocation failure */
-#define EAI_NODATA 7 /* no address associated with hostname */
-#define EAI_NONAME 8 /* hostname nor servname provided, or not known */
-#define EAI_SERVICE 9 /* servname not supported for ai_socktype */
-#define EAI_SOCKTYPE 10 /* ai_socktype not supported */
-#define EAI_SYSTEM 11 /* system error returned in errno */
-#define EAI_BADHINTS 12
-#define EAI_PROTOCOL 13
-#define EAI_MAX 14
-
-/* internal error */
-#define NETDB_INTERNAL -1 /* see errno */
-
-/*
- * Flag values for getaddrinfo()
- */
-#define AI_PASSIVE 0x00000001 /* get address to use bind() */
-#define AI_CANONNAME 0x00000002 /* fill ai_canonname */
-#define AI_NUMERICHOST 0x00000004 /* prevent name resolution */
-/* valid flags for addrinfo */
-#define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST)
-
-#define AI_ALL 0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */
-#define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */
-#define AI_ADDRCONFIG 0x00000400 /* only if any address is assigned */
-#define AI_V4MAPPED 0x00000800 /* accept IPv4-mapped IPv6 address */
-/* special recommended flags for getipnodebyname */
-#define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG)
-
-struct addrinfo {
- int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
- int ai_family; /* PF_xxx */
- int ai_socktype; /* SOCK_xxx */
- int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
- size_t ai_addrlen; /* length of ai_addr */
- char *ai_canonname; /* canonical name for hostname */
- struct sockaddr *ai_addr; /* binary address */
- struct addrinfo *ai_next; /* next structure in linked list */
-};
-
-extern void freeaddrinfo (struct addrinfo *);
-extern void freehostent (struct hostent *);
-extern int getnameinfo (const struct sockaddr *, size_t, char *,
- size_t, char *, size_t, int);
-extern struct hostent *getipnodebyaddr (const void *, size_t, int, int *);
-extern struct hostent *getipnodebyname (const char *, int, int, int *);
-extern int inet_pton (int, const char *, void *);
-extern const char *inet_ntop (int, const void *, char *, size_t);
-#endif /* HAVE_ADDRINFO */
-
-/*
- * Constants for getnameinfo()
- */
-#ifndef NI_MAXHOST
-#define NI_MAXHOST 1025
-#endif
-#ifndef NI_MAXSERV
-#define NI_MAXSERV 32
-#endif
-
-/*
- * Flag values for getnameinfo()
- */
-#ifndef NI_NOFQDN
-#define NI_NOFQDN 0x00000001
-#endif
-#ifndef NI_NUMERICHOST
-#define NI_NUMERICHOST 0x00000002
-#endif
-#ifndef NI_NAMEREQD
-#define NI_NAMEREQD 0x00000004
-#endif
-#ifndef NI_NUMERICSERV
-#define NI_NUMERICSERV 0x00000008
-#endif
-#ifndef NI_DGRAM
-#define NI_DGRAM 0x00000010
-#endif
diff --git a/missing/datalinks.c b/missing/datalinks.c
index e7d526bcedb1..4a7d6fe961d7 100644
--- a/missing/datalinks.c
+++ b/missing/datalinks.c
@@ -35,7 +35,7 @@
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <pcap.h>
#include <stdlib.h>
diff --git a/missing/dlnames.c b/missing/dlnames.c
index a10cd398d893..16bfcf7940c2 100644
--- a/missing/dlnames.c
+++ b/missing/dlnames.c
@@ -35,12 +35,13 @@
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <pcap.h>
#include <string.h>
#include "pcap-missing.h"
+#include "ascii_strcasecmp.h"
struct dlt_choice {
const char *name;
@@ -137,7 +138,7 @@ pcap_datalink_name_to_val(const char *name)
int i;
for (i = 0; dlt_choices[i].name != NULL; i++) {
- if (strcasecmp(dlt_choices[i].name + sizeof("DLT_") - 1,
+ if (ascii_strcasecmp(dlt_choices[i].name + sizeof("DLT_") - 1,
name) == 0)
return (dlt_choices[i].dlt);
}
diff --git a/missing/getnameinfo.c b/missing/getnameinfo.c
deleted file mode 100644
index 63aba7310487..000000000000
--- a/missing/getnameinfo.c
+++ /dev/null
@@ -1,276 +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.
- */
-
-/*
- * Issues to be discussed:
- * - Thread safe-ness must be checked
- * - Return values. There seems to be no standard for return value (RFC2553)
- * but INRIA implementation returns EAI_xxx defined for getaddrinfo().
- * - RFC2553 says that we should raise error on short buffer. X/Open says
- * we need to truncate the result. We obey RFC2553 (and X/Open should be
- * modified).
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <net/if.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <arpa/nameser.h>
-#include <netdb.h>
-#include <resolv.h>
-#include <string.h>
-#include <stddef.h>
-#include <errno.h>
-
-#ifdef NEED_ADDRINFO_H
-#include "addrinfo.h"
-#endif
-
-#define SUCCESS 0
-#define ANY 0
-#define YES 1
-#define NO 0
-
-static struct afd {
- int a_af;
- int a_addrlen;
- int a_socklen;
- int a_off;
-} afdl [] = {
-#ifdef INET6
- {PF_INET6, sizeof(struct in6_addr), sizeof(struct sockaddr_in6),
- offsetof(struct sockaddr_in6, sin6_addr)},
-#endif
- {PF_INET, sizeof(struct in_addr), sizeof(struct sockaddr_in),
- offsetof(struct sockaddr_in, sin_addr)},
- {0, 0, 0},
-};
-
-struct sockinet {
- u_char si_len;
- u_char si_family;
- u_short si_port;
-};
-
-#define ENI_NOSOCKET 0
-#define ENI_NOSERVNAME 1
-#define ENI_NOHOSTNAME 2
-#define ENI_MEMORY 3
-#define ENI_SYSTEM 4
-#define ENI_FAMILY 5
-#define ENI_SALEN 6
-
-int
-getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
- const struct sockaddr *sa;
- size_t salen;
- char *host;
- size_t hostlen;
- char *serv;
- size_t servlen;
- int flags;
-{
- struct afd *afd;
- struct servent *sp;
- struct hostent *hp;
- u_short port;
- int family, i;
- char *addr, *p;
- uint32_t v4a;
- int h_error;
- char numserv[512];
- char numaddr[512];
-
- if (sa == NULL)
- return ENI_NOSOCKET;
-
-#ifdef HAVE_SA_LEN /*XXX*/
- if (sa->sa_len != salen)
- return ENI_SALEN;
-#endif
-
- family = sa->sa_family;
- for (i = 0; afdl[i].a_af; i++)
- if (afdl[i].a_af == family) {
- afd = &afdl[i];
- goto found;
- }
- return ENI_FAMILY;
-
- found:
- if (salen != afd->a_socklen)
- return ENI_SALEN;
-
- port = ((struct sockinet *)sa)->si_port; /* network byte order */
- addr = (char *)sa + afd->a_off;
-
- if (serv == NULL || servlen == 0) {
- /*
- * do nothing in this case.
- * in case you are wondering if "&&" is more correct than
- * "||" here: RFC2553 says that serv == NULL OR servlen == 0
- * means that the caller does not want the result.
- */
- } else {
- if (flags & NI_NUMERICSERV)
- sp = NULL;
- else {
- sp = getservbyport(port,
- (flags & NI_DGRAM) ? "udp" : "tcp");
- }
- if (sp) {
- if (strlen(sp->s_name) + 1 > servlen)
- return ENI_MEMORY;
- strcpy(serv, sp->s_name);
- } else {
- snprintf(numserv, sizeof(numserv), "%d", ntohs(port));
- if (strlen(numserv) + 1 > servlen)
- return ENI_MEMORY;
- strcpy(serv, numserv);
- }
- }
-
- switch (sa->sa_family) {
- case AF_INET:
- v4a = (uint32_t)
- ntohl(((struct sockaddr_in *)sa)->sin_addr.s_addr);
- if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a))
- flags |= NI_NUMERICHOST;
- v4a >>= IN_CLASSA_NSHIFT;
- if (v4a == 0)
- flags |= NI_NUMERICHOST;
- break;
-#ifdef INET6
- case AF_INET6:
- {
- struct sockaddr_in6 *sin6;
- sin6 = (struct sockaddr_in6 *)sa;
- switch (sin6->sin6_addr.s6_addr[0]) {
- case 0x00:
- if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr))
- ;
- else if (IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr))
- ;
- else
- flags |= NI_NUMERICHOST;
- break;
- default:
- if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
- flags |= NI_NUMERICHOST;
- }
- else if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))
- flags |= NI_NUMERICHOST;
- break;
- }
- }
- break;
-#endif
- }
- if (host == NULL || hostlen == 0) {
- /*
- * do nothing in this case.
- * in case you are wondering if "&&" is more correct than
- * "||" here: RFC2553 says that host == NULL OR hostlen == 0
- * means that the caller does not want the result.
- */
- } else if (flags & NI_NUMERICHOST) {
- /* NUMERICHOST and NAMEREQD conflicts with each other */
- if (flags & NI_NAMEREQD)
- return ENI_NOHOSTNAME;
- if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr))
- == NULL)
- return ENI_SYSTEM;
- if (strlen(numaddr) + 1 > hostlen)
- return ENI_MEMORY;
- strcpy(host, numaddr);
-#if defined(INET6) && defined(NI_WITHSCOPEID)
- if (afd->a_af == AF_INET6 &&
- (IN6_IS_ADDR_LINKLOCAL((struct in6_addr *)addr) ||
- IN6_IS_ADDR_MULTICAST((struct in6_addr *)addr)) &&
- ((struct sockaddr_in6 *)sa)->sin6_scope_id) {
-#ifndef ALWAYS_WITHSCOPE
- if (flags & NI_WITHSCOPEID)
-#endif /* !ALWAYS_WITHSCOPE */
- {
- char *ep = strchr(host, '\0');
- unsigned int ifindex =
- ((struct sockaddr_in6 *)sa)->sin6_scope_id;
-
- *ep = SCOPE_DELIMITER;
- if ((if_indextoname(ifindex, ep + 1)) == NULL)
- /* XXX what should we do? */
- strncpy(ep + 1, "???", 3);
- }
- }
-#endif /* INET6 */
- } else {
-#ifdef USE_GETIPNODEBY
- hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error);
-#else
- hp = gethostbyaddr(addr, afd->a_addrlen, afd->a_af);
-#ifdef HAVE_H_ERRNO
- h_error = h_errno;
-#else
- h_error = EINVAL;
-#endif
-#endif
-
- if (hp) {
- if (flags & NI_NOFQDN) {
- p = strchr(hp->h_name, '.');
- if (p) *p = '\0';
- }
- if (strlen(hp->h_name) + 1 > hostlen) {
-#ifdef USE_GETIPNODEBY
- freehostent(hp);
-#endif
- return ENI_MEMORY;
- }
- strcpy(host, hp->h_name);
-#ifdef USE_GETIPNODEBY
- freehostent(hp);
-#endif
- } else {
- if (flags & NI_NAMEREQD)
- return ENI_NOHOSTNAME;
- if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr))
- == NULL)
- return ENI_NOHOSTNAME;
- if (strlen(numaddr) + 1 > hostlen)
- return ENI_MEMORY;
- strcpy(host, numaddr);
- }
- }
- return SUCCESS;
-}
diff --git a/missing/inet_aton.c b/missing/inet_aton.c
deleted file mode 100644
index e85ad5f814dc..000000000000
--- a/missing/inet_aton.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 1995, 1996, 1997 Kungliga Tekniska Hgskolan
- * (Royal Institute of Technology, Stockholm, Sweden).
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the Kungliga Tekniska
- * Hgskolan and its contributors.
- *
- * 4. Neither the name of the Institute nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <tcpdump-stdinc.h>
-
-/* Minimal implementation of inet_aton.
- * Cannot distinguish between failure and a local broadcast address. */
-
-#ifndef INADDR_NONE
-#define INADDR_NONE 0xffffffff
-#endif
-
-int
-inet_aton(const char *cp, struct in_addr *addr)
-{
- addr->s_addr = inet_addr(cp);
- return (addr->s_addr == INADDR_NONE) ? 0 : 1;
-}
diff --git a/missing/snprintf.c b/missing/snprintf.c
index 21d235d217f2..921b74c1df3f 100644
--- a/missing/snprintf.c
+++ b/missing/snprintf.c
@@ -42,7 +42,7 @@
#include <ctype.h>
#include <sys/types.h>
-#include <interface.h>
+#include "netdissect.h"
enum format_flags {
minus_flag = 1,
diff --git a/missing/strdup.c b/missing/strdup.c
index 9fca7529e34d..9cbf35ae2470 100644
--- a/missing/strdup.c
+++ b/missing/strdup.c
@@ -35,7 +35,7 @@
#include <stdlib.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
char *
strdup(str)
diff --git a/missing/strlcat.c b/missing/strlcat.c
index 34f1af2d9628..405493545b51 100644
--- a/missing/strlcat.c
+++ b/missing/strlcat.c
@@ -28,15 +28,15 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifdef HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
/*
* Appends src to string dst of size siz (unlike strncat, siz is the
diff --git a/missing/strlcpy.c b/missing/strlcpy.c
index b0671ebd311b..24dcca67667f 100644
--- a/missing/strlcpy.c
+++ b/missing/strlcpy.c
@@ -28,15 +28,15 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifdef HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
/*
* Copy src to string dst of size siz. At most siz-1 characters
diff --git a/missing/strsep.c b/missing/strsep.c
index a1e6b3017b6f..2c17275f3391 100644
--- a/missing/strsep.c
+++ b/missing/strsep.c
@@ -31,15 +31,15 @@
* SUCH DAMAGE.
*/
-#ifdef HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
/*
* Get next token from string *stringp, where tokens are possibly-empty
diff --git a/nameser.h b/nameser.h
index 11e71ef87d6a..e075f09228aa 100644
--- a/nameser.h
+++ b/nameser.h
@@ -71,20 +71,6 @@
#define RRFIXEDSZ 10
/*
- * Internet nameserver port number
- */
-#define NAMESERVER_PORT 53
-
-/*
- * Port for multicast DNS; see
- *
- * http://files.multicastdns.org/draft-cheshire-dnsext-multicastdns.txt
- *
- * for the current mDNS spec.
- */
-#define MULTICASTDNS_PORT 5353
-
-/*
* Currently defined opcodes
*/
#define QUERY 0x0 /* standard query */
diff --git a/tcpdump-stdinc.h b/netdissect-stdinc.h
index 32f8fc920b01..c7070f0a04c2 100644
--- a/tcpdump-stdinc.h
+++ b/netdissect-stdinc.h
@@ -32,28 +32,30 @@
/*
* Include the appropriate OS header files on Windows and various flavors
* of UNIX, include various non-OS header files on Windows, and define
- * various items as needed, to isolate most of tcpdump's platform
+ * various items as needed, to isolate most of netdissect's platform
* differences to this one file.
*/
-#ifndef tcpdump_stdinc_h
-#define tcpdump_stdinc_h
+#ifndef netdissect_stdinc_h
+#define netdissect_stdinc_h
#include <errno.h>
-#ifdef WIN32
+#ifdef _WIN32
+
+/*
+ * Includes and definitions for Windows.
+ */
#include <stdint.h>
#include <stdio.h>
#include <winsock2.h>
#include <ws2tcpip.h>
-#include "bittypes.h" /* in wpcap's Win32/include */
#include <ctype.h>
#include <time.h>
#include <io.h>
#include <fcntl.h>
#include <sys/types.h>
-#include <net/netdb.h> /* in wpcap's Win32/include */
#ifndef uint8_t
#define uint8_t unsigned char
@@ -133,6 +135,17 @@
#endif /* _MSC_EXTENSIONS */
+/*
+ * Suppress definition of intN_t in bittypes.h, as included by <pcap/pcap.h>
+ * on Windows.
+ * (Yes, HAVE_U_INTn_T, as the definition guards are UN*X-oriented, and
+ * we check for u_intN_t in the UN*X configure script.)
+ */
+#define HAVE_U_INT8_T
+#define HAVE_U_INT16_T
+#define HAVE_U_INT32_T
+#define HAVE_U_INT64_T
+
#ifdef _MSC_VER
#define stat _stat
#define open _open
@@ -142,13 +155,6 @@
#define O_RDONLY _O_RDONLY
#endif /* _MSC_VER */
-/* Protos for missing/x.c functions (ideally <missing/addrinfo.h>
- * should be used, but it clashes with <ws2tcpip.h>).
- */
-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.
*/
@@ -156,6 +162,10 @@ extern int inet_aton (const char *cp, struct in_addr *addr);
#define inline __inline
#endif
+#ifdef AF_INET6
+#define HAVE_OS_IPV6_SUPPORT
+#endif
+
#ifndef INET6_ADDRSTRLEN
#define INET6_ADDRSTRLEN 46
#endif
@@ -171,12 +181,15 @@ typedef char* caddr_t;
#endif /* caddr_t */
#define MAXHOSTNAMELEN 64
-#define NI_MAXHOST 1025
#define snprintf _snprintf
#define vsnprintf _vsnprintf
#define RETSIGTYPE void
-#else /* WIN32 */
+#else /* _WIN32 */
+
+/*
+ * Includes and definitions for various flavors of UN*X.
+ */
#include <ctype.h>
#include <unistd.h>
@@ -198,7 +211,7 @@ typedef char* caddr_t;
#include <arpa/inet.h>
-#endif /* WIN32 */
+#endif /* _WIN32 */
#ifndef HAVE___ATTRIBUTE__
#define __attribute__(x)
@@ -241,7 +254,10 @@ typedef char* caddr_t;
#define UNALIGNED __attribute__((packed))
#endif
-#if defined(WIN32) || defined(MSDOS)
+/*
+ * fopen() read and write modes for text files and binary files.
+ */
+#if defined(_WIN32) || defined(MSDOS)
#define FOPEN_READ_TXT "rt"
#define FOPEN_READ_BIN "rb"
#define FOPEN_WRITE_TXT "wt"
@@ -253,6 +269,16 @@ typedef char* caddr_t;
#define FOPEN_WRITE_BIN FOPEN_WRITE_TXT
#endif
+/*
+ * Inline x86 assembler-language versions of ntoh[ls]() and hton[ls](),
+ * defined if the OS doesn't provide them. These assume no more than
+ * an 80386, so, for example, it avoids the bswap instruction added in
+ * the 80486.
+ *
+ * (We don't use them on OS X; Apple provides their own, which *doesn't*
+ * avoid the bswap instruction, as OS X only supports machines that
+ * have it.)
+ */
#if defined(__GNUC__) && defined(__i386__) && !defined(__APPLE__) && !defined(__ntohl)
#undef ntohl
#undef ntohs
@@ -284,6 +310,32 @@ typedef char* caddr_t;
}
#endif
+/*
+ * If the OS doesn't define AF_INET6 and struct in6_addr:
+ *
+ * define AF_INET6, so we can use it internally as a "this is an
+ * IPv6 address" indication;
+ *
+ * define struct in6_addr so that we can use it for IPv6 addresses.
+ */
+#ifndef HAVE_OS_IPV6_SUPPORT
+#ifndef AF_INET6
+#define AF_INET6 24
+
+struct in6_addr {
+ union {
+ __uint8_t __u6_addr8[16];
+ __uint16_t __u6_addr16[8];
+ __uint32_t __u6_addr32[4];
+ } __u6_addr; /* 128-bit IP6 address */
+};
+#endif
+#endif
+
+#ifndef NI_MAXHOST
+#define NI_MAXHOST 1025
+#endif
+
#ifndef INET_ADDRSTRLEN
#define INET_ADDRSTRLEN 16
#endif
@@ -349,4 +401,4 @@ typedef char* caddr_t;
#define max(a,b) ((b)>(a)?(b):(a))
#endif
-#endif /* tcpdump_stdinc_h */
+#endif /* netdissect_stdinc_h */
diff --git a/netdissect.c b/netdissect.c
new file mode 100644
index 000000000000..0215c83b7f23
--- /dev/null
+++ b/netdissect.c
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 1988-1997
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Copyright (c) 1998-2012 Michael Richardson <mcr@tcpdump.org>
+ * The TCPDUMP project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <netdissect-stdinc.h>
+#include "netdissect.h"
+#include <string.h>
+#include <stdio.h>
+
+#ifdef USE_LIBSMI
+#include <smi.h>
+#endif
+
+/*
+ * Initialize anything that must be initialized before dissecting
+ * packets.
+ *
+ * This should be called at the beginning of the program; it does
+ * not need to be called, and should not be called, for every
+ * netdissect_options structure.
+ */
+int
+nd_init(char *errbuf, size_t errbuf_size)
+{
+#ifdef _WIN32
+ WORD wVersionRequested;
+ WSADATA wsaData;
+ int err;
+
+ /*
+ * Request Winsock 2.2; we expect Winsock 2.
+ */
+ wVersionRequested = MAKEWORD(2, 2);
+ err = WSAStartup(wVersionRequested, &wsaData);
+ if (err != 0) {
+ strlcpy(errbuf, "Attempting to initialize Winsock failed",
+ errbuf_size);
+ return (-1);
+ }
+#endif /* _WIN32 */
+
+#ifdef USE_LIBSMI
+ /*
+ * XXX - should we just fail if this fails? Some of the
+ * libsmi calls may fail.
+ */
+ smiInit("tcpdump");
+#endif
+
+ /*
+ * Clears the error buffer, and uses it so we don't get
+ * "unused argument" warnings at compile time.
+ */
+ strlcpy(errbuf, "", errbuf_size);
+ return (0);
+}
+
+/*
+ * Clean up anything that ndo_init() did.
+ */
+void
+nd_cleanup(void)
+{
+#ifdef USE_LIBSMI
+ /*
+ * This appears, in libsmi 0.4.8, to do nothing if smiInit()
+ * wasn't done or failed, so we call it unconditionally.
+ */
+ smiExit();
+#endif
+
+#ifdef _WIN32
+ /*
+ * Undo the WSAStartup() call above.
+ */
+ WSACleanup();
+#endif
+}
+
+int
+nd_have_smi_support(void)
+{
+#ifdef USE_LIBSMI
+ return (1);
+#else
+ return (0);
+#endif
+}
+
+/*
+ * Indicates whether an SMI module has been loaded, so that we can use
+ * libsmi to translate OIDs.
+ */
+int nd_smi_module_loaded;
+
+int
+nd_load_smi_module(const char *module, char *errbuf, size_t errbuf_size)
+{
+#ifdef USE_LIBSMI
+ if (smiLoadModule(module) == 0) {
+ snprintf(errbuf, errbuf_size, "could not load MIB module %s",
+ module);
+ return (-1);
+ }
+ nd_smi_module_loaded = 1;
+ return (0);
+#else
+ snprintf(errbuf, errbuf_size, "MIB module %s not loaded: no libsmi support",
+ module);
+ return (-1);
+#endif
+}
+
+const char *
+nd_smi_version_string(void)
+{
+#ifdef USE_LIBSMI
+ return (smi_version_string);
+#else
+ return (NULL);
+#endif
+}
diff --git a/netdissect.h b/netdissect.h
index e54c01acd98a..ac916c2a2e11 100644
--- a/netdissect.h
+++ b/netdissect.h
@@ -34,11 +34,52 @@
#define __attribute__(x)
#endif
+/*
+ * Data types corresponding to multi-byte integral values within data
+ * structures. These are defined as arrays of octets, so that they're
+ * not aligned on their "natural" boundaries, and so that you *must*
+ * use the EXTRACT_ macros to extract them (which you should be doing
+ * *anyway*, so as not to assume a particular byte order or alignment
+ * in your code).
+ */
+typedef unsigned char nd_uint16_t[2];
+typedef unsigned char nd_uint24_t[3];
+typedef unsigned char nd_uint32_t[4];
+typedef unsigned char nd_uint40_t[5];
+typedef unsigned char nd_uint48_t[6];
+typedef unsigned char nd_uint56_t[7];
+typedef unsigned char nd_uint64_t[8];
+
+/*
+ * Use this for IPv4 addresses. It's defined as an array of octets, so
+ * that it's not aligned on its "natural" boundary, and it's defined as
+ * a structure in the hopes that this makes it harder to naively use
+ * EXTRACT_32BITS() to extract the value - in many cases you just want
+ * to use UNALIGNED_MEMCPY() to copy its value, so that it remains in
+ * network byte order.
+ */
+typedef struct {
+ unsigned char bytes[4];
+} nd_ipv4;
+
+/*
+ * Data types corresponding to single-byte integral values, for
+ * completeness.
+ */
+typedef unsigned char nd_uint8_t;
+typedef signed char nd_int8_t;
+
/* snprintf et al */
#include <stdarg.h>
+#include <pcap.h>
#include "ip.h" /* struct ip for nextproto4_cksum() */
+#include "ip6.h" /* struct ip6 for nextproto6_cksum() */
+
+extern int32_t thiszone; /* seconds offset from gmt to local time */
+/* invalid string to print '(invalid)' for malformed or corrupted packets */
+extern const char istr[];
#if !defined(HAVE_SNPRINTF)
int snprintf (char *str, size_t sz, const char *format, ...)
@@ -54,7 +95,7 @@ int vsnprintf (char *str, size_t sz, const char *format, va_list ap)
__attribute__((format (printf, 3, 0)))
#endif /* __ATTRIBUTE___FORMAT_OK */
;
-#endif /* !defined(HAVE_SNPRINTF) */
+#endif /* !defined(HAVE_VSNPRINTF) */
#ifndef HAVE_STRLCAT
extern size_t strlcat (char *, const char *, size_t);
@@ -76,7 +117,6 @@ struct tok {
const char *s; /* string */
};
-#define TOKBUFSIZE 128
extern const char *tok2strbuf(const struct tok *, const char *, u_int,
char *buf, size_t bufsize);
@@ -85,11 +125,27 @@ extern const char *tok2str(const struct tok *, const char *, u_int);
extern char *bittok2str(const struct tok *, const char *, u_int);
extern char *bittok2str_nosep(const struct tok *, const char *, u_int);
+/* Initialize netdissect. */
+extern int nd_init(char *, size_t);
+/* Clean up netdissect. */
+extern void nd_cleanup(void);
+
+/* Do we have libsmi support? */
+extern int nd_have_smi_support(void);
+/* Load an SMI module. */
+extern int nd_load_smi_module(const char *, char *, size_t);
+/* Flag indicating whether an SMI module has been loaded. */
+extern int nd_smi_module_loaded;
+/* Version number of the SMI library, or NULL if we don't have libsmi support. */
+extern const char *nd_smi_version_string(void);
typedef struct netdissect_options netdissect_options;
+#define IF_PRINTER_ARGS (netdissect_options *, const struct pcap_pkthdr *, const u_char *)
+
+typedef u_int (*if_printer) IF_PRINTER_ARGS;
+
struct netdissect_options {
- int ndo_aflag; /* translate network and broadcast addresses */
int ndo_bflag; /* print 4 byte ASes in ASDOT notation */
int ndo_eflag; /* print ethernet header */
int ndo_fflag; /* don't translate "foreign" IP address */
@@ -97,69 +153,41 @@ struct netdissect_options {
int ndo_nflag; /* leave addresses as numbers */
int ndo_Nflag; /* remove domains from printed host names */
int ndo_qflag; /* quick (shorter) output */
- int ndo_Rflag; /* print sequence # field in AH/ESP*/
- int ndo_sflag; /* use the libsmi to translate OIDs */
int ndo_Sflag; /* print raw TCP sequence numbers */
int ndo_tflag; /* print packet arrival time */
- int ndo_Uflag; /* "unbuffered" output of dump files */
int ndo_uflag; /* Print undecoded NFS handles */
- int ndo_vflag; /* verbose */
+ int ndo_vflag; /* verbosity level */
int ndo_xflag; /* print packet in hex */
int ndo_Xflag; /* print packet in hex/ascii */
int ndo_Aflag; /* print packet only in ascii observing TAB,
* LF, CR and SPACE as graphical chars
*/
- int ndo_Bflag; /* buffer size */
- int ndo_Iflag; /* rfmon (monitor) mode */
- int ndo_Oflag; /* run filter code optimizer */
- int ndo_dlt; /* if != -1, ask libpcap for the DLT it names*/
- int ndo_jflag; /* packet time stamp source */
- int ndo_pflag; /* don't go promiscuous */
- int ndo_immediate; /* use immediate mode */
-
- int ndo_Cflag; /* rotate dump files after this many bytes */
- int ndo_Cflag_count; /* Keep track of which file number we're writing */
- int ndo_Gflag; /* rotate dump files after this many seconds */
- int ndo_Gflag_count; /* number of files created with Gflag rotation */
- time_t ndo_Gflag_time; /* The last time_t the dump file was rotated. */
- int ndo_Wflag; /* recycle output files after this number of files */
- int ndo_WflagChars;
int ndo_Hflag; /* dissect 802.11s draft mesh standard */
int ndo_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;
+ int ndo_tstamp_precision; /* requested time stamp precision */
+ const char *program_name; /* Name of the program using the library */
char *ndo_espsecret;
struct sa_list *ndo_sa_list_head; /* used by print-esp.c */
struct sa_list *ndo_sa_default;
- char *ndo_sigsecret; /* Signature verification secret key */
-
- struct esp_algorithm *ndo_espsecret_xform; /* cache of decoded */
- char *ndo_espsecret_key;
+ char *ndo_sigsecret; /* Signature verification secret key */
int ndo_packettype; /* as specified by -T */
- char *ndo_program_name; /*used to generate self-identifying messages */
-
- int32_t ndo_thiszone; /* seconds offset from gmt to local time */
-
int ndo_snaplen;
/*global pointers to beginning and end of current packet (during printing) */
const u_char *ndo_packetp;
const u_char *ndo_snapend;
- /* bookkeeping for ^T output */
- int ndo_infodelay;
+ /* pointer to the if_printer function */
+ if_printer ndo_if_printer;
/* pointer to void function to output stuff */
void (*ndo_default_print)(netdissect_options *,
- register const u_char *bp, register u_int length);
-
- /* pointer to function to print ^T output */
- void (*ndo_info)(netdissect_options *, int verbose);
+ register const u_char *bp, register u_int length);
/* pointer to function to do regular output */
int (*ndo_printf)(netdissect_options *,
@@ -203,6 +231,7 @@ struct netdissect_options {
#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 PT_RESP 17 /* RESP */
#ifndef min
#define min(a,b) ((a)>(b)?(b):(a))
@@ -211,6 +240,9 @@ struct netdissect_options {
#define max(a,b) ((b)>(a)?(b):(a))
#endif
+/* For source or destination ports tests (UDP, TCP, ...) */
+#define IS_SRC_OR_DST_PORT(p) (sport == (p) || dport == (p))
+
/*
* Maximum snapshot length. This should be enough to capture the full
* packet on most network interfaces.
@@ -271,6 +303,11 @@ struct netdissect_options {
* http://www.kb.cert.org/vuls/id/162289
*/
+/*
+ * Test in two parts to avoid these warnings:
+ * comparison of unsigned expression >= 0 is always true [-Wtype-limits],
+ * comparison is always true due to limited range of data type [-Wtype-limits].
+ */
#define IS_NOT_NEGATIVE(x) (((x) > 0) || ((x) == 0))
#define ND_TTEST2(var, l) \
@@ -291,9 +328,12 @@ struct netdissect_options {
#define ND_DEFAULTPRINT(ap, length) (*ndo->ndo_default_print)(ndo, ap, length)
extern void ts_print(netdissect_options *, const struct timeval *);
-extern void relts_print(netdissect_options *, int);
+extern void signed_relts_print(netdissect_options *, int32_t);
+extern void unsigned_relts_print(netdissect_options *, uint32_t);
+extern void fn_print_char(netdissect_options *, u_char);
extern int fn_print(netdissect_options *, const u_char *, const u_char *);
+extern u_int fn_printztn(netdissect_options *ndo, const u_char *, u_int, 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 *);
@@ -305,11 +345,6 @@ extern int fn_printzp(netdissect_options *, const u_char *, u_int, const u_char
extern void txtproto_print(netdissect_options *, const u_char *, u_int,
const char *, const char **, u_int);
-#if 0
-extern char *read_infile(netdissect_options *, char *);
-extern char *copy_argv(netdissect_options *, char **);
-#endif
-
/*
* Locale-independent macros for testing character properties and
* stripping the 8th bit from characters. Assumed to be handed
@@ -352,284 +387,277 @@ extern int unaligned_memcmp(const void *, const void *, size_t);
#define PLURAL_SUFFIX(n) \
(((n) != 1) ? "s" : "")
-#if 0
-extern const char *dnname_string(netdissect_options *, u_short);
-extern const char *dnnum_string(netdissect_options *, u_short);
-#endif
-
-/* The printer routines. */
-
-#include <pcap.h>
-
-extern char *q922_string(netdissect_options *ndo, const u_char *, u_int);
-
-typedef u_int (*if_ndo_printer)(struct netdissect_options *ndo,
- const struct pcap_pkthdr *, const u_char *);
-typedef u_int (*if_printer)(const struct pcap_pkthdr *, const u_char *);
+extern 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 if_ndo_printer lookup_ndo_printer(int);
extern if_printer lookup_printer(int);
-extern void eap_print(netdissect_options *,const u_char *, u_int);
-extern int esp_print(netdissect_options *,
- 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 *);
-extern void icmp6_print(netdissect_options *ndo, const u_char *,
- u_int, const u_char *, int);
-extern void isakmp_print(netdissect_options *,const u_char *,
- u_int, const u_char *);
-extern void isakmp_rfc3948_print(netdissect_options *,const u_char *,
- u_int, const u_char *);
-extern void ip_print(netdissect_options *,const u_char *, u_int);
-extern void ip_print_inner(netdissect_options *ndo,
- const u_char *bp, u_int length, u_int nh,
- const u_char *bp2);
-extern void rrcp_print(netdissect_options *,const u_char *, u_int);
-extern void loopback_print(netdissect_options *, const u_char *, const u_int);
-extern void carp_print(netdissect_options *, const u_char *, u_int, int);
+/* The DLT printer routines */
+
+extern u_int ap1394_if_print IF_PRINTER_ARGS;
+extern u_int arcnet_if_print IF_PRINTER_ARGS;
+extern u_int arcnet_linux_if_print IF_PRINTER_ARGS;
+extern u_int atm_if_print IF_PRINTER_ARGS;
+extern u_int bt_if_print IF_PRINTER_ARGS;
+extern u_int chdlc_if_print IF_PRINTER_ARGS;
+extern u_int cip_if_print IF_PRINTER_ARGS;
+extern u_int enc_if_print IF_PRINTER_ARGS;
+extern u_int ether_if_print IF_PRINTER_ARGS;
+extern u_int fddi_if_print IF_PRINTER_ARGS;
+extern u_int fr_if_print IF_PRINTER_ARGS;
+extern u_int ieee802_11_if_print IF_PRINTER_ARGS;
+extern u_int ieee802_11_radio_avs_if_print IF_PRINTER_ARGS;
+extern u_int ieee802_11_radio_if_print IF_PRINTER_ARGS;
+extern u_int ieee802_15_4_if_print IF_PRINTER_ARGS;
+extern u_int ipfc_if_print IF_PRINTER_ARGS;
+extern u_int ipnet_if_print IF_PRINTER_ARGS;
+extern u_int juniper_atm1_print IF_PRINTER_ARGS;
+extern u_int juniper_atm2_print IF_PRINTER_ARGS;
+extern u_int juniper_chdlc_print IF_PRINTER_ARGS;
+extern u_int juniper_es_print IF_PRINTER_ARGS;
+extern u_int juniper_ether_print IF_PRINTER_ARGS;
+extern u_int juniper_frelay_print IF_PRINTER_ARGS;
+extern u_int juniper_ggsn_print IF_PRINTER_ARGS;
+extern u_int juniper_mfr_print IF_PRINTER_ARGS;
+extern u_int juniper_mlfr_print IF_PRINTER_ARGS;
+extern u_int juniper_mlppp_print IF_PRINTER_ARGS;
+extern u_int juniper_monitor_print IF_PRINTER_ARGS;
+extern u_int juniper_ppp_print IF_PRINTER_ARGS;
+extern u_int juniper_pppoe_atm_print IF_PRINTER_ARGS;
+extern u_int juniper_pppoe_print IF_PRINTER_ARGS;
+extern u_int juniper_services_print IF_PRINTER_ARGS;
+extern u_int lane_if_print IF_PRINTER_ARGS;
+extern u_int ltalk_if_print IF_PRINTER_ARGS;
+extern u_int mfr_if_print IF_PRINTER_ARGS;
+extern u_int netanalyzer_if_print IF_PRINTER_ARGS;
+extern u_int netanalyzer_transparent_if_print IF_PRINTER_ARGS;
+extern u_int nflog_if_print IF_PRINTER_ARGS;
+extern u_int null_if_print IF_PRINTER_ARGS;
+extern u_int pflog_if_print IF_PRINTER_ARGS;
+extern u_int pktap_if_print IF_PRINTER_ARGS;
+extern u_int ppi_if_print IF_PRINTER_ARGS;
+extern u_int ppp_bsdos_if_print IF_PRINTER_ARGS;
+extern u_int ppp_hdlc_if_print IF_PRINTER_ARGS;
+extern u_int ppp_if_print IF_PRINTER_ARGS;
+extern u_int pppoe_if_print IF_PRINTER_ARGS;
+extern u_int prism_if_print IF_PRINTER_ARGS;
+extern u_int raw_if_print IF_PRINTER_ARGS;
+extern u_int sl_bsdos_if_print IF_PRINTER_ARGS;
+extern u_int sl_if_print IF_PRINTER_ARGS;
+extern u_int sll_if_print IF_PRINTER_ARGS;
+extern u_int sunatm_if_print IF_PRINTER_ARGS;
+extern u_int symantec_if_print IF_PRINTER_ARGS;
+extern u_int token_if_print IF_PRINTER_ARGS;
+extern u_int usb_linux_48_byte_print IF_PRINTER_ARGS;
+extern u_int usb_linux_64_byte_print IF_PRINTER_ARGS;
-extern void ether_print(netdissect_options *,
- const u_char *, u_int, u_int,
- void (*)(netdissect_options *, const u_char *),
- const u_char *);
-
-extern u_int ether_if_print(netdissect_options *,
- const struct pcap_pkthdr *,const u_char *);
-extern u_int netanalyzer_if_print(netdissect_options *,
- const struct pcap_pkthdr *,const u_char *);
-extern u_int netanalyzer_transparent_if_print(netdissect_options *,
- const struct pcap_pkthdr *,
- const u_char *);
-
-extern int ethertype_print(netdissect_options *,u_short, const u_char *,
- u_int, u_int);
+/*
+ * Structure passed to some printers to allow them to print
+ * link-layer address information if ndo_eflag isn't set
+ * (because they are for protocols that don't have their
+ * own addresses, so that we'd want to report link-layer
+ * address information).
+ *
+ * This contains a pointer to an address and a pointer to a routine
+ * to which we pass that pointer in order to get a string.
+ */
+struct lladdr_info {
+ const char *(*addr_string)(netdissect_options *, const u_char *);
+ const u_char *addr;
+};
-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);
+/* The printer routines. */
+extern void aarp_print(netdissect_options *, 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 aodv_print(netdissect_options *, const u_char *, u_int, int);
+extern void aoe_print(netdissect_options *, const u_char *, const u_int);
+extern void arp_print(netdissect_options *, const u_char *, u_int, u_int);
+extern void ascii_print(netdissect_options *, const u_char *, u_int);
+extern void atalk_print(netdissect_options *, const u_char *, u_int);
+extern void atm_print(netdissect_options *, u_int, u_int, u_int, const u_char *, u_int, u_int);
+extern void babel_print(netdissect_options *, const u_char *, u_int);
+extern void beep_print(netdissect_options *, const u_char *, u_int);
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 void bgp_print(netdissect_options *, const u_char *, int);
+extern char *bgp_vpn_rd_print (netdissect_options *, const u_char *);
+extern void bootp_print(netdissect_options *, const u_char *, u_int);
+extern void calm_fast_print(netdissect_options *, const u_char *, u_int, const struct lladdr_info *);
+extern void carp_print(netdissect_options *, const u_char *, u_int, int);
+extern void cdp_print(netdissect_options *, const u_char *, u_int, u_int);
+extern void cfm_print(netdissect_options *, const u_char *, u_int);
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 cisco_autorp_print(netdissect_options *, const u_char *, u_int);
extern void cnfp_print(netdissect_options *, const u_char *);
+extern void dccp_print(netdissect_options *, const u_char *, const u_char *, u_int);
+extern void decnet_print(netdissect_options *, const u_char *, u_int, u_int);
+extern void dhcp6_print(netdissect_options *, const u_char *, u_int);
+extern int dstopt_print(netdissect_options *, const u_char *);
+extern void dtp_print(netdissect_options *, const u_char *, u_int);
extern void dvmrp_print(netdissect_options *, const u_char *, u_int);
+extern void eap_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 eigrp_print(netdissect_options *, const u_char *, u_int);
+extern int esp_print(netdissect_options *, const u_char *, const int, const u_char *, int *, int *);
+extern u_int ether_print(netdissect_options *, const u_char *, u_int, u_int, void (*)(netdissect_options *, const u_char *), const u_char *);
+extern int ethertype_print(netdissect_options *, u_short, const u_char *, u_int, u_int, const struct lladdr_info *, const struct lladdr_info *);
+extern u_int fddi_print(netdissect_options *, const u_char *, u_int, u_int);
extern void forces_print(netdissect_options *, const u_char *, u_int);
-extern void lspping_print(netdissect_options *, const u_char *, u_int);
+extern u_int fr_print(netdissect_options *, register const u_char *, u_int);
+extern int frag6_print(netdissect_options *, const u_char *, const u_char *);
+extern void ftp_print(netdissect_options *, const u_char *, u_int);
+extern void geneve_print(netdissect_options *, const u_char *, u_int);
+extern void geonet_print(netdissect_options *, const u_char *, u_int, const struct lladdr_info *);
+extern void gre_print(netdissect_options *, const u_char *, u_int);
+extern int hbhopt_print(netdissect_options *, const u_char *);
+extern void hex_and_ascii_print(netdissect_options *, const char *, const u_char *, u_int);
+extern void hex_and_ascii_print_with_offset(netdissect_options *, const char *, const u_char *, u_int, u_int);
+extern void hex_print(netdissect_options *, const char *ident, const u_char *cp, u_int);
+extern void hex_print_with_offset(netdissect_options *, const char *ident, const u_char *cp, u_int, u_int);
+extern void hncp_print(netdissect_options *, const u_char *, u_int);
+extern void hsrp_print(netdissect_options *, const u_char *, u_int);
+extern void http_print(netdissect_options *, const u_char *, u_int);
+extern void icmp6_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 igmp_print(netdissect_options *, const u_char *, u_int);
+extern void igrp_print(netdissect_options *, const u_char *, u_int);
+extern void ip6_print(netdissect_options *, const u_char *, u_int);
+extern void ipN_print(netdissect_options *, const u_char *, u_int);
+extern void ip_print(netdissect_options *, const u_char *, u_int);
+extern void ip_print_inner(netdissect_options *, const u_char *, u_int, u_int nh, const u_char *);
+extern void ipcomp_print(netdissect_options *, register const u_char *);
+extern void ipx_netbios_print(netdissect_options *, const u_char *, u_int);
+extern void ipx_print(netdissect_options *, const u_char *, u_int);
+extern void isakmp_print(netdissect_options *, const u_char *, u_int, const u_char *);
+extern void isakmp_rfc3948_print(netdissect_options *, const u_char *, u_int, const u_char *);
extern void 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 void l2tp_print(netdissect_options *, const u_char *, u_int);
+extern void lane_print(netdissect_options *, const u_char *, u_int, u_int);
+extern void ldp_print(netdissect_options *, const u_char *, u_int);
+extern void lisp_print(netdissect_options *, const u_char *, u_int);
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 int llc_print(netdissect_options *, const u_char *, u_int, u_int, const struct lladdr_info *, const struct lladdr_info *);
+extern void lldp_print(netdissect_options *, const u_char *, u_int);
+extern void lmp_print(netdissect_options *, const u_char *, u_int);
+extern void loopback_print(netdissect_options *, const u_char *, const u_int);
+extern void lspping_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 lwres_print(netdissect_options *, const u_char *, u_int);
-extern void cfm_print(netdissect_options *, const u_char *, u_int);
+extern void m3ua_print(netdissect_options *, const u_char *, const u_int);
+extern void medsa_print(netdissect_options *, const u_char *, u_int, u_int, const struct lladdr_info *, const struct lladdr_info *);
+extern u_int mfr_print(netdissect_options *, register const u_char *, u_int);
+extern void mobile_print(netdissect_options *, const u_char *, u_int);
+extern int mobility_print(netdissect_options *, const u_char *, const u_char *);
+extern void mpcp_print(netdissect_options *, const u_char *, u_int);
+extern void mpls_print(netdissect_options *, const u_char *, u_int);
+extern int mptcp_print(netdissect_options *, const u_char *, u_int, u_char);
+extern void msdp_print(netdissect_options *, const u_char *, u_int);
+extern void msnlb_print(netdissect_options *, const u_char *);
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 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 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 nsh_print(netdissect_options *ndo, const u_char *bp, u_int len);
+extern void ntp_print(netdissect_options *, const u_char *, u_int);
+extern void oam_print(netdissect_options *, const u_char *, u_int, u_int);
+extern void olsr_print(netdissect_options *, const u_char *, u_int, int);
+extern void openflow_print(netdissect_options *, const u_char *, const u_int);
+extern void ospf6_print(netdissect_options *, const u_char *, u_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 int ospf_print_te_lsa(netdissect_options *, const uint8_t *, u_int);
+extern void otv_print(netdissect_options *, const u_char *, u_int);
+extern void pgm_print(netdissect_options *, const u_char *, u_int, const u_char *);
+extern void pim_print(netdissect_options *, const u_char *, u_int, const u_char *);
+extern void pimv1_print(netdissect_options *, const u_char *, 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 u_int pppoe_print(netdissect_options *, const u_char *, u_int);
+extern void pptp_print(netdissect_options *, const u_char *);
+extern int print_unknown_data(netdissect_options *, const u_char *, const char *, int);
+extern char *q922_string(netdissect_options *, const u_char *, u_int);
+extern void q933_print(netdissect_options *, const u_char *, u_int);
+extern void radius_print(netdissect_options *, const u_char *, u_int);
+extern void resp_print(netdissect_options *, const u_char *, u_int);
+extern void rip_print(netdissect_options *, const u_char *, u_int);
+extern void ripng_print(netdissect_options *, const u_char *, unsigned int);
+extern void rpki_rtr_print(netdissect_options *, const u_char *, u_int);
+extern void rrcp_print(netdissect_options *, const u_char *, u_int, const struct lladdr_info *, const struct lladdr_info *);
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);
-extern void ftp_print(netdissect_options *, const u_char *, u_int);
-extern void http_print(netdissect_options *, const u_char *, u_int);
+extern int rt6_print(netdissect_options *, const u_char *, const u_char *);
extern void rtsp_print(netdissect_options *, const u_char *, u_int);
+extern void rx_print(netdissect_options *, register const u_char *, int, int, int, const u_char *);
+extern void sctp_print(netdissect_options *, const u_char *, const u_char *, u_int);
+extern void sflow_print(netdissect_options *, const u_char *, u_int);
+extern void sip_print(netdissect_options *, const u_char *, u_int);
+extern void slow_print(netdissect_options *, const u_char *, u_int);
+extern void smb_print_data(netdissect_options *, const unsigned char *, int);
+extern void smb_tcp_print(netdissect_options *, const u_char *, int);
extern void smtp_print(netdissect_options *, const u_char *, u_int);
-extern void geneve_print(netdissect_options *, const u_char *, u_int);
-
-/* stuff that has not yet been rototiled */
-
-#if 0
-extern void ascii_print(netdissect_options *,u_int);
-extern void default_print(netdissect_options *,const u_char *, u_int);
-extern char *smb_errstr(netdissect_options *,int, int);
-extern const char *nt_errstr(netdissect_options *, uint32_t);
-#endif
+extern int snap_print(netdissect_options *, const u_char *, u_int, u_int, const struct lladdr_info *, const struct lladdr_info *, u_int);
+extern void snmp_print(netdissect_options *, const u_char *, u_int);
+extern void stp_print(netdissect_options *, const u_char *, u_int);
+extern void sunrpcrequest_print(netdissect_options *, const u_char *, u_int, const u_char *);
+extern void syslog_print(netdissect_options *, const u_char *, u_int);
+extern void tcp_print(netdissect_options *, const u_char *, u_int, const u_char *, int);
+extern void telnet_print(netdissect_options *, const u_char *, u_int);
+extern void tftp_print(netdissect_options *, const u_char *, u_int);
+extern void timed_print(netdissect_options *, const u_char *);
+extern void tipc_print(netdissect_options *, const u_char *, u_int, u_int);
+extern u_int token_print(netdissect_options *, const u_char *, u_int, u_int);
+extern void udld_print(netdissect_options *, const u_char *, u_int);
+extern void udp_print(netdissect_options *, const u_char *, u_int, const u_char *, int);
+extern int vjc_print(netdissect_options *, register const char *, u_short);
+extern void vqp_print(netdissect_options *, register const u_char *, register u_int);
+extern void vrrp_print(netdissect_options *, const u_char *, u_int, const u_char *, int);
+extern void vtp_print(netdissect_options *, const u_char *, u_int);
+extern void vxlan_gpe_print(netdissect_options *ndo, const u_char *bp, u_int len);
+extern void vxlan_print(netdissect_options *, const u_char *, u_int);
+extern void wb_print(netdissect_options *, const void *, u_int);
+extern void zephyr_print(netdissect_options *, const u_char *, 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 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 *);
-
-extern void ip6_print(netdissect_options *,const u_char *, u_int);
-#ifdef INET6
-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*/
+/* checksum routines */
+extern void init_checksum(void);
+extern uint16_t verify_crc10_cksum(uint16_t, const u_char *, int);
+extern uint16_t create_osi_cksum(const uint8_t *, int, int);
-#if 0
struct cksum_vec {
const uint8_t *ptr;
int len;
};
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);
-extern int esp_print_decrypt_buffer_by_ikev2(netdissect_options *ndo,
- int initiator,
- u_char spii[8], u_char spir[8],
- u_char *buf, u_char *end);
+extern int nextproto4_cksum(netdissect_options *, const struct ip *, const uint8_t *, u_int, u_int, u_int);
+
+/* in print-ip6.c */
+extern int nextproto6_cksum(netdissect_options *, const struct ip6_hdr *, const uint8_t *, u_int, u_int, u_int);
+
+/* Utilities */
+extern int mask2plen(uint32_t);
+extern int mask62plen(const u_char *);
+
+extern const char *dnname_string(netdissect_options *, u_short);
+extern const char *dnnum_string(netdissect_options *, u_short);
+extern char *smb_errstr(int, int);
+extern const char *nt_errstr(uint32_t);
-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);
+extern int decode_prefix4(netdissect_options *, const u_char *, u_int, char *, u_int);
+extern int decode_prefix6(netdissect_options *, const u_char *, u_int, char *, u_int);
+
+extern void esp_print_decodesecret(netdissect_options *);
+extern int esp_print_decrypt_buffer_by_ikev2(netdissect_options *, int,
+ u_char spii[8], u_char spir[8],
+ const u_char *, const u_char *);
#endif /* netdissect_h */
diff --git a/nfsfh.h b/nfsfh.h
index cfd073bd054d..5cf8fc4417a6 100644
--- a/nfsfh.h
+++ b/nfsfh.h
@@ -63,4 +63,4 @@ typedef struct {
#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 *, uint32_t *, const char **, const char **, int);
+extern void Parse_fh(const unsigned char *, u_int, my_fsid *, uint32_t *, const char **, const char **, int);
diff --git a/nlpid.c b/nlpid.c
index 919e87dd4ae8..4b44ee1c2095 100755
--- a/nlpid.c
+++ b/nlpid.c
@@ -13,13 +13,12 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-#include "interface.h"
+#include <netdissect-stdinc.h>
+#include "netdissect.h"
#include "nlpid.h"
const struct tok nlpid_values[] = {
diff --git a/oui.c b/oui.c
index 2aea5ad74d0a..71425de6534b 100644
--- a/oui.c
+++ b/oui.c
@@ -13,13 +13,12 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-#include "interface.h"
+#include <netdissect-stdinc.h>
+#include "netdissect.h"
#include "oui.h"
/* FIXME complete OUI list using a script */
@@ -27,6 +26,7 @@
const struct tok oui_values[] = {
{ OUI_ENCAP_ETHER, "Ethernet" },
{ OUI_CISCO, "Cisco" },
+ { OUI_IANA, "IANA" },
{ OUI_NORTEL, "Nortel Networks SONMP" },
{ OUI_CISCO_90, "Cisco bridged" },
{ OUI_RFC2684, "Ethernet bridged" },
diff --git a/oui.h b/oui.h
index 4a983ecd3de8..a85f883df240 100644
--- a/oui.h
+++ b/oui.h
@@ -16,29 +16,30 @@
extern const struct tok oui_values[];
extern const struct tok smi_values[];
-#define OUI_ENCAP_ETHER 0x000000 /* encapsulated Ethernet */
-#define OUI_CISCO 0x00000c /* Cisco protocols */
-#define OUI_NORTEL 0x000081 /* Nortel SONMP */
-#define OUI_CISCO_90 0x0000f8 /* Cisco bridging */
-#define OUI_RFC2684 0x0080c2 /* RFC 2427/2684 bridged Ethernet */
-#define OUI_ATM_FORUM 0x00A03E /* ATM Forum */
-#define OUI_CABLE_BPDU 0x00E02F /* DOCSIS spanning tree BPDU */
-#define OUI_APPLETALK 0x080007 /* Appletalk */
-#define OUI_JUNIPER 0x009069 /* Juniper */
-#define OUI_HP 0x080009 /* Hewlett-Packard */
-#define OUI_IEEE_8021_PRIVATE 0x0080c2 /* IEEE 802.1 Organisation Specific - Annex F */
-#define OUI_IEEE_8023_PRIVATE 0x00120f /* IEEE 802.3 Organisation Specific - Annex G */
-#define OUI_TIA 0x0012bb /* TIA - Telecommunications Industry Association - ANSI/TIA-1057- 2006 */
-#define OUI_DCBX 0x001B21 /* DCBX */
-#define OUI_NICIRA 0x002320 /* Nicira Networks */
-#define OUI_BSN 0x5c16c7 /* Big Switch Networks */
-#define OUI_VELLO 0xb0d2f5 /* Vello Systems */
-#define OUI_HP2 0x002481 /* HP too */
-#define OUI_HPLABS 0x0004ea /* HP-Labs */
-#define OUI_INFOBLOX 0x748771 /* Infoblox Inc */
-#define OUI_ONLAB 0xa42305 /* Open Networking Lab */
-#define OUI_FREESCALE 0x00049f /* Freescale */
-#define OUI_NETRONOME 0x0015ad /* Netronome */
+#define OUI_ENCAP_ETHER 0x000000 /* encapsulated Ethernet */
+#define OUI_CISCO 0x00000c /* Cisco protocols */
+#define OUI_IANA 0x00005E /* IANA */
+#define OUI_NORTEL 0x000081 /* Nortel SONMP */
+#define OUI_CISCO_90 0x0000f8 /* Cisco bridging */
+#define OUI_RFC2684 0x0080c2 /* RFC 2427/2684 bridged Ethernet */
+#define OUI_ATM_FORUM 0x00A03E /* ATM Forum */
+#define OUI_CABLE_BPDU 0x00E02F /* DOCSIS spanning tree BPDU */
+#define OUI_APPLETALK 0x080007 /* Appletalk */
+#define OUI_JUNIPER 0x009069 /* Juniper */
+#define OUI_HP 0x080009 /* Hewlett-Packard */
+#define OUI_IEEE_8021_PRIVATE 0x0080c2 /* IEEE 802.1 Organisation Specific - Annex F */
+#define OUI_IEEE_8023_PRIVATE 0x00120f /* IEEE 802.3 Organisation Specific - Annex G */
+#define OUI_TIA 0x0012bb /* TIA - Telecommunications Industry Association - ANSI/TIA-1057- 2006 */
+#define OUI_DCBX 0x001B21 /* DCBX */
+#define OUI_NICIRA 0x002320 /* Nicira Networks */
+#define OUI_BSN 0x5c16c7 /* Big Switch Networks */
+#define OUI_VELLO 0xb0d2f5 /* Vello Systems */
+#define OUI_HP2 0x002481 /* HP too */
+#define OUI_HPLABS 0x0004ea /* HP-Labs */
+#define OUI_INFOBLOX 0x748771 /* Infoblox Inc */
+#define OUI_ONLAB 0xa42305 /* Open Networking Lab */
+#define OUI_FREESCALE 0x00049f /* Freescale */
+#define OUI_NETRONOME 0x0015ad /* Netronome */
/*
* These are SMI Network Management Private Enterprise Codes for
diff --git a/parsenfsfh.c b/parsenfsfh.c
index 826ca94e4c5c..8f48e774d766 100644
--- a/parsenfsfh.c
+++ b/parsenfsfh.c
@@ -40,17 +40,16 @@
* Western Research Laboratory
*/
-#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <stdio.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "nfsfh.h"
/*
@@ -103,10 +102,10 @@
((lsb) + ((e)<<8) + ((d)<<16) + ((c)<<24))
#endif
-static int is_UCX(const unsigned char *);
+static int is_UCX(const unsigned char *, u_int);
void
-Parse_fh(register const unsigned char *fh, int len _U_, my_fsid *fsidp,
+Parse_fh(register const unsigned char *fh, u_int len, 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) */
@@ -115,138 +114,146 @@ Parse_fh(register const unsigned char *fh, int len _U_, my_fsid *fsidp,
register const unsigned char *fhp = fh;
uint32_t temp;
int fhtype = FHT_UNKNOWN;
- int i;
+ u_int i;
- if (ourself) {
- /* File handle generated on this host, no need for guessing */
+ /*
+ * Require at least 16 bytes of file handle; it's variable-length
+ * in NFSv3. "len" is in units of 32-bit words, not bytes.
+ */
+ if (len < 16/4)
+ fhtype = FHT_UNKNOWN;
+ else {
+ if (ourself) {
+ /* File handle generated on this host, no need for guessing */
#if defined(IRIX40)
- fhtype = FHT_IRIX4;
+ fhtype = FHT_IRIX4;
#endif
#if defined(IRIX50)
- fhtype = FHT_IRIX5;
+ fhtype = FHT_IRIX5;
#endif
#if defined(IRIX51)
- fhtype = FHT_IRIX5;
+ fhtype = FHT_IRIX5;
#endif
#if defined(SUNOS4)
- fhtype = FHT_SUNOS4;
+ fhtype = FHT_SUNOS4;
#endif
#if defined(SUNOS5)
- fhtype = FHT_SUNOS5;
+ fhtype = FHT_SUNOS5;
#endif
#if defined(ultrix)
- fhtype = FHT_ULTRIX;
+ fhtype = FHT_ULTRIX;
#endif
#if defined(__osf__)
- fhtype = FHT_DECOSF;
+ fhtype = FHT_DECOSF;
#endif
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) \
|| defined(__OpenBSD__)
- fhtype = FHT_BSD44;
-#endif
- }
- /*
- * This is basically a big decision tree
- */
- else if ((fhp[0] == 0) && (fhp[1] == 0)) {
- /* bytes[0,1] == (0,0); rules out Ultrix, IRIX5, SUNOS5 */
- /* probably rules out HP-UX, AIX unless they allow major=0 */
- if ((fhp[2] == 0) && (fhp[3] == 0)) {
- /* bytes[2,3] == (0,0); must be Auspex */
- /* XXX or could be Ultrix+MASSBUS "hp" disk? */
- fhtype = FHT_AUSPEX;
- }
- else {
- /*
- * bytes[2,3] != (0,0); rules out Auspex, could be
- * DECOSF, SUNOS4, or IRIX4
- */
- if ((fhp[4] != 0) && (fhp[5] == 0) &&
- (fhp[8] == 12) && (fhp[9] == 0)) {
- /* seems to be DECOSF, with minor == 0 */
- fhtype = FHT_DECOSF;
- }
- else {
- /* could be SUNOS4 or IRIX4 */
- /* XXX the test of fhp[5] == 8 could be wrong */
- if ((fhp[4] == 0) && (fhp[5] == 8) && (fhp[6] == 0) &&
- (fhp[7] == 0)) {
- /* looks like a length, not a file system typecode */
- fhtype = FHT_IRIX4;
- }
- else {
- /* by elimination */
- fhtype = FHT_SUNOS4;
- }
- }
- }
- }
- else {
- /*
- * bytes[0,1] != (0,0); rules out Auspex, IRIX4, SUNOS4
- * could be IRIX5, DECOSF, UCX, Ultrix, SUNOS5
- * could be AIX, HP-UX
- */
- if ((fhp[2] == 0) && (fhp[3] == 0)) {
- /*
- * bytes[2,3] == (0,0); rules out OSF, probably not UCX
- * (unless the exported device name is just one letter!),
- * could be Ultrix, IRIX5, AIX, or SUNOS5
- * might be HP-UX (depends on their values for minor devs)
- */
- if ((fhp[6] == 0) && (fhp[7] == 0)) {
fhtype = FHT_BSD44;
+#endif
}
- /*XXX we probably only need to test of these two bytes */
- else if ((fhp[21] == 0) && (fhp[23] == 0)) {
- fhtype = FHT_ULTRIX;
- }
- else {
- /* Could be SUNOS5/IRIX5, maybe AIX */
- /* XXX no obvious difference between SUNOS5 and IRIX5 */
- if (fhp[9] == 10)
- fhtype = FHT_SUNOS5;
- /* XXX what about AIX? */
- }
- }
- else {
/*
- * bytes[2,3] != (0,0); rules out Ultrix, could be
- * DECOSF, SUNOS5, IRIX5, AIX, HP-UX, or UCX
+ * This is basically a big decision tree
*/
- if ((fhp[8] == 12) && (fhp[9] == 0)) {
- fhtype = FHT_DECOSF;
- }
- else if ((fhp[8] == 0) && (fhp[9] == 10)) {
- /* could be SUNOS5/IRIX5, AIX, HP-UX */
- if ((fhp[7] == 0) && (fhp[6] == 0) &&
- (fhp[5] == 0) && (fhp[4] == 0)) {
- /* XXX is this always true of HP-UX? */
- fhtype = FHT_HPUX9;
- }
- else if (fhp[7] == 2) {
- /* This would be MNT_NFS on AIX, which is impossible */
- fhtype = FHT_SUNOS5; /* or maybe IRIX5 */
+ else if ((fhp[0] == 0) && (fhp[1] == 0)) {
+ /* bytes[0,1] == (0,0); rules out Ultrix, IRIX5, SUNOS5 */
+ /* probably rules out HP-UX, AIX unless they allow major=0 */
+ if ((fhp[2] == 0) && (fhp[3] == 0)) {
+ /* bytes[2,3] == (0,0); must be Auspex */
+ /* XXX or could be Ultrix+MASSBUS "hp" disk? */
+ fhtype = FHT_AUSPEX;
}
else {
/*
- * XXX Could be SUNOS5/IRIX5 or AIX. I don't
- * XXX see any way to disambiguate these, so
- * XXX I'm going with the more likely guess.
- * XXX Sorry, Big Blue.
+ * bytes[2,3] != (0,0); rules out Auspex, could be
+ * DECOSF, SUNOS4, or IRIX4
*/
- fhtype = FHT_SUNOS5; /* or maybe IRIX5 */
+ if ((fhp[4] != 0) && (fhp[5] == 0) &&
+ (fhp[8] == 12) && (fhp[9] == 0)) {
+ /* seems to be DECOSF, with minor == 0 */
+ fhtype = FHT_DECOSF;
+ }
+ else {
+ /* could be SUNOS4 or IRIX4 */
+ /* XXX the test of fhp[5] == 8 could be wrong */
+ if ((fhp[4] == 0) && (fhp[5] == 8) && (fhp[6] == 0) &&
+ (fhp[7] == 0)) {
+ /* looks like a length, not a file system typecode */
+ fhtype = FHT_IRIX4;
+ }
+ else {
+ /* by elimination */
+ fhtype = FHT_SUNOS4;
+ }
+ }
}
- }
+ }
else {
- if (is_UCX(fhp)) {
- fhtype = FHT_VMSUCX;
+ /*
+ * bytes[0,1] != (0,0); rules out Auspex, IRIX4, SUNOS4
+ * could be IRIX5, DECOSF, UCX, Ultrix, SUNOS5
+ * could be AIX, HP-UX
+ */
+ if ((fhp[2] == 0) && (fhp[3] == 0)) {
+ /*
+ * bytes[2,3] == (0,0); rules out OSF, probably not UCX
+ * (unless the exported device name is just one letter!),
+ * could be Ultrix, IRIX5, AIX, or SUNOS5
+ * might be HP-UX (depends on their values for minor devs)
+ */
+ if ((fhp[6] == 0) && (fhp[7] == 0)) {
+ fhtype = FHT_BSD44;
+ }
+ /*XXX we probably only need to test of these two bytes */
+ else if ((len >= 24/4) && (fhp[21] == 0) && (fhp[23] == 0)) {
+ fhtype = FHT_ULTRIX;
+ }
+ else {
+ /* Could be SUNOS5/IRIX5, maybe AIX */
+ /* XXX no obvious difference between SUNOS5 and IRIX5 */
+ if (fhp[9] == 10)
+ fhtype = FHT_SUNOS5;
+ /* XXX what about AIX? */
+ }
}
else {
- fhtype = FHT_UNKNOWN;
+ /*
+ * bytes[2,3] != (0,0); rules out Ultrix, could be
+ * DECOSF, SUNOS5, IRIX5, AIX, HP-UX, or UCX
+ */
+ if ((fhp[8] == 12) && (fhp[9] == 0)) {
+ fhtype = FHT_DECOSF;
+ }
+ else if ((fhp[8] == 0) && (fhp[9] == 10)) {
+ /* could be SUNOS5/IRIX5, AIX, HP-UX */
+ if ((fhp[7] == 0) && (fhp[6] == 0) &&
+ (fhp[5] == 0) && (fhp[4] == 0)) {
+ /* XXX is this always true of HP-UX? */
+ fhtype = FHT_HPUX9;
+ }
+ else if (fhp[7] == 2) {
+ /* This would be MNT_NFS on AIX, which is impossible */
+ fhtype = FHT_SUNOS5; /* or maybe IRIX5 */
+ }
+ else {
+ /*
+ * XXX Could be SUNOS5/IRIX5 or AIX. I don't
+ * XXX see any way to disambiguate these, so
+ * XXX I'm going with the more likely guess.
+ * XXX Sorry, Big Blue.
+ */
+ fhtype = FHT_SUNOS5; /* or maybe IRIX5 */
+ }
+ }
+ else {
+ if (is_UCX(fhp, len)) {
+ fhtype = FHT_VMSUCX;
+ }
+ else {
+ fhtype = FHT_UNKNOWN;
+ }
+ }
}
}
- }
}
/* XXX still needs to handle SUNOS3 */
@@ -361,13 +368,13 @@ Parse_fh(register const unsigned char *fh, int len _U_, my_fsid *fsidp,
if (sizeof(*fsidp) > 14)
memset((char *)fsidp, 0, sizeof(*fsidp));
/* just use the whole thing */
- memcpy((char *)fsidp, (char *)fh, 14);
+ memcpy((char *)fsidp, (const char *)fh, 14);
}
else {
uint32_t tempa[4]; /* at least 16 bytes, maybe more */
memset((char *)tempa, 0, sizeof(tempa));
- memcpy((char *)tempa, (char *)fh, 14); /* ensure alignment */
+ memcpy((char *)tempa, (const char *)fh, 14); /* ensure alignment */
fsidp->Fsid_dev.Minor = tempa[0] + (tempa[1]<<1);
fsidp->Fsid_dev.Major = tempa[2] + (tempa[3]<<1);
fsidp->fsid_code = 0;
@@ -378,7 +385,7 @@ Parse_fh(register const unsigned char *fh, int len _U_, my_fsid *fsidp,
/* Caller must save (and null-terminate?) this value */
if (fsnamep)
- *fsnamep = (char *)&(fhp[1]);
+ *fsnamep = (const char *)&(fhp[1]);
if (osnamep)
*osnamep = "VMS";
@@ -410,13 +417,14 @@ Parse_fh(register const unsigned char *fh, int len _U_, my_fsid *fsidp,
case FHT_UNKNOWN:
#ifdef DEBUG
/* XXX debugging */
- for (i = 0; i < 32; i++)
+ for (i = 0; i < len*4; i++)
(void)fprintf(stderr, "%x.", fhp[i]);
(void)fprintf(stderr, "\n");
#endif
/* Save the actual handle, so it can be display with -u */
- for (i = 0; i < 32; i++)
+ for (i = 0; i < len*4 && i*2 < sizeof(fsidp->Opaque_Handle) - 1; i++)
(void)snprintf(&(fsidp->Opaque_Handle[i*2]), 3, "%.2X", fhp[i]);
+ fsidp->Opaque_Handle[i*2] = '\0';
/* XXX for now, give "bogus" values to aid debugging */
fsidp->fsid_code = 0;
@@ -443,11 +451,18 @@ Parse_fh(register const unsigned char *fh, int len _U_, my_fsid *fsidp,
* (3) followed by string of nulls
*/
static int
-is_UCX(const unsigned char *fhp)
+is_UCX(const unsigned char *fhp, u_int len)
{
- register int i;
+ register u_int i;
int seen_null = 0;
+ /*
+ * Require at least 28 bytes of file handle; it's variable-length
+ * in NFSv3. "len" is in units of 32-bit words, not bytes.
+ */
+ if (len < 28/4)
+ return(0);
+
for (i = 1; i < 14; i++) {
if (ND_ISPRINT(fhp[i])) {
if (seen_null)
diff --git a/pcap-missing.h b/pcap-missing.h
index d776810f9112..92706b14782c 100644
--- a/pcap-missing.h
+++ b/pcap-missing.h
@@ -19,8 +19,8 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef tcpdump_pcap_missing_h
-#define tcpdump_pcap_missing_h
+#ifndef netdissect_pcap_missing_h
+#define netdissect_pcap_missing_h
/*
* Declarations of functions that might be missing from libpcap.
@@ -46,13 +46,4 @@ extern const char *pcap_datalink_val_to_description(int);
extern long pcap_dump_ftell(pcap_dumper_t *);
#endif
-#endif
-
-
-
-
-
-
-
-
-
+#endif /* netdissect_pcap_missing_h */
diff --git a/print-802_11.c b/print-802_11.c
index 697e2c926000..1bbe47ace504 100644
--- a/print-802_11.c
+++ b/print-802_11.c
@@ -20,16 +20,17 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: IEEE 802.11 printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
@@ -45,8 +46,11 @@
#define IEEE802_11_BSSID_LEN 6
#define IEEE802_11_RA_LEN 6
#define IEEE802_11_TA_LEN 6
+#define IEEE802_11_ADDR1_LEN 6
#define IEEE802_11_SEQ_LEN 2
#define IEEE802_11_CTL_LEN 2
+#define IEEE802_11_CARRIED_FC_LEN 2
+#define IEEE802_11_HT_CONTROL_LEN 4
#define IEEE802_11_IV_LEN 3
#define IEEE802_11_KID_LEN 1
@@ -166,15 +170,15 @@ static const struct tok ctrl_str[] = {
#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_PROTECTED(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];
+ uint8_t da[IEEE802_11_DA_LEN];
+ uint8_t sa[IEEE802_11_SA_LEN];
+ uint8_t bssid[IEEE802_11_BSSID_LEN];
uint16_t seq_ctrl;
};
@@ -292,85 +296,90 @@ struct mgmt_body_t {
struct tim_t tim;
};
-struct ctrl_rts_t {
+struct ctrl_control_wrapper_hdr_t {
+ uint16_t fc;
+ uint16_t duration;
+ uint8_t addr1[IEEE802_11_ADDR1_LEN];
+ uint16_t carried_fc[IEEE802_11_CARRIED_FC_LEN];
+ uint16_t ht_control[IEEE802_11_HT_CONTROL_LEN];
+};
+
+#define CTRL_CONTROL_WRAPPER_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
+ IEEE802_11_ADDR1_LEN+\
+ IEEE802_11_CARRIED_FC_LEN+\
+ IEEE802_11_HT_CONTROL_LEN)
+
+struct ctrl_rts_hdr_t {
uint16_t fc;
uint16_t duration;
- uint8_t ra[6];
- uint8_t ta[6];
- uint8_t fcs[4];
+ uint8_t ra[IEEE802_11_RA_LEN];
+ uint8_t ta[IEEE802_11_TA_LEN];
};
#define CTRL_RTS_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
IEEE802_11_RA_LEN+IEEE802_11_TA_LEN)
-struct ctrl_cts_t {
+struct ctrl_cts_hdr_t {
uint16_t fc;
uint16_t duration;
- uint8_t ra[6];
- uint8_t fcs[4];
+ uint8_t ra[IEEE802_11_RA_LEN];
};
#define CTRL_CTS_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
-struct ctrl_ack_t {
+struct ctrl_ack_hdr_t {
uint16_t fc;
uint16_t duration;
- uint8_t ra[6];
- uint8_t fcs[4];
+ uint8_t ra[IEEE802_11_RA_LEN];
};
#define CTRL_ACK_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
-struct ctrl_ps_poll_t {
+struct ctrl_ps_poll_hdr_t {
uint16_t fc;
uint16_t aid;
- uint8_t bssid[6];
- uint8_t ta[6];
- uint8_t fcs[4];
+ uint8_t bssid[IEEE802_11_BSSID_LEN];
+ uint8_t ta[IEEE802_11_TA_LEN];
};
#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 {
+struct ctrl_end_hdr_t {
uint16_t fc;
uint16_t duration;
- uint8_t ra[6];
- uint8_t bssid[6];
- uint8_t fcs[4];
+ uint8_t ra[IEEE802_11_RA_LEN];
+ uint8_t bssid[IEEE802_11_BSSID_LEN];
};
#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 {
+struct ctrl_end_ack_hdr_t {
uint16_t fc;
uint16_t duration;
- uint8_t ra[6];
- uint8_t bssid[6];
- uint8_t fcs[4];
+ uint8_t ra[IEEE802_11_RA_LEN];
+ uint8_t bssid[IEEE802_11_BSSID_LEN];
};
#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 {
+struct ctrl_ba_hdr_t {
uint16_t fc;
uint16_t duration;
- uint8_t ra[6];
- uint8_t fcs[4];
+ uint8_t ra[IEEE802_11_RA_LEN];
};
#define CTRL_BA_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
-struct ctrl_bar_t {
+struct ctrl_bar_hdr_t {
uint16_t fc;
uint16_t dur;
- uint8_t ra[6];
- uint8_t ta[6];
+ uint8_t ra[IEEE802_11_RA_LEN];
+ uint8_t ta[IEEE802_11_TA_LEN];
uint16_t ctl;
uint16_t seq;
- uint8_t fcs[4];
};
#define CTRL_BAR_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
@@ -390,310 +399,6 @@ struct meshcntl_t {
#define IV_PAD(iv) (((iv) >> 24) & 0x3F)
#define IV_KEYID(iv) (((iv) >> 30) & 0x03)
-/* $FreeBSD: src/sys/net80211/ieee80211_radiotap.h,v 1.5 2005/01/22 20:12:05 sam Exp $ */
-/* NetBSD: ieee802_11_radio.h,v 1.2 2006/02/26 03:04:03 dyoung Exp */
-
-/*-
- * 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
-{
- uint32_t present;
-
- uint8_t rate;
-};
-
#define PRINT_SSID(p) \
if (p.ssid_present) { \
ND_PRINT((ndo, " (")); \
@@ -1283,7 +988,7 @@ wep_print(netdissect_options *ndo,
return 0;
iv = EXTRACT_LE_32BITS(p);
- ND_PRINT((ndo, "Data IV:%3x Pad %x KeyID %x", IV_IV(iv), IV_PAD(iv),
+ ND_PRINT((ndo, " IV:%3x Pad %x KeyID %x", IV_IV(iv), IV_PAD(iv),
IV_KEYID(iv)));
return 1;
@@ -1801,7 +1506,7 @@ handle_auth(netdissect_options *ndo,
static int
handle_deauth(netdissect_options *ndo,
- const struct mgmt_header_t *pmh, const u_char *p, u_int length)
+ const uint8_t *src, const u_char *p, u_int length)
{
struct mgmt_body_t pbody;
const char *reason = NULL;
@@ -1821,7 +1526,7 @@ handle_deauth(netdissect_options *ndo,
if (ndo->ndo_eflag) {
ND_PRINT((ndo, ": %s", reason));
} else {
- ND_PRINT((ndo, " (%s): %s", etheraddr_string(ndo, pmh->sa), reason));
+ ND_PRINT((ndo, " (%s): %s", etheraddr_string(ndo, src), reason));
}
return 1;
}
@@ -1886,7 +1591,7 @@ handle_deauth(netdissect_options *ndo,
static int
handle_action(netdissect_options *ndo,
- const struct mgmt_header_t *pmh, const u_char *p, u_int length)
+ const uint8_t *src, const u_char *p, u_int length)
{
if (!ND_TTEST2(*p, 2))
return 0;
@@ -1895,7 +1600,7 @@ handle_action(netdissect_options *ndo,
if (ndo->ndo_eflag) {
ND_PRINT((ndo, ": "));
} else {
- ND_PRINT((ndo, " (%s): ", etheraddr_string(ndo, pmh->sa)));
+ ND_PRINT((ndo, " (%s): ", etheraddr_string(ndo, src)));
}
switch (p[0]) {
case 0: ND_PRINT((ndo, "Spectrum Management Act#%d", p[1])); break;
@@ -1926,10 +1631,13 @@ handle_action(netdissect_options *ndo,
static int
mgmt_body_print(netdissect_options *ndo,
- uint16_t fc, const struct mgmt_header_t *pmh,
- const u_char *p, u_int length)
+ uint16_t fc, const uint8_t *src, const u_char *p, u_int length)
{
ND_PRINT((ndo, "%s", tok2str(st_str, "Unhandled Management subtype(%x)", FC_SUBTYPE(fc))));
+
+ /* There may be a problem w/ AP not having this bit set */
+ if (FC_PROTECTED(fc))
+ return wep_print(ndo, p);
switch (FC_SUBTYPE(fc)) {
case ST_ASSOC_REQUEST:
return handle_assoc_request(ndo, p, length);
@@ -1950,17 +1658,11 @@ mgmt_body_print(netdissect_options *ndo,
case ST_DISASSOC:
return handle_disassoc(ndo, p, length);
case ST_AUTH:
- if (!ND_TTEST2(*p, 3))
- return 0;
- if ((p[0] == 0 ) && (p[1] == 0) && (p[2] == 0)) {
- ND_PRINT((ndo, "Authentication (Shared-Key)-3 "));
- return wep_print(ndo, p);
- }
return handle_auth(ndo, p, length);
case ST_DEAUTH:
- return handle_deauth(ndo, pmh, p, length);
+ return handle_deauth(ndo, src, p, length);
case ST_ACTION:
- return handle_action(ndo, pmh, p, length);
+ return handle_action(ndo, src, p, length);
default:
return 1;
}
@@ -1985,68 +1687,64 @@ ctrl_body_print(netdissect_options *ndo,
return 0;
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))));
+ etheraddr_string(ndo, ((const struct ctrl_bar_hdr_t *)p)->ra),
+ etheraddr_string(ndo, ((const struct ctrl_bar_hdr_t *)p)->ta),
+ EXTRACT_LE_16BITS(&(((const struct ctrl_bar_hdr_t *)p)->ctl)),
+ EXTRACT_LE_16BITS(&(((const struct ctrl_bar_hdr_t *)p)->seq))));
break;
case CTRL_BA:
if (!ND_TTEST2(*p, CTRL_BA_HDRLEN))
return 0;
if (!ndo->ndo_eflag)
ND_PRINT((ndo, " RA:%s ",
- etheraddr_string(ndo, ((const struct ctrl_ba_t *)p)->ra)));
+ etheraddr_string(ndo, ((const struct ctrl_ba_hdr_t *)p)->ra)));
break;
case CTRL_PS_POLL:
if (!ND_TTEST2(*p, CTRL_PS_POLL_HDRLEN))
return 0;
ND_PRINT((ndo, " AID(%x)",
- EXTRACT_LE_16BITS(&(((const struct ctrl_ps_poll_t *)p)->aid))));
+ EXTRACT_LE_16BITS(&(((const struct ctrl_ps_poll_hdr_t *)p)->aid))));
break;
case CTRL_RTS:
if (!ND_TTEST2(*p, CTRL_RTS_HDRLEN))
return 0;
if (!ndo->ndo_eflag)
ND_PRINT((ndo, " TA:%s ",
- etheraddr_string(ndo, ((const struct ctrl_rts_t *)p)->ta)));
+ etheraddr_string(ndo, ((const struct ctrl_rts_hdr_t *)p)->ta)));
break;
case CTRL_CTS:
if (!ND_TTEST2(*p, CTRL_CTS_HDRLEN))
return 0;
if (!ndo->ndo_eflag)
ND_PRINT((ndo, " RA:%s ",
- etheraddr_string(ndo, ((const struct ctrl_cts_t *)p)->ra)));
+ etheraddr_string(ndo, ((const struct ctrl_cts_hdr_t *)p)->ra)));
break;
case CTRL_ACK:
if (!ND_TTEST2(*p, CTRL_ACK_HDRLEN))
return 0;
if (!ndo->ndo_eflag)
ND_PRINT((ndo, " RA:%s ",
- etheraddr_string(ndo, ((const struct ctrl_ack_t *)p)->ra)));
+ etheraddr_string(ndo, ((const struct ctrl_ack_hdr_t *)p)->ra)));
break;
case CTRL_CF_END:
if (!ND_TTEST2(*p, CTRL_END_HDRLEN))
return 0;
if (!ndo->ndo_eflag)
ND_PRINT((ndo, " RA:%s ",
- etheraddr_string(ndo, ((const struct ctrl_end_t *)p)->ra)));
+ etheraddr_string(ndo, ((const struct ctrl_end_hdr_t *)p)->ra)));
break;
case CTRL_END_ACK:
if (!ND_TTEST2(*p, CTRL_END_ACK_HDRLEN))
return 0;
if (!ndo->ndo_eflag)
ND_PRINT((ndo, " RA:%s ",
- etheraddr_string(ndo, ((const struct ctrl_end_ack_t *)p)->ra)));
+ etheraddr_string(ndo, ((const struct ctrl_end_ack_hdr_t *)p)->ra)));
break;
}
return 1;
}
/*
- * Print Header funcs
- */
-
-/*
* Data Frame - Address field contents
*
* To Ds | From DS | Addr 1 | Addr 2 | Addr 3 | Addr 4
@@ -2056,10 +1754,63 @@ ctrl_body_print(netdissect_options *ndo,
* 1 | 1 | RA | TA | DA | SA
*/
+/*
+ * Function to get source and destination MAC addresses for a data frame.
+ */
+static void
+get_data_src_dst_mac(uint16_t fc, const u_char *p, const uint8_t **srcp,
+ const uint8_t **dstp)
+{
+#define ADDR1 (p + 4)
+#define ADDR2 (p + 10)
+#define ADDR3 (p + 16)
+#define ADDR4 (p + 24)
+
+ if (!FC_TO_DS(fc)) {
+ if (!FC_FROM_DS(fc)) {
+ /* not To DS and not From DS */
+ *srcp = ADDR2;
+ *dstp = ADDR1;
+ } else {
+ /* not To DS and From DS */
+ *srcp = ADDR3;
+ *dstp = ADDR1;
+ }
+ } else {
+ if (!FC_FROM_DS(fc)) {
+ /* From DS and not To DS */
+ *srcp = ADDR2;
+ *dstp = ADDR3;
+ } else {
+ /* To DS and From DS */
+ *srcp = ADDR4;
+ *dstp = ADDR3;
+ }
+ }
+
+#undef ADDR1
+#undef ADDR2
+#undef ADDR3
+#undef ADDR4
+}
+
+static void
+get_mgmt_src_dst_mac(const u_char *p, const uint8_t **srcp, const uint8_t **dstp)
+{
+ const struct mgmt_header_t *hp = (const struct mgmt_header_t *) p;
+
+ if (srcp != NULL)
+ *srcp = hp->sa;
+ if (dstp != NULL)
+ *dstp = hp->da;
+}
+
+/*
+ * Print Header funcs
+ */
+
static void
-data_header_print(netdissect_options *ndo,
- uint16_t fc, const u_char *p, const uint8_t **srcp,
- const uint8_t **dstp)
+data_header_print(netdissect_options *ndo, uint16_t fc, const u_char *p)
{
u_int subtype = FC_SUBTYPE(fc);
@@ -2086,42 +1837,18 @@ data_header_print(netdissect_options *ndo,
#define ADDR4 (p + 24)
if (!FC_TO_DS(fc) && !FC_FROM_DS(fc)) {
- if (srcp != NULL)
- *srcp = ADDR2;
- if (dstp != NULL)
- *dstp = ADDR1;
- if (!ndo->ndo_eflag)
- return;
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 (!ndo->ndo_eflag)
- return;
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 (!ndo->ndo_eflag)
- return;
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 (!ndo->ndo_eflag)
- return;
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)));
@@ -2134,77 +1861,60 @@ data_header_print(netdissect_options *ndo,
}
static void
-mgmt_header_print(netdissect_options *ndo,
- const u_char *p, const uint8_t **srcp, const uint8_t **dstp)
+mgmt_header_print(netdissect_options *ndo, const u_char *p)
{
const struct mgmt_header_t *hp = (const struct mgmt_header_t *) p;
- if (srcp != NULL)
- *srcp = hp->sa;
- if (dstp != NULL)
- *dstp = hp->da;
- if (!ndo->ndo_eflag)
- return;
-
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(netdissect_options *ndo,
- uint16_t fc, const u_char *p, const uint8_t **srcp,
- const uint8_t **dstp)
+ctrl_header_print(netdissect_options *ndo, uint16_t fc, const u_char *p)
{
- if (srcp != NULL)
- *srcp = NULL;
- if (dstp != NULL)
- *dstp = NULL;
- if (!ndo->ndo_eflag)
- return;
-
switch (FC_SUBTYPE(fc)) {
case CTRL_BAR:
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))));
+ etheraddr_string(ndo, ((const struct ctrl_bar_hdr_t *)p)->ra),
+ etheraddr_string(ndo, ((const struct ctrl_bar_hdr_t *)p)->ta),
+ EXTRACT_LE_16BITS(&(((const struct ctrl_bar_hdr_t *)p)->ctl)),
+ EXTRACT_LE_16BITS(&(((const struct ctrl_bar_hdr_t *)p)->seq))));
break;
case CTRL_BA:
ND_PRINT((ndo, "RA:%s ",
- etheraddr_string(ndo, ((const struct ctrl_ba_t *)p)->ra)));
+ etheraddr_string(ndo, ((const struct ctrl_ba_hdr_t *)p)->ra)));
break;
case CTRL_PS_POLL:
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)));
+ etheraddr_string(ndo, ((const struct ctrl_ps_poll_hdr_t *)p)->bssid),
+ etheraddr_string(ndo, ((const struct ctrl_ps_poll_hdr_t *)p)->ta)));
break;
case CTRL_RTS:
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)));
+ etheraddr_string(ndo, ((const struct ctrl_rts_hdr_t *)p)->ra),
+ etheraddr_string(ndo, ((const struct ctrl_rts_hdr_t *)p)->ta)));
break;
case CTRL_CTS:
ND_PRINT((ndo, "RA:%s ",
- etheraddr_string(ndo, ((const struct ctrl_cts_t *)p)->ra)));
+ etheraddr_string(ndo, ((const struct ctrl_cts_hdr_t *)p)->ra)));
break;
case CTRL_ACK:
ND_PRINT((ndo, "RA:%s ",
- etheraddr_string(ndo, ((const struct ctrl_ack_t *)p)->ra)));
+ etheraddr_string(ndo, ((const struct ctrl_ack_hdr_t *)p)->ra)));
break;
case CTRL_CF_END:
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)));
+ etheraddr_string(ndo, ((const struct ctrl_end_hdr_t *)p)->ra),
+ etheraddr_string(ndo, ((const struct ctrl_end_hdr_t *)p)->bssid)));
break;
case CTRL_END_ACK:
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)));
+ etheraddr_string(ndo, ((const struct ctrl_end_ack_hdr_t *)p)->ra),
+ etheraddr_string(ndo, ((const struct ctrl_end_ack_hdr_t *)p)->bssid)));
break;
default:
- ND_PRINT((ndo, "(H) Unknown Ctrl Subtype"));
+ /* We shouldn't get here - we should already have quit */
break;
}
}
@@ -2220,8 +1930,12 @@ extract_header_length(netdissect_options *ndo,
return MGMT_HDRLEN;
case T_CTRL:
switch (FC_SUBTYPE(fc)) {
+ case CTRL_CONTROL_WRAPPER:
+ return CTRL_CONTROL_WRAPPER_HDRLEN;
case CTRL_BAR:
return CTRL_BAR_HDRLEN;
+ case CTRL_BA:
+ return CTRL_BA_HDRLEN;
case CTRL_PS_POLL:
return CTRL_PS_POLL_HDRLEN;
case CTRL_RTS:
@@ -2235,6 +1949,7 @@ extract_header_length(netdissect_options *ndo,
case CTRL_END_ACK:
return CTRL_END_ACK_HDRLEN;
default:
+ ND_PRINT((ndo, "unknown 802.11 ctrl frame subtype (%d)", FC_SUBTYPE(fc)));
return 0;
}
case T_DATA:
@@ -2243,7 +1958,7 @@ extract_header_length(netdissect_options *ndo,
len += 2;
return len;
default:
- ND_PRINT((ndo, "unknown IEEE802.11 frame type (%d)", FC_TYPE(fc)));
+ ND_PRINT((ndo, "unknown 802.11 frame type (%d)", FC_TYPE(fc)));
return 0;
}
}
@@ -2255,15 +1970,12 @@ extract_mesh_header_length(const u_char *p)
}
/*
- * Print the 802.11 MAC header if eflag is set, and set "*srcp" and "*dstp"
- * to point to the source and destination MAC addresses in any case if
- * "srcp" and "dstp" aren't null.
+ * Print the 802.11 MAC header.
*/
static void
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)
+ u_int meshdrlen)
{
if (ndo->ndo_vflag) {
if (FC_MORE_DATA(fc))
@@ -2276,8 +1988,8 @@ ieee_802_11_hdr_print(netdissect_options *ndo,
ND_PRINT((ndo, "Retry "));
if (FC_ORDER(fc))
ND_PRINT((ndo, "Strictly Ordered "));
- if (FC_WEP(fc))
- ND_PRINT((ndo, "WEP Encrypted "));
+ if (FC_PROTECTED(fc))
+ ND_PRINT((ndo, "Protected "));
if (FC_TYPE(fc) != T_CTRL || FC_SUBTYPE(fc) != CTRL_PS_POLL)
ND_PRINT((ndo, "%dus ",
EXTRACT_LE_16BITS(
@@ -2301,19 +2013,15 @@ ieee_802_11_hdr_print(netdissect_options *ndo,
switch (FC_TYPE(fc)) {
case T_MGMT:
- mgmt_header_print(ndo, p, srcp, dstp);
+ mgmt_header_print(ndo, p);
break;
case T_CTRL:
- ctrl_header_print(ndo, fc, p, srcp, dstp);
+ ctrl_header_print(ndo, fc, p);
break;
case T_DATA:
- data_header_print(ndo, fc, p, srcp, dstp);
+ data_header_print(ndo, fc, p);
break;
default:
- ND_PRINT((ndo, "(header) unknown IEEE802.11 frame type (%d)",
- FC_TYPE(fc)));
- *srcp = NULL;
- *dstp = NULL;
break;
}
}
@@ -2322,6 +2030,8 @@ ieee_802_11_hdr_print(netdissect_options *ndo,
#define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */
#endif
+static const char tstr[] = "[|802.11]";
+
static u_int
ieee802_11_print(netdissect_options *ndo,
const u_char *p, u_int length, u_int orig_caplen, int pad,
@@ -2329,8 +2039,8 @@ ieee802_11_print(netdissect_options *ndo,
{
uint16_t fc;
u_int caplen, hdrlen, meshdrlen;
- const uint8_t *src, *dst;
- u_short extracted_ethertype;
+ struct lladdr_info src, dst;
+ int llc_hdrlen;
caplen = orig_caplen;
/* Remove FCS, if present */
@@ -2353,6 +2063,10 @@ ieee802_11_print(netdissect_options *ndo,
fc = EXTRACT_LE_16BITS(p);
hdrlen = extract_header_length(ndo, fc);
+ if (hdrlen == 0) {
+ /* Unknown frame type or control frame subtype; quit. */
+ return (0);
+ }
if (pad)
hdrlen = roundup2(hdrlen, 4);
if (ndo->ndo_Hflag && FC_TYPE(fc) == T_DATA &&
@@ -2362,13 +2076,13 @@ ieee802_11_print(netdissect_options *ndo,
} else
meshdrlen = 0;
-
if (caplen < hdrlen) {
ND_PRINT((ndo, "%s", tstr));
return hdrlen;
}
- ieee_802_11_hdr_print(ndo, fc, p, hdrlen, meshdrlen, &src, &dst);
+ if (ndo->ndo_eflag)
+ ieee_802_11_hdr_print(ndo, fc, p, hdrlen, meshdrlen);
/*
* Go past the 802.11 header.
@@ -2377,10 +2091,12 @@ ieee802_11_print(netdissect_options *ndo,
caplen -= hdrlen;
p += hdrlen;
+ src.addr_string = etheraddr_string;
+ dst.addr_string = etheraddr_string;
switch (FC_TYPE(fc)) {
case T_MGMT:
- if (!mgmt_body_print(ndo, fc,
- (const struct mgmt_header_t *)(p - hdrlen), p, length)) {
+ get_mgmt_src_dst_mac(p - hdrlen, &src.addr, &dst.addr);
+ if (!mgmt_body_print(ndo, fc, src.addr, p, length)) {
ND_PRINT((ndo, "%s", tstr));
return hdrlen;
}
@@ -2395,30 +2111,29 @@ ieee802_11_print(netdissect_options *ndo,
if (DATA_FRAME_IS_NULL(FC_SUBTYPE(fc)))
return hdrlen; /* no-data frame */
/* There may be a problem w/ AP not having this bit set */
- if (FC_WEP(fc)) {
+ if (FC_PROTECTED(fc)) {
+ ND_PRINT((ndo, "Data"));
if (!wep_print(ndo, p)) {
ND_PRINT((ndo, "%s", tstr));
return hdrlen;
}
- } else if (llc_print(ndo, p, length, caplen, dst, src,
- &extracted_ethertype) == 0) {
- /*
- * Some kinds of LLC packet we cannot
- * handle intelligently
- */
- if (!ndo->ndo_eflag)
- ieee_802_11_hdr_print(ndo, fc, p - hdrlen, hdrlen,
- meshdrlen, NULL, NULL);
- if (extracted_ethertype)
- ND_PRINT((ndo, "(LLC %s) ",
- etherproto_string(
- htons(extracted_ethertype))));
- if (!ndo->ndo_suppress_default_print)
- ND_DEFAULTPRINT(p, caplen);
+ } else {
+ get_data_src_dst_mac(fc, p - hdrlen, &src.addr, &dst.addr);
+ llc_hdrlen = llc_print(ndo, p, length, caplen, &src, &dst);
+ if (llc_hdrlen < 0) {
+ /*
+ * Some kinds of LLC packet we cannot
+ * handle intelligently
+ */
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
+ llc_hdrlen = -llc_hdrlen;
+ }
+ hdrlen += llc_hdrlen;
}
break;
default:
- ND_PRINT((ndo, "unknown 802.11 frame type (%d)", FC_TYPE(fc)));
+ /* We shouldn't get here - we should already have quit */
break;
}
@@ -2438,6 +2153,349 @@ ieee802_11_if_print(netdissect_options *ndo,
return ieee802_11_print(ndo, p, h->len, h->caplen, 0, 0);
}
+
+/* $FreeBSD: src/sys/net80211/ieee80211_radiotap.h,v 1.5 2005/01/22 20:12:05 sam Exp $ */
+/* NetBSD: ieee802_11_radio.h,v 1.2 2006/02/26 03:04:03 dyoung Exp */
+
+/*-
+ * 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_AMPDU_STATUS u32, u16, u8, u8 unitless
+ *
+ * Contains the AMPDU information for the subframe.
+ *
+ * IEEE80211_RADIOTAP_VHT u16, u8, u8, u8[4], u8, u8, u16
+ *
+ * Contains VHT information about this frame.
+ *
+ * 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_AMPDU_STATUS = 20,
+ IEEE80211_RADIOTAP_VHT = 21,
+ 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
+#define IEEE80211_RADIOTAP_MCS_NESS_KNOWN 0x40
+#define IEEE80211_RADIOTAP_MCS_NESS_BIT_1 0x80
+
+/* 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
+#define IEEE80211_RADIOTAP_MCS_NESS_BIT_0 0x80
+
+/* For IEEE80211_RADIOTAP_AMPDU_STATUS */
+#define IEEE80211_RADIOTAP_AMPDU_REPORT_ZEROLEN 0x0001
+#define IEEE80211_RADIOTAP_AMPDU_IS_ZEROLEN 0x0002
+#define IEEE80211_RADIOTAP_AMPDU_LAST_KNOWN 0x0004
+#define IEEE80211_RADIOTAP_AMPDU_IS_LAST 0x0008
+#define IEEE80211_RADIOTAP_AMPDU_DELIM_CRC_ERR 0x0010
+#define IEEE80211_RADIOTAP_AMPDU_DELIM_CRC_KNOWN 0x0020
+
+/* For IEEE80211_RADIOTAP_VHT known */
+#define IEEE80211_RADIOTAP_VHT_STBC_KNOWN 0x0001
+#define IEEE80211_RADIOTAP_VHT_TXOP_PS_NA_KNOWN 0x0002
+#define IEEE80211_RADIOTAP_VHT_GUARD_INTERVAL_KNOWN 0x0004
+#define IEEE80211_RADIOTAP_VHT_SGI_NSYM_DIS_KNOWN 0x0008
+#define IEEE80211_RADIOTAP_VHT_LDPC_EXTRA_OFDM_SYM_KNOWN 0x0010
+#define IEEE80211_RADIOTAP_VHT_BEAMFORMED_KNOWN 0x0020
+#define IEEE80211_RADIOTAP_VHT_BANDWIDTH_KNOWN 0x0040
+#define IEEE80211_RADIOTAP_VHT_GROUP_ID_KNOWN 0x0080
+#define IEEE80211_RADIOTAP_VHT_PARTIAL_AID_KNOWN 0x0100
+
+/* For IEEE80211_RADIOTAP_VHT flags */
+#define IEEE80211_RADIOTAP_VHT_STBC 0x01
+#define IEEE80211_RADIOTAP_VHT_TXOP_PS_NA 0x02
+#define IEEE80211_RADIOTAP_VHT_SHORT_GI 0x04
+#define IEEE80211_RADIOTAP_VHT_SGI_NSYM_M10_9 0x08
+#define IEEE80211_RADIOTAP_VHT_LDPC_EXTRA_OFDM_SYM 0x10
+#define IEEE80211_RADIOTAP_VHT_BEAMFORMED 0x20
+
+#define IEEE80211_RADIOTAP_VHT_BANDWIDTH_MASK 0x1f
+
+#define IEEE80211_RADIOTAP_VHT_NSS_MASK 0x0f
+#define IEEE80211_RADIOTAP_VHT_MCS_MASK 0xf0
+#define IEEE80211_RADIOTAP_VHT_MCS_SHIFT 4
+
+#define IEEE80211_RADIOTAP_CODING_LDPC_USERn 0x01
+
#define IEEE80211_CHAN_FHSS \
(IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_GFSK)
#define IEEE80211_CHAN_A \
@@ -2464,30 +2522,41 @@ ieee802_11_if_print(netdissect_options *ndo,
static void
print_chaninfo(netdissect_options *ndo,
- int freq, int flags)
+ uint16_t freq, int flags, int presentflags)
{
ND_PRINT((ndo, "%u MHz", freq));
- if (IS_CHAN_FHSS(flags))
- ND_PRINT((ndo, " FHSS"));
- if (IS_CHAN_A(flags)) {
- if (flags & IEEE80211_CHAN_HALF)
- ND_PRINT((ndo, " 11a/10Mhz"));
- else if (flags & IEEE80211_CHAN_QUARTER)
- ND_PRINT((ndo, " 11a/5Mhz"));
- else
- ND_PRINT((ndo, " 11a"));
+ if (presentflags & (1 << IEEE80211_RADIOTAP_MCS)) {
+ /*
+ * We have the MCS field, so this is 11n, regardless
+ * of what the channel flags say.
+ */
+ ND_PRINT((ndo, " 11n"));
+ } else {
+ if (IS_CHAN_FHSS(flags))
+ ND_PRINT((ndo, " FHSS"));
+ if (IS_CHAN_A(flags)) {
+ if (flags & IEEE80211_CHAN_HALF)
+ ND_PRINT((ndo, " 11a/10Mhz"));
+ else if (flags & IEEE80211_CHAN_QUARTER)
+ ND_PRINT((ndo, " 11a/5Mhz"));
+ else
+ ND_PRINT((ndo, " 11a"));
+ }
+ if (IS_CHAN_ANYG(flags)) {
+ if (flags & IEEE80211_CHAN_HALF)
+ ND_PRINT((ndo, " 11g/10Mhz"));
+ else if (flags & IEEE80211_CHAN_QUARTER)
+ ND_PRINT((ndo, " 11g/5Mhz"));
+ else
+ ND_PRINT((ndo, " 11g"));
+ } else if (IS_CHAN_B(flags))
+ ND_PRINT((ndo, " 11b"));
+ if (flags & IEEE80211_CHAN_TURBO)
+ ND_PRINT((ndo, " Turbo"));
}
- if (IS_CHAN_ANYG(flags)) {
- if (flags & IEEE80211_CHAN_HALF)
- ND_PRINT((ndo, " 11g/10Mhz"));
- else if (flags & IEEE80211_CHAN_QUARTER)
- ND_PRINT((ndo, " 11g/5Mhz"));
- else
- ND_PRINT((ndo, " 11g"));
- } else if (IS_CHAN_B(flags))
- ND_PRINT((ndo, " 11b"));
- if (flags & IEEE80211_CHAN_TURBO)
- ND_PRINT((ndo, " Turbo"));
+ /*
+ * These apply to 11n.
+ */
if (flags & IEEE80211_CHAN_HT20)
ND_PRINT((ndo, " ht/20"));
else if (flags & IEEE80211_CHAN_HT40D)
@@ -2499,146 +2568,50 @@ print_chaninfo(netdissect_options *ndo,
static int
print_radiotap_field(netdissect_options *ndo,
- struct cpack_state *s, uint32_t bit, uint8_t *flags,
- struct radiotap_state *state, uint32_t presentflags)
+ struct cpack_state *s, uint32_t bit, uint8_t *flagsp,
+ uint32_t presentflags)
{
- union {
- int8_t i8;
- uint8_t u8;
- int16_t i16;
- uint16_t u16;
- uint32_t u32;
- uint64_t u64;
- } u, u2, u3, u4;
+ u_int i;
int rc;
switch (bit) {
- case IEEE80211_RADIOTAP_FLAGS:
- rc = cpack_uint8(s, &u.u8);
- if (rc != 0)
- break;
- *flags = u.u8;
- break;
- case IEEE80211_RADIOTAP_RATE:
- rc = cpack_uint8(s, &u.u8);
- if (rc != 0)
- break;
- /* Save state rate */
- state->rate = u.u8;
- break;
- case IEEE80211_RADIOTAP_DB_ANTSIGNAL:
- case IEEE80211_RADIOTAP_DB_ANTNOISE:
- case IEEE80211_RADIOTAP_ANTENNA:
- rc = cpack_uint8(s, &u.u8);
- break;
- case IEEE80211_RADIOTAP_DBM_ANTSIGNAL:
- case IEEE80211_RADIOTAP_DBM_ANTNOISE:
- rc = cpack_int8(s, &u.i8);
- break;
- case IEEE80211_RADIOTAP_CHANNEL:
- rc = cpack_uint16(s, &u.u16);
- if (rc != 0)
- break;
- rc = cpack_uint16(s, &u2.u16);
- break;
- case IEEE80211_RADIOTAP_FHSS:
- case IEEE80211_RADIOTAP_LOCK_QUALITY:
- case IEEE80211_RADIOTAP_TX_ATTENUATION:
- case IEEE80211_RADIOTAP_RX_FLAGS:
- rc = cpack_uint16(s, &u.u16);
- break;
- case IEEE80211_RADIOTAP_DB_TX_ATTENUATION:
- rc = cpack_uint8(s, &u.u8);
- break;
- case IEEE80211_RADIOTAP_DBM_TX_POWER:
- rc = cpack_int8(s, &u.i8);
- break;
- case IEEE80211_RADIOTAP_TSFT:
- rc = cpack_uint64(s, &u.u64);
- break;
- case IEEE80211_RADIOTAP_XCHANNEL:
- rc = cpack_uint32(s, &u.u32);
- if (rc != 0)
- break;
- rc = cpack_uint16(s, &u2.u16);
- if (rc != 0)
- break;
- rc = cpack_uint8(s, &u3.u8);
- if (rc != 0)
- break;
- rc = cpack_uint8(s, &u4.u8);
- break;
- case IEEE80211_RADIOTAP_MCS:
- rc = cpack_uint8(s, &u.u8);
- if (rc != 0)
- break;
- rc = cpack_uint8(s, &u2.u8);
+ case IEEE80211_RADIOTAP_TSFT: {
+ uint64_t tsft;
+
+ rc = cpack_uint64(s, &tsft);
if (rc != 0)
- break;
- rc = cpack_uint8(s, &u3.u8);
+ goto trunc;
+ ND_PRINT((ndo, "%" PRIu64 "us tsft ", tsft));
break;
- case IEEE80211_RADIOTAP_VENDOR_NAMESPACE: {
- uint8_t vns[3];
- uint16_t length;
- uint8_t subspace;
-
- if ((cpack_align_and_reserve(s, 2)) == NULL) {
- rc = -1;
- break;
}
- rc = cpack_uint8(s, &vns[0]);
- if (rc != 0)
- break;
- rc = cpack_uint8(s, &vns[1]);
- if (rc != 0)
- break;
- rc = cpack_uint8(s, &vns[2]);
- if (rc != 0)
- break;
- rc = cpack_uint8(s, &subspace);
- if (rc != 0)
- break;
- rc = cpack_uint16(s, &length);
- if (rc != 0)
- break;
+ case IEEE80211_RADIOTAP_FLAGS: {
+ uint8_t flagsval;
- /* Skip up to length */
- s->c_next += length;
+ rc = cpack_uint8(s, &flagsval);
+ if (rc != 0)
+ goto trunc;
+ *flagsp = flagsval;
+ if (flagsval & IEEE80211_RADIOTAP_F_CFP)
+ ND_PRINT((ndo, "cfp "));
+ if (flagsval & IEEE80211_RADIOTAP_F_SHORTPRE)
+ ND_PRINT((ndo, "short preamble "));
+ if (flagsval & IEEE80211_RADIOTAP_F_WEP)
+ ND_PRINT((ndo, "wep "));
+ if (flagsval & IEEE80211_RADIOTAP_F_FRAG)
+ ND_PRINT((ndo, "fragmented "));
+ if (flagsval & IEEE80211_RADIOTAP_F_BADFCS)
+ ND_PRINT((ndo, "bad-fcs "));
break;
- }
- default:
- /* this bit indicates a field whose
- * size we do not know, so we cannot
- * proceed. Just print the bit number.
- */
- ND_PRINT((ndo, "[bit %u] ", bit));
- return -1;
- }
-
- if (rc != 0) {
- ND_PRINT((ndo, "%s", tstr));
- return rc;
- }
+ }
- /* Preserve the state present flags */
- state->present = presentflags;
+ case IEEE80211_RADIOTAP_RATE: {
+ uint8_t rate;
- switch (bit) {
- case IEEE80211_RADIOTAP_CHANNEL:
- /*
- * If CHANNEL and XCHANNEL are both present, skip
- * CHANNEL.
- */
- if (presentflags & (1 << IEEE80211_RADIOTAP_XCHANNEL))
- break;
- print_chaninfo(ndo, u.u16, u2.u16);
- break;
- case IEEE80211_RADIOTAP_FHSS:
- ND_PRINT((ndo, "fhset %d fhpat %d ", u.u16 & 0xff, (u.u16 >> 8) & 0xff));
- break;
- case IEEE80211_RADIOTAP_RATE:
+ rc = cpack_uint8(s, &rate);
+ if (rc != 0)
+ goto trunc;
/*
* XXX On FreeBSD rate & 0x80 means we have an MCS. On
* Linux and AirPcap it does not. (What about
@@ -2660,7 +2633,7 @@ print_radiotap_field(netdissect_options *ndo,
* setting. Such rates do exist, e.g. 11n
* MCS 7 at 20 MHz with a long guard interval.
*/
- if (u.u8 >= 0x80 && u.u8 <= 0x8f) {
+ if (rate >= 0x80 && rate <= 0x8f) {
/*
* XXX - we don't know the channel width
* or guard interval length, so we can't
@@ -2677,60 +2650,173 @@ print_radiotap_field(netdissect_options *ndo,
* information from Flags, at least on
* FreeBSD?
*/
- ND_PRINT((ndo, "MCS %u ", u.u8 & 0x7f));
+ ND_PRINT((ndo, "MCS %u ", rate & 0x7f));
} else
- ND_PRINT((ndo, "%2.1f Mb/s ", .5 * u.u8));
+ ND_PRINT((ndo, "%2.1f Mb/s ", .5 * rate));
break;
- case IEEE80211_RADIOTAP_DBM_ANTSIGNAL:
- ND_PRINT((ndo, "%ddB signal ", u.i8));
+ }
+
+ case IEEE80211_RADIOTAP_CHANNEL: {
+ uint16_t frequency;
+ uint16_t flags;
+
+ rc = cpack_uint16(s, &frequency);
+ if (rc != 0)
+ goto trunc;
+ rc = cpack_uint16(s, &flags);
+ if (rc != 0)
+ goto trunc;
+ /*
+ * If CHANNEL and XCHANNEL are both present, skip
+ * CHANNEL.
+ */
+ if (presentflags & (1 << IEEE80211_RADIOTAP_XCHANNEL))
+ break;
+ print_chaninfo(ndo, frequency, flags, presentflags);
break;
- case IEEE80211_RADIOTAP_DBM_ANTNOISE:
- ND_PRINT((ndo, "%ddB noise ", u.i8));
+ }
+
+ case IEEE80211_RADIOTAP_FHSS: {
+ uint8_t hopset;
+ uint8_t hoppat;
+
+ rc = cpack_uint8(s, &hopset);
+ if (rc != 0)
+ goto trunc;
+ rc = cpack_uint8(s, &hoppat);
+ if (rc != 0)
+ goto trunc;
+ ND_PRINT((ndo, "fhset %d fhpat %d ", hopset, hoppat));
break;
- case IEEE80211_RADIOTAP_DB_ANTSIGNAL:
- ND_PRINT((ndo, "%ddB signal ", u.u8));
+ }
+
+ case IEEE80211_RADIOTAP_DBM_ANTSIGNAL: {
+ int8_t dbm_antsignal;
+
+ rc = cpack_int8(s, &dbm_antsignal);
+ if (rc != 0)
+ goto trunc;
+ ND_PRINT((ndo, "%ddBm signal ", dbm_antsignal));
break;
- case IEEE80211_RADIOTAP_DB_ANTNOISE:
- ND_PRINT((ndo, "%ddB noise ", u.u8));
+ }
+
+ case IEEE80211_RADIOTAP_DBM_ANTNOISE: {
+ int8_t dbm_antnoise;
+
+ rc = cpack_int8(s, &dbm_antnoise);
+ if (rc != 0)
+ goto trunc;
+ ND_PRINT((ndo, "%ddBm noise ", dbm_antnoise));
break;
- case IEEE80211_RADIOTAP_LOCK_QUALITY:
- ND_PRINT((ndo, "%u sq ", u.u16));
+ }
+
+ case IEEE80211_RADIOTAP_LOCK_QUALITY: {
+ uint16_t lock_quality;
+
+ rc = cpack_uint16(s, &lock_quality);
+ if (rc != 0)
+ goto trunc;
+ ND_PRINT((ndo, "%u sq ", lock_quality));
break;
- case IEEE80211_RADIOTAP_TX_ATTENUATION:
- ND_PRINT((ndo, "%d tx power ", -(int)u.u16));
+ }
+
+ case IEEE80211_RADIOTAP_TX_ATTENUATION: {
+ uint16_t tx_attenuation;
+
+ rc = cpack_uint16(s, &tx_attenuation);
+ if (rc != 0)
+ goto trunc;
+ ND_PRINT((ndo, "%d tx power ", -(int)tx_attenuation));
break;
- case IEEE80211_RADIOTAP_DB_TX_ATTENUATION:
- ND_PRINT((ndo, "%ddB tx power ", -(int)u.u8));
+ }
+
+ case IEEE80211_RADIOTAP_DB_TX_ATTENUATION: {
+ uint8_t db_tx_attenuation;
+
+ rc = cpack_uint8(s, &db_tx_attenuation);
+ if (rc != 0)
+ goto trunc;
+ ND_PRINT((ndo, "%ddB tx attenuation ", -(int)db_tx_attenuation));
break;
- case IEEE80211_RADIOTAP_DBM_TX_POWER:
- ND_PRINT((ndo, "%ddBm tx power ", u.i8));
+ }
+
+ case IEEE80211_RADIOTAP_DBM_TX_POWER: {
+ int8_t dbm_tx_power;
+
+ rc = cpack_int8(s, &dbm_tx_power);
+ if (rc != 0)
+ goto trunc;
+ ND_PRINT((ndo, "%ddBm tx power ", dbm_tx_power));
break;
- case IEEE80211_RADIOTAP_FLAGS:
- if (u.u8 & IEEE80211_RADIOTAP_F_CFP)
- ND_PRINT((ndo, "cfp "));
- if (u.u8 & IEEE80211_RADIOTAP_F_SHORTPRE)
- ND_PRINT((ndo, "short preamble "));
- if (u.u8 & IEEE80211_RADIOTAP_F_WEP)
- ND_PRINT((ndo, "wep "));
- if (u.u8 & IEEE80211_RADIOTAP_F_FRAG)
- ND_PRINT((ndo, "fragmented "));
- if (u.u8 & IEEE80211_RADIOTAP_F_BADFCS)
- ND_PRINT((ndo, "bad-fcs "));
+ }
+
+ case IEEE80211_RADIOTAP_ANTENNA: {
+ uint8_t antenna;
+
+ rc = cpack_uint8(s, &antenna);
+ if (rc != 0)
+ goto trunc;
+ ND_PRINT((ndo, "antenna %u ", antenna));
break;
- case IEEE80211_RADIOTAP_ANTENNA:
- ND_PRINT((ndo, "antenna %d ", u.u8));
+ }
+
+ case IEEE80211_RADIOTAP_DB_ANTSIGNAL: {
+ uint8_t db_antsignal;
+
+ rc = cpack_uint8(s, &db_antsignal);
+ if (rc != 0)
+ goto trunc;
+ ND_PRINT((ndo, "%ddB signal ", db_antsignal));
break;
- case IEEE80211_RADIOTAP_TSFT:
- ND_PRINT((ndo, "%" PRIu64 "us tsft ", u.u64));
+ }
+
+ case IEEE80211_RADIOTAP_DB_ANTNOISE: {
+ uint8_t db_antnoise;
+
+ rc = cpack_uint8(s, &db_antnoise);
+ if (rc != 0)
+ goto trunc;
+ ND_PRINT((ndo, "%ddB noise ", db_antnoise));
break;
- case IEEE80211_RADIOTAP_RX_FLAGS:
+ }
+
+ case IEEE80211_RADIOTAP_RX_FLAGS: {
+ uint16_t rx_flags;
+
+ rc = cpack_uint16(s, &rx_flags);
+ if (rc != 0)
+ goto trunc;
/* Do nothing for now */
break;
- case IEEE80211_RADIOTAP_XCHANNEL:
- print_chaninfo(ndo, u2.u16, u.u32);
+ }
+
+ case IEEE80211_RADIOTAP_XCHANNEL: {
+ uint32_t flags;
+ uint16_t frequency;
+ uint8_t channel;
+ uint8_t maxpower;
+
+ rc = cpack_uint32(s, &flags);
+ if (rc != 0)
+ goto trunc;
+ rc = cpack_uint16(s, &frequency);
+ if (rc != 0)
+ goto trunc;
+ rc = cpack_uint8(s, &channel);
+ if (rc != 0)
+ goto trunc;
+ rc = cpack_uint8(s, &maxpower);
+ if (rc != 0)
+ goto trunc;
+ print_chaninfo(ndo, frequency, flags, presentflags);
break;
+ }
+
case IEEE80211_RADIOTAP_MCS: {
- static const char *bandwidth[4] = {
+ uint8_t known;
+ uint8_t flags;
+ uint8_t mcs_index;
+ static const char *ht_bandwidth[4] = {
"20 MHz",
"40 MHz",
"20 MHz (L)",
@@ -2738,15 +2824,24 @@ print_radiotap_field(netdissect_options *ndo,
};
float htrate;
- if (u.u8 & IEEE80211_RADIOTAP_MCS_MCS_INDEX_KNOWN) {
+ rc = cpack_uint8(s, &known);
+ if (rc != 0)
+ goto trunc;
+ rc = cpack_uint8(s, &flags);
+ if (rc != 0)
+ goto trunc;
+ rc = cpack_uint8(s, &mcs_index);
+ if (rc != 0)
+ goto trunc;
+ if (known & IEEE80211_RADIOTAP_MCS_MCS_INDEX_KNOWN) {
/*
* We know the MCS index.
*/
- if (u3.u8 <= MAX_MCS_INDEX) {
+ if (mcs_index <= MAX_MCS_INDEX) {
/*
* And it's in-range.
*/
- if (u.u8 & (IEEE80211_RADIOTAP_MCS_BANDWIDTH_KNOWN|IEEE80211_RADIOTAP_MCS_GUARD_INTERVAL_KNOWN)) {
+ if (known & (IEEE80211_RADIOTAP_MCS_BANDWIDTH_KNOWN|IEEE80211_RADIOTAP_MCS_GUARD_INTERVAL_KNOWN)) {
/*
* And we know both the bandwidth and
* the guard interval, so we can look
@@ -2754,9 +2849,9 @@ print_radiotap_field(netdissect_options *ndo,
*/
htrate =
ieee80211_float_htrates \
- [u3.u8] \
- [((u2.u8 & IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK) == IEEE80211_RADIOTAP_MCS_BANDWIDTH_40 ? 1 : 0)] \
- [((u2.u8 & IEEE80211_RADIOTAP_MCS_SHORT_GI) ? 1 : 0)];
+ [mcs_index] \
+ [((flags & IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK) == IEEE80211_RADIOTAP_MCS_BANDWIDTH_40 ? 1 : 0)] \
+ [((flags & IEEE80211_RADIOTAP_MCS_SHORT_GI) ? 1 : 0)];
} else {
/*
* We don't know both the bandwidth
@@ -2776,126 +2871,398 @@ print_radiotap_field(netdissect_options *ndo,
* We have the rate.
* Print it.
*/
- ND_PRINT((ndo, "%.1f Mb/s MCS %u ", htrate, u3.u8));
+ ND_PRINT((ndo, "%.1f Mb/s MCS %u ", htrate, mcs_index));
} else {
/*
* We at least have the MCS index.
* Print it.
*/
- ND_PRINT((ndo, "MCS %u ", u3.u8));
+ ND_PRINT((ndo, "MCS %u ", mcs_index));
}
}
- if (u.u8 & IEEE80211_RADIOTAP_MCS_BANDWIDTH_KNOWN) {
+ if (known & IEEE80211_RADIOTAP_MCS_BANDWIDTH_KNOWN) {
ND_PRINT((ndo, "%s ",
- bandwidth[u2.u8 & IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK]));
+ ht_bandwidth[flags & IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK]));
}
- if (u.u8 & IEEE80211_RADIOTAP_MCS_GUARD_INTERVAL_KNOWN) {
+ if (known & IEEE80211_RADIOTAP_MCS_GUARD_INTERVAL_KNOWN) {
ND_PRINT((ndo, "%s GI ",
- (u2.u8 & IEEE80211_RADIOTAP_MCS_SHORT_GI) ?
- "short" : "lon"));
+ (flags & IEEE80211_RADIOTAP_MCS_SHORT_GI) ?
+ "short" : "long"));
}
- if (u.u8 & IEEE80211_RADIOTAP_MCS_HT_FORMAT_KNOWN) {
+ if (known & IEEE80211_RADIOTAP_MCS_HT_FORMAT_KNOWN) {
ND_PRINT((ndo, "%s ",
- (u2.u8 & IEEE80211_RADIOTAP_MCS_HT_GREENFIELD) ?
+ (flags & IEEE80211_RADIOTAP_MCS_HT_GREENFIELD) ?
"greenfield" : "mixed"));
}
- if (u.u8 & IEEE80211_RADIOTAP_MCS_FEC_TYPE_KNOWN) {
+ if (known & IEEE80211_RADIOTAP_MCS_FEC_TYPE_KNOWN) {
ND_PRINT((ndo, "%s FEC ",
- (u2.u8 & IEEE80211_RADIOTAP_MCS_FEC_LDPC) ?
+ (flags & IEEE80211_RADIOTAP_MCS_FEC_LDPC) ?
"LDPC" : "BCC"));
}
- if (u.u8 & IEEE80211_RADIOTAP_MCS_STBC_KNOWN) {
+ if (known & IEEE80211_RADIOTAP_MCS_STBC_KNOWN) {
ND_PRINT((ndo, "RX-STBC%u ",
- (u2.u8 & IEEE80211_RADIOTAP_MCS_STBC_MASK) >> IEEE80211_RADIOTAP_MCS_STBC_SHIFT));
+ (flags & IEEE80211_RADIOTAP_MCS_STBC_MASK) >> IEEE80211_RADIOTAP_MCS_STBC_SHIFT));
+ }
+ break;
}
+ case IEEE80211_RADIOTAP_AMPDU_STATUS: {
+ uint32_t reference_num;
+ uint16_t flags;
+ uint8_t delim_crc;
+ uint8_t reserved;
+
+ rc = cpack_uint32(s, &reference_num);
+ if (rc != 0)
+ goto trunc;
+ rc = cpack_uint16(s, &flags);
+ if (rc != 0)
+ goto trunc;
+ rc = cpack_uint8(s, &delim_crc);
+ if (rc != 0)
+ goto trunc;
+ rc = cpack_uint8(s, &reserved);
+ if (rc != 0)
+ goto trunc;
+ /* Do nothing for now */
break;
}
+
+ case IEEE80211_RADIOTAP_VHT: {
+ uint16_t known;
+ uint8_t flags;
+ uint8_t bandwidth;
+ uint8_t mcs_nss[4];
+ uint8_t coding;
+ uint8_t group_id;
+ uint16_t partial_aid;
+ static const char *vht_bandwidth[32] = {
+ "20 MHz",
+ "40 MHz",
+ "20 MHz (L)",
+ "20 MHz (U)",
+ "80 MHz",
+ "80 MHz (L)",
+ "80 MHz (U)",
+ "80 MHz (LL)",
+ "80 MHz (LU)",
+ "80 MHz (UL)",
+ "80 MHz (UU)",
+ "160 MHz",
+ "160 MHz (L)",
+ "160 MHz (U)",
+ "160 MHz (LL)",
+ "160 MHz (LU)",
+ "160 MHz (UL)",
+ "160 MHz (UU)",
+ "160 MHz (LLL)",
+ "160 MHz (LLU)",
+ "160 MHz (LUL)",
+ "160 MHz (UUU)",
+ "160 MHz (ULL)",
+ "160 MHz (ULU)",
+ "160 MHz (UUL)",
+ "160 MHz (UUU)",
+ "unknown (26)",
+ "unknown (27)",
+ "unknown (28)",
+ "unknown (29)",
+ "unknown (30)",
+ "unknown (31)"
+ };
+
+ rc = cpack_uint16(s, &known);
+ if (rc != 0)
+ goto trunc;
+ rc = cpack_uint8(s, &flags);
+ if (rc != 0)
+ goto trunc;
+ rc = cpack_uint8(s, &bandwidth);
+ if (rc != 0)
+ goto trunc;
+ for (i = 0; i < 4; i++) {
+ rc = cpack_uint8(s, &mcs_nss[i]);
+ if (rc != 0)
+ goto trunc;
+ }
+ rc = cpack_uint8(s, &coding);
+ if (rc != 0)
+ goto trunc;
+ rc = cpack_uint8(s, &group_id);
+ if (rc != 0)
+ goto trunc;
+ rc = cpack_uint16(s, &partial_aid);
+ if (rc != 0)
+ goto trunc;
+ for (i = 0; i < 4; i++) {
+ u_int nss, mcs;
+ nss = mcs_nss[i] & IEEE80211_RADIOTAP_VHT_NSS_MASK;
+ mcs = (mcs_nss[i] & IEEE80211_RADIOTAP_VHT_MCS_MASK) >> IEEE80211_RADIOTAP_VHT_MCS_SHIFT;
+
+ if (nss == 0)
+ continue;
+
+ ND_PRINT((ndo, "User %u MCS %u ", i, mcs));
+ ND_PRINT((ndo, "%s FEC ",
+ (coding & (IEEE80211_RADIOTAP_CODING_LDPC_USERn << i)) ?
+ "LDPC" : "BCC"));
+ }
+ if (known & IEEE80211_RADIOTAP_VHT_BANDWIDTH_KNOWN) {
+ ND_PRINT((ndo, "%s ",
+ vht_bandwidth[bandwidth & IEEE80211_RADIOTAP_VHT_BANDWIDTH_MASK]));
+ }
+ if (known & IEEE80211_RADIOTAP_VHT_GUARD_INTERVAL_KNOWN) {
+ ND_PRINT((ndo, "%s GI ",
+ (flags & IEEE80211_RADIOTAP_VHT_SHORT_GI) ?
+ "short" : "long"));
+ }
+ break;
+ }
+
+ default:
+ /* this bit indicates a field whose
+ * size we do not know, so we cannot
+ * proceed. Just print the bit number.
+ */
+ ND_PRINT((ndo, "[bit %u] ", bit));
+ return -1;
}
+
return 0;
+
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return rc;
}
-static u_int
-ieee802_11_radio_print(netdissect_options *ndo,
- const u_char *p, u_int length, u_int caplen)
+
+static int
+print_in_radiotap_namespace(netdissect_options *ndo,
+ struct cpack_state *s, uint8_t *flags,
+ uint32_t presentflags, int bit0)
{
#define BITNO_32(x) (((x) >> 16) ? 16 + BITNO_16((x) >> 16) : BITNO_16((x)))
#define BITNO_16(x) (((x) >> 8) ? 8 + BITNO_8((x) >> 8) : BITNO_8((x)))
#define BITNO_8(x) (((x) >> 4) ? 4 + BITNO_4((x) >> 4) : BITNO_4((x)))
#define BITNO_4(x) (((x) >> 2) ? 2 + BITNO_2((x) >> 2) : BITNO_2((x)))
#define BITNO_2(x) (((x) & 2) ? 1 : 0)
+ uint32_t present, next_present;
+ int bitno;
+ enum ieee80211_radiotap_type bit;
+ int rc;
+
+ for (present = presentflags; present; present = next_present) {
+ /*
+ * Clear the least significant bit that is set.
+ */
+ next_present = present & (present - 1);
+
+ /*
+ * Get the bit number, within this presence word,
+ * of the remaining least significant bit that
+ * is set.
+ */
+ bitno = BITNO_32(present ^ next_present);
+
+ /*
+ * Stop if this is one of the "same meaning
+ * in all presence flags" bits.
+ */
+ if (bitno >= IEEE80211_RADIOTAP_NAMESPACE)
+ break;
+
+ /*
+ * Get the radiotap bit number of that bit.
+ */
+ bit = (enum ieee80211_radiotap_type)(bit0 + bitno);
+
+ rc = print_radiotap_field(ndo, s, bit, flags, presentflags);
+ if (rc != 0)
+ return rc;
+ }
+
+ return 0;
+}
+
+static u_int
+ieee802_11_radio_print(netdissect_options *ndo,
+ const u_char *p, u_int length, u_int caplen)
+{
#define BIT(n) (1U << n)
#define IS_EXTENDED(__p) \
(EXTRACT_LE_32BITS(__p) & BIT(IEEE80211_RADIOTAP_EXT)) != 0
struct cpack_state cpacker;
- struct ieee80211_radiotap_header *hdr;
- uint32_t present, next_present;
- uint32_t presentflags = 0;
- uint32_t *presentp, *last_presentp;
- enum ieee80211_radiotap_type bit;
+ const struct ieee80211_radiotap_header *hdr;
+ uint32_t presentflags;
+ const uint32_t *presentp, *last_presentp;
+ int vendor_namespace;
+ uint8_t vendor_oui[3];
+ uint8_t vendor_subnamespace;
+ uint16_t skip_length;
int bit0;
u_int len;
uint8_t flags;
int pad;
u_int fcslen;
- struct radiotap_state state;
if (caplen < sizeof(*hdr)) {
ND_PRINT((ndo, "%s", tstr));
return caplen;
}
- hdr = (struct ieee80211_radiotap_header *)p;
+ hdr = (const struct ieee80211_radiotap_header *)p;
len = EXTRACT_LE_16BITS(&hdr->it_len);
+ /*
+ * If we don't have the entire radiotap header, just give up.
+ */
if (caplen < len) {
ND_PRINT((ndo, "%s", tstr));
return caplen;
}
- cpack_init(&cpacker, (uint8_t *)hdr, len); /* align against header start */
+ cpack_init(&cpacker, (const 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;
+ (const u_char*)(last_presentp + 1) <= p + len &&
+ IS_EXTENDED(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)) {
+ if ((const u_char*)(last_presentp + 1) > p + len) {
ND_PRINT((ndo, "%s", tstr));
return caplen;
}
+ /*
+ * Start out at the beginning of the default radiotap namespace.
+ */
+ bit0 = 0;
+ vendor_namespace = 0;
+ memset(vendor_oui, 0, 3);
+ vendor_subnamespace = 0;
+ skip_length = 0;
/* Assume no flags */
flags = 0;
/* Assume no Atheros padding between 802.11 header and body */
pad = 0;
/* Assume no FCS at end of frame */
fcslen = 0;
- for (bit0 = 0, presentp = &hdr->it_present; presentp <= last_presentp;
- presentp++, bit0 += 32) {
+ for (presentp = &hdr->it_present; presentp <= last_presentp;
+ presentp++) {
presentflags = EXTRACT_LE_32BITS(presentp);
- /* Clear state. */
- memset(&state, 0, sizeof(state));
+ /*
+ * If this is a vendor namespace, we don't handle it.
+ */
+ if (vendor_namespace) {
+ /*
+ * Skip past the stuff we don't understand.
+ * If we add support for any vendor namespaces,
+ * it'd be added here; use vendor_oui and
+ * vendor_subnamespace to interpret the fields.
+ */
+ if (cpack_advance(&cpacker, skip_length) != 0) {
+ /*
+ * Ran out of space in the packet.
+ */
+ break;
+ }
+
+ /*
+ * We've skipped it all; nothing more to
+ * skip.
+ */
+ skip_length = 0;
+ } else {
+ if (print_in_radiotap_namespace(ndo, &cpacker,
+ &flags, presentflags, bit0) != 0) {
+ /*
+ * Fatal error - can't process anything
+ * more in the radiotap header.
+ */
+ break;
+ }
+ }
+
+ /*
+ * Handle the namespace switch bits; we've already handled
+ * the extension bit in all but the last word above.
+ */
+ switch (presentflags &
+ (BIT(IEEE80211_RADIOTAP_NAMESPACE)|BIT(IEEE80211_RADIOTAP_VENDOR_NAMESPACE))) {
+
+ case 0:
+ /*
+ * We're not changing namespaces.
+ * advance to the next 32 bits in the current
+ * namespace.
+ */
+ bit0 += 32;
+ break;
- for (present = EXTRACT_LE_32BITS(presentp); present;
- present = next_present) {
- /* clear the least significant bit that is set */
- next_present = present & (present - 1);
+ case BIT(IEEE80211_RADIOTAP_NAMESPACE):
+ /*
+ * We're switching to the radiotap namespace.
+ * Reset the presence-bitmap index to 0, and
+ * reset the namespace to the default radiotap
+ * namespace.
+ */
+ bit0 = 0;
+ vendor_namespace = 0;
+ memset(vendor_oui, 0, 3);
+ vendor_subnamespace = 0;
+ skip_length = 0;
+ break;
- /* extract the least significant bit that is set */
- bit = (enum ieee80211_radiotap_type)
- (bit0 + BITNO_32(present ^ next_present));
+ case BIT(IEEE80211_RADIOTAP_VENDOR_NAMESPACE):
+ /*
+ * We're switching to a vendor namespace.
+ * Reset the presence-bitmap index to 0,
+ * note that we're in a vendor namespace,
+ * and fetch the fields of the Vendor Namespace
+ * item.
+ */
+ bit0 = 0;
+ vendor_namespace = 1;
+ if ((cpack_align_and_reserve(&cpacker, 2)) == NULL) {
+ ND_PRINT((ndo, "%s", tstr));
+ break;
+ }
+ if (cpack_uint8(&cpacker, &vendor_oui[0]) != 0) {
+ ND_PRINT((ndo, "%s", tstr));
+ break;
+ }
+ if (cpack_uint8(&cpacker, &vendor_oui[1]) != 0) {
+ ND_PRINT((ndo, "%s", tstr));
+ break;
+ }
+ if (cpack_uint8(&cpacker, &vendor_oui[2]) != 0) {
+ ND_PRINT((ndo, "%s", tstr));
+ break;
+ }
+ if (cpack_uint8(&cpacker, &vendor_subnamespace) != 0) {
+ ND_PRINT((ndo, "%s", tstr));
+ break;
+ }
+ if (cpack_uint16(&cpacker, &skip_length) != 0) {
+ ND_PRINT((ndo, "%s", tstr));
+ break;
+ }
+ break;
- if (print_radiotap_field(ndo, &cpacker, bit, &flags, &state, presentflags) != 0)
- goto out;
+ default:
+ /*
+ * Illegal combination. The behavior in this
+ * case is undefined by the radiotap spec; we
+ * just ignore both bits.
+ */
+ break;
}
}
-out:
if (flags & IEEE80211_RADIOTAP_F_DATAPAD)
pad = 1; /* Atheros padding */
if (flags & IEEE80211_RADIOTAP_F_FCS)
diff --git a/print-802_15_4.c b/print-802_15_4.c
index 26c28ee652aa..6fe6d35b287f 100644
--- a/print-802_15_4.c
+++ b/print-802_15_4.c
@@ -20,14 +20,15 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: IEEE 802.15.4 printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
@@ -112,7 +113,7 @@ ieee802_15_4_if_print(netdissect_options *ndo,
if (ndo->ndo_vflag)
ND_PRINT((ndo,"seq %02x ", seq));
if (hdrlen == -1) {
- ND_PRINT((ndo,"malformed! "));
+ ND_PRINT((ndo,"invalid! "));
return caplen;
}
@@ -139,7 +140,7 @@ ieee802_15_4_if_print(netdissect_options *ndo,
case 0x03:
panid = EXTRACT_LE_16BITS(p);
p += 2;
- ND_PRINT((ndo,"%04x:%s ", panid, le64addr_string(p)));
+ ND_PRINT((ndo,"%04x:%s ", panid, le64addr_string(ndo, p)));
p += 8;
break;
}
@@ -165,7 +166,7 @@ ieee802_15_4_if_print(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(ndo, p)));
p += 8;
break;
}
diff --git a/print-ah.c b/print-ah.c
index 0badf48233bf..bec6f88f67d0 100644
--- a/print-ah.c
+++ b/print-ah.c
@@ -21,40 +21,40 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: IPSEC Authentication Header printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include "ah.h"
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
int
ah_print(netdissect_options *ndo, register const u_char *bp)
{
register const struct ah *ah;
- register const u_char *ep;
int sumlen;
- uint32_t spi;
ah = (const struct ah *)bp;
- ep = ndo->ndo_snapend; /* 'ep' points to the end of available data. */
ND_TCHECK(*ah);
sumlen = ah->ah_len << 2;
- spi = EXTRACT_32BITS(&ah->ah_spi);
- ND_PRINT((ndo, "AH(spi=0x%08x", spi));
+ ND_PRINT((ndo, "AH(spi=0x%08x", EXTRACT_32BITS(&ah->ah_spi)));
if (ndo->ndo_vflag)
ND_PRINT((ndo, ",sumlen=%d", sumlen));
+ ND_TCHECK_32BITS(ah + 1);
ND_PRINT((ndo, ",seq=0x%x", EXTRACT_32BITS(ah + 1)));
- if (bp + sizeof(struct ah) + sumlen > ep)
- ND_PRINT((ndo, "[truncated]"));
+ if (!ND_TTEST2(*bp, sizeof(struct ah) + sumlen)) {
+ ND_PRINT((ndo, "[truncated]):"));
+ return -1;
+ }
ND_PRINT((ndo, "): "));
return sizeof(struct ah) + sumlen;
diff --git a/print-ahcp.c b/print-ahcp.c
index a9ae38a97233..067b50694442 100644
--- a/print-ahcp.c
+++ b/print-ahcp.c
@@ -1,8 +1,4 @@
/*
- * 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.
*
@@ -29,19 +25,21 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: Ad Hoc Configuration Protocol (AHCP) printer */
+
+/* Based on draft-chroboczek-ahcp-00 and source code of ahcpd-0.53 */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.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
@@ -107,7 +105,7 @@ ahcp_time_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
char buf[BUFSIZE];
if (cp + 4 != ep)
- goto corrupt;
+ goto invalid;
ND_TCHECK2(*cp, 4);
t = EXTRACT_32BITS(cp);
if (NULL == (tm = gmtime(&t)))
@@ -118,8 +116,8 @@ ahcp_time_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
ND_PRINT((ndo, ": %s UTC", buf));
return 0;
-corrupt:
- ND_PRINT((ndo, ": %s", cstr));
+invalid:
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return 0;
trunc:
@@ -131,13 +129,13 @@ static int
ahcp_seconds_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
{
if (cp + 4 != ep)
- goto corrupt;
+ goto invalid;
ND_TCHECK2(*cp, 4);
ND_PRINT((ndo, ": %us", EXTRACT_32BITS(cp)));
return 0;
-corrupt:
- ND_PRINT((ndo, ": %s", cstr));
+invalid:
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return 0;
trunc:
@@ -152,20 +150,16 @@ ahcp_ipv6_addresses_print(netdissect_options *ndo, const u_char *cp, const u_cha
while (cp < ep) {
if (cp + 16 > ep)
- goto corrupt;
+ goto invalid;
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));
+invalid:
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return 0;
trunc:
@@ -180,7 +174,7 @@ ahcp_ipv4_addresses_print(netdissect_options *ndo, const u_char *cp, const u_cha
while (cp < ep) {
if (cp + 4 > ep)
- goto corrupt;
+ goto invalid;
ND_TCHECK2(*cp, 4);
ND_PRINT((ndo, "%s%s", sep, ipaddr_string(ndo, cp)));
cp += 4;
@@ -188,8 +182,8 @@ ahcp_ipv4_addresses_print(netdissect_options *ndo, const u_char *cp, const u_cha
}
return 0;
-corrupt:
- ND_PRINT((ndo, ": %s", cstr));
+invalid:
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return 0;
trunc:
@@ -204,20 +198,16 @@ ahcp_ipv6_prefixes_print(netdissect_options *ndo, const u_char *cp, const u_char
while (cp < ep) {
if (cp + 17 > ep)
- goto corrupt;
+ goto invalid;
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));
+invalid:
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return 0;
trunc:
@@ -232,7 +222,7 @@ ahcp_ipv4_prefixes_print(netdissect_options *ndo, const u_char *cp, const u_char
while (cp < ep) {
if (cp + 5 > ep)
- goto corrupt;
+ goto invalid;
ND_TCHECK2(*cp, 5);
ND_PRINT((ndo, "%s%s/%u", sep, ipaddr_string(ndo, cp), *(cp + 4)));
cp += 5;
@@ -240,8 +230,8 @@ ahcp_ipv4_prefixes_print(netdissect_options *ndo, const u_char *cp, const u_char
}
return 0;
-corrupt:
- ND_PRINT((ndo, ": %s", cstr));
+invalid:
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return 0;
trunc:
@@ -283,12 +273,12 @@ ahcp1_options_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
continue;
/* Length */
if (cp + 1 > ep)
- goto corrupt;
+ goto invalid;
ND_TCHECK2(*cp, 1);
option_len = *cp;
cp += 1;
if (cp + option_len > ep)
- goto corrupt;
+ goto invalid;
/* Value */
if (option_no <= AHCP1_OPT_MAX && data_decoders[option_no] != NULL) {
if (data_decoders[option_no](ndo, cp, cp + option_len) < 0)
@@ -301,8 +291,8 @@ ahcp1_options_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
}
return;
-corrupt:
- ND_PRINT((ndo, " %s", cstr));
+invalid:
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return;
trunc:
@@ -316,7 +306,7 @@ ahcp1_body_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
uint16_t body_len;
if (cp + AHCP1_BODY_MIN_LEN > ep)
- goto corrupt;
+ goto invalid;
/* Type */
ND_TCHECK2(*cp, 1);
type = *cp;
@@ -337,7 +327,7 @@ ahcp1_body_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
ND_PRINT((ndo, ", Length %u", body_len));
}
if (cp + body_len > ep)
- goto corrupt;
+ goto invalid;
/* Options */
if (ndo->ndo_vflag >= 2)
@@ -346,8 +336,8 @@ ahcp1_body_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
ND_TCHECK2(*cp, body_len);
return;
-corrupt:
- ND_PRINT((ndo, " %s", cstr));
+invalid:
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return;
trunc:
@@ -362,11 +352,11 @@ ahcp_print(netdissect_options *ndo, const u_char *cp, const u_int len)
ND_PRINT((ndo, "AHCP"));
if (len < 2)
- goto corrupt;
+ goto invalid;
/* Magic */
ND_TCHECK2(*cp, 1);
if (*cp != AHCP_MAGIC_NUMBER)
- goto corrupt;
+ goto invalid;
cp += 1;
/* Version */
ND_TCHECK2(*cp, 1);
@@ -376,7 +366,7 @@ ahcp_print(netdissect_options *ndo, const u_char *cp, const u_int len)
case AHCP_VERSION_1: {
ND_PRINT((ndo, " Version 1"));
if (len < AHCP1_HEADER_FIX_LEN)
- goto corrupt;
+ goto invalid;
if (!ndo->ndo_vflag) {
ND_TCHECK2(*cp, AHCP1_HEADER_FIX_LEN - 2);
cp += AHCP1_HEADER_FIX_LEN - 2;
@@ -412,8 +402,8 @@ ahcp_print(netdissect_options *ndo, const u_char *cp, const u_int len)
}
return;
-corrupt:
- ND_PRINT((ndo, " %s", cstr));
+invalid:
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return;
trunc:
diff --git a/print-aodv.c b/print-aodv.c
index ef27eee6bc2d..6cd0c9ea1b6d 100644
--- a/print-aodv.c
+++ b/print-aodv.c
@@ -30,16 +30,17 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: Ad hoc On-Demand Distance Vector (AODV) Routing printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
-#include "extract.h" /* must come after interface.h */
+#include "extract.h"
struct aodv_rreq {
@@ -53,7 +54,6 @@ struct aodv_rreq {
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 */
@@ -76,7 +76,6 @@ struct aodv_rreq6_draft_01 {
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 */
@@ -95,7 +94,6 @@ struct aodv_rrep {
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 */
@@ -116,7 +114,6 @@ struct aodv_rrep6_draft_01 {
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 */
@@ -127,7 +124,6 @@ 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 */
@@ -136,7 +132,6 @@ 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) */
@@ -275,7 +270,7 @@ aodv_rerr(netdissect_options *ndo, const u_char *dat, u_int length)
ND_PRINT((ndo, " rerr %s [items %u] [%u]:",
ap->rerr_flags & RERR_NODELETE ? "[D]" : "",
ap->rerr_dc, length));
- dp = (struct rerr_unreach *)(dat + sizeof(*ap));
+ dp = (const struct rerr_unreach *)(dat + sizeof(*ap));
i = length - sizeof(*ap);
for (dc = ap->rerr_dc; dc != 0; dc--) {
ND_TCHECK(*dp);
@@ -293,13 +288,8 @@ trunc:
}
static void
-#ifdef INET6
aodv_v6_rreq(netdissect_options *ndo, const u_char *dat, u_int length)
-#else
-aodv_v6_rreq(netdissect_options *ndo, const u_char *dat _U_, u_int length)
-#endif
{
-#ifdef INET6
u_int i;
const struct aodv_rreq6 *ap = (const struct aodv_rreq6 *)dat;
@@ -326,19 +316,11 @@ aodv_v6_rreq(netdissect_options *ndo, const u_char *dat _U_, u_int length)
trunc:
ND_PRINT((ndo, " [|rreq"));
-#else
- ND_PRINT((ndo, " v6 rreq %u", length));
-#endif
}
static void
-#ifdef INET6
aodv_v6_rrep(netdissect_options *ndo, const u_char *dat, u_int length)
-#else
-aodv_v6_rrep(netdissect_options *ndo, const u_char *dat _U_, u_int length)
-#endif
{
-#ifdef INET6
u_int i;
const struct aodv_rrep6 *ap = (const struct aodv_rrep6 *)dat;
@@ -362,19 +344,11 @@ aodv_v6_rrep(netdissect_options *ndo, const u_char *dat _U_, u_int length)
trunc:
ND_PRINT((ndo, " [|rreq"));
-#else
- ND_PRINT((ndo, " rrep %u", length));
-#endif
}
static void
-#ifdef INET6
aodv_v6_rerr(netdissect_options *ndo, const u_char *dat, u_int length)
-#else
-aodv_v6_rerr(netdissect_options *ndo, const u_char *dat _U_, u_int length)
-#endif
{
-#ifdef INET6
u_int i, dc;
const struct aodv_rerr *ap = (const struct aodv_rerr *)dat;
const struct rerr_unreach6 *dp6;
@@ -385,7 +359,7 @@ aodv_v6_rerr(netdissect_options *ndo, const u_char *dat _U_, u_int length)
ND_PRINT((ndo, " rerr %s [items %u] [%u]:",
ap->rerr_flags & RERR_NODELETE ? "[D]" : "",
ap->rerr_dc, length));
- dp6 = (struct rerr_unreach6 *)(void *)(ap + 1);
+ dp6 = (const struct rerr_unreach6 *)(const void *)(ap + 1);
i = length - sizeof(*ap);
for (dc = ap->rerr_dc; dc != 0; dc--) {
ND_TCHECK(*dp6);
@@ -400,19 +374,11 @@ aodv_v6_rerr(netdissect_options *ndo, const u_char *dat _U_, u_int length)
trunc:
ND_PRINT((ndo, "[|rerr]"));
-#else
- ND_PRINT((ndo, " rerr %u", length));
-#endif
}
static void
-#ifdef INET6
aodv_v6_draft_01_rreq(netdissect_options *ndo, const u_char *dat, u_int length)
-#else
-aodv_v6_draft_01_rreq(netdissect_options *ndo, const u_char *dat _U_, u_int length)
-#endif
{
-#ifdef INET6
u_int i;
const struct aodv_rreq6_draft_01 *ap = (const struct aodv_rreq6_draft_01 *)dat;
@@ -439,19 +405,11 @@ aodv_v6_draft_01_rreq(netdissect_options *ndo, const u_char *dat _U_, u_int leng
trunc:
ND_PRINT((ndo, " [|rreq"));
-#else
- ND_PRINT((ndo, " rreq %u", length));
-#endif
}
static void
-#ifdef INET6
aodv_v6_draft_01_rrep(netdissect_options *ndo, const u_char *dat, u_int length)
-#else
-aodv_v6_draft_01_rrep(netdissect_options *ndo, const u_char *dat _U_, u_int length)
-#endif
{
-#ifdef INET6
u_int i;
const struct aodv_rrep6_draft_01 *ap = (const struct aodv_rrep6_draft_01 *)dat;
@@ -475,19 +433,11 @@ aodv_v6_draft_01_rrep(netdissect_options *ndo, const u_char *dat _U_, u_int leng
trunc:
ND_PRINT((ndo, " [|rreq"));
-#else
- ND_PRINT((ndo, " rrep %u", length));
-#endif
}
static void
-#ifdef INET6
aodv_v6_draft_01_rerr(netdissect_options *ndo, const u_char *dat, u_int length)
-#else
-aodv_v6_draft_01_rerr(netdissect_options *ndo, const u_char *dat _U_, u_int length)
-#endif
{
-#ifdef INET6
u_int i, dc;
const struct aodv_rerr *ap = (const struct aodv_rerr *)dat;
const struct rerr_unreach6_draft_01 *dp6;
@@ -498,7 +448,7 @@ aodv_v6_draft_01_rerr(netdissect_options *ndo, const u_char *dat _U_, u_int leng
ND_PRINT((ndo, " rerr %s [items %u] [%u]:",
ap->rerr_flags & RERR_NODELETE ? "[D]" : "",
ap->rerr_dc, length));
- dp6 = (struct rerr_unreach6_draft_01 *)(void *)(ap + 1);
+ dp6 = (const struct rerr_unreach6_draft_01 *)(const void *)(ap + 1);
i = length - sizeof(*ap);
for (dc = ap->rerr_dc; dc != 0; dc--) {
ND_TCHECK(*dp6);
@@ -513,9 +463,6 @@ aodv_v6_draft_01_rerr(netdissect_options *ndo, const u_char *dat _U_, u_int leng
trunc:
ND_PRINT((ndo, "[|rerr]"));
-#else
- ND_PRINT((ndo, " rerr %u", length));
-#endif
}
void
diff --git a/print-aoe.c b/print-aoe.c
index f8bc1fc9b990..97e93df2eab5 100644
--- a/print-aoe.c
+++ b/print-aoe.c
@@ -1,8 +1,4 @@
/*
- * 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.
*
@@ -29,20 +25,22 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: ATA over Ethernet (AoE) protocol printer */
+
+/* specification: http://brantleycoilecompany.com/AoEr11.pdf */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.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
@@ -148,7 +146,7 @@ aoev1_issue_print(netdissect_options *ndo,
const u_char *ep = cp + len;
if (len < AOEV1_ISSUE_ARG_LEN)
- goto corrupt;
+ goto invalid;
/* AFlags */
ND_TCHECK2(*cp, 1);
ND_PRINT((ndo, "\n\tAFlags: [%s]", bittok2str(aoev1_aflag_str, "none", *cp)));
@@ -197,8 +195,8 @@ aoev1_issue_print(netdissect_options *ndo,
ND_PRINT((ndo, "\n\tData: %u bytes", len - AOEV1_ISSUE_ARG_LEN));
return;
-corrupt:
- ND_PRINT((ndo, "%s", cstr));
+invalid:
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return;
trunc:
@@ -213,7 +211,7 @@ aoev1_query_print(netdissect_options *ndo,
uint16_t cslen;
if (len < AOEV1_QUERY_ARG_LEN)
- goto corrupt;
+ goto invalid;
/* Buffer Count */
ND_TCHECK2(*cp, 2);
ND_PRINT((ndo, "\n\tBuffer Count: %u", EXTRACT_16BITS(cp)));
@@ -236,7 +234,7 @@ aoev1_query_print(netdissect_options *ndo,
cslen = EXTRACT_16BITS(cp);
cp += 2;
if (cslen > AOEV1_MAX_CONFSTR_LEN || AOEV1_QUERY_ARG_LEN + cslen > len)
- goto corrupt;
+ goto invalid;
/* Config String */
ND_TCHECK2(*cp, cslen);
if (cslen) {
@@ -246,8 +244,8 @@ aoev1_query_print(netdissect_options *ndo,
}
return;
-corrupt:
- ND_PRINT((ndo, "%s", cstr));
+invalid:
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return;
trunc:
@@ -262,7 +260,7 @@ aoev1_mac_print(netdissect_options *ndo,
uint8_t dircount, i;
if (len < AOEV1_MAC_ARG_LEN)
- goto corrupt;
+ goto invalid;
/* Reserved */
ND_TCHECK2(*cp, 1);
cp += 1;
@@ -280,7 +278,7 @@ aoev1_mac_print(netdissect_options *ndo,
cp += 1;
ND_PRINT((ndo, ", Dir Count: %u", dircount));
if (AOEV1_MAC_ARG_LEN + dircount * 8 > len)
- goto corrupt;
+ goto invalid;
/* directives */
for (i = 0; i < dircount; i++) {
/* Reserved */
@@ -297,8 +295,8 @@ aoev1_mac_print(netdissect_options *ndo,
}
return;
-corrupt:
- ND_PRINT((ndo, "%s", cstr));
+invalid:
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return;
trunc:
@@ -313,7 +311,7 @@ aoev1_reserve_print(netdissect_options *ndo,
uint8_t nmacs, i;
if (len < AOEV1_RESERVE_ARG_LEN || (len - AOEV1_RESERVE_ARG_LEN) % ETHER_ADDR_LEN)
- goto corrupt;
+ goto invalid;
/* RCmd */
ND_TCHECK2(*cp, 1);
ND_PRINT((ndo, "\n\tRCmd: %s", tok2str(aoev1_rcmd_str, "Unknown (0x%02x)", *cp)));
@@ -324,7 +322,7 @@ aoev1_reserve_print(netdissect_options *ndo,
cp += 1;
ND_PRINT((ndo, ", NMacs: %u", nmacs));
if (AOEV1_RESERVE_ARG_LEN + nmacs * ETHER_ADDR_LEN != len)
- goto corrupt;
+ goto invalid;
/* addresses */
for (i = 0; i < nmacs; i++) {
ND_PRINT((ndo, "\n\tEthernet Address %u: %s", i, etheraddr_string(ndo, cp)));
@@ -332,8 +330,8 @@ aoev1_reserve_print(netdissect_options *ndo,
}
return;
-corrupt:
- ND_PRINT((ndo, "%s", cstr));
+invalid:
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return;
trunc:
@@ -350,7 +348,7 @@ aoev1_print(netdissect_options *ndo,
void (*cmd_decoder)(netdissect_options *, const u_char *, const u_int);
if (len < AOEV1_COMMON_HDR_LEN)
- goto corrupt;
+ goto invalid;
/* Flags */
flags = *cp & 0x0F;
ND_PRINT((ndo, ", Flags: [%s]", bittok2str(aoev1_flag_str, "none", flags)));
@@ -390,8 +388,8 @@ aoev1_print(netdissect_options *ndo,
cmd_decoder(ndo, cp, len - AOEV1_COMMON_HDR_LEN);
return;
-corrupt:
- ND_PRINT((ndo, "%s", cstr));
+invalid:
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return;
trunc:
@@ -408,7 +406,7 @@ aoe_print(netdissect_options *ndo,
ND_PRINT((ndo, "AoE length %u", len));
if (len < 1)
- goto corrupt;
+ goto invalid;
/* Ver/Flags */
ND_TCHECK2(*cp, 1);
ver = (*cp & 0xF0) >> 4;
@@ -422,8 +420,8 @@ aoe_print(netdissect_options *ndo,
}
return;
-corrupt:
- ND_PRINT((ndo, "%s", cstr));
+invalid:
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return;
trunc:
diff --git a/print-ap1394.c b/print-ap1394.c
index 3befe2335bd0..79401cba0ef7 100644
--- a/print-ap1394.c
+++ b/print-ap1394.c
@@ -19,14 +19,15 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: Apple IP-over-IEEE 1394 printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
#include "ethertype.h"
@@ -48,6 +49,12 @@ struct firewire_header {
*/
#define FIREWIRE_HDRLEN 18
+static const char *
+fwaddr_string(netdissect_options *ndo, const u_char *addr)
+{
+ return (linkaddr_string(ndo, addr, LINKADDR_IEEE1394, FIREWIRE_EUI64_LEN));
+}
+
static inline void
ap1394_hdr_print(netdissect_options *ndo, register const u_char *bp, u_int length)
{
@@ -57,8 +64,8 @@ ap1394_hdr_print(netdissect_options *ndo, register const u_char *bp, u_int lengt
fp = (const struct firewire_header *)bp;
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)));
+ fwaddr_string(ndo, fp->firewire_shost),
+ fwaddr_string(ndo, fp->firewire_dhost)));
firewire_type = EXTRACT_16BITS(&fp->firewire_type);
if (!ndo->ndo_qflag) {
@@ -83,8 +90,9 @@ ap1394_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_ch
{
u_int length = h->len;
u_int caplen = h->caplen;
- struct firewire_header *fp;
+ const struct firewire_header *fp;
u_short ether_type;
+ struct lladdr_info src, dst;
if (caplen < FIREWIRE_HDRLEN) {
ND_PRINT((ndo, "[|ap1394]"));
@@ -96,14 +104,18 @@ ap1394_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_ch
length -= FIREWIRE_HDRLEN;
caplen -= FIREWIRE_HDRLEN;
- fp = (struct firewire_header *)p;
+ fp = (const struct firewire_header *)p;
p += FIREWIRE_HDRLEN;
ether_type = EXTRACT_16BITS(&fp->firewire_type);
- if (ethertype_print(ndo, ether_type, p, length, caplen) == 0) {
+ src.addr = fp->firewire_shost;
+ src.addr_string = fwaddr_string;
+ dst.addr = fp->firewire_dhost;
+ dst.addr_string = fwaddr_string;
+ if (ethertype_print(ndo, ether_type, p, length, caplen, &src, &dst) == 0) {
/* ether_type not known, print raw packet */
if (!ndo->ndo_eflag)
- ap1394_hdr_print(ndo, (u_char *)fp, length + FIREWIRE_HDRLEN);
+ ap1394_hdr_print(ndo, (const u_char *)fp, length + FIREWIRE_HDRLEN);
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
diff --git a/print-arcnet.c b/print-arcnet.c
index 0ffb9220709b..abc19b80704d 100644
--- a/print-arcnet.c
+++ b/print-arcnet.c
@@ -21,14 +21,15 @@
* From: NetBSD: print-arcnet.c,v 1.2 2000/04/24 13:02:28 itojun Exp
*/
-#define NETDISSECT_REWORKED
+/* \summary: Attached Resource Computer NETwork (ARCNET) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
/*
diff --git a/print-arp.c b/print-arp.c
index 76f39fe084a6..eff97c469074 100644
--- a/print-arp.c
+++ b/print-arp.c
@@ -19,20 +19,21 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: Address Resolution Protocol (ARP) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "ether.h"
#include "ethertype.h"
-#include "extract.h" /* must come after interface.h */
+#include "extract.h"
static const char tstr[] = "[|ARP]";
@@ -176,7 +177,17 @@ struct atmarp_pkthdr {
#define ATMTSA(ap) (aar_tsa(ap))
#define ATMTPA(ap) (aar_tpa(ap))
-static u_char ezero[6];
+static int
+isnonzero(const u_char *a, size_t len)
+{
+ while (len > 0) {
+ if (*a != 0)
+ return (1);
+ a++;
+ len--;
+ }
+ return (0);
+}
static void
atmarp_addr_print(netdissect_options *ndo,
@@ -357,7 +368,7 @@ arp_print(netdissect_options *ndo,
case ARPOP_REQUEST:
ND_PRINT((ndo, "who-has %s", ipaddr_string(ndo, TPA(ap))));
- if (memcmp((const char *)ezero, (const char *)THA(ap), HRD_LEN(ap)) != 0)
+ if (isnonzero((const u_char *)THA(ap), HRD_LEN(ap)))
ND_PRINT((ndo, " (%s)",
linkaddr_string(ndo, THA(ap), linkaddr, HRD_LEN(ap))));
ND_PRINT((ndo, " tell %s", ipaddr_string(ndo, SPA(ap))));
diff --git a/print-ascii.c b/print-ascii.c
index 3cefef33aeb4..4ef38a17a50d 100644
--- a/print-ascii.c
+++ b/print-ascii.c
@@ -36,15 +36,16 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: ASCII packet dump printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <stdio.h>
-#include "interface.h"
+#include "netdissect.h"
#define ASCII_LINELENGTH 300
#define HEXDUMP_BYTES_PER_LINE 16
diff --git a/print-atalk.c b/print-atalk.c
index 61405493d0ea..9d7d69d3d790 100644
--- a/print-atalk.c
+++ b/print-atalk.c
@@ -17,24 +17,23 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Format and print AppleTalk packets.
*/
-#define NETDISSECT_REWORKED
+/* \summary: AppleTalk printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <stdio.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "ethertype.h"
-#include "extract.h" /* must come after interface.h */
+#include "extract.h"
#include "appletalk.h"
static const char tstr[] = "[|atalk]";
@@ -78,7 +77,14 @@ u_int
ltalk_if_print(netdissect_options *ndo,
const struct pcap_pkthdr *h, const u_char *p)
{
- return (llap_print(ndo, p, h->caplen));
+ u_int hdrlen;
+
+ hdrlen = llap_print(ndo, p, h->len);
+ if (hdrlen == 0) {
+ /* Cut short by the snapshot length. */
+ return (h->caplen);
+ }
+ return (hdrlen);
}
/*
@@ -98,6 +104,10 @@ llap_print(netdissect_options *ndo,
ND_PRINT((ndo, " [|llap %u]", length));
return (length);
}
+ if (!ND_TTEST2(*bp, sizeof(*lp))) {
+ ND_PRINT((ndo, " [|llap]"));
+ return (0); /* cut short by the snapshot length */
+ }
lp = (const struct LAP *)bp;
bp += sizeof(*lp);
length -= sizeof(*lp);
@@ -109,6 +119,10 @@ llap_print(netdissect_options *ndo,
ND_PRINT((ndo, " [|sddp %u]", length));
return (length);
}
+ if (!ND_TTEST2(*bp, ddpSSize)) {
+ ND_PRINT((ndo, " [|sddp]"));
+ return (0); /* cut short by the snapshot length */
+ }
sdp = (const struct atShortDDP *)bp;
ND_PRINT((ndo, "%s.%s",
ataddr_string(ndo, 0, lp->src), ddpskt_string(ndo, sdp->srcSkt)));
@@ -125,6 +139,10 @@ llap_print(netdissect_options *ndo,
ND_PRINT((ndo, " [|ddp %u]", length));
return (length);
}
+ if (!ND_TTEST2(*bp, ddpSize)) {
+ ND_PRINT((ndo, " [|ddp]"));
+ return (0); /* cut short by the snapshot length */
+ }
dp = (const struct atDDP *)bp;
snet = EXTRACT_16BITS(&dp->srcNet);
ND_PRINT((ndo, "%s.%s", ataddr_string(ndo, snet, dp->srcNode),
@@ -171,6 +189,10 @@ atalk_print(netdissect_options *ndo,
ND_PRINT((ndo, " [|ddp %u]", length));
return;
}
+ if (!ND_TTEST2(*bp, ddpSize)) {
+ ND_PRINT((ndo, " [|ddp]"));
+ return;
+ }
dp = (const struct atDDP *)bp;
snet = EXTRACT_16BITS(&dp->srcNet);
ND_PRINT((ndo, "%s.%s", ataddr_string(ndo, snet, dp->srcNode),
@@ -194,6 +216,15 @@ aarp_print(netdissect_options *ndo,
ND_PRINT((ndo, "aarp "));
ap = (const struct aarp *)bp;
+ if (!ND_TTEST(*ap)) {
+ /* Just bail if we don't have the whole chunk. */
+ ND_PRINT((ndo, " [|aarp]"));
+ return;
+ }
+ if (length < sizeof(*ap)) {
+ ND_PRINT((ndo, " [|aarp %u]", length));
+ return;
+ }
if (EXTRACT_16BITS(&ap->htype) == 1 &&
EXTRACT_16BITS(&ap->ptype) == ETHERTYPE_ATALK &&
ap->halen == 6 && ap->palen == 4 )
@@ -380,7 +411,7 @@ nbp_print(netdissect_options *ndo,
register u_char snode, register u_char skt)
{
register const struct atNBPtuple *tp =
- (const struct atNBPtuple *)((u_char *)np + nbpHeaderSize);
+ (const struct atNBPtuple *)((const u_char *)np + nbpHeaderSize);
int i;
const u_char *ep;
@@ -567,8 +598,11 @@ ataddr_string(netdissect_options *ndo,
tp->nxt; tp = tp->nxt)
;
tp->addr = i2;
- tp->nxt = newhnamemem();
+ tp->nxt = newhnamemem(ndo);
tp->name = strdup(nambuf);
+ if (tp->name == NULL)
+ (*ndo->ndo_error)(ndo,
+ "ataddr_string: strdup(nambuf)");
}
fclose(fp);
}
@@ -582,20 +616,25 @@ ataddr_string(netdissect_options *ndo,
for (tp2 = &hnametable[i & (HASHNAMESIZE-1)]; tp2->nxt; tp2 = tp2->nxt)
if (tp2->addr == i) {
tp->addr = (atnet << 8) | athost;
- tp->nxt = newhnamemem();
+ tp->nxt = newhnamemem(ndo);
(void)snprintf(nambuf, sizeof(nambuf), "%s.%d",
tp2->name, athost);
tp->name = strdup(nambuf);
+ if (tp->name == NULL)
+ (*ndo->ndo_error)(ndo,
+ "ataddr_string: strdup(nambuf)");
return (tp->name);
}
tp->addr = (atnet << 8) | athost;
- tp->nxt = newhnamemem();
+ tp->nxt = newhnamemem(ndo);
if (athost != 255)
(void)snprintf(nambuf, sizeof(nambuf), "%d.%d", atnet, athost);
else
(void)snprintf(nambuf, sizeof(nambuf), "%d", atnet);
tp->name = strdup(nambuf);
+ if (tp->name == NULL)
+ (*ndo->ndo_error)(ndo, "ataddr_string: strdup(nambuf)");
return (tp->name);
}
diff --git a/print-atm.c b/print-atm.c
index 8faf715dac2d..596e406ccab6 100644
--- a/print-atm.c
+++ b/print-atm.c
@@ -19,20 +19,110 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: Asynchronous Transfer Mode (ATM) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
#include "atm.h"
-#include "atmuni31.h"
#include "llc.h"
+/* start of the original atmuni31.h */
+
+/*
+ * Copyright (c) 1997 Yen Yen Lim and North Dakota State University
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Yen Yen Lim and
+ North Dakota State University
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* Based on UNI3.1 standard by ATM Forum */
+
+/* ATM traffic types based on VPI=0 and (the following VCI */
+#define VCI_PPC 0x05 /* Point-to-point signal msg */
+#define VCI_BCC 0x02 /* Broadcast signal msg */
+#define VCI_OAMF4SC 0x03 /* Segment OAM F4 flow cell */
+#define VCI_OAMF4EC 0x04 /* End-to-end OAM F4 flow cell */
+#define VCI_METAC 0x01 /* Meta signal msg */
+#define VCI_ILMIC 0x10 /* ILMI msg */
+
+/* Q.2931 signalling messages */
+#define CALL_PROCEED 0x02 /* call proceeding */
+#define CONNECT 0x07 /* connect */
+#define CONNECT_ACK 0x0f /* connect_ack */
+#define SETUP 0x05 /* setup */
+#define RELEASE 0x4d /* release */
+#define RELEASE_DONE 0x5a /* release_done */
+#define RESTART 0x46 /* restart */
+#define RESTART_ACK 0x4e /* restart ack */
+#define STATUS 0x7d /* status */
+#define STATUS_ENQ 0x75 /* status ack */
+#define ADD_PARTY 0x80 /* add party */
+#define ADD_PARTY_ACK 0x81 /* add party ack */
+#define ADD_PARTY_REJ 0x82 /* add party rej */
+#define DROP_PARTY 0x83 /* drop party */
+#define DROP_PARTY_ACK 0x84 /* drop party ack */
+
+/* Information Element Parameters in the signalling messages */
+#define CAUSE 0x08 /* cause */
+#define ENDPT_REF 0x54 /* endpoint reference */
+#define AAL_PARA 0x58 /* ATM adaptation layer parameters */
+#define TRAFF_DESCRIP 0x59 /* atm traffic descriptors */
+#define CONNECT_ID 0x5a /* connection identifier */
+#define QOS_PARA 0x5c /* quality of service parameters */
+#define B_HIGHER 0x5d /* broadband higher layer information */
+#define B_BEARER 0x5e /* broadband bearer capability */
+#define B_LOWER 0x5f /* broadband lower information */
+#define CALLING_PARTY 0x6c /* calling party number */
+#define CALLED_PARTY 0x70 /* called party nmber */
+
+#define Q2931 0x09
+
+/* Q.2931 signalling general messages format */
+#define PROTO_POS 0 /* offset of protocol discriminator */
+#define CALL_REF_POS 2 /* offset of call reference value */
+#define MSG_TYPE_POS 5 /* offset of message type */
+#define MSG_LEN_POS 7 /* offset of mesage length */
+#define IE_BEGIN_POS 9 /* offset of first information element */
+
+/* format of signalling messages */
+#define TYPE_POS 0
+#define LEN_POS 2
+#define FIELD_BEGIN_POS 4
+
+/* end of the original atmuni31.h */
+
static const char tstr[] = "[|atm]";
#define OAM_CRC10_MASK 0x3ff
@@ -126,22 +216,20 @@ static const struct tok *oam_functype_values[16] = {
/*
* Print an RFC 1483 LLC-encapsulated ATM frame.
*/
-static void
+static u_int
atm_llc_print(netdissect_options *ndo,
const u_char *p, int length, int caplen)
{
- u_short extracted_ethertype;
-
- if (!llc_print(ndo, p, length, caplen, NULL, NULL,
- &extracted_ethertype)) {
- /* ether_type not known, print raw packet */
- if (extracted_ethertype) {
- ND_PRINT((ndo, "(LLC %s) ",
- etherproto_string(htons(extracted_ethertype))));
- }
+ int llc_hdrlen;
+
+ llc_hdrlen = llc_print(ndo, p, length, caplen, NULL, NULL);
+ if (llc_hdrlen < 0) {
+ /* packet not known, print raw packet */
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
+ llc_hdrlen = -llc_hdrlen;
}
+ return (llc_hdrlen);
}
/*
@@ -229,7 +317,7 @@ atm_if_print(netdissect_options *ndo,
caplen -= 20;
hdrlen += 20;
}
- atm_llc_print(ndo, p, length, caplen);
+ hdrlen += atm_llc_print(ndo, p, length, caplen);
return (hdrlen);
}
@@ -257,24 +345,18 @@ static const struct tok msgtype2str[] = {
static void
sig_print(netdissect_options *ndo,
- const u_char *p, int caplen)
+ const u_char *p)
{
uint32_t call_ref;
- if (caplen < PROTO_POS) {
- ND_PRINT((ndo, "%s", tstr));
- return;
- }
+ ND_TCHECK(p[PROTO_POS]);
if (p[PROTO_POS] == Q2931) {
/*
* protocol:Q.2931 for User to Network Interface
* (UNI 3.1) signalling
*/
ND_PRINT((ndo, "Q.2931"));
- if (caplen < MSG_TYPE_POS) {
- ND_PRINT((ndo, " %s", tstr));
- return;
- }
+ ND_TCHECK(p[MSG_TYPE_POS]);
ND_PRINT((ndo, ":%s ",
tok2str(msgtype2str, "msgtype#%d", p[MSG_TYPE_POS])));
@@ -290,6 +372,10 @@ sig_print(netdissect_options *ndo,
/* SCCOP with some unknown protocol atop it */
ND_PRINT((ndo, "SSCOP, proto %d ", p[PROTO_POS]));
}
+ return;
+
+trunc:
+ ND_PRINT((ndo, " %s", tstr));
}
/*
@@ -307,7 +393,7 @@ atm_print(netdissect_options *ndo,
switch (vci) {
case VCI_PPC:
- sig_print(ndo, p, caplen);
+ sig_print(ndo, p);
return;
case VCI_BCC:
@@ -360,7 +446,7 @@ struct oam_fm_ais_rdi_t {
uint8_t unused[28];
};
-int
+void
oam_print (netdissect_options *ndo,
const u_char *p, u_int length, u_int hec)
{
@@ -374,6 +460,7 @@ oam_print (netdissect_options *ndo,
} oam_ptr;
+ ND_TCHECK(*(p+ATM_HDR_LEN_NOHEC+hec));
cell_header = EXTRACT_32BITS(p+hec);
cell_type = ((*(p+ATM_HDR_LEN_NOHEC+hec))>>4) & 0x0f;
func_type = (*(p+ATM_HDR_LEN_NOHEC+hec)) & 0x0f;
@@ -390,7 +477,7 @@ oam_print (netdissect_options *ndo,
clp, length));
if (!ndo->ndo_vflag) {
- return 1;
+ return;
}
ND_PRINT((ndo, "\n\tcell-type %s (%u)",
@@ -409,6 +496,7 @@ oam_print (netdissect_options *ndo,
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);
+ ND_TCHECK(*oam_ptr.oam_fm_loopback);
ND_PRINT((ndo, "\n\tLoopback-Indicator %s, Correlation-Tag 0x%08x",
tok2str(oam_fm_loopback_indicator_values,
"Unknown",
@@ -431,6 +519,7 @@ oam_print (netdissect_options *ndo,
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);
+ ND_TCHECK(*oam_ptr.oam_fm_ais_rdi);
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++) {
@@ -449,6 +538,7 @@ oam_print (netdissect_options *ndo,
}
/* crc10 checksum verification */
+ ND_TCHECK2(*(p + OAM_CELLTYPE_FUNCTYPE_LEN + OAM_FUNCTION_SPECIFIC_LEN), 2);
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);
@@ -457,5 +547,9 @@ oam_print (netdissect_options *ndo,
cksum,
cksum_shouldbe == 0 ? "" : "in"));
- return 1;
+ return;
+
+trunc:
+ ND_PRINT((ndo, "[|oam]"));
+ return;
}
diff --git a/print-babel.c b/print-babel.c
index 75cb32cf19e9..f8741d7bfd19 100644
--- a/print-babel.c
+++ b/print-babel.c
@@ -26,17 +26,18 @@
* SUCH DAMAGE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: Babel Routing Protocol printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <stdio.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
@@ -53,7 +54,7 @@ babel_print(netdissect_options *ndo,
ND_TCHECK2(*cp, 4);
if(cp[0] != 42) {
- ND_PRINT((ndo, " malformed header"));
+ ND_PRINT((ndo, " invalid header"));
return;
} else {
ND_PRINT((ndo, " %d", cp[1]));
@@ -89,6 +90,9 @@ babel_print(netdissect_options *ndo,
#define MESSAGE_MH_REQUEST 10
#define MESSAGE_TSPC 11
#define MESSAGE_HMAC 12
+#define MESSAGE_UPDATE_SRC_SPECIFIC 13
+#define MESSAGE_REQUEST_SRC_SPECIFIC 14
+#define MESSAGE_MH_REQUEST_SRC_SPECIFIC 15
/* sub-TLVs */
#define MESSAGE_SUB_PAD1 0
@@ -123,11 +127,7 @@ format_prefix(netdissect_options *ndo, const u_char *prefix, unsigned char plen)
if(plen >= 96 && memcmp(prefix, v4prefix, 12) == 0)
snprintf(buf, 50, "%s/%u", ipaddr_string(ndo, prefix + 12), plen - 96);
else
-#ifdef INET6
snprintf(buf, 50, "%s/%u", ip6addr_string(ndo, prefix), plen);
-#else
- snprintf(buf, 50, "IPv6 addresses not supported");
-#endif
buf[49] = '\0';
return buf;
}
@@ -138,11 +138,7 @@ format_address(netdissect_options *ndo, const u_char *prefix)
if(memcmp(prefix, v4prefix, 12) == 0)
return ipaddr_string(ndo, prefix + 12);
else
-#ifdef INET6
return ip6addr_string(ndo, prefix);
-#else
- return "IPv6 addresses not supported";
-#endif
}
static const char *
@@ -284,10 +280,10 @@ subtlvs_print(netdissect_options *ndo,
continue;
}
if(cp == ep)
- goto corrupt;
+ goto invalid;
sublen = *cp++;
if(cp + sublen > ep)
- goto corrupt;
+ goto invalid;
switch(subtype) {
case MESSAGE_SUB_PADN:
@@ -305,19 +301,20 @@ subtlvs_print(netdissect_options *ndo,
ND_PRINT((ndo, "%s%s", sep, tok2str(diversity_str, "%u", *cp++)));
sep = "-";
}
- if(tlv_type != MESSAGE_UPDATE)
+ if(tlv_type != MESSAGE_UPDATE &&
+ tlv_type != MESSAGE_UPDATE_SRC_SPECIFIC)
ND_PRINT((ndo, " (bogus)"));
break;
case MESSAGE_SUB_TIMESTAMP:
ND_PRINT((ndo, " sub-timestamp"));
if(tlv_type == MESSAGE_HELLO) {
if(sublen < 4)
- goto corrupt;
+ goto invalid;
t1 = EXTRACT_32BITS(cp);
ND_PRINT((ndo, " %s", format_timestamp(t1)));
} else if(tlv_type == MESSAGE_IHU) {
if(sublen < 8)
- goto corrupt;
+ goto invalid;
t1 = EXTRACT_32BITS(cp);
ND_PRINT((ndo, " %s", format_timestamp(t1)));
t2 = EXTRACT_32BITS(cp + 4);
@@ -333,12 +330,12 @@ subtlvs_print(netdissect_options *ndo,
} /* while */
return;
- corrupt:
- ND_PRINT((ndo, " (corrupt)"));
+ invalid:
+ ND_PRINT((ndo, "%s", istr));
}
#define ICHECK(i, l) \
- if ((i) + (l) > bodylen || (i) + (l) > length) goto corrupt;
+ if ((i) + (l) > bodylen || (i) + (l) > length) goto invalid;
static void
babel_print_v2(netdissect_options *ndo,
@@ -352,7 +349,7 @@ babel_print_v2(netdissect_options *ndo,
ND_TCHECK2(*cp, 4);
if (length < 4)
- goto corrupt;
+ goto invalid;
bodylen = EXTRACT_16BITS(cp + 2);
ND_PRINT((ndo, " (%u)", bodylen));
@@ -393,7 +390,7 @@ babel_print_v2(netdissect_options *ndo,
ND_PRINT((ndo, " ack-req"));
else {
ND_PRINT((ndo, "\n\tAcknowledgment Request "));
- if(len < 6) goto corrupt;
+ if(len < 6) goto invalid;
nonce = EXTRACT_16BITS(message + 4);
interval = EXTRACT_16BITS(message + 6);
ND_PRINT((ndo, "%04x %s", nonce, format_interval(interval)));
@@ -407,7 +404,7 @@ babel_print_v2(netdissect_options *ndo,
ND_PRINT((ndo, " ack"));
else {
ND_PRINT((ndo, "\n\tAcknowledgment "));
- if(len < 2) goto corrupt;
+ if(len < 2) goto invalid;
nonce = EXTRACT_16BITS(message + 2);
ND_PRINT((ndo, "%04x", nonce));
}
@@ -420,7 +417,7 @@ babel_print_v2(netdissect_options *ndo,
ND_PRINT((ndo, " hello"));
else {
ND_PRINT((ndo, "\n\tHello "));
- if(len < 6) goto corrupt;
+ if(len < 6) goto invalid;
seqno = EXTRACT_16BITS(message + 4);
interval = EXTRACT_16BITS(message + 6);
ND_PRINT((ndo, "seqno %u interval %s", seqno, format_interval(interval)));
@@ -439,7 +436,7 @@ babel_print_v2(netdissect_options *ndo,
u_char address[16];
int rc;
ND_PRINT((ndo, "\n\tIHU "));
- if(len < 6) goto corrupt;
+ if(len < 6) goto invalid;
txcost = EXTRACT_16BITS(message + 4);
interval = EXTRACT_16BITS(message + 6);
rc = network_address(message[2], message + 8, len - 6, address);
@@ -459,7 +456,7 @@ babel_print_v2(netdissect_options *ndo,
ND_PRINT((ndo, " router-id"));
else {
ND_PRINT((ndo, "\n\tRouter Id"));
- if(len < 10) goto corrupt;
+ if(len < 10) goto invalid;
ND_PRINT((ndo, " %s", format_id(message + 4)));
}
}
@@ -472,9 +469,9 @@ babel_print_v2(netdissect_options *ndo,
int rc;
u_char nh[16];
ND_PRINT((ndo, "\n\tNext Hop"));
- if(len < 2) goto corrupt;
+ if(len < 2) goto invalid;
rc = network_address(message[2], message + 4, len - 2, nh);
- if(rc < 0) goto corrupt;
+ if(rc < 0) goto invalid;
ND_PRINT((ndo, " %s", format_address(ndo, nh)));
}
}
@@ -496,13 +493,13 @@ babel_print_v2(netdissect_options *ndo,
int rc;
u_char prefix[16];
ND_PRINT((ndo, "\n\tUpdate"));
- if(len < 10) goto corrupt;
+ if(len < 10) goto invalid;
plen = message[4] + (message[2] == 1 ? 96 : 0);
rc = network_prefix(message[2], message[4], message[5],
message + 12,
message[2] == 1 ? v4_prefix : v6_prefix,
len - 10, prefix);
- if(rc < 0) goto corrupt;
+ if(rc < 0) goto invalid;
interval = EXTRACT_16BITS(message + 6);
seqno = EXTRACT_16BITS(message + 8);
metric = EXTRACT_16BITS(message + 10);
@@ -532,11 +529,11 @@ babel_print_v2(netdissect_options *ndo,
int rc;
u_char prefix[16], plen;
ND_PRINT((ndo, "\n\tRequest "));
- if(len < 2) goto corrupt;
+ if(len < 2) goto invalid;
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;
+ if(rc < 0) goto invalid;
ND_PRINT((ndo, "for %s",
message[2] == 0 ? "any" : format_prefix(ndo, prefix, plen)));
}
@@ -551,11 +548,11 @@ babel_print_v2(netdissect_options *ndo,
u_short seqno;
u_char prefix[16], plen;
ND_PRINT((ndo, "\n\tMH-Request "));
- if(len < 14) goto corrupt;
+ if(len < 14) goto invalid;
seqno = EXTRACT_16BITS(message + 4);
rc = network_prefix(message[2], message[3], 0,
message + 16, NULL, len - 14, prefix);
- if(rc < 0) goto corrupt;
+ if(rc < 0) goto invalid;
plen = message[3] + (message[2] == 1 ? 96 : 0);
ND_PRINT((ndo, "(%u hops) for %s seqno %u id %s",
message[6], format_prefix(ndo, prefix, plen),
@@ -568,7 +565,7 @@ babel_print_v2(netdissect_options *ndo,
ND_PRINT((ndo, " tspc"));
else {
ND_PRINT((ndo, "\n\tTS/PC "));
- if(len < 6) goto corrupt;
+ if(len < 6) goto invalid;
ND_PRINT((ndo, "timestamp %u packetcounter %u", EXTRACT_32BITS (message + 4),
EXTRACT_16BITS(message + 2)));
}
@@ -579,13 +576,127 @@ babel_print_v2(netdissect_options *ndo,
else {
unsigned j;
ND_PRINT((ndo, "\n\tHMAC "));
- if(len < 18) goto corrupt;
+ if(len < 18) goto invalid;
ND_PRINT((ndo, "key-id %u digest-%u ", EXTRACT_16BITS(message + 2), len - 2));
for (j = 0; j < len - 2; j++)
ND_PRINT((ndo, "%02X", message[4 + j]));
}
}
break;
+
+ case MESSAGE_UPDATE_SRC_SPECIFIC : {
+ if(!ndo->ndo_vflag) {
+ ND_PRINT((ndo, " ss-update"));
+ } else {
+ u_char prefix[16], src_prefix[16];
+ u_short interval, seqno, metric;
+ u_char ae, plen, src_plen, omitted;
+ int rc;
+ int parsed_len = 10;
+ ND_PRINT((ndo, "\n\tSS-Update"));
+ if(len < 10) goto invalid;
+ ae = message[2];
+ src_plen = message[3];
+ plen = message[4];
+ omitted = message[5];
+ interval = EXTRACT_16BITS(message + 6);
+ seqno = EXTRACT_16BITS(message + 8);
+ metric = EXTRACT_16BITS(message + 10);
+ rc = network_prefix(ae, plen, omitted, message + 2 + parsed_len,
+ ae == 1 ? v4_prefix : v6_prefix,
+ len - parsed_len, prefix);
+ if(rc < 0) goto invalid;
+ if(ae == 1)
+ plen += 96;
+ parsed_len += rc;
+ rc = network_prefix(ae, src_plen, 0, message + 2 + parsed_len,
+ NULL, len - parsed_len, src_prefix);
+ if(rc < 0) goto invalid;
+ if(ae == 1)
+ src_plen += 96;
+ parsed_len += rc;
+
+ ND_PRINT((ndo, " %s from", format_prefix(ndo, prefix, plen)));
+ ND_PRINT((ndo, " %s metric %u seqno %u interval %s",
+ format_prefix(ndo, src_prefix, src_plen),
+ metric, seqno, format_interval_update(interval)));
+ /* extra data? */
+ if((u_int)parsed_len < len)
+ subtlvs_print(ndo, message + 2 + parsed_len,
+ message + 2 + len, type);
+ }
+ }
+ break;
+
+ case MESSAGE_REQUEST_SRC_SPECIFIC : {
+ if(!ndo->ndo_vflag)
+ ND_PRINT((ndo, " ss-request"));
+ else {
+ int rc, parsed_len = 3;
+ u_char ae, plen, src_plen, prefix[16], src_prefix[16];
+ ND_PRINT((ndo, "\n\tSS-Request "));
+ if(len < 3) goto invalid;
+ ae = message[2];
+ plen = message[3];
+ src_plen = message[4];
+ rc = network_prefix(ae, plen, 0, message + 2 + parsed_len,
+ NULL, len - parsed_len, prefix);
+ if(rc < 0) goto invalid;
+ if(ae == 1)
+ plen += 96;
+ parsed_len += rc;
+ rc = network_prefix(ae, src_plen, 0, message + 2 + parsed_len,
+ NULL, len - parsed_len, src_prefix);
+ if(rc < 0) goto invalid;
+ if(ae == 1)
+ src_plen += 96;
+ parsed_len += rc;
+ if(ae == 0) {
+ ND_PRINT((ndo, "for any"));
+ } else {
+ ND_PRINT((ndo, "for (%s, ", format_prefix(ndo, prefix, plen)));
+ ND_PRINT((ndo, "%s)", format_prefix(ndo, src_prefix, src_plen)));
+ }
+ }
+ }
+ break;
+
+ case MESSAGE_MH_REQUEST_SRC_SPECIFIC : {
+ if(!ndo->ndo_vflag)
+ ND_PRINT((ndo, " ss-mh-request"));
+ else {
+ int rc, parsed_len = 14;
+ u_short seqno;
+ u_char ae, plen, src_plen, prefix[16], src_prefix[16], hopc;
+ const u_char *router_id = NULL;
+ ND_PRINT((ndo, "\n\tSS-MH-Request "));
+ if(len < 14) goto invalid;
+ ae = message[2];
+ plen = message[3];
+ seqno = EXTRACT_16BITS(message + 4);
+ hopc = message[6];
+ src_plen = message[7];
+ router_id = message + 8;
+ rc = network_prefix(ae, plen, 0, message + 2 + parsed_len,
+ NULL, len - parsed_len, prefix);
+ if(rc < 0) goto invalid;
+ if(ae == 1)
+ plen += 96;
+ parsed_len += rc;
+ rc = network_prefix(ae, src_plen, 0, message + 2 + parsed_len,
+ NULL, len - parsed_len, src_prefix);
+ if(rc < 0) goto invalid;
+ if(ae == 1)
+ src_plen += 96;
+ ND_PRINT((ndo, "(%u hops) for (%s, ",
+ hopc, format_prefix(ndo, prefix, plen)));
+ ND_PRINT((ndo, "%s) seqno %u id %s",
+ format_prefix(ndo, src_prefix, src_plen),
+ seqno, format_id(router_id)));
+ }
+ }
+ break;
+
default:
if (!ndo->ndo_vflag)
ND_PRINT((ndo, " unknown"));
@@ -600,7 +711,7 @@ babel_print_v2(netdissect_options *ndo,
ND_PRINT((ndo, " %s", tstr));
return;
- corrupt:
- ND_PRINT((ndo, " (corrupt)"));
+ invalid:
+ ND_PRINT((ndo, "%s", istr));
return;
}
diff --git a/print-beep.c b/print-beep.c
index 7982feb5c362..ed502b96cabc 100644
--- a/print-beep.c
+++ b/print-beep.c
@@ -2,23 +2,24 @@
* Copyright (C) 2000, Richard Sharpe
*
* This software may be distributed either under the terms of the
- * BSD-style licence that accompanies tcpdump or under the GNU GPL
+ * BSD-style license that accompanies tcpdump or under the GNU GPL
* version 2 or later.
*
* print-beep.c
*
*/
-#define NETDISSECT_REWORKED
+/* \summary: Blocks Extensible Exchange Protocol (BEEP) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
/* Check for a string but not go beyond length
* Return TRUE on match, FALSE otherwise
diff --git a/print-bfd.c b/print-bfd.c
index f1c2ee8cea8f..ad0a4065c11f 100644
--- a/print-bfd.c
+++ b/print-bfd.c
@@ -13,14 +13,17 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#define NETDISSECT_REWORKED
+/* \summary: Bidirectional Forwarding Detection (BFD) printer */
+
+/* specification: RFC 5880 (for version 1) and RFC 5881 */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "udp.h"
@@ -46,12 +49,12 @@
*/
/*
- * Control packet, BFDv1, draft-ietf-bfd-base-02.txt
+ * Control packet, BFDv1, RFC 5880
*
* 0 1 2 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * |Vers | Diag |Sta|P|F|C|A|D|R| Detect Mult | Length |
+ * |Vers | Diag |Sta|P|F|C|A|D|M| Detect Mult | Length |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | My Discriminator |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -91,20 +94,37 @@ struct bfd_auth_header_t {
uint8_t auth_type;
uint8_t auth_len;
uint8_t auth_data;
+ uint8_t dummy; /* minimun 4 bytes */
+};
+
+enum auth_type {
+ AUTH_PASSWORD = 1,
+ AUTH_MD5 = 2,
+ AUTH_MET_MD5 = 3,
+ AUTH_SHA1 = 4,
+ AUTH_MET_SHA1 = 5
};
static const struct tok bfd_v1_authentication_values[] = {
- { 0, "Reserved" },
- { 1, "Simple Password" },
- { 2, "Keyed MD5" },
- { 3, "Meticulous Keyed MD5" },
- { 4, "Keyed SHA1" },
- { 5, "Meticulous Keyed SHA1" },
+ { AUTH_PASSWORD, "Simple Password" },
+ { AUTH_MD5, "Keyed MD5" },
+ { AUTH_MET_MD5, "Meticulous Keyed MD5" },
+ { AUTH_SHA1, "Keyed SHA1" },
+ { AUTH_MET_SHA1, "Meticulous Keyed SHA1" },
{ 0, NULL }
};
-#define BFD_EXTRACT_VERSION(x) (((x)&0xe0)>>5)
-#define BFD_EXTRACT_DIAG(x) ((x)&0x1f)
+enum auth_length {
+ AUTH_PASSWORD_FIELD_MIN_LEN = 4, /* header + password min: 3 + 1 */
+ AUTH_PASSWORD_FIELD_MAX_LEN = 19, /* header + password max: 3 + 16 */
+ AUTH_MD5_FIELD_LEN = 24,
+ AUTH_MD5_HASH_LEN = 16,
+ AUTH_SHA1_FIELD_LEN = 28,
+ AUTH_SHA1_HASH_LEN = 20
+};
+
+#define BFD_EXTRACT_VERSION(x) (((x)&0xe0)>>5)
+#define BFD_EXTRACT_DIAG(x) ((x)&0x1f)
static const struct tok bfd_port_values[] = {
{ BFD_CONTROL_PORT, "Control" },
@@ -112,7 +132,6 @@ static const struct tok bfd_port_values[] = {
{ 0, NULL }
};
-
static const struct tok bfd_diag_values[] = {
{ 0, "No Diagnostic" },
{ 1, "Control Detection Time Expired" },
@@ -127,14 +146,14 @@ static const struct tok bfd_diag_values[] = {
};
static const struct tok bfd_v0_flag_values[] = {
- { 0x80, "I Hear You" },
- { 0x40, "Demand" },
- { 0x20, "Poll" },
- { 0x10, "Final" },
- { 0x08, "Reserved" },
- { 0x04, "Reserved" },
- { 0x02, "Reserved" },
- { 0x01, "Reserved" },
+ { 0x80, "I Hear You" },
+ { 0x40, "Demand" },
+ { 0x20, "Poll" },
+ { 0x10, "Final" },
+ { 0x08, "Reserved" },
+ { 0x04, "Reserved" },
+ { 0x02, "Reserved" },
+ { 0x01, "Reserved" },
{ 0, NULL }
};
@@ -146,7 +165,7 @@ static const struct tok bfd_v1_flag_values[] = {
{ 0x08, "Control Plane Independent" },
{ BFD_FLAG_AUTH, "Authentication Present" },
{ 0x02, "Demand" },
- { 0x01, "Reserved" },
+ { 0x01, "Multipoint" },
{ 0, NULL }
};
@@ -158,12 +177,122 @@ static const struct tok bfd_v1_state_values[] = {
{ 0, NULL }
};
+static int
+auth_print(netdissect_options *ndo, register const u_char *pptr)
+{
+ const struct bfd_auth_header_t *bfd_auth_header;
+ int i;
+
+ pptr += sizeof (const struct bfd_header_t);
+ bfd_auth_header = (const struct bfd_auth_header_t *)pptr;
+ ND_TCHECK(*bfd_auth_header);
+ ND_PRINT((ndo, "\n\tAuthentication: %s (%u), length: %u",
+ tok2str(bfd_v1_authentication_values,"Unknown",bfd_auth_header->auth_type),
+ bfd_auth_header->auth_type,
+ bfd_auth_header->auth_len));
+ pptr += 2;
+ ND_PRINT((ndo, "\n\t Auth Key ID: %d", *pptr));
+
+ switch(bfd_auth_header->auth_type) {
+ case AUTH_PASSWORD:
+/*
+ * Simple Password Authentication Section Format
+ *
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Auth Type | Auth Len | Auth Key ID | Password... |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | ... |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+ if (bfd_auth_header->auth_len < AUTH_PASSWORD_FIELD_MIN_LEN ||
+ bfd_auth_header->auth_len > AUTH_PASSWORD_FIELD_MAX_LEN) {
+ ND_PRINT((ndo, "[invalid length %d]",
+ bfd_auth_header->auth_len));
+ break;
+ }
+ pptr++;
+ ND_PRINT((ndo, ", Password: "));
+ /* the length is equal to the password length plus three */
+ if (fn_printn(ndo, pptr, bfd_auth_header->auth_len - 3,
+ ndo->ndo_snapend))
+ goto trunc;
+ break;
+ case AUTH_MD5:
+ case AUTH_MET_MD5:
+/*
+ * Keyed MD5 and Meticulous Keyed MD5 Authentication Section Format
+ *
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Auth Type | Auth Len | Auth Key ID | Reserved |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Sequence Number |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Auth Key/Digest... |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | ... |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+ if (bfd_auth_header->auth_len != AUTH_MD5_FIELD_LEN) {
+ ND_PRINT((ndo, "[invalid length %d]",
+ bfd_auth_header->auth_len));
+ break;
+ }
+ pptr += 2;
+ ND_TCHECK2(*pptr, 4);
+ ND_PRINT((ndo, ", Sequence Number: 0x%08x", EXTRACT_32BITS(pptr)));
+ pptr += 4;
+ ND_TCHECK2(*pptr, AUTH_MD5_HASH_LEN);
+ ND_PRINT((ndo, "\n\t Digest: "));
+ for(i = 0; i < AUTH_MD5_HASH_LEN; i++)
+ ND_PRINT((ndo, "%02x", pptr[i]));
+ break;
+ case AUTH_SHA1:
+ case AUTH_MET_SHA1:
+/*
+ * Keyed SHA1 and Meticulous Keyed SHA1 Authentication Section Format
+ *
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Auth Type | Auth Len | Auth Key ID | Reserved |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Sequence Number |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Auth Key/Hash... |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | ... |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+ if (bfd_auth_header->auth_len != AUTH_SHA1_FIELD_LEN) {
+ ND_PRINT((ndo, "[invalid length %d]",
+ bfd_auth_header->auth_len));
+ break;
+ }
+ pptr += 2;
+ ND_TCHECK2(*pptr, 4);
+ ND_PRINT((ndo, ", Sequence Number: 0x%08x", EXTRACT_32BITS(pptr)));
+ pptr += 4;
+ ND_TCHECK2(*pptr, AUTH_SHA1_HASH_LEN);
+ ND_PRINT((ndo, "\n\t Hash: "));
+ for(i = 0; i < AUTH_SHA1_HASH_LEN; i++)
+ ND_PRINT((ndo, "%02x", pptr[i]));
+ break;
+ }
+ return 0;
+
+trunc:
+ return 1;
+}
+
void
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;
uint8_t version = 0;
bfd_header = (const struct bfd_header_t *)pptr;
@@ -244,13 +373,8 @@ bfd_print(netdissect_options *ndo, register const u_char *pptr,
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;
- 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));
+ if (auth_print(ndo, pptr))
+ goto trunc;
}
break;
diff --git a/print-bgp.c b/print-bgp.c
index c617c3bbbed3..79afeab4c759 100644
--- a/print-bgp.c
+++ b/print-bgp.c
@@ -30,17 +30,18 @@
* complete BGP support.
*/
-#define NETDISSECT_REWORKED
+/* \summary: Border Gateway Protocol (BGP) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <stdio.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
#include "af.h"
@@ -121,18 +122,25 @@ struct bgp_route_refresh {
#define BGPTYPE_ATOMIC_AGGREGATE 6
#define BGPTYPE_AGGREGATOR 7
#define BGPTYPE_COMMUNITIES 8 /* RFC1997 */
-#define BGPTYPE_ORIGINATOR_ID 9 /* RFC1998 */
-#define BGPTYPE_CLUSTER_LIST 10 /* RFC1998 */
-#define BGPTYPE_DPA 11 /* draft-ietf-idr-bgp-dpa */
-#define BGPTYPE_ADVERTISERS 12 /* RFC1863 */
-#define BGPTYPE_RCID_PATH 13 /* RFC1863 */
-#define BGPTYPE_MP_REACH_NLRI 14 /* RFC2283 */
-#define BGPTYPE_MP_UNREACH_NLRI 15 /* RFC2283 */
-#define BGPTYPE_EXTD_COMMUNITIES 16 /* draft-ietf-idr-bgp-ext-communities */
-#define BGPTYPE_AS4_PATH 17 /* RFC4893 */
-#define BGPTYPE_AGGREGATOR4 18 /* RFC4893 */
-#define BGPTYPE_PMSI_TUNNEL 22 /* draft-ietf-l3vpn-2547bis-mcast-bgp-02.txt */
-#define BGPTYPE_ATTR_SET 128 /* draft-marques-ppvpn-ibgp */
+#define BGPTYPE_ORIGINATOR_ID 9 /* RFC4456 */
+#define BGPTYPE_CLUSTER_LIST 10 /* RFC4456 */
+#define BGPTYPE_DPA 11 /* deprecated, draft-ietf-idr-bgp-dpa */
+#define BGPTYPE_ADVERTISERS 12 /* deprecated RFC1863 */
+#define BGPTYPE_RCID_PATH 13 /* deprecated RFC1863 */
+#define BGPTYPE_MP_REACH_NLRI 14 /* RFC4760 */
+#define BGPTYPE_MP_UNREACH_NLRI 15 /* RFC4760 */
+#define BGPTYPE_EXTD_COMMUNITIES 16 /* RFC4360 */
+#define BGPTYPE_AS4_PATH 17 /* RFC6793 */
+#define BGPTYPE_AGGREGATOR4 18 /* RFC6793 */
+#define BGPTYPE_PMSI_TUNNEL 22 /* RFC6514 */
+#define BGPTYPE_TUNNEL_ENCAP 23 /* RFC5512 */
+#define BGPTYPE_TRAFFIC_ENG 24 /* RFC5543 */
+#define BGPTYPE_IPV6_EXTD_COMMUNITIES 25 /* RFC5701 */
+#define BGPTYPE_AIGP 26 /* RFC7311 */
+#define BGPTYPE_PE_DISTINGUISHER_LABEL 27 /* RFC6514 */
+#define BGPTYPE_ENTROPY_LABEL 28 /* RFC6790 */
+#define BGPTYPE_LARGE_COMMUNITY 32 /* draft-ietf-idr-large-community-05 */
+#define BGPTYPE_ATTR_SET 128 /* RFC6368 */
#define BGP_MP_NLRI_MINSIZE 3 /* End of RIB Marker detection */
@@ -156,6 +164,13 @@ static const struct tok bgp_attr_values[] = {
{ BGPTYPE_MP_UNREACH_NLRI, "Multi-Protocol Unreach NLRI"},
{ BGPTYPE_EXTD_COMMUNITIES, "Extended Community"},
{ BGPTYPE_PMSI_TUNNEL, "PMSI Tunnel"},
+ { BGPTYPE_TUNNEL_ENCAP, "Tunnel Encapsulation"},
+ { BGPTYPE_TRAFFIC_ENG, "Traffic Engineering"},
+ { BGPTYPE_IPV6_EXTD_COMMUNITIES, "IPv6 Extended Community"},
+ { BGPTYPE_AIGP, "Accumulated IGP Metric"},
+ { BGPTYPE_PE_DISTINGUISHER_LABEL, "PE Distinguisher Label"},
+ { BGPTYPE_ENTROPY_LABEL, "Entropy Label"},
+ { BGPTYPE_LARGE_COMMUNITY, "Large Community"},
{ BGPTYPE_ATTR_SET, "Attribute Set"},
{ 255, "Reserved for development"},
{ 0, NULL}
@@ -188,28 +203,37 @@ static const struct tok bgp_as_path_segment_close_values[] = {
#define BGP_OPT_AUTH 1
#define BGP_OPT_CAP 2
-
static const struct tok bgp_opt_values[] = {
{ BGP_OPT_AUTH, "Authentication Information"},
{ BGP_OPT_CAP, "Capabilities Advertisement"},
{ 0, NULL}
};
-#define BGP_CAPCODE_MP 1
-#define BGP_CAPCODE_RR 2
-#define BGP_CAPCODE_ORF 3 /* XXX */
-#define BGP_CAPCODE_RESTART 64 /* draft-ietf-idr-restart-05 */
-#define BGP_CAPCODE_AS_NEW 65 /* XXX */
-#define BGP_CAPCODE_DYN_CAP 67 /* XXX */
+#define BGP_CAPCODE_MP 1 /* RFC2858 */
+#define BGP_CAPCODE_RR 2 /* RFC2918 */
+#define BGP_CAPCODE_ORF 3 /* RFC5291 */
+#define BGP_CAPCODE_MR 4 /* RFC3107 */
+#define BGP_CAPCODE_EXT_NH 5 /* RFC5549 */
+#define BGP_CAPCODE_RESTART 64 /* RFC4724 */
+#define BGP_CAPCODE_AS_NEW 65 /* RFC6793 */
+#define BGP_CAPCODE_DYN_CAP 67 /* draft-ietf-idr-dynamic-cap */
+#define BGP_CAPCODE_MULTISESS 68 /* draft-ietf-idr-bgp-multisession */
+#define BGP_CAPCODE_ADD_PATH 69 /* RFC7911 */
+#define BGP_CAPCODE_ENH_RR 70 /* draft-keyur-bgp-enhanced-route-refresh */
#define BGP_CAPCODE_RR_CISCO 128
static const struct tok bgp_capcode_values[] = {
{ BGP_CAPCODE_MP, "Multiprotocol Extensions"},
{ BGP_CAPCODE_RR, "Route Refresh"},
{ BGP_CAPCODE_ORF, "Cooperative Route Filtering"},
+ { BGP_CAPCODE_MR, "Multiple Routes to a Destination"},
+ { BGP_CAPCODE_EXT_NH, "Extended Next Hop Encoding"},
{ BGP_CAPCODE_RESTART, "Graceful Restart"},
{ BGP_CAPCODE_AS_NEW, "32-Bit AS Number"},
{ BGP_CAPCODE_DYN_CAP, "Dynamic Capability"},
+ { BGP_CAPCODE_MULTISESS, "Multisession BGP"},
+ { BGP_CAPCODE_ADD_PATH, "Multiple Paths"},
+ { BGP_CAPCODE_ENH_RR, "Enhanced Route Refresh"},
{ BGP_CAPCODE_RR_CISCO, "Route Refresh (Cisco)"},
{ 0, NULL}
};
@@ -279,6 +303,13 @@ static const struct tok bgp_notify_minor_update_values[] = {
{ 0, NULL}
};
+static const struct tok bgp_notify_minor_fsm_values[] = {
+ { 1, "In OpenSent State"},
+ { 2, "In OpenConfirm State"},
+ { 3, "In Established State"},
+ { 0, NULL }
+};
+
static const struct tok bgp_notify_minor_cap_values[] = {
{ 1, "Invalid Action Value" },
{ 2, "Invalid Capability Length" },
@@ -318,25 +349,34 @@ static const struct tok bgp_pmsi_flag_values[] = {
{ 0, NULL}
};
+#define BGP_AIGP_TLV 1
+
+static const struct tok bgp_aigp_values[] = {
+ { BGP_AIGP_TLV, "AIGP"},
+ { 0, NULL}
+};
/* Subsequent address family identifier, RFC2283 section 7 */
#define SAFNUM_RES 0
#define SAFNUM_UNICAST 1
#define SAFNUM_MULTICAST 2
-#define SAFNUM_UNIMULTICAST 3
+#define SAFNUM_UNIMULTICAST 3 /* deprecated now */
/* labeled BGP RFC3107 */
#define SAFNUM_LABUNICAST 4
-/* draft-ietf-l3vpn-2547bis-mcast-bgp-02.txt */
+/* RFC6514 */
#define SAFNUM_MULTICAST_VPN 5
-#define SAFNUM_TUNNEL 64 /* XXX */
-#define SAFNUM_VPLS 65 /* XXX */
-/* draft-nalawade-idr-mdt-safi-03 */
+/* draft-nalawade-kapoor-tunnel-safi */
+#define SAFNUM_TUNNEL 64
+/* RFC4761 */
+#define SAFNUM_VPLS 65
+/* RFC6037 */
#define SAFNUM_MDT 66
-/* Section 4.3.4 of draft-rosen-rfc2547bis-03.txt */
+/* RFC4364 */
#define SAFNUM_VPNUNICAST 128
+/* RFC6513 */
#define SAFNUM_VPNMULTICAST 129
-#define SAFNUM_VPNUNIMULTICAST 130
-/* draft-marques-ppvpn-rt-constrain-01.txt */
+#define SAFNUM_VPNUNIMULTICAST 130 /* deprecated now */
+/* RFC4684 */
#define SAFNUM_RT_ROUTING_INFO 132
#define BGP_VPN_RD_LEN 8
@@ -390,7 +430,6 @@ static const struct tok bgp_safi_values[] = {
#define BGP_EXT_COM_L2VPN_RT_0 0x000a /* L2VPN Identifier,Format AS(2bytes):AN(4bytes) */
#define BGP_EXT_COM_L2VPN_RT_1 0xF10a /* L2VPN Identifier,Format IP address:AN(2bytes) */
-
/* http://www.cisco.com/en/US/tech/tk436/tk428/technologies_tech_note09186a00801eb09a.shtml */
#define BGP_EXT_COM_EIGRP_GEN 0x8800
#define BGP_EXT_COM_EIGRP_METRIC_AS_DELAY 0x8801
@@ -454,7 +493,14 @@ static const struct tok bgp_extd_comm_ospf_rtype_values[] = {
{ 0, NULL },
};
-#define TOKBUFSIZE 128
+/* ADD-PATH Send/Receive field values */
+static const struct tok bgp_add_path_recvsend[] = {
+ { 1, "Receive" },
+ { 2, "Send" },
+ { 3, "Both" },
+ { 0, NULL },
+};
+
static char astostr[20];
/*
@@ -503,7 +549,7 @@ decode_prefix4(netdissect_options *ndo,
((u_char *)&addr)[plenbytes - 1] &=
((0xff00 >> (plen % 8)) & 0xff);
}
- snprintf(buf, buflen, "%s/%d", getname(ndo, (u_char *)&addr), plen);
+ snprintf(buf, buflen, "%s/%d", ipaddr_string(ndo, &addr), plen);
return 1 + plenbytes;
trunc:
@@ -553,7 +599,7 @@ decode_labeled_prefix4(netdissect_options *ndo,
}
/* the label may get offsetted by 4 bits so lets shift it right */
snprintf(buf, buflen, "%s/%d, label:%u %s",
- getname(ndo, (u_char *)&addr),
+ ipaddr_string(ndo, &addr),
plen,
EXTRACT_24BITS(pptr+1)>>4,
((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
@@ -586,12 +632,10 @@ bgp_vpn_ip_print(netdissect_options *ndo,
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 */
ND_TCHECK2(pptr[0], sizeof(struct in6_addr));
snprintf(pos, sizeof(addr), "%s", ip6addr_string(ndo, pptr));
break;
-#endif
default:
snprintf(pos, sizeof(addr), "bogus address length %u", addr_length);
break;
@@ -662,7 +706,6 @@ trunc:
return (total_length);
}
-
/* RDs and RTs share the same semantics
* we use bgp_vpn_rd_print for
* printing route targets inside a NLRI */
@@ -775,7 +818,7 @@ decode_labeled_vpn_prefix4(netdissect_options *ndo,
/* 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(ndo, pptr+4),
- getname(ndo, (u_char *)&addr),
+ ipaddr_string(ndo, &addr),
plen,
EXTRACT_24BITS(pptr+1)>>4,
((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
@@ -951,21 +994,21 @@ trunc:
* the buffer would have overflowed; again, set buflen to 0 in
* that case.
*/
-#define UPDATE_BUF_BUFLEN(buf, buflen, strlen) \
- if (strlen<0) \
+#define UPDATE_BUF_BUFLEN(buf, buflen, stringlen) \
+ if (stringlen<0) \
buflen=0; \
- else if ((u_int)strlen>buflen) \
+ else if ((u_int)stringlen>buflen) \
buflen=0; \
else { \
- buflen-=strlen; \
- buf+=strlen; \
+ buflen-=stringlen; \
+ buf+=stringlen; \
}
static int
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;
+ int plen,tlen,stringlen,tlv_type,tlv_len,ttlv_len;
ND_TCHECK2(pptr[0], 2);
plen=EXTRACT_16BITS(pptr);
@@ -979,12 +1022,11 @@ decode_labeled_vpn_l2(netdissect_options *ndo,
/* assume AD-only with RD, BGPNH */
ND_TCHECK2(pptr[0],12);
buf[0]='\0';
- strlen=snprintf(buf, buflen, "RD: %s, BGPNH: %s",
- bgp_vpn_rd_print(ndo, pptr),
- /* need something like getname(ndo, ) here */
- getname(ndo, pptr+8)
- );
- UPDATE_BUF_BUFLEN(buf, buflen, strlen);
+ stringlen=snprintf(buf, buflen, "RD: %s, BGPNH: %s",
+ bgp_vpn_rd_print(ndo, pptr),
+ ipaddr_string(ndo, pptr+8)
+ );
+ UPDATE_BUF_BUFLEN(buf, buflen, stringlen);
pptr+=12;
tlen-=12;
return plen;
@@ -994,12 +1036,12 @@ decode_labeled_vpn_l2(netdissect_options *ndo,
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(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 */
- UPDATE_BUF_BUFLEN(buf, buflen, strlen);
+ stringlen=snprintf(buf, buflen, "RD: %s, CE-ID: %u, Label-Block Offset: %u, Label Base %u",
+ 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 */
+ UPDATE_BUF_BUFLEN(buf, buflen, stringlen);
pptr+=15;
tlen-=15;
@@ -1016,27 +1058,27 @@ decode_labeled_vpn_l2(netdissect_options *ndo,
switch(tlv_type) {
case 1:
if (buflen!=0) {
- strlen=snprintf(buf,buflen, "\n\t\tcircuit status vector (%u) length: %u: 0x",
- tlv_type,
- tlv_len);
- UPDATE_BUF_BUFLEN(buf, buflen, strlen);
+ stringlen=snprintf(buf,buflen, "\n\t\tcircuit status vector (%u) length: %u: 0x",
+ tlv_type,
+ tlv_len);
+ UPDATE_BUF_BUFLEN(buf, buflen, stringlen);
}
ttlv_len=ttlv_len/8+1; /* how many bytes do we need to read ? */
while (ttlv_len>0) {
ND_TCHECK(pptr[0]);
if (buflen!=0) {
- strlen=snprintf(buf,buflen, "%02x",*pptr++);
- UPDATE_BUF_BUFLEN(buf, buflen, strlen);
+ stringlen=snprintf(buf,buflen, "%02x",*pptr++);
+ UPDATE_BUF_BUFLEN(buf, buflen, stringlen);
}
ttlv_len--;
}
break;
default:
if (buflen!=0) {
- strlen=snprintf(buf,buflen, "\n\t\tunknown TLV #%u, length: %u",
- tlv_type,
- tlv_len);
- UPDATE_BUF_BUFLEN(buf, buflen, strlen);
+ stringlen=snprintf(buf,buflen, "\n\t\tunknown TLV #%u, length: %u",
+ tlv_type,
+ tlv_len);
+ UPDATE_BUF_BUFLEN(buf, buflen, stringlen);
}
break;
}
@@ -1054,7 +1096,6 @@ trunc:
return -2;
}
-#ifdef INET6
int
decode_prefix6(netdissect_options *ndo,
const u_char *pd, u_int itemlen, char *buf, u_int buflen)
@@ -1078,7 +1119,7 @@ decode_prefix6(netdissect_options *ndo,
addr.s6_addr[plenbytes - 1] &=
((0xff00 >> (plen % 8)) & 0xff);
}
- snprintf(buf, buflen, "%s/%d", getname6(ndo, (u_char *)&addr), plen);
+ snprintf(buf, buflen, "%s/%d", ip6addr_string(ndo, &addr), plen);
return 1 + plenbytes;
trunc:
@@ -1119,7 +1160,7 @@ decode_labeled_prefix6(netdissect_options *ndo,
}
/* the label may get offsetted by 4 bits so lets shift it right */
snprintf(buf, buflen, "%s/%d, label:%u %s",
- getname6(ndo, (u_char *)&addr),
+ ip6addr_string(ndo, &addr),
plen,
EXTRACT_24BITS(pptr+1)>>4,
((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
@@ -1161,7 +1202,7 @@ decode_labeled_vpn_prefix6(netdissect_options *ndo,
/* 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(ndo, pptr+4),
- getname6(ndo, (u_char *)&addr),
+ ip6addr_string(ndo, &addr),
plen,
EXTRACT_24BITS(pptr+1)>>4,
((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
@@ -1171,7 +1212,6 @@ decode_labeled_vpn_prefix6(netdissect_options *ndo,
trunc:
return -2;
}
-#endif
static int
decode_clnp_prefix(netdissect_options *ndo,
@@ -1194,7 +1234,7 @@ decode_clnp_prefix(netdissect_options *ndo,
((0xff00 >> (plen % 8)) & 0xff);
}
snprintf(buf, buflen, "%s/%d",
- isonsap_string(addr,(plen + 7) / 8),
+ isonsap_string(ndo, addr,(plen + 7) / 8),
plen);
return 1 + (plen + 7) / 8;
@@ -1231,7 +1271,7 @@ decode_labeled_vpn_clnp_prefix(netdissect_options *ndo,
/* 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(ndo, pptr+4),
- isonsap_string(addr,(plen + 7) / 8),
+ isonsap_string(ndo, addr,(plen + 7) / 8),
plen,
EXTRACT_24BITS(pptr+1)>>4,
((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
@@ -1315,7 +1355,6 @@ bgp_attr_print(netdissect_options *ndo,
u_int tlen;
const u_char *tptr;
char buf[MAXHOSTNAMELEN + 100];
- char tokbuf[TOKBUFSIZE];
int as_size;
tptr = pptr;
@@ -1327,14 +1366,12 @@ bgp_attr_print(netdissect_options *ndo,
ND_PRINT((ndo, "invalid len"));
else {
ND_TCHECK(*tptr);
- ND_PRINT((ndo, "%s", tok2strbuf(bgp_origin_values,
+ ND_PRINT((ndo, "%s", tok2str(bgp_origin_values,
"Unknown Origin Typecode",
- tptr[0],
- tokbuf, sizeof(tokbuf))));
+ tptr[0])));
}
break;
-
/*
* Process AS4 byte path and AS2 byte path attributes here.
*/
@@ -1361,9 +1398,8 @@ bgp_attr_print(netdissect_options *ndo,
while (tptr < pptr + len) {
ND_TCHECK(tptr[0]);
- ND_PRINT((ndo, "%s", tok2strbuf(bgp_as_path_segment_open_values,
- "?", tptr[0],
- tokbuf, sizeof(tokbuf))));
+ ND_PRINT((ndo, "%s", tok2str(bgp_as_path_segment_open_values,
+ "?", tptr[0])));
for (i = 0; i < tptr[1] * as_size; i += as_size) {
ND_TCHECK2(tptr[2 + i], as_size);
ND_PRINT((ndo, "%s ",
@@ -1373,9 +1409,8 @@ bgp_attr_print(netdissect_options *ndo,
EXTRACT_32BITS(&tptr[2 + i]))));
}
ND_TCHECK(tptr[0]);
- ND_PRINT((ndo, "%s", tok2strbuf(bgp_as_path_segment_close_values,
- "?", tptr[0],
- tokbuf, sizeof(tokbuf))));
+ ND_PRINT((ndo, "%s", tok2str(bgp_as_path_segment_close_values,
+ "?", tptr[0])));
ND_TCHECK(tptr[1]);
tptr += 2 + tptr[1] * as_size;
}
@@ -1385,7 +1420,7 @@ bgp_attr_print(netdissect_options *ndo,
ND_PRINT((ndo, "invalid len"));
else {
ND_TCHECK2(tptr[0], 4);
- ND_PRINT((ndo, "%s", getname(ndo, tptr)));
+ ND_PRINT((ndo, "%s", ipaddr_string(ndo, tptr)));
}
break;
case BGPTYPE_MULTI_EXIT_DISC:
@@ -1415,11 +1450,11 @@ bgp_attr_print(netdissect_options *ndo,
if (len == 6) {
ND_PRINT((ndo, " AS #%s, origin %s",
as_printf(ndo, astostr, sizeof(astostr), EXTRACT_16BITS(tptr)),
- getname(ndo, tptr + 2)));
+ ipaddr_string(ndo, tptr + 2)));
} else {
ND_PRINT((ndo, " AS #%s, origin %s",
as_printf(ndo, astostr, sizeof(astostr),
- EXTRACT_32BITS(tptr)), getname(ndo, tptr + 4)));
+ EXTRACT_32BITS(tptr)), ipaddr_string(ndo, tptr + 4)));
}
break;
case BGPTYPE_AGGREGATOR4:
@@ -1430,7 +1465,7 @@ bgp_attr_print(netdissect_options *ndo,
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)));
+ ipaddr_string(ndo, tptr + 4)));
break;
case BGPTYPE_COMMUNITIES:
if (len % 4) {
@@ -1468,7 +1503,7 @@ bgp_attr_print(netdissect_options *ndo,
break;
}
ND_TCHECK2(tptr[0], 4);
- ND_PRINT((ndo, "%s",getname(ndo, tptr)));
+ ND_PRINT((ndo, "%s",ipaddr_string(ndo, tptr)));
break;
case BGPTYPE_CLUSTER_LIST:
if (len % 4) {
@@ -1478,7 +1513,7 @@ bgp_attr_print(netdissect_options *ndo,
while (tlen>0) {
ND_TCHECK2(tptr[0], 4);
ND_PRINT((ndo, "%s%s",
- getname(ndo, tptr),
+ ipaddr_string(ndo, tptr),
(tlen>4) ? ", " : ""));
tlen -=4;
tptr +=4;
@@ -1490,12 +1525,10 @@ bgp_attr_print(netdissect_options *ndo,
safi = tptr[2];
ND_PRINT((ndo, "\n\t AFI: %s (%u), %sSAFI: %s (%u)",
- tok2strbuf(af_values, "Unknown AFI", af,
- tokbuf, sizeof(tokbuf)),
+ tok2str(af_values, "Unknown AFI", af),
af,
(safi>128) ? "vendor specific " : "", /* 128 is meanwhile wellknown */
- tok2strbuf(bgp_safi_values, "Unknown SAFI", safi,
- tokbuf, sizeof(tokbuf)),
+ tok2str(bgp_safi_values, "Unknown SAFI", safi),
safi));
switch(af<<8 | safi) {
@@ -1509,7 +1542,6 @@ bgp_attr_print(netdissect_options *ndo,
case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST):
case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN):
case (AFNUM_INET<<8 | SAFNUM_MDT):
-#ifdef INET6
case (AFNUM_INET6<<8 | SAFNUM_UNICAST):
case (AFNUM_INET6<<8 | SAFNUM_MULTICAST):
case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST):
@@ -1517,7 +1549,6 @@ bgp_attr_print(netdissect_options *ndo,
case (AFNUM_INET6<<8 | SAFNUM_VPNUNICAST):
case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST):
case (AFNUM_INET6<<8 | SAFNUM_VPNUNIMULTICAST):
-#endif
case (AFNUM_NSAP<<8 | SAFNUM_UNICAST):
case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST):
case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST):
@@ -1565,7 +1596,7 @@ bgp_attr_print(netdissect_options *ndo,
tlen = 0;
} else {
ND_TCHECK2(tptr[0], sizeof(struct in_addr));
- ND_PRINT((ndo, "%s",getname(ndo, tptr)));
+ ND_PRINT((ndo, "%s",ipaddr_string(ndo, tptr)));
tlen -= sizeof(struct in_addr);
tptr += sizeof(struct in_addr);
}
@@ -1580,12 +1611,11 @@ bgp_attr_print(netdissect_options *ndo,
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)));
+ ipaddr_string(ndo, tptr+BGP_VPN_RD_LEN)));
tlen -= (sizeof(struct in_addr)+BGP_VPN_RD_LEN);
tptr += (sizeof(struct in_addr)+BGP_VPN_RD_LEN);
}
break;
-#ifdef INET6
case (AFNUM_INET6<<8 | SAFNUM_UNICAST):
case (AFNUM_INET6<<8 | SAFNUM_MULTICAST):
case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST):
@@ -1595,7 +1625,7 @@ bgp_attr_print(netdissect_options *ndo,
tlen = 0;
} else {
ND_TCHECK2(tptr[0], sizeof(struct in6_addr));
- ND_PRINT((ndo, "%s", getname6(ndo, tptr)));
+ ND_PRINT((ndo, "%s", ip6addr_string(ndo, tptr)));
tlen -= sizeof(struct in6_addr);
tptr += sizeof(struct in6_addr);
}
@@ -1610,12 +1640,11 @@ bgp_attr_print(netdissect_options *ndo,
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)));
+ ip6addr_string(ndo, tptr+BGP_VPN_RD_LEN)));
tlen -= (sizeof(struct in6_addr)+BGP_VPN_RD_LEN);
tptr += (sizeof(struct in6_addr)+BGP_VPN_RD_LEN);
}
break;
-#endif
case (AFNUM_VPLS<<8 | SAFNUM_VPLS):
case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST):
case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST):
@@ -1625,7 +1654,7 @@ bgp_attr_print(netdissect_options *ndo,
tlen = 0;
} else {
ND_TCHECK2(tptr[0], sizeof(struct in_addr));
- ND_PRINT((ndo, "%s", getname(ndo, tptr)));
+ ND_PRINT((ndo, "%s", ipaddr_string(ndo, tptr)));
tlen -= (sizeof(struct in_addr));
tptr += (sizeof(struct in_addr));
}
@@ -1634,7 +1663,7 @@ bgp_attr_print(netdissect_options *ndo,
case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST):
case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST):
ND_TCHECK2(tptr[0], tlen);
- ND_PRINT((ndo, "%s", isonsap_string(tptr, tlen)));
+ ND_PRINT((ndo, "%s", isonsap_string(ndo, tptr, tlen)));
tptr += tlen;
tlen = 0;
break;
@@ -1649,15 +1678,13 @@ bgp_attr_print(netdissect_options *ndo,
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)));
+ isonsap_string(ndo, tptr+BGP_VPN_RD_LEN,tlen-BGP_VPN_RD_LEN)));
/* rfc986 mapped IPv4 address ? */
if (EXTRACT_32BITS(tptr+BGP_VPN_RD_LEN) == 0x47000601)
- ND_PRINT((ndo, " = %s", getname(ndo, tptr+BGP_VPN_RD_LEN+4)));
-#ifdef INET6
+ ND_PRINT((ndo, " = %s", ipaddr_string(ndo, tptr+BGP_VPN_RD_LEN+4)));
/* rfc1888 mapped IPv6 address ? */
else if (EXTRACT_24BITS(tptr+BGP_VPN_RD_LEN) == 0x350000)
- ND_PRINT((ndo, " = %s", getname6(ndo, tptr+BGP_VPN_RD_LEN+3)));
-#endif
+ ND_PRINT((ndo, " = %s", ip6addr_string(ndo, tptr+BGP_VPN_RD_LEN+3)));
tptr += tlen;
tlen = 0;
}
@@ -1758,7 +1785,6 @@ bgp_attr_print(netdissect_options *ndo,
else
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):
@@ -1794,7 +1820,6 @@ bgp_attr_print(netdissect_options *ndo,
else
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):
@@ -1851,12 +1876,10 @@ bgp_attr_print(netdissect_options *ndo,
safi = tptr[2];
ND_PRINT((ndo, "\n\t AFI: %s (%u), %sSAFI: %s (%u)",
- tok2strbuf(af_values, "Unknown AFI", af,
- tokbuf, sizeof(tokbuf)),
+ tok2str(af_values, "Unknown AFI", af),
af,
(safi>128) ? "vendor specific " : "", /* 128 is meanwhile wellknown */
- tok2strbuf(bgp_safi_values, "Unknown SAFI", safi,
- tokbuf, sizeof(tokbuf)),
+ tok2str(bgp_safi_values, "Unknown SAFI", safi),
safi));
if (len == BGP_MP_NLRI_MINSIZE)
@@ -1901,7 +1924,6 @@ bgp_attr_print(netdissect_options *ndo,
else
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):
@@ -1937,7 +1959,6 @@ bgp_attr_print(netdissect_options *ndo,
else
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):
@@ -2017,9 +2038,9 @@ bgp_attr_print(netdissect_options *ndo,
extd_comm=EXTRACT_16BITS(tptr);
ND_PRINT((ndo, "\n\t %s (0x%04x), Flags [%s]",
- tok2strbuf(bgp_extd_comm_subtype_values,
+ tok2str(bgp_extd_comm_subtype_values,
"unknown extd community typecode",
- extd_comm, tokbuf, sizeof(tokbuf)),
+ extd_comm),
extd_comm,
bittok2str(bgp_extd_comm_flag_values, "none", extd_comm)));
@@ -2031,14 +2052,14 @@ bgp_attr_print(netdissect_options *ndo,
ND_PRINT((ndo, ": %u:%u (= %s)",
EXTRACT_16BITS(tptr+2),
EXTRACT_32BITS(tptr+4),
- getname(ndo, tptr+4)));
+ ipaddr_string(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:
ND_PRINT((ndo, ": %s:%u",
- getname(ndo, tptr+2),
+ ipaddr_string(ndo, tptr+2),
EXTRACT_16BITS(tptr+6)));
break;
case BGP_EXT_COM_RT_2:
@@ -2058,25 +2079,23 @@ bgp_attr_print(netdissect_options *ndo,
case BGP_EXT_COM_VPN_ORIGIN4:
case BGP_EXT_COM_OSPF_RID:
case BGP_EXT_COM_OSPF_RID2:
- ND_PRINT((ndo, "%s", getname(ndo, tptr+2)));
+ ND_PRINT((ndo, "%s", ipaddr_string(ndo, tptr+2)));
break;
case BGP_EXT_COM_OSPF_RTYPE:
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,
+ ipaddr_string(ndo, tptr+2),
+ tok2str(bgp_extd_comm_ospf_rtype_values,
"unknown (0x%02x)",
- *(tptr+6),
- tokbuf, sizeof(tokbuf)),
+ *(tptr+6)),
(*(tptr+7) & BGP_OSPF_RTYPE_METRIC_TYPE) ? "E2" : "",
((*(tptr+6) == BGP_OSPF_RTYPE_EXT) || (*(tptr+6) == BGP_OSPF_RTYPE_NSSA)) ? "E1" : ""));
break;
case BGP_EXT_COM_L2INFO:
ND_PRINT((ndo, ": %s Control Flags [0x%02x]:MTU %u",
- tok2strbuf(l2vpn_encaps_values,
+ tok2str(l2vpn_encaps_values,
"unknown encaps",
- *(tptr+2),
- tokbuf, sizeof(tokbuf)),
+ *(tptr+2)),
*(tptr+3),
EXTRACT_16BITS(tptr+4)));
break;
@@ -2151,6 +2170,48 @@ bgp_attr_print(netdissect_options *ndo,
}
break;
}
+ case BGPTYPE_AIGP:
+ {
+ uint8_t type;
+ uint16_t length;
+
+ ND_TCHECK2(tptr[0], 3);
+
+ tlen = len;
+
+ while (tlen >= 3) {
+
+ type = *tptr;
+ length = EXTRACT_16BITS(tptr+1);
+
+ ND_PRINT((ndo, "\n\t %s TLV (%u), length %u",
+ tok2str(bgp_aigp_values, "Unknown", type),
+ type, length));
+
+ /*
+ * Check if we can read the TLV data.
+ */
+ ND_TCHECK2(tptr[3], length - 3);
+
+ switch (type) {
+
+ case BGP_AIGP_TLV:
+ ND_TCHECK2(tptr[3], 8);
+ ND_PRINT((ndo, ", metric %" PRIu64,
+ EXTRACT_64BITS(tptr+3)));
+ break;
+
+ default:
+ if (ndo->ndo_vflag <= 1) {
+ print_unknown_data(ndo, tptr+3,"\n\t ", length-3);
+ }
+ }
+
+ tptr += length;
+ tlen -= length;
+ }
+ break;
+ }
case BGPTYPE_ATTR_SET:
ND_TCHECK2(tptr[0], 4);
if (len < 4)
@@ -2161,7 +2222,7 @@ bgp_attr_print(netdissect_options *ndo,
len -=4;
while (len) {
- u_int aflags, atype, alenlen, alen;
+ u_int aflags, alenlen, alen;
ND_TCHECK2(tptr[0], 2);
if (len < 2)
@@ -2179,9 +2240,8 @@ bgp_attr_print(netdissect_options *ndo,
len -= alenlen;
ND_PRINT((ndo, "\n\t %s (%u), length: %u",
- tok2strbuf(bgp_attr_values,
- "Unknown Attribute", atype,
- tokbuf, sizeof(tokbuf)),
+ tok2str(bgp_attr_values,
+ "Unknown Attribute", atype),
atype,
alen));
@@ -2203,7 +2263,23 @@ bgp_attr_print(netdissect_options *ndo,
}
break;
-
+ case BGPTYPE_LARGE_COMMUNITY:
+ if (len == 0 || len % 12) {
+ ND_PRINT((ndo, "invalid len"));
+ break;
+ }
+ ND_PRINT((ndo, "\n\t "));
+ while (len > 0) {
+ ND_TCHECK2(*tptr, 12);
+ ND_PRINT((ndo, "%u:%u:%u%s",
+ EXTRACT_32BITS(tptr),
+ EXTRACT_32BITS(tptr + 4),
+ EXTRACT_32BITS(tptr + 8),
+ (len > 12) ? ", " : ""));
+ tptr += 12;
+ len -= 12;
+ }
+ break;
default:
ND_TCHECK2(*pptr,len);
ND_PRINT((ndo, "\n\t no Attribute %u decoder", atype)); /* we have no decoder for the attribute */
@@ -2225,8 +2301,6 @@ static void
bgp_capabilities_print(netdissect_options *ndo,
const u_char *opt, int caps_len)
{
- char tokbuf[TOKBUFSIZE];
- char tokbuf2[TOKBUFSIZE];
int cap_type, cap_len, tcap_len, cap_offset;
int i = 0;
@@ -2236,21 +2310,19 @@ bgp_capabilities_print(netdissect_options *ndo,
cap_len=opt[i+1];
tcap_len=cap_len;
ND_PRINT((ndo, "\n\t %s (%u), length: %u",
- tok2strbuf(bgp_capcode_values, "Unknown",
- cap_type, tokbuf, sizeof(tokbuf)),
+ tok2str(bgp_capcode_values, "Unknown",
+ cap_type),
cap_type,
cap_len));
ND_TCHECK2(opt[i+2], cap_len);
switch (cap_type) {
case BGP_CAPCODE_MP:
ND_PRINT((ndo, "\n\t\tAFI %s (%u), SAFI %s (%u)",
- tok2strbuf(af_values, "Unknown",
- EXTRACT_16BITS(opt+i+2),
- tokbuf, sizeof(tokbuf)),
+ tok2str(af_values, "Unknown",
+ EXTRACT_16BITS(opt+i+2)),
EXTRACT_16BITS(opt+i+2),
- tok2strbuf(bgp_safi_values, "Unknown",
- opt[i+5],
- tokbuf, sizeof(tokbuf)),
+ tok2str(bgp_safi_values, "Unknown",
+ opt[i+5]),
opt[i+5]));
break;
case BGP_CAPCODE_RESTART:
@@ -2261,13 +2333,11 @@ bgp_capabilities_print(netdissect_options *ndo,
cap_offset=4;
while(tcap_len>=4) {
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)),
+ tok2str(af_values,"Unknown",
+ EXTRACT_16BITS(opt+i+cap_offset)),
EXTRACT_16BITS(opt+i+cap_offset),
- tok2strbuf(bgp_safi_values,"Unknown",
- opt[i+cap_offset+2],
- tokbuf2, sizeof(tokbuf2)),
+ tok2str(bgp_safi_values,"Unknown",
+ opt[i+cap_offset+2]),
opt[i+cap_offset+2],
((opt[i+cap_offset+3])&0x80) ? "yes" : "no" ));
tcap_len-=4;
@@ -2288,6 +2358,28 @@ bgp_capabilities_print(netdissect_options *ndo,
EXTRACT_32BITS(opt + i + 2))));
}
break;
+ case BGP_CAPCODE_ADD_PATH:
+ cap_offset=2;
+ if (tcap_len == 0) {
+ ND_PRINT((ndo, " (bogus)")); /* length */
+ break;
+ }
+ while (tcap_len > 0) {
+ if (tcap_len < 4) {
+ ND_PRINT((ndo, "\n\t\t(invalid)"));
+ break;
+ }
+ ND_PRINT((ndo, "\n\t\tAFI %s (%u), SAFI %s (%u), Send/Receive: %s",
+ tok2str(af_values,"Unknown",EXTRACT_16BITS(opt+i+cap_offset)),
+ EXTRACT_16BITS(opt+i+cap_offset),
+ tok2str(bgp_safi_values,"Unknown",opt[i+cap_offset+2]),
+ opt[i+cap_offset+2],
+ tok2str(bgp_add_path_recvsend,"Bogus (0x%02x)",opt[i+cap_offset+3])
+ ));
+ tcap_len-=4;
+ cap_offset+=4;
+ }
+ break;
default:
ND_PRINT((ndo, "\n\t\tno decoder for Capability %u",
cap_type));
@@ -2314,7 +2406,6 @@ bgp_open_print(netdissect_options *ndo,
struct bgp_opt bgpopt;
const u_char *opt;
int i;
- char tokbuf[TOKBUFSIZE];
ND_TCHECK2(dat[0], BGP_OPEN_SIZE);
memcpy(&bgpo, dat, BGP_OPEN_SIZE);
@@ -2323,7 +2414,7 @@ bgp_open_print(netdissect_options *ndo,
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, "ID %s", ipaddr_string(ndo, &bgpo.bgpo_id)));
ND_PRINT((ndo, "\n\t Optional parameters, length: %u", bgpo.bgpo_optlen));
/* some little sanity checking */
@@ -2344,9 +2435,8 @@ bgp_open_print(netdissect_options *ndo,
}
ND_PRINT((ndo, "\n\t Option %s (%u), length: %u",
- tok2strbuf(bgp_opt_values,"Unknown",
- bgpopt.bgpopt_type,
- tokbuf, sizeof(tokbuf)),
+ tok2str(bgp_opt_values,"Unknown",
+ bgpopt.bgpopt_type),
bgpopt.bgpopt_type,
bgpopt.bgpopt_len));
@@ -2380,11 +2470,6 @@ bgp_update_print(netdissect_options *ndo,
int withdrawn_routes_len;
int len;
int i;
- char tokbuf[TOKBUFSIZE];
-#ifndef INET6
- char buf[MAXHOSTNAMELEN + 100];
- int wpfx;
-#endif
ND_TCHECK2(dat[0], BGP_SIZE);
if (length < BGP_SIZE)
@@ -2409,36 +2494,9 @@ bgp_update_print(netdissect_options *ndo,
ND_TCHECK2(p[0], withdrawn_routes_len);
if (length < withdrawn_routes_len)
goto trunc;
-#ifdef INET6
ND_PRINT((ndo, "\n\t Withdrawn routes: %d bytes", withdrawn_routes_len));
p += withdrawn_routes_len;
length -= withdrawn_routes_len;
-#else
- if (withdrawn_routes_len < 2)
- goto trunc;
- length -= 2;
- withdrawn_routes_len -= 2;
-
-
- ND_PRINT((ndo, "\n\t Withdrawn routes:"));
-
- while(withdrawn_routes_len > 0) {
- wpfx = decode_prefix4(ndo, p, withdrawn_routes_len, buf, sizeof(buf));
- if (wpfx == -1) {
- 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 {
- ND_PRINT((ndo, "\n\t %s", buf));
- p += wpfx;
- length -= wpfx;
- withdrawn_routes_len -= wpfx;
- }
- }
-#endif
}
ND_TCHECK2(p[0], 2);
@@ -2481,9 +2539,8 @@ bgp_update_print(netdissect_options *ndo,
length -= alenlen;
ND_PRINT((ndo, "\n\t %s (%u), length: %u",
- tok2strbuf(bgp_attr_values, "Unknown Attribute",
- atype,
- tokbuf, sizeof(tokbuf)),
+ tok2str(bgp_attr_values, "Unknown Attribute",
+ atype),
atype,
alen));
@@ -2547,8 +2604,6 @@ bgp_notification_print(netdissect_options *ndo,
{
struct bgp_notification bgpn;
const u_char *tptr;
- char tokbuf[TOKBUFSIZE];
- char tokbuf2[TOKBUFSIZE];
ND_TCHECK2(dat[0], BGP_NOTIFICATION_SIZE);
memcpy(&bgpn, dat, BGP_NOTIFICATION_SIZE);
@@ -2558,39 +2613,46 @@ bgp_notification_print(netdissect_options *ndo,
return;
ND_PRINT((ndo, ", %s (%u)",
- tok2strbuf(bgp_notify_major_values, "Unknown Error",
- bgpn.bgpn_major, tokbuf, sizeof(tokbuf)),
+ tok2str(bgp_notify_major_values, "Unknown Error",
+ bgpn.bgpn_major),
bgpn.bgpn_major));
switch (bgpn.bgpn_major) {
case BGP_NOTIFY_MAJOR_MSG:
ND_PRINT((ndo, ", subcode %s (%u)",
- tok2strbuf(bgp_notify_minor_msg_values, "Unknown",
- bgpn.bgpn_minor, tokbuf, sizeof(tokbuf)),
+ tok2str(bgp_notify_minor_msg_values, "Unknown",
+ bgpn.bgpn_minor),
bgpn.bgpn_minor));
break;
case BGP_NOTIFY_MAJOR_OPEN:
ND_PRINT((ndo, ", subcode %s (%u)",
- tok2strbuf(bgp_notify_minor_open_values, "Unknown",
- bgpn.bgpn_minor, tokbuf, sizeof(tokbuf)),
+ tok2str(bgp_notify_minor_open_values, "Unknown",
+ bgpn.bgpn_minor),
bgpn.bgpn_minor));
break;
case BGP_NOTIFY_MAJOR_UPDATE:
ND_PRINT((ndo, ", subcode %s (%u)",
- tok2strbuf(bgp_notify_minor_update_values, "Unknown",
- bgpn.bgpn_minor, tokbuf, sizeof(tokbuf)),
+ tok2str(bgp_notify_minor_update_values, "Unknown",
+ bgpn.bgpn_minor),
+ bgpn.bgpn_minor));
+ break;
+ case BGP_NOTIFY_MAJOR_FSM:
+ ND_PRINT((ndo, " subcode %s (%u)",
+ tok2str(bgp_notify_minor_fsm_values, "Unknown",
+ bgpn.bgpn_minor),
bgpn.bgpn_minor));
break;
case BGP_NOTIFY_MAJOR_CAP:
ND_PRINT((ndo, " subcode %s (%u)",
- tok2strbuf(bgp_notify_minor_cap_values, "Unknown",
- bgpn.bgpn_minor, tokbuf, sizeof(tokbuf)),
+ tok2str(bgp_notify_minor_cap_values, "Unknown",
+ bgpn.bgpn_minor),
bgpn.bgpn_minor));
+ break;
case BGP_NOTIFY_MAJOR_CEASE:
ND_PRINT((ndo, ", subcode %s (%u)",
- tok2strbuf(bgp_notify_minor_cease_values, "Unknown",
- bgpn.bgpn_minor, tokbuf, sizeof(tokbuf)),
+ tok2str(bgp_notify_minor_cease_values, "Unknown",
+ bgpn.bgpn_minor),
bgpn.bgpn_minor));
/* draft-ietf-idr-cease-subcode-02 mentions optionally 7 bytes
@@ -2600,11 +2662,10 @@ bgp_notification_print(netdissect_options *ndo,
tptr = dat + BGP_NOTIFICATION_SIZE;
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)),
+ tok2str(af_values, "Unknown",
+ EXTRACT_16BITS(tptr)),
EXTRACT_16BITS(tptr),
- tok2strbuf(bgp_safi_values, "Unknown", *(tptr+2),
- tokbuf2, sizeof(tokbuf)),
+ tok2str(bgp_safi_values, "Unknown", *(tptr+2)),
*(tptr+2),
EXTRACT_32BITS(tptr+3)));
}
@@ -2623,8 +2684,6 @@ 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];
ND_TCHECK2(pptr[0], BGP_ROUTE_REFRESH_SIZE);
@@ -2635,15 +2694,13 @@ bgp_route_refresh_print(netdissect_options *ndo,
bgp_route_refresh_header = (const struct bgp_route_refresh *)pptr;
ND_PRINT((ndo, "\n\t AFI %s (%u), SAFI %s (%u)",
- tok2strbuf(af_values,"Unknown",
+ tok2str(af_values,"Unknown",
/* this stinks but the compiler pads the structure
* weird */
- EXTRACT_16BITS(&bgp_route_refresh_header->afi),
- tokbuf, sizeof(tokbuf)),
+ EXTRACT_16BITS(&bgp_route_refresh_header->afi)),
EXTRACT_16BITS(&bgp_route_refresh_header->afi),
- tok2strbuf(bgp_safi_values,"Unknown",
- bgp_route_refresh_header->safi,
- tokbuf2, sizeof(tokbuf2)),
+ tok2str(bgp_safi_values,"Unknown",
+ bgp_route_refresh_header->safi),
bgp_route_refresh_header->safi));
if (ndo->ndo_vflag > 1) {
@@ -2661,13 +2718,11 @@ bgp_header_print(netdissect_options *ndo,
const u_char *dat, int length)
{
struct bgp bgp;
- char tokbuf[TOKBUFSIZE];
ND_TCHECK2(dat[0], BGP_SIZE);
memcpy(&bgp, dat, BGP_SIZE);
ND_PRINT((ndo, "\n\t%s Message (%u), length: %u",
- tok2strbuf(bgp_msg_values, "Unknown", bgp.bgp_type,
- tokbuf, sizeof(tokbuf)),
+ tok2str(bgp_msg_values, "Unknown", bgp.bgp_type),
bgp.bgp_type,
length));
@@ -2712,7 +2767,6 @@ bgp_print(netdissect_options *ndo,
};
struct bgp bgp;
uint16_t hlen;
- char tokbuf[TOKBUFSIZE];
ep = dat + length;
if (ndo->ndo_snapend < dat + length)
@@ -2761,10 +2815,9 @@ bgp_print(netdissect_options *ndo,
start = p;
} else {
ND_PRINT((ndo, "\n[|BGP %s]",
- tok2strbuf(bgp_msg_values,
+ tok2str(bgp_msg_values,
"Unknown Message Type",
- bgp.bgp_type,
- tokbuf, sizeof(tokbuf))));
+ bgp.bgp_type)));
break;
}
}
diff --git a/print-bootp.c b/print-bootp.c
index fe0a070ca093..fe798a0483da 100644
--- a/print-bootp.c
+++ b/print-bootp.c
@@ -17,20 +17,19 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Format and print bootp packets.
*/
-#define NETDISSECT_REWORKED
+/* \summary: BOOTP and IPv4 DHCP printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
@@ -213,8 +212,9 @@ struct bootp {
#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)
+/* RFC 4833, TZ codes */
+#define TAG_TZ_PCODE ((uint8_t) 100)
+#define TAG_TZ_TCODE ((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)
@@ -222,6 +222,7 @@ struct bootp {
#define TAG_FAILOVER ((uint8_t) 115)
#define TAG_EXTENDED_REQUEST ((uint8_t) 126)
#define TAG_EXTENDED_OPTION ((uint8_t) 127)
+#define TAG_MUDURL ((uint8_t) 161)
/* DHCP Message types (values for TAG_DHCP_MESSAGE option) */
#define DHCPDISCOVER 1
@@ -292,6 +293,7 @@ bootp_print(netdissect_options *ndo,
ND_PRINT((ndo, "BOOTP/DHCP, %s",
tok2str(bootp_op_values, "unknown (0x%02x)", bp->bp_op)));
+ ND_TCHECK(bp->bp_hlen);
if (bp->bp_htype == 1 && bp->bp_hlen == 6 && bp->bp_op == BOOTPREQUEST) {
ND_TCHECK2(bp->bp_chaddr[0], 6);
ND_PRINT((ndo, " from %s", etheraddr_string(ndo, bp->bp_chaddr)));
@@ -354,7 +356,8 @@ bootp_print(netdissect_options *ndo,
ND_TCHECK2(bp->bp_sname[0], 1); /* check first char only */
if (*bp->bp_sname) {
ND_PRINT((ndo, "\n\t sname \""));
- if (fn_print(ndo, bp->bp_sname, ndo->ndo_snapend)) {
+ if (fn_printztn(ndo, bp->bp_sname, (u_int)sizeof bp->bp_sname,
+ ndo->ndo_snapend)) {
ND_PRINT((ndo, "\""));
ND_PRINT((ndo, "%s", tstr + 1));
return;
@@ -364,7 +367,8 @@ bootp_print(netdissect_options *ndo,
ND_TCHECK2(bp->bp_file[0], 1); /* check first char only */
if (*bp->bp_file) {
ND_PRINT((ndo, "\n\t file \""));
- if (fn_print(ndo, bp->bp_file, ndo->ndo_snapend)) {
+ if (fn_printztn(ndo, bp->bp_file, (u_int)sizeof bp->bp_file,
+ ndo->ndo_snapend)) {
ND_PRINT((ndo, "\""));
ND_PRINT((ndo, "%s", tstr + 1));
return;
@@ -520,13 +524,14 @@ static const struct tok tag2str[] = {
{ TAG_CLIENT_GUID, "bGUID" }, /* XXX 'b' */
{ TAG_LDAP_URL, "aLDAP" },
{ TAG_6OVER4, "i6o4" },
- { TAG_PRINTER_NAME, "aPRTR" },
- { TAG_MDHCP_SERVER, "bMDHCP" }, /* XXX 'b' */
+ { TAG_TZ_PCODE, "aPOSIX-TZ" },
+ { TAG_TZ_TCODE, "aTZ-Name" },
{ TAG_IPX_COMPAT, "bIPX" }, /* XXX 'b' */
{ TAG_NETINFO_PARENT, "iNI" },
{ TAG_NETINFO_PARENT_TAG, "aNITAG" },
{ TAG_URL, "aURL" },
{ TAG_FAILOVER, "bFAIL" }, /* XXX 'b' */
+ { TAG_MUDURL, "aMUD-URL" },
{ 0, NULL }
};
/* 2-byte extended tags */
@@ -997,7 +1002,7 @@ rfc1048_print(netdissect_options *ndo,
break;
}
if (len < suboptlen) {
- ND_PRINT((ndo, "ERROR: malformed option"));
+ ND_PRINT((ndo, "ERROR: invalid option"));
bp += len;
len = 0;
break;
diff --git a/print-bt.c b/print-bt.c
index 128daade063f..b37f8fa0e312 100644
--- a/print-bt.c
+++ b/print-bt.c
@@ -17,14 +17,15 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: Bluetooth printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#if defined(DLT_BLUETOOTH_HCI_H4_WITH_PHDR) && defined(HAVE_PCAP_BLUETOOTH_H)
diff --git a/print-calm-fast.c b/print-calm-fast.c
index 5cc39f418531..c9be008cc29f 100644
--- a/print-calm-fast.c
+++ b/print-calm-fast.c
@@ -15,14 +15,15 @@
* Original code by Ola Martin Lykkja (ola.lykkja@q-free.com)
*/
-#define NETDISSECT_REWORKED
+/* \summary: Communication access for land mobiles (CALM) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
/*
@@ -36,19 +37,33 @@
* 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)
+calm_fast_print(netdissect_options *ndo, const u_char *bp, u_int length, const struct lladdr_info *src)
{
- int srcNwref = bp[0];
- int dstNwref = bp[1];
+ int srcNwref;
+ int dstNwref;
+
+ ND_TCHECK2(*bp, 2);
+ if (length < 2)
+ goto trunc;
+ srcNwref = bp[0];
+ dstNwref = bp[1];
length -= 2;
bp += 2;
- ND_PRINT((ndo, "CALM FAST src:%s; ", etheraddr_string(ndo, eth+6)));
+ ND_PRINT((ndo, "CALM FAST"));
+ if (src != NULL)
+ ND_PRINT((ndo, " src:%s", (src->addr_string)(ndo, src->addr)));
+ ND_PRINT((ndo, "; "));
ND_PRINT((ndo, "SrcNwref:%d; ", srcNwref));
ND_PRINT((ndo, "DstNwref:%d; ", dstNwref));
if (ndo->ndo_vflag)
ND_DEFAULTPRINT(bp, length);
+ return;
+
+trunc:
+ ND_PRINT((ndo, "[|calm fast]"));
+ return;
}
diff --git a/print-carp.c b/print-carp.c
index 7b9f28ceae4f..c650d181b08a 100644
--- a/print-carp.c
+++ b/print-carp.c
@@ -34,14 +34,15 @@
*
*/
-#define NETDISSECT_REWORKED
+/* \summary: Common Address Redundancy Protocol (CARP) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h" /* for checksum structure and functions */
+#include "netdissect.h" /* for checksum structure and functions */
#include "extract.h"
void
diff --git a/print-cdp.c b/print-cdp.c
index 932f7bccea68..6f8f356736fe 100644
--- a/print-cdp.c
+++ b/print-cdp.c
@@ -24,18 +24,19 @@
* http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/frames.htm
*/
-#define NETDISSECT_REWORKED
+/* \summary: Cisco Discovery Protocol (CDP) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
-#include "extract.h" /* must come after interface.h */
+#include "extract.h"
#include "nlpid.h"
static const char tstr[] = "[|cdp]";
@@ -170,9 +171,11 @@ cdp_print(netdissect_options *ndo,
ND_PRINT((ndo, "\n\t "));
for (i=0;i<len;i++) {
j = *(tptr+i);
- ND_PRINT((ndo, "%c", j));
- if (j == 0x0a) /* lets rework the version string to get a nice indentation */
- ND_PRINT((ndo, "\t "));
+ if (j == '\n') /* lets rework the version string to
+ get a nice indentation */
+ ND_PRINT((ndo, "\n\t "));
+ else
+ fn_print_char(ndo, j);
}
break;
case 0x06: /* Platform */
@@ -278,11 +281,9 @@ cdp_print_addr(netdissect_options *ndo,
{
int pt, pl, al, num;
const u_char *endp = p + l;
-#ifdef INET6
static const u_char prot_ipv6[] = {
0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00, 0x86, 0xdd
};
-#endif
ND_TCHECK2(*p, 4);
if (p + 4 > endp)
@@ -317,7 +318,6 @@ cdp_print_addr(netdissect_options *ndo,
ND_PRINT((ndo, "IPv4 (%u) %s", num, ipaddr_string(ndo, p)));
p += 4;
}
-#ifdef INET6
else if (pt == PT_IEEE_802_2 && pl == 8 &&
memcmp(p, prot_ipv6, 8) == 0 && al == 16) {
/*
@@ -334,7 +334,6 @@ cdp_print_addr(netdissect_options *ndo,
ND_PRINT((ndo, "IPv6 (%u) %s", num, ip6addr_string(ndo, p)));
p += al;
}
-#endif
else {
/*
* Generic case: just print raw data
diff --git a/print-cfm.c b/print-cfm.c
index a85eec09139e..43ad438c6a40 100644
--- a/print-cfm.c
+++ b/print-cfm.c
@@ -12,21 +12,20 @@
* LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE.
*
- * Support for the IEEE Connectivity Fault Management Protocols as per 802.1ag.
- *
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#define NETDISSECT_REWORKED
+/* \summary: IEEE 802.1ag Connectivity Fault Management (CFM) protocols printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <stdio.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "ether.h"
#include "addrtoname.h"
@@ -65,18 +64,15 @@ static const struct tok cfm_opcode_values[] = {
struct cfm_ccm_t {
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];
+ uint8_t names[48];
+ uint8_t itu_t_y_1731[16];
};
/*
* Timer Bases for the CCM Interval field.
* Expressed in units of seconds.
*/
-const float ccm_interval_base[8] = {0, 0.003333, 0.01, 0.1, 1, 10, 60, 600};
+static const float ccm_interval_base[8] = {0, 0.003333, 0.01, 0.1, 1, 10, 60, 600};
#define CCM_INTERVAL_MIN_MULTIPLIER 3.25
#define CCM_INTERVAL_MAX_MULTIPLIER 3.5
@@ -115,16 +111,13 @@ static const struct tok cfm_ma_nameformat_values[] = {
struct cfm_lbm_t {
uint8_t transaction_id[4];
- uint8_t reserved[4];
};
struct cfm_ltm_t {
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[] = {
@@ -134,11 +127,8 @@ static const struct tok cfm_ltm_flag_values[] = {
struct cfm_ltr_t {
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[] = {
@@ -226,10 +216,10 @@ static const struct tok cfm_tlv_senderid_chassisid_values[] = {
static int
-cfm_mgmt_addr_print(netdissect_options *ndo,
- register const u_char *tptr)
+cfm_network_addr_print(netdissect_options *ndo,
+ register const u_char *tptr)
{
- u_int mgmt_addr_type;
+ u_int network_addr_type;
u_int hexdump = FALSE;
/*
@@ -237,24 +227,22 @@ cfm_mgmt_addr_print(netdissect_options *ndo,
* 802.1ab specifies that this field width
* is only once octet
*/
- mgmt_addr_type = *tptr;
- ND_PRINT((ndo, "\n\t Management Address Type %s (%u)",
- tok2str(af_values, "Unknown", mgmt_addr_type),
- mgmt_addr_type));
+ network_addr_type = *tptr;
+ ND_PRINT((ndo, "\n\t Network Address Type %s (%u)",
+ tok2str(af_values, "Unknown", network_addr_type),
+ network_addr_type));
/*
* Resolve the passed in Address.
*/
- switch(mgmt_addr_type) {
+ switch(network_addr_type) {
case AFNUM_INET:
ND_PRINT((ndo, ", %s", ipaddr_string(ndo, tptr + 1)));
break;
-#ifdef INET6
case AFNUM_INET6:
ND_PRINT((ndo, ", %s", ip6addr_string(ndo, tptr + 1)));
break;
-#endif
default:
hexdump = TRUE;
@@ -264,29 +252,19 @@ cfm_mgmt_addr_print(netdissect_options *ndo,
return hexdump;
}
-/*
- * The egress-ID string is a 16-Bit string plus a MAC address.
- */
-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 0x%4x-%s",
- EXTRACT_16BITS(tptr),
- etheraddr_string(ndo, tptr+2));
-
- return egress_id_buffer;
-}
-
void
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 uint8_t *tptr, *tlv_ptr, *ma_name, *ma_nameformat, *ma_namelength;
+ const uint8_t *tptr, *tlv_ptr;
+ const uint8_t *namesp;
+ u_int names_data_remaining;
+ uint8_t md_nameformat, md_namelength;
+ const uint8_t *md_name;
+ uint8_t ma_nameformat, ma_namelength;
+ const uint8_t *ma_name;
u_int hexdump, tlen, cfm_tlv_len, cfm_tlv_type, ccm_interval;
@@ -299,6 +277,8 @@ cfm_print(netdissect_options *ndo,
tptr=pptr;
cfm_common_header = (const struct cfm_common_header_t *)pptr;
+ if (length < sizeof(*cfm_common_header))
+ goto tooshort;
ND_TCHECK(*cfm_common_header);
/*
@@ -328,9 +308,25 @@ cfm_print(netdissect_options *ndo,
tptr += sizeof(const struct cfm_common_header_t);
tlen = length - sizeof(struct cfm_common_header_t);
+ /*
+ * Sanity check the first TLV offset.
+ */
+ if (cfm_common_header->first_tlv_offset > tlen) {
+ ND_PRINT((ndo, " (too large, must be <= %u)", tlen));
+ return;
+ }
+
switch (cfm_common_header->opcode) {
case CFM_OPCODE_CCM:
msg_ptr.cfm_ccm = (const struct cfm_ccm_t *)tptr;
+ if (cfm_common_header->first_tlv_offset < sizeof(*msg_ptr.cfm_ccm)) {
+ ND_PRINT((ndo, " (too small 1, must be >= %lu)",
+ (unsigned long) sizeof(*msg_ptr.cfm_ccm)));
+ return;
+ }
+ if (tlen < sizeof(*msg_ptr.cfm_ccm))
+ goto tooshort;
+ ND_TCHECK(*msg_ptr.cfm_ccm);
ccm_interval = CFM_EXTRACT_CCM_INTERVAL(cfm_common_header->flags);
ND_PRINT((ndo, ", Flags [CCM Interval %u%s]",
@@ -353,55 +349,89 @@ cfm_print(netdissect_options *ndo,
EXTRACT_32BITS(msg_ptr.cfm_ccm->sequence),
EXTRACT_16BITS(msg_ptr.cfm_ccm->ma_epi)));
+ namesp = msg_ptr.cfm_ccm->names;
+ names_data_remaining = sizeof(msg_ptr.cfm_ccm->names);
/*
* Resolve the MD fields.
*/
- 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));
+ md_nameformat = *namesp;
+ namesp++;
+ names_data_remaining--; /* We know this is != 0 */
+ if (md_nameformat != CFM_CCM_MD_FORMAT_NONE) {
+ md_namelength = *namesp;
+ namesp++;
+ names_data_remaining--; /* We know this is !=0 */
+ ND_PRINT((ndo, "\n\t MD Name Format %s (%u), MD Name length %u",
+ tok2str(cfm_md_nameformat_values, "Unknown",
+ md_nameformat),
+ md_nameformat,
+ md_namelength));
+
+ /* -2 for the MA short name format and length */
+ if (md_namelength > names_data_remaining - 2) {
+ ND_PRINT((ndo, " (too large, must be <= %u)", names_data_remaining - 2));
+ return;
+ }
- if (msg_ptr.cfm_ccm->md_nameformat != CFM_CCM_MD_FORMAT_NONE) {
+ md_name = namesp;
ND_PRINT((ndo, "\n\t MD Name: "));
- switch (msg_ptr.cfm_ccm->md_nameformat) {
+ switch (md_nameformat) {
case CFM_CCM_MD_FORMAT_DNS:
case CFM_CCM_MD_FORMAT_CHAR:
- safeputs(ndo, msg_ptr.cfm_ccm->md_name, msg_ptr.cfm_ccm->md_namelength);
+ safeputs(ndo, md_name, md_namelength);
break;
case CFM_CCM_MD_FORMAT_MAC:
- ND_PRINT((ndo, "\n\t MAC %s", etheraddr_string(ndo,
- msg_ptr.cfm_ccm->md_name)));
+ if (md_namelength == 6) {
+ ND_PRINT((ndo, "\n\t MAC %s", etheraddr_string(ndo,
+ md_name)));
+ } else {
+ ND_PRINT((ndo, "\n\t MAC (length invalid)"));
+ }
break;
/* FIXME add printers for those MD formats - hexdump for now */
case CFM_CCM_MA_FORMAT_8021:
default:
- print_unknown_data(ndo, msg_ptr.cfm_ccm->md_name, "\n\t ",
- msg_ptr.cfm_ccm->md_namelength);
+ print_unknown_data(ndo, md_name, "\n\t ",
+ md_namelength);
}
+ namesp += md_namelength;
+ names_data_remaining -= md_namelength;
+ } else {
+ ND_PRINT((ndo, "\n\t MD Name Format %s (%u)",
+ tok2str(cfm_md_nameformat_values, "Unknown",
+ md_nameformat),
+ md_nameformat));
}
/*
* Resolve the MA fields.
*/
- ma_nameformat = msg_ptr.cfm_ccm->md_name + msg_ptr.cfm_ccm->md_namelength;
- ma_namelength = msg_ptr.cfm_ccm->md_name + msg_ptr.cfm_ccm->md_namelength + 1;
- ma_name = msg_ptr.cfm_ccm->md_name + msg_ptr.cfm_ccm->md_namelength + 2;
-
+ ma_nameformat = *namesp;
+ namesp++;
+ names_data_remaining--; /* We know this is != 0 */
+ ma_namelength = *namesp;
+ namesp++;
+ names_data_remaining--; /* We know this is != 0 */
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_nameformat),
+ ma_nameformat,
+ ma_namelength));
+ if (ma_namelength > names_data_remaining) {
+ ND_PRINT((ndo, " (too large, must be <= %u)", names_data_remaining));
+ return;
+ }
+
+ ma_name = namesp;
ND_PRINT((ndo, "\n\t MA Name: "));
- switch (*ma_nameformat) {
+ switch (ma_nameformat) {
case CFM_CCM_MA_FORMAT_CHAR:
- safeputs(ndo, ma_name, *ma_namelength);
+ safeputs(ndo, ma_name, ma_namelength);
break;
/* FIXME add printers for those MA formats - hexdump for now */
@@ -410,19 +440,26 @@ cfm_print(netdissect_options *ndo,
case CFM_CCM_MA_FORMAT_INT:
case CFM_CCM_MA_FORMAT_VPN:
default:
- print_unknown_data(ndo, 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;
+ if (cfm_common_header->first_tlv_offset < sizeof(*msg_ptr.cfm_ltm)) {
+ ND_PRINT((ndo, " (too small 4, must be >= %lu)",
+ (unsigned long) sizeof(*msg_ptr.cfm_ltm)));
+ return;
+ }
+ if (tlen < sizeof(*msg_ptr.cfm_ltm))
+ goto tooshort;
+ ND_TCHECK(*msg_ptr.cfm_ltm);
ND_PRINT((ndo, ", Flags [%s]",
bittok2str(cfm_ltm_flag_values, "none", cfm_common_header->flags)));
- ND_PRINT((ndo, "\n\t Transaction-ID 0x%08x, Egress-ID %s, ttl %u",
+ ND_PRINT((ndo, "\n\t Transaction-ID 0x%08x, ttl %u",
EXTRACT_32BITS(msg_ptr.cfm_ltm->transaction_id),
- cfm_egress_id_string(ndo, msg_ptr.cfm_ltm->egress_id),
msg_ptr.cfm_ltm->ttl));
ND_PRINT((ndo, "\n\t Original-MAC %s, Target-MAC %s",
@@ -432,16 +469,20 @@ cfm_print(netdissect_options *ndo,
case CFM_OPCODE_LTR:
msg_ptr.cfm_ltr = (const struct cfm_ltr_t *)tptr;
+ if (cfm_common_header->first_tlv_offset < sizeof(*msg_ptr.cfm_ltr)) {
+ ND_PRINT((ndo, " (too small 5, must be >= %lu)",
+ (unsigned long) sizeof(*msg_ptr.cfm_ltr)));
+ return;
+ }
+ if (tlen < sizeof(*msg_ptr.cfm_ltr))
+ goto tooshort;
+ ND_TCHECK(*msg_ptr.cfm_ltr);
ND_PRINT((ndo, ", Flags [%s]",
bittok2str(cfm_ltr_flag_values, "none", cfm_common_header->flags)));
- ND_PRINT((ndo, "\n\t Transaction-ID 0x%08x, Last-Egress-ID %s",
+ ND_PRINT((ndo, "\n\t Transaction-ID 0x%08x, ttl %u",
EXTRACT_32BITS(msg_ptr.cfm_ltr->transaction_id),
- cfm_egress_id_string(ndo, msg_ptr.cfm_ltr->last_egress_id)));
-
- 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));
ND_PRINT((ndo, "\n\t Replay-Action %s (%u)",
@@ -458,20 +499,11 @@ cfm_print(netdissect_options *ndo,
case CFM_OPCODE_LBR:
case CFM_OPCODE_LBM:
default:
- if (tlen > cfm_common_header->first_tlv_offset) {
- print_unknown_data(ndo, tptr, "\n\t ",
- tlen - cfm_common_header->first_tlv_offset);
- }
+ print_unknown_data(ndo, tptr, "\n\t ",
+ tlen - cfm_common_header->first_tlv_offset);
break;
}
- /*
- * Sanity check for not walking off.
- */
- if (tlen <= cfm_common_header->first_tlv_offset) {
- return;
- }
-
tptr += cfm_common_header->first_tlv_offset;
tlen -= cfm_common_header->first_tlv_offset;
@@ -482,55 +514,59 @@ cfm_print(netdissect_options *ndo,
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 ? */
- ND_TCHECK2(*tptr, sizeof(struct cfm_tlv_header_t));
- cfm_tlv_len=EXTRACT_16BITS(&cfm_tlv_header->length);
- } else {
- cfm_tlv_len = 0;
- }
-
- ND_PRINT((ndo, "\n\t%s TLV (0x%02x), length %u",
+ ND_PRINT((ndo, "\n\t%s TLV (0x%02x)",
tok2str(cfm_tlv_values, "Unknown", cfm_tlv_type),
- cfm_tlv_type,
- cfm_tlv_len));
-
- /* sanity check for not walking off and infinite loop check. */
- if ((cfm_tlv_type != CFM_TLV_END) &&
- ((cfm_tlv_len + sizeof(struct cfm_tlv_header_t) > tlen) ||
- (!cfm_tlv_len))) {
- print_unknown_data(ndo, tptr, "\n\t ", tlen);
+ cfm_tlv_type));
+
+ if (cfm_tlv_type == CFM_TLV_END) {
+ /* Length is "Not present if the Type field is 0." */
return;
}
+ /* do we have the full tlv header ? */
+ if (tlen < sizeof(struct cfm_tlv_header_t))
+ goto tooshort;
+ ND_TCHECK2(*tptr, sizeof(struct cfm_tlv_header_t));
+ cfm_tlv_len=EXTRACT_16BITS(&cfm_tlv_header->length);
+
+ ND_PRINT((ndo, ", length %u", cfm_tlv_len));
+
tptr += sizeof(struct cfm_tlv_header_t);
tlen -= sizeof(struct cfm_tlv_header_t);
tlv_ptr = tptr;
- /* did we capture enough for fully decoding the object ? */
- if (cfm_tlv_type != CFM_TLV_END) {
- ND_TCHECK2(*tptr, cfm_tlv_len);
- }
+ /* do we have the full tlv ? */
+ if (tlen < cfm_tlv_len)
+ goto tooshort;
+ ND_TCHECK2(*tptr, cfm_tlv_len);
hexdump = FALSE;
switch(cfm_tlv_type) {
- case CFM_TLV_END:
- /* we are done - bail out */
- return;
-
case CFM_TLV_PORT_STATUS:
+ if (cfm_tlv_len < 1) {
+ ND_PRINT((ndo, " (too short, must be >= 1)"));
+ return;
+ }
ND_PRINT((ndo, ", Status: %s (%u)",
tok2str(cfm_tlv_port_status_values, "Unknown", *tptr),
*tptr));
break;
case CFM_TLV_INTERFACE_STATUS:
+ if (cfm_tlv_len < 1) {
+ ND_PRINT((ndo, " (too short, must be >= 1)"));
+ return;
+ }
ND_PRINT((ndo, ", Status: %s (%u)",
tok2str(cfm_tlv_interface_status_values, "Unknown", *tptr),
*tptr));
break;
case CFM_TLV_PRIVATE:
+ if (cfm_tlv_len < 4) {
+ ND_PRINT((ndo, " (too short, must be >= 4)"));
+ return;
+ }
ND_PRINT((ndo, ", Vendor: %s (%u), Sub-Type %u",
tok2str(oui_values,"Unknown", EXTRACT_24BITS(tptr)),
EXTRACT_24BITS(tptr),
@@ -543,20 +579,26 @@ cfm_print(netdissect_options *ndo,
u_int chassis_id_type, chassis_id_length;
u_int mgmt_addr_length;
+ if (cfm_tlv_len < 1) {
+ ND_PRINT((ndo, " (too short, must be >= 1)"));
+ return;
+ }
+
/*
- * Check if there is a Chassis-ID.
+ * Get the Chassis ID length and check it.
*/
chassis_id_length = *tptr;
- if (chassis_id_length > tlen) {
- hexdump = TRUE;
- break;
- }
-
tptr++;
tlen--;
+ cfm_tlv_len--;
if (chassis_id_length) {
+ if (cfm_tlv_len < 1) {
+ ND_PRINT((ndo, "\n\t (TLV too short)"));
+ return;
+ }
chassis_id_type = *tptr;
+ cfm_tlv_len--;
ND_PRINT((ndo, "\n\t Chassis-ID Type %s (%u), Chassis-ID length %u",
tok2str(cfm_tlv_senderid_chassisid_values,
"Unknown",
@@ -564,13 +606,18 @@ cfm_print(netdissect_options *ndo,
chassis_id_type,
chassis_id_length));
+ if (cfm_tlv_len < chassis_id_length) {
+ ND_PRINT((ndo, "\n\t (TLV too short)"));
+ return;
+ }
+
switch (chassis_id_type) {
case CFM_CHASSIS_ID_MAC_ADDRESS:
ND_PRINT((ndo, "\n\t MAC %s", etheraddr_string(ndo, tptr + 1)));
break;
case CFM_CHASSIS_ID_NETWORK_ADDRESS:
- hexdump |= cfm_mgmt_addr_print(ndo, tptr);
+ hexdump |= cfm_network_addr_print(ndo, tptr);
break;
case CFM_CHASSIS_ID_INTERFACE_NAME: /* fall through */
@@ -585,32 +632,60 @@ cfm_print(netdissect_options *ndo,
hexdump = TRUE;
break;
}
- }
+ cfm_tlv_len -= chassis_id_length;
- tptr += chassis_id_length;
- tlen -= chassis_id_length;
+ tptr += 1 + chassis_id_length;
+ tlen -= 1 + chassis_id_length;
+ }
/*
* Check if there is a Management Address.
*/
- mgmt_addr_length = *tptr;
- if (mgmt_addr_length > tlen) {
- hexdump = TRUE;
- break;
+ if (cfm_tlv_len == 0) {
+ /* No, there isn't; we're done. */
+ return;
}
+ mgmt_addr_length = *tptr;
tptr++;
tlen--;
-
+ cfm_tlv_len--;
if (mgmt_addr_length) {
- hexdump |= cfm_mgmt_addr_print(ndo, tptr);
+ if (cfm_tlv_len < mgmt_addr_length) {
+ ND_PRINT((ndo, "\n\t (TLV too short)"));
+ return;
+ }
+ cfm_tlv_len -= mgmt_addr_length;
+ /*
+ * XXX - this is an OID; print it as such.
+ */
+ tptr += mgmt_addr_length;
+ tlen -= mgmt_addr_length;
+
+ if (cfm_tlv_len < 1) {
+ ND_PRINT((ndo, "\n\t (TLV too short)"));
+ return;
+ }
+
+ mgmt_addr_length = *tptr;
+ tptr++;
+ tlen--;
+ cfm_tlv_len--;
+ if (mgmt_addr_length) {
+ if (cfm_tlv_len < mgmt_addr_length) {
+ ND_PRINT((ndo, "\n\t (TLV too short)"));
+ return;
+ }
+ cfm_tlv_len -= mgmt_addr_length;
+ /*
+ * XXX - this is a TransportDomain; print it as such.
+ */
+ tptr += mgmt_addr_length;
+ tlen -= mgmt_addr_length;
+ }
}
-
- tptr += mgmt_addr_length;
- tlen -= mgmt_addr_length;
-
+ break;
}
- break;
/*
* FIXME those are the defined TLVs that lack a decoder
@@ -632,6 +707,11 @@ cfm_print(netdissect_options *ndo,
tlen-=cfm_tlv_len;
}
return;
+
+tooshort:
+ ND_PRINT((ndo, "\n\t\t packet is too short"));
+ return;
+
trunc:
ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
}
diff --git a/print-chdlc.c b/print-chdlc.c
index 3951ef77cdff..450d286848cb 100644
--- a/print-chdlc.c
+++ b/print-chdlc.c
@@ -19,14 +19,15 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: Cisco HDLC printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "ethertype.h"
#include "extract.h"
@@ -96,9 +97,9 @@ chdlc_print(netdissect_options *ndo, register const u_char *p, u_int length)
if (*(p+1) == 0x81 ||
*(p+1) == 0x82 ||
*(p+1) == 0x83)
- isoclns_print(ndo, p + 1, length - 1, length - 1);
+ isoclns_print(ndo, p + 1, length - 1, ndo->ndo_snapend - p - 1);
else
- isoclns_print(ndo, p, length, length);
+ isoclns_print(ndo, p, length, ndo->ndo_snapend - p);
break;
default:
if (!ndo->ndo_eflag)
diff --git a/print-cip.c b/print-cip.c
index 91abe08d306a..a123b69f51bf 100644
--- a/print-cip.c
+++ b/print-cip.c
@@ -20,20 +20,19 @@
*
*/
-#define NETDISSECT_REWORKED
+/* \summary: Classical-IP over ATM printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h>
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
-#define RFC1483LLC_LEN 8
-
static const unsigned char rfcllc[] = {
0xaa, /* DSAP: non-ISO */
0xaa, /* SSAP: non-ISO */
@@ -43,12 +42,12 @@ static const unsigned char rfcllc[] = {
0x00 };
static inline void
-cip_print(netdissect_options *ndo, int length)
+cip_print(netdissect_options *ndo, u_int length)
{
/*
* There is no MAC-layer header, so just print the length.
*/
- ND_PRINT((ndo, "%d: ", length));
+ ND_PRINT((ndo, "%u: ", length));
}
/*
@@ -62,40 +61,42 @@ cip_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char
{
u_int caplen = h->caplen;
u_int length = h->len;
- u_short extracted_ethertype;
+ size_t cmplen;
+ int llc_hdrlen;
- if (memcmp(rfcllc, p, sizeof(rfcllc))==0 && caplen < RFC1483LLC_LEN) {
- ND_PRINT((ndo, "[|cip]"));
- return (0);
- }
+ cmplen = sizeof(rfcllc);
+ if (cmplen > caplen)
+ cmplen = caplen;
+ if (cmplen > length)
+ cmplen = length;
if (ndo->ndo_eflag)
cip_print(ndo, length);
- if (memcmp(rfcllc, p, sizeof(rfcllc)) == 0) {
+ if (cmplen == 0) {
+ ND_PRINT((ndo, "[|cip]"));
+ return 0;
+ }
+ if (memcmp(rfcllc, p, cmplen) == 0) {
/*
* LLC header is present. Try to print it & higher layers.
*/
- if (llc_print(ndo, p, length, caplen, NULL, NULL,
- &extracted_ethertype) == 0) {
- /* ether_type not known, print raw packet */
- if (!ndo->ndo_eflag)
- cip_print(ndo, length);
- if (extracted_ethertype) {
- ND_PRINT((ndo, "(LLC %s) ",
- etherproto_string(htons(extracted_ethertype))));
- }
+ llc_hdrlen = llc_print(ndo, p, length, caplen, NULL, NULL);
+ if (llc_hdrlen < 0) {
+ /* packet type not known, print raw packet */
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
+ llc_hdrlen = -llc_hdrlen;
}
} else {
/*
* LLC header is absent; treat it as just IP.
*/
+ llc_hdrlen = 0;
ip_print(ndo, p, length);
}
- return (0);
+ return (llc_hdrlen);
}
diff --git a/print-cnfp.c b/print-cnfp.c
index d80d7fd27442..e3e9b6d07b8b 100644
--- a/print-cnfp.c
+++ b/print-cnfp.c
@@ -30,6 +30,8 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/* \summary: Cisco NetFlow protocol printer */
+
/*
* Cisco NetFlow protocol
*
@@ -38,17 +40,16 @@
* http://www.cisco.com/c/en/us/td/docs/net_mgmt/netflow_collection_engine/3-6/user/guide/format.html#wp1005892
*/
-#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <stdio.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
diff --git a/print-dccp.c b/print-dccp.c
index 45468b555473..6e2526427240 100644
--- a/print-dccp.c
+++ b/print-dccp.c
@@ -7,23 +7,22 @@
* BSD-style license that accompanies tcpdump or the GNU GPL version 2
*/
-#define NETDISSECT_REWORKED
+/* \summary: Datagram Congestion Control Protocol (DCCP) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <stdio.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
-#include "extract.h" /* must come after interface.h */
+#include "extract.h"
#include "ip.h"
-#ifdef INET6
#include "ip6.h"
-#endif
#include "ipproto.h"
/* RFC4340: Datagram Congestion Control Protocol (DCCP) */
@@ -201,17 +200,16 @@ static inline u_int dccp_csum_coverage(const struct dccp_hdr* dh, u_int len)
static int dccp_cksum(netdissect_options *ndo, const struct ip *ip,
const struct dccp_hdr *dh, u_int len)
{
- return nextproto4_cksum(ndo, ip, (const uint8_t *)(void *)dh, len,
+ return nextproto4_cksum(ndo, ip, (const uint8_t *)(const 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)
+static int dccp6_cksum(netdissect_options *ndo, const struct ip6_hdr *ip6,
+ const struct dccp_hdr *dh, u_int len)
{
- return nextproto6_cksum(ip6, (const uint8_t *)(void *)dh, len,
+ return nextproto6_cksum(ndo, ip6, (const uint8_t *)(const void *)dh, len,
dccp_csum_coverage(dh, len), IPPROTO_DCCP);
}
-#endif
static const char *dccp_reset_code(uint8_t code)
{
@@ -272,9 +270,7 @@ void dccp_print(netdissect_options *ndo, const u_char *bp, const u_char *data2,
{
const struct dccp_hdr *dh;
const struct ip *ip;
-#ifdef INET6
const struct ip6_hdr *ip6;
-#endif
const u_char *cp;
u_short sport, dport;
u_int hlen;
@@ -283,13 +279,11 @@ void dccp_print(netdissect_options *ndo, const u_char *bp, const u_char *data2,
dh = (const struct dccp_hdr *)bp;
- ip = (struct ip *)data2;
-#ifdef INET6
+ ip = (const struct ip *)data2;
if (IP_V(ip) == 6)
ip6 = (const struct ip6_hdr *)data2;
else
ip6 = NULL;
-#endif /*INET6*/
/* make sure we have enough data to look at the X bit */
cp = (const u_char *)(dh + 1);
@@ -316,14 +310,11 @@ void dccp_print(netdissect_options *ndo, const u_char *bp, const u_char *data2,
dport = EXTRACT_16BITS(&dh->dccph_dport);
hlen = dh->dccph_doff * 4;
-#ifdef INET6
if (ip6) {
ND_PRINT((ndo, "%s.%d > %s.%d: ",
ip6addr_string(ndo, &ip6->ip6_src), sport,
ip6addr_string(ndo, &ip6->ip6_dst), dport));
- } else
-#endif /*INET6*/
- {
+ } else {
ND_PRINT((ndo, "%s.%d > %s.%d: ",
ipaddr_string(ndo, &ip->ip_src), sport,
ipaddr_string(ndo, &ip->ip_dst), dport));
@@ -353,10 +344,8 @@ void dccp_print(netdissect_options *ndo, const u_char *bp, const u_char *data2,
ND_PRINT((ndo, "cksum 0x%04x ", dccp_sum));
if (IP_V(ip) == 4)
sum = dccp_cksum(ndo, ip, dh, len);
-#ifdef INET6
else if (IP_V(ip) == 6)
- sum = dccp6_cksum(ip6, dh, len);
-#endif
+ sum = dccp6_cksum(ndo, ip6, dh, len);
if (sum != 0)
ND_PRINT((ndo, "(incorrect -> 0x%04x)",in_cksum_shouldbe(dccp_sum, sum)));
else
@@ -370,8 +359,8 @@ void dccp_print(netdissect_options *ndo, const u_char *bp, const u_char *data2,
dccph_type = DCCPH_TYPE(dh);
switch (dccph_type) {
case DCCP_PKT_REQUEST: {
- struct dccp_hdr_request *dhr =
- (struct dccp_hdr_request *)(bp + fixed_hdrlen);
+ const struct dccp_hdr_request *dhr =
+ (const struct dccp_hdr_request *)(bp + fixed_hdrlen);
fixed_hdrlen += 4;
if (len < fixed_hdrlen) {
ND_PRINT((ndo, "truncated-%s - %u bytes missing!",
@@ -386,8 +375,8 @@ void dccp_print(netdissect_options *ndo, const u_char *bp, const u_char *data2,
break;
}
case DCCP_PKT_RESPONSE: {
- struct dccp_hdr_response *dhr =
- (struct dccp_hdr_response *)(bp + fixed_hdrlen);
+ const struct dccp_hdr_response *dhr =
+ (const struct dccp_hdr_response *)(bp + fixed_hdrlen);
fixed_hdrlen += 12;
if (len < fixed_hdrlen) {
ND_PRINT((ndo, "truncated-%s - %u bytes missing!",
@@ -447,8 +436,8 @@ void dccp_print(netdissect_options *ndo, const u_char *bp, const u_char *data2,
ND_PRINT((ndo, "%s ", tok2str(dccp_pkt_type_str, "", dccph_type)));
break;
case DCCP_PKT_RESET: {
- struct dccp_hdr_reset *dhr =
- (struct dccp_hdr_reset *)(bp + fixed_hdrlen);
+ const struct dccp_hdr_reset *dhr =
+ (const struct dccp_hdr_reset *)(bp + fixed_hdrlen);
fixed_hdrlen += 12;
if (len < fixed_hdrlen) {
ND_PRINT((ndo, "truncated-%s - %u bytes missing!",
@@ -498,7 +487,6 @@ void dccp_print(netdissect_options *ndo, const u_char *bp, const u_char *data2,
/* process options */
if (hlen > fixed_hdrlen){
- const u_char *cp;
u_int optlen;
cp = bp + fixed_hdrlen;
ND_PRINT((ndo, " <"));
diff --git a/print-decnet.c b/print-decnet.c
index 5414ec20b5cd..88aa9e3efe75 100644
--- a/print-decnet.c
+++ b/print-decnet.c
@@ -19,12 +19,13 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: DECnet printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
struct mbuf;
struct rtentry;
@@ -38,12 +39,12 @@ struct rtentry;
#include <string.h>
#include "extract.h"
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
static const char tstr[] = "[|decnet]";
-#ifndef WIN32
+#ifndef _WIN32
typedef uint8_t byte[1]; /* single byte field */
#else
/*
@@ -51,7 +52,7 @@ typedef uint8_t byte[1]; /* single byte field */
*/
typedef unsigned char Byte[1]; /* single byte field */
#define byte Byte
-#endif /* WIN32 */
+#endif /* _WIN32 */
typedef uint8_t word[2]; /* 2 byte field */
typedef uint8_t longword[4]; /* 4 bytes field */
@@ -325,7 +326,6 @@ union controlmsg
#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 */
@@ -491,9 +491,6 @@ static void print_i_info(netdissect_options *, int);
static int print_elist(const char *, u_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(netdissect_options *, u_char *, u_int);
-#endif
#ifndef HAVE_NETDNET_DNETDB_H_DNET_HTOA
extern char *dnet_htoa(struct dn_naddr *);
@@ -586,7 +583,7 @@ decnet_print(netdissect_options *ndo,
break;
default:
ND_PRINT((ndo, "unknown message flags under mask"));
- ND_DEFAULTPRINT((u_char *)ap, min(length, caplen));
+ ND_DEFAULTPRINT((const u_char *)ap, min(length, caplen));
return;
}
@@ -617,11 +614,11 @@ print_decnet_ctlmsg(netdissect_options *ndo,
u_int caplen)
{
int mflags = EXTRACT_LE_8BITS(rhp->rh_short.sh_flags);
- register union controlmsg *cmp = (union controlmsg *)rhp;
+ register const union controlmsg *cmp = (const union controlmsg *)rhp;
int src, dst, info, blksize, eco, ueco, hello, other, vers;
etheraddr srcea, rtea;
int priority;
- char *rhpx = (char *)rhp;
+ const char *rhpx = (const char *)rhp;
int ret;
switch (mflags & RMF_CTLMASK) {
@@ -692,7 +689,7 @@ print_decnet_ctlmsg(netdissect_options *ndo,
vers = EXTRACT_LE_8BITS(cmp->cm_rhello.rh_vers);
eco = EXTRACT_LE_8BITS(cmp->cm_rhello.rh_eco);
ueco = EXTRACT_LE_8BITS(cmp->cm_rhello.rh_ueco);
- memcpy((char *)&srcea, (char *)&(cmp->cm_rhello.rh_src),
+ memcpy((char *)&srcea, (const char *)&(cmp->cm_rhello.rh_src),
sizeof(srcea));
src = EXTRACT_LE_16BITS(srcea.dne_remote.dne_nodeaddr);
info = EXTRACT_LE_8BITS(cmp->cm_rhello.rh_info);
@@ -715,13 +712,13 @@ print_decnet_ctlmsg(netdissect_options *ndo,
vers = EXTRACT_LE_8BITS(cmp->cm_ehello.eh_vers);
eco = EXTRACT_LE_8BITS(cmp->cm_ehello.eh_eco);
ueco = EXTRACT_LE_8BITS(cmp->cm_ehello.eh_ueco);
- memcpy((char *)&srcea, (char *)&(cmp->cm_ehello.eh_src),
+ memcpy((char *)&srcea, (const char *)&(cmp->cm_ehello.eh_src),
sizeof(srcea));
src = EXTRACT_LE_16BITS(srcea.dne_remote.dne_nodeaddr);
info = EXTRACT_LE_8BITS(cmp->cm_ehello.eh_info);
blksize = EXTRACT_LE_16BITS(cmp->cm_ehello.eh_blksize);
/*seed*/
- memcpy((char *)&rtea, (char *)&(cmp->cm_ehello.eh_router),
+ memcpy((char *)&rtea, (const char *)&(cmp->cm_ehello.eh_router),
sizeof(rtea));
dst = EXTRACT_LE_16BITS(rtea.dne_remote.dne_nodeaddr);
hello = EXTRACT_LE_16BITS(cmp->cm_ehello.eh_hello);
@@ -736,7 +733,7 @@ print_decnet_ctlmsg(netdissect_options *ndo,
default:
ND_PRINT((ndo, "unknown control message"));
- ND_DEFAULTPRINT((u_char *)rhp, min(length, caplen));
+ ND_DEFAULTPRINT((const u_char *)rhp, min(length, caplen));
ret = 1;
break;
}
@@ -855,7 +852,7 @@ static int
print_nsp(netdissect_options *ndo,
const u_char *nspp, u_int nsplen)
{
- const struct nsphdr *nsphp = (struct nsphdr *)nspp;
+ const struct nsphdr *nsphp = (const struct nsphdr *)nspp;
int dst, src, flags;
if (nsplen < sizeof(struct nsphdr))
@@ -874,11 +871,8 @@ print_nsp(netdissect_options *ndo,
case MFS_BOM+MFS_EOM:
ND_PRINT((ndo, "data %d>%d ", src, dst));
{
- struct seghdr *shp = (struct seghdr *)nspp;
+ const struct seghdr *shp = (const struct seghdr *)nspp;
int ack;
-#ifdef PRINT_NSPDATA
- u_char *dp;
-#endif
u_int data_off = sizeof(struct minseghdr);
if (nsplen < data_off)
@@ -908,23 +902,13 @@ print_nsp(netdissect_options *ndo,
}
}
ND_PRINT((ndo, "seg %d ", ack & SGQ_MASK));
-#ifdef PRINT_NSPDATA
- if (nsplen > data_off) {
- dp = &(nspp[data_off]);
- ND_TCHECK2(*dp, nsplen - data_off);
- pdata(ndo, dp, nsplen - data_off);
- }
-#endif
}
break;
case MFS_ILS+MFS_INT:
ND_PRINT((ndo, "intr "));
{
- struct seghdr *shp = (struct seghdr *)nspp;
+ const struct seghdr *shp = (const struct seghdr *)nspp;
int ack;
-#ifdef PRINT_NSPDATA
- u_char *dp;
-#endif
u_int data_off = sizeof(struct minseghdr);
if (nsplen < data_off)
@@ -954,21 +938,14 @@ print_nsp(netdissect_options *ndo,
}
}
ND_PRINT((ndo, "seg %d ", ack & SGQ_MASK));
-#ifdef PRINT_NSPDATA
- if (nsplen > data_off) {
- dp = &(nspp[data_off]);
- ND_TCHECK2(*dp, nsplen - data_off);
- pdata(ndo, dp, nsplen - data_off);
- }
-#endif
}
break;
case MFS_ILS:
ND_PRINT((ndo, "link-service %d>%d ", src, dst));
{
- struct seghdr *shp = (struct seghdr *)nspp;
- struct lsmsg *lsmp =
- (struct lsmsg *)&(nspp[sizeof(struct seghdr)]);
+ const struct seghdr *shp = (const struct seghdr *)nspp;
+ const struct lsmsg *lsmp =
+ (const struct lsmsg *)&(nspp[sizeof(struct seghdr)]);
int ack;
int lsflags, fcval;
@@ -1032,7 +1009,7 @@ print_nsp(netdissect_options *ndo,
case MFS_DACK:
ND_PRINT((ndo, "data-ack %d>%d ", src, dst));
{
- struct ackmsg *amp = (struct ackmsg *)nspp;
+ const struct ackmsg *amp = (const struct ackmsg *)nspp;
int ack;
if (nsplen < sizeof(struct ackmsg))
@@ -1057,7 +1034,7 @@ print_nsp(netdissect_options *ndo,
case MFS_IACK:
ND_PRINT((ndo, "ils-ack %d>%d ", src, dst));
{
- struct ackmsg *amp = (struct ackmsg *)nspp;
+ const struct ackmsg *amp = (const struct ackmsg *)nspp;
int ack;
if (nsplen < sizeof(struct ackmsg))
@@ -1098,11 +1075,8 @@ print_nsp(netdissect_options *ndo,
ND_PRINT((ndo, "retrans-conn-initiate "));
ND_PRINT((ndo, "%d>%d ", src, dst));
{
- struct cimsg *cimp = (struct cimsg *)nspp;
+ const struct cimsg *cimp = (const struct cimsg *)nspp;
int services, info, segsize;
-#ifdef PRINT_NSPDATA
- u_char *dp;
-#endif
if (nsplen < sizeof(struct cimsg))
goto trunc;
@@ -1120,9 +1094,6 @@ print_nsp(netdissect_options *ndo,
case COS_MESSAGE:
ND_PRINT((ndo, "msg "));
break;
- case COS_CRYPTSER:
- ND_PRINT((ndo, "crypt "));
- break;
}
switch (info & COI_MASK) {
case COI_32:
@@ -1139,24 +1110,14 @@ print_nsp(netdissect_options *ndo,
break;
}
ND_PRINT((ndo, "segsize %d ", segsize));
-#ifdef PRINT_NSPDATA
- if (nsplen > sizeof(struct cimsg)) {
- dp = &(nspp[sizeof(struct cimsg)]);
- ND_TCHECK2(*dp, nsplen - sizeof(struct cimsg));
- pdata(ndo, dp, nsplen - sizeof(struct cimsg));
- }
-#endif
}
break;
case MFS_CC:
ND_PRINT((ndo, "conn-confirm %d>%d ", src, dst));
{
- struct ccmsg *ccmp = (struct ccmsg *)nspp;
+ const struct ccmsg *ccmp = (const struct ccmsg *)nspp;
int services, info;
u_int segsize, optlen;
-#ifdef PRINT_NSPDATA
- u_char *dp;
-#endif
if (nsplen < sizeof(struct ccmsg))
goto trunc;
@@ -1175,9 +1136,6 @@ print_nsp(netdissect_options *ndo,
case COS_MESSAGE:
ND_PRINT((ndo, "msg "));
break;
- case COS_CRYPTSER:
- ND_PRINT((ndo, "crypt "));
- break;
}
switch (info & COI_MASK) {
case COI_32:
@@ -1196,25 +1154,15 @@ print_nsp(netdissect_options *ndo,
ND_PRINT((ndo, "segsize %d ", segsize));
if (optlen) {
ND_PRINT((ndo, "optlen %d ", optlen));
-#ifdef PRINT_NSPDATA
- if (optlen > nsplen - sizeof(struct ccmsg))
- goto trunc;
- dp = &(nspp[sizeof(struct ccmsg)]);
- ND_TCHECK2(*dp, optlen);
- pdata(ndo, dp, optlen);
-#endif
}
}
break;
case MFS_DI:
ND_PRINT((ndo, "disconn-initiate %d>%d ", src, dst));
{
- struct dimsg *dimp = (struct dimsg *)nspp;
+ const struct dimsg *dimp = (const struct dimsg *)nspp;
int reason;
u_int optlen;
-#ifdef PRINT_NSPDATA
- u_char *dp;
-#endif
if (nsplen < sizeof(struct dimsg))
goto trunc;
@@ -1225,20 +1173,13 @@ print_nsp(netdissect_options *ndo,
print_reason(ndo, reason);
if (optlen) {
ND_PRINT((ndo, "optlen %d ", optlen));
-#ifdef PRINT_NSPDATA
- if (optlen > nsplen - sizeof(struct dimsg))
- goto trunc;
- dp = &(nspp[sizeof(struct dimsg)]);
- ND_TCHECK2(*dp, optlen);
- pdata(ndo, dp, optlen);
-#endif
}
}
break;
case MFS_DC:
ND_PRINT((ndo, "disconn-confirm %d>%d ", src, dst));
{
- struct dcmsg *dcmp = (struct dcmsg *)nspp;
+ const struct dcmsg *dcmp = (const struct dcmsg *)nspp;
int reason;
ND_TCHECK(*dcmp);
@@ -1296,7 +1237,7 @@ print_reason(netdissect_options *ndo,
}
const char *
-dnnum_string(u_short dnaddr)
+dnnum_string(netdissect_options *ndo, u_short dnaddr)
{
char *str;
size_t siz;
@@ -1305,13 +1246,13 @@ dnnum_string(u_short dnaddr)
str = (char *)malloc(siz = sizeof("00.0000"));
if (str == NULL)
- error("dnnum_string: malloc");
+ (*ndo->ndo_error)(ndo, "dnnum_string: malloc");
snprintf(str, siz, "%d.%d", area, node);
return(str);
}
const char *
-dnname_string(u_short dnaddr)
+dnname_string(netdissect_options *ndo, u_short dnaddr)
{
#ifdef HAVE_DNET_HTOA
struct dn_naddr dna;
@@ -1323,23 +1264,8 @@ dnname_string(u_short dnaddr)
if(dnname != NULL)
return (strdup(dnname));
else
- return(dnnum_string(dnaddr));
+ return(dnnum_string(ndo, dnaddr));
#else
- return(dnnum_string(dnaddr)); /* punt */
+ return(dnnum_string(ndo, dnaddr)); /* punt */
#endif
}
-
-#ifdef PRINT_NSPDATA
-static void
-pdata(netdissect_options *ndo,
- u_char *dp, u_int maxlen)
-{
- char c;
- u_int x = maxlen;
-
- while (x-- > 0) {
- c = *dp++;
- safeputchar(ndo, c);
- }
-}
-#endif
diff --git a/print-dhcp6.c b/print-dhcp6.c
index 53b96ef954c9..762d9187eb0b 100644
--- a/print-dhcp6.c
+++ b/print-dhcp6.c
@@ -26,6 +26,9 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
+
+/* \summary: IPv6 DHCP printer */
+
/*
* RFC3315: DHCPv6
* supported DHCPv6 options:
@@ -40,17 +43,16 @@
* RFC6334: Dual-Stack Lite option,
*/
-#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <stdio.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
@@ -103,8 +105,8 @@ static const struct tok dh6_msgtype_str[] = {
/* DHCP6 base packet format */
struct dhcp6 {
union {
- uint8_t m;
- uint32_t x;
+ nd_uint8_t m;
+ nd_uint32_t x;
} dh6_msgtypexid;
/* options follow */
};
@@ -114,10 +116,10 @@ struct dhcp6 {
/* DHCPv6 relay messages */
struct dhcp6_relay {
- uint8_t dh6relay_msgtype;
- uint8_t dh6relay_hcnt;
- uint8_t dh6relay_linkaddr[16]; /* XXX: badly aligned */
- uint8_t dh6relay_peeraddr[16];
+ nd_uint8_t dh6relay_msgtype;
+ nd_uint8_t dh6relay_hcnt;
+ nd_uint8_t dh6relay_linkaddr[16]; /* XXX: badly aligned */
+ nd_uint8_t dh6relay_peeraddr[16];
/* options follow */
};
@@ -192,6 +194,7 @@ struct dhcp6_relay {
# define DH6OPT_NTP_SUBOPTION_MC_ADDR 2
# define DH6OPT_NTP_SUBOPTION_SRV_FQDN 3
#define DH6OPT_AFTR_NAME 64
+#define DH6OPT_MUDURL 112
static const struct tok dh6opt_str[] = {
{ DH6OPT_CLIENTID, "client-ID" },
@@ -242,27 +245,28 @@ static const struct tok dh6opt_str[] = {
{ DH6OPT_LQ_CLIENT_LINK, "LQ-client-link" },
{ DH6OPT_NTP_SERVER, "NTP-server" },
{ DH6OPT_AFTR_NAME, "AFTR-Name" },
+ { DH6OPT_MUDURL, "MUD-URL" },
{ 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" },
+ { DH6OPT_STCODE_SUCCESS, "Success" }, /* RFC3315 */
+ { DH6OPT_STCODE_UNSPECFAIL, "UnspecFail" }, /* RFC3315 */
+ { DH6OPT_STCODE_NOADDRAVAIL, "NoAddrsAvail" }, /* RFC3315 */
+ { DH6OPT_STCODE_NOBINDING, "NoBinding" }, /* RFC3315 */
+ { DH6OPT_STCODE_NOTONLINK, "NotOnLink" }, /* RFC3315 */
+ { DH6OPT_STCODE_USEMULTICAST, "UseMulticast" }, /* RFC3315 */
+ { DH6OPT_STCODE_NOPREFIXAVAIL, "NoPrefixAvail" }, /* RFC3633 */
+ { DH6OPT_STCODE_UNKNOWNQUERYTYPE, "UnknownQueryType" }, /* RFC5007 */
+ { DH6OPT_STCODE_MALFORMEDQUERY, "MalformedQuery" }, /* RFC5007 */
+ { DH6OPT_STCODE_NOTCONFIGURED, "NotConfigured" }, /* RFC5007 */
+ { DH6OPT_STCODE_NOTALLOWED, "NotAllowed" }, /* RFC5007 */
{ 0, NULL }
};
struct dhcp6opt {
- uint16_t dh6opt_type;
- uint16_t dh6opt_len;
+ nd_uint16_t dh6opt_type;
+ nd_uint16_t dh6opt_len;
/* type-dependent data follows */
};
@@ -293,13 +297,14 @@ dhcp6opt_print(netdissect_options *ndo,
while (cp < ep) {
if (ep < cp + sizeof(*dh6o))
goto trunc;
- dh6o = (struct dhcp6opt *)cp;
+ dh6o = (const struct dhcp6opt *)cp;
ND_TCHECK(*dh6o);
optlen = EXTRACT_16BITS(&dh6o->dh6opt_len);
if (ep < cp + sizeof(*dh6o) + optlen)
goto trunc;
opttype = EXTRACT_16BITS(&dh6o->dh6opt_type);
ND_PRINT((ndo, " (%s", tok2str(dh6opt_str, "opt_%u", opttype)));
+ ND_TCHECK2(*(cp + sizeof(*dh6o)), optlen);
switch (opttype) {
case DH6OPT_CLIENTID:
case DH6OPT_SERVERID:
@@ -308,7 +313,7 @@ dhcp6opt_print(netdissect_options *ndo,
ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
+ tp = (const u_char *)(dh6o + 1);
switch (EXTRACT_16BITS(tp)) {
case 1:
if (optlen >= 2 + 6) {
@@ -360,7 +365,7 @@ dhcp6opt_print(netdissect_options *ndo,
ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
+ tp = (const u_char *)(dh6o + 1);
ND_PRINT((ndo, " %s", ip6addr_string(ndo, &tp[0])));
ND_PRINT((ndo, " pltime:%u vltime:%u",
EXTRACT_32BITS(&tp[16]),
@@ -377,7 +382,7 @@ dhcp6opt_print(netdissect_options *ndo,
ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
+ tp = (const u_char *)(dh6o + 1);
for (i = 0; i < optlen; i += 2) {
ND_PRINT((ndo, " %s",
tok2str(dh6opt_str, "opt_%u", EXTRACT_16BITS(&tp[i]))));
@@ -389,7 +394,7 @@ dhcp6opt_print(netdissect_options *ndo,
ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
+ tp = (const u_char *)(dh6o + 1);
ND_PRINT((ndo, " %d)", *tp));
break;
case DH6OPT_ELAPSED_TIME:
@@ -397,12 +402,12 @@ dhcp6opt_print(netdissect_options *ndo,
ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
+ tp = (const u_char *)(dh6o + 1);
ND_PRINT((ndo, " %d)", EXTRACT_16BITS(tp)));
break;
case DH6OPT_RELAY_MSG:
ND_PRINT((ndo, " ("));
- tp = (u_char *)(dh6o + 1);
+ tp = (const u_char *)(dh6o + 1);
dhcp6_print(ndo, tp, optlen);
ND_PRINT((ndo, ")"));
break;
@@ -411,7 +416,7 @@ dhcp6opt_print(netdissect_options *ndo,
ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
+ tp = (const u_char *)(dh6o + 1);
auth_proto = *tp;
switch (auth_proto) {
case DH6OPT_AUTHPROTO_DELAYED:
@@ -506,14 +511,14 @@ dhcp6opt_print(netdissect_options *ndo,
* Since we cannot predict the encoding, print hex dump
* at most 10 characters.
*/
- tp = (u_char *)(dh6o + 1);
+ tp = (const u_char *)(dh6o + 1);
ND_PRINT((ndo, " "));
for (i = 0; i < optlen && i < 10; i++)
ND_PRINT((ndo, "%02x", tp[i]));
ND_PRINT((ndo, "...)"));
break;
case DH6OPT_RECONF_MSG:
- tp = (u_char *)(dh6o + 1);
+ tp = (const u_char *)(dh6o + 1);
switch (*tp) {
case DH6_RENEW:
ND_PRINT((ndo, " for renew)"));
@@ -541,14 +546,14 @@ dhcp6opt_print(netdissect_options *ndo,
ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
+ tp = (const u_char *)(dh6o + 1);
for (i = 0; i < optlen; i += 16)
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);
+ tp = (const u_char *)(dh6o + 1);
while (tp < cp + sizeof(*dh6o) + optlen) {
ND_PRINT((ndo, " "));
if ((tp = ns_nprint(ndo, tp, cp + sizeof(*dh6o) + optlen)) == NULL)
@@ -561,7 +566,7 @@ dhcp6opt_print(netdissect_options *ndo,
ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
+ tp = (const u_char *)(dh6o + 1);
ND_PRINT((ndo, " %s)", dhcp6stcode(EXTRACT_16BITS(&tp[0]))));
break;
case DH6OPT_IA_NA:
@@ -570,7 +575,7 @@ dhcp6opt_print(netdissect_options *ndo,
ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
+ tp = (const u_char *)(dh6o + 1);
ND_PRINT((ndo, " IAID:%u T1:%u T2:%u",
EXTRACT_32BITS(&tp[0]),
EXTRACT_32BITS(&tp[4]),
@@ -586,7 +591,7 @@ dhcp6opt_print(netdissect_options *ndo,
ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
+ tp = (const u_char *)(dh6o + 1);
ND_PRINT((ndo, " IAID:%u", EXTRACT_32BITS(tp)));
if (optlen > 4) {
/* there are sub-options */
@@ -599,7 +604,7 @@ dhcp6opt_print(netdissect_options *ndo,
ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
+ tp = (const u_char *)(dh6o + 1);
ND_PRINT((ndo, " %s/%d", ip6addr_string(ndo, &tp[9]), tp[8]));
ND_PRINT((ndo, " pltime:%u vltime:%u",
EXTRACT_32BITS(&tp[0]),
@@ -616,7 +621,7 @@ dhcp6opt_print(netdissect_options *ndo,
ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
+ tp = (const u_char *)(dh6o + 1);
ND_PRINT((ndo, " %d)", EXTRACT_32BITS(tp)));
break;
case DH6OPT_REMOTE_ID:
@@ -624,7 +629,7 @@ dhcp6opt_print(netdissect_options *ndo,
ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
+ tp = (const u_