tpcdump: Update to 4.99.4

Local changes:

- Update some local modifications to fix build
- Synch config.h with upstream as much as possible

Changelog:      https://git.tcpdump.org/tcpdump/blob/55bc126b0216cfe409b8d6bd378f65679d136ddf:/CHANGES
Reviewed by:    emaste
Obtained from:  https://www.tcpdump.org/release/tcpdump-4.99.4.tar.gz
Sponsored by:   The FreeBSD Foundation
This commit is contained in:
Joseph Mingrone 2023-06-08 14:30:54 -03:00
commit ee67461e56
277 changed files with 48047 additions and 33349 deletions

View File

@ -1,3 +1,264 @@
Friday, April 7, 2023 / The Tcpdump Group
Summary for 4.99.4 tcpdump release
Source code:
Fix spaces before tabs in indentation.
Updated printers:
LSP ping: Fix "Unused value" warnings from Coverity.
CVE-2023-1801: Fix an out-of-bounds write in the SMB printer.
DNS: sync resource types with IANA.
ICMPv6: Update the output to show a RPL DAO field name.
Geneve: Fix the Geneve UDP port test.
Building and testing:
Require at least autoconf 2.69.
Don't check for strftime(), as it's in C90 and beyond.
Update config.{guess,sub}, timestamps 2023-01-01,2023-01-21.
Documentation:
man: Document TCP flag names better.
Thursday, January 12, 2023 / The Tcpdump Group
Summary for 4.99.3 tcpdump release
Updated printers:
PTP: Use the proper values for the control field and print un-allocated
values for the message field as "Reserved" instead of "none".
Source code:
smbutil.c: Replace obsolete function call (asctime)
Building and testing:
cmake: Update the minimum required version to 2.8.12 (except Windows).
CI: Introduce and use TCPDUMP_CMAKE_TAINTED.
Makefile.in: Add the releasecheck target.
Makefile.in: Add "make -s install" in the releasecheck target.
Cirrus CI: Run the "make releasecheck" command in the Linux task.
Makefile.in: Add the whitespacecheck target.
Cirrus CI: Run the "make whitespacecheck" command in the Linux task.
Address all shellcheck warnings in update-test.sh.
Makefile.in: Get rid of a remain of gnuc.h.
Documentation:
Reformat the installation notes (INSTALL.txt) in Markdown.
Convert CONTRIBUTING to Markdown.
CONTRIBUTING.md: Document the use of "protocol: " in a commit summary.
Add a README file for NetBSD.
Fix CMake build to set man page section numbers in tcpdump.1
Saturday, December 31, 2022 / The Tcpdump Group
Summary for 4.99.2 tcpdump release
Updated printers:
BGP: Update cease notification decoding to RFC 9003.
BGP: decode BGP link-bandwidth extended community properly.
BGP: Fix parsing the AIGP attribute
BGP: make sure the path attributes don't go past the end of the packet.
BGP: Shutdown message can be up to 255 bytes length according to rfc9003
DSA: correctly determine VID.
EAP: fix some length checks and output issues.
802.11: Fix the misleading comment regarding "From DS", "To DS" Frame
Control Flags.
802.11: Fetch the CF and TIM IEs a field at a time.
802.15.4, BGP, LISP: fix some length checks, compiler warnings,
and undefined behavior warnings.
PFLOG: handle LINKTYPE_PFLOG/DLT_PFLOG files from all OSes on all
OSes.
RRCP: support more Realtek protocols than just RRCP.
MPLS: show the EXP field as TC, as per RFC 5462.
ICMP: redo MPLS Extension code as general ICMP Extension code.
VQP: Do not print unknown error codes twice.
Juniper: Add some bounds checks.
Juniper: Don't treat known DLT_ types as "Unknown".
lwres: Fix a length check, update a variable type.
EAP: Fix some undefined behaviors at runtime.
Ethernet: Rework the length checks, add a length check.
IPX: Add two length checks.
Zephyr: Avoid printing non-ASCII characters.
VRRP: Print the protocol name before any GET_().
DCCP: Get rid of trailing commas in lists.
Juniper: Report invalid packets as invalid, not truncated.
IPv6: Remove an obsolete code in an always-false #if wrapper.
ISAKMP: Use GET_U_1() to replace a direct dereference.
RADIUS: Use GET_U_1() to replace a direct dereference.
TCP: Fix an invalid check.
RESP: Fix an invalid check.
RESP: Remove an unnecessary test.
Arista: Refine the output format and print HwInfo.
sFlow: add support for IPv6 agent, add a length check.
VRRP: add support for IPv6.
OSPF: Update to match the Router Properties registry.
OSPF: Remove two unnecessary dereferences.
OSPF: Add support bit Nt RFC3101.
OSPFv3: Remove two unnecessary dereferences.
ICMPv6: Fix output for Router Renumbering messages.
ICMPv6: Fix the Node Information flags.
ICMPv6: Remove an unused macro and extra blank lines.
ICMPv6: Add a length check in the rpl_dio_print() function.
ICMPv6: Use GET_IP6ADDR_STRING() in the rpl_dio_print() function.
IPv6: Add some checks for the Hop-by-Hop Options header
IPv6: Add a check for the Jumbo Payload Hop-by-Hop option.
NFS: Fix the format for printing an unsigned int
PTP: fix printing of the correction fields
PTP: Use ND_LCHECK_U for checking invalid length.
WHOIS: Add its own printer source file and printer function
MPTCP: print length before subtype inside MPTCP options
ESP: Add a workaround to a "use-of-uninitialized-value".
PPP: Add tests to avoid incorrectly re-entering ppp_hdlc().
PPP: Don't process further if protocol is unknown (-e option).
PPP: Change the pointer to packet data.
ZEP: Add three length checks.
Add some const qualifiers.
Building and testing:
Update config.guess and config.sub.
Use AS_HELP_STRING macro instead of AC_HELP_STRING.
Handle some Autoconf/make errors better.
Fix an error when cross-compiling.
Use "git archive" for the "make releasetar" process.
Remove the release candidate rcX targets.
Mend "make check" on Solaris 9 with Autoconf.
Address assorted compiler warnings.
Fix auto-enabling of Capsicum on FreeBSD with Autoconf.
Treat "msys" as Windows for test exit statuses.
Clean up some help messages in configure.
Use unified diff by default.
Remove awk code from mkdep.
Fix configure test errors with Clang 15
CMake: Prevent stripping of the RPATH on installation.
AppVeyor CI: update Npcap site, update to 1.12 SDK.
Cirrus CI: Use the same configuration as for the main branch.
CI: Add back running tcpdump -J/-L and capture, now with Cirrus VMs.
Remove four test files (They are now in the libpcap tests directory).
On Solaris, for 64-bit builds, use the 64-bit pcap-config.
Tell CMake not to check for a C++ compiler.
CMake: Add a way to request -Werror and equivalents.
configure: Special-case macOS /usr/bin/pcap-config as we do in CMake.
configure: Use pcap-config --static-pcap-only if available.
configure: Use ac_c_werror_flag to force unknown compiler flags to fail.
configure: Use AC_COMPILE_IFELSE() and AC_LANG_SOURCE() for testing
flags.
Run the test that fails on OpenBSD only if we're not on OpenBSD.
Source code:
Fix some snapend-changing routines to protect against pointer
underflow.
Use __func__ from C99 in some function calls.
Memory allocator: Update nd_add_alloc_list() to a static function.
addrtoname.c: Fix two invalid tests.
Use more S_SUCCESS and S_ERR_HOST_PROGRAM in main().
Add some comments about "don't use GET_IP6ADDR_STRING()".
Assign ndo->ndo_packetp in pretty_print_packet().
Add ND_LCHECKMSG_U, ND_LCHECK_U, ND_LCHECKMSG_ZU and ND_LCHECK_ZU macros.
Update tok2strbuf() to a static function.
netdissect.h: Keep the link-layer dissectors names sorted.
setsignal(): Set SA_RESTART on non-lethal signals (REQ_INFO, FLUSH_PCAP)
to avoid corrupting binary pcap output.
Use __builtin_unreachable().
Fail if nd_push_buffer() or nd_push_snaplen() fails.
Improve code style and fix many typos.
Documentation:
Some man page cleanups.
Update the print interface for the packet count to stdout.
Note that we require compilers to support at least some of C99.
Update AIX and Solaris-related specifics.
INSTALL.txt: Add doc/README.*, delete the deleted win32 directory.
Update README.md and README.Win32.md.
Update some comments with new RFC numbers.
Wednesday, June 9, 2021 by gharris
Summary for 4.99.1 tcpdump release
Source code:
Squelch some compiler warnings
ICMP: Update the snapend for some nested IP packets.
MACsec: Update the snapend thus the ICV field is not payload
for the caller.
EIGRP: Fix packet header fields
SMB: Disable printer by default in CMake builds
OLSR: Print the protocol name even if the packet is invalid
MSDP: Print ": " before the protocol name
ESP: Remove padding, padding length and next header from the buffer
DHCPv6: Update the snapend for nested DHCPv6 packets
OpenFlow 1.0: Get snapend right for nested frames.
TCP: Update the snapend before decoding a MPTCP option
Ethernet, IEEE 802.15.4, IP, L2TP, TCP, ZEP: Add bounds checks
ForCES: Refine SPARSEDATA-TLV length check.
ASCII/hex: Use nd_trunc_longjmp() in truncation cases
GeoNet: Add a ND_TCHECK_LEN() call
Replace ND_TCHECK_/memcpy() pairs with GET_CPY_BYTES().
BGP: Fix overwrites of global 'astostr' temporary buffer
ARP: fix overwrites of static buffer in q922_string().
Frame Relay: have q922_string() handle errors better.
Building and testing:
Rebuild configure script when building release
Fix "make clean" for out-of-tree autotools builds
CMake: add stuff from CMAKE_PREFIX_PATH to PKG_CONFIG_PATH.
Documentation:
man: Update a reference as www.cifs.org is gone. [skip ci]
man: Update DNS sections
Solaris:
Fix a compile error with Sun C
Wednesday, December 30, 2020, by mcr@sandelman.ca, denis and fxl.
Summary for 4.99.0 tcpdump release
CVE-2018-16301: For the -F option handle large input files safely.
Improve the contents, wording and formatting of the man page.
Print unsupported link-layer protocol packets in hex.
Add support for new network protocols and DLTs: Arista, Autosar SOME/IP,
Broadcom LI and Ethernet switches tag, IEEE 802.15.9, IP-over-InfiniBand
(IPoIB), Linux SLL2, Linux vsockmon, MACsec, Marvell Distributed Switch
Architecture, OpenFlow 1.3, Precision Time Protocol (PTP), SSH, WHOIS,
ZigBee Encapsulation Protocol (ZEP).
Make protocol-specific updates for: AH, DHCP, DNS, ESP, FRF.16, HNCP,
ICMP6, IEEE 802.15.4, IPv6, IS-IS, Linux SLL, LLDP, LSP ping, MPTCP, NFS,
NSH, NTP, OSPF, OSPF6, PGM, PIM, PPTP, RADIUS, RSVP, Rx, SMB, UDLD,
VXLAN-GPE.
User interface:
Make SLL2 the default for Linux "any" pseudo-device.
Add --micro and --nano shorthands.
Add --count to print a counter only instead of decoding.
Add --print, to cause packet printing even with -w.
Add support for remote capture if libpcap supports it.
Display the "wireless" flag and connection status.
Flush the output packet buffer on a SIGUSR2.
Add the snapshot length to the "reading from file ..." message.
Fix local time printing (DST offset in timestamps).
Allow -C arguments > 2^31-1 GB if they can fit into a long.
Handle very large -f files by rejecting them.
Report periodic stats only when safe to do so.
Print the number of packets captured only as often as necessary.
With no -s, or with -s 0, don't specify the snapshot length with newer
versions of libpcap.
Improve version and usage message printing.
Building and testing:
Install into bindir, not sbindir.
autoconf: replace --with-system-libpcap with --disable-local-libpcap.
Require the compiler to support C99.
Better detect and use various C compilers and their features.
Add CMake as the second build system.
Make out-of-tree builds more reliable.
Use pkg-config to detect libpcap if available.
Improve Windows support.
Add more tests and improve the scripts that run them.
Test both with "normal" and "x87" floating-point.
Eliminate dependency on libdnet.
FreeBSD:
Print a proper error message about monitor mode VAP.
Use libcasper if available.
Fix failure to capture on RDMA device.
Include the correct capsicum header.
Source code:
Start the transition to longjmp() for packet truncation handling.
Introduce new helper functions, including GET_*(), nd_print_protocol(),
nd_print_invalid(), nd_print_trunc(), nd_trunc_longjmp() and others.
Put integer signedness right in many cases.
Introduce nd_uint*, nd_mac_addr, nd_ipv4 and nd_ipv6 types to fix
alignment issues, especially on SPARC.
Fix many C compiler, Coverity, UBSan and cppcheck warnings.
Fix issues detected with AddressSanitizer.
Remove many workarounds for older compilers and OSes.
Add a sanity check on packet header length.
Add and remove plenty of bounds checks.
Clean up pcap_findalldevs() call to find the first interface.
Use a short timeout, rather than immediate mode, for text output.
Handle DLT_ENC files *not* written on the same OS and byte-order host.
Add, and use, macros to do locale-independent case mapping.
Use a table instead of getprotobynumber().
Get rid of ND_UNALIGNED and ND_TCHECK().
Make roundup2() generally available.
Resync SMI list against Wireshark.
Fix many typos.
Friday, September 20, 2019, by mcr@sandelman.ca
A huge thank you to Denis, Francois-Xavier and Guy who did much of the heavy lifting.
Summary for 4.9.3 tcpdump release
@ -21,7 +282,6 @@ Friday, September 20, 2019, by mcr@sandelman.ca
CVE-2018-14882 (RPL)
CVE-2018-16227 (802.11)
CVE-2018-16229 (DCCP)
CVE-2018-16301 (was fixed in libpcap)
CVE-2018-16230 (BGP)
CVE-2018-16452 (SMB)
CVE-2018-16300 (BGP)
@ -66,8 +326,6 @@ Sunday September 3, 2017 denis@ovsienko.info
CVE-2017-12991 (BGP)
CVE-2017-12992 (RIPng)
CVE-2017-12993 (Juniper)
CVE-2017-11542 (PIMv1)
CVE-2017-11541 (safeputs)
CVE-2017-12994 (BGP)
CVE-2017-12996 (PIMv2)
CVE-2017-12998 (ISO IS-IS)
@ -393,7 +651,7 @@ Wednesday Jul. 2, 2014 mcr@sandelman.ca
a number of unaligned access faults fixed
-A flag does not consider CR to be printable anymore
fx.lebail took over coverity baby sitting
default snapshot size increased to 256K for accomodate USB captures
default snapshot size increased to 256K for accommodate USB captures
WARNING: this release contains a lot of very worthwhile code churn.
Wednesday Jan. 15, 2014 guy@alum.mit.edu
@ -533,7 +791,7 @@ Tue. July 20, 2010. guy@alum.mit.edu.
Summary for 4.1.2 tcpdump release
If -U is specified, flush the file after creating it, so it's
not zero-length
Fix TCP flags output description, and some typoes, in the man
Fix TCP flags output description, and some typos, in the man
page
Add a -h flag, and only attempt to recognize 802.11s mesh
headers if it's set
@ -617,7 +875,7 @@ Mon. September 10, 2007. ken@xelerance.com. Summary for 3.9.8 tcpdump relea
Wed. July 23, 2007. mcr@xelerance.com. Summary for 3.9.7 libpcap release
NFS: Print unsigned values as such.
NFS: Print unsigned values as such.
RX: parse safely.
BGP: fixes for IPv6-less builds.
801.1ag: use standard codepoint.
@ -628,7 +886,7 @@ Wed. July 23, 2007. mcr@xelerance.com. Summary for 3.9.7 libpcap release
NFS: from NetBSD; don't interpret the reply as a possible NFS reply
if it got MSG_DENIED.
BGP: don't print TLV values that didn't fit, from www.digit-labs.org.
revised INSTALL.txt about libpcap dependancy.
revised INSTALL.txt about libpcap dependency.
Wed. April 25, 2007. ken@xelerance.com. Summary for 3.9.6 tcpdump release
Update man page to reflect changes to libpcap
@ -648,7 +906,7 @@ Wed. April 25, 2007. ken@xelerance.com. Summary for 3.9.6 tcpdump release
Add support for CFM Link-trace msg, Link-trace-Reply msg,
Sender-ID tlv, private tlv, port, interface status
Add support for unidirectional link detection as per
http://www.ietf.org/internet-drafts/draft-foschiano-udld-02.txt
https://tools.ietf.org/id/draft-foschiano-udld-02.txt
Add support for the olsr protocol as per RFC 3626 plus the LQ
extensions from olsr.org
Add support for variable-length checksum in DCCP, as per section 9 of
@ -689,7 +947,7 @@ Tue. September 19, 2006. ken@xelerance.com. Summary for 3.9.5 tcpdump release
Lots of minor cosmetic changes to output printers
Mon. September 19, 2005. ken@xelerance.com. Summary for 3.9.4 tcpdump release
Mon. September 19, 2005. ken@xelerance.com. Summary for 3.9.4 tcpdump release
Decoder support for more Juniper link-layer types
Fix a potential buffer overflow (although it can't occur in
practice).
@ -708,14 +966,14 @@ Mon. September 19, 2005. ken@xelerance.com. Summary for 3.9.4 tcpdump release
those TLVs as system IDs, not as node IDs.
Support for DCCP.
Tue. July 5, 2005. ken@xelerance.com. Summary for 3.9.3 tcpdump release
Tue. July 5, 2005. ken@xelerance.com. Summary for 3.9.3 tcpdump release
Option to chroot() when dropping privs
Fixes for compiling on nearly every platform,
including improved 64bit support
Many new testcases
Support for sending packets
Many compliation fixes on most platforms
Many compilation fixes on most platforms
Fixes for recent version of GCC to eliminate warnings
Improved Unicode support
@ -753,7 +1011,7 @@ Tue. March 30, 2004. mcr@sandelman.ottawa.on.ca. Summary for 3.8.3 release
Mon. March 29, 2004. mcr@sandelman.ottawa.on.ca. Summary for 3.8.2 release
Fixes for print-isakmp.c CVE: CAN-2004-0183, CAN-2004-0184
http://www.rapid7.com/advisories/R7-0017.html
https://web.archive.org/web/20160328035955/https://www.rapid7.com/resources/advisories/R7-0017.jsp
IP-over-IEEE1394 printing.
some MINGW32 changes.
updates for autoconf 2.5
@ -826,7 +1084,6 @@ Tuesday, February 25, 2003. fenner@research.att.com. 3.7.2 release
2.100.3 to be misrepresented as 4.20.3 .
Monday, January 21, 2002. mcr@sandelman.ottawa.on.ca. Summary for 3.7 release
see http://www.tcpdump.org/cvs-log/2002-01-21.10:16:48.html for commit log.
keyword "ipx" added.
Better OSI/802.2 support on Linux.
IEEE 802.11 support, from clenahan@fortresstech.com, achirica@ttd.net.
@ -894,7 +1151,7 @@ Tuesday January 9, 2001. mcr@sandelman.ottawa.on.ca. Summary for 3.6 release
libpcap changes provide for exchanging capture files between
systems. Save files now have well known PACKET_ values instead of
depending upon system dependant mappings of DLT_* types.
depending upon system dependent mappings of DLT_* types.
Support for computing/checking IP and UDP/TCP checksums.
@ -1205,7 +1462,7 @@ v3.1 Thu Jun 13 20:59:32 PDT 1996
- Print out a little more information for sun rpc packets.
- Add suport for Kerberos 4 thanks to John Hawkinson (jhawk@mit.edu).
- Add support for Kerberos 4 thanks to John Hawkinson (jhawk@mit.edu).
- Fixed the Fix EXTRACT_SHORT() and EXTRACT_LONG() macros (which were
wrong on little endian machines).
@ -1370,7 +1627,7 @@ v2.2 Fri May 22 17:19:41 PDT 1992
v2.1 Tue Jan 28 11:00:14 PST 1992
- Internal release (never publically exported).
- Internal release (never publicly exported).
v2.0.1 Sun Jan 26 21:10:10 PDT

File diff suppressed because it is too large Load Diff

View File

@ -1,151 +0,0 @@
Some Information for Contributors
---------------------------------
You want to contribute to Tcpdump, Thanks!
Please, read these lines.
How to report bugs and other problems
-------------------------------------
To report a security issue (segfault, buffer overflow, infinite loop, arbitrary
code execution etc) please send an e-mail to security@tcpdump.org, do not use
the bug tracker!
To report a non-security problem (failure to compile, incorrect output in the
protocol printout, missing support for a particular protocol etc) please check
first that it reproduces with the latest stable release of tcpdump and the latest
stable release of libpcap. If it does, please check that the problem reproduces
with the current git master branch of tcpdump and the current git master branch of
libpcap. If it does (and it is not a security-related problem, otherwise see
above), please navigate to https://github.com/the-tcpdump-group/tcpdump/issues
and check if the problem has already been reported. If it has not, please open
a new issue and provide the following details:
* tcpdump and libpcap version (tcpdump --version)
* operating system name and version and any other details that may be relevant
(uname -a, compiler name and version, CPU type etc.)
* configure flags if any were used
* statement of the problem
* steps to reproduce
Please note that if you know exactly how to solve the problem and the solution
would not be too intrusive, it would be best to contribute some development time
and open a pull request instead as discussed below.
Still not sure how to do? Feel free to [subscribe](https://www.tcpdump.org/#mailing-lists)
to the mailing list tcpdump-workers@lists.tcpdump.org and ask!
How to add new code and to update existing code
-----------------------------------------------
0) Check that there isn't a pull request already opened for the changes you
intend to make.
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) Setup your git working copy
git clone https://github.com/<username>/tcpdump.git
cd tcpdump
git remote add upstream https://github.com/the-tcpdump-group/tcpdump
git fetch upstream
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) Try to rebase your commits to keep the history simple.
git rebase upstream/master
(If the rebase fails and you cannot resolve, issue "git rebase --abort"
and ask for help in the pull request comment.)
9) Once 100% happy, put your work into your forked repository.
git push
10) Initiate and send a pull request
(See https://help.github.com/articles/using-pull-requests/)
Code style and generic 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 if there is no
published normative reference.
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

@ -0,0 +1,191 @@
# Some Information for Contributors
Thank you for considering to make a contribution to tcpdump! Please use the
guidelines below to achieve the best results and experience for everyone.
## How to report bugs and other problems
**To report a security issue (segfault, buffer overflow, infinite loop, arbitrary
code execution etc) please send an e-mail to security@tcpdump.org, do not use
the bug tracker!**
To report a non-security problem (failure to compile, incorrect output in the
protocol printout, missing support for a particular protocol etc) please check
first that it reproduces with the latest stable release of tcpdump and the latest
stable release of libpcap. If it does, please check that the problem reproduces
with the current git master branch of tcpdump and the current git master branch of
libpcap. If it does (and it is not a security-related problem, otherwise see
above), please navigate to the
[bug tracker](https://github.com/the-tcpdump-group/tcpdump/issues)
and check if the problem has already been reported. If it has not, please open
a new issue and provide the following details:
* tcpdump and libpcap version (`tcpdump --version`)
* operating system name and version and any other details that may be relevant
(`uname -a`, compiler name and version, CPU type etc.)
* custom `configure`/`cmake` flags, if any
* statement of the problem
* steps to reproduce
Please note that if you know exactly how to solve the problem and the solution
would not be too intrusive, it would be best to contribute some development time
and to open a pull request instead as discussed below.
Still not sure how to do? Feel free to
[subscribe to the mailing list](https://www.tcpdump.org/#mailing-lists)
and ask!
## How to add new code and to update existing code
0) Check that there isn't a pull request already opened for the changes you
intend to make.
1) [Fork](https://help.github.com/articles/fork-a-repo/) the Tcpdump
[repository](https://github.com/the-tcpdump-group/tcpdump).
2) The easiest way to test your changes on multiple operating systems and
architectures is to let the upstream CI test your pull request (more on
this below).
3) Setup your git working copy
```
git clone https://github.com/<username>/tcpdump.git
cd tcpdump
git remote add upstream https://github.com/the-tcpdump-group/tcpdump
git fetch upstream
```
4) Do a `touch .devel` in your working directory.
Currently, the effect is
* add (via `configure`, in `Makefile`) some warnings options (`-Wall`,
`-Wmissing-prototypes`, `-Wstrict-prototypes`, ...) to the compiler if it
supports these options,
* have the `Makefile` support `make depend` and the `configure` script run it.
5) Configure and build
```
./configure && make -s && make check
```
6) Add/update tests
The `tests` directory contains regression tests of the dissection of captured
packets. Those captured packets were saved running tcpdump with option
`-w sample.pcap`. Additional options, such as `-n`, are used to create relevant
and reproducible output; `-#` is used to indicate which particular packets
have output that differs. The tests are run with the `TZ` environment
variable set to `GMT0`, so that UTC, rather than the local time where the
tests are being run, is used when "local time" values are printed. The
actual test compares the current text output with the expected result
(`sample.out`) saved from a previous version.
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 produced as follows:
```
(cd tests && TZ=GMT0 ../tcpdump -# -n -r sample.pcap tcpdump-options > sample.out)
```
Or, for convenience, use `./update-test.sh test-name`
It is often useful to have test outputs with different verbosity levels
(none, `-v`, `-vv`, `-vvv`, etc.) depending on the code.
7) Test using `make check` (current build options) and `./build_matrix.sh`
(a multitude of build options, build systems and compilers). If you can,
test on more than one operating system. Don't send a pull request until
all tests pass.
8) Try to rebase your commits to keep the history simple.
```
git fetch upstream
git rebase upstream/master
```
(If the rebase fails and you cannot resolve, issue `git rebase --abort`
and ask for help in the pull request comment.)
9) Once 100% happy, put your work into your forked repository using `git push`.
10) [Initiate and send](https://help.github.com/articles/using-pull-requests/)
a pull request.
This will trigger the upstream repository CI tests.
## Code style and generic remarks
* A thorough reading of some other printers code is useful.
* Put the normative reference if any as comments (RFC, etc.).
* Put the format of packets/headers/options as comments if there is no
published normative reference.
* The printer may receive incomplete packet in the buffer, truncated at any
random position, for example by capturing with `-s size` option.
If your code reads and decodes every byte of the protocol packet, then to
ensure proper and complete bounds checks it would be sufficient to read all
packet data using the `GET_*()` macros, typically:
```
GET_U_1(p)
GET_S_1(p)
GET_BE_U_n(p), n in { 2, 3, 4, 5, 6, 7, 8 }
GET_BE_S_n(p), n in { 2, 3, 4, 5, 6, 7, 8 }
```
If your code uses the macros above only on some packet data, then the gaps
would have to be bounds-checked using the `ND_TCHECK_*()` macros:
```
ND_TCHECK_n(p), n in { 1, 2, 3, 4, 5, 6, 7, 8, 16 }
ND_TCHECK_SIZE(p)
ND_TCHECK_LEN(p, l)
```
For the `ND_TCHECK_*` macros (if not already done):
* Assign: `ndo->ndo_protocol = "protocol";`
* Define: `ND_LONGJMP_FROM_TCHECK` before including `netdissect.h`
* Make sure that the intersection of `GET_*()` and `ND_TCHECK_*()` is minimal,
but at the same time their union covers all packet data in all cases.
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.
* 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 or for some other reason).
Print with: `nd_print_invalid(ndo); /* to print " (invalid)" */`
* Use `struct tok` for indexed strings and print them with
`tok2str()` or `bittok2str()` (for flags).
* Avoid empty lines in output of printers.
* A commit message must have:
```
First line: Capitalized short summary in the imperative (50 chars or less)
If the commit concerns a protocol, the summary line must start with
"protocol: ".
Body: Detailed explanatory text, if necessary. Fold it to approximately
72 characters. There must be an empty line separating the summary from
the body.
```
* Avoid non-ASCII characters in code and commit messages.
* Use the style of the modified sources.
* Don't mix declarations and code.
* Don't use `//` for comments.
Not all C compilers accept C++/C99 comments by default.
* Avoid trailing tabs/spaces

View File

@ -1,48 +1,64 @@
This file lists people who have contributed to tcpdump:
This file lists people who have contributed to tcpdump.
The current maintainers:
Bill Fenner <fenner at research dot att dot com>
The current maintainers (in alphabetical order):
Denis Ovsienko <denis at ovsienko dot info>
Fulvio Risso <risso at polito dot it>
Guy Harris <guy at alum dot mit dot edu>
Hannes Gredler <hannes at gredler dot at>
Francois-Xavier Le Bail <devel dot fx dot lebail at orange dot fr>
Guy Harris <gharris at sonic dot net>
Michael Richardson <mcr at sandelman dot ottawa dot on dot ca>
Francois-Xavier Le Bail <fx dot lebail at yahoo dot com>
Additional people who have contributed patches:
Additional people who have contributed patches (in alphabetical order):
Aaron Campbell <aaron at arbor dot net>
A Costa <agcosta at gis dot net>
ABHIMANYU <agupta07 at sourceforge dot net>
Adam Sampson <ats at offog dot org>
Ahmed Abdelsalam <ahabdels at gmail dot com>
Ajith Adapa <adapa dot ajith at gmail dot com>
Albert Chin <china at thewrittenword dot com>
Alexandra Kossovsky <alexandra1975 at sourceforge dot net>
Alexandr Nedvedicky <alexandr dot nedvedicky at oracle dot com>
Alexandre Ferrieux <alexandre dot ferrieux at orange dot com>
Alexis La Goutte <alexis dot lagoutte at gmail dot com>
Alfredo Andres <aandres at s21sec dot com>
Ali Abdulkadir <autostart dot ini at gmail dot com>
Ananth Suryanarayana <anantha at juniper dot net>
Andrea Bittau <a dot bittau at cs dot ucl dot ac dot uk>
Andrea Ieri <andrea dot ieri at canonical dot com>
Andreas Jaggi <andreas dot jaggi at waterwave dot ch>
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 Lunn <andrew at lunn dot ch>
Andrew Nording <andrew at nording dot ru>
Andrew Tridgell <tridge at linuxcare dot com>
Andy Heffernan <ahh at juniper dot net>
Angus Cameron <anguscc at yahoo dot com>
Anton Bernal <anton at juniper dot net>
Antonin Décimo <antonin dot decimo at gmail dot com>
Aravind Prasad S <raja dot avi 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>
Atsushi Onoe <onoe at netbsd dot org>
Baptiste Jonglez <baptiste dot jonglez at ens-lyon dot org>
Baruch Siach <baruch at tkos dot co dot il>
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 Fenner <fenner at gmail 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>
Brian Carpenter <brian dot carpenter at gmail dot com>
Brian Ginsbach <ginsbach at cray dot com>
Brooks Davis <brooks at one-eyed-alien dot net>
Bruce M. Simpson <bms at spc dot org>
Bryce Wood <woodbr at oregonstate dot edu>
bugyo <bugyo at users dot noreply dot github dot com>
Carles Kishimoto Bisbe <ckishimo at ac dot upc dot es>
Casey Deccio <casey at deccio dot net>
Charles (Chas) Williams <chwillia at ciena dot com>
Charles M. Hannum <mycroft at netbsd dot org>
Charlie Lenahan <clenahan at fortresstech dot com>
Chris Cogdon <chris at cogdon dot org>
@ -52,22 +68,39 @@ Additional people who have contributed patches:
Christian Sievers <c_s at users dot sourceforge dot net>
Christophe Rhodes <csr21 at cantab dot net>
Cliff Frey <cliff at meraki dot com>
Craig Leres <leres at xse dot com>
Craig Rodrigues <rodrigc at mediaone dot net>
Crist J. Clark <cjclark at alum dot mit dot edu>
Dagobert Michelsen <dam at opencsw dot org>
Daniel Hagerty <hag at ai dot mit dot edu>
Daniel Lee <Longinus00 at gmail dot com>
Daniel Miller <dmiller at nmap dot org>
Dario Lombardo <lomato at gmail dot com>
Darren Reed <darrenr at reed dot wattle dot id dot au>
David Binderman <d dot binderman at virgin dot net>
David Cronin <davidcronin94 at gmail dot com>
Davide Caratti <dcaratti at redhat dot com>
David Horn <dhorn2000 at gmail dot com>
David Smith <dsmith at redhat dot com>
David Young <dyoung at ojctech dot com>
Dion Bosschieter <dbosschieter at transip dot nl>
Dmitrij Tejblum <tejblum at yandex-team dot ru>
Dmitry Eremin-Solenikov <dbaryshkov at gmail dot com>
Don Ebright <Don dot Ebright at compuware dot com>
Donatas Abraitis <donatas dot abraitis at gmail dot com>
d simonov <simonov-d at yandex-team dot ru>
Duane Wessels <dwessels at verisign dot com>
Eamon Doyle <eamonjd at arista dot com>
Eddie Kohler <xexd at sourceforge dot net>
Ege Cetin <egecetin at hotmail dot com dot tr>
Eliot Lear <lear at upstairs dot ofcourseimright dot com>
Elmar Kirchner <elmar at juniper dot net>
Eric S. Raymond <esr at thyrsus dot com>
Etienne Marais <etienne at marais dot green>
Fang Wang <fangwang at sourceforge dot net>
Ferry Huberts <ferry dot huberts at pelagic dot nl>
Florent Drouin <Florent dot Drouin at alcatel-lucent dot fr>
Florian Fainelli <f dot fainelli at gmail dot com>
Florian Forster <octo at verplant dot org>
fra <foo at bar dot baz>
Francesco Fondelli <francesco dot fondelli at gmail dot com>
@ -77,15 +110,24 @@ Additional people who have contributed patches:
Fulvio Risso <risso at polito dot it>
George Bakos <gbakos at ists dot dartmouth dot edu>
Gerald Combs <gerald at ethereal dot com>
Gerard Garcia <ggarcia at deic dot uab dot cat>
George Neville-Neil <gnn at freebsd dot org>
Gerald Combs <gerald at wireshark dot org>
Gerrit Renker <gerrit at erg dot abdn dot ac dot uk>
Gert Doering <gert at greenie dot muc dot de>
Gianluca Varenni <gianluca dot varenni at gmail dot com>
Gilbert Ramirez Jr. <gram at xiexie dot org>
Gisle Vanem <gvanem at yahoo dot no>
Gleb Smirnoff <glebius at FreeBSD dot org>
Gokul Sivakumar <gokulkumar792 at gmail dot com>
Greg Minshall <minshall at acm dot org>
Grégoire Henry <henry at pps dot jussieu dot fr>
Gregory Detal <gregory dot detal at uclouvain dot be>
Greg Stark <gsstark at mit dot edu>
Greg Steinbrecher <steinbrecher at alum dot mit dot edu>
Guy Lewin <guy at lewin dot co dot il>
Hank Leininger <tcpdump-workers at progressive-comp dot com>
Hannes Gredler <hannes at gredler dot at>
Hannes Viertel <hviertel at juniper dot net>
Hanno Böck <hanno at hboeck dot de>
Harry Raaymakers <harryr at connect dot com dot au>
@ -94,18 +136,27 @@ Additional people who have contributed patches:
Herwin Weststrate <herwin at quarantainenet dot nl>
Ian McDonald <imcdnzl at gmail dot com>
Ilpo Järvinen <ilpo dot jarvinen at helsinki dot fi>
ishaangandhi <ishaangandhi at gmail dot com>
Jacek Tobiasz <Jacek dot Tobiasz at atm dot com dot pl>
Jacob Davis <jacobgb24 at yahoo dot com>
Jakob Schlyter <jakob at openbsd dot org>
Jakub Zawadzki <darkjames at darkjames dot pl>
Jamal Hadi Salim <hadi at cyberus dot ca>
James Ko <jck at exegin dot com>
Jamie Bainbridge <jamie dot bainbridge at gmail dot com>
Jan Oravec <wsx at wsx6 dot net>
Jason L. Wright <jason at thought dot net>
Jason R. Thorpe <thorpej at netbsd dot org>
Jean-Raphaël Gaglione <jr dot gaglione at yahoo dot fr>
Jeff Chan <jchan at arista dot com>
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>
Jeremy Browne <jer at ifni dot ca>
Jesper Peterson <jesper at endace dot com>
Jesse Gross <jesse at nicira dot com>
Jim Hutchins <jim at ca dot sandia dot gov>
João Medeiros <ignotus21 at sourceforge dot net>
Job Snijders <job at instituut dot net>
Joerg Mayer <jmayer at loplof dot de>
Jonathan Heusser <jonny at drugphish dot ch>
Jorge Boncompte [DTI2] <jorge at dti2 dot net>
@ -118,55 +169,81 @@ Additional people who have contributed patches:
Karl Norby <karl-norby at sourceforge dot net>
Kazushi Sugyo <sugyo at pb dot jp dot nec dot com>
Kelly Carmichael <kcarmich at ipapp dot com>
Ken Bantoft <ken at xelerance dot com>
Ken Hornstein <kenh at cmf dot nrl dot navy dot mil>
Kenichi Maehashi <webmaster at kenichimaehashi dot com>
Kevin Steves <stevesk at pobox dot com>
Klaus Klein <kleink at reziprozitaet dot de>
Kovarththanan Rajaratnam <kovarththanan dot rajaratnam at gmail dot com>
Kris Kennaway <kris at freebsd dot org>
Krzysztof Halasa <khc at pm dot waw dot pl>
Larry Lile <lile at stdio dot com>
Lennert Buytenhek <buytenh at gnu dot org>
Loganaden Velvindron <logan at elandsys dot com>
Loganaden Velvindron <logan at cyberstorm dot mu>
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>
Luigi Rizzo <luigi at freebsd dot org>
Luis MartinGarcia <luis dot mgarc at gmail dot com>
Luiz Otavio O Souza <loos at freebsd dot org>
Maciej W. Rozycki <macro at ds2 dot pg dot gda dot pl>
Manoharan Sundaramoorthy <manoharan at arista dot com>
Manu Pathak <mapathak at cisco dot com>
Marc Abramowitz <marc at marc-abramowitz dot com>
Marc A. Lehmann <pcg at goof dot com>
Marc Binderberger <mbind at sourceforge dot net>
Mark Andrews <marka at isc dot org>
Mark Ellzey Thomas <mark at ackers dot net>
Marko Kiiskila <carnil at cs dot tut dot fi>
Markus Schöpflin <schoepflin at sourceforge dot net>
Marshall Rose <mrose at dbc dot mtview dot ca dot us>
Martin Buck <mb-tmp-tvguho dot pbz at gromit dot dyndns dot org>
Martin Husemann <martin at netbsd dot org>
Martin Sehnoutka <msehnout at redhat dot com>
Matt Eaton <agnosticdev at gmail dot com>
Matthew Luckie <matthewluckie at sourceforge dot net>
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 Haardt <michael at moria dot de>
Michael Kirkhart <michael dot kirkhart at att dot net>
Michael Madore <mmadore at turbolinux dot com>
Michael Riepe <too-tired at sourceforge dot net>
Michael Shalayeff <mickey at openbsd dot org>
Michael Shields <shields at msrl dot com>
Michael T. Stolarchuk <mts at off dot to>
Michal Ruprich <michalruprich at gmail dot com>
Michal Sekletar <msekleta at redhat dot com>
Michele "mydecay" Marchetto <smarchetto1 at tin dot it>
Mike Frysinger <vapier at gmail dot com>
Mingrui <972931182 at qq dot com>
Minto Jeyananth <minto at juniper dot net>
Miroslav Lichvar <mlichvar at redhat dot com>
Mister X <3520734+Mister-X- at users dot noreply dot github dot com>
Mitsunori Komatsu <komamitsu at gmail dot com>
Monroe Williams <monroe at pobox dot com>
Monthadar Al Jaberi <monthadar at gmail dot com>
Moses Devadason <mosesdevadason at gmail dot com>
Motonori Shindo <mshindo at mshindo dot net>
Nan Xiao <nan at chinadtrace dot org>
Nathaniel Couper-Noles <Nathaniel at isi1 dot tccisi dot com>
Nathan J. Williams <nathanw at MIT dot EDU>
Neelabh <neelabhsahay at gmail dot com>
Neil T. Spring <bluehal at users dot sourceforge dot net>
Nicholas Reilly <nreilly at blackberry dot com>
Nickolai Zeldovich <kolya at MIT dot EDU>
Nikolay Edigaryev <edigaryev at gmail dot com>
Nicolas Ferrero <toorop at babylo dot net>
niks3089 <niks3089 at gmail dot com>
Niels Provos <provos at openbsd dot org>
Nikhil AP <nikhilap at arista dot com>
Noritoshi Demizu <demizu at users dot sourceforge dot net>
Olaf Kirch <okir at caldera dot de>
Ola Martin Lykkja <ola dot lykkja at q-free dot com>
Oleksij Rempel <linux at rempel-privat dot de>
Onno van der Linden <onno at simplex dot nl>
Paolo Abeni <paolo dot abeni at email dot it>
Partha Ghosh <psg at cumulusnetworks dot com>
Pascal Hennequin <pascal dot hennequin at int-evry dot fr>
Pasvorn Boonmark <boonmark at juniper dot net>
Patrik Lundquist <patrik dot lundquist at gmail dot com>
@ -175,26 +252,43 @@ Additional people who have contributed patches:
Paul S. Traina <pst at freebsd dot org>
Pavlin Radoslavov <pavlin at icir dot org>
Pawel Worach <pawel dot worach at gmail dot com>
Pedro Monreal <pmgdeb at gmail dot com>
Pekka Savola <pekkas at netcore dot fi>
peppe <g1pi at libero dot it>
Petar Alilovic <petar dot alilovic at gmail dot com>
Peter Fales <peter at fales-lorenz dot net>
Peter Jeremy <peter dot jeremy at alcatel dot com dot au>
Peter Krystad <peter dot krystad at linux dot intel dot com>
Peter Volkov <pva at gentoo dot org>
Petr Vorel <pvorel at suse dot cz>
<pfhunt at users dot sourceforge dot net>
Phil Wood <cpw at lanl dot gov>
Pier Carlo Chiodi <pierky at pierky dot com>
Quentin Armitage <quentin at armitage dot org dot uk>
Rafal Maszkowski <rzm at icm dot edu dot pl>
Randy Sofia <rsofia at users dot sourceforge dot net>
Raphael Raimbault <raphael dot raimbault at netasq dot com>
Renato Botelho <garga at FreeBSD dot org>
Ricardo Nabinger Sanchez <rnsanchez at taghos dot com dot br>
Richard Scheffenegger <srichard at netapp dot com>
Rick Cheng <rcheng at juniper dot net>
Rick Jones <rick dot jones2 at hp dot com>
Rick Watson <watsonrick at users dot sourceforge dot net>
Ritesh Ranjan <r dot ranjan789 at gmail dot com>
Rob Braun <bbraun at synack dot net>
Robert Edmonds <stu-42 at sourceforge dot net>
Rocco Lucia <rlucia at iscanet dot com>
Roderick Schertler <roderick at argon dot org>
Romain Francoise <rfrancoise at debian dot org>
Romero Malaquias <romero dot malaquias at gmail dot com>
Ruben Kerkhof <ruben at rubenkerkhof dot com>
Rui Paulo <rpaulo at FreeBSD dot org>
Sabrina Dubroca <sd at queasysnail dot net>
Sagun Shakya <sagun dot shakya at sun dot com>
Sam James <sam at gentoo dot org>
Sami Farin <safari at iki dot fi>
Sascha Wildner <swildner at sourceforge dot net>
Sawssen Hadded <saw dot hadded at gmail dot com>
Scott Mcmillan <scott dot a dot mcmillan at intel dot com>
Scott Rose <syberpunk at users dot sourceforge dot net>
Sebastian Krahmer <krahmer at cs dot uni-potsdam dot de>
@ -203,22 +297,41 @@ Additional people who have contributed patches:
Sepherosa Ziehau <sepherosa at gmail dot com>
Seth Webster <swebster at sst dot ll dot mit dot edu>
Shinsuke Suzuki <suz at kame dot net>
Simon Nicolussi <sinic at sinic dot name>
Simon Ruderich <simon at ruderich dot org>
Slava Shwartsman <slavash at mellanox dot com>
Stefan Hajnoczi <stefanha at redhat dot com>
Steinar Haug <sthaug at nethelp dot no>
Stephane Bortzmeyer <stephane+github at bortzmeyer dot org>
Swaminathan Chandrasekaran <chander at juniper dot net>
Steve Kay <stevekay at gmail dot com>
Steve-o <fnjordy at sourceforge dot net>
Steven H. Wang <wang dot steven dot h at gmail dot com>
Swaathi Vetrivel <swaathiv at juniper dot net>
Swaminathan Chandrasekaran <chander at juniper dot net>
Takashi Yamamoto <yamt at mwd dot biglobe dot ne dot jp>
Tatuya Jinmei <jinmei at kame dot net>
Tero Kivinen <kivinen at iki dot fi>
Terry Kennedy <terry at tmk dot com>
test2 <test2 at safs64 dot (none)>
Thomas Jacob <jacob at internet24 dot de>
Tillmann Karras <tilkax at gmail dot com>
Timo Koskiahde
Tobias Waldekranz <tobias at waldekranz dot com>
Tom Jones <thj at freebsd dot org>
Tommy Beadle <tbeadle at arbor dot net>
Tony Li <tli at procket dot com>
Tony Samuels <vegizombie at gmail dot com>
Tony Xu <hhktony at gmail dot com>
Toshihiro Kanda <candy at fct dot kgc dot co dot jp>
Udayakumar <udaya011 at gmail dot com>
Ulrich Windl <Ulrich dot Windl at RZ dot Uni-Regensburg dot DE>
Uns Lider <unslider at miranda dot org>
Victor Oppleman <oppleman at users dot sourceforge dot net>
Viral Mehta <viral dot mehta at dell dot com>
Vitaly Lavrov <vel21ripn at gmail dot com>
Vivien Didelot <vivien dot didelot at gmail dot com>
Vyacheslav Trushkin <dogonthesun at gmail dot com>
Wang Jian <larkwang at gmail dot com>
Weesan Lee <weesan at juniper dot net>
Wesley Griffin <wgriffin at users dot sourceforge dot net>
Wesley Shields <wxs at FreeBSD dot org>
@ -226,13 +339,21 @@ Additional people who have contributed patches:
Will Drewry <will at alum dot bu dot edu>
William J. Hulley <bill dot hulley at gmail dot com>
Wim Torfs <wtorfs at gmail dot com>
Wolfgang Karall <office at karall-edv dot at>
Xin Li <delphij at FreeBSD dot org>
yekm <yekm at h0me>
Yen Yen Lim
Yoshifumi Nishida
zilog80a <zilog80a at sourceforge dot net>
zolf <flos at xs4all dot nl>
The original LBL crew:
Steve McCanne
Craig Leres
Van Jacobson
Past maintainers:
Jun-ichiro itojun Hagino <itojun at iijlab dot net> Also see: http://www.wide.ad.jp/itojun-award/
Past maintainers (in alphabetical order):
Bill Fenner <fenner at gmail dot com>
Fulvio Risso <risso at polito dot it>
Hannes Gredler <hannes at gredler dot at>
Jun-ichiro itojun Hagino <itojun at iijlab dot net> Also see: http://www.wide.ad.jp/itojun-award/

View File

@ -1,53 +1,61 @@
# tcpdump installation notes
If you have not built libpcap, and your system does not have libpcap
installed, install libpcap first. Your system might provide a version
of libpcap that can be installed; if so, to compile tcpdump you might
need to install a "developer" version of libpcap as well as the
"run-time" version. You can also install tcpdump.org's version of
libpcap; see the README file in this directory for the ftp location.
libpcap; see [this file](README.md) for the location.
You will need an ANSI C compiler to build tcpdump. The configure script
will abort if your compiler is not ANSI compliant. If this happens, use
the generally available GNU C compiler (GCC).
You will need a C99 compiler to build tcpdump. The build system
will abort if your compiler is not C99 compliant. If this happens, use
the generally available GNU C compiler (GCC) or Clang.
After libpcap has been built (either install it with "make install" or
After libpcap has been built (either install it with `make install` or
make sure both the libpcap and tcpdump source trees are in the same
directory), run ./configure (a shell script). "configure" will
determine your system attributes and generate an appropriate Makefile
from Makefile.in. Now build tcpdump by running "make".
directory), run `./configure` (a shell script). `configure` will
determine your system attributes and generate an appropriate `Makefile`
from `Makefile.in`. Now build tcpdump by running `make`.
If everything builds ok, su and type "make install". This will install
If everything builds ok, `su` and type `make install`. This will install
tcpdump and the manual entry. Any user will be able to use tcpdump to
read saved captures. Whether a user will be able to capture traffic
depends on the OS and the configuration of the system; see the tcpdump
man page for details. DO NOT give untrusted users the ability to
depends on the OS and the configuration of the system; see the
[tcpdump man page](https://www.tcpdump.org/manpages/tcpdump.1.html)
for details. DO NOT give untrusted users the ability to
capture traffic. If a user can capture traffic, he or she could use
utilities such as tcpdump to capture any traffic on your net, including
passwords.
Note that most systems ship tcpdump, but usually an older version.
Remember to remove or rename the installed binary when upgrading.
Building tcpdump from source as explained above will usually install the
binary as `/usr/local/bin/tcpdump`. If your system has other tcpdump
binaries, you might need to deinstall these or to set the PATH environment
variable if you need the `tcpdump` command to run the new binary
(`tcpdump --version` can be used to tell different versions apart).
If your system is not one which we have tested tcpdump on, you may have
to modify the configure script and Makefile.in. Please send us patches
to modify the `configure` script and `Makefile.in`. Please
[send us patches](https://www.tcpdump.org/index.html#patches)
for any modifications you need to make.
Please see "PLATFORMS" for notes about tested platforms.
Please see [this file](README.md) for notes about tested platforms.
FILES
-----
## Description of files
```
CHANGES - description of differences between releases
CONTRIBUTING - guidelines for contributing
CONTRIBUTING.md - guidelines for contributing
CREDITS - people that have helped tcpdump along
INSTALL.txt - this file
INSTALL.md - this file
LICENSE - the license under which tcpdump is distributed
Makefile.in - compilation rules (input to the configure script)
README - description of distribution
Readme.Win32 - notes on building tcpdump on Win32 systems (with WinPcap)
README.md - description of distribution
VERSION - version of this release
aclocal.m4 - autoconf macros
addrtoname.c - address to hostname routines
addrtoname.h - address to hostname definitions
addrtostr.c - address to printable string routines
addrtostr.h - address to printable string definitions
ah.h - IPSEC Authentication Header definitions
appletalk.h - AppleTalk definitions
ascii_strcasecmp.c - locale-independent case-independent string comparison
@ -64,13 +72,11 @@ config.h.in - autoconf input
config.sub - autoconf support
configure - configure script (run this first)
configure.ac - configure script source
ether.h - Ethernet definitions
doc/README.* - some building documentation
ethertype.h - Ethernet type value definitions
extract.h - alignment definitions
gmpls.c - GMPLS definitions
gmpls.h - GMPLS declarations
gmt2local.c - time conversion routines
gmt2local.h - time conversion prototypes
install-sh - BSD style install script
interface.h - globals, prototypes and definitions
ip.h - IP definitions
@ -86,6 +92,8 @@ machdep.h - machine dependent definitions
makemib - mib to header script
mib.h - mib definitions
missing/* - replacements for missing library functions
ntp.c - functions to handle ntp structs
ntp.h - declarations of functions to handle ntp structs
mkdep - construct Makefile dependency list
mpls.h - MPLS definitions
nameser.h - DNS definitions
@ -98,8 +106,6 @@ nlpid.h - OSI NLPID definitions
ospf.h - Open Shortest Path First definitions
packetdat.awk - TCP chunk summary awk script
parsenfsfh.c - Network File System file parser routines
pcap_dump_ftell.c - pcap_dump_ftell() implementation, in case libpcap
doesn't have it
pcap-missing.h - declarations of functions possibly missing from libpcap
ppp.h - Point to Point Protocol definitions
print.c - Top-level routines for protocol printing
@ -107,8 +113,6 @@ 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
setsignal.c - OS-independent signal routines
setsignal.h - OS-independent signal prototypes
slcompress.h - SLIP/PPP Van Jacobson compression (RFC1144) definitions
smb.h - SMB/CIFS definitions
smbutil.c - SMB/CIFS utility routines
@ -119,5 +123,4 @@ tcpdump.c - main program
timeval-operations.h - timeval operations macros
udp.h - UDP definitions
util-print.c - utility routines for protocol printers
vfprintf.c - emulation routine
win32 - headers and routines for building on Win32 systems
```

View File

@ -1,9 +1,9 @@
License: BSD
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
@ -13,7 +13,7 @@ are met:
3. The names of the authors may not be used to endorse or promote
products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.

View File

@ -1,5 +1,5 @@
# Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
# The Regents of the University of California. All rights reserved.
# The Regents of the University of California. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that: (1) source code distributions
@ -26,12 +26,13 @@ prefix = @prefix@
exec_prefix = @exec_prefix@
datarootdir = @datarootdir@
# Pathname of directory to install the binary
sbindir = @sbindir@
bindir = @bindir@
# Pathname of directory to install the man page
mandir = @mandir@
# VPATH
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
#
@ -70,7 +71,7 @@ DEPENDENCY_CFLAG = @DEPENDENCY_CFLAG@
@rm -f $@
$(CC) $(FULL_CFLAGS) -c $(srcdir)/$*.c
CSRC = setsignal.c tcpdump.c
CSRC = fptype.c tcpdump.c
LIBNETDISSECT_SRC=\
addrtoname.c \
@ -80,12 +81,14 @@ LIBNETDISSECT_SRC=\
checksum.c \
cpack.c \
gmpls.c \
gmt2local.c \
in_cksum.c \
ipproto.c \
l2vpn.c \
machdep.c \
netdissect.c \
netdissect-alloc.c \
nlpid.c \
ntp.c \
oui.c \
parsenfsfh.c \
print.c \
@ -97,15 +100,18 @@ LIBNETDISSECT_SRC=\
print-aoe.c \
print-ap1394.c \
print-arcnet.c \
print-arista.c \
print-arp.c \
print-ascii.c \
print-atalk.c \
print-atm.c \
print-babel.c \
print-bcm-li.c \
print-beep.c \
print-bfd.c \
print-bgp.c \
print-bootp.c \
print-brcmtag.c \
print-bt.c \
print-calm-fast.c \
print-carp.c \
@ -118,6 +124,7 @@ LIBNETDISSECT_SRC=\
print-decnet.c \
print-dhcp6.c \
print-domain.c \
print-dsa.c \
print-dtp.c \
print-dvmrp.c \
print-eap.c \
@ -141,12 +148,14 @@ LIBNETDISSECT_SRC=\
print-icmp6.c \
print-igmp.c \
print-igrp.c \
print-ip-demux.c \
print-ip.c \
print-ip6.c \
print-ip6opts.c \
print-ipcomp.c \
print-ipfc.c \
print-ipnet.c \
print-ipoib.c \
print-ipx.c \
print-isakmp.c \
print-isoclns.c \
@ -164,7 +173,7 @@ LIBNETDISSECT_SRC=\
print-lwapp.c \
print-lwres.c \
print-m3ua.c \
print-medsa.c \
print-macsec.c \
print-mobile.c \
print-mobility.c \
print-mpcp.c \
@ -179,10 +188,12 @@ LIBNETDISSECT_SRC=\
print-null.c \
print-olsr.c \
print-openflow-1.0.c \
print-openflow-1.3.c \
print-openflow.c \
print-ospf.c \
print-ospf6.c \
print-otv.c \
print-pflog.c \
print-pgm.c \
print-pim.c \
print-pktap.c \
@ -190,13 +201,14 @@ LIBNETDISSECT_SRC=\
print-ppp.c \
print-pppoe.c \
print-pptp.c \
print-ptp.c \
print-radius.c \
print-raw.c \
print-realtek.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 \
@ -209,6 +221,8 @@ LIBNETDISSECT_SRC=\
print-slow.c \
print-smtp.c \
print-snmp.c \
print-someip.c \
print-ssh.c \
print-stp.c \
print-sunatm.c \
print-sunrpc.c \
@ -222,34 +236,36 @@ LIBNETDISSECT_SRC=\
print-token.c \
print-udld.c \
print-udp.c \
print-unsupported.c \
print-usb.c \
print-vjc.c \
print-vqp.c \
print-vrrp.c \
print-vsock.c \
print-vtp.c \
print-vxlan.c \
print-vxlan-gpe.c \
print-vxlan.c \
print-wb.c \
print-whois.c \
print-zep.c \
print-zephyr.c \
print-zeromq.c \
netdissect.c \
signature.c \
strtoaddr.c \
util-print.c
LOCALSRC = @LOCALSRC@
GENSRC = version.c
LIBOBJS = @LIBOBJS@
LIBNETDISSECT_OBJ=$(LIBNETDISSECT_SRC:.c=.o) ${LOCALSRC:.c=.o} ${LIBOBJS}
LIBNETDISSECT=libnetdissect.a
SRC = $(CSRC) $(GENSRC) $(LOCALSRC) $(LIBNETDISSECT_SRC)
SRC = $(CSRC) $(LOCALSRC)
# We would like to say "OBJ = $(SRC:.c=.o)" but Ultrix's make cannot
# hack the extra indirection
OBJ = $(CSRC:.c=.o) $(GENSRC:.c=.o) $(LIBNETDISSECT_OBJ)
OBJ = $(CSRC:.c=.o)
HDR = \
addrtoname.h \
addrtostr.h \
@ -259,14 +275,16 @@ HDR = \
ascii_strcasecmp.h \
atm.h \
chdlc.h \
compiler-tests.h \
cpack.h \
ether.h \
diag-control.h \
ethertype.h \
extract.h \
fptype.h \
ftmacros.h \
funcattrs.h \
getopt_long.h \
getservent.h \
gmpls.h \
gmt2local.h \
interface.h \
ip.h \
ip6.h \
@ -278,72 +296,81 @@ HDR = \
mpls.h \
nameser.h \
netdissect.h \
netdissect-alloc.h \
netdissect-ctype.h \
netdissect-stdinc.h \
nfs.h \
nfsfh.h \
nlpid.h \
ntp.h \
openflow.h \
ospf.h \
oui.h \
pcap-missing.h \
pflog.h \
ppp.h \
print.h \
rpc_auth.h \
rpc_msg.h \
rpl.h \
setsignal.h \
signature.h \
slcompress.h \
smb.h \
status-exit-codes.h \
strtoaddr.h \
tcp.h \
netdissect-stdinc.h \
timeval-operations.h \
udp.h
udp.h \
varattrs.h
TAGHDR = \
/usr/include/arpa/tftp.h \
/usr/include/net/if_arp.h \
/usr/include/netinet/if_ether.h \
/usr/include/netinet/in.h \
/usr/include/netinet/ip_icmp.h \
/usr/include/netinet/tcp.h \
/usr/include/netinet/udp.h \
/usr/include/protocols/routed.h
/usr/include/netinet/in.h
TAGFILES = $(SRC) $(HDR) $(TAGHDR)
TAGFILES = $(SRC) $(HDR) $(TAGHDR) $(LIBNETDISSECT_SRC) \
print-smb.c smbutil.c
CLEANFILES = $(PROG) $(OBJ) $(GENSRC)
CLEANFILES = $(PROG) $(OBJ) $(LIBNETDISSECT_OBJ) print-smb.o smbutil.o
EXTRA_DIST = \
CHANGES \
CONTRIBUTING \
CMakeLists.txt \
CONTRIBUTING.md \
CREDITS \
INSTALL.txt \
INSTALL.md \
LICENSE \
Makefile.in \
Makefile-devel-adds \
PLATFORMS \
README \
Makefile.in \
README.md \
Readme.Win32 \
VERSION \
aclocal.m4 \
atime.awk \
bpf_dump.c \
cmake/Modules/FindCRYPTO.cmake \
cmake/Modules/FindPCAP.cmake \
cmake/Modules/FindSMI.cmake \
cmake_uninstall.cmake.in \
cmakeconfig.h.in \
config.guess \
config.h.in \
config.sub \
configure \
configure.ac \
doc/README.aix.md \
doc/README.NetBSD.md \
doc/README.solaris.md \
doc/README.Win32.md \
install-sh \
lbl/os-osf4.h \
lbl/os-solaris2.h \
lbl/os-sunos4.h \
lbl/os-ultrix4.h \
makemib \
missing/dlnames.c \
missing/datalinks.c \
missing/dlnames.c \
missing/getopt_long.c \
missing/getopt_long.h \
missing/getservent.c \
missing/pcap_dump_ftell.c \
missing/snprintf.c \
missing/strdup.c \
missing/strlcat.c \
@ -351,28 +378,21 @@ EXTRA_DIST = \
missing/strsep.c \
mkdep \
packetdat.awk \
pcap_dump_ftell.c \
print-pflog.c \
print-smb.c \
send-ack.awk \
smbutil.c \
stime.awk \
tcpdump.1.in \
vfprintf.c \
win32/prj/GNUmakefile \
win32/prj/WinDump.dsp \
win32/prj/WinDump.dsw \
win32/prj/WinDump.sln \
win32/prj/WinDump.vcproj \
win32/src/ether_ntohost.c
tcpdump.1.in
TEST_DIST= `git ls-files tests | grep -v 'tests/\..*'`
all: $(PROG) $(LIBNETDISSECT)
RELEASE_FILES = $(CSRC) $(HDR) $(LIBNETDISSECT_SRC) $(EXTRA_DIST) $(TEST_DIST)
$(PROG): $(OBJ) @V_PCAPDEP@
all: $(PROG)
$(PROG): $(OBJ) @V_PCAPDEP@ $(LIBNETDISSECT)
@rm -f $@
$(CC) $(FULL_CFLAGS) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
$(CC) $(FULL_CFLAGS) $(LDFLAGS) -o $@ $(OBJ) $(LIBNETDISSECT) $(LIBS)
$(LIBNETDISSECT): $(LIBNETDISSECT_OBJ)
@rm -f $@
@ -383,6 +403,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
getservent.o: $(srcdir)/missing/getservent.c
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/getservent.c
getopt_long.o: $(srcdir)/missing/getopt_long.c
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/getopt_long.c
snprintf.o: $(srcdir)/missing/snprintf.c
@ -395,50 +417,40 @@ strlcpy.o: $(srcdir)/missing/strlcpy.c
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strlcpy.c
strsep.o: $(srcdir)/missing/strsep.c
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strsep.c
version.o: version.c
$(CC) $(FULL_CFLAGS) -c version.c
version.c: $(srcdir)/VERSION
@rm -f $@
if grep GIT ${srcdir}/VERSION >/dev/null; then \
read ver <${srcdir}/VERSION; \
echo $$ver | tr -d '\012'; \
date +_%Y_%m_%d; \
else \
cat ${srcdir}/VERSION; \
fi | sed -e 's/.*/const char version[] = "&";/' > $@
pcap_dump_ftell.o: $(srcdir)/missing/pcap_dump_ftell.c
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/pcap_dump_ftell.c
install: all
[ -d $(DESTDIR)$(sbindir) ] || \
(mkdir -p $(DESTDIR)$(sbindir); chmod 755 $(DESTDIR)$(sbindir))
$(INSTALL_PROGRAM) $(PROG) $(DESTDIR)$(sbindir)/$(PROG)
$(INSTALL_PROGRAM) $(PROG) $(DESTDIR)$(sbindir)/$(PROG).`cat ${srcdir}/VERSION`
[ -d $(DESTDIR)$(bindir) ] || \
(mkdir -p $(DESTDIR)$(bindir); chmod 755 $(DESTDIR)$(bindir))
$(INSTALL_PROGRAM) $(PROG) $(DESTDIR)$(bindir)/$(PROG)
$(INSTALL_PROGRAM) $(PROG) $(DESTDIR)$(bindir)/$(PROG).`cat ${srcdir}/VERSION`
[ -d $(DESTDIR)$(mandir)/man1 ] || \
(mkdir -p $(DESTDIR)$(mandir)/man1; chmod 755 $(DESTDIR)$(mandir)/man1)
$(INSTALL_DATA) $(PROG).1 $(DESTDIR)$(mandir)/man1/$(PROG).1
uninstall:
rm -f $(DESTDIR)$(sbindir)/$(PROG)
rm -f $(DESTDIR)$(bindir)/$(PROG)
rm -f $(DESTDIR)$(bindir)/$(PROG).`cat ${srcdir}/VERSION`
rm -f $(DESTDIR)$(mandir)/man1/$(PROG).1
lint: $(GENSRC)
lint -hbxn $(SRC) | \
lint:
lint -hbxn $(SRC) $(LIBNETDISSECT_SRC) | \
grep -v 'struct/union .* never defined' | \
grep -v 'possible pointer alignment problem'
clean:
rm -f $(CLEANFILES) $(PROG)-`cat VERSION`.tar.gz
rm -f $(CLEANFILES) $(PROG)-`cat ${srcdir}/VERSION`.tar.gz
distclean:
rm -f $(CLEANFILES) Makefile config.cache config.log config.status \
config.h gnuc.h os-proto.h stamp-h stamp-h.in $(PROG).1 \
config.h os-proto.h stamp-h stamp-h.in $(PROG).1 \
libnetdissect.a tests/.failed tests/.passed \
tests/failure-outputs.txt
rm -rf autom4te.cache tests/DIFF tests/NEW
check: tcpdump
(mkdir -p tests && SRCDIR=`cd ${srcdir}; pwd` && export SRCDIR && $$SRCDIR/tests/TESTrun.sh )
$(srcdir)/tests/TESTrun
extags: $(TAGFILES)
ctags $(TAGFILES)
@ -450,14 +462,78 @@ TAGS: $(TAGFILES)
etags $(TAGFILES)
releasetar:
@cwd=`pwd` ; dir=`basename $$cwd` ; name=$(PROG)-`cat VERSION` ; \
mkdir $$name; \
tar cf - $(CSRC) $(HDR) $(LIBNETDISSECT_SRC) $(EXTRA_DIST) $(TEST_DIST) | (cd $$name; tar xf -); \
tar -c -z -f $$name.tar.gz $$name; \
rm -rf $$name
@TAG=$(PROG)-`cat VERSION` && \
if git show-ref --tags --quiet --verify -- "refs/tags/$$TAG"; then \
git archive --prefix="$$TAG"/ -o "$$TAG".tar.gz "$$TAG" \
$(RELEASE_FILES) && \
echo "Archive build from tag $$TAG."; \
else \
git archive --prefix="$$TAG"/ -o "$$TAG".tar.gz HEAD \
$(RELEASE_FILES) && \
echo "No $$TAG tag. Archive build from HEAD."; \
fi
releasecheck: releasetar
@TAG=$(PROG)-`cat VERSION` && \
INSTALL_DIR=/tmp/install_"$$TAG"_$$$$ && \
DIR=`pwd` && \
cd /tmp && \
rm -rf "$$TAG" && \
rm -rf "$$INSTALL_DIR" && \
tar xf "$$DIR"/"$$TAG".tar.gz && \
cd "$$TAG" && \
echo "[$@] $$ ./configure --enable-smb --quiet --prefix=$$INSTALL_DIR" && \
./configure --enable-smb --quiet --prefix="$$INSTALL_DIR" && \
echo '[$@] $$ make -s all check' && \
make -s all check >/dev/null && \
echo '[$@] $$ make -s install' && \
make -s install && \
cd .. && \
rm -rf "$$TAG" && \
rm -rf "$$INSTALL_DIR" && \
tar xf "$$DIR"/"$$TAG".tar.gz && \
cd "$$TAG" && \
mkdir build && \
cd build && \
echo '[$@] $$ cmake -DENABLE_SMB=yes [...] ..' && \
cmake -DENABLE_SMB=yes \
-DCMAKE_INSTALL_PREFIX="$$INSTALL_DIR" \
-DCMAKE_MESSAGE_LOG_LEVEL=NOTICE \
-DCMAKE_RULE_MESSAGES=OFF \
-DCMAKE_INSTALL_MESSAGE=NEVER \
.. && \
echo '[$@] $$ make -s all check' && \
make -s all check >/dev/null && \
echo '[$@] $$ make -s install' && \
make -s install && \
cd ../.. && \
rm -rf "$$TAG" && \
rm -rf "$$INSTALL_DIR" && \
echo '[$@] Done.'
whitespacecheck:
@# trailing space(s)?
@if git grep -I -n ' $$' $$(git ls-files|grep -v '^tests/'); then \
echo 'Error: Trailing space(s).'; \
exit 1; \
fi
@# trailing tab(s)?
@# install-sh has a tab at the end of one line
@if git grep -I -n ' $$' $$(git ls-files|grep -vE '^(tests/|install-sh$$)'); then \
echo 'Error: Trailing tabs(s).'; \
exit 1; \
fi
@# space(s) before tab(s)?
@if git grep -I -n '[ ][ ]' $$(git ls-files|grep -v '^tests/'); then \
echo 'Error: space(s) before tab(s).'; \
exit 1; \
fi
testlist:
echo $(TEST_DIST)
depend: $(GENSRC)
$(MKDEP) -c $(CC) -m $(DEPENDENCY_CFLAG) $(DEFS) $(INCLS) $(SRC)
depend:
$(MKDEP) -c "$(CC)" -m "$(DEPENDENCY_CFLAG)" -s "$(srcdir)" $(DEFS) $(INCLS) $(SRC) $(LIBNETDISSECT_SRC)
shellcheck:
shellcheck -f gcc -e SC2006 build.sh build_matrix.sh build_common.sh

View File

@ -1,16 +0,0 @@
In many operating systems tcpdump is available as a native package or port,
which simplifies installation of updates and long-term maintenance. However,
the native packages are sometimes a few versions behind and to try a more
recent snapshot it will take to compile tcpdump from the source code.
tcpdump compiles and works on at least the following platforms:
* AIX
* FreeBSD
* HP-UX 11i
* Linux (any) with glibc (usually just works)
* Linux (any) with musl libc (sometimes fails to compile, please report any bugs)
* Mac OS X / macOS
* NetBSD
* OpenWrt
* Solaris

View File

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

View File

@ -1,79 +1,79 @@
# tcpdump
# TCPDUMP 4.x.y by [The Tcpdump Group](https://www.tcpdump.org/)
[![Build
Status](https://travis-ci.org/the-tcpdump-group/tcpdump.png)](https://travis-ci.org/the-tcpdump-group/tcpdump)
To report a security issue please send an e-mail to security@tcpdump.org.
**To report a security issue please send an e-mail to security@tcpdump.org.**
To report bugs and other problems, contribute patches, request a
feature, provide generic feedback etc please see the file
CONTRIBUTING in the tcpdump source tree root.
feature, provide generic feedback etc please see the
[guidelines for contributing](CONTRIBUTING.md) in the tcpdump source tree root.
TCPDUMP 4.x.y
Now maintained by "The Tcpdump Group"
See www.tcpdump.org
Anonymous Git is available via
Anonymous Git is available via:
git clone git://bpf.tcpdump.org/tcpdump
formerly from Lawrence Berkeley National Laboratory
Network Research Group <tcpdump@ee.lbl.gov>
ftp://ftp.ee.lbl.gov/old/tcpdump.tar.Z (3.4)
https://github.com/the-tcpdump-group/tcpdump.git
This directory contains source code for tcpdump, a tool for network
monitoring and data acquisition. This software was originally
developed by the Network Research Group at the Lawrence Berkeley
National Laboratory. The original distribution is available via
anonymous ftp to `ftp.ee.lbl.gov`, in `tcpdump.tar.Z`. More recent
development is performed at tcpdump.org, http://www.tcpdump.org/
monitoring and data acquisition.
Over the past few years, tcpdump has been steadily improved by the
excellent contributions from the Internet community (just browse
through the [change log](CHANGES)). We are grateful for all the input.
### Supported platforms
In many operating systems tcpdump is available as a native package or port,
which simplifies installation of updates and long-term maintenance. However,
the native packages are sometimes a few versions behind and to try a more
recent snapshot it will take to compile tcpdump from the source code.
tcpdump compiles and works on at least the following platforms:
* AIX
* DragonFly BSD
* FreeBSD
* Haiku
* HP-UX 11i
* illumos (OmniOS, OpenIndiana)
* GNU/Linux
* {Mac} OS X / macOS
* NetBSD
* OpenBSD
* OpenWrt
* Solaris
* Windows (requires WinPcap or Npcap, and Visual Studio with CMake)
### Dependency on libpcap
Tcpdump uses libpcap, a system-independent interface for user-level
packet capture. Before building tcpdump, you must first retrieve and
build libpcap, also originally from LBL and now being maintained by
tcpdump.org; see http://www.tcpdump.org/ .
build libpcap.
Once libpcap is built (either install it or make sure it's in
`../libpcap`), you can build tcpdump using the procedure in the `INSTALL.txt`
file.
`../libpcap`), you can build tcpdump using the procedure in the
[installation notes](INSTALL.md).
### Origins of tcpdump
The program is loosely based on SMI's "etherfind" although none of the
etherfind code remains. It was originally written by Van Jacobson as
part of an ongoing research project to investigate and improve tcp and
internet gateway performance. The parts of the program originally
part of an ongoing research project to investigate and improve TCP and
Internet gateway performance. The parts of the program originally
taken from Sun's etherfind were later re-written by Steven McCanne of
LBL. To insure that there would be no vestige of proprietary code in
tcpdump, Steve wrote these pieces from the specification given by the
manual entry, with no access to the source of tcpdump or etherfind.
```text
formerly from Lawrence Berkeley National Laboratory
Network Research Group <tcpdump@ee.lbl.gov>
ftp://ftp.ee.lbl.gov/old/tcpdump.tar.Z (3.4)
```
Over the past few years, tcpdump has been steadily improved by the
excellent contributions from the Internet community (just browse
through the `CHANGES` file). We are grateful for all the input.
### See also
Richard Stevens gives an excellent treatment of the Internet protocols
in his book *"TCP/IP Illustrated, Volume 1"*. If you want to learn more
about tcpdump and how to interpret its output, pick up this book.
Some tools for viewing and analyzing tcpdump trace files are available
from the Internet Traffic Archive:
* http://www.sigcomm.org/ITA/
Another tool that tcpdump users might find useful is tcpslice:
* https://github.com/the-tcpdump-group/tcpslice
Another tool that tcpdump users might find useful is
[tcpslice](https://github.com/the-tcpdump-group/tcpslice).
It is a program that can be used to extract portions of tcpdump binary
trace files. See the above distribution for further details and
documentation.
trace files.
Current versions can be found at www.tcpdump.org.
- The TCPdump team
original text by: Steve McCanne, Craig Leres, Van Jacobson
-------------------------------------
### The original LBL README by Steve McCanne, Craig Leres and Van Jacobson
```
This directory also contains some short awk programs intended as
examples of ways to reduce tcpdump data when you're tracking

View File

@ -1 +1 @@
4.9.3
4.99.4

View File

@ -23,7 +23,7 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#include <config.h>
#endif
#ifdef HAVE_CASPER
@ -31,32 +31,75 @@
#include <casper/cap_dns.h>
#endif /* HAVE_CASPER */
#include <netdissect-stdinc.h>
#include "netdissect-stdinc.h"
#ifdef USE_ETHER_NTOHOST
#ifdef HAVE_NETINET_IF_ETHER_H
struct mbuf; /* Squelch compiler warnings on some platforms for */
struct rtentry; /* declarations in <net/if.h> */
#include <net/if.h> /* for "struct ifnet" in "struct arpcom" on Solaris */
#include <netinet/if_ether.h>
#endif /* HAVE_NETINET_IF_ETHER_H */
#ifdef NETINET_ETHER_H_DECLARES_ETHER_NTOHOST
#include <netinet/ether.h>
#endif /* NETINET_ETHER_H_DECLARES_ETHER_NTOHOST */
#if defined(NET_ETHERNET_H_DECLARES_ETHER_NTOHOST)
/*
* OK, just include <net/ethernet.h>.
*/
#include <net/ethernet.h>
#elif defined(NETINET_ETHER_H_DECLARES_ETHER_NTOHOST)
/*
* OK, just include <netinet/ether.h>
*/
#include <netinet/ether.h>
#elif defined(SYS_ETHERNET_H_DECLARES_ETHER_NTOHOST)
/*
* OK, just include <sys/ethernet.h>
*/
#include <sys/ethernet.h>
#elif defined(ARPA_INET_H_DECLARES_ETHER_NTOHOST)
/*
* OK, just include <arpa/inet.h>
*/
#include <arpa/inet.h>
#elif defined(NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST)
/*
* OK, include <netinet/if_ether.h>, after all the other stuff we
* need to include or define for its benefit.
*/
#define NEED_NETINET_IF_ETHER_H
#else
/*
* We'll have to declare it ourselves.
* If <netinet/if_ether.h> defines struct ether_addr, include
* it. Otherwise, define it ourselves.
*/
#ifdef HAVE_STRUCT_ETHER_ADDR
#define NEED_NETINET_IF_ETHER_H
#else /* HAVE_STRUCT_ETHER_ADDR */
struct ether_addr {
/* Beware FreeBSD calls this "octet". */
unsigned char ether_addr_octet[MAC_ADDR_LEN];
};
#endif /* HAVE_STRUCT_ETHER_ADDR */
#endif /* what declares ether_ntohost() */
#if !defined(HAVE_DECL_ETHER_NTOHOST) || !HAVE_DECL_ETHER_NTOHOST
#ifndef HAVE_STRUCT_ETHER_ADDR
struct ether_addr {
unsigned char ether_addr_octet[6];
};
#endif
extern int ether_ntohost(char *, const struct ether_addr *);
#endif
#ifdef NEED_NETINET_IF_ETHER_H
/*
* Include diag-control.h before <net/if.h>, which too defines a macro
* named ND_UNREACHABLE.
*/
#include "diag-control.h"
#include <net/if.h> /* Needed on some platforms */
#include <netinet/in.h> /* Needed on some platforms */
#include <netinet/if_ether.h>
#endif /* NEED_NETINET_IF_ETHER_H */
#ifndef HAVE_DECL_ETHER_NTOHOST
/*
* No header declares it, so declare it ourselves.
*/
extern int ether_ntohost(char *, const struct ether_addr *);
#endif /* !defined(HAVE_DECL_ETHER_NTOHOST) */
#endif /* USE_ETHER_NTOHOST */
#include <pcap.h>
#include <pcap-namedb.h>
#ifndef HAVE_GETSERVENT
#include <getservent.h>
#endif
#include <signal.h>
#include <stdio.h>
#include <string.h>
@ -67,18 +110,13 @@ extern int ether_ntohost(char *, const struct ether_addr *);
#include "addrtostr.h"
#include "ethertype.h"
#include "llc.h"
#include "setsignal.h"
#include "extract.h"
#include "oui.h"
#ifndef ETHER_ADDR_LEN
#define ETHER_ADDR_LEN 6
#endif
/*
* hash tables for whatever-to-name translations
*
* ndo_error() called on strdup(3) failure
* ndo_error() called on strdup(3) failure with S_ERR_ND_MEM_ALLOC status
*/
#define HASHNAMESIZE 4096
@ -137,7 +175,7 @@ win32_gethostbyaddr(const char *addr, int len, int type)
#endif /* _WIN32 */
struct h6namemem {
struct in6_addr addr;
nd_ipv6 addr;
char *name;
struct h6namemem *nxt;
};
@ -183,25 +221,25 @@ static struct protoidmem protoidtable[HASHNAMESIZE];
const char *
intoa(uint32_t addr)
{
register char *cp;
register u_int byte;
register int n;
char *cp;
u_int byte;
int n;
static char buf[sizeof(".xxx.xxx.xxx.xxx")];
NTOHL(addr);
addr = ntohl(addr);
cp = buf + sizeof(buf);
*--cp = '\0';
n = 4;
do {
byte = addr & 0xff;
*--cp = byte % 10 + '0';
*--cp = (char)(byte % 10) + '0';
byte /= 10;
if (byte > 0) {
*--cp = byte % 10 + '0';
*--cp = (char)(byte % 10) + '0';
byte /= 10;
if (byte > 0)
*--cp = byte + '0';
*--cp = (char)byte + '0';
}
*--cp = '.';
addr >>= 8;
@ -213,16 +251,15 @@ intoa(uint32_t addr)
static uint32_t f_netmask;
static uint32_t f_localnet;
#ifdef HAVE_CASPER
extern cap_channel_t *capdns;
cap_channel_t *capdns;
#endif
/*
* Return a name for the IP address pointed to by ap. This address
* is assumed to be in network byte order.
*
* NOTE: ap is *NOT* necessarily part of the packet data (not even if
* this is being called with the "ipaddr_string()" macro), so you
* *CANNOT* use the ND_TCHECK{2}/ND_TTEST{2} macros on it. Furthermore,
* NOTE: ap is *NOT* necessarily part of the packet data, so you
* *CANNOT* use the ND_TCHECK_* or ND_TTEST_* 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
@ -236,9 +273,9 @@ extern cap_channel_t *capdns;
* also needs to check whether they're present in the packet buffer.
*/
const char *
getname(netdissect_options *ndo, const u_char *ap)
ipaddr_string(netdissect_options *ndo, const u_char *ap)
{
register struct hostent *hp;
struct hostent *hp;
uint32_t addr;
struct hnamemem *p;
@ -272,8 +309,8 @@ getname(netdissect_options *ndo, const u_char *ap)
p->name = strdup(hp->h_name);
if (p->name == NULL)
(*ndo->ndo_error)(ndo,
"getname: strdup(hp->h_name)");
(*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
"%s: strdup(hp->h_name)", __func__);
if (ndo->ndo_Nflag) {
/* Remove domain qualifications */
dotp = strchr(p->name, '.');
@ -285,7 +322,8 @@ 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))");
(*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
"%s: strdup(intoa(addr))", __func__);
return (p->name);
}
@ -294,18 +332,18 @@ getname(netdissect_options *ndo, const u_char *ap)
* is assumed to be in network byte order.
*/
const char *
getname6(netdissect_options *ndo, const u_char *ap)
ip6addr_string(netdissect_options *ndo, const u_char *ap)
{
register struct hostent *hp;
struct hostent *hp;
union {
struct in6_addr addr;
nd_ipv6 addr;
struct for_hash_addr {
char fill[14];
uint16_t d;
} addra;
} addr;
struct h6namemem *p;
register const char *cp;
const char *cp;
char ntop_buf[INET6_ADDRSTRLEN];
memcpy(&addr, ap, sizeof(addr));
@ -314,7 +352,7 @@ getname6(netdissect_options *ndo, const u_char *ap)
if (memcmp(&p->addr, &addr, sizeof(addr)) == 0)
return (p->name);
}
p->addr = addr.addr;
memcpy(p->addr, addr.addr, sizeof(nd_ipv6));
p->nxt = newh6namemem(ndo);
/*
@ -334,8 +372,8 @@ getname6(netdissect_options *ndo, const u_char *ap)
p->name = strdup(hp->h_name);
if (p->name == NULL)
(*ndo->ndo_error)(ndo,
"getname6: strdup(hp->h_name)");
(*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
"%s: strdup(hp->h_name)", __func__);
if (ndo->ndo_Nflag) {
/* Remove domain qualifications */
dotp = strchr(p->name, '.');
@ -348,19 +386,54 @@ getname6(netdissect_options *ndo, const u_char *ap)
cp = addrtostr6(ap, ntop_buf, sizeof(ntop_buf));
p->name = strdup(cp);
if (p->name == NULL)
(*ndo->ndo_error)(ndo, "getname6: strdup(cp)");
(*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
"%s: strdup(cp)", __func__);
return (p->name);
}
static const char hex[16] = "0123456789abcdef";
static const char hex[16] = {
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
};
/*
* Convert an octet to two hex digits.
*
* Coverity appears either:
*
* not to believe the C standard when it asserts that a uint8_t is
* exactly 8 bits in size;
*
* not to believe that an unsigned type of exactly 8 bits has a value
* in the range of 0 to 255;
*
* not to believe that, for a range of unsigned values, if you shift
* one of those values right by 4 bits, the maximum result value is
* the maximum value shifted right by 4 bits, with no stray 1's shifted
* in;
*
* not to believe that 255 >> 4 is 15;
*
* so it gets upset that we're taking a "tainted" unsigned value, shifting
* it right 4 bits, and using it as an index into a 16-element array.
*
* So we do a stupid pointless masking of the result of the shift with
* 0xf, to hammer the point home to Coverity.
*/
static inline char *
octet_to_hex(char *cp, uint8_t octet)
{
*cp++ = hex[(octet >> 4) & 0xf];
*cp++ = hex[(octet >> 0) & 0xf];
return (cp);
}
/* Find the hash node that corresponds the ether address 'ep' */
static inline struct enamemem *
static struct enamemem *
lookup_emem(netdissect_options *ndo, const u_char *ep)
{
register u_int i, j, k;
u_int i, j, k;
struct enamemem *tp;
k = (ep[0] << 8) | ep[1];
@ -375,12 +448,12 @@ lookup_emem(netdissect_options *ndo, const u_char *ep)
return tp;
else
tp = tp->e_nxt;
tp->e_addr0 = i;
tp->e_addr1 = j;
tp->e_addr2 = k;
tp->e_addr0 = (u_short)i;
tp->e_addr1 = (u_short)j;
tp->e_addr2 = (u_short)k;
tp->e_nxt = (struct enamemem *)calloc(1, sizeof(*tp));
if (tp->e_nxt == NULL)
(*ndo->ndo_error)(ndo, "lookup_emem: calloc");
(*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC, "%s: calloc", __func__);
return tp;
}
@ -390,12 +463,12 @@ lookup_emem(netdissect_options *ndo, const u_char *ep)
* with length 'nlen'
*/
static inline struct bsnamemem *
lookup_bytestring(netdissect_options *ndo, register const u_char *bs,
static struct bsnamemem *
lookup_bytestring(netdissect_options *ndo, const u_char *bs,
const unsigned int nlen)
{
struct bsnamemem *tp;
register u_int i, j, k;
u_int i, j, k;
if (nlen >= 6) {
k = (bs[0] << 8) | bs[1];
@ -419,30 +492,32 @@ lookup_bytestring(netdissect_options *ndo, register const u_char *bs,
else
tp = tp->bs_nxt;
tp->bs_addr0 = i;
tp->bs_addr1 = j;
tp->bs_addr2 = k;
tp->bs_addr0 = (u_short)i;
tp->bs_addr1 = (u_short)j;
tp->bs_addr2 = (u_short)k;
tp->bs_bytes = (u_char *) calloc(1, nlen);
if (tp->bs_bytes == NULL)
(*ndo->ndo_error)(ndo, "lookup_bytestring: calloc");
(*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
"%s: calloc", __func__);
memcpy(tp->bs_bytes, bs, nlen);
tp->bs_nbytes = nlen;
tp->bs_nxt = (struct bsnamemem *)calloc(1, sizeof(*tp));
if (tp->bs_nxt == NULL)
(*ndo->ndo_error)(ndo, "lookup_bytestring: calloc");
(*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
"%s: calloc", __func__);
return tp;
}
/* Find the hash node that corresponds the NSAP 'nsap' */
static inline struct enamemem *
lookup_nsap(netdissect_options *ndo, register const u_char *nsap,
register u_int nsap_length)
static struct enamemem *
lookup_nsap(netdissect_options *ndo, const u_char *nsap,
u_int nsap_length)
{
register u_int i, j, k;
u_int i, j, k;
struct enamemem *tp;
const u_char *ensap;
@ -466,27 +541,27 @@ lookup_nsap(netdissect_options *ndo, register const u_char *nsap,
return tp;
else
tp = tp->e_nxt;
tp->e_addr0 = i;
tp->e_addr1 = j;
tp->e_addr2 = k;
tp->e_addr0 = (u_short)i;
tp->e_addr1 = (u_short)j;
tp->e_addr2 = (u_short)k;
tp->e_nsap = (u_char *)malloc(nsap_length + 1);
if (tp->e_nsap == NULL)
(*ndo->ndo_error)(ndo, "lookup_nsap: malloc");
(*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC, "%s: malloc", __func__);
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)
(*ndo->ndo_error)(ndo, "lookup_nsap: calloc");
(*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC, "%s: calloc", __func__);
return tp;
}
/* Find the hash node that corresponds the protoid 'pi'. */
static inline struct protoidmem *
static struct protoidmem *
lookup_protoid(netdissect_options *ndo, const u_char *pi)
{
register u_int i, j;
u_int i, j;
struct protoidmem *tp;
/* 5 octets won't be aligned */
@ -501,20 +576,20 @@ lookup_protoid(netdissect_options *ndo, const u_char *pi)
else
tp = tp->p_nxt;
tp->p_oui = i;
tp->p_proto = j;
tp->p_proto = (u_short)j;
tp->p_nxt = (struct protoidmem *)calloc(1, sizeof(*tp));
if (tp->p_nxt == NULL)
(*ndo->ndo_error)(ndo, "lookup_protoid: calloc");
(*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC, "%s: calloc", __func__);
return tp;
}
const char *
etheraddr_string(netdissect_options *ndo, register const u_char *ep)
etheraddr_string(netdissect_options *ndo, const uint8_t *ep)
{
register int i;
register char *cp;
register struct enamemem *tp;
int i;
char *cp;
struct enamemem *tp;
int oui;
char buf[BUFSIZE];
@ -524,24 +599,29 @@ etheraddr_string(netdissect_options *ndo, register const u_char *ep)
#ifdef USE_ETHER_NTOHOST
if (!ndo->ndo_nflag) {
char buf2[BUFSIZE];
/*
* This is a non-const copy of ep for ether_ntohost(), which
* has its second argument non-const in OpenBSD. Also saves a
* type cast.
*/
struct ether_addr ea;
if (ether_ntohost(buf2, (const struct ether_addr *)ep) == 0) {
memcpy (&ea, ep, MAC_ADDR_LEN);
if (ether_ntohost(buf2, &ea) == 0) {
tp->e_name = strdup(buf2);
if (tp->e_name == NULL)
(*ndo->ndo_error)(ndo,
"etheraddr_string: strdup(buf2)");
(*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
"%s: strdup(buf2)", __func__);
return (tp->e_name);
}
}
#endif
cp = buf;
oui = EXTRACT_24BITS(ep);
*cp++ = hex[*ep >> 4 ];
*cp++ = hex[*ep++ & 0xf];
oui = EXTRACT_BE_U_3(ep);
cp = octet_to_hex(cp, *ep++);
for (i = 5; --i >= 0;) {
*cp++ = ':';
*cp++ = hex[*ep >> 4 ];
*cp++ = hex[*ep++ & 0xf];
cp = octet_to_hex(cp, *ep++);
}
if (!ndo->ndo_nflag) {
@ -551,17 +631,18 @@ etheraddr_string(netdissect_options *ndo, register const u_char *ep)
*cp = '\0';
tp->e_name = strdup(buf);
if (tp->e_name == NULL)
(*ndo->ndo_error)(ndo, "etheraddr_string: strdup(buf)");
(*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
"%s: strdup(buf)", __func__);
return (tp->e_name);
}
const char *
le64addr_string(netdissect_options *ndo, const u_char *ep)
le64addr_string(netdissect_options *ndo, const uint8_t *ep)
{
const unsigned int len = 8;
register u_int i;
register char *cp;
register struct bsnamemem *tp;
u_int i;
char *cp;
struct bsnamemem *tp;
char buf[BUFSIZE];
tp = lookup_bytestring(ndo, ep, len);
@ -570,8 +651,7 @@ le64addr_string(netdissect_options *ndo, const u_char *ep)
cp = buf;
for (i = len; i > 0 ; --i) {
*cp++ = hex[*(ep + i - 1) >> 4];
*cp++ = hex[*(ep + i - 1) & 0xf];
cp = octet_to_hex(cp, *(ep + i - 1));
*cp++ = ':';
}
cp --;
@ -580,23 +660,24 @@ le64addr_string(netdissect_options *ndo, const u_char *ep)
tp->bs_name = strdup(buf);
if (tp->bs_name == NULL)
(*ndo->ndo_error)(ndo, "le64addr_string: strdup(buf)");
(*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
"%s: strdup(buf)", __func__);
return (tp->bs_name);
}
const char *
linkaddr_string(netdissect_options *ndo, const u_char *ep,
linkaddr_string(netdissect_options *ndo, const uint8_t *ep,
const unsigned int type, const unsigned int len)
{
register u_int i;
register char *cp;
register struct bsnamemem *tp;
u_int i;
char *cp;
struct bsnamemem *tp;
if (len == 0)
return ("<empty>");
if (type == LINKADDR_ETHER && len == ETHER_ADDR_LEN)
if (type == LINKADDR_ETHER && len == MAC_ADDR_LEN)
return (etheraddr_string(ndo, ep));
if (type == LINKADDR_FRELAY)
@ -608,83 +689,25 @@ linkaddr_string(netdissect_options *ndo, const u_char *ep,
tp->bs_name = cp = (char *)malloc(len*3);
if (tp->bs_name == NULL)
(*ndo->ndo_error)(ndo, "linkaddr_string: malloc");
*cp++ = hex[*ep >> 4];
*cp++ = hex[*ep++ & 0xf];
(*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
"%s: malloc", __func__);
cp = octet_to_hex(cp, *ep++);
for (i = len-1; i > 0 ; --i) {
*cp++ = ':';
*cp++ = hex[*ep >> 4];
*cp++ = hex[*ep++ & 0xf];
cp = octet_to_hex(cp, *ep++);
}
*cp = '\0';
return (tp->bs_name);
}
const char *
etherproto_string(netdissect_options *ndo, u_short port)
{
register char *cp;
register struct hnamemem *tp;
register uint32_t i = port;
char buf[sizeof("0000")];
for (tp = &eprototable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt)
if (tp->addr == i)
return (tp->name);
tp->addr = i;
tp->nxt = newhnamemem(ndo);
cp = buf;
NTOHS(port);
*cp++ = hex[port >> 12 & 0xf];
*cp++ = hex[port >> 8 & 0xf];
*cp++ = hex[port >> 4 & 0xf];
*cp++ = hex[port & 0xf];
*cp++ = '\0';
tp->name = strdup(buf);
if (tp->name == NULL)
(*ndo->ndo_error)(ndo, "etherproto_string: strdup(buf)");
return (tp->name);
}
const char *
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(ndo, pi);
if (tp->p_name)
return tp->p_name;
cp = buf;
if ((j = *pi >> 4) != 0)
*cp++ = hex[j];
*cp++ = hex[*pi++ & 0xf];
for (i = 4; (int)--i >= 0;) {
*cp++ = ':';
if ((j = *pi >> 4) != 0)
*cp++ = hex[j];
*cp++ = hex[*pi++ & 0xf];
}
*cp = '\0';
tp->p_name = strdup(buf);
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(netdissect_options *ndo, const u_char *nsap,
register u_int nsap_length)
isonsap_string(netdissect_options *ndo, const uint8_t *nsap,
u_int nsap_length)
{
register u_int nsap_idx;
register char *cp;
register struct enamemem *tp;
u_int nsap_idx;
char *cp;
struct enamemem *tp;
if (nsap_length < 1 || nsap_length > ISONSAP_MAX_LENGTH)
return ("isonsap_string: illegal length");
@ -695,14 +718,14 @@ isonsap_string(netdissect_options *ndo, const u_char *nsap,
tp->e_name = cp = (char *)malloc(sizeof("xx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xx"));
if (cp == NULL)
(*ndo->ndo_error)(ndo, "isonsap_string: malloc");
(*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
"%s: malloc", __func__);
for (nsap_idx = 0; nsap_idx < nsap_length; nsap_idx++) {
*cp++ = hex[*nsap >> 4];
*cp++ = hex[*nsap++ & 0xf];
cp = octet_to_hex(cp, *nsap++);
if (((nsap_idx & 1) == 0) &&
(nsap_idx + 1 < nsap_length)) {
*cp++ = '.';
*cp++ = '.';
}
}
*cp = '\0';
@ -712,8 +735,8 @@ isonsap_string(netdissect_options *ndo, const u_char *nsap,
const char *
tcpport_string(netdissect_options *ndo, u_short port)
{
register struct hnamemem *tp;
register uint32_t i = port;
struct hnamemem *tp;
uint32_t i = port;
char buf[sizeof("00000")];
for (tp = &tporttable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt)
@ -726,15 +749,16 @@ tcpport_string(netdissect_options *ndo, u_short port)
(void)snprintf(buf, sizeof(buf), "%u", i);
tp->name = strdup(buf);
if (tp->name == NULL)
(*ndo->ndo_error)(ndo, "tcpport_string: strdup(buf)");
(*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
"%s: strdup(buf)", __func__);
return (tp->name);
}
const char *
udpport_string(netdissect_options *ndo, register u_short port)
udpport_string(netdissect_options *ndo, u_short port)
{
register struct hnamemem *tp;
register uint32_t i = port;
struct hnamemem *tp;
uint32_t i = port;
char buf[sizeof("00000")];
for (tp = &uporttable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt)
@ -747,16 +771,17 @@ udpport_string(netdissect_options *ndo, register u_short port)
(void)snprintf(buf, sizeof(buf), "%u", i);
tp->name = strdup(buf);
if (tp->name == NULL)
(*ndo->ndo_error)(ndo, "udpport_string: strdup(buf)");
(*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
"%s: strdup(buf)", __func__);
return (tp->name);
}
const char *
ipxsap_string(netdissect_options *ndo, u_short port)
{
register char *cp;
register struct hnamemem *tp;
register uint32_t i = port;
char *cp;
struct hnamemem *tp;
uint32_t i = port;
char buf[sizeof("0000")];
for (tp = &ipxsaptable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt)
@ -767,7 +792,7 @@ ipxsap_string(netdissect_options *ndo, u_short port)
tp->nxt = newhnamemem(ndo);
cp = buf;
NTOHS(port);
port = ntohs(port);
*cp++ = hex[port >> 12 & 0xf];
*cp++ = hex[port >> 8 & 0xf];
*cp++ = hex[port >> 4 & 0xf];
@ -775,7 +800,8 @@ ipxsap_string(netdissect_options *ndo, u_short port)
*cp++ = '\0';
tp->name = strdup(buf);
if (tp->name == NULL)
(*ndo->ndo_error)(ndo, "ipxsap_string: strdup(buf)");
(*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
"%s: strdup(buf)", __func__);
return (tp->name);
}
@ -783,8 +809,8 @@ static void
init_servarray(netdissect_options *ndo)
{
struct servent *sv;
register struct hnamemem *table;
register int i;
struct hnamemem *table;
int i;
char buf[sizeof("0000000000")];
while ((sv = getservent()) != NULL) {
@ -805,7 +831,8 @@ init_servarray(netdissect_options *ndo)
} else
table->name = strdup(sv->s_name);
if (table->name == NULL)
(*ndo->ndo_error)(ndo, "init_servarray: strdup");
(*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
"%s: strdup", __func__);
table->addr = port;
table->nxt = newhnamemem(ndo);
@ -817,34 +844,26 @@ static const struct eproto {
const char *s;
u_short p;
} eproto_db[] = {
{ "pup", ETHERTYPE_PUP },
{ "xns", ETHERTYPE_NS },
{ "aarp", ETHERTYPE_AARP },
{ "arp", ETHERTYPE_ARP },
{ "atalk", ETHERTYPE_ATALK },
{ "decnet", ETHERTYPE_DN },
{ "ip", ETHERTYPE_IP },
{ "ip6", ETHERTYPE_IPV6 },
{ "arp", ETHERTYPE_ARP },
{ "rarp", ETHERTYPE_REVARP },
{ "sprite", ETHERTYPE_SPRITE },
{ "lat", ETHERTYPE_LAT },
{ "loopback", ETHERTYPE_LOOPBACK },
{ "mopdl", ETHERTYPE_MOPDL },
{ "moprc", ETHERTYPE_MOPRC },
{ "decnet", ETHERTYPE_DN },
{ "lat", ETHERTYPE_LAT },
{ "rarp", ETHERTYPE_REVARP },
{ "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(netdissect_options *ndo)
{
register int i;
register struct hnamemem *table;
int i;
struct hnamemem *table;
for (i = 0; eproto_db[i].s; i++) {
int j = htons(eproto_db[i].p) & (HASHNAMESIZE-1);
@ -876,8 +895,8 @@ static const struct protoidlist {
static void
init_protoidarray(netdissect_options *ndo)
{
register int i;
register struct protoidmem *tp;
int i;
struct protoidmem *tp;
const struct protoidlist *pl;
u_char protoid[5];
@ -891,8 +910,8 @@ init_protoidarray(netdissect_options *ndo)
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)");
(*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
"%s: strdup(eproto_db[i].s)", __func__);
}
/* Hardwire some SNAP proto ID names */
for (pl = protoidlist; pl->name != NULL; ++pl) {
@ -906,7 +925,7 @@ init_protoidarray(netdissect_options *ndo)
}
static const struct etherlist {
const u_char addr[6];
const nd_mac_addr addr;
const char *name;
} etherlist[] = {
{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, "Broadcast" },
@ -930,13 +949,13 @@ static const struct etherlist {
static void
init_etherarray(netdissect_options *ndo)
{
register const struct etherlist *el;
register struct enamemem *tp;
const struct etherlist *el;
struct enamemem *tp;
#ifdef USE_ETHER_NTOHOST
char name[256];
#else
register struct pcap_etherent *ep;
register FILE *fp;
struct pcap_etherent *ep;
FILE *fp;
/* Suck in entire ethers file */
fp = fopen(PCAP_ETHERS_FILE, "r");
@ -945,8 +964,8 @@ init_etherarray(netdissect_options *ndo)
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)");
(*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
"%s: strdup(ep->addr)", __func__);
}
(void)fclose(fp);
}
@ -963,11 +982,14 @@ init_etherarray(netdissect_options *ndo)
/*
* Use YP/NIS version of name if available.
*/
if (ether_ntohost(name, (const struct ether_addr *)el->addr) == 0) {
/* Same workaround as in etheraddr_string(). */
struct ether_addr ea;
memcpy (&ea, el->addr, MAC_ADDR_LEN);
if (ether_ntohost(name, &ea) == 0) {
tp->e_name = strdup(name);
if (tp->e_name == NULL)
(*ndo->ndo_error)(ndo,
"init_etherarray: strdup(name)");
(*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
"%s: strdup(name)", __func__);
continue;
}
#endif
@ -975,7 +997,10 @@ init_etherarray(netdissect_options *ndo)
}
}
static const struct tok ipxsap_db[] = {
static const struct ipxsap_ent {
uint16_t v;
const char *s;
} ipxsap_db[] = {
{ 0x0000, "Unknown" },
{ 0x0001, "User" },
{ 0x0002, "User Group" },
@ -1195,11 +1220,11 @@ static const struct tok ipxsap_db[] = {
static void
init_ipxsaparray(netdissect_options *ndo)
{
register int i;
register struct hnamemem *table;
int i;
struct hnamemem *table;
for (i = 0; ipxsap_db[i].s != NULL; i++) {
int j = htons(ipxsap_db[i].v) & (HASHNAMESIZE-1);
u_int j = htons(ipxsap_db[i].v) & (HASHNAMESIZE-1);
table = &ipxsaptable[j];
while (table->name)
table = table->nxt;
@ -1238,7 +1263,7 @@ init_addrtoname(netdissect_options *ndo, uint32_t localnet, uint32_t mask)
const char *
dnaddr_string(netdissect_options *ndo, u_short dnaddr)
{
register struct hnamemem *tp;
struct hnamemem *tp;
for (tp = &dnaddrtable[dnaddr & (HASHNAMESIZE-1)]; tp->nxt != NULL;
tp = tp->nxt)
@ -1256,15 +1281,16 @@ dnaddr_string(netdissect_options *ndo, u_short dnaddr)
struct hnamemem *
newhnamemem(netdissect_options *ndo)
{
register struct hnamemem *p;
struct hnamemem *p;
static struct hnamemem *ptr = NULL;
static u_int num = 0;
if (num <= 0) {
if (num == 0) {
num = 64;
ptr = (struct hnamemem *)calloc(num, sizeof (*ptr));
if (ptr == NULL)
(*ndo->ndo_error)(ndo, "newhnamemem: calloc");
(*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
"%s: calloc", __func__);
}
--num;
p = ptr++;
@ -1275,15 +1301,16 @@ newhnamemem(netdissect_options *ndo)
struct h6namemem *
newh6namemem(netdissect_options *ndo)
{
register struct h6namemem *p;
struct h6namemem *p;
static struct h6namemem *ptr = NULL;
static u_int num = 0;
if (num <= 0) {
if (num == 0) {
num = 64;
ptr = (struct h6namemem *)calloc(num, sizeof (*ptr));
if (ptr == NULL)
(*ndo->ndo_error)(ndo, "newh6namemem: calloc");
(*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
"%s: calloc", __func__);
}
--num;
p = ptr++;

View File

@ -19,8 +19,15 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#include "extract.h"
#ifdef HAVE_CASPER
#include <libcasper.h>
extern cap_channel_t *capdns;
#endif
/*
* Definitions to let us compile most of the IPv6 code even on systems
* Definition to let us compile most of the IPv6 code even on systems
* without IPv6 support.
*/
#ifndef INET6_ADDRSTRLEN
@ -39,18 +46,16 @@ enum {
#define BUFSIZE 128
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(netdissect_options *, const u_char *);
extern const char *etherproto_string(netdissect_options *, u_short);
extern const char *linkaddr_string(netdissect_options *, const uint8_t *, const unsigned int, const unsigned int);
extern const char *etheraddr_string(netdissect_options *, const uint8_t *);
extern const char *le64addr_string(netdissect_options *, const uint8_t *);
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 *isonsap_string(netdissect_options *, const uint8_t *, u_int);
extern const char *dnaddr_string(netdissect_options *, 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 *);
extern const char *getname6(netdissect_options *, const u_char *);
extern const char *ipaddr_string(netdissect_options *, const u_char *);
extern const char *ip6addr_string(netdissect_options *, const u_char *);
extern const char *intoa(uint32_t);
extern void init_addrtoname(netdissect_options *, uint32_t, uint32_t);
@ -58,5 +63,64 @@ 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))
#define ip6addr_string(ndo, p) getname6(ndo, (const u_char *)(p))
/* macro(s) and inline function(s) with setjmp/longjmp logic to call
* the X_string() function(s) after bounds checking.
* The macro(s) must be used on a packet buffer pointer.
*/
static inline const char *
get_linkaddr_string(netdissect_options *ndo, const uint8_t *p,
const unsigned int type, const unsigned int len)
{
if (!ND_TTEST_LEN(p, len))
nd_trunc_longjmp(ndo);
return linkaddr_string(ndo, p, type, len);
}
static inline const char *
get_etheraddr_string(netdissect_options *ndo, const uint8_t *p)
{
if (!ND_TTEST_LEN(p, MAC_ADDR_LEN))
nd_trunc_longjmp(ndo);
return etheraddr_string(ndo, p);
}
static inline const char *
get_le64addr_string(netdissect_options *ndo, const u_char *p)
{
if (!ND_TTEST_8(p))
nd_trunc_longjmp(ndo);
return le64addr_string(ndo, p);
}
static inline const char *
get_isonsap_string(netdissect_options *ndo, const uint8_t *nsap,
u_int nsap_length)
{
if (!ND_TTEST_LEN(nsap, nsap_length))
nd_trunc_longjmp(ndo);
return isonsap_string(ndo, nsap, nsap_length);
}
static inline const char *
get_ipaddr_string(netdissect_options *ndo, const u_char *p)
{
if (!ND_TTEST_4(p))
nd_trunc_longjmp(ndo);
return ipaddr_string(ndo, p);
}
static inline const char *
get_ip6addr_string(netdissect_options *ndo, const u_char *p)
{
if (!ND_TTEST_16(p))
nd_trunc_longjmp(ndo);
return ip6addr_string(ndo, p);
}
#define GET_LINKADDR_STRING(p, type, len) get_linkaddr_string(ndo, (const u_char *)(p), type, len)
#define GET_ETHERADDR_STRING(p) get_etheraddr_string(ndo, (const u_char *)(p))
#define GET_LE64ADDR_STRING(p) get_le64addr_string(ndo, (const u_char *)(p))
#define GET_ISONSAP_STRING(nsap, nsap_length) get_isonsap_string(ndo, (const u_char *)(nsap), nsap_length)
#define GET_IPADDR_STRING(p) get_ipaddr_string(ndo, (const u_char *)(p))
#define GET_IP6ADDR_STRING(p) get_ip6addr_string(ndo, (const u_char *)(p))

View File

@ -37,10 +37,10 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#include <config.h>
#endif
#include <netdissect-stdinc.h>
#include "netdissect-stdinc.h"
#include "addrtostr.h"
#include <stdio.h>
@ -71,7 +71,7 @@ addrtostr (const void *src, char *dst, size_t size)
return NULL;
}
for (i = 0; i < 4; ++i) {
int n = *srcaddr++;
int n = *srcaddr++;
int non_zerop = 0;
if (non_zerop || n / 100 > 0) {
@ -127,7 +127,7 @@ addrtostr6 (const void *src, char *dst, size_t size)
best.base = -1;
cur.len = 0;
cur.base = -1;
for (i = 0; i < (int)(IN6ADDRSZ / INT16SZ); i++)
for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++)
{
if (words[i] == 0)
{
@ -160,14 +160,14 @@ addrtostr6 (const void *src, char *dst, size_t size)
*dp++ = c; \
space_left--; \
}
for (i = 0; i < (int)(IN6ADDRSZ / INT16SZ); i++)
for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++)
{
/* Are we inside the best run of 0x00's?
*/
if (best.base != -1 && i >= best.base && i < (best.base + best.len))
{
if (i == best.base)
APPEND_CHAR(':');
APPEND_CHAR(':');
continue;
}

View File

@ -16,10 +16,10 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#include <config.h>
#endif
#include <netdissect-stdinc.h>
#include "netdissect-stdinc.h"
#include "netdissect.h"
#include "af.h"

View File

@ -52,4 +52,4 @@ extern const struct tok bsd_af_values[];
#define BSD_AFNUM_IPX 23
#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 */
#define BSD_AFNUM_INET6_DARWIN 30 /* macOS, iOS, other Darwin-based OSes */

View File

@ -31,27 +31,37 @@
*/
/*
* RFC1826/2402 authentication header.
* RFC4302 authentication header.
*/
#ifndef _NETINET6_AH_H_
#define _NETINET6_AH_H_
#ifndef ND_AH_H_
#define ND_AH_H_
/*
* 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
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Next Header | Payload Len | RESERVED |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Security Parameters Index (SPI) |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Sequence Number Field |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | |
* + Integrity Check Value-ICV (variable) |
* | |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*
* Figure 1. AH Format
*/
struct ah {
uint8_t ah_nxt; /* Next Header */
uint8_t ah_len; /* Length of data, in 32bit */
uint16_t ah_reserve; /* Reserved for future use */
uint32_t ah_spi; /* Security parameter index */
/* variable size, 32bit bound*/ /* Authentication data */
nd_uint8_t ah_nxt; /* Next Header */
nd_uint8_t ah_len; /* Payload Len in 32bit words minus 2 */
nd_uint16_t ah_reserved; /* Reserved for future use */
nd_uint32_t ah_spi; /* Security Parameters Index */
nd_uint32_t ah_seq; /* Sequence Number Field */
/* variable size, 32bit bound*/ /* Integrity Check Value-ICV */
};
struct newah {
uint8_t ah_nxt; /* Next Header */
uint8_t ah_len; /* Length of data + 1, in 32bit */
uint16_t ah_reserve; /* Reserved for future use */
uint32_t ah_spi; /* Security parameter index */
uint32_t ah_seq; /* Sequence number field */
/* variable size, 32bit bound*/ /* Authentication data */
};
#endif /*_NETINET6_AH_H_*/
#endif /* ND_AH_H_ */

View File

@ -22,9 +22,9 @@
*/
struct LAP {
uint8_t dst;
uint8_t src;
uint8_t type;
nd_uint8_t dst;
nd_uint8_t src;
nd_uint8_t type;
};
#define lapShortDDP 1 /* short DDP type */
#define lapDDP 2 /* DDP type */
@ -33,22 +33,22 @@ struct LAP {
/* Datagram Delivery Protocol */
struct atDDP {
uint16_t length;
uint16_t checksum;
uint16_t dstNet;
uint16_t srcNet;
uint8_t dstNode;
uint8_t srcNode;
uint8_t dstSkt;
uint8_t srcSkt;
uint8_t type;
nd_uint16_t length;
nd_uint16_t checksum;
nd_uint16_t dstNet;
nd_uint16_t srcNet;
nd_uint8_t dstNode;
nd_uint8_t srcNode;
nd_uint8_t dstSkt;
nd_uint8_t srcSkt;
nd_uint8_t type;
};
struct atShortDDP {
uint16_t length;
uint8_t dstSkt;
uint8_t srcSkt;
uint8_t type;
nd_uint16_t length;
nd_uint8_t dstSkt;
nd_uint8_t srcSkt;
nd_uint8_t type;
};
#define ddpMaxWKS 0x7F
@ -72,10 +72,10 @@ struct atShortDDP {
/* AppleTalk Transaction Protocol */
struct atATP {
uint8_t control;
uint8_t bitmap;
uint16_t transID;
int32_t userData;
nd_uint8_t control;
nd_uint8_t bitmap;
nd_uint16_t transID;
nd_uint32_t userData;
};
#define atpReqCode 0x40
@ -93,8 +93,8 @@ struct atATP {
/* AppleTalk Echo Protocol */
struct atEcho {
uint8_t echoFunction;
uint8_t *echoData;
nd_uint8_t echoFunction;
nd_uint8_t echoData[1]; /* Should be [], C99-style */
};
#define echoSkt 4 /* the echoer socket */
@ -106,15 +106,15 @@ struct atEcho {
/* Name Binding Protocol */
struct atNBP {
uint8_t control;
uint8_t id;
nd_uint8_t control;
nd_uint8_t id;
};
struct atNBPtuple {
uint16_t net;
uint8_t node;
uint8_t skt;
uint8_t enumerator;
nd_uint16_t net;
nd_uint8_t node;
nd_uint8_t skt;
nd_uint8_t enumerator;
};
#define nbpBrRq 0x10
@ -140,8 +140,8 @@ struct atNBPtuple {
/* Zone Information Protocol */
struct zipHeader {
uint8_t command;
uint8_t netcount;
nd_uint8_t command;
nd_uint8_t netcount;
};
#define zipHeaderSize 2

View File

@ -58,7 +58,7 @@ static const unsigned char charmap[] = {
int
ascii_strcasecmp(const char *s1, const char *s2)
{
register const unsigned char *cm = charmap,
const unsigned char *cm = charmap,
*us1 = (const unsigned char *)s1,
*us2 = (const unsigned char *)s2;
@ -69,9 +69,9 @@ ascii_strcasecmp(const char *s1, const char *s2)
}
int
ascii_strncasecmp(const char *s1, const char *s2, register size_t n)
ascii_strncasecmp(const char *s1, const char *s2, size_t n)
{
register const unsigned char *cm = charmap,
const unsigned char *cm = charmap,
*us1 = (const unsigned char *)s1,
*us2 = (const unsigned char *)s2;

View File

@ -1,4 +1,4 @@
$6 ~ /^ack/ && $5 !~ /[SFR]/ {
$6 ~ /^ack/ && $5 !~ /[SFR]/ {
# given a tcpdump ftp trace, output one line for each ack
# in the form
# <ack time> <seq no>

View File

@ -20,14 +20,15 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#include <config.h>
#endif
#include <netdissect-stdinc.h>
#include "netdissect-stdinc.h"
#include <stdio.h>
#include "netdissect.h"
#include "interface.h"
void
bpf_dump(const struct bpf_program *p, int option)

View File

@ -19,7 +19,7 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#define CHDLC_HDRLEN 4
#define CHDLC_HDRLEN 4
#define CHDLC_UNICAST 0x0f
#define CHDLC_BCAST 0x8f
#define CHDLC_TYPE_SLARP 0x8035

View File

@ -18,10 +18,10 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#include <config.h>
#endif
#include <netdissect-stdinc.h>
#include "netdissect-stdinc.h"
#include <stdio.h>
#include <stdlib.h>
@ -90,8 +90,8 @@ static void
init_crc10_table(void)
{
#define CRC10_POLYNOMIAL 0x633
register int i, j;
register uint16_t accum;
int i, j;
uint16_t accum;
uint16_t verify_crc10_table[256];
for ( i = 0; i < 256; i++ )
@ -112,7 +112,7 @@ init_crc10_table(void)
uint16_t
verify_crc10_cksum(uint16_t accum, const u_char *p, int length)
{
register int i;
int i;
for ( i = 0; i < length; i++ )
{

View File

@ -0,0 +1,24 @@
#
# Try to find libcrypto.
#
# Try to find the header
find_path(CRYPTO_INCLUDE_DIR openssl/crypto.h)
# Try to find the library
find_library(CRYPTO_LIBRARY crypto)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(CRYPTO
DEFAULT_MSG
CRYPTO_INCLUDE_DIR
CRYPTO_LIBRARY
)
mark_as_advanced(
CRYPTO_INCLUDE_DIR
CRYPTO_LIBRARY
)
set(CRYPTO_INCLUDE_DIRS ${CRYPTO_INCLUDE_DIR})
set(CRYPTO_LIBRARIES ${CRYPTO_LIBRARY})

View File

@ -0,0 +1,462 @@
#
# Try to find libpcap.
#
# To tell this module where to look, a user may set the environment variable
# PCAP_ROOT to point cmake to the *root* of a directory with include and
# lib subdirectories for pcap.dll (e.g WpdPack or npcap-sdk).
# Alternatively, PCAP_ROOT may also be set from cmake command line or GUI
# (e.g cmake -DPCAP_ROOT=C:\path\to\pcap [...])
#
if(WIN32)
#
# Building for Windows.
#
# libpcap isn't set up to install .pc files or pcap-config on Windows,
# and it's not clear that either of them would work without a lot
# of additional effort. WinPcap doesn't supply them, and neither
# does Npcap.
#
# So just search for them directly. Look for both pcap and wpcap.
# Don't bother looking for static libraries; unlike most UN*Xes
# (with the exception of AIX), where different extensions are used
# for shared and static, Windows uses .lib both for import libraries
# for DLLs and for static libraries.
#
# We don't directly set PCAP_INCLUDE_DIRS or PCAP_LIBRARIES, as
# they're not supposed to be cache entries, and find_path() and
# find_library() set cache entries.
#
find_path(PCAP_INCLUDE_DIR pcap.h)
# The 64-bit Packet.lib is located under /x64
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
#
# For the WinPcap and Npcap SDKs, the Lib subdirectory of the top-level
# directory contains 32-bit libraries; the 64-bit libraries are in the
# Lib/x64 directory.
#
# The only way to *FORCE* CMake to look in the Lib/x64 directory
# without searching in the Lib directory first appears to be to set
# CMAKE_LIBRARY_ARCHITECTURE to "x64".
#
set(CMAKE_LIBRARY_ARCHITECTURE "x64")
endif()
find_library(PCAP_LIBRARY NAMES pcap wpcap)
#
# Do the standard arg processing, including failing if it's a
# required package.
#
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(PCAP
DEFAULT_MSG
PCAP_INCLUDE_DIR
PCAP_LIBRARY
)
mark_as_advanced(
PCAP_INCLUDE_DIR
PCAP_LIBRARY
)
if(PCAP_FOUND)
set(PCAP_LIBRARIES ${PCAP_LIBRARY})
set(PCAP_INCLUDE_DIRS ${PCAP_INCLUDE_DIR})
endif()
else(WIN32)
#
# Building for UN*X.
#
# See whether we were handed a QUIET argument, so we can pass it on
# to pkg_search_module. Do *NOT* pass on the REQUIRED argument,
# because, if pkg-config isn't found, or it is but it has no .pc
# files for libpcap, that is *not* necessarily an indication that
# libpcap isn't available - not all systems ship pkg-config, and
# libpcap didn't have .pc files until libpcap 1.9.0.
#
if(PCAP_FIND_QUIETLY)
set(_quiet "QUIET")
endif()
#
# First, try pkg-config.
# Before doing so, set the PKG_CONFIG_PATH environment variable
# to include all the directories in CMAKE_PREFIX_PATH.
#
# *If* we were to require CMake 3.1 or later on UN*X,
# pkg_search_module() would do this for us, but, for now,
# we're not doing that, in case somebody's building with
# CMake on some "long-term support" version, predating
# CMake 3.1, of an OS that supplies an earlier
# version as a package.
#
# If we ever set a minimum of 3.1 or later on UN*X, we should
# remove the environment variable changes.
#
# This is based on code in the CMake 3.12.4 FindPkgConfig.cmake,
# which is "Distributed under the OSI-approved BSD 3-Clause License."
#
find_package(PkgConfig)
#
# Get the current PKG_CONFIG_PATH setting.
#
set(_pkg_config_path "$ENV{PKG_CONFIG_PATH}")
#
# Save it, so we can restore it after we run pkg-config.
#
set(_saved_pkg_config_path "${_pkg_config_path}")
if(NOT "${CMAKE_PREFIX_PATH}" STREQUAL "")
#
# Convert it to a CMake-style path, before we add additional
# values to it.
#
if(NOT "${_pkg_config_path}" STREQUAL "")
file(TO_CMAKE_PATH "${_pkg_config_path}" _pkg_config_path)
endif()
#
# Turn CMAKE_PREFIX_PATH into a list of extra paths to add
# to _pkg_config_path.
#
set(_extra_paths "")
list(APPEND _extra_paths ${CMAKE_PREFIX_PATH})
# Create a list of the possible pkgconfig subfolder (depending on
# the system
set(_lib_dirs)
if(NOT DEFINED CMAKE_SYSTEM_NAME
OR (CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU)$"
AND NOT CMAKE_CROSSCOMPILING))
if(EXISTS "/etc/debian_version") # is this a debian system ?
if(CMAKE_LIBRARY_ARCHITECTURE)
list(APPEND _lib_dirs "lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig")
endif()
else()
# not debian, check the FIND_LIBRARY_USE_LIB32_PATHS and FIND_LIBRARY_USE_LIB64_PATHS properties
get_property(uselib32 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS)
if(uselib32 AND CMAKE_SIZEOF_VOID_P EQUAL 4)
list(APPEND _lib_dirs "lib32/pkgconfig")
endif()
get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
if(uselib64 AND CMAKE_SIZEOF_VOID_P EQUAL 8)
list(APPEND _lib_dirs "lib64/pkgconfig")
endif()
get_property(uselibx32 GLOBAL PROPERTY FIND_LIBRARY_USE_LIBX32_PATHS)
if(uselibx32 AND CMAKE_INTERNAL_PLATFORM_ABI STREQUAL "ELF X32")
list(APPEND _lib_dirs "libx32/pkgconfig")
endif()
endif()
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" AND NOT CMAKE_CROSSCOMPILING)
list(APPEND _lib_dirs "libdata/pkgconfig")
endif()
list(APPEND _lib_dirs "lib/pkgconfig")
list(APPEND _lib_dirs "share/pkgconfig")
# Check if directories exist and eventually append them to the
# pkgconfig path list
foreach(_prefix_dir ${_extra_paths})
foreach(_lib_dir ${_lib_dirs})
if(EXISTS "${_prefix_dir}/${_lib_dir}")
list(APPEND _pkg_config_path "${_prefix_dir}/${_lib_dir}")
list(REMOVE_DUPLICATES _pkg_config_path)
endif()
endforeach()
endforeach()
if(NOT "${_pkg_config_path}" STREQUAL "")
# remove empty values from the list
list(REMOVE_ITEM _pkg_config_path "")
file(TO_NATIVE_PATH "${_pkg_config_path}" _pkg_config_path)
if(UNIX)
string(REPLACE ";" ":" _pkg_config_path "${_pkg_config_path}")
string(REPLACE "\\ " " " _pkg_config_path "${_pkg_config_path}")
endif()
set(ENV{PKG_CONFIG_PATH} "${_pkg_config_path}")
endif()
endif()
pkg_search_module(CONFIG_PCAP ${_quiet} libpcap)
set(ENV{PKG_CONFIG_PATH} "${_saved_pkg_config_path}")
if(NOT CONFIG_PCAP_FOUND)
#
# That didn't work. Try pcap-config.
#
find_program(PCAP_CONFIG pcap-config)
if(PCAP_CONFIG)
#
# We have pcap-config; use it.
#
if(NOT "${_quiet}" STREQUAL "QUIET")
message(STATUS "Found pcap-config")
endif()
#
# If this is a vendor-supplied pcap-config, which we define as
# being "a pcap-config in /usr/bin or /usr/ccs/bin" (the latter
# is for Solaris and Sun/Oracle Studio), there are some issues.
# Work around them.
#
if("${PCAP_CONFIG}" STREQUAL /usr/bin/pcap-config OR
"${PCAP_CONFIG}" STREQUAL /usr/ccs/bin/pcap-config)
#
# It's vendor-supplied.
#
if(APPLE)
#
# This is macOS or another Darwin-based OS.
#
# That means that /usr/bin/pcap-config it may provide
# -I/usr/local/include with --cflags and -L/usr/local/lib
# with --libs; if there's no pcap installed under /usr/local,
# that will cause the build to fail, and if there is a pcap
# installed there, you'll get that pcap even if you don't
# want it. Remember that, so we ignore those values.
#
set(_broken_apple_pcap_config TRUE)
elseif(CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND CMAKE_SYSTEM_VERSION MATCHES "5[.][0-9.]*")
#
# This is Solaris 2 or later, i.e. SunOS 5.x.
#
# At least on Solaris 11; there's /usr/bin/pcap-config, which
# reports -L/usr/lib with --libs, causing the 32-bit libraries
# to be found, and there's /usr/bin/{64bitarch}/pcap-config,
# where {64bitarch} is a name for the 64-bit version of the
# instruction set, which reports -L /usr/lib/{64bitarch},
# causing the 64-bit libraries to be found.
#
# So if we're building 64-bit targets, we replace PCAP_CONFIG
# with /usr/bin/{64bitarch}; we get {64bitarch} as the
# output of "isainfo -n".
#
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
execute_process(COMMAND "isainfo" "-n"
RESULT_VARIABLE ISAINFO_RESULT
OUTPUT_VARIABLE ISAINFO_OUTPUT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(ISAINFO_RESULT EQUAL 0)
#
# Success - change PCAP_CONFIG.
#
string(REPLACE "/bin/" "/bin/${ISAINFO_OUTPUT}/" PCAP_CONFIG "${PCAP_CONFIG}")
endif()
endif()
endif()
endif()
#
# Now get the include directories.
#
execute_process(COMMAND "${PCAP_CONFIG}" "--cflags"
RESULT_VARIABLE PCAP_CONFIG_RESULT
OUTPUT_VARIABLE PCAP_CONFIG_OUTPUT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT PCAP_CONFIG_RESULT EQUAL 0)
message(FATAL_ERROR "pcap-config --cflags failed")
endif()
separate_arguments(CFLAGS_LIST UNIX_COMMAND ${PCAP_CONFIG_OUTPUT})
set(CONFIG_PCAP_INCLUDE_DIRS "")
foreach(_arg IN LISTS CFLAGS_LIST)
if(_arg MATCHES "^-I")
#
# Extract the directory by removing the -I.
#
string(REGEX REPLACE "-I" "" _dir ${_arg})
#
# Work around macOS (and probably other Darwin) brokenness,
# by not adding /usr/local/include if it's from the broken
# Apple pcap-config.
#
if(NOT _broken_apple_pcap_config OR
NOT "${_dir}" STREQUAL /usr/local/include)
# Add it to CONFIG_PCAP_INCLUDE_DIRS
list(APPEND CONFIG_PCAP_INCLUDE_DIRS ${_dir})
endif()
endif()
endforeach()
#
# Now, get the library directories and libraries for dynamic linking.
#
execute_process(COMMAND "${PCAP_CONFIG}" "--libs"
RESULT_VARIABLE PCAP_CONFIG_RESULT
OUTPUT_VARIABLE PCAP_CONFIG_OUTPUT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT PCAP_CONFIG_RESULT EQUAL 0)
message(FATAL_ERROR "pcap-config --libs failed")
endif()
separate_arguments(LIBS_LIST UNIX_COMMAND ${PCAP_CONFIG_OUTPUT})
set(CONFIG_PCAP_LIBRARY_DIRS "")
set(CONFIG_PCAP_LIBRARIES "")
foreach(_arg IN LISTS LIBS_LIST)
if(_arg MATCHES "^-L")
#
# Extract the directory by removing the -L.
#
string(REGEX REPLACE "-L" "" _dir ${_arg})
#
# Work around macOS (and probably other Darwin) brokenness,
# by not adding /usr/local/lib if it's from the broken
# Apple pcap-config.
#
if(NOT _broken_apple_pcap_config OR
NOT "${_dir}" STREQUAL /usr/local/lib)
# Add this directory to CONFIG_PCAP_LIBRARY_DIRS
list(APPEND CONFIG_PCAP_LIBRARY_DIRS ${_dir})
endif()
elseif(_arg MATCHES "^-l")
string(REGEX REPLACE "-l" "" _lib ${_arg})
list(APPEND CONFIG_PCAP_LIBRARIES ${_lib})
endif()
endforeach()
#
# Now, get the library directories and libraries for static linking.
#
execute_process(COMMAND "${PCAP_CONFIG}" "--libs" "--static"
RESULT_VARIABLE PCAP_CONFIG_RESULT
OUTPUT_VARIABLE PCAP_CONFIG_OUTPUT
)
if(NOT PCAP_CONFIG_RESULT EQUAL 0)
message(FATAL_ERROR "pcap-config --libs --static failed")
endif()
separate_arguments(LIBS_LIST UNIX_COMMAND ${PCAP_CONFIG_OUTPUT})
set(CONFIG_PCAP_STATIC_LIBRARY_DIRS "")
set(CONFIG_PCAP_STATIC_LIBRARIES "")
foreach(_arg IN LISTS LIBS_LIST)
if(_arg MATCHES "^-L")
#
# Extract the directory by removing the -L.
#
string(REGEX REPLACE "-L" "" _dir ${_arg})
#
# Work around macOS (and probably other Darwin) brokenness,
# by not adding /usr/local/lib if it's from the broken
# Apple pcap-config.
#
if(NOT _broken_apple_pcap_config OR
NOT "${_dir}" STREQUAL /usr/local/lib)
# Add this directory to CONFIG_PCAP_STATIC_LIBRARY_DIRS
list(APPEND CONFIG_PCAP_STATIC_LIBRARY_DIRS ${_dir})
endif()
elseif(_arg MATCHES "^-l")
string(REGEX REPLACE "-l" "" _lib ${_arg})
#
# Try to find that library, so we get its full path, as
# we do with dynamic libraries.
#
list(APPEND CONFIG_PCAP_STATIC_LIBRARIES ${_lib})
endif()
endforeach()
#
# We've set CONFIG_PCAP_INCLUDE_DIRS, CONFIG_PCAP_LIBRARIES, and
# CONFIG_PCAP_STATIC_LIBRARIES above; set CONFIG_PCAP_FOUND.
#
set(CONFIG_PCAP_FOUND YES)
endif()
endif()
#
# If CONFIG_PCAP_FOUND is set, we have information from pkg-config and
# pcap-config; we need to convert library names to library full paths.
#
# If it's not set, we have to look for the libpcap headers and library
# ourselves.
#
if(CONFIG_PCAP_FOUND)
#
# Use CONFIG_PCAP_INCLUDE_DIRS as the value for PCAP_INCLUDE_DIRS.
#
set(PCAP_INCLUDE_DIRS "${CONFIG_PCAP_INCLUDE_DIRS}")
#
# CMake *really* doesn't like the notion of specifying
# "here are the directories in which to look for libraries"
# except in find_library() calls; it *really* prefers using
# full paths to library files, rather than library names.
#
foreach(_lib IN LISTS CONFIG_PCAP_LIBRARIES)
find_library(_libfullpath ${_lib} HINTS ${CONFIG_PCAP_LIBRARY_DIRS})
list(APPEND PCAP_LIBRARIES ${_libfullpath})
#
# Remove that from the cache; we're using it as a local variable,
# but find_library insists on making it a cache variable.
#
unset(_libfullpath CACHE)
endforeach()
#
# Now do the same for the static libraries.
#
set(SAVED_CMAKE_FIND_LIBRARY_SUFFIXES "${CMAKE_FIND_LIBRARY_SUFFIXES}")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
foreach(_lib IN LISTS CONFIG_PCAP_STATIC_LIBRARIES)
find_library(_libfullpath ${_lib} HINTS ${CONFIG_PCAP_LIBRARY_DIRS})
list(APPEND PCAP_STATIC_LIBRARIES ${_libfullpath})
#
# Remove that from the cache; we're using it as a local variable,
# but find_library insists on making it a cache variable.
#
unset(_libfullpath CACHE)
endforeach()
set(CMAKE_FIND_LIBRARY_SUFFIXES "${SAVED_CMAKE_FIND_LIBRARY_SUFFIXES}")
#
# We found libpcap using pkg-config or pcap-config.
#
set(PCAP_FOUND YES)
else(CONFIG_PCAP_FOUND)
#
# We didn't have pkg-config, or we did but it didn't have .pc files
# for libpcap, and we don't have pkg-config, so we have to look for
# the headers and libraries ourself.
#
# We don't directly set PCAP_INCLUDE_DIRS or PCAP_LIBRARIES, as
# they're not supposed to be cache entries, and find_path() and
# find_library() set cache entries.
#
# Try to find the header file.
#
find_path(PCAP_INCLUDE_DIR pcap.h)
#
# Try to find the library
#
find_library(PCAP_LIBRARY pcap)
# Try to find the static library (XXX - what about AIX?)
set(SAVED_CMAKE_FIND_LIBRARY_SUFFIXES "${CMAKE_FIND_LIBRARY_SUFFIXES}")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
find_library(PCAP_STATIC_LIBRARY pcap)
set(CMAKE_FIND_LIBRARY_SUFFIXES "${SAVED_CMAKE_FIND_LIBRARY_SUFFIXES}")
#
# This will fail if REQUIRED is set and PCAP_INCLUDE_DIR or
# PCAP_LIBRARY aren't set.
#
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(PCAP
DEFAULT_MSG
PCAP_INCLUDE_DIR
PCAP_LIBRARY
)
mark_as_advanced(
PCAP_INCLUDE_DIR
PCAP_LIBRARY
PCAP_STATIC_LIBRARY
)
if(PCAP_FOUND)
set(PCAP_INCLUDE_DIRS ${PCAP_INCLUDE_DIR})
set(PCAP_LIBRARIES ${PCAP_LIBRARY})
set(PCAP_STATIC_LIBRARIES ${PCAP_STATIC_LIBRARY})
endif(PCAP_FOUND)
endif(CONFIG_PCAP_FOUND)
endif(WIN32)

View File

@ -0,0 +1,24 @@
#
# Try to find libsmi.
#
# Try to find the header
find_path(SMI_INCLUDE_DIR smi.h)
# Try to find the library
find_library(SMI_LIBRARY smi)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SMI
DEFAULT_MSG
SMI_INCLUDE_DIR
SMI_LIBRARY
)
mark_as_advanced(
SMI_INCLUDE_DIR
SMI_LIBRARY
)
set(SMI_INCLUDE_DIRS ${SMI_INCLUDE_DIR})
set(SMI_LIBRARIES ${SMI_LIBRARY})

View File

@ -0,0 +1,21 @@
if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}")
foreach(file ${files})
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
exec_program(
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
)
if(NOT "${rm_retval}" STREQUAL 0)
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
endif(NOT "${rm_retval}" STREQUAL 0)
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
endforeach(file)

View File

@ -0,0 +1,290 @@
/* cmakeconfig.h.in */
/* Define to 1 if arpa/inet.h declares `ether_ntohost' */
#cmakedefine ARPA_INET_H_DECLARES_ETHER_NTOHOST 1
/* define if you want to build the possibly-buggy SMB printer */
#cmakedefine ENABLE_SMB 1
/* Define to 1 if you have the `bpf_dump' function. */
#cmakedefine HAVE_BPF_DUMP 1
/* capsicum support available */
#cmakedefine HAVE_CAPSICUM 1
/* Define to 1 if you have the `cap_enter' function. */
#cmakedefine HAVE_CAP_ENTER 1
/* Define to 1 if you have the `cap_ioctls_limit' function. */
#cmakedefine HAVE_CAP_IOCTLS_LIMIT 1
/* Define to 1 if you have the <cap-ng.h> header file. */
#cmakedefine HAVE_CAP_NG_H 1
/* Define to 1 if you have the `cap_rights_limit' function. */
#cmakedefine HAVE_CAP_RIGHTS_LIMIT 1
/* Casper support available */
#cmakedefine HAVE_CASPER 1
/* Define to 1 if you have the declaration of `ether_ntohost' */
#cmakedefine HAVE_DECL_ETHER_NTOHOST 1
/* Define to 1 if you have the `ether_ntohost' function. */
#cmakedefine HAVE_ETHER_NTOHOST 1
/* Define to 1 if you have the `EVP_CIPHER_CTX_new' function. */
#cmakedefine HAVE_EVP_CIPHER_CTX_NEW 1
/* Define to 1 if you have the `EVP_DecryptInit_ex' function. */
#cmakedefine HAVE_EVP_DECRYPTINIT_EX 1
/* Define to 1 if you have the <fcntl.h> header file. */
#cmakedefine HAVE_FCNTL_H 1
/* Define to 1 if you have the `fork' function. */
#cmakedefine HAVE_FORK 1
/* Define to 1 if you have the `getopt_long' function. */
#cmakedefine HAVE_GETOPT_LONG 1
/* define if you have getrpcbynumber() */
#cmakedefine HAVE_GETRPCBYNUMBER 1
/* Define to 1 if you have the `getservent' function. */
#cmakedefine HAVE_GETSERVENT 1
/* Define to 1 if you have the <inttypes.h> header file. */
#cmakedefine HAVE_INTTYPES_H 1
/* Define to 1 if you have the `cap-ng' library (-lcap-ng). */
#cmakedefine HAVE_LIBCAP_NG 1
/* Define to 1 if you have the `crypto' library (-lcrypto). */
#cmakedefine HAVE_LIBCRYPTO 1
/* Define to 1 if you have the `rpc' library (-lrpc). */
#cmakedefine HAVE_LIBRPC 1
/* Define to 1 if you have the <memory.h> header file. */
#cmakedefine HAVE_MEMORY_H 1
/* Define to 1 if you have the <net/if.h> header file. */
#cmakedefine HAVE_NET_IF_H 1
/* Define to 1 if you have the `openat' function. */
#cmakedefine HAVE_OPENAT 1
/* Define to 1 if you have the <openssl/evp.h> header file. */
#cmakedefine HAVE_OPENSSL_EVP_H 1
/* define if the OS provides AF_INET6 and struct in6_addr */
#cmakedefine HAVE_OS_IPV6_SUPPORT 1
/* if there's an os_proto.h for this platform, to use additional prototypes */
#cmakedefine HAVE_OS_PROTO_H 1
/* Define to 1 if you have the `pcap_breakloop' function. */
#cmakedefine HAVE_PCAP_BREAKLOOP 1
/* Define to 1 if you have the `pcap_create' function. */
#cmakedefine HAVE_PCAP_CREATE 1
/* define if libpcap has pcap_datalink_name_to_val() */
#cmakedefine HAVE_PCAP_DATALINK_NAME_TO_VAL 1
/* define if libpcap has pcap_datalink_val_to_description() */
#cmakedefine HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION 1
/* define if libpcap has pcap_debug */
#cmakedefine HAVE_PCAP_DEBUG 1
/* Define to 1 if you have the `pcap_dump_flush' function. */
#cmakedefine HAVE_PCAP_DUMP_FLUSH 1
/* Define to 1 if you have the `pcap_dump_ftell' function. */
#cmakedefine HAVE_PCAP_DUMP_FTELL 1
/* Define to 1 if you have the `pcap_dump_ftell64' function. */
#cmakedefine HAVE_PCAP_DUMP_FTELL64 1
/* Define to 1 if you have the `pcap_findalldevs' function. */
#cmakedefine HAVE_PCAP_FINDALLDEVS 1
/* Define to 1 if you have the `pcap_findalldevs_ex' function. */
#cmakedefine HAVE_PCAP_FINDALLDEVS_EX 1
/* Define to 1 if you have the `pcap_free_datalinks' function. */
#cmakedefine HAVE_PCAP_FREE_DATALINKS 1
/* Define to 1 if the system has the type `pcap_if_t'. */
#cmakedefine HAVE_PCAP_IF_T 1
/* Define to 1 if you have the `pcap_lib_version' function. */
#cmakedefine HAVE_PCAP_LIB_VERSION 1
/* define if libpcap has pcap_list_datalinks() */
#cmakedefine HAVE_PCAP_LIST_DATALINKS 1
/* Define to 1 if you have the `pcap_open' function. */
#cmakedefine HAVE_PCAP_OPEN 1
/* Define to 1 if you have the <pcap/pcap-inttypes.h> header file. */
#cmakedefine HAVE_PCAP_PCAP_INTTYPES_H 1
/* Define to 1 if you have the `pcap_setdirection' function. */
#cmakedefine HAVE_PCAP_SETDIRECTION 1
/* Define to 1 if you have the `pcap_set_datalink' function. */
#cmakedefine HAVE_PCAP_SET_DATALINK 1
/* Define to 1 if you have the `pcap_set_immediate_mode' function. */
#cmakedefine HAVE_PCAP_SET_IMMEDIATE_MODE 1
/* Define to 1 if you have the `pcap_set_optimizer_debug' function. */
#cmakedefine HAVE_PCAP_SET_OPTIMIZER_DEBUG 1
/* Define to 1 if you have the `pcap_set_parser_debug' function. */
#cmakedefine HAVE_PCAP_SET_PARSER_DEBUG 1
/* Define to 1 if you have the `pcap_set_tstamp_precision' function. */
#cmakedefine HAVE_PCAP_SET_TSTAMP_PRECISION 1
/* Define to 1 if you have the `pcap_set_tstamp_type' function. */
#cmakedefine HAVE_PCAP_SET_TSTAMP_TYPE 1
/* define if libpcap has pcap_version */
#cmakedefine HAVE_PCAP_VERSION 1
/* Define to 1 if you have the `pcap_wsockinit' function. */
#cmakedefine HAVE_PCAP_WSOCKINIT 1
/* Define to 1 if you have the `pfopen' function. */
#cmakedefine HAVE_PFOPEN 1
/* Define to 1 if you have the <rpc/rpcent.h> header file. */
#cmakedefine HAVE_RPC_RPCENT_H 1
/* Define to 1 if you have the <rpc/rpc.h> header file. */
#cmakedefine HAVE_RPC_RPC_H 1
/* Define to 1 if you have the `setlinebuf' function. */
#cmakedefine HAVE_SETLINEBUF 1
/* Define to 1 if you have the <stdint.h> header file. */
#cmakedefine HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#cmakedefine HAVE_STDLIB_H 1
/* Define to 1 if you have the `strdup' function. */
#cmakedefine HAVE_STRDUP 1
/* Define to 1 if you have the <strings.h> header file. */
#cmakedefine HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#cmakedefine HAVE_STRING_H 1
/* Define to 1 if you have the `strlcat' function. */
#cmakedefine HAVE_STRLCAT 1
/* Define to 1 if you have the `strlcpy' function. */
#cmakedefine HAVE_STRLCPY 1
/* Define to 1 if you have the `strsep' function. */
#cmakedefine HAVE_STRSEP 1
/* Define to 1 if the system has the type `struct ether_addr'. */
#cmakedefine HAVE_STRUCT_ETHER_ADDR 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#cmakedefine HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#cmakedefine HAVE_SYS_TYPES_H 1
/* Define to 1 if the system has the type `uintptr_t'. */
#cmakedefine HAVE_UINTPTR_T 1
/* Define to 1 if you have the <unistd.h> header file. */
#cmakedefine HAVE_UNISTD_H 1
/* Define to 1 if you have the `vfork' function. */
#cmakedefine HAVE_VFORK 1
/* Define to 1 if you have the `wsockinit' function. */
#cmakedefine HAVE_WSOCKINIT 1
/* define if libpcap has yydebug */
#cmakedefine HAVE_YYDEBUG 1
/* Define to 1 if netinet/ether.h declares `ether_ntohost' */
#cmakedefine NETINET_ETHER_H_DECLARES_ETHER_NTOHOST 1
/* Define to 1 if netinet/if_ether.h declares `ether_ntohost' */
#cmakedefine NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST 1
/* Define to 1 if net/ethernet.h declares `ether_ntohost' */
#cmakedefine NET_ETHERNET_H_DECLARES_ETHER_NTOHOST 1
/* Define to the address where bug reports for this package should be sent. */
#cmakedefine PACKAGE_BUGREPORT ""
/* Define to the full name of this package. */
#cmakedefine PACKAGE_NAME "@PACKAGE_NAME@"
/* Define to the full name and version of this package. */
#cmakedefine PACKAGE_STRING "@PACKAGE_STRING@"
/* Define to the one symbol short name of this package. */
#cmakedefine PACKAGE_TARNAME ""
/* Define to the home page for this package. */
#cmakedefine PACKAGE_URL ""
/* Define to the version of this package. */
#cmakedefine PACKAGE_VERSION "@PACKAGE_VERSION@"
/* Define to 1 if you have the ANSI C header files. */
#cmakedefine STDC_HEADERS 1
/* Define to 1 if sys/ethernet.h declares `ether_ntohost' */
#cmakedefine SYS_ETHERNET_H_DECLARES_ETHER_NTOHOST 1
/* define if you have ether_ntohost() and it works */
#cmakedefine USE_ETHER_NTOHOST 1
/* Define if you enable support for libsmi */
#cmakedefine USE_LIBSMI 1
/* define if should chroot when dropping privileges */
#cmakedefine WITH_CHROOT "@WITH_CHROOT@"
/* define if should drop privileges by default */
#cmakedefine WITH_USER "@WITH_USER@"
/* define on AIX to get certain functions */
#cmakedefine _SUN 1
/* to handle Ultrix compilers that don't support const in prototypes */
#cmakedefine const 1
/* Define as token for inline if inlining supported */
#cmakedefine inline 1
/* Define to `uint16_t' if u_int16_t not defined. */
#cmakedefine u_int16_t 1
/* Define to `uint32_t' if u_int32_t not defined. */
#cmakedefine u_int32_t 1
/* Define to `uint64_t' if u_int64_t not defined. */
#cmakedefine u_int64_t 1
/* Define to `uint8_t' if u_int8_t not defined. */
#cmakedefine u_int8_t 1
/* Define to the type of an unsigned integer type wide enough to hold a
pointer, if such a type exists, and if the system does not define it. */
#cmakedefine uintptr_t 1

View File

@ -0,0 +1,196 @@
/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */
/*
* Copyright (c) 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Computer Systems
* Engineering Group at Lawrence Berkeley Laboratory.
* 4. Neither the name of the University nor of the Laboratory may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef nd_compiler_tests_h
#define nd_compiler_tests_h
/*
* This was introduced by Clang:
*
* https://clang.llvm.org/docs/LanguageExtensions.html#has-attribute
*
* in some version (which version?); it has been picked up by GCC 5.0.
*/
#ifndef __has_attribute
/*
* It's a macro, so you can check whether it's defined to check
* whether it's supported.
*
* If it's not, define it to always return 0, so that we move on to
* the fallback checks.
*/
#define __has_attribute(x) 0
#endif
/*
* Note that the C90 spec's "6.8.1 Conditional inclusion" and the
* C99 spec's and C11 spec's "6.10.1 Conditional inclusion" say:
*
* Prior to evaluation, macro invocations in the list of preprocessing
* tokens that will become the controlling constant expression are
* replaced (except for those macro names modified by the defined unary
* operator), just as in normal text. If the token "defined" is
* generated as a result of this replacement process or use of the
* "defined" unary operator does not match one of the two specified
* forms prior to macro replacement, the behavior is undefined.
*
* so you shouldn't use defined() in a #define that's used in #if or
* #elif. Some versions of Clang, for example, will warn about this.
*
* Instead, we check whether the pre-defined macros for particular
* compilers are defined and, if not, define the "is this version XXX
* or a later version of this compiler" macros as 0.
*/
/*
* Check whether this is GCC major.minor or a later release, or some
* compiler that claims to be "just like GCC" of that version or a
* later release.
*/
#if ! defined(__GNUC__)
/* Not GCC and not "just like GCC" */
#define ND_IS_AT_LEAST_GNUC_VERSION(major, minor) 0
#else
/* GCC or "just like GCC" */
#define ND_IS_AT_LEAST_GNUC_VERSION(major, minor) \
(__GNUC__ > (major) || \
(__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
#endif
/*
* Check whether this is Clang major.minor or a later release.
*/
#if !defined(__clang__)
/* Not Clang */
#define ND_IS_AT_LEAST_CLANG_VERSION(major, minor) 0
#else
/* Clang */
#define ND_IS_AT_LEAST_CLANG_VERSION(major, minor) \
(__clang_major__ > (major) || \
(__clang_major__ == (major) && __clang_minor__ >= (minor)))
#endif
/*
* Check whether this is Sun C/SunPro C/Oracle Studio major.minor
* or a later release.
*
* The version number in __SUNPRO_C is encoded in hex BCD, with the
* uppermost hex digit being the major version number, the next
* one or two hex digits being the minor version number, and
* the last digit being the patch version.
*
* It represents the *compiler* version, not the product version;
* see
*
* https://sourceforge.net/p/predef/wiki/Compilers/
*
* for a partial mapping, which we assume continues for later
* 12.x product releases.
*/
#if ! defined(__SUNPRO_C)
/* Not Sun/Oracle C */
#define ND_IS_AT_LEAST_SUNC_VERSION(major,minor) 0
#else
/* Sun/Oracle C */
#define ND_SUNPRO_VERSION_TO_BCD(major, minor) \
(((minor) >= 10) ? \
(((major) << 12) | (((minor)/10) << 8) | (((minor)%10) << 4)) : \
(((major) << 8) | ((minor) << 4)))
#define ND_IS_AT_LEAST_SUNC_VERSION(major,minor) \
(__SUNPRO_C >= ND_SUNPRO_VERSION_TO_BCD((major), (minor)))
#endif
/*
* Check whether this is IBM XL C major.minor or a later release.
*
* The version number in __xlC__ has the major version in the
* upper 8 bits and the minor version in the lower 8 bits.
* On AIX __xlC__ is always defined, __ibmxl__ becomes defined in XL C 16.1.
* On Linux since XL C 13.1.6 __xlC__ is not defined by default anymore, but
* __ibmxl__ is defined since at least XL C 13.1.1.
*/
#if ! defined(__xlC__) && ! defined(__ibmxl__)
/* Not XL C */
#define ND_IS_AT_LEAST_XL_C_VERSION(major,minor) 0
#define ND_IS_AT_LEAST_XL_C_MODFIX(modification, fixlevel) 0
#else
/* XL C */
#if defined(__ibmxl__)
/*
* Later Linux version of XL C; use __ibmxl_version__ to test
* the version.
*/
#define ND_IS_AT_LEAST_XL_C_VERSION(major, minor) \
(__ibmxl_version__ > (major) || \
(__ibmxl_version__ == (major) && __ibmxl_release__ >= (minor)))
#define ND_IS_AT_LEAST_XL_C_MODFIX(modification, fixlevel) \
(__ibmxl_modification__ > (modification) || \
(__ibmxl_modification__ == (modification) && \
__ibmxl_ptf_fix_level__ >= (fixlevel)))
#else /* __ibmxl__ */
/*
* __ibmxl__ not defined; use __xlC__ to test the version.
*/
#define ND_IS_AT_LEAST_XL_C_VERSION(major, minor) \
(__xlC__ >= (((major) << 8) | (minor)))
#define ND_IS_AT_LEAST_XL_C_MODFIX(modification, fixlevel) \
((((modification) << 8) | (fixlevel)) >= __xlC_ver__)
#endif /* __ibmxl__ */
#endif
/*
* Check whether this is HP aC++/HP C major.minor or a later release.
*
* The version number in __HP_aCC is encoded in zero-padded decimal BCD,
* with the "A." stripped off, the uppermost two decimal digits being
* the major version number, the next two decimal digits being the minor
* version number, and the last two decimal digits being the patch version.
* (Strip off the A., remove the . between the major and minor version
* number, and add two digits of patch.)
*/
#if ! defined(__HP_aCC)
/* Not HP C */
#define ND_IS_AT_LEAST_HP_C_VERSION(major,minor) 0
#else
/* HP C */
#define ND_IS_AT_LEAST_HP_C_VERSION(major,minor) \
(__HP_aCC >= ((major)*10000 + (minor)*100))
#endif
#endif /* nd_funcattrs_h */

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,11 @@
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if arpa/inet.h declares `ether_ntohost' */
#undef ARPA_INET_H_DECLARES_ETHER_NTOHOST
/* 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
/* Define to 1 if you have the `bpf_dump' function. */
#undef HAVE_BPF_DUMP
@ -24,19 +24,21 @@
/* Define to 1 if you have the `cap_rights_limit' function. */
#undef HAVE_CAP_RIGHTS_LIMIT
/* Define to 1 if you have the declaration of `ether_ntohost', and to 0 if you
don't. */
/* Casper support available */
#undef HAVE_CASPER
/* Define to 1 if you have the declaration of `ether_ntohost' */
#undef HAVE_DECL_ETHER_NTOHOST
/* Define to 1 if you have the `ether_ntohost' function. */
#undef HAVE_ETHER_NTOHOST
/* Define to 1 if you have the `EVP_CipherInit_ex' function. */
#undef HAVE_EVP_CIPHERINIT_EX
/* 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 `EVP_DecryptInit_ex' function. */
#undef HAVE_EVP_DECRYPTINIT_EX
/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
@ -49,6 +51,9 @@
/* define if you have getrpcbynumber() */
#undef HAVE_GETRPCBYNUMBER
/* Define to 1 if you have the `getservent' function. */
#undef HAVE_GETSERVENT
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
@ -64,17 +69,11 @@
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the <netinet/ether.h> header file. */
#undef HAVE_NETINET_ETHER_H
/* Define to 1 if you have the <net/if.h> header file. */
#undef HAVE_NET_IF_H
/* Define to 1 if you have the <netinet/if_ether.h> header file. */
#undef HAVE_NETINET_IF_ETHER_H
/* Define to 1 if you have the <net/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
/* Define to 1 if printf(3) does not support the z length modifier. */
#undef HAVE_NO_PRINTF_Z
/* Define to 1 if you have the `openat' function. */
#undef HAVE_OPENAT
@ -88,9 +87,6 @@
/* if there's an os_proto.h for this platform, to use additional prototypes */
#undef HAVE_OS_PROTO_H
/* Define to 1 if you have the <pcap/bluetooth.h> header file. */
#undef HAVE_PCAP_BLUETOOTH_H
/* Define to 1 if you have the `pcap_breakloop' function. */
#undef HAVE_PCAP_BREAKLOOP
@ -109,12 +105,18 @@
/* Define to 1 if you have the `pcap_dump_flush' function. */
#undef HAVE_PCAP_DUMP_FLUSH
/* define if libpcap has pcap_dump_ftell() */
/* Define to 1 if you have the `pcap_dump_ftell' function. */
#undef HAVE_PCAP_DUMP_FTELL
/* Define to 1 if you have the `pcap_dump_ftell64' function. */
#undef HAVE_PCAP_DUMP_FTELL64
/* Define to 1 if you have the `pcap_findalldevs' function. */
#undef HAVE_PCAP_FINDALLDEVS
/* Define to 1 if you have the `pcap_findalldevs_ex' function. */
#undef HAVE_PCAP_FINDALLDEVS_EX
/* Define to 1 if you have the `pcap_free_datalinks' function. */
#undef HAVE_PCAP_FREE_DATALINKS
@ -127,8 +129,11 @@
/* define if libpcap has pcap_list_datalinks() */
#undef HAVE_PCAP_LIST_DATALINKS
/* Define to 1 if you have the <pcap/nflog.h> header file. */
#undef HAVE_PCAP_NFLOG_H
/* Define to 1 if you have the `pcap_open' function. */
#undef HAVE_PCAP_OPEN
/* Define to 1 if you have the <pcap/pcap-inttypes.h> header file. */
#undef HAVE_PCAP_PCAP_INTTYPES_H
/* Define to 1 if you have the `pcap_setdirection' function. */
#undef HAVE_PCAP_SETDIRECTION
@ -151,9 +156,6 @@
/* Define to 1 if you have the `pcap_set_tstamp_type' function. */
#undef HAVE_PCAP_SET_TSTAMP_TYPE
/* Define to 1 if you have the <pcap/usb.h> header file. */
#undef HAVE_PCAP_USB_H
/* define if libpcap has pcap_version */
#undef HAVE_PCAP_VERSION
@ -169,18 +171,6 @@
/* Define to 1 if you have the `setlinebuf' function. */
#undef HAVE_SETLINEBUF
/* Define to 1 if you have the `sigaction' function. */
#undef HAVE_SIGACTION
/* Define to 1 if you have the `sigset' function. */
#undef HAVE_SIGSET
/* Define to 1 if you have the `snprintf' function. */
#undef HAVE_SNPRINTF
/* if struct sockaddr has the sa_len member */
#undef HAVE_SOCKADDR_SA_LEN
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
@ -190,9 +180,6 @@
/* Define to 1 if you have the `strdup' function. */
#undef HAVE_STRDUP
/* Define to 1 if you have the `strftime' function. */
#undef HAVE_STRFTIME
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
@ -226,27 +213,18 @@
/* Define to 1 if you have the `vfork' function. */
#undef HAVE_VFORK
/* Define to 1 if you have the `vfprintf' function. */
#undef HAVE_VFPRINTF
/* Define to 1 if you have the `vsnprintf' function. */
#undef HAVE_VSNPRINTF
/* define if libpcap has yydebug */
#undef HAVE_YYDEBUG
/* define if your compiler has __attribute__ */
#undef HAVE___ATTRIBUTE__
/* if unaligned access fails */
#undef LBL_ALIGN
/* Define to 1 if netinet/ether.h declares `ether_ntohost' */
#undef NETINET_ETHER_H_DECLARES_ETHER_NTOHOST
/* Define to 1 if netinet/if_ether.h declares `ether_ntohost' */
#undef NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST
/* Define to 1 if net/ethernet.h declares `ether_ntohost' */
#undef NET_ETHERNET_H_DECLARES_ETHER_NTOHOST
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
@ -265,29 +243,14 @@
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* define if the platform doesn't define PRId64 */
#undef PRId64
/* define if the platform doesn't define PRIo64 */
#undef PRIo64
/* define if the platform doesn't define PRIx64 */
#undef PRIu64
/* define if the platform doesn't define PRIu64 */
#undef PRIx64
/* Define as the return type of signal handlers (`int' or `void'). */
#undef RETSIGTYPE
/* return value of signal handlers */
#undef RETSIGVAL
/* The size of `void *', as computed by sizeof. */
#undef SIZEOF_VOID_P
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#undef TIME_WITH_SYS_TIME
/* Define to 1 if sys/ethernet.h declares `ether_ntohost' */
#undef SYS_ETHERNET_H_DECLARES_ETHER_NTOHOST
/* define if you have ether_ntohost() and it works */
#undef USE_ETHER_NTOHOST
@ -301,60 +264,15 @@
/* define if should drop privileges by default */
#undef WITH_USER
/* get BSD semantics on Irix */
#undef _BSD_SIGNALS
/* define on AIX to get certain functions */
#undef _SUN
/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
#define below would cause a syntax error. */
#undef _UINT32_T
/* Define for Solaris 2.5.1 so the uint64_t typedef from <sys/synch.h>,
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
#define below would cause a syntax error. */
#undef _UINT64_T
/* Define for Solaris 2.5.1 so the uint8_t typedef from <sys/synch.h>,
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
#define below would cause a syntax error. */
#undef _UINT8_T
/* define if your compiler allows __attribute__((format)) without a warning */
#undef __ATTRIBUTE___FORMAT_OK
/* define if your compiler allows __attribute__((format)) to be applied to
function pointers */
#undef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS
/* define if your compiler allows __attribute__((noreturn)) to be applied to
function pointers */
#undef __ATTRIBUTE___NORETURN_OK_FOR_FUNCTION_POINTERS
/* to handle Ultrix compilers that don't support const in prototypes */
#undef const
/* Define as token for inline if inlining supported */
#undef inline
/* Define to the type of a signed integer type of width exactly 16 bits if
such a type exists and the standard includes do not define it. */
#undef int16_t
/* Define to the type of a signed integer type of width exactly 32 bits if
such a type exists and the standard includes do not define it. */
#undef int32_t
/* Define to the type of a signed integer type of width exactly 64 bits if
such a type exists and the standard includes do not define it. */
#undef int64_t
/* Define to the type of a signed integer type of width exactly 8 bits if such
a type exists and the standard includes do not define it. */
#undef int8_t
/* Define to `uint16_t' if u_int16_t not defined. */
#undef u_int16_t
@ -367,22 +285,6 @@
/* Define to `uint8_t' if u_int8_t not defined. */
#undef u_int8_t
/* Define to the type of an unsigned integer type of width exactly 16 bits if
such a type exists and the standard includes do not define it. */
#undef uint16_t
/* Define to the type of an unsigned integer type of width exactly 32 bits if
such a type exists and the standard includes do not define it. */
#undef uint32_t
/* Define to the type of an unsigned integer type of width exactly 64 bits if
such a type exists and the standard includes do not define it. */
#undef uint64_t
/* Define to the type of an unsigned integer type of width exactly 8 bits if
such a type exists and the standard includes do not define it. */
#undef uint8_t
/* Define to the type of an unsigned integer type wide enough to hold a
pointer, if such a type exists, and if the system does not define it. */
#undef uintptr_t

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -7,71 +7,37 @@ dnl
#
# See
#
# http://ftp.gnu.org/gnu/config/README
# https://ftp.gnu.org/gnu/config/README
#
# for the URLs to use to fetch new versions of config.guess and
# config.sub.
#
AC_PREREQ(2.61)
AC_INIT(tcpdump.c)
AC_PREREQ(2.69)
AC_INIT(tcpdump, m4_esyscmd_s([cat VERSION]))
AC_CONFIG_SRCDIR(tcpdump.c)
AC_CANONICAL_HOST
AC_LBL_C_INIT_BEFORE_CC(V_INCLS)
AC_PROG_CC
#
# Try to enable as many C99 features as we can.
# At minimum, we want C++/C99-style // comments.
#
AC_PROG_CC_C99
if test "$ac_cv_prog_cc_c99" = "no"; then
AC_MSG_WARN([The C compiler does not support C99; there may be compiler errors])
fi
AC_LBL_C_INIT(V_CCOPT, V_INCLS)
AC_LBL_C_INLINE
AC_C___ATTRIBUTE__
if test "$ac_cv___attribute__" = "yes"; then
AC_C___ATTRIBUTE___UNUSED
AC_C___ATTRIBUTE___NORETURN_FUNCTION_POINTER
AC_C___ATTRIBUTE___FORMAT
if test "$ac_cv___attribute___format" = "yes"; then
AC_C___ATTRIBUTE___FORMAT_FUNCTION_POINTER
fi
fi
AC_CHECK_HEADERS(fcntl.h rpc/rpc.h rpc/rpcent.h)
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
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>])
if test "$ac_cv_header_netinet_if_ether_h" != yes; then
#
# The simple test didn't work.
# Do we need to include <net/if.h> first?
# Unset ac_cv_header_netinet_if_ether_h so we don't
# treat the previous failure as a cached value and
# suppress the next test.
#
AC_MSG_NOTICE([Rechecking with some additional includes])
unset ac_cv_header_netinet_if_ether_h
AC_CHECK_HEADERS(netinet/if_ether.h, , , [#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
struct mbuf;
struct rtentry;
#include <net/if.h>])
fi
AC_HEADER_TIME
AC_CHECK_HEADERS(fcntl.h rpc/rpc.h rpc/rpcent.h net/if.h)
case "$host_os" in
darwin*)
AC_ARG_ENABLE(universal,
AC_HELP_STRING([--disable-universal],[don't build universal on OS X]))
AS_HELP_STRING([--disable-universal],[don't build universal on macOS]))
if test "$enable_universal" != "no"; then
case "$host_os" in
@ -98,10 +64,11 @@ darwin*)
esac
AC_ARG_WITH(smi,
[ --with-smi link with libsmi (allows to load MIBs on the fly to decode SNMP packets. [default=yes]
--without-smi don't link with libsmi],,
with_smi=yes)
AC_ARG_WITH([smi],
[AS_HELP_STRING([--with-smi],
[link with libsmi (allows to load MIBs on the fly to decode SNMP packets) [default=yes, if available]])],
[],
[with_smi=yes])
if test "x$with_smi" != "xno" ; then
AC_CHECK_HEADER(smi.h,
@ -120,8 +87,11 @@ if test "x$with_smi" != "xno" ; then
AC_TRY_RUN(
[
/* libsmi available check */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <smi.h>
main()
int main()
{
int current, revision, age, n;
const int required = 2;
@ -168,10 +138,11 @@ main()
fi
AC_MSG_CHECKING([whether to enable the possibly-buggy SMB printer])
AC_ARG_ENABLE(smb,
[ --enable-smb enable possibly-buggy SMB printer [default=no]
--disable-smb disable possibly-buggy SMB printer],,
enableval=no)
AC_ARG_ENABLE([smb],
[AS_HELP_STRING([--enable-smb],
[enable possibly-buggy SMB printer [default=no]])],
[],
[enableval=no])
case "$enableval" in
yes) AC_MSG_RESULT(yes)
AC_DEFINE(ENABLE_SMB, 1,
@ -220,10 +191,21 @@ AC_ARG_WITH(sandbox-capsicum,
# XXX - do we need to check for all of them, or are there some that, if
# present, imply others are present?
#
if test ! -z "$with_sandbox-capsicum" && test "$with_sandbox-capsicum" != "no" ; then
AC_CHECK_FUNCS(cap_enter cap_rights_limit cap_ioctls_limit openat,
ac_lbl_capsicum_function_seen=yes,
ac_lbl_capsicum_function_not_seen=yes)
if test -z "$with_sandbox_capsicum" || test "$with_sandbox_capsicum" != "no" ; then
#
# First, make sure we have the required header.
#
AC_CHECK_HEADER(sys/capsicum.h,
[
#
# We do; now make sure we have the required functions.
#
AC_CHECK_FUNCS(cap_enter cap_rights_limit cap_ioctls_limit openat,
ac_lbl_capsicum_function_seen=yes,
ac_lbl_capsicum_function_not_seen=yes)
])
AC_CHECK_LIB(casper, cap_init, LIBS="$LIBS -lcasper")
AC_CHECK_LIB(cap_dns, cap_gethostbyaddr, LIBS="$LIBS -lcap_dns")
fi
AC_MSG_CHECKING([whether to sandbox using capsicum])
if test "x$ac_lbl_capsicum_function_seen" = "xyes" -a "x$ac_lbl_capsicum_function_not_seen" != "xyes"; then
@ -232,6 +214,13 @@ if test "x$ac_lbl_capsicum_function_seen" = "xyes" -a "x$ac_lbl_capsicum_functio
else
AC_MSG_RESULT(no)
fi
AC_MSG_CHECKING([whether to sandbox using Casper library])
if test "x$ac_cv_lib_casper_cap_init" = "xyes" -a "x$ac_cv_lib_cap_dns_cap_gethostbyaddr" = "xyes"; then
AC_DEFINE(HAVE_CASPER, 1, [Casper support available])
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
#
# We must check this before checking whether to check the OS's IPv6,
@ -251,10 +240,15 @@ AC_COMPILE_IFELSE(
[
AC_LANG_SOURCE(
[[
#include <string.h>
/* AF_INET6 available check */
#include <sys/types.h>
#ifdef _WIN32
#include <ws2tcpip.h>
#else
#include <sys/socket.h>
#include <netinet/in.h>
#endif
#ifdef AF_INET6
void
foo(struct in6_addr *addr)
@ -385,18 +379,49 @@ if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
fi
fi
AC_REPLACE_FUNCS(vfprintf strlcat strlcpy strdup strsep getopt_long)
AC_CHECK_FUNCS(fork vfork strftime)
AC_CHECK_FUNCS(setlinebuf alarm)
AC_REPLACE_FUNCS(strlcat strlcpy strdup strsep getservent getopt_long)
AC_CHECK_FUNCS(fork vfork)
AC_CHECK_FUNCS(setlinebuf)
needsnprintf=no
AC_CHECK_FUNCS(vsnprintf snprintf,,
[needsnprintf=yes])
if test $needsnprintf = yes; then
AC_LIBOBJ(snprintf)
fi
#
# Make sure we have vsnprintf() and snprintf(); we require them.
#
AC_CHECK_FUNC(vsnprintf,,
AC_MSG_ERROR([vsnprintf() is required but wasn't found]))
AC_CHECK_FUNC(snprintf,,
AC_MSG_ERROR([snprintf() is required but wasn't found]))
AC_LBL_TYPE_SIGNAL
#
# Define HAVE_NO_PRINTF_Z to make it possible to disable test cases that
# depend on %zu.
#
AC_MSG_CHECKING([whether printf(3) supports the z length modifier])
AC_RUN_IFELSE(
[
AC_LANG_SOURCE([[
#include <stdio.h>
#include <string.h>
int main()
{
char buf[100];
snprintf(buf, sizeof(buf), "%zu", sizeof(buf));
return strncmp(buf, "100", sizeof(buf)) ? 1 : 0;
}
]])
],
[
AC_MSG_RESULT(yes)
],
[
AC_MSG_RESULT(no)
AC_DEFINE(HAVE_NO_PRINTF_Z, 1,
[Define to 1 if printf(3) does not support the z length modifier.])
],
[
AC_MSG_RESULT(not while cross-compiling)
]
)
AC_CHECK_LIB(rpc, main) dnl It's unclear why we might need -lrpc
@ -412,11 +437,12 @@ AC_LBL_LIBPCAP(V_PCAPDEP, V_INCLS)
#
# You are in a twisty little maze of UN*Xes, all different.
# Some might not have ether_ntohost().
# Some might have it, but not declare it in any header file.
# Some might have it, but declare it in <netinet/if_ether.h>.
# Some might have it, but declare it in <netinet/ether.h>
# (And some might have it but document it as something declared in
# <netinet/ethernet.h>, although <netinet/if_ether.h> appears to work.)
# Some might have it and declare it in <net/ethernet.h>.
# Some might have it and declare it in <netinet/ether.h>
# Some might have it and declare it in <sys/ethernet.h>.
# Some might have it and declare it in <arpa/inet.h>.
# Some might have it and declare it in <netinet/if_ether.h>.
# Some might have it and not declare it in any header file.
#
# Before you is a C compiler.
#
@ -424,6 +450,8 @@ AC_CHECK_FUNCS(ether_ntohost, [
AC_CACHE_CHECK(for buggy ether_ntohost, ac_cv_buggy_ether_ntohost, [
AC_TRY_RUN([
#include <netdb.h>
#include <netinet/ether.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
@ -448,12 +476,114 @@ AC_CHECK_FUNCS(ether_ntohost, [
if test "$ac_cv_func_ether_ntohost" = yes -a \
"$ac_cv_buggy_ether_ntohost" = "no"; then
#
# OK, we have ether_ntohost(). Do we have <netinet/if_ether.h>?
# OK, we have ether_ntohost(). Is it declared in <net/ethernet.h>?
#
if test "$ac_cv_header_netinet_if_ether_h" = yes; then
# This test fails if we don't have <net/ethernet.h> or if we do
# but it doesn't declare ether_ntohost().
#
AC_CHECK_DECL(ether_ntohost,
[
AC_DEFINE(NET_ETHERNET_H_DECLARES_ETHER_NTOHOST,,
[Define to 1 if net/ethernet.h declares `ether_ntohost'])
],,
[
#include <net/ethernet.h>
])
#
# Did that succeed?
#
if test "$ac_cv_have_decl_ether_ntohost" != yes; then
#
# Yes. Does it declare ether_ntohost()?
# No, how about <netinet/ether.h>, as on Linux?
#
# This test fails if we don't have <netinet/ether.h>
# or if we do but it doesn't declare ether_ntohost().
#
# Unset ac_cv_have_decl_ether_ntohost so we don't
# treat the previous failure as a cached value and
# suppress the next test.
#
unset ac_cv_have_decl_ether_ntohost
AC_CHECK_DECL(ether_ntohost,
[
AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_NTOHOST,,
[Define to 1 if netinet/ether.h declares `ether_ntohost'])
],,
[
#include <netinet/ether.h>
])
fi
#
# Did that succeed?
#
if test "$ac_cv_have_decl_ether_ntohost" != yes; then
#
# No, how about <sys/ethernet.h>, as on Solaris 10
# and later?
#
# This test fails if we don't have <sys/ethernet.h>
# or if we do but it doesn't declare ether_ntohost().
#
# Unset ac_cv_have_decl_ether_ntohost so we don't
# treat the previous failure as a cached value and
# suppress the next test.
#
unset ac_cv_have_decl_ether_ntohost
AC_CHECK_DECL(ether_ntohost,
[
AC_DEFINE(SYS_ETHERNET_H_DECLARES_ETHER_NTOHOST,,
[Define to 1 if sys/ethernet.h declares `ether_ntohost'])
],,
[
#include <sys/ethernet.h>
])
fi
#
# Did that succeed?
#
if test "$ac_cv_have_decl_ether_ntohost" != yes; then
#
# No, how about <arpa/inet.h>, as in AIX?
#
# This test fails if we don't have <arpa/inet.h>
# (if we have ether_ntohost(), we should have
# networking, and if we have networking, we should
# have <arpa/inet.h>) or if we do but it doesn't
# declare ether_ntohost().
#
# Unset ac_cv_have_decl_ether_ntohost so we don't
# treat the previous failure as a cached value and
# suppress the next test.
#
unset ac_cv_have_decl_ether_ntohost
AC_CHECK_DECL(ether_ntohost,
[
AC_DEFINE(ARPA_INET_H_DECLARES_ETHER_NTOHOST,,
[Define to 1 if arpa/inet.h declares `ether_ntohost'])
],,
[
#include <arpa/inet.h>
])
fi
#
# Did that succeed?
#
if test "$ac_cv_have_decl_ether_ntohost" != yes; then
#
# No, how about <netinet/if_ether.h>?
# On some platforms, it requires <net/if.h> and
# <netinet/in.h>, and we always include it with
# both of them, so test it with both of them.
#
# This test fails if we don't have <netinet/if_ether.h>
# and the headers we include before it, or if we do but
# <netinet/if_ether.h> doesn't declare ether_hostton().
#
# Unset ac_cv_have_decl_ether_ntohost so we don't
# treat the previous failure as a cached value and
# suppress the next test.
#
unset ac_cv_have_decl_ether_ntohost
AC_CHECK_DECL(ether_ntohost,
[
AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST,,
@ -462,76 +592,45 @@ if test "$ac_cv_func_ether_ntohost" = yes -a \
[
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
struct mbuf;
struct rtentry;
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
])
fi
#
# Did that succeed?
# After all that, is ether_ntohost() declared?
#
if test "$ac_cv_have_decl_ether_ntohost" != yes; then
if test "$ac_cv_have_decl_ether_ntohost" = yes; then
#
# No, how about <netinet/ether.h>, as on Linux?
# Yes.
#
AC_CHECK_HEADERS(netinet/ether.h)
if test "$ac_cv_header_netinet_ether_h" = yes; then
#
# We have it - does it declare ether_ntohost()?
# Unset ac_cv_have_decl_ether_ntohost so we don't
# treat the previous failure as a cached value and
# suppress the next test.
#
unset ac_cv_have_decl_ether_ntohost
AC_CHECK_DECL(ether_ntohost,
[
AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_NTOHOST,,
[Define to 1 if netinet/ether.h declares `ether_ntohost'])
],,
[
#include <netinet/ether.h>
])
fi
fi
#
# Is ether_ntohost() declared?
#
if test "$ac_cv_have_decl_ether_ntohost" != yes; then
AC_DEFINE(HAVE_DECL_ETHER_NTOHOST, 1,
[Define to 1 if you have the declaration of `ether_ntohost'])
else
#
# No, we'll have to declare it ourselves.
# Do we have "struct ether_addr"?
# Do we have "struct ether_addr" if we include
# <netinet/if_ether.h>?
#
AC_CHECK_TYPES(struct ether_addr,,,
[
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
struct mbuf;
struct rtentry;
#include <net/if.h>
#include <netinet/if_ether.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
])
AC_DEFINE(HAVE_DECL_ETHER_NTOHOST, 0,
[Define to 1 if you have the declaration of `ether_ntohost', and to 0 if you
don't.])
else
AC_DEFINE(HAVE_DECL_ETHER_NTOHOST, 1,
[Define to 1 if you have the declaration of `ether_ntohost', and to 0 if you
don't.])
fi
fi
# libdlpi is needed for Solaris 11 and later.
AC_CHECK_LIB(dlpi, dlpi_walk, LIBS="$LIBS -ldlpi" LDFLAGS="-L/lib $LDFLAGS", ,-L/lib)
dnl
dnl Check for "pcap_list_datalinks()", "pcap_set_datalink()",
dnl and "pcap_datalink_name_to_val()", and use substitute versions
dnl if they're not present.
dnl Check for "pcap_list_datalinks()" and use a substitute version if
dnl it's not present. If it is present, check for "pcap_free_datalinks()";
dnl if it's not present, we don't replace it for now. (We could do so
dnl on UN*X, but not on Windows, where hilarity ensues if a program
dnl built with one version of the MSVC support library tries to free
dnl something allocated by a library built with another version of
dnl the MSVC support library.)
dnl
AC_CHECK_FUNC(pcap_list_datalinks,
[
@ -542,7 +641,13 @@ AC_CHECK_FUNC(pcap_list_datalinks,
[
AC_LIBOBJ(datalinks)
])
AC_CHECK_FUNCS(pcap_set_datalink)
dnl
dnl Check for "pcap_datalink_name_to_val()", and use a substitute
dnl version if it's not present. If it is present, check for
dnl "pcap_datalink_val_to_description()", and if we don't have it,
dnl use a substitute version.
dnl
AC_CHECK_FUNC(pcap_datalink_name_to_val,
[
AC_DEFINE(HAVE_PCAP_DATALINK_NAME_TO_VAL, 1,
@ -558,6 +663,13 @@ AC_CHECK_FUNC(pcap_datalink_name_to_val,
AC_LIBOBJ(dlnames)
])
dnl
dnl Check for "pcap_set_datalink()"; you can't substitute for it if
dnl it's absent (it has hooks into libpcap), so just define the
dnl HAVE_ value if it's there.
dnl
AC_CHECK_FUNCS(pcap_set_datalink)
dnl
dnl Check for "pcap_breakloop()"; you can't substitute for it if
dnl it's absent (it has hooks into the live capture routines),
@ -565,17 +677,6 @@ dnl so just define the HAVE_ value if it's there.
dnl
AC_CHECK_FUNCS(pcap_breakloop)
dnl
dnl Check for "pcap_dump_ftell()" and use a substitute version
dnl if it's not present.
dnl
AC_CHECK_FUNC(pcap_dump_ftell,
AC_DEFINE(HAVE_PCAP_DUMP_FTELL, 1,
[define if libpcap has pcap_dump_ftell()]),
[
AC_LIBOBJ(pcap_dump_ftell)
])
#
# Do we have the new open API? Check for pcap_create, and assume that,
# if we do, we also have pcap_activate() and the other new routines
@ -599,17 +700,18 @@ fi
# Check for a miscellaneous collection of functions which we use
# if we have them.
#
AC_CHECK_FUNCS(pcap_findalldevs pcap_dump_flush pcap_lib_version pcap_setdirection pcap_set_immediate_mode)
AC_CHECK_FUNCS(pcap_findalldevs)
if test $ac_cv_func_pcap_findalldevs = "yes" ; then
dnl Check for Mac OS X, which may ship pcap.h from 0.6 but libpcap may
dnl be 0.8; this means that lib has pcap_findalldevs but header doesn't
dnl have pcap_if_t.
dnl Check for libpcap having pcap_findalldevs() but the pcap.h header
dnl not having pcap_if_t; some versions of Mac OS X shipped with pcap.h
dnl from 0.6 and libpcap 0.8, so that libpcap had pcap_findalldevs but
dnl pcap.h didn't have pcap_if_t.
savedcppflags="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $V_INCLS"
AC_CHECK_TYPES(pcap_if_t, , , [#include <pcap.h>])
CPPFLAGS="$savedcppflags"
fi
AC_CHECK_FUNCS(pcap_dump_flush pcap_lib_version)
if test $ac_cv_func_pcap_lib_version = "no" ; then
AC_MSG_CHECKING(whether pcap_version is defined by libpcap)
AC_TRY_LINK([],
@ -627,6 +729,9 @@ if test $ac_cv_func_pcap_lib_version = "no" ; then
AC_MSG_RESULT(no)
fi
fi
AC_CHECK_FUNCS(pcap_setdirection pcap_set_immediate_mode pcap_dump_ftell64)
AC_CHECK_FUNCS(pcap_open pcap_findalldevs_ex)
AC_REPLACE_FUNCS(pcap_dump_ftell)
#
# Check for special debugging functions
@ -734,25 +839,21 @@ if test -f /dev/bpf0 ; then
V_GROUP=bpf
fi
#
# Make sure we have definitions for all the C99 specified-width types
# (regardless of whether the environment is a C99 environment or not).
#
AC_TYPE_INT8_T
AC_TYPE_INT16_T
AC_TYPE_INT32_T
AC_TYPE_INT64_T
AC_TYPE_UINT8_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
#
# Make sure we have a definition for C99's uintptr_t (regardless of
# whether the environment is a C99 environment or not).
#
AC_TYPE_UINTPTR_T
#
# Check whether we have pcap/pcap-inttypes.h.
# If we do, we use that to get the C99 types defined.
#
savedcppflags="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $V_INCLS"
AC_CHECK_HEADERS(pcap/pcap-inttypes.h)
CPPFLAGS="$savedcppflags"
#
# Define the old BSD specified-width types in terms of the C99 types;
# we may need them with libpcap include files.
@ -782,88 +883,11 @@ AC_CHECK_TYPE([u_int64_t], ,
#include <sys/types.h>
])
#
# Check for <inttypes.h>
#
AC_CHECK_HEADERS(inttypes.h,
[
#
# OK, we have inttypes.h, but does it define all the PRI[doxu]64 macros?
# Some systems have an inttypes.h that doesn't define all of them.
#
AC_MSG_CHECKING([[whether inttypes.h defines the PRI[doxu]64 macros]])
AC_COMPILE_IFELSE(
[
AC_LANG_SOURCE(
[[
#include <inttypes.h>
#include <stdio.h>
#include <sys/types.h>
main()
{
printf("%" PRId64 "\n", (uint64_t)1);
printf("%" PRIo64 "\n", (uint64_t)1);
printf("%" PRIx64 "\n", (uint64_t)1);
printf("%" PRIu64 "\n", (uint64_t)1);
}
]])
],
[
AC_MSG_RESULT(yes)
ac_lbl_inttypes_h_defines_formats=yes
],
[
AC_MSG_RESULT(no)
ac_lbl_inttypes_h_defines_formats=no
])
],
[
#
# We don't have inttypes.h, so it obviously can't define those
# macros.
#
ac_lbl_inttypes_h_defines_formats=no
])
if test "$ac_lbl_inttypes_h_defines_formats" = no; then
AC_LBL_CHECK_64BIT_FORMAT(l,
[
AC_LBL_CHECK_64BIT_FORMAT(ll,
[
AC_LBL_CHECK_64BIT_FORMAT(L,
[
AC_LBL_CHECK_64BIT_FORMAT(q,
[
AC_MSG_ERROR([neither %llx nor %Lx nor %qx worked on a 64-bit integer])
])
])
])
])
fi
#
# Check for some headers introduced in later versions of libpcap
# and used by some printers.
#
# Those headers use the {u_}intN_t types, so we must do this after
# we check for what's needed to get them defined.
#
savedcppflags="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $V_INCLS"
AC_CHECK_HEADERS(pcap/bluetooth.h,,,[#include "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
AC_CHECK_TOOL([AR], [ar])
AC_LBL_DEVEL(V_CCOPT)
AC_LBL_SOCKADDR_SA_LEN
AC_LBL_UNALIGNED_ACCESS
# Check for OpenSSL/libressl libcrypto
AC_MSG_CHECKING(whether to use OpenSSL/libressl libcrypto)
# Specify location for both includes and libraries.
@ -913,7 +937,7 @@ if test "$want_libcrypto" != "no"; then
# 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.
# Library and that only runs on macOS.
#
AC_CHECK_HEADER(openssl/crypto.h,
[
@ -928,19 +952,19 @@ if test "$want_libcrypto" != "no"; then
# EVP_CIPHER_CTX, as EVP_CIPHER_CTX may be
# opaque; otherwise, we allocate it ourselves.
#
# 2) do we have EVP_CipherInit_ex()?
# 2) do we have EVP_DecryptInit_ex()?
# If so, we use it, because we need to be
# able to make two "initialize the cipher"
# calls, one with the cipher and key, and
# one with the IV, and, as of OpenSSL 1.1,
# You Can't Do That with EVP_CipherInit(),
# because a call to EVP_CipherInit() will
# You Can't Do That with EVP_DecryptInit(),
# because a call to EVP_DecryptInit() will
# unconditionally clear the context, and
# if you don't supply a cipher, it'll
# clear the cipher, rendering the context
# unusable and causing a crash.
#
AC_CHECK_FUNCS(EVP_CIPHER_CTX_new EVP_CipherInit_ex)
AC_CHECK_FUNCS(EVP_CIPHER_CTX_new EVP_DecryptInit_ex)
fi
])
fi
@ -996,8 +1020,8 @@ AC_CONFIG_HEADER(config.h)
AC_OUTPUT_COMMANDS([if test -f .devel; then
echo timestamp > stamp-h
cat Makefile-devel-adds >> Makefile
make depend
cat $srcdir/Makefile-devel-adds >> Makefile
make depend || exit 1
fi])
AC_OUTPUT(Makefile tcpdump.1)
exit 0

View File

@ -28,18 +28,20 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#include <config.h>
#endif
#include <stdlib.h>
#include <string.h>
#include <netdissect-stdinc.h>
#include "netdissect-stdinc.h"
#include "cpack.h"
#include "netdissect.h"
#include "extract.h"
#include "cpack.h"
const uint8_t *
cpack_next_boundary(const uint8_t *buf, const uint8_t *p, size_t alignment)
nd_cpack_next_boundary(const uint8_t *buf, const uint8_t *p, size_t alignment)
{
size_t misalignment = (size_t)(p - buf) % alignment;
@ -54,12 +56,12 @@ cpack_next_boundary(const uint8_t *buf, const uint8_t *p, size_t alignment)
* return a pointer to the boundary.
*/
const uint8_t *
cpack_align_and_reserve(struct cpack_state *cs, size_t wordsize)
nd_cpack_align_and_reserve(struct cpack_state *cs, size_t wordsize)
{
const uint8_t *next;
/* Ensure alignment. */
next = cpack_next_boundary(cs->c_buf, cs->c_next, wordsize);
next = nd_cpack_next_boundary(cs->c_buf, cs->c_next, wordsize);
/* Too little space for wordsize bytes? */
if (next - cs->c_buf + wordsize > cs->c_len)
@ -70,7 +72,7 @@ cpack_align_and_reserve(struct cpack_state *cs, size_t wordsize)
/* Advance by N bytes without returning them. */
int
cpack_advance(struct cpack_state *cs, const size_t toskip)
nd_cpack_advance(struct cpack_state *cs, const size_t toskip)
{
/* No space left? */
if (cs->c_next - cs->c_buf + toskip > cs->c_len)
@ -80,7 +82,7 @@ cpack_advance(struct cpack_state *cs, const size_t toskip)
}
int
cpack_init(struct cpack_state *cs, const uint8_t *buf, size_t buflen)
nd_cpack_init(struct cpack_state *cs, const uint8_t *buf, size_t buflen)
{
memset(cs, 0, sizeof(*cs));
@ -93,63 +95,126 @@ cpack_init(struct cpack_state *cs, const uint8_t *buf, size_t buflen)
/* Unpack a 64-bit unsigned integer. */
int
cpack_uint64(struct cpack_state *cs, uint64_t *u)
nd_cpack_uint64(netdissect_options *ndo, struct cpack_state *cs, uint64_t *u)
{
const uint8_t *next;
if ((next = cpack_align_and_reserve(cs, sizeof(*u))) == NULL)
if ((next = nd_cpack_align_and_reserve(cs, sizeof(*u))) == NULL)
return -1;
*u = EXTRACT_LE_64BITS(next);
*u = GET_LE_U_8(next);
/* Move pointer past the uint64_t. */
cs->c_next = next + sizeof(*u);
return 0;
}
/* Unpack a 32-bit unsigned integer. */
/* Unpack a 64-bit signed integer. */
int
cpack_uint32(struct cpack_state *cs, uint32_t *u)
nd_cpack_int64(netdissect_options *ndo, struct cpack_state *cs, int64_t *u)
{
const uint8_t *next;
if ((next = cpack_align_and_reserve(cs, sizeof(*u))) == NULL)
if ((next = nd_cpack_align_and_reserve(cs, sizeof(*u))) == NULL)
return -1;
*u = EXTRACT_LE_32BITS(next);
*u = GET_LE_S_8(next);
/* Move pointer past the int64_t. */
cs->c_next = next + sizeof(*u);
return 0;
}
/* Unpack a 32-bit unsigned integer. */
int
nd_cpack_uint32(netdissect_options *ndo, struct cpack_state *cs, uint32_t *u)
{
const uint8_t *next;
if ((next = nd_cpack_align_and_reserve(cs, sizeof(*u))) == NULL)
return -1;
*u = GET_LE_U_4(next);
/* Move pointer past the uint32_t. */
cs->c_next = next + sizeof(*u);
return 0;
}
/* Unpack a 16-bit unsigned integer. */
/* Unpack a 32-bit signed integer. */
int
cpack_uint16(struct cpack_state *cs, uint16_t *u)
nd_cpack_int32(netdissect_options *ndo, struct cpack_state *cs, int32_t *u)
{
const uint8_t *next;
if ((next = cpack_align_and_reserve(cs, sizeof(*u))) == NULL)
if ((next = nd_cpack_align_and_reserve(cs, sizeof(*u))) == NULL)
return -1;
*u = EXTRACT_LE_16BITS(next);
*u = GET_LE_S_4(next);
/* Move pointer past the int32_t. */
cs->c_next = next + sizeof(*u);
return 0;
}
/* Unpack a 16-bit unsigned integer. */
int
nd_cpack_uint16(netdissect_options *ndo, struct cpack_state *cs, uint16_t *u)
{
const uint8_t *next;
if ((next = nd_cpack_align_and_reserve(cs, sizeof(*u))) == NULL)
return -1;
*u = GET_LE_U_2(next);
/* Move pointer past the uint16_t. */
cs->c_next = next + sizeof(*u);
return 0;
}
/* Unpack a 16-bit signed integer. */
int
nd_cpack_int16(netdissect_options *ndo, struct cpack_state *cs, int16_t *u)
{
const uint8_t *next;
if ((next = nd_cpack_align_and_reserve(cs, sizeof(*u))) == NULL)
return -1;
*u = GET_LE_S_2(next);
/* Move pointer past the int16_t. */
cs->c_next = next + sizeof(*u);
return 0;
}
/* Unpack an 8-bit unsigned integer. */
int
cpack_uint8(struct cpack_state *cs, uint8_t *u)
nd_cpack_uint8(netdissect_options *ndo, struct cpack_state *cs, uint8_t *u)
{
/* No space left? */
if ((size_t)(cs->c_next - cs->c_buf) >= cs->c_len)
return -1;
*u = *cs->c_next;
*u = GET_U_1(cs->c_next);
/* Move pointer past the uint8_t. */
cs->c_next++;
return 0;
}
/* Unpack an 8-bit signed integer. */
int
nd_cpack_int8(netdissect_options *ndo, struct cpack_state *cs, int8_t *u)
{
/* No space left? */
if ((size_t)(cs->c_next - cs->c_buf) >= cs->c_len)
return -1;
*u = GET_S_1(cs->c_next);
/* Move pointer past the int8_t. */
cs->c_next++;
return 0;
}

View File

@ -27,8 +27,10 @@
* OF SUCH DAMAGE.
*/
#ifndef _CPACK_H
#define _CPACK_H
#ifndef ND_CPACK_H
#define ND_CPACK_H
#include "netdissect.h"
struct cpack_state {
const uint8_t *c_buf;
@ -36,21 +38,20 @@ struct cpack_state {
size_t c_len;
};
int cpack_init(struct cpack_state *, const uint8_t *, size_t);
int nd_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 *);
int nd_cpack_uint8(netdissect_options *, struct cpack_state *, uint8_t *);
int nd_cpack_int8(netdissect_options *, struct cpack_state *, int8_t *);
int nd_cpack_uint16(netdissect_options *, struct cpack_state *, uint16_t *);
int nd_cpack_int16(netdissect_options *, struct cpack_state *, int16_t *);
int nd_cpack_uint32(netdissect_options *, struct cpack_state *, uint32_t *);
int nd_cpack_int32(netdissect_options *, struct cpack_state *, int32_t *);
int nd_cpack_uint64(netdissect_options *, struct cpack_state *, uint64_t *);
int nd_cpack_int64(netdissect_options *, struct cpack_state *, int64_t *);
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);
const uint8_t *nd_cpack_next_boundary(const uint8_t *buf, const uint8_t *p, size_t alignment);
const uint8_t *nd_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))
#define cpack_int32(__s, __p) cpack_uint32((__s), (uint32_t*)(__p))
#define cpack_int64(__s, __p) cpack_uint64((__s), (uint64_t*)(__p))
extern int nd_cpack_advance(struct cpack_state *, const size_t);
extern int cpack_advance(struct cpack_state *, const size_t);
#endif /* _CPACK_H */
#endif /* ND_CPACK_H */

View File

@ -0,0 +1,186 @@
/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */
/*
* Copyright (c) 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Computer Systems
* Engineering Group at Lawrence Berkeley Laboratory.
* 4. Neither the name of the University nor of the Laboratory may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _diag_control_h
#define _diag_control_h
#include "compiler-tests.h"
#ifndef _MSC_VER
/*
* Clang and GCC both support this way of putting pragmas into #defines.
* We don't use it unless we have a compiler that supports it; the
* warning-suppressing pragmas differ between Clang and GCC, so we test
* for both of those separately.
*/
#define DIAG_DO_PRAGMA(x) _Pragma (#x)
#endif
/*
* XL C 12.1 and 13.1 for AIX require no attention in this department.
* XL C 16.1 defines both __GNUC__ and __clang__, so has to be tested first.
*/
#if ND_IS_AT_LEAST_XL_C_VERSION(16,1)
/*
* See respective Clang note below.
*/
#define DIAG_OFF_ASSIGN_ENUM \
DIAG_DO_PRAGMA(clang diagnostic push) \
DIAG_DO_PRAGMA(clang diagnostic ignored "-Wassign-enum")
#define DIAG_ON_ASSIGN_ENUM \
DIAG_DO_PRAGMA(clang diagnostic pop)
#define DIAG_OFF_CAST_QUAL
#define DIAG_ON_CAST_QUAL
#define DIAG_OFF_DEPRECATION
#define DIAG_ON_DEPRECATION
/*
* The current clang compilers also define __GNUC__ and __GNUC_MINOR__
* thus we need to test the clang case before the GCC one
*/
#elif ND_IS_AT_LEAST_CLANG_VERSION(2,8)
/*
* Clang complains if you OR together multiple enum values of a
* given enum type and them pass it as an argument of that enum
* type. Some libcap-ng routines use enums to define bit flags;
* we want to squelch the warnings that produces.
*/
#define DIAG_OFF_ASSIGN_ENUM \
DIAG_DO_PRAGMA(clang diagnostic push) \
DIAG_DO_PRAGMA(clang diagnostic ignored "-Wassign-enum")
#define DIAG_ON_ASSIGN_ENUM \
DIAG_DO_PRAGMA(clang diagnostic pop)
/*
* It also legitimately complains about some code in the BSD
* getopt_long() - that code explicitly and deliberately
* violates the contract by permuting the argument vector
* (declared as char const *argv[], meaning "I won't change
* the vector by changing any of its elements), as do the
* GNU and Solaris getopt_long(). This is documented in the
* man pages for all versions; it can be suppressed by setting
* the environment variable POSIXLY_CORRECT or by putting a "+"
* at the beginning of the option string.
*
* We suppress the warning.
*/
#define DIAG_OFF_CAST_QUAL \
DIAG_DO_PRAGMA(clang diagnostic push) \
DIAG_DO_PRAGMA(clang diagnostic ignored "-Wcast-qual")
#define DIAG_ON_CAST_QUAL \
DIAG_DO_PRAGMA(clang diagnostic pop)
/*
* Suppress deprecation warnings.
*/
#define DIAG_OFF_DEPRECATION \
DIAG_DO_PRAGMA(clang diagnostic push) \
DIAG_DO_PRAGMA(clang diagnostic ignored "-Wdeprecated-declarations")
#define DIAG_ON_DEPRECATION \
DIAG_DO_PRAGMA(clang diagnostic pop)
/*
* Clang supports the generic C11 extension even if run with the -std=gnu99
* flag, which leads FreeBSD <sys/cdefs.h> to use the extension, which
* results in Clang emitting a -Wc11-extensions warning. The warning is not
* documented in the user manual, but it happens with Clang 10.0.1 on
* FreeBSD 12.2, so let's use that as a reference.
*/
#if ND_IS_AT_LEAST_CLANG_VERSION(10,0)
#define DIAG_OFF_C11_EXTENSIONS \
DIAG_DO_PRAGMA(clang diagnostic push) \
DIAG_DO_PRAGMA(clang diagnostic ignored "-Wc11-extensions")
#define DIAG_ON_C11_EXTENSIONS \
DIAG_DO_PRAGMA(clang diagnostic pop)
#endif
#elif ND_IS_AT_LEAST_GNUC_VERSION(4,2)
/* GCC apparently doesn't complain about ORing enums together. */
#define DIAG_OFF_ASSIGN_ENUM
#define DIAG_ON_ASSIGN_ENUM
/*
* It does, however, complain about casting away constness in
* missing/getopt_long.c.
*/
#define DIAG_OFF_CAST_QUAL \
DIAG_DO_PRAGMA(GCC diagnostic push) \
DIAG_DO_PRAGMA(GCC diagnostic ignored "-Wcast-qual")
#define DIAG_ON_CAST_QUAL \
DIAG_DO_PRAGMA(GCC diagnostic pop)
/*
* Suppress deprecation warnings.
*/
#define DIAG_OFF_DEPRECATION \
DIAG_DO_PRAGMA(GCC diagnostic push) \
DIAG_DO_PRAGMA(GCC diagnostic ignored "-Wdeprecated-declarations")
#define DIAG_ON_DEPRECATION \
DIAG_DO_PRAGMA(GCC diagnostic pop)
/*
* GCC supports -Wc99-c11-compat since version 5.1.0, but the warning does
* not trigger for now, so let's just leave it be.
*/
#else
#define DIAG_OFF_ASSIGN_ENUM
#define DIAG_ON_ASSIGN_ENUM
#define DIAG_OFF_CAST_QUAL
#define DIAG_ON_CAST_QUAL
#define DIAG_OFF_DEPRECATION
#define DIAG_ON_DEPRECATION
#endif
#ifndef DIAG_OFF_C11_EXTENSIONS
#define DIAG_OFF_C11_EXTENSIONS
#endif
#ifndef DIAG_ON_C11_EXTENSIONS
#define DIAG_ON_C11_EXTENSIONS
#endif
/*
* GCC needs this on AIX for longjmp().
*/
#if ND_IS_AT_LEAST_GNUC_VERSION(5,1)
/*
* Beware that the effect of this builtin is more than just squelching the
* warning! GCC trusts it enough for the process to segfault if the control
* flow reaches the builtin (an infinite empty loop in the same context would
* squelch the warning and ruin the process too, albeit in a different way).
* So please remember to use this very carefully.
*/
#define ND_UNREACHABLE __builtin_unreachable();
#else
#define ND_UNREACHABLE
#endif
#endif /* _diag_control_h */

View File

@ -0,0 +1,22 @@
# Compiling tcpdump on NetBSD
NetBSD has two libpcap libraries: one that is always installed as a part of the
OS and another that can be installed as a package from pkgsrc. Also the usual
method of compiling with the upstream libpcap in `../libpcap` is available.
GCC, Clang, Autoconf and CMake are presumed to work, if this is not the case,
please report a bug as explained in the
[guidelines for contributing](../CONTRIBUTING.md).
## NetBSD 9.3
* Upstream libpcap works.
* OS libpcap works.
* pkgsrc libpcap works.
## NetBSD 9.2, 9.1 and 9.0
* Upstream libpcap works.
* OS libpcap cannot be used due to
[this bug](https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=55901).

View File

@ -0,0 +1,200 @@
Building tcpdump on Windows with Visual Studio
==============================================
Unlike the UN*Xes on which libpcap can capture network traffic, Windows
has no network traffic capture mechanism that libpcap can use.
Therefore, libpcap requires a driver, and a library to access the
driver, provided by the Npcap or WinPcap projects.
Those projects include versions of libpcap built to use that driver and
library; these instructions are for people who want to build libpcap
source releases, or libpcap from the Git repository, as a replacement
for the version provided with Npcap or WinPcap.
Npcap and WinPcap SDK
---------------------
In order to build tcpdump, you will need to download Npcap and its
software development kit (SDK) or WinPcap and its software development
kit.
Npcap is currently being developed and maintained, and offers many
additional capabilities that WinPcap does not.
WinPcap is no longer being developed or maintained; it should be used
only if there is some other requirement to use it rather than Npcap,
such as a requirement to support versions of Windows earlier than
Windows Vista, which is the earliest version supported by Npcap.
Npcap and its SDK can be downloaded from its [home page](https://npcap.com).
The SDK is a ZIP archive; create a folder on your `C:` drive, e.g.
`C:\npcap-sdk`, and put the contents of the ZIP archive into that folder.
The WinPcap installer can be downloaded from
[here](https://www.winpcap.org/install/default.htm)
and the WinPcap Developer's Kit can be downloaded from
[here](https://www.winpcap.org/devel.htm).
Required build tools
--------------------
The Developer's Kit is a ZIP archive; it contains a folder named
`WpdPack`, which you should place on your `C:` drive, e.g. `C:\WpdPack`.
Building tcpdump on Windows requires Visual Studio 2015 or later. The
Community Edition of Visual Studio can be downloaded at no cost from
[here](https://visualstudio.microsoft.com).
Additional tools are also required. Chocolatey is a package manager for
Windows with which those tools, and other tools, can be installed; it
can be downloaded from [here](https://chocolatey.org).
It is a command-line tool; a GUI tool, Chocolatey GUI, is provided as a
Chocolatey package, which can be installed from the command line:
```
choco install chocolateygui
```
For convenience, the `choco install` command can be run with the `-y`
flag, forcing it to automatically answer all questions asked of the user
with "yes":
```
choco install -y chocolateygui
```
The required tools are:
### CMake ###
libpcap does not provide supported project files for Visual Studio
(there are currently unsupported project files provided, but we do not
guarantee that they will work or that we will continue to provide them).
It does provide files for CMake, which is a cross-platform tool that
runs on UN\*Xes and on Windows and that can generate project files for
UN\*X Make, the Ninja build system, and Visual Studio, among other build
systems.
Visual Studio 2015 does not provide CMake; an installer can be
downloaded from [here](https://cmake.org/download/).
When you run the installer, you should choose to add CMake to the system
`PATH` for all users and to create the desktop icon.
CMake can also be installed as the Chocolatey package `cmake`:
```
choco install -y cmake
```
Visual Studio 2017 and later provide CMake, so you will not need to
install CMake if you have installed Visual Studio 2017 or later. They
include built-in support for CMake-based projects as described
[here](https://devblogs.microsoft.com/cppblog/cmake-support-in-visual-studio/).
For Visual Studio 2017, make sure "Visual C++ tools for CMake" is
installed; for Visual Studio 2019, make sure "C++ CMake tools for
Windows" is installed.
Git
---
An optional tool, required only if you will be building from a Git
repository rather than from a release source tarball, is Git. Git is
provided as an optional installation component, "Git for Windows", with
Visual Studio 2017 and later.
Building from the Visual Studio GUI
-----------------------------------
### Visual Studio 2017 ###
Open the folder containing the libpcap source with Open > Folder.
Visual Studio will run CMake; however, you will need to indicate where
the Npcap or WinPcap SDK is installed.
To do this, go to Project > "Change CMake Settings" > tcpdump and:
Choose which configuration type to build, if you don't want the default
Debug build.
In the CMakeSettings.json tab, change cmakeCommandArgs to include
```
-DPacket_ROOT={path-to-sdk}
```
where `{path-to-sdk}` is the path of the directory containing the Npcap or
WinPcap SDK. Note that backslashes in the path must be specified as two
backslashes.
Save the configuration changes with File > "Save CMakeSettings.json" or
with Control-S.
Visual Studio will then re-run CMake. If that completes without errors,
you can build with CMake > "Build All".
### Visual Studio 2019 ###
Open the folder containing the libpcap source with Open > Folder.
Visual Studio will run CMake; however, you will need to indicate where
the Npcap or WinPcap SDK is installed.
To do this, go to Project > "CMake Settings for tcpdump" and:
Choose which configuration type to build, if you don't want the default
Debug build.
Scroll down to "Cmake variables and cache", scroll through the list
looking for the entry for Packet_ROOT, and either type in the path of
the directory containing the Npcap or WinPcap SDK or use the "Browse..."
button to browse for that directory.
Save the configuration changes with File > "Save CMakeSettings.json" or
with Control-S.
Visual Studio will then re-run CMake. If that completes without errors,
you can build with Build > "Build All".
Building from the command line
------------------------------
Start the appropriate Native Tools command line prompt.
Change to the directory into which you want to build tcpdump, possibly
after creating it first. One choice is to create it as a subdirectory
of the tcpdump source directory.
Run the command
```
cmake "-DPacket_ROOT={path-to-sdk}" -G {generator} {path-to-tcpdump-source}
```
`{path-to-sdk}` is the path of the directory containing the Npcap or
WinPcap SDK.
`{generator}` is the string "Visual Studio N YYYY", where `N` is the
version of Visual Studio and `YYYY` is the year number for that version;
if you are building a 64-bit version of tcpdump, `YYYY` must be followed
by a space and "Win64". For example, to build a 32-bit version of
tcpdump with Visual Studio 2017, `{generator}` would be "Visual Studio
15 2017" and to build a 64-bit version of tcpdump with Visual Studio
2017, `{generator}` would be "Visual Studio 15 2017 Win64".
`{path-to-tcpdump-source}` is the pathname of the top-level source
directory for tcpdump.
Run the command
```
msbuild /m /nologo /p:Configuration={configuration} tcpdump.sln
```
where `{configuration}` can be "Release", "Debug", or "RelWithDebInfo".
Building with MinGW
-------------------
(XXX - this should be added)

View File

@ -0,0 +1,17 @@
# Compiling tcpdump on AIX
* Autoconf works everywhere.
## AIX 7.1/POWER7
* Only local libpcap is suitable.
* CMake 3.16.0 does not work.
* GCC 8.3.0 and XL C 12.1.0.0 work.
* System m4 does not work, GNU m4 1.4.17 works.
## AIX 7.2/POWER8
* Only local libpcap is suitable.
* GCC 7.2.0 and XL C 13.1.3.6 work.
* System m4 does not work, GNU m4 1.4.17 works.

View File

@ -0,0 +1,41 @@
# Compiling tcpdump on Solaris and related OSes
* Autoconf works everywhere.
## OmniOS r151042/AMD64
* Both system and local libpcap are suitable.
* CMake 3.23.1 works.
* GCC 11.2.0 and Clang 14.0.3 work.
## OpenIndiana 2021.04/AMD64
* Both system and local libpcap are suitable.
* CMake 3.21.1 works.
* GCC 7.5.0 and GCC 10.3.0 work, Clang 9.0.1 works.
For reference, the tests were done using a system installed from
`OI-hipster-text-20210430.iso` plus the following packages:
```shell
xargs -L1 pkg install <<ENDOFTEXT
developer/build/autoconf
developer/build/cmake
developer/gcc-10
developer/clang-90
ENDOFTEXT
```
## Oracle Solaris 11.4.42/AMD64
* Both system and local libpcap are suitable.
* GCC 11.2 and Clang 11.0 work.
For reference, the tests were done on a VM booted from `sol-11_4-vbox.ova`
and updated to 11.4.42.111.0 plus the following packages:
```shell
xargs -L1 pkg install <<ENDOFTEXT
developer/build/autoconf
developer/gcc
developer/llvm/clang
ENDOFTEXT
```

View File

@ -19,6 +19,13 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
/*
* Maximum length of the length field in an Ethernet header; any value
* greater than this is not a length value, so it's either an Ethernet
* type or an invalid value.
*/
#define MAX_ETHERNET_LENGTH_VAL 1500
/*
* Ethernet types.
*
@ -106,8 +113,8 @@
#endif
/* see:
http://en.wikipedia.org/wiki/IEEE_802.1Q
and http://en.wikipedia.org/wiki/QinQ
https://en.wikipedia.org/wiki/IEEE_802.1Q
and https://en.wikipedia.org/wiki/QinQ
*/
#ifndef ETHERTYPE_8021Q9100
#define ETHERTYPE_8021Q9100 0x9100
@ -118,6 +125,9 @@
#ifndef ETHERTYPE_8021QinQ
#define ETHERTYPE_8021QinQ 0x88a8
#endif
#ifndef ETHERTYPE_MACSEC
#define ETHERTYPE_MACSEC 0x88e5
#endif
#ifndef ETHERTYPE_IPX
#define ETHERTYPE_IPX 0x8137
#endif
@ -145,6 +155,9 @@
#ifndef ETHERTYPE_PPPOES
#define ETHERTYPE_PPPOES 0x8864
#endif
#ifndef ETHERTYPE_NSH
#define ETHERTYPE_NSH 0x894F
#endif
#ifndef ETHERTYPE_PPPOED2
#define ETHERTYPE_PPPOED2 0x3c12
#endif
@ -161,13 +174,16 @@
#define ETHERTYPE_LLDP 0x88cc
#endif
#ifndef ETHERTYPE_EAPOL
#define ETHERTYPE_EAPOL 0x888e
#define ETHERTYPE_EAPOL 0x888e
#endif
#ifndef ETHERTYPE_RRCP
#define ETHERTYPE_RRCP 0x8899
#ifndef ETHERTYPE_REALTEK
#define ETHERTYPE_REALTEK 0x8899 /* Realtek layer 2 protocols and switch tags */
#endif
#ifndef ETHERTYPE_AOE
#define ETHERTYPE_AOE 0x88a2
#define ETHERTYPE_AOE 0x88a2
#endif
#ifndef ETHERTYPE_PTP
#define ETHERTYPE_PTP 0x88f7
#endif
#ifndef ETHERTYPE_LOOPBACK
#define ETHERTYPE_LOOPBACK 0x9000
@ -196,8 +212,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 */
#ifndef ETHERTYPE_ARISTA
#define ETHERTYPE_ARISTA 0xd28b /* Arista Networks vendor specific EtherType */
#endif
extern const struct tok ethertype_values[];

View File

@ -19,18 +19,25 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef EXTRACT_H
#define EXTRACT_H
#include <string.h>
/*
* For 8-bit values; provided for the sake of completeness. Byte order
* For 8-bit values; needed to fetch a one-byte value. Byte order
* isn't relevant, and alignment isn't an issue.
*/
#define EXTRACT_8BITS(p) (*(p))
#define EXTRACT_LE_8BITS(p) (*(p))
#define EXTRACT_U_1(p) ((uint8_t)(*(p)))
#define EXTRACT_S_1(p) ((int8_t)(*(p)))
/*
* Inline functions or macros to extract possibly-unaligned big-endian
* integral values.
*/
#include "funcattrs.h"
#include "netdissect.h"
#include "diag-control.h"
/*
* If we have versions of GCC or Clang that support an __attribute__
@ -62,29 +69,91 @@
#define UNALIGNED_OK
#endif
#ifdef LBL_ALIGN
#if (defined(__i386__) || defined(_M_IX86) || defined(__X86__) || defined(__x86_64__) || defined(_M_X64)) || \
(defined(__m68k__) && (!defined(__mc68000__) && !defined(__mc68010__))) || \
(defined(__ppc__) || defined(__ppc64__) || defined(_M_PPC) || defined(_ARCH_PPC) || defined(_ARCH_PPC64)) || \
(defined(__s390__) || defined(__s390x__) || defined(__zarch__))
/*
* The processor doesn't natively handle unaligned loads.
* The processor natively handles unaligned loads, so we can just
* cast the pointer and fetch through it.
*
* XXX - are those all the x86 tests we need?
* XXX - are those the only 68k tests we need not to generated
* unaligned accesses if the target is the 68000 or 68010?
* XXX - are there any tests we don't need, because some definitions are for
* compilers that also predefine the GCC symbols?
* XXX - do we need to test for both 32-bit and 64-bit versions of those
* architectures in all cases?
*/
#if defined(__GNUC__) && defined(HAVE___ATTRIBUTE__) && \
(defined(__alpha) || defined(__alpha__) || \
defined(__mips) || defined(__mips__))
UNALIGNED_OK static inline uint16_t
EXTRACT_BE_U_2(const void *p)
{
return ((uint16_t)ntohs(*(const uint16_t *)(p)));
}
UNALIGNED_OK static inline int16_t
EXTRACT_BE_S_2(const void *p)
{
return ((int16_t)ntohs(*(const int16_t *)(p)));
}
UNALIGNED_OK static inline uint32_t
EXTRACT_BE_U_4(const void *p)
{
return ((uint32_t)ntohl(*(const uint32_t *)(p)));
}
UNALIGNED_OK static inline int32_t
EXTRACT_BE_S_4(const void *p)
{
return ((int32_t)ntohl(*(const int32_t *)(p)));
}
UNALIGNED_OK static inline uint64_t
EXTRACT_BE_U_8(const void *p)
{
return ((uint64_t)(((uint64_t)ntohl(*((const uint32_t *)(p) + 0))) << 32 |
((uint64_t)ntohl(*((const uint32_t *)(p) + 1))) << 0));
}
UNALIGNED_OK static inline int64_t
EXTRACT_BE_S_8(const void *p)
{
return ((int64_t)(((int64_t)ntohl(*((const uint32_t *)(p) + 0))) << 32 |
((uint64_t)ntohl(*((const uint32_t *)(p) + 1))) << 0));
}
/*
* This is a GCC-compatible compiler and we have __attribute__, which
* we assume that mean we have __attribute__((packed)), and this is
* MIPS or Alpha, which has instructions that can help when doing
* unaligned loads.
* Extract an IPv4 address, which is in network byte order, and not
* necessarily aligned, and provide the result in host byte order.
*/
UNALIGNED_OK static inline uint32_t
EXTRACT_IPV4_TO_HOST_ORDER(const void *p)
{
return ((uint32_t)ntohl(*(const uint32_t *)(p)));
}
#elif ND_IS_AT_LEAST_GNUC_VERSION(2,0) && \
(defined(__alpha) || defined(__alpha__) || \
defined(__mips) || defined(__mips__))
/*
* This is MIPS or Alpha, which don't natively handle unaligned loads,
* but which have instructions that can help when doing unaligned
* loads, and this is GCC 2.0 or later or a compiler that claims to
* be GCC 2.0 or later, which we assume that mean we have
* __attribute__((packed)), which we can use to convince the compiler
* to generate those instructions.
*
* Declare packed structures containing a uint16_t and a uint32_t,
* cast the pointer to point to one of those, and fetch through it;
* the GCC manual doesn't appear to explicitly say that
* __attribute__((packed)) causes the compiler to generate unaligned-safe
* code, but it apppears to do so.
* code, but it appears to do so.
*
* We do this in case the compiler can generate code using those
* instructions to do an unaligned load and pass stuff to "ntohs()" or
* "ntohl()", which might be better than than the code to fetch the
* "ntohl()", which might be better than the code to fetch the
* bytes one at a time and assemble them. (That might not be the
* case on a little-endian platform, such as DEC's MIPS machines and
* Alpha machines, where "ntohs()" and "ntohl()" might not be done
@ -124,46 +193,101 @@ typedef struct {
uint16_t val;
} __attribute__((packed)) unaligned_uint16_t;
typedef struct {
int16_t val;
} __attribute__((packed)) unaligned_int16_t;
typedef struct {
uint32_t val;
} __attribute__((packed)) unaligned_uint32_t;
typedef struct {
int32_t val;
} __attribute__((packed)) unaligned_int32_t;
UNALIGNED_OK static inline uint16_t
EXTRACT_16BITS(const void *p)
EXTRACT_BE_U_2(const void *p)
{
return ((uint16_t)ntohs(((const unaligned_uint16_t *)(p))->val));
}
UNALIGNED_OK static inline int16_t
EXTRACT_BE_S_2(const void *p)
{
return ((int16_t)ntohs(((const unaligned_int16_t *)(p))->val));
}
UNALIGNED_OK static inline uint32_t
EXTRACT_32BITS(const void *p)
EXTRACT_BE_U_4(const void *p)
{
return ((uint32_t)ntohl(((const unaligned_uint32_t *)(p))->val));
}
UNALIGNED_OK static inline int32_t
EXTRACT_BE_S_4(const void *p)
{
return ((int32_t)ntohl(((const unaligned_int32_t *)(p))->val));
}
UNALIGNED_OK static inline uint64_t
EXTRACT_64BITS(const void *p)
EXTRACT_BE_U_8(const void *p)
{
return ((uint64_t)(((uint64_t)ntohl(((const unaligned_uint32_t *)(p) + 0)->val)) << 32 |
((uint64_t)ntohl(((const unaligned_uint32_t *)(p) + 1)->val)) << 0));
}
#else /* have to do it a byte at a time */
UNALIGNED_OK static inline int64_t
EXTRACT_BE_S_8(const void *p)
{
return ((int64_t)(((uint64_t)ntohl(((const unaligned_uint32_t *)(p) + 0)->val)) << 32 |
((uint64_t)ntohl(((const unaligned_uint32_t *)(p) + 1)->val)) << 0));
}
/*
* This isn't a GCC-compatible compiler, we don't have __attribute__,
* Extract an IPv4 address, which is in network byte order, and not
* necessarily aligned, and provide the result in host byte order.
*/
UNALIGNED_OK static inline uint32_t
EXTRACT_IPV4_TO_HOST_ORDER(const void *p)
{
return ((uint32_t)ntohl(((const unaligned_uint32_t *)(p))->val));
}
#else
/*
* This architecture doesn't natively support unaligned loads, and either
* this isn't a GCC-compatible compiler, we don't have __attribute__,
* or we do but we don't know of any better way with this instruction
* set to do unaligned loads, so do unaligned loads of big-endian
* quantities the hard way - fetch the bytes one at a time and
* assemble them.
*
* XXX - ARM is a special case. ARMv1 through ARMv5 didn't suppory
* unaligned loads; ARMv6 and later support it *but* have a bit in
* the system control register that the OS can set and that causes
* unaligned loads to fault rather than succeeding.
*
* At least some OSes may set that flag, so we do *not* treat ARM
* as supporting unaligned loads. If your OS supports them on ARM,
* and you want to use them, please update the tests in the #if above
* to check for ARM *and* for your OS.
*/
#define EXTRACT_16BITS(p) \
#define EXTRACT_BE_U_2(p) \
((uint16_t)(((uint16_t)(*((const uint8_t *)(p) + 0)) << 8) | \
((uint16_t)(*((const uint8_t *)(p) + 1)) << 0)))
#define EXTRACT_32BITS(p) \
#define EXTRACT_BE_S_2(p) \
((int16_t)(((uint16_t)(*((const uint8_t *)(p) + 0)) << 8) | \
((uint16_t)(*((const uint8_t *)(p) + 1)) << 0)))
#define EXTRACT_BE_U_4(p) \
((uint32_t)(((uint32_t)(*((const uint8_t *)(p) + 0)) << 24) | \
((uint32_t)(*((const uint8_t *)(p) + 1)) << 16) | \
((uint32_t)(*((const uint8_t *)(p) + 2)) << 8) | \
((uint32_t)(*((const uint8_t *)(p) + 3)) << 0)))
#define EXTRACT_64BITS(p) \
#define EXTRACT_BE_S_4(p) \
((int32_t)(((uint32_t)(*((const uint8_t *)(p) + 0)) << 24) | \
((uint32_t)(*((const uint8_t *)(p) + 1)) << 16) | \
((uint32_t)(*((const uint8_t *)(p) + 2)) << 8) | \
((uint32_t)(*((const uint8_t *)(p) + 3)) << 0)))
#define EXTRACT_BE_U_8(p) \
((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 56) | \
((uint64_t)(*((const uint8_t *)(p) + 1)) << 48) | \
((uint64_t)(*((const uint8_t *)(p) + 2)) << 40) | \
@ -172,47 +296,133 @@ EXTRACT_64BITS(const void *p)
((uint64_t)(*((const uint8_t *)(p) + 5)) << 16) | \
((uint64_t)(*((const uint8_t *)(p) + 6)) << 8) | \
((uint64_t)(*((const uint8_t *)(p) + 7)) << 0)))
#endif /* must special-case unaligned accesses */
#else /* LBL_ALIGN */
#define EXTRACT_BE_S_8(p) \
((int64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 56) | \
((uint64_t)(*((const uint8_t *)(p) + 1)) << 48) | \
((uint64_t)(*((const uint8_t *)(p) + 2)) << 40) | \
((uint64_t)(*((const uint8_t *)(p) + 3)) << 32) | \
((uint64_t)(*((const uint8_t *)(p) + 4)) << 24) | \
((uint64_t)(*((const uint8_t *)(p) + 5)) << 16) | \
((uint64_t)(*((const uint8_t *)(p) + 6)) << 8) | \
((uint64_t)(*((const uint8_t *)(p) + 7)) << 0)))
/*
* The processor natively handles unaligned loads, so we can just
* cast the pointer and fetch through it.
* Extract an IPv4 address, which is in network byte order, and not
* necessarily aligned, and provide the result in host byte order.
*/
static inline uint16_t UNALIGNED_OK
EXTRACT_16BITS(const void *p)
#define EXTRACT_IPV4_TO_HOST_ORDER(p) \
((uint32_t)(((uint32_t)(*((const uint8_t *)(p) + 0)) << 24) | \
((uint32_t)(*((const uint8_t *)(p) + 1)) << 16) | \
((uint32_t)(*((const uint8_t *)(p) + 2)) << 8) | \
((uint32_t)(*((const uint8_t *)(p) + 3)) << 0)))
#endif /* unaligned access checks */
/*
* Extract numerical values in *host* byte order. (Some metadata
* headers are in the byte order of the host that wrote the file,
* and libpcap translate them to the byte order of the host
* reading the file. This means that if a program on that host
* reads with libpcap and writes to a new file, the new file will
* be written in the byte order of the host writing the file. Thus,
* the magic number in pcap files and byte-order magic in pcapng
* files can be used to determine the byte order in those metadata
* headers.)
*
* XXX - on platforms that can do unaligned accesses, just cast and
* dereference the pointer.
*/
static inline uint16_t
EXTRACT_HE_U_2(const void *p)
{
return ((uint16_t)ntohs(*(const uint16_t *)(p)));
uint16_t val;
UNALIGNED_MEMCPY(&val, p, sizeof(uint16_t));
return val;
}
static inline uint32_t UNALIGNED_OK
EXTRACT_32BITS(const void *p)
static inline int16_t
EXTRACT_HE_S_2(const void *p)
{
return ((uint32_t)ntohl(*(const uint32_t *)(p)));
int16_t val;
UNALIGNED_MEMCPY(&val, p, sizeof(int16_t));
return val;
}
static inline uint64_t UNALIGNED_OK
EXTRACT_64BITS(const void *p)
static inline uint32_t
EXTRACT_HE_U_4(const void *p)
{
return ((uint64_t)(((uint64_t)ntohl(*((const uint32_t *)(p) + 0))) << 32 |
((uint64_t)ntohl(*((const uint32_t *)(p) + 1))) << 0));
uint32_t val;
UNALIGNED_MEMCPY(&val, p, sizeof(uint32_t));
return val;
}
#endif /* LBL_ALIGN */
static inline int32_t
EXTRACT_HE_S_4(const void *p)
{
int32_t val;
#define EXTRACT_24BITS(p) \
UNALIGNED_MEMCPY(&val, p, sizeof(int32_t));
return val;
}
/*
* Extract an IPv4 address, which is in network byte order, and which
* is not necessarily aligned on a 4-byte boundary, and provide the
* result in network byte order.
*
* This works the same way regardless of the host's byte order.
*/
static inline uint32_t
EXTRACT_IPV4_TO_NETWORK_ORDER(const void *p)
{
uint32_t addr;
UNALIGNED_MEMCPY(&addr, p, sizeof(uint32_t));
return addr;
}
/*
* Non-power-of-2 sizes.
*/
#define EXTRACT_BE_U_3(p) \
((uint32_t)(((uint32_t)(*((const uint8_t *)(p) + 0)) << 16) | \
((uint32_t)(*((const uint8_t *)(p) + 1)) << 8) | \
((uint32_t)(*((const uint8_t *)(p) + 2)) << 0)))
#define EXTRACT_40BITS(p) \
#define EXTRACT_BE_S_3(p) \
(((*((const uint8_t *)(p) + 0)) & 0x80) ? \
((int32_t)(((uint32_t)(*((const uint8_t *)(p) + 0)) << 16) | \
((uint32_t)(*((const uint8_t *)(p) + 1)) << 8) | \
((uint32_t)(*((const uint8_t *)(p) + 2)) << 0))) : \
((int32_t)(0xFF000000U | \
((uint32_t)(*((const uint8_t *)(p) + 0)) << 16) | \
((uint32_t)(*((const uint8_t *)(p) + 1)) << 8) | \
((uint32_t)(*((const uint8_t *)(p) + 2)) << 0))))
#define EXTRACT_BE_U_5(p) \
((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 32) | \
((uint64_t)(*((const uint8_t *)(p) + 1)) << 24) | \
((uint64_t)(*((const uint8_t *)(p) + 2)) << 16) | \
((uint64_t)(*((const uint8_t *)(p) + 3)) << 8) | \
((uint64_t)(*((const uint8_t *)(p) + 4)) << 0)))
#define EXTRACT_48BITS(p) \
#define EXTRACT_BE_S_5(p) \
(((*((const uint8_t *)(p) + 0)) & 0x80) ? \
((int64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 32) | \
((uint64_t)(*((const uint8_t *)(p) + 1)) << 24) | \
((uint64_t)(*((const uint8_t *)(p) + 2)) << 16) | \
((uint64_t)(*((const uint8_t *)(p) + 3)) << 8) | \
((uint64_t)(*((const uint8_t *)(p) + 4)) << 0))) : \
((int64_t)(INT64_T_CONSTANT(0xFFFFFF0000000000U) | \
((uint64_t)(*((const uint8_t *)(p) + 0)) << 32) | \
((uint64_t)(*((const uint8_t *)(p) + 1)) << 24) | \
((uint64_t)(*((const uint8_t *)(p) + 2)) << 16) | \
((uint64_t)(*((const uint8_t *)(p) + 3)) << 8) | \
((uint64_t)(*((const uint8_t *)(p) + 4)) << 0))))
#define EXTRACT_BE_U_6(p) \
((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 40) | \
((uint64_t)(*((const uint8_t *)(p) + 1)) << 32) | \
((uint64_t)(*((const uint8_t *)(p) + 2)) << 24) | \
@ -220,7 +430,23 @@ EXTRACT_64BITS(const void *p)
((uint64_t)(*((const uint8_t *)(p) + 4)) << 8) | \
((uint64_t)(*((const uint8_t *)(p) + 5)) << 0)))
#define EXTRACT_56BITS(p) \
#define EXTRACT_BE_S_6(p) \
(((*((const uint8_t *)(p) + 0)) & 0x80) ? \
((int64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 40) | \
((uint64_t)(*((const uint8_t *)(p) + 1)) << 32) | \
((uint64_t)(*((const uint8_t *)(p) + 2)) << 24) | \
((uint64_t)(*((const uint8_t *)(p) + 3)) << 16) | \
((uint64_t)(*((const uint8_t *)(p) + 4)) << 8) | \
((uint64_t)(*((const uint8_t *)(p) + 5)) << 0))) : \
((int64_t)(INT64_T_CONSTANT(0xFFFFFFFF00000000U) | \
((uint64_t)(*((const uint8_t *)(p) + 0)) << 40) | \
((uint64_t)(*((const uint8_t *)(p) + 1)) << 32) | \
((uint64_t)(*((const uint8_t *)(p) + 2)) << 24) | \
((uint64_t)(*((const uint8_t *)(p) + 3)) << 16) | \
((uint64_t)(*((const uint8_t *)(p) + 4)) << 8) | \
((uint64_t)(*((const uint8_t *)(p) + 5)) << 0))))
#define EXTRACT_BE_U_7(p) \
((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 48) | \
((uint64_t)(*((const uint8_t *)(p) + 1)) << 40) | \
((uint64_t)(*((const uint8_t *)(p) + 2)) << 32) | \
@ -229,23 +455,45 @@ EXTRACT_64BITS(const void *p)
((uint64_t)(*((const uint8_t *)(p) + 5)) << 8) | \
((uint64_t)(*((const uint8_t *)(p) + 6)) << 0)))
#define EXTRACT_BE_S_7(p) \
(((*((const uint8_t *)(p) + 0)) & 0x80) ? \
((int64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 48) | \
((uint64_t)(*((const uint8_t *)(p) + 1)) << 40) | \
((uint64_t)(*((const uint8_t *)(p) + 2)) << 32) | \
((uint64_t)(*((const uint8_t *)(p) + 3)) << 24) | \
((uint64_t)(*((const uint8_t *)(p) + 4)) << 16) | \
((uint64_t)(*((const uint8_t *)(p) + 5)) << 8) | \
((uint64_t)(*((const uint8_t *)(p) + 6)) << 0))) : \
((int64_t)(INT64_T_CONSTANT(0xFFFFFFFFFF000000U) | \
((uint64_t)(*((const uint8_t *)(p) + 0)) << 48) | \
((uint64_t)(*((const uint8_t *)(p) + 1)) << 40) | \
((uint64_t)(*((const uint8_t *)(p) + 2)) << 32) | \
((uint64_t)(*((const uint8_t *)(p) + 3)) << 24) | \
((uint64_t)(*((const uint8_t *)(p) + 4)) << 16) | \
((uint64_t)(*((const uint8_t *)(p) + 5)) << 8) | \
((uint64_t)(*((const uint8_t *)(p) + 6)) << 0))))
/*
* Macros to extract possibly-unaligned little-endian integral values.
* XXX - do loads on little-endian machines that support unaligned loads?
*/
#define EXTRACT_LE_16BITS(p) \
#define EXTRACT_LE_U_2(p) \
((uint16_t)(((uint16_t)(*((const uint8_t *)(p) + 1)) << 8) | \
((uint16_t)(*((const uint8_t *)(p) + 0)) << 0)))
#define EXTRACT_LE_32BITS(p) \
#define EXTRACT_LE_S_2(p) \
((int16_t)(((uint16_t)(*((const uint8_t *)(p) + 1)) << 8) | \
((uint16_t)(*((const uint8_t *)(p) + 0)) << 0)))
#define EXTRACT_LE_U_4(p) \
((uint32_t)(((uint32_t)(*((const uint8_t *)(p) + 3)) << 24) | \
((uint32_t)(*((const uint8_t *)(p) + 2)) << 16) | \
((uint32_t)(*((const uint8_t *)(p) + 1)) << 8) | \
((uint32_t)(*((const uint8_t *)(p) + 0)) << 0)))
#define EXTRACT_LE_24BITS(p) \
((uint32_t)(((uint32_t)(*((const uint8_t *)(p) + 2)) << 16) | \
((uint32_t)(*((const uint8_t *)(p) + 1)) << 8) | \
((uint32_t)(*((const uint8_t *)(p) + 0)) << 0)))
#define EXTRACT_LE_64BITS(p) \
#define EXTRACT_LE_S_4(p) \
((int32_t)(((uint32_t)(*((const uint8_t *)(p) + 3)) << 24) | \
((uint32_t)(*((const uint8_t *)(p) + 2)) << 16) | \
((uint32_t)(*((const uint8_t *)(p) + 1)) << 8) | \
((uint32_t)(*((const uint8_t *)(p) + 0)) << 0)))
#define EXTRACT_LE_U_8(p) \
((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 7)) << 56) | \
((uint64_t)(*((const uint8_t *)(p) + 6)) << 48) | \
((uint64_t)(*((const uint8_t *)(p) + 5)) << 40) | \
@ -254,33 +502,409 @@ 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)))
#define EXTRACT_LE_S_8(p) \
((int64_t)(((uint64_t)(*((const uint8_t *)(p) + 7)) << 56) | \
((uint64_t)(*((const uint8_t *)(p) + 6)) << 48) | \
((uint64_t)(*((const uint8_t *)(p) + 5)) << 40) | \
((uint64_t)(*((const uint8_t *)(p) + 4)) << 32) | \
((uint64_t)(*((const uint8_t *)(p) + 3)) << 24) | \
((uint64_t)(*((const uint8_t *)(p) + 2)) << 16) | \
((uint64_t)(*((const uint8_t *)(p) + 1)) << 8) | \
((uint64_t)(*((const uint8_t *)(p) + 0)) << 0)))
/*
* Non-power-of-2 sizes.
*/
#define EXTRACT_LE_U_3(p) \
((uint32_t)(((uint32_t)(*((const uint8_t *)(p) + 2)) << 16) | \
((uint32_t)(*((const uint8_t *)(p) + 1)) << 8) | \
((uint32_t)(*((const uint8_t *)(p) + 0)) << 0)))
#define EXTRACT_LE_S_3(p) \
((int32_t)(((uint32_t)(*((const uint8_t *)(p) + 2)) << 16) | \
((uint32_t)(*((const uint8_t *)(p) + 1)) << 8) | \
((uint32_t)(*((const uint8_t *)(p) + 0)) << 0)))
#define EXTRACT_LE_U_5(p) \
((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 4)) << 32) | \
((uint64_t)(*((const uint8_t *)(p) + 3)) << 24) | \
((uint64_t)(*((const uint8_t *)(p) + 2)) << 16) | \
((uint64_t)(*((const uint8_t *)(p) + 1)) << 8) | \
((uint64_t)(*((const uint8_t *)(p) + 0)) << 0)))
#define EXTRACT_LE_U_6(p) \
((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 5)) << 40) | \
((uint64_t)(*((const uint8_t *)(p) + 4)) << 32) | \
((uint64_t)(*((const uint8_t *)(p) + 3)) << 24) | \
((uint64_t)(*((const uint8_t *)(p) + 2)) << 16) | \
((uint64_t)(*((const uint8_t *)(p) + 1)) << 8) | \
((uint64_t)(*((const uint8_t *)(p) + 0)) << 0)))
#define EXTRACT_LE_U_7(p) \
((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 6)) << 48) | \
((uint64_t)(*((const uint8_t *)(p) + 5)) << 40) | \
((uint64_t)(*((const uint8_t *)(p) + 4)) << 32) | \
((uint64_t)(*((const uint8_t *)(p) + 3)) << 24) | \
((uint64_t)(*((const uint8_t *)(p) + 2)) << 16) | \
((uint64_t)(*((const uint8_t *)(p) + 1)) << 8) | \
((uint64_t)(*((const uint8_t *)(p) + 0)) << 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_1(p) ND_TTEST_LEN((p), 1)
#define ND_TCHECK_1(p) ND_TCHECK_LEN((p), 1)
#define ND_TTEST_16BITS(p) ND_TTEST2(*(p), 2)
#define ND_TCHECK_16BITS(p) ND_TCHECK2(*(p), 2)
#define ND_TTEST_2(p) ND_TTEST_LEN((p), 2)
#define ND_TCHECK_2(p) ND_TCHECK_LEN((p), 2)
#define ND_TTEST_24BITS(p) ND_TTEST2(*(p), 3)
#define ND_TCHECK_24BITS(p) ND_TCHECK2(*(p), 3)
#define ND_TTEST_3(p) ND_TTEST_LEN((p), 3)
#define ND_TCHECK_3(p) ND_TCHECK_LEN((p), 3)
#define ND_TTEST_32BITS(p) ND_TTEST2(*(p), 4)
#define ND_TCHECK_32BITS(p) ND_TCHECK2(*(p), 4)
#define ND_TTEST_4(p) ND_TTEST_LEN((p), 4)
#define ND_TCHECK_4(p) ND_TCHECK_LEN((p), 4)
#define ND_TTEST_40BITS(p) ND_TTEST2(*(p), 5)
#define ND_TCHECK_40BITS(p) ND_TCHECK2(*(p), 5)
#define ND_TTEST_5(p) ND_TTEST_LEN((p), 5)
#define ND_TCHECK_5(p) ND_TCHECK_LEN((p), 5)
#define ND_TTEST_48BITS(p) ND_TTEST2(*(p), 6)
#define ND_TCHECK_48BITS(p) ND_TCHECK2(*(p), 6)
#define ND_TTEST_6(p) ND_TTEST_LEN((p), 6)
#define ND_TCHECK_6(p) ND_TCHECK_LEN((p), 6)
#define ND_TTEST_56BITS(p) ND_TTEST2(*(p), 7)
#define ND_TCHECK_56BITS(p) ND_TCHECK2(*(p), 7)
#define ND_TTEST_7(p) ND_TTEST_LEN((p), 7)
#define ND_TCHECK_7(p) ND_TCHECK_LEN((p), 7)
#define ND_TTEST_64BITS(p) ND_TTEST2(*(p), 8)
#define ND_TCHECK_64BITS(p) ND_TCHECK2(*(p), 8)
#define ND_TTEST_8(p) ND_TTEST_LEN((p), 8)
#define ND_TCHECK_8(p) ND_TCHECK_LEN((p), 8)
#define ND_TTEST_128BITS(p) ND_TTEST2(*(p), 16)
#define ND_TCHECK_128BITS(p) ND_TCHECK2(*(p), 16)
#define ND_TTEST_16(p) ND_TTEST_LEN((p), 16)
#define ND_TCHECK_16(p) ND_TCHECK_LEN((p), 16)
/* get_u_1 and get_s_1 */
static inline uint8_t
get_u_1(netdissect_options *ndo, const u_char *p)
{
if (!ND_TTEST_1(p))
nd_trunc_longjmp(ndo);
return EXTRACT_U_1(p);
}
static inline int8_t
get_s_1(netdissect_options *ndo, const u_char *p)
{
if (!ND_TTEST_1(p))
nd_trunc_longjmp(ndo);
return EXTRACT_S_1(p);
}
/* get_be_u_N */
static inline uint16_t
get_be_u_2(netdissect_options *ndo, const u_char *p)
{
if (!ND_TTEST_2(p))
nd_trunc_longjmp(ndo);
return EXTRACT_BE_U_2(p);
}
static inline uint32_t
get_be_u_3(netdissect_options *ndo, const u_char *p)
{
if (!ND_TTEST_3(p))
nd_trunc_longjmp(ndo);
return EXTRACT_BE_U_3(p);
}
static inline uint32_t
get_be_u_4(netdissect_options *ndo, const u_char *p)
{
if (!ND_TTEST_4(p))
nd_trunc_longjmp(ndo);
return EXTRACT_BE_U_4(p);
}
static inline uint64_t
get_be_u_5(netdissect_options *ndo, const u_char *p)
{
if (!ND_TTEST_5(p))
nd_trunc_longjmp(ndo);
return EXTRACT_BE_U_5(p);
}
static inline uint64_t
get_be_u_6(netdissect_options *ndo, const u_char *p)
{
if (!ND_TTEST_6(p))
nd_trunc_longjmp(ndo);
return EXTRACT_BE_U_6(p);
}
static inline uint64_t
get_be_u_7(netdissect_options *ndo, const u_char *p)
{
if (!ND_TTEST_7(p))
nd_trunc_longjmp(ndo);
return EXTRACT_BE_U_7(p);
}
static inline uint64_t
get_be_u_8(netdissect_options *ndo, const u_char *p)
{
if (!ND_TTEST_8(p))
nd_trunc_longjmp(ndo);
return EXTRACT_BE_U_8(p);
}
/* get_be_s_N */
static inline int16_t
get_be_s_2(netdissect_options *ndo, const u_char *p)
{
if (!ND_TTEST_2(p))
nd_trunc_longjmp(ndo);
return EXTRACT_BE_S_2(p);
}
static inline int32_t
get_be_s_3(netdissect_options *ndo, const u_char *p)
{
if (!ND_TTEST_3(p))
nd_trunc_longjmp(ndo);
return EXTRACT_BE_S_3(p);
}
static inline int32_t
get_be_s_4(netdissect_options *ndo, const u_char *p)
{
if (!ND_TTEST_4(p))
nd_trunc_longjmp(ndo);
return EXTRACT_BE_S_4(p);
}
static inline int64_t
get_be_s_5(netdissect_options *ndo, const u_char *p)
{
if (!ND_TTEST_5(p))
nd_trunc_longjmp(ndo);
return EXTRACT_BE_S_5(p);
}
static inline int64_t
get_be_s_6(netdissect_options *ndo, const u_char *p)
{
if (!ND_TTEST_6(p))
nd_trunc_longjmp(ndo);
return EXTRACT_BE_S_6(p);
}
static inline int64_t
get_be_s_7(netdissect_options *ndo, const u_char *p)
{
if (!ND_TTEST_7(p))
nd_trunc_longjmp(ndo);
return EXTRACT_BE_S_7(p);
}
static inline int64_t
get_be_s_8(netdissect_options *ndo, const u_char *p)
{
if (!ND_TTEST_8(p))
nd_trunc_longjmp(ndo);
return EXTRACT_BE_S_8(p);
}
/* get_he_u_N */
static inline uint16_t
get_he_u_2(netdissect_options *ndo, const u_char *p)
{
if (!ND_TTEST_2(p))
nd_trunc_longjmp(ndo);
return EXTRACT_HE_U_2(p);
}
static inline uint32_t
get_he_u_4(netdissect_options *ndo, const u_char *p)
{
if (!ND_TTEST_4(p))
nd_trunc_longjmp(ndo);
return EXTRACT_HE_U_4(p);
}
/* get_he_s_N */
static inline int16_t
get_he_s_2(netdissect_options *ndo, const u_char *p)
{
if (!ND_TTEST_2(p))
nd_trunc_longjmp(ndo);
return EXTRACT_HE_S_2(p);
}
static inline int32_t
get_he_s_4(netdissect_options *ndo, const u_char *p)
{
if (!ND_TTEST_4(p))
nd_trunc_longjmp(ndo);
return EXTRACT_HE_S_4(p);
}
/* get_le_u_N */
static inline uint16_t
get_le_u_2(netdissect_options *ndo, const u_char *p)
{
if (!ND_TTEST_2(p))
nd_trunc_longjmp(ndo);
return EXTRACT_LE_U_2(p);
}
static inline uint32_t
get_le_u_3(netdissect_options *ndo, const u_char *p)
{
if (!ND_TTEST_3(p))
nd_trunc_longjmp(ndo);
return EXTRACT_LE_U_3(p);
}
static inline uint32_t
get_le_u_4(netdissect_options *ndo, const u_char *p)
{
if (!ND_TTEST_4(p))
nd_trunc_longjmp(ndo);
return EXTRACT_LE_U_4(p);
}
static inline uint64_t
get_le_u_5(netdissect_options *ndo, const u_char *p)
{
if (!ND_TTEST_5(p))
nd_trunc_longjmp(ndo);
return EXTRACT_LE_U_5(p);
}
static inline uint64_t
get_le_u_6(netdissect_options *ndo, const u_char *p)
{
if (!ND_TTEST_6(p))
nd_trunc_longjmp(ndo);
return EXTRACT_LE_U_6(p);
}
static inline uint64_t
get_le_u_7(netdissect_options *ndo, const u_char *p)
{
if (!ND_TTEST_7(p))
nd_trunc_longjmp(ndo);
return EXTRACT_LE_U_7(p);
}
static inline uint64_t
get_le_u_8(netdissect_options *ndo, const u_char *p)
{
if (!ND_TTEST_8(p))
nd_trunc_longjmp(ndo);
return EXTRACT_LE_U_8(p);
}
/* get_le_s_N */
static inline int16_t
get_le_s_2(netdissect_options *ndo, const u_char *p)
{
if (!ND_TTEST_2(p))
nd_trunc_longjmp(ndo);
return EXTRACT_LE_S_2(p);
}
static inline int32_t
get_le_s_3(netdissect_options *ndo, const u_char *p)
{
if (!ND_TTEST_3(p))
nd_trunc_longjmp(ndo);
return EXTRACT_LE_S_3(p);
}
static inline int32_t
get_le_s_4(netdissect_options *ndo, const u_char *p)
{
if (!ND_TTEST_4(p))
nd_trunc_longjmp(ndo);
return EXTRACT_LE_S_4(p);
}
static inline int64_t
get_le_s_8(netdissect_options *ndo, const u_char *p)
{
if (!ND_TTEST_8(p))
nd_trunc_longjmp(ndo);
return EXTRACT_LE_S_8(p);
}
/* get_ipv4_to_{host|network]_order */
static inline uint32_t
get_ipv4_to_host_order(netdissect_options *ndo, const u_char *p)
{
if (!ND_TTEST_4(p))
nd_trunc_longjmp(ndo);
return EXTRACT_IPV4_TO_HOST_ORDER(p);
}
static inline uint32_t
get_ipv4_to_network_order(netdissect_options *ndo, const u_char *p)
{
if (!ND_TTEST_4(p))
nd_trunc_longjmp(ndo);
return EXTRACT_IPV4_TO_NETWORK_ORDER(p);
}
static inline void
get_cpy_bytes(netdissect_options *ndo, u_char *dst, const u_char *p, size_t len)
{
if (!ND_TTEST_LEN(p, len))
nd_trunc_longjmp(ndo);
UNALIGNED_MEMCPY(dst, p, len);
}
#define GET_U_1(p) get_u_1(ndo, (const u_char *)(p))
#define GET_S_1(p) get_s_1(ndo, (const u_char *)(p))
#define GET_BE_U_2(p) get_be_u_2(ndo, (const u_char *)(p))
#define GET_BE_U_3(p) get_be_u_3(ndo, (const u_char *)(p))
#define GET_BE_U_4(p) get_be_u_4(ndo, (const u_char *)(p))
#define GET_BE_U_5(p) get_be_u_5(ndo, (const u_char *)(p))
#define GET_BE_U_6(p) get_be_u_6(ndo, (const u_char *)(p))
#define GET_BE_U_7(p) get_be_u_7(ndo, (const u_char *)(p))
#define GET_BE_U_8(p) get_be_u_8(ndo, (const u_char *)(p))
#define GET_BE_S_2(p) get_be_s_2(ndo, (const u_char *)(p))
#define GET_BE_S_3(p) get_be_s_3(ndo, (const u_char *)(p))
#define GET_BE_S_4(p) get_be_s_4(ndo, (const u_char *)(p))
#define GET_BE_S_5(p) get_be_s_5(ndo, (const u_char *)(p))
#define GET_BE_S_6(p) get_be_s_6(ndo, (const u_char *)(p))
#define GET_BE_S_7(p) get_be_s_7(ndo, (const u_char *)(p))
#define GET_BE_S_8(p) get_be_s_8(ndo, (const u_char *)(p))
#define GET_HE_U_2(p) get_he_u_2(ndo, (const u_char *)(p))
#define GET_HE_U_4(p) get_he_u_4(ndo, (const u_char *)(p))
#define GET_HE_S_2(p) get_he_s_2(ndo, (const u_char *)(p))
#define GET_HE_S_4(p) get_he_s_4(ndo, (const u_char *)(p))
#define GET_LE_U_2(p) get_le_u_2(ndo, (const u_char *)(p))
#define GET_LE_U_3(p) get_le_u_3(ndo, (const u_char *)(p))
#define GET_LE_U_4(p) get_le_u_4(ndo, (const u_char *)(p))
#define GET_LE_U_5(p) get_le_u_5(ndo, (const u_char *)(p))
#define GET_LE_U_6(p) get_le_u_6(ndo, (const u_char *)(p))
#define GET_LE_U_7(p) get_le_u_7(ndo, (const u_char *)(p))
#define GET_LE_U_8(p) get_le_u_8(ndo, (const u_char *)(p))
#define GET_LE_S_2(p) get_le_s_2(ndo, (const u_char *)(p))
#define GET_LE_S_3(p) get_le_s_3(ndo, (const u_char *)(p))
#define GET_LE_S_4(p) get_le_s_4(ndo, (const u_char *)(p))
#define GET_LE_S_8(p) get_le_s_8(ndo, (const u_char *)(p))
#define GET_IPV4_TO_HOST_ORDER(p) get_ipv4_to_host_order(ndo, (const u_char *)(p))
#define GET_IPV4_TO_NETWORK_ORDER(p) get_ipv4_to_network_order(ndo, (const u_char *)(p))
#define GET_CPY_BYTES(dst, p, len) get_cpy_bytes(ndo, (u_char *)(dst), (const u_char *)(p), len)
#endif /* EXTRACT_H */

View File

@ -29,29 +29,22 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)if_ether.h 8.3 (Berkeley) 5/2/95
*/
#define ETHERMTU 1500
#include <stdio.h>
/*
* The number of bytes in an ethernet (MAC) address.
*/
#define ETHER_ADDR_LEN 6
#include "netdissect-stdinc.h"
/*
* 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_length_type;
};
#include "fptype.h"
/*
* 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
void
float_type_check(uint32_t in)
{
union { /* int to float conversion buffer */
float f;
uint32_t i;
} f;
f.i = in;
printf("%.3f\n", f.f*8/1000000);
}

34
contrib/tcpdump/fptype.h Normal file
View File

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

127
contrib/tcpdump/ftmacros.h Normal file
View File

@ -0,0 +1,127 @@
/*
* Copyright (c) 1994, 1995, 1996
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Computer Systems
* Engineering Group at Lawrence Berkeley Laboratory.
* 4. Neither the name of the University nor of the Laboratory may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef ftmacros_h
#define ftmacros_h
/*
* Define some feature test macros to make sure that everything we want
* to be declared gets declared.
*
* On some UN*Xes we need to force strtok_r() to be declared.
* We do *NOT* want to define _POSIX_C_SOURCE, as that tends
* to make non-POSIX APIs that we use unavailable.
* XXX - is there no portable way to say "please pollute the
* namespace to the maximum extent possible"?
*/
#if defined(sun) || defined(__sun)
/*
* On Solaris Clang defines __EXTENSIONS__ automatically.
*/
#ifndef __EXTENSIONS__
#define __EXTENSIONS__
#endif
/*
* We also need to define _XPG4_2 in order to get
* the Single UNIX Specification version of
* recvmsg().
*/
#define _XPG4_2
#elif defined(_hpux) || defined(hpux) || defined(__hpux)
#define _REENTRANT
/*
* We need this to get the versions of socket functions that
* use socklen_t. Define it only if it's not already defined,
* so we don't get redefiniton warnings.
*/
#ifndef _XOPEN_SOURCE_EXTENDED
#define _XOPEN_SOURCE_EXTENDED
#endif
/*
* XXX - the list of PA-RISC options for GCC makes it sound as if
* building code that uses a particular vintage of UNIX API/ABI
* is complicated:
*
* https://gcc.gnu.org/onlinedocs/gcc/HPPA-Options.html
*
* See the description of the -munix flag.
*
* We probably want libpcap to work with programs built for any
* UN*X standard. I'm not sure whether that's possible and, if
* it is, what sort of stuff it'd have to do.
*
* It might also be a requirement that we build with a special
* flag to allow the library to be used with threaded code, at
* least with HP's C compiler; hopefully doing so won't make it
* *not* work with *un*-threaded code.
*/
#else
/*
* Turn on _GNU_SOURCE to get everything GNU libc has to offer,
* including asprintf(), if we're using GNU libc.
*
* Unfortunately, one thing it has to offer is a strerror_r()
* that's not POSIX-compliant, but we deal with that in
* pcap_fmt_errmsg_for_errno().
*
* We don't limit this to, for example, Linux and Cygwin, because
* this might, for example, be GNU/HURD or one of Debian's kFreeBSD
* OSes ("GNU/FreeBSD").
*/
#define _GNU_SOURCE
/*
* We turn on both _DEFAULT_SOURCE and _BSD_SOURCE to try to get
* the BSD u_XXX types, such as u_int and u_short, defined. We
* define _DEFAULT_SOURCE first, so that newer versions of GNU libc
* don't whine about _BSD_SOURCE being deprecated; we still have
* to define _BSD_SOURCE to handle older versions of GNU libc that
* don't support _DEFAULT_SOURCE.
*
* But, if it's already defined, don't define it, so that we don't
* get a warning of it being redefined if it's defined as, for
* example, 1.
*/
#ifndef _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#endif
/* Avoid redefining _BSD_SOURCE if it's already defined as for ex. 1 */
#ifndef _BSD_SOURCE
#define _BSD_SOURCE
#endif
#endif
#endif

View File

@ -35,29 +35,13 @@
#ifndef lib_funcattrs_h
#define lib_funcattrs_h
#include "compiler-tests.h"
/*
* Attributes to apply to functions and their arguments, using various
* compiler-specific extensions.
*/
/*
* This was introduced by Clang:
*
* http://clang.llvm.org/docs/LanguageExtensions.html#has-attribute
*
* in some version (which version?); it has been picked up by GCC 5.0.
*/
#ifndef __has_attribute
/*
* It's a macro, so you can check whether it's defined to check
* whether it's supported.
*
* If it's not, define it to always return 0, so that we move on to
* the fallback checks.
*/
#define __has_attribute(x) 0
#endif
/*
* NORETURN, before a function declaration, means "this function
* never returns". (It must go before the function declaration, e.g.
@ -65,24 +49,55 @@
* declaration, as the MSVC version has to go before the declaration.)
*/
#if __has_attribute(noreturn) \
|| (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 205)) \
|| (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) \
|| (defined(__xlC__) && __xlC__ >= 0x0A01) \
|| (defined(__HP_aCC) && __HP_aCC >= 61000)
|| ND_IS_AT_LEAST_GNUC_VERSION(2,5) \
|| ND_IS_AT_LEAST_SUNC_VERSION(5,9) \
|| ND_IS_AT_LEAST_XL_C_VERSION(10,1) \
|| ND_IS_AT_LEAST_HP_C_VERSION(6,10)
/*
* Compiler with support for __attribute((noreturn)), or GCC 2.5 and
* later, or some compiler asserting compatibility with GCC 2.5 and
* later, or Solaris Studio 12 (Sun C 5.9) and later, or IBM XL C 10.1
* and later (do any earlier versions of XL C support this?), or
* HP aCC A.06.10 and later.
* and later (do any earlier versions of XL C support this?), or HP aCC
* A.06.10 and later.
*/
#define NORETURN __attribute((noreturn))
/*
* However, GCC didn't support that for function *pointers* until GCC
* 4.1.0; see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3481.
*
* Sun C/Oracle Studio C doesn't seem to support it, either.
*/
#if (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) < 401)) \
|| (defined(__SUNPRO_C))
#define NORETURN_FUNCPTR
#else
#define NORETURN_FUNCPTR __attribute((noreturn))
#endif
#elif defined(_MSC_VER)
/*
* MSVC.
* It doesn't allow __declspec(noreturn) to be applied to function
* pointers.
*/
#define NORETURN __declspec(noreturn)
#define NORETURN_FUNCPTR
#else
#define NORETURN
#define NORETURN_FUNCPTR
#endif
/*
* WARN_UNUSED_RESULT, before a function declaration, means "the caller
* should use the result of this function" (even if it's just a success/
* failure indication).
*/
#if __has_attribute(warn_unused_result) \
|| ND_IS_AT_LEAST_GNUC_VERSION(3,4) \
|| ND_IS_AT_LEAST_HP_C_VERSION(6,25)
#define WARN_UNUSED_RESULT __attribute((warn_unused_result))
#else
#define WARN_UNUSED_RESULT
#endif
/*
@ -92,29 +107,52 @@
* string".
*/
#if __has_attribute(__format__) \
|| (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 203)) \
|| (defined(__xlC__) && __xlC__ >= 0x0A01) \
|| (defined(__HP_aCC) && __HP_aCC >= 61000)
|| ND_IS_AT_LEAST_GNUC_VERSION(2,3) \
|| ND_IS_AT_LEAST_XL_C_VERSION(10,1) \
|| ND_IS_AT_LEAST_HP_C_VERSION(6,10)
/*
* Compiler with support for it, or GCC 2.3 and later, or IBM XL C 10.1
* Compiler with support for it, or GCC 2.3 and later, or some compiler
* asserting compatibility with GCC 2.3 and later, or IBM XL C 10.1
* and later (do any earlier versions of XL C support this?),
* or HP aCC A.06.10 and later.
*/
#define PRINTFLIKE(x,y) __attribute__((__format__(__printf__,x,y)))
#else
#define PRINTFLIKE(x,y)
/*
* However, GCC didn't support that for function *pointers* until GCC
* 4.1.0; see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3481.
* XL C 16.1 (and possibly some earlier versions, but not 12.1 or 13.1) has
* a similar bug, the bugfix for which was made in:
* * version 16.1.1.8 for Linux (25 June 2020), which fixes
* https://www.ibm.com/support/pages/apar/LI81402
* * version 16.1.0.5 for AIX (5 May 2020), which fixes
* https://www.ibm.com/support/pages/apar/IJ24678
*
* When testing versions, keep in mind that XL C 16.1 pretends to be both
* GCC 4.2 and Clang 4.0 at once.
*/
#if (ND_IS_AT_LEAST_GNUC_VERSION(4,1) \
&& !ND_IS_AT_LEAST_XL_C_VERSION(10,1)) \
|| (ND_IS_AT_LEAST_XL_C_VERSION(16,1) \
&& (ND_IS_AT_LEAST_XL_C_MODFIX(1, 8) && defined(__linux__)) \
|| (ND_IS_AT_LEAST_XL_C_MODFIX(0, 5) && defined(_AIX)))
#define PRINTFLIKE_FUNCPTR(x,y) __attribute__((__format__(__printf__,x,y)))
#endif
#endif
#if !defined(PRINTFLIKE)
#define PRINTFLIKE(x,y)
#endif
#if !defined(PRINTFLIKE_FUNCPTR)
#define PRINTFLIKE_FUNCPTR(x,y)
#endif
/*
* For flagging arguments as format strings in MSVC.
*/
#if _MSC_VER >= 1400
#ifdef _MSC_VER
#include <sal.h>
#if _MSC_VER > 1400
#define FORMAT_STRING(p) _Printf_format_string_ p
#else
#define FORMAT_STRING(p) __format_string p
#endif
#define FORMAT_STRING(p) _Printf_format_string_ p
#else
#define FORMAT_STRING(p) p
#endif

View File

@ -0,0 +1,67 @@
/*
* Copyright (c) 1983, 1993 The Regents of the University of California.
* Copyright (c) 1993 Digital Equipment Corporation.
* Copyright (c) 2012 G. Vanem <gvanem@yahoo.no>.
* Copyright (c) 2017 Ali Abdulkadir <autostart.ini@gmail.com>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef ND_GETSERVENT_H
#define ND_GETSERVENT_H
#ifdef _NETDB_H_
/* Just in case... */
#error netdb.h and getservent.h are incompatible
#else
#define _NETDB_H_
#endif
#ifdef _WIN32
#define __PATH_SYSROOT "SYSTEMROOT"
#define __PATH_ETC_INET "\\System32\\drivers\\etc\\"
#define __PATH_SERVICES "services"
#else
/*
* The idea here is to be able to replace "PREFIX" in __PATH_SYSROOT with a variable
* that could, for example, point to an alternative install location.
*/
#define __PATH_SYSROOT "PREFIX"
#define __PATH_ETC_INET "/etc/"
#define __PATH_SERVICES __PATH_ETC_INET"services"
#endif
#define MAXALIASES 35
void endservent (void);
struct servent *getservent(void);
void setservent (int f);
#endif /* ! ND_GETSERVENT_H */

View File

@ -14,10 +14,10 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#include <config.h>
#endif
#include <netdissect-stdinc.h>
#include "netdissect-stdinc.h"
#include "netdissect.h"
#include "gmpls.h"

View File

@ -1,66 +0,0 @@
/*
* Copyright (c) 1997
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
* the University nor the names of its contributors may be used to endorse
* or promote products derived from this software without specific prior
* written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <netdissect-stdinc.h>
#include <stdio.h>
#ifdef HAVE_OS_PROTO_H
#include "os-proto.h"
#endif
#include "gmt2local.h"
/*
* Returns the difference between gmt and local time in seconds.
* Use gmtime() and localtime() to keep things simple.
*/
int32_t
gmt2local(time_t t)
{
register int dt, dir;
register struct tm *gmt, *loc;
struct tm sgmt;
if (t == 0)
t = time(NULL);
gmt = &sgmt;
*gmt = *gmtime(&t);
loc = localtime(&t);
dt = (loc->tm_hour - gmt->tm_hour) * 60 * 60 +
(loc->tm_min - gmt->tm_min) * 60;
/*
* If the year or julian day is different, we span 00:00 GMT
* and must add or subtract a day. Check the year first to
* avoid problems when the julian day wraps.
*/
dir = loc->tm_year - gmt->tm_year;
if (dir == 0)
dir = loc->tm_yday - gmt->tm_yday;
dt += dir * 24 * 60 * 60;
return (dt);
}

View File

@ -1,25 +0,0 @@
/*
* Copyright (c) 1997
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
* the University nor the names of its contributors may be used to endorse
* or promote products derived from this software without specific prior
* written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef gmt2local_h
#define gmt2local_h
int32_t gmt2local(time_t);
#endif

View File

@ -36,10 +36,10 @@
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
# include <config.h>
#endif
#include <netdissect-stdinc.h>
#include "netdissect-stdinc.h"
#include "netdissect.h"
@ -56,9 +56,9 @@
uint16_t
in_cksum(const struct cksum_vec *vec, int veclen)
{
register const uint16_t *w;
register int sum = 0;
register int mlen = 0;
const uint16_t *w;
int sum = 0;
int mlen = 0;
int byte_swapped = 0;
union {
@ -196,5 +196,5 @@ in_cksum_shouldbe(uint16_t sum, uint16_t computed_sum)
shouldbe += ntohs(computed_sum);
shouldbe = (shouldbe & 0xFFFF) + (shouldbe >> 16);
shouldbe = (shouldbe & 0xFFFF) + (shouldbe >> 16);
return shouldbe;
return (uint16_t)shouldbe;
}

View File

@ -26,7 +26,7 @@
#include "os-proto.h"
#endif
/* snprintf et al */
#include "funcattrs.h"
#include <stdarg.h>
@ -34,22 +34,6 @@
#include <stdint.h>
#endif
#if !defined(HAVE_SNPRINTF)
int snprintf(char *, size_t, const char *, ...)
#ifdef __ATTRIBUTE___FORMAT_OK
__attribute__((format(printf, 3, 4)))
#endif /* __ATTRIBUTE___FORMAT_OK */
;
#endif /* !defined(HAVE_SNPRINTF) */
#if !defined(HAVE_VSNPRINTF)
int vsnprintf(char *, size_t, const char *, va_list)
#ifdef __ATTRIBUTE___FORMAT_OK
__attribute__((format(printf, 3, 0)))
#endif /* __ATTRIBUTE___FORMAT_OK */
;
#endif /* !defined(HAVE_VSNPRINTF) */
#ifndef HAVE_STRLCAT
extern size_t strlcat(char *, const char *, size_t);
#endif

View File

@ -51,13 +51,13 @@
*/
struct ip {
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)
#define IP_V(ip) ((GET_U_1((ip)->ip_vhl) & 0xf0) >> 4)
#define IP_HL(ip) (GET_U_1((ip)->ip_vhl) & 0x0f)
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_DF 0x4000 /* don't fragment flag */
#define IP_MF 0x2000 /* more fragments flag */
#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
nd_uint8_t ip_ttl; /* time to live */

View File

@ -1,4 +1,4 @@
/* NetBSD: ip6.h,v 1.9 2000/07/13 05:34:21 itojun Exp */
/* NetBSD: ip6.h,v 1.9 2000/07/13 05:34:21 itojun Exp */
/* $KAME: ip6.h,v 1.9 2000/07/02 21:01:32 itojun Exp $ */
/*
@ -65,8 +65,8 @@
* @(#)ip.h 8.1 (Berkeley) 6/10/93
*/
#ifndef _NETINET_IP6_H_
#define _NETINET_IP6_H_
#ifndef ND_IP6_H_
#define ND_IP6_H_
/*
* Definition for internet protocol version 6.
@ -76,19 +76,19 @@
struct ip6_hdr {
union {
struct ip6_hdrctl {
uint32_t ip6_un1_flow; /* 20 bits of flow-ID */
uint16_t ip6_un1_plen; /* payload length */
uint8_t ip6_un1_nxt; /* next header */
uint8_t ip6_un1_hlim; /* hop limit */
nd_uint32_t ip6_un1_flow; /* 20 bits of flow-ID */
nd_uint16_t ip6_un1_plen; /* payload length */
nd_uint8_t ip6_un1_nxt; /* next header */
nd_uint8_t ip6_un1_hlim; /* hop limit */
} ip6_un1;
uint8_t ip6_un2_vfc; /* 4 bits version, top 4 bits class */
nd_uint8_t ip6_un2_vfc; /* 4 bits version, top 4 bits class */
} ip6_ctlun;
struct in6_addr ip6_src; /* source address */
struct in6_addr ip6_dst; /* destination address */
} UNALIGNED;
nd_ipv6 ip6_src; /* source address */
nd_ipv6 ip6_dst; /* destination address */
};
#define ip6_vfc ip6_ctlun.ip6_un2_vfc
#define IP6_VERSION(ip6_hdr) (((ip6_hdr)->ip6_vfc & 0xf0) >> 4)
#define IP6_VERSION(ip6_hdr) ((GET_U_1((ip6_hdr)->ip6_vfc) & 0xf0) >> 4)
#define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow
#define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen
#define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt
@ -98,36 +98,31 @@ struct ip6_hdr {
/* in network endian */
#define IPV6_FLOWINFO_MASK ((uint32_t)htonl(0x0fffffff)) /* flow info (28 bits) */
#define IPV6_FLOWLABEL_MASK ((uint32_t)htonl(0x000fffff)) /* flow label (20 bits) */
#if 1
/* ECN bits proposed by Sally Floyd */
#define IP6TOS_CE 0x01 /* congestion experienced */
#define IP6TOS_ECT 0x02 /* ECN-capable transport */
#endif
/*
* Extension Headers
*/
struct ip6_ext {
uint8_t ip6e_nxt;
uint8_t ip6e_len;
} UNALIGNED;
nd_uint8_t ip6e_nxt;
nd_uint8_t ip6e_len;
};
/* Hop-by-Hop options header */
struct ip6_hbh {
uint8_t ip6h_nxt; /* next header */
uint8_t ip6h_len; /* length in units of 8 octets */
nd_uint8_t ip6h_nxt; /* next header */
nd_uint8_t ip6h_len; /* length in units of 8 octets */
/* followed by options */
} UNALIGNED;
};
/* Destination options header */
struct ip6_dest {
uint8_t ip6d_nxt; /* next header */
uint8_t ip6d_len; /* length in units of 8 octets */
nd_uint8_t ip6d_nxt; /* next header */
nd_uint8_t ip6d_len; /* length in units of 8 octets */
/* followed by options */
} UNALIGNED;
};
/* http://www.iana.org/assignments/ipv6-parameters/ipv6-parameters.xhtml */
/* https://www.iana.org/assignments/ipv6-parameters/ipv6-parameters.xhtml */
/* Option types and related macros */
#define IP6OPT_PAD1 0x00 /* 00 0 00000 */
@ -141,7 +136,7 @@ struct ip6_dest {
#define IP6OPT_RTALERT_LEN 4
#define IP6OPT_RTALERT_MLD 0 /* Datagram contains an MLD message */
#define IP6OPT_RTALERT_RSVP 1 /* Datagram contains an RSVP message */
#define IP6OPT_RTALERT_ACTNET 2 /* contains an Active Networks msg */
#define IP6OPT_RTALERT_ACTNET 2 /* contains an Active Networks msg */
#define IP6OPT_MINLEN 2
#define IP6OPT_QUICK_START 0x26 /* 00 1 00110 */
@ -165,15 +160,16 @@ struct ip6_dest {
/* Routing header */
struct ip6_rthdr {
uint8_t ip6r_nxt; /* next header */
uint8_t ip6r_len; /* length in units of 8 octets */
uint8_t ip6r_type; /* routing type */
uint8_t ip6r_segleft; /* segments left */
nd_uint8_t ip6r_nxt; /* next header */
nd_uint8_t ip6r_len; /* length in units of 8 octets */
nd_uint8_t ip6r_type; /* routing type */
nd_uint8_t ip6r_segleft; /* segments left */
/* followed by routing type specific data */
} UNALIGNED;
};
#define IPV6_RTHDR_TYPE_0 0
#define IPV6_RTHDR_TYPE_2 2
#define IPV6_RTHDR_TYPE_4 4
/* Type 0 Routing header */
/* Also used for Type 2 */
@ -183,19 +179,34 @@ struct ip6_rthdr0 {
nd_uint8_t ip6r0_type; /* always zero */
nd_uint8_t ip6r0_segleft; /* segments left */
nd_uint32_t ip6r0_reserved; /* reserved field */
struct in6_addr ip6r0_addr[1]; /* up to 23 addresses */
nd_ipv6 ip6r0_addr[1]; /* up to 23 addresses */
};
/**
* Type 4 Routing header
* known as Segment Routing Header 'SRH'
*/
struct ip6_srh {
nd_uint8_t srh_nxt; /* next header */
nd_uint8_t srh_len; /* length in units of 8 octets */
nd_uint8_t srh_type; /* Routing Type 4 */
nd_uint8_t srh_segleft; /* segments left */
nd_uint8_t srh_last_ent; /* Last Entry*/
nd_uint8_t srh_flags; /* Flags */
nd_uint16_t srh_tag; /* Tag */
nd_ipv6 srh_segments[1]; /* SRH segments list*/
};
/* Fragment header */
struct ip6_frag {
uint8_t ip6f_nxt; /* next header */
uint8_t ip6f_reserved; /* reserved field */
uint16_t ip6f_offlg; /* offset, reserved, and flag */
uint32_t ip6f_ident; /* identification */
} UNALIGNED;
nd_uint8_t ip6f_nxt; /* next header */
nd_uint8_t ip6f_reserved; /* reserved field */
nd_uint16_t ip6f_offlg; /* offset, reserved, and flag */
nd_uint32_t ip6f_ident; /* identification */
};
#define IP6F_OFF_MASK 0xfff8 /* mask out offset from ip6f_offlg */
#define IP6F_RESERVED_MASK 0x0006 /* reserved bits in ip6f_offlg */
#define IP6F_MORE_FRAG 0x0001 /* more-fragments flag */
#endif /* not _NETINET_IP6_H_ */
#endif /* not ND_IP6_H_ */

View File

@ -14,10 +14,10 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#include <config.h>
#endif
#include <netdissect-stdinc.h>
#include "netdissect-stdinc.h"
#include "netdissect.h"
#include "ipproto.h"
@ -46,12 +46,12 @@ const struct tok ipproto_values[] = {
{ IPPROTO_OSPF, "OSPF" },
{ IPPROTO_PIM, "PIM" },
{ IPPROTO_IPCOMP, "Compressed IP" },
{ IPPROTO_VRRP, "VRRP" },
{ IPPROTO_VRRP, "VRRP" }, /* See also CARP. */
{ IPPROTO_PGM, "PGM" },
{ IPPROTO_SCTP, "SCTP" },
{ IPPROTO_MOBILITY, "Mobility" },
{ IPPROTO_CARP, "CARP" },
{ IPPROTO_PFSYNC, "pfsync" },
{ IPPROTO_ETHERNET, "Ethernet" },
{ 0, NULL }
};
@ -357,7 +357,7 @@ static const char *netdb_protocol_names[256] = {
/* The function enforces the array index to be 8-bit. */
const char *
netdb_protoname (const nd_uint8_t protoid)
netdb_protoname (const uint8_t protoid)
{
return netdb_protocol_names[protoid];
}

View File

@ -36,7 +36,7 @@
*/
extern const struct tok ipproto_values[];
extern const char *netdb_protoname (const nd_uint8_t);
extern const char *netdb_protoname (const uint8_t);
#ifndef IPPROTO_IP
#define IPPROTO_IP 0 /* dummy for IP */
@ -78,7 +78,7 @@ extern const char *netdb_protoname (const nd_uint8_t);
#define IPPROTO_FRAGMENT 44 /* IPv6 fragmentation header */
#endif
#ifndef IPPROTO_RSVP
#define IPPROTO_RSVP 46 /* resource reservation */
#define IPPROTO_RSVP 46 /* resource reservation */
#endif
#ifndef IPPROTO_GRE
#define IPPROTO_GRE 47 /* General Routing Encap. */
@ -104,8 +104,7 @@ extern const char *netdb_protoname (const nd_uint8_t);
#ifndef IPPROTO_MOBILITY_OLD
/*
* The current Protocol Numbers list says that the IP protocol number for
* mobility headers is 135; it cites draft-ietf-mobileip-ipv6-24, but
* that draft doesn't actually give a number.
* mobility headers is 135; it cites RFC 6275 (obsoletes RFC 3775).
*
* It appears that 62 used to be used, even though that's assigned to
* a protocol called CFTP; however, the only reference for CFTP is a
@ -130,10 +129,7 @@ extern const char *netdb_protoname (const nd_uint8_t);
#define IPPROTO_IPCOMP 108
#endif
#ifndef IPPROTO_VRRP
#define IPPROTO_VRRP 112
#endif
#ifndef IPPROTO_CARP
#define IPPROTO_CARP 112
#define IPPROTO_VRRP 112 /* See also CARP. */
#endif
#ifndef IPPROTO_PGM
#define IPPROTO_PGM 113
@ -144,3 +140,6 @@ extern const char *netdb_protoname (const nd_uint8_t);
#ifndef IPPROTO_MOBILITY
#define IPPROTO_MOBILITY 135
#endif
#ifndef IPPROTO_ETHERNET
#define IPPROTO_ETHERNET 143 /* TEMPORARY - registered 2020-01-31, expires 2021-01-31 */
#endif

View File

@ -14,10 +14,10 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#include <config.h>
#endif
#include <netdissect-stdinc.h>
#include "netdissect-stdinc.h"
#include "netdissect.h"
#include "l2vpn.h"
@ -26,7 +26,7 @@
*
* RFC 6624
*
* http://www.iana.org/assignments/bgp-parameters/bgp-parameters.xhtml#bgp-l2-encapsulation-types-registry
* https://www.iana.org/assignments/bgp-parameters/bgp-parameters.xhtml#bgp-l2-encapsulation-types-registry
*/
const struct tok l2vpn_encaps_values[] = {
{ 0, "Reserved"},
@ -61,7 +61,7 @@ const struct tok l2vpn_encaps_values[] = {
*
* RFC 4446
*
* http://www.iana.org/assignments/pwe3-parameters/pwe3-parameters.xhtml#pwe3-parameters-2
* https://www.iana.org/assignments/pwe3-parameters/pwe3-parameters.xhtml#pwe3-parameters-2
*/
const struct tok mpls_pw_types_values[] = {
{ 0x0000, "Reserved"},

View File

@ -20,34 +20,18 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#include <config.h>
#endif
/*
* XXX - all we need, on platforms other than DEC OSF/1 (a/k/a Digital UNIX,
* a/k/a Tru64 UNIX), is "size_t", which is a standard C type; what do we
* need to do to get it defined? This is clearly wrong, as we shouldn't
* have to include UNIX or Windows system header files to get it.
*/
#include <netdissect-stdinc.h>
#ifndef HAVE___ATTRIBUTE__
#define __attribute__(x)
#endif /* HAVE___ATTRIBUTE__ */
#include <stddef.h>
#ifdef __osf__
#include <stdio.h>
#include <sys/sysinfo.h>
#include <sys/proc.h>
#if !defined(HAVE_SNPRINTF)
int snprintf(char *, size_t, const char *, ...)
#ifdef __ATTRIBUTE___FORMAT_OK
__attribute__((format(printf, 3, 4)))
#endif /* __ATTRIBUTE___FORMAT_OK */
;
#endif /* !defined(HAVE_SNPRINTF) */
#endif /* __osf__ */
#include "varattrs.h"
#include "machdep.h"
/*

View File

@ -32,7 +32,7 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#include <config.h>
#endif
#include <netdissect-stdinc.h>

View File

@ -32,7 +32,7 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#include <config.h>
#endif
#include <netdissect-stdinc.h>
@ -119,9 +119,6 @@ static struct dlt_choice dlt_choices[] = {
#ifdef DLT_LINUX_IRDA
DLT_CHOICE(DLT_LINUX_IRDA, "Linux IrDA"),
#endif
#ifdef DLT_LANE8023
DLT_CHOICE(DLT_LANE8023, "Linux 802.3 LANE"),
#endif
#ifdef DLT_CIP
DLT_CHOICE(DLT_CIP, "Linux Classical IP-over-ATM"),
#endif

View File

@ -57,6 +57,8 @@
#include <string.h>
#include <stdarg.h>
#include "diag-control.h"
#define GNU_COMPATIBLE /* Be more compatible, configure's use us! */
#define PRINT_ERROR ((opterr) && (*options != ':'))
@ -68,7 +70,7 @@
/* return values */
#define BADCH (int)'?'
#define BADARG ((*options == ':') ? (int)':' : (int)'?')
#define INORDER (int)1
#define INORDER (int)1
#define EMSG ""
@ -158,11 +160,29 @@ permute_args(int panonopt_start, int panonopt_end, int opt_end,
pos -= nnonopts;
else
pos += nopts;
/*
* This is annoying - I guess the
* "char * const argv[]" in the declaration
* of getopt() - and thus getopt_long() -
* means that it makes a promise not to
* shuffle the arguments, but here we are,
* shuffling the arguments.
*
* (No, it's not a promise that it won't
* modify any of the argument strings.
* It's a promise that it won't modify
* the array of pointers to the argument
* strings.)
*
* So squelch the cast warnings.
*/
swap = nargv[pos];
DIAG_OFF_CAST_QUAL
/* LINTED const cast */
((char **) nargv)[pos] = nargv[cstart];
/* LINTED const cast */
((char **)nargv)[cstart] = swap;
DIAG_ON_CAST_QUAL
}
}
}
@ -291,6 +311,7 @@ parse_long_options(char * const *nargv, const char *options,
}
if (long_options[match].has_arg == required_argument ||
long_options[match].has_arg == optional_argument) {
DIAG_OFF_CAST_QUAL
if (has_equal)
optarg = (char *)has_equal;
else if (long_options[match].has_arg ==
@ -300,6 +321,7 @@ parse_long_options(char * const *nargv, const char *options,
*/
optarg = nargv[optind++];
}
DIAG_ON_CAST_QUAL
}
if ((long_options[match].has_arg == required_argument)
&& (optarg == NULL)) {
@ -543,9 +565,11 @@ getopt_internal(int nargc, char * const *nargv, const char *options,
++optind;
} else { /* takes (optional) argument */
optarg = NULL;
if (*place) /* no white space */
if (*place) { /* no white space */
DIAG_OFF_CAST_QUAL
optarg = (char *)place;
else if (oli[1] != ':') { /* arg not optional */
DIAG_ON_CAST_QUAL
} else if (oli[1] != ':') { /* arg not optional */
if (++optind >= nargc) { /* no arg */
place = EMSG;
if (PRINT_ERROR)

View File

@ -30,8 +30,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _GETOPT_LONG_H_
#define _GETOPT_LONG_H_
#ifndef ND_GETOPT_LONG_H_
#define ND_GETOPT_LONG_H_
/*
* GNU-like getopt_long()/getopt_long_only() with 4.4BSD optreset extension.
@ -63,4 +63,4 @@ int getopt_long_only(int, char * const *, const char *,
extern char *optarg; /* getopt(3) external variables */
extern int optind, opterr, optopt;
#endif /* !_GETOPT_LONG_H_ */
#endif /* ! ND_GETOPT_LONG_H_ */

View File

@ -0,0 +1,143 @@
/*
* Copyright (c) 1983, 1993 The Regents of the University of California.
* Copyright (c) 1993 Digital Equipment Corporation.
* Copyright (c) 2012 G. Vanem <gvanem@yahoo.no>.
* Copyright (c) 2017 Ali Abdulkadir <autostart.ini@gmail.com>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <netdissect-stdinc.h>
#include <getservent.h>
static FILE *servf = NULL;
static char line[BUFSIZ+1];
static struct servent serv;
static char *serv_aliases[MAXALIASES];
int _serv_stayopen;
const char *etc_path(const char *file);
/*
* Check if <file> exists in the current directory and, if so, return it.
* Else return either "%SYSTEMROOT%\System32\drivers\etc\<file>"
* or $PREFIX/etc/<file>.
* "<file>" is aka __PATH_SERVICES (aka "services" on Windows and
* "/etc/services" on other platforms that would need this).
*/
const char *etc_path(const char *file)
{
const char *env = getenv(__PATH_SYSROOT);
static char path[_MAX_PATH];
/* see if "<file>" exists locally or whether __PATH_SYSROOT is valid */
if (fopen(file, "r") || !env)
return (file);
else
#ifdef _WIN32
snprintf(path, sizeof(path), "%s%s%s", env, __PATH_ETC_INET, file);
#else
snprintf(path, sizeof(path), "%s%s", env, file);
#endif
return (path);
}
void
setservent(int f)
{
if (servf == NULL)
servf = fopen(etc_path(__PATH_SERVICES), "r");
else
rewind(servf);
_serv_stayopen |= f;
}
void
endservent(void)
{
if (servf) {
fclose(servf);
servf = NULL;
}
_serv_stayopen = 0;
}
struct servent *
getservent(void)
{
char *p;
char *cp, **q;
if (servf == NULL && (servf = fopen(etc_path(__PATH_SERVICES), "r")) == NULL)
return (NULL);
again:
if ((p = fgets(line, BUFSIZ, servf)) == NULL)
return (NULL);
if (*p == '#')
goto again;
cp = strpbrk(p, "#\n");
if (cp == NULL)
goto again;
*cp = '\0';
serv.s_name = p;
p = strpbrk(p, " \t");
if (p == NULL)
goto again;
*p++ = '\0';
while (*p == ' ' || *p == '\t')
p++;
cp = strpbrk(p, ",/");
if (cp == NULL)
goto again;
*cp++ = '\0';
serv.s_port = htons((u_short)atoi(p));
serv.s_proto = cp;
q = serv.s_aliases = serv_aliases;
cp = strpbrk(cp, " \t");
if (cp != NULL)
*cp++ = '\0';
while (cp && *cp) {
if (*cp == ' ' || *cp == '\t') {
cp++;
continue;
}
if (q < &serv_aliases[MAXALIASES - 1])
*q++ = cp;
cp = strpbrk(cp, " \t");
if (cp != NULL)
*cp++ = '\0';
}
*q = NULL;
return (&serv);
}

View File

@ -0,0 +1,46 @@
/*
* Copyright (c) 1993, 1994, 1995, 1996, 1997, 1998
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Computer Systems
* Engineering Group at Lawrence Berkeley Laboratory.
* 4. Neither the name of the University nor of the Laboratory may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <stdio.h>
#include <pcap.h>
#include "pcap-missing.h"
long
pcap_dump_ftell(pcap_dumper_t *p)
{
/* FIXME: Using pcap_dump_file(p) would be a better style. That would
* require to test if pcap_dump_file() is available, and to substitute it,
* if it is not.
*/
return (ftell((FILE *)p));
}

View File

@ -67,25 +67,6 @@ struct state {
/* XXX - methods */
};
#ifndef HAVE_VSNPRINTF
static int
sn_reserve (struct state *state, size_t n)
{
return state->s + n > state->theend;
}
static int
sn_append_char (struct state *state, unsigned char c)
{
if (sn_reserve (state, 1)) {
return 1;
} else {
*state->s++ = c;
return 0;
}
}
#endif
#if 0
static int
as_reserve (struct state *state, size_t n)
@ -430,7 +411,7 @@ xyzprintf (struct state *state, const char *char_format, va_list ap)
break;
}
case 'n' : {
int *arg = va_arg(ap, int*);
int *arg = va_arg(ap, int *);
*arg = state->s - state->str;
break;
}
@ -454,37 +435,6 @@ xyzprintf (struct state *state, const char *char_format, va_list ap)
return 0;
}
#ifndef HAVE_SNPRINTF
int
snprintf (char *str, size_t sz, const char *format, ...)
{
va_list args;
int ret;
va_start(args, format);
ret = vsnprintf (str, sz, format, args);
#ifdef PARANOIA
{
int ret2;
char *tmp;
tmp = malloc (sz);
if (tmp == NULL)
abort ();
ret2 = vsprintf (tmp, format, args);
if (ret != ret2 || strcmp(str, tmp))
abort ();
free (tmp);
}
#endif
va_end(args);
return ret;
}
#endif
#if 0
#ifndef HAVE_ASPRINTF
int
@ -516,48 +466,9 @@ asprintf (char **ret, const char *format, ...)
}
#endif
#ifndef HAVE_ASNPRINTF
int
asnprintf (char **ret, size_t max_sz, const char *format, ...)
{
va_list args;
int val;
va_start(args, format);
val = vasnprintf (ret, max_sz, format, args);
#ifdef PARANOIA
{
int ret2;
char *tmp;
tmp = malloc (val + 1);
if (tmp == NULL)
abort ();
ret2 = vsprintf (tmp, format, args);
if (val != ret2 || strcmp(*ret, tmp))
abort ();
free (tmp);
}
#endif
va_end(args);
return val;
}
#endif
#ifndef HAVE_VASPRINTF
int
vasprintf (char **ret, const char *format, va_list args)
{
return vasnprintf (ret, 0, format, args);
}
#endif
#ifndef HAVE_VASNPRINTF
int
vasnprintf (char **ret, size_t max_sz, const char *format, va_list args)
nd_vasnprintf (char **ret, size_t max_sz, const char *format, va_list args)
{
int st;
size_t len;
@ -597,29 +508,3 @@ vasnprintf (char **ret, size_t max_sz, const char *format, va_list args)
}
#endif
#endif
#ifndef HAVE_VSNPRINTF
int
vsnprintf (char *str, size_t sz, const char *format, va_list args)
{
struct state state;
int ret;
unsigned char *ustr = (unsigned char *)str;
state.max_sz = 0;
state.sz = sz;
state.str = ustr;
state.s = ustr;
state.theend = ustr + sz - 1;
state.append_char = sn_append_char;
state.reserve = sn_reserve;
ret = xyzprintf (&state, format, args);
*state.s = '\0';
if (ret)
return sz;
else
return state.s - state.str;
}
#endif

View File

@ -1,5 +1,5 @@
/* $NetBSD: strlcat.c,v 1.5 1999/09/20 04:39:47 lukem Exp $ */
/* from OpenBSD: strlcat.c,v 1.2 1999/06/17 16:28:58 millert Exp */
/* from OpenBSD: strlcat.c,v 1.2 1999/06/17 16:28:58 millert Exp */
/*
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
@ -47,9 +47,9 @@
size_t
strlcat(char *dst, const char *src, size_t siz)
{
register char *d = dst;
register const char *s = src;
register size_t n = siz;
char *d = dst;
const char *s = src;
size_t n = siz;
size_t dlen;
/* Find the end of dst and adjust bytes left but don't go past end */

View File

@ -1,5 +1,5 @@
/* $NetBSD: strlcpy.c,v 1.5 1999/09/20 04:39:47 lukem Exp $ */
/* from OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp */
/* from OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp */
/*
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
@ -46,9 +46,9 @@
size_t
strlcpy(char *dst, const char *src, size_t siz)
{
register char *d = dst;
register const char *s = src;
register size_t n = siz;
char *d = dst;
const char *s = src;
size_t n = siz;
/* Copy as many bytes as will fit */
if (n != 0 && --n != 0) {

View File

@ -55,9 +55,9 @@
char *
strsep(char **stringp, const char *delim)
{
register char *s;
register const char *spanp;
register int c, sc;
char *s;
const char *spanp;
int c, sc;
char *tok;
if ((s = *stringp) == NULL)

View File

@ -16,7 +16,10 @@
MAKE=Makefile # default makefile name is "Makefile"
CC=cc # default C compiler is "cc"
DEPENDENCY_CFLAG=-M # default dependency-generation flag is -M
SOURCE_DIRECTORY=. # default source directory is the current directory
# No command-line flags seen yet.
flags=""
while :
do case "$1" in
# -c allows you to specify the C compiler
@ -39,13 +42,24 @@ while :
-p)
SED='s;\.o;;'
shift ;;
# -s allows you to specify the source directory
-s)
SOURCE_DIRECTORY=$2
shift; shift ;;
# other command-line flag
-*)
flags="$flags $1"
shift ;;
*)
break ;;
esac
done
if [ $# = 0 ] ; then
echo 'usage: mkdep [-p] [-c cc] [-f makefile] [-m dependency-cflag] [flags] file ...'
echo 'usage: mkdep [-p] [-c cc] [-f makefile] [-m dependency-cflag] [-s source-directory] [flags] file ...'
exit 1
fi
@ -73,33 +87,23 @@ _EOF_
# hack can't deal with anything that requires a search path, and doesn't
# even try for anything using bracket (<>) syntax.
#
# egrep '^#include[ ]*".*"' /dev/null $* |
# grep -E '^#include[[:blank:]]*".*"' /dev/null $* |
# sed -e 's/:[^"]*"\([^"]*\)".*/: \1/' -e 's/\.c/.o/' |
#
# Construct a list of source files with paths relative to the source directory.
#
sources=""
for srcfile in $*
do
sources="$sources $SOURCE_DIRECTORY/$srcfile"
done
# XXX this doesn't work with things like "-DDECLWAITSTATUS=union\ wait"
$CC $DEPENDENCY_CFLAG $* |
$CC $DEPENDENCY_CFLAG $flags $sources |
sed "
s; \./; ;g
$SED" |
awk '{
if ($1 != prev) {
if (rec != "")
print rec;
rec = $0;
prev = $1;
}
else {
if (length(rec $2) > 78) {
print rec;
rec = $0;
}
else
rec = rec " " $2
}
}
END {
print rec
}' >> $TMP
$SED" >> $TMP
cat << _EOF_ >> $TMP

View File

@ -28,14 +28,14 @@
#define LABEL_MASK 0xfffff000
#define LABEL_SHIFT 12
#define EXP_MASK 0x00000e00
#define EXP_SHIFT 9
#define TC_MASK 0x00000e00
#define TC_SHIFT 9
#define STACK_MASK 0x00000100
#define STACK_SHIFT 8
#define TTL_MASK 0x000000ff
#define TTL_SHIFT 0
#define MPLS_LABEL(x) (((x) & LABEL_MASK) >> LABEL_SHIFT)
#define MPLS_EXP(x) (((x) & EXP_MASK) >> EXP_SHIFT)
#define MPLS_TC(x) (((x) & TC_MASK) >> TC_SHIFT)
#define MPLS_STACK(x) (((x) & STACK_MASK) >> STACK_SHIFT)
#define MPLS_TTL(x) (((x) & TTL_MASK) >> TTL_SHIFT)

View File

@ -169,13 +169,35 @@
#define T_RRSIG 46 /* new security signature */
#define T_NSEC 47 /* provable insecure information */
#define T_DNSKEY 48 /* new security key */
#define T_DHCID 49 /* DHCP IDentifier */
#define T_NSEC3 50 /* Next SECure record v3 */
#define T_NSEC3PARAM 51 /* NSEC3 PARAMeter */
#define T_TLSA 52 /* TLS Authentication */
#define T_SMIMEA 53 /* S/MIME Authentication */
/* Unassigned */
#define T_HIP 55 /* Host Identity Protocol */
#define T_NINFO 56 /* zone status information */
#define T_RKEY 57 /* Record encryption KEY */
#define T_TALINK 58 /* Trust Anchor LINK */
#define T_CDS 59 /* Child Delegation Signer */
#define T_CDNSKEY 60 /* Child DNSKEY */
#define T_OPENPGPKEY 61 /* OpenPGP KEY */
#define T_CSYNC 62 /* Child to parent SYNCronization */
#define T_ZONEMD 63 /* ZONE data Message Digest */
#define T_SVCB 64 /* SerViCe Binding */
#define T_HTTPS 65 /* HTTPS binding */
/* non standard */
#define T_SPF 99 /* sender policy framework */
#define T_UINFO 100 /* user (finger) information */
#define T_UID 101 /* user ID */
#define T_GID 102 /* group ID */
#define T_UNSPEC 103 /* Unspecified format (binary data) */
#define T_UNSPECA 104 /* "unspecified ascii". Ugly MIT hack */
#define T_NID 104 /* Node IDentifier */
#define T_L32 105 /* Locator 32-bit */
#define T_L64 106 /* Locator 64-bit */
#define T_LP 107 /* Locator Pointer */
#define T_EUI48 108 /* an EUI-48 address */
#define T_EUI64 109 /* an EUI-64 address */
/* Query type values which do not appear in resource records */
#define T_TKEY 249 /* Transaction Key [RFC2930] */
#define T_TSIG 250 /* Transaction Signature [RFC2845] */
@ -184,6 +206,13 @@
#define T_MAILB 253 /* transfer mailbox records */
#define T_MAILA 254 /* transfer mail agent records */
#define T_ANY 255 /* wildcard match */
#define T_URI 256 /* uri records [RFC7553] */
#define T_CAA 257 /* Certification Authority Authorization */
#define T_AVC 258 /* Application Visibility and Control */
#define T_DOA 259 /* Digital Object Architecture */
#define T_AMTRELAY 260 /* Automatic Multicast Tunneling RELAY */
#define T_TA 32768 /* DNSSEC Trust Authorities */
#define T_DLV 32769 /* DNSSEC Lookaside Validation */
/*
* Values for class field
@ -197,6 +226,64 @@
#define C_QU 0x8000 /* mDNS QU flag in queries */
#define C_CACHE_FLUSH 0x8000 /* mDNS cache flush flag in replies */
/*
* Values for EDNS option types
*/
#define E_LLQ 1 /* long lived queries protocol */
#define E_UL 2 /* dynamic dns update leases */
#define E_NSID 3 /* name server identifier */
#define E_DAU 5 /* signal DNSSEC algorithm understood */
#define E_DHU 6 /* signal DS hash understood */
#define E_N3U 7 /* signal NSEC3 hash understood */
#define E_ECS 8 /* EDNS client subnet */
#define E_EXPIRE 9 /* zone expiration */
#define E_COOKIE 10 /* DNS cookies */
#define E_KEEPALIVE 11 /* TCP keepalive */
#define E_PADDING 12 /* pad DNS messages */
#define E_CHAIN 13 /* chain DNS queries */
#define E_KEYTAG 14 /* EDNS key tag */
#define E_CLIENTTAG 16 /* EDNS client tag */
#define E_SERVERTAG 17 /* EDNS server tag */
/*
* Values for DNSSEC Algorithms
* https://www.iana.org/assignments/dns-sec-alg-numbers/dns-sec-alg-numbers.xhtml
*/
#define A_DELETE 0
#define A_RSAMD5 1
#define A_DH 2
#define A_DSA 3
#define A_RSASHA1 5
#define A_DSA_NSEC3_SHA1 6
#define A_RSASHA1_NSEC3_SHA1 7
#define A_RSASHA256 8
#define A_RSASHA512 10
#define A_ECC_GOST 12
#define A_ECDSAP256SHA256 13
#define A_ECDSAP384SHA384 14
#define A_ED25519 15
#define A_ED448 16
#define A_INDIRECT 252
#define A_PRIVATEDNS 253
#define A_PRIVATEOID 254
/*
* Values for NSEC3 algorithms
* https://www.iana.org/assignments/dnssec-nsec3-parameters/dnssec-nsec3-parameters.xhtml
*/
#define NSEC_SHA1 1
/*
* Values for delegation signer algorithms
* https://www.iana.org/assignments/ds-rr-types/ds-rr-types.xhtml
*/
#define DS_SHA1 1
#define DS_SHA256 2
#define DS_GOST 3
#define DS_SHA384 4
/*
* Status return codes for T_UNSPEC conversion routines
*/
@ -210,91 +297,35 @@
* Structure for query header.
*/
typedef struct {
uint16_t id; /* query identification number */
uint8_t flags1; /* first byte of flags */
uint8_t flags2; /* second byte of flags */
uint16_t qdcount; /* number of question entries */
uint16_t ancount; /* number of answer entries */
uint16_t nscount; /* number of authority entries */
uint16_t arcount; /* number of resource entries */
} HEADER;
nd_uint16_t id; /* query identification number */
nd_uint16_t flags; /* QR, Opcode, AA, TC, RD, RA, RCODE */
nd_uint16_t qdcount; /* number of question entries */
nd_uint16_t ancount; /* number of answer entries */
nd_uint16_t nscount; /* number of authority entries */
nd_uint16_t arcount; /* number of resource entries */
} dns_header_t;
/*
* Macros for subfields of flag fields.
*/
#define DNS_QR(np) ((np)->flags1 & 0x80) /* response flag */
#define DNS_OPCODE(np) ((((np)->flags1) >> 3) & 0xF) /* purpose of message */
#define DNS_AA(np) ((np)->flags1 & 0x04) /* authoritative answer */
#define DNS_TC(np) ((np)->flags1 & 0x02) /* truncated message */
#define DNS_RD(np) ((np)->flags1 & 0x01) /* recursion desired */
#define DNS_RA(np) ((np)->flags2 & 0x80) /* recursion available */
#define DNS_AD(np) ((np)->flags2 & 0x20) /* authentic data from named */
#define DNS_CD(np) ((np)->flags2 & 0x10) /* checking disabled by resolver */
#define DNS_RCODE(np) ((np)->flags2 & 0xF) /* response code */
#define DNS_QR(flags) ((flags) & 0x8000) /* response flag */
#define DNS_OPCODE(flags) (((flags) >> 11) & 0xF) /* purpose of message */
#define DNS_AA(flags) (flags & 0x0400) /* authoritative answer */
#define DNS_TC(flags) (flags & 0x0200) /* truncated message */
#define DNS_RD(flags) (flags & 0x0100) /* recursion desired */
#define DNS_RA(flags) (flags & 0x0080) /* recursion available */
#define DNS_AD(flags) (flags & 0x0020) /* authentic data from named */
#define DNS_CD(flags) (flags & 0x0010) /* checking disabled by resolver */
#define DNS_RCODE(flags) (flags & 0x000F) /* response code */
/*
* Defines for handling compressed domain names, EDNS0 labels, etc.
*/
#define INDIR_MASK 0xc0 /* 11.... */
#define EDNS0_MASK 0x40 /* 01.... */
#define TYPE_MASK 0xc0 /* mask for the type bits of the item */
#define TYPE_INDIR 0xc0 /* 11.... - pointer */
#define TYPE_RESERVED 0x80 /* 10.... - reserved */
#define TYPE_EDNS0 0x40 /* 01.... - EDNS(0) label */
#define TYPE_LABEL 0x00 /* 00.... - regular label */
# define EDNS0_ELT_BITLABEL 0x01
/*
* Structure for passing resource records around.
*/
struct rrec {
int16_t r_zone; /* zone number */
int16_t r_class; /* class number */
int16_t r_type; /* type number */
uint32_t r_ttl; /* time to live */
int r_size; /* size of data area */
char *r_data; /* pointer to data */
};
/*
* Inline versions of get/put short/long. Pointer is advanced.
* We also assume that a "uint16_t" holds 2 "chars"
* and that a "uint32_t" holds 4 "chars".
*
* These macros demonstrate the property of C whereby it can be
* portable or it can be elegant but never both.
*/
#define GETSHORT(s, cp) { \
register u_char *t_cp = (u_char *)(cp); \
(s) = ((uint16_t)t_cp[0] << 8) | (uint16_t)t_cp[1]; \
(cp) += 2; \
}
#define GETLONG(l, cp) { \
register u_char *t_cp = (u_char *)(cp); \
(l) = (((uint32_t)t_cp[0]) << 24) \
| (((uint32_t)t_cp[1]) << 16) \
| (((uint32_t)t_cp[2]) << 8) \
| (((uint32_t)t_cp[3])); \
(cp) += 4; \
}
#define PUTSHORT(s, cp) { \
register uint16_t t_s = (uint16_t)(s); \
register u_char *t_cp = (u_char *)(cp); \
*t_cp++ = t_s >> 8; \
*t_cp = t_s; \
(cp) += 2; \
}
/*
* Warning: PUTLONG --no-longer-- destroys its first argument. if you
* were depending on this "feature", you will lose.
*/
#define PUTLONG(l, cp) { \
register uint32_t t_l = (uint32_t)(l); \
register u_char *t_cp = (u_char *)(cp); \
*t_cp++ = t_l >> 24; \
*t_cp++ = t_l >> 16; \
*t_cp++ = t_l >> 8; \
*t_cp = t_l; \
(cp) += 4; \
}
#endif /* !_NAMESER_H_ */

View File

@ -0,0 +1,64 @@
/*
* Copyright (c) 2018 The TCPDUMP project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code
* distributions retain the above copyright notice and this paragraph
* in its entirety, and (2) distributions including binary code include
* the above copyright notice and this paragraph in its entirety in
* the documentation or other materials provided with the distribution.
* 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 <stdlib.h>
#include "netdissect-alloc.h"
static void nd_add_alloc_list(netdissect_options *, nd_mem_chunk_t *);
/*
* nd_free_all() is intended to be used after a packet printing
*/
/* Add a memory chunk in allocation linked list */
static void
nd_add_alloc_list(netdissect_options *ndo, nd_mem_chunk_t *chunkp)
{
if (ndo->ndo_last_mem_p == NULL) /* first memory allocation */
chunkp->prev_mem_p = NULL;
else /* previous memory allocation */
chunkp->prev_mem_p = ndo->ndo_last_mem_p;
ndo->ndo_last_mem_p = chunkp;
}
/* malloc replacement, with tracking in a linked list */
void *
nd_malloc(netdissect_options *ndo, size_t size)
{
nd_mem_chunk_t *chunkp = malloc(sizeof(nd_mem_chunk_t) + size);
if (chunkp == NULL)
return NULL;
nd_add_alloc_list(ndo, chunkp);
return chunkp + 1;
}
/* Free chunks in allocation linked list from last to first */
void
nd_free_all(netdissect_options *ndo)
{
nd_mem_chunk_t *current, *previous;
current = ndo->ndo_last_mem_p;
while (current != NULL) {
previous = current->prev_mem_p;
free(current);
current = previous;
}
ndo->ndo_last_mem_p = NULL;
}

View File

@ -0,0 +1,32 @@
/*
* Copyright (c) 2018 The TCPDUMP project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code
* distributions retain the above copyright notice and this paragraph
* in its entirety, and (2) distributions including binary code include
* the above copyright notice and this paragraph in its entirety in
* the documentation or other materials provided with the distribution.
* 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_alloc_h
#define netdissect_alloc_h
#include <stdarg.h>
#include "netdissect-stdinc.h"
#include "netdissect.h"
typedef struct nd_mem_chunk {
void *prev_mem_p;
/* variable size data */
} nd_mem_chunk_t;
void * nd_malloc(netdissect_options *, size_t);
void nd_free_all(netdissect_options *);
#endif /* netdissect_alloc_h */

View File

@ -0,0 +1,56 @@
/*
* 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_ctype_h
#define netdissect_ctype_h
/*
* Locale-independent macros for testing character properties and
* stripping the 8th bit from characters.
*
* Byte values outside the ASCII range are considered unprintable, so
* both ND_ASCII_ISPRINT() and ND_ASCII_ISGRAPH() return "false" for them.
*
* Assumed to be handed a value between 0 and 255, i.e. don't hand them
* a char, as those might be in the range -128 to 127.
*/
#define ND_ISASCII(c) (!((c) & 0x80)) /* value is an ASCII code point */
#define ND_ASCII_ISPRINT(c) ((c) >= 0x20 && (c) <= 0x7E)
#define ND_ASCII_ISGRAPH(c) ((c) > 0x20 && (c) <= 0x7E)
#define ND_ASCII_ISDIGIT(c) ((c) >= '0' && (c) <= '9')
#define ND_TOASCII(c) ((c) & 0x7F)
/*
* Locale-independent macros for converting to upper or lower case.
*
* Byte values outside the ASCII range are not converted. Byte values
* *in* the ASCII range are converted to byte values in the ASCII range;
* in particular, 'i' is upper-cased to 'I" and 'I' is lower-cased to 'i',
* even in Turkish locales.
*/
#define ND_ASCII_TOLOWER(c) (((c) >= 'A' && (c) <= 'Z') ? (c) - 'A' + 'a' : (c))
#define ND_ASCII_TOUPPER(c) (((c) >= 'a' && (c) <= 'z') ? (c) - 'a' + 'A' : (c))
#endif /* netdissect-ctype.h */

View File

@ -39,120 +39,160 @@
#ifndef netdissect_stdinc_h
#define netdissect_stdinc_h
#include "ftmacros.h"
#include <errno.h>
#include "compiler-tests.h"
#include "varattrs.h"
/*
* If we're compiling with Visual Studio, make sure we have at least
* VS 2015 or later, so we have sufficient C99 support.
*
* XXX - verify that we have at least C99 support on UN*Xes?
*
* What about MinGW or various DOS toolchains? We're currently assuming
* sufficient C99 support there.
*/
#if defined(_MSC_VER)
/*
* Make sure we have VS 2015 or later.
*/
#if _MSC_VER < 1900
#error "Building tcpdump requires VS 2015 or later"
#endif
#endif
/*
* Get the C99 types, and the PRI[doux]64 format strings, defined.
*/
#ifdef HAVE_PCAP_PCAP_INTTYPES_H
/*
* We have pcap/pcap-inttypes.h; use that, as it'll do all the
* work, and won't cause problems if a file includes this file
* and later includes a pcap header file that also includes
* pcap/pcap-inttypes.h.
*/
#include <pcap/pcap-inttypes.h>
#else
/*
* OK, we don't have pcap/pcap-inttypes.h, so we'll have to
* do the work ourselves, but at least we don't have to
* worry about other headers including it and causing
* clashes.
*/
/*
* Include <inttypes.h> to get the integer types and PRi[doux]64 values
* defined.
*
* If the compiler is MSVC, we require VS 2015 or newer, so we
* have <inttypes.h> - and support for %zu in the formatted
* printing functions.
*
* If the compiler is MinGW, we assume we have <inttypes.h> - and
* support for %zu in the formatted printing functions.
*
* If the target is UN*X, we assume we have a C99-or-later development
* environment, and thus have <inttypes.h> - and support for %zu in
* the formatted printing functions.
*
* If the target is MS-DOS, we assume we have <inttypes.h> - and support
* for %zu in the formatted printing functions.
*/
#include <inttypes.h>
#if defined(_MSC_VER)
/*
* Suppress definition of intN_t in bittypes.h, which might be included
* by <pcap/pcap.h> in older versions of WinPcap.
* (Yes, HAVE_U_INTn_T, as the definition guards are UN*X-oriented.)
*/
#define HAVE_U_INT8_T
#define HAVE_U_INT16_T
#define HAVE_U_INT32_T
#define HAVE_U_INT64_T
#endif
#endif /* HAVE_PCAP_PCAP_INTTYPES_H */
#ifdef _WIN32
/*
* Includes and definitions for Windows.
*/
#include <stdint.h>
#include <stdio.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#include <ctype.h>
#include <time.h>
#include <io.h>
#include <fcntl.h>
#include <sys/types.h>
#ifndef uint8_t
#define uint8_t unsigned char
#ifdef _MSC_VER
/*
* Compiler is MSVC.
*
* We require VS 2015 or newer, so we have strtoll(). Use that for
* strtoint64_t().
*/
#define strtoint64_t strtoll
/*
* And we have LL as a suffix for constants, so use that.
*/
#define INT64_T_CONSTANT(constant) (constant##LL)
#else
/*
* Non-Microsoft compiler.
*
* XXX - should we use strtoll or should we use _strtoi64()?
*/
#define strtoint64_t strtoll
/*
* Assume LL works.
*/
#define INT64_T_CONSTANT(constant) (constant##LL)
#endif
#ifndef int8_t
#define int8_t signed char
#endif
#ifndef uint16_t
#define uint16_t unsigned short
#endif
#ifndef int16_t
#define int16_t signed short
#endif
#ifndef uint32_t
#define uint32_t unsigned int
#endif
#ifndef int32_t
#define int32_t signed int
#endif
#ifdef _MSC_EXTENSIONS
#ifndef uint64_t
#define uint64_t unsigned _int64
#endif
#ifndef int64_t
#define int64_t _int64
#endif
#ifndef PRId64
#define PRId64 "I64d"
#endif
#ifndef PRIo64
#define PRIo64 "I64o"
#endif
#ifndef PRIu64
#define PRIu64 "I64u"
#endif
#ifndef PRIx64
#define PRIx64 "I64x"
#endif
#else /* _MSC_EXTENSIONS */
#ifndef uint64_t
#define uint64_t unsigned long long
#endif
#ifndef int64_t
#define int64_t long long
#endif
#ifndef PRId64
#define PRId64 "lld"
#endif
#ifndef PRIo64
#define PRIo64 "llo"
#endif
#ifndef PRIu64
#define PRIu64 "llu"
#endif
#ifndef PRIx64
#define PRIx64 "llx"
#endif
#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
#define fstat _fstat
#define read _read
#define close _close
#define O_RDONLY _O_RDONLY
/*
* Microsoft tries to avoid polluting the C namespace with UN*Xisms,
* by adding a preceding underscore; we *want* the UN*Xisms, so add
* #defines to let us use them.
*/
#define isatty _isatty
#define stat _stat
#define strdup _strdup
#define open _open
#define read _read
#define close _close
#define O_RDONLY _O_RDONLY
/*
* We define our_fstat64 as _fstati64, and define our_statb as
* struct _stati64, so we get 64-bit file sizes.
*/
#define our_fstat _fstati64
#define our_statb struct _stati64
/*
* If <crtdbg.h> has been included, and _DEBUG is defined, and
* __STDC__ is zero, <crtdbg.h> will define strdup() to call
* _strdup_dbg(). So if it's already defined, don't redefine
* it.
*/
#ifndef strdup
#define strdup _strdup
#endif
/*
* Windows doesn't have ssize_t; routines such as _read() return int.
*/
typedef int ssize_t;
#endif /* _MSC_VER */
/*
@ -162,7 +202,7 @@
#define inline __inline
#endif
#ifdef AF_INET6
#if defined(AF_INET6) && !defined(HAVE_OS_IPV6_SUPPORT)
#define HAVE_OS_IPV6_SUPPORT
#endif
@ -177,13 +217,10 @@
#endif
#ifndef caddr_t
typedef char* caddr_t;
typedef char *caddr_t;
#endif /* caddr_t */
#define MAXHOSTNAMELEN 64
#define snprintf _snprintf
#define vsnprintf _vsnprintf
#define RETSIGTYPE void
#else /* _WIN32 */
@ -191,68 +228,40 @@ typedef char* caddr_t;
* Includes and definitions for various flavors of UN*X.
*/
#include <ctype.h>
#include <unistd.h>
#include <netdb.h>
#if HAVE_INTTYPES_H
#include <inttypes.h>
#elif HAVE_STDINT_H
#include <stdint.h>
#endif
#include <sys/param.h>
#include <sys/types.h> /* concession to AIX */
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#ifdef TIME_WITH_SYS_TIME
#include <time.h>
#endif
#include <arpa/inet.h>
#endif /* _WIN32 */
#ifndef HAVE___ATTRIBUTE__
#define __attribute__(x)
#endif
/*
* We should have large file support enabled, if it's available,
* so just use fstat as our_fstat and struct stat as our_statb.
*/
#define our_fstat fstat
#define our_statb struct stat
/*
* Used to declare a structure unaligned, so that the C compiler,
* if necessary, generates code that doesn't assume alignment.
* This is required because there is no guarantee that the packet
* data we get from libpcap/WinPcap is properly aligned.
*
* This assumes that, for all compilers that support __attribute__:
*
* 1) they support __attribute__((packed));
*
* 2) for all instruction set architectures requiring strict
* alignment, declaring a structure with that attribute
* causes the compiler to generate code that handles
* misaligned 2-byte, 4-byte, and 8-byte integral
* quantities.
*
* It does not (yet) handle compilers where you can get the compiler
* to generate code of that sort by some other means.
*
* This is required in order to, for example, keep the compiler from
* generating, for
*
* if (bp->bp_htype == 1 && bp->bp_hlen == 6 && bp->bp_op == BOOTPREQUEST) {
*
* in print-bootp.c, code that loads the first 4-byte word of a
* "struct bootp", masking out the bp_hops field, and comparing the result
* against 0x01010600.
*
* Note: this also requires that padding be put into the structure,
* at least for compilers where it's implemented as __attribute__((packed)).
* Assume all UN*Xes have strtoll(), and use it for strtoint64_t().
*/
#if !(defined(_MSC_VER) && defined(UNALIGNED))
/* MSVC may have its own macro defined with the same name and purpose. */
#undef UNALIGNED
#define UNALIGNED __attribute__((packed))
#endif
#define strtoint64_t strtoll
/*
* Assume LL works.
*/
#define INT64_T_CONSTANT(constant) (constant##LL)
#endif /* _WIN32 */
/*
* Function attributes, for various compilers.
*/
#include "funcattrs.h"
/*
* fopen() read and write modes for text files and binary files.
@ -275,8 +284,8 @@ typedef char* caddr_t;
* 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
* (We don't use them on macOS; Apple provides their own, which *doesn't*
* avoid the bswap instruction, as macOS only supports machines that
* have it.)
*/
#if defined(__GNUC__) && defined(__i386__) && !defined(__APPLE__) && !defined(__ntohl)
@ -349,61 +358,25 @@ struct in6_addr {
#endif
/*
* The Apple deprecation workaround macros below were adopted from the
* FreeRADIUS server code under permission of Alan DeKok and Arran Cudbard-Bell.
* Statement attributes, for various compilers.
*
* This was introduced sufficiently recently that compilers implementing
* it also implement __has_attribute() (for example, GCC 5.0 and later
* have __has_attribute(), and the "fallthrough" attribute was introduced
* in GCC 7).
*
* Unfortunately, Clang does this wrong - a statement
*
* __attribute__ ((fallthrough));
*
* produces bogus -Wmissing-declaration "declaration does not declare
* anything" warnings (dear Clang: that's not a declaration, it's an
* empty statement). GCC, however, has no trouble with this.
*/
#define XSTRINGIFY(x) #x
/*
* Macros for controlling warnings in GCC >= 4.2 and clang >= 2.8
*/
#define DIAG_JOINSTR(x,y) XSTRINGIFY(x ## y)
#define DIAG_DO_PRAGMA(x) _Pragma (#x)
#if defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 402
# define DIAG_PRAGMA(x) DIAG_DO_PRAGMA(GCC diagnostic x)
# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406
# define DIAG_OFF(x) DIAG_PRAGMA(push) DIAG_PRAGMA(ignored DIAG_JOINSTR(-W,x))
# define DIAG_ON(x) DIAG_PRAGMA(pop)
# else
# define DIAG_OFF(x) DIAG_PRAGMA(ignored DIAG_JOINSTR(-W,x))
# define DIAG_ON(x) DIAG_PRAGMA(warning DIAG_JOINSTR(-W,x))
# endif
#elif defined(__clang__) && ((__clang_major__ * 100) + __clang_minor__ >= 208)
# define DIAG_PRAGMA(x) DIAG_DO_PRAGMA(clang diagnostic x)
# define DIAG_OFF(x) DIAG_PRAGMA(push) DIAG_PRAGMA(ignored DIAG_JOINSTR(-W,x))
# define DIAG_ON(x) DIAG_PRAGMA(pop)
#if __has_attribute(fallthrough) && !defined(__clang__)
# define ND_FALL_THROUGH __attribute__ ((fallthrough))
#else
# define DIAG_OFF(x)
# define DIAG_ON(x)
#endif
/*
* For dealing with APIs which are only deprecated in OSX (like the OpenSSL API)
*/
#ifdef __APPLE__
# define USES_APPLE_DEPRECATED_API DIAG_OFF(deprecated-declarations)
# define USES_APPLE_RST DIAG_ON(deprecated-declarations)
#else
# define USES_APPLE_DEPRECATED_API
# define USES_APPLE_RST
#endif
/*
* end of Apple deprecation workaround macros
*/
/*
* Function attributes, for various compilers.
*/
#include "funcattrs.h"
#ifndef min
#define min(a,b) ((a)>(b)?(b):(a))
#endif
#ifndef max
#define max(a,b) ((b)>(a)?(b):(a))
#endif
# define ND_FALL_THROUGH
#endif /* __has_attribute(fallthrough) */
#endif /* netdissect_stdinc_h */

View File

@ -23,13 +23,14 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#include <config.h>
#endif
#include <netdissect-stdinc.h>
#include "netdissect-stdinc.h"
#include "netdissect.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#ifdef USE_LIBSMI
#include <smi.h>
@ -144,3 +145,157 @@ nd_smi_version_string(void)
return (NULL);
#endif
}
int
nd_push_buffer(netdissect_options *ndo, u_char *new_buffer,
const u_char *new_packetp, const u_int newlen)
{
struct netdissect_saved_packet_info *ndspi;
ndspi = (struct netdissect_saved_packet_info *)malloc(sizeof(struct netdissect_saved_packet_info));
if (ndspi == NULL)
return (0); /* fail */
ndspi->ndspi_buffer = new_buffer;
ndspi->ndspi_packetp = ndo->ndo_packetp;
ndspi->ndspi_snapend = ndo->ndo_snapend;
ndspi->ndspi_prev = ndo->ndo_packet_info_stack;
ndo->ndo_packetp = new_packetp;
ndo->ndo_snapend = new_packetp + newlen;
ndo->ndo_packet_info_stack = ndspi;
return (1); /* success */
}
/*
* In a given netdissect_options structure:
*
* push the current packet information onto the packet information
* stack;
*
* given a pointer into the packet and a length past that point in
* the packet, calculate a new snapshot end that's at the lower
* of the current snapshot end and that point in the packet;
*
* set the snapshot end to that new value.
*/
int
nd_push_snaplen(netdissect_options *ndo, const u_char *bp, const u_int newlen)
{
struct netdissect_saved_packet_info *ndspi;
u_int snaplen_remaining;
ndspi = (struct netdissect_saved_packet_info *)malloc(sizeof(struct netdissect_saved_packet_info));
if (ndspi == NULL)
return (0); /* fail */
ndspi->ndspi_buffer = NULL; /* no new buffer */
ndspi->ndspi_packetp = ndo->ndo_packetp;
ndspi->ndspi_snapend = ndo->ndo_snapend;
ndspi->ndspi_prev = ndo->ndo_packet_info_stack;
/*
* Push the saved previous data onto the stack.
*/
ndo->ndo_packet_info_stack = ndspi;
/*
* Find out how many bytes remain after the current snapend.
*
* We're restricted to packets with at most UINT_MAX bytes;
* cast the result to u_int, so that we don't get truncation
* warnings on LP64 and LLP64 platforms. (ptrdiff_t is
* signed and we want an unsigned difference; the pointer
* should at most be equal to snapend, and must *never*
* be past snapend.)
*/
snaplen_remaining = (u_int)(ndo->ndo_snapend - bp);
/*
* If the new snapend is smaller than the one calculated
* above, set the snapend to that value, otherwise leave
* it unchanged.
*/
if (newlen <= snaplen_remaining) {
/* Snapend isn't past the previous snapend */
ndo->ndo_snapend = bp + newlen;
}
return (1); /* success */
}
/*
* In a given netdissect_options structure:
*
* given a pointer into the packet and a length past that point in
* the packet, calculate a new snapshot end that's at the lower
* of the previous snapshot end - or, if there is no previous
* snapshot end, the current snapshot end - and that point in the
* packet;
*
* set the snapshot end to that new value.
*
* This is to change the current snapshot end. This may increase the
* snapshot end, as it may be used, for example, for a Jumbo Payload
* option in IPv6. It must not increase it past the snapshot length
* atop which the current one was pushed, however.
*/
void
nd_change_snaplen(netdissect_options *ndo, const u_char *bp, const u_int newlen)
{
struct netdissect_saved_packet_info *ndspi;
const u_char *previous_snapend;
u_int snaplen_remaining;
ndspi = ndo->ndo_packet_info_stack;
if (ndspi->ndspi_prev != NULL)
previous_snapend = ndspi->ndspi_prev->ndspi_snapend;
else
previous_snapend = ndo->ndo_snapend;
/*
* Find out how many bytes remain after the previous
* snapend - or, if there is no previous snapend, after
* the current snapend.
*
* We're restricted to packets with at most UINT_MAX bytes;
* cast the result to u_int, so that we don't get truncation
* warnings on LP64 and LLP64 platforms. (ptrdiff_t is
* signed and we want an unsigned difference; the pointer
* should at most be equal to snapend, and must *never*
* be past snapend.)
*/
snaplen_remaining = (u_int)(previous_snapend - bp);
/*
* If the new snapend is smaller than the one calculated
* above, set the snapend to that value, otherwise leave
* it unchanged.
*/
if (newlen <= snaplen_remaining) {
/* Snapend isn't past the previous snapend */
ndo->ndo_snapend = bp + newlen;
}
}
void
nd_pop_packet_info(netdissect_options *ndo)
{
struct netdissect_saved_packet_info *ndspi;
ndspi = ndo->ndo_packet_info_stack;
ndo->ndo_packetp = ndspi->ndspi_packetp;
ndo->ndo_snapend = ndspi->ndspi_snapend;
ndo->ndo_packet_info_stack = ndspi->ndspi_prev;
free(ndspi->ndspi_buffer);
free(ndspi);
}
void
nd_pop_all_packet_info(netdissect_options *ndo)
{
while (ndo->ndo_packet_info_stack != NULL)
nd_pop_packet_info(ndo);
}

View File

@ -29,10 +29,10 @@
#include "os-proto.h"
#endif
#include <sys/types.h>
#ifndef HAVE___ATTRIBUTE__
#define __attribute__(x)
#endif
#include <setjmp.h>
#include "status-exit-codes.h"
#include "funcattrs.h" /* for PRINTFLIKE_FUNCPTR() */
#include "diag-control.h" /* for ND_UNREACHABLE */
/*
* Data types corresponding to multi-byte integral values within data
@ -41,7 +41,11 @@
* 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).
*
* We even want EXTRACT_U_1 used for 8-bit integral values, so we
* define nd_uint8_t and nd_int8_t as arrays as well.
*/
typedef unsigned char nd_uint8_t[1];
typedef unsigned char nd_uint16_t[2];
typedef unsigned char nd_uint24_t[3];
typedef unsigned char nd_uint32_t[4];
@ -50,26 +54,67 @@ 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;
typedef signed char nd_int8_t[1];
/*
* Data types corresponding to single-byte integral values, for
* completeness.
* "unsigned char" so that sign extension isn't done on the
* individual bytes while they're being assembled.
*/
typedef unsigned char nd_uint8_t;
typedef signed char nd_int8_t;
typedef unsigned char nd_int32_t[4];
typedef unsigned char nd_int64_t[8];
/* snprintf et al */
#define FMAXINT (4294967296.0) /* floating point rep. of MAXINT */
/*
* Use this for IPv4 addresses and netmasks.
*
* It's defined as an array of octets, so that it's not guaranteed to
* be aligned on its "natural" boundary (in some packet formats, it
* *isn't* so aligned). We have separate EXTRACT_ calls for them;
* sometimes you want the host-byte-order value, other times you want
* the network-byte-order value.
*
* Don't use EXTRACT_BE_U_4() on them, use EXTRACT_IPV4_TO_HOST_ORDER()
* if you want them in host byte order and EXTRACT_IPV4_TO_NETWORK_ORDER()
* if you want them in network byte order (which you want with system APIs
* that expect network-order IPv4 addresses, such as inet_ntop()).
*
* If, on your little-endian machine (e.g., an "IBM-compatible PC", no matter
* what the OS, or an Intel Mac, no matter what the OS), you get the wrong
* answer, and you've used EXTRACT_BE_U_4(), do *N*O*T* "fix" this by using
* EXTRACT_LE_U_4(), fix it by using EXTRACT_IPV4_TO_NETWORK_ORDER(),
* otherwise you're breaking the result on big-endian machines (e.g.,
* most PowerPC/Power ISA machines, System/390 and z/Architecture, SPARC,
* etc.).
*
* Yes, people do this; that's why Wireshark has tvb_get_ipv4(), to extract
* an IPv4 address from a packet data buffer; it was introduced in reaction
* to somebody who *had* done that.
*/
typedef unsigned char nd_ipv4[4];
/*
* Use this for IPv6 addresses and netmasks.
*/
typedef unsigned char nd_ipv6[16];
/*
* Use this for MAC addresses.
*/
#define MAC_ADDR_LEN 6U /* length of MAC addresses */
typedef unsigned char nd_mac_addr[MAC_ADDR_LEN];
/*
* Use this for blobs of bytes; make them arrays of nd_byte.
*/
typedef unsigned char nd_byte;
/*
* Round up x to a multiple of y; y must be a power of 2.
*/
#ifndef roundup2
#define roundup2(x, y) (((x)+((u_int)((y)-1)))&(~((u_int)((y)-1))))
#endif
#include <stdarg.h>
#include <pcap.h>
@ -77,20 +122,6 @@ typedef signed char nd_int8_t;
#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, FORMAT_STRING(const char *format), ...)
PRINTFLIKE(3, 4);
#endif /* !defined(HAVE_SNPRINTF) */
#if !defined(HAVE_VSNPRINTF)
int vsnprintf (char *str, size_t sz, FORMAT_STRING(const char *format),
va_list ap) PRINTFLIKE(3, 0);
#endif /* !defined(HAVE_VSNPRINTF) */
#ifndef HAVE_STRLCAT
extern size_t strlcat (char *, const char *, size_t);
#endif
@ -111,9 +142,6 @@ struct tok {
const char *s; /* string */
};
extern const char *tok2strbuf(const struct tok *, const char *, u_int,
char *buf, size_t bufsize);
/* tok2str is deprecated */
extern const char *tok2str(const struct tok *, const char *, u_int);
extern char *bittok2str(const struct tok *, const char *, u_int);
@ -137,13 +165,42 @@ 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;
typedef void (*if_printer) IF_PRINTER_ARGS;
/*
* In case the data in a buffer needs to be processed by being decrypted,
* decompressed, etc. before it's dissected, we can't process it in place,
* we have to allocate a new buffer for the processed data.
*
* We keep a stack of those buffers; when we allocate a new buffer, we
* push the current one onto a stack, and when we're done with the new
* buffer, we free the current buffer and pop the previous one off the
* stack.
*
* A buffer has a beginning and end pointer, and a link to the previous
* buffer on the stack.
*
* In other cases, we temporarily adjust the snapshot end to reflect a
* packet-length field in the packet data and, when finished dissecting
* that part of the packet, restore the old snapshot end. We keep that
* on the stack with null buffer pointer, meaning there's nothing to
* free.
*/
struct netdissect_saved_packet_info {
u_char *ndspi_buffer; /* pointer to allocated buffer data */
const u_char *ndspi_packetp; /* saved beginning of data */
const u_char *ndspi_snapend; /* saved end of data */
struct netdissect_saved_packet_info *ndspi_prev; /* previous buffer on the stack */
};
/* 'val' value(s) for longjmp */
#define ND_TRUNCATED 1
struct netdissect_options {
int ndo_bflag; /* print 4 byte ASes in ASDOT notation */
int ndo_eflag; /* print ethernet header */
int ndo_fflag; /* don't translate "foreign" IP address */
int ndo_Kflag; /* don't check TCP checksums */
int ndo_Kflag; /* don't check IP, TCP or UDP checksums */
int ndo_nflag; /* leave addresses as numbers */
int ndo_Nflag; /* remove domains from printed host names */
int ndo_qflag; /* quick (shorter) output */
@ -152,11 +209,14 @@ struct netdissect_options {
int ndo_uflag; /* Print undecoded NFS handles */
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,
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_Hflag; /* dissect 802.11s draft mesh standard */
const char *ndo_protocol; /* protocol */
jmp_buf ndo_early_end; /* jmp_buf for setjmp()/longjmp() */
void *ndo_last_mem_p; /* pointer to the last allocated memory chunk */
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 */
@ -171,44 +231,57 @@ struct netdissect_options {
int ndo_packettype; /* as specified by -T */
int ndo_snaplen;
int ndo_ll_hdr_len; /* link-layer header length */
/*global pointers to beginning and end of current packet (during printing) */
const u_char *ndo_packetp;
const u_char *ndo_snapend;
/* stack of saved packet boundary and buffer information */
struct netdissect_saved_packet_info *ndo_packet_info_stack;
/* 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);
const u_char *bp, u_int length);
/* pointer to function to do regular output */
int (*ndo_printf)(netdissect_options *,
const char *fmt, ...)
#ifdef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS
__attribute__ ((format (printf, 2, 3)))
#endif
;
PRINTFLIKE_FUNCPTR(2, 3);
/* pointer to function to output errors */
void (*ndo_error)(netdissect_options *,
const char *fmt, ...)
#ifdef __ATTRIBUTE___NORETURN_OK_FOR_FUNCTION_POINTERS
__attribute__ ((noreturn))
#endif /* __ATTRIBUTE___NORETURN_OK_FOR_FUNCTION_POINTERS */
#ifdef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS
__attribute__ ((format (printf, 2, 3)))
#endif /* __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS */
;
void NORETURN_FUNCPTR (*ndo_error)(netdissect_options *,
status_exit_codes_t status,
const char *fmt, ...)
PRINTFLIKE_FUNCPTR(3, 4);
/* pointer to function to output warnings */
void (*ndo_warning)(netdissect_options *,
const char *fmt, ...)
#ifdef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS
__attribute__ ((format (printf, 2, 3)))
#endif
;
PRINTFLIKE_FUNCPTR(2, 3);
};
extern WARN_UNUSED_RESULT int nd_push_buffer(netdissect_options *, u_char *, const u_char *, const u_int);
extern WARN_UNUSED_RESULT int nd_push_snaplen(netdissect_options *, const u_char *, const u_int);
extern void nd_change_snaplen(netdissect_options *, const u_char *, const u_int);
extern void nd_pop_packet_info(netdissect_options *);
extern void nd_pop_all_packet_info(netdissect_options *);
static inline NORETURN void
nd_trunc_longjmp(netdissect_options *ndo)
{
longjmp(ndo->ndo_early_end, ND_TRUNCATED);
#ifdef _AIX
/*
* In AIX <setjmp.h> decorates longjmp() with "#pragma leaves", which tells
* XL C that the function is noreturn, but GCC remains unaware of that and
* yields a "'noreturn' function does return" warning.
*/
ND_UNREACHABLE
#endif /* _AIX */
}
#define PT_VAT 1 /* Visual Audio Tool */
#define PT_WB 2 /* distributed White Board */
#define PT_RPC 3 /* Remote Procedure Call */
@ -226,13 +299,12 @@ struct netdissect_options {
#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 */
#define PT_PTP 18 /* PTP */
#define PT_SOMEIP 19 /* Autosar SOME/IP Protocol */
#define PT_DOMAIN 20 /* Domain Name System (DNS) */
#ifndef min
#define min(a,b) ((a)>(b)?(b):(a))
#endif
#ifndef max
#define max(a,b) ((b)>(a)?(b):(a))
#endif
#define ND_MIN(a,b) ((a)>(b)?(b):(a))
#define ND_MAX(a,b) ((b)>(a)?(b):(a))
/* For source or destination ports tests (UDP, TCP, ...) */
#define IS_SRC_OR_DST_PORT(p) (sport == (p) || dport == (p))
@ -247,7 +319,7 @@ struct netdissect_options {
* 1) big enough for maximum-size Linux loopback packets (65549)
* and some USB packets captured with USBPcap:
*
* http://desowin.org/usbpcap/
* https://desowin.org/usbpcap/
*
* (> 131072, < 262144)
*
@ -258,27 +330,16 @@ struct netdissect_options {
* savefile header to control the size of the buffer they allocate,
* so a size of, say, 2^31-1 might not work well.
*
* XXX - does it need to be bigger still?
* XXX - does it need to be bigger still? Note that, for versions of
* libpcap with pcap_create()/pcap_activate(), if no -s flag is specified
* or -s 0 is specified, we won't set the snapshot length at all, and will
* let libpcap choose a snapshot length; newer versions may choose a bigger
* value than 262144 for D-Bus, for example.
*/
#define MAXIMUM_SNAPLEN 262144
/*
* The default snapshot length is the maximum.
*/
#define DEFAULT_SNAPLEN MAXIMUM_SNAPLEN
#define ESRC(ep) ((ep)->ether_shost)
#define EDST(ep) ((ep)->ether_dhost)
#ifndef NTOHL
#define NTOHL(x) (x) = ntohl(x)
#define NTOHS(x) (x) = ntohs(x)
#define HTONL(x) (x) = htonl(x)
#define HTONS(x) (x) = htons(x)
#endif
/*
* True if "l" bytes of "var" were captured.
* True if "l" bytes from "p" were captured.
*
* The "ndo->ndo_snapend - (l) <= ndo->ndo_snapend" checks to make sure
* "l" isn't so large that "ndo->ndo_snapend - (l)" underflows.
@ -294,7 +355,7 @@ struct netdissect_options {
* 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
* https://www.kb.cert.org/vuls/id/162289
*/
/*
@ -304,32 +365,72 @@ struct netdissect_options {
*/
#define IS_NOT_NEGATIVE(x) (((x) > 0) || ((x) == 0))
#define ND_TTEST2(var, l) \
#define ND_TTEST_LEN(p, l) \
(IS_NOT_NEGATIVE(l) && \
((uintptr_t)ndo->ndo_snapend - (l) <= (uintptr_t)ndo->ndo_snapend && \
(uintptr_t)&(var) <= (uintptr_t)ndo->ndo_snapend - (l)))
(uintptr_t)(p) <= (uintptr_t)ndo->ndo_snapend - (l)))
/* True if "var" was captured */
#define ND_TTEST(var) ND_TTEST2(var, sizeof(var))
/* True if "*(p)" was captured */
#define ND_TTEST_SIZE(p) ND_TTEST_LEN(p, sizeof(*(p)))
/* Bail if "l" bytes of "var" were not captured */
#define ND_TCHECK2(var, l) if (!ND_TTEST2(var, l)) goto trunc
/* Bail out if "l" bytes from "p" were not captured */
#ifdef ND_LONGJMP_FROM_TCHECK
#define ND_TCHECK_LEN(p, l) if (!ND_TTEST_LEN(p, l)) nd_trunc_longjmp(ndo)
#else
#define ND_TCHECK_LEN(p, l) if (!ND_TTEST_LEN(p, l)) goto trunc
#endif
/* Bail if "var" was not captured */
#define ND_TCHECK(var) ND_TCHECK2(var, sizeof(var))
/* Bail out if "*(p)" was not captured */
#define ND_TCHECK_SIZE(p) ND_TCHECK_LEN(p, sizeof(*(p)))
#define ND_PRINT(STUFF) (*ndo->ndo_printf)STUFF
/*
* Number of bytes between two pointers.
*/
#define ND_BYTES_BETWEEN(p1, p2) ((u_int)(((const uint8_t *)(p1)) - (const uint8_t *)(p2)))
/*
* Number of bytes remaining in the captured data, starting at the
* byte pointed to by the argument.
*/
#define ND_BYTES_AVAILABLE_AFTER(p) ND_BYTES_BETWEEN(ndo->ndo_snapend, (p))
/* Check length < minimum for invalid packet with a custom message, format %u */
#define ND_LCHECKMSG_U(length, minimum, what) \
if ((length) < (minimum)) { \
ND_PRINT(" [%s %u < %u]", (what), (length), (minimum)); \
goto invalid; \
}
/* Check length < minimum for invalid packet with #length message, format %u */
#define ND_LCHECK_U(length, minimum) \
ND_LCHECKMSG_U((length), (minimum), (#length))
/* Check length < minimum for invalid packet with a custom message, format %zu */
#define ND_LCHECKMSG_ZU(length, minimum, what) \
if ((length) < (minimum)) { \
ND_PRINT(" [%s %u < %zu]", (what), (length), (minimum)); \
goto invalid; \
}
/* Check length < minimum for invalid packet with #length message, format %zu */
#define ND_LCHECK_ZU(length, minimum) \
ND_LCHECKMSG_ZU((length), (minimum), (#length))
#define ND_PRINT(...) (ndo->ndo_printf)(ndo, __VA_ARGS__)
#define ND_DEFAULTPRINT(ap, length) (*ndo->ndo_default_print)(ndo, ap, length)
extern void ts_print(netdissect_options *, const struct timeval *);
extern void signed_relts_print(netdissect_options *, int32_t);
extern void unsigned_relts_print(netdissect_options *, uint32_t);
extern const char *nd_format_time(char *buf, size_t bufsize,
const char *format, const struct tm *timeptr);
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 *);
extern void fn_print_str(netdissect_options *, const u_char *);
extern u_int nd_printztn(netdissect_options *, const u_char *, u_int, const u_char *);
extern int nd_printn(netdissect_options *, const u_char *, u_int, const u_char *);
extern void nd_printjnp(netdissect_options *, const u_char *, u_int);
/*
* Flags for txtproto_print().
@ -337,23 +438,32 @@ extern int fn_printzp(netdissect_options *, const u_char *, u_int, const u_char
#define RESP_CODE_SECOND_TOKEN 0x00000001 /* response code is second token in response line */
extern void txtproto_print(netdissect_options *, const u_char *, u_int,
const char *, const char **, u_int);
const char **, u_int);
#if (defined(__i386__) || defined(_M_IX86) || defined(__X86__) || defined(__x86_64__) || defined(_M_X64)) || \
(defined(__arm__) || defined(_M_ARM) || defined(__aarch64__)) || \
(defined(__m68k__) && (!defined(__mc68000__) && !defined(__mc68010__))) || \
(defined(__ppc__) || defined(__ppc64__) || defined(_M_PPC) || defined(_ARCH_PPC) || defined(_ARCH_PPC64)) || \
(defined(__s390__) || defined(__s390x__) || defined(__zarch__)) || \
defined(__vax__)
/*
* Locale-independent macros for testing character properties and
* stripping the 8th bit from characters. Assumed to be handed
* a value between 0 and 255, i.e. don't hand them a char, as
* those might be in the range -128 to 127.
* The processor natively handles unaligned loads, so just use memcpy()
* and memcmp(), to enable those optimizations.
*
* XXX - are those all the x86 tests we need?
* XXX - do we need to worry about ARMv1 through ARMv5, which didn't
* support unaligned loads, and, if so, do we need to worry about all
* of them, or just some of them, e.g. ARMv5?
* XXX - are those the only 68k tests we need not to generated
* unaligned accesses if the target is the 68000 or 68010?
* XXX - are there any tests we don't need, because some definitions are for
* compilers that also predefine the GCC symbols?
* XXX - do we need to test for both 32-bit and 64-bit versions of those
* architectures in all cases?
*/
#define ND_ISASCII(c) (!((c) & 0x80)) /* value is an ASCII code point */
#define ND_ISPRINT(c) ((c) >= 0x20 && (c) <= 0x7E)
#define ND_ISGRAPH(c) ((c) > 0x20 && (c) <= 0x7E)
#define ND_TOASCII(c) ((c) & 0x7F)
extern void safeputchar(netdissect_options *, const u_char);
extern void safeputs(netdissect_options *, const u_char *, const u_int);
#ifdef LBL_ALIGN
#define UNALIGNED_MEMCPY(p, q, l) memcpy((p), (q), (l))
#define UNALIGNED_MEMCMP(p, q, l) memcmp((p), (q), (l))
#else
/*
* The processor doesn't natively handle unaligned loads,
* and the compiler might "helpfully" optimize memcpy()
@ -369,13 +479,6 @@ extern void unaligned_memcpy(void *, const void *, size_t);
extern int unaligned_memcmp(const void *, const void *, size_t);
#define UNALIGNED_MEMCPY(p, q, l) unaligned_memcpy((p), (q), (l))
#define UNALIGNED_MEMCMP(p, q, l) unaligned_memcmp((p), (q), (l))
#else
/*
* The procesor natively handles unaligned loads, so just use memcpy()
* and memcmp(), to enable those optimizations.
*/
#define UNALIGNED_MEMCPY(p, q, l) memcpy((p), (q), (l))
#define UNALIGNED_MEMCMP(p, q, l) memcmp((p), (q), (l))
#endif
#define PLURAL_SUFFIX(n) \
@ -384,66 +487,85 @@ extern int unaligned_memcmp(const void *, const void *, size_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)
struct uint_tokary
{
u_int uintval;
const struct tok *tokary;
};
extern const struct tok *uint2tokary_internal(const struct uint_tokary[], const size_t, const u_int);
#define uint2tokary(a, i) uint2tokary_internal(a, sizeof(a)/sizeof(a[0]), i)
extern if_printer lookup_printer(int);
#define ND_DEBUG {printf(" [%s:%d %s] ", __FILE__, __LINE__, __func__); fflush(stdout);}
/* The DLT printer routines */
extern u_int ap1394_if_print IF_PRINTER_ARGS;
extern u_int arcnet_if_print IF_PRINTER_ARGS;
extern u_int arcnet_linux_if_print IF_PRINTER_ARGS;
extern u_int atm_if_print IF_PRINTER_ARGS;
extern u_int bt_if_print IF_PRINTER_ARGS;
extern u_int chdlc_if_print IF_PRINTER_ARGS;
extern u_int cip_if_print IF_PRINTER_ARGS;
extern u_int enc_if_print IF_PRINTER_ARGS;
extern u_int ether_if_print IF_PRINTER_ARGS;
extern u_int fddi_if_print IF_PRINTER_ARGS;
extern u_int fr_if_print IF_PRINTER_ARGS;
extern u_int ieee802_11_if_print IF_PRINTER_ARGS;
extern u_int ieee802_11_radio_avs_if_print IF_PRINTER_ARGS;
extern u_int ieee802_11_radio_if_print IF_PRINTER_ARGS;
extern u_int ieee802_15_4_if_print IF_PRINTER_ARGS;
extern u_int ipfc_if_print IF_PRINTER_ARGS;
extern u_int ipnet_if_print IF_PRINTER_ARGS;
extern u_int juniper_atm1_print IF_PRINTER_ARGS;
extern u_int juniper_atm2_print IF_PRINTER_ARGS;
extern u_int juniper_chdlc_print IF_PRINTER_ARGS;
extern u_int juniper_es_print IF_PRINTER_ARGS;
extern u_int juniper_ether_print IF_PRINTER_ARGS;
extern u_int juniper_frelay_print IF_PRINTER_ARGS;
extern u_int juniper_ggsn_print IF_PRINTER_ARGS;
extern u_int juniper_mfr_print IF_PRINTER_ARGS;
extern u_int juniper_mlfr_print IF_PRINTER_ARGS;
extern u_int juniper_mlppp_print IF_PRINTER_ARGS;
extern u_int juniper_monitor_print IF_PRINTER_ARGS;
extern u_int juniper_ppp_print IF_PRINTER_ARGS;
extern u_int juniper_pppoe_atm_print IF_PRINTER_ARGS;
extern u_int juniper_pppoe_print IF_PRINTER_ARGS;
extern u_int juniper_services_print IF_PRINTER_ARGS;
extern u_int lane_if_print IF_PRINTER_ARGS;
extern u_int ltalk_if_print IF_PRINTER_ARGS;
extern u_int mfr_if_print IF_PRINTER_ARGS;
extern u_int netanalyzer_if_print IF_PRINTER_ARGS;
extern u_int netanalyzer_transparent_if_print IF_PRINTER_ARGS;
extern u_int nflog_if_print IF_PRINTER_ARGS;
extern u_int null_if_print IF_PRINTER_ARGS;
extern u_int pflog_if_print IF_PRINTER_ARGS;
extern u_int pktap_if_print IF_PRINTER_ARGS;
extern u_int ppi_if_print IF_PRINTER_ARGS;
extern u_int ppp_bsdos_if_print IF_PRINTER_ARGS;
extern u_int ppp_hdlc_if_print IF_PRINTER_ARGS;
extern u_int ppp_if_print IF_PRINTER_ARGS;
extern u_int pppoe_if_print IF_PRINTER_ARGS;
extern u_int prism_if_print IF_PRINTER_ARGS;
extern u_int raw_if_print IF_PRINTER_ARGS;
extern u_int sl_bsdos_if_print IF_PRINTER_ARGS;
extern u_int sl_if_print IF_PRINTER_ARGS;
extern u_int sll_if_print IF_PRINTER_ARGS;
extern u_int sunatm_if_print IF_PRINTER_ARGS;
extern u_int symantec_if_print IF_PRINTER_ARGS;
extern u_int token_if_print IF_PRINTER_ARGS;
extern u_int usb_linux_48_byte_print IF_PRINTER_ARGS;
extern u_int usb_linux_64_byte_print IF_PRINTER_ARGS;
extern void ap1394_if_print IF_PRINTER_ARGS;
extern void arcnet_if_print IF_PRINTER_ARGS;
extern void arcnet_linux_if_print IF_PRINTER_ARGS;
extern void atm_if_print IF_PRINTER_ARGS;
extern void brcm_tag_if_print IF_PRINTER_ARGS;
extern void brcm_tag_prepend_if_print IF_PRINTER_ARGS;
extern void bt_if_print IF_PRINTER_ARGS;
extern void chdlc_if_print IF_PRINTER_ARGS;
extern void cip_if_print IF_PRINTER_ARGS;
extern void dsa_if_print IF_PRINTER_ARGS;
extern void edsa_if_print IF_PRINTER_ARGS;
extern void enc_if_print IF_PRINTER_ARGS;
extern void ether_if_print IF_PRINTER_ARGS;
extern void fddi_if_print IF_PRINTER_ARGS;
extern void fr_if_print IF_PRINTER_ARGS;
extern void ieee802_11_if_print IF_PRINTER_ARGS;
extern void ieee802_11_radio_avs_if_print IF_PRINTER_ARGS;
extern void ieee802_11_radio_if_print IF_PRINTER_ARGS;
extern void ieee802_15_4_if_print IF_PRINTER_ARGS;
extern void ieee802_15_4_tap_if_print IF_PRINTER_ARGS;
extern void ipfc_if_print IF_PRINTER_ARGS;
extern void ipnet_if_print IF_PRINTER_ARGS;
extern void ipoib_if_print IF_PRINTER_ARGS;
extern void juniper_atm1_if_print IF_PRINTER_ARGS;
extern void juniper_atm2_if_print IF_PRINTER_ARGS;
extern void juniper_chdlc_if_print IF_PRINTER_ARGS;
extern void juniper_es_if_print IF_PRINTER_ARGS;
extern void juniper_ether_if_print IF_PRINTER_ARGS;
extern void juniper_frelay_if_print IF_PRINTER_ARGS;
extern void juniper_ggsn_if_print IF_PRINTER_ARGS;
extern void juniper_mfr_if_print IF_PRINTER_ARGS;
extern void juniper_mlfr_if_print IF_PRINTER_ARGS;
extern void juniper_mlppp_if_print IF_PRINTER_ARGS;
extern void juniper_monitor_if_print IF_PRINTER_ARGS;
extern void juniper_ppp_if_print IF_PRINTER_ARGS;
extern void juniper_pppoe_atm_if_print IF_PRINTER_ARGS;
extern void juniper_pppoe_if_print IF_PRINTER_ARGS;
extern void juniper_services_if_print IF_PRINTER_ARGS;
extern void ltalk_if_print IF_PRINTER_ARGS;
extern void mfr_if_print IF_PRINTER_ARGS;
extern void netanalyzer_if_print IF_PRINTER_ARGS;
extern void netanalyzer_transparent_if_print IF_PRINTER_ARGS;
extern void nflog_if_print IF_PRINTER_ARGS;
extern void null_if_print IF_PRINTER_ARGS;
extern void pflog_if_print IF_PRINTER_ARGS;
extern void pktap_if_print IF_PRINTER_ARGS;
extern void ppi_if_print IF_PRINTER_ARGS;
extern void ppp_bsdos_if_print IF_PRINTER_ARGS;
extern void ppp_hdlc_if_print IF_PRINTER_ARGS;
extern void ppp_if_print IF_PRINTER_ARGS;
extern void pppoe_if_print IF_PRINTER_ARGS;
extern void prism_if_print IF_PRINTER_ARGS;
extern void raw_if_print IF_PRINTER_ARGS;
extern void sl_bsdos_if_print IF_PRINTER_ARGS;
extern void sl_if_print IF_PRINTER_ARGS;
extern void sll2_if_print IF_PRINTER_ARGS;
extern void sll_if_print IF_PRINTER_ARGS;
extern void sunatm_if_print IF_PRINTER_ARGS;
extern void symantec_if_print IF_PRINTER_ARGS;
extern void token_if_print IF_PRINTER_ARGS;
extern void unsupported_if_print IF_PRINTER_ARGS;
extern void usb_linux_48_byte_if_print IF_PRINTER_ARGS;
extern void usb_linux_64_byte_if_print IF_PRINTER_ARGS;
extern void vsock_if_print IF_PRINTER_ARGS;
/*
* Structure passed to some printers to allow them to print
@ -463,50 +585,53 @@ struct lladdr_info {
/* The printer routines. */
extern void aarp_print(netdissect_options *, const u_char *, u_int);
extern int ah_print(netdissect_options *, register const u_char *);
extern void ahcp_print(netdissect_options *, const u_char *, const u_int);
extern int ah_print(netdissect_options *, const u_char *);
extern void ahcp_print(netdissect_options *, const u_char *, u_int);
extern void aodv_print(netdissect_options *, const u_char *, u_int, int);
extern void aoe_print(netdissect_options *, const u_char *, const u_int);
extern int arista_ethertype_print(netdissect_options *,const u_char *, 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 bcm_li_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 char *bgp_vpn_rd_print (netdissect_options *, const u_char *);
extern void bgp_print(netdissect_options *, const u_char *, u_int);
extern const 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 carp_print(netdissect_options *, const u_char *, u_int, u_int);
extern void cdp_print(netdissect_options *, const u_char *, 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 u_int chdlc_print(netdissect_options *, const u_char *, u_int);
extern void cisco_autorp_print(netdissect_options *, const u_char *, u_int);
extern void cnfp_print(netdissect_options *, const u_char *);
extern void dccp_print(netdissect_options *, const u_char *, const u_char *, u_int);
extern void decnet_print(netdissect_options *, const u_char *, u_int, u_int);
extern void dhcp6_print(netdissect_options *, const u_char *, u_int);
extern int dstopt_print(netdissect_options *, const u_char *);
extern int dstopt_process(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 eapol_print(netdissect_options *, const u_char *);
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 void esp_print(netdissect_options *, const u_char *, u_int, const u_char *, u_int, int, u_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 u_int ether_switch_tag_print(netdissect_options *, const u_char *, u_int, u_int, void (*)(netdissect_options *, const u_char *), u_int);
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 u_int fr_print(netdissect_options *, register const u_char *, u_int);
extern u_int fr_print(netdissect_options *, 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 int hbhopt_process(netdissect_options *, const u_char *, int *, uint32_t *);
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);
@ -514,18 +639,18 @@ 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 u_int ieee802_15_4_print(netdissect_options *, const u_char *, u_int);
extern u_int ieee802_11_radio_print(netdissect_options *, const u_char *, u_int, u_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 ipcomp_print(netdissect_options *, 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 isakmp_rfc3948_print(netdissect_options *, const u_char *, u_int, const u_char *, int, int, u_int);
extern void isoclns_print(netdissect_options *, const u_char *, u_int);
extern void krb_print(netdissect_options *, const u_char *);
extern void l2tp_print(netdissect_options *, const u_char *, u_int);
@ -536,14 +661,16 @@ extern u_int llap_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 loopback_print(netdissect_options *, const u_char *, 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 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 int macsec_print(netdissect_options *, const u_char **,
u_int *, u_int *, u_int *, const struct lladdr_info *,
const struct lladdr_info *);
extern u_int mfr_print(netdissect_options *, 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);
@ -551,57 +678,58 @@ 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 netbeui_print(netdissect_options *, u_short, const u_char *, int);
extern void nbt_tcp_print(netdissect_options *, const u_char *, u_int);
extern void nbt_udp137_print(netdissect_options *, const u_char *, u_int);
extern void nbt_udp138_print(netdissect_options *, const u_char *, u_int);
extern void netbeui_print(netdissect_options *, u_short, 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 nfsreply_noaddr_print(netdissect_options *, const u_char *, u_int, const u_char *);
extern void nfsreq_noaddr_print(netdissect_options *, const u_char *, u_int, const u_char *);
extern const u_char *fqdn_print(netdissect_options *, const u_char *, const u_char *);
extern void domain_print(netdissect_options *, const u_char *, u_int, int, int);
extern void nsh_print(netdissect_options *, const u_char *, u_int);
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 openflow_print(netdissect_options *, const u_char *, u_int);
extern void ospf6_print(netdissect_options *, const u_char *, u_int);
extern void ospf_print(netdissect_options *, const u_char *, u_int, const u_char *);
extern int ospf_print_grace_lsa(netdissect_options *, const uint8_t *, u_int);
extern int ospf_print_te_lsa(netdissect_options *, const uint8_t *, u_int);
extern int ospf_grace_lsa_print(netdissect_options *, const u_char *, u_int);
extern int ospf_te_lsa_print(netdissect_options *, const u_char *, u_int);
extern void otv_print(netdissect_options *, const u_char *, u_int);
extern void pfsync_ip_print(netdissect_options *, const u_char *, u_int);
extern u_int pfsync_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
extern void pgm_print(netdissect_options *, const u_char *, u_int, const u_char *);
extern void pim_print(netdissect_options *, const u_char *, u_int, const u_char *);
extern void pimv1_print(netdissect_options *, const u_char *, u_int);
extern u_int ppp_print(netdissect_options *, register const u_char *, u_int);
extern u_int ppp_print(netdissect_options *, const u_char *, u_int);
extern u_int pppoe_print(netdissect_options *, const u_char *, u_int);
extern void pptp_print(netdissect_options *, const u_char *);
extern int print_unknown_data(netdissect_options *, const u_char *, const char *, int);
extern char *q922_string(netdissect_options *, const u_char *, u_int);
extern void ptp_print(netdissect_options *, const u_char *, u_int);
extern int print_unknown_data(netdissect_options *, const u_char *, const char *, u_int);
extern const 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 rtl_print(netdissect_options *, const u_char *, u_int, const struct lladdr_info *, const struct lladdr_info *);
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 rx_print(netdissect_options *, const u_char *, u_int, uint16_t, uint16_t, 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 ssh_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 smb_tcp_print(netdissect_options *, const u_char *, u_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 sunrpc_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);
@ -610,17 +738,20 @@ 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 udp_print(netdissect_options *, const u_char *, u_int, const u_char *, int, u_int);
extern int vjc_print(netdissect_options *, const u_char *, u_short);
extern void vqp_print(netdissect_options *, const u_char *, u_int);
extern void vrrp_print(netdissect_options *, const u_char *, u_int, const u_char *, int, int);
extern void vtp_print(netdissect_options *, const u_char *, const u_int);
extern void vxlan_gpe_print(netdissect_options *, const u_char *, u_int);
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 wb_print(netdissect_options *, const u_char *, u_int);
extern void whois_print(netdissect_options *, const u_char *, u_int);
extern void zep_print(netdissect_options *, const u_char *, u_int);
extern void zephyr_print(netdissect_options *, 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 zmtp1_datagram_print(netdissect_options *, const u_char *, const u_int);
extern void someip_print(netdissect_options *, const u_char *, const u_int);
/* checksum routines */
extern void init_checksum(void);
@ -634,26 +765,32 @@ struct cksum_vec {
extern uint16_t in_cksum(const struct cksum_vec *, int);
extern uint16_t in_cksum_shouldbe(uint16_t, uint16_t);
extern int nextproto4_cksum(netdissect_options *, const struct ip *, const uint8_t *, u_int, u_int, u_int);
/* IP protocol demuxing routines */
extern void ip_demux_print(netdissect_options *, const u_char *, u_int, u_int, int, u_int, uint8_t, const u_char *);
extern uint16_t nextproto4_cksum(netdissect_options *, const struct ip *, const uint8_t *, u_int, u_int, uint8_t);
/* in print-ip6.c */
extern int nextproto6_cksum(netdissect_options *, const struct ip6_hdr *, const uint8_t *, u_int, u_int, u_int);
extern uint16_t nextproto6_cksum(netdissect_options *, const struct ip6_hdr *, const uint8_t *, u_int, u_int, uint8_t);
/* Utilities */
extern void nd_print_trunc(netdissect_options *);
extern void nd_print_protocol(netdissect_options *);
extern void nd_print_protocol_caps(netdissect_options *);
extern void nd_print_invalid(netdissect_options *);
extern int mask2plen(uint32_t);
extern int mask62plen(const u_char *);
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 *, size_t);
extern int decode_prefix6(netdissect_options *, const u_char *, u_int, char *, size_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],
extern void esp_decodesecret_print(netdissect_options *);
extern int esp_decrypt_buffer_by_ikev2_print(netdissect_options *, int,
const u_char spii[8],
const u_char spir[8],
const u_char *, const u_char *);
#endif /* netdissect_h */

View File

@ -1,4 +1,4 @@
/* NetBSD: nfs.h,v 1.1 1996/05/23 22:49:53 fvdl Exp */
/* NetBSD: nfs.h,v 1.1 1996/05/23 22:49:53 fvdl Exp */
/*
* Copyright (c) 1989, 1993
@ -118,11 +118,10 @@
#define NFSX_V3FHMAX 64 /* max. allowed by protocol */
#define NFSX_V3FATTR 84
#define NFSX_V3SATTR 60 /* max. all fields filled in */
#define NFSX_V3SRVSATTR (sizeof (struct nfsv3_sattr))
#define NFSX_V3POSTOPATTR (NFSX_V3FATTR + NFSX_UNSIGNED)
#define NFSX_V3WCCDATA (NFSX_V3POSTOPATTR + 8 * NFSX_UNSIGNED)
#define NFSX_V3COOKIEVERF 8
#define NFSX_V3WRITEVERF 8
#define NFSX_V3COOKIEVERF 8
#define NFSX_V3WRITEVERF 8
#define NFSX_V3CREATEVERF 8
#define NFSX_V3STATFS 52
#define NFSX_V3FSINFO 48
@ -139,7 +138,6 @@
NFSX_V2FATTR)
#define NFSX_WCCDATA(v3) ((v3) ? NFSX_V3WCCDATA : 0)
#define NFSX_WCCORFATTR(v3) ((v3) ? NFSX_V3WCCDATA : NFSX_V2FATTR)
#define NFSX_SATTR(v3) ((v3) ? NFSX_V3SATTR : NFSX_V2SATTR)
#define NFSX_COOKIEVERF(v3) ((v3) ? NFSX_V3COOKIEVERF : 0)
#define NFSX_WRITEVERF(v3) ((v3) ? NFSX_V3WRITEVERF : 0)
#define NFSX_READDIR(v3) ((v3) ? (5 * NFSX_UNSIGNED) : \
@ -248,7 +246,15 @@
typedef enum { NFNON=0, NFREG=1, NFDIR=2, NFBLK=3, NFCHR=4, NFLNK=5,
NFSOCK=6, NFFIFO=7 } nfs_type;
/* Structs for common parts of the rpc's */
/*
* Structs for common parts of the rpc's
*
* NOTE: these structures are not always overlaid directly on the
* packet data - sometimes we declare a local variable of that type,
* and fill it up with fields extracted using byte pointers - so we
* don't use nd_ types for their members.
*/
/*
* File Handle (32 bytes for version 2), variable up to 64 for version 3.
* File Handles of up to NFS_SMALLFH in size are stored directly in the
@ -266,32 +272,23 @@ union nfsfh {
typedef union nfsfh nfsfh_t;
struct nfsv2_time {
uint32_t nfsv2_sec;
uint32_t nfsv2_usec;
nd_uint32_t nfsv2_sec;
nd_uint32_t nfsv2_usec;
};
typedef struct nfsv2_time nfstime2;
struct nfsv3_time {
uint32_t nfsv3_sec;
uint32_t nfsv3_nsec;
nd_uint32_t nfsv3_sec;
nd_uint32_t nfsv3_nsec;
};
typedef struct nfsv3_time nfstime3;
/*
* Quads are defined as arrays of 2 longs to ensure dense packing for the
* protocol and to facilitate xdr conversion.
*/
struct nfs_uquad {
uint32_t nfsuquad[2];
};
typedef struct nfs_uquad nfsuint64;
/*
* NFS Version 3 special file number.
*/
struct nfsv3_spec {
uint32_t specdata1;
uint32_t specdata2;
nd_uint32_t specdata1;
nd_uint32_t specdata2;
};
typedef struct nfsv3_spec nfsv3spec;
@ -305,32 +302,32 @@ typedef struct nfsv3_spec nfsv3spec;
* NFSX_FATTR(v3) macro.
*/
struct nfs_fattr {
uint32_t fa_type;
uint32_t fa_mode;
uint32_t fa_nlink;
uint32_t fa_uid;
uint32_t fa_gid;
nd_uint32_t fa_type;
nd_uint32_t fa_mode;
nd_uint32_t fa_nlink;
nd_uint32_t fa_uid;
nd_uint32_t fa_gid;
union {
struct {
uint32_t nfsv2fa_size;
uint32_t nfsv2fa_blocksize;
uint32_t nfsv2fa_rdev;
uint32_t nfsv2fa_blocks;
uint32_t nfsv2fa_fsid;
uint32_t nfsv2fa_fileid;
nfstime2 nfsv2fa_atime;
nfstime2 nfsv2fa_mtime;
nfstime2 nfsv2fa_ctime;
nd_uint32_t nfsv2fa_size;
nd_uint32_t nfsv2fa_blocksize;
nd_uint32_t nfsv2fa_rdev;
nd_uint32_t nfsv2fa_blocks;
nd_uint32_t nfsv2fa_fsid;
nd_uint32_t nfsv2fa_fileid;
nfstime2 nfsv2fa_atime;
nfstime2 nfsv2fa_mtime;
nfstime2 nfsv2fa_ctime;
} fa_nfsv2;
struct {
nfsuint64 nfsv3fa_size;
nfsuint64 nfsv3fa_used;
nfsv3spec nfsv3fa_rdev;
nfsuint64 nfsv3fa_fsid;
nfsuint64 nfsv3fa_fileid;
nfstime3 nfsv3fa_atime;
nfstime3 nfsv3fa_mtime;
nfstime3 nfsv3fa_ctime;
nd_uint64_t nfsv3fa_size;
nd_uint64_t nfsv3fa_used;
nfsv3spec nfsv3fa_rdev;
nd_uint64_t nfsv3fa_fsid;
nd_uint64_t nfsv3fa_fileid;
nfstime3 nfsv3fa_atime;
nfstime3 nfsv3fa_mtime;
nfstime3 nfsv3fa_ctime;
} fa_nfsv3;
} fa_un;
};
@ -355,49 +352,31 @@ struct nfs_fattr {
#define fa3_ctime fa_un.fa_nfsv3.nfsv3fa_ctime
struct nfsv2_sattr {
uint32_t sa_mode;
uint32_t sa_uid;
uint32_t sa_gid;
uint32_t sa_size;
nfstime2 sa_atime;
nfstime2 sa_mtime;
};
/*
* NFS Version 3 sattr structure for the new node creation case.
*/
struct nfsv3_sattr {
uint32_t sa_modeset;
uint32_t sa_mode;
uint32_t sa_uidset;
uint32_t sa_uid;
uint32_t sa_gidset;
uint32_t sa_gid;
uint32_t sa_sizeset;
uint32_t sa_size;
uint32_t sa_atimetype;
nfstime3 sa_atime;
uint32_t sa_mtimetype;
nfstime3 sa_mtime;
nd_uint32_t sa_mode;
nd_uint32_t sa_uid;
nd_uint32_t sa_gid;
nd_uint32_t sa_size;
nfstime2 sa_atime;
nfstime2 sa_mtime;
};
struct nfs_statfs {
union {
struct {
uint32_t nfsv2sf_tsize;
uint32_t nfsv2sf_bsize;
uint32_t nfsv2sf_blocks;
uint32_t nfsv2sf_bfree;
uint32_t nfsv2sf_bavail;
nd_uint32_t nfsv2sf_tsize;
nd_uint32_t nfsv2sf_bsize;
nd_uint32_t nfsv2sf_blocks;
nd_uint32_t nfsv2sf_bfree;
nd_uint32_t nfsv2sf_bavail;
} sf_nfsv2;
struct {
nfsuint64 nfsv3sf_tbytes;
nfsuint64 nfsv3sf_fbytes;
nfsuint64 nfsv3sf_abytes;
nfsuint64 nfsv3sf_tfiles;
nfsuint64 nfsv3sf_ffiles;
nfsuint64 nfsv3sf_afiles;
uint32_t nfsv3sf_invarsec;
nd_uint64_t nfsv3sf_tbytes;
nd_uint64_t nfsv3sf_fbytes;
nd_uint64_t nfsv3sf_abytes;
nd_uint64_t nfsv3sf_tfiles;
nd_uint64_t nfsv3sf_ffiles;
nd_uint64_t nfsv3sf_afiles;
nd_uint32_t nfsv3sf_invarsec;
} sf_nfsv3;
} sf_un;
};
@ -416,23 +395,23 @@ struct nfs_statfs {
#define sf_invarsec sf_un.sf_nfsv3.nfsv3sf_invarsec
struct nfsv3_fsinfo {
uint32_t fs_rtmax;
uint32_t fs_rtpref;
uint32_t fs_rtmult;
uint32_t fs_wtmax;
uint32_t fs_wtpref;
uint32_t fs_wtmult;
uint32_t fs_dtpref;
nfsuint64 fs_maxfilesize;
nfstime3 fs_timedelta;
uint32_t fs_properties;
nd_uint32_t fs_rtmax;
nd_uint32_t fs_rtpref;
nd_uint32_t fs_rtmult;
nd_uint32_t fs_wtmax;
nd_uint32_t fs_wtpref;
nd_uint32_t fs_wtmult;
nd_uint32_t fs_dtpref;
nd_uint64_t fs_maxfilesize;
nfstime3 fs_timedelta;
nd_uint32_t fs_properties;
};
struct nfsv3_pathconf {
uint32_t pc_linkmax;
uint32_t pc_namemax;
uint32_t pc_notrunc;
uint32_t pc_chownrestricted;
uint32_t pc_caseinsensitive;
uint32_t pc_casepreserving;
nd_uint32_t pc_linkmax;
nd_uint32_t pc_namemax;
nd_uint32_t pc_notrunc;
nd_uint32_t pc_chownrestricted;
nd_uint32_t pc_caseinsensitive;
nd_uint32_t pc_casepreserving;
};

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 *, u_int, my_fsid *, uint32_t *, const char **, const char **, int);
extern void Parse_fh(netdissect_options *, const unsigned char *, u_int, my_fsid *, uint32_t *, const char **, const char **, int);

View File

@ -14,10 +14,10 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#include <config.h>
#endif
#include <netdissect-stdinc.h>
#include "netdissect-stdinc.h"
#include "netdissect.h"
#include "nlpid.h"

74
contrib/tcpdump/ntp.c Normal file
View File

@ -0,0 +1,74 @@
/*
* Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
* the University nor the names of its contributors may be used to endorse
* or promote products derived from this software without specific prior
* written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "ntp.h"
#include "extract.h"
#define JAN_1970 INT64_T_CONSTANT(2208988800) /* 1970 - 1900 in seconds */
void
p_ntp_time(netdissect_options *ndo,
const struct l_fixedpt *lfp)
{
uint32_t i;
uint32_t uf;
uint32_t f;
double ff;
i = GET_BE_U_4(lfp->int_part);
uf = GET_BE_U_4(lfp->fraction);
ff = uf;
if (ff < 0.0) /* some compilers are buggy */
ff += FMAXINT;
ff = ff / FMAXINT; /* shift radix point by 32 bits */
f = (uint32_t)(ff * 1000000000.0); /* treat fraction as parts per billion */
ND_PRINT("%u.%09u", i, f);
/*
* print the UTC time in human-readable format.
*/
if (i) {
int64_t seconds_64bit = (int64_t)i - JAN_1970;
time_t seconds;
char time_buf[128];
const char *time_string;
seconds = (time_t)seconds_64bit;
if (seconds != seconds_64bit) {
/*
* It doesn't fit into a time_t, so we can't hand it
* to gmtime.
*/
time_string = "[Time is too large to fit into a time_t]";
} else {
/* use ISO 8601 (RFC3339) format */
time_string = nd_format_time(time_buf, sizeof (time_buf),
"%Y-%m-%dT%H:%M:%SZ", gmtime(&seconds));
}
ND_PRINT(" (%s)", time_string);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995
* Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -17,38 +17,38 @@
* 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 <sys/types.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <unistd.h>
#include "netdissect-stdinc.h"
#include "netdissect.h"
/*
* Stock 4.3 doesn't have vfprintf.
* This routine is due to Chris Torek.
*/
vfprintf(f, fmt, args)
FILE *f;
char *fmt;
va_list args;
{
int ret;
* Structure definitions for NTP fixed point values
*
* 0 1 2 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Integer Part |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Fraction Part |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*
* 0 1 2 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Integer Part | Fraction Part |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
struct l_fixedpt {
nd_uint32_t int_part;
nd_uint32_t fraction;
};
if ((f->_flag & _IOWRT) == 0) {
if (f->_flag & _IORW)
f->_flag |= _IOWRT;
else
return EOF;
}
ret = _doprnt(fmt, args, f);
return ferror(f) ? EOF : ret;
}
struct s_fixedpt {
nd_uint16_t int_part;
nd_uint16_t fraction;
};
void p_ntp_time(netdissect_options *, const struct l_fixedpt *);

View File

@ -30,7 +30,25 @@
/* for netdissect_options */
#include "netdissect.h"
#define OF_HEADER_LEN 8
#define OF_FWD(n) { \
cp += (n); \
len -= (n); \
}
#define OF_CHK_FWD(n) { \
ND_TCHECK_LEN(cp, (n)); \
cp += (n); \
len -= (n); \
}
#define OF_VER_1_0 0x01U
#define OF_VER_1_1 0x02U
#define OF_VER_1_2 0x03U
#define OF_VER_1_3 0x04U
#define OF_VER_1_4 0x05U
#define OF_VER_1_5 0x06U
#define OF_HEADER_FIXLEN 8U
#define ONF_EXP_ONF 0x4f4e4600
#define ONF_EXP_BUTE 0xff000001
@ -40,12 +58,33 @@
#define ONF_EXP_WMOB 0xff000005
#define ONF_EXP_FABS 0xff000006
#define ONF_EXP_OTRANS 0xff000007
#define ONF_EXP_NBLNCTU 0xff000008
#define ONF_EXP_MPCE 0xff000009
#define ONF_EXP_MPLSTPSPTN 0xff00000a
extern const struct tok onf_exp_str[];
/*
* Routines to print packets for various versions of OpenFlow.
*/
extern const u_char *of10_header_body_print(netdissect_options *ndo,
const u_char *, const u_char *,
const uint8_t, const uint16_t, const uint32_t);
extern const char * of_vendor_name(const uint32_t);
extern void of_bitmap_print(netdissect_options *ndo,
const struct tok *, const uint32_t, const uint32_t);
extern void of_data_print(netdissect_options *ndo,
const u_char *, const u_int);
/*
* Routines to handle various versions of OpenFlow.
*/
struct of_msgtypeinfo {
/* Should not be NULL. */
const char *name;
/* May be NULL to mean "message body printing is not implemented". */
void (*decoder)(netdissect_options *ndo, const u_char *, const u_int);
enum {
REQ_NONE, /* Message body length may be anything. */
REQ_FIXLEN, /* Message body length must be == req_value. */
REQ_MINLEN, /* Message body length must be >= req_value. */
} req_what;
uint16_t req_value;
};
extern const struct of_msgtypeinfo *of10_identify_msgtype(const uint8_t);
extern const struct of_msgtypeinfo *of13_identify_msgtype(const uint8_t);

View File

@ -20,7 +20,6 @@
*
* OSPF support contributed by Jeffrey Honig (jch@mitchell.cit.cornell.edu)
*/
#define OSPF_TYPE_UMD 0 /* UMd's special monitoring packets */
#define OSPF_TYPE_HELLO 1 /* Hello */
#define OSPF_TYPE_DD 2 /* Database Description */
#define OSPF_TYPE_LS_REQ 3 /* Link State Request */
@ -35,11 +34,10 @@
*
*/
#define OSPF_OPTION_T 0x01 /* T bit: TOS support */
#define OSPF_OPTION_E 0x02 /* E bit: External routes advertised */
#define OSPF_OPTION_MT 0x01 /* MT bit: multi-topology */
#define OSPF_OPTION_E 0x02 /* E bit: External routes advertised */
#define OSPF_OPTION_MC 0x04 /* MC bit: Multicast capable */
#define OSPF_OPTION_NP 0x08 /* N/P bit: NSSA capable */
#define OSPF_OPTION_EA 0x10 /* EA bit: External Attribute capable */
#define OSPF_OPTION_L 0x10 /* L bit: Packet contains LLS data block */
#define OSPF_OPTION_DC 0x20 /* DC bit: Demand circuit capable */
#define OSPF_OPTION_O 0x40 /* O bit: Opaque LSA capable */
@ -117,8 +115,10 @@
/* rla_flags */
#define RLA_FLAG_B 0x01
#define RLA_FLAG_E 0x02
#define RLA_FLAG_W1 0x04
#define RLA_FLAG_W2 0x08
#define RLA_FLAG_V 0x04
#define RLA_FLAG_W 0x08
#define RLA_FLAG_NT 0x10 /* RFC3101 Appendix B */
#define RLA_FLAG_H 0x80
/* sla_tosmetric breakdown */
#define SLA_MASK_TOS 0x7f000000
@ -148,14 +148,14 @@
* TOS metric struct (will be 0 or more in router links update)
*/
struct tos_metric {
uint8_t tos_type;
uint8_t reserved;
uint8_t tos_metric[2];
nd_uint8_t tos_type;
nd_uint8_t reserved;
nd_uint16_t tos_metric;
};
struct tos_link {
uint8_t link_type;
uint8_t link_tos_count;
uint8_t tos_metric[2];
nd_uint8_t link_type;
nd_uint8_t link_tos_count;
nd_uint16_t tos_metric;
};
union un_tos {
struct tos_link link;
@ -164,20 +164,20 @@ union un_tos {
/* link state advertisement header */
struct lsa_hdr {
uint16_t ls_age;
uint8_t ls_options;
uint8_t ls_type;
nd_uint16_t ls_age;
nd_uint8_t ls_options;
nd_uint8_t ls_type;
union {
struct in_addr lsa_id;
nd_ipv4 lsa_id;
struct { /* opaque LSAs change the LSA-ID field */
uint8_t opaque_type;
uint8_t opaque_id[3];
nd_uint8_t opaque_type;
nd_uint24_t opaque_id;
} opaque_field;
} un_lsa_id;
struct in_addr ls_router;
uint32_t ls_seq;
uint16_t ls_chksum;
uint16_t ls_length;
nd_ipv4 ls_router;
nd_uint32_t ls_seq;
nd_uint16_t ls_chksum;
nd_uint16_t ls_length;
};
/* link state advertisement */
@ -188,68 +188,68 @@ struct lsa {
union {
/* Router links advertisements */
struct {
uint8_t rla_flags;
uint8_t rla_zero[1];
uint16_t rla_count;
nd_uint8_t rla_flags;
nd_byte rla_zero;
nd_uint16_t rla_count;
struct rlalink {
struct in_addr link_id;
struct in_addr link_data;
nd_ipv4 link_id;
nd_ipv4 link_data;
union un_tos un_tos;
} rla_link[1]; /* may repeat */
} un_rla;
/* Network links advertisements */
struct {
struct in_addr nla_mask;
struct in_addr nla_router[1]; /* may repeat */
nd_ipv4 nla_mask;
nd_ipv4 nla_router[1]; /* may repeat */
} un_nla;
/* Summary links advertisements */
struct {
struct in_addr sla_mask;
uint32_t sla_tosmetric[1]; /* may repeat */
nd_ipv4 sla_mask;
nd_uint32_t sla_tosmetric[1]; /* may repeat */
} un_sla;
/* AS external links advertisements */
struct {
struct in_addr asla_mask;
nd_ipv4 asla_mask;
struct aslametric {
uint32_t asla_tosmetric;
struct in_addr asla_forward;
struct in_addr asla_tag;
nd_uint32_t asla_tosmetric;
nd_ipv4 asla_forward;
nd_ipv4 asla_tag;
} asla_metric[1]; /* may repeat */
} un_asla;
/* Multicast group membership */
struct mcla {
uint32_t mcla_vtype;
struct in_addr mcla_vid;
nd_uint32_t mcla_vtype;
nd_ipv4 mcla_vid;
} un_mcla[1];
/* Opaque TE LSA */
struct {
uint16_t type;
uint16_t length;
uint8_t data[1]; /* may repeat */
} un_te_lsa_tlv;
nd_uint16_t type;
nd_uint16_t length;
nd_byte data[1]; /* may repeat */
} un_te_lsa_tlv[1]; /* may repeat */
/* Opaque Grace LSA */
struct {
uint16_t type;
uint16_t length;
uint8_t data[1]; /* may repeat */
} un_grace_tlv;
nd_uint16_t type;
nd_uint16_t length;
nd_byte data[1]; /* may repeat */
} un_grace_tlv[1]; /* may repeat */
/* Opaque Router information LSA */
struct {
uint16_t type;
uint16_t length;
uint8_t data[1]; /* may repeat */
} un_ri_tlv;
nd_uint16_t type;
nd_uint16_t length;
nd_byte data[1]; /* may repeat */
} un_ri_tlv[1]; /* may repeat */
/* Unknown LSA */
struct unknown {
uint8_t data[1]; /* may repeat */
nd_byte data[1]; /* may repeat */
} un_unknown[1];
} lsa_un;
@ -261,54 +261,54 @@ struct lsa {
* the main header
*/
struct ospfhdr {
uint8_t ospf_version;
uint8_t ospf_type;
uint16_t ospf_len;
struct in_addr ospf_routerid;
struct in_addr ospf_areaid;
uint16_t ospf_chksum;
uint16_t ospf_authtype;
uint8_t ospf_authdata[OSPF_AUTH_SIZE];
nd_uint8_t ospf_version;
nd_uint8_t ospf_type;
nd_uint16_t ospf_len;
nd_ipv4 ospf_routerid;
nd_ipv4 ospf_areaid;
nd_uint16_t ospf_chksum;
nd_uint16_t ospf_authtype;
nd_byte ospf_authdata[OSPF_AUTH_SIZE];
union {
/* Hello packet */
struct {
struct in_addr hello_mask;
uint16_t hello_helloint;
uint8_t hello_options;
uint8_t hello_priority;
uint32_t hello_deadint;
struct in_addr hello_dr;
struct in_addr hello_bdr;
struct in_addr hello_neighbor[1]; /* may repeat */
nd_ipv4 hello_mask;
nd_uint16_t hello_helloint;
nd_uint8_t hello_options;
nd_uint8_t hello_priority;
nd_uint32_t hello_deadint;
nd_ipv4 hello_dr;
nd_ipv4 hello_bdr;
nd_ipv4 hello_neighbor[1]; /* may repeat */
} un_hello;
/* Database Description packet */
struct {
uint16_t db_ifmtu;
uint8_t db_options;
uint8_t db_flags;
uint32_t db_seq;
nd_uint16_t db_ifmtu;
nd_uint8_t db_options;
nd_uint8_t db_flags;
nd_uint32_t db_seq;
struct lsa_hdr db_lshdr[1]; /* may repeat */
} un_db;
/* Link State Request */
struct lsr {
uint8_t ls_type[4];
nd_uint32_t ls_type;
union {
struct in_addr ls_stateid;
nd_ipv4 ls_stateid;
struct { /* opaque LSAs change the LSA-ID field */
uint8_t opaque_type;
uint8_t opaque_id[3];
nd_uint8_t opaque_type;
nd_uint24_t opaque_id;
} opaque_field;
} un_ls_stateid;
struct in_addr ls_router;
nd_ipv4 ls_router;
} un_lsr[1]; /* may repeat */
/* Link State Update */
struct {
uint32_t lsu_count;
struct lsa lsu_lsa[1]; /* may repeat */
nd_uint32_t lsu_count;
struct lsa lsu_lsa[1]; /* may repeat */
} un_lsu;
/* Link State Acknowledgement */

View File

@ -14,10 +14,10 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#include <config.h>
#endif
#include <netdissect-stdinc.h>
#include "netdissect-stdinc.h"
#include "netdissect.h"
#include "oui.h"
@ -48,6 +48,9 @@ const struct tok oui_values[] = {
{ OUI_ONLAB, "Open Networking Lab" },
{ OUI_FREESCALE, "Freescale" },
{ OUI_NETRONOME, "Netronome" },
{ OUI_BROADCOM, "Broadcom" },
{ OUI_PMC_SIERRA, "PMC-Sierra" },
{ OUI_ERICSSON, "Ericsson" },
{ 0, NULL }
};
@ -68,6 +71,8 @@ const struct tok smi_values[] = {
{ SMI_HEWLETT_PACKARD, "Hewlett Packard"},
{ SMI_SUN_MICROSYSTEMS, "Sun Microsystems"},
{ SMI_MERIT, "Merit"},
{ SMI_AT_AND_T, "AT&T"},
{ SMI_MOTOROLA, "Motorola"},
{ SMI_SHIVA, "Shiva"},
{ SMI_ERICSSON, "Ericsson AB"},
{ SMI_CISCO_VPN5000, "Cisco VPN 5000"},
@ -81,24 +86,46 @@ const struct tok smi_values[] = {
{ SMI_REDBACK, "Redback"},
{ SMI_JUNIPER, "Juniper Networks"},
{ SMI_APTIS, "Aptis"},
{ SMI_DT_AG, "Deutsche Telekom AG"},
{ SMI_IXIA, "Ixia Communications"},
{ SMI_CISCO_VPN3000, "Cisco VPN 3000"},
{ SMI_COSINE, "CoSine Communications"},
{ SMI_NETSCREEN, "Netscreen"},
{ SMI_SHASTA, "Shasta"},
{ SMI_NOMADIX, "Nomadix"},
{ SMI_T_MOBILE, "T-Mobile"},
{ SMI_BROADBAND_FORUM, "The Broadband Forum"},
{ SMI_ZTE, "ZTE"},
{ SMI_SIEMENS, "Siemens"},
{ SMI_CABLELABS, "CableLabs"},
{ SMI_UNISPHERE, "Unisphere Networks"},
{ SMI_CISCO_BBSM, "Cisco BBSM"},
{ SMI_THE3GPP2, "3rd Generation Partnership Project 2 (3GPP2)"},
{ SMI_SKT_TELECOM, "SK Telecom"},
{ SMI_IP_UNPLUGGED, "ipUnplugged"},
{ SMI_ISSANNI, "Issanni Communications"},
{ SMI_NETSCALER, "Netscaler"},
{ SMI_DE_TE_MOBIL, "T-Mobile"},
{ SMI_QUINTUM, "Quintum"},
{ SMI_INTERLINK, "Interlink"},
{ SMI_CNCTC, "CNCTC"},
{ SMI_STARENT_NETWORKS, "Starent Networks"},
{ SMI_COLUBRIS, "Colubris"},
{ SMI_COLUMBIA_UNIVERSITY, "Columbia University"},
{ SMI_THE3GPP, "3GPP"},
{ SMI_GEMTEK_SYSTEMS, "Gemtek-Systems"},
{ SMI_BARRACUDA, "Barracuda Networks"},
{ SMI_ERICSSON_PKT_CORE, "Ericsson AB - Packet Core Networks"},
{ SMI_DACOM, "dacom"},
{ SMI_COLUMBIA_UNIVERSITY, "Columbia University"},
{ SMI_FORTINET, "Fortinet"},
{ SMI_VERIZON, "Verizon Wireless"},
{ SMI_PLIXER, "Plixer"},
{ SMI_WIFI_ALLIANCE, "Wi-Fi Alliance"},
{ SMI_T_SYSTEMS_NOVA, "T-Systems Nova"},
{ SMI_CHINATELECOM_GUANZHOU, "China Telecom - Guangzhou Research Institute"},
{ SMI_GIGAMON, "Gigamon Systems"},
{ SMI_CACE, "CACE Technologies"},
{ SMI_NTOP, "ntop"},
{ SMI_ERICSSON_CANADA_INC, "Ericsson Canada"},
{ 0, NULL}
};

View File

@ -40,12 +40,15 @@ extern const struct tok smi_values[];
#define OUI_ONLAB 0xa42305 /* Open Networking Lab */
#define OUI_FREESCALE 0x00049f /* Freescale */
#define OUI_NETRONOME 0x0015ad /* Netronome */
#define OUI_BROADCOM 0x001018 /* Broadcom */
#define OUI_PMC_SIERRA 0x00e004 /* PMC-Sierra */
#define OUI_ERICSSON 0xd0f0db /* Ericsson */
/*
* These are SMI Network Management Private Enterprise Codes for
* organizations; see
*
* http://www.iana.org/assignments/enterprise-numbers
* https://www.iana.org/assignments/enterprise-numbers
*
* for a list.
*
@ -57,6 +60,8 @@ extern const struct tok smi_values[];
#define SMI_HEWLETT_PACKARD 11
#define SMI_SUN_MICROSYSTEMS 42
#define SMI_MERIT 61
#define SMI_AT_AND_T 74
#define SMI_MOTOROLA 161
#define SMI_SHIVA 166
#define SMI_ERICSSON 193
#define SMI_CISCO_VPN5000 255
@ -70,22 +75,45 @@ extern const struct tok smi_values[];
#define SMI_REDBACK 2352
#define SMI_JUNIPER 2636
#define SMI_APTIS 2637
#define SMI_DT_AG 2937
#define SMI_IXIA 3054
#define SMI_CISCO_VPN3000 3076
#define SMI_COSINE 3085
#define SMI_SHASTA 3199
#define SMI_NETSCREEN 3224
#define SMI_NOMADIX 3309
#define SMI_T_MOBILE 3414
#define SMI_BROADBAND_FORUM 3561
#define SMI_ZTE 3902
#define SMI_SIEMENS 4329
#define SMI_CABLELABS 4491
#define SMI_UNISPHERE 4874
#define SMI_CISCO_BBSM 5263
#define SMI_THE3GPP2 5535
#define SMI_SKT_TELECOM 5806
#define SMI_IP_UNPLUGGED 5925
#define SMI_ISSANNI 5948
#define SMI_NETSCALER 5951
#define SMI_DE_TE_MOBIL 6490
#define SMI_QUINTUM 6618
#define SMI_INTERLINK 6728
#define SMI_CNCTC 7951
#define SMI_STARENT_NETWORKS 8164
#define SMI_COLUBRIS 8744
#define SMI_COLUMBIA_UNIVERSITY 11862
#define SMI_THE3GPP 10415
#define SMI_GEMTEK_SYSTEMS 10529
#define SMI_BARRACUDA 10704
#define SMI_ERICSSON_PKT_CORE 10923
#define SMI_DACOM 11665
#define SMI_COLUMBIA_UNIVERSITY 11862
#define SMI_FORTINET 12356
#define SMI_VERIZON 12951
#define SMI_PLIXER 13745
#define SMI_WIFI_ALLIANCE 14122
#define SMI_T_SYSTEMS_NOVA 16787
#define SMI_CHINATELECOM_GUANZHOU 20942
#define SMI_GIGAMON 26866
#define SMI_CACE 32622
/* Greater than 32,767 need to be tagged unsigned. */
#define SMI_NTOP 35632u
#define SMI_ERICSSON_CANADA_INC 46098u

View File

@ -41,15 +41,18 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#include <config.h>
#endif
#include <netdissect-stdinc.h>
#include "netdissect-stdinc.h"
#include <stdio.h>
#include <string.h>
#include "netdissect-ctype.h"
#include "netdissect.h"
#include "extract.h"
#include "nfsfh.h"
/*
@ -76,42 +79,16 @@
#define FHT_HPUX9 11
#define FHT_BSD44 12
#ifdef ultrix
/* Nasty hack to keep the Ultrix C compiler from emitting bogus warnings */
#define XFF(x) ((uint32_t)(x))
#else
#define XFF(x) (x)
#endif
#define make_uint32(msb,b,c,lsb)\
(XFF(lsb) + (XFF(c)<<8) + (XFF(b)<<16) + (XFF(msb)<<24))
#define make_uint24(msb,b, lsb)\
(XFF(lsb) + (XFF(b)<<8) + (XFF(msb)<<16))
#define make_uint16(msb,lsb)\
(XFF(lsb) + (XFF(msb)<<8))
#ifdef __alpha
/* or other 64-bit systems */
#define make_uint48(msb,b,c,d,e,lsb)\
((lsb) + ((e)<<8) + ((d)<<16) + ((c)<<24) + ((b)<<32) + ((msb)<<40))
#else
/* on 32-bit systems ignore high-order bits */
#define make_uint48(msb,b,c,d,e,lsb)\
((lsb) + ((e)<<8) + ((d)<<16) + ((c)<<24))
#endif
static int is_UCX(const unsigned char *, u_int);
static int is_UCX(netdissect_options *, const unsigned char *, u_int);
void
Parse_fh(register const unsigned char *fh, u_int len, my_fsid *fsidp,
uint32_t *inop,
Parse_fh(netdissect_options *ndo, 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) */
int ourself) /* true if file handle was generated on this host */
{
register const unsigned char *fhp = fh;
const unsigned char *fhp = fh;
uint32_t temp;
int fhtype = FHT_UNKNOWN;
u_int i;
@ -154,10 +131,10 @@ Parse_fh(register const unsigned char *fh, u_int len, my_fsid *fsidp,
/*
* This is basically a big decision tree
*/
else if ((fhp[0] == 0) && (fhp[1] == 0)) {
else if ((GET_U_1(fhp) == 0) && (GET_U_1(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)) {
if ((GET_U_1(fhp + 2) == 0) && (GET_U_1(fhp + 3) == 0)) {
/* bytes[2,3] == (0,0); must be Auspex */
/* XXX or could be Ultrix+MASSBUS "hp" disk? */
fhtype = FHT_AUSPEX;
@ -167,16 +144,16 @@ Parse_fh(register const unsigned char *fh, u_int len, my_fsid *fsidp,
* 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)) {
if ((GET_U_1(fhp + 4) != 0) && (GET_U_1(fhp + 5) == 0) &&
(GET_U_1(fhp + 8) == 12) && (GET_U_1(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)) {
if ((GET_U_1(fhp + 4) == 0) && (GET_U_1(fhp + 5) == 8) && (GET_U_1(fhp + 6) == 0) &&
(GET_U_1(fhp + 7) == 0)) {
/* looks like a length, not a file system typecode */
fhtype = FHT_IRIX4;
}
@ -193,24 +170,24 @@ Parse_fh(register const unsigned char *fh, u_int len, my_fsid *fsidp,
* could be IRIX5, DECOSF, UCX, Ultrix, SUNOS5
* could be AIX, HP-UX
*/
if ((fhp[2] == 0) && (fhp[3] == 0)) {
if ((GET_U_1(fhp + 2) == 0) && (GET_U_1(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)) {
if ((GET_U_1(fhp + 6) == 0) && (GET_U_1(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)) {
else if ((len >= 24/4) && (GET_U_1(fhp + 21) == 0) && (GET_U_1(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)
if (GET_U_1(fhp + 9) == 10)
fhtype = FHT_SUNOS5;
/* XXX what about AIX? */
}
@ -220,17 +197,17 @@ Parse_fh(register const unsigned char *fh, u_int len, my_fsid *fsidp,
* 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)) {
if ((GET_U_1(fhp + 8) == 12) && (GET_U_1(fhp + 9) == 0)) {
fhtype = FHT_DECOSF;
}
else if ((fhp[8] == 0) && (fhp[9] == 10)) {
else if ((GET_U_1(fhp + 8) == 0) && (GET_U_1(fhp + 9) == 10)) {
/* could be SUNOS5/IRIX5, AIX, HP-UX */
if ((fhp[7] == 0) && (fhp[6] == 0) &&
(fhp[5] == 0) && (fhp[4] == 0)) {
if ((GET_U_1(fhp + 7) == 0) && (GET_U_1(fhp + 6) == 0) &&
(GET_U_1(fhp + 5) == 0) && (GET_U_1(fhp + 4) == 0)) {
/* XXX is this always true of HP-UX? */
fhtype = FHT_HPUX9;
}
else if (fhp[7] == 2) {
else if (GET_U_1(fhp + 7) == 2) {
/* This would be MNT_NFS on AIX, which is impossible */
fhtype = FHT_SUNOS5; /* or maybe IRIX5 */
}
@ -245,7 +222,7 @@ Parse_fh(register const unsigned char *fh, u_int len, my_fsid *fsidp,
}
}
else {
if (is_UCX(fhp, len)) {
if (is_UCX(ndo, fhp, len)) {
fhtype = FHT_VMSUCX;
}
else {
@ -260,57 +237,57 @@ Parse_fh(register const unsigned char *fh, u_int len, my_fsid *fsidp,
switch (fhtype) {
case FHT_AUSPEX:
fsidp->Fsid_dev.Minor = fhp[7];
fsidp->Fsid_dev.Major = fhp[6];
fsidp->Fsid_dev.Minor = GET_U_1(fhp + 7);
fsidp->Fsid_dev.Major = GET_U_1(fhp + 6);
fsidp->fsid_code = 0;
*inop = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
*inop = GET_BE_U_4(fhp + 12);
if (osnamep)
*osnamep = "Auspex";
break;
case FHT_BSD44:
fsidp->Fsid_dev.Minor = fhp[0];
fsidp->Fsid_dev.Major = fhp[1];
fsidp->Fsid_dev.Minor = GET_U_1(fhp);
fsidp->Fsid_dev.Major = GET_U_1(fhp + 1);
fsidp->fsid_code = 0;
*inop = make_uint32(fhp[15], fhp[14], fhp[13], fhp[12]);
*inop = GET_LE_U_4(fhp + 12);
if (osnamep)
*osnamep = "BSD 4.4";
break;
case FHT_DECOSF:
fsidp->fsid_code = make_uint32(fhp[7], fhp[6], fhp[5], fhp[4]);
fsidp->fsid_code = GET_LE_U_4(fhp + 4);
/* XXX could ignore 3 high-order bytes */
temp = make_uint32(fhp[3], fhp[2], fhp[1], fhp[0]);
temp = GET_LE_U_4(fhp);
fsidp->Fsid_dev.Minor = temp & 0xFFFFF;
fsidp->Fsid_dev.Major = (temp>>20) & 0xFFF;
*inop = make_uint32(fhp[15], fhp[14], fhp[13], fhp[12]);
*inop = GET_LE_U_4(fhp + 12);
if (osnamep)
*osnamep = "OSF";
break;
case FHT_IRIX4:
fsidp->Fsid_dev.Minor = fhp[3];
fsidp->Fsid_dev.Major = fhp[2];
fsidp->Fsid_dev.Minor = GET_U_1(fhp + 3);
fsidp->Fsid_dev.Major = GET_U_1(fhp + 2);
fsidp->fsid_code = 0;
*inop = make_uint32(fhp[8], fhp[9], fhp[10], fhp[11]);
*inop = GET_BE_U_4(fhp + 8);
if (osnamep)
*osnamep = "IRIX4";
break;
case FHT_IRIX5:
fsidp->Fsid_dev.Minor = make_uint16(fhp[2], fhp[3]);
fsidp->Fsid_dev.Major = make_uint16(fhp[0], fhp[1]);
fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]);
fsidp->Fsid_dev.Minor = GET_BE_U_2(fhp + 2);
fsidp->Fsid_dev.Major = GET_BE_U_2(fhp);
fsidp->fsid_code = GET_BE_U_4(fhp + 4);
*inop = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
*inop = GET_BE_U_4(fhp + 12);
if (osnamep)
*osnamep = "IRIX5";
@ -328,24 +305,24 @@ Parse_fh(register const unsigned char *fh, u_int len, my_fsid *fsidp,
#endif
case FHT_SUNOS4:
fsidp->Fsid_dev.Minor = fhp[3];
fsidp->Fsid_dev.Major = fhp[2];
fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]);
fsidp->Fsid_dev.Minor = GET_U_1(fhp + 3);
fsidp->Fsid_dev.Major = GET_U_1(fhp + 2);
fsidp->fsid_code = GET_BE_U_4(fhp + 4);
*inop = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
*inop = GET_BE_U_4(fhp + 12);
if (osnamep)
*osnamep = "SUNOS4";
break;
case FHT_SUNOS5:
temp = make_uint16(fhp[0], fhp[1]);
temp = GET_BE_U_2(fhp);
fsidp->Fsid_dev.Major = (temp>>2) & 0x3FFF;
temp = make_uint24(fhp[1], fhp[2], fhp[3]);
temp = GET_BE_U_3(fhp + 1);
fsidp->Fsid_dev.Minor = temp & 0x3FFFF;
fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]);
fsidp->fsid_code = GET_BE_U_4(fhp + 4);
*inop = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
*inop = GET_BE_U_4(fhp + 12);
if (osnamep)
*osnamep = "SUNOS5";
@ -353,10 +330,10 @@ Parse_fh(register const unsigned char *fh, u_int len, my_fsid *fsidp,
case FHT_ULTRIX:
fsidp->fsid_code = 0;
fsidp->Fsid_dev.Minor = fhp[0];
fsidp->Fsid_dev.Major = fhp[1];
fsidp->Fsid_dev.Minor = GET_U_1(fhp);
fsidp->Fsid_dev.Major = GET_U_1(fhp + 1);
temp = make_uint32(fhp[7], fhp[6], fhp[5], fhp[4]);
temp = GET_LE_U_4(fhp + 4);
*inop = temp;
if (osnamep)
*osnamep = "Ultrix";
@ -381,34 +358,36 @@ Parse_fh(register const unsigned char *fh, u_int len, my_fsid *fsidp,
}
/* VMS file ID is: (RVN, FidHi, FidLo) */
*inop = make_uint32(fhp[26], fhp[27], fhp[23], fhp[22]);
*inop = (((uint32_t) GET_U_1(fhp + 26)) << 24) |
(((uint32_t) GET_U_1(fhp + 27)) << 16) |
(GET_LE_U_2(fhp + 22) << 0);
/* Caller must save (and null-terminate?) this value */
if (fsnamep)
*fsnamep = (const char *)&(fhp[1]);
*fsnamep = (const char *)(fhp + 1);
if (osnamep)
*osnamep = "VMS";
break;
case FHT_AIX32:
fsidp->Fsid_dev.Minor = make_uint16(fhp[2], fhp[3]);
fsidp->Fsid_dev.Major = make_uint16(fhp[0], fhp[1]);
fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]);
fsidp->Fsid_dev.Minor = GET_BE_U_2(fhp + 2);
fsidp->Fsid_dev.Major = GET_BE_U_2(fhp);
fsidp->fsid_code = GET_BE_U_4(fhp + 4);
*inop = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
*inop = GET_BE_U_4(fhp + 12);
if (osnamep)
*osnamep = "AIX32";
break;
case FHT_HPUX9:
fsidp->Fsid_dev.Major = fhp[0];
temp = make_uint24(fhp[1], fhp[2], fhp[3]);
fsidp->Fsid_dev.Major = GET_U_1(fhp);
temp = GET_BE_U_3(fhp + 1);
fsidp->Fsid_dev.Minor = temp;
fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]);
fsidp->fsid_code = GET_BE_U_4(fhp + 4);
*inop = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
*inop = GET_BE_U_4(fhp + 12);
if (osnamep)
*osnamep = "HPUX9";
@ -418,12 +397,13 @@ Parse_fh(register const unsigned char *fh, u_int len, my_fsid *fsidp,
#ifdef DEBUG
/* XXX debugging */
for (i = 0; i < len*4; i++)
(void)fprintf(stderr, "%x.", fhp[i]);
(void)fprintf(stderr, "%x.", GET_U_1(fhp + i));
(void)fprintf(stderr, "\n");
#endif
/* Save the actual handle, so it can be display with -u */
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]);
(void)snprintf(&(fsidp->Opaque_Handle[i*2]), 3, "%.2X",
GET_U_1(fhp + i));
fsidp->Opaque_Handle[i*2] = '\0';
/* XXX for now, give "bogus" values to aid debugging */
@ -451,9 +431,9 @@ Parse_fh(register const unsigned char *fh, u_int len, my_fsid *fsidp,
* (3) followed by string of nulls
*/
static int
is_UCX(const unsigned char *fhp, u_int len)
is_UCX(netdissect_options *ndo, const unsigned char *fhp, u_int len)
{
register u_int i;
u_int i;
int seen_null = 0;
/*
@ -464,13 +444,13 @@ is_UCX(const unsigned char *fhp, u_int len)
return(0);
for (i = 1; i < 14; i++) {
if (ND_ISPRINT(fhp[i])) {
if (ND_ASCII_ISPRINT(GET_U_1(fhp + i))) {
if (seen_null)
return(0);
else
continue;
}
else if (fhp[i] == 0) {
else if (GET_U_1(fhp + i) == 0) {
seen_null = 1;
continue;
}

View File

@ -1,31 +0,0 @@
/*
* Copyright (c) 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
* the University nor the names of its contributors may be used to endorse
* or promote products derived from this software without specific prior
* written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#include <stdio.h>
#include <pcap.h>
#include "pcap-missing.h"
long
pcap_dump_ftell(pcap_dumper_t *p)
{
return (ftell((FILE *)p));
}

152
contrib/tcpdump/pflog.h Normal file
View File

@ -0,0 +1,152 @@
/*
* Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* pflog headers, at least as they exist now.
*/
#define PFLOG_IFNAMSIZ 16
#define PFLOG_RULESET_NAME_SIZE 16
/*
* Direction values.
*/
#define PF_INOUT 0
#define PF_IN 1
#define PF_OUT 2
#if defined(__OpenBSD__)
#define PF_FWD 3
#endif
/*
* Reason values.
*/
#define PFRES_MATCH 0
#define PFRES_BADOFF 1
#define PFRES_FRAG 2
#define PFRES_SHORT 3
#define PFRES_NORM 4
#define PFRES_MEMORY 5
#define PFRES_TS 6
#define PFRES_CONGEST 7
#define PFRES_IPOPTIONS 8
#define PFRES_PROTCKSUM 9
#define PFRES_BADSTATE 10
#define PFRES_STATEINS 11
#define PFRES_MAXSTATES 12
#define PFRES_SRCLIMIT 13
#define PFRES_SYNPROXY 14
#if defined(__FreeBSD__)
#define PFRES_MAPFAILED 15
#elif defined(__NetBSD__)
#define PFRES_STATELOCKED 15
#elif defined(__OpenBSD__)
#define PFRES_TRANSLATE 15
#define PFRES_NOROUTE 16
#elif defined(__APPLE__)
#define PFRES_DUMMYNET 15
#endif
/*
* Action values.
*/
#define PF_PASS 0
#define PF_DROP 1
#define PF_SCRUB 2
#define PF_NOSCRUB 3
#define PF_NAT 4
#define PF_NONAT 5
#define PF_BINAT 6
#define PF_NOBINAT 7
#define PF_RDR 8
#define PF_NORDR 9
#define PF_SYNPROXY_DROP 10
#if defined(__FreeBSD__)
#define PF_DEFER 11
#define PF_MATCH 12
#elif defined(__OpenBSD__)
#define PF_DEFER 11
#define PF_MATCH 12
#define PF_DIVERT 13
#define PF_RT 14
#define PF_AFRT 15
#elif defined(__APPLE__)
#define PF_DUMMYNET 11
#define PF_NODUMMYNET 12
#define PF_NAT64 13
#define PF_NONAT64 14
#endif
struct pf_addr {
union {
nd_ipv4 v4;
nd_ipv6 v6;
} pfa; /* 128-bit address */
#define v4 pfa.v4
#define v6 pfa.v6
};
struct pfloghdr {
uint8_t length;
uint8_t af;
uint8_t action;
uint8_t reason;
char ifname[PFLOG_IFNAMSIZ];
char ruleset[PFLOG_RULESET_NAME_SIZE];
uint32_t rulenr;
uint32_t subrulenr;
uint32_t uid;
int32_t pid;
uint32_t rule_uid;
int32_t rule_pid;
uint8_t dir;
#if defined(__OpenBSD__)
uint8_t rewritten;
uint8_t naf;
uint8_t pad[1];
#else
uint8_t pad[3];
#endif
#if defined(__FreeBSD__)
uint32_t ridentifier;
uint8_t reserve;
uint8_t pad2[3];
#elif defined(__OpenBSD__)
struct pf_addr saddr;
struct pf_addr daddr;
uint16_t sport;
uint16_t dport;
#endif
};

View File

@ -19,8 +19,8 @@
#define PPP_ADDRESS 0xff /* The address byte value */
#define PPP_CONTROL 0x03 /* The control byte value */
#define PPP_WITHDIRECTION_IN 0x00 /* non-standard for DLT_PPP_WITHDIRECTION */
#define PPP_WITHDIRECTION_OUT 0x01 /* non-standard for DLT_PPP_WITHDIRECTION */
#define PPP_PPPD_IN 0x00 /* non-standard for DLT_PPP_PPPD */
#define PPP_PPPD_OUT 0x01 /* non-standard for DLT_PPP_PPPD */
/* Protocol numbers */
#define PPP_IP 0x0021 /* Raw IP */
@ -34,9 +34,9 @@
#define PPP_BRPDU 0x0031 /* Bridging PDU */
#define PPP_STII 0x0033 /* Stream Protocol (ST-II) */
#define PPP_VINES 0x0035 /* Banyan Vines */
#define PPP_ML 0x003d /* Multi-Link PPP */
#define PPP_ML 0x003d /* Multi-Link PPP */
#define PPP_IPV6 0x0057 /* IPv6 */
#define PPP_COMP 0x00fd /* Compressed Datagram */
#define PPP_COMP 0x00fd /* Compressed Datagram */
#define PPP_HELLO 0x0201 /* 802.1d Hello Packets */
#define PPP_LUXCOM 0x0231 /* Luxcom */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -24,41 +24,52 @@
/* \summary: IPSEC Authentication Header printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#include <config.h>
#endif
#include <netdissect-stdinc.h>
#include "ah.h"
#include "netdissect-stdinc.h"
#include "netdissect.h"
#include "extract.h"
int
ah_print(netdissect_options *ndo, register const u_char *bp)
{
register const struct ah *ah;
int sumlen;
#include "ah.h"
int
ah_print(netdissect_options *ndo, const u_char *bp)
{
const struct ah *ah;
uint8_t ah_len;
u_int ah_hdr_len;
uint16_t reserved;
const u_char *p;
ndo->ndo_protocol = "ah";
ah = (const struct ah *)bp;
ND_TCHECK(*ah);
nd_print_protocol_caps(ndo);
/*
* RFC4302
*
* 2.2. Payload Length
*
* This 8-bit field specifies the length of AH in 32-bit words (4-byte
* units), minus "2".
*/
ah_len = GET_U_1(ah->ah_len);
ah_hdr_len = (ah_len + 2) * 4;
sumlen = ah->ah_len << 2;
ND_PRINT((ndo, "AH(spi=0x%08x", EXTRACT_32BITS(&ah->ah_spi)));
ND_PRINT("(");
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 (!ND_TTEST2(*bp, sizeof(struct ah) + sumlen)) {
ND_PRINT((ndo, "[truncated]):"));
return -1;
}
ND_PRINT((ndo, "): "));
ND_PRINT("length=%u(%u-bytes),", ah_len, ah_hdr_len);
reserved = GET_BE_U_2(ah->ah_reserved);
if (reserved)
ND_PRINT("reserved=0x%x[MustBeZero],", reserved);
ND_PRINT("spi=0x%08x,", GET_BE_U_4(ah->ah_spi));
ND_PRINT("seq=0x%x,", GET_BE_U_4(ah->ah_seq));
ND_PRINT("icv=0x");
for (p = (const u_char *)(ah + 1); p < bp + ah_hdr_len; p++)
ND_PRINT("%02x", GET_U_1(p));
ND_PRINT("): ");
return sizeof(struct ah) + sumlen;
trunc:
ND_PRINT((ndo, "[|AH]"));
return -1;
return ah_hdr_len;
}

View File

@ -30,16 +30,16 @@
/* Based on draft-chroboczek-ahcp-00 and source code of ahcpd-0.53 */
#ifdef HAVE_CONFIG_H
#include "config.h"
#include <config.h>
#endif
#include <netdissect-stdinc.h>
#include "netdissect-stdinc.h"
#define ND_LONGJMP_FROM_TCHECK
#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
static const char tstr[] = " [|ahcp]";
#define AHCP_MAGIC_NUMBER 43
#define AHCP_VERSION_1 1
@ -97,151 +97,126 @@ static const struct tok ahcp1_opt_str[] = {
{ 0, NULL }
};
static int
ahcp_time_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
static void
ahcp_time_print(netdissect_options *ndo,
const u_char *cp, uint8_t len)
{
time_t t;
struct tm *tm;
char buf[BUFSIZE];
char buf[sizeof("-yyyyyyyyyy-mm-dd hh:mm:ss UTC")];
if (cp + 4 != ep)
if (len != 4)
goto invalid;
ND_TCHECK2(*cp, 4);
t = EXTRACT_32BITS(cp);
if (NULL == (tm = gmtime(&t)))
ND_PRINT((ndo, ": gmtime() error"));
else if (0 == strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", tm))
ND_PRINT((ndo, ": strftime() error"));
else
ND_PRINT((ndo, ": %s UTC", buf));
return 0;
t = GET_BE_U_4(cp);
ND_PRINT(": %s",
nd_format_time(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S UTC",
gmtime(&t)));
return;
invalid:
ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return 0;
trunc:
ND_PRINT((ndo, "%s", tstr));
return -1;
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
}
static int
ahcp_seconds_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
static void
ahcp_seconds_print(netdissect_options *ndo,
const u_char *cp, uint8_t len)
{
if (cp + 4 != ep)
if (len != 4)
goto invalid;
ND_TCHECK2(*cp, 4);
ND_PRINT((ndo, ": %us", EXTRACT_32BITS(cp)));
return 0;
ND_PRINT(": %us", GET_BE_U_4(cp));
return;
invalid:
ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return 0;
trunc:
ND_PRINT((ndo, "%s", tstr));
return -1;
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
}
static int
ahcp_ipv6_addresses_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
static void
ahcp_ipv6_addresses_print(netdissect_options *ndo,
const u_char *cp, uint8_t len)
{
const char *sep = ": ";
while (cp < ep) {
if (cp + 16 > ep)
while (len) {
if (len < 16)
goto invalid;
ND_TCHECK2(*cp, 16);
ND_PRINT((ndo, "%s%s", sep, ip6addr_string(ndo, cp)));
ND_PRINT("%s%s", sep, GET_IP6ADDR_STRING(cp));
cp += 16;
len -= 16;
sep = ", ";
}
return 0;
return;
invalid:
ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return 0;
trunc:
ND_PRINT((ndo, "%s", tstr));
return -1;
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
}
static int
ahcp_ipv4_addresses_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
static void
ahcp_ipv4_addresses_print(netdissect_options *ndo,
const u_char *cp, uint8_t len)
{
const char *sep = ": ";
while (cp < ep) {
if (cp + 4 > ep)
while (len) {
if (len < 4)
goto invalid;
ND_TCHECK2(*cp, 4);
ND_PRINT((ndo, "%s%s", sep, ipaddr_string(ndo, cp)));
ND_PRINT("%s%s", sep, GET_IPADDR_STRING(cp));
cp += 4;
len -= 4;
sep = ", ";
}
return 0;
return;
invalid:
ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return 0;
trunc:
ND_PRINT((ndo, "%s", tstr));
return -1;
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
}
static int
ahcp_ipv6_prefixes_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
static void
ahcp_ipv6_prefixes_print(netdissect_options *ndo,
const u_char *cp, uint8_t len)
{
const char *sep = ": ";
while (cp < ep) {
if (cp + 17 > ep)
while (len) {
if (len < 17)
goto invalid;
ND_TCHECK2(*cp, 17);
ND_PRINT((ndo, "%s%s/%u", sep, ip6addr_string(ndo, cp), *(cp + 16)));
ND_PRINT("%s%s/%u", sep, GET_IP6ADDR_STRING(cp), GET_U_1(cp + 16));
cp += 17;
len -= 17;
sep = ", ";
}
return 0;
return;
invalid:
ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return 0;
trunc:
ND_PRINT((ndo, "%s", tstr));
return -1;
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
}
static int
ahcp_ipv4_prefixes_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
static void
ahcp_ipv4_prefixes_print(netdissect_options *ndo,
const u_char *cp, uint8_t len)
{
const char *sep = ": ";
while (cp < ep) {
if (cp + 5 > ep)
while (len) {
if (len < 5)
goto invalid;
ND_TCHECK2(*cp, 5);
ND_PRINT((ndo, "%s%s/%u", sep, ipaddr_string(ndo, cp), *(cp + 4)));
ND_PRINT("%s%s/%u", sep, GET_IPADDR_STRING(cp), GET_U_1(cp + 4));
cp += 5;
len -= 5;
sep = ", ";
}
return 0;
return;
invalid:
ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return 0;
trunc:
ND_PRINT((ndo, "%s", tstr));
return -1;
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
}
/* Data decoders signal truncated data with -1. */
static int
(* const data_decoders[AHCP1_OPT_MAX + 1])(netdissect_options *, const u_char *, const u_char *) = {
static void
(* const data_decoders[AHCP1_OPT_MAX + 1])(netdissect_options *, const u_char *, uint8_t) = {
/* [AHCP1_OPT_PAD] = */ NULL,
/* [AHCP1_OPT_MANDATORY] = */ NULL,
/* [AHCP1_OPT_ORIGIN_TIME] = */ ahcp_time_print,
@ -259,153 +234,151 @@ static int
};
static void
ahcp1_options_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
ahcp1_options_print(netdissect_options *ndo,
const u_char *cp, uint16_t len)
{
uint8_t option_no, option_len;
while (len) {
uint8_t option_no, option_len;
while (cp < ep) {
/* Option no */
ND_TCHECK2(*cp, 1);
option_no = *cp;
option_no = GET_U_1(cp);
cp += 1;
ND_PRINT((ndo, "\n\t %s", tok2str(ahcp1_opt_str, "Unknown-%u", option_no)));
len -= 1;
ND_PRINT("\n\t %s", tok2str(ahcp1_opt_str, "Unknown-%u", option_no));
if (option_no == AHCP1_OPT_PAD || option_no == AHCP1_OPT_MANDATORY)
continue;
/* Length */
if (cp + 1 > ep)
if (!len)
goto invalid;
ND_TCHECK2(*cp, 1);
option_len = *cp;
option_len = GET_U_1(cp);
cp += 1;
if (cp + option_len > ep)
len -= 1;
if (option_len > len)
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)
break; /* truncated and already marked up */
data_decoders[option_no](ndo, cp, option_len);
} else {
ND_PRINT((ndo, " (Length %u)", option_len));
ND_TCHECK2(*cp, option_len);
ND_PRINT(" (Length %u)", option_len);
ND_TCHECK_LEN(cp, option_len);
}
cp += option_len;
len -= option_len;
}
return;
invalid:
ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return;
trunc:
ND_PRINT((ndo, "%s", tstr));
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
}
static void
ahcp1_body_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
ahcp1_body_print(netdissect_options *ndo,
const u_char *cp, u_int len)
{
uint8_t type, mbz;
uint16_t body_len;
if (cp + AHCP1_BODY_MIN_LEN > ep)
if (len < AHCP1_BODY_MIN_LEN)
goto invalid;
/* Type */
ND_TCHECK2(*cp, 1);
type = *cp;
type = GET_U_1(cp);
cp += 1;
len -= 1;
/* MBZ */
ND_TCHECK2(*cp, 1);
mbz = *cp;
mbz = GET_U_1(cp);
cp += 1;
len -= 1;
/* Length */
ND_TCHECK2(*cp, 2);
body_len = EXTRACT_16BITS(cp);
body_len = GET_BE_U_2(cp);
cp += 2;
len -= 2;
if (ndo->ndo_vflag) {
ND_PRINT((ndo, "\n\t%s", tok2str(ahcp1_msg_str, "Unknown-%u", type)));
ND_PRINT("\n\t%s", tok2str(ahcp1_msg_str, "Unknown-%u", type));
if (mbz != 0)
ND_PRINT((ndo, ", MBZ %u", mbz));
ND_PRINT((ndo, ", Length %u", body_len));
ND_PRINT(", MBZ %u", mbz);
ND_PRINT(", Length %u", body_len);
}
if (cp + body_len > ep)
if (body_len > len)
goto invalid;
/* Options */
/* Here use "body_len", not "len" (ignore any extra data). */
if (ndo->ndo_vflag >= 2)
ahcp1_options_print(ndo, cp, cp + body_len); /* not ep (ignore extra data) */
ahcp1_options_print(ndo, cp, body_len);
else
ND_TCHECK2(*cp, body_len);
ND_TCHECK_LEN(cp, body_len);
return;
invalid:
ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return;
trunc:
ND_PRINT((ndo, "%s", tstr));
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
}
void
ahcp_print(netdissect_options *ndo, const u_char *cp, const u_int len)
ahcp_print(netdissect_options *ndo,
const u_char *cp, u_int len)
{
const u_char *ep = cp + len;
uint8_t version;
ND_PRINT((ndo, "AHCP"));
ndo->ndo_protocol = "ahcp";
nd_print_protocol_caps(ndo);
if (len < 2)
goto invalid;
/* Magic */
ND_TCHECK2(*cp, 1);
if (*cp != AHCP_MAGIC_NUMBER)
if (GET_U_1(cp) != AHCP_MAGIC_NUMBER)
goto invalid;
cp += 1;
len -= 1;
/* Version */
ND_TCHECK2(*cp, 1);
version = *cp;
version = GET_U_1(cp);
cp += 1;
len -= 1;
switch (version) {
case AHCP_VERSION_1: {
ND_PRINT((ndo, " Version 1"));
if (len < AHCP1_HEADER_FIX_LEN)
ND_PRINT(" Version 1");
if (len < AHCP1_HEADER_FIX_LEN - 2)
goto invalid;
if (!ndo->ndo_vflag) {
ND_TCHECK2(*cp, AHCP1_HEADER_FIX_LEN - 2);
ND_TCHECK_LEN(cp, AHCP1_HEADER_FIX_LEN - 2);
cp += AHCP1_HEADER_FIX_LEN - 2;
len -= AHCP1_HEADER_FIX_LEN - 2;
} else {
/* Hopcount */
ND_TCHECK2(*cp, 1);
ND_PRINT((ndo, "\n\tHopcount %u", *cp));
ND_PRINT("\n\tHopcount %u", GET_U_1(cp));
cp += 1;
len -= 1;
/* Original Hopcount */
ND_TCHECK2(*cp, 1);
ND_PRINT((ndo, ", Original Hopcount %u", *cp));
ND_PRINT(", Original Hopcount %u", GET_U_1(cp));
cp += 1;
len -= 1;
/* Nonce */
ND_TCHECK2(*cp, 4);
ND_PRINT((ndo, ", Nonce 0x%08x", EXTRACT_32BITS(cp)));
ND_PRINT(", Nonce 0x%08x", GET_BE_U_4(cp));
cp += 4;
len -= 4;
/* Source Id */
ND_TCHECK2(*cp, 8);
ND_PRINT((ndo, ", Source Id %s", linkaddr_string(ndo, cp, 0, 8)));
ND_PRINT(", Source Id %s", GET_LINKADDR_STRING(cp, LINKADDR_OTHER, 8));
cp += 8;
len -= 8;
/* Destination Id */
ND_TCHECK2(*cp, 8);
ND_PRINT((ndo, ", Destination Id %s", linkaddr_string(ndo, cp, 0, 8)));
ND_PRINT(", Destination Id %s", GET_LINKADDR_STRING(cp, LINKADDR_OTHER, 8));
cp += 8;
len -= 8;
}
/* Body */
ahcp1_body_print(ndo, cp, ep);
ahcp1_body_print(ndo, cp, len);
break;
}
default:
ND_PRINT((ndo, " Version %u (unknown)", version));
ND_PRINT(" Version %u (unknown)", version);
ND_TCHECK_LEN(cp, len);
break;
}
return;
invalid:
ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return;
trunc:
ND_PRINT((ndo, "%s", tstr));
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
}

View File

@ -33,10 +33,10 @@
/* \summary: Ad hoc On-Demand Distance Vector (AODV) Routing printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#include <config.h>
#endif
#include <netdissect-stdinc.h>
#include "netdissect-stdinc.h"
#include "netdissect.h"
#include "addrtoname.h"
@ -46,37 +46,37 @@
* RFC 3561
*/
struct aodv_rreq {
uint8_t rreq_type; /* AODV message type (1) */
uint8_t rreq_flags; /* various flags */
uint8_t rreq_zero0; /* reserved, set to zero */
uint8_t rreq_hops; /* number of hops from originator */
uint32_t rreq_id; /* request ID */
uint32_t rreq_da; /* destination IPv4 address */
uint32_t rreq_ds; /* destination sequence number */
uint32_t rreq_oa; /* originator IPv4 address */
uint32_t rreq_os; /* originator sequence number */
nd_uint8_t rreq_type; /* AODV message type (1) */
nd_uint8_t rreq_flags; /* various flags */
nd_uint8_t rreq_zero0; /* reserved, set to zero */
nd_uint8_t rreq_hops; /* number of hops from originator */
nd_uint32_t rreq_id; /* request ID */
nd_ipv4 rreq_da; /* destination IPv4 address */
nd_uint32_t rreq_ds; /* destination sequence number */
nd_ipv4 rreq_oa; /* originator IPv4 address */
nd_uint32_t rreq_os; /* originator sequence number */
};
struct aodv_rreq6 {
uint8_t rreq_type; /* AODV message type (1) */
uint8_t rreq_flags; /* various flags */
uint8_t rreq_zero0; /* reserved, set to zero */
uint8_t rreq_hops; /* number of hops from originator */
uint32_t rreq_id; /* request ID */
struct in6_addr rreq_da; /* destination IPv6 address */
uint32_t rreq_ds; /* destination sequence number */
struct in6_addr rreq_oa; /* originator IPv6 address */
uint32_t rreq_os; /* originator sequence number */
nd_uint8_t rreq_type; /* AODV message type (1) */
nd_uint8_t rreq_flags; /* various flags */
nd_uint8_t rreq_zero0; /* reserved, set to zero */
nd_uint8_t rreq_hops; /* number of hops from originator */
nd_uint32_t rreq_id; /* request ID */
nd_ipv6 rreq_da; /* destination IPv6 address */
nd_uint32_t rreq_ds; /* destination sequence number */
nd_ipv6 rreq_oa; /* originator IPv6 address */
nd_uint32_t rreq_os; /* originator sequence number */
};
struct aodv_rreq6_draft_01 {
uint8_t rreq_type; /* AODV message type (16) */
uint8_t rreq_flags; /* various flags */
uint8_t rreq_zero0; /* reserved, set to zero */
uint8_t rreq_hops; /* number of hops from originator */
uint32_t rreq_id; /* request ID */
uint32_t rreq_ds; /* destination sequence number */
uint32_t rreq_os; /* originator sequence number */
struct in6_addr rreq_da; /* destination IPv6 address */
struct in6_addr rreq_oa; /* originator IPv6 address */
nd_uint8_t rreq_type; /* AODV message type (16) */
nd_uint8_t rreq_flags; /* various flags */
nd_uint8_t rreq_zero0; /* reserved, set to zero */
nd_uint8_t rreq_hops; /* number of hops from originator */
nd_uint32_t rreq_id; /* request ID */
nd_uint32_t rreq_ds; /* destination sequence number */
nd_uint32_t rreq_os; /* originator sequence number */
nd_ipv6 rreq_da; /* destination IPv6 address */
nd_ipv6 rreq_oa; /* originator IPv6 address */
};
#define RREQ_JOIN 0x80 /* join (reserved for multicast */
@ -87,34 +87,34 @@ struct aodv_rreq6_draft_01 {
#define RREQ_FLAGS_MASK 0xF8 /* mask for rreq_flags */
struct aodv_rrep {
uint8_t rrep_type; /* AODV message type (2) */
uint8_t rrep_flags; /* various flags */
uint8_t rrep_ps; /* prefix size */
uint8_t rrep_hops; /* number of hops from o to d */
uint32_t rrep_da; /* destination IPv4 address */
uint32_t rrep_ds; /* destination sequence number */
uint32_t rrep_oa; /* originator IPv4 address */
uint32_t rrep_life; /* lifetime of this route */
nd_uint8_t rrep_type; /* AODV message type (2) */
nd_uint8_t rrep_flags; /* various flags */
nd_uint8_t rrep_ps; /* prefix size */
nd_uint8_t rrep_hops; /* number of hops from o to d */
nd_ipv4 rrep_da; /* destination IPv4 address */
nd_uint32_t rrep_ds; /* destination sequence number */
nd_ipv4 rrep_oa; /* originator IPv4 address */
nd_uint32_t rrep_life; /* lifetime of this route */
};
struct aodv_rrep6 {
uint8_t rrep_type; /* AODV message type (2) */
uint8_t rrep_flags; /* various flags */
uint8_t rrep_ps; /* prefix size */
uint8_t rrep_hops; /* number of hops from o to d */
struct in6_addr rrep_da; /* destination IPv6 address */
uint32_t rrep_ds; /* destination sequence number */
struct in6_addr rrep_oa; /* originator IPv6 address */
uint32_t rrep_life; /* lifetime of this route */
nd_uint8_t rrep_type; /* AODV message type (2) */
nd_uint8_t rrep_flags; /* various flags */
nd_uint8_t rrep_ps; /* prefix size */
nd_uint8_t rrep_hops; /* number of hops from o to d */
nd_ipv6 rrep_da; /* destination IPv6 address */
nd_uint32_t rrep_ds; /* destination sequence number */
nd_ipv6 rrep_oa; /* originator IPv6 address */
nd_uint32_t rrep_life; /* lifetime of this route */
};
struct aodv_rrep6_draft_01 {
uint8_t rrep_type; /* AODV message type (17) */
uint8_t rrep_flags; /* various flags */
uint8_t rrep_ps; /* prefix size */
uint8_t rrep_hops; /* number of hops from o to d */
uint32_t rrep_ds; /* destination sequence number */
struct in6_addr rrep_da; /* destination IPv6 address */
struct in6_addr rrep_oa; /* originator IPv6 address */
uint32_t rrep_life; /* lifetime of this route */
nd_uint8_t rrep_type; /* AODV message type (17) */
nd_uint8_t rrep_flags; /* various flags */
nd_uint8_t rrep_ps; /* prefix size */
nd_uint8_t rrep_hops; /* number of hops from o to d */
nd_uint32_t rrep_ds; /* destination sequence number */
nd_ipv6 rrep_da; /* destination IPv6 address */
nd_ipv6 rrep_oa; /* originator IPv6 address */
nd_uint32_t rrep_life; /* lifetime of this route */
};
#define RREP_REPAIR 0x80 /* repair (reserved for multicast */
@ -123,31 +123,31 @@ struct aodv_rrep6_draft_01 {
#define RREP_PREFIX_MASK 0x1F /* mask for prefix size */
struct rerr_unreach {
uint32_t u_da; /* IPv4 address */
uint32_t u_ds; /* sequence number */
nd_ipv4 u_da; /* IPv4 address */
nd_uint32_t u_ds; /* sequence number */
};
struct rerr_unreach6 {
struct in6_addr u_da; /* IPv6 address */
uint32_t u_ds; /* sequence number */
nd_ipv6 u_da; /* IPv6 address */
nd_uint32_t u_ds; /* sequence number */
};
struct rerr_unreach6_draft_01 {
struct in6_addr u_da; /* IPv6 address */
uint32_t u_ds; /* sequence number */
nd_ipv6 u_da; /* IPv6 address */
nd_uint32_t u_ds; /* sequence number */
};
struct aodv_rerr {
uint8_t rerr_type; /* AODV message type (3 or 18) */
uint8_t rerr_flags; /* various flags */
uint8_t rerr_zero0; /* reserved, set to zero */
uint8_t rerr_dc; /* destination count */
nd_uint8_t rerr_type; /* AODV message type (3 or 18) */
nd_uint8_t rerr_flags; /* various flags */
nd_uint8_t rerr_zero0; /* reserved, set to zero */
nd_uint8_t rerr_dc; /* destination count */
};
#define RERR_NODELETE 0x80 /* don't delete the link */
#define RERR_FLAGS_MASK 0x80 /* mask for rerr_flags */
struct aodv_rrep_ack {
uint8_t ra_type;
uint8_t ra_zero0;
nd_uint8_t ra_type;
nd_uint8_t ra_zero0;
};
#define AODV_RREQ 1 /* route request */
@ -161,13 +161,13 @@ struct aodv_rrep_ack {
#define AODV_V6_DRAFT_01_RREP_ACK 19 /* IPV6 route response acknowledgment */
struct aodv_ext {
uint8_t type; /* extension type */
uint8_t length; /* extension length */
nd_uint8_t type; /* extension type */
nd_uint8_t length; /* extension length */
};
struct aodv_hello {
struct aodv_ext eh; /* extension header */
uint8_t interval[4]; /* expect my next hello in
nd_uint32_t interval; /* expect my next hello in
* (n) ms
* NOTE: this is not aligned */
};
@ -180,29 +180,31 @@ aodv_extension(netdissect_options *ndo,
{
const struct aodv_hello *ah;
ND_TCHECK(*ep);
switch (ep->type) {
ND_TCHECK_SIZE(ep);
switch (GET_U_1(ep->type)) {
case AODV_EXT_HELLO:
ah = (const struct aodv_hello *)(const void *)ep;
ND_TCHECK(*ah);
ND_TCHECK_SIZE(ah);
if (length < sizeof(struct aodv_hello))
goto trunc;
if (ep->length < 4) {
ND_PRINT((ndo, "\n\text HELLO - bad length %u", ep->length));
if (GET_U_1(ep->length) < 4) {
ND_PRINT("\n\text HELLO - bad length %u",
GET_U_1(ep->length));
break;
}
ND_PRINT((ndo, "\n\text HELLO %ld ms",
(unsigned long)EXTRACT_32BITS(&ah->interval)));
ND_PRINT("\n\text HELLO %u ms",
GET_BE_U_4(ah->interval));
break;
default:
ND_PRINT((ndo, "\n\text %u %u", ep->type, ep->length));
ND_PRINT("\n\text %u %u", GET_U_1(ep->type),
GET_U_1(ep->length));
break;
}
return;
trunc:
ND_PRINT((ndo, " [|hello]"));
nd_print_trunc(ndo);
}
static void
@ -211,29 +213,29 @@ aodv_rreq(netdissect_options *ndo, const u_char *dat, u_int length)
u_int i;
const struct aodv_rreq *ap = (const struct aodv_rreq *)dat;
ND_TCHECK(*ap);
ND_TCHECK_SIZE(ap);
if (length < sizeof(*ap))
goto trunc;
ND_PRINT((ndo, " rreq %u %s%s%s%s%shops %u id 0x%08lx\n"
"\tdst %s seq %lu src %s seq %lu", length,
ap->rreq_type & RREQ_JOIN ? "[J]" : "",
ap->rreq_type & RREQ_REPAIR ? "[R]" : "",
ap->rreq_type & RREQ_GRAT ? "[G]" : "",
ap->rreq_type & RREQ_DEST ? "[D]" : "",
ap->rreq_type & RREQ_UNKNOWN ? "[U] " : " ",
ap->rreq_hops,
(unsigned long)EXTRACT_32BITS(&ap->rreq_id),
ipaddr_string(ndo, &ap->rreq_da),
(unsigned long)EXTRACT_32BITS(&ap->rreq_ds),
ipaddr_string(ndo, &ap->rreq_oa),
(unsigned long)EXTRACT_32BITS(&ap->rreq_os)));
ND_PRINT(" rreq %u %s%s%s%s%shops %u id 0x%08x\n"
"\tdst %s seq %u src %s seq %u", length,
GET_U_1(ap->rreq_type) & RREQ_JOIN ? "[J]" : "",
GET_U_1(ap->rreq_type) & RREQ_REPAIR ? "[R]" : "",
GET_U_1(ap->rreq_type) & RREQ_GRAT ? "[G]" : "",
GET_U_1(ap->rreq_type) & RREQ_DEST ? "[D]" : "",
GET_U_1(ap->rreq_type) & RREQ_UNKNOWN ? "[U] " : " ",
GET_U_1(ap->rreq_hops),
GET_BE_U_4(ap->rreq_id),
GET_IPADDR_STRING(ap->rreq_da),
GET_BE_U_4(ap->rreq_ds),
GET_IPADDR_STRING(ap->rreq_oa),
GET_BE_U_4(ap->rreq_os));
i = length - sizeof(*ap);
if (i >= sizeof(struct aodv_ext))
aodv_extension(ndo, (const struct aodv_ext *)(dat + sizeof(*ap)), i);
return;
trunc:
ND_PRINT((ndo, " [|rreq"));
nd_print_trunc(ndo);
}
static void
@ -242,26 +244,26 @@ aodv_rrep(netdissect_options *ndo, const u_char *dat, u_int length)
u_int i;
const struct aodv_rrep *ap = (const struct aodv_rrep *)dat;
ND_TCHECK(*ap);
ND_TCHECK_SIZE(ap);
if (length < sizeof(*ap))
goto trunc;
ND_PRINT((ndo, " rrep %u %s%sprefix %u hops %u\n"
"\tdst %s dseq %lu src %s %lu ms", length,
ap->rrep_type & RREP_REPAIR ? "[R]" : "",
ap->rrep_type & RREP_ACK ? "[A] " : " ",
ap->rrep_ps & RREP_PREFIX_MASK,
ap->rrep_hops,
ipaddr_string(ndo, &ap->rrep_da),
(unsigned long)EXTRACT_32BITS(&ap->rrep_ds),
ipaddr_string(ndo, &ap->rrep_oa),
(unsigned long)EXTRACT_32BITS(&ap->rrep_life)));
ND_PRINT(" rrep %u %s%sprefix %u hops %u\n"
"\tdst %s dseq %u src %s %u ms", length,
GET_U_1(ap->rrep_type) & RREP_REPAIR ? "[R]" : "",
GET_U_1(ap->rrep_type) & RREP_ACK ? "[A] " : " ",
GET_U_1(ap->rrep_ps) & RREP_PREFIX_MASK,
GET_U_1(ap->rrep_hops),
GET_IPADDR_STRING(ap->rrep_da),
GET_BE_U_4(ap->rrep_ds),
GET_IPADDR_STRING(ap->rrep_oa),
GET_BE_U_4(ap->rrep_life));
i = length - sizeof(*ap);
if (i >= sizeof(struct aodv_ext))
aodv_extension(ndo, (const struct aodv_ext *)(dat + sizeof(*ap)), i);
return;
trunc:
ND_PRINT((ndo, " [|rreq"));
nd_print_trunc(ndo);
}
static void
@ -271,27 +273,27 @@ aodv_rerr(netdissect_options *ndo, const u_char *dat, u_int length)
const struct aodv_rerr *ap = (const struct aodv_rerr *)dat;
const struct rerr_unreach *dp;
ND_TCHECK(*ap);
ND_TCHECK_SIZE(ap);
if (length < sizeof(*ap))
goto trunc;
ND_PRINT((ndo, " rerr %s [items %u] [%u]:",
ap->rerr_flags & RERR_NODELETE ? "[D]" : "",
ap->rerr_dc, length));
ND_PRINT(" rerr %s [items %u] [%u]:",
GET_U_1(ap->rerr_flags) & RERR_NODELETE ? "[D]" : "",
GET_U_1(ap->rerr_dc), length);
dp = (const struct rerr_unreach *)(dat + sizeof(*ap));
i = length - sizeof(*ap);
for (dc = ap->rerr_dc; dc != 0; dc--) {
ND_TCHECK(*dp);
for (dc = GET_U_1(ap->rerr_dc); dc != 0; dc--) {
ND_TCHECK_SIZE(dp);
if (i < sizeof(*dp))
goto trunc;
ND_PRINT((ndo, " {%s}(%ld)", ipaddr_string(ndo, &dp->u_da),
(unsigned long)EXTRACT_32BITS(&dp->u_ds)));
ND_PRINT(" {%s}(%u)", GET_IPADDR_STRING(dp->u_da),
GET_BE_U_4(dp->u_ds));
dp++;
i -= sizeof(*dp);
}
return;
trunc:
ND_PRINT((ndo, "[|rerr]"));
nd_print_trunc(ndo);
}
static void
@ -300,29 +302,29 @@ aodv_v6_rreq(netdissect_options *ndo, const u_char *dat, u_int length)
u_int i;
const struct aodv_rreq6 *ap = (const struct aodv_rreq6 *)dat;
ND_TCHECK(*ap);
ND_TCHECK_SIZE(ap);
if (length < sizeof(*ap))
goto trunc;
ND_PRINT((ndo, " v6 rreq %u %s%s%s%s%shops %u id 0x%08lx\n"
"\tdst %s seq %lu src %s seq %lu", length,
ap->rreq_type & RREQ_JOIN ? "[J]" : "",
ap->rreq_type & RREQ_REPAIR ? "[R]" : "",
ap->rreq_type & RREQ_GRAT ? "[G]" : "",
ap->rreq_type & RREQ_DEST ? "[D]" : "",
ap->rreq_type & RREQ_UNKNOWN ? "[U] " : " ",
ap->rreq_hops,
(unsigned long)EXTRACT_32BITS(&ap->rreq_id),
ip6addr_string(ndo, &ap->rreq_da),
(unsigned long)EXTRACT_32BITS(&ap->rreq_ds),
ip6addr_string(ndo, &ap->rreq_oa),
(unsigned long)EXTRACT_32BITS(&ap->rreq_os)));
ND_PRINT(" v6 rreq %u %s%s%s%s%shops %u id 0x%08x\n"
"\tdst %s seq %u src %s seq %u", length,
GET_U_1(ap->rreq_type) & RREQ_JOIN ? "[J]" : "",
GET_U_1(ap->rreq_type) & RREQ_REPAIR ? "[R]" : "",
GET_U_1(ap->rreq_type) & RREQ_GRAT ? "[G]" : "",
GET_U_1(ap->rreq_type) & RREQ_DEST ? "[D]" : "",
GET_U_1(ap->rreq_type) & RREQ_UNKNOWN ? "[U] " : " ",
GET_U_1(ap->rreq_hops),
GET_BE_U_4(ap->rreq_id),
GET_IP6ADDR_STRING(ap->rreq_da),
GET_BE_U_4(ap->rreq_ds),
GET_IP6ADDR_STRING(ap->rreq_oa),
GET_BE_U_4(ap->rreq_os));
i = length - sizeof(*ap);
if (i >= sizeof(struct aodv_ext))
aodv_extension(ndo, (const struct aodv_ext *)(dat + sizeof(*ap)), i);
return;
trunc:
ND_PRINT((ndo, " [|rreq"));
nd_print_trunc(ndo);
}
static void
@ -331,26 +333,26 @@ aodv_v6_rrep(netdissect_options *ndo, const u_char *dat, u_int length)
u_int i;
const struct aodv_rrep6 *ap = (const struct aodv_rrep6 *)dat;
ND_TCHECK(*ap);
ND_TCHECK_SIZE(ap);
if (length < sizeof(*ap))
goto trunc;
ND_PRINT((ndo, " rrep %u %s%sprefix %u hops %u\n"
"\tdst %s dseq %lu src %s %lu ms", length,
ap->rrep_type & RREP_REPAIR ? "[R]" : "",
ap->rrep_type & RREP_ACK ? "[A] " : " ",
ap->rrep_ps & RREP_PREFIX_MASK,
ap->rrep_hops,
ip6addr_string(ndo, &ap->rrep_da),
(unsigned long)EXTRACT_32BITS(&ap->rrep_ds),
ip6addr_string(ndo, &ap->rrep_oa),
(unsigned long)EXTRACT_32BITS(&ap->rrep_life)));
ND_PRINT(" rrep %u %s%sprefix %u hops %u\n"
"\tdst %s dseq %u src %s %u ms", length,
GET_U_1(ap->rrep_type) & RREP_REPAIR ? "[R]" : "",
GET_U_1(ap->rrep_type) & RREP_ACK ? "[A] " : " ",
GET_U_1(ap->rrep_ps) & RREP_PREFIX_MASK,
GET_U_1(ap->rrep_hops),
GET_IP6ADDR_STRING(ap->rrep_da),
GET_BE_U_4(ap->rrep_ds),
GET_IP6ADDR_STRING(ap->rrep_oa),
GET_BE_U_4(ap->rrep_life));
i = length - sizeof(*ap);
if (i >= sizeof(struct aodv_ext))
aodv_extension(ndo, (const struct aodv_ext *)(dat + sizeof(*ap)), i);
return;
trunc:
ND_PRINT((ndo, " [|rreq"));
nd_print_trunc(ndo);
}
static void
@ -360,27 +362,27 @@ aodv_v6_rerr(netdissect_options *ndo, const u_char *dat, u_int length)
const struct aodv_rerr *ap = (const struct aodv_rerr *)dat;
const struct rerr_unreach6 *dp6;
ND_TCHECK(*ap);
ND_TCHECK_SIZE(ap);
if (length < sizeof(*ap))
goto trunc;
ND_PRINT((ndo, " rerr %s [items %u] [%u]:",
ap->rerr_flags & RERR_NODELETE ? "[D]" : "",
ap->rerr_dc, length));
ND_PRINT(" rerr %s [items %u] [%u]:",
GET_U_1(ap->rerr_flags) & RERR_NODELETE ? "[D]" : "",
GET_U_1(ap->rerr_dc), length);
dp6 = (const struct rerr_unreach6 *)(const void *)(ap + 1);
i = length - sizeof(*ap);
for (dc = ap->rerr_dc; dc != 0; dc--) {
ND_TCHECK(*dp6);
for (dc = GET_U_1(ap->rerr_dc); dc != 0; dc--) {
ND_TCHECK_SIZE(dp6);
if (i < sizeof(*dp6))
goto trunc;
ND_PRINT((ndo, " {%s}(%ld)", ip6addr_string(ndo, &dp6->u_da),
(unsigned long)EXTRACT_32BITS(&dp6->u_ds)));
ND_PRINT(" {%s}(%u)", GET_IP6ADDR_STRING(dp6->u_da),
GET_BE_U_4(dp6->u_ds));
dp6++;
i -= sizeof(*dp6);
}
return;
trunc:
ND_PRINT((ndo, "[|rerr]"));
nd_print_trunc(ndo);
}
static void
@ -389,29 +391,29 @@ aodv_v6_draft_01_rreq(netdissect_options *ndo, const u_char *dat, u_int length)
u_int i;
const struct aodv_rreq6_draft_01 *ap = (const struct aodv_rreq6_draft_01 *)dat;
ND_TCHECK(*ap);
ND_TCHECK_SIZE(ap);
if (length < sizeof(*ap))
goto trunc;
ND_PRINT((ndo, " rreq %u %s%s%s%s%shops %u id 0x%08lx\n"
"\tdst %s seq %lu src %s seq %lu", length,
ap->rreq_type & RREQ_JOIN ? "[J]" : "",
ap->rreq_type & RREQ_REPAIR ? "[R]" : "",
ap->rreq_type & RREQ_GRAT ? "[G]" : "",
ap->rreq_type & RREQ_DEST ? "[D]" : "",
ap->rreq_type & RREQ_UNKNOWN ? "[U] " : " ",
ap->rreq_hops,
(unsigned long)EXTRACT_32BITS(&ap->rreq_id),
ip6addr_string(ndo, &ap->rreq_da),
(unsigned long)EXTRACT_32BITS(&ap->rreq_ds),
ip6addr_string(ndo, &ap->rreq_oa),
(unsigned long)EXTRACT_32BITS(&ap->rreq_os)));
ND_PRINT(" rreq %u %s%s%s%s%shops %u id 0x%08x\n"
"\tdst %s seq %u src %s seq %u", length,
GET_U_1(ap->rreq_type) & RREQ_JOIN ? "[J]" : "",
GET_U_1(ap->rreq_type) & RREQ_REPAIR ? "[R]" : "",
GET_U_1(ap->rreq_type) & RREQ_GRAT ? "[G]" : "",
GET_U_1(ap->rreq_type) & RREQ_DEST ? "[D]" : "",
GET_U_1(ap->rreq_type) & RREQ_UNKNOWN ? "[U] " : " ",
GET_U_1(ap->rreq_hops),
GET_BE_U_4(ap->rreq_id),
GET_IP6ADDR_STRING(ap->rreq_da),
GET_BE_U_4(ap->rreq_ds),
GET_IP6ADDR_STRING(ap->rreq_oa),
GET_BE_U_4(ap->rreq_os));
i = length - sizeof(*ap);
if (i >= sizeof(struct aodv_ext))
aodv_extension(ndo, (const struct aodv_ext *)(dat + sizeof(*ap)), i);
return;
trunc:
ND_PRINT((ndo, " [|rreq"));
nd_print_trunc(ndo);
}
static void
@ -420,26 +422,26 @@ aodv_v6_draft_01_rrep(netdissect_options *ndo, const u_char *dat, u_int length)
u_int i;
const struct aodv_rrep6_draft_01 *ap = (const struct aodv_rrep6_draft_01 *)dat;
ND_TCHECK(*ap);
ND_TCHECK_SIZE(ap);
if (length < sizeof(*ap))
goto trunc;
ND_PRINT((ndo, " rrep %u %s%sprefix %u hops %u\n"
"\tdst %s dseq %lu src %s %lu ms", length,
ap->rrep_type & RREP_REPAIR ? "[R]" : "",
ap->rrep_type & RREP_ACK ? "[A] " : " ",
ap->rrep_ps & RREP_PREFIX_MASK,
ap->rrep_hops,
ip6addr_string(ndo, &ap->rrep_da),
(unsigned long)EXTRACT_32BITS(&ap->rrep_ds),
ip6addr_string(ndo, &ap->rrep_oa),
(unsigned long)EXTRACT_32BITS(&ap->rrep_life)));
ND_PRINT(" rrep %u %s%sprefix %u hops %u\n"
"\tdst %s dseq %u src %s %u ms", length,
GET_U_1(ap->rrep_type) & RREP_REPAIR ? "[R]" : "",
GET_U_1(ap->rrep_type) & RREP_ACK ? "[A] " : " ",
GET_U_1(ap->rrep_ps) & RREP_PREFIX_MASK,
GET_U_1(ap->rrep_hops),
GET_IP6ADDR_STRING(ap->rrep_da),
GET_BE_U_4(ap->rrep_ds),
GET_IP6ADDR_STRING(ap->rrep_oa),
GET_BE_U_4(ap->rrep_life));
i = length - sizeof(*ap);
if (i >= sizeof(struct aodv_ext))
aodv_extension(ndo, (const struct aodv_ext *)(dat + sizeof(*ap)), i);
return;
trunc:
ND_PRINT((ndo, " [|rreq"));
nd_print_trunc(ndo);
}
static void
@ -449,27 +451,27 @@ aodv_v6_draft_01_rerr(netdissect_options *ndo, const u_char *dat, u_int length)
const struct aodv_rerr *ap = (const struct aodv_rerr *)dat;
const struct rerr_unreach6_draft_01 *dp6;
ND_TCHECK(*ap);
ND_TCHECK_SIZE(ap);
if (length < sizeof(*ap))
goto trunc;
ND_PRINT((ndo, " rerr %s [items %u] [%u]:",
ap->rerr_flags & RERR_NODELETE ? "[D]" : "",
ap->rerr_dc, length));
ND_PRINT(" rerr %s [items %u] [%u]:",
GET_U_1(ap->rerr_flags) & RERR_NODELETE ? "[D]" : "",
GET_U_1(ap->rerr_dc), length);
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);
for (dc = GET_U_1(ap->rerr_dc); dc != 0; dc--) {
ND_TCHECK_SIZE(dp6);
if (i < sizeof(*dp6))
goto trunc;
ND_PRINT((ndo, " {%s}(%ld)", ip6addr_string(ndo, &dp6->u_da),
(unsigned long)EXTRACT_32BITS(&dp6->u_ds)));
ND_PRINT(" {%s}(%u)", GET_IP6ADDR_STRING(dp6->u_da),
GET_BE_U_4(dp6->u_ds));
dp6++;
i -= sizeof(*dp6);
}
return;
trunc:
ND_PRINT((ndo, "[|rerr]"));
nd_print_trunc(ndo);
}
void
@ -478,13 +480,13 @@ aodv_print(netdissect_options *ndo,
{
uint8_t msg_type;
ndo->ndo_protocol = "aodv";
/*
* The message type is the first byte; make sure we have it
* and then fetch it.
*/
ND_TCHECK(*dat);
msg_type = *dat;
ND_PRINT((ndo, " aodv"));
msg_type = GET_U_1(dat);
ND_PRINT(" aodv");
switch (msg_type) {
@ -510,7 +512,7 @@ aodv_print(netdissect_options *ndo,
break;
case AODV_RREP_ACK:
ND_PRINT((ndo, " rrep-ack %u", length));
ND_PRINT(" rrep-ack %u", length);
break;
case AODV_V6_DRAFT_01_RREQ:
@ -526,14 +528,10 @@ aodv_print(netdissect_options *ndo,
break;
case AODV_V6_DRAFT_01_RREP_ACK:
ND_PRINT((ndo, " rrep-ack %u", length));
ND_PRINT(" rrep-ack %u", length);
break;
default:
ND_PRINT((ndo, " type %u %u", msg_type, length));
ND_PRINT(" type %u %u", msg_type, length);
}
return;
trunc:
ND_PRINT((ndo, " [|aodv]"));
}

View File

@ -27,20 +27,21 @@
/* \summary: ATA over Ethernet (AoE) protocol printer */
/* specification: http://brantleycoilecompany.com/AoEr11.pdf */
/* specification:
* https://web.archive.org/web/20161025044402/http://brantleycoilecompany.com/AoEr11.pdf
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#include <config.h>
#endif
#include <netdissect-stdinc.h>
#include "netdissect-stdinc.h"
#define ND_LONGJMP_FROM_TCHECK
#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
#include "ether.h"
static const char tstr[] = " [|aoe]";
#define AOE_V1 1
#define ATA_SECTOR_SIZE 512
@ -71,8 +72,8 @@ static const struct tok cmdcode_str[] = {
static const struct tok aoev1_flag_str[] = {
{ AOEV1_FLAG_R, "Response" },
{ AOEV1_FLAG_E, "Error" },
{ 0x02, "MBZ-0x02" },
{ 0x01, "MBZ-0x01" },
{ 0x02, "MBZ-1" },
{ 0x01, "MBZ-0" },
{ 0, NULL }
};
@ -91,13 +92,13 @@ static const struct tok aoev1_errcode_str[] = {
#define AOEV1_AFLAG_A 0x02
#define AOEV1_AFLAG_W 0x01
static const struct tok aoev1_aflag_str[] = {
{ 0x08, "MBZ-0x08" },
static const struct tok aoev1_aflag_bitmap_str[] = {
{ 0x80, "MBZ-7" },
{ AOEV1_AFLAG_E, "Ext48" },
{ 0x06, "MBZ-0x06" },
{ 0x20, "MBZ-5" },
{ AOEV1_AFLAG_D, "Device" },
{ 0x04, "MBZ-0x04" },
{ 0x03, "MBZ-0x03" },
{ 0x08, "MBZ-3" },
{ 0x04, "MBZ-2" },
{ AOEV1_AFLAG_A, "Async" },
{ AOEV1_AFLAG_W, "Write" },
{ 0, NULL }
@ -141,244 +142,231 @@ static const struct tok aoev1_rcmd_str[] = {
static void
aoev1_issue_print(netdissect_options *ndo,
const u_char *cp, const u_int len)
const u_char *cp, u_int len)
{
const u_char *ep = cp + len;
if (len < AOEV1_ISSUE_ARG_LEN)
goto invalid;
/* AFlags */
ND_TCHECK2(*cp, 1);
ND_PRINT((ndo, "\n\tAFlags: [%s]", bittok2str(aoev1_aflag_str, "none", *cp)));
ND_PRINT("\n\tAFlags: [%s]",
bittok2str(aoev1_aflag_bitmap_str, "none", GET_U_1(cp)));
cp += 1;
len -= 1;
/* Err/Feature */
ND_TCHECK2(*cp, 1);
ND_PRINT((ndo, ", Err/Feature: %u", *cp));
ND_PRINT(", Err/Feature: %u", GET_U_1(cp));
cp += 1;
len -= 1;
/* Sector Count (not correlated with the length) */
ND_TCHECK2(*cp, 1);
ND_PRINT((ndo, ", Sector Count: %u", *cp));
ND_PRINT(", Sector Count: %u", GET_U_1(cp));
cp += 1;
len -= 1;
/* Cmd/Status */
ND_TCHECK2(*cp, 1);
ND_PRINT((ndo, ", Cmd/Status: %u", *cp));
ND_PRINT(", Cmd/Status: %u", GET_U_1(cp));
cp += 1;
len -= 1;
/* lba0 */
ND_TCHECK2(*cp, 1);
ND_PRINT((ndo, "\n\tlba0: %u", *cp));
ND_PRINT("\n\tlba0: %u", GET_U_1(cp));
cp += 1;
len -= 1;
/* lba1 */
ND_TCHECK2(*cp, 1);
ND_PRINT((ndo, ", lba1: %u", *cp));
ND_PRINT(", lba1: %u", GET_U_1(cp));
cp += 1;
len -= 1;
/* lba2 */
ND_TCHECK2(*cp, 1);
ND_PRINT((ndo, ", lba2: %u", *cp));
ND_PRINT(", lba2: %u", GET_U_1(cp));
cp += 1;
len -= 1;
/* lba3 */
ND_TCHECK2(*cp, 1);
ND_PRINT((ndo, ", lba3: %u", *cp));
ND_PRINT(", lba3: %u", GET_U_1(cp));
cp += 1;
len -= 1;
/* lba4 */
ND_TCHECK2(*cp, 1);
ND_PRINT((ndo, ", lba4: %u", *cp));
ND_PRINT(", lba4: %u", GET_U_1(cp));
cp += 1;
len -= 1;
/* lba5 */
ND_TCHECK2(*cp, 1);
ND_PRINT((ndo, ", lba5: %u", *cp));
ND_PRINT(", lba5: %u", GET_U_1(cp));
cp += 1;
len -= 1;
/* Reserved */
ND_TCHECK2(*cp, 2);
ND_TCHECK_2(cp);
cp += 2;
len -= 2;
/* Data */
if (len > AOEV1_ISSUE_ARG_LEN)
ND_PRINT((ndo, "\n\tData: %u bytes", len - AOEV1_ISSUE_ARG_LEN));
if (len)
ND_PRINT("\n\tData: %u bytes", len);
return;
invalid:
ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return;
trunc:
ND_PRINT((ndo, "%s", tstr));
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
}
static void
aoev1_query_print(netdissect_options *ndo,
const u_char *cp, const u_int len)
const u_char *cp, u_int len)
{
const u_char *ep = cp + len;
uint16_t cslen;
if (len < AOEV1_QUERY_ARG_LEN)
goto invalid;
/* Buffer Count */
ND_TCHECK2(*cp, 2);
ND_PRINT((ndo, "\n\tBuffer Count: %u", EXTRACT_16BITS(cp)));
ND_PRINT("\n\tBuffer Count: %u", GET_BE_U_2(cp));
cp += 2;
len -= 2;
/* Firmware Version */
ND_TCHECK2(*cp, 2);
ND_PRINT((ndo, ", Firmware Version: %u", EXTRACT_16BITS(cp)));
ND_PRINT(", Firmware Version: %u", GET_BE_U_2(cp));
cp += 2;
len -= 2;
/* Sector Count */
ND_TCHECK2(*cp, 1);
ND_PRINT((ndo, ", Sector Count: %u", *cp));
ND_PRINT(", Sector Count: %u", GET_U_1(cp));
cp += 1;
len -= 1;
/* AoE/CCmd */
ND_TCHECK2(*cp, 1);
ND_PRINT((ndo, ", AoE: %u, CCmd: %s", (*cp & 0xF0) >> 4,
tok2str(aoev1_ccmd_str, "Unknown (0x02x)", *cp & 0x0F)));
ND_PRINT(", AoE: %u, CCmd: %s", (GET_U_1(cp) & 0xF0) >> 4,
tok2str(aoev1_ccmd_str, "Unknown (0x02x)", GET_U_1(cp) & 0x0F));
cp += 1;
len -= 1;
/* Config String Length */
ND_TCHECK2(*cp, 2);
cslen = EXTRACT_16BITS(cp);
cslen = GET_BE_U_2(cp);
cp += 2;
if (cslen > AOEV1_MAX_CONFSTR_LEN || AOEV1_QUERY_ARG_LEN + cslen > len)
len -= 2;
if (cslen > AOEV1_MAX_CONFSTR_LEN || cslen > len)
goto invalid;
/* Config String */
ND_TCHECK2(*cp, cslen);
if (cslen) {
ND_PRINT((ndo, "\n\tConfig String (length %u): ", cslen));
if (fn_printn(ndo, cp, cslen, ndo->ndo_snapend))
goto trunc;
ND_PRINT("\n\tConfig String (length %u): ", cslen);
(void)nd_printn(ndo, cp, cslen, NULL);
}
return;
invalid:
ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return;
trunc:
ND_PRINT((ndo, "%s", tstr));
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
}
static void
aoev1_mac_print(netdissect_options *ndo,
const u_char *cp, const u_int len)
const u_char *cp, u_int len)
{
const u_char *ep = cp + len;
uint8_t dircount, i;
if (len < AOEV1_MAC_ARG_LEN)
goto invalid;
/* Reserved */
ND_TCHECK2(*cp, 1);
cp += 1;
len -= 1;
/* MCmd */
ND_TCHECK2(*cp, 1);
ND_PRINT((ndo, "\n\tMCmd: %s", tok2str(aoev1_mcmd_str, "Unknown (0x%02x)", *cp)));
ND_PRINT("\n\tMCmd: %s",
tok2str(aoev1_mcmd_str, "Unknown (0x%02x)", GET_U_1(cp)));
cp += 1;
len -= 1;
/* MError */
ND_TCHECK2(*cp, 1);
ND_PRINT((ndo, ", MError: %s", tok2str(aoev1_merror_str, "Unknown (0x%02x)", *cp)));
ND_PRINT(", MError: %s",
tok2str(aoev1_merror_str, "Unknown (0x%02x)", GET_U_1(cp)));
cp += 1;
len -= 1;
/* Dir Count */
ND_TCHECK2(*cp, 1);
dircount = *cp;
dircount = GET_U_1(cp);
cp += 1;
ND_PRINT((ndo, ", Dir Count: %u", dircount));
if (AOEV1_MAC_ARG_LEN + dircount * 8 > len)
len -= 1;
ND_PRINT(", Dir Count: %u", dircount);
if (dircount * 8U > len)
goto invalid;
/* directives */
for (i = 0; i < dircount; i++) {
/* Reserved */
ND_TCHECK2(*cp, 1);
cp += 1;
len -= 1;
/* DCmd */
ND_TCHECK2(*cp, 1);
ND_PRINT((ndo, "\n\t DCmd: %s", tok2str(aoev1_dcmd_str, "Unknown (0x%02x)", *cp)));
ND_PRINT("\n\t DCmd: %s",
tok2str(aoev1_dcmd_str, "Unknown (0x%02x)", GET_U_1(cp)));
cp += 1;
len -= 1;
/* Ethernet Address */
ND_TCHECK2(*cp, ETHER_ADDR_LEN);
ND_PRINT((ndo, ", Ethernet Address: %s", etheraddr_string(ndo, cp)));
cp += ETHER_ADDR_LEN;
ND_PRINT(", Ethernet Address: %s", GET_ETHERADDR_STRING(cp));
cp += MAC_ADDR_LEN;
len -= MAC_ADDR_LEN;
}
return;
invalid:
ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return;
trunc:
ND_PRINT((ndo, "%s", tstr));
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
}
static void
aoev1_reserve_print(netdissect_options *ndo,
const u_char *cp, const u_int len)
const u_char *cp, u_int len)
{
const u_char *ep = cp + len;
uint8_t nmacs, i;
if (len < AOEV1_RESERVE_ARG_LEN || (len - AOEV1_RESERVE_ARG_LEN) % ETHER_ADDR_LEN)
if (len < AOEV1_RESERVE_ARG_LEN || (len - AOEV1_RESERVE_ARG_LEN) % MAC_ADDR_LEN)
goto invalid;
/* RCmd */
ND_TCHECK2(*cp, 1);
ND_PRINT((ndo, "\n\tRCmd: %s", tok2str(aoev1_rcmd_str, "Unknown (0x%02x)", *cp)));
ND_PRINT("\n\tRCmd: %s",
tok2str(aoev1_rcmd_str, "Unknown (0x%02x)", GET_U_1(cp)));
cp += 1;
len -= 1;
/* NMacs (correlated with the length) */
ND_TCHECK2(*cp, 1);
nmacs = *cp;
nmacs = GET_U_1(cp);
cp += 1;
ND_PRINT((ndo, ", NMacs: %u", nmacs));
if (AOEV1_RESERVE_ARG_LEN + nmacs * ETHER_ADDR_LEN != len)
len -= 1;
ND_PRINT(", NMacs: %u", nmacs);
if (nmacs * MAC_ADDR_LEN != len)
goto invalid;
/* addresses */
for (i = 0; i < nmacs; i++) {
ND_TCHECK2(*cp, ETHER_ADDR_LEN);
ND_PRINT((ndo, "\n\tEthernet Address %u: %s", i, etheraddr_string(ndo, cp)));
cp += ETHER_ADDR_LEN;
ND_PRINT("\n\tEthernet Address %u: %s", i, GET_ETHERADDR_STRING(cp));
cp += MAC_ADDR_LEN;
len -= MAC_ADDR_LEN;
}
return;
invalid:
ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return;
trunc:
ND_PRINT((ndo, "%s", tstr));
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
}
/* cp points to the Ver/Flags octet */
static void
aoev1_print(netdissect_options *ndo,
const u_char *cp, const u_int len)
const u_char *cp, u_int len)
{
const u_char *ep = cp + len;
uint8_t flags, command;
void (*cmd_decoder)(netdissect_options *, const u_char *, const u_int);
void (*cmd_decoder)(netdissect_options *, const u_char *, u_int);
if (len < AOEV1_COMMON_HDR_LEN)
goto invalid;
/* Flags */
ND_TCHECK2(*cp, 1);
flags = *cp & 0x0F;
ND_PRINT((ndo, ", Flags: [%s]", bittok2str(aoev1_flag_str, "none", flags)));
flags = GET_U_1(cp) & 0x0F;
ND_PRINT(", Flags: [%s]", bittok2str(aoev1_flag_str, "none", flags));
cp += 1;
len -= 1;
if (! ndo->ndo_vflag)
return;
/* Error */
ND_TCHECK2(*cp, 1);
if (flags & AOEV1_FLAG_E)
ND_PRINT((ndo, "\n\tError: %s", tok2str(aoev1_errcode_str, "Invalid (%u)", *cp)));
ND_PRINT("\n\tError: %s",
tok2str(aoev1_errcode_str, "Invalid (%u)", GET_U_1(cp)));
cp += 1;
len -= 1;
/* Major */
ND_TCHECK2(*cp, 2);
ND_PRINT((ndo, "\n\tMajor: 0x%04x", EXTRACT_16BITS(cp)));
ND_PRINT("\n\tMajor: 0x%04x", GET_BE_U_2(cp));
cp += 2;
len -= 2;
/* Minor */
ND_TCHECK2(*cp, 1);
ND_PRINT((ndo, ", Minor: 0x%02x", *cp));
ND_PRINT(", Minor: 0x%02x", GET_U_1(cp));
cp += 1;
len -= 1;
/* Command */
ND_TCHECK2(*cp, 1);
command = *cp;
command = GET_U_1(cp);
cp += 1;
ND_PRINT((ndo, ", Command: %s", tok2str(cmdcode_str, "Unknown (0x%02x)", command)));
len -= 1;
ND_PRINT(", Command: %s", tok2str(cmdcode_str, "Unknown (0x%02x)", command));
/* Tag */
ND_TCHECK2(*cp, 4);
ND_PRINT((ndo, ", Tag: 0x%08x", EXTRACT_32BITS(cp)));
ND_PRINT(", Tag: 0x%08x", GET_BE_U_4(cp));
cp += 4;
len -= 4;
/* Arg */
cmd_decoder =
command == AOEV1_CMD_ISSUE_ATA_COMMAND ? aoev1_issue_print :
@ -387,33 +375,29 @@ aoev1_print(netdissect_options *ndo,
command == AOEV1_CMD_RESERVE_RELEASE ? aoev1_reserve_print :
NULL;
if (cmd_decoder != NULL)
cmd_decoder(ndo, cp, len - AOEV1_COMMON_HDR_LEN);
cmd_decoder(ndo, cp, len);
return;
invalid:
ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return;
trunc:
ND_PRINT((ndo, "%s", tstr));
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
}
void
aoe_print(netdissect_options *ndo,
const u_char *cp, const u_int len)
{
const u_char *ep = cp + len;
uint8_t ver;
ND_PRINT((ndo, "AoE length %u", len));
ndo->ndo_protocol = "aoe";
ND_PRINT("AoE length %u", len);
if (len < 1)
goto invalid;
/* Ver/Flags */
ND_TCHECK2(*cp, 1);
ver = (*cp & 0xF0) >> 4;
ver = (GET_U_1(cp) & 0xF0) >> 4;
/* Don't advance cp yet: low order 4 bits are version-specific. */
ND_PRINT((ndo, ", Ver %u", ver));
ND_PRINT(", Ver %u", ver);
switch (ver) {
case AOE_V1:
@ -423,10 +407,7 @@ aoe_print(netdissect_options *ndo,
return;
invalid:
ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return;
trunc:
ND_PRINT((ndo, "%s", tstr));
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
}

View File

@ -22,11 +22,12 @@
/* \summary: Apple IP-over-IEEE 1394 printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#include <config.h>
#endif
#include <netdissect-stdinc.h>
#include "netdissect-stdinc.h"
#define ND_LONGJMP_FROM_TCHECK
#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
@ -37,9 +38,9 @@
*/
#define FIREWIRE_EUI64_LEN 8
struct firewire_header {
u_char firewire_dhost[FIREWIRE_EUI64_LEN];
u_char firewire_shost[FIREWIRE_EUI64_LEN];
u_short firewire_type;
nd_byte firewire_dhost[FIREWIRE_EUI64_LEN];
nd_byte firewire_shost[FIREWIRE_EUI64_LEN];
nd_uint16_t firewire_type;
};
/*
@ -52,31 +53,31 @@ struct firewire_header {
static const char *
fwaddr_string(netdissect_options *ndo, const u_char *addr)
{
return (linkaddr_string(ndo, addr, LINKADDR_IEEE1394, FIREWIRE_EUI64_LEN));
return GET_LINKADDR_STRING(addr, LINKADDR_IEEE1394, FIREWIRE_EUI64_LEN);
}
static inline void
ap1394_hdr_print(netdissect_options *ndo, register const u_char *bp, u_int length)
static void
ap1394_hdr_print(netdissect_options *ndo, const u_char *bp, u_int length)
{
register const struct firewire_header *fp;
const struct firewire_header *fp;
uint16_t firewire_type;
fp = (const struct firewire_header *)bp;
ND_PRINT((ndo, "%s > %s",
ND_PRINT("%s > %s",
fwaddr_string(ndo, fp->firewire_shost),
fwaddr_string(ndo, fp->firewire_dhost)));
fwaddr_string(ndo, fp->firewire_dhost));
firewire_type = EXTRACT_16BITS(&fp->firewire_type);
firewire_type = GET_BE_U_2(fp->firewire_type);
if (!ndo->ndo_qflag) {
ND_PRINT((ndo, ", ethertype %s (0x%04x)",
ND_PRINT(", ethertype %s (0x%04x)",
tok2str(ethertype_values,"Unknown", firewire_type),
firewire_type));
firewire_type);
} else {
ND_PRINT((ndo, ", %s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", firewire_type)));
ND_PRINT(", %s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", firewire_type));
}
ND_PRINT((ndo, ", length %u: ", length));
ND_PRINT(", length %u: ", length);
}
/*
@ -85,7 +86,7 @@ ap1394_hdr_print(netdissect_options *ndo, register const u_char *bp, u_int lengt
* 'h->len' is the length of the packet off the wire, and 'h->caplen'
* is the number of bytes actually captured.
*/
u_int
void
ap1394_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
{
u_int length = h->len;
@ -94,10 +95,9 @@ ap1394_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_ch
u_short ether_type;
struct lladdr_info src, dst;
if (caplen < FIREWIRE_HDRLEN) {
ND_PRINT((ndo, "[|ap1394]"));
return FIREWIRE_HDRLEN;
}
ndo->ndo_protocol = "ap1394";
ND_TCHECK_LEN(p, FIREWIRE_HDRLEN);
ndo->ndo_ll_hdr_len += FIREWIRE_HDRLEN;
if (ndo->ndo_eflag)
ap1394_hdr_print(ndo, p, length);
@ -107,7 +107,7 @@ ap1394_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_ch
fp = (const struct firewire_header *)p;
p += FIREWIRE_HDRLEN;
ether_type = EXTRACT_16BITS(&fp->firewire_type);
ether_type = GET_BE_U_2(fp->firewire_type);
src.addr = fp->firewire_shost;
src.addr_string = fwaddr_string;
dst.addr = fp->firewire_dhost;
@ -120,6 +120,4 @@ ap1394_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_ch
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
}
return FIREWIRE_HDRLEN;
}

View File

@ -24,10 +24,10 @@
/* \summary: Attached Resource Computer NETwork (ARCNET) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#include <config.h>
#endif
#include <netdissect-stdinc.h>
#include "netdissect-stdinc.h"
#include "netdissect.h"
#include "extract.h"
@ -41,22 +41,22 @@
* as given to interface code.
*/
struct arc_header {
uint8_t arc_shost;
uint8_t arc_dhost;
uint8_t arc_type;
nd_uint8_t arc_shost;
nd_uint8_t arc_dhost;
nd_uint8_t arc_type;
/*
* only present for newstyle encoding with LL fragmentation.
* Don't use sizeof(anything), use ARC_HDR{,NEW}LEN instead.
*/
uint8_t arc_flag;
uint16_t arc_seqid;
nd_uint8_t arc_flag;
nd_uint16_t arc_seqid;
/*
* only present in exception packets (arc_flag == 0xff)
*/
uint8_t arc_type2; /* same as arc_type */
uint8_t arc_flag2; /* real flag value */
uint16_t arc_seqid2; /* real seqid value */
nd_uint8_t arc_type2; /* same as arc_type */
nd_uint8_t arc_flag2; /* real flag value */
nd_uint16_t arc_seqid2; /* real seqid value */
};
#define ARC_HDRLEN 3
@ -85,17 +85,17 @@ struct arc_header {
* never presents packets that look like exception frames.
*/
struct arc_linux_header {
uint8_t arc_shost;
uint8_t arc_dhost;
uint16_t arc_offset;
uint8_t arc_type;
nd_uint8_t arc_shost;
nd_uint8_t arc_dhost;
nd_uint16_t arc_offset;
nd_uint8_t arc_type;
/*
* only present for newstyle encoding with LL fragmentation.
* Don't use sizeof(anything), use ARC_LINUX_HDR{,NEW}LEN
* instead.
*/
uint8_t arc_flag;
uint16_t arc_seqid;
nd_uint8_t arc_flag;
nd_uint16_t arc_seqid;
};
#define ARC_LINUX_HDRLEN 5
@ -115,54 +115,61 @@ static const struct tok arctypemap[] = {
{ ARCTYPE_IPX, "ipx" },
{ ARCTYPE_INET6, "ipv6" },
{ ARCTYPE_DIAGNOSE, "diag" },
{ 0, 0 }
{ 0, NULL }
};
static inline void
static void
arcnet_print(netdissect_options *ndo, const u_char *bp, u_int length, int phds,
int flag, u_int seqid)
u_int flag, u_int seqid)
{
const struct arc_header *ap;
const char *arctypename;
ndo->ndo_protocol = "arcnet";
ap = (const struct arc_header *)bp;
if (ndo->ndo_qflag) {
ND_PRINT((ndo, "%02x %02x %d: ",
ap->arc_shost,
ap->arc_dhost,
length));
ND_PRINT("%02x %02x %u: ",
GET_U_1(ap->arc_shost),
GET_U_1(ap->arc_dhost),
length);
return;
}
arctypename = tok2str(arctypemap, "%02x", ap->arc_type);
arctypename = tok2str(arctypemap, "%02x", GET_U_1(ap->arc_type));
if (!phds) {
ND_PRINT((ndo, "%02x %02x %s %d: ",
ap->arc_shost, ap->arc_dhost, arctypename,
length));
return;
ND_PRINT("%02x %02x %s %u: ",
GET_U_1(ap->arc_shost),
GET_U_1(ap->arc_dhost),
arctypename,
length);
return;
}
if (flag == 0) {
ND_PRINT((ndo, "%02x %02x %s seqid %04x %d: ",
ap->arc_shost, ap->arc_dhost, arctypename, seqid,
length));
return;
ND_PRINT("%02x %02x %s seqid %04x %u: ",
GET_U_1(ap->arc_shost),
GET_U_1(ap->arc_dhost),
arctypename, seqid,
length);
return;
}
if (flag & 1)
ND_PRINT((ndo, "%02x %02x %s seqid %04x "
"(first of %d fragments) %d: ",
ap->arc_shost, ap->arc_dhost, arctypename, seqid,
(flag + 3) / 2, length));
ND_PRINT("%02x %02x %s seqid %04x "
"(first of %u fragments) %u: ",
GET_U_1(ap->arc_shost),
GET_U_1(ap->arc_dhost),
arctypename, seqid,
(flag + 3) / 2, length);
else
ND_PRINT((ndo, "%02x %02x %s seqid %04x "
"(fragment %d) %d: ",
ap->arc_shost, ap->arc_dhost, arctypename, seqid,
flag/2 + 1, length));
ND_PRINT("%02x %02x %s seqid %04x "
"(fragment %u) %u: ",
GET_U_1(ap->arc_shost),
GET_U_1(ap->arc_dhost),
arctypename, seqid,
flag/2 + 1, length);
}
/*
@ -171,24 +178,26 @@ arcnet_print(netdissect_options *ndo, const u_char *bp, u_int length, int phds,
* 'h->len' is the length of the packet off the wire, and 'h->caplen'
* is the number of bytes actually captured.
*/
u_int
void
arcnet_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
{
u_int caplen = h->caplen;
u_int length = h->len;
const struct arc_header *ap;
int phds, flag = 0, archdrlen = 0;
int phds;
u_int flag = 0, archdrlen = 0;
u_int seqid = 0;
u_char arc_type;
if (caplen < ARC_HDRLEN || length < ARC_HDRLEN) {
ND_PRINT((ndo, "[|arcnet]"));
return (caplen);
ndo->ndo_protocol = "arcnet";
if (caplen < ARC_HDRLEN) {
ndo->ndo_ll_hdr_len += caplen;
nd_trunc_longjmp(ndo);
}
ap = (const struct arc_header *)p;
arc_type = ap->arc_type;
arc_type = GET_U_1(ap->arc_type);
switch (arc_type) {
default:
@ -203,24 +212,26 @@ arcnet_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_ch
}
if (phds) {
if (caplen < ARC_HDRNEWLEN || length < ARC_HDRNEWLEN) {
if (caplen < ARC_HDRNEWLEN) {
arcnet_print(ndo, p, length, 0, 0, 0);
ND_PRINT((ndo, "[|phds]"));
return (caplen);
ND_PRINT(" phds");
ndo->ndo_ll_hdr_len += caplen;
nd_trunc_longjmp(ndo);
}
if (ap->arc_flag == 0xff) {
if (caplen < ARC_HDRNEWLEN_EXC || length < ARC_HDRNEWLEN_EXC) {
flag = GET_U_1(ap->arc_flag);
if (flag == 0xff) {
if (caplen < ARC_HDRNEWLEN_EXC) {
arcnet_print(ndo, p, length, 0, 0, 0);
ND_PRINT((ndo, "[|phds extended]"));
return (caplen);
ND_PRINT(" phds extended");
ndo->ndo_ll_hdr_len += caplen;
nd_trunc_longjmp(ndo);
}
flag = ap->arc_flag2;
seqid = EXTRACT_16BITS(&ap->arc_seqid2);
flag = GET_U_1(ap->arc_flag2);
seqid = GET_BE_U_2(ap->arc_seqid2);
archdrlen = ARC_HDRNEWLEN_EXC;
} else {
flag = ap->arc_flag;
seqid = EXTRACT_16BITS(&ap->arc_seqid);
seqid = GET_BE_U_2(ap->arc_seqid);
archdrlen = ARC_HDRNEWLEN;
}
}
@ -240,13 +251,14 @@ arcnet_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_ch
/*
* This is a middle fragment.
*/
return (archdrlen);
ndo->ndo_ll_hdr_len += archdrlen;
return;
}
if (!arcnet_encap_print(ndo, arc_type, p, length, caplen))
ND_DEFAULTPRINT(p, caplen);
return (archdrlen);
ndo->ndo_ll_hdr_len += archdrlen;
}
/*
@ -259,7 +271,7 @@ arcnet_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_ch
* reassembled packets rather than raw frames, and headers have an
* extra "offset" field between the src/dest and packet type.
*/
u_int
void
arcnet_linux_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
{
u_int caplen = h->caplen;
@ -269,20 +281,21 @@ arcnet_linux_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, cons
int archdrlen = 0;
u_char arc_type;
if (caplen < ARC_LINUX_HDRLEN || length < ARC_LINUX_HDRLEN) {
ND_PRINT((ndo, "[|arcnet]"));
return (caplen);
ndo->ndo_protocol = "arcnet_linux";
if (caplen < ARC_LINUX_HDRLEN) {
ndo->ndo_ll_hdr_len += caplen;
nd_trunc_longjmp(ndo);
}
ap = (const struct arc_linux_header *)p;
arc_type = ap->arc_type;
arc_type = GET_U_1(ap->arc_type);
switch (arc_type) {
default:
archdrlen = ARC_LINUX_HDRNEWLEN;
if (caplen < ARC_LINUX_HDRNEWLEN || length < ARC_LINUX_HDRNEWLEN) {
ND_PRINT((ndo, "[|arcnet]"));
return (caplen);
if (caplen < ARC_LINUX_HDRNEWLEN) {
ndo->ndo_ll_hdr_len += caplen;
nd_trunc_longjmp(ndo);
}
break;
case ARCTYPE_IP_OLD:
@ -305,7 +318,7 @@ arcnet_linux_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, cons
if (!arcnet_encap_print(ndo, arc_type, p, length, caplen))
ND_DEFAULTPRINT(p, caplen);
return (archdrlen);
ndo->ndo_ll_hdr_len += archdrlen;
}
/*
@ -339,7 +352,7 @@ arcnet_encap_print(netdissect_options *ndo, u_char arctype, const u_char *p,
case ARCTYPE_ATALK: /* XXX was this ever used? */
if (ndo->ndo_vflag)
ND_PRINT((ndo, "et1 "));
ND_PRINT("et1 ");
atalk_print(ndo, p, length);
return (1);
@ -351,10 +364,3 @@ arcnet_encap_print(netdissect_options *ndo, u_char arctype, const u_char *p,
return (0);
}
}
/*
* Local Variables:
* c-style: bsd
* End:
*/

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