Commit Graph

55 Commits

Author SHA1 Message Date
Guy Harris
c19f2e8f2b Squelch a warning, style normalization. 2009-05-21 10:32:59 -07:00
Florian Forster
127b352b40 util.c: Add the `mask62plen' utility function.
The function does the same as `mask2plen' but for IPv6.

Signed-off-by: Florian Forster <octo@leeloo.lan.home.verplant.org>
2009-05-21 10:29:24 -07:00
Guy Harris
0cd29d2917 From Marc Binderberger: check whether XXX is null before checking
whether XXX->YYY is null.
2009-02-26 01:24:10 -08:00
hannes
9427d40c14 change the TCP printer to print new-style order:
- seperate fields by comma
  - use [] for flags and options sets
  - print a trailing length field

make use of tok2str() and bitttok2str()
move port definitions into tcp.h
2007-01-29 09:59:42 +00:00
guy
7daf6157e2 Fix indentation. 2006-08-19 06:47:39 +00:00
hannes
03f755dab7 add support for AIS/RDI OAM cell payload printing, hexdump location/source ID for loopback OAM cells rather than attempting to print it 2006-02-08 16:18:56 +00:00
hannes
ddb7009f90 add a maxlen boundary check to safeputs, print unprintable chars as hex in safeputchar 2006-02-08 01:38:16 +00:00
gianluca
bae81fc719 Moved the declaration of d_usec and d_sec at the beginning of the function. 2006-01-22 19:06:37 +00:00
hannes
8e01df24a4 init last/first packet timestamp for both -ttt and -tttttt option 2005-12-13 08:47:10 +00:00
hannes
a6df5512cf - add the -ttttt timestamp option which prints the time difference
(in micro-second resolution) between the first and current packet.

- cleanup the the ts_print code a bit -> add a ts_format helper
2005-12-13 08:37:22 +00:00
guy
8a871af07f We don't need gettimeofday() to just get seconds since January 1, 1970,
midnight GMT; just use time().

We also don't need to flush the standard error right before exiting.

Clean up white space.
2005-12-05 20:24:48 +00:00
hannes
b2bf371ad5 from Gisle Vanem <giva@bgnett.no>: privatize filetime_to_unix_epoch() gettimeofday() for win32 platforms 2005-12-05 08:57:30 +00:00
guy
db34d9c99d Add some sanity checking of the arguments to "print_unknown_data()", as
per the problems found by Gerald Combs.
2005-06-16 01:19:38 +00:00
guy
638229f1b6 Bounds-check the individual components of a SAP reply.
Make "fn_printzp()" return 0 if we don't run past the end of the packet
and we don't find any padding NULs.
2005-05-06 08:26:44 +00:00
guy
6191f36146 Add an "fn_printzp()" routine for printing null-padded strings (strings
with a maximum length, where a string shorter than that length is padded
with NULs), as "fn_print()" won't handle the maximum length *and* the
snapshot length and "fn_printn()" won't stop on a null string.  Use it
where appropriate.

Always pass "snapend" to "fn_print()" and "fn_printn()" if they're
passed a pointer into the packet data; only pass NULL if they're being
handed a pointer into a buffer that's not part of the packet data.

Always check the return value of "fn_print()", "fn_printn()", and
"fn_printzp()" if they're passed "snapend", and do the appropriate
string termination and "packet truncated" indication if they return 1.
2005-05-06 07:56:51 +00:00
guy
079ae67825 Don't run past the end of the data when printing unknown data. 2005-04-26 03:43:27 +00:00
guy
686d1b333d Don't dump core if a null "struct tok" array pointer is passed to
"tok2strbuf()".
2005-04-25 16:14:43 +00:00
hannes
b9bc936cc6 -add basic support for codeset shifting for IE printing in the frame-relay printer
-harden tok2str() and bittok2str() to catch NULL refs
-don't attempt to print a frame-relay IE if there is not enough bytes on the wire
 to print at least a full TLV
2005-03-21 11:35:55 +00:00
guy
791d0e8bb7 Make "tflag" count the number of "-t"s, to make it more obvious what
tflag values correspond to what output formats (e.g., 4 means "-tttt").

Switch on the tflag value to determine whether to call "gmt2local()" to
set "thiszone", just as we switch on it to determine the format for time
stamps, to make it more obvious in what cases we call it.
2004-06-15 23:05:05 +00:00
mcr
4217d3321a merge error for tok2str. 2004-04-29 02:15:16 +00:00
mcr
6ed2536f5d change tok2str API to permit caller to provide
a buffer, and make tok2str a wrapper for this.
2004-04-29 01:32:47 +00:00
guy
2d6231deeb From Gisle Vanem: give "tok2str()" 4 static buffers it can fill in, so
that it can be called up to 4 times in a given "printf()".
2004-04-28 22:06:33 +00:00
hannes
388842b5e4 pave the way for eliminating print_unknown_data() and subsequent hex_print() replacement 2003-12-29 11:07:17 +00:00
guy
bbc1cfa669 Have the configure script arrange that the Makefile define _U_
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.
2003-11-16 09:36:07 +00:00
guy
3824a6c041 From Neil Spring:
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".
2003-11-15 00:39:12 +00:00
hannes
b717e4dba5 fix display of correct offset for hexdumps 2003-10-02 13:16:14 +00:00
guy
66b89d8fb8 As per a comment by Alex Medvedev <alexm@pycckue.org>, start the search
for prefixes at bitmasks[32] (the last element of a 33-element array),
not bitmasks[33] (one past the last element of that array).

Clean up white space.
2003-07-30 00:20:28 +00:00
fenner
99c03187af Fix fencepost error in fn_printn() which would return a truncation
indication if the last byte of the counted string was the last
 byte captured.
2003-04-21 16:59:52 +00:00
guy
ab6d9582af From Gisle Vanem: use ISO 8601 date/time format in "-tttt" mode. 2003-03-04 08:53:26 +00:00
guy
49e3507eb3 From Gisle Vanem <giva@bgnett.no>:
open the file containing a filter expression in binary mode, so
	that we get all the characters that "fstat()" claims are there,
	rather than having CRs stripped out (causing us to report an
	error because the "read()" call gives us less data than
	"fstat()" claims was in the file);

	close the file descriptor once we're finished reading the file;

	strip out everything on a line starting with "#", so that "#"
	can be used for to-end-of-line comments in the file.

Update his address in the CREDITS file.
2003-02-08 19:31:59 +00:00
hannes
a4d961cbef add mask2plen function to util.c 2002-12-22 01:26:48 +00:00
hannes
686992b829 new function bittok2str()
this is useful for scanning bitfields
  the input is a tokenlist and a testvalue
  the function will parse the tokenlist for each single bitmatch
    of the testvalue;
  if it finds a a match it will write teh tokenstring into a buffer
    and place a comma to seperate the values

  if there is no match it will format the buffer according to the format string;

  i saw many private instances of similar bitscanning functions;
    lets use bittok2str() from now on;
2002-11-07 20:07:58 +00:00
hannes
c70aa5a19d don't attempt to hexdump if length == 0 2002-10-11 10:34:07 +00:00
guy
79877e90f4 Get rid of some unnecessary includes (<time.h>, <netdb.h>, and <ctype.h>
are included by <tcpdump-stdinc.h>, so we don't have to include them
explicitly; <errno.h> isn't needed by print routines).
2002-08-06 04:42:04 +00:00
guy
2d5b082ff9 From Motonori Shindo <mshindo@mshindo.net>: squelch warnings from some
compilers.
2002-08-02 04:22:11 +00:00
risso
3d932490b8 Added support for Win32, based on WinPcap. 2002-08-01 08:52:55 +00:00
hannes
cde343c41a yet another hexdump routine;
print_unknown_data{} supports identation;
2002-07-18 00:04:12 +00:00
guy
e36afc3163 Clean up "safeputchar()" a bit. 2002-07-16 04:03:16 +00:00
guy
dfa8cbe527 In "safeputchar()", use the result of extracting an unsigned character
from the argument, rather than the argument itself, when testing whether
it should be printed or not (the argument might well be a sign-extended
version of an 8-bit character, in which case it's < 0x80 as it's
negative, but it can't be safely handed to "isprint()").
2002-07-16 03:58:16 +00:00
itojun
111ff8a61d whitespace cleanup 2002-06-11 17:08:37 +00:00
fenner
405e7c0140 Introduce tok2strary(), similar to tok2str() except it takes an
array of strings instead of a list of value/string pairs.
2001-10-08 16:12:12 +00:00
fenner
d5c621ba52 Handle negative timestamps in relts_print(). 2001-09-17 21:05:43 +00:00
fenner
6913fe611b Add some const qualifiers
Check for malloc failure in read_infile()
2001-09-10 00:28:54 +00:00
assar
6e2695e9e0 remove gnuc.h and __dead 2000-07-11 00:49:02 +00:00
assar
3cd171317f remove non-STDC code 2000-07-01 03:38:59 +00:00
itojun
76c5a0bdc1 fix safeputc, the if statment was completely reversed 2000-06-21 09:08:34 +00:00
assar
e67c4ce1ed (ts_print): fix printing in `-tttt' style. From "Gisle Vanem"
<gvanem@eunet.no>
2000-06-10 08:11:12 +00:00
itojun
e44561cc48 avoid possible infinite loop in relts_print().
move safeputchar() and safeputs() into util.c for better code sharing.
some style.
2000-06-03 16:40:35 +00:00
assar
b8b7356458 (ts_print): add new styles of timestamps.
From Francisco Matias Cuenca-Acuna <mcuenca@george.rutgers.edu>
2000-06-01 01:13:53 +00:00
itojun
dff10c7f70 s/sprintf/snprintf/.
there seem to be couple of unsafe use of strcat and strcpy - we should
bring in strl{cat,cpy}.
2000-01-17 06:24:23 +00:00