Import tcpdump-4.9.0 into dist.

This commit is contained in:
Gleb Smirnoff 2017-01-31 19:17:06 +00:00
parent 1bf4ba1024
commit d79b843cb7
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/vendor/tcpdump/dist/; revision=313024
459 changed files with 23075 additions and 9718 deletions

190
CHANGES
View File

@ -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

103
CONTRIBUTING Normal file
View File

@ -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

View File

@ -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>

View File

@ -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

View File

@ -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)

9
PLATFORMS Normal file
View File

@ -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)

1
README Symbolic link
View File

@ -0,0 +1 @@
README.md

View File

@ -1 +1 @@
4.7.4
4.9.0

175
aclocal.m4 vendored
View File

@ -218,6 +218,36 @@ AC_DEFUN(AC_LBL_C_INIT,
fi
])
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
@ -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()
@ -1113,131 +1161,6 @@ dnl LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
dnl OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
dnl SUCH DAMAGE.
dnl
dnl Checks to see if AF_INET6 is defined
AC_DEFUN(AC_CHECK_AF_INET6, [
AC_MSG_CHECKING(for AF_INET6)
AC_CACHE_VAL($1,
AC_TRY_COMPILE([
# include <sys/types.h>
# include <sys/socket.h>],
[int a = AF_INET6],
$1=yes,
$1=no))
AC_MSG_RESULT($$1)
if test $$1 = yes ; then
AC_DEFINE(HAVE_AF_INET6)
fi
])
dnl
dnl Checks to see if the sockaddr struct has the 4.4 BSD sa_len member
dnl borrowed from LBL libpcap
AC_DEFUN(AC_CHECK_SA_LEN, [
AC_MSG_CHECKING(if sockaddr struct has sa_len member)
AC_CACHE_VAL($1,
AC_TRY_COMPILE([
# include <sys/types.h>
# include <sys/socket.h>],
[u_int i = sizeof(((struct sockaddr *)0)->sa_len)],
$1=yes,
$1=no))
AC_MSG_RESULT($$1)
if test $$1 = yes ; then
AC_DEFINE(HAVE_SOCKADDR_SA_LEN)
fi
])
dnl
dnl Checks for addrinfo structure
AC_DEFUN(AC_STRUCT_ADDRINFO, [
AC_MSG_CHECKING(for addrinfo)
AC_CACHE_VAL($1,
AC_TRY_COMPILE([
# include <netdb.h>],
[struct addrinfo a],
$1=yes,
$1=no))
AC_MSG_RESULT($$1)
if test $$1 = yes; then
AC_DEFINE(HAVE_ADDRINFO, 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

View File

@ -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 *

View File

@ -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

View File

@ -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
@ -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);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999 Kungliga Tekniska H<EFBFBD>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<EFBFBD>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);

5
af.c
View File

@ -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[] = {

6
af.h
View File

@ -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 */

105
ascii_strcasecmp.c Normal file
View File

@ -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]);
}

33
ascii_strcasecmp.h Normal file
View File

@ -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 */

View File

@ -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

View File

@ -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)

View File

@ -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 {

View File

@ -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

1167
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -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)
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(yes)
AC_DEFINE(HAVE_OS_IPV6_SUPPORT, 1,
[define if the OS provides AF_INET6 and struct in6_addr])
ipv6=yes
],
[
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)
#
# Check for special debugging functions
#
AC_CHECK_FUNCS(pcap_set_parser_debug)
if test "$ac_cv_func_pcap_set_parser_debug" = "no" ; then
#
# OK, what about "yydebug"?
#
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

19
cpack.c
View File

@ -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;

10
cpack.h
View File

@ -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))

11
ether.h
View File

@ -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

View File

@ -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[];

View File

@ -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)

View File

@ -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 */

View File

@ -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>

View File

@ -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;
}

View File

@ -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

44
ip.h
View File

@ -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 */

7
ip6.h
View File

@ -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_ */

View File

@ -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[] = {

101
l2vpn.c
View File

@ -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}
};

View File

@ -14,3 +14,4 @@
*/
extern const struct tok l2vpn_encaps_values[];
extern const struct tok mpls_pw_types_values[];

View File

@ -25,4 +25,3 @@ int setlinebuf(FILE *);
#endif
char *strerror(int);
int snprintf(char *, size_t, const char *, ...);
int strcasecmp(const char *, const char *);

View File

@ -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 *, ...);

View File

@ -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 *);

View File

@ -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)

View File

@ -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

2
mib.h
View File

@ -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

View File

@ -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

View File

@ -35,7 +35,7 @@
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
#include <netdissect-stdinc.h>
#include <pcap.h>
#include <stdlib.h>

View File

@ -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);
}

View File

@ -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;
}

View File

@ -1,53 +0,0 @@
/*
* Copyright (c) 1995, 1996, 1997 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Kungliga Tekniska
* Högskolan and its contributors.
*
* 4. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#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;
}

View File

@ -42,7 +42,7 @@
#include <ctype.h>
#include <sys/types.h>
#include <interface.h>
#include "netdissect.h"
enum format_flags {
minus_flag = 1,

View File

@ -35,7 +35,7 @@
#include <stdlib.h>
#include <string.h>
#include "interface.h"
#include "netdissect.h"
char *
strdup(str)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -70,20 +70,6 @@
/* number of bytes of fixed size data in resource record */
#define RRFIXEDSZ 10
/*
* Internet nameserver port number
*/
#define NAMESERVER_PORT 53
/*
* Port for multicast DNS; see
*
* http://files.multicastdns.org/draft-cheshire-dnsext-multicastdns.txt
*
* for the current mDNS spec.
*/
#define MULTICASTDNS_PORT 5353
/*
* Currently defined opcodes
*/

View File

@ -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 */

146
netdissect.c Normal file
View File

@ -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
}

View File

@ -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
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_printer lookup_printer(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;
/*
* 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;
};
/* 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 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);
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);
extern int print_unknown_data(netdissect_options *,const u_char *, const char *,int);
extern void ascii_print(netdissect_options *, const u_char *, u_int);
extern void hex_print_with_offset(netdissect_options *, const char *ident, const u_char *cp,
u_int, u_int);
extern void hex_print(netdissect_options *,const char *ident, const u_char *cp,u_int);
extern void hex_and_ascii_print_with_offset(netdissect_options *, const char *, const u_char *, u_int, u_int);
extern void hex_and_ascii_print(netdissect_options *, const char *, const u_char *, u_int);
extern 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 bfd_print(netdissect_options *, const u_char *, u_int, u_int);
extern void gre_print(netdissect_options *, const u_char *, u_int);
extern int vjc_print(netdissect_options *, register const char *, u_short);
extern void ipN_print(netdissect_options *, const u_char *, u_int);
extern u_int raw_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
extern u_int usb_linux_48_byte_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
extern u_int usb_linux_64_byte_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
extern u_int symantec_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
extern u_int chdlc_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
extern u_int chdlc_print(netdissect_options *, register const u_char *, u_int);
extern void zmtp1_print(netdissect_options *, const u_char *, u_int);
extern void zmtp1_print_datagram(netdissect_options *, const u_char *, const u_int);
extern void ipx_print(netdissect_options *, const u_char *, u_int);
extern void mpls_print(netdissect_options *, const u_char *, u_int);
extern u_int pppoe_print(netdissect_options *, const u_char *, u_int);
extern u_int pppoe_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
extern void sunrpcrequest_print(netdissect_options *, const u_char *, u_int, const u_char *);
extern u_int pflog_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
extern u_int token_print(netdissect_options *, const u_char *, u_int, u_int);
extern u_int token_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
extern void vqp_print(netdissect_options *, register const u_char *, register u_int);
extern void zephyr_print(netdissect_options *, const u_char *, int);
extern void fddi_print(netdissect_options *, const u_char *, u_int, u_int);
extern u_int fddi_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
extern void mpcp_print(netdissect_options *, const u_char *, u_int);
extern void rpki_rtr_print(netdissect_options *, const u_char *, u_int);
extern u_int sll_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
extern void dccp_print(netdissect_options *, const u_char *, const u_char *, u_int);
extern int llc_print(netdissect_options *, const u_char *, u_int, u_int, const u_char *, const u_char *, u_short *);
extern int snap_print(netdissect_options *, const u_char *, u_int, u_int, u_int);
extern void eigrp_print(netdissect_options *, const u_char *, u_int);
extern void stp_print(netdissect_options *, const u_char *, u_int);
extern void l2tp_print(netdissect_options *, const u_char *, u_int);
extern void udp_print(netdissect_options *, const u_char *, u_int, const u_char *, int);
extern void icmp_print(netdissect_options *, const u_char *, u_int, const u_char *, int);
extern void openflow_print(netdissect_options *, const u_char *, const u_int);
extern void telnet_print(netdissect_options *, const u_char *, u_int);
extern void slow_print(netdissect_options *, const u_char *, u_int);
extern void radius_print(netdissect_options *, const u_char *, u_int);
extern void lmp_print(netdissect_options *, const u_char *, u_int);
extern u_int fr_print(netdissect_options *, register const u_char *, u_int);
extern u_int mfr_print(netdissect_options *, register const u_char *, u_int);
extern u_int fr_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
extern u_int mfr_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
extern void q933_print(netdissect_options *, const u_char *, u_int);
extern void igmp_print(netdissect_options *, const u_char *, u_int);
extern void rip_print(netdissect_options *, const u_char *, u_int);
extern void lwapp_control_print(netdissect_options *, const u_char *, u_int, int);
extern void lwapp_data_print(netdissect_options *, const u_char *, u_int);
extern void pgm_print(netdissect_options *, const u_char *, u_int, const u_char *);
extern void pptp_print(netdissect_options *, const u_char *);
extern void ldp_print(netdissect_options *, const u_char *, u_int);
extern void wb_print(netdissect_options *, const void *, u_int);
extern int oam_print(netdissect_options *, const u_char *, u_int, u_int);
extern void atm_print(netdissect_options *, u_int, u_int, u_int, const u_char *, u_int, u_int);
extern u_int sunatm_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
extern u_int atm_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
extern void vtp_print(netdissect_options *, const u_char *, u_int);
extern int mptcp_print(netdissect_options *, const u_char *, u_int, u_char);
extern void ntp_print(netdissect_options *, const u_char *, u_int);
extern void cnfp_print(netdissect_options *, const u_char *);
extern void dvmrp_print(netdissect_options *, const u_char *, u_int);
extern void egp_print(netdissect_options *, const u_char *, u_int);
extern u_int enc_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
extern u_int sl_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
extern u_int sl_bsdos_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
extern void tftp_print(netdissect_options *, const u_char *, u_int);
extern void vrrp_print(netdissect_options *, const u_char *, u_int, const u_char *, int);
extern void pimv1_print(netdissect_options *, const u_char *, u_int);
extern void cisco_autorp_print(netdissect_options *, const u_char *, u_int);
extern void pim_print(netdissect_options *, const u_char *, u_int, u_int);
extern const u_char * ns_nprint (netdissect_options *, register const u_char *, register const u_char *);
extern void ns_print(netdissect_options *, const u_char *, u_int, int);
extern void bootp_print(netdissect_options *, const u_char *, u_int);
extern void sflow_print(netdissect_options *, const u_char *, u_int);
extern void aodv_print(netdissect_options *, const u_char *, u_int, int);
extern void sctp_print(netdissect_options *, const u_char *, const u_char *, u_int);
extern char *bgp_vpn_rd_print (netdissect_options *, const u_char *);
extern void 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 bgp_print(netdissect_options *, const u_char *, int);
extern void olsr_print(netdissect_options *, const u_char *, u_int, 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 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 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 ospf_print(netdissect_options *, const u_char *, u_int, const u_char *);
extern int ospf_print_te_lsa(netdissect_options *, const uint8_t *, u_int);
extern int ospf_print_grace_lsa(netdissect_options *, const uint8_t *, u_int);
extern u_int ppp_print(netdissect_options *, register const u_char *, u_int);
extern u_int ppp_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
extern u_int ppp_hdlc_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
extern u_int ppp_bsdos_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
extern void lldp_print(netdissect_options *, const u_char *, u_int);
extern void rsvp_print(netdissect_options *, const u_char *, u_int);
extern void timed_print(netdissect_options *, const u_char *);
extern void m3ua_print(netdissect_options *, const u_char *, const u_int);
extern void aoe_print(netdissect_options *, const u_char *, const u_int);
extern void ftp_print(netdissect_options *, const u_char *, u_int);
extern void http_print(netdissect_options *, const u_char *, u_int);
extern void rtsp_print(netdissect_options *, const u_char *, u_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 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 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 babel_print(netdissect_options *, const u_char *, u_int);
#endif /*INET6*/
extern void ospf_print(netdissect_options *, const u_char *, u_int, const u_char *);
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 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 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 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);
/* 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,
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 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],
u_char *buf, u_char *end);
extern void geonet_print(netdissect_options *ndo,const u_char *eth_hdr,const u_char *geo_pck, u_int len);
extern void calm_fast_print(netdissect_options *ndo,const u_char *eth_hdr,const u_char *calm_pck, u_int len);
const u_char *, const u_char *);
#endif /* netdissect_h */

View File

@ -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);

View File

@ -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[] = {

6
oui.c
View File

@ -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" },

47
oui.h
View File

@ -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

View File

@ -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 */
}
}
else {
if (is_UCX(fhp)) {
fhtype = FHT_VMSUCX;
}
else {
fhtype = FHT_UNKNOWN;
if ((fhp[4] != 0) && (fhp[5] == 0) &&
(fhp[8] == 12) && (fhp[9] == 0)) {
/* seems to be DECOSF, with minor == 0 */
fhtype = FHT_DECOSF;
}
else {
/* could be SUNOS4 or IRIX4 */
/* XXX the test of fhp[5] == 8 could be wrong */
if ((fhp[4] == 0) && (fhp[5] == 8) && (fhp[6] == 0) &&
(fhp[7] == 0)) {
/* looks like a length, not a file system typecode */
fhtype = FHT_IRIX4;
}
else {
/* by elimination */
fhtype = FHT_SUNOS4;
}
}
}
}
else {
/*
* bytes[0,1] != (0,0); rules out Auspex, IRIX4, SUNOS4
* could be IRIX5, DECOSF, UCX, Ultrix, SUNOS5
* could be AIX, HP-UX
*/
if ((fhp[2] == 0) && (fhp[3] == 0)) {
/*
* bytes[2,3] == (0,0); rules out OSF, probably not UCX
* (unless the exported device name is just one letter!),
* could be Ultrix, IRIX5, AIX, or SUNOS5
* might be HP-UX (depends on their values for minor devs)
*/
if ((fhp[6] == 0) && (fhp[7] == 0)) {
fhtype = FHT_BSD44;
}
/*XXX we probably only need to test of these two bytes */
else if ((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 {
/*
* 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)

View File

@ -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 */

File diff suppressed because it is too large Load Diff

View File

@ -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;
}

View File

@ -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;

View File

@ -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:

View File

@ -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 @@ aodv_rerr(netdissect_options *ndo, const u_char *dat, u_int length)
}
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

View File

@ -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:

View File

@ -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);

View File

@ -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"
/*

View File

@ -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))));

View File

@ -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

View File

@ -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);
}

View File

@ -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;
int llc_hdrlen;
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))));
}
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;
}

View File

@ -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;
}

View File

@ -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

View File

@ -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;

File diff suppressed because it is too large Load Diff

View File

@ -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;

View File

@ -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)

View File

@ -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;
}

View File

@ -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

View File

@ -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

View File

@ -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));
if (msg_ptr.cfm_ccm->md_nameformat != CFM_CCM_MD_FORMAT_NONE) {
/* -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;
}
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));
cfm_tlv_type));
/* 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);
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;
/*
* Check if there is a Chassis-ID.
*/
chassis_id_length = *tptr;
if (chassis_id_length > tlen) {
hexdump = TRUE;
break;
if (cfm_tlv_len < 1) {
ND_PRINT((ndo, " (too short, must be >= 1)"));
return;
}
/*
* Get the Chassis ID length and check it.
*/
chassis_id_length = *tptr;
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"));
}

View File

@ -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)

View File

@ -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);
}

View File

@ -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"

View File

@ -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, " <"));

View File

@ -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

View File

@ -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_char *)(dh6o + 1);
ND_PRINT((ndo, " %d ", EXTRACT_32BITS(tp)));
/*
* Print hex dump first 10 characters.
@ -638,7 +643,7 @@ dhcp6opt_print(netdissect_options *ndo,
ND_PRINT((ndo, " ?)"));
break;
}
tp = (u_char *)(dh6o + 1);
tp = (const u_char *)(dh6o + 1);
switch (*tp) {
case 1:
ND_PRINT((ndo, " by-address"));
@ -658,7 +663,7 @@ dhcp6opt_print(netdissect_options *ndo,
ND_PRINT((ndo, ")"));
break;
case DH6OPT_CLIENT_DATA:
tp = (u_char *)(dh6o + 1);
tp = (const u_char *)(dh6o + 1);
if (optlen > 0) {
/* there are encapsulated options */
dhcp6opt_print(ndo, tp, tp + optlen);
@ -670,7 +675,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])));
/*
* Print hex dump first 10 characters.
@ -684,7 +689,7 @@ dhcp6opt_print(netdissect_options *ndo,
ND_PRINT((ndo, " ?)"));
break;
}
tp = (u_char *)(dh6o + 1);
tp = (const u_char *)(dh6o + 1);
while (tp < cp + sizeof(*dh6o) + optlen - 4) {
subopt_code = EXTRACT_16BITS(tp);
tp += 2;
@ -720,14 +725,14 @@ dhcp6opt_print(netdissect_options *ndo,
ND_PRINT((ndo, " ?)"));
break;
}
tp = (u_char *)(dh6o + 1);
tp = (const u_char *)(dh6o + 1);
remain_len = optlen;
ND_PRINT((ndo, " "));
/* Encoding is described in section 3.1 of RFC 1035 */
while (remain_len && *tp) {
label_len = *tp++;
if (label_len < remain_len - 1) {
ND_PRINT((ndo, "%.*s", label_len, tp));
(void)fn_printn(ndo, tp, label_len, NULL);
tp += label_len;
remain_len -= (label_len + 1);
if(*tp) ND_PRINT((ndo, "."));
@ -738,6 +743,19 @@ dhcp6opt_print(netdissect_options *ndo,
}
ND_PRINT((ndo, ")"));
break;
case DH6OPT_NEW_POSIX_TIMEZONE: /* all three of these options */
case DH6OPT_NEW_TZDB_TIMEZONE: /* are encoded similarly */
case DH6OPT_MUDURL: /* although GMT might not work */
if (optlen < 5) {
ND_PRINT((ndo, " ?)"));
break;
}
tp = (const u_char *)(dh6o + 1);
ND_PRINT((ndo, "="));
(void)fn_printn(ndo, tp, (u_int)optlen, NULL);
ND_PRINT((ndo, ")"));
break;
default:
ND_PRINT((ndo, ")"));
break;
@ -758,20 +776,20 @@ void
dhcp6_print(netdissect_options *ndo,
const u_char *cp, u_int length)
{
struct dhcp6 *dh6;
struct dhcp6_relay *dh6relay;
const struct dhcp6 *dh6;
const struct dhcp6_relay *dh6relay;
const u_char *ep;
u_char *extp;
const u_char *extp;
const char *name;
ND_PRINT((ndo, "dhcp6"));
ep = (u_char *)ndo->ndo_snapend;
ep = (const u_char *)ndo->ndo_snapend;
if (cp + length < ep)
ep = cp + length;
dh6 = (struct dhcp6 *)cp;
dh6relay = (struct dhcp6_relay *)cp;
dh6 = (const struct dhcp6 *)cp;
dh6relay = (const struct dhcp6_relay *)cp;
ND_TCHECK(dh6->dh6_xid);
name = tok2str(dh6_msgtype_str, "msgtype-%u", dh6->dh6_msgtype);
@ -786,7 +804,7 @@ dhcp6_print(netdissect_options *ndo,
if (dh6->dh6_msgtype != DH6_RELAY_FORW &&
dh6->dh6_msgtype != DH6_RELAY_REPLY) {
ND_PRINT((ndo, "xid=%x", EXTRACT_32BITS(&dh6->dh6_xid) & DH6_XIDMASK));
extp = (u_char *)(dh6 + 1);
extp = (const u_char *)(dh6 + 1);
dhcp6opt_print(ndo, extp, ep);
} else { /* relay messages */
struct in6_addr addr6;
@ -799,7 +817,7 @@ dhcp6_print(netdissect_options *ndo,
memcpy(&addr6, dh6relay->dh6relay_peeraddr, sizeof (addr6));
ND_PRINT((ndo, " peeraddr=%s", ip6addr_string(ndo, &addr6)));
dhcp6opt_print(ndo, (u_char *)(dh6relay + 1), ep);
dhcp6opt_print(ndo, (const u_char *)(dh6relay + 1), ep);
}
/*(*/
ND_PRINT((ndo, ")"));

View File

@ -19,20 +19,22 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#define NETDISSECT_REWORKED
/* \summary: Domain Name System (DNS) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
#include <netdissect-stdinc.h>
#include "nameser.h"
#include <string.h>
#include "interface.h"
#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h" /* must come after interface.h */
#include "addrtostr.h"
#include "extract.h"
static const char *ns_ops[] = {
"", " inv_q", " stat", " op3", " notify", " update", " op6", " op7",
@ -395,7 +397,7 @@ ns_rprint(netdissect_options *ndo,
} else if (ndo->ndo_vflag > 2) {
/* print ttl */
ND_PRINT((ndo, " ["));
relts_print(ndo, EXTRACT_32BITS(cp));
unsigned_relts_print(ndo, EXTRACT_32BITS(cp));
ND_PRINT((ndo, "]"));
cp += 4;
} else {
@ -481,17 +483,14 @@ ns_rprint(netdissect_options *ndo,
EXTRACT_16BITS(cp), EXTRACT_16BITS(cp + 2)));
break;
#ifdef INET6
case T_AAAA:
{
struct in6_addr addr;
char ntop_buf[INET6_ADDRSTRLEN];
if (!ND_TTEST2(*cp, sizeof(struct in6_addr)))
return(NULL);
memcpy(&addr, cp, sizeof(struct in6_addr));
ND_PRINT((ndo, " %s",
inet_ntop(AF_INET6, &addr, ntop_buf, sizeof(ntop_buf))));
addrtostr6(cp, ntop_buf, sizeof(ntop_buf))));
break;
}
@ -515,7 +514,7 @@ ns_rprint(netdissect_options *ndo,
memset(&a, 0, sizeof(a));
memcpy(&a.s6_addr[pbyte], cp + 1, sizeof(a) - pbyte);
ND_PRINT((ndo, " %u %s", pbit,
inet_ntop(AF_INET6, &a, ntop_buf, sizeof(ntop_buf))));
addrtostr6(&a, ntop_buf, sizeof(ntop_buf))));
}
if (pbit > 0) {
ND_PRINT((ndo, " "));
@ -524,12 +523,11 @@ ns_rprint(netdissect_options *ndo,
}
break;
}
#endif /*INET6*/
case T_OPT:
ND_PRINT((ndo, " UDPsize=%u", class));
if (opt_flags & 0x8000)
ND_PRINT((ndo, " OK"));
ND_PRINT((ndo, " DO"));
break;
case T_UNSPECA: /* One long string */
@ -666,7 +664,7 @@ ns_print(netdissect_options *ndo,
DNS_CD(np) ? "%" : ""));
/* any weirdness? */
b2 = EXTRACT_16BITS(((u_short *)np)+1);
b2 = EXTRACT_16BITS(((const u_short *)np)+1);
if (b2 & 0x6cf)
ND_PRINT((ndo, " [b2&3=0x%x]", b2));

View File

@ -12,22 +12,23 @@
* LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE.
*
* Dynamic Trunk Protocol (DTP)
*
* Original code by Carles Kishimoto <carles.kishimoto@gmail.com>
*/
#define NETDISSECT_REWORKED
/* \summary: Dynamic Trunking Protocol (DTP) 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"
static const char tstr[] = " [|dtp]";
#define DTP_HEADER_LEN 1
#define DTP_DOMAIN_TLV 0x0001
#define DTP_STATUS_TLV 0x0002
@ -71,30 +72,36 @@ dtp_print (netdissect_options *ndo, const u_char *pptr, u_int length)
while (tptr < (pptr+length)) {
ND_TCHECK2(*tptr, 4);
type = EXTRACT_16BITS(tptr);
len = EXTRACT_16BITS(tptr+2);
/* infinite loop check */
if (type == 0 || len == 0) {
/* XXX: should not be but sometimes it is, see the test captures */
if (type == 0)
return;
}
ND_PRINT((ndo, "\n\t%s (0x%04x) TLV, length %u",
tok2str(dtp_tlv_values, "Unknown", type),
type, len));
/* infinite loop check */
if (len < 4)
goto invalid;
ND_TCHECK2(*tptr, len);
switch (type) {
case DTP_DOMAIN_TLV:
ND_PRINT((ndo, ", %s", tptr+4));
ND_PRINT((ndo, ", "));
fn_printzp(ndo, tptr+4, len-4, pptr+length);
break;
case DTP_STATUS_TLV:
case DTP_DTP_TYPE_TLV:
if (len < 5)
goto invalid;
ND_PRINT((ndo, ", 0x%x", *(tptr+4)));
break;
case DTP_NEIGHBOR_TLV:
if (len < 10)
goto invalid;
ND_PRINT((ndo, ", %s", etheraddr_string(ndo, tptr+4)));
break;
@ -106,8 +113,11 @@ dtp_print (netdissect_options *ndo, const u_char *pptr, u_int length)
return;
invalid:
ND_PRINT((ndo, "%s", istr));
return;
trunc:
ND_PRINT((ndo, "[|dtp]"));
ND_PRINT((ndo, "%s", tstr));
}
/*

View File

@ -19,14 +19,15 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#define NETDISSECT_REWORKED
/* \summary: Distance Vector Multicast Routing Protocol 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"
@ -337,7 +338,7 @@ print_prune(netdissect_options *ndo,
ND_PRINT((ndo, " src %s grp %s", ipaddr_string(ndo, bp), ipaddr_string(ndo, bp + 4)));
bp += 8;
ND_PRINT((ndo, " timer "));
relts_print(ndo, EXTRACT_32BITS(bp));
unsigned_relts_print(ndo, EXTRACT_32BITS(bp));
return (0);
trunc:
return (-1);

View File

@ -16,19 +16,17 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* Format and print EAP packets.
*
*/
#define NETDISSECT_REWORKED
/* \summary: Extensible Authentication Protocol (EAP) 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"
#define EAP_FRAME_TYPE_PACKET 0
@ -151,7 +149,7 @@ static const struct tok eap_aka_subtype_values[] = {
void
eap_print(netdissect_options *ndo,
register const u_char *cp,
u_int length _U_)
u_int length)
{
const struct eap_frame_t *eap;
const u_char *tptr;

View File

@ -18,14 +18,15 @@
* Initial contribution from Jeff Honig (jch@MITCHELL.CIT.CORNELL.EDU).
*/
#define NETDISSECT_REWORKED
/* \summary: Exterior Gateway Protocol (EGP) 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"
@ -128,7 +129,7 @@ static const char *egp_reasons[] = {
static void
egpnrprint(netdissect_options *ndo,
register const struct egp_packet *egp)
register const struct egp_packet *egp, u_int length)
{
register const uint8_t *cp;
uint32_t addr;
@ -152,12 +153,15 @@ egpnrprint(netdissect_options *ndo,
net = 0;
netlen = 0;
}
cp = (uint8_t *)(egp + 1);
cp = (const uint8_t *)(egp + 1);
length -= sizeof(*egp);
t_gateways = egp->egp_intgw + egp->egp_extgw;
for (gateways = 0; gateways < t_gateways; ++gateways) {
/* Pickup host part of gateway address */
addr = 0;
if (length < 4 - netlen)
goto trunc;
ND_TCHECK2(cp[0], 4 - netlen);
switch (netlen) {
@ -171,8 +175,12 @@ egpnrprint(netdissect_options *ndo,
addr = (addr << 8) | *cp++;
}
addr |= net;
length -= 4 - netlen;
if (length < 1)
goto trunc;
ND_TCHECK2(cp[0], 1);
distances = *cp++;
length--;
ND_PRINT((ndo, " %s %s ",
gateways < (int)egp->egp_intgw ? "int" : "ext",
ipaddr_string(ndo, &addr)));
@ -180,21 +188,33 @@ egpnrprint(netdissect_options *ndo,
comma = "";
ND_PRINT((ndo, "("));
while (--distances >= 0) {
if (length < 2)
goto trunc;
ND_TCHECK2(cp[0], 2);
ND_PRINT((ndo, "%sd%d:", comma, (int)*cp++));
comma = ", ";
networks = *cp++;
length -= 2;
while (--networks >= 0) {
/* Pickup network number */
if (length < 1)
goto trunc;
ND_TCHECK2(cp[0], 1);
addr = (uint32_t)*cp++ << 24;
length--;
if (IN_CLASSB(addr)) {
if (length < 1)
goto trunc;
ND_TCHECK2(cp[0], 1);
addr |= (uint32_t)*cp++ << 16;
length--;
} else if (!IN_CLASSA(addr)) {
if (length < 2)
goto trunc;
ND_TCHECK2(cp[0], 2);
addr |= (uint32_t)*cp++ << 16;
addr |= (uint32_t)*cp++ << 8;
length -= 2;
}
ND_PRINT((ndo, " %s", ipaddr_string(ndo, &addr)));
}
@ -215,8 +235,8 @@ egp_print(netdissect_options *ndo,
register int code;
register int type;
egp = (struct egp_packet *)bp;
if (!ND_TTEST2(*egp, length)) {
egp = (const struct egp_packet *)bp;
if (length < sizeof(*egp) || !ND_TTEST(*egp)) {
ND_PRINT((ndo, "[|egp]"));
return;
}
@ -333,7 +353,7 @@ egp_print(netdissect_options *ndo,
egp->egp_intgw,
egp->egp_extgw));
if (ndo->ndo_vflag)
egpnrprint(ndo, egp);
egpnrprint(ndo, egp, length);
break;
case EGPT_ERROR:

View File

@ -14,16 +14,17 @@
* FOR A PARTICULAR PURPOSE.
*/
#define NETDISSECT_REWORKED
/* \summary: Enhanced Interior Gateway Routing Protocol (EIGRP) 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 "extract.h"
#include "addrtoname.h"

View File

@ -21,14 +21,15 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#define NETDISSECT_REWORKED
/* \summary: OpenBSD IPsec encapsulation BPF layer 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"
/* From $OpenBSD: if_enc.h,v 1.8 2001/06/25 05:14:00 angelos Exp $ */
@ -98,7 +99,7 @@ enc_if_print(netdissect_options *ndo,
goto out;
}
hdr = (struct enchdr *)p;
hdr = (const struct enchdr *)p;
flags = hdr->flags;
if (flags == 0)
ND_PRINT((ndo, "(unprotected): "));

View File

@ -21,12 +21,13 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#define NETDISSECT_REWORKED
/* \summary: IPSEC Encapsulating Security Payload (ESP) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
#include <netdissect-stdinc.h>
#include <string.h>
#include <stdlib.h>
@ -43,14 +44,15 @@
#endif
#endif
#include "ip.h"
#ifdef INET6
#include "ip6.h"
#endif
#include "interface.h"
#include "netdissect.h"
#include "strtoaddr.h"
#include "extract.h"
#include "ascii_strcasecmp.h"
#include "ip.h"
#include "ip6.h"
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* All rights reserved.
@ -98,9 +100,7 @@ struct newesp {
#ifdef HAVE_LIBCRYPTO
union inaddr_u {
struct in_addr in4;
#ifdef INET6
struct in6_addr in6;
#endif
};
struct sa_list {
struct sa_list *next;
@ -119,6 +119,32 @@ struct sa_list {
int secretlen;
};
#ifndef HAVE_EVP_CIPHER_CTX_NEW
/*
* Allocate an EVP_CIPHER_CTX.
* Used if we have an older version of OpenSSL that doesn't provide
* routines to allocate and free them.
*/
static EVP_CIPHER_CTX *
EVP_CIPHER_CTX_new(void)
{
EVP_CIPHER_CTX *ctx;
ctx = malloc(sizeof(*ctx));
if (ctx == NULL)
return (NULL);
memset(ctx, 0, sizeof(*ctx));
return (ctx);
}
static void
EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *ctx)
{
EVP_CIPHER_CTX_cleanup(ctx);
free(ctx);
}
#endif
/*
* this will adjust ndo_packetp and ndo_snapend to new buffer!
*/
@ -126,12 +152,12 @@ USES_APPLE_DEPRECATED_API
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)
const u_char *buf, const u_char *end)
{
struct sa_list *sa;
u_char *iv;
const u_char *iv;
int len;
EVP_CIPHER_CTX ctx;
EVP_CIPHER_CTX *ctx;
/* initiator arg is any non-zero value */
if(initiator) initiator=1;
@ -159,12 +185,14 @@ int esp_print_decrypt_buffer_by_ikev2(netdissect_options *ndo,
if(end <= buf) return 0;
memset(&ctx, 0, sizeof(ctx));
if (EVP_CipherInit(&ctx, sa->evp, sa->secret, NULL, 0) < 0)
ctx = EVP_CIPHER_CTX_new();
if (ctx == NULL)
return 0;
if (EVP_CipherInit(ctx, sa->evp, sa->secret, NULL, 0) < 0)
(*ndo->ndo_warning)(ndo, "espkey init failed");
EVP_CipherInit(&ctx, NULL, NULL, iv, 0);
EVP_Cipher(&ctx, buf, buf, len);
EVP_CIPHER_CTX_cleanup(&ctx);
EVP_CipherInit(ctx, NULL, NULL, iv, 0);
EVP_Cipher(ctx, buf, buf, len);
EVP_CIPHER_CTX_free(ctx);
ndo->ndo_packetp = buf;
ndo->ndo_snapend = end;
@ -332,8 +360,8 @@ espprint_decode_authalgo(netdissect_options *ndo,
}
*colon = '\0';
if(strcasecmp(colon,"sha1") == 0 ||
strcasecmp(colon,"md5") == 0) {
if(ascii_strcasecmp(colon,"sha1") == 0 ||
ascii_strcasecmp(colon,"md5") == 0) {
sa->authlen = 12;
}
return 1;
@ -427,22 +455,23 @@ static void esp_print_decode_onesecret(netdissect_options *ndo, char *line,
} else
decode = line;
if (spikey && strcasecmp(spikey, "file") == 0) {
if (spikey && ascii_strcasecmp(spikey, "file") == 0) {
/* open file and read it */
FILE *secretfile;
char fileline[1024];
int lineno=0;
int subfile_lineno=0;
char *nl;
char *filename = line;
secretfile = fopen(filename, FOPEN_READ_TXT);
if (secretfile == NULL) {
perror(filename);
exit(3);
(*ndo->ndo_error)(ndo, "print_esp: can't open %s: %s\n",
filename, strerror(errno));
return;
}
while (fgets(fileline, sizeof(fileline)-1, secretfile) != NULL) {
lineno++;
subfile_lineno++;
/* remove newline from the line */
nl = strchr(fileline, '\n');
if (nl)
@ -450,14 +479,14 @@ static void esp_print_decode_onesecret(netdissect_options *ndo, char *line,
if (fileline[0] == '#') continue;
if (fileline[0] == '\0') continue;
esp_print_decode_onesecret(ndo, fileline, filename, lineno);
esp_print_decode_onesecret(ndo, fileline, filename, subfile_lineno);
}
fclose(secretfile);
return;
}
if (spikey && strcasecmp(spikey, "ikev2") == 0) {
if (spikey && ascii_strcasecmp(spikey, "ikev2") == 0) {
esp_print_decode_ikeline(ndo, line, file, lineno);
return;
}
@ -477,17 +506,14 @@ static void esp_print_decode_onesecret(netdissect_options *ndo, char *line,
sa1.spi = spino;
#ifdef INET6
if (inet_pton(AF_INET6, spikey, &sa1.daddr.in6) == 1) {
if (strtoaddr6(spikey, &sa1.daddr.in6) == 1) {
sa1.daddr_version = 6;
} else
#endif
if (inet_pton(AF_INET, spikey, &sa1.daddr.in4) == 1) {
sa1.daddr_version = 4;
} else {
(*ndo->ndo_warning)(ndo, "print_esp: can not decode IP# %s\n", spikey);
return;
}
} else if (strtoaddr(spikey, &sa1.daddr.in4) == 1) {
sa1.daddr_version = 4;
} else {
(*ndo->ndo_warning)(ndo, "print_esp: can not decode IP# %s\n", spikey);
return;
}
}
if (decode) {
@ -506,8 +532,14 @@ static void esp_print_decode_onesecret(netdissect_options *ndo, char *line,
USES_APPLE_DEPRECATED_API
static void esp_init(netdissect_options *ndo _U_)
{
/*
* 0.9.6 doesn't appear to define OPENSSL_API_COMPAT, so
* we check whether it's undefined or it's less than the
* value for 1.1.0.
*/
#if !defined(OPENSSL_API_COMPAT) || OPENSSL_API_COMPAT < 0x10100000L
OpenSSL_add_all_algorithms();
#endif
EVP_add_cipher_alias(SN_des_ede3_cbc, "3des");
}
USES_APPLE_RST
@ -564,21 +596,19 @@ esp_print(netdissect_options *ndo,
register const struct newesp *esp;
register const u_char *ep;
#ifdef HAVE_LIBCRYPTO
struct ip *ip;
const struct ip *ip;
struct sa_list *sa = NULL;
#ifdef INET6
struct ip6_hdr *ip6 = NULL;
#endif
const struct ip6_hdr *ip6 = NULL;
int advance;
int len;
u_char *secret;
int ivlen = 0;
u_char *ivoff;
u_char *p;
EVP_CIPHER_CTX ctx;
const u_char *ivoff;
const u_char *p;
EVP_CIPHER_CTX *ctx;
#endif
esp = (struct newesp *)bp;
esp = (const struct newesp *)bp;
#ifdef HAVE_LIBCRYPTO
secret = NULL;
@ -593,7 +623,7 @@ esp_print(netdissect_options *ndo,
/* 'ep' points to the end of available data. */
ep = ndo->ndo_snapend;
if ((u_char *)(esp + 1) >= ep) {
if ((const u_char *)(esp + 1) >= ep) {
ND_PRINT((ndo, "[|ESP]"));
goto fail;
}
@ -615,11 +645,10 @@ esp_print(netdissect_options *ndo,
if (ndo->ndo_sa_list_head == NULL)
goto fail;
ip = (struct ip *)bp2;
ip = (const struct ip *)bp2;
switch (IP_V(ip)) {
#ifdef INET6
case 6:
ip6 = (struct ip6_hdr *)bp2;
ip6 = (const struct ip6_hdr *)bp2;
/* we do not attempt to decrypt jumbograms */
if (!EXTRACT_16BITS(&ip6->ip6_plen))
goto fail;
@ -636,7 +665,6 @@ esp_print(netdissect_options *ndo,
}
}
break;
#endif /*INET6*/
case 4:
/* nexthdr & padding are in the last fragment */
if (EXTRACT_16BITS(&ip->ip_off) & IP_MF)
@ -675,21 +703,24 @@ esp_print(netdissect_options *ndo,
ep = bp2 + len;
}
ivoff = (u_char *)(esp + 1) + 0;
ivoff = (const u_char *)(esp + 1) + 0;
ivlen = sa->ivlen;
secret = sa->secret;
ep = ep - sa->authlen;
if (sa->evp) {
memset(&ctx, 0, sizeof(ctx));
if (EVP_CipherInit(&ctx, sa->evp, secret, NULL, 0) < 0)
(*ndo->ndo_warning)(ndo, "espkey init failed");
ctx = EVP_CIPHER_CTX_new();
if (ctx != NULL) {
if (EVP_CipherInit(ctx, sa->evp, secret, NULL, 0) < 0)
(*ndo->ndo_warning)(ndo, "espkey init failed");
p = ivoff;
EVP_CipherInit(&ctx, NULL, NULL, p, 0);
EVP_Cipher(&ctx, p + ivlen, p + ivlen, ep - (p + ivlen));
EVP_CIPHER_CTX_cleanup(&ctx);
advance = ivoff - (u_char *)esp + ivlen;
p = ivoff;
EVP_CipherInit(ctx, NULL, NULL, p, 0);
EVP_Cipher(ctx, p + ivlen, p + ivlen, ep - (p + ivlen));
EVP_CIPHER_CTX_free(ctx);
advance = ivoff - (const u_char *)esp + ivlen;
} else
advance = sizeof(struct newesp);
} else
advance = sizeof(struct newesp);

View File

@ -19,14 +19,15 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#define NETDISSECT_REWORKED
/* \summary: Ethernet 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"
@ -83,6 +84,7 @@ const struct tok ethertype_values[] = {
{ ETHERTYPE_GEONET, "GeoNet"},
{ ETHERTYPE_CALM_FAST, "CALM FAST"},
{ ETHERTYPE_AOE, "AoE" },
{ ETHERTYPE_MEDSA, "MEDSA" },
{ 0, NULL}
};
@ -91,7 +93,7 @@ ether_hdr_print(netdissect_options *ndo,
const u_char *bp, u_int length)
{
register const struct ether_header *ep;
uint16_t ether_type;
uint16_t length_type;
ep = (const struct ether_header *)bp;
@ -99,19 +101,21 @@ ether_hdr_print(netdissect_options *ndo,
etheraddr_string(ndo, ESRC(ep)),
etheraddr_string(ndo, EDST(ep))));
ether_type = EXTRACT_16BITS(&ep->ether_type);
length_type = EXTRACT_16BITS(&ep->ether_length_type);
if (!ndo->ndo_qflag) {
if (ether_type <= ETHERMTU)
ND_PRINT((ndo, ", 802.3"));
else
ND_PRINT((ndo, ", ethertype %s (0x%04x)",
tok2str(ethertype_values,"Unknown", ether_type),
ether_type));
if (length_type <= ETHERMTU) {
ND_PRINT((ndo, ", 802.3"));
length = length_type;
} else
ND_PRINT((ndo, ", ethertype %s (0x%04x)",
tok2str(ethertype_values,"Unknown", length_type),
length_type));
} else {
if (ether_type <= ETHERMTU)
ND_PRINT((ndo, ", 802.3"));
else
ND_PRINT((ndo, ", %s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", ether_type)));
if (length_type <= ETHERMTU) {
ND_PRINT((ndo, ", 802.3"));
length = length_type;
} else
ND_PRINT((ndo, ", %s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", length_type)));
}
ND_PRINT((ndo, ", length %u: ", length));
@ -122,20 +126,28 @@ ether_hdr_print(netdissect_options *ndo,
* This might be encapsulated within another frame; we might be passed
* a pointer to a function that can print header information for that
* frame's protocol, and an argument to pass to that function.
*
* FIXME: caplen can and should be derived from ndo->ndo_snapend and p.
*/
void
u_int
ether_print(netdissect_options *ndo,
const u_char *p, u_int length, u_int caplen,
void (*print_encap_header)(netdissect_options *ndo, const u_char *), const u_char *encap_header_arg)
{
struct ether_header *ep;
const struct ether_header *ep;
u_int orig_length;
u_short ether_type;
u_short extracted_ether_type;
u_short length_type;
u_int hdrlen;
int llc_hdrlen;
struct lladdr_info src, dst;
if (caplen < ETHER_HDRLEN || length < ETHER_HDRLEN) {
if (caplen < ETHER_HDRLEN) {
ND_PRINT((ndo, "[|ether]"));
return;
return (caplen);
}
if (length < ETHER_HDRLEN) {
ND_PRINT((ndo, "[|ether]"));
return (length);
}
if (ndo->ndo_eflag) {
@ -147,55 +159,61 @@ ether_print(netdissect_options *ndo,
length -= ETHER_HDRLEN;
caplen -= ETHER_HDRLEN;
ep = (struct ether_header *)p;
ep = (const struct ether_header *)p;
p += ETHER_HDRLEN;
hdrlen = ETHER_HDRLEN;
ether_type = EXTRACT_16BITS(&ep->ether_type);
src.addr = ESRC(ep);
src.addr_string = etheraddr_string;
dst.addr = EDST(ep);
dst.addr_string = etheraddr_string;
length_type = EXTRACT_16BITS(&ep->ether_length_type);
recurse:
/*
* Is it (gag) an 802.3 encapsulation?
*/
if (ether_type <= ETHERMTU) {
if (length_type <= ETHERMTU) {
/* Try to print the LLC-layer header & higher layers */
if (llc_print(ndo, p, length, caplen, ESRC(ep), EDST(ep),
&extracted_ether_type) == 0) {
/* ether_type not known, print raw packet */
if (!ndo->ndo_eflag) {
if (print_encap_header != NULL)
(*print_encap_header)(ndo, encap_header_arg);
ether_hdr_print(ndo, (u_char *)ep, orig_length);
}
llc_hdrlen = llc_print(ndo, p, length, caplen, &src, &dst);
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 if (ether_type == ETHERTYPE_8021Q ||
ether_type == ETHERTYPE_8021Q9100 ||
ether_type == ETHERTYPE_8021Q9200 ||
ether_type == ETHERTYPE_8021QinQ) {
hdrlen += llc_hdrlen;
} else if (length_type == ETHERTYPE_8021Q ||
length_type == ETHERTYPE_8021Q9100 ||
length_type == ETHERTYPE_8021Q9200 ||
length_type == ETHERTYPE_8021QinQ) {
/*
* Print VLAN information, and then go back and process
* the enclosed type field.
*/
if (caplen < 4 || length < 4) {
if (caplen < 4) {
ND_PRINT((ndo, "[|vlan]"));
return;
return (hdrlen + caplen);
}
if (length < 4) {
ND_PRINT((ndo, "[|vlan]"));
return (hdrlen + length);
}
if (ndo->ndo_eflag) {
uint16_t tag = EXTRACT_16BITS(p);
uint16_t tag = EXTRACT_16BITS(p);
ND_PRINT((ndo, "%s, ", ieee8021q_tci_string(tag)));
}
ether_type = EXTRACT_16BITS(p + 2);
if (ndo->ndo_eflag && ether_type > ETHERMTU)
ND_PRINT((ndo, "ethertype %s, ", tok2str(ethertype_values,"0x%04x", ether_type)));
length_type = EXTRACT_16BITS(p + 2);
if (ndo->ndo_eflag && length_type > ETHERMTU)
ND_PRINT((ndo, "ethertype %s, ", tok2str(ethertype_values,"0x%04x", length_type)));
p += 4;
length -= 4;
caplen -= 4;
hdrlen += 4;
goto recurse;
} else if (ether_type == ETHERTYPE_JUMBO) {
} else if (length_type == ETHERTYPE_JUMBO) {
/*
* Alteon jumbo frames.
* See
@ -206,53 +224,48 @@ ether_print(netdissect_options *ndo,
* there's an LLC header and payload.
*/
/* Try to print the LLC-layer header & higher layers */
if (llc_print(ndo, p, length, caplen, ESRC(ep), EDST(ep),
&extracted_ether_type) == 0) {
/* ether_type not known, print raw packet */
if (!ndo->ndo_eflag) {
if (print_encap_header != NULL)
(*print_encap_header)(ndo, encap_header_arg);
ether_hdr_print(ndo, (u_char *)ep, orig_length);
}
llc_hdrlen = llc_print(ndo, p, length, caplen, &src, &dst);
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;
}
hdrlen += llc_hdrlen;
} else {
if (ethertype_print(ndo, ether_type, p, length, caplen) == 0) {
/* ether_type not known, print raw packet */
if (ethertype_print(ndo, length_type, p, length, caplen, &src, &dst) == 0) {
/* type not known, print raw packet */
if (!ndo->ndo_eflag) {
if (print_encap_header != NULL)
(*print_encap_header)(ndo, encap_header_arg);
ether_hdr_print(ndo, (u_char *)ep, orig_length);
ether_hdr_print(ndo, (const u_char *)ep, orig_length);
}
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
}
}
return (hdrlen);
}
/*
* This is the top level routine of the printer. 'p' points
* to the ether header of the packet, 'h->ts' is the timestamp,
* 'h->len' is the length of the packet off the wire, and 'h->caplen'
* is the number of bytes actually captured.
* to the ether header of the packet, 'h->len' is the length
* of the packet off the wire, and 'h->caplen' is the number
* of bytes actually captured.
*/
u_int
ether_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
const u_char *p)
{
ether_print(ndo, p, h->len, h->caplen, NULL, NULL);
return (ETHER_HDRLEN);
return (ether_print(ndo, p, h->len, h->caplen, NULL, NULL));
}
/*
* This is the top level routine of the printer. 'p' points
* to the ether header of the packet, 'h->ts' is the timestamp,
* 'h->len' is the length of the packet off the wire, and 'h->caplen'
* is the number of bytes actually captured.
* to the ether header of the packet, 'h->len' is the length
* of the packet off the wire, and 'h->caplen' is the number
* of bytes actually captured.
*
* This is for DLT_NETANALYZER, which has a 4-byte pseudo-header
* before the Ethernet header.
@ -270,16 +283,14 @@ netanalyzer_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
}
/* Skip the pseudo-header. */
ether_print(ndo, p + 4, h->len - 4, h->caplen - 4, NULL, NULL);
return (4 + ETHER_HDRLEN);
return (4 + ether_print(ndo, p + 4, h->len - 4, h->caplen - 4, NULL, NULL));
}
/*
* This is the top level routine of the printer. 'p' points
* to the ether header of the packet, 'h->ts' is the timestamp,
* 'h->len' is the length of the packet off the wire, and 'h->caplen'
* is the number of bytes actually captured.
* to the ether header of the packet, 'h->len' is the length
* of the packet off the wire, and 'h->caplen' is the number
* of bytes actually captured.
*
* This is for DLT_NETANALYZER_TRANSPARENT, which has a 4-byte
* pseudo-header, a 7-byte Ethernet preamble, and a 1-byte Ethernet SOF
@ -300,9 +311,7 @@ netanalyzer_transparent_if_print(netdissect_options *ndo,
}
/* Skip the pseudo-header, preamble, and SOF. */
ether_print(ndo, p + 12, h->len - 12, h->caplen - 12, NULL, NULL);
return (12 + ETHER_HDRLEN);
return (12 + ether_print(ndo, p + 12, h->len - 12, h->caplen - 12, NULL, NULL));
}
/*
@ -315,7 +324,8 @@ netanalyzer_transparent_if_print(netdissect_options *ndo,
int
ethertype_print(netdissect_options *ndo,
u_short ether_type, const u_char *p,
u_int length, u_int caplen)
u_int length, u_int caplen,
const struct lladdr_info *src, const struct lladdr_info *dst)
{
switch (ether_type) {
@ -329,7 +339,7 @@ ethertype_print(netdissect_options *ndo,
case ETHERTYPE_ARP:
case ETHERTYPE_REVARP:
arp_print(ndo, p, length, caplen);
arp_print(ndo, p, length, caplen);
return (1);
case ETHERTYPE_DN:
@ -352,7 +362,11 @@ ethertype_print(netdissect_options *ndo,
return (1);
case ETHERTYPE_ISO:
isoclns_print(ndo, p + 1, length - 1, length - 1);
if (length == 0 || caplen == 0) {
ND_PRINT((ndo, " [|osi]"));
return (1);
}
isoclns_print(ndo, p + 1, length - 1, caplen - 1);
return(1);
case ETHERTYPE_PPPOED:
@ -367,7 +381,7 @@ ethertype_print(netdissect_options *ndo,
return (1);
case ETHERTYPE_RRCP:
rrcp_print(ndo, p - 14 , length + 14);
rrcp_print(ndo, p, length, src, dst);
return (1);
case ETHERTYPE_PPP:
@ -413,17 +427,21 @@ ethertype_print(netdissect_options *ndo,
case ETHERTYPE_GEONET_OLD:
case ETHERTYPE_GEONET:
geonet_print(ndo, p-14, p, length);
geonet_print(ndo, p, length, src);
return (1);
case ETHERTYPE_CALM_FAST:
calm_fast_print(ndo, p-14, p, length);
calm_fast_print(ndo, p, length, src);
return (1);
case ETHERTYPE_AOE:
aoe_print(ndo, p, length);
return (1);
case ETHERTYPE_MEDSA:
medsa_print(ndo, p, length, caplen, src, dst);
return (1);
case ETHERTYPE_LAT:
case ETHERTYPE_SCA:
case ETHERTYPE_MOPRC:

Some files were not shown because too many files have changed in this diff Show More