Commit Graph

4833 Commits

Author SHA1 Message Date
Guy Harris
509c212dc6 Use nd_ types in packet structures.
Add EXTRACT_U_1() calls as appropriate.

Use EXTRACT_IPV4_TO_HOST_ORDER(), rather than EXTRACT_BE_U_4(), when
extracting an IPv4 mask into host byte order.

Use %u, and u_int, for unsigned values.

Add ISO standard numbers for the protocols in a specification comment up
front.
2017-12-20 09:55:47 -08:00
Guy Harris
b347189ca6 Add EXTRACT_ macros/functions for IPv4 addresses, get rid of structure wrappers.
Add EXTRACT_IPV4_TO_HOST_ORDER() and EXTRACT_IPV4_TO_NETWORK_ORDER();
the former extracts a possibly-unaligned IPv4 address, in network byte
order, returning a uint32_t in host byte order, and the latter extracts
a possibly-unaligned IPv4 address, in network byte order, returning a
uint32_t in *network* byte order.  Some APIs take an address in network
byte order, and some operations are more easily done in host byte order,
so both are useful.

Remove the structure wrappers around nd_ipv4 and nd_ipv6; that makes it
easier to pass variables of those types to functions/macros that take a
byte pointer as an argument (because they might be used either with
pointers to structure members or raw buffer pointers), and the structure
probably wouldn't do much to prevent people from using EXTRACT_BE_U_4()
when they really want to extract the value in *network* byte order;
using the above EXTRACT_IPV4_ calls should do more to encourage that.
2017-12-20 01:07:48 -08:00
Francois-Xavier Le Bail
acbfc682d6 DCCP: Use nd_ types
Use nd_ types for various packet structures.
Use EXTRACT_ macros as necessary.
Remove & in EXTRACT_ macros if not necessary.
2017-12-19 09:08:27 +01:00
Guy Harris
58f2aa4b57 Use nd_ types, clean up ICMPv6 dissection.
Use nd_ types for various packet structures, and use EXTRACT_ macros as
necessary.  Get rid of & in EXTRACT_ macros if not necessary.

The 1-byte pad RPL suboption is called PAD1, not PAD0, in the RFC.

Rename rpl_dio_printopt() to rpl_printopts() because 1) it's for all RPL
messages and 2) it prints multiple options.  Clean up its processing
loop.

Pass rpl_print() the ICMPv6 code, not a pointer to the full header; all
it needs is the code.

Use %u to print unsigned values.

In Node Information node address lists, the TTL comes before the
address, as per the RFC.  Dissect it that way.
2017-12-18 21:41:18 -08:00
Francois-Xavier Le Bail
c45936d9f1 Tavis-CI: Update to add openssl support in OSX build
The Homebrew softwares are installed in /usr/local/Cellar
2017-12-18 21:53:44 +01:00
Guy Harris
57efe20b35 Get rid of an unused variable. 2017-12-18 12:29:08 -08:00
Francois-Xavier Le Bail
1af717b1ac SMB: Add two missing bounds checks 2017-12-18 13:01:43 +01:00
Guy Harris
5fc11e8d2f Fix decryption code path.
Thanks for making this hard to test on macOS, Apple.  You *could*
continue to ship the headers for libcrypto even if you want to get
everybody to use your Shiny New SSL code rather than Boring Old OpenSSL
- just don't ship the headers for the SSL library - but nooooooo.
2017-12-17 23:45:14 -08:00
Guy Harris
811063b60d Add comments explaining why using EXTRACT_BE_U_4() isn't wrong.
When showing a readdir verifier, using big-endian means that it shows
the verifier as a string of 16 octet values, from the first to the last,
which makes sense, and which means that the way we display it is
independent of the byte order of the host running tcpdump, which is a
Good Thing.

When showing a file handle, the same applies, although one could make a
case for not separating the 4-octet words with colons, and just showing
it as a sequence of octets.
2017-12-17 22:53:56 -08:00
Guy Harris
195a4cfd9d Clean up ISAKMP dissection, use nd_ types and EXTRACT_ macros.
Add some RFC numbers.

Structures with nd_ types work well if you overlay them on top of the
packet buffer, but not as well with an on-the-stack structure into which
you copy from the packet, which is ugly if you do *both* with the same
structure.  Use overlaying uniformly.

Add EXTRACT_ macros as necessary for the nd_ types.

Make stuff unsigned if it's appropriate.

Use unsigned formats for unsigned values.

A number of routines are passed the length of a payload, so they don't
have to re-fetch that length themselves.  That length has been
pre-checked to make sure it's big enough for the payload header; note
that in comments.
2017-12-17 21:49:46 -08:00
Guy Harris
3c70644596 Use nd_ipv6 for IPV6 addresses. 2017-12-17 14:46:04 -08:00
Francois-Xavier Le Bail
1f30eeb06a Simplify some expressions 2017-12-17 20:00:08 +01:00
Francois-Xavier Le Bail
60aaea00cc OSPF: Fix two bounds checks
ND_TCHECK(*lp) test for only one byte.
A test for four bytes is needed.
2017-12-17 16:10:23 +01:00
Francois-Xavier Le Bail
481b700dc6 Update CONTRIBUTING according to recent changes 2017-12-17 16:04:08 +01:00
Francois-Xavier Le Bail
b04ee9c12e FR: Rework extracting the flags
Moreover:
Rename parse_q922_addr to parse_q922_header
2017-12-17 14:22:14 +01:00
Francois-Xavier Le Bail
e835e6a934 Fix spaces 2017-12-17 13:12:36 +01:00
Francois-Xavier Le Bail
e74cccfe79 FR: Fix extracting the DE flag
Update the output of a test accordingly.
2017-12-17 12:34:13 +01:00
Francois-Xavier Le Bail
9113e560eb NFS: Use more the EXTRACT_BE_U_4 macro 2017-12-17 09:30:00 +01:00
Guy Harris
6a58ce3ad1 Directly refer to ether_shost and ether_dhost; get rid of ESRC() and EDST().
They don't really add anything.
2017-12-16 19:57:14 -08:00
Guy Harris
a08e63fd7a Move NTOH and HTON macros into addrname.c
We don't want to encourage people to use them in code that pulls data
out of packets, as we want that code to use the EXTRACT_ macros.
2017-12-16 19:52:35 -08:00
Francois-Xavier Le Bail
41dbcba30b Use more the EXTRACT_U_1() macro (57/n) 2017-12-16 21:35:08 +01:00
Francois-Xavier Le Bail
b01cc24ce4 Simplify some expressions 2017-12-16 20:46:46 +01:00
Guy Harris
ed4e3d85a3 More cleanups.
Add the current BGP RFC as a comment.

Use unsigned types where appropriate.

Use size_t where appropriate.

Further whitespace cleanups.
2017-12-16 10:50:00 -08:00
Francois-Xavier Le Bail
6d65e3df34 Use more the EXTRACT_U_1() macro (56/n) 2017-12-16 15:01:02 +01:00
Guy Harris
e18798ad05 Use EXTRACT_BE_U_4() to fetch a 4-byte big-endian value from a packet. 2017-12-16 00:34:12 -08:00
Guy Harris
eb58492d87 More whitespace cleanup. 2017-12-16 00:05:49 -08:00
Guy Harris
1a859e9f5c Re-fix indentation. 2017-12-15 22:51:45 -08:00
Guy Harris
27cc76fd53 Fix build. 2017-12-15 22:37:49 -08:00
Francois-Xavier Le Bail
f066b01db4 Remove a never used macro 2017-12-16 07:36:24 +01:00
Guy Harris
762439d880
Merge pull request #630 from davidcronin-arista/master
tcpdump should decode BGP add-path NLRI and withrawn routes correctly
2017-12-15 22:34:56 -08:00
Guy Harris
6ec714988c
Merge branch 'master' into master 2017-12-15 22:34:42 -08:00
Guy Harris
6ceeae50d8 Temporarily undo whitespace cleanups to help a pull request.
Hopefully this will reduce the number of conflicts.
2017-12-15 22:32:02 -08:00
Guy Harris
ae1a0ebcd6 Clean up white space.
Consistently use 4-space, no-tab indentation.
2017-12-15 22:29:24 -08:00
Guy Harris
c9ed5865f3 Redo BGP dissection a bit.
Don't copy structures out of the packet, access them in-place using the
EXTRACT_ macros as appropriate, as we already did for some packet types.
Declare the structures using nd_ types.

Rename bgp_header_print() to bgp_pdu_print(), because, after dissecting
and printing stuff from the header, it calls routines to dissect the
body.
2017-12-15 16:04:26 -08:00
Guy Harris
0489e347dc Use nd_ types for ONC RPC.
We don't do this for NFS; that'd require more work.  The NFS dissector
is already using EXTRACT_ calls for the NFS message.
2017-12-15 12:21:50 -08:00
Francois-Xavier Le Bail
1a04b92e36 Use more the ND_TTEST_1() macro 2017-12-15 19:39:00 +01:00
Guy Harris
09393e2faa Pull rpl.h into print-icmp6.c; nothing else uses it. 2017-12-14 20:30:09 -08:00
Guy Harris
aeb105bfbf Use nd_ types in AppleTalk structures, and add EXTRACT_ calls. 2017-12-14 19:27:49 -08:00
Guy Harris
a5874ee6b1 Update the -s documentation.
The -s default is now large, so it's not as if you'll have to increase
it to get more packet data; you might have to *decrease* it to avoid
dropping packets.
2017-12-14 15:48:30 -08:00
Francois-Xavier Le Bail
3e6a7011af ISIS: Replace ND_TCHECK2 calls by ND_TCHECK_LEN calls 2017-12-14 22:51:27 +01:00
Francois-Xavier Le Bail
ce4e690346 OSPFv3: Replace ND_TCHECK2 call by ND_TCHECK_LEN call 2017-12-14 22:41:15 +01:00
Francois-Xavier Le Bail
8bd200e5a3 NTP: Replace ND_TCHECK2 calls by ND_TCHECK_LEN calls 2017-12-14 22:32:15 +01:00
Francois-Xavier Le Bail
81e4dfecd3 ICMPv6: Replace ND_TCHECK2 calls by ND_TCHECK_LEN calls 2017-12-14 22:21:52 +01:00
Francois-Xavier Le Bail
607d4a5c33 ICMP: Replace ND_TTEST2 calls by ND_TTEST_LEN calls 2017-12-14 22:16:55 +01:00
Francois-Xavier Le Bail
329b43101e TCP: Replace ND_TTEST2 calls by ND_TTEST_LEN calls 2017-12-14 21:50:06 +01:00
Guy Harris
41b9478cc8 Use nd_ types for OSPF and OSPF6 packets.
And add EXTRACT_ calls as required.

Remove no-longer-necessary & operators in EXTRACT_ calls.
2017-12-14 10:28:57 -08:00
Guy Harris
6fe4295795 Use nd_ types for AH headers. 2017-12-13 20:43:33 -08:00
Guy Harris
41c93b0d33 C99 type, not BSD type; use uint16_t. 2017-12-13 11:11:32 -08:00
Francois-Xavier Le Bail
5cea270318 Remove all storage class specifier 'register'
Let the compiler do the optimizations (or not) based on build options.

Avoid 'value has been optimized out' messages in gdb using '-O0'.
2017-12-13 19:17:47 +01:00
Guy Harris
e9306685c6 Use MAC_ADDR_LEN, and don't include ether.h.
We no longer have an ether.h header; the only thing we used from it is
ETHER_ADDR_LEN, and netdissect.h defines MAC_ADDR_LEN, so use that
instead.
2017-12-13 09:44:09 -08:00