From c7a136a5c08934ad5b639cd80e7dd1d33ae4a6cc Mon Sep 17 00:00:00 2001 From: John Thacker Date: Sat, 6 Aug 2022 09:31:23 -0400 Subject: [PATCH] epan: Rearrange column includes Move all the declarations of routines that are internal and not for use by dissectors from column-utils.h column-info.h Move the column max length defines into column-utils.h because dissectors might need that Since packet.h already includes column-utils.h, dissectors don't need to include column-utils.h anymore. Remove or downgrade a few other column header includes that are unnecessary. --- epan/column-info.h | 57 ++++++++++++-- epan/column-utils.h | 75 ++----------------- epan/column.c | 1 + epan/column.h | 5 +- epan/dissectors/packet-dlt.c | 1 - epan/dissectors/packet-frame.c | 1 - epan/dissectors/packet-lbmc.c | 1 - epan/dissectors/packet-lbmsrs.c | 2 - epan/dissectors/packet-rtps-processed.c | 1 - .../packet-rtps-virtual-transport.c | 1 - epan/epan.c | 2 +- epan/packet.c | 1 + epan/sequence_analysis.c | 2 +- fuzz/fuzzshark.c | 1 + sharkd_session.c | 1 + ui/qt/column_editor_frame.cpp | 1 - ui/qt/column_preferences_frame.cpp | 1 - ui/qt/models/column_list_model.cpp | 1 - ui/qt/models/packet_list_record.cpp | 1 - ui/qt/models/packet_list_record.h | 2 +- ui/qt/packet_list.cpp | 1 - ui/qt/widgets/syntax_line_edit.cpp | 2 +- 22 files changed, 69 insertions(+), 92 deletions(-) diff --git a/epan/column-info.h b/epan/column-info.h index 5f611f3e93..89fb024b22 100644 --- a/epan/column-info.h +++ b/epan/column-info.h @@ -1,5 +1,7 @@ /* column-info.h - * Definitions for column structures and routines + * Definitions for internal column structures and routines + * + * For internal Wireshark use only. Don't include this header in dissectors! * * Wireshark - Network traffic analyzer * By Gerald Combs @@ -22,10 +24,6 @@ extern "C" { * Column info. */ -#define COL_MAX_LEN 2048 -#define COL_MAX_INFO_LEN 4096 -#define COL_CUSTOM_PRIME_REGEX " *([^ \\|]+) *(?:(?:\\|\\|)|(?:or)| *$){1}" - /** Column expression */ typedef struct { const gchar **col_expr; /**< Filter expression */ @@ -59,6 +57,55 @@ struct epan_column_info { GRegex *prime_regex; /**< Used to prime custom columns */ }; +/** Allocate all the data structures for constructing column data, given + * the number of columns. + */ +WS_DLL_PUBLIC void col_setup(column_info *cinfo, const gint num_cols); + +/** Cleanup all the data structures for constructing column data; + * undoes the alocations that col_setup() does. + */ +WS_DLL_PUBLIC void col_cleanup(column_info *cinfo); + +/** Initialize the data structures for constructing column data. + */ +extern void col_init(column_info *cinfo, const struct epan_session *epan); + +/** Fill in all columns of the given packet which are based on values from frame_data. + */ +WS_DLL_PUBLIC void col_fill_in_frame_data(const frame_data *fd, column_info *cinfo, const gint col, gboolean const fill_col_exprs); + +/** Fill in all columns of the given packet. + */ +WS_DLL_PUBLIC void col_fill_in(packet_info *pinfo, const gboolean fill_col_exprs, const gboolean fill_fd_colums); + +/** Fill in columns if we got an error reading the packet. + * We set most columns to "???", and set the Info column to an error + * message. + */ +WS_DLL_PUBLIC void col_fill_in_error(column_info *cinfo, frame_data *fdata, const gboolean fill_col_exprs, const gboolean fill_fd_colums); + +/** Check to see if our column data has changed, e.g. we have new request/response info. + */ +WS_DLL_PUBLIC gboolean col_data_changed(void); + +void col_custom_set_edt(struct epan_dissect *edt, column_info *cinfo); + +WS_DLL_PUBLIC +void col_custom_prime_edt(struct epan_dissect *edt, column_info *cinfo); + +WS_DLL_PUBLIC +gboolean have_custom_cols(column_info *cinfo); + +WS_DLL_PUBLIC +gboolean have_field_extractors(void); + +WS_DLL_PUBLIC +gboolean col_has_time_fmt(column_info *cinfo, const gint col); + +WS_DLL_PUBLIC +gboolean col_based_on_frame_data(column_info *cinfo, const gint col); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/epan/column-utils.h b/epan/column-utils.h index 6d39191422..91c2b9e3dc 100644 --- a/epan/column-utils.h +++ b/epan/column-utils.h @@ -1,5 +1,6 @@ /** @file * Definitions for column utility structures and routines + * Utility routines used by packet*.c * * Wireshark - Network traffic analyzer * By Gerald Combs @@ -20,6 +21,10 @@ extern "C" { #endif /* __cplusplus */ +#define COL_MAX_LEN 2048 +#define COL_MAX_INFO_LEN 4096 +#define COL_CUSTOM_PRIME_REGEX " *([^ \\|]+) *(?:(?:\\|\\|)|(?:or)| *$){1}" + struct epan_dissect; /** @@ -92,54 +97,6 @@ enum { NUM_COL_FMTS /**< 50) Should always be last */ }; -/** Allocate all the data structures for constructing column data, given - * the number of columns. - * - * Internal, don't use this in dissectors! - */ -WS_DLL_PUBLIC void col_setup(column_info *cinfo, const gint num_cols); - -/** Cleanup all the data structures for constructing column data; - * undoes the alocations that col_setup() does. - * - * Internal, don't use this in dissectors! - */ -WS_DLL_PUBLIC void col_cleanup(column_info *cinfo); - -/** Initialize the data structures for constructing column data. - * - * Internal, don't use this in dissectors! - */ -extern void col_init(column_info *cinfo, const struct epan_session *epan); - -/** Fill in all columns of the given packet which are based on values from frame_data. - * - * Internal, don't use this in dissectors! - */ -WS_DLL_PUBLIC void col_fill_in_frame_data(const frame_data *fd, column_info *cinfo, const gint col, gboolean const fill_col_exprs); - -/** Fill in all columns of the given packet. - * - * Internal, don't use this in dissectors! - */ -WS_DLL_PUBLIC void col_fill_in(packet_info *pinfo, const gboolean fill_col_exprs, const gboolean fill_fd_colums); - -/** Fill in columns if we got an error reading the packet. - * We set most columns to "???", and set the Info column to an error - * message. - * - * Internal, don't use this in dissectors! - */ -WS_DLL_PUBLIC void col_fill_in_error(column_info *cinfo, frame_data *fdata, const gboolean fill_col_exprs, const gboolean fill_fd_colums); - -/** Check to see if our column data has changed, e.g. we have new request/response info. - * - * Internal, don't use this in dissectors! - */ -WS_DLL_PUBLIC gboolean col_data_changed(void); - -/* Utility routines used by packet*.c */ - /** Are the columns writable? * * @param cinfo the current packet row @@ -227,28 +184,6 @@ WS_DLL_PUBLIC void col_add_lstr(column_info *cinfo, const gint el, const gchar * WS_DLL_PUBLIC void col_add_fstr(column_info *cinfo, const gint col, const gchar *format, ...) G_GNUC_PRINTF(3, 4); -/** For internal Wireshark use only. Not to be called from dissectors. */ -void col_custom_set_edt(struct epan_dissect *edt, column_info *cinfo); - -/** For internal Wireshark use only. Not to be called from dissectors. */ -WS_DLL_PUBLIC -void col_custom_prime_edt(struct epan_dissect *edt, column_info *cinfo); - -/** For internal Wireshark use only. Not to be called from dissectors. */ -WS_DLL_PUBLIC -gboolean have_custom_cols(column_info *cinfo); - -/** For internal Wireshark use only. Not to be called from dissectors. */ -WS_DLL_PUBLIC -gboolean have_field_extractors(void); - -/** For internal Wireshark use only. Not to be called from dissectors. */ -WS_DLL_PUBLIC -gboolean col_has_time_fmt(column_info *cinfo, const gint col); -/** For internal Wireshark use only. Not to be called from dissectors. */ -WS_DLL_PUBLIC -gboolean col_based_on_frame_data(column_info *cinfo, const gint col); - /** Append the given text to a column element, the text will be copied. * * @param cinfo the current packet row diff --git a/epan/column.c b/epan/column.c index 4ae7f3c2f9..6f53efb494 100644 --- a/epan/column.c +++ b/epan/column.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include diff --git a/epan/column.h b/epan/column.h index 4a042adfc9..d81517a1dd 100644 --- a/epan/column.h +++ b/epan/column.h @@ -1,5 +1,8 @@ /** @file * Definitions for column handling routines + * Column preference and format settings. + * + * For internal Wireshark useonly. Don't include this header in dissectors! * * Wireshark - Network traffic analyzer * By Gerald Combs @@ -12,7 +15,7 @@ #define __COLUMN_H__ #include "ws_symbol_export.h" -#include +#include #ifdef __cplusplus extern "C" { diff --git a/epan/dissectors/packet-dlt.c b/epan/dissectors/packet-dlt.c index 4879ea2d78..cc4b595d81 100644 --- a/epan/dissectors/packet-dlt.c +++ b/epan/dissectors/packet-dlt.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include diff --git a/epan/dissectors/packet-frame.c b/epan/dissectors/packet-frame.c index 608d046992..5258c49a09 100644 --- a/epan/dissectors/packet-frame.c +++ b/epan/dissectors/packet-frame.c @@ -38,7 +38,6 @@ #include "packet-frame.h" #include "packet-icmp.h" -#include #include void proto_register_frame(void); diff --git a/epan/dissectors/packet-lbmc.c b/epan/dissectors/packet-lbmc.c index 05743aed0f..b078c224f5 100644 --- a/epan/dissectors/packet-lbmc.c +++ b/epan/dissectors/packet-lbmc.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include "packet-lbm.h" diff --git a/epan/dissectors/packet-lbmsrs.c b/epan/dissectors/packet-lbmsrs.c index 39b1b14526..c9035ef1dc 100644 --- a/epan/dissectors/packet-lbmsrs.c +++ b/epan/dissectors/packet-lbmsrs.c @@ -17,11 +17,9 @@ #include "config.h" #include #include -#include #include #include #include -#include #include #include #include diff --git a/epan/dissectors/packet-rtps-processed.c b/epan/dissectors/packet-rtps-processed.c index 74bf9413aa..852ba5b265 100644 --- a/epan/dissectors/packet-rtps-processed.c +++ b/epan/dissectors/packet-rtps-processed.c @@ -60,7 +60,6 @@ #include #include #include -#include #include #include diff --git a/epan/dissectors/packet-rtps-virtual-transport.c b/epan/dissectors/packet-rtps-virtual-transport.c index a640a8ed09..1b1222ffe9 100644 --- a/epan/dissectors/packet-rtps-virtual-transport.c +++ b/epan/dissectors/packet-rtps-virtual-transport.c @@ -60,7 +60,6 @@ #include #include #include -#include #include #include diff --git a/epan/epan.c b/epan/epan.c index 55ed2a3164..a7ef10e85b 100644 --- a/epan/epan.c +++ b/epan/epan.c @@ -39,7 +39,7 @@ #include "except.h" #include "packet.h" #include "prefs.h" -#include "column-utils.h" +#include "column-info.h" #include "tap.h" #include "addr_resolv.h" #include "oids.h" diff --git a/epan/packet.c b/epan/packet.c index 1b12b2cf95..2947e5e03e 100644 --- a/epan/packet.c +++ b/epan/packet.c @@ -32,6 +32,7 @@ #include +#include #include #include #include diff --git a/epan/sequence_analysis.c b/epan/sequence_analysis.c index 7842754329..966617de5f 100644 --- a/epan/sequence_analysis.c +++ b/epan/sequence_analysis.c @@ -17,7 +17,7 @@ #include "addr_resolv.h" #include "proto.h" #include "color_filters.h" -#include "column-info.h" +#include #include "tap.h" #include diff --git a/fuzz/fuzzshark.c b/fuzz/fuzzshark.c index e6ee5720b8..e31ff8cd73 100644 --- a/fuzz/fuzzshark.c +++ b/fuzz/fuzzshark.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include diff --git a/sharkd_session.c b/sharkd_session.c index 9d3443236a..866f596fcc 100644 --- a/sharkd_session.c +++ b/sharkd_session.c @@ -34,6 +34,7 @@ #include #include +#include #include diff --git a/ui/qt/column_editor_frame.cpp b/ui/qt/column_editor_frame.cpp index 6ca0e9597f..ea527b9a87 100644 --- a/ui/qt/column_editor_frame.cpp +++ b/ui/qt/column_editor_frame.cpp @@ -11,7 +11,6 @@ #include -#include #include #include #include diff --git a/ui/qt/column_preferences_frame.cpp b/ui/qt/column_preferences_frame.cpp index 5dad7524f0..961e2737a5 100644 --- a/ui/qt/column_preferences_frame.cpp +++ b/ui/qt/column_preferences_frame.cpp @@ -11,7 +11,6 @@ #include -#include #include #include #include diff --git a/ui/qt/models/column_list_model.cpp b/ui/qt/models/column_list_model.cpp index a5f20f1bcb..a0e5c8ba80 100644 --- a/ui/qt/models/column_list_model.cpp +++ b/ui/qt/models/column_list_model.cpp @@ -14,7 +14,6 @@ #include #include -#include #include #include #include diff --git a/ui/qt/models/packet_list_record.cpp b/ui/qt/models/packet_list_record.cpp index 1db703d622..60f017dd5c 100644 --- a/ui/qt/models/packet_list_record.cpp +++ b/ui/qt/models/packet_list_record.cpp @@ -12,7 +12,6 @@ #include #include -#include #include #include #include diff --git a/ui/qt/models/packet_list_record.h b/ui/qt/models/packet_list_record.h index b764936e35..29ca64a3dd 100644 --- a/ui/qt/models/packet_list_record.h +++ b/ui/qt/models/packet_list_record.h @@ -16,7 +16,7 @@ #include "cfile.h" -#include +#include #include #include diff --git a/ui/qt/packet_list.cpp b/ui/qt/packet_list.cpp index 5cc8fdb3be..837a9a9b1b 100644 --- a/ui/qt/packet_list.cpp +++ b/ui/qt/packet_list.cpp @@ -18,7 +18,6 @@ #include #include -#include #include #include #include diff --git a/ui/qt/widgets/syntax_line_edit.cpp b/ui/qt/widgets/syntax_line_edit.cpp index 634589e6e0..43058a6627 100644 --- a/ui/qt/widgets/syntax_line_edit.cpp +++ b/ui/qt/widgets/syntax_line_edit.cpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include