summaryrefslogtreecommitdiff
path: root/cpack.c
Commit message (Collapse)AuthorAgeFilesLines
* Prefix all cpack function names with "nd_". [skip ci]Denis Ovsienko2020-09-301-19/+19
| | | | | | | | | | | | | | | | | | | 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.
* Use the new GET_ macros instead of the EXTRACT_ onesFrancois-Xavier Le Bail2019-03-261-8/+8
| | | | | | | 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.
* Add the ndo parameter to some functionsFrancois-Xavier Le Bail2019-03-261-8/+8
| | | | This parameter will be needed at the next step.
* Always include <config.h> rather than "config.h".Guy Harris2018-01-211-1/+1
| | | | | | | | 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.
* Use quoted include netdissect-stdinc.h instead of angle-bracketed oneFrancois-Xavier Le Bail2018-01-211-1/+1
|
* Add EXTRACT_ macros/functions for IPv4 addresses, get rid of structure wrappers.Guy Harris2017-12-201-1/+3
| | | | | | | | | | | | | | | | | | 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.
* Clean up signed vs. unsigned.Guy Harris2017-11-231-1/+64
| | | | | | | | | | | | | | 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.
* Rename EXTRACT_ macrosFrancois-Xavier Le Bail2017-11-221-3/+3
| | | | | | | | | | | | | | | | 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
* Rename 'tcpdump-stdinc.h' to 'netdissect-stdinc.h'Francois-Xavier Le Bail2015-09-101-1/+1
| | | | Get the full log via: git log --follow netdissect-stdinc.h
* Fix a bunch of de-constifications.Guy Harris2015-04-261-8/+8
|
* dismiss NETDISSECT_REWORKED macroDenis Ovsienko2015-03-221-1/+0
| | | | | | | 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.
* u_intN_t is dead, long live uintN_t.Guy Harris2014-04-231-16/+16
| | | | | | | | | 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.
* Define NETDISSECT_REWORKED in a bunch of files, and fix the issues it finds.Guy Harris2014-04-041-0/+1
| | | | | The only one it found was that routines in sigsecret.c needed to refer to ndo->ndo_sigsecret, not just sigsecret.
* fix bug #303 (DLT_IEEE802_11_RADIO ext. bitmaps)Denis Ovsienko2013-04-281-0/+11
| | | | | | | | | | | | | | | | | | | | | | | 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.
* Support RX flags, MCS and the vendor namespace, and fix Rate.Guy Harris2011-04-271-2/+2
| | | | | | | | | | 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.
* Include <string.h> to declare "memset()".guy2004-09-241-1/+2
| | | | Add a cast to squelch a compiler complaint.
* Add "cpack", a library for extracting 1-, 2-, 4-, and 8-octet wordsdyoung2004-09-231-0/+143
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.