Commit Graph

14 Commits

Author SHA1 Message Date
Guy Harris
fb2479d733 Always include <config.h> rather than "config.h".
This can prevent bizarre failures if, for example, you've done a
configuration in the top-level source directory, leaving behind one
config.h file, and then do an out-of-tree build in another directory,
with different configuration options.  This way, we always pick up the
same config.h, in the build directory.
2018-01-21 12:27:28 -08:00
Francois-Xavier Le Bail
513f782ae1 Use quoted include netdissect-stdinc.h instead of angle-bracketed one 2018-01-21 10:28:15 +01: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
Guy Harris
c45bfbe0ab Clean up signed vs. unsigned.
Have separate cpack_ routines for signed and unsigned numbers, with the
signed ones using _S_ extract macros.  That way, we can do more type
checking.

Add EXTRACT_LE_S_ macros.

Use signed variables for IEEE80211_RADIOTAP_TX_ATTENUATION and
IEEE80211_RADIOTAP_DB_TX_ATTENUATION, rather than using unsigned
variables that we cast to int.

Also, use EXTRACT_U_1() in cpack_uint8.
2017-11-23 11:19:38 -08:00
Francois-Xavier Le Bail
da20bc56d6 Rename EXTRACT_ macros
Now all the macros have a name meaning a count in bytes.

With _S_: signed, _U_: unsigned

e.g.:
EXTRACT_BE_32BITS -> EXTRACT_BE_U_4
EXTRACT_LE_32BITS -> EXTRACT_LE_U_4
...
EXTRACT_BE_INT32 -> EXTRACT_BE_S_4

and have:
EXTRACT_8BITS -> EXTRACT_U_1
EXTRACT_INT8  -> EXTRACT_S_1
2017-11-22 23:54:09 +01:00
Francois-Xavier Le Bail
99c91c3aec Rename 'tcpdump-stdinc.h' to 'netdissect-stdinc.h'
Get the full log via: git log --follow netdissect-stdinc.h
2015-09-10 08:50:40 +02:00
Guy Harris
69cb46af91 Fix a bunch of de-constifications. 2015-04-26 17:24:42 -07:00
Denis Ovsienko
38700c7f24 dismiss NETDISSECT_REWORKED macro
The purpose of this macro was to enable the file-by-file switch to NDO,
after which only tcpdump.c had a use of it and the definitions guarded
by it. Update tcpdump.c not to require them any more and dismiss the
unused definitions.
2015-03-22 10:06:15 +00:00
Guy Harris
ed85e20e4d u_intN_t is dead, long live uintN_t.
And, as we require at least autoconf 2.61, and as autoconf 2.61 and
later have AC_TYPE_UINTn_T and AC_TYPE_INTn_T macros, we use them to
define the uintN_t and intN_t macros if the system doesn't define them
for us.

This lets us get rid of bitypes.h as well.
2014-04-23 00:20:40 -07:00
Guy Harris
5cdf53e257 Define NETDISSECT_REWORKED in a bunch of files, and fix the issues it finds.
The only one it found was that routines in sigsecret.c needed to refer
to ndo->ndo_sigsecret, not just sigsecret.
2014-04-04 00:53:03 -07:00
Denis Ovsienko
b766ec9d3b fix bug #303 (DLT_IEEE802_11_RADIO ext. bitmaps)
This bug was discovered and pinned down by Wim Torfs.

The code in question handles DLT_IEEE802_11_RADIO datalink type, which
consists of a variable-sized header, a variable number of fields and the
actual 802.11 frame. The integers contained in the fields are aligned,
properly extracting them is exactly the purpose of the existing "cpack"
module. The issue with the current code is that it sets alignment base
for cpack at the end of the variable-sized header, in other words,
64-bit integers would be properly extracted only so long as the header
is 64-bit long, which only happens when the total number of bitmaps in
it is odd (the minimum number of bitmaps is one). Once this condition
isn't met, as is with two bitmaps, decoding becomes incorrect. The
reporter's point that the alignment base must be the beginning of the
variable-sized header is accurate.

This commit adds a new cpack_advance() function to fast-forward the
"c_next" pointer of a cpack_state context by an arbitrary number of
octets. The ieee802_11_radio_print() function now uses it to skip the
header and all its bitmaps, and the alignment base is now the header
start.
2013-04-28 18:26:53 +04:00
Guy Harris
54db122321 Support RX flags, MCS and the vendor namespace, and fix Rate.
Based on patches from an anonymous donor, support the radiotap RX flags and
MCS fields, and the vendor namespace, and, if Channel and XChannel are
both present, use XChannel, not Channel.

Do not try to look up a rate for an MCS value from the Rate field; you
cannot map an MCS value to a rate without also knowing the channel width
and guard interval length.
2011-04-27 12:08:27 -07:00
guy
3be7baca5e Include <string.h> to declare "memset()".
Add a cast to squelch a compiler complaint.
2004-09-24 18:18:00 +00:00
dyoung
665b5651a8 Add "cpack", a library for extracting 1-, 2-, 4-, and 8-octet words
from a buffer.  The cpack library expects for words to appear on
their natural boundaries.

The radiotap (802.11 + radio information) capture format uses cpack
to extract the radio information fields.
2004-09-23 21:27:18 +00:00