summaryrefslogtreecommitdiff
path: root/util.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix display of timestamps with -ttt and -ttttt optionsFrancois-Xavier Le Bail2015-07-021-22/+34
| | | | | | | | - Fix display of some nanoseconds timestamps For example, bad print 00:-16:-2.000851566 is now 00:00:00.037851566 - Fix display of timestamp of a packet when it is lower than previous one For example, bad print 00:00:-1.000999790 is now -00:00:00.000000210
* Fix display of nanoseconds timestamps with -tt option (GH issue 466)Francois-Xavier Le Bail2015-06-301-3/+39
| | | | Add 'ts_unix_format' function.
* Fix a non-reentrant code in a functionFrancois-Xavier Le Bail2015-06-301-8/+14
| | | | | | | | Delete the 'static char buf' array in ts_format(). buf is now a parameter of ts_format(). Moreover: Decrease a too long string. Fix a space in a comment.
* Use unsigned values in tok2str and bittok2str routines.Guy Harris2015-04-181-10/+10
| | | | | | | | | | This prevents the compiler issue mentioned in GitHub issue #451, and also cleans up some other signed vs. unsigned stuff. While we're at it, clean up bittok2str_internal() (just pass it the separator string, not a Boolean value that's tested to choose the separator string), and print unknown arguments to the bittok2str routines in hex, not decimal.
* If we don't find a CR-LF or LF, print up to the end of the packet.Guy Harris2014-10-191-0/+1
|
* Add a routine to print "text protocols", and add FTP/HTTP/SMTP/RTSP support.Guy Harris2014-10-191-0/+258
| | | | | | | | | | "Text protocols" are protocols that have the general feel of FTP, with command lines with a command name and space-separated arguments and response lines beginning with a 3-digit reply code. They can also include HTTP-style headers and an entity body. We add support for the FTP control channel, HTTP, SMTP, and RTSP. We also change the SIP printer to use it.
* ts_format only uses ndo if HAVE_PCAP_SET_TSTAMP_PRECISION is defined.Guy Harris2014-10-181-1/+5
|
* Allow builds if libpcap doesn't have pcap_set_tstamp_precision().Guy Harris2014-06-251-2/+20
| | | | | | Check for pcap_set_tstamp_precision() in the configure script and, if it's not there, don't include the code that allows time stamp precisions to be set.
* Merge pull request #377 from msekletar/masterGuy Harris2014-06-251-7/+10
|\ | | | | timestamps: make possible to request high precision timestamps
| * Introduce --time-stamp-precisionMichal Sekletar2014-05-141-7/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A while ago we introduced new API in libpcap which made possible to request time stamps with higher precision (nanoseconds). This commit aims to move things forward and implement missing bits. It introduces new long option --time-stamp-precision. Note that there is no equivalent short option. When used for a live capture tcpdump will ask the kernel for time stamp with desired precision and tcpdump will print fraction part of the time stamp using respective format. We currently support only microsecond and nanosecond precision. In the future we might support even more granular time stamp precision, but we should be fine to support only microseconds and nanoseconds for now. libpcap doesn't provide anything else at the moment anyway. When used in combination with -r/-w options then we obtain time stamps appropriately scaled up or down from libpcap. Also note that distinct magic number is used for savefiles containing nanosecond time stamps.
* | fix bittok2str_internal() w/o separator (GH #391)Denis Ovsienko2014-06-061-17/+6
|/ | | | | | | | | | | | | Simplify separator string handling in bittok2str_internal(): use empty value for the first snprintf() call and set new value after each use. This makes the terminating null char management unnecessary, especially that it missed the case where there was no separator and no match (it would return the previous content of the static buffer unchanged). This change may affect the output of tcpdump in that before it could print either "[]" or "[none]" or a string like "[S.]" for TCP flags value 0. Now it prints "[none]" as that is exactly the value passed to bittok2str_nosep() in tcp_print().
* Include <errno.h> on both Windows and UN*X.Guy Harris2014-05-041-1/+0
| | | | | | | We need <errno.h> on UN*X in some files that include tcpdump-stdinc.h, such as missing/inet_pton.c. Remove includes of <errno.h> from files that include tcpdump-stdinc.h.
* u_intN_t is dead, long live uintN_t.Guy Harris2014-04-231-2/+2
| | | | | | | | | 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-17/+16
|
* Merge remote-tracking branch 'bpf/master'Denis Ovsienko2014-04-061-0/+1
|\
| * 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 a couple typosDenis Ovsienko2014-04-061-1/+1
|/
* NDOize some generic codeDenis Ovsienko2014-04-031-19/+19
|
* NDOize safeputs() and safeputchar()Denis Ovsienko2014-04-011-12/+8
|
* don't include pcap.h needlesslyDenis Ovsienko2014-02-281-1/+0
| | | | | | | | | | Both interface.h and netdissect.h include <pcap.h>, thus most files should not include it regardless if these need it or not. The only exceptions so far remain: * addrtoname.c * missing/datalinks.c * missing/dlnames.c * tcpdump.c
* base struct tok on unsigned rather than signed intDenis Ovsienko2014-02-261-1/+1
| | | | | | | | | This resolves a few Solaris-specific warnings emitted by /opt/solarisstudio12.3/bin/cc like below: warning: initializer does not fit or is out of range: 0xffffffff (also happened for 0x80000000)
* Do our own isascii(), isprint(), isgraph(), and toascii().Guy Harris2014-02-021-10/+10
| | | | | | | | | 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.
* Only do the unaligned_mem{cpy,cmp} hack if necessary.Guy Harris2014-01-171-2/+3
| | | | If the processor does unaligned accesses, it's not necessary.
* memcmp() doesn't modify either of its arguments.Guy Harris2014-01-151-1/+1
|
* Revert print-tcp memcpy() changes, and use unaligned_memcpy() instead.Guy Harris2014-01-151-0/+8
| | | | | | | That should prevent optimizing the memcpy into code that assumes alignment. Add unaligned_memcmp(), and use it, as well.
* Move safememcpy() to util.c so it doesn't get inlined.Guy Harris2014-01-151-0/+11
| | | | | | | | | | | It appears that some C compilers will inline safememcpy() *and* will, as a result, optimize to assume alignment it if it's passed a putatively-aligned pointer. As the pointers in question are not guaranteed to be aligned, that can cause crashes on, for example, SPARC. Also, rename the function to unaligned_memcpy(), to clarify what's "safe" about it, and change some direct memcpy() calls to use it as well.
* 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.
* ndo-ize print-ascii: hex_print_with_offset()Michael Richardson2014-01-011-6/+6
|
* whitespace changesMichael Richardson2014-01-011-2/+2
|
* 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.