Commit Graph

340 Commits

Author SHA1 Message Date
Ulf Lamping 2509c20b61 quit_after_cap should be a gboolean, not an int, and it should be initialized
svn path=/trunk/; revision=10169
2004-02-21 13:40:06 +00:00
Ulf Lamping ba50469654 rework of capture.c: better seperation of sync and capture pipe by using
explicit names and seperated functionality of do_capture(),
but no functional change!

svn path=/trunk/; revision=10168
2004-02-21 12:58:42 +00:00
Guy Harris 727b913bbd Add an "open_failure_alert_box()" routine to pop up an alert box for a
failed attempt to open/create a file.

Fix one call to pass the right value for the "for_writing" flag.

svn path=/trunk/; revision=10026
2004-02-11 01:23:25 +00:00
Ulf Lamping 1987113fa6 bugfix: close capture file again, if empty after capturing
(bug appears only, if "update list of packets ..." not used)

svn path=/trunk/; revision=10017
2004-02-09 19:19:19 +00:00
Guy Harris 4b5d510056 Tweak the error messages for bad capture filters.
svn path=/trunk/; revision=9974
2004-02-03 20:48:50 +00:00
Ulf Lamping 41cd2385c3 ups, moved previously missing %s to the right place
svn path=/trunk/; revision=9970
2004-02-03 19:54:08 +00:00
Guy Harris 1d7a46d039 Add a missing "%s" to the format string.
svn path=/trunk/; revision=9967
2004-02-03 18:39:52 +00:00
Ulf Lamping 1d2c791ab6 enhanced some dialog messages,
close capture file when user told so

svn path=/trunk/; revision=9965
2004-02-03 17:59:01 +00:00
Guy Harris 1980fa5dbf Pass ESD_BTN_OK rather than NULL as a second argument to
"simple_dialog()"; NULL might be #defined to be a pointer expression on
some platforms, causing compiler warnings (and, on platforms where a
null pointer doesn't have all its bits 0, possibly causing misbehavior,
although I don't think there are any such platforms on which Ethereal
runs).

Don't allow 0 as button mask argument to "simple_dialog()".

Squelch a compiler warning.

Report fatal problems as errors, not warnings.

Report file I/O errors with "file_open_error_message()".

Report file write errors (including those reported by "close()", e.g.
some errors writing to an NFS server) when saving raw packet data to a
file.

svn path=/trunk/; revision=9915
2004-01-31 03:22:42 +00:00
Guy Harris 61e26a56ba Add some more information to the error message for invalid capture
filters that look like display filters.

svn path=/trunk/; revision=9914
2004-01-31 02:29:19 +00:00
Ulf Lamping 25edd1c53e renamed ESD_TYPE_CRIT to ESD_TYPE_ERROR to
better reflect the real error text

svn path=/trunk/; revision=9913
2004-01-31 02:25:46 +00:00
Guy Harris d90d26ece2 If "pcap_compile()" fails to compile an empty filter string (because,
for example, the libpcap code generator doesn't support the link-layer
type for the capture), "dfilter_compile()" will succeed but return a
null rfcode pointer.

In that case, instead of telling people that it looks like a valid
display filter (which it does, but it also looks like a complete list of
all the Basque words likely to be known by Hammurabi :-)), and then
crashing when we try to "free" that non-existent dfilter code, we just
report it as a "sorry, couldn't compile that capture filter.

svn path=/trunk/; revision=9912
2004-01-31 01:32:51 +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 46848f0a9e Add a new "file_open_error_message()" routine in "epan/filesystem.c", to
translate UNIX errno values to a somewhat friendly message format
string.

Rename "file_open_error_message()" in "file.c" to
"cf_open_error_message()", make "cf_open_error_message()" use the new
"file_open_error_message()" for UNIX errno values, have "do_capture()"
in "capture.c" use "file_open_error_message()" to report errors from
"open()", and make "cf_open_error_message()" static as nothing outside
"file.c" uses it.

Do similar stuff in "tethereal.c".

svn path=/trunk/; revision=9821
2004-01-24 01:44:29 +00:00
Guy Harris 71887f8792 Use "fork_child" rather than "child_process" - on Win32, "child_process"
tracks "fork_child", and, on UNIX, "child_process" doesn't exist.

svn path=/trunk/; revision=9783
2004-01-22 20:45:49 +00:00
Ulf Lamping cf57056f70 bugfix: wrong parameter name
svn path=/trunk/; revision=9778
2004-01-22 19:25:36 +00:00
Ulf Lamping a0f78e3b8f moved GTK specific parts from capture.c to ui_util.c,
implemented Win32 "Capture Stop" when using
"update list of packets in realtime" while capturing

svn path=/trunk/; revision=9777
2004-01-22 18:13:57 +00:00
Ulf Lamping ef57df088f a.) saving GTK1 and GTK2 fontnames in different preference setting, to prevent problems when switching between GTK1 and GTK2 ethereal versions
b.) added new feature "Edit->Go To First Packet" "Edit->Go To Last Packet" with corresponding menu and toolbar items
c.) added new feature "View->Zoom In" / "View->Zoom Out" / View->Normal Size" with corresponding menu and toolbar items
This feature will act as a "size offset" to the current fontsize, so that the packet list/tree view/... will have a larger/smaller font size.
The value is stored inside the recent file.
d.) Win32 only: Try to get the win32 system font and fontsize at program startup and show the menus/dialogs and such with the same font and fontsize like other win32 windows.
This makes the program make a *lot* more feel like a normal win32 program.

svn path=/trunk/; revision=9753
2004-01-20 18:47:25 +00:00
Guy Harris 6033a79387 Update the Win32 information given when we fail to open a capture device
to note that the 3.0 and later versions of WinPcap don't support PPP/WAN
captures even on Windows OT.

svn path=/trunk/; revision=9709
2004-01-18 04:13:44 +00:00
Ulf Lamping 0d9679de8d removed some MSVC warnings (level 3)
svn path=/trunk/; revision=9561
2004-01-05 19:31:44 +00:00
Ulf Lamping 3b77bfee59 removed some MSVC warnings (moved pcap.h before glib.h)
svn path=/trunk/; revision=9393
2003-12-21 12:19:39 +00:00
Guy Harris e65abd0ef4 Top-of-tree and top-of-0.8-branch libpcap support limited filtering on
DLT_LINUX_IRDA (empty expression and "link[M:N]" expressions), so don't
special-case IRDA adapters.

svn path=/trunk/; revision=9349
2003-12-18 21:18:34 +00:00
Guy Harris b8299f0b98 From Jan Kiszka: IrDA support.
svn path=/trunk/; revision=9345
2003-12-18 19:07:14 +00:00
Guy Harris 08f3ea2cf3 Fix a typo.
svn path=/trunk/; revision=8983
2003-11-17 19:40:09 +00:00
Guy Harris d9ad0a2062 Get rid of a no-longer-used variable.
svn path=/trunk/; revision=8980
2003-11-17 00:26:30 +00:00
Ulf Lamping bca18fcf68 seperated capture dialog from capture.c and put into new gtk/capture_info_dlg.c
svn path=/trunk/; revision=8968
2003-11-15 08:48:14 +00:00
Guy Harris f4d0c0d9c2 When it comes to whether to use "select()" or not, even if you're
building in Cygwin's pretend-it's-UNIX environment, we need to treat the
platform as Windows.

Get rid of the BSD #define - just check for the platforms on which we
mustn't use "select()".

svn path=/trunk/; revision=8967
2003-11-14 21:18:06 +00:00
Guy Harris 219b6cefa2 Based on a patch from Brian Fundakowski Feldman, add support for setting
link-layer type when capturing, using the "pcap_set_datalink()" and
related APIs.

svn path=/trunk/; revision=8848
2003-11-01 02:30:18 +00:00
Jörg Mayer 5d4949f2dd Part 3 of display vs. capture syntax confusion patches: Detect probable
use of display filter syntax where capture filter syntax need to be used
in Ethereal.

svn path=/trunk/; revision=8677
2003-10-11 21:49:56 +00:00
Guy Harris b4746f3546 Make sure we return FALSE in all the failure paths in "do_capture()".
svn path=/trunk/; revision=8483
2003-09-15 23:48:42 +00:00
Guy Harris 2e98c97118 Don't pop up tap windows specified with "-z" options until we have a
capture file open.

svn path=/trunk/; revision=8480
2003-09-15 23:15:32 +00:00
Guy Harris 14509164fc Rename various capture file routines to have names starting with "cf_".
svn path=/trunk/; revision=8479
2003-09-15 22:48:42 +00:00
Guy Harris 183fa7f482 Give a more detailed message when WSAStartup fails.
svn path=/trunk/; revision=8069
2003-07-23 05:01:15 +00:00
Laurent Deniel 3070b797d5 Implement a ring buffer switch duration:
when the new "Rotate capture file every n second(s)" checkbox or the
-b <# of file>[:<duration>] argument are used, [t]ethereal will skip to the
next ring buffer file if the specified duration has elapsed (even if the
specified capture size is not reached). This is useful when you want to have
separate capture files per hour or day for instance.

I let the autostop filesize parameter mandatory (i.e. the "rotate capture
file after n kilobytes") but this could be no longer strictly necessary when
that new feature is used ...

Another point: it might be interesting to really truncate the file at the
switch and not the closure ... According to user comments and my own real
case tests, I might plan to enhance this point and others (still ring buffer
related) in the future.

svn path=/trunk/; revision=7678
2003-05-15 13:40:20 +00:00
Guy Harris eb8c0fb210 Don't ignore SIGCHLD - doing so means that, on many platforms, we don't
get any status information from the child process when it terminates,
and we want that status information (e.g., death due to a signal).

svn path=/trunk/; revision=7549
2003-04-24 09:07:36 +00:00
Guy Harris 5b1484f7b3 From a look at the Linux ARCNET code, it appears that no frame delivered
to the networking stack will have an exception frame header.

Note, however, that on the BSD's ARCNET might be a bit of a mess.

svn path=/trunk/; revision=6986
2003-01-23 09:04:54 +00:00
Guy Harris 498c94b10a Add a "capture_arcnet()" routine and use it when capturing.
In "dissect_arcnet_common()", fetch the protocol ID using the correct
offset rather than a hardwired 4.

svn path=/trunk/; revision=6982
2003-01-23 06:57:37 +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 06803d2919 Re-word-wrap the "you can't capture on PPP/WAN interfaces on NT"
message, to make the margins more even and to bring the second line
under 80 characters.  (It's amazing how long Herman Hollerith's legacy
has lasted....)

svn path=/trunk/; revision=6835
2003-01-01 03:51:02 +00:00
Guy Harris 3534ae5454 Use _WIN32 rather than WIN32 throughout (both of them appear to work - I
don't know whether one is the "right" one to use and, if one is, which
one it is - and they're both used in Ethereal, but let's at least be
consistent within a given file).

svn path=/trunk/; revision=6828
2002-12-31 21:12:55 +00:00
Guy Harris 4ff2dcfcda Clean up the comments a bit.
svn path=/trunk/; revision=6827
2002-12-31 21:06:48 +00:00
Guy Harris 0b9234c3a3 Fix a typo.
svn path=/trunk/; revision=6821
2002-12-29 01:25:01 +00:00
Guy Harris fac9a235d7 "&magic" is a "guint32 *", so adding a byte count to it points that
number of *32-bit words* into the magic number, not that number of
*bytes* into the magic number; cast it to "char *" before adding the
byte count.

svn path=/trunk/; revision=6820
2002-12-29 01:19:08 +00:00
Guy Harris 462a1b80b4 Correctly compute the minutes portion of the elapsed time.
svn path=/trunk/; revision=6797
2002-12-18 06:44:50 +00:00
Guy Harris 22496138e9 Add a capture routine for IP-over-FC, and call it from the capture code.
svn path=/trunk/; revision=6767
2002-12-08 22:35:30 +00:00
Guy Harris 926a65f2f0 Suppress compiler warnings on platforms where "time_t" is a "long",
without introducing warnings where it's an "int".

svn path=/trunk/; revision=6459
2002-10-19 07:52:12 +00:00
Guy Harris b99f379f55 From Ulf Lamping: show total running time of capture in capture progress
dialog box.

svn path=/trunk/; revision=6440
2002-10-16 23:34:52 +00:00
Guy Harris 63d65a3f69 From Ulf Lamping: count ARP packets in capture progress dialog box.
svn path=/trunk/; revision=6416
2002-10-14 17:33:50 +00:00
Guy Harris 2dcc8ee1fc From Ulf Lamping: keep "Update list of packets in real time" from
crashing on Windows.

svn path=/trunk/; revision=6387
2002-10-09 08:18:37 +00:00
Gerald Combs 18061d6537 From Graeme Hewson:
It can sometimes happen that capturing is stopped just after Ethereal
  has switched to a new ring buffer.  The result is that no frames
  are displayed.  The patch to ringbuffer.c displays the previous ring
  buffer if the current buffer is empty on close.

  The patch to capture.c fixes a bug where an error return from
  ringbuf_wtap_dump_close was ignored, and tidies up the code around
  the call.

svn path=/trunk/; revision=6315
2002-09-22 16:17:41 +00:00
Guy Harris 5e8ecbaf46 From Graeme Hewson:
Currently Ethereal sets and uses a default directory for reading
	and writing, but only in some places.  This set of patches extends
	the setting of the default directory to the -w option as well as
	the -r option, and causes all file dialogs to use and set the
	default consistently.  (I haven't changed the
	Preferences/Printing/File dialog, though, as that's a special
	case.)

	There's also a fix for a bug where Ethereal was issuing the
	message "Ring buffer requested, but capture isn't being saved to
	a permanent file" even though a file was specified with -w.

There also appear to be some other cleanups in his patch.

svn path=/trunk/; revision=6238
2002-09-09 20:39:01 +00:00
Jörg Mayer 7c4176d868 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=6117
2002-08-28 21:04:11 +00:00
Guy Harris da901e7434 Not all compilers allow labels that don't have a statement following
them.  Put a "break;" statement after a case label that didn't have it.

svn path=/trunk/; revision=5990
2002-08-13 18:12:11 +00:00
Jörg Mayer 173fe5aef4 Replace the types from sys/types.h and netinet/in.h by their glib.h
equivalents for the toplevel directory. The removal of winsock2.h will
hopefully not cause any problems under MSVC++, as those files using
struct timeval still include wtap.h, which still includes winsock2.h.

svn path=/trunk/; revision=5932
2002-08-02 23:36:07 +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 41dc7b1b59 From Graeme Hewson:
In sync mode, if the capture file written by the child can't be
	opened by the parent, ethereal will write two identical popup
	error messages.

	This patch fixes the problem.

svn path=/trunk/; revision=5883
2002-07-16 05:43:39 +00:00
Guy Harris a77d6a14c2 Update the "NT sucks for PPP capture" note to include NT 5.1 (XP and
.NET Server).

Fix indentation.

svn path=/trunk/; revision=5882
2002-07-15 23:25:59 +00:00
Guy Harris 900c9f0ffc On Windows, there's no "pipe_fd", so don't refer to it.
svn path=/trunk/; revision=5734
2002-06-22 10:21:00 +00:00
Guy Harris afa5eefe49 From Graeme Hewson: fix capture-from-pipe not to block when reading from
the pipe, and clean up various other things.

svn path=/trunk/; revision=5670
2002-06-13 21:23:02 +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 1eadf370cd Just have "pcap_dispatch()" cons up a "strut pcap_pkthdr" and call
"capture_pcap_cb()", so it duplicates even less of the latter routine.

svn path=/trunk/; revision=5648
2002-06-07 11:12:43 +00:00
Guy Harris 748c6566f9 Have a common routine for doing the packet counter stuff, rather than
having two different versions, both broken in different ways.

Bump the count of total packets in the capture-from-pipe routine.

svn path=/trunk/; revision=5647
2002-06-07 10:54:03 +00:00
Guy Harris b53c02b4ef Pass the captured length, not the full length, to the "capture_"
routines.

Call the 802.11 and Cisco HDLC capture routines for those packet types.

svn path=/trunk/; revision=5646
2002-06-07 10:36:57 +00:00
Guy Harris 358df4f2f4 From Michael Tuexen: remove the old workaround for "select()"s not
working on MacOS X.

It appears that the underlying problem with the timeout was that we
weren't treating MacOS X as a BSD, and the "select()" we were doing
presumably wasn't working as it doesn't work on BPF devices on many
BSDs; the workaround no longer appears to be necessary, with Michael's
fix to treat MacOS X as BSD.

(Presumably a select timeout with "tv_usec" set to 1000*1000
microseconds was treated as an error, or otherwise treated in such a way
that it didn't block waiting for the BPF device to say it could be
read.)

svn path=/trunk/; revision=5637
2002-06-06 19:03:39 +00:00
Guy Harris 2dbb4324e3 From Michael Tuexen: treat Darwin/MacOS X like the other BSDs, as its
BPF, in at least some OS versions, acts like the other BPFs in some
versions of other BSDs, and doesn't work with "select()".

svn path=/trunk/; revision=5620
2002-06-04 22:15:12 +00:00
Guy Harris bc5a543e03 From Graeme Hewson:
This fixes some bugs:

	1. With the -S option under Linux, Capture/Stop or ^E was
	ignored until the next packet was read.  This is because
	capture.c wasn't checking for EINTR from select(), which is
	returned when the child receives SIGUSR1 from the parent.

	2. When reading from a pipe, a spurious error message from
	pcap_open_live() was written to stderr.

	3. Error messages from the child in Sync mode were displayed in
	a Warning alert box.

	Also, there's a new subroutine, popup_errmsg(), to replace
	several instances of duplicate code.

svn path=/trunk/; revision=5616
2002-06-04 11:19:59 +00:00
Guy Harris 6da70104fa From Joerg Mayer: get rid of some unused arguments, and mark others as
unused.

Put in a comment to note that if we fail to open the interface either as
a device or as a pipe, we report the error from the failed
"pcap_open_live()" (which explains why "pipe_open_live()" doesn't return
an error string).

svn path=/trunk/; revision=5381
2002-05-04 09:11:28 +00:00
Guy Harris 8a5d5f9bde From Joerg Mayer: get rid of extra arguments to capture routines.
svn path=/trunk/; revision=5233
2002-04-24 06:03:34 +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 541c654ff0 Put all the capture options into a structure.
Move the ringbuffer capture options from the "capture_file" structure to
the structure for capture options, as they're a property of an
in-progress capture, not a property of a particular capture file.

svn path=/trunk/; revision=4799
2002-02-24 09:25:36 +00:00
Guy Harris 8bd63530ed "autostop_filesize" and "autostop_duration" don't need to be in the
"capture_file" structure - they're a property of an in-progress capture,
not a property of an open capture file.  Make them just variables.

The maximum number of packets to be captured should be a variable
separate from the "count" field in the "capture_file" structure - the
latter is a count of the packets in the capture file in question.

Have Boolean variables indicating whether a maximum packet count,
maximum capture file size, and maximum capture duration were specified.
If an option isn't set, and we're doing an "update list of packets in
real time" capture, don't pass the option to the child process with a
command-line argument.

Don't create "stop when the capture file reaches this size" or "stop
when the capture's run for this long" conditions if a maximum capture
file size or a maximum capture duration, respectively, haven't been
specified.  Don't test or free a condition if it wasn't created.

Don't allow a 0 argument to the "-c" flag - the absence of a "-c" flag
is the way you specify "no limit on the number of packets".

Initialize the check boxes and spin buttons for the "maximum packets to
capture", "maximum capture size", and "maximum capture duration" options
to the values they had in the last capture.  If an option wasn't
specified, don't read its value from the dialog box and set the
variable.

svn path=/trunk/; revision=4795
2002-02-24 03:33:05 +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
Guy Harris ee5ca25d31 Include files from the "epan" directory and subdirectories thereof with
"epan/..." pathnames, so as to avoid collisions with header files in any
of the directories in which we look (e.g., "proto.h", as some other
package has its own "proto.h" file which it installs in the top-level
include directory).

Don't add "-I" flags to search "epan", as that's no longer necessary
(and we want includes of "epan" headers to fail if the "epan/" is left
out, so that we don't re-introduce includes lacking "epan/").

svn path=/trunk/; revision=4586
2002-01-21 07:37:49 +00:00
Guy Harris b3f81eb30c Separate the promiscuous mode, "Update list of packets in real time",
and "Automatic scrolling in live capture" options from the preference
settings for them, so that the preference settings affect the initial
values of those options, but changing those values in a capture don't
affect the preferences, and don't automatically get saved when you save
the preferences.

If we're building without libpcap, don't have an "Automatic scrolling in
live capture" option anywhere.

svn path=/trunk/; revision=4514
2002-01-10 11:05:50 +00:00
Guy Harris 12d566c0ac Add a routine to kill a capture child if it exists, so that if we exit
(by deleting the main window or selecting File->Quit or typing ^Q) while
an "Update list of packets in real time" capture is in progress, we can
abort the capture.

Arrange that "fork_child" is -1 when there is no capture child, so said
routine knows when it can kill the child.

When we exit, kill off any capture child, using that routine, and, if
we're exiting due to a request to delete the main window and, if a read
is in progress (from an "Update list of packets in real time" capture),
don't delete the main window - just set the "Read aborted" flag, so that
the code doing the read will see that flag (it will be called because
the pipe to the capture child is closed due to the child exiting) will
see that and clean up and exit itself.

svn path=/trunk/; revision=4498
2002-01-08 09:32:15 +00:00
Guy Harris 9588f37fac As per Michael Tuexen's suggestion, set the libpcap open timeout to 1
second rather than 1/4 second on MacOS X, to workaround what appears to
be a MacOS BPF bug.

svn path=/trunk/; revision=4473
2002-01-04 06:27:42 +00:00
Guy Harris b1f4093d1a Make the "go" member of the "loop_data" structure in Ethereal a
"gboolean", as it's a Boolean value, and move it to the beginning of the
structure in Tethereal, as it is in Ethereal.

From Graeme Hewson:

	Check for "pcap_dispatch()" returning -1, meaning an error
	occurred; if it does, stop capturing, and report the error.

	If we get a signal in tethereal, stop the capture with a
	"longjmp()", rather than by clearning the "go" flag;
	"pcap_dispatch()", on many platforms, keeps reading rather than
	returning a captured packet count of 0 if the system call to
	read packets returns -1 with an errno of EINTR, so the
	"pcap_dispatch()" won't be broken out of if the signal handler
	returns.

	Fix a typo in an error message.

svn path=/trunk/; revision=4471
2002-01-03 22:03:24 +00:00
Guy Harris 8032fa8a1b Make the bytes-written information from Wiretap a long, as we allow
files to get that big.

From Thomas Wittwer and Matthias Nyffenegger:

Support for "ring buffer mode", wherein there's a ring buffer of N
capture files; as each capture file reaches its maximum size (the ring
buffer works only with a maximum capture file size specified), Ethereal
rolls over to the next capture file in the ring buffer, replacing
whatever packets might be in it with new packets.

svn path=/trunk/; revision=4323
2001-12-04 08:26:00 +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 2f10c7f630 Get rid of the "len" and "captured_len" members of the "packet_info"
structure; they're no longer used.

svn path=/trunk/; revision=4236
2001-11-20 22:29:07 +00:00
Guy Harris e8d4f4f0ac Make the capture routines take an additional argument giving the amount
of packet data captured.

Make the "BYTES_ARE_IN_FRAME()" macro take a "captured length of the
packet" argument.

Add some length checks to capture routines.

svn path=/trunk/; revision=4235
2001-11-20 21:59:18 +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
Gilbert Ramirez 6de396c4a8 Fix the rest of the signed/unsigned comparison warnings.
svn path=/trunk/; revision=4088
2001-10-26 18:28:17 +00:00
Guy Harris 456a121f2a Use "g_warning" to print warning messages from "pcap_open_live()", as
that should cause it to show up in a console window if run from Ethereal
on Windows.

svn path=/trunk/; revision=4075
2001-10-25 08:06:15 +00:00
Guy Harris 8a96e8c675 Handle "pcap_open_live()" succeeding but returning a warning; print the
warning before the capture starts.

svn path=/trunk/; revision=4074
2001-10-25 06:41:48 +00:00
Guy Harris b9222c0011 Various signed vs. unsigned fixes, from Joerg Mayer.
svn path=/trunk/; revision=3560
2001-06-18 01:49:17 +00:00
Guy Harris cb1260ab9f If the capture child process sends the parent an error message with a
byte count of zero, don't bother allocating a buffer for that message,
as we wouldn't do anything with that buffer.

Null-terminate the error message once we read it, before using it as a
string.

svn path=/trunk/; revision=3551
2001-06-15 01:36:46 +00:00
Guy Harris 2851b7ef76 Enable "Match Selected" only if there's a field selected *and* we can do
a "Match Selected" on it - we can't do a "Match Selected" if the field
has no value (e.g., FT_NULL) and has a length of 0.

If we unselect the current packet, we don't have a protocol tree, so we
don't have a currently selected field - clear the "Match Selected" menu
item and the display in the status line of information about the
currently selected field.

Move the low-level statusbar manipulation into "gtk/main.c", in routines
whose API doesn't expose anything GTK+-ish.

"close_cap_file()" calls one of those routines to clear out the status
bar, so it doesn't need to take a pointer to the statusbar widget as an
argument.

"clear_tree_and_hex_views()" is purely a display-manipulating routine;
move it to "gtk/proto_draw.c".

Extract from "tree_view_unselect_row_cb()" an "unselect_field()" routine
to do all the work that needs to be done if the currently selected
protocol tree row is unselected, and call it if the currently selected
packet list row is unselected (if it's unselected, there *is* no
protocol tree, so no row can be selected), as well as from
"tree_view_unselect_row_cb()".

Before pushing a new field-description message onto the statusbar, pop
the old one off.

Get rid of an unused variable (set, but not used).

svn path=/trunk/; revision=3513
2001-06-05 07:39:31 +00:00
Guy Harris b699efc451 Changes to structure initializations not to initialize some but not all
members, from Joerg Mayer.

svn path=/trunk/; revision=3501
2001-06-02 06:26:54 +00:00
Guy Harris bdb69627b2 "prefs.capture_real_time", not "prefs.capture_auto_scroll", should
control whether we have a child process do the capturing; a user might
want the packet list to be updated as packets arrive but *not* want it
to scroll so that the most recently arrived packets are shown.

"prefs.capture_auto_scroll", not "auto_scroll_live", should control
whether we scroll a real-time-update capture's packet list;
"auto_scroll_live" isn't set by the capture dialog box,
"prefs_capture_auto_scroll" is.

svn path=/trunk/; revision=3388
2001-05-01 00:18:48 +00:00
Jeff Foster 78ce39994c Added the ethereal capture preferences to the preference file.
svn path=/trunk/; revision=3298
2001-04-13 14:59:30 +00:00
Guy Harris 094dc29f19 The Software Porting And Archive Centre for HP-UX now has libpcap 0.6.2
binaries, so users only need to make sure they have that version
installed in order to have Ethereal (and tcpdump, and snort, and so on)
accept "lanN"-style names (i.e., names of the sort reported by lanscan
and handled by ifconfig), rather than "dlpiN".

Get rid of the patches to update libpcap, get rid of the discussion in
"README.hpux" of patching libpcap and just say "get 0.6.2", and make the
notes on HP-UX kernel patches to fix problems with capturing outgoing
packets a separate item in the list of items in "README.hpux".

Also update the error messages Ethereal and Tethereal display if they
can't open a device and the error is "can't find PPA for XXX" to say
"get 0.6.2" rather than "patch libpcap and recompile.

svn path=/trunk/; revision=3288
2001-04-11 05:24:08 +00:00
Guy Harris c4979d817a WinPcap 2.1 allows you to capture on Token Ring, so remove the note
about Token Ring in the "sorry, we couldn't open the capture device"
dialog box on Windows.

svn path=/trunk/; revision=3257
2001-04-04 23:40:23 +00:00
Guy Harris a65579287d Call the capture routine for PPP-in-HDLC-like-framing (RFC 1662) the
"ppp_hdlc" capture routine.

svn path=/trunk/; revision=3209
2001-03-30 06:15:47 +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 4dee072069 Rename "SP_ERROR" to "SP_ERROR_MSG" to avoid a #define collision with
yet another Windows #define.

svn path=/trunk/; revision=3034
2001-02-14 09:40:20 +00:00
Guy Harris cb1f3a8093 In an "Update list of packets in real time" capture, pass the number of
dropped packets from the child to the parent.

svn path=/trunk/; revision=3019
2001-02-11 22:46:27 +00:00
Guy Harris 56875e0937 Change the protocol between the parent and child processes in an "Update
list of packets in real time" capture so that "!" always indicates an
error, with the "!" preceded by a count of characters in the error
message and followed by the text of the error, and so that those error
messages can be sent after the capture has started.

Use that to report capture errors, and errors writing to the capture
file, while the capture is under way.

Use #defines for the message type characters in that protocol.

svn path=/trunk/; revision=3018
2001-02-11 22:36:57 +00:00
Guy Harris 35a14714c0 Report failures of "pcap_stats()", as tcpdump does.
Print the "Capturing on <interface>" message, the running count of
packets captured, and error messages to the standard error in Tethereal,
so that you can pipe the output of a live capture that's printing
packets to a program or script without that script having to worry about
parsing stuff other than dissected packet summaries or details (tcpdump
does the same).

svn path=/trunk/; revision=3017
2001-02-11 21:29:03 +00:00
Guy Harris bf0a3a32d1 In Ethereal, attempt to get the packet statistics from libpcap when
capturing; if we succeed, display the packet drops count as the "Drops"
value in the status line and as the "Dropped packets" statistics in the
summary dialog box, otherwise don't display it at all.

In Tethereal, attempt to get the packet statistics from libpcap when
capturing; if we succeed, and if there were any dropped packets, print
out the count of dropped packets when the capture finishes.

svn path=/trunk/; revision=3016
2001-02-11 09:28:17 +00:00
Guy Harris 261f3f1a6c Check for errors when writing a capture file.
Report errors when writing or closing a capture file.

Clean up some I/O error messages.

svn path=/trunk/; revision=3011
2001-02-10 09:08:14 +00:00
Guy Harris 00fcdc0900 There's no need for a member of a "capture_file" structure holding a
compiled capture filter program, so remove it, and remove the include of
<pcap.h> from "file.h"; instead, have local "struct bpf_program"
structures where needed, and have those files that need stuff from
<pcap.h> include it.

This cleans stuff up a bit, and should eliminate a pile of compile
warnings with Visual C++ due to <pcap.h> and some GTK+/GLib header file
(or files they include) both defining "inline".

svn path=/trunk/; revision=2954
2001-01-28 23:56:29 +00:00
Gilbert Ramirez 73b6dadd24 Actually call capture_sll() from the capture loop.
svn path=/trunk/; revision=2889
2001-01-13 03:17:15 +00:00
Guy Harris 035e9caa22 Don't do the "select()" in the capture codepath on Win32; it's not
necessary, and won't necessarily work.

svn path=/trunk/; revision=2846
2001-01-09 00:53:26 +00:00
Guy Harris 4f5e161fe2 It turns out that the read timeout in Solaris's "bufmod" STREAMS module
doesn't work like the read timeout in BPF - the timer doesn't start
until at least one packet has arrived.

I think that's the way read timeouts should work on *all* packet capture
mechanisms, but it does mean that Solaris will, on a quiet net, exhibit
the same symptoms that Linux used to exhibit before we put in a
"select()" call to wait until either packets arrive or a timer expires -
the "pcap_dispatch()" call blocks until a packet arrives, so the display
doesn't get updated and Ethereal doesn't respond to user input until a
packet arrives.

Furthermore, Linux isn't the only OS that lacks any read timeout
on its packet capture mechanism; the others will also have that problem.

We therefore do the "select()" on *all* platforms other than the BSDs
(where the timer starts when the read is done, and can be used for
polling); I don't know whether it's necessary on Digital UNIX, but I
suspect it's necessary on SunOS 4.x (as the 5.x "bufmod" is probably
derived from the 4.x one, and the 5.x one, as per the above, starts the
timer when a packet arrives), and it may even be necessary on 3.x, those
(BSD, SunOS including 5.x, and Digital UNIX) apparently being the only
UNIXes that appear to have such a read timeout.

svn path=/trunk/; revision=2790
2000-12-28 01:44:19 +00:00
Guy Harris f6782c1ebe If the capture child process exits unexpectedly, give more information
on it, such as the exit status if it exited "normally" but unexpectedly.

On UNIX systems, #define the various POSIX <sys/wait.h> macros (and the
non-POSIX WCOREDUMP()" macro) if they're not defined by <sys/wait.h> (or
if we don't have <sys/wait.h>), and use them to dissect the exit status.

svn path=/trunk/; revision=2788
2000-12-27 22:35:48 +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
Guy Harris e023b751c0 Instead of failing if we can't find a netmask for the interface on which
we're capturing, just use a netmask of 0, and warn the user in Tethereal
(doing it in Ethereal would be more disruptive, and doing so only once
per interface in a session is a bit of work, as, in an "Update list of
packets in real time" capture the child process would have to tell the
parent that it couldn't get the netmask).

svn path=/trunk/; revision=2546
2000-11-01 07:38:54 +00:00
Guy Harris 1a2bc366bb Capture statistics box improvements from Santeri Paavolainen.
svn path=/trunk/; revision=2521
2000-10-21 04:20:07 +00:00
Guy Harris 54ecbe2d4e Santeri Paavolainen's patch to add a "Capture->Stop" menu item to let
you stop an "Update list of packets in real time" capture from the main
window as well as from the capture statistics dialog.

svn path=/trunk/; revision=2487
2000-10-11 06:01:16 +00:00
Gerald Combs e61373a7c1 Change addresses from ethereal.zing.org to www.ethereal.com.
svn path=/trunk/; revision=2481
2000-10-08 17:16:29 +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 d0caa40dec libpcap unconditionally includes <net/if.h> on UNIX systems, as that is,
as far as I know, the only way to get IFF_UP, IFF_LOOPBACK, "struct
ifreq", and "struct ifconf" defined, and those are required in order to
get, via SIOCGIFCONF, the interface list, and to exclude interfaces that
aren't up and handle loopback interfaces differently from other
interfaces.

If we're on UNIX and have libpcap, we should do the same; that way, if
the system doesn't have <net/if.h> installed, the compile will fail with
an "I can't find <net/if.h>" error, rather than the configure indicating
that <net/if.h> can't be found, causing "util.c" not to include it,
causing it to fail with complaints about IFF_UP, IFF_LOOPBACK, and
various structures not being defined - the former tells you the root
cause, the latter doesn't.

svn path=/trunk/; revision=2442
2000-09-17 03:20:05 +00:00
Guy Harris 00b4224ee0 Add a "-p" command-line option, and a checkbox in the "Capture
Preferences" dialog box, to control whether to put the interface in
promiscuous mode or not; Debian bug #34376 asked for this.

svn path=/trunk/; revision=2439
2000-09-15 05:32:49 +00:00
Graham Bloice f30b84ce23 Corrected startup // shutdown of windows sockets to allow name resolution to work
svn path=/trunk/; revision=2438
2000-09-14 22:59:08 +00:00
Gilbert Ramirez ca78ae622c Change #include "wtap-int.h" to #include "wtap.h"
svn path=/trunk/; revision=2434
2000-09-14 11:49:40 +00:00
Guy Harris 064936053c Given that DLT_ values and libpcap appear to mutate almost as fast as
the influenza virus, if "wtap_pcap_encap_to_wtap_encap()" returns
WTAP_ENCAP_UNKNOWN, indicating that the libpcap encapsulation type can't
be mapped to a Wiretap encapsulation type, include the data link type in
the message, so the user can at least give us a clue as to what type it
is that we don't support (or, at least, the DLT_ value for that type -
it could well be some standard type whose value just got gratuitously
changed).

svn path=/trunk/; revision=2333
2000-08-22 06:04:40 +00:00
Guy Harris e697eb8e9f Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.

On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.

Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use.  Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.

If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.

svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
Laurent Deniel 8bc95e98e4 Fix potential buffer overflows.
svn path=/trunk/; revision=2298
2000-08-19 18:20:59 +00:00
Guy Harris 364ec7fa05 PPP/WAN captures work on Windows 9x, so speak of them not working only
on NT/2000.

Refer to Tethereal, not to Ethereal, in the long explanations of capture
problems in Tethereal.

svn path=/trunk/; revision=2270
2000-08-14 08:36:41 +00:00
Guy Harris 1c910d808a On Win32, if the attempt to open the capture device fails, don't talk
about checking permissions, as the capture devices are probably
available to all users, and talking about permissions will only confuse
the user.  Do, however, warn that Ethereal can't capture on Token Ring
or PPP/WAN interfaces.

On UNIX, if the attempt to open the capture device fails, and the error
message starts with "can't find PPA for ", they are probably running on
HP-UX with a version of libpcap not patched to properly look up PPAs for
network interfaces given the interface name; give them a detailed
warning about this, telling them that they'll have to fix libpcap and
build Ethereal from source, and pointing them at the "README.hpux" file.

svn path=/trunk/; revision=2265
2000-08-13 08:17:03 +00:00
Laurent Deniel 6a480953a9 Miscellaneous code cleaning
- add <stdarg.h> or <varargs.h> in snprintf.h
  and remove those inclusions in the other #ifdef NEED_SNPRINTF_H codes

- remove the check of multiple inclusions in source (.c)  code
  (there is a bit loss of _cpp_ performance, but I prefer the gain of
   code reading and maintenance; and nowadays, disk caches and VM are
   correctly optimized ;-).

- protect all (well almost) header files against multiple inclusions

- add header (i.e. GPL license) in some include files

- reorganize a bit the way header files are included:

  First:
  #include <system_include_files>
  #include <external_package_include_files (e.g. gtk, glib etc.)>
  Then
  #include "ethereal_include_files"

  with the correct HAVE_XXX or NEED_XXX protections.

- add some HAVE_XXX checks before including some system header files

- add the same HAVE_XXX in wiretap as in ethereal

Please forgive me, if I break something (I've only compiled and regression
tested on Linux).

svn path=/trunk/; revision=2254
2000-08-11 13:37:21 +00:00
Guy Harris d8b8ee50a0 Fix it to compile on non-Linux UNIX-flavored systems and Win32 systems.
svn path=/trunk/; revision=2184
2000-07-31 04:03:31 +00:00
Olivier Abad 00492ede72 Add missing function prototypes.
svn path=/trunk/; revision=2182
2000-07-30 16:59:07 +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
Gilbert Ramirez e88d4d3a30 Get rid of "Playback" in capture window title.
svn path=/trunk/; revision=2150
2000-07-21 15:56:15 +00:00
Guy Harris 024c2d72fe Use ESD_TYPE_CRIT for most errors (the model used by various GUIs seems
to use "warning" dialog boxes only to warn the user "if you do that, bad
things may happen" *and* to offer them the option either to drive on or
quit, so perhaps ESD_TYPE_CRIT should be used for all errors).

However, put "Ethereal: Error" rather than "Ethereal: Critical" in the
title bar, in the hopes that it'll make it clearer that Something Bad
Happened.

If the user specifies that captures should be saved to a user-specified
file rather than a temporary file, report errors trying to create that
file with "file_open_error_message()".

Make the "for_writing" argument to "file_open_error_message()" a
"gboolean", as it's either TRUE (if the file is being opened for
writing) or FALSE (if it's being opened for reading).

Report EISDIR as "XXX is a directory (folder), not a file.".

svn path=/trunk/; revision=2143
2000-07-20 05:10:02 +00:00
Guy Harris 36d85ce33c To make windows modal, use "gtk_window_set_modal()" rather than
"gtk_grab_add()"; the former makes it a bit clearer what's being done,
and I think it may be considered the right way to do it (GTK+ remembers
the state of the window and appears to add and remove the grab as
appropriate).

svn path=/trunk/; revision=2113
2000-07-05 02:52:39 +00:00
Guy Harris 7843ac6d0e Add routines to Wiretap to allow a client of Wiretap to get:
a pointer to the "wtap_pkthdr" structure for an open capture
	file;

	a pointer to the "wtap_pseudo_header" union for an open capture
	file;

	a pointer to the packet buffer for an open capture file;

so that a program using "wtap_read()" in a loop can get at those items.

Keep, in a "capture_file" structure, an indicator of whether:

	no file is open;

	a file is open, and being read;

	a file is open, and is being read, but the user tried to quit
	out of reading the file (e.g., by doing "File/Quit");

	a file is open, and has been completely read.

Abort if we try to close a capture that's being read if the user hasn't
tried to quit out of the read.

Have "File/Quit" check if a file is being read; if so, just set the
state indicator to "user tried to quit out of it", so that the code
reading the file can do what's appropriate to clean up, rather than
closing the file out from under that code and causing crashes.

Have "read_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
close the capture and return an indication that the read was aborted by
the user.  Otherwise, return an indication of whether the read
completely succeeded or failed in the middle (and, if it failed, return
the error code through a pointer).

Have "continue_tail_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
quit the loop, and after the loop finishes (even if it read no packets),
return an indication that the read was aborted by the user if that
happened.  Otherwise, return an indication of whether the read
completely succeeded or failed in the middle (and, if it failed, return
the error code through a pointer).

Have "finish_tail_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
quit the loop, and after the loop finishes (even if it read no packets),
close the capture and return an indication that the read was aborted by
the user if that happened.  Otherwise, return an indication of whether
the read completely succeeded or failed in the middle (and, if it
failed, return the error code through a pointer).

Have their callers check whether the read was aborted or not and, if it
was, bail out in the appropriate fashion (exit if it's reading a file
specified by "-r" on the command line; exit the main loop if it's
reading a file specified with File->Open; kill the capture child if it's
"continue_tail_cap_file()"; exit the main loop if it's
"finish_tail_cap_file()".

svn path=/trunk/; revision=2095
2000-06-27 07:13:42 +00:00
Guy Harris 7fbf320b8a Patch from Ben Fowler to rename the global variable "cf" to "cfile", to
make it easier to use grep to find all references to it without getting
a lot of false hits and to check, after allocating the memory chunk for
"frame_data" structures, that the allocation succeeded.

svn path=/trunk/; revision=2092
2000-06-27 04:36:03 +00:00
Guy Harris f3eddb46cc Changes from Graham Bloice to support "Update list of packets in real
time" during captures on Win32.

svn path=/trunk/; revision=2074
2000-06-15 08:02:43 +00:00
Guy Harris 7250d49c49 Mark Clayton's patch to add support for capturing on ATM interfaces on
Linux (call the until-now-unused "capture_clip()" routine for each
packet).

svn path=/trunk/; revision=2070
2000-06-15 04:23:06 +00:00
Guy Harris 41f7100539 Support for SCTP in the capture dialog, from Michael Tuexen.
svn path=/trunk/; revision=2012
2000-05-26 22:08:16 +00:00
Gilbert Ramirez 40c5ed378f Convert dissect_ppp() and friends to use tvbuffs.
(the ip_tcp_options stuff is still non-tvbuff until I convert ip and tcp).

Add preliminary fix for Linux ISDN ippp devices (similar watch was posted
to ethereal-users, but did not use tvbuffs).

Change packet-raw.c to call capture_ppp()/dissect_ppp() in the case
where the frame starts with FF:03. We had been calling
capture_ip()/dissect_ip() at byte offset 4, but I think this is for
historical reasons of packet-raw.c and packet-ip.c existing before
packet-ppp.c.

svn path=/trunk/; revision=1998
2000-05-25 07:42:26 +00:00
Guy Harris 586e1b6fca Move the closes of the save file FD around:
"capture()" should ensure that it's closed before returning, but
	it was only getting closed by "wtap_dump_close()" on success, so
	close the raw FD on failure (no "wtap_dump" stream is opened on
	failure, so we just close the raw FD);

	in a "update the display as packets arrive" capture, we should
	close the FD in the parent as soon as the fork is done, before
	even testing whether the fork succeeded (and we might as well do
	the same with the write side of the sync pipe).

svn path=/trunk/; revision=1988
2000-05-19 22:37:57 +00:00
Gilbert Ramirez 14d71d8986 Close capture file descriptor.
From Mark Burton <markb@ordern.com>

svn path=/trunk/; revision=1986
2000-05-19 19:53:48 +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 2f4c852318 Check whether "pipe()" succeeds, and pop up a message box and quit if it
doesn't.

svn path=/trunk/; revision=1912
2000-05-06 07:07:27 +00:00
Guy Harris 826e964d81 If the attempt to execute Ethereal in a child process fails, have the
child process send to the parent a message indicating why it failed, so
that the parent can report that, and then exit.

If the attempt to create the child process to run Ethereal fails, pop up
a dialog box indicating that this happened.

Change the fork code a bit, to make it easier to substitute, on Win32
systems, code that does a "CreateProcess()" for the small chunk of code
that does the fork and exec.

svn path=/trunk/; revision=1910
2000-05-06 05:08:39 +00:00
Guy Harris f6b5d7b8b5 Paul Welchinski's changes to, on Win32 systems:
properly handle ASCII vs. Unicode in the list of interfaces;

	initialize Winsock before starting a capture, so that the code
	in the Win32 libpcap to get the IP address and netmask by
	translating the host name to an IP address works.

svn path=/trunk/; revision=1737
2000-03-21 06:52:13 +00:00
Olivier Abad 44a7c1ec31 Used register_init_routine() to register "reinit_x25_hashtable()" as a
routine to be called every time a new capture file is opened instead of
calling it in read_cap_file() and do_capture().

svn path=/trunk/; revision=1651
2000-02-19 14:00:35 +00:00
Olivier Abad bb2454e8bd Renamed init_dissect_x25() to reinit_x25_hashtable() and actually used it !
This function is used to re-initialize the hash table used by the X.25
dissector to record the upper layer protocol used by each VC. The hash
table should be re-initialized each time we read / start a new capture.

I moved the definition of the function from packet.h to packet-x25.h, and
added calls to reinit_x25_hashtable() in read_cap_file (file.c) and
do_capture (capture.c).

svn path=/trunk/; revision=1644
2000-02-18 13:41:26 +00:00
Gilbert Ramirez ddfa11e870 Create a header file for every packet-*.c file. Prune the packet.h file.
This change allows you to add a new packet-*.c file and not cause a
recompilation of everything that #include's packet.h

Add the plugin_api.[ch] files ot the plugins/Makefile.am packaging list.

Add #define YY_NO_UNPUT 1 to the lex source so that the yyunput symbol
is not defined, squelching a compiler complaint when compiling the generated
C file.

svn path=/trunk/; revision=1637
2000-02-15 21:06:58 +00:00
Gilbert Ramirez f9a8a11ef5 Integrate Ed Meaney's <emeaney@altiga.com> changes for using libpcap
from WinDump with Ethereal. We now have packet capturing on Win32. :)

svn path=/trunk/; revision=1612
2000-02-09 19:18:42 +00:00
Gilbert Ramirez 16fbabe46f Also listen for GDK_INPUT_EXCEPTION on the sync pipe. On Solaris 2.6
this is needed to get the last message from the pipe.

svn path=/trunk/; revision=1595
2000-02-02 18:38:52 +00:00
Nathan Neulinger f44e0c9b9d added support for clicking capture window's close box to stop capture
svn path=/trunk/; revision=1586
2000-01-30 17:10:29 +00:00
Guy Harris ba520e3c93 In case the "ts" field of a libpcap per-packet header isn't a "struct
timeval" (if, say, it's a "struct bpf_timeval", with member sizes wired
to 32 bits, as it appears to be in SuSE 6.3 and will, I think, be in the
0.5 release of libpcap), copy the members of that field to the "ts"
field of the Wiretap per-packet header (which also lets us make it not a
"struct timeval" as well).

svn path=/trunk/; revision=1572
2000-01-26 23:09:21 +00:00
Guy Harris 2461d79698 In "dissect_eth()", update "pi.len" and "pi.captured_len" regardless of
whether we're building a protocol tree or not.

Make "dissect_eth()" use "BYTES_ARE_IN_FRAME()" to see if we have a full
Ethernet header - it can be called with a non-zero offset, if Ethernet
frames are encapsulated inside other frames (e.g., ATM LANE).

Make capture routines take an "offset" argument if the corresponding
dissect routine takes one (for symmetry, and for Cisco ISL or any other
protocol that encapsulates Ethernet or Token-Ring frames inside other
frames).

Pass the frame lengths to capture routines via the "pi" structure,
rather than as an in-line argument, so that they can macros such as
"BYTES_ARE_IN_FRAME()" the way the corresponding dissect routines do.

Make capture routines update "pi.len" and "pi.captured_len" the same way
the corresponding diseect routines do, if the capture routines then call
other capture routines.

Make "capture_vlan()" count as "other" frames that are too short, the
way other capture routines do.

svn path=/trunk/; revision=1525
2000-01-23 08:55:37 +00:00