forked from osmocom/wireshark
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>
This commit is contained in:
parent
751e078d2b
commit
e52c95c6c8
|
@ -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
|
||||
|
|
|
@ -132,7 +132,6 @@ set(LIBWIRESHARK_FILES
|
|||
oids.c
|
||||
osi-utils.c
|
||||
oui.c
|
||||
packet_range.c
|
||||
packet.c
|
||||
print.c
|
||||
print_stream.c
|
||||
|
|
|
@ -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 \
|
||||
|
|
28
epan/print.c
28
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);
|
||||
|
|
42
epan/print.h
42
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);
|
||||
|
|
8
file.c
8
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);
|
||||
|
||||
|
|
27
file.h
27
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.
|
||||
*
|
||||
|
|
17
tfshark.c
17
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))
|
||||
|
|
32
tshark.c
32
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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
|
||||
}
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
#include <glib.h>
|
||||
|
||||
#include "epan/packet_range.h"
|
||||
#include "ui/packet_range.h"
|
||||
|
||||
#include "syntax_line_edit.h"
|
||||
#include <QGroupBox>
|
||||
|
|
Loading…
Reference in New Issue