Commit Graph

146 Commits

Author SHA1 Message Date
Guy Harris 80fda10f18 Make -q not a capture option again - it's used by tshark even when not
capturing, and thus even when we build without pcap.

svn path=/trunk/; revision=32988
2010-05-27 01:13:49 +00:00
Guy Harris b0bfae2a85 Don't send ^T output to the standard error if we're a capture child.
Make SIGINFO a restart-the-system-call signal, so reads etc. don't
return an error.

svn path=/trunk/; revision=32968
2010-05-26 04:29:36 +00:00
Guy Harris 7a630c61a1 Add a -q flag to dumpcap, to squelch its reporting of the packet count,
and add support for SIGINFO, so, if your OS supports SIGINFO, you can
get the packet count by typing ^T.

svn path=/trunk/; revision=32958
2010-05-26 00:19:27 +00:00
Guy Harris 71de391514 Pull the big pile of code that handles the
capture-stopping/file-switching operation into a routine.  Move a few
variables into the loop_data structure so that routine can get at them.

svn path=/trunk/; revision=32949
2010-05-25 20:14:22 +00:00
Guy Harris 72ed0558f2 Don't have -M affect -v yet; if we end up, for example, having dumpcap
being the only program that needs to be linked with *pcap, that's when
we'd want to fetch that information, but there might be other libraries
(e.g., the POSIX capabilities library) that it might be linked with but
that programs that use it aren't linked with.

Don't commit to the output formats of -M, as they are, as noted, subject
to change from release to release.

svn path=/trunk/; revision=32904
2010-05-19 23:27:35 +00:00
Guy Harris c1e651802e -S doesn't require an interface, either.
svn path=/trunk/; revision=32883
2010-05-19 02:55:05 +00:00
Guy Harris ccac912244 Regularize indentation a bit.
Let pcap_statustostr()'s result suffice for most PCAP_ERROR_ errors. 
Don't mention the capture device name multiple times in the error
message.  Treat positive returns from pcap_can_set_rfmon() other than 0
or 1 as weird returns, not error returns.

svn path=/trunk/; revision=32882
2010-05-19 02:47:16 +00:00
Guy Harris ece9788353 Squelch an unused-variable warning.
svn path=/trunk/; revision=32856
2010-05-18 03:35:20 +00:00
Guy Harris 0910d319cd Move some routines around, fix and shuffle comments.
svn path=/trunk/; revision=32854
2010-05-18 02:48:51 +00:00
Guy Harris 1bf60839c9 Move get_pcap_linktype() into dumpcap - it's not used elsewhere.
svn path=/trunk/; revision=32853
2010-05-18 02:36:02 +00:00
Guy Harris c58680fd40 Only negative return values from pcap_activate() are errors; positive
return values are success-with-a-warning.

Report those errors with a string.

svn path=/trunk/; revision=32852
2010-05-18 01:48:46 +00:00
Guy Harris e3038273ca Don't write the SP_SUCCESS messages unless -Z was specified.
Add support for a machine-readable "-v" output, which prints only the
pcap version string.

Give a little more information about the machine-readable format, but
note that it's primarily intended for consumption by Wireshark and
TShark and is subject to change.

Properly hyphenate "pcap-ng".

svn path=/trunk/; revision=32851
2010-05-18 00:20:30 +00:00
Guy Harris 14c40a21aa Make -Z always generate machine-readable output, and don't bother
supplying -M along with -Z.  (We keep -M around for debugging use; it's
documented, unlike -Z.)

svn path=/trunk/; revision=32850
2010-05-17 23:56:00 +00:00
Guy Harris 859c6e4d3e If dumpcap is run with -D, don't select a default interface; it's not
necessary.

If it's run with -D and -M, and we found no interfaces, don't treat that
as an error; let the code that reads our output just indicate it as "no
interfaces available", so *its* caller can decide whether to report an
error or not (in some cases in Wireshark, it's obvious that there are no
interfaces, e.g. there aren't any listed on the welcome screen, so
popping up a dialog is pointless).

svn path=/trunk/; revision=32849
2010-05-17 23:13:24 +00:00
Guy Harris 991c5e9898 When dumpcap is run to get an interface list, interface capabilities, or
interface statistics, have its error messages come out as sync-pipe
errors, have it send a sync-pipe "success" message on success, and have
the callers get that message and display it.

svn path=/trunk/; revision=32843
2010-05-17 18:40:23 +00:00
Guy Harris 9307251bb8 Um, no, the problem with the Leopard x86 build is that we first do a
build without libpcap, to make sure that works, and then do a build with
libpcap, to put into a binary release.  It's the former that's failing;
I'll back out the previous change and then work on that.

svn path=/trunk/; revision=32801
2010-05-14 00:49:28 +00:00
Guy Harris 0e54136213 See whether the Leopard x86 buildbot is upset because of the name
if_capabilities_t - it doesn't fail on Snow Leopard, even if I undefine
HAVE_PCAP_CREATE, and doesn't fail on the Leopard PPC buildbot, either.

svn path=/trunk/; revision=32799
2010-05-14 00:10:15 +00:00
Guy Harris 1c18115bd3 Fetch an indication of whether the interface supports capturing in
monitor mode at the same time that we fetch its list of link-layer
types.  Support fetching that list in monitor mode, as the list may be
different in regular and monitor mode.  If the interface supports
monitor mode, when printing the list of link-layer types, indicate
whether they're fetched in monitor mode or not, as tcpdump 4.1.x does.

svn path=/trunk/; revision=32789
2010-05-13 17:37:39 +00:00
Guy Harris 5be9fa156f If we have pcap_open(), and we're *not* opening an rpcap URL, open the
device, don't just execute whatever comes after the open code as an else
clause.

svn path=/trunk/; revision=32761
2010-05-11 20:19:35 +00:00
Guy Harris 55dc4be5ba Include inet_v6defs.h after include the Windows socket headers, so it
knows whether AF_INET6 is needed.

svn path=/trunk/; revision=32722
2010-05-08 01:37:36 +00:00
Guy Harris 3debd13524 Include inet_v6defs.h if needed to declare inet_ntop().
svn path=/trunk/; revision=32720
2010-05-08 01:15:56 +00:00
Guy Harris 547b9e48a2 The default capture buffer size is, in fact, *nominally* 1MB; however,
libpcap/WinPcap and the capture mechanism atop which they run might
either silently limit the buffer size to a smaller value or raise it to
a higher value - that's the part that's platform-dependent.

svn path=/trunk/; revision=32718
2010-05-08 00:39:07 +00:00
Guy Harris 077ff72ac1 As with the list of data link types, so with the list of interfaces; move
the code to print the machine-readable format into dumpcap, and have the
code in capture_opts.c just print the human-readable format.

svn path=/trunk/; revision=32714
2010-05-07 19:24:32 +00:00
Guy Harris 13bf4a0c55 Add routines vfprintf_stderr() and fprintf_stderr() to print to the
standard error and, in Wireshark on Windows, create a console if
necessary.  Have the cmdarg_err routines use them.

Use *fprintf_stderr() to print the output of -L, rather than using
cmdarg_err_cont(), so that we don't get extra newlines in the output (it
should look similar to the output of tcpdump).

svn path=/trunk/; revision=32711
2010-05-07 08:40:02 +00:00
Guy Harris cc05b9250d For TShark and Wireshark, get the list of link-layer types for an
interface by running dumpcap, so that if you need privileges to open an
interface, and dumpcap has those privileges, neither TShark nor
Wireshark need them.

svn path=/trunk/; revision=32710
2010-05-07 08:06:25 +00:00
Guy Harris 4cd5e44340 Oops, -B disappeared from the list of dumpcap options in the change to
support multiple, err, optional options.

svn path=/trunk/; revision=32705
2010-05-07 01:50:22 +00:00
Guy Harris 20cbf81d39 Beginnings of monitor mode support with libpcap 1.x.
svn path=/trunk/; revision=32702
2010-05-07 01:22:33 +00:00
Guy Harris 4c5b8c5277 Instead, say that the default is platform-dependent.
svn path=/trunk/; revision=32701
2010-05-07 00:28:42 +00:00
Guy Harris 96f67d9517 Now that we support -B on various UN*X platforms as well as Windows, we
can no longer state what the default is (it's platform-dependent).

svn path=/trunk/; revision=32700
2010-05-07 00:16:52 +00:00
Guy Harris 7dbbb8c572 Just check for pcap_create(); it first appeared in libpcap 1.0.0, and
pcap_set_buffer_size() did as well, so there aren't any libpcap releases
with pcap_create() but not pcap_set_buffer_size().

Only do one check for pcap_create.

svn path=/trunk/; revision=32695
2010-05-06 23:33:41 +00:00
Gerald Combs 6ee96dc4a4 Fix compilation.
svn path=/trunk/; revision=32694
2010-05-06 23:29:55 +00:00
Anders Broman f9981411f1 Checking in Stigs changes from
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=475
BUT not activating the check for 
pcap_create()
pcap_set_buffer_size()
This should make it possible to build with support for setting the buffersize if not capturing 802.11 traffic.

The code for handling the 'B' option should be OK in any case.

svn path=/trunk/; revision=32688
2010-05-06 18:34:30 +00:00
Gerald Combs f2a66480df Revert r31529. Timing out while waiting for the pcap file header causes
more problems than it solves.

svn path=/trunk/; revision=32544
2010-04-23 17:22:51 +00:00
Guy Harris 7b41a72801 Expand the comment explaining the workaround for the Snow Leopard
timeout bug.

Make the code for the workaround assume any 10.6.x release other than
10.6.2 requires it; that way we don't have to update the code until
either

	1) Apple fixes the bug in a later 10.6.x update

or

	2) Apple comes out with a major release that still has, or
	   reintroduces, the bug.

svn path=/trunk/; revision=32349
2010-04-01 00:27:25 +00:00
Michael Tüxen d87005b114 Enable pcap timeout workaround for Mac OS X 10.6.3, since the bug seems to be
back.

svn path=/trunk/; revision=32348
2010-03-31 23:37:42 +00:00
Guy Harris 2b321eaf56 From Hilko Bengen: support capturing from UNIX-domain sockets.
Update a comment.

svn path=/trunk/; revision=32177
2010-03-13 00:29:30 +00:00
Guy Harris 25d49313cc "capture-pcap-util.h" include <pcap.h>, and <pcap.h>, for better or
worse, has no include-once guards; include it only once.

svn path=/trunk/; revision=32110
2010-03-04 07:19:43 +00:00
Guy Harris 167ab3a98c In Wireshark and TShark, run dumpcap to get interface lists and lists of
link-layer header types for interfaces; if special privileges are
necessary to open capture devices, Wireshark and TShark shouldn't have
those privileges, but dumpcap should.

svn path=/trunk/; revision=32104
2010-03-04 01:12:04 +00:00
Guy Harris cde1496de2 Squelch some compiler warnings.
svn path=/trunk/; revision=32074
2010-03-01 23:43:47 +00:00
Guy Harris 3b845dcce0 Move a routine into dumpcap - it's not used outside dumpcap.
svn path=/trunk/; revision=32042
2010-02-27 23:32:08 +00:00
Gerald Combs 97c480741d If we're using threads, time out when reading the file header.
svn path=/trunk/; revision=31529
2010-01-14 22:45:12 +00:00
Guy Harris 89d7efc44a Only do the 1-second timeout in OS X 10.6 and 10.6.1; the bug is fixed
in 10.6.2.

svn path=/trunk/; revision=31081
2009-11-26 04:17:18 +00:00
Stig Bjørlykke 98024a007f Invert check for getopt: NEED_GETOPT_H -> HAVE_GETOPT_H
Rename getopt.[ch] -> wsgetopt.[ch] to avoid name collision.

svn path=/trunk/; revision=30370
2009-10-06 16:01:18 +00:00
Stig Bjørlykke b82f3a8037 Cast a pointer to avoid a warning.
svn path=/trunk/; revision=30229
2009-10-01 11:09:27 +00:00
Stig Bjørlykke ee37f6194f Initialize magic to avoid a warning about a possible uninitialized read.
svn path=/trunk/; revision=30188
2009-09-29 06:57:11 +00:00
Jeff Morriss af6fca176d Don't use SIGUSR1 to tell dumpcap to exit, use SIGINT: SIGINT is traditionally
used for this purpose and using it also prevents the 2 signals the child gets:
	- the user's Ctrl-C (which is sent as a SIGINT to both *shark and its
	  child dumpcap)
	- the signal *shark generates to shut down the child

from colliding (and running 2 signal handlers in the child).

It might be possible for tshark to not send the signal at all when it gets
SIGINT, but it doesn't do any harm now.

Also, do not call g_log() within the signal handler: doing so can cause
aborts (if g_log is being called by the process when the signal comes, the
2nd entrance into g_log is detected as a recursion).

This fixes https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=2767

svn path=/trunk/; revision=29881
2009-09-13 17:46:10 +00:00
Kovarththanan Rajaratnam 0ef69d922a Use Wireshark/GLib attribute specifiers instead of checking for __GNUC__ explicitly
svn path=/trunk/; revision=29804
2009-09-08 18:02:43 +00:00
Michael Tüxen 4a50092991 Use a timeout of a second for Mac OS X, when building
a 64-bit application. Workaround a bug in Mac OS X...

svn path=/trunk/; revision=29641
2009-08-31 19:13:50 +00:00
Anders Broman 5cba22a89b Make the windows build compile.
svn path=/trunk/; revision=29591
2009-08-28 05:17:14 +00:00
Gerald Combs 3b4fb8e340 Properly set our file descriptor when we're capturing from a pipe on
non-Windows systems.

svn path=/trunk/; revision=29590
2009-08-27 23:55:48 +00:00