Commit Graph

52 Commits

Author SHA1 Message Date
Guy Harris 88e9d1c1e5 Do not call wtap_file_read_unknown_bytes() or
wtap_file_read_expected_bytes() from an open routine - open routines are
supposed to return -1 on error, 0 if the file doesn't appear to be a
file of the specified type, or 1 if the file does appear to be a file of
the specified type, but those macros will cause the caller to return
FALSE on errors (so that, even if there's an I/O error, it reports "the
file isn't a file of the specified type" rather than "we got an error
trying to read the file").

When doing reads in an open routine before we've concluded that the file
is probably of the right type, return 0, rather than -1, if we get
WTAP_ERR_SHORT_READ - if we don't have enough data to check whether a
file is of a given type, we should keep trying other types, not give up.
For reads done *after* we've concluded the file is probably of the right
type, if a read doesn't return the number of bytes we asked for, but
returns an error of 0, return WTAP_ERR_SHORT_READ - the file is
apparently cut short.

For NetMon and NetXRay/Windows Sniffer files, use a #define for the
magic number size, and use that for both magic numbers.

svn path=/trunk/; revision=46803
2012-12-27 12:19:25 +00:00
Guy Harris 6d678c20d6 OK, does *this* convince the compiler that the loop isn't ever going to
be infinite?

svn path=/trunk/; revision=46757
2012-12-26 06:56:17 +00:00
Guy Harris 44d7a093e8 Widen an argument to match its (theoretical) widest possible width. See
if that squelches a loop-optimization warning.

svn path=/trunk/; revision=46752
2012-12-26 06:14:44 +00:00
Guy Harris 70d39d2dcc Handle the fractions-of-a-second part of the time stamp correctly.
Extract it as a string, not a number, and determine the resolution based
on the length of the string, i.e. on the number of digits presented. 
(If you base it on the numerical value, leading zeroes will not be taken
into account, but they aren't any different from other digits when
determining the resolution.)  The resolution is 1/10^ndigits seconds, so
we have to multiply it by 10^(9-ndigits) to convert the number to
nanoseconds.

svn path=/trunk/; revision=45627
2012-10-18 05:20:09 +00:00
Guy Harris 25b493fbcb Redo the processing of lines in iSeries text packet dumps.
Process several different flavors of header lines the same: "IP Header",
"IPv6 Header", "ARP Header", "TCP Header", "UDP Header", "ICMP Header",
"ICMPv6 Hdr", "Option Hdr" - the hex data for all of them should be
included in the packet data.  Process continuation lines if those
headers wrap over more than one line.

Do not assume, or require, that *any* of those be present; there is no
guarantee that "IP Header" or "IPv6 Header" will be present (there's at
least one IBM page showing a packet with "ARP Header" in a trace), and
there is no guarantee that "TCP Header" will be present (there are
traces with "UDP Header" and "ICMPv6 Hdr").

Do not impose limits, other than the overall line limit, on the amount
of hex data in header or data lines; there is no guarantee that, for
example, a TCP header is 20 bytes long (if there are TCP options, it
*will* have more than 20 bytes).

Make sure we have an even number of hex digits.

Set "caplen" to the actual number of bytes we've read, even if that's
less than the purported packet length.

svn path=/trunk/; revision=45626
2012-10-18 04:52:33 +00:00
Jakub Zawadzki 78631020b8 Add wtap_pseudo_header union to wtap_pkthdr structure.
Use pkthdr instead of pseudo_header as argument for dissecting.

svn path=/trunk/; revision=45601
2012-10-16 21:50:57 +00:00
Jeff Morriss 3551a86c36 We always HAVE_CONFIG_H so don't bother checking whether we have it or not.
svn path=/trunk/; revision=45015
2012-09-20 01:29:52 +00:00
Jakub Zawadzki bf81b42e1e Update Free Software Foundation address.
(COPYING will be updated in next commit)

svn path=/trunk/; revision=43536
2012-06-28 22:56:06 +00:00
Guy Harris 33bb54a945 file_seek() used to be a wrapper around fseek() or gzseek(), both of
which could use lseek() and were thus expensive due to system call
overhead.  To avoid making a system call for every packet on a
sequential read, we maintained a data_offset field in the wtap structure
for sequential reads.

It's now a routine that just returns information from the FILE_T data
structure, so it's cheap.  Use it, rather than maintaining the data_offset
field.

Readers for some file formats need to maintain file offset themselves;
have them do so in their private data structures.

svn path=/trunk/; revision=42423
2012-05-04 16:56:18 +00:00
Bill Meier 9c8aba73d7 Fix a buildbot compile warning.
svn path=/trunk/; revision=42197
2012-04-22 19:14:19 +00:00
Bill Meier ee89329b9a Various minor cleanup:
- fix a few small memory leaks;
 - fix some indentation to match style used (gnu);
 - remove trailing whitespace;
 - ...

svn path=/trunk/; revision=42196
2012-04-22 18:44:10 +00:00
Guy Harris bb36edf54e Fix more indentation.
svn path=/trunk/; revision=42147
2012-04-20 01:44:49 +00:00
Guy Harris 5a1b276845 Use consistent 2-space indentation, and don't use tabs.
svn path=/trunk/; revision=42146
2012-04-20 01:43:12 +00:00
Guy Harris b6ff142f60 Add a presence flag field to the packet information structure filled in
by Wiretap, to indicate whether certain fields in that structure
actually have data in them.

Use the "time stamp present" flag to omit showing time stamp information
for packets (and "packets") that don't have time stamps; don't bother
working very hard to "fake" a time stamp for data files.

Use the "interface ID present" flag to omit the interface ID for packets
that don't have an interface ID.

We don't use the "captured length, separate from packet length, present"
flag to omit the captured length; that flag might be present but equal
to the packet length, and if you want to know if a packet was cut short
by a snapshot length, comparing the values would be the way to do that.

More work is needed to have wiretap/pcapng.c properly report the flags,
e.g. reporting no time stamp being present for a Simple Packet Block.

svn path=/trunk/; revision=41185
2012-02-25 23:24:34 +00:00
Alexis La Goutte 64b511f5e7 Fix some Dead Store (Dead assignement/Dead increment) Warning found by Clang
svn path=/trunk/; revision=40909
2012-02-06 22:20:29 +00:00
Alexis La Goutte 7424e362c6 Fix some Dead Store (Dead assignement/Dead increment) Warning found by Clang
svn path=/trunk/; revision=40907
2012-02-06 22:18:45 +00:00
Guy Harris d94bd07f99 Rename WTAP_ERR_BAD_RECORD to WTAP_ERR_BAD_FILE; it really reports any
form of corruption/bogosity in a file, including in a file header as
well as in records in the file.  Change the error message
wtap_strerror() returns for it to reflect that.

Use it for some file header problems for which it wasn't already being
used - WTAP_ERR_UNSUPPORTED shouldn't be used for that, it should only
be used for files that we have no reason to believe are invalid but that
have a version number we don't know about or some other
non-link-layer-encapsulation-type value we don't know about.

svn path=/trunk/; revision=40175
2011-12-13 09:53:50 +00:00
Bill Meier 2841028cf2 Fix gcc 4.6 "set but not used [-Wunused-but-set-variable]" warning.
svn path=/trunk/; revision=37604
2011-06-07 23:05:53 +00:00
Anders Broman 780978a58d Remove unused varable:
iseries.c:305: warning: unused variable 'tcpformat'

svn path=/trunk/; revision=37467
2011-05-29 19:50:55 +00:00
Anders Broman 3e1baff3b5 From Martin Warnes:
This is significant update to the existing iseries wiretap module. It adds
support for IPv6 (formatted & unformatted comms traces), in addition I've
tidied up the sscanf routines to better handle traces files with offset lines.

https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5957

svn path=/trunk/; revision=37466
2011-05-29 19:36:21 +00:00
Guy Harris 6cbf6ce16c Add a new WTAP_ERR_DECOMPRESS error, and use that for errors discovered
by the gunzipping code.  Have it also supply a err_info string, and
report it.  Have file_error() supply an err_info string.

Put "the file" - or, for WTAP_ERR_DECOMPRESS, "the compressed file", to
suggest a decompression error - into the rawshark and tshark errors,
along the lines of what other programs print.

Fix a case in the Netscaler code where we weren't fetching the error
code on a read failure.

svn path=/trunk/; revision=36748
2011-04-21 09:41:52 +00:00
Guy Harris f5f74bed3d Use ws_open(), not open(), so we handle UTF-8 pathnames on Windows.
Update or remove some additional "we don't have ferror() in zlib"
comments to reflect the current reality.

svn path=/trunk/; revision=36568
2011-04-11 22:19:01 +00:00
Gerald Combs 56bc7f5e47 Be more picky about our sscanf integer field widths. Hopefully this will
help squelch Coverity CIDs 701-709.

svn path=/trunk/; revision=36511
2011-04-07 23:16:05 +00:00
Guy Harris 4c93827e34 From Jakub Zawadzki:
file_read(buf, bsize, count, file) macro is compilant with fread
function and takes elements count+ size of each element, however to make
it compilant with gzread() it always returns number of bytes.

In wiretap file_read() this is not really used, file_read is called
either with bsize set to 1 or count to 1.

Attached patch remove bsize argument from macro.

svn path=/trunk/; revision=36491
2011-04-06 06:51:19 +00:00
Gerald Combs 8af7080001 Fix errors found by the Visual C++ analyzer.
svn path=/trunk/; revision=35954
2011-02-16 00:44:12 +00:00
Guy Harris 17392a865a Move the definitions of all the private data structures out of
wtap-int.h, and change the unions of pointers to those private data
structures into just void *'s.

Have the generic wtap close routine free up the private data, rather
than the type-specific close routine, just as the wtap_dumper close
routine does for its private data.  Get rid of close routines that don't
do anything any more.

svn path=/trunk/; revision=32015
2010-02-26 07:59:54 +00:00
Guy Harris 756bf60020 Move the definition of the private data structure from wtap-int.h to the
iSeries capture processor.  Parse the start date into year/month/day at
the time we see it, rather than for every packet; that means we don't
need to allocate a buffer to hold the date as a string (a buffer which
we weren't ever freeing).

svn path=/trunk/; revision=31981
2010-02-24 08:39:19 +00:00
Stig Bjørlykke de88ead3bc Fixed data type for asciibuf.
svn path=/trunk/; revision=30608
2009-10-18 21:29:17 +00:00
Gerald Combs cc739fecb0 P64 fixes.
svn path=/trunk/; revision=27683
2009-03-09 21:18:55 +00:00
Stig Bjørlykke 80b62e6728 Fixed a datatype to avoid a warning.
svn path=/trunk/; revision=26479
2008-10-16 13:36:37 +00:00
Guy Harris 9d1b5335ac g_ascii_strdown() and g_ascii_strup(), unlike g_strdown() and g_strup(),
do *not* modify the string handed to them - they g_mallocate a new
string and return it.

Create routines that *do* ASCII-only case mapping in place, and use them
instead.

Clean up indentation.

svn path=/trunk/; revision=26131
2008-09-03 19:14:52 +00:00
Guy Harris 9ab8f5a907 Have iseries_parse_hex_string() take a "const char *" as its first
argument, as

	1) it doesn't modify the string that argument points to

and

	2) it's a buffer of "char".

Use g_ascii_xdigit_value() and put the values of the two bytes together
ourselves; strtoul() is a bit of overkill for two-hex-digit pairs. 
While we're at it, check for invalid hex digits, and for bytes where
only one hex digit is present.

svn path=/trunk/; revision=25392
2008-05-29 23:30:51 +00:00
Jeff Morriss 3251c05742 Always set pkt_encap, not just when we have the start date. This bug, around
since rev 17756, meant that attempts to read iSeries files would fail in the
"Make sure it [pkt_encap] is not WTAP_ENCAP_PER_PACKET" assertion in
wtap_read().

Also set file_encap to WTAP_ENCAP_ETHERNET (instead of WTAP_ENCAP_PER_PACKET)
since it seems that all the packets in iSeries files are Ethernet (or at least
this module currently only supports Ethernet).

svn path=/trunk/; revision=25388
2008-05-28 15:01:16 +00:00
Martin Mathieson 7e40100fb3 From Anders: Checkapi enabled for wiretap and more functions converted.
svn path=/trunk/; revision=25257
2008-05-08 09:37:11 +00:00
Anders Broman 6d91aae2e1 strncpy -> g_strlcpy
svn path=/trunk/; revision=25254
2008-05-08 05:16:33 +00:00
Bill Meier bad9f18d33 Fix (Sun) compiler warnings as reported by David Kirkby: Part 1
svn path=/trunk/; revision=24295
2008-02-09 23:35:28 +00:00
Stig Bjørlykke d5d2e97b47 Fixed some more malloc -> g_malloc, free -> g_free, strdup -> g_strdup.
svn path=/trunk/; revision=24180
2008-01-24 19:30:43 +00:00
Stephen Fisher 721e353447 Fix bug #1926: buffer overflow when parsing iseries files
svn path=/trunk/; revision=23232
2007-10-19 22:40:42 +00:00
Sake Blok 0e4ae39920 From Martin Warnes:
Attached is a small patch that correct an issue with reading certain IBM
iSeries Comms traces.

Traces where data has been dropped for whatever reason now have the
packet number suffixed with an asterix "*", this causes the current
iSeries wiretap routine to report a "bad" header. The attached patch
simply scans the packet number field and removes any "* characters prior
to scanning, the fact that data may be missing is more than adequately
reported later by current wireshark packet processing.

Regards .. Martin


svn path=/trunk/; revision=23000
2007-09-27 18:36:17 +00:00
Guy Harris 3b120c2491 Match "%4x" with an unsigned value in sscanf.
Check for a case where, conceivably, the on-the-wire packet length (from
the IP header) could be shorter than the captured data length (due to
Ethernet padding), and handle it by making sure the on-the-wire length
is always >= the captured data length.

svn path=/trunk/; revision=21490
2007-04-21 22:59:52 +00:00
Jaap Keuter c150904c6a Fix for bug 1526. Compare to uppercased strings.
svn path=/trunk/; revision=21361
2007-04-10 05:38:57 +00:00
Stephen Fisher 8fd3ee0560 Remove almost all of the casts I committed recently and in place of
them, add -Wno-pointer-sign to CFLAGS when gcc will accept it.


svn path=/trunk/; revision=21253
2007-03-28 21:55:11 +00:00
Stephen Fisher 2896811274 Fix about 150 warnings new to gcc 4.0 in the error on warning directories.
Comment out -Werror in plugins/asn1/ until warnings can be fixed.


svn path=/trunk/; revision=21158
2007-03-23 22:49:23 +00:00
Gerald Combs b7d30175c0 Fix a couple of off-by-one overflows reported in bug 1415. Update the
release notes accordingly.

svn path=/trunk/; revision=20990
2007-03-07 01:17:24 +00:00
Ulf Lamping 59d6c8ea33 change all file offsets from long to gint64 so we can - theoretically - handle files > 2GB correct.
Please distclean Win32 builds!

svn path=/trunk/; revision=19814
2006-11-05 22:46:44 +00:00
Anders Broman ca8bc2b83a From Martin Warnes:
The patch addresses issues with higher precision packet
timings on top end iSeries hardware and should enable the iseries wiretap to handle timings in both micro and nano seconds.

svn path=/trunk/; revision=19428
2006-10-04 17:36:40 +00:00
Jaap Keuter 9daa63d451 The header will be there, just make sure the date is put in.
Coverity bug 148

svn path=/trunk/; revision=17756
2006-03-29 16:06:57 +00:00
Anders Broman 2502e30bc1 From Martin Warnes:
> I've attached a fix that cleans up this code, actually since my last 
> update of this module the particular call in question was fairly 
> redundant so I just went ahead and removed it and updated the constant 
> that specifies the maximum possible line length instead.
>
> Thanks for bring this to my attention.

svn path=/trunk/; revision=17737
2006-03-27 18:24:26 +00:00
Gerald Combs 480818a431 Fix a possible NULL dereference (bug 827 / CID 145). Add an SVN
ID.  Fix up whitespace.

svn path=/trunk/; revision=17732
2006-03-27 16:09:47 +00:00
Anders Broman 70a045d772 From Mertin Wrnes:
Following my last submitted patch I did some further investigation on the different types of iSeries  Comms Traces, although the field formats are constant, things such as page throws and line spacing vary depending on the tool used to pull the trace form the iSeries spool.

This patch should better handle the different formats and more importantly exit in a graceful manner if an unknown format is encountered.


svn path=/trunk/; revision=17699
2006-03-22 17:37:04 +00:00