Commit Graph

289 Commits

Author SHA1 Message Date
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 94800ef0fb From Chris Waters: support Tazmen Sniffer Protocol and DLT_TZSP captures
from network-based libpcaps that use that protocol.

svn path=/trunk/; revision=6875
2003-01-08 05:03:54 +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 7280374f3d Add support for the new DLT_ value of 127, for the AVS WLAN header.
svn path=/trunk/; revision=6780
2002-12-11 22:45:24 +00:00
Guy Harris a40e352b26 The "pd" argument to "wtap_process_pcap_packet()" is a const pointer;
when extracting the ATM pseudo-header from the data it points to, cast
it to a "const struct sunatm_hdr *".

svn path=/trunk/; revision=6679
2002-11-27 22:23:34 +00:00
Guy Harris 2fed18defb AIX's tcpdump has the same annoying habit as AIX's iptrace of putting 3
bytes of padding in front of FDDI frames; strip it off.

svn path=/trunk/; revision=6647
2002-11-16 20:20:30 +00:00
Guy Harris 2a54cd2a76 Add a Wiretap encapsulation type for RFC 2625 IP-over-Fibre Channel, and
map libpcap's DLT_IP_OVER_FC to it.

svn path=/trunk/; revision=6473
2002-10-22 09:11:13 +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 1c7b05f665 Properly set the LANE traffic type.
svn path=/trunk/; revision=5967
2002-08-07 06:59:49 +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 5e42823dc0 Move the entries to map between platform-dependent libpcap link-layer
types and Wiretap encapsulations after the entries to map between
platform-independent libpcap link-layer types and those Wiretap
encapsulations, so that, when writing a libpcap-format file, we choose
the platform-independent link-layer types.

svn path=/trunk/; revision=5668
2002-06-13 11:03:23 +00:00
Gilbert Ramirez 87e011637c Add #define HAVE_PCAP_H 1 to config.h.win32.
In libpcap.c, move wtap_pcap_encap_to_wtap_encap before libpcap_open
so that if HAVE_PCAP_H is not true, the file will still compile.

svn path=/trunk/; revision=5660
2002-06-10 15:45:30 +00:00
Guy Harris c2b438ddfa Add a Wiretap routine to process packets captured via libpcap, possibly
extracting a pseudo-header, for the use of SunATM captures.

Add support for SunATM capture.

svn path=/trunk/; revision=5652
2002-06-07 21:11:24 +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 199aaacbb7 BSD/OS Frame Relay packets just begin with the Frame Relay header, so
they are, in fact, WTAP_ENCAP_FRELAY.  Support 11 as WTAP_ENCAP_FRELAY
if DLT_FR is defined and is equal to 11, and support 107 as
WTAP_ENCAP_FRELAY unconditionally.

Get rid of a comment indicating that 105 isn't used - it's been
supported as DLT_IEEE802_11 for a while.

svn path=/trunk/; revision=5640
2002-06-07 04:48:36 +00:00
Guy Harris 7acc6a8e1a Use "phtons()", not "htons()", just as we use "pntohs()" rather than
"ntohs()".

svn path=/trunk/; revision=5636
2002-06-06 18:58:12 +00:00
Guy Harris bb778e86a7 Support the Solaris+SunATM libpcap capture file type (not yet checked
into libpcap or tcpdump, but the LINKTYPE_ number is reserved for that
purpose).

svn path=/trunk/; revision=5633
2002-06-06 09:18:28 +00:00
Guy Harris 7d77975a14 Sigh. Tcpdump cannot handle capture files with a snapshot length of 0,
as BPF filters return either 0 if they fail or the snapshot length if
they succeed, and a snapshot length of 0 means success is
indistinguishable from failure and the filter expression would reject
all packets.

Now that a snapshot length of 0, inside Ethereal, means "snapshot length
unknown", we have to, when opening a libpcap file for output, make the
snapshot length some non-zero value.  We make it WTAP_MAX_PACKET_SIZE,
in case some program uses the snapshot length as a buffer size.  (That
doesn't help if there are packets with more than 65535 bytes of data; if
there are, we'd need to raise WTAP_MAX_PACKET_SIZE just to make those
files readable in Ethereal in any case.)

svn path=/trunk/; revision=4905
2002-03-09 23:07:26 +00:00
Guy Harris 828df9d18f Fix a comment.
svn path=/trunk/; revision=4899
2002-03-07 21:46:06 +00:00
Guy Harris ab0302ea1b Fix a typo - IFT_ISO88025 is 9, not 8.
svn path=/trunk/; revision=4898
2002-03-07 21:31:12 +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 f9c109a239 Support in Wiretap for DLT_HHDLC, from Tomas Kukosa.
svn path=/trunk/; revision=4707
2002-02-07 20:41:28 +00:00
Guy Harris 5cf3587feb Support a libpcap link-layer type of 17 as DLT_PFLOG unless DLT_LANE8023
is defined as 17.

svn path=/trunk/; revision=4617
2002-01-29 08:55:24 +00:00
Guy Harris c873f79156 Support for capturing on, and reading captures from, OpenBSD firewall
logging virtual interface, from Mike Frantzen.

svn path=/trunk/; revision=4616
2002-01-29 08:44:53 +00:00
Guy Harris a1660d6d3a Support for stopping capture at specified capture file size or capture
duration, from Thomas Wittwer and Matthias Nyffenegger.

svn path=/trunk/; revision=4322
2001-12-04 07:32:05 +00:00
Guy Harris a7bb49b0d9 Add support for LocalTalk Link Access Protocol.
Rename WTAP_ENCAP_PRISM to WTAP_ENCAP_PRISM_HEADER, to match
DLT_PRISM_HEADER.

Add in missing capture support for WTAP_ENCAP_PRISM_HEADER when
capturing with "pcap_open_live()" rather than reading the capture from a
pipe.

svn path=/trunk/; revision=4299
2001-11-30 07:14:22 +00:00
Guy Harris 56636f157a Support for 802.11+Prism II monitor-mode link-layer headers, from
Tim Newsham.

Add in missing item for WTAP_ENCAP_CISCO_IOS in the Wiretap
encapsulation type table.

svn path=/trunk/; revision=4290
2001-11-28 07:11:11 +00:00
Guy Harris 16bb4350ff Back the previous hack out - the padding is often zero, but it's not
*always* zero, so it won't always work, and it's somewhat gross.  The
right answer is "don't use Digital/Tru64 UNIX's tcpdump, use
tcpdump.org's".

svn path=/trunk/; revision=4202
2001-11-14 22:54:26 +00:00
Guy Harris e96b689067 Throw in a hack to try to detect FDDI captures from Digital UNIX's
tcpdump and, if we think we've found one, strip off the 3 padding bytes
they put in front of the frame.

svn path=/trunk/; revision=4201
2001-11-14 22:34: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
Guy Harris 40b22f317b Wrap calls to "pcap_datalink()" in a routine that attempts to compensate
for AIX 5.x's non-standard libpcap, where "pcap_datalink()" doesn't
return DLT_ values, it returns RFC 1573 ifType values.

Put that wrapper, and the routine to get the interface list, in a
separate file, for packet-capture utility routines, so not everybody who
includes "util.h" needs to include <pcap.h>.

Fix up the Wiretap hack for dealing with said incompatibility to use the
correct ifType value for Token Ring.

svn path=/trunk/; revision=4184
2001-11-09 07:44:51 +00:00
Guy Harris b7d32da1eb Expand on the comments about AIX libpcap.
No, Nokia *weren't* kind enough to change the major or minor version
number in the capture file when they changed the format, just as they
weren't kind enough to change the magic number.

svn path=/trunk/; revision=4173
2001-11-07 08:16:26 +00:00
Guy Harris 6910b84deb Add in some heuristics to try to detect AIX libpcap format. (This works
with one capture I've seen, but perhaps that was done with an old
version of AIX, and newer versions use a minor version number, in the
file, of 4.

However, libpcap hasn't used a minor version of 2 for ages, so perhaps
AIX hasn't updated their libpcap in ages, and aren't about to do so
soon.  If they do, let's hope they change the magic number.  The capture
file in question *does* have the capture length and real length in the
old, pre-2.3, order, so it really looks as if it's an old version,
rather than IBM trying to be "helpful" by using a different minor
version number so that you can distinguish between normal libpcap and
AIX libpcap formats.)

svn path=/trunk/; revision=4164
2001-11-06 01:55:14 +00:00
Gilbert Ramirez 0326e32563 Support DLT_CISCO_IOS.
svn path=/trunk/; revision=4126
2001-11-02 13:00:30 +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 f7b50ca754 From Joerg Mayer:
* gcc 3.0 warning fixes:
  - text2pcap.c: The number of characters to scan should probably not be 0
  - wiretap/csids.c: using preincrement on a variable used on both
    sides of an assignment might be undefined by the C99(?) standard
 * turn on additional warnings for epan and wiretap too
  - epan/configure.in
  - wiretap/configure.in
 * Fix some warnings (missing includes, signed/unsigned, missing
    initializers) found by turning on the warnings
  - all other files :-)

svn path=/trunk/; revision=3709
2001-07-13 00:55:58 +00:00
Guy Harris 7ecac8fbd0 Add a new Wiretap encapsulation type for Cisco HDLC. Map the NetBSD
DLT_HDLC to it.

Make a separate dissector for Cisco HDLC, and add a dissector for Cisco
SLARP.  Have the PPP dissector call the Cisco HDLC dissector if the
address field is the Cisco HDLC unicast or multicast address.  Use the
Cisco HDLC dissector for the Cisco HDLC Wiretap encapsulation type.

Add a new dissector table "chdlctype", for Cisco HDLC packet types
(they're *almost* the same as Ethernet types, but 0x8035 is SLARP, not
Reverse ARP, and 0x2000 is the Cisco Discovery protocol, for example),
replacing "fr.chdlc".

Have a "chdlctype()" routine, similar to "ethertype()", used both by the
Cisco HDLC and Frame Relay dissectors.  Have a "chdlc_vals[]"
"value_string" table for Cisco HDLC types and protocol names.  Split the
packet type field in the Frame Relay dissector into separate SNAP and
Cisco HDLC fields, and give them the Ethernet type and Cisco HDLC type
"value_string" tables, respectively.

svn path=/trunk/; revision=3133
2001-03-15 09:11:03 +00:00
Guy Harris ed3b9031f6 Handle NetBSD Cisco HDLC as PPP, for now.
svn path=/trunk/; revision=3125
2001-03-11 02:51:05 +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 039805843b Add support for the DLT_LINUX_SLL capture type in the current CVS
version of libpcap; that's used on Linux for captures on the "any"
device (which captures from all interfaces simultaneously) and for
captures on devices whose link-layer type libpcap doesn't (yet) support
natively.

The spanning tree code, when checking for GV{M,R,...}P packets, must
first check whether the link-layer destination address is, in fact, an
Ethernet-style address; on Linux cooked captures, there *is* no
destination address, so it's of type AT_NONE, not AT_ETHER.

svn path=/trunk/; revision=2772
2000-12-23 08:06:16 +00:00
Guy Harris 7c3fcbac34 IEEE 802.11 support, from Johan Jorgensen of Axis Communications AB.
Add in stuff for a bunch of libpcap formats either in libpcap 0.5.2 or
in the current CVS version; we don't implement all of them in
Ethereal/Wiretap (those are "#if 0"ed out), but we do implement the IEEE
802.11 stuff (which isn't yet in libpcap or tcpdump, but the CVS version
of libpcap *does* reserve 105 as the encapsulation type number for
802.11).

svn path=/trunk/; revision=2646
2000-11-15 05:42:35 +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
Guy Harris 726da14b05 Close the handle for the SNMP library after we're done with it - shared
objects are reference-counted so that won't make it disappear if
Ethereal is also linked with it as a shared SNMP library.

svn path=/trunk/; revision=2444
2000-09-17 07:50:35 +00:00
Guy Harris 6eccd35505 Code to read capture files from some version of tcpdump from some sort
of Nokia box (firewall) - yep, it's yet *another* mutant libpcap format
that didn't change the magic number, sigh....

svn path=/trunk/; revision=2440
2000-09-15 07:52:43 +00:00
Guy Harris e4fd931dde Add support for NetBSD DLT_PPP_SERIAL, which has the value 50, and which
is, for now, handled as WTAP_ENCAP_PPP (although we may have to split
WTAP_ENCAP_PPP into more than one type at some point).

svn path=/trunk/; revision=2423
2000-09-12 18:35:47 +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
Guy Harris 5e52e98926 Redo the way we map between libpcap encapsulation type codes and Wiretap
encapsulation type codes - for those libpcap type codes whose numerical
value is interpreted differently by different versions of libpcap,
include <pcap.h> if you can and, if you can, use what it defines to
control which Wiretap code we map those type codes to.

Also, map the new libpcap type codes introduced by libpcap 0.5.

svn path=/trunk/; revision=2369
2000-08-25 06:25:21 +00:00
Olivier Abad 9348644164 Support for capturing packet data from a pipe (a FIFO, or standard input).
capture.c :
- modified capture() to try to open an interface as a pipe if pcap_open_live()
  failed, and then read data in libpcap format from this pipe ;
- add new functions used by capture() : pipe_open_live() and pipe_dispatch()
  which are equivalents to the pcap_ functions.

libpcap.[ch] :
- moved the MAGIC and headers definitions from libpcap.c to libpcap.h
  because capture() now needs it.

svn path=/trunk/; revision=2181
2000-07-30 16:54:12 +00:00
Guy Harris 7de3b988bd In the final scene of the horror movie, just when you think the monster
is finally dead, and you're walking away, it springs up again and
attacks.

It appears that the ss990915 version of Alexey Kuznetzov's libpcap patch
has some extra stuff in the per-packet header for some sort of SMP
debugging, and that SuSE Linux 6.3 picked it up.

Thus, even if a libpcap file has the modified magic number, we *still*
have to go through the usual heuristic hell to figure out what type of
file it is.

svn path=/trunk/; revision=2164
2000-07-26 06:04:34 +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 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
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 78b75095f4 Add to some comments notes on the meaning of DLT types 15 and 16 on
Linux systems with the isdn4linux patches; they help make DLT types even
less useful than they were after the various flavors of BSD proceeded to
add their own types past 14, with no coordination whatosever, so that
they overlapped, rendering it impossible to read a libpcap capture file
without knowing what particular OS generated it.

svn path=/trunk/; revision=1442
2000-01-09 07:55:48 +00:00
Guy Harris 9658c33db6 Handle i4btrace captures if they're from a machine with the opposite
byte order from the machine that's reading them.

svn path=/trunk/; revision=1338
1999-12-15 02:25:50 +00:00
Guy Harris 96a2e32a70 Provide different file types for "modified" and Red Hat 6.1 "libpcap"
files (the former have a different per-packet header, and a different
magic number, from the standard "libpcap"; the latter have the same
per-packet header as "modified" "libpcap" files, but the same magic
number as standard "libpcap" files, sigh).

Support writing "libpcap" captures in all three formats (so that, for
example, people running Ethereal on RH 6.1 can write out captures that
the "tcpdump" that comes with RH 6.1 can read, although that's not the
default format we save in - there's no way to tell whether you're
running on RH 6.1, as far as I know; "uname()" just tells you, on Linux
systems, that the kernel is Linux 2.x, and what "x" is, it doesn't say
what the *rest* of the system is).

Fix the table in "file.c" to use Olivier's code for writing Sniffer
files.

svn path=/trunk/; revision=1288
1999-12-11 00:40:40 +00:00
Guy Harris 1eaa99a669 Fix some names.
svn path=/trunk/; revision=1203
1999-12-04 09:38:38 +00:00
Guy Harris 3b93574402 Add some infrastructure for the use of Ethereal, so it can make a list
of all the file types in which a file can be saved.

Giving each dumpable file type a routine that checks whether a file of a
given file type and encapsulation can be written lets us hoist some
checks into common code from out of the open routines.

If the "dump close" routine for a dump stream is NULL, have that mean
that there's no action that needs to be taken on a close by the code to
handle that file type; some file types don't need that, as they can be
written purely sequentially.

svn path=/trunk/; revision=1200
1999-12-04 08:32:14 +00:00
Guy Harris 4c37395f73 Add support to Wiretap for writing Network Monitor 1.x-format capture
files.

Make the return type of a number of routines that return 1 (for "true")
on success and 0 (for "false") on failure to "gboolean", and make the 1's
and 0's TRUEs and FALSEs.

svn path=/trunk/; revision=1194
1999-12-04 05:14:39 +00:00
Guy Harris d49b158b49 Add in a gross heuristic that attempts to detect files with the version
of the "libpcap" patch that changes the per-packet header but not the
magic number - it seems to work on at least one capture file I tried it
on.

Give the modified "libpcap" format a WTAP_FILE type of its own (so that,
in the future, we could support writing captures out in that format,
possibly).

svn path=/trunk/; revision=987
1999-11-06 10:31:47 +00:00
Guy Harris 148d0c865a Add support for capture files written by programs linked with Alexey
Kuznetsov's modified "libpcap" *as long as you have the ss990915 or
later patch*; the 990417 patch, alas, changes the per-packet header but
*doesn't* change the magic number, so you can't just look at the magic
number to see that it's Not Standard Libpcap.  (Even more unfortunately,
Red Hat appears to have picked up *that* patch for Red Hat 6.1; I've
filed bug 6773 with Bugzilla on their site - hopefully, if I'm not
misremembering the RH 6.1 code I've seen, and they really *did* pick up
the older patch, they'll fix it ASAP to use the new magic number, and
will make updates available.)

svn path=/trunk/; revision=986
1999-11-06 08:42:01 +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
Guy Harris 5e0274153e When reading a capture file, we can detect whether it's compressed or
not, so it's OK to use "zlib" to read capture files, as it handles
uncompressed files correctly.

When *writing* capture files, however, we can't detect automatically
whether the user wanted to write the file out as a compressed file or
not, so we should *NOT* use "zlib" until we add a flag to the API
specifying whether to write the file out as a compressed file or not.

Furthermore, the code in Ethereal that implements the "-S" flag depends
on being able to get the "FILE *" for a capture file being written, so
that it can "fflush()" it.

svn path=/trunk/; revision=703
1999-09-23 05:00:59 +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 9d14dfd6a9 Fix, from Bert Driehuis, to the stuff that checks for BSD/OS.
svn path=/trunk/; revision=620
1999-08-31 22:36:20 +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 73df88f11e Modify the comments to show how much of a mess the different DLT_ values
on different flavors of BSD are - even worse than I thought, now that
I've seen the BSD/OS <net/bpf.h>.

svn path=/trunk/; revision=552
1999-08-22 19:08:40 +00:00
Guy Harris 5a2b4b7ad2 Fix the pcap-encapsulation-to-wiretap-encapsulation mapping table.
Have the code that opens "libpcap" files for writing check to make sure
that the Wiretap encapsulation can be written to a "libpcap" file, and
return -1 and supply a new WTAP_ERR_UNSUPPORTED_ENCAP error code if it
can't.

Handle that new error code in "wtap_strerror()".

svn path=/trunk/; revision=546
1999-08-22 03:50:31 +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 ee39938f67 DLT_NULL, from "libpcap", means different things on different platforms
and in different capture files; throw in some heuristics to try to
figure out whether the 4-byte header is:

	1) PPP-over-HDLC (some version of ISDN4BSD?);

	2) big-endian AF_ value (BSD on big-endian platforms);

	3) little-endian AF_ value (BSD on little-endian platforms);

	4) two octets of 0 followed by an Ethernet type (Linux, at least
	   on little-endian platforms, as mutated by "libpcap").

Make a separate Wiretap encapsulation type, WTAP_ENCAP_NULL,
corresponding to DLT_NULL.

Have the PPP code dissect the frame if it's PPP-over-HDLC, and have
"ethertype()" dissect the Ethernet type and the rest of the packet if
it's a Linux-style header; dissect it ourselves only if it's an AF_
value.

Have Wiretap impose a maximum packet size of 65535 bytes, so that it
fails more gracefully when handed a corrupt "libpcap" capture file
(other capture file formats with more than a 16-bit capture length
field, if any, will have that check added later), and put that size in
"wtap.h" and have Ethereal use it as its notion of a maximum packet
size.

Have Ethereal put up a "this file appears to be damaged or corrupt"
message box if Wiretap returns a WTAP_ERR_BAD_RECORD error when opening
or reading a capture file.

Include loopback interfaces in the list of interfaces offered by the
"Capture" dialog box, but put them at the end of the list so that it
doesn't default to a loopback interface unless there are no other
interfaces.  Also, don't require that an interface in the list have an
IP address associated with it, and only put one entry in the list for a
given interface (SIOCGIFCONF returns one entry per interface *address*,
not per *interface* - and even if you were to use only IP addresses, an
interface could conceivably have more than one IP address).

Exclusively use Wiretap encapsulation types internally, even when
capturing; don't use DLT_ types.

svn path=/trunk/; revision=540
1999-08-22 00:47:56 +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 31d104a9c5 "wtap_pcap_encap_to_wtap_encap()" shouldn't return a file type if it
can't translate the encapsulation type, it should return an
encapsulation type; we add a new one, WTAP_ENCAP_UNKNOWN. and have it
return that.

Have "capture()" handle "wtap_pcap_encap_to_wtap_encap()" returning that
encapsulation type (if it happens, we need to add a new Wiretap
encapsulation type to handle the new "libpcap" encapsulation type).

svn path=/trunk/; revision=513
1999-08-18 17:08:47 +00:00
Guy Harris 28809e2002 Make "wtap_dump()" and "wtap_dump_close()" return error codes, and check
for errors when closing a file to which we've written packets (we don't
bother checking if we're giving up on a capture).

Add some more error checks in Wiretap.

Make a single list of all Wiretap error codes, giving them all different
values (some can be returned by more than one routine, so they shouldn't
be per-routine).

svn path=/trunk/; revision=510
1999-08-18 04:41:20 +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
Guy Harris 6f1d3a3be8 Patches from Thierry Andry to support Classical IP captures from systems
with the ATM on Linux software from <http://lrcwww.epfl.ch/linux-atm/>.

svn path=/trunk/; revision=401
1999-07-28 23:16:42 +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
Gilbert Ramirez 2dbd008ea5 Added display filters to wiretap.
svn path=/trunk/; revision=198
1999-03-01 18:57:07 +00:00
Gilbert Ramirez 7757b2e72b I removed the per-file encapsulation type from wiretap, and make all filetypes
provide a per-packet encapsulation type. this required minor modifications to
ethereal.

svn path=/trunk/; revision=162
1999-01-07 16:15:37 +00:00
Gilbert Ramirez e071c65555 Added Guy Harris' patch to read Sniffer ATM trace files. Very nice.
svn path=/trunk/; revision=128
1998-12-17 06:39:13 +00:00
Guy Harris 86bf1fc851 Add support to wiretap for reading Sun "snoop" capture files.
That requires that, in the packet-reading loop, we pass to the callback
routine the offset in the file of a packet's data, because we can no
longer compute that offset by subtracting the size of the captured
packet data from the offset in the file after the data was read -
"snoop" may stick padding in after the packet data to align packet
headers on 4-byte boundaries.

Doing that required that we arrange that we do that for "libpcap"
capture files as well; the cleanest way to do that was to write our own
code for reading "libpcap" capture files, rather than using the
"libpcap" code to do it.

Make "wtap_dispatch_cb()" and "pcap_dispatch_cb()" static to "file.c",
as they're not used elsewhere.

If we're using wiretap, don't define in "file.h" stuff used only when
we're not using wiretap.

Update the wiretap README to reflect Gilbert's and my recent changes.

Clean up some memory leaks in "wiretap/lanalyzer.c" and
"wiretap/ngsniffer.c", where the capture-file-format-specific data
wasn't freed if the open failed.

svn path=/trunk/; revision=91
1998-11-15 05:29:17 +00:00