Commit Graph

117 Commits

Author SHA1 Message Date
Ronnie Sahlberg e6ed260aca some more path fixes for g_ascii_strcasecmp.h
svn path=/trunk/; revision=23638
2007-11-28 01:31:23 +00:00
Guy Harris 9c89cdaaa3 strcasecmp(), strncasecmp(), g_strcasecmp(), and g_strncasecmp() delenda
est.  Use g_ascii_strcasecmp() and g_ascii_strncasecmp(), and supply our
own versions if they're missing from GLib (as is the case with GLib
1.x).

In the code to build the list of named fields for Diameter, don't use
g_strdown(); do our own g_ascii_-style upper-case to lower-case mapping
in the hash function and use g_ascii_strcasecmp() in the compare
function.

We do this because there is no guarantee that toupper(), tolower(), and
functions that use them will, for example, map between "I" and "i" in
all locales; in Turkish locales, for example, there are, in both
upper case and lower case, versions of "i" with and without a dot, and
the upper-case version of "i" is "I"-with-a-dot and the lower-case
version of "I" is "i"-without-a-dot.  This causes strings that should
match not to match.

This finishes fixing bug 2010 - an earlier checkin prevented the crash
(as there are other ways to produce the same crash, e.g. a bogus
dictionary.xml file), but didn't fix the case-insensitive string matching.

svn path=/trunk/; revision=23623
2007-11-27 18:52:51 +00:00
Jeff Morriss 5b8d2e49dc Change (yet another--I really need to find a way to automate finding these things) open() to eth_open() to fix http://bugs.wireshark.org/bugzilla/show_bug.cgi?id=1987
svn path=/trunk/; revision=23601
2007-11-26 16:40:17 +00:00
Gerald Combs 0ffff17f53 Move some items back into capture_loop.c (since TShark no longer needs them).
Clean up some of the Windows named pipe code.

svn path=/trunk/; revision=23592
2007-11-25 21:38:18 +00:00
Guy Harris 3bfb727c55 Have capture_loop_dispatch() calculate the number of packets written
out, and return that; pcap_dispatch() returns the number of packets it
processed, but we might have discarded some or all of them if we hit the
packet limit in the middle of processing them.

svn path=/trunk/; revision=23542
2007-11-22 01:51:16 +00:00
Guy Harris 9f8968cd07 Don't count packets until we've successfully written them to the capture
file.

If we set the "stop capture" flag, don't process the packet.

svn path=/trunk/; revision=23541
2007-11-22 01:16:57 +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 d5ea683007 For bug 1685, check for the errors reported on at least some platforms
when an interface goes down or goes away, and, in that case, just report
that, rather than reporting a more technical error and indicating that
the error should be reported to the Wireshark developers.

Line-break the "please report this to the Wireshark developers" error
differently (so that it doesn't look weird if the dialog box line-wraps
it).

Fix indentation.

svn path=/trunk/; revision=22771
2007-09-02 23:32:43 +00:00
Gerald Combs 92802883a6 Change the "--enable-setuid-install" option to install dumpcap and TShark
setuid instead of Wireshark.  Remove the "DANGEROUS" notices, but leave it
disabled by default.  Whine if the user runs Wireshark or TShark as root.
Add a preference to disable the whining.  Add a "setuid-root" script that
can be used to switch dumpcap and TShark's setuid-ness on and off for
development and testing.  Update the release notes and README.packaging.

svn path=/trunk/; revision=22733
2007-08-30 00:24:40 +00:00
Richard van der Hoff 56d329f7e9 Add some comments to the effect that capture_loop_dispatch must timeout to make
the packet batching stuff work properly.

Hence, do not block forever when doing a select() on a capture fd.

svn path=/trunk/; revision=22638
2007-08-24 15:33:37 +00:00
Guy Harris f2c8e0c0ba The libpcap callback "user" argument *should* have been a "void *", as
it's a pointer to an arbitrary object, assumed to be correctly aligned,
not a pointer to a not-necessarily-properly-aligned array of bytes. 
Cast it, so we won't get alignment warnings.

svn path=/trunk/; revision=21939
2007-05-25 19:26:45 +00:00
Stephen Fisher 4d0920e5d6 Remove a linebreak from an error message dialog so it wraps properly
svn path=/trunk/; revision=21470
2007-04-18 21:42:37 +00:00
Sebastien Tandel 2371ad2eb0 fix gcc warning about qualifier types (const) which are discarded when arriving
at the pcap interface.

svn path=/trunk/; revision=21417
2007-04-13 20:59:20 +00:00
Bill Meier 4009deca1b Output error msgs when using dumpcap from cmd-line (stand-alone);
Also: minor cleanup for capture_loop.c

svn path=/trunk/; revision=20864
2007-02-19 20:25:56 +00:00
Bill Meier 4c5da0a9f6 Fix error handling for invalid named pipe;
Generate correct message;
(test suite 'tshark invalid capture interface' test
should now work again).


svn path=/trunk/; revision=20851
2007-02-19 04:48:02 +00:00
Gerald Combs 79dab1658d Windows named pipe support, which was disabled several months ago,
is now inexplicably working, so enable it.

svn path=/trunk/; revision=20762
2007-02-10 01:13:05 +00:00
Bill Meier 4ca6957095 Fix "dumpcap -w -" to use binmode on stdout if Windows;
(The related tests in suite-capture.sh should now work correctly).
(Also: Print error message if attempting to use ring-buffers
   with a named pipe).

svn path=/trunk/; revision=20255
2007-01-01 17:04:38 +00:00
Guy Harris 97939febb9 As Ulf Lamping notes:
if the pipename argument to cap_pipe_open_live() is null, that's
	a bug, and we want a crash so it's caught;

	if ld->pcap_h is null in capture_loop_dispatch(), that's a bug,
	and we want a crash so it's caught;

	if capture_opts is null in capture_loop_start(), that's a bug,
	and we want a crash so it's caught;

	there's no need to null out capture_opts->save_file twice.

Also, errmsg and secondary_errmsg are null-terminated strings, so the
array size should be the maximum length + 1.

svn path=/trunk/; revision=19857
2006-11-07 09:50:09 +00:00
Jörg Mayer 23ce819952 Frederic Heem:
Fix some memleaks and overflows.

I haven't committed the changes that are not bug fixes.

svn path=/trunk/; revision=19777
2006-11-02 09:45:12 +00:00
Ulf Lamping 599ca2b824 from Richard van der Hoff:
> [tshark from a fifo]
> Ulf - I notice you made the relevant change here (r16787) - is there any reason why tshark shouldn't use capture_loop_dispatch to do its processing, rather than attempting to use cap_pipe_dispatch or pcap_dispatch directly?

well, there didn't seem to be, so I've made a patch which does exactly this, and which fixes the problem.

svn path=/trunk/; revision=19456
2006-10-08 22:39:23 +00:00
Michael Tüxen fb6348011a Do not show the Windows specific message on non-Windows systems.
svn path=/trunk/; revision=19396
2006-10-02 19:26:53 +00:00
Ronnie Sahlberg 66c44bb699 make sure we still compile for all out rh71 users
svn path=/trunk/; revision=19320
2006-09-25 08:10:10 +00:00
Ulf Lamping 7351f86076 squelch some compiler warnings due to currently disabled code
svn path=/trunk/; revision=19300
2006-09-23 00:38:00 +00:00
Gerald Combs 9e23f31e5f Add support for reading from stdin under Windows. Based on a patch sent
in last year by Gianluca Varenni.

Add partial support for reading from named pipes (currently disabled).

Move utf_8to16() and utf_16to8() to a separate module (unicode-utils.[ch])
so that we don't have to cut and paste code in dumpcap.c.

Fix up whitespace.

svn path=/trunk/; revision=19291
2006-09-22 21:14:54 +00:00
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