2003-01-08 01:59:42 +00:00
|
|
|
/* color_filters.h
|
|
|
|
* Definitions for color filters
|
|
|
|
*
|
2006-05-21 05:12:17 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2003-01-08 01:59:42 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
2018-02-08 16:59:17 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
2003-01-08 01:59:42 +00:00
|
|
|
*/
|
|
|
|
#ifndef __COLOR_FILTERS_H__
|
|
|
|
#define __COLOR_FILTERS_H__
|
|
|
|
|
2015-12-22 20:07:00 +00:00
|
|
|
#include "ws_symbol_export.h"
|
|
|
|
|
2021-03-16 09:36:10 +00:00
|
|
|
#include <wsutil/color.h>
|
|
|
|
|
2011-12-29 00:08:47 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
2017-06-10 01:43:00 +00:00
|
|
|
struct epan_dissect;
|
2015-12-22 20:07:00 +00:00
|
|
|
|
2018-10-09 09:46:00 +00:00
|
|
|
#define COLORFILTERS_FILE_NAME "colorfilters"
|
|
|
|
|
2011-07-01 21:13:40 +00:00
|
|
|
#define CONVERSATION_COLOR_PREFIX "___conversation_color_filter___"
|
2004-06-01 20:28:05 +00:00
|
|
|
/** @file
|
|
|
|
* Color filters.
|
|
|
|
*/
|
2004-07-24 02:29:14 +00:00
|
|
|
|
|
|
|
/* Data for a color filter. */
|
|
|
|
typedef struct _color_filter {
|
2013-02-28 23:05:09 +00:00
|
|
|
gchar *filter_name; /* name of the filter */
|
|
|
|
gchar *filter_text; /* text of the filter expression */
|
|
|
|
color_t bg_color; /* background color for packets that match */
|
|
|
|
color_t fg_color; /* foreground color for packets that match */
|
|
|
|
gboolean disabled; /* set if the filter is disabled */
|
|
|
|
|
|
|
|
/* only used inside of color_filters.c */
|
2013-12-03 21:31:04 +00:00
|
|
|
struct epan_dfilter *c_colorfilter; /* compiled filter expression */
|
2013-02-28 23:05:09 +00:00
|
|
|
|
|
|
|
/* only used outside of color_filters.c (beside init) */
|
2004-07-24 02:29:14 +00:00
|
|
|
} color_filter_t;
|
|
|
|
|
2015-12-22 20:07:00 +00:00
|
|
|
/** A color filter was added (while importing).
|
|
|
|
* (color_filters.c calls this for every filter coming in)
|
|
|
|
*
|
|
|
|
* @param colorf the new color filter
|
|
|
|
* @param user_data from caller
|
|
|
|
*/
|
|
|
|
typedef void (*color_filter_add_cb_func)(color_filter_t *colorf, gpointer user_data);
|
2003-01-08 01:59:42 +00:00
|
|
|
|
2006-10-03 18:39:36 +00:00
|
|
|
/** Init the color filters (incl. initial read from file). */
|
2016-01-01 04:14:08 +00:00
|
|
|
WS_DLL_PUBLIC gboolean color_filters_init(gchar** err_msg, color_filter_add_cb_func add_cb);
|
2003-01-08 01:59:42 +00:00
|
|
|
|
2008-01-14 16:40:23 +00:00
|
|
|
/** Reload the color filters */
|
2016-01-01 04:14:08 +00:00
|
|
|
WS_DLL_PUBLIC gboolean color_filters_reload(gchar** err_msg, color_filter_add_cb_func add_cb);
|
2008-01-14 16:40:23 +00:00
|
|
|
|
2006-10-03 23:24:48 +00:00
|
|
|
/** Cleanup remaining color filter zombies */
|
2015-12-22 20:07:00 +00:00
|
|
|
WS_DLL_PUBLIC void color_filters_cleanup(void);
|
2006-10-03 18:39:36 +00:00
|
|
|
|
|
|
|
/** Color filters currently used?
|
2004-06-01 20:28:05 +00:00
|
|
|
*
|
2006-10-03 18:39:36 +00:00
|
|
|
* @return TRUE, if filters are used
|
2004-06-01 20:28:05 +00:00
|
|
|
*/
|
2015-12-22 20:07:00 +00:00
|
|
|
WS_DLL_PUBLIC gboolean color_filters_used(void);
|
2004-06-01 20:28:05 +00:00
|
|
|
|
2007-12-15 23:38:29 +00:00
|
|
|
/** Are there any temporary coloring filters used?
|
|
|
|
*
|
|
|
|
* @return TRUE, if temporary coloring filters are used
|
|
|
|
*/
|
2015-12-22 20:07:00 +00:00
|
|
|
WS_DLL_PUBLIC gboolean tmp_color_filters_used(void);
|
2006-10-03 18:39:36 +00:00
|
|
|
|
2020-06-18 18:43:20 +00:00
|
|
|
/** Get the filter string of a temporary color filter
|
|
|
|
*
|
|
|
|
* @param filt_nr a number 1-10 pointing to a temporary color
|
|
|
|
* @return the current filter string which is assigned to the specified slot, or NULL if not available.
|
|
|
|
*/
|
|
|
|
WS_DLL_PUBLIC gchar*
|
|
|
|
color_filters_get_tmp(guint8 filt_nr);
|
|
|
|
|
2007-11-24 11:38:16 +00:00
|
|
|
/** Set the filter string of a temporary color filter
|
|
|
|
*
|
|
|
|
* @param filt_nr a number 1-10 pointing to a temporary color
|
|
|
|
* @param filter the new filter-string
|
2007-11-25 14:17:56 +00:00
|
|
|
* @param disabled whether the filter-rule should be disabled
|
2016-01-26 08:05:53 +00:00
|
|
|
* @param err_msg a string with error message
|
2007-11-24 11:38:16 +00:00
|
|
|
*/
|
2015-12-22 20:07:00 +00:00
|
|
|
WS_DLL_PUBLIC gboolean
|
|
|
|
color_filters_set_tmp(guint8 filt_nr, const gchar *filter, gboolean disabled, gchar **err_msg);
|
2007-11-25 14:17:56 +00:00
|
|
|
|
2015-07-10 23:15:55 +00:00
|
|
|
/** Get a temporary color filter.
|
|
|
|
*
|
|
|
|
* @param filter_num A number from 1 to 10 specifying the color to fetch.
|
|
|
|
* @return The corresponding color or NULL.
|
|
|
|
*/
|
2015-12-22 20:07:00 +00:00
|
|
|
WS_DLL_PUBLIC const color_filter_t *
|
2015-07-10 23:15:55 +00:00
|
|
|
color_filters_tmp_color(guint8 filter_num);
|
|
|
|
|
2007-11-25 14:17:56 +00:00
|
|
|
/** Reset the temporary color filters
|
|
|
|
*
|
|
|
|
*/
|
2015-12-22 20:07:00 +00:00
|
|
|
WS_DLL_PUBLIC gboolean
|
|
|
|
color_filters_reset_tmp(gchar **err_msg);
|
2006-10-03 18:39:36 +00:00
|
|
|
|
|
|
|
/* Prime the epan_dissect_t with all the compiler
|
2009-09-06 06:07:53 +00:00
|
|
|
* color filters of the current filter list.
|
2006-10-03 18:39:36 +00:00
|
|
|
*
|
|
|
|
* @param the epan dissector details
|
|
|
|
*/
|
2015-12-22 20:07:00 +00:00
|
|
|
WS_DLL_PUBLIC void color_filters_prime_edt(struct epan_dissect *edt);
|
2006-10-03 18:39:36 +00:00
|
|
|
|
|
|
|
/** Colorize a specific packet.
|
|
|
|
*
|
|
|
|
* @param edt the dissected packet
|
|
|
|
* @return the matching color filter or NULL
|
|
|
|
*/
|
2015-12-22 20:07:00 +00:00
|
|
|
WS_DLL_PUBLIC const color_filter_t *
|
2013-12-03 23:49:51 +00:00
|
|
|
color_filters_colorize_packet(struct epan_dissect *edt);
|
2006-10-03 18:39:36 +00:00
|
|
|
|
|
|
|
/** Clone the currently active filter list.
|
|
|
|
*
|
2021-12-20 02:40:23 +00:00
|
|
|
* @param user_data will be returned by each call to color_filter_add_cb()
|
2016-01-26 11:21:57 +00:00
|
|
|
* @param add_cb the callback function to add color filter
|
2006-10-03 18:39:36 +00:00
|
|
|
*/
|
2015-12-22 20:07:00 +00:00
|
|
|
WS_DLL_PUBLIC void color_filters_clone(gpointer user_data, color_filter_add_cb_func add_cb);
|
2005-03-26 01:09:14 +00:00
|
|
|
|
|
|
|
/** Load filters (import) from some other filter file.
|
|
|
|
*
|
2006-10-03 18:39:36 +00:00
|
|
|
* @param path the path to the import file
|
2021-12-20 02:40:23 +00:00
|
|
|
* @param user_data will be returned by each call to color_filter_add_cb()
|
2016-01-26 08:05:53 +00:00
|
|
|
* @param err_msg a string with error message
|
|
|
|
* @param add_cb the callback function to add color filter
|
2005-03-26 01:09:14 +00:00
|
|
|
* @return TRUE, if read succeeded
|
|
|
|
*/
|
2016-01-05 12:06:36 +00:00
|
|
|
WS_DLL_PUBLIC gboolean color_filters_import(const gchar *path, gpointer user_data, gchar **err_msg, color_filter_add_cb_func add_cb);
|
2005-03-26 01:09:14 +00:00
|
|
|
|
2006-10-03 18:39:36 +00:00
|
|
|
/** Read filters from the global filter file (not the users file).
|
2005-03-26 01:09:14 +00:00
|
|
|
*
|
2021-12-20 02:40:23 +00:00
|
|
|
* @param user_data will be returned by each call to color_filter_add_cb()
|
2016-01-26 08:05:53 +00:00
|
|
|
* @param err_msg a string with error message
|
|
|
|
* @param add_cb the callback function to add color filter
|
2006-10-03 18:39:36 +00:00
|
|
|
* @return TRUE, if read succeeded
|
2005-03-26 01:09:14 +00:00
|
|
|
*/
|
2016-01-01 04:14:08 +00:00
|
|
|
WS_DLL_PUBLIC gboolean color_filters_read_globals(gpointer user_data, gchar** err_msg, color_filter_add_cb_func add_cb);
|
2006-10-03 18:39:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
/** Apply a changed filter list.
|
2005-03-26 11:32:43 +00:00
|
|
|
*
|
2007-11-25 12:36:33 +00:00
|
|
|
* @param tmp_cfl the temporary color filter list to apply
|
|
|
|
* @param edit_cfl the edited permanent color filter list to apply
|
2016-01-26 11:21:57 +00:00
|
|
|
* @param err_msg a string with error message
|
2005-03-26 11:32:43 +00:00
|
|
|
*/
|
2015-12-22 20:07:00 +00:00
|
|
|
WS_DLL_PUBLIC gboolean color_filters_apply(GSList *tmp_cfl, GSList *edit_cfl, gchar** err_msg);
|
2005-03-26 11:32:43 +00:00
|
|
|
|
2006-10-03 18:39:36 +00:00
|
|
|
/** Save filters in users filter file.
|
2005-03-27 02:19:51 +00:00
|
|
|
*
|
2006-10-03 18:39:36 +00:00
|
|
|
* @param cfl the filter list to write
|
2016-01-26 11:21:57 +00:00
|
|
|
* @param err_msg a string with error message
|
2006-10-03 18:39:36 +00:00
|
|
|
* @return TRUE if write succeeded
|
2005-03-27 02:19:51 +00:00
|
|
|
*/
|
2015-12-22 20:07:00 +00:00
|
|
|
WS_DLL_PUBLIC gboolean color_filters_write(GSList *cfl, gchar** err_msg);
|
2005-03-27 02:19:51 +00:00
|
|
|
|
2006-10-03 18:39:36 +00:00
|
|
|
/** Save filters (export) to some other filter file.
|
2005-03-26 11:32:43 +00:00
|
|
|
*
|
2006-10-03 18:39:36 +00:00
|
|
|
* @param path the path to the filter file
|
|
|
|
* @param cfl the filter list to write
|
|
|
|
* @param only_selected TRUE if only the selected filters should be saved
|
2016-01-26 11:21:57 +00:00
|
|
|
* @param err_msg a string with error message
|
2006-10-03 18:39:36 +00:00
|
|
|
* @return TRUE, if write succeeded
|
2005-03-26 11:32:43 +00:00
|
|
|
*/
|
2016-01-20 13:24:09 +00:00
|
|
|
WS_DLL_PUBLIC gboolean color_filters_export(const gchar *path, GSList *cfl, gboolean only_selected, gchar** err_msg);
|
2005-03-26 11:32:43 +00:00
|
|
|
|
2006-10-03 18:39:36 +00:00
|
|
|
/** Create a new color filter (g_malloc'ed).
|
2004-06-01 20:28:05 +00:00
|
|
|
*
|
|
|
|
* @param name the name of the filter
|
|
|
|
* @param filter_string the filter string
|
|
|
|
* @param bg_color background color
|
|
|
|
* @param fg_color foreground color
|
2010-08-26 20:31:09 +00:00
|
|
|
* @param disabled gboolean
|
2004-06-01 20:28:05 +00:00
|
|
|
* @return the new color filter
|
|
|
|
*/
|
2015-12-22 20:07:00 +00:00
|
|
|
WS_DLL_PUBLIC color_filter_t *color_filter_new(
|
2006-10-03 18:39:36 +00:00
|
|
|
const gchar *name, const gchar *filter_string,
|
2007-11-10 15:18:49 +00:00
|
|
|
color_t *bg_color, color_t *fg_color, gboolean disabled);
|
2004-06-01 20:28:05 +00:00
|
|
|
|
2006-10-03 18:39:36 +00:00
|
|
|
/** Delete a single color filter (g_free'ed).
|
2004-06-01 20:28:05 +00:00
|
|
|
*
|
|
|
|
* @param colorf the color filter to be removed
|
|
|
|
*/
|
2015-12-22 20:07:00 +00:00
|
|
|
WS_DLL_PUBLIC void color_filter_delete(color_filter_t *colorf);
|
2006-10-03 18:39:36 +00:00
|
|
|
|
|
|
|
/** Delete a filter list including all entries.
|
2004-07-24 02:29:14 +00:00
|
|
|
*
|
2006-10-03 18:39:36 +00:00
|
|
|
* @param cfl the filter list to delete
|
2004-07-24 02:29:14 +00:00
|
|
|
*/
|
2015-12-22 20:07:00 +00:00
|
|
|
WS_DLL_PUBLIC void color_filter_list_delete(GSList **cfl);
|
2006-10-03 18:39:36 +00:00
|
|
|
|
2011-12-29 00:08:47 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif /* __cplusplus */
|
2004-07-24 02:29:14 +00:00
|
|
|
|
2003-01-08 01:59:42 +00:00
|
|
|
#endif
|
2013-02-28 23:05:09 +00:00
|
|
|
|
|
|
|
/*
|
2019-07-26 18:43:17 +00:00
|
|
|
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
2013-02-28 23:05:09 +00:00
|
|
|
*
|
|
|
|
* 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:
|
|
|
|
*/
|