summaryrefslogtreecommitdiff
path: root/print-wb.c
Commit message (Collapse)AuthorAgeFilesLines
* Replace '(void)nd_print()' calls by nd_printjnp() callsFrancois-Xavier Le Bail2020-12-111-1/+1
| | | | | '(void)nd_print(ndo, start, start + len)' are replaced by 'nd_printjnp(ndo, start, len)'
* WB: Modernize packet parsing style.Denis Ovsienko2020-10-111-45/+38
| | | | | | | | | | Enable ND_LONGJMP_FROM_TCHECK. Remove ND_TTEST*() instances that were excess and convert the rest to ND_TCHECK*() with comments. Do not guard ndo_snapend directly. Make sure that functions specific to message types do not return on truncated data and return -1 when they have looked deep enough to tell an invalid packet. In wb_print() deduplicate some code and report invalid packets as invalid instead of truncated, also consider an unknown packet type invalid. Update a test.
* WB: Do some generic cleanup.Denis Ovsienko2020-10-111-45/+37
| | | | | | Remove stale comments. Disable unused named constants. Retype an array and print drawing operation codes with tok2str(). wb_dops() always returned 0, make it void.
* WB: Reorder printing of wb-id messages.Denis Ovsienko2020-09-151-8/+7
| | | | | | | | | | | | | As struct pkt_id informally notes it, the site name string follows "seqptr's", which is a sequence of zero or more (as encoded in the "nid" field) struct id_off items. Try to print the string after trying to print the sequence, so the output makes as much sense as possible for truncated packets. Also remove one ND_TTEST_LEN() before a nd_print() so the latter prints as much data as is available and deals with the snapshot end. While at it, rename and retype a pointer for clarity and lose two excess type casts, also add a length sanity check.
* More bounds checking when fetching addresses and converting to strings.Guy Harris2020-01-191-11/+11
| | | | | | | | | | | | | | 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.
* Clean up rounding up.Guy Harris2019-11-101-1/+1
| | | | | | | | Have roundup2() cast the power-of-2 argument to u_int; that way, you don't have to explicitly define it as an unsigned value in order to avoid compiler or UBSan complaints about signed integers. Use it instead of rolling our own rounding-to-a-power-of-2.
* Use the new GET_ macros instead of the EXTRACT_ onesFrancois-Xavier Le Bail2019-03-261-31/+31
| | | | | | | 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.
* Print truncations with nd_print_trunc() instead of tstr[] stringsFrancois-Xavier Le Bail2018-05-041-9/+8
| | | | | | | | Remove the tstr[] strings. Update the output of some tests accordingly. Moreover: Add or update some ndo_protocol fields.
* Rename the fn_printX() functions to nd_printX()Francois-Xavier Le Bail2018-04-301-1/+1
| | | | | | | 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.
* Add the ndo_protocol field in the netdissect_options structureFrancois-Xavier Le Bail2018-03-161-0/+1
| | | | | Update this field in printer entry functions. It will be used for some printings.
* Have ip{6}addr_string take a u_char * as the second argument.Guy Harris2018-01-311-11/+11
| | | | Fix warnings that introduces.
* 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
|
* Update ND_PRINT() as a variadic macroFrancois-Xavier Le Bail2018-01-071-43/+43
|
* Use ND_TTEST_SIZE()/ND_TCHECK_SIZE() macros (1/n)Francois-Xavier Le Bail2018-01-031-11/+11
|
* Use 'u_char *' type for input buffer pointer like in most similar casesFrancois-Xavier Le Bail2018-01-021-1/+1
|
* Use nd_ types, add EXTRACT_ calls, clean up signs vs. unsigned.Guy Harris2017-12-301-66/+69
|
* Remove all storage class specifier 'register'Francois-Xavier Le Bail2017-12-131-2/+2
| | | | | | Let the compiler do the optimizations (or not) based on build options. Avoid 'value has been optimized out' messages in gdb using '-O0'.
* Replace ND_TTEST2()/ND_TCHECK2() macros by macros using pointers (1/n)Francois-Xavier Le Bail2017-12-111-1/+1
| | | | | ND_TTEST2(var, l) -> ND_TTEST_LEN(p, l) ND_TCHECK2(var, l) -> ND_TCHECK_LEN(p, l)
* WB: Fix a bounds checkFrancois-Xavier Le Bail2017-12-051-1/+1
|
* Rename EXTRACT_ macrosFrancois-Xavier Le Bail2017-11-221-27/+27
| | | | | | | | | | | | | | | | 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 EXTRACT_nBITS() macros to EXTRACT_BE_nBITS()Francois-Xavier Le Bail2017-11-181-27/+27
| | | | | It indicates clearly that these macros are used to extract big-endian integral values.
* CVE-2017-13014/White Board: Do more bounds checks.Guy Harris2017-09-131-2/+7
| | | | | | | | | | This fixes a buffer over-read discovered by Yannick Formaggio. Add a test using the capture file supplied by the reporter(s). While we're at it, print a truncation error if the packets are truncated, rather than just, in effect, ignoring the result of the routines that print particular packet types.
* Move the printer summaries from INSTALL.txt to each printerFrancois-Xavier Le Bail2016-08-141-0/+2
| | | | | | | | with the tag '\summary:' for greping. Remark: Currently some printers have no summary line. Moreover: Summarize all printers with a single line in INSTALL.txt
* 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
* Printers must include 'netdissect.h', not 'interface.h'Francois-Xavier Le Bail2015-09-051-1/+1
|
* Fix a bunch of de-constifications.Guy Harris2015-04-261-14/+14
|
* whiteboard: fixup a few reversed tests (GH #446)Denis Ovsienko2015-03-251-3/+3
| | | | This is a follow-up to commit 3a3ec26.
* 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.
* Add additional bounds checks, ND_TTESTize existing ones.Guy Harris2014-10-191-19/+23
| | | | | | | | Use ND_TTEST() and ND_TTEST2() for bounds checks. Pass a pointer to the struct pkt_top to wb_dops, and calculate the address of the first struct dophdr there. Check each struct dophdr before printing it. Hopefully this will quiet a Coverity complaint.
* u_intN_t is dead, long live uintN_t.Guy Harris2014-04-231-24/+24
| | | | | | | | | 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.
* NDOize the rest of util.cDenis Ovsienko2014-04-141-1/+1
|
* Netdissectify the to-name resolution routines.Guy Harris2014-04-041-11/+11
| | | | | | | | Have them take a netdissect_options * argument, and get the "no name resolution" flag from it. Move the declaration of dnaddr_string to addrtoname.h, along with the other XXX-to-string routines.
* spell "%s" format strings (complements 708a68a)Denis Ovsienko2014-03-311-2/+2
| | | | | Make "%s" format string always reside in the print function call explicitly such that the reader doesn't have to assess its safety.
* NDOize ATM, MPTCP, NTP, VTP & Whiteboard decodersDenis Ovsienko2014-03-201-67/+76
|
* remove tcpdump's own CVS keywordsDenis Ovsienko2014-01-031-5/+0
| | | | | | Remove lots of $Header's and a few $Id's that all belong to the former CVS repository of tcpdump itself. These keywords have been frozen since the migration to git in late 2008.
* make more array declarations static/constDenis Ovsienko2013-12-191-1/+1
|
* Improve the bounds checking.guy2004-03-241-4/+4
|
* Have the configure script arrange that the Makefile define _U_guy2003-11-161-4/+4
| | | | | | | | | | appropriately, and that GNUmakefile and the MSVC++ project file define it apppriately, as we do with libpcap, rather than defining it in "interface.h". Undo the rcsid-shuffling and addition of extra #includes, as we no longer need to arrange that "interface.h" be included before using _U_ in an RCS ID or copyright.
* From Neil Spring:guy2003-11-151-4/+4
| | | | | | | | | | | use "_U_" in the definitions of "rcsid[]", to eliminate complaints about those variables being unused; move the definitions after the include of "interface.h", or add an include of "interface.h", so that "_U_" is defined. Include "config.h" before including "tcpdump-stdinc.h" in "missing/datalinks.c".
* The "__attribute__((packed))" tag on structures causes some files not toguy2002-12-111-37/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | compile with Sun C, as "interface.h" isn't being included before the structures are being declared. Furthermore, in the files that Sun C *can* compile, it doesn't cause Sun C to generate code that's safe with unaligned accesses, as "__attribute__" is defined as a do-nothing macro with compilers that don't support it. Therefore, we get rid of that tag on the structures to which it was added, and instead use "EXTRACT_16BIT()" and "EXTRACT_32BIT()" to fetch 16-bit and 32-bit big-endian quantities from packets. We also fix some other references to multi-byte quantities to get rid of code that tries to do unaligned loads on platforms that don't support them. We also throw in a hack that makes those macros use "__attribute__((packed))" on structures containing only one 16-bit or 32-bit integer to get the compiler to generate unaligned-safe code rather than doing it by hand. (GCC on SPARC produces the same code that doing it by hand does; I don't know if GCC on any other big-endian strict-alignment processor generates better code for that case. On little-endian processors, as "ntohs()" and "ntohl()" might be functions, that might actually produce worse code.) Fix some places to use "%u" rather than "%d" to print unsigned quantities.
* put __attribute__((packed)) to packet headers. s/u_short/u_int16_t/ and soitojun2002-11-091-16/+16
| | | | forth while i'm here
* Add a few more GCC warnings on GCC >= 2 for ".devel" builds.guy2002-09-051-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | From Neil T. Spring: fixes for many of those warnings: addrtoname.c, configure.in: Linux needs netinet/ether.h for ether_ntohost print-*.c: change char *foo = "bar" to const char *foo = "bar" to appease -Wwrite-strings; should affect no run-time behavior. print-*.c: make some variables unsigned. print-bgp.c: plen ('prefix len') is unsigned, no reason to validate by comparing to zero. print-cnfp.c, print-rx.c: use intoa, provided by addrtoname, instead of inet_ntoa. print-domain.c: unsigned int l; (l=foo()) < 0 is guaranteed to be false, so check for (u_int)-1, which represents failure, explicitly. print-isakmp.c: complete initialization of attrmap objects. print-lwres.c: "if(x); print foo;" seemed much more likely to be intended to be "if(x) { print foo; }". print-smb.c: complete initialization of some structures. In addition, add some fixes for the signed vs. unsigned comparison warnings: extract.h: cast the result of the byte-extraction-and-combining, as, at least for the 16-bit version, C's integral promotions will turn "u_int16_t" into "int" if there are other "int"s nearby. print-*.c: make some more variables unsigned, or add casts to an unsigned type of signed values known not to be negative, or add casts to "int" of unsigned values known to fit in an "int", and make other changes needed to handle the aforementioned variables now being unsigned. print-isakmp.c: clean up the handling of error/status indicators in notify messages. print-ppp.c: get rid of a check that an unsigned quantity is >= 0. print-radius.c: clean up some of the bounds checking. print-smb.c: extract the word count into a "u_int" to avoid the aforementioned problems with C's integral promotions. print-snmp.c: change a check that an unsigned variable is >= 0 to a check that it's != 0. Also, fix some formats to use "%u" rather than "%d" for unsigned quantities.
* Added support for Win32, based on WinPcap.risso2002-08-011-5/+2
|
* *Another* #define that's also defined by some OS; in this case, it'sguy2001-06-271-1/+5
| | | | | PF_USER, defined by {Digital,Tru64} UNIX, so, if it's defined, undefine it before we define it, to squelch compiler warnings.
* Switch to config.h instead of passing defines in DEFS.fenner1999-11-211-1/+5
|
* Initial revisionmcr1999-10-071-0/+435