summaryrefslogtreecommitdiff
path: root/print-ascii.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix spaces before tabs in indentationFrancois-Xavier Le Bail2023-02-151-1/+1
|
* ASCII/hex: Rename a variableFrancois-Xavier Le Bail2022-03-041-9/+9
| | | | | | | s/oset/offset/ Moreover: Fix indentation.
* Spell "indent" where it belongs.Denis Ovsienko2021-03-281-10/+10
|
* ASCII/hex: Use nd_trunc_longjmp() in truncation casesFrancois-Xavier Le Bail2021-03-271-8/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In functions ascii_print(), hex_and_ascii_print_with_offset() and hex_print_with_offset(). Therefore indirectly for the functions hex_and_ascii_print(), hex_print() and ndo_default_print(). Even if hex_and_ascii_print(), hex_print() and ascii_print() are used in print.c after the setjmp() block with the calls: 1) hex_and_ascii_print(ndo, "\n\t", sp, h->caplen); 2) hex_and_ascii_print(ndo, "\n\t", sp + hdrlen, h->caplen - hdrlen); 3) hex_print(ndo, "\n\t", sp, h->caplen); 4) hex_print(ndo, "\n\t", sp + hdrlen, h->caplen - hdrlen); 5) ascii_print(ndo, sp, h->caplen); 6) ascii_print(ndo, sp + hdrlen, h->caplen - hdrlen); sp and h->caplen are unmodified, ndo->ndo_snapend was restored. 1), 3) and 5) the length to print is caplen => no truncation can occur. 2), 4) and 6) the length to print is (caplen - hdrlen) after a shift of hdrlen => no truncation can occur. Moreover: Update the output of three tests accordingly. Remove an useless comment. Fix indentation.
* Lose a forward declaration in print-ascii.c. [skip ci]Denis Ovsienko2020-09-131-2/+0
|
* Don't use <ctype.h> macros.Guy Harris2019-09-011-4/+7
| | | | | | | | | | | | | | Some of them are locale-dependent, and all of them run the risk of failing if you hand them a char with the 8th bit set. Move our replacements to a new netdissect-ctype.h file, and, for the ones that check for particular character types, add _ASCII to the name, to indicate that only ASCII characters pass the check. Do the same for the ones that map between cases, to indicate that they only map ASCII letters. For isspace(), explicitly check for the characters we care about, to make it clearer what we're doing.
* Remove more old-compiler compensation.Guy Harris2019-08-081-2/+2
| | | | | | | | | | | | We require an environment with a C99-compatible snprintf(), so we don't need to work around older implementations. Make the configuration process fail if we don't have snprintf() and vsnprintf(). We require at least VS 2015, so we don't have to check for _MSC_VER >= 1400. Make the build fail if we don't have at least VS 2015. We apparently do, however, have to use __inline, as the VS 2015 documentation doesn't meaning plain old "inline". Update a comment.
* Fix some narrowing warnings on LP64/LLP64 platforms.Guy Harris2019-04-181-3/+3
| | | | | | | | | | | | Add a ND_BYTES_AVAILABLE_AFTER() macro to find the number of bytes available in the captured data, starting at the byte pointed to by the argument. It returns a u_int rather than a ptrdiff_t, so it'll be 32 bits on LP64 and LLP64 platforms as well as on ILP32 platforms. Use that macro. Make size-of-buffer arguments size_t. Cast some size_t and ptrdiff_t values to u_int or int.
* 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.
* Type and size cleanups.Guy Harris2018-12-101-9/+11
| | | | | | | | | | Make the count of 2-octet values to dump an unsigned value. Make the variables into which we fetch those octets unsigned as well. Cast the result of the "is the character printable ASCII? If so, it's the character, otherwise it's '.'" to char, to squelch narrowing warnings.
* Simplify some expressionsFrancois-Xavier Le Bail2018-06-011-3/+3
| | | | In the equality case, the difference is also zero.
* Update hex_and_ascii_print_with_offset() to staticFrancois-Xavier Le Bail2018-05-101-1/+3
|
* 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.
* Add nd_{v}snprintf() routines/wrappers.Guy Harris2018-01-291-2/+2
| | | | | | | | Some versions of the MSVC runtime library have a non-C99-compliant vsnprintf(), which we want to avoid. On Windows, use snprintf() and vsnprintf() for VS 2015 and later, where they both exist in C99-compliant forms, and wrap _{v}snprintf_s() otherwise (they're guaranteed to do the null termination that we want).
* Use the EXTRACT_U_1() macro in some utility functionsFrancois-Xavier Le Bail2018-01-281-6/+11
|
* 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-12/+12
|
* Remove all storage class specifier 'register'Francois-Xavier Le Bail2017-12-131-10/+10
| | | | | | Let the compiler do the optimizations (or not) based on build options. Avoid 'value has been optimized out' messages in gdb using '-O0'.
* Use more the EXTRACT_U_1() macro (48/n)Francois-Xavier Le Bail2017-12-091-1/+2
|
* Use more the EXTRACT_U_1() macro (47/n)Francois-Xavier Le Bail2017-12-051-1/+2
| | | | In: if (... *(p) ...) ...
* 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
|
* 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.
* Don't run past the snapshot length when doing hex/ASCII dumps.Guy Harris2014-10-231-0/+12
|
* coordinate ascii_print() prototypes for MSVCGisle Vanem2014-04-031-1/+1
| | | | | ascii_print() has conflicts between prototype and implementation. MSVC doesn't allow adding a register modifier just like that.
* improve previous NDO conversionsDenis Ovsienko2014-04-031-7/+8
|
* finalize some previous NDO conversionsDenis Ovsienko2014-03-261-5/+5
| | | | | | Eliminate a number of fputs(), putchar() and fflush() uses. Justify preprocessor directives. Don't typecast ND_PRINT() to void and fix some indentation.
* NDOize print-ascii.c furtherDenis Ovsienko2014-03-131-8/+8
| | | | | Introduce netdissect_options into hex_and_ascii_print_with_offset(), hex_and_ascii_print() and related functions.
* With -A and -AA, don't send CRs to the standard output.Guy Harris2014-02-031-5/+19
| | | | | | They don't belong on the ends of lines on UN*X, and the standard I/O library will give us one at the end of the line on Windows so they're not needed there. In the middle of a line, just print a ".".
* Do our own isascii(), isprint(), isgraph(), and toascii().Guy Harris2014-02-021-4/+4
| | | | | | | | | We do *not* want the behavior of isprint() and isgraph() to be locale-dependent - we want both of them to return "true" only for ASCII characters. We have to do our own isascii() and toascii() on non-UN*X systems anyway, so let's just do all of them ourselves.
* remove tcpdump's own CVS keywordsDenis Ovsienko2014-01-031-4/+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.
* fix a few compiler warnings about prototypesDenis Ovsienko2014-01-021-0/+1
| | | | | | | print-ascii.c needs prototypes of ascii_print(), hex_and_ascii_print_with_offset() and hex_and_ascii_print(). print-icmp6.c needs prototypes of in_cksum_shouldbe() and ns_nprint().
* ndo-ize print-ascii: hex_print_with_offset()Michael Richardson2014-01-011-10/+11
|
* Have "ascii_print()" do the "-A" output, and nothing but the "-A"guy2005-07-061-48/+46
| | | | | | | | | | | | | | output. Have "hex_and_ascii_print_with_offset()" and "hex_and_ascii_print()" to the "-X"-style offset, leaving "hex_print_with_offset()" and "hex_print()" doing the "-x"-style output. Don't have any of them check "xflag", "Xflag", or "Aflag" - they print what they're intended to print, and the caller should check the flags in question. Don't have "-A" set "xflag" or "Xflag". This cleans up some problems with "-A" printing hex informatioin - it's not supposed to.
* The first argument to "ascii_print_with_offset()", "ascii_print()",guy2004-07-211-5/+5
| | | | | | | | | | | | "hex_print_with_offset()", and "hex_print()" is a string used as a tag; make it a "const char *", not a "const u_char *". Copy the declaration of "strsep()" from "interface.h" to "netdissect.h", and get rid of the include of "interface.h" from "print-esp.c", as it includes "netdissect.h". Update the "ND_TTEST2()" macro to do the same overflow checks that "TTEST2()" now does.
* pass on ident string to hex_print()hannes2003-12-291-6/+6
|
* elimitate tabs as they mess up the multi-line outputhannes2003-12-291-3/+3
|
* pass an identation string to the ascii printerhannes2003-12-291-9/+11
|
* 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".
* Add a few more GCC warnings on GCC >= 2 for ".devel" builds.guy2002-09-051-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-3/+2
|
* whitespace cleanupitojun2002-06-111-3/+3
|
* "-A" flag to print packet data in ASCII, from Jørgen Thomsenguy2002-04-241-19/+43
| | | | <jth@jth.net>.
* fix ascii dump with -X. due to mistake in snprintf() fixes.itojun2000-01-291-3/+5
| | | | (no need to pull into 3.5)
* s/sprintf/snprintf/.itojun2000-01-171-3/+3
| | | | | there seem to be couple of unsafe use of strcat and strcpy - we should bring in strl{cat,cpy}.
* Unify rcsid[]'s.fenner2000-01-091-6/+2
|
* <sys/cdefs.h>: conditionalizeassar2000-01-071-0/+2
|