Commit Graph

28 Commits

Author SHA1 Message Date
John Thacker 3fbefe9c36 dumpcap: Make capture child logging work
Distinguish log messages from SP_ERROR_MSG; log messages don't
necessarily represent a failure, and they have a level. This
doesn't affect logging while capturing much, as SP_ERROR_MSGs
are just printed to the console, but it makes it possible to log
while retrieving interface information or the stats, where SP_ERROR_MSG
indicates that the command failed.
2023-12-31 16:44:25 -05:00
John Thacker 3794caff71 capture: Fix up getting stats
Missed copying the dlt type
Increase the sync pipe max message size.

Fixup 54ed27e11a
2023-12-22 22:13:59 -05:00
John Thacker 2b21fe5e4f capture_sync: Keep PIPE_BUF_SIZE and SP_MAX_MSG_LEN related
We might at some point want to increase SP_MAX_MSG_LEN. Make
sure that PIPE_BUF_SIZE increases in tandem, or else there can
be a segfault.
2023-12-20 10:40:29 +01:00
John Thacker 607b3671c8 dumpcap: Add a welcome mode
Allow dumpcap to have the "-D" "-L" and "-S" flags all specified.
This is a "welcome mode" that prints out the interfaces and their
capabilities, and then prints out the running statistics.
("-L" and "-S" without "-D" will just print the statistics, but
doesn't give an error.)

In capture child mode, the interface information is sent as a
message on the sync pipe before the success message; the statistics
are sent on the data pipe as usual.

Actually using this in Wireshark will be added next.

Related to #15082
2023-12-18 21:17:29 -05:00
Guy Harris fe835ae95c capture child: send an errno message if exec of dumpcap fails.
On at least some Linux distributions, dumpcap is either installed with
elevated privileges sufficient to support traffic capture by default or
can optionally be given those privileges.  If it has those privileges,
it's typically made group-executable but not world-executable and owned
by a special group, e.g. "wireshark", so that only users in that group
can use dumpcap to capture traffic.

The user installing the Wireshark package is *not* necessarily put into
that group by default; this means that any attempt by Wireshark or
TShark to run dumpcap will fail with EACCES.

If the exec call in the child process sends text error mesages, intended
for end users, up the message pipe, as we had been doing, then figuring
out *why* the exec failed would require some heuristic parsing to figure
out whether it's a permissions problem or not.

Instead of doing that, just send a message giving the errno for exec
failing.

For now, we just format an error message for that in the parent process,
but this leaves room to do a better job.

While we're at it, fix some cases where an empty error message could be
printed.
2023-09-09 23:47:27 -07:00
Guy Harris 6ad78bcc44 Clean up sync pipe write routines.
Give them all names beginning with sync_pipe_write_

Rename pipe_write_block() to sync_pipe_write_string_msg(), as it writes
a message containing a string, not a "block".

Add sync_pipe_write_uint_msg(), which takes an unsigned integer as an
argument and writes a message containing its value (as a string) as the
body.

Make sync_pipe_write_header() and SP_DECISIZE local to
sync_pipe_write.c, as they're no longer used outside that file.
2023-08-26 14:58:08 -07:00
João Valverde 4448b6494e Add a ws_posix_compat.h header
Currently used to define ssize_t on platforms that lack it.

Fix some Windows build errors caused by moving the definition into a
separate header.

Fix some narrowing warnings on Windows x64 from changing the definition
of ssize_t from long int to int64_t.

The casts in dumpcap are ugly but necessary. The whole code needs
to be rewritten for portability, or the warnings disabled.
2021-12-21 01:30:06 +00:00
Guy Harris 20800366dd HTTPS (almost) everywhere.
Change all wireshark.org URLs to use https.

Fix some broken links while we're at it.

Change-Id: I161bf8eeca43b8027605acea666032da86f5ea1c
Reviewed-on: https://code.wireshark.org/review/34089
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-07-26 18:44:40 +00:00
Dario Lombardo 8cd389e161 replace SPDX identifier GPL-2.0+ with GPL-2.0-or-later.
The first is deprecated, as per https://spdx.org/licenses/.

Change-Id: I8e21e1d32d09b8b94b93a2dc9fbdde5ffeba6bed
Reviewed-on: https://code.wireshark.org/review/25661
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-02-08 14:57:36 +00:00
Gerald Combs 775bbbcded Start using SPDX license identifiers.
A while back Graham pointed out the SPDX project (spdx.org), which is
working on standardizing license specifications:

https://www.wireshark.org/lists/wireshark-dev/201509/msg00119.html

Appendix V of the specification describes a short identifier
(SPDX-License-Identifier) that you can use in place of boilerplate in
your source files:

https://spdx.org/spdx-specification-21-web-version#h.twlc0ztnng3b

Start the conversion process with our top-level C and C++ files.

Change-Id: Iba1d835776714deb6285e2181e8ca17f95221878
Reviewed-on: https://code.wireshark.org/review/24302
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Reviewed-by: Balint Reczey <balint@balintreczey.hu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-11-09 20:03:51 +00:00
Stig Bjørlykke 77751c94f1 Qt: Add interface toolbar support
An extcap utility can provide configuration for controls to use in a
GUI interface toolbar.  This controls are bidirectional and can be
used to control the extcap utility while capturing.

This is useful in scenarios where configuration can be done based on
findings in the capture process, setting temporary values or give other
inputs without restarting current capture.

Todo:
- Add support for Windows

Change-Id: Ie15fa67f92eb27d8b73df6bb36f66b9a7d81932d
Reviewed-on: https://code.wireshark.org/review/19982
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2017-04-25 06:19:39 +00:00
Gerald Combs b16166c36a Revert "Windows: Wait for dumpcap to initialize."
This didn't fix the test failures.

This reverts commit e5f4c5c8a8.

Change-Id: I0cff5eff88d2b49806797cef83338dbbace42a4c
Reviewed-on: https://code.wireshark.org/review/15135
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2016-04-28 00:12:31 +00:00
Gerald Combs e5f4c5c8a8 Windows: Wait for dumpcap to initialize.
As the MSDN documentation says, "CreateProcess returns without waiting
for the new process to finish its initialization." Add an SP_INIT sync
pipe indicator on Windows and use it in dumpcap to signal to its parent
that it has started up.

Change-Id: I88a4c158871dbe2dd6eba13434e92c5d4b1c2e4b
Reviewed-on: https://code.wireshark.org/review/15132
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2016-04-27 23:11:34 +00:00
Bill Meier 9c866ff971 Replace tabs by spaces when editor modelines has "expandtab"
Change-Id: If7a6f2697be732ae4f94ed8b845fd293c32510f7
Also: tabs-stops should be 8
Reviewed-on: https://code.wireshark.org/review/7100
Reviewed-by: Bill Meier <wmeier@newsguy.com>
2015-02-13 17:34:53 +00:00
Bill Meier bfe3706035 Always put editor-modelines at the end of the file ...
... to ensure that there are no potential issues with respect to
editors limiting the number of lines scanned at the end of the file
when checking for editor modelines.

Change-Id: Ic85cbb108bb5159d6ec4116fea11f5eebb4e44a4
Reviewed-on: https://code.wireshark.org/review/4688
Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-10-14 20:08:29 +00:00
Bill Meier 1b8b2a8aa8 Add editor modelines; Adjust whitespace as needed.
Change-Id: I4da7b335d905dbca10bbce03aa88e1cdeeb1f8ad
Reviewed-on: https://code.wireshark.org/review/4626
Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-10-12 18:58:32 +00:00
Alexis La Goutte 296591399f Remove all $Id$ from top of file
(Using sed : sed -i '/^ \* \$Id\$/,+1 d')

Fix manually some typo (in export_object_dicom.c and crc16-plain.c)

Change-Id: I4c1ae68d1c4afeace8cb195b53c715cf9e1227a8
Reviewed-on: https://code.wireshark.org/review/497
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-04 14:27:33 +00:00
Gerald Combs b671f8dbd6 Suggest fancier ways to communicate with the capture process.
svn path=/trunk/; revision=46985
2013-01-07 16:26:45 +00:00
Guy Harris ec5a6f8c5e pipe_write_header() should return ssize_t, as it returns the return
value from write(), which, at least on UN*X, is ssize_t.

svn path=/trunk/; revision=46779
2012-12-26 12:14:59 +00:00
Guy Harris 8ed7a73e22 Fix a bunch of warnings.
Cast away some implicit 64-bit-to-32-bit conversion errors due to use of
sizeof.

Cast away some implicit 64-bit-to-32-bit conversion errors due to use of
strtol() and strtoul().

Change some data types to avoid those implicit conversion warnings.

When assigning a constant to a float, make sure the constant isn't a
double, by appending "f" to the constant.

Constify a bunch of variables, parameters, and return values to
eliminate warnings due to strings being given const qualifiers.  Cast
away those warnings in some cases where an API we don't control forces
us to do so.

Enable a bunch of additional warnings by default.  Note why at least
some of the other warnings aren't enabled.

randpkt.c and text2pcap.c are used to build programs, so they don't need
to be in EXTRA_DIST.

If the user specifies --enable-warnings-as-errors, add -Werror *even if
the user specified --enable-extra-gcc-flags; assume they know what
they're doing and are willing to have the compile fail due to the extra
GCC warnings being treated as errors.

svn path=/trunk/; revision=46748
2012-12-26 05:57:06 +00:00
Jakub Zawadzki bf81b42e1e Update Free Software Foundation address.
(COPYING will be updated in next commit)

svn path=/trunk/; revision=43536
2012-06-28 22:56:06 +00:00
Guy Harris f6aa7ae0dd Move stuff that should *only* be known by the lowest-level code that
deals with the sync pipe - i.e., only by sync_pipe.c and dumpcap.c -
into sync_pipe.h.

svn path=/trunk/; revision=40366
2012-01-04 03:02:13 +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 ddb5a7a13f Rename an argument to avoid colliding with pipe().
svn path=/trunk/; revision=25555
2008-06-23 21:24:48 +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
Ronnie Sahlberg f0b33a4789 ethereal->wireshark updates
svn path=/trunk/; revision=18206
2006-05-22 08:14:01 +00:00
Ronnie Sahlberg 89f022b12b name change
svn path=/trunk/; revision=18197
2006-05-21 05:12:17 +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