Commit Graph

208 Commits

Author SHA1 Message Date
Luis Ontanon 83296ec679 Another off by one error found by coverity (CID 83), using > instead of >= when comparing index against array size.
svn path=/trunk/; revision=17521
2006-03-08 10:20:09 +00:00
Jaap Keuter ca4000cbaf The attached patch to fix bug 663 allows Ethereal to read Windows
Sniffer V2 format capture files with captyp=5, timeunit=0.
The ticks_per_sec for this case apparently is 1e6.

Bill Meier

svn path=/trunk/; revision=17019
2006-01-12 15:02:25 +00:00
Guy Harris 90ce35c64e From Bill Meier:
define "timezone" as "gint16", as it can be positive (west of
	UTC) or negative (east of UTC);

	update comments to refer to the new names for structure members;

	say the precision of the time stamps is 1 nanosecond only if the
	ticks per second is > 10 million;

	fix the handling of files truncated exactly on a frame boundary.

svn path=/trunk/; revision=15739
2005-09-09 08:40:58 +00:00
Guy Harris 88c5c6c0d8 Get rid of the old file header definition.
Set the time stamp resolution based on whether the number of ticks per
second is > 1 million or not.

svn path=/trunk/; revision=15606
2005-08-29 01:18:27 +00:00
Guy Harris 394582573d From Bill Meier:
1. Use the new (good work!) 'nanosec' precision only for gig pods;
2. Rework 'struct netxray_hdr' to make it (somewhat) easier
   to maintain and revise:
   a. Declare known hdr fields such as 'captype' instead
      of using offsets in 'xxx placeholder' fields.
   d. Define 'unknown' hdr fields using placeholder names
      based upon hex-offset in the netxray header record.
      (This isn't perfect, but I hope it will make things 
       more manageable).
3. Update hdr field info (based upon examination of various
   capture files):
   a. Define a hdr field which appears to be 'time-zone' 
      [offset in hours from UTC] for the machine doing
      the capture.
      (Maybe this field can eventually be used for Ethereal
       to display the (local) time as it was at the time
       of the capture).
   b. Describe certain hdr fields as being "file offsets"
      (altho the exact use is still unclear).

Update some comments.

svn path=/trunk/; revision=15603
2005-08-28 23:11:53 +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 d5891d9623 Try yet another scheme for handling time stamps; realtick isn't always
correct.

svn path=/trunk/; revision=15404
2005-08-18 09:47:00 +00:00
Jörg Mayer adddb9819b Chris Lydick: Support for Sniffer 2.003 files.
Modified to match the current codebase.


svn path=/trunk/; revision=14832
2005-07-02 15:40:49 +00:00
Guy Harris f28456dd84 Note that the WAN_CAPTYPE value of 4 can correspond to Cisco HDLC
traffic as well as Frame Relay traffic, and give some information about
the cruft found in the xxc field of the header for one CHDLC and one FR
capture.

svn path=/trunk/; revision=14659
2005-06-16 08:10:13 +00:00
Guy Harris e4a550c538 Add some notes about stuff discovered by Ken Mann.
svn path=/trunk/; revision=13194
2005-01-29 10:48:16 +00:00
Guy Harris c3240e1ccb Note that the low-order bit of hdr->hdr_2_x.xxx[8] appears to be a "bad
FCS" bit for 802.11, just as it appears to be for Ethernet, and give
more details on the 4 bytes of junk at the end of the packet (i.e., that
we haven't yet seen an 802.11 capture where it's an FCS rather than just
junk).

svn path=/trunk/; revision=13028
2005-01-14 09:47:22 +00:00
Guy Harris bcedae3c1f Add some more comments about the FCS issue.
svn path=/trunk/; revision=12939
2005-01-03 10:27:20 +00:00
Guy Harris 0e1e5e9feb Give a bit more information on the "are there FCSes in the frame?"
issue.

svn path=/trunk/; revision=12938
2005-01-03 10:10:23 +00:00
Guy Harris fd56bd7689 Rename the CAPTYPE_ definitions as appropriate - many of them are
specific to particular types of captures, and the same value might
correspond to more than one CAPTYPE_ definition.

Add an additional CAPTYPE_ for some non-gigabit Ethereal capture seen by
Bill Meier, and fix the range check the time stamp units value as per
his mail.

svn path=/trunk/; revision=12937
2005-01-03 05:27:35 +00:00
Guy Harris b5070624a7 From James Fields and Kevin Johnson: fix the handling of time stamps in
a number of Windows Sniffer captures - apparently the time stamp units
are in a field in the file header.

Add a capture type value seen in at least one ATM capture.

Update some comments, and add some comments.

Get rid of some redundant setting of "timeunit".

svn path=/trunk/; revision=12936
2005-01-03 03:42:23 +00:00
Guy Harris 88982558b0 file_hdr.network is one byte long, so don't use htoles() on values it's
set to - that causes it to be set to zero.

svn path=/trunk/; revision=12328
2004-10-17 06:20:43 +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 ba72e955dc Have "wtap_read()" set "wth->phdr.pkt_encap" to "wth->file_encap",
rather than requiring individual capture file type handlers to do it
(unless they're doing per-packet encapsulation, in which case we check
to make sure they didn't *leave* it as WTAP_ENCAP_PER_PACKET).

svn path=/trunk/; revision=10290
2004-03-03 22:24:53 +00:00
Guy Harris 2528c053ce Supply a pseudo-header for all 802.11 packets; add an "fcs_len" field to
it, similar to the Ethernet pseudo-header's "fcs_len" field, and use it
in the 802.11 dissector.

svn path=/trunk/; revision=9884
2004-01-27 08:06:12 +00:00
Guy Harris bbf3806ba7 Don't muck with the Ethernet pseudo-header if we have an 802.11 capture.
svn path=/trunk/; revision=9857
2004-01-25 23:50:48 +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
Guy Harris c19c7677fb It appears that, for ISDN captures, the rules for whether there's 4
bytes of extra stuff at the end of the packet or not are the same as for
Ethernet and 802.11.

svn path=/trunk/; revision=9728
2004-01-19 02:23:18 +00:00
Ulf Lamping f16ac7a482 removed some MSVC warnings (level 3)
svn path=/trunk/; revision=9558
2004-01-05 17:33:28 +00:00
Guy Harris be2736adcf Have a pseudo-header for Ethernet packets, giving the size of the FCS -
0 means "there is no FCS in the packet data", 4 means "there is an FCS
in the packet data", -1 means "I don't know whether there's an FCS in
the packet data, guess based on the packet size".

Assume that Ethernet encapsulated inside other protocols has no FCS, by
having the "eth" dissector assume that (and not check for an Ethernet
pseudo-header).

Have "ethertype()" take an argument giving the FCS size; pass 0 when
appropriate.

Fix up Wiretap routines to set the pseudo-header.  This means we no
longer use the "generic" seek-and-read routine, so get rid of it.

svn path=/trunk/; revision=8574
2003-10-01 07:11:49 +00:00
Guy Harris f4a639c7c1 It appears that, at least for gigabit pod captures, there are time stamp
differences between versions 002.001 and 002.002.

svn path=/trunk/; revision=8563
2003-09-28 23:15:40 +00:00
Guy Harris 924136d7d7 A couple of captures have been seen with the first (low-order) byte of
the network type being 1 and the byte after it being 2; we assume, for
now, that the network type is 1 byte, and that if the byte after it is
0, the network type is an NDIS type - 1, and if it's 2, it's an NDIS type.

svn path=/trunk/; revision=7973
2003-07-07 21:08:49 +00:00
Guy Harris 7ccb4234a0 The units, in non-whizzo-gigabit-pod captures, for hdr.timeunit = 2
aren't 1/1193000.0 second; the code used to use 1/1193180.0 second, but
at least one capture appears to have units of somewhere around
1/3579540.0 second.

svn path=/trunk/; revision=7388
2003-03-31 21:11:49 +00:00
Guy Harris 86518e40f5 Ian Schorr discovered that, for gigabit pod captures, if hdr.timeunit is
2 the time stamps are in units of 1/31250000 seconds rather than
nanoseconds - and, by generating Windows Sniffer captures with various
hdr.timeunit values, that for all the non-zero values he tested, the
time stamps for non-gigabit pod captures are in units of 1/1193000
second.

Instead of having a TpS array, just test for the exception value (0 for
non-gigabit pod captures, 2 for gigabit pod captures).

svn path=/trunk/; revision=7380
2003-03-28 21:59:12 +00:00
Guy Harris cdfc37b6b6 Handle the direction bit in SDLC and PPP Sniffer files.
svn path=/trunk/; revision=7267
2003-03-04 02:04:00 +00:00
Guy Harris 15eea3fbb6 Handle packet direction information for SDLC Sniffer captures.
Add a bunch of capture types discovered by stuffing them into Windows
Sniffer captures and seeing what a Sniffer thought they were.  Add
support for writing at least some of them.

svn path=/trunk/; revision=7265
2003-03-03 23:29:59 +00:00
Guy Harris a37b287a50 A "hdr.xxb[20]" value of 2 in a version 2 capture appears to mean that
it's a gigabit Ethernet capture, possibly, with special hardware, and
that time stamps have 1000 times the resolution that they have in other
captures (perhaps due to the special hardware having a higher-resolution
clock?).

svn path=/trunk/; revision=7240
2003-03-01 09:42:44 +00:00
Guy Harris f88816e60f Add WTAP_ENCAP_FRELAY_WITH_PHDR for use with Frame Relay capture files
that have direction information.

Support writing WTAP_ENCAP_FRELAY_WITH_PHDR and WTAP_ENCAP_PPP_WITH_PHDR
captures out in libpcap format - we throw away the direction
information, but so it goes.

When reading/writing Windows Sniffer format, read and write the
direction flag.

svn path=/trunk/; revision=7052
2003-01-31 01:02:14 +00:00
Guy Harris 3f0e5dad19 Add support for writing Frame Relay files in NetXRay format 2.x.
svn path=/trunk/; revision=7048
2003-01-30 22:38:47 +00:00
Guy Harris 50e696df81 The Sniffer file formats include a file to identify raw cells; export
that flag in the ATM pseudo-header, and use it to determine whether a
frame is a raw cell or a reassembled frame, rather than using the AAL,
as you can have raw AAL5 cells in a capture.

svn path=/trunk/; revision=6889
2003-01-10 04:04:42 +00:00
Guy Harris a0c5cac89d It appears that a channel number of 0 means DTE->DCE, and a channel
number of 1 means DCE->DTE, in DOS Sniffer ATM captures.

svn path=/trunk/; revision=6881
2003-01-09 01:55:13 +00:00
Guy Harris f8a7dc5ad3 PRI captures appear to be the ISDN captures with padding.
The Windows Sniffer does *not* appear to know the difference between
802.3 and 802.3 multicast LANE traffic.

svn path=/trunk/; revision=6870
2003-01-07 07:16:24 +00:00
Guy Harris 2639f7f9dc Use some fields in the per-packet header for ATM to get the AAL type
and traffic type.

svn path=/trunk/; revision=6868
2003-01-07 06:09:08 +00:00
Guy Harris 553235d47d The direction flag for LAPB/X.25 and ISDN appears to be in the
bottommost bit of the 12th byte of "hdr.hdr_2_x.xxx".

svn path=/trunk/; revision=6866
2003-01-07 02:21:38 +00:00
Guy Harris 84bbc626d2 Update a comment.
svn path=/trunk/; revision=6865
2003-01-07 01:11:34 +00:00
Guy Harris a83be44e56 Properly turn the raw ISDN channel number field into an actual channel
number.

Put in some commented-out code to deal with some end-of-packet crud in
some ISDN captures - not all ISDN captures have it, so we can't
unconditionally slice it out.

svn path=/trunk/; revision=6863
2003-01-07 01:06:58 +00:00
Guy Harris 4750bf47a7 Add some more comments.
svn path=/trunk/; revision=6843
2003-01-03 08:00:51 +00:00
Guy Harris ae6cb2b4e3 Get rid of some bogus commented-out statements.
svn path=/trunk/; revision=6842
2003-01-03 07:54:01 +00:00
Guy Harris eaea31134c It appears there are, indeed, two fields in the "xxb" part of the file
header that specify the detailed capture type for WAN captures; use
those fields.

svn path=/trunk/; revision=6841
2003-01-03 07:51:26 +00:00
Guy Harris 0a5be3f18b Rename WTAP_ENCAP_ATM_SNIFFER to WTAP_ENCAP_ATM_PDUS, as it's not just
used for the DOS-based ATM Sniffer.  (That's not a great name, but I
couldn't think of a better one.)

Add a new WTAP_ENCAP_ATM_PDUS_UNTRUNCATED encapsulation type for capture
files where reassembled frames don't have trailers, such as the AAL5
trailer, chopped off.  That's what at least some versions of the
Windows-based ATM Sniffer appear to have.

Map the ATM capture file type for NetXRay captures to
WTAP_ENCAP_ATM_PDUS_UNTRUNCATED, and put in stuff to fill in what we've
reverse-engineered, so far, for the pseudo-header; there's more that
needs to be done on it, e.g. getting the channel, AAL type, and traffic
type (or inferring them if they're not in the packet header).

svn path=/trunk/; revision=6840
2003-01-03 06:45:45 +00:00
Guy Harris decd1f84d1 Add support for version 002.000, and note that there's probably
something hidden in the per-packet header for ATM captures that
specifies the traffic type (and stuff such as that).

svn path=/trunk/; revision=6839
2003-01-03 02:24:56 +00:00
Guy Harris 56f644145e Discard the WTAP_ENCAP_LAPD encapsulation type in favor of a
WTAP_ENCAP_ISDN encapsulation type, which includes a pseudo-header
giving the direction (user-to-network or network-to-user) and the
channel number.

Add a new circuit type, using the ISDN channel number as the circuit ID.

Add an ISDN dissector to put the direction and channel number into the
protocol tree and to call the appropriate dissector for the payload
based on the channel (LAPD for the D channel; V.120, PPP, or data for B
channels, based on some heuristics).

svn path=/trunk/; revision=6521
2002-10-31 07:12:42 +00:00
Guy Harris f806f64b71 Some fields that are treated as 16-bit or 8-bit fields followed by
unknown bytes might actually be 32-bit fields.

The field after the upper 32 bits of the time stamp of the capture start
appears to be the speed of the network, in bits/second.

Put in a field for the rest of the file header, as a bunch of 32-bit
values (most fields are 32 bits, and all of them might be, in that
header), for use when reverse-engineering.

At least in version 002.x of NetXRay-format captures, WAN captures might
be ISDN captures; treat all WAN version 002.x captures as ISDN captures
for now, until we see some captures where that's wrong (and thus stand a
chance of figuring out where in the file header it indicates what type
of capture it is).

svn path=/trunk/; revision=6519
2002-10-29 06:12:35 +00:00
Guy Harris 671ba8b6a6 Put in a comment noting that not *all* captures with a network type of 3
look like Ethernet captures.

svn path=/trunk/; revision=6474
2002-10-22 18:48:15 +00:00
Jörg Mayer 64b6acac6d Removed trailing whitespaces from .h and .c files using the
winapi_cleanup tool written by Patrik Stridvall for the wine
project.

svn path=/trunk/; revision=6115
2002-08-28 20:30:45 +00:00
Guy Harris 6e21561be8 From Joerg Mayer:
All files:
  - Replace types from sys/types.h by those from glib.h
  - Replace ntoh family of macros from netinet/in.h and winsock2.h
    by g_ntoh family from glib.h
  - Remove now unneeded includes of sys/types.h, netinet/in.h and
    winsock2.h
wtap.h
  Move includes to the top

svn path=/trunk/; revision=5909
2002-07-29 06:09:59 +00:00
Guy Harris 44d19627ef From Graeme Hewson:
Allow "-" as the output file name in Wiretap, referring to the
	standard error.

	Optimize the capture loop.

Fix some of the error-message printing code in Ethereal and Tethereal.

Have Wiretap check whether it can seek on a file descriptor, and pass
the results of that test to the file-type-specific "open for output"
routine.  Have the "open for output" routines for files where we need to
seek when writing the file return an error if seeks don't work.

svn path=/trunk/; revision=5884
2002-07-16 07:15:09 +00:00
Guy Harris 2aad75bb82 Graeme Hewson noted that zlib has a bug wherein "gzseek()" doesn't set
the internal z_err value for the stream if an "fseek()" call it makes
fails, so that if "gzerror()" is subsequently called, it returns Z_OK
rather than an error.

To work around this, we pass "file_seek()" an "int *err", and have the
with-zlib version of "file_seek()" check, if "gzseek()" fails, whether
the return value of "file_error()" is 0 and, if so, have it return
"errno" instead.

svn path=/trunk/; revision=5642
2002-06-07 07:27:35 +00:00
Guy Harris 586e97727f Add support for old NetXRay format.
svn path=/trunk/; revision=5576
2002-05-28 02:39:15 +00:00
Guy Harris 82f364ab1a Fix capture-file-specific "close output" routines to check whether the
"err" argument is null and return an error code through that argument
only if it isn't, to match what "wtap_dump_close()", which calls those
routines, does.

Put the NetXRay dump routines in order by version number.

svn path=/trunk/; revision=5385
2002-05-04 10:00:18 +00:00
Guy Harris ea17f40455 Initial support for writing NetXRay 2.x (Windows Sniffer) format
captures, from Olivier Abad.

svn path=/trunk/; revision=5202
2002-04-18 21:35:57 +00:00
Guy Harris 939b3c8e0a Add an encapsulation type for "802.11 with radio information"; that type
returns radio information such as signal strength, channel, and data
rate in a pseudo-header.  Add that pseudo-header.

Use the "802.11 with radio information" encapsulation type for Wireless
Sniffer files; extract the radio information from where it appears to be
in the header.

Add dissector code for that encapsulation type.

Fix an error in the code to put radio information into the AiroPeek
tree.

Make the "wrapped" flag for NetXRay/Windows Sniffer captures a
"gboolean".

svn path=/trunk/; revision=5122
2002-04-08 09:09:49 +00:00
Guy Harris 34ab745db0 Yes, that stuff really *does* appear to be just padding. Go figure.
svn path=/trunk/; revision=5119
2002-04-08 02:11:24 +00:00
Guy Harris 5bb4bf06a9 Gerald says the padding has values that don't look like FCSes; note that
in the comment.

svn path=/trunk/; revision=5108
2002-04-07 21:44:55 +00:00
Guy Harris ae54ef681c Make the end-of-packet padding a per-capture-file property.
Read in the entire packet, including the padding, and just tell our
caller about the non-padding part; that avoids doing a "file_seek()"
("fseek()"s are inefficient on some platforms, as they flush the
standard I/O buffers and do an "lseek()"), and would also let us supply
the padding to the caller if it turns out it's an FCS rather than
padding.

svn path=/trunk/; revision=5107
2002-04-07 21:29:01 +00:00
Gerald Combs f0e2b1a83c Add support for Sniffer 4.6 wireless captures.
svn path=/trunk/; revision=5106
2002-04-07 19:10:10 +00:00
Guy Harris d54bd0bd6b Check for errors in seeks, "tell"s, and "stat()"s/"fstat()"s.
For file types where we allocate private data, add "close" routines
where they were missing, to free the private data.  Also fix up the code
to clean up after some errors by freeing private data where that wasn't
being done.

Get rid of unused arguments to "wtap_dump_open_finish()".

Fix indentation.

svn path=/trunk/; revision=4857
2002-03-04 00:25:35 +00:00
Guy Harris 761ae95b19 From Joerg Mayer: get rid of "-Wno-unused" flag in some configure
scripts, and check in changes to add _U_ to some unused arguments (some
other should perhaps be used, so we leave the _U_ out so that the
warnings serve as a reminder to check those).

svn path=/trunk/; revision=4847
2002-03-02 20:41:08 +00:00
Guy Harris cbf5c537c4 From Joerg Mayer: remove unused variables and declarations of
non-existent functions.

Remove the "filetype" argument from the "can_write_encap" functions for
particular capture file types - the argument value is implicit, in that
the routine being called is the routine for that particular file type.

svn path=/trunk/; revision=4823
2002-02-27 08:57:25 +00:00
Guy Harris 89a4acb438 Have Wiretap set the snapshot length to 0 if it can't be derived from
reading the capture file.  Have callers of "wtap_snapshot_length()"
treat a value of 0 as "unknown", and default to WTAP_MAX_PACKET_SIZE (so
that, when writing a capture file in a format that *does* store the
snapshot length, we can at least put *something* in the file).

If we don't know the snapshot length of the current capture file, don't
display a value in the summary window.

Don't use "cfile.snap" as the snapshot length option when capturing -
doing so causes Ethereal to default, when capturing, to the snapshot
length of the last capture file that you read in, rather than to the
snapshot length of the last capture you did (or the initial default of
"no snapshot length").

Redo the "Capture Options" dialog box to group options into sections
with frames around them, and add units to the snapshot length, maximum
file size, and capture duration options, as per a suggestion by Ulf
Lamping.  Also add units to the capture count option.

Make the snapshot length, capture count, maximum file size, and capture
duration options into a combination of a check box and a spin button.
If the check box is not checked, the limit in question is inactive
(snapshot length of 65535, no max packet count, no max file size, no max
capture duration); if it's checked, the spinbox specifies the limit.
Default all of the check boxes to "not checked" and all of the spin
boxes to small values.

Use "gtk_toggle_button_get_active()" rather than directly fetching the
state of a check box.

svn path=/trunk/; revision=4709
2002-02-08 10:07:41 +00:00
Gilbert Ramirez f14a6b8b91 Hopefully the last time I have to change my e-mail address.
svn path=/trunk/; revision=4199
2001-11-13 23:55:44 +00:00
Gilbert Ramirez a505b64912 Get rid of signed/unsigned comparison warnings in wiretap.
svn path=/trunk/; revision=4077
2001-10-25 20:29:24 +00:00
Guy Harris 3c9efdf478 Use longs as file offsets, so that on platforms with 64-bit "long" we
can handle capture files bigger than 2GB.

svn path=/trunk/; revision=3993
2001-10-04 08:30:36 +00:00
Guy Harris 606d363a9b The return value from "fwrite()" is a "size_t"; make the variable into
which we store it a "size_t", and then fix up the bugs that were
revealed by the compiler warnings that produced - "fwrite()" returns 0,
not a negative number, on an I/O error.

Fix up some other items to have type "size_t", or to have various
unsigned types, while we're at it, to squelch compiler warnings.

svn path=/trunk/; revision=3867
2001-08-25 03:18:48 +00:00
Guy Harris 288053a6db Patch from Chris Jepeway to use, in NetXRay 2.x captures, a field from
the file header to specify the time units; different files appear to
have different time stamp units.

svn path=/trunk/; revision=3407
2001-05-09 04:42:27 +00:00
Guy Harris 289f57e570 Back out the guint64 stuff - it's not clear it's the right way to handle
this, as

	1) we still need to handle platforms that don't support 64-bit
	   integral data types, so we still needed the old stuff in some
	   fashion anyway

and

	2) MSVC appears to treat structures as requiring 8-byte
	   alignment in some cases, and "guint64"s require 8-byte
	   alignment on at least some platforms, forcing structures
	   containing those 64-bit time stamps to have a size that's a
	   multiple of 8 bytes, which *isn't* the correct size for the
	   data record header.

svn path=/trunk/; revision=3177
2001-03-23 23:16:29 +00:00
Guy Harris a251addb63 Obliging every capture file reader's "open()" routine to seek to the
beginning of the file before reading anything from the file is bogus -
do that in the loop that tries each of the open routines, instead.
(They may have to reset the seek pointer later if, for example, the
capture file begins with the first packet, and the "open()" routine
looks at that packet to try to guess whether the packet is in the file
format in question.)

Set "wth->data_offset" to 0 while you're at it, so capture file readers
don't have to do that, either.

svn path=/trunk/; revision=3123
2001-03-10 06:33:58 +00:00
Guy Harris 33ca70bed1 Sigh. Microsoft Visual C++ 6.0 won't convert a "guint64" to a "double"
- it only allows you to convert a *signed* 64-bit integer to a "double".
Cast the result of "pletohll()" to "gint64" before returning it from a
function that returns a "double".

svn path=/trunk/; revision=3033
2001-02-14 09:38:10 +00:00
Guy Harris b3f35be74a Changes from Chris Jepeway to
in some places use "guint64", on plaforms where it's available,
	rather than floating point (we don't yet use it universally, as
	we'd have to provide code to do 64-bit arithmetic on
	platforms/compilers where 64-bit integral types aren't
	supported);

	use .838096 microseconds rather than 1 microseconds as the time
	stamp units for NetXRay 2.x format, as those capture files seem
	to use that time stamp (that's the Sniffer "PC" time stamp;
	perhaps when Network Associates assimilated Cinco, they changed
	the time stamp units).

svn path=/trunk/; revision=3027
2001-02-13 00:50:05 +00:00
Guy Harris 4933cc340f "wtap_read()" must *always* set "*err" when it returns FALSE - if it's
just an EOF, it should set "*err" to 0.  Fix up a bunch of read routines
for various capture file types to set "*err" appropriately.

svn path=/trunk/; revision=2667
2000-11-19 03:47:36 +00:00
Guy Harris f881e13932 Windows Sniffers appear to write out ATM traces with a network type of
8, which is NDIS's ATM type.  At least one capture appears to have
LLC-encapsulated frames in it; for now, we'll map it to
WTAP_ENCAP_ATM_RFC1483 - and make Ethereal dissect
WTAP_ENCAP_ATM_RFC1483 by handing the frames to "dissect_llc()".

While we're at it, we'll have Ethereal panic if handed a Wiretap packet
type it doesn't dissect, rather than giving you a rather blank
dissection.

svn path=/trunk/; revision=2457
2000-09-23 05:58:26 +00:00
Gilbert Ramirez c312f69abc Make sure to pass the sent/received direction from pppdump.c in
pseudo_header.
Use generic "p2p_phdr" instead of "lapd_phdr". Modify toshiba.c and
packet-lapd.c to take that into account.
Add frame.p2p_dir, a filterable field, 0=sent, 1=recvd
Make p2p_dir available in packe_info, as I think it will be needed
in VJ COMP and UNCOMP dissection.

Rename WTAP_ENCAP_TR to WTAP_ENCAP_TOKEN_RING.

Mention pppd-log support in man page.
Mention atmsnoop in README.

svn path=/trunk/; revision=2455
2000-09-21 04:41:37 +00:00
Gilbert Ramirez f52ffba407 Change wtap_read() API so that the data offset is set via a pointer, and
a "keep reading" boolean value is returned from the function.
This avoids having to hack around the fact that some file formats truly
do have records that start at offset 0. (i4btrace and csids have no
file header. Neither does the pppdump-style file that I'm looking at right now).

svn path=/trunk/; revision=2392
2000-09-07 05:34:23 +00:00
Gilbert Ramirez 4a3b77ba46 Move #include <time.h> into wtap-int.h instead of requiring it in
every C file. I noticed this because of a build break of csids.obj on
Win32.

svn path=/trunk/; revision=2378
2000-08-25 21:25:43 +00:00
Guy Harris ae1f565029 Joerg Mayer's changes to add support for NetXRay file format version
2.002, as used by release 3.50 of the Network Associates Sniffer for
Windows; currently, we treat it just like the 2.001 version, so we
rename the version #define WTAP_FILE_NETXRAY_2_001 to
WTAP_FILE_NETXRAY_2_00x and use that for both 2.001 and 2.002.

svn path=/trunk/; revision=2087
2000-06-24 05:32:48 +00:00
Gilbert Ramirez d7e6e0e384 Add wtap-int.h. Move definitions relevant to the internal workins of wiretap
to that file, leave public definitions in wtap.h.

Rename "union pseudo_header" to "union wtap_pseudo_header".
Make the wtap_pseudo_header pointer available in packet_info struct.

svn path=/trunk/; revision=1989
2000-05-19 23:07:04 +00:00
Guy Harris f3d90d30a4 Remove the "union pseudo_header" from the "frame_data" structure;
there's no need to keep it around in memory - when the frame data is
read in when handing a frame, read in the information, if any, necessary
to reconstruct the frame header, and reconstruct it.  This saves some
memory.

This requires that the seek-and-read function be implemented inside
Wiretap, and that the Wiretap handle remain open even after we've
finished reading the file sequentially.

This also points out that we can't really do X.25-over-Ethernet
correctly, as we don't know where the direction (DTE->DCE or DCE->DTE)
flag is stored; it's not clear how the Ethernet type 0x0805 for X.25
Layer 3 is supposed to be handled in any case.  We eliminate
X.25-over-Ethernet support (until we find out what we're supposed to
do).

svn path=/trunk/; revision=1975
2000-05-18 09:09:50 +00:00
Guy Harris 0fdd93d1ce Rename the "private" member of a "wtap_dumper" structure to "dump", as
per the "capture" member of a "wtap" structure, so that it doesn't
collide with the C++ reserved word "private".

svn path=/trunk/; revision=1936
2000-05-10 22:16:31 +00:00
Guy Harris 005588b8b9 In a Network Monitor capture file, get the starting offsets of frames
from the frame table - Network Monitor 2.x, at least, doesn't always
write frame N+1 right after frame N.

To do that, we need to mallocate a big array to hold the frame table,
and free it when we close the capture file; this requires that we have
capture-file-type-specific close routines as well as
capture-file-type-specific read routines - we let it the pointer to that
routine be null if it's not needed.  Given that, we might as well get
rid of the switch statement in "wtap_close()", in favor of using
capture-file-type-specific close routines, as per the comment before
that switch statement.

svn path=/trunk/; revision=1740
2000-03-22 07:06:59 +00:00
Guy Harris 585268e3e1 Use WTAP_ERR_UNSUPPORTED_ENCAP for all attempts to open or read a
capture file for an unsupported link-layer encapsulation type (as the
nettl reader does), and report it correctly if it occurs on an open or
read attempt rather than a save attempt.

svn path=/trunk/; revision=1647
2000-02-19 08:00:08 +00:00
Gilbert Ramirez 65b4006f46 Support for NetXray 3.03 (the program version, not file version) PPP
traces. The trace we got from Tom Poe (tomp@intrex.net) contains PPP
data which NetXRay has transformed into looking like Ethernet frames.
The hardware addresses are the bytes for the ASCII reprsentation of
"SRC" and "DEST", with null pad bytes at the end. Interesting.

svn path=/trunk/; revision=1576
2000-01-29 05:10:06 +00:00
Guy Harris 3e067b812c Fix files that had Gilbert's old e-mail address or that didn't have my
forwarding e-mail address.

svn path=/trunk/; revision=1522
2000-01-22 06:22:44 +00:00
Guy Harris 7a36bede0b We are obliged to define HAVE_UNISTD_H in "config.h"; to avoid the
hideous problem on FreeBSD 3.[23] (and perhaps other BSDs) if
HAVE_UNISTD_H is defined before "zlib.h" is included, turn "file_seek()"
into a subroutine defined in a file that *undefines* HAVE_UNISTD_H
before including "zlib.h", so that the *only* call to "gzseek()" is made
from a file that does not have HAVE_UNISTD_H defined when it includes
"zlib.h".

Move "file_error()" to that file while you're at it, so it holds all the
wrappers that hide the presence or absence of zlib from routines to read
capture files.

Turn "file.h", which declared those wrapper functions as well as wrapper
macros, into "file_wrapper.h" - it belongs with the "file_wrapper.c"
file that defines the wrapper functions, not with "file.c" which handles
higher-layer file access functions.

Remove the comment in "configure.in" that explained why defining
HAVE_UNISTD_H was a bad idea, as we're not obliged to define it and work
around the problem.  (The comment in "file_wrapper.c" explains the
workaround.)

svn path=/trunk/; revision=1463
2000-01-13 07:09:20 +00:00
Guy Harris cc4e9f698b One field in the NetXRay header appears to be the number of frames in
the capture; set it to that when writing the capture.

Support Token Ring and FDDI captures (as per the network type in the
file header appearing to be either the NDIS network type, or the NDIS
network type minus 1 - I forget whether Ethernet has an NDIS type of 0
or 1).

Don't write the file header twice, keeping a static copy of it around,
as Wiretap code isn't supposed to keep any static data around; instead,
write it only when we're done writing out all the records (as we do on
Network Monitor captures).

Compute the time stamps when writing the file.

Give Windows Sniffer 1.1-format a short name, so "editcap" doesn't dump
core or print "(null)" in its usage message.

WTAP_ENCAP_NULL isn't supported by NetMon; don't write it.

svn path=/trunk/; revision=1336
1999-12-15 01:34:17 +00:00
Nathan Neulinger f78124579c more work on netxray, still not sniffer compatible though
svn path=/trunk/; revision=1333
1999-12-14 21:59:07 +00:00
Guy Harris 392e51a42e Include <string.h> to declare "memset()".
svn path=/trunk/; revision=1321
1999-12-14 05:34:30 +00:00
Nathan Neulinger 2ad53e520e Added support for writing netxray version 1.1 dumps.
It's very basic, and doesn't write out the timestamps currently. It also
only handles WTAP_ENCAP_ETHERNET, although it can probably do the others,
but I don't have a good way to test them. This code has not yet been tested
against a Sniffer Pro, although wiretap can read the files just fine.

svn path=/trunk/; revision=1318
1999-12-14 01:12:59 +00:00
Guy Harris 5f7868c7e0 Better handle errors from zlib:
Assign a range of Wiretap errors for zlib errors, and have
	"wtap_strerror()" use "zError()" to get an error message for
	them.

	Have the internal "file_error()" routine return 0 for no error
	and a Wiretap error code for an error.

svn path=/trunk/; revision=769
1999-10-05 07:06:08 +00:00
Guy Harris a9c36a4b69 Fix it so that it builds with "--disable-zlib".
The "fh" member of a "wtap" structure points to something constructed
from the "fd" member of that structure, so that closing the stream
referred to by "fh" also closes the underlying file descriptor; get rid
of an unnecessary close of "wth->fd".

svn path=/trunk/; revision=720
1999-09-24 05:49:53 +00:00
Ashok Narayanan 3dfa56c498 This commit contains support for reading capture files compressed using
gzip. The zLib library is used for this purpose. If zLib is not available
(or it's use is disabled by the --disable-zlib option to configure), you
can still compile Ethereal but it will be unable to read compressed capture
files.

IMPORTANT:

Now all file accesses to capture files should be done through special macros.
Specifically, for any use of the following functions on capture files, replace them.
The arguments for the right-side functions are exactly the same as for the
original stdio functions.

	fopen			file_open
	fdopen			filed_open
	fread			file_read
	fwrite			file_write
	fseek			file_seek
	fclose			file_close
	ferror			file_error

svn path=/trunk/; revision=695
1999-09-22 01:26:50 +00:00
Guy Harris ae53260d02 Keep in the "wtap" structure the current offset into the file being
read, and maintain it ourselves as we read through the file, rather than
calling "ftell()" for every packet we read - "ftell()" may involve an
"lseek()" call, which could add a noticeable CPU overhead when reading a
large file.

svn path=/trunk/; revision=596
1999-08-28 01:19:45 +00:00
Guy Harris 678b5fd6ff Add a new Wiretap encapsulation type WTAP_ENCAP_FDDI_BITSWAPPED, meaning
"FDDI with the MAC addresses bit-swapped"; whether the MAC addresses are
bit-swapped is a property of the machine on which the capture was taken,
not of the machine on which the capture is being read - right now, none
of the capture file formats we read indicate whether FDDI MAC addresses
are bit-swapped, but this does let us treat non-"libpcap" captures as
being bit-swapped or not bit-swapped independent of the machine on which
they're being read (and of the machine on which they were captured, but
I have the impression they're bit-swapped on most platforms), and allows
us to, if, as, and when we implement packet capture in Wiretap, mark
packets in a capture file written in Wiretap-native format based on the
machine on which they are captured (assuming the rule "Ultrix, Alpha,
and BSD/OS are the only platforms that don't bit-swap", or some other
compile-time rule, gets the right answer, or that some platform has
drivers that can tell us whether the addresses are bit-swapped).

(NOTE: if, for any of the capture file formats used only on one
platform, FDDI MAC addresses aren't bit-swapped, the code to read that
capture file format should be fixed to flag them as not bit-swapped.)

Use the encapsulation type to decide whether to bit-swap addresses in
"dissect_fddi()".

svn path=/trunk/; revision=557
1999-08-24 03:19:34 +00:00
Guy Harris 4b9ab6d1fc Get rid of some cruft left in by previous checkins as placeholders.
Get rid of WTAP_ENCAP_NONE; replace it with WTAP_ENCAP_UNKNOWN, which
means "I can't handle that file, it's using an encapsulation I don't
support".

Check for encapsulations we don't support, and return an error (as is
already done in "libpcap.c").

Check for too-large packet sizes, and return an error (as is already
done in "libpcap.c").

Print unsigned quantities in Wiretap messages with "%u", not "%d".

svn path=/trunk/; revision=544
1999-08-22 02:29:40 +00:00
Guy Harris 137ba48d18 Have the per-capture-file-type open routines "wtap_open_offline()" calls
return 1 on success, -1 if they got an error, and 0 if the file isn't of
the type that file is checking for, and supply an error code if they
return -1; have "wtap_open_offline()" use that error code.  Also, have
the per-capture-file-type open routines treat errors accessing the file
as errors, and return -1, rather than just returning 0 so that we try
another file type.

Have the per-capture-file-type read routines "wtap_loop()" calls return
-1 and supply an error code on error (and not, as they did in some
cases, call "g_error()" and abort), and have "wtap_loop()", if the read
routine returned an error, return FALSE (and pass an error-code-pointer
argument onto the read routines, so they fill it in), and return TRUE on
success.

Add some new error codes for them to return.

Now that "wtap_loop()" can return a success/failure indication and an
error code, in "read_cap_file()" put up a message box if we get an error
reading the file, and return the error code.

Handle the additional errors we can get when opening a capture file.

If the attempt to open a capture file succeeds, but the attempt to read
it fails, don't treat that as a complete failure - we may have managed
to read some of the capture file, and we should display what we managed
to read.

svn path=/trunk/; revision=516
1999-08-19 05:31:38 +00:00
Guy Harris df490a7085 Add to Wiretap the ability to write capture files; for now, it can only
write them in "libpcap" format, but the mechanism can have other formats
added.

When creating the temporary file for a capture, use "create_tempfile()",
to close a security hole opened by the fact that "tempnam()" creates a
temporary file, but doesn't open it, and we open the file with the name
it gives us - somebody could remove the file and plant a link to some
file, and, if as may well be the case when Ethereal is capturing
packets, it's running as "root", that means we write a capture on top of
that file....  (The aforementioned changes to Wiretap let you open a
capture file for writing given an file descriptor, "fdopen()"-style,
which this change requires.)

svn path=/trunk/; revision=509
1999-08-18 04:17:38 +00:00
Gilbert Ramirez 601c52f0fb Added support for compiling on win32 with Visual C and 'nmake'. It compiles,
but does not link. Perhaps someone who understands the MS tools can help
out. I made it link a few months ago, but with different version of glib/gtk+.
I can't remember how I made it link.

Most of the compatibility issues were resolved with adding
#ifdef HAVE_UNISTD_H the the source code. Please be sure to add this to all
future code.

svn path=/trunk/; revision=359
1999-07-13 02:53:26 +00:00
Guy Harris 6399732b86 Add support for Network Monitor 2.0 files, thanks to information
supplied by Tim Farley.

Tim also indicated that the Network Monitor network types may be NDIS
network types+1.  It also appears that NetXRay/Windows Sniffer network
types may be NDIS network types as well.

svn path=/trunk/; revision=284
1999-05-12 21:40:07 +00:00
Guy Harris 4932ef3dcc The program that produced the version 2.001 file was Sniffer Pro 2.50.05
(presumably a Windows version).

Note also that version 2.001 files appear to have microsecond time
stamps, like version 1.1 files.

svn path=/trunk/; revision=228
1999-03-25 06:34:32 +00:00
Gilbert Ramirez bdbd5ee203 Got rid of "hdr_size may not be initialized" warning, even though it was
innocuous.

svn path=/trunk/; revision=221
1999-03-22 15:02:25 +00:00
Guy Harris 56b5a15d5f Add support for file format version 2.001 (used by Sniffer Basic 2.0?).
This assumes that the time stamps are still in units of microseconds; I
don't yet have a text decode of the version-2.001 file from the program
that decoded it, so I can't check the time stamps.

svn path=/trunk/; revision=217
1999-03-20 09:10:49 +00:00
Guy Harris e2b7e1aba9 It turns out that the first of the unknown fields in the NetXRay header
appears to be the UNIX "time_t" when the capture started, so use that to
figure out the time when a packet was captured.

svn path=/trunk/; revision=204
1999-03-01 22:59:47 +00:00
Gilbert Ramirez 2dbd008ea5 Added display filters to wiretap.
svn path=/trunk/; revision=198
1999-03-01 18:57:07 +00:00
Guy Harris 3200c25437 Add support for Cinco Networks NetXRay - which is, after their acquision
by Network General (subsequently merged with McAfee Associates into
Network Associates), called "Sniffer Basic".

A similar format appears to be used by the Windows Sniffer Pro.

svn path=/trunk/; revision=194
1999-02-20 06:49:27 +00:00