summaryrefslogtreecommitdiff
path: root/util.c
Commit message (Collapse)AuthorAgeFilesLines
* Squelch a warning, style normalization.Guy Harris2009-05-211-13/+13
|
* util.c: Add the `mask62plen' utility function.Florian Forster2009-05-211-0/+29
| | | | | | The function does the same as `mask2plen' but for IPv6. Signed-off-by: Florian Forster <octo@leeloo.lan.home.verplant.org>
* From Marc Binderberger: check whether XXX is null before checkingGuy Harris2009-02-261-1/+1
| | | | whether XXX->YYY is null.
* change the TCP printer to print new-style order:hannes2007-01-291-6/+35
| | | | | | | | | - 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
* Fix indentation.guy2006-08-191-2/+3
|
* add support for AIS/RDI OAM cell payload printing, hexdump location/source ↵hannes2006-02-081-2/+2
| | | | ID for loopback OAM cells rather than attempting to print it
* add a maxlen boundary check to safeputs, print unprintable chars as hex in ↵hannes2006-02-081-4/+6
| | | | safeputchar
* Moved the declaration of d_usec and d_sec at the beginning of the function.gianluca2006-01-221-3/+5
|
* init last/first packet timestamp for both -ttt and -tttttt optionhannes2005-12-131-2/+2
|
* - add the -ttttt timestamp option which prints the time differencehannes2005-12-131-24/+41
| | | | | | (in micro-second resolution) between the first and current packet. - cleanup the the ts_print code a bit -> add a ts_format helper
* We don't need gettimeofday() to just get seconds since January 1, 1970,guy2005-12-051-41/+1
| | | | | | | | midnight GMT; just use time(). We also don't need to flush the standard error right before exiting. Clean up white space.
* from Gisle Vanem <giva@bgnett.no>: privatize filetime_to_unix_epoch() ↵hannes2005-12-051-1/+41
| | | | gettimeofday() for win32 platforms
* Add some sanity checking of the arguments to "print_unknown_data()", asguy2005-06-161-1/+11
| | | | per the problems found by Gerald Combs.
* Bounds-check the individual components of a SAP reply.guy2005-05-061-2/+2
| | | | | Make "fn_printzp()" return 0 if we don't run past the end of the packet and we don't find any padding NULs.
* Add an "fn_printzp()" routine for printing null-padded strings (stringsguy2005-05-061-2/+36
| | | | | | | | | | | | | | | 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.
* Don't run past the end of the data when printing unknown data.guy2005-04-261-1/+3
|
* Don't dump core if a null "struct tok" array pointer is passed toguy2005-04-251-5/+7
| | | | "tok2strbuf()".
* -add basic support for codeset shifting for IE printing in the frame-relay ↵hannes2005-03-211-3/+3
| | | | | | | | 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
* Make "tflag" count the number of "-t"s, to make it more obvious whatguy2004-06-151-6/+13
| | | | | | | | 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.
* merge error for tok2str.mcr2004-04-291-2/+4
|
* change tok2str API to permit caller to providemcr2004-04-291-11/+20
| | | | a buffer, and make tok2str a wrapper for this.
* From Gisle Vanem: give "tok2str()" 4 static buffers it can fill in, soguy2004-04-281-4/+8
| | | | that it can be called up to 4 times in a given "printf()".
* pave the way for eliminating print_unknown_data() and subsequent hex_print() ↵hannes2003-12-291-21/+3
| | | | replacement
* 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".
* fix display of correct offset for hexdumpshannes2003-10-021-2/+2
|
* As per a comment by Alex Medvedev <alexm@pycckue.org>, start the searchguy2003-07-301-9/+9
| | | | | | | 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.
* Fix fencepost error in fn_printn() which would return a truncationfenner2003-04-211-9/+4
| | | | | indication if the last byte of the counted string was the last byte captured.
* From Gisle Vanem: use ISO 8601 date/time format in "-tttt" mode.guy2003-03-041-7/+9
|
* From Gisle Vanem <giva@bgnett.no>:guy2003-02-081-13/+21
| | | | | | | | | | | | | | | 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.
* add mask2plen function to util.channes2002-12-221-1/+32
|
* new function bittok2str()hannes2002-11-071-1/+46
| | | | | | | | | | | | | | 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;
* don't attempt to hexdump if length == 0hannes2002-10-111-1/+4
|
* Get rid of some unnecessary includes (<time.h>, <netdb.h>, and <ctype.h>guy2002-08-061-4/+1
| | | | | are included by <tcpdump-stdinc.h>, so we don't have to include them explicitly; <errno.h> isn't needed by print routines).
* From Motonori Shindo <mshindo@mshindo.net>: squelch warnings from someguy2002-08-021-2/+2
| | | | compilers.
* Added support for Win32, based on WinPcap.risso2002-08-011-6/+12
|
* yet another hexdump routine;hannes2002-07-181-1/+29
| | | | print_unknown_data{} supports identation;
* Clean up "safeputchar()" a bit.guy2002-07-161-3/+3
|
* In "safeputchar()", use the result of extracting an unsigned characterguy2002-07-161-4/+4
| | | | | | | 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()").
* whitespace cleanupitojun2002-06-111-2/+2
|
* Introduce tok2strary(), similar to tok2str() except it takes anfenner2001-10-081-1/+20
| | | | array of strings instead of a list of value/string pairs.
* Handle negative timestamps in relts_print().fenner2001-09-171-2/+6
|
* Add some const qualifiersfenner2001-09-101-6/+9
| | | | Check for malloc failure in read_infile()
* remove gnuc.h and __deadassar2000-07-111-2/+2
|
* remove non-STDC codeassar2000-07-011-28/+1
|
* fix safeputc, the if statment was completely reverseditojun2000-06-211-3/+3
|
* (ts_print): fix printing in `-tttt' style. From "Gisle Vanem"assar2000-06-101-3/+3
| | | | <gvanem@eunet.no>
* avoid possible infinite loop in relts_print().itojun2000-06-031-56/+77
| | | | | move safeputchar() and safeputs() into util.c for better code sharing. some style.
* (ts_print): add new styles of timestamps.assar2000-06-011-17/+32
| | | | From Francisco Matias Cuenca-Acuna <mcuenca@george.rutgers.edu>
* s/sprintf/snprintf/.itojun2000-01-171-2/+2
| | | | | there seem to be couple of unsafe use of strcat and strcpy - we should bring in strl{cat,cpy}.