Commit Graph

93 Commits

Author SHA1 Message Date
Guy Harris a28b428aff Go back to setting the capture filter to an empty string when we start;
that obviates the need to check for a null capture filter string, and
fixes bug 1055.

Keep track of whether it was set from the command line, though, so we
can catch attempts to set the filter more than once, and attempts to set
it when we're not capturing.

Clean up white space.

svn path=/trunk/; revision=19047
2006-08-26 18:36:09 +00:00
Guy Harris fde1140905 Initialize the cfilter field of a capture_opts structure to a null
pointer, so we can determine whether a capture filter has been set or
not.

Use that to check in TShark whether the user specified a filter with
"-f" or not, rather than using the no-longer-set
"capture_filter_specified" variable.

Also, check for multiple "-f" options.

If no capture filter is specified, use a null string, to work around
broken versions of Linux libpcap.

svn path=/trunk/; revision=18989
2006-08-21 23:28:19 +00:00
Guy Harris 6b61f890fe Explicitly note that a "Please report this to the Wireshark developers"
is *NOT* a crash; if Wireshark had crashed, it couldn't have put up that
dialog.  (Yes, at least one bug report calls it a crash; see Ethereal
bug 1006 at http://bugs.ethereal.com/bugzilla/show_bug.cgi?id=1006.)

svn path=/trunk/; revision=18628
2006-07-01 02:22:28 +00:00
Gerald Combs 8958bab6de Tethereal/tethereal -> TShark/tshark.
svn path=/trunk/; revision=18268
2006-05-31 17:38:42 +00:00
Anders Broman f68d6e4c8c Ethereal->Wireshark
svn path=/trunk/; revision=18235
2006-05-28 20:28:20 +00:00
Ronnie Sahlberg 6075ec39fb ethereal->wireshark
svn path=/trunk/; revision=18207
2006-05-22 08:21:22 +00:00
Guy Harris a79553b3af Fix the only gerald@ethereal.com references left.
svn path=/trunk/; revision=18203
2006-05-21 21:52:33 +00:00
Guy Harris aa1e053ce6 If we have pcap_breakloop(), at least on UN*X we can stop the capture
with a pcap_breakloop() call - we don't need to call select() before
calling pcap_dispatch().

Even if we do need to call select(), we don't need to supply it with a
timeout - it's OK if we block indefinitely, as the signal will interrupt
select().

That also means we can pass -1 as the count to pcap_dispatch(), as
pcap_breakloop() will terminate the loop in pcap_dispatch().

Use sigaction() to catch SIGUSR1, so we can make sure that the signal
handler doesn't get reset when the signal is delivered, and that system
calls don't restart when we return from the signal handler.

svn path=/trunk/; revision=18201
2006-05-21 21:32:04 +00:00
Guy Harris 58a0b10698 The timeout is needed if you don't have pcap_breakloop(), so we'll put
it back for now; I'll fix it later not to do the timeout if we have
pcap_breakloop().

svn path=/trunk/; revision=18195
2006-05-20 23:18:44 +00:00
Guy Harris 37a570600e Dumpcap doesn't need to ensure that it doesn't block indefinitely, as it
has no UI, nor does it need to ensure it processes only one packet at a
time; get rid of the select stuff, and pass a count of -1 to
pcap_dispatch() so it processes a single bufferfull of packets rather
than just one packet at a time.

svn path=/trunk/; revision=18194
2006-05-20 22:01:08 +00:00
Guy Harris 25e8c37489 Have the ring buffer routines take a pointer to a "bytes written" count
as an argument, rather than keeping the count to themselves, so the
count kept by the capturing program can be updated correctly - including
getting reset when files are switched.  Fixes bug 895.

svn path=/trunk/; revision=18032
2006-04-29 17:54:46 +00:00
Guy Harris d260003026 Put the low-level sync routines into a common file so they can be shared
by dumpcap and Ethereal (so that, on UN*X, the child process can report
a detailed "can't exec dumpcap" error).

Rename most of the "sync_pipe_XXX_to_parent()" routines, as they're also
in Tethereal, which doesn't have a sync pipe.

svn path=/trunk/; revision=17789
2006-04-03 01:56:53 +00:00
Guy Harris 2de9620eea In Tethereal, don't save to a temporary file if "-w" isn't specified,
even if doing a live capture; just print the packets without saving
them.

In dumpcap:

	default to the capturing the entire packet;

	don't do the "Press any key" stuff when debugging on UN*X;

	do console logging (to the standard error) even when we're
	running as the capture child (the sync pipe should only be the
	standard output, not the standard error).

svn path=/trunk/; revision=17786
2006-04-03 00:52:59 +00:00
Ulf Lamping f8d7cbf654 remove some XXX markers in comments which are no (longer) ToDo items
svn path=/trunk/; revision=17715
2006-03-24 02:40:59 +00:00
Guy Harris 0129bb146c Simplify the argument list to cap_pipe_dispatch().
svn path=/trunk/; revision=17690
2006-03-21 09:36:07 +00:00
Ulf Lamping 069b26b2d9 fix bug #803: sync pipe on Win32 wasn't set to binary mode, so error message transport failed between Ethereal and dumpcap.
I've also changed the way the secondary error message is transported from former "header message 0 secondary 0" to "header header message 0 header secondary 0" as that might be a bit more clearer, and I'll need it for further development anyway.

I was using this while debugging and not recognizing the real problem - for about four hours :-(. I'll need this feature when doing the interface (and link layer type) browsing later (transferring this data from dumpcap to Ethereal) to get a full blown privilege seperation.

svn path=/trunk/; revision=17608
2006-03-13 00:30:51 +00:00
Ulf Lamping ecc7e43f2c fix two bugs causing crashes on Win32:
- fix buggy g_snprintf call (Win32 fails if %s is called with a NULL pointer)
- don't call file close if file wasn't open before (Win32 crashes if eth_unlink is called with a NULL pointer)

svn path=/trunk/; revision=17558
2006-03-09 22:06:25 +00:00
Guy Harris 949c591a9d Add in a variable we need on Windows.
svn path=/trunk/; revision=17469
2006-03-05 04:17:07 +00:00
Guy Harris 6f5916eb36 In the capture_loop.c code, open the capture device for input before
doing anything with the output file, so that

	1) if the attempt to open the capture device fails, we don't
	   bother creating any output files;

	2) we could relinquish privileges permanently as soon as we
	   finish opening the capture device, so we don't have to give
	   them up temporarily when opening the output file, reclaim
	   them to open the input device, and then give them up
	   permanently;

(we already do that in Tethereal).

While we're at it, set the capture filter immediately after opening the
capture device, so we quit before opening capture devices if that fails.

svn path=/trunk/; revision=17468
2006-03-05 04:11:57 +00:00
Guy Harris 49de5e663e Make some routines not used outside capture_loop.c static.
svn path=/trunk/; revision=17466
2006-03-05 03:26:21 +00:00
Guy Harris cbe69401cc Pass two strings in capture child messages, so the child can send
primary and secondary error messages and let the parent worry about how
to display them.  This means dumpcap doesn't need stub routines for
generating the formatting tags for the primary and secondary messages.

Have a separate message for capture filter errors, so that the parent
can check whether the capture filter looks like a display filter and
report the appropriate message.  This means that dumpcap doesn't need a
stub routine for compiling display filters (a stub routine also means
that Ethereal won't do the check for capture filters that look like
display filters!).

svn path=/trunk/; revision=17465
2006-03-05 03:14:16 +00:00
Guy Harris e6886d90ce When capturing, we only support writing to libpcap files. Given that,
bypass Wiretap; that means we don't have to run the packet through
wtap_process_pcap_packet() and then undo that conversion in Wiretap if
we're just going to write it out, shortening the code path.

svn path=/trunk/; revision=17461
2006-03-04 22:33:04 +00:00
Ulf Lamping 79053183c5 remove dependencies to pcap.h, so getting an idea what needs to be done by dumpcap in addition to the things already done now
various dumpcap related code cleanup: mainly #include's and capture engine related stuff

svn path=/trunk/; revision=17327
2006-02-17 02:18:48 +00:00
Guy Harris 4d8d477018 Move create_tempfile() to tempfile.c out of util.c. This means dumpcap
no longer needs util.c, so it no longer includes routines that use
host_ip_af(), so it no longer needs to define its own host_ip_af().

That also means dumpcap.c no longer needs to include <sys/socket.h>.

svn path=/trunk/; revision=17278
2006-02-12 21:52:18 +00:00
Ulf Lamping 4d81998607 mark an unused parameter
svn path=/trunk/; revision=17263
2006-02-12 01:38:02 +00:00
Ulf Lamping cf94760fa4 the point of no return ...
using dumpcap as the capture child for Ethereal.

dumpcap is a plain console application now, even for Win32 (so no WinMain, create_console and special piping stuff reguired). The undocumented command line option -Z will switch dumpcap into "child mode", using binary instead of plain text output messages to communicate with a parent Ethereal.

Ethereal's main.c no longer needs to distinguish between child mode or not, so some simplifying here.

capture_sync.c has to call dumpcap in a "hidden window" mode using CreateProcess instead of spawnvp, otherwise an uggly console window would appear. The handles created by _pipe doesn't seem to be inheritable for this function, using CreatePipe instead.

The file capture_loop.c is only needed by dumpcap, removed from Ethereal link objects.

Some debugging aid added and other minor cleanup done.

svn path=/trunk/; revision=17256
2006-02-11 23:25:11 +00:00
Ulf Lamping 15f9051029 move output_to_pipe flag from tethereal's loop_data into capture_opts, so it can be used by dumpcap (capture_loop.c) as well
svn path=/trunk/; revision=16972
2006-01-07 01:29:45 +00:00
Ulf Lamping 161d4d7efd code cleanup: use "-" for all places, where stdin/stdout is meant
tethereal internally converted the stdout capture filename "-" into "" which doesn't make any real sense and only complicated things.

To make things even more confusing, wiretap expected "" for dump output and "-" for offline reading ...

svn path=/trunk/; revision=16962
2006-01-06 01:06:46 +00:00
Guy Harris d0a1b97ee7 Handle a null-string file name in "capture_loop_open_output()" - that's
what indicates that we're supposed to write to the standard output
(Tethereal turns "-" into "").

svn path=/trunk/; revision=16941
2006-01-04 02:50:56 +00:00
Ulf Lamping ad692841a8 Ooops, remove a debug message in the Win32 code part of the capturing loop.
It might (very slightly) slow down capturing in the 0.10.14 release :-(

svn path=/trunk/; revision=16923
2005-12-31 10:48:29 +00:00
Ulf Lamping cee67cb78b Win32 bugfix: peeking the signal_pipe at capture_loop start seems to be unreliable
Instead, simply keep the signal_pipe setting directly from the command line which is working well

svn path=/trunk/; revision=16833
2005-12-17 00:19:47 +00:00
Guy Harris eaee2b68c5 Constify a bunch of arguments and variables, to squelch compiler
warnings.

Include "wiretap/libpcap.h" in "capture_loop.h", to get its declarations
of data structures for headers in libpcap files.  This lets us remove
the includes of "wiretap/libpcap.h from files including
"capture_loop.h".

Make "log_func_ignore()" in "tethereal.c" static, and declare some of
its arguments unused.  Also get rid of an unused variable.

Include <pcap.h> before including "wiretap/wtap-capture.h", to declare
"struct pcap_pkthdr".

svn path=/trunk/; revision=16791
2005-12-14 07:29:38 +00:00
Ulf Lamping 79217bab2e HUGE STEP (hopefully toward the right direction):
remove a lot of redundant code from tethereal and use (move) stuff from capture_loop.c instead.

concentrate common capture related code in capture_opts.c, e.g. trying to find the right interface to capture from (command line option, preference, first usable) instead of duplicating this code over several files.

remove redundant code from dumpcap.c

this also implements command line option -D (and indexed interfaces at -i) for Ethereal and Dumpcap (as we have it in Tethereal already for a while)

svn path=/trunk/; revision=16787
2005-12-13 22:48:58 +00:00
Ulf Lamping 7e3a24418c rename pcap-....c/.h files to capture-pcap-....c/.h
this way, the capture prefix will "logically" group the files together and file browsers will also group them

we may want to move the files into a subdir capture later

svn path=/trunk/; revision=16691
2005-12-06 00:07:13 +00:00
Ulf Lamping 56f1f421bd I've forgot to put one line under _WIN32, should fix the unix build
svn path=/trunk/; revision=16679
2005-12-05 02:30:04 +00:00
Ulf Lamping 61c8c42aef Win32: fix signal_pipe handling if we run dumpcap as a standalone application (no signal_pipe)
svn path=/trunk/; revision=16677
2005-12-05 01:23:18 +00:00
Ulf Lamping e829856c0c move the complete functionality of the capture info dialog from capture_loop.c to capture_info.c and call it from capture.c (instead of capture_loop.c).
This way, the capture child don't need to now any of the packet_counter things (no epan/packet.h and all alike).

Currently the capture_info code will always open another wiretap file instance to build it's own counter values. This isn't optimized for now (next step: use data from cf_continue_tail() somehow).

svn path=/trunk/; revision=16669
2005-12-04 02:04:18 +00:00
Ulf Lamping f856dbafa8 split some parts of the packet counting functions into their own files capture_info(.c/.h),
so we can use it from the main program

svn path=/trunk/; revision=16668
2005-12-03 22:38:50 +00:00
Ulf Lamping d2a024af60 split capture.h into capture.h, capture_loop.h and capture_opts.h and place the parts into the corresponding files
svn path=/trunk/; revision=16664
2005-12-03 19:32:54 +00:00
Ulf Lamping 6674e5bf12 the function capture_loop_popup_errmsg seems to be useless and misleading,
simply call sync_pipe_errmsg_to_parent directly instead

svn path=/trunk/; revision=16662
2005-12-03 12:56:57 +00:00
Ulf Lamping c85fb9fcb4 performance improvement: if the packet info dialog is hidden, we don't need to call the capture_... packet count functions
svn path=/trunk/; revision=16647
2005-12-02 09:24:55 +00:00
Ulf Lamping 61dc6ad226 dumpcap.c doesn't need to link with file.c!
this fortunately removes *a lot* of dependencies and make the resulting binary a lot smaller (and hopefully faster to load :-)

some more cleanup (like replacing // by /**/)

svn path=/trunk/; revision=16620
2005-11-28 20:51:27 +00:00
Ulf Lamping fc61a1de25 first steps towards a separated capture tool, working title "dumpcap"
personal backup only, not meant for public testing!

I've copied main.c into dumpcap.c and carved out all things not needed

currently won't work as a command line tool, capture_loop.c wants an input pipe
console output is also very ugly and the whole code needs a lot of further cleanup

shouldn't break the unix build as I've only changed the nmake files so far, but who knows ...

svn path=/trunk/; revision=16615
2005-11-28 08:54:52 +00:00
Ulf Lamping 03b4388fe0 rephrase the error dialog if an interface couldn't be opened.
made the CaptureSetup wiki page more prominent
added some "headings" so some of the help subtopics are easier for "human grep" IMHO

svn path=/trunk/; revision=16592
2005-11-25 22:38:02 +00:00
Guy Harris b7407b5a2a Fix a typo.
svn path=/trunk/; revision=16408
2005-11-07 02:38:34 +00:00
Ulf Lamping c3187174bf replace *a lot* of file related calls by their GLib counterparts. This is necessary for the switch to GTK 2.6 (at least on WIN32).
to do this, I've added file_util.h to wiretap (would file_compat.h be a better name?), and provide compat_macros like eth_open() instead of open(). While at it, move other file related things there, like #include <io.h>, definition of O_BINARY and alike, so it's all in one place.

deleted related things from config.h.win32

As of these massive changes, I'm almost certain that this will break the Unix build. I'll keep an eye on the buildbot so hopefully everything is working again soon.

svn path=/trunk/; revision=16403
2005-11-06 22:43:25 +00:00
Guy Harris dfb65a4db6 Make capture filter (and capture filter error message) strings "safe" as
necessary before putting them into an error message dialog.  Fixes bug
564.

svn path=/trunk/; revision=16365
2005-10-30 20:16:01 +00:00
Ulf Lamping 4443681a9e fix Ethereal so command line capture parameter will work with kilobytes (again)
remove Byte(s) from the dropdown list of filesizes, this doesn't make sense
replace 1000 with 1024, as all (modern?) file managers are based on 1024 bytes for a kilobyte (the old KB vs. KiB controversy)

svn path=/trunk/; revision=16149
2005-10-07 03:34:27 +00:00
Ulf Lamping 70d4979557 bugfix: reset the packet counter to zero, if switching to the next "multiple file". This fixes the live update of the packet output after switching to another capture file
svn path=/trunk/; revision=16135
2005-10-06 00:28:36 +00:00
Guy Harris 9e96a03e18 Add a note about 64-bit support in WinPcap to the capture errors on
Windows, and add the URL for the CaptureSetup page to the Tethereal
error.

svn path=/trunk/; revision=16103
2005-10-04 04:23:09 +00:00