Commit Graph

83 Commits

Author SHA1 Message Date
Francois-Xavier Le Bail
99c91c3aec Rename 'tcpdump-stdinc.h' to 'netdissect-stdinc.h'
Get the full log via: git log --follow netdissect-stdinc.h
2015-09-10 08:50:40 +02:00
Brooks Davis
7f17c777dc Move functions in util.c that are used in the dissectors into a
util-print.c.  The remaining functions are used only in the frontend.
2015-04-15 18:52:33 +00:00
Denis Ovsienko
38700c7f24 dismiss NETDISSECT_REWORKED macro
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.
2015-03-22 10:06:15 +00:00
Guy Harris
43904b5d7c If we don't find a CR-LF or LF, print up to the end of the packet. 2014-10-19 13:48:04 -07:00
Guy Harris
b83e04bd09 Add a routine to print "text protocols", and add FTP/HTTP/SMTP/RTSP support.
"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.
2014-10-19 11:21:44 -07:00
Guy Harris
f91b36d2a0 ts_format only uses ndo if HAVE_PCAP_SET_TSTAMP_PRECISION is defined. 2014-10-18 22:41:55 -07:00
Guy Harris
a509c52d31 Allow builds if libpcap doesn't have pcap_set_tstamp_precision().
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.
2014-06-25 12:06:35 -07:00
Guy Harris
fc7b8aeb5e Merge pull request #377 from msekletar/master
timestamps: make possible to request high precision timestamps
2014-06-25 11:23:54 -07:00
Denis Ovsienko
bb9331dff5 fix bittok2str_internal() w/o separator (GH #391)
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().
2014-06-06 00:56:05 +04:00
Michal Sekletar
52b27d11fc Introduce --time-stamp-precision
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.
2014-05-14 14:18:40 +02:00
Guy Harris
27991a20a8 Include <errno.h> on both Windows and UN*X.
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.
2014-05-04 10:08:58 -07:00
Guy Harris
ed85e20e4d u_intN_t is dead, long live uintN_t.
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.
2014-04-23 00:20:40 -07:00
Denis Ovsienko
24598ce6b7 NDOize the rest of util.c 2014-04-14 10:53:46 +04:00
Denis Ovsienko
bbedebc666 Merge remote-tracking branch 'bpf/master' 2014-04-06 21:22:43 +04:00
Denis Ovsienko
d802a5d6cd fix a couple typos 2014-04-06 21:22:10 +04:00
Guy Harris
5cdf53e257 Define NETDISSECT_REWORKED in a bunch of files, and fix the issues it finds.
The only one it found was that routines in sigsecret.c needed to refer
to ndo->ndo_sigsecret, not just sigsecret.
2014-04-04 00:53:03 -07:00
Denis Ovsienko
8863fc0e5d NDOize some generic code 2014-04-03 17:43:33 +04:00
Denis Ovsienko
51670d1949 NDOize safeputs() and safeputchar() 2014-04-01 19:46:05 +04:00
Denis Ovsienko
88e479b75e don't include pcap.h needlessly
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
2014-02-28 18:11:09 +04:00
Denis Ovsienko
5840e0669e base struct tok on unsigned rather than signed int
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)
2014-02-26 14:49:56 +04:00
Guy Harris
3454732513 Do our own isascii(), isprint(), isgraph(), and toascii().
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.
2014-02-02 15:17:06 -08:00
Guy Harris
941a2c08f1 Only do the unaligned_mem{cpy,cmp} hack if necessary.
If the processor does unaligned accesses, it's not necessary.
2014-01-17 17:51:04 -08:00
Guy Harris
d45385cd18 memcmp() doesn't modify either of its arguments. 2014-01-15 23:03:53 -08:00
Guy Harris
34ec62cf99 Revert print-tcp memcpy() changes, and use unaligned_memcpy() instead.
That should prevent optimizing the memcpy into code that assumes
alignment.

Add unaligned_memcmp(), and use it, as well.
2014-01-15 19:08:07 -08:00
Guy Harris
00cef632b4 Move safememcpy() to util.c so it doesn't get inlined.
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.
2014-01-15 18:12:06 -08:00
Denis Ovsienko
fe3253b9b8 remove tcpdump's own CVS keywords
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.
2014-01-03 00:59:08 +04:00
Michael Richardson
ac910c086e ndo-ize print-ascii: hex_print_with_offset() 2014-01-01 21:31:18 -05:00
Michael Richardson
a97fb2f3ae whitespace changes 2014-01-01 21:31:18 -05:00
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