Commit Graph

55 Commits

Author SHA1 Message Date
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 f2c1c108f5 AFAIKT there's no reason to #include <wsutil/crc32.c>; Include crc32.h like everyone else...
Also: Do some whitespace and indentation cleanup.

svn path=/trunk/; revision=41281
2012-03-02 00:31:30 +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
Guy Harris 197f7b9c02 TYPE_PAD records can have zero bytes of payload; don't treat them as
errors.

svn path=/trunk/; revision=41030
2012-02-14 22:31:33 +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
Guy Harris e4658ced93 Rename pletonll() to reflect what it actually does, namely convert a
host-byte-order 64-bit integral quantity to little-endian byte order.

svn path=/trunk/; revision=39900
2011-11-17 09:24:15 +00:00
Gerald Combs 666b58d408 From Huzaifa Sidhpurwala of Red Hat Security Response Team:
I found a heap-based buffer overflow, when parsing ERF file format.
The overflow seems to be controlled by the values read from the file, 
and hence seems exploitable to me.

svn path=/trunk/; revision=39508
2011-10-21 19:07:42 +00:00
Stig Bjørlykke 967b9086aa Removed newencap as it's unused.
svn path=/trunk/; revision=39419
2011-10-14 08:22:16 +00:00
Anders Broman 6a847b1f30 From Andrew Kampjes:
Allows the saving of packets with snapped length to ERF. Prevents the adding of
automatic CRC and rounds down to the nearest 8 bytes instead of up, adding
zeros.
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6409

svn path=/trunk/; revision=39247
2011-10-04 05:27:14 +00:00
Guy Harris d7af4e2037 Don't synthesize a CRC if the packet already has one.
svn path=/trunk/; revision=38905
2011-09-06 23:36:18 +00:00
Stig Bjørlykke 415533faaf Check return value from wtap_dump_file_write.
This fixes CID 1272.

svn path=/trunk/; revision=38876
2011-09-03 20:47:58 +00:00
Guy Harris e9fc1b72aa Use guint8 rather than guchar for raw octets and pointers to arrays of
same.

Add to wiretap/pcap-common.c a routine to fill in the pseudo-header for
ATM (by looking at the VPI, VCI, and packet data, and guessing) and
Ethernet (setting the FCS length appropriately).  Use it for both pcap
and pcap-ng files.

svn path=/trunk/; revision=38840
2011-09-01 09:43:10 +00:00
Guy Harris 30ec5387fa Not ideal, but OK for now - alignbytes, at that point, is < 8, so we
know it'll fit in a gint16.  (alignbytes really shouldn't need to be 64
bits, as if we have 2^63-1 bytes of alignment, We Have A Problem; fixing
that may involve calculating it differently earlier in that routine.)

svn path=/trunk/; revision=38828
2011-08-31 22:22:40 +00:00
Stig Bjørlykke ff32408b0a Try using gint64 for alignbytes.
svn path=/trunk/; revision=38827
2011-08-31 21:16:18 +00:00
Stig Bjørlykke 141a830b9f From Andrew Kampjes via bug 6260:
Added support for saving ERF files.

From me:
Use crc routines from libwsutil.

svn path=/trunk/; revision=38826
2011-08-31 20:50:15 +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 0aeaa16426 pntohll() takes a guint8 * as an argument; there's no need to cast to a
guint64 *, and it causes clang to complain.

svn path=/trunk/; revision=36738
2011-04-20 17:53:11 +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
Jaap Keuter d6c7ebee86 From Alexis La Goutte:
Replace all *_min()/*_max() by MIN() and MAX().

svn path=/trunk/; revision=34770
2010-11-04 06:37:58 +00:00
Anders Broman 37e8e4cde6 From Stephen Donnelly:
Wireshark tools do not detect and read some ERF files correctly
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5344

svn path=/trunk/; revision=34665
2010-10-28 14:33:55 +00:00
Anders Broman 441c3f63b2 From Stephen Donnelly:
InfiniBand Link Packet (flow control) dissector.
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=4656

svn path=/trunk/; revision=32425
2010-04-08 08:41:56 +00:00
Anders Broman 6dfde68911 From Stephen Donnelly:
Endace ATM and AAL2 enhancements.
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=4447

svn path=/trunk/; revision=31766
2010-02-02 04:56:39 +00:00
Stig Bjørlykke 50916b9174 Removed an unused variable.
svn path=/trunk/; revision=30891
2009-11-09 14:22:26 +00:00
Guy Harris 93ad454c6a Update a comment - a bad packet size could also be the result of a file
not actually being an ERF file.

Don't compute the packet size until you know that rlen is valid.

svn path=/trunk/; revision=29366
2009-08-10 18:22:05 +00:00
Gerald Combs c158c4ad69 Don't try to allocate more than WTAP_MAX_PACKET_SIZE. Fixes a crash
reported in bug 3849.

svn path=/trunk/; revision=29364
2009-08-10 16:12:55 +00:00
Guy Harris ad33ca6c2f Clean up some 64-bit issues.
svn path=/trunk/; revision=28117
2009-04-22 03:07:37 +00:00
Anders Broman 637761d295 From Francesco Fusco:
Endace ERFII (extension header) support.

svn path=/trunk/; revision=26287
2008-09-29 16:20:24 +00:00
Jaap Keuter 2665b689c1 From Stephen Donnelly:
ERF files can contain records of type TYPE_PAD. These records are not related
to captured packets, have a zero timestamp value and no associated packet data.
Normally TYPE_PAD records are stripped out during capture, but in rare cases
unstripped files may exist.
Previously wiretap/erf.c generated an 'unknown record encapsulation' error when
encountering TYPE_PAD records.
With this patch Wireshark skips over any TYPE_PAD records within ERF traces
files without reporting an error. TYPE_PAD records are not counted, displayed
or decoded.

svn path=/trunk/; revision=25733
2008-07-14 05:46:09 +00:00
Sake Blok 5c7b76b8a0 From Stephen Donnelly (bug 2359):
- add support for ERF files created with a snaplength
- tighten heuristics (rlen>=16, time_delta < 1 week)


svn path=/trunk/; revision=24929
2008-04-12 10:21:51 +00:00
Gerald Combs 68d23708bc From Stephen Donnelly via bug 2235:
This plugin implements a dissector for Infiniband. It is released 
under the GPL v2.

Rather than using say libpcap to capture raw (unframed) IP packets 
from near the top of an IPoIB stack, this plugin dissects link level
Infiniband frames.

Infiniband trace files can be read from Endace ERF format trace 
files, or from libpcap DLT_ERF files containing ERF TYPE_INFINIBAND 
records. There is currently no native DLT_INFINIBAND in libpcap.

Each record contains a hardware timestamp, capture metadata such as 
port Id, and a complete link level Infiniband frame starting from
the Local Route Header.

svn path=/trunk/; revision=24628
2008-03-14 17:47:53 +00:00
Stig Bjørlykke c6af1bfdd4 Removed some "statement not reached" warnings.
svn path=/trunk/; revision=24282
2008-02-07 12:14:40 +00:00
Guy Harris 3fb946dbec Get rid of extra blank lines at the end of the file.
svn path=/trunk/; revision=24054
2008-01-10 08:50:16 +00:00
Guy Harris 605e462b45 Use WTAP_ENCAP_ERF as the file encapsulation, as that's what we'd
otherwise use as the per-packet encapsulation.

The close routine does nothing; get rid of it - you don't *need* a close
routine (by default, the subtype_close pointer is null, which means that
nothing per-file-type is done when the file is closed).

Make the code to handle the length fields in the ERF header common,
rather than copying it to each group of record types.

svn path=/trunk/; revision=24053
2008-01-10 08:49:11 +00:00
Jeff Morriss f75249281d From Florent Drouin:
fix http://bugs.wireshark.org/bugzilla/show_bug.cgi?id=1727 (pppd format file
incorrectly detected as being an ERF file) by:

The file_seek() call has been replaced by a call to file_read(), so, when the
end of the file is reached and the current record is truncated, we have got an
error.
This solves the problem of bad file format detection.

Additionaly, the ERF heuristic has been improved.

svn path=/trunk/; revision=24051
2008-01-09 22:58:34 +00:00
Gerald Combs 3ce14803f9 Get the number of captured bytes from "rlen" instead of "wlen". This should
fix bug #1983.

svn path=/trunk/; revision=23500
2007-11-19 19:09:01 +00:00
Anders Broman 5cd9fcc943 From Florent Drouin:
Fix bug Some Toshiba format files with LAPD cannot be open
http://bugs.wireshark.org/bugzilla/show_bug.cgi?id=1711

svn path=/trunk/; revision=23379
2007-11-06 19:22:51 +00:00
Anders Broman e10e84c243 Strengthen BER and ERF heuristics to solve:
Fail to load I4B traces http://bugs.wireshark.org/bugzilla/show_bug.cgi?id=1972

svn path=/trunk/; revision=23367
2007-11-05 20:43:25 +00:00
Anders Broman b9f9b33e0e From Florent DROUIN:
This is a replacement of the existing decoding of ERF files (Extensible Record
Format from Endace). 
For the decoding of the ERF files, according to the "type of record" given in
the ERF header, several decoders can be used. Up to now, the decoder is
determined according to an environment variable, or with a kind of heuristic.
And, all the treatment is done during the file extraction.

The new architecture, will separate the ERF file decoding, and the ERF record
decoding. The ERF records will be decoded with a specific dissector. This
dissector can be configured with options, to replace the environment variable.

http://bugs.wireshark.org/bugzilla/show_bug.cgi?id=1839

svn path=/trunk/; revision=23092
2007-10-08 11:41:21 +00:00
Guy Harris 230c951306 From Stephen Donnelly of Endace:
The code for reading ERF files has not been significantly
	updated since 2004.  This patch brings it up to date with a
	number of changes.

	1) Increase number of decodable ERF types from 7 to 12. This
	   covers newer DAG card models and firmware updates.

	2) Fix timestamp conversion. Was calculating only microsecond
	   precision, now displaying with nanosecond resolution.  Hardware
	   precision is 7.5 to 30 ns depending on model.

	3) Allow the user to specify HDLC encapsulation as 'chdlc',
	   'ppp_serial', 'frelay' or 'mtp2'.  This is needed because the
	   ERF HDLC capture formats do not include information on what
	   protocol is used at the next level.  This is currently done via
	   an environment variable 'ERF_HDLC_ENCAP' and is analagous to the
	   existing 'ERF_ATM_ENCAP' variable.

	   If the user does not specify an HDLC encapsulation it tries to
	   guess, and falls back to MTP2 for backwards compatibility with
	   Florent's existing behaviour.

	   I know environment variables are ugly, suggestions are welcome.

	4) When reading HDLC captures as MTP2, use
	   WTAP_ENCAP_MTP2_WITH_PHDR rather than WTAP_ENCAP_MTP2.  This
	   allows us to put the 'Multi-Channel ERF' record 'channel
	   number' field into the MTP2 pseudo header > 'link_number'
	   field.  This is then displayed in Frame information, and can
	   be filtered on.  (Would be nice if it could be made a display
	   column?)

	Because the ERF record does not specify whether Annex A is used
	or not, we pass MTP2_ANNEX_A_USED_UNKNOWN and allow the existing
	user preference to decide.

Move the MTP2_ANNEX_A_ definitions into Wiretap, make the annex_a_used
field a guint8, and change MTP2_ANNEX_A_USED_UNKNOWN to 2 so it fits in
a guint8.  (This means that if you can save an ERF MTP2 file as a
libpcap file, the pseudo-header will have MTP2_ANNEX_A_USED_UNKNOWN in
it.)

svn path=/trunk/; revision=22067
2007-06-08 17:06:13 +00:00
Jeff Morriss 28767302a5 From Florent Drouin: support for MTP2 in ERF type 5 (Multi-Channel HDLC) files
svn path=/trunk/; revision=20838
2007-02-18 11:32:54 +00:00
Anders Broman 6c9ce8acf8 Froim Rene Pilz:
This patch consists also the last issues. Additionally it solves:
- For the SSCOP frames the AAL5 decoding was not performed due to an earlier patch. This caused that no SSCOP message was properly decoded.
- As the detection between a LANE frame and a SSCOP frame is rather hard a switch within the atm dissector is included which enforce SSCOP dissecting over a LANE frame. At the moment I do not see a better solution for that.

svn path=/trunk/; revision=20013
2006-11-29 06:44:07 +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
Ulf Lamping 76bbd4181b don't claim to be an erf file if it isn't (e.g. if the file_read call fails)
I don't know if this is the right way to fix it, but it seems at least better than before

svn path=/trunk/; revision=16971
2006-01-07 01:19:29 +00:00
Guy Harris 98473c77b6 Ethereal now requires 64-bit integer support, so get rid of the tests of
G_HAVE_GINT64.

Get rid of the floating-point stuff in the Etherpeek Classic file
reading code, just use 64-bit integers.  Fix up the calculation of the
nanoseconds portion of the time stamp.

svn path=/trunk/; revision=15544
2005-08-26 19:40:46 +00:00
Ulf Lamping 723c80ea90 timestamp display precision:
- automatic adjustment depending on file format
- manual adjustment through menu items

save the setting in the recent file

svn path=/trunk/; revision=15534
2005-08-25 21:29:54 +00:00
Ulf Lamping 6f43fbb2f0 EVERYTHING IN THE BUILDBOT IS GOING TO BE RED!!! Sorry!
I've done more than a day to change the timestamp resolution from microseconds to nanoseconds. As I really don't want to loose those changes, I'm going to check in the changes I've done so far. Hopefully someone else will give me a helping hand with the things left ...

What's done: I've changed the timestamp resolution from usec to nsec in almost any place in the sources. I've changed parts of the implementation in nstime.s/.h and a lot of places elsewhere.

As I don't understand the editcap source (well, I'm maybe just too tired right now), hopefully someone else might be able to fix this soon.

Doing all those changes, we get native nanosecond timestamp resolution in Ethereal. After fixing all the remaining issues, I'll take a look how to display this in a convenient way...

As I've also changed the wiretap timestamp resolution from usec to nsec we might want to change the wiretap version number...

svn path=/trunk/; revision=15520
2005-08-24 21:31:56 +00:00
Guy Harris e86a1c6a47 Give a URL for the ERF specification.
svn path=/trunk/; revision=13252
2005-02-03 02:26:20 +00:00
Guy Harris 8a8b883450 Set the svn:eol-style property on all text files to "native", so that
they have LF at the end of the line on UN*X and CR/LF on Windows;
hopefully this means that if a CR/LF version is checked in on Windows,
the CRs will be stripped so that they show up only when checked out on
Windows, not on UN*X.

svn path=/trunk/; revision=11400
2004-07-18 00:24:25 +00:00
Guy Harris d6cd61061e Have the Wiretap open, read, and seek-and-read routines return, in
addition to an error code, an error info string, for
WTAP_ERR_UNSUPPORTED, WTAP_ERR_UNSUPPORTED_ENCAP, and
WTAP_ERR_BAD_RECORD errors.  Replace the error messages logged with
"g_message()" for those errors with g_strdup()ed or g_strdup_printf()ed
strings returned as the error info string, and change the callers of
those routines to, for those errors, put the info string into the
printed message or alert box for the error.

Add messages for cases where those errors were returned without printing
an additional message.

Nobody uses the error code from "cf_read()" - "cf_read()" puts up the
alert box itself for failures; get rid of the error code, so it just
returns a success/failure indication.

Rename "file_read_error_message()" to "cf_read_error_message()", as it
handles read errors from Wiretap, and have it take an error info string
as an argument.  (That handles a lot of the work of putting the info
string into the error message.)

Make some variables in "ascend-grammar.y" static.

Check the return value of "erf_read_header()" in "erf_seek_read()".

Get rid of an unused #define in "i4btrace.c".

svn path=/trunk/; revision=9852
2004-01-25 21:55:17 +00:00
Ulf Lamping f16ac7a482 removed some MSVC warnings (level 3)
svn path=/trunk/; revision=9558
2004-01-05 17:33:28 +00:00