Wireshark 5.1.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
tag_rules.h File Reference
#include <glib.h>
#include "ws_symbol_export.h"

Go to the source code of this file.

Classes

struct  _tag_prefs
 Display preferences for the tagging subsystem. More...
struct  _tag_rule
 Data for a single tagging rule. More...

Macros

#define TAGRULES_FILE_NAME   "tagrules.jsonc"

Typedefs

typedef struct _tag_prefs tag_prefs_t
 Display preferences for the tagging subsystem.
typedef struct _tag_rule tag_rule_t
 Data for a single tagging rule.
typedef void(* tag_rule_add_cb_func) (tag_rule_t *rule, void *user_data)
 A tag rule was added (while importing or cloning). (tag_rules.c calls this for every rule coming in).

Enumerations

enum  tag_link_click_mode_t { TAG_LINK_CLICK_SINGLE = 0 , TAG_LINK_CLICK_CTRL , TAG_LINK_CLICK_NONE }
 Controls how a tag link is activated in the packet list. More...

Functions

WS_DLL_PUBLIC void tag_rules_init (void)
 Initialize the tag rules subsystem (read from file).
WS_DLL_PUBLIC void tag_rules_reload (void)
 Reload the tag rules from disk.
WS_DLL_PUBLIC bool tag_rules_write (void)
 Write tag rules to the active profile's tagrules.jsonc file.
WS_DLL_PUBLIC tag_rule_t * tag_rule_new (const char *name, const char *filter, const char *tag_content, const char *tag_url, const char *comment)
 Create a new tag rule (g_new0-allocated).
WS_DLL_PUBLIC void tag_rule_delete (tag_rule_t *rule)
 Delete a single tag rule and free all its memory.
WS_DLL_PUBLIC void tag_rules_clone (tag_rule_add_cb_func cb, void *user_data)
 Clone the currently active tag rule list.
WS_DLL_PUBLIC void tag_rules_apply (GSList *new_list)
 Apply a new tag rule list (called when the dialog OK is pressed).
WS_DLL_PUBLIC const GSList * tag_rules_get_list (void)
 Return the currently active tag rule list.
WS_DLL_PUBLIC void tag_rules_prime_edt (struct epan_dissect *edt)
 Prime an epan_dissect_t with all compiled tag rule filters.
WS_DLL_PUBLIC bool tag_rules_used (void)
WS_DLL_PUBLIC tag_prefs_t tag_rules_get_prefs (void)
 Get the current display preferences.
WS_DLL_PUBLIC void tag_rules_set_prefs (const tag_prefs_t *prefs)
 Set the display preferences (does not write to disk).
WS_DLL_PUBLIC GSList * tag_rules_read_path (const char *path, char **err_msg)
 Read tag rules from a file into a new GSList without touching the active list.
WS_DLL_PUBLIC bool tag_rules_write_path (GSList *list, const char *path, const tag_prefs_t *prefs, char **err_msg)
 Write a rule list to an arbitrary file path.
WS_DLL_PUBLIC bool tag_rules_export_list (GSList *list, const char *path, char **err_msg)
 Write an arbitrary tag rule GSList to a file without touching the active list.
WS_DLL_PUBLIC void tag_rule_list_free (GSList *list)
 Free a GSList of tag_rule_t* (e.g. one built by the model for export).

Detailed Description

Tagging rules — associate user-defined tags with packets via display filters.

Macro Definition Documentation

◆ TAGRULES_FILE_NAME

#define TAGRULES_FILE_NAME   "tagrules.jsonc"

Per-profile tagrules file (JSONC).

Typedef Documentation

◆ tag_prefs_t

typedef struct _tag_prefs tag_prefs_t

Display preferences for the tagging subsystem.

Stored in the profile's tagrules.jsonc file as a leading "prefs_for_tagging_rules" element.

◆ tag_rule_add_cb_func

typedef void(* tag_rule_add_cb_func) (tag_rule_t *rule, void *user_data)

A tag rule was added (while importing or cloning). (tag_rules.c calls this for every rule coming in).

Parameters
rulethe new tag rule
user_datafrom caller

Enumeration Type Documentation

◆ tag_link_click_mode_t

Controls how a tag link is activated in the packet list.

Enumerator
TAG_LINK_CLICK_SINGLE 

Single left-click opens the link.

TAG_LINK_CLICK_CTRL 

Ctrl+Shift+left-click opens the link.

TAG_LINK_CLICK_NONE 

Right-click menu only; click/double-click disabled.

Function Documentation

◆ tag_rule_delete()

WS_DLL_PUBLIC void tag_rule_delete ( tag_rule_t * rule)

Delete a single tag rule and free all its memory.

Parameters
rulethe tag rule to free

◆ tag_rule_list_free()

WS_DLL_PUBLIC void tag_rule_list_free ( GSList * list)

Free a GSList of tag_rule_t* (e.g. one built by the model for export).

Parameters
listGSList of tag_rule_t* to free; each element is also freed.

◆ tag_rule_new()

WS_DLL_PUBLIC tag_rule_t * tag_rule_new ( const char * name,
const char * filter,
const char * tag_content,
const char * tag_url,
const char * comment )

Create a new tag rule (g_new0-allocated).

Parameters
nameRule name (also used as frame.tag value).
filterDisplay filter expression.
tag_contentVisual content for the COL_TAG column.
commentOptional reference comment (may be NULL).
Returns
Newly allocated tag_rule_t; caller takes ownership.

◆ tag_rules_apply()

WS_DLL_PUBLIC void tag_rules_apply ( GSList * new_list)

Apply a new tag rule list (called when the dialog OK is pressed).

Replaces the current list with new_list and compiles all filters.

Parameters
new_listGSList of tag_rule_t* to install as the active list.

◆ tag_rules_clone()

WS_DLL_PUBLIC void tag_rules_clone ( tag_rule_add_cb_func cb,
void * user_data )

Clone the currently active tag rule list.

Iterates the list, clones each rule, and calls cb for each clone.

Parameters
cbCallback invoked for each cloned rule.
user_dataOpaque pointer forwarded to cb.

◆ tag_rules_export_list()

WS_DLL_PUBLIC bool tag_rules_export_list ( GSList * list,
const char * path,
char ** err_msg )

Write an arbitrary tag rule GSList to a file without touching the active list.

Parameters
listGSList of tag_rule_t* to write (not freed by this function).
pathPath of the file to write.
err_msgSet to a newly allocated error string on failure; caller g_frees.
Returns
true on success, false on failure.

◆ tag_rules_get_list()

WS_DLL_PUBLIC const GSList * tag_rules_get_list ( void )

Return the currently active tag rule list.

Returns
Pointer to the internal GSList; do not modify or free.

◆ tag_rules_init()

WS_DLL_PUBLIC void tag_rules_init ( void )

Initialize the tag rules subsystem (read from file).

Loads from the active profile's tagrules.jsonc file.

< Per-profile tagrules file (JSONC).

◆ tag_rules_prime_edt()

WS_DLL_PUBLIC void tag_rules_prime_edt ( struct epan_dissect * edt)

Prime an epan_dissect_t with all compiled tag rule filters.

Must be called before epan_dissect_run() so the dissector extracts all fields referenced by any tag rule filter.

Parameters
edtThe epan_dissect_t to prime.

◆ tag_rules_read_path()

WS_DLL_PUBLIC GSList * tag_rules_read_path ( const char * path,
char ** err_msg )

Read tag rules from a file into a new GSList without touching the active list.

Parameters
pathFull path to a tagrules.jsonc file.
err_msgSet to error string on failure; caller g_frees. May be NULL.
Returns
Newly allocated GSList of tag_rule_t*, or NULL on error. Caller owns the list.

◆ tag_rules_reload()

WS_DLL_PUBLIC void tag_rules_reload ( void )

Reload the tag rules from disk.

Frees the current list and re-runs tag_rules_init().

◆ tag_rules_used()

WS_DLL_PUBLIC bool tag_rules_used ( void )

Returns true if there is at least one tag rule (enabled or disabled).

◆ tag_rules_write()

WS_DLL_PUBLIC bool tag_rules_write ( void )

Write tag rules to the active profile's tagrules.jsonc file.

Returns
true if the write succeeded, false otherwise.

< Per-profile tagrules file (JSONC).

◆ tag_rules_write_path()

WS_DLL_PUBLIC bool tag_rules_write_path ( GSList * list,
const char * path,
const tag_prefs_t * prefs,
char ** err_msg )

Write a rule list to an arbitrary file path.

Does not modify the active list.

Parameters
listGSList of tag_rule_t* to write.
pathFull path to write.
prefsPrefs to embed in the file (may be NULL for defaults).
err_msgSet to error string on failure; caller g_frees.
Returns
true on success.