forked from osmocom/wireshark
Move the last of the routines from capture_info.c into ui/capture.c.
That means the packet-count-during-capture stuff is scattered amongst fewer locations. Move capture_info.h into ui; it's now a header that declares routines whose implementations are GUI-platform-dependent. Change-Id: I475815724a4766f6bc2511e67ebae14865e1a9d1 Reviewed-on: https://code.wireshark.org/review/26249 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
parent
1f2d36aa0b
commit
6d6376e81f
|
@ -2162,7 +2162,6 @@ set_target_properties(version_info shark_common cli_main capture_opts
|
|||
|
||||
if(BUILD_wireshark AND QT_FOUND)
|
||||
set(WIRESHARK_SRC
|
||||
capture_info.c
|
||||
file.c
|
||||
fileset.c
|
||||
${PLATFORM_UI_SRC}
|
||||
|
|
|
@ -1,90 +0,0 @@
|
|||
/* capture_info.c
|
||||
* capture info functions
|
||||
*
|
||||
* Wireshark - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@wireshark.org>
|
||||
* Copyright 1998 Gerald Combs
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ifdef HAVE_LIBPCAP
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <epan/packet.h>
|
||||
#include <wiretap/wtap.h>
|
||||
|
||||
#include "capture_info.h"
|
||||
|
||||
#include <epan/capture_dissectors.h>
|
||||
|
||||
static void
|
||||
capture_info_packet(info_data_t* cap_info, gint wtap_linktype, const guchar *pd, guint32 caplen, union wtap_pseudo_header *pseudo_header)
|
||||
{
|
||||
capture_packet_info_t cpinfo;
|
||||
|
||||
/* Setup the capture packet structure */
|
||||
cpinfo.counts = cap_info->counts.counts_hash;
|
||||
|
||||
cap_info->counts.total++;
|
||||
if (!try_capture_dissector("wtap_encap", wtap_linktype, pd, 0, caplen, &cpinfo, pseudo_header))
|
||||
cap_info->counts.other++;
|
||||
}
|
||||
|
||||
/* new packets arrived */
|
||||
void capture_info_new_packets(int to_read, wtap *wth, info_data_t* cap_info)
|
||||
{
|
||||
int err;
|
||||
gchar *err_info;
|
||||
gint64 data_offset;
|
||||
wtap_rec rec;
|
||||
Buffer buf;
|
||||
union wtap_pseudo_header *pseudo_header;
|
||||
int wtap_linktype;
|
||||
|
||||
cap_info->ui.new_packets = to_read;
|
||||
|
||||
/*g_warning("new packets: %u", to_read);*/
|
||||
|
||||
wtap_rec_init(&rec);
|
||||
ws_buffer_init(&buf, 1514);
|
||||
while (to_read > 0) {
|
||||
wtap_cleareof(wth);
|
||||
if (wtap_read(wth, &rec, &buf, &err, &err_info, &data_offset)) {
|
||||
if (rec.rec_type == REC_TYPE_PACKET) {
|
||||
pseudo_header = &rec.rec_header.packet_header.pseudo_header;
|
||||
wtap_linktype = rec.rec_header.packet_header.pkt_encap;
|
||||
|
||||
capture_info_packet(cap_info, wtap_linktype,
|
||||
ws_buffer_start_ptr(&buf),
|
||||
rec.rec_header.packet_header.caplen,
|
||||
pseudo_header);
|
||||
|
||||
/*g_warning("new packet");*/
|
||||
to_read--;
|
||||
}
|
||||
}
|
||||
}
|
||||
wtap_rec_cleanup(&rec);
|
||||
ws_buffer_free(&buf);
|
||||
|
||||
capture_info_ui_update(&cap_info->ui);
|
||||
}
|
||||
|
||||
#endif /* HAVE_LIBPCAP */
|
||||
|
||||
/*
|
||||
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local variables:
|
||||
* c-basic-offset: 4
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=4 tabstop=8 expandtab:
|
||||
* :indentSize=4:tabSize=8:noTabs=true:
|
||||
*/
|
2
tshark.c
2
tshark.c
|
@ -109,7 +109,7 @@
|
|||
#endif /* _WIN32 */
|
||||
#include <capchild/capture_session.h>
|
||||
#include <capchild/capture_sync.h>
|
||||
#include <capture_info.h>
|
||||
#include <ui/capture_info.h>
|
||||
#endif /* HAVE_LIBPCAP */
|
||||
#include "log.h"
|
||||
#include <epan/funnel.h>
|
||||
|
|
54
ui/capture.c
54
ui/capture.c
|
@ -24,7 +24,7 @@
|
|||
#include "ui/capture.h"
|
||||
#include "caputils/capture_ifinfo.h"
|
||||
#include <capchild/capture_sync.h>
|
||||
#include "capture_info.h"
|
||||
#include "ui/capture_info.h"
|
||||
#include "ui/capture_ui_utils.h"
|
||||
#include "ui/util.h"
|
||||
#include "caputils/capture-pcap-util.h"
|
||||
|
@ -476,6 +476,58 @@ capture_input_new_file(capture_session *cap_session, gchar *new_file)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
capture_info_packet(info_data_t* cap_info, gint wtap_linktype, const guchar *pd, guint32 caplen, union wtap_pseudo_header *pseudo_header)
|
||||
{
|
||||
capture_packet_info_t cpinfo;
|
||||
|
||||
/* Setup the capture packet structure */
|
||||
cpinfo.counts = cap_info->counts.counts_hash;
|
||||
|
||||
cap_info->counts.total++;
|
||||
if (!try_capture_dissector("wtap_encap", wtap_linktype, pd, 0, caplen, &cpinfo, pseudo_header))
|
||||
cap_info->counts.other++;
|
||||
}
|
||||
|
||||
/* new packets arrived */
|
||||
static void capture_info_new_packets(int to_read, wtap *wth, info_data_t* cap_info)
|
||||
{
|
||||
int err;
|
||||
gchar *err_info;
|
||||
gint64 data_offset;
|
||||
wtap_rec rec;
|
||||
Buffer buf;
|
||||
union wtap_pseudo_header *pseudo_header;
|
||||
int wtap_linktype;
|
||||
|
||||
cap_info->ui.new_packets = to_read;
|
||||
|
||||
/*g_warning("new packets: %u", to_read);*/
|
||||
|
||||
wtap_rec_init(&rec);
|
||||
ws_buffer_init(&buf, 1514);
|
||||
while (to_read > 0) {
|
||||
wtap_cleareof(wth);
|
||||
if (wtap_read(wth, &rec, &buf, &err, &err_info, &data_offset)) {
|
||||
if (rec.rec_type == REC_TYPE_PACKET) {
|
||||
pseudo_header = &rec.rec_header.packet_header.pseudo_header;
|
||||
wtap_linktype = rec.rec_header.packet_header.pkt_encap;
|
||||
|
||||
capture_info_packet(cap_info, wtap_linktype,
|
||||
ws_buffer_start_ptr(&buf),
|
||||
rec.rec_header.packet_header.caplen,
|
||||
pseudo_header);
|
||||
|
||||
/*g_warning("new packet");*/
|
||||
to_read--;
|
||||
}
|
||||
}
|
||||
}
|
||||
wtap_rec_cleanup(&rec);
|
||||
ws_buffer_free(&buf);
|
||||
|
||||
capture_info_ui_update(&cap_info->ui);
|
||||
}
|
||||
|
||||
/* capture child tells us we have new packets to read */
|
||||
void
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* capture_info.h
|
||||
* capture info functions
|
||||
* Declarations of platform-dependent capture info functions.
|
||||
*
|
||||
* Wireshark - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@wireshark.org>
|
||||
|
@ -41,9 +41,6 @@ typedef struct _info_data {
|
|||
capture_info ui; /* user interface data */
|
||||
} info_data_t;
|
||||
|
||||
/* new packets arrived - read from wtap, count */
|
||||
extern void capture_info_new_packets(int to_read, wtap *wtap, info_data_t* cap_info);
|
||||
|
||||
/** Create the capture info dialog */
|
||||
extern void
|
||||
capture_info_ui_create(capture_info *cinfo, capture_session *cap_session);
|
||||
|
@ -60,7 +57,7 @@ capture_info *cinfo);
|
|||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* capture_info.h */
|
||||
#endif /* ui/capture_info.h */
|
||||
|
||||
/*
|
||||
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#include <glib.h>
|
||||
|
||||
#include "capture_info.h"
|
||||
#include "ui/capture_info.h"
|
||||
|
||||
#include "epan/capture_dissectors.h"
|
||||
#include "epan/proto.h"
|
||||
|
|
Loading…
Reference in New Issue