summaryrefslogtreecommitdiff
path: root/capture_loop.c
AgeCommit message (Collapse)AuthorFilesLines
2007-10-26For the Wireshark/TShark -> dumpcap signal pipe on Windows, use a namedGerald Combs1-14/+11
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-09-02For bug 1685, check for the errors reported on at least some platformsGuy Harris1-7/+30
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-08-30Change the "--enable-setuid-install" option to install dumpcap and TSharkGerald Combs1-0/+3
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-24Add some comments to the effect that capture_loop_dispatch must timeout to makeRichard van der Hoff1-3/+15
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-05-25The libpcap callback "user" argument *should* have been a "void *", asGuy Harris1-1/+1
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-04-18Remove a linebreak from an error message dialog so it wraps properlyStephen Fisher1-1/+1
svn path=/trunk/; revision=21470
2007-04-13fix gcc warning about qualifier types (const) which are discarded when arrivingSebastien Tandel1-1/+1
at the pcap interface. svn path=/trunk/; revision=21417
2007-02-19Output error msgs when using dumpcap from cmd-line (stand-alone);Bill Meier1-4/+3
Also: minor cleanup for capture_loop.c svn path=/trunk/; revision=20864
2007-02-19Fix error handling for invalid named pipe;Bill Meier1-1/+3
Generate correct message; (test suite 'tshark invalid capture interface' test should now work again). svn path=/trunk/; revision=20851
2007-02-10Windows named pipe support, which was disabled several months ago,Gerald Combs1-6/+6
is now inexplicably working, so enable it. svn path=/trunk/; revision=20762
2007-01-01Fix "dumpcap -w -" to use binmode on stdout if Windows;Bill Meier1-6/+14
(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
2006-11-07As Ulf Lamping notes:Guy Harris1-20/+3
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-02Frederic Heem:Jörg Mayer1-2/+24
Fix some memleaks and overflows. I haven't committed the changes that are not bug fixes. svn path=/trunk/; revision=19777
2006-10-08from Richard van der Hoff:Ulf Lamping1-5/+5
> [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-02Do not show the Windows specific message on non-Windows systems.Michael Tüxen1-1/+1
svn path=/trunk/; revision=19396
2006-09-25make sure we still compile for all out rh71 usersRonnie Sahlberg1-1/+1
svn path=/trunk/; revision=19320
2006-09-23squelch some compiler warnings due to currently disabled codeUlf Lamping1-0/+2
svn path=/trunk/; revision=19300
2006-09-22Add support for reading from stdin under Windows. Based on a patch sentGerald Combs1-96/+210
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-08-26Go back to setting the capture filter to an empty string when we start;Guy Harris1-8/+0
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-21Initialize the cfilter field of a capture_opts structure to a nullGuy Harris1-0/+8
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-07-01Explicitly note that a "Please report this to the Wireshark developers"Guy Harris1-1/+2
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-05-31Tethereal/tethereal -> TShark/tshark.Gerald Combs1-3/+3
svn path=/trunk/; revision=18268
2006-05-28Ethereal->WiresharkAnders Broman1-11/+11
svn path=/trunk/; revision=18235
2006-05-22ethereal->wiresharkRonnie Sahlberg1-1/+1
svn path=/trunk/; revision=18207
2006-05-21Fix the only gerald@ethereal.com references left.Guy Harris1-1/+1
svn path=/trunk/; revision=18203
2006-05-21If we have pcap_breakloop(), at least on UN*X we can stop the captureGuy Harris1-122/+136
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-20The timeout is needed if you don't have pcap_breakloop(), so we'll putGuy Harris1-26/+112
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-20Dumpcap doesn't need to ensure that it doesn't block indefinitely, as itGuy Harris1-112/+26
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-04-29Have the ring buffer routines take a pointer to a "bytes written" countGuy Harris1-3/+5
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-03Put the low-level sync routines into a common file so they can be sharedGuy Harris1-19/+19
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-03In Tethereal, don't save to a temporary file if "-w" isn't specified,Guy Harris1-35/+41
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-03-24remove some XXX markers in comments which are no (longer) ToDo itemsUlf Lamping1-2/+2
svn path=/trunk/; revision=17715
2006-03-21Simplify the argument list to cap_pipe_dispatch().Guy Harris1-16/+15
svn path=/trunk/; revision=17690
2006-03-13fix bug #803: sync pipe on Win32 wasn't set to binary mode, so error message ↵Ulf Lamping1-1/+2
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-09fix two bugs causing crashes on Win32: Ulf Lamping1-6/+10
- 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-05Add in a variable we need on Windows.Guy Harris1-0/+3
svn path=/trunk/; revision=17469
2006-03-05In the capture_loop.c code, open the capture device for input beforeGuy Harris1-8/+8
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-05Make some routines not used outside capture_loop.c static.Guy Harris1-2/+2
svn path=/trunk/; revision=17466
2006-03-05Pass two strings in capture child messages, so the child can sendGuy Harris1-73/+69
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-04When capturing, we only support writing to libpcap files. Given that,Guy Harris1-50/+29
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-02-17remove dependencies to pcap.h, so getting an idea what needs to be done by ↵Ulf Lamping1-39/+18
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-12Move create_tempfile() to tempfile.c out of util.c. This means dumpcapGuy Harris1-1/+1
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-12mark an unused parameterUlf Lamping1-1/+1
svn path=/trunk/; revision=17263
2006-02-11the point of no return ...Ulf Lamping1-6/+9
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-01-07move output_to_pipe flag from tethereal's loop_data into capture_opts, so it ↵Ulf Lamping1-2/+5
can be used by dumpcap (capture_loop.c) as well svn path=/trunk/; revision=16972
2006-01-06code cleanup: use "-" for all places, where stdin/stdout is meantUlf Lamping1-1/+1
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-04Handle a null-string file name in "capture_loop_open_output()" - that'sGuy Harris1-12/+25
what indicates that we're supposed to write to the standard output (Tethereal turns "-" into ""). svn path=/trunk/; revision=16941
2005-12-31Ooops, remove a debug message in the Win32 code part of the capturing loop.Ulf Lamping1-1/+1
It might (very slightly) slow down capturing in the 0.10.14 release :-( svn path=/trunk/; revision=16923
2005-12-17Win32 bugfix: peeking the signal_pipe at capture_loop start seems to be ↵Ulf Lamping1-10/+5
unreliable Instead, simply keep the signal_pipe setting directly from the command line which is working well svn path=/trunk/; revision=16833
2005-12-14Constify a bunch of arguments and variables, to squelch compilerGuy Harris1-3/+2
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