Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Functions
color_filters.h File Reference
#include <glib.h>
#include "ws_symbol_export.h"
#include <wsutil/color.h>
#include <wsutil/wmem/wmem_list.h>

Go to the source code of this file.

Classes

struct  _color_filter
 Data for a color filter. More...
 

Macros

#define COLORFILTERS_FILE_NAME   "colorfilters"
 
#define CONVERSATION_COLOR_PREFIX   "___conversation_color_filter___"
 

Typedefs

typedef struct _color_filter color_filter_t
 Data for a color filter.
 
typedef void(* color_filter_add_cb_func) (color_filter_t *colorf, void *user_data)
 A color filter was added (while importing). (color_filters.c calls this for every filter coming in)
 

Functions

WS_DLL_PUBLIC bool color_filters_init (char **err_msg, color_filter_add_cb_func add_cb, const char *app_env_var_prefix)
 Init the color filters (incl. initial read from file).
 
WS_DLL_PUBLIC bool color_filters_reload (char **err_msg, color_filter_add_cb_func add_cb, const char *app_env_var_prefix)
 Reload the color filters.
 
WS_DLL_PUBLIC void color_filters_cleanup (void)
 Cleanup remaining color filter zombies.
 
WS_DLL_PUBLIC bool color_filters_used (void)
 Check if color filters are currently used.
 
WS_DLL_PUBLIC bool tmp_color_filters_used (void)
 Are there any temporary coloring filters used?
 
WS_DLL_PUBLIC char * color_filters_get_tmp (uint8_t filt_nr)
 Get the filter string of a temporary color filter.
 
WS_DLL_PUBLIC bool color_filters_set_tmp (uint8_t filt_nr, const char *filter, bool disabled, char **err_msg)
 Set the filter string of a temporary color filter.
 
WS_DLL_PUBLIC const color_filter_tcolor_filters_tmp_color (uint8_t filter_num)
 Get a temporary color filter.
 
WS_DLL_PUBLIC bool color_filters_reset_tmp (char **err_msg)
 Reset the temporary color filters.
 
WS_DLL_PUBLIC void color_filters_prime_edt (struct epan_dissect *edt)
 Prime the epan_dissect_t with all the compiled color filters of the current filter list.
 
WS_DLL_PUBLIC bool color_filters_use_hfid (int hfid)
 Check if any of the enabled compiled color filters of the current filter list depend on a given header field.
 
WS_DLL_PUBLIC bool color_filters_use_proto (int proto_id)
 Check if any of the enabled compiled color filters of the current filter list depend on any field in a given protocol.
 
WS_DLL_PUBLIC const color_filter_tcolor_filters_colorize_packet (struct epan_dissect *edt)
 Colorize a specific packet.
 
WS_DLL_PUBLIC const color_filter_tcolor_filters_colorize_packet_all (struct epan_dissect *edt, wmem_allocator_t *scope, wmem_list_t **matches)
 Colorize a packet with ALL matching filters.
 
WS_DLL_PUBLIC void color_filter_set_session_disabled (const char *filter_name, bool disabled)
 Set a color filter as session-disabled (paused).
 
WS_DLL_PUBLIC bool color_filter_is_session_disabled (const char *filter_name)
 Check if a color filter is session-disabled.
 
WS_DLL_PUBLIC void color_filter_clear_session_disabled (void)
 Clear all session-disabled filters.
 
WS_DLL_PUBLIC void color_filter_write_paused (const char *app_env_var_prefix)
 Write paused filters to profile directory.
 
WS_DLL_PUBLIC void color_filter_read_paused (const char *app_env_var_prefix)
 Read paused filters from profile directory.
 
WS_DLL_PUBLIC void color_filter_resume_all (const char *app_env_var_prefix)
 Resume all paused filters (clears all session-disabled filters and saves to profile).
 
WS_DLL_PUBLIC void color_filters_clone (void *user_data, color_filter_add_cb_func add_cb)
 Clone the currently active filter list.
 
WS_DLL_PUBLIC bool color_filters_import (const char *path, void *user_data, char **err_msg, color_filter_add_cb_func add_cb)
 Load filters (import) from some other filter file.
 
WS_DLL_PUBLIC bool color_filters_read_globals (void *user_data, char **err_msg, color_filter_add_cb_func add_cb, const char *app_env_var_prefix)
 Read filters from the global filter file (not the users file).
 
WS_DLL_PUBLIC bool color_filters_apply (GSList *tmp_cfl, GSList *edit_cfl, char **err_msg)
 Apply a changed filter list.
 
WS_DLL_PUBLIC bool color_filters_write (GSList *cfl, const char *app_name, const char *app_env_var_prefix, char **err_msg)
 Save filters in users filter file.
 
WS_DLL_PUBLIC bool color_filters_export (const char *path, GSList *cfl, bool only_selected, const char *app_name, char **err_msg)
 Save filters (export) to some other filter file.
 
WS_DLL_PUBLIC color_filter_tcolor_filter_new (const char *name, const char *filter_string, color_t *bg_color, color_t *fg_color, bool disabled)
 Create a new color filter (g_malloc'ed).
 
WS_DLL_PUBLIC void color_filter_delete (color_filter_t *colorf)
 Delete a single color filter (g_free'ed).
 
WS_DLL_PUBLIC void color_filter_list_delete (GSList **cfl)
 Delete a filter list including all entries.
 

Detailed Description

Color filters.

Typedef Documentation

◆ color_filter_add_cb_func

typedef void(* color_filter_add_cb_func) (color_filter_t *colorf, void *user_data)

A color filter was added (while importing). (color_filters.c calls this for every filter coming in)

Parameters
colorfthe new color filter
user_datafrom caller

Function Documentation

◆ color_filter_delete()

WS_DLL_PUBLIC void color_filter_delete ( color_filter_t colorf)

Delete a single color filter (g_free'ed).

Parameters
colorfthe color filter to be removed

◆ color_filter_is_session_disabled()

WS_DLL_PUBLIC bool color_filter_is_session_disabled ( const char *  filter_name)

Check if a color filter is session-disabled.

Parameters
filter_namethe name of the filter to check
Returns
true if disabled, false otherwise

◆ color_filter_list_delete()

WS_DLL_PUBLIC void color_filter_list_delete ( GSList **  cfl)

Delete a filter list including all entries.

Parameters
cflthe filter list to delete

◆ color_filter_new()

WS_DLL_PUBLIC color_filter_t * color_filter_new ( const char *  name,
const char *  filter_string,
color_t bg_color,
color_t fg_color,
bool  disabled 
)

Create a new color filter (g_malloc'ed).

Parameters
namethe name of the filter
filter_stringthe filter string
bg_colorbackground color
fg_colorforeground color
disabledbool
Returns
the new color filter

◆ color_filter_read_paused()

WS_DLL_PUBLIC void color_filter_read_paused ( const char *  app_env_var_prefix)

Read paused filters from profile directory.

Parameters
app_env_var_prefixThe prefix for the application environment variable

◆ color_filter_resume_all()

WS_DLL_PUBLIC void color_filter_resume_all ( const char *  app_env_var_prefix)

Resume all paused filters (clears all session-disabled filters and saves to profile).

Parameters
app_env_var_prefixThe prefix for the application environment variable

◆ color_filter_set_session_disabled()

WS_DLL_PUBLIC void color_filter_set_session_disabled ( const char *  filter_name,
bool  disabled 
)

Set a color filter as session-disabled (paused).

Parameters
filter_namethe name of the filter to disable/enable
disabledtrue to disable, false to enable

◆ color_filter_write_paused()

WS_DLL_PUBLIC void color_filter_write_paused ( const char *  app_env_var_prefix)

Write paused filters to profile directory.

Parameters
app_env_var_prefixThe prefix for the application environment variable

◆ color_filters_apply()

WS_DLL_PUBLIC bool color_filters_apply ( GSList *  tmp_cfl,
GSList *  edit_cfl,
char **  err_msg 
)

Apply a changed filter list.

Parameters
tmp_cflthe temporary color filter list to apply
edit_cflthe edited permanent color filter list to apply
err_msga string with error message

◆ color_filters_clone()

WS_DLL_PUBLIC void color_filters_clone ( void *  user_data,
color_filter_add_cb_func  add_cb 
)

Clone the currently active filter list.

Parameters
user_datawill be returned by each call to color_filter_add_cb()
add_cbthe callback function to add color filter

◆ color_filters_colorize_packet()

WS_DLL_PUBLIC const color_filter_t * color_filters_colorize_packet ( struct epan_dissect edt)

Colorize a specific packet.

Parameters
edtthe dissected packet
Returns
the matching color filter or NULL

◆ color_filters_colorize_packet_all()

WS_DLL_PUBLIC const color_filter_t * color_filters_colorize_packet_all ( struct epan_dissect edt,
wmem_allocator_t scope,
wmem_list_t **  matches 
)

Colorize a packet with ALL matching filters.

Parameters
edtthe dissected packet
scopewmem allocator to use for the returned list (e.g. wmem_file_scope())
matchesoutput parameter: wmem_list_t of matching color_filter_t* (can be NULL)
Returns
the first matching color filter or NULL (for backward compatibility)

◆ color_filters_export()

WS_DLL_PUBLIC bool color_filters_export ( const char *  path,
GSList *  cfl,
bool  only_selected,
const char *  app_name,
char **  err_msg 
)

Save filters (export) to some other filter file.

Parameters
paththe path to the filter file
cflthe filter list to write
only_selectedtrue if only the selected filters should be saved
err_msga string with error message
app_nameProper name of the application (used in comment strings)
Returns
true, if write succeeded

◆ color_filters_get_tmp()

WS_DLL_PUBLIC char * color_filters_get_tmp ( uint8_t  filt_nr)

Get the filter string of a temporary color filter.

Parameters
filt_nra number 1-10 pointing to a temporary color
Returns
the current filter string which is assigned to the specified slot, or NULL if not available.

◆ color_filters_import()

WS_DLL_PUBLIC bool color_filters_import ( const char *  path,
void *  user_data,
char **  err_msg,
color_filter_add_cb_func  add_cb 
)

Load filters (import) from some other filter file.

Parameters
paththe path to the import file
user_datawill be returned by each call to color_filter_add_cb()
err_msga string with error message
add_cbthe callback function to add color filter
Returns
true, if read succeeded

◆ color_filters_init()

WS_DLL_PUBLIC bool color_filters_init ( char **  err_msg,
color_filter_add_cb_func  add_cb,
const char *  app_env_var_prefix 
)

Init the color filters (incl. initial read from file).

Parameters
err_msgPointer to a string that will receive an error message if the initialization fails.
add_cbCallback function to be called when a color filter is added.
app_env_var_prefixPrefix for application environment variables.
Returns
true if the initialization was successful, false otherwise.

◆ color_filters_prime_edt()

WS_DLL_PUBLIC void color_filters_prime_edt ( struct epan_dissect edt)

Prime the epan_dissect_t with all the compiled color filters of the current filter list.

Parameters
edtthe epan dissector details

◆ color_filters_read_globals()

WS_DLL_PUBLIC bool color_filters_read_globals ( void *  user_data,
char **  err_msg,
color_filter_add_cb_func  add_cb,
const char *  app_env_var_prefix 
)

Read filters from the global filter file (not the users file).

Parameters
user_datawill be returned by each call to color_filter_add_cb()
err_msga string with error message
add_cbthe callback function to add color filter
app_env_var_prefixThe prefix for the application environment variable used to get the global configuration directory.
Returns
true, if read succeeded

◆ color_filters_reload()

WS_DLL_PUBLIC bool color_filters_reload ( char **  err_msg,
color_filter_add_cb_func  add_cb,
const char *  app_env_var_prefix 
)

Reload the color filters.

Parameters
err_msgPointer to a string that will receive an error message if the reload fails.
add_cbCallback function to be called when a color filter is added.
app_env_var_prefixPrefix for application environment variables.
Returns
true if the reload was successful, false otherwise.

◆ color_filters_reset_tmp()

WS_DLL_PUBLIC bool color_filters_reset_tmp ( char **  err_msg)

Reset the temporary color filters.

Parameters
err_msga string with error message
Returns
true if successful, false otherwise

◆ color_filters_set_tmp()

WS_DLL_PUBLIC bool color_filters_set_tmp ( uint8_t  filt_nr,
const char *  filter,
bool  disabled,
char **  err_msg 
)

Set the filter string of a temporary color filter.

Parameters
filt_nra number 1-10 pointing to a temporary color
filterthe new filter-string
disabledwhether the filter-rule should be disabled
err_msga string with error message

◆ color_filters_tmp_color()

WS_DLL_PUBLIC const color_filter_t * color_filters_tmp_color ( uint8_t  filter_num)

Get a temporary color filter.

Parameters
filter_numA number from 1 to 10 specifying the color to fetch.
Returns
The corresponding color or NULL.

◆ color_filters_use_hfid()

WS_DLL_PUBLIC bool color_filters_use_hfid ( int  hfid)

Check if any of the enabled compiled color filters of the current filter list depend on a given header field.

Parameters
hfidThe header field ID to check
Returns
true if the color filter contains the header field.

◆ color_filters_use_proto()

WS_DLL_PUBLIC bool color_filters_use_proto ( int  proto_id)

Check if any of the enabled compiled color filters of the current filter list depend on any field in a given protocol.

Parameters
proto_idThe protocol ID to check
Returns
true if the color filter contains a field from the protocol

◆ color_filters_used()

WS_DLL_PUBLIC bool color_filters_used ( void  )

Check if color filters are currently used.

Returns
true, if filters are used

◆ color_filters_write()

WS_DLL_PUBLIC bool color_filters_write ( GSList *  cfl,
const char *  app_name,
const char *  app_env_var_prefix,
char **  err_msg 
)

Save filters in users filter file.

Parameters
cflthe filter list to write
err_msga string with error message
app_nameProper name of the application (used in comment strings)
app_env_var_prefixThe prefix for the application environment variable used to get the global configuration directory.
Returns
true if write succeeded

◆ tmp_color_filters_used()

WS_DLL_PUBLIC bool tmp_color_filters_used ( void  )

Are there any temporary coloring filters used?

Returns
true, if temporary coloring filters are used