Commit Graph

165 Commits

Author SHA1 Message Date
Gokul Sivakumar
ff5484806e Fix the misleading comment regarding "From DS", "To DS" Frame Control Flags
In the case where the "From DS" bit is not set and the "To DS" bit is set
in the Frame Control Bitmask, the comment line in the corresponding if else
block was misleading that the "From DS" bit is set and the "To DS" bit is
not set.
2021-06-27 19:00:00 +00:00
Denis Ovsienko
fd60dce545 IEEE 802.11: Simplify handle_action(). [skip ci]
Lose PRINT_MESHLINK_ACTION(), PRINT_MESHPEERING_ACTION() and
PRINT_MESHPATH_ACTION(), which were unused since commit f1c0553. Convert
the remaining 5 macros and hard-coded strings using tok2str() and
uint2tokary().
2021-01-22 11:10:25 +00:00
Denis Ovsienko
7810dd37c2 Prefix all cpack function names with "nd_". [skip ci]
Gisle Vanem reported in GH #881 that in Windows tcpdump failed to link
with static AirPcap because the latter seems to include its own variant
of cpack code:

airpcap_static.lib(RadiotapDecode.obj) : error LNK2005: _cpack_init
already defined in cpack.obj
airpcap_static.lib(RadiotapDecode.obj) : error LNK2005: _cpack_uint16
already defined in cpack.obj
airpcap_static.lib(RadiotapDecode.obj) : error LNK2005: _cpack_uint32
already defined in cpack.obj
airpcap_static.lib(RadiotapDecode.obj) : error LNK2005: _cpack_uint64
already defined in cpack.obj
airpcap_static.lib(RadiotapDecode.obj) : error LNK2005: _cpack_uint8
already defined in cpack.obj

He confirms this change resolves the issue.
2020-09-30 19:16:19 +01:00
Francois-Xavier Le Bail
4eb7a801c3 IEEE 802.11: Remove trailing "_if" from protocol names 2020-08-02 11:36:05 +02:00
Francois-Xavier Le Bail
627051ec20 IEEE 802.11: Update the link-layer header length in two steps (PRISM)
This way, even if we longjmped out of the code because trucation,
the prism header length is subtracted for -x/-X print.
2020-08-02 10:58:16 +02:00
Francois-Xavier Le Bail
dc8a38c289 IEEE 802.11: Update the link-layer dissectors to void functions 2020-08-02 10:35:09 +02:00
Francois-Xavier Le Bail
52ad9e15b4 IEEE 802.11: Fix signedness of the flags parameters of print_chaninfo()
uint32_t for flags, because there are calls with uint16_t and uint32_t.

This change avoids (for presentflags):
print-802_11.c:2795:41: runtime error: implicit conversion from type
'uint32_t' (aka 'unsigned int') of value 2147502191 (32-bit, unsigned)
to type 'int' changed the value to -2147465105 (32-bit, signed)
    #0 0x815e130 in print_radiotap_field ./print-802_11.c:2795:41
2020-07-01 10:28:43 +02:00
Francois-Xavier Le Bail
815e033571 IEEE 802.11: Add a missing comma to separate two string literals
Should fix Coverity CID 1463833.
2020-05-25 20:22:02 +02:00
Guy Harris
b751376719
Merge pull request #773 from Mister-X-/fix-reason-codes
Fix and update 802.11 reason codes
2020-05-24 20:41:01 -07:00
Guy Harris
4aac37f043
Merge pull request #772 from Mister-X-/fix-status-codes
Fix and update 802.11 status codes
2020-05-24 20:40:19 -07:00
Guy Harris
306c2a0384 More bounds checking when fetching addresses and converting to strings.
Replace more calls to ipaddr_string()/ip6addr_string() with calls to
GET_IPADDR_STRING()/GET_IP6ADDR_STRING() macros performing bounds
checking.

Add similar bounds-checking inline functions and macros to wrap
linkaddr_string(), etheraddr_string(), and isonsap_string() and convert
calls to them to use the macros as well.

Shuffle the inline functions in addrtoname.h around a bit, so that the
inline functions, external declarations, and macros are all in the same
order.
2020-01-19 19:55:38 -08:00
Mister X
ee5abf5c87 Fixed missing space 2019-06-20 21:59:34 +00:00
Mister X
b8377853aa Fixed missing double quote 2019-06-20 21:58:47 +00:00
Mister X
d20791d385 Fixed and updated status codes from 802.11-2016 2019-06-08 02:20:27 +00:00
Mister X
ddbf2c428f Fixed and updated reason codes from 802.11-2016 2019-06-08 02:19:27 +00:00
Francois-Xavier Le Bail
ee68aa3646 Use the new GET_ macros instead of the EXTRACT_ ones
The exceptions are currently:
Some EXTRACT_ in print-juniper.c, not used on packet buffer pointer.
An EXTRACT_BE_U_3 in addrtoname.c, not always used on packet buffer
pointer.
2019-03-26 21:06:24 +01:00
Francois-Xavier Le Bail
1af20c3adc Add the ndo parameter to some functions
This parameter will be needed at the next step.
2019-03-26 21:06:23 +01:00
Francois-Xavier Le Bail
91b0ee0a59 IEEE 802.11: Replace some ND_TTEST_*() calls with ND_TCHECK_*() calls
Moreover:
Use 'goto trunc' in some length tests.
2019-02-24 10:55:12 +01:00
Francois-Xavier Le Bail
6d855c7007 Clean up whitespaces/indentation 2019-02-24 09:44:14 +01:00
Antonin Décimo
0b3880c91e Fix small misspellings 2019-01-23 17:28:14 +01:00
Guy Harris
83e419c628 Fix printing of Linux cooked captures with monitor-mode packets.
Apparently, if you have an interface in monitor mode, capturing on the
"any" device can get packets that have a SLL hatype of 803, which is the
ARPHRD_ value for radiotap, and with the payload containing a radiotap
header, followed by an 802.11 header, followed by the 802.11 payload.
Handle that.
2018-11-12 22:03:49 -08:00
Francois-Xavier Le Bail
46efa1bc47 Fix spaces 2018-09-03 15:18:19 +02:00
Guy Harris
cf99f0bc83 Explicitly check to make sure the header length isn't too short. 2018-08-08 13:41:44 -07:00
Guy Harris
6e80fcdbe9 Make roundup2() generally available. 2018-06-22 11:18:20 -07:00
Francois-Xavier Le Bail
3f1c4af001 IEEE 802.11: Add a bounds check 2018-06-18 21:47:43 +02:00
Francois-Xavier Le Bail
419cc7087b IEEE 802.11: Print the SSID with the fn_print_str() function
We cannot use nd_print() because the parameter is not a pointer on the
packet buffer.
2018-05-19 09:14:19 +02:00
Francois-Xavier Le Bail
ba8936b39b Print truncations with nd_print_trunc() instead of tstr[] strings
Remove the tstr[] strings.
Update the output of some tests accordingly.

Moreover:
Add or update some ndo_protocol fields.
2018-05-04 13:47:49 +02:00
Francois-Xavier Le Bail
3e3e6d2ef4 Rename the fn_printX() functions to nd_printX()
The functions are: nd_print, nd_printztn, nd_printn and nd_printzp.
Trying to make it clearer that they currently have to be used only on part
of the packet buffer.
Update some comments.
2018-04-30 13:35:06 +02:00
Francois-Xavier Le Bail
546558eabd Add the ndo_protocol field in the netdissect_options structure
Update this field in printer entry functions.
It will be used for some printings.
2018-03-16 19:44:47 +01:00
Francois-Xavier Le Bail
75397ef8d5 Fix naming
For coherency.
We have: DLT_IEEE802_11_RADIO_AVS and ieee802_11_radio_avs_if_print().
Thus rename ieee802_11_avs_radio_print() to ieee802_11_radio_avs_print().
2018-03-14 18:37:09 +01:00
Francois-Xavier Le Bail
46f5203a8d Style update
Use parens around the sizeof argument, to match the style used elsewhere.
2018-02-06 20:01:55 +01:00
Guy Harris
7b909aba81 Squelch warnings from MSVC.
Use float values, rather than double values, to initialize an array of
floats.
2018-01-29 02:25:56 -08:00
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
3bc62cd35f Use pcapng as the name of the file format.
At one point, I remember a discussion resulting in the official name of
the next-generation replacement for pcap format being changed to
"pcapng", with no hyphen.

Make tcpdump reflect that.

While we're at it, uppdate to use "macOS" as the name of Apple's
UNIX-for-Macs, as appropriate (don't use it for versions that were still
called Mac OS X or OS X).
2018-01-08 18:50:06 -08:00
Francois-Xavier Le Bail
e2982e7f6f Update ND_PRINT() as a variadic macro 2018-01-07 13:36:41 +01:00
Francois-Xavier Le Bail
ff1c209392 Fix some Coccinelle warnings "a \ character appears outside of a #define" 2018-01-04 13:26:39 +01:00
Guy Harris
1eae026e55 Use nd_ types, add EXTRACT_ calls, clean up signed vs. unsigned. 2017-12-31 11:12:12 -08:00
Francois-Xavier Le Bail
84ef17ac0e Replace ND_TTEST2()/ND_TCHECK2() macros by macros using pointers (1/n)
ND_TTEST2(var, l)  -> ND_TTEST_LEN(p, l)
ND_TCHECK2(var, l) -> ND_TCHECK_LEN(p, l)
2017-12-11 22:11:01 +01:00
Francois-Xavier Le Bail
c56f25c54b Use more the EXTRACT_U_1() macro (55/n) 2017-12-10 21:33:49 +01:00
Francois-Xavier Le Bail
e44bc94ad0 Use pointer expressions like in most similar cases 2017-12-10 15:17:06 +01:00
Francois-Xavier Le Bail
ef3437c081 Use more the EXTRACT_U_1() macro (50/n) 2017-12-09 10:17:18 +01:00
Francois-Xavier Le Bail
dbcba20b5e Use more the EXTRACT_U_1() macro (42/n)
In: switch (... p[n] ...) ...
2017-12-02 00:04:55 +01:00
Francois-Xavier Le Bail
505cd1fe15 Use more the EXTRACT_U_1() macro (39/n)
In some macros and functions call, p[n]
2017-12-01 15:48:41 +01:00
Francois-Xavier Le Bail
1a90fd99d2 Use more the EXTRACT_U_1() macro (28/n)
In ND_PRINT() macro call(s) (step 7).

p[n] ...
2017-11-26 15:44:43 +01:00
Francois-Xavier Le Bail
39c8c55aa9 Use more ND_TCHECK_n()/ND_TTEST_n() macros 2017-11-24 22:48:55 +01:00
Guy Harris
317abbf877 Get rid of an unnecessary cast. 2017-11-23 13:11:44 -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
cb9b665059 Use more the EXTRACT_8BITS() macro to fetch a one-byte value (18/n)
Assignment, *(p op e)

Partial list.
2017-11-21 22:23:47 +01:00