Commit Graph

93 Commits

Author SHA1 Message Date
Balint Reczey 98d79569e0 From Rob Leslie <rob@mars.org>:
[PATCH] Fix dumpcap believing error on ^C i.e. pcap_breakloop()
When ^C was pressed during a packet capture, dumpcap believed a pcap
error had occurred.  We check the return value more closely to avoid
this problem.

svn path=/trunk/; revision=29510
2009-08-22 22:49:59 +00:00
Gerald Combs e0ebc32195 Updates to create_tempfile:
- Use g_get_tmp_dir, just like get_tempfile_path.
  - Don't make the caller worry about the path buffer length.

svn path=/trunk/; revision=28915
2009-07-01 23:36:51 +00:00
Gerald Combs 59a767f0b2 Unfortunately, r28452 seems to cause more problems than it fixes. Back
out the change for now.

svn path=/trunk/; revision=28852
2009-06-26 21:25:09 +00:00
Balint Reczey 1f8c72ff25 Set SIGPIPE handler every time the program starts.
This hopefully fixes bug 1740.

svn path=/trunk/; revision=28549
2009-05-31 18:38:28 +00:00
Gerald Combs f7f2a08def From Benjamin Tse via bug 2200:
I've created a new bug rather than reopening 1181 as the scope is constrained
somewhat more.

Basically, when capturing from a named pipe the wireshark display lags by one
packet. This is especially frustrating when the packets arrive at low rates.

tshark is fine. But the packet count in dumpcap also lags by one.

Looking at the code, the problem appears to be in cap_pipe_select(). It
attempts to use WaitForSingleObject() on the named pipe but AFAICT this never
blocks.

I've attached a diff for some code that fixes the issue for me. The semantics
of overlapped IO in Win32 is quite different from the select/read model - hence
the other changes!

I've tested this fix on WinXP, 2k server and 2003 server. I've also checked
that my changes compile on a Freespire box that I have lying around.


From me:

Adapt the changes for dumpcap, which is where the affected code now lives.

svn path=/trunk/; revision=28452
2009-05-22 19:52:30 +00:00
Michael Tüxen 6de58c28f0 Add -n option to dumpcap. It will save the capture files in
pcapng format instead of pcap. The default is to use pcap.

svn path=/trunk/; revision=28170
2009-04-27 08:11:10 +00:00
Michael Tüxen f5547c0d78 Make ringbuffer.[ch] file format agnostic.
Move write routines to dumpcap.c
This is a preparation for pcapng support.

svn path=/trunk/; revision=28155
2009-04-26 15:51:25 +00:00
Gerald Combs e648060f0f Fix the last(?) of the Win64 compilation problems.
svn path=/trunk/; revision=28065
2009-04-16 04:05:39 +00:00
Bill Meier 013db77404 Use wireshark (instead of ether) for temp file name prefix.
svn path=/trunk/; revision=27992
2009-04-08 12:22:12 +00:00
Jaap Keuter 69463d1fd0 From Toralf Förster:
Small cleanup of preprocessor logic.

svn path=/trunk/; revision=27212
2009-01-11 18:16:50 +00:00
Jaap Keuter da34ecd34a From Ronald W. Henderson:
dumpcap should terminate if exactly the maximum number of packets have been captured 
(or greater) as specified by the user: "-c <capture packet count>". The current behavior 
waits until an additional packet is captured until this threshold check occurs.

svn path=/trunk/; revision=27208
2009-01-11 12:26:32 +00:00
Balint Reczey 4942a20da4 From Pavol Rusnak (bug 1740):
Set SA_RESTART flag when setting SIGPIPE handler.

svn path=/trunk/; revision=26851
2008-11-26 12:54:39 +00:00
Stig Bjørlykke 32d411be1d Do not set buffer size for remote interfaces or when using default value.
Do not get link-layer for remote interfaces.

svn path=/trunk/; revision=26683
2008-11-03 21:38:53 +00:00
Stig Bjørlykke 841e3a0a3f Fixed some "ignoring return value" warnings.
This is the last commit to make it compile clean on Ubuntu 8.10.

svn path=/trunk/; revision=26654
2008-10-31 17:43:51 +00:00
Balint Reczey c2ce5dcbf6 Based on patch from Sergio Barjola:
Enable the default action for SIGPIPE
This fixes bug 2888 and 1740

svn path=/trunk/; revision=26621
2008-10-30 11:48:13 +00:00
Guy Harris e8ba2515de The packet counts and drop counts reported by libpcap are unsigned.
Clean up indentation a bit.

svn path=/trunk/; revision=26037
2008-08-19 05:10:16 +00:00
Gerald Combs cb3022d098 If we can't open open an interface in Windows, instead of talking about
specific issues (one of which no longer applies), point the user at the 
wiki.

svn path=/trunk/; revision=25833
2008-07-25 22:29:02 +00:00
Jeff Morriss 83f9ecf96f Move privileges.c and unicode-utils.c from epan to wsutil (so things like
capinfos and dumpcap don't need to depend on libwireshark nor directly pull
in those modules).  Because capinfos and editcap were only being linked with
privileges.c if we had plugins, this allows those programs to be linked when
someone is compiling --without-plugins.

svn path=/trunk/; revision=25640
2008-06-30 17:16:29 +00:00
Guy Harris f8b7863753 Fix some references to the global loop_data structure that weren't
changed in the previous checkin.

svn path=/trunk/; revision=25573
2008-06-24 03:33:51 +00:00
Guy Harris 802d9abf4f Rename the global "ld" structure to "global_ld", to avoid collisions
with the "ld" pointer argument (and to point out that it's a global
variable).

svn path=/trunk/; revision=25554
2008-06-23 21:22:11 +00:00
Guy Harris ee78dbb925 Get rid of the static capture_opts pointer - it collides with parameter
names, as noted by John Smith.

svn path=/trunk/; revision=25542
2008-06-23 20:21:46 +00:00
Guy Harris e731e24b51 capture_opts_print_statistics() has nothing to do with capture options
setting, and is used only in dumpcap.c, and needs to get at information
set by dumpcap's signal handlers so it can respond to ^C; move it to
dumpcap.c, rename it print_statistics_loop(), and make it set ld.go to
TRUE before looping and loop only as long as ld.go is TRUE.

That fixes bug 2592 (at least on Mac OS X, and probably on other UN*Xes;
it should fix it on Windows as well).

svn path=/trunk/; revision=25492
2008-06-20 00:09:47 +00:00
Anders Broman 36d89bb79c Fix some of the Errors/warnings detected by checkapi.
svn path=/trunk/; revision=25368
2008-05-23 05:55:34 +00:00
Jeff Morriss a5cee04fad Move the file utility functions from wiretap to libwsutil so that
libwireshark (and the plugins using those functions) do not depend on
wiretap on Windows.

While doing that, rename the eth_* functions to ws_*.

svn path=/trunk/; revision=25354
2008-05-22 15:46:27 +00:00
Bill Meier 398e06e875 Fix a few typos.
svn path=/trunk/; revision=24724
2008-03-24 18:32:15 +00:00
Gerald Combs ec74de5957 dumpcap.c: Fix a typo.
INSTALL: Add entries for libcap.

svn path=/trunk/; revision=24722
2008-03-24 16:22:30 +00:00
Bill Meier e843df87f6 Fix (aka workaround) for bug #2228.
Essentially: if using libcap, drop capabilities
after doing pcap_open_live. 
See comment in main() for details.

svn path=/trunk/; revision=24716
2008-03-22 19:04:26 +00:00
Gerald Combs c288c1ae05 Don't call cap_set_proc() unless we were started with elevated
privileges.  Otherwise, we might print

dumpcap: cap_set_proc() fail return: Operation not permitted

to stderr.

svn path=/trunk/; revision=24704
2008-03-20 19:18:33 +00:00
Bill Meier 2c07da3195 Fix for handling dumpcap errmsgs when wireshark does 'dumpcap -D -M', etc
svn path=/trunk/; revision=24507
2008-02-29 18:48:29 +00:00
Jeff Morriss 404c087195 Use plain old strcmp() instead of g_ascii_strcasecmp() when searching for -Z.
On glib-1.2 systems g_ascii_strcasecmp() is in libwireshark (which we don't
want to include in dumpcap) and anyway our code should be the only thing
calling dumpcap with "-Z"--so hopefully there's no need for doing a
case-insensitive comparison.

(This is another argument for adding a "utils" library.)

svn path=/trunk/; revision=24462
2008-02-25 20:43:03 +00:00
Bill Meier 8d4f01eea7 Ensure tshark/wireshark always get good err msgs from dumpcap:
1. Clean up dumpcap 'as a child' err msg handling so that:
   - all err msgs are properly formatted when being sent 
     back to the parent.
   - any log Critical, Warning, etc messages
     are sent back to parent and are properly formatted.
2. Change handling of -w <...> slightly in capture_opts.c
   so that wireshark provides a good error message if
   there is a 'write permissions' issue on the file.
   (Previously the error popup said only 
   "Child exited with status 2").
   This fixes bug #2288.

Add some conditionalized DEBUG_CHILD_DUMPCAP code for
   dumpcap debug logging to a file.

svn path=/trunk/; revision=24446
2008-02-23 19:59:38 +00:00
Guy Harris 8d8800f3e9 dumpcap doesn't need stuff declared in capture.h; it just needs what's
declared in capture_opts.h.

svn path=/trunk/; revision=24352
2008-02-16 08:44:33 +00:00
Guy Harris 7eac554d02 One include of epan/unicode-utils.h suffices - and the routines it
declares are called only on Windows.

svn path=/trunk/; revision=24351
2008-02-16 08:38:23 +00:00
Guy Harris 7aa5f3f1ad Directly call capture_loop_packet_cb(), rather than making a pointer to
the callback function part of the loop_data structure - we always call
capture_loop_packet_cb().

svn path=/trunk/; revision=24350
2008-02-16 08:09:56 +00:00
Guy Harris 95f3802ae9 If we don't have libcap, relinquish special privileges just after
opening the capture device.  That somewhat fixes bug 2273, although the
second and subsequent files don't have the right group ownership,
probably because of the problem described in the comment before
relinquish_special_privs_perm().

We should also relinquish special privileges *before* trying to open the
capture pipe, so that we can't open a pipe to which the real user
doesn't have access.

svn path=/trunk/; revision=24347
2008-02-16 03:18:36 +00:00
Guy Harris 4aac1e2c0b Pull capture_loop.c into dumpcap.c, as dumpcap is the only program that
does capturing any more.  (We will be inserting a call to give up
privileges after the pcap_open_live(), which should fix 2273; we're
currently only giving up privileges on platforms with libcap.)

svn path=/trunk/; revision=24345
2008-02-16 02:39:58 +00:00
Bill Meier 8f6398d5ba Fix typo in help text
svn path=/trunk/; revision=24148
2008-01-20 23:12:12 +00:00
Tomas Kukosa 08bbd29c71 Support for RPCAP features in GUI (from Boris Misenov, see Bug 1366)
- retrieving the list of remote PCAP interfaces
  - password authentication support
  - UDP data fransfer
  - packet sampling (available in WinPcap 4.x)
  etc.

fix problem if non-default rpcap port is used

svn path=/trunk/; revision=23750
2007-12-04 11:19:29 +00:00
Bill Meier bfc4f6d466 Rename Windows ConsoleCtrHandlerRoutine --> capture_cleanup to match SVN #23537 change
svn path=/trunk/; revision=23540
2007-11-22 00:33:22 +00:00
Guy Harris d722f061f4 Catch SIGINT, SIGHUP, and SIGTERM on UN*X, so we cleanly exit if, for
example, we're ^C'ed.  This should fix bug 2003.

svn path=/trunk/; revision=23538
2007-11-21 22:49:02 +00:00
Gerald Combs 58914b5248 If libcap is present, have dumpcap use it to drop privileges while
retaining CAP_NET_ADMIN and CAP_NET_RAW.  Update some Makefile
dependencies for dumpcap.

svn path=/trunk/; revision=23511
2007-11-20 16:53:01 +00:00
Gerald Combs 8f05294027 For the Wireshark/TShark -> dumpcap signal pipe on Windows, use a named
pipe instead of stdin.  Add an argument (currently the parent PID) back
to the "-Z" flag and use it to construct the pipe name.  This lets us
pass the parent's stdin handle to dumpcap, which lets us capture from
stdin on Windows.  Add a comment about checking for the parent process.

In capture_loop.c, remove the wait_forever argument from cap_pipe_select()
since it was always FALSE.  Set the timeout under Windows to 250 ms
instead of 250000 ms.

svn path=/trunk/; revision=23279
2007-10-26 16:32:28 +00:00
Guy Harris e8ea45d6ed Make the sync pipe the standard error, not the standard output, of
dumpcap, when using it as a capture child; leave the standard output
alone, in case tshark was told to write the capture to the standard
error.

Get rid of the argument to the "-Z" option to dumpcap; it might not work
on Windows.

svn path=/trunk/; revision=23124
2007-10-10 01:31:36 +00:00
Guy Harris 61e8c424b3 "get_compiled_version_info()" appends to the string text starting with
"with", so we shouldn't put our own "with" in there.

svn path=/trunk/; revision=23037
2007-09-30 22:34:15 +00:00
Guy Harris 322d44d416 Make the "-Z" argument to dumpcap take an argument that's the file
descriptor to use as the sync pipe.  For now, always pass 1, so the sync
pipe is the standard output of dumpcap.

svn path=/trunk/; revision=23025
2007-09-29 01:36:03 +00:00
Guy Harris 6d065e2eb2 Don't hardcode the notion that the sync pipe is the standard output into
sync_pipe_errmsg_to_parent(); have it take the FD for the sync pipe as
an argument.

svn path=/trunk/; revision=23024
2007-09-29 01:15:11 +00:00
Guy Harris 72eed77ed7 We don't use NetSNMP any more.
svn path=/trunk/; revision=23022
2007-09-29 01:01:02 +00:00
Gerald Combs 89a2966ced Add a "-S" flag to dumpcap, which prints out interface statistics. Use
this in the GUI rather than calling pcap_stats() directly. This gets rid
of the last pcap_open_live() call in the GUI code. Update
README.packaging.

svn path=/trunk/; revision=22443
2007-08-02 21:45:27 +00:00
Gerald Combs c02e0c7b4a Remove the "-I" flag from dumpcap, and add a "-M" flag used to specify
that "-D" and "-L" should produce machine-readable output.  Use this to
move an indirect get_pcap_linktype() call from the GUI to dumpcap.

svn path=/trunk/; revision=22367
2007-07-20 21:43:07 +00:00
Gerald Combs e9f1a0b692 One more step in privilege separation.
Add a capture_interface_list(), which works similar to
get_interface_list() except that it forks dumpcap instead of calling
the pcap routines directly.  Use it in the GUI.

Add a "-I" flag to dumpcap, which prints out verbose interface
information.

Tested under Windows and Linux.

svn path=/trunk/; revision=22071
2007-06-11 03:58:58 +00:00