Commit Graph

19 Commits

Author SHA1 Message Date
Guy Harris b5d65c0074 Move still *more* headers outside of extern "C".
If a header declares a function, or anything else requiring the extern
"C" decoration, have it wrap the declaration itself; don't rely on the
header itself being included inside extern "C".

(cherry picked from commit 2820156fbd)
2021-03-16 15:03:17 -07:00
Guy Harris 30bad8e627 Have callback function pointers in a capture_session structure.
Instead of having programs that use the capchild library define
functions with known names, with the library routines calling back
routines with those names, have function pointers for those callbacks in
the capture_session structure, and have capture_session_init() set them.

Make the callback routines in TShark and in the ui library static.

Change-Id: Ia1ba6119c5ef7708e0f87b8420f200136ba41eae
Reviewed-on: https://code.wireshark.org/review/36583
Petri-Dish: Guy Harris <gharris@sonic.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <gharris@sonic.net>
2020-03-25 23:16:06 +00:00
Stig Bjørlykke abfa0d6218 Qt: Keep extcap control channels when capturing to multiple files
When using the "Create a new file automatically" feature the capture in
Wireshark will stop and start, but the extcap utility will continue run
as normal. Ensure the control channels are kept when doing this.

Rename the unused capture_session.session_started to session_will_restart
to detect this.

Bug: 16178
Change-Id: I6797c982760a1013fca2a24699befff1dc82f28c
Reviewed-on: https://code.wireshark.org/review/35013
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
2019-11-07 12:53:47 +00:00
Guy Harris 0771cf73cd Use a single wtap_rec and Buffer for an entire capture session.
That way we aren't allocating memory, reading packets from a batch, and
freeing the memory for each batch of packets delivered by dumpcap; we do
the allocation when the capture starts and the freeing when it finishes.

Change-Id: If012ab865f3a99d869535ad10827ad8680c1b10c
Reviewed-on: https://code.wireshark.org/review/32766
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-04-08 07:58:16 +00:00
Guy Harris 2c1dcfed4f The wtap from which we're reading to get statistics isn't a statistic itself.
Move it to the capture_session structure from the info_data_t structure,
and pass it as an argument to capture_info_new_packets().

Change-Id: I822392bbf48eeb27ba9e17b73775d2fc4349bc17
Reviewed-on: https://code.wireshark.org/review/32765
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-04-07 02:23:58 +00:00
Guy Harris f727e8b387 Fix indentation.
Change-Id: I60d9b7b5dce04dae560a68feb329041c0374c241
Reviewed-on: https://code.wireshark.org/review/31342
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-01-03 19:41:05 +00:00
Stig Bjørlykke 14720ace06 Fix comment end after SPDX identifier
Move */ to a separate line below the SPDX identifier.

Change-Id: Id1032215449cfccae0933147b45e04b65e0b727f
Reviewed-on: https://code.wireshark.org/review/27211
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-01 06:56:37 +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
Dario Lombardo d93db54dc0 capchild: use SPDX identifiers.
Change-Id: I123e043c3266993081f9bff404da5d7db76ee68e
Reviewed-on: https://code.wireshark.org/review/25558
Reviewed-by: Michael Mann <mmann78@netscape.net>
2018-02-02 13:40:04 +00:00
Guy Harris eb8ffb74e2 Use cfile.h to define the capture_file type.
Have cfile-int.h declare the structure, and use it in files that
directly access the structure.

Have cfile.h just incompletely declare the structure and include it
rather than explicitly declaring it in source files or other header
files.

Never directly refer to struct _capture_file except when typedeffing
capture_file.

Add #includes as necessary, now that cfile.h doesn't drag in a ton of

Change-Id: I7931c8039d75ff7c980b0f2a6e221f20e602a556
Reviewed-on: https://code.wireshark.org/review/24686
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-12-03 18:54:37 +00:00
Guy Harris b3068a0d1b Fix a comment to match we-run-on-Windows-too reality.
Change-Id: I68a299afd1d8228e7c842f66ffd3b4ee1ffb3798
Reviewed-on: https://code.wireshark.org/review/20014
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-02-08 02:21:44 +00:00
Michael Mann 444dfda793 Allow "capture info data" to not be a singleton.
It was buried as a static variable in capture_info.c, and functions were refactored to allow a pointer to the info_data_t structure to be passed in. TShark and GTK will have their own single (global) copy of the structure, while it opens up Qt to have multiple instances.

Change-Id: Ic2d7a2ad574de43f457cb18b194d6bc3fffb6120
Reviewed-on: https://code.wireshark.org/review/12691
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-12-19 14:22:56 +00:00
Guy Harris a10a41f5c7 Rename wsutil/process.h to wsutil/processes.h to avoid collisions.
The MSVC rules for searching for headers are a huge barrel of fun; it
appears that, for some files that need the MSVC <process.h> to declare
getpid(), they're getting our <wsutil/process.h> instead, as that's in
the current directory.  Rename it to avoid the collision.

Change-Id: I88eb70237062fa7957e38d7ff8132524390a6a5c
Reviewed-on: https://code.wireshark.org/review/8870
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-06-10 01:56:27 +00:00
Guy Harris 2e76bb466a Use pid_t on UN*X, and HANDLE on Windows, for the process ID.
This avoids type punning; at least with Xcode 7 beta on El Capitan beta,
that produces warnings that get turned into errors.

Change-Id: I57f47455b9630f359828c07c92a190b5cb33816f
Reviewed-on: https://code.wireshark.org/review/8862
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-06-10 00:30:57 +00:00
Anders 4e60e8fb39 [MSVC 2015] Use intptr_t for "pointer stored as int" to make MSVC happy.
Change-Id: I5dbbea8527a8bb73b17e5a8a5611c3923d82459c
Reviewed-on: https://code.wireshark.org/review/8852
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-06-09 14:13:14 +00:00
Guy Harris 1871fb2b0d Keep a captured-packet count in a capture_session and use that.
Have the count in a cfile_t structure always reflect the actual number
of packets that have been read from the file, rather than, when doing a
non-update-list-of-packets-in-real-time capture, falsely increasing the
count in the cfile_t to reflect the number of packets captured but not
yet read.

Have the status bar base its captured-packet count on the count in the
capture_session structure, and base the "sorry, no packets were
captured" message on the count in the capture_session structure, as
we're no longer using the count in the cfile_t structure to count
anything in the process of a non-update-list-of-packets-in-real-time
capture.

That way, we preserve the invariant that the "frames" member of a
cfile_t will be non-null if the "count" member is non-zero, fixing bug
6217.

It also means we can get rid of cf_set_packet_count(), as we only set
the count in the capture-file-reading code.

Bug: 6217
Change-Id: I72c0e2c07c30782bad777995370b7c19e1460cc2
Reviewed-on: https://code.wireshark.org/review/7950
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-04-06 19:15:24 +00:00
Gerald Combs 9ba9cd83a4 Qt: Add a CaptureFile class.
Wrap the capture_file struct in a QObject which translates cf_cb_* and
capture_cb_* events into signals. Move the global cfile to
capture_file.cpp.

Don't use a void pointer for the capture file struct.

Change-Id: Ic5d5efb4bb1db64aa0247245890e5669b1da723a
Reviewed-on: https://code.wireshark.org/review/5885
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2014-12-20 17:39:29 +00:00
Irene Ruengeler f3c5f14bc4 Manage Interfaces
- Add dialog to manage interfaces
- Add and delete pipes
- Hide local interfaces

Change-Id: I08323c306c2ea736f99e57c28e2fe3170a0c2216
Reviewed-on: https://code.wireshark.org/review/2613
Tested-by: Anders Broman <a.broman58@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Michael Tüxen <tuexen@wireshark.org>
2014-07-02 20:56:37 +00:00
Guy Harris b33512b704 Move capture_session.h to capchild; what it declares is defined there.
Change-Id: I8b1407839390b7ac0b45bf6f583c1a509073f002
Reviewed-on: https://code.wireshark.org/review/2709
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-06-30 05:09:31 +00:00