Commit Graph

118 Commits

Author SHA1 Message Date
Guy Harris 54b733ce9a Make the time stamp resolution per-packet.
Pcap-ng files don't have a per-file time stamp resolution, they have a
per-interface time stamp resolution.  Add new time stamp resolution
types of "unknown" and "per-packet", add the time stamp resolution to
struct wtap_pkthdr, have the libwiretap core initialize it to the
per-file time stamp resolution, and have pcap-ng do the same thing with
the resolution that it does with the packet encapsulation.

Get rid of the TS_PREC_AUTO_XXX values; just have TS_PREC_AUTO, which
means "use the packet's resolution to determine how many significant
digits to display".  Rename all the WTAP_FILE_TSPREC_XXX values to
WTAP_TSPREC_XXX, as they're also used for per-packet values.

Change-Id: If9fd8f799b19836a5104aaa0870a951498886c69
Reviewed-on: https://code.wireshark.org/review/4349
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-09-28 18:38:18 +00:00
Guy Harris 0734ac385f Rename buffer_ routines to ws_buffer_ to avoid name collisions.
In particular, epan/wslua/lrexlib.c has its own buffer_ routines,
causing some linker warnings on some platforms, as reported in bug
10332.

(Not to be backported to 1.12, as that would change the API and ABI of
libwsutil and libwiretap.  We should also make the buffer_ routines in
epan/wslua/lrexlib.c static, which should also address this problem, but
the name change avoids other potential namespace collisions.)

Change-Id: I1d42c7d1778c7e4c019deb2608d476c52001ce28
Reviewed-on: https://code.wireshark.org/review/3351
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-08-02 11:01:29 +00:00
Guy Harris d4dab16a3f Only one buffer.c, please.
Otherwise, if you link with both libwiretap and libfiletap, it's
anybody's guess which one you get.  That means you're wasting memory
with two copies of its routines if they're identical, and means
surprising behavior if they're not (which showed up when I was debugging
a double-free crash - fixing libwiretap's buffer_free() didn't fix the
problem, because Wireshark happened to be calling libfiletap' unfixed
buffer_free()).

There's nothing *tap-specific about Buffers, anyway, so it really
belongs in wsutil.

Change-Id: I91537e46917e91277981f8f3365a2c0873152870
Reviewed-on: https://code.wireshark.org/review/3066
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-07-15 23:43:32 +00:00
Guy Harris b5d4128bee Avoid sign-extending bytes before handing them to <ctype.h> macros.
Pointed out by the Visual Studio code analyzer.

Change-Id: Idd429b4d0fb3db11ce171c3a5b38bdc55cc53c15
Reviewed-on: https://code.wireshark.org/review/2988
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-07-11 00:28:36 +00:00
Peter Wu 16f8ba1bed catapult,irda: Fix ASAN crashes due to buffer underrun
The catapult dissector tripped on this random file I had. A quick look
at other dissectors which use a construct like "-1] *= '*\\[rn]" showed
packet-irda too, so fix that as well.

Change-Id: I4b5fadcacd0b09d0fb29bdefc3dd1f28aef9b593
Reviewed-on: https://code.wireshark.org/review/2802
Reviewed-by: Evan Huus <eapache@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-07-03 13:02:24 +00:00
Guy Harris 6db77b000f Allow wtap_read() and wtap_seek_read() to return records other than packets.
Add a "record type" field to "struct wtap_pkthdr"; currently, it can be
REC_TYPE_PACKET, for a record containing a packet, or
REC_TYPE_FILE_TYPE_SPECIFIC, for records containing file-type-specific
data.

Modify code that reads packets to be able to handle non-packet records,
even if that just means ignoring them.

Rename some routines to indicate that they handle more than just
packets.

We don't yet have any libwiretap code that supplies records other than
REC_TYPE_PACKET or that supporting writing records other than
REC_TYPE_PACKET, or any code to support plugins for handling
REC_TYPE_FILE_TYPE_SPECIFIC records; this is just the first step for bug
8590.

Change-Id: Idb40b78f17c2c3aea72031bcd252abf9bc11c813
Reviewed-on: https://code.wireshark.org/review/1773
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-05-24 18:31:25 +00:00
Guy Harris a344c9736e Revert "Allow wtap_read() and wtap_seek_read() to return non-packet records."
This reverts commit c0c480d08c.

A better way to do this is to have the record type be part of struct wtap_pkthdr; that keeps the metadata for the record together and requires fewer API changes.  That is in-progress.

Change-Id: Ic558f163a48e2c6d0df7f55e81a35a5e24b53bc6
Reviewed-on: https://code.wireshark.org/review/1741
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-05-23 10:50:10 +00:00
Guy Harris c0c480d08c Allow wtap_read() and wtap_seek_read() to return non-packet records.
This is the first step towards implementing the mechanisms requestd in
bug 8590; currently, we don't return any records other than packet
records from libwiretap, and just ignore non-packet records in the rest
of Wireshark, but this at least gets the ball rolling.

Change-Id: I34a45b54dd361f69fdad1a758d8ca4f42d67d574
Reviewed-on: https://code.wireshark.org/review/1736
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-05-23 03:02:32 +00:00
Guy Harris a1b1c8bed5 Revert "Refactor Wiretap"
This reverts commit 1abeb277f5.

This isn't building, and looks as if it requires significant work to fix.

Change-Id: I622b1bb243e353e874883a302ab419532b7601f2
Reviewed-on: https://code.wireshark.org/review/1568
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-05-09 05:21:01 +00:00
Guy Harris a651f3e5ed Revert "Try to fix the build boot by changing the signature of catapult_dct2000_dump() to the declared one."
This reverts commit f5a0d7e897.

There's a lot more work needed to fix this change; that's not the only broken file.  I'm going to be reverting the whole thing.

Change-Id: I8e9bb3902f7e398ccb71c66711869c3dd338271c
Reviewed-on: https://code.wireshark.org/review/1569
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-05-09 05:20:29 +00:00
AndersBroman f5a0d7e897 Try to fix the build boot by changing the signature of
catapult_dct2000_dump() to the declared one.

Change-Id: Ib9b38fb35ace1e858e8105a54a192c044899b69a
Reviewed-on: https://code.wireshark.org/review/1567
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-05-09 04:30:45 +00:00
Michael Mann 1abeb277f5 Refactor Wiretap
Start of refactoring Wiretap and breaking structures down into "generally useful fields for dissection" and "capture specific". Since this in intended as a "base" for Wiretap and Filetap, the "wft" prefix is used for "common" functionality.

The "architectural" changes can be found in cfile.h, wtap.h, wtap-int.h and (new file) wftap-int.h. Most of the other (painstaking) changes were really just the result of compiling those new architecture changes.

bug:9607
Change-Id: Ife858a61760d7a8a03be073546c0e7e582cab2ae
Reviewed-on: https://code.wireshark.org/review/1485
Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-05-09 03:04:39 +00:00
Evan Huus 72fc075e9a Fix potential invalid-reads in catapult files
As caught by CppCheck, the conditions checking that n is in bounds should
occur *before* the conditions using n as an index so that if n is out of bounds
we don't try and use it anyways.

Change-Id: I107c983153aa12203f8c88b14e1addd3807d6b6e
Reviewed-on: https://code.wireshark.org/review/1415
Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-04-28 21:02:54 +00:00
Alexis La Goutte 296591399f Remove all $Id$ from top of file
(Using sed : sed -i '/^ \* \$Id\$/,+1 d')

Fix manually some typo (in export_object_dicom.c and crc16-plain.c)

Change-Id: I4c1ae68d1c4afeace8cb195b53c715cf9e1227a8
Reviewed-on: https://code.wireshark.org/review/497
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-04 14:27:33 +00:00
Guy Harris 9d41c658fe No seek-read routines use the length argument, so eliminate it from
wtap_seek_read().

svn path=/trunk/; revision=54570
2014-01-02 20:47:21 +00:00
Guy Harris a628e77311 Make it clearer that we're using the packet length read from the packet
header when reading packets randomly.

svn path=/trunk/; revision=54520
2013-12-31 23:33:49 +00:00
Jakub Zawadzki 38edae1c71 Replace wtap_nstime with nstime_t, remove wtap_nstime_to_sec.
After r50154 nstime_t is inside wsutil/ so wiretap don't need it's own copy. 

svn path=/trunk/; revision=53184
2013-11-09 10:38:02 +00:00
Bill Meier 5a0809c718 (Trivial) whitespace cleanup (mostly trailing whitespace).
svn path=/trunk/; revision=53172
2013-11-08 17:17:57 +00:00
Guy Harris 853da2eb9b The "file types" we have are actually combinations of types and
subtypes, e.g. Network Monitor version 1 and Network Monitor version 2
are separate "file types", even though they both come from Network
Monitor.

Rename various functions, #defines, and variables appropriately.

svn path=/trunk/; revision=53166
2013-11-08 09:53:01 +00:00
Guy Harris 847257a27d Make a never-changed table const.
svn path=/trunk/; revision=51002
2013-07-29 07:30:34 +00:00
Guy Harris 7f7733579c Don't cast away constness.
svn path=/trunk/; revision=50853
2013-07-23 23:25:04 +00:00
Guy Harris f13ba97806 Fix some pointer-signedness (well, signedness of what the pointer points
to) warnings.

svn path=/trunk/; revision=50104
2013-06-21 02:59:54 +00:00
Guy Harris 8c9edf1280 Have the seek-read routines take a Buffer rather than a guint8 pointer
as the "where to put the packet data" argument.

This lets more of the libwiretap code be common between the read and
seek-read code paths, and also allows for more flexibility in the "fill
in the data" path - we can expand the buffer as needed in both cases.

svn path=/trunk/; revision=49949
2013-06-16 00:20:00 +00:00
Guy Harris e6e5aa7fa4 wth->priv is always set in the open routine; no need to check that it's
non-null.

svn path=/trunk/; revision=49338
2013-05-16 18:30:24 +00:00
Guy Harris d9d8174f12 Pull all the post-processing for a parsed line into a common routine,
used in both the seek and seek_read routines.

(And, yes, the time stamp *is* supposed to be filled in by seek_read
routines.)

Pull some now-used-only-once routines into the new routine.

svn path=/trunk/; revision=49335
2013-05-16 18:27:27 +00:00
Anders Broman 85973068cc From beroset:
remove C++ incompatibilities

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

svn path=/trunk/; revision=48038
2013-03-03 17:14:19 +00:00
Martin Mathieson cf15301cbf Add support for reading/writing 'sprint' lines from test scripts.
svn path=/trunk/; revision=47686
2013-02-15 23:43:30 +00:00
Guy Harris 41e6e0f7e6 Always check the return value of read_new_line().
svn path=/trunk/; revision=46821
2012-12-28 09:10:18 +00:00
Guy Harris 5996b49c53 Squelch implicit 64-bit-to-32-bit conversion warnings.
svn path=/trunk/; revision=46650
2012-12-21 03:32:16 +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
Martin Mathieson 5809e2cfdf Some improvements after looking at profile of large reordercap run.
- speed up writing timestamp by avoiding g_snprintf()
- avoid call to strstr()
- don't use g_snprintf() for writing a liternal string
- avoid atio() for single-digit strings
- avoid some strcmp() calls where the release number at the end wasn't
  important

svn path=/trunk/; revision=45091
2012-09-24 10:29:19 +00:00
Martin Mathieson 32ed74e83d Shouldn't set the time in seek_read() after all. At least the pcap
support doesn't.

svn path=/trunk/; revision=45022
2012-09-20 10:21:04 +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
Martin Mathieson a59117bd87 Fix a couple of dumping issues seen while working on 'reorder'.
svn path=/trunk/; revision=45003
2012-09-19 09:24:11 +00:00
Martin Mathieson d2b7806d3f Avoid some calls to strlen() by remembering return value from
g_strlcpy().

svn path=/trunk/; revision=44608
2012-08-21 17:19:05 +00:00
Martin Mathieson d29d88e687 Ignore '\r' which will be found at the end of a line when a windows host
writes a log.

Also re-line-up args under function definitions.

svn path=/trunk/; revision=44444
2012-08-11 15:19:25 +00:00
Martin Mathieson 7901962209 Fix another uninitialised bug (the same bug in _read() I fixed
yesterday, also in _seek_read()).  Spotted by running 'valgrind-wireshark.sh -2'.

svn path=/trunk/; revision=44043
2012-07-26 13:59:20 +00:00
Martin Mathieson ca8d59f834 Initialize a byte to avoid more valgrind warnings.
svn path=/trunk/; revision=44019
2012-07-25 22:56:08 +00:00
Martin Mathieson 2f3a057bca Don't write one payload byte too many. Spotted by valgrind!
svn path=/trunk/; revision=44016
2012-07-25 21:53:39 +00:00
Martin Mathieson e7b8e93e27 memcpy() is quite a bit faster than g_strlcpy()!
svn path=/trunk/; revision=43675
2012-07-11 20:53:24 +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
Anders Broman 2bc42dc547 Try to squelch warnings
svn path=/trunk/; revision=42998
2012-06-02 14:13:14 +00:00
Gerald Combs bdb614e264 Fix a bunch of uninitialized variables found by Coverity Scan. CIDs
702403, 702404, 702405, 702406, 702407, 702408, 702409, 702410, 702411,
and 702412.

svn path=/trunk/; revision=42658
2012-05-16 16:29:12 +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
Martin Mathieson 722c68ec90 Fix a typo (just clearing my client out before I start doing diffs).
svn path=/trunk/; revision=42077
2012-04-15 01:38:12 +00:00
Martin Mathieson f0798dabd1 Set up table to help with ascii-hex -> hex conversion in advance to
avoid testing static for every conversion.

svn path=/trunk/; revision=41900
2012-04-03 01:49:27 +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
Bill Meier 727046dc35 Tighten up format string used for date/time parse;
Use 'static' in function definitions to match function declarations;
Do minor reformatting.

svn path=/trunk/; revision=40305
2011-12-27 18:54:32 +00:00
Martin Mathieson c5cfc416a1 Skip extra info if present (IP with LTE PDCP threading info).
svn path=/trunk/; revision=38983
2011-09-13 12:14:24 +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