aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2017-04-23 16:48:17 -0700
committerGuy Harris <guy@alum.mit.edu>2017-04-24 03:38:21 +0000
commite52c95c6c8cdac34eccdba9b49d68a6982685f1a (patch)
treefc479aac517dbee8b5a6a82ea33ec40a482cc248
parent751e078d2bc6adf1179de164291eb743abd8732b (diff)
Move UI-only stuff out of libwireshark.
Packet ranges are used only in the UI; move the packet range stuff into libui. Don't pass a print_args_t structure to libwireshark packet-printing routines, just pass the few parameters they need. Move the declaration of print_args_t into file.h. Change-Id: Icff5991eea7d7d56f33b4716105895263d275bcf Reviewed-on: https://code.wireshark.org/review/21308 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Guy Harris <guy@alum.mit.edu>
-rw-r--r--debian/libwireshark0.symbols6
-rw-r--r--epan/CMakeLists.txt1
-rw-r--r--epan/Makefile.am2
-rw-r--r--epan/print.c28
-rw-r--r--epan/print.h42
-rw-r--r--file.c8
-rw-r--r--file.h27
-rw-r--r--tfshark.c17
-rw-r--r--tshark.c32
-rw-r--r--ui/CMakeLists.txt1
-rw-r--r--ui/Makefile.am2
-rw-r--r--ui/packet_range.c (renamed from epan/packet_range.c)0
-rw-r--r--ui/packet_range.h (renamed from epan/packet_range.h)13
-rw-r--r--ui/qt/capture_file_dialog.cpp2
-rw-r--r--ui/qt/export_dissection_dialog.cpp2
-rw-r--r--ui/qt/packet_range_group_box.h2
16 files changed, 86 insertions, 99 deletions
diff --git a/debian/libwireshark0.symbols b/debian/libwireshark0.symbols
index 133805e..36a704b 100644
--- a/debian/libwireshark0.symbols
+++ b/debian/libwireshark0.symbols
@@ -924,12 +924,6 @@ libwireshark.so.0 libwireshark0 #MINVER#
p_add_proto_data@Base 1.9.1
p_get_proto_data@Base 1.9.1
p_remove_proto_data@Base 1.12.0~rc1
- packet_range_check@Base 1.12.0~rc1
- packet_range_convert_str@Base 1.12.0~rc1
- packet_range_init@Base 1.12.0~rc1
- packet_range_process_all@Base 1.12.0~rc1
- packet_range_process_init@Base 1.12.0~rc1
- packet_range_process_packet@Base 1.12.0~rc1
parse_key_string@Base 1.9.1
pfilter_expression_head@Base 1.9.1
plugin_if_apply_filter@Base 1.99.8
diff --git a/epan/CMakeLists.txt b/epan/CMakeLists.txt
index 4ebc03f..1d3c7ac 100644
--- a/epan/CMakeLists.txt
+++ b/epan/CMakeLists.txt
@@ -132,7 +132,6 @@ set(LIBWIRESHARK_FILES
oids.c
osi-utils.c
oui.c
- packet_range.c
packet.c
print.c
print_stream.c
diff --git a/epan/Makefile.am b/epan/Makefile.am
index 1b9878f..46d8bd0 100644
--- a/epan/Makefile.am
+++ b/epan/Makefile.am
@@ -95,7 +95,6 @@ LIBWIRESHARK_SRC = \
oids.c \
osi-utils.c \
oui.c \
- packet_range.c \
packet.c \
prefs.c \
print.c \
@@ -247,7 +246,6 @@ LIBWIRESHARK_INCLUDES = \
oids.h \
osi-utils.h \
oui.h \
- packet_range.h \
packet.h \
packet_info.h \
params.h \
diff --git a/epan/print.c b/epan/print.c
index 5ce5e2b..90710f5 100644
--- a/epan/print.c
+++ b/epan/print.c
@@ -32,7 +32,7 @@
#include <epan/epan_dissect.h>
#include <epan/to_str.h>
#include <epan/expert.h>
-#include <epan/packet_range.h>
+#include <epan/column-info.h>
#include <epan/prefs.h>
#include <epan/print.h>
#include <epan/charsets.h>
@@ -135,8 +135,9 @@ void print_cache_field_handles(void)
}
gboolean
-proto_tree_print(print_args_t *print_args, epan_dissect_t *edt,
- GHashTable *output_only_tables, print_stream_t *stream)
+proto_tree_print(print_dissections_e print_dissections, gboolean print_hex_data,
+ epan_dissect_t *edt, GHashTable *output_only_tables,
+ print_stream_t *stream)
{
print_data data;
@@ -146,10 +147,10 @@ proto_tree_print(print_args_t *print_args, epan_dissect_t *edt,
data.success = TRUE;
data.src_list = edt->pi.data_src;
data.encoding = (packet_char_enc)edt->pi.fd->flags.encoding;
- data.print_dissections = print_args->print_dissections;
+ data.print_dissections = print_dissections;
/* If we're printing the entire packet in hex, don't
print uninterpreted data fields in hex as well. */
- data.print_hex_for_data = !print_args->print_hex;
+ data.print_hex_for_data = !print_hex_data;
data.output_only_tables = output_only_tables;
proto_tree_children_foreach(edt->tree, proto_tree_print_node, &data);
@@ -337,7 +338,11 @@ write_pdml_proto_tree(output_fields_t* fields, gchar **protocolfilter, pf_flags
}
void
-write_json_proto_tree(output_fields_t* fields, print_args_t *print_args, gchar **protocolfilter, pf_flags protocolfilter_flags, epan_dissect_t *edt, FILE *fh)
+write_json_proto_tree(output_fields_t* fields,
+ print_dissections_e print_dissections,
+ gboolean print_hex_data, gchar **protocolfilter,
+ pf_flags protocolfilter_flags, epan_dissect_t *edt,
+ FILE *fh)
{
write_json_data data;
char ts[30];
@@ -373,9 +378,9 @@ write_json_proto_tree(output_fields_t* fields, print_args_t *print_args, gchar *
data.src_list = edt->pi.data_src;
data.filter = protocolfilter;
data.filter_flags = protocolfilter_flags;
- data.print_hex = print_args->print_hex;
+ data.print_hex = print_hex_data;
data.print_text = TRUE;
- if (print_args->print_dissections == print_dissections_none) {
+ if (print_dissections == print_dissections_none) {
data.print_text = FALSE;
}
@@ -393,7 +398,10 @@ write_json_proto_tree(output_fields_t* fields, print_args_t *print_args, gchar *
}
void
-write_ek_proto_tree(output_fields_t* fields, print_args_t *print_args, gchar **protocolfilter, pf_flags protocolfilter_flags, epan_dissect_t *edt, FILE *fh)
+write_ek_proto_tree(output_fields_t* fields,
+ gboolean print_hex_data, gchar **protocolfilter,
+ pf_flags protocolfilter_flags, epan_dissect_t *edt,
+ FILE *fh)
{
write_json_data data;
char ts[30];
@@ -421,7 +429,7 @@ write_ek_proto_tree(output_fields_t* fields, print_args_t *print_args, gchar **p
data.src_list = edt->pi.data_src;
data.filter = protocolfilter;
data.filter_flags = protocolfilter_flags;
- data.print_hex = print_args->print_hex;
+ data.print_hex = print_hex_data;
proto_tree_children_foreach(edt->tree, proto_tree_write_node_ek,
&data);
diff --git a/epan/print.h b/epan/print.h
index ef7330b..6dedc30 100644
--- a/epan/print.h
+++ b/epan/print.h
@@ -32,8 +32,6 @@
#include <epan/print_stream.h>
-#include <epan/packet_range.h>
-
#include "ws_symbol_export.h"
#ifdef __cplusplus
@@ -46,14 +44,6 @@ typedef enum {
PR_FMT_PS /* postscript */
} print_format_e;
-/* print_range, enum which frames should be printed */
-typedef enum {
- print_range_selected_only, /* selected frame(s) only (currently only one) */
- print_range_marked_only, /* marked frames only */
- print_range_all_displayed, /* all frames currently displayed */
- print_range_all_captured /* all frames in capture */
-} print_range_e;
-
/* print_dissections, enum how the dissections should be printed */
typedef enum {
print_dissections_none, /* no dissections at all */
@@ -62,22 +52,6 @@ typedef enum {
print_dissections_expanded /* all dissection details */
} print_dissections_e;
-typedef struct {
- print_stream_t *stream; /* the stream to which we're printing */
- print_format_e format; /* plain text or PostScript */
- gboolean to_file; /* TRUE if we're printing to a file */
- char *file; /* file output pathname */
- char *cmd; /* print command string (not win32) */
- packet_range_t range;
-
- gboolean print_summary; /* TRUE if we should print summary line. */
- gboolean print_col_headings; /* TRUE if we should print column headings */
- print_dissections_e print_dissections;
- gboolean print_hex; /* TRUE if we should print hex data;
- * FALSE if we should print only if not dissected. */
- gboolean print_formfeed; /* TRUE if a formfeed should be printed before
- * each new packet */
-} print_args_t;
typedef enum {
FORMAT_CSV, /* CSV */
@@ -110,7 +84,8 @@ WS_DLL_PUBLIC gboolean output_fields_has_cols(output_fields_t* info);
* Higher-level packet-printing code.
*/
-WS_DLL_PUBLIC gboolean proto_tree_print(print_args_t *print_args,
+WS_DLL_PUBLIC gboolean proto_tree_print(print_dissections_e print_dissections,
+ gboolean print_hex_data,
epan_dissect_t *edt,
GHashTable *output_only_tables,
print_stream_t *stream);
@@ -121,10 +96,19 @@ WS_DLL_PUBLIC void write_pdml_proto_tree(output_fields_t* fields, gchar **protoc
WS_DLL_PUBLIC void write_pdml_finale(FILE *fh);
WS_DLL_PUBLIC void write_json_preamble(FILE *fh);
-WS_DLL_PUBLIC void write_json_proto_tree(output_fields_t* fields, print_args_t *print_args, gchar **protocolfilter, pf_flags protocolfilter_flags, epan_dissect_t *edt, FILE *fh);
+WS_DLL_PUBLIC void write_json_proto_tree(output_fields_t* fields,
+ print_dissections_e print_dissections,
+ gboolean print_hex_data,
+ gchar **protocolfilter,
+ pf_flags protocolfilter_flags,
+ epan_dissect_t *edt, FILE *fh);
WS_DLL_PUBLIC void write_json_finale(FILE *fh);
-WS_DLL_PUBLIC void write_ek_proto_tree(output_fields_t* fields, print_args_t *print_args, gchar **protocolfilter, pf_flags protocolfilter_flags, epan_dissect_t *edt, FILE *fh);
+WS_DLL_PUBLIC void write_ek_proto_tree(output_fields_t* fields,
+ gboolean print_hex_data,
+ gchar **protocolfilter,
+ pf_flags protocolfilter_flags,
+ epan_dissect_t *edt, FILE *fh);
WS_DLL_PUBLIC void write_psml_preamble(column_info *cinfo, FILE *fh);
WS_DLL_PUBLIC void write_psml_columns(epan_dissect_t *edt, FILE *fh);
diff --git a/file.c b/file.c
index a05cd24..72771c4 100644
--- a/file.c
+++ b/file.c
@@ -2321,7 +2321,9 @@ print_packet(capture_file *cf, frame_data *fdata,
}
/* Print the information in that tree. */
- if (!proto_tree_print(args->print_args, &args->edt, NULL, args->print_args->stream))
+ if (!proto_tree_print(args->print_args->print_dissections,
+ args->print_args->print_hex, &args->edt, NULL,
+ args->print_args->stream))
goto fail;
/* Print a blank line if we print anything after this (aka more than one packet). */
@@ -2848,7 +2850,9 @@ write_json_packet(capture_file *cf, frame_data *fdata,
epan_dissect_run(&args->edt, cf->cd_t, phdr, frame_tvbuff_new(fdata, pd), fdata, NULL);
/* Write out the information in that tree. */
- write_json_proto_tree(NULL, args->print_args, NULL, PF_NONE, &args->edt, args->fh);
+ write_json_proto_tree(NULL, args->print_args->print_dissections,
+ args->print_args->print_hex, NULL, PF_NONE,
+ &args->edt, args->fh);
epan_dissect_reset(&args->edt);
diff --git a/file.h b/file.h
index 226da02..5ff86b6 100644
--- a/file.h
+++ b/file.h
@@ -28,7 +28,7 @@
#include <epan/epan.h>
#include <epan/print.h>
-#include <epan/packet_range.h>
+#include <ui/packet_range.h>
#ifdef __cplusplus
extern "C" {
@@ -417,6 +417,31 @@ cf_read_status_t cf_retap_packets(capture_file *cf);
*/
void cf_timestamp_auto_precision(capture_file *cf);
+/* print_range, enum which frames should be printed */
+typedef enum {
+ print_range_selected_only, /* selected frame(s) only (currently only one) */
+ print_range_marked_only, /* marked frames only */
+ print_range_all_displayed, /* all frames currently displayed */
+ print_range_all_captured /* all frames in capture */
+} print_range_e;
+
+typedef struct {
+ print_stream_t *stream; /* the stream to which we're printing */
+ print_format_e format; /* plain text or PostScript */
+ gboolean to_file; /* TRUE if we're printing to a file */
+ char *file; /* file output pathname */
+ char *cmd; /* print command string (not win32) */
+ packet_range_t range;
+
+ gboolean print_summary; /* TRUE if we should print summary line. */
+ gboolean print_col_headings; /* TRUE if we should print column headings */
+ print_dissections_e print_dissections;
+ gboolean print_hex; /* TRUE if we should print hex data;
+ * FALSE if we should print only if not dissected. */
+ gboolean print_formfeed; /* TRUE if a formfeed should be printed before
+ * each new packet */
+} print_args_t;
+
/**
* Print the capture file.
*
diff --git a/tfshark.c b/tfshark.c
index 54ab61c..16b4b6e 100644
--- a/tfshark.c
+++ b/tfshark.c
@@ -1979,8 +1979,6 @@ print_columns(capture_file *cf)
static gboolean
print_packet(capture_file *cf, epan_dissect_t *edt)
{
- print_args_t print_args;
-
if (print_summary || output_fields_has_cols(output_fields)) {
/* Just fill in the columns. */
epan_dissect_fill_in_columns(edt, FALSE, TRUE);
@@ -2008,19 +2006,8 @@ print_packet(capture_file *cf, epan_dissect_t *edt)
switch (output_action) {
case WRITE_TEXT:
- /* Only initialize the fields that are actually used in proto_tree_print.
- * This is particularly important for .range, as that's heap memory which
- * we would otherwise have to g_free().
- print_args.to_file = TRUE;
- print_args.format = print_format;
- print_args.print_summary = print_summary;
- print_args.print_formfeed = FALSE;
- packet_range_init(&print_args.range, &cfile);
- */
- print_args.print_hex = print_hex;
- print_args.print_dissections = print_details ? print_dissections_expanded : print_dissections_none;
-
- if (!proto_tree_print(&print_args, edt, output_only_tables, print_stream))
+ if (!proto_tree_print(print_details ? print_dissections_expanded : print_dissections_none,
+ print_hex, edt, output_only_tables, print_stream))
return FALSE;
if (!print_hex) {
if (!print_line(print_stream, 0, separator))
diff --git a/tshark.c b/tshark.c
index 2989460..7fc5938 100644
--- a/tshark.c
+++ b/tshark.c
@@ -3779,8 +3779,6 @@ print_columns(capture_file *cf)
static gboolean
print_packet(capture_file *cf, epan_dissect_t *edt)
{
- print_args_t print_args;
-
if (print_summary || output_fields_has_cols(output_fields)) {
/* Just fill in the columns. */
epan_dissect_fill_in_columns(edt, FALSE, TRUE);
@@ -3811,19 +3809,8 @@ print_packet(capture_file *cf, epan_dissect_t *edt)
switch (output_action) {
case WRITE_TEXT:
- /* Only initialize the fields that are actually used in proto_tree_print.
- * This is particularly important for .range, as that's heap memory which
- * we would otherwise have to g_free().
- print_args.to_file = TRUE;
- print_args.format = print_format;
- print_args.print_summary = print_summary;
- print_args.print_formfeed = FALSE;
- packet_range_init(&print_args.range, &cfile);
- */
- print_args.print_hex = print_hex;
- print_args.print_dissections = print_details ? print_dissections_expanded : print_dissections_none;
-
- if (!proto_tree_print(&print_args, edt, output_only_tables, print_stream))
+ if (!proto_tree_print(print_details ? print_dissections_expanded : print_dissections_none,
+ print_hex, edt, output_only_tables, print_stream))
return FALSE;
if (!print_hex) {
if (!print_line(print_stream, 0, separator))
@@ -3840,20 +3827,19 @@ print_packet(capture_file *cf, epan_dissect_t *edt)
printf("\n");
return !ferror(stdout);
case WRITE_JSON:
- print_args.print_dissections = print_dissections_expanded;
- print_args.print_hex = print_hex;
- write_json_proto_tree(output_fields, &print_args, protocolfilter, protocolfilter_flags, edt, stdout);
+ write_json_proto_tree(output_fields, print_dissections_expanded,
+ print_hex, protocolfilter, protocolfilter_flags,
+ edt, stdout);
printf("\n");
return !ferror(stdout);
case WRITE_JSON_RAW:
- print_args.print_dissections = print_dissections_none;
- print_args.print_hex = TRUE;
- write_json_proto_tree(output_fields, &print_args, protocolfilter, protocolfilter_flags, edt, stdout);
+ write_json_proto_tree(output_fields, print_dissections_none, TRUE,
+ protocolfilter, protocolfilter_flags, edt, stdout);
printf("\n");
return !ferror(stdout);
case WRITE_EK:
- print_args.print_hex = print_hex;
- write_ek_proto_tree(output_fields, &print_args, protocolfilter, protocolfilter_flags, edt, stdout);
+ write_ek_proto_tree(output_fields, print_hex, protocolfilter,
+ protocolfilter_flags, edt, stdout);
return !ferror(stdout);
}
}
diff --git a/ui/CMakeLists.txt b/ui/CMakeLists.txt
index d1f778e..8a52ef9 100644
--- a/ui/CMakeLists.txt
+++ b/ui/CMakeLists.txt
@@ -39,6 +39,7 @@ set(COMMON_UI_SRC
language.c
mcast_stream.c
packet_list_utils.c
+ packet_range.c
persfilepath_opt.c
preference_utils.c
profile.c
diff --git a/ui/Makefile.am b/ui/Makefile.am
index c7e9841..776ad42 100644
--- a/ui/Makefile.am
+++ b/ui/Makefile.am
@@ -66,6 +66,7 @@ WIRESHARK_UI_SRC = \
help_url.c \
mcast_stream.c \
packet_list_utils.c \
+ packet_range.c \
persfilepath_opt.c \
preference_utils.c \
profile.c \
@@ -113,6 +114,7 @@ WIRESHARK_UI_INCLUDES = \
language.h \
mcast_stream.h \
main_statusbar.h \
+ packet_range.h \
persfilepath_opt.h \
preference_utils.h \
profile.h \
diff --git a/epan/packet_range.c b/ui/packet_range.c
index a6797e3..a6797e3 100644
--- a/epan/packet_range.c
+++ b/ui/packet_range.c
diff --git a/epan/packet_range.h b/ui/packet_range.h
index 500cdc9..49e8cdb 100644
--- a/epan/packet_range.h
+++ b/ui/packet_range.h
@@ -36,7 +36,6 @@ extern "C" {
#include "cfile.h"
-
extern guint32 curr_selected_frame;
typedef enum {
@@ -94,22 +93,22 @@ typedef enum {
} range_process_e;
/* init the range structure */
-WS_DLL_PUBLIC void packet_range_init(packet_range_t *range, capture_file *cf);
+extern void packet_range_init(packet_range_t *range, capture_file *cf);
/* check whether the packet range is OK */
-WS_DLL_PUBLIC convert_ret_t packet_range_check(packet_range_t *range);
+extern convert_ret_t packet_range_check(packet_range_t *range);
/* init the processing run */
-WS_DLL_PUBLIC void packet_range_process_init(packet_range_t *range);
+extern void packet_range_process_init(packet_range_t *range);
/* do we have to process all packets? */
-WS_DLL_PUBLIC gboolean packet_range_process_all(packet_range_t *range);
+extern gboolean packet_range_process_all(packet_range_t *range);
/* do we have to process this packet? */
-WS_DLL_PUBLIC range_process_e packet_range_process_packet(packet_range_t *range, frame_data *fdata);
+extern range_process_e packet_range_process_packet(packet_range_t *range, frame_data *fdata);
/* convert user given string to the internal user specified range representation */
-WS_DLL_PUBLIC void packet_range_convert_str(packet_range_t *range, const gchar *es);
+extern void packet_range_convert_str(packet_range_t *range, const gchar *es);
#ifdef __cplusplus
}
diff --git a/ui/qt/capture_file_dialog.cpp b/ui/qt/capture_file_dialog.cpp
index cb83f4c..1d6bff7 100644
--- a/ui/qt/capture_file_dialog.cpp
+++ b/ui/qt/capture_file_dialog.cpp
@@ -26,7 +26,7 @@
#ifdef Q_OS_WIN
#include <windows.h>
-#include "epan/packet_range.h"
+#include "ui/packet_range.h"
#include "ui/win32/file_dlg_win32.h"
#else // Q_OS_WIN
diff --git a/ui/qt/export_dissection_dialog.cpp b/ui/qt/export_dissection_dialog.cpp
index 24db5d4..8dd70dd 100644
--- a/ui/qt/export_dissection_dialog.cpp
+++ b/ui/qt/export_dissection_dialog.cpp
@@ -23,7 +23,7 @@
#ifdef Q_OS_WIN
#include <windows.h>
-#include "epan/packet_range.h"
+#include "ui/packet_range.h"
#include "ui/win32/file_dlg_win32.h"
#else // Q_OS_WIN
diff --git a/ui/qt/packet_range_group_box.h b/ui/qt/packet_range_group_box.h
index 769f75f..7a96e58 100644
--- a/ui/qt/packet_range_group_box.h
+++ b/ui/qt/packet_range_group_box.h
@@ -26,7 +26,7 @@
#include <glib.h>
-#include "epan/packet_range.h"
+#include "ui/packet_range.h"
#include "syntax_line_edit.h"
#include <QGroupBox>